From e00d888daefbfbd5f17e0772421773f8e295087b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 2 Oct 2019 15:03:35 +0200 Subject: iOS: Prevent UIKit from adding UITextInteraction to our view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's added automatically when some languages such as Japanese are the active input language/keyboard, which results in UIKit triggering the edit menu for any tap in the UI, regardless of whether it hits the focus object or not. Adopting the protocol is a much larger effort and needs to be coordinated so that we still support text interaction on iOS versions pre 13.0. Even with this patch the UITextSelectionView will still blink its own cursor, which doesn't seem to sync up with the UITextInput protocol's view of where the cursor is. Fixes: QTBUG-78496 Change-Id: I61500ad7ab9c8577f71188c0c99ead39465e3839 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index e64c05d099..4e3657ec37 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,6 +628,18 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) +- (void)addInteraction:(id)interaction +{ + if (__builtin_available(iOS 13.0, *)) { + if ([interaction isKindOfClass:UITextInteraction.class]) + return; // Prevent iOS from adding UITextInteraction + } + + [super addInteraction:interaction]; +} +#endif + @end @implementation UIView (QtHelpers) -- cgit v1.2.3 From 3dd8f6dc34a1357018484158a5e91c3afc71ae77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 27 Sep 2019 16:16:52 +0200 Subject: Schannel: no longer keep old ssl errors around when reusing socket And add a test for it so it can no longer happen in any current or future implementation. Change-Id: I3214aa90595e291b1e1c66befe185cfe1ea7bc6b Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket_schannel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_schannel.cpp b/src/network/ssl/qsslsocket_schannel.cpp index 339ecf4da2..46c109b6e5 100644 --- a/src/network/ssl/qsslsocket_schannel.cpp +++ b/src/network/ssl/qsslsocket_schannel.cpp @@ -974,6 +974,7 @@ bool QSslSocketBackendPrivate::performHandshake() bool QSslSocketBackendPrivate::verifyHandshake() { Q_Q(QSslSocket); + sslErrors.clear(); const bool isClient = mode == QSslSocket::SslClientMode; #define CHECK_STATUS(status) \ @@ -1062,7 +1063,7 @@ bool QSslSocketBackendPrivate::verifyHandshake() } // verifyCertContext returns false if the user disconnected while it was checking errors. - if (certificateContext && sslErrors.isEmpty() && !verifyCertContext(certificateContext)) + if (certificateContext && !verifyCertContext(certificateContext)) return false; if (!checkSslErrors() || state != QAbstractSocket::ConnectedState) { -- cgit v1.2.3 From 45b76fc4eac1acd38a899753b115a89038a0de71 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 7 Oct 2019 13:08:33 +0200 Subject: eglfs/linuxfb: Add an env.var. to disable screen/cursor control By default we disable screen blank and hide the cursor. This is something inherited from Qt 4. Then reset to some default values when exiting. This is not ideal when the system is configured with kernel parameters like consoleblank=0 or vt.global_cursor_default=0. So have a way to skip all tty voodoo. On systems where relevant, one can now launch with QT_QPA_PRESERVE_CONSOLE_STATE=1 set. [ChangeLog][Platform Specific Changes][Linux] Added an environment variable QT_QPA_PRESERVE_CONSOLE_STATE that can be used to prevent Qt from altering the tty screen and cursor settings when running with platforms like linuxfb and eglfs. Task-number: QTBUG-61916 Change-Id: I0e84e53f2d5fca992a7d26d0280ba35e30523379 Reviewed-by: Eirik Aavitsland --- src/platformsupport/fbconvenience/qfbvthandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp index 7bb9e28ac2..8aab0bada4 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler.cpp +++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp @@ -70,6 +70,10 @@ QT_BEGIN_NAMESPACE #ifdef VTH_ENABLED static void setTTYCursor(bool enable) { + static bool ignore = qEnvironmentVariableIntValue("QT_QPA_PRESERVE_CONSOLE_STATE"); + if (ignore) + return; + const char * const devs[] = { "/dev/tty0", "/dev/tty", "/dev/console", 0 }; int fd = -1; for (const char * const *dev = devs; *dev; ++dev) { -- cgit v1.2.3 From b7aaee002677caf411190bbc6ea7f18a28a71360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 7 Oct 2019 16:56:19 +0200 Subject: iOS: Remove assert when doing GL rendering in the background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-76961 Change-Id: If2212601dbb867dd7ceb826b867bb24d302f86df Reviewed-by: Volker Hilsheimer Reviewed-by: Timur Pocheptsov Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioscontext.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 535e7d7aa6..cecbb17039 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -332,11 +332,8 @@ bool QIOSContext::verifyGraphicsHardwareAvailability() ); }); - if (applicationBackgrounded) { - static const char warning[] = "OpenGL ES calls are not allowed while an application is backgrounded"; - Q_ASSERT_X(!applicationBackgrounded, "QIOSContext", warning); - qCWarning(lcQpaGLContext, warning); - } + if (applicationBackgrounded) + qCWarning(lcQpaGLContext, "OpenGL ES calls are not allowed while an application is backgrounded"); return !applicationBackgrounded; } -- cgit v1.2.3 From 4f88e0bbd1c014adc6db7a37e4754446c4c8f529 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 6 Oct 2019 21:14:58 -0700 Subject: Fix build: disable the HWRNG in bootstrapped mode qmake build fails: qrandom.o: in function `QRandomGenerator::SystemGenerator::generate(unsigned int*, unsigned int*)': /home/tjmaciei/src/qt/qt5/qtbase/src/corelib/global/qrandom.cpp:333: undefined reference to `qRandomCpu(void*, long long)' Fixes: QTBUG-78937 Change-Id: Ib5d667bf77a740c28d2efffd15cb4236f765917c Reviewed-by: Edward Welbourne --- src/corelib/tools/qsimd_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index d603631a24..397b0f55a6 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -346,7 +346,7 @@ extern Q_CORE_EXPORT QBasicAtomicInteger qt_cpu_features[2]; #endif Q_CORE_EXPORT quint64 qDetectCpuFeatures(); -#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) +#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !defined(QT_BOOTSTRAPPED) Q_CORE_EXPORT qsizetype qRandomCpu(void *, qsizetype) Q_DECL_NOTHROW; #else static inline qsizetype qRandomCpu(void *, qsizetype) Q_DECL_NOTHROW -- cgit v1.2.3 From a0f145baab0080b335fa0a5be44472a3acda34e0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 9 Oct 2019 17:37:11 +0200 Subject: Fix vertical advance for printing on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Y coordinate needed to be reversed to produce expected results. Fixes: QTBUG-69803 Change-Id: If349912cd078d17ce69d207c2ed35cf781c1a14d Reviewed-by: Michael Brüning --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 072dd1a28a..30c80ebd86 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -471,7 +471,7 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt const qreal firstY = positions[0].y.toReal(); for (int i = 0; i < glyphs.size(); ++i) { cgPositions[i].x = positions[i].x.toReal() - firstX; - cgPositions[i].y = positions[i].y.toReal() - firstY; + cgPositions[i].y = firstY - positions[i].y.toReal(); cgGlyphs[i] = glyphs[i]; } -- cgit v1.2.3 From 6426a38d822344397755e653787891f6a6521d42 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Aug 2019 20:33:11 -0700 Subject: Partially revert "qfloat16: suppress the tables if FP16 is supported by the CPU" This reverts the x86 F16 part of commit 9649c41ed950eaa7dd9d3cb6d37a05d3a9ed8a3e. Unfortunately, it is perfectly valid to compile coe without F16C an link to a QtCore that was compiled with it. That's the case in Clear Linux where there's /usr/lib64/libQt5Core.so.5 and /usr/lib4/haswell/libQt5Core.so.5. Change-Id: I907a43cd9a714da288a2fffd15baacace8331403 Reviewed-by: Jani Heikkinen --- src/tools/qfloat16-tables/gen_qfloat16_tables.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp index 17fc978039..6f0997bc25 100644 --- a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp +++ b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp @@ -79,7 +79,7 @@ qint32 main(qint32 argc, char **argv) fid.write("#include \n\n"); fid.write("QT_BEGIN_NAMESPACE\n\n"); - fid.write("#if !defined(__F16C__) && !defined(__ARM_FP16_FORMAT_IEEE)\n\n"); + fid.write("#if !defined(__ARM_FP16_FORMAT_IEEE)\n\n"); fid.write("const quint32 qfloat16::mantissatable[2048] = {\n"); fid.write("0,\n"); @@ -156,7 +156,7 @@ qint32 main(qint32 argc, char **argv) fid.write("};\n\n"); - fid.write("#endif // !__F16C__ && !__ARM_FP16_FORMAT_IEEE\n\n"); + fid.write("#endif // !__ARM_FP16_FORMAT_IEEE\n\n"); fid.write("QT_END_NAMESPACE\n"); fid.close(); return 0; -- cgit v1.2.3 From c9eff4aa074823cbfbfc5e0240ba53f7e9141367 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 2 Oct 2019 08:46:21 +0200 Subject: iOS: Fix showing emoji characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In d5abda313dab0f83873d34b7c4ddbe8d8a06dacf, we started populating meta-fallback-fonts in the font database because some that are returned as fallbacks are not in the main list of fonts on the system, so we would exclude them, thinking they were non-existent. But populating these fonts by name does not always work, as the system explicitly forbids requesting meta-fonts by name for some cases. One of these was the emoji font, which would resolve to a incompatible font descriptor and support for emojis would be broken. The fix is to retain the font descriptors we get from the system instead, since these are guaranteed to be refer to the correct font. This also saves us an unnecessary round-trip. Task-number: QTBUG-78821 Task-number: QTBUG-77467 Change-Id: Icb17ccc75811eebf03919437828ba71f3ef08938 Reviewed-by: Tor Arne Vestbø --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index e8ea194897..e78fb4e8e4 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -481,7 +481,12 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo for (int i = 0; i < numCascades; ++i) { CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i); QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute); - fallbackList.append(QString::fromCFString(fallbackFamilyName)); + + QString fallbackName = QString::fromCFString(fallbackFamilyName); + fallbackList.append(fallbackName); + + if (!qt_isFontFamilyPopulated(fallbackName)) + const_cast(this)->populateFromDescriptor(fontFallback, fallbackName); } // .Apple Symbols Fallback will be at the beginning of the list and we will @@ -494,15 +499,6 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo addExtraFallbacks(&fallbackList); - // Since iOS 13, the cascade list may contain meta-fonts which have not been - // populated to the database, such as ".AppleJapaneseFont". It is important that we - // include this in the fallback list, in order to get fallback support for all - // languages - for (const QString &fallback : fallbackList) { - if (!qt_isFontFamilyPopulated(fallback)) - const_cast(this)->populateFamily(fallback); - } - extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); fallbackList = qt_sort_families_by_writing_system(script, fallbackList); -- cgit v1.2.3 From 90d94c1c2c3571d48c7b8c2d6ba98ae4a9a28f0b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 7 Oct 2019 08:39:35 +0200 Subject: macOS: Fix regression with some characters in non-bundle apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .Noto Sans Univeral is a system-generated font, but for some undiscovered reason, it has different content when the app has a valid Info.plist versus when it does not. When there is no valid Info.plist, the font will act as a last-resort font and return a question mark glyph (index 4) for all characters it does not support. This was discovered with emojis, but I also verified that the font returns index 4 for a random character in the Cherokee range, in order to check if this was specific for emojis or not. This causes the font to take precedence over anything that follows it in the fallback list in apps that do not have a valid Info.plist, so it has to be at the end of the list. Note that in these apps, it will act as a last-resort font, so the glyphs returned for missing characters will be different from in a regular app bundle. But this seems safer than to exclude the font entirely, given that Noto Sans cover a large range of characters and might be needed. This font also refactors the look up of fonts to push to the end to avoid doing lots of unnecessary looping over the list. Fixes: QTBUG-78833 Change-Id: I38bec5d5941681c4b4586072f7811d31561e1051 Reviewed-by: Tor Arne Vestbø --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index e78fb4e8e4..c450e91d49 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -478,6 +478,9 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (cascadeList) { QStringList fallbackList; const int numCascades = CFArrayGetCount(cascadeList); + + int symbolIndex = -1; + int notoSansUniversalIndex = -1; for (int i = 0; i < numCascades; ++i) { CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i); QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute); @@ -487,15 +490,28 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (!qt_isFontFamilyPopulated(fallbackName)) const_cast(this)->populateFromDescriptor(fontFallback, fallbackName); + + if (fallbackName == QLatin1String(".Apple Symbols Fallback")) + symbolIndex = fallbackList.size() - 1; + else if (fallbackName == QLatin1String(".Noto Sans Universal")) + notoSansUniversalIndex = fallbackList.size() - 1; } // .Apple Symbols Fallback will be at the beginning of the list and we will // detect that this has glyphs for Arabic and other writing systems. // Since it is a symbol font, it should be the last resort, so that // the proper fonts for these writing systems are preferred. - int symbolIndex = fallbackList.indexOf(QLatin1String(".Apple Symbols Fallback")); - if (symbolIndex >= 0) + if (symbolIndex >= 0) { fallbackList.move(symbolIndex, fallbackList.size() - 1); + if (notoSansUniversalIndex > symbolIndex) + --notoSansUniversalIndex; + } + + // .Noto Sans Universal appears to have a bug when the application + // does not have a valid Info.plist, which causes it to return glyph #4 + // (a question mark) for any character. + if (notoSansUniversalIndex >= 0) + fallbackList.move(notoSansUniversalIndex, fallbackList.size() - 1); addExtraFallbacks(&fallbackList); -- cgit v1.2.3 From 631efee29371246ba1a1d9d007b23ca08b867191 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 16 Oct 2019 12:35:11 +0200 Subject: iOS: Account for when the older SDK is used when building MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the pre-built versions of Qt at this point are still built against the iOS 12.x SDKs, then we need to account for this in order to have the workaround implemented in e00d888daefbfbd5f17e0772421773f8e295087b still working when deployed to an iOS 13 based device. Change-Id: I649a453c549ee272de64624d68f9382276fcba64 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.h | 5 +++++ src/plugins/platforms/ios/quiview.mm | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index e1d5d5af0c..343f102971 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -70,3 +70,8 @@ QT_END_NAMESPACE @property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets; @end +#if !QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) +@interface UITextInteraction : NSObject +@end +#endif + diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 4e3657ec37..962b1d929f 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,7 +628,6 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) - (void)addInteraction:(id)interaction { if (__builtin_available(iOS 13.0, *)) { @@ -638,7 +637,6 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") [super addInteraction:interaction]; } -#endif @end -- cgit v1.2.3 From a7a24784eeba6747d319eb911583bdd99ef38cdb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 25 Oct 2019 06:57:32 +0000 Subject: Revert "iOS: Account for when the older SDK is used when building" This reverts commit 631efee29371246ba1a1d9d007b23ca08b867191. Reason for revert: This causes a problem when running on iOS 11 devices. Change-Id: If5194989b8d7a9f4cf2d72e770fdaad754d7e236 Reviewed-by: Jani Heikkinen --- src/plugins/platforms/ios/quiview.h | 5 ----- src/plugins/platforms/ios/quiview.mm | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index 343f102971..e1d5d5af0c 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -70,8 +70,3 @@ QT_END_NAMESPACE @property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets; @end -#if !QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) -@interface UITextInteraction : NSObject -@end -#endif - diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 962b1d929f..4e3657ec37 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,6 +628,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) - (void)addInteraction:(id)interaction { if (__builtin_available(iOS 13.0, *)) { @@ -637,6 +638,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") [super addInteraction:interaction]; } +#endif @end -- cgit v1.2.3 From d86192e5ba7911407881f5079c4486c1fb084dc6 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Sat, 26 Oct 2019 13:57:05 +0200 Subject: QFontDatabase: improve logging output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log the style name, add more descriptions of what's being logged. Before: Adding font "Lucida Grande" 50 QFont::StyleNormal 0 aa true fixed false After: Adding font family "Lucida Grande" stylename "Regular" weight 50 style QFont::StyleNormal pixelSize 0 antialiased true fixed false Change-Id: I138f1b9f41dc41c528c830d81f8018fc16561631 Reviewed-by: Tor Arne Vestbø --- src/gui/text/qfontdatabase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index fe7dd80e44..67783e5b42 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -733,7 +733,8 @@ void qt_registerFont(const QString &familyName, const QString &stylename, const QSupportedWritingSystems &writingSystems, void *handle) { QFontDatabasePrivate *d = privateDb(); - qCDebug(lcFontDb) << "Adding font" << familyName << weight << style << pixelSize << "aa" << antialiased << "fixed" << fixedPitch; + qCDebug(lcFontDb) << "Adding font: familyName" << familyName << "stylename" << stylename << "weight" << weight + << "style" << style << "pixelSize" << pixelSize << "antialiased" << antialiased << "fixed" << fixedPitch; QtFontStyle::Key styleKey; styleKey.style = style; styleKey.weight = weight; -- cgit v1.2.3 From ccd3bf0871b81dfc09bb469b161f32dfb47ee53e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 22 Oct 2019 13:01:38 +0200 Subject: Ensure that child windows are visible again when showing their parent When a window is closed, then it will cause the child windows to be closed as well as a result. Therefore in order to ensure that they are shown again as a result, we need to remove the WA_WState_ExplicitShowHide attribute if the widget was not already hidden before. This enables us to test for this attribute when calling showChildren(), so that if the window has a windowHandle then we can make sure that this widget is shown again. Fixes: QTBUG-73021 Change-Id: I1186242b889899dfcd38d782a67567348e2055ee Reviewed-by: Ulf Hermann --- src/widgets/kernel/qwidget.cpp | 4 +++- src/widgets/kernel/qwidgetwindow.cpp | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 0fa5907744..048a17364b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. @@ -8460,6 +8460,8 @@ void QWidgetPrivate::showChildren(bool spontaneous) QList childList = children; for (int i = 0; i < childList.size(); ++i) { QWidget *widget = qobject_cast(childList.at(i)); + if (widget && widget->windowHandle() && !widget->testAttribute(Qt::WA_WState_ExplicitShowHide)) + widget->setAttribute(Qt::WA_WState_Hidden, false); if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden)) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index aad505ed29..878e484ab8 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -72,10 +72,18 @@ public: void setVisible(bool visible) override { Q_Q(QWidgetWindow); - if (QWidget *widget = q->widget()) + if (QWidget *widget = q->widget()) { + // Check if the widget was already hidden, as this indicates it was done + // explicitly and not because the parent window in this case made it hidden. + // In which case do not automatically show the widget when the parent + // window is shown. + const bool wasHidden = widget->testAttribute(Qt::WA_WState_Hidden); QWidgetPrivate::get(widget)->setVisible(visible); - else + if (!wasHidden) + widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false); + } else { QWindowPrivate::setVisible(visible); + } } QWindow *eventReceiver() override { -- cgit v1.2.3 From be73bdc5d2491d036e5a6334dada453ed808dbc0 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 18 Oct 2019 12:28:13 +0200 Subject: Only call ShowCaret if Windows 10 1709 or later is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This amends cc873ec23a98ac32d10ac5fa569792fde2f6b2c8 which worked around a problem that was showing up on earlier versions of Windows. This extends the workaround up to Windows 10 1703 as the problem was still occurring up to that version. Fixes: QTBUG-79143 Change-Id: Ib7eace17fb8e3817c556e2bcd462e37834b1cbcf Reviewed-by: Friedemann Kleint Reviewed-by: André de la Rocha --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 8054f9fe83..bbfad7d712 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -280,13 +280,15 @@ void QWindowsInputContext::showInputPanel() // with Windows 10 if the Windows IME is (re)enabled _after_ the caret is shown. if (m_caretCreated) { cursorRectChanged(); - // We only call ShowCaret() on Windows 10 as in earlier versions the caret - // would actually be visible (QTBUG-74492) and the workaround for the - // Surface seems unnecessary there anyway. But leave it hidden for IME. - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) + // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions + // the caret would actually be visible (QTBUG-74492) and the workaround for + // the Surface seems unnecessary there anyway. But leave it hidden for IME. + if (QOperatingSystemVersion::current() >= + QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); - else + } else { HideCaret(platformWindow->handle()); + } setWindowsImeEnabled(platformWindow, false); setWindowsImeEnabled(platformWindow, true); } -- cgit v1.2.3 From 58f56950848bae9c90da3873090c7698e0128b12 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 14 Aug 2019 11:13:36 +0200 Subject: Update bundled Freetype to 2.10.1 [ChangeLog][Freetype] Upgraded bundled Freetype version to 2.10.1. Fixes: QTBUG-77466 Change-Id: I1de8b8b03e0ffd0b17eeafff1017df7c638c9279 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/3rdparty/freetype/README | 18 +- src/3rdparty/freetype/builds/unix/ftsystem.c | 4 +- src/3rdparty/freetype/docs/CHANGES | 197 +- src/3rdparty/freetype/docs/CUSTOMIZE | 2 +- src/3rdparty/freetype/docs/DEBUG | 21 +- src/3rdparty/freetype/docs/TODO | 2 +- .../freetype/include/freetype/config/ftconfig.h | 420 +- .../freetype/include/freetype/config/ftheader.h | 352 +- .../freetype/include/freetype/config/ftmodule.h | 12 +- .../freetype/include/freetype/config/ftoption.h | 1369 ++-- .../freetype/include/freetype/config/ftstdlib.h | 160 +- src/3rdparty/freetype/include/freetype/freetype.h | 7016 ++++++++++---------- src/3rdparty/freetype/include/freetype/ftadvanc.h | 239 +- src/3rdparty/freetype/include/freetype/ftbbox.h | 129 +- src/3rdparty/freetype/include/freetype/ftbdf.h | 241 +- src/3rdparty/freetype/include/freetype/ftbitmap.h | 438 +- src/3rdparty/freetype/include/freetype/ftbzip2.h | 140 +- src/3rdparty/freetype/include/freetype/ftcache.h | 1190 ++-- .../freetype/include/freetype/ftchapters.h | 284 +- src/3rdparty/freetype/include/freetype/ftcid.h | 102 +- src/3rdparty/freetype/include/freetype/ftcolor.h | 311 + src/3rdparty/freetype/include/freetype/ftdriver.h | 749 +-- src/3rdparty/freetype/include/freetype/fterrdef.h | 101 +- src/3rdparty/freetype/include/freetype/fterrors.h | 263 +- src/3rdparty/freetype/include/freetype/ftfntfmt.h | 117 +- src/3rdparty/freetype/include/freetype/ftgasp.h | 74 +- src/3rdparty/freetype/include/freetype/ftglyph.h | 999 +-- src/3rdparty/freetype/include/freetype/ftgxval.h | 490 +- src/3rdparty/freetype/include/freetype/ftgzip.h | 226 +- src/3rdparty/freetype/include/freetype/ftimage.h | 1771 ++--- src/3rdparty/freetype/include/freetype/ftincrem.h | 139 +- src/3rdparty/freetype/include/freetype/ftlcdfil.h | 311 +- src/3rdparty/freetype/include/freetype/ftlist.h | 421 +- src/3rdparty/freetype/include/freetype/ftlzw.h | 137 +- src/3rdparty/freetype/include/freetype/ftmac.h | 399 +- src/3rdparty/freetype/include/freetype/ftmm.h | 1103 +-- src/3rdparty/freetype/include/freetype/ftmodapi.h | 946 +-- src/3rdparty/freetype/include/freetype/ftmoderr.h | 191 +- src/3rdparty/freetype/include/freetype/ftotval.h | 303 +- src/3rdparty/freetype/include/freetype/ftoutln.h | 941 +-- src/3rdparty/freetype/include/freetype/ftparams.h | 99 +- src/3rdparty/freetype/include/freetype/ftpfr.h | 258 +- src/3rdparty/freetype/include/freetype/ftrender.h | 214 +- src/3rdparty/freetype/include/freetype/ftsizes.h | 239 +- src/3rdparty/freetype/include/freetype/ftsnames.h | 394 +- src/3rdparty/freetype/include/freetype/ftstroke.h | 431 +- src/3rdparty/freetype/include/freetype/ftsynth.h | 38 +- src/3rdparty/freetype/include/freetype/ftsystem.h | 134 +- src/3rdparty/freetype/include/freetype/fttrigon.h | 84 +- src/3rdparty/freetype/include/freetype/fttypes.h | 851 +-- src/3rdparty/freetype/include/freetype/ftwinfnt.h | 162 +- .../freetype/include/freetype/internal/autohint.h | 326 +- .../freetype/include/freetype/internal/cffotypes.h | 88 +- .../freetype/include/freetype/internal/cfftypes.h | 95 +- .../freetype/include/freetype/internal/ftcalc.h | 246 +- .../freetype/include/freetype/internal/ftdebug.h | 248 +- .../freetype/include/freetype/internal/ftdrv.h | 336 +- .../freetype/include/freetype/internal/ftgloadr.h | 55 +- .../freetype/include/freetype/internal/fthash.h | 28 +- .../freetype/include/freetype/internal/ftmemory.h | 77 +- .../freetype/include/freetype/internal/ftobjs.h | 1273 ++-- .../freetype/include/freetype/internal/ftpsprop.h | 32 +- .../freetype/include/freetype/internal/ftrfork.h | 305 +- .../freetype/include/freetype/internal/ftserv.h | 669 +- .../freetype/include/freetype/internal/ftstream.h | 106 +- .../freetype/include/freetype/internal/fttrace.h | 84 +- .../freetype/include/freetype/internal/ftvalid.h | 82 +- .../freetype/include/freetype/internal/internal.h | 46 +- .../freetype/include/freetype/internal/psaux.h | 601 +- .../freetype/include/freetype/internal/pshints.h | 170 +- .../include/freetype/internal/services/svbdf.h | 48 +- .../include/freetype/internal/services/svcfftl.h | 54 +- .../include/freetype/internal/services/svcid.h | 53 +- .../include/freetype/internal/services/svfntfmt.h | 38 +- .../include/freetype/internal/services/svgldict.h | 59 +- .../include/freetype/internal/services/svgxval.h | 50 +- .../include/freetype/internal/services/svkern.h | 32 +- .../include/freetype/internal/services/svmetric.h | 62 +- .../include/freetype/internal/services/svmm.h | 150 +- .../include/freetype/internal/services/svotval.h | 32 +- .../include/freetype/internal/services/svpfr.h | 32 +- .../include/freetype/internal/services/svpostnm.h | 58 +- .../include/freetype/internal/services/svprop.h | 48 +- .../include/freetype/internal/services/svpscmap.h | 80 +- .../include/freetype/internal/services/svpsinfo.h | 57 +- .../include/freetype/internal/services/svsfnt.h | 49 +- .../include/freetype/internal/services/svttcmap.h | 94 +- .../include/freetype/internal/services/svtteng.h | 34 +- .../include/freetype/internal/services/svttglyf.h | 45 +- .../include/freetype/internal/services/svwinfnt.h | 32 +- .../freetype/include/freetype/internal/sfnt.h | 1094 +-- .../freetype/include/freetype/internal/t1types.h | 85 +- .../freetype/include/freetype/internal/tttypes.h | 2010 +++--- .../freetype/include/freetype/internal/wofftypes.h | 112 + src/3rdparty/freetype/include/freetype/t1tables.h | 616 +- src/3rdparty/freetype/include/freetype/ttnameid.h | 138 +- src/3rdparty/freetype/include/freetype/tttables.h | 976 +-- src/3rdparty/freetype/include/freetype/tttags.h | 34 +- src/3rdparty/freetype/include/ft2build.h | 64 +- src/3rdparty/freetype/qt_attribution.json | 2 +- src/3rdparty/freetype/src/Jamfile | 2 +- src/3rdparty/freetype/src/autofit/Jamfile | 2 +- src/3rdparty/freetype/src/autofit/afangles.c | 52 +- src/3rdparty/freetype/src/autofit/afangles.h | 6 +- src/3rdparty/freetype/src/autofit/afblue.c | 39 +- src/3rdparty/freetype/src/autofit/afblue.cin | 32 +- src/3rdparty/freetype/src/autofit/afblue.dat | 28 +- src/3rdparty/freetype/src/autofit/afblue.h | 171 +- src/3rdparty/freetype/src/autofit/afblue.hin | 32 +- src/3rdparty/freetype/src/autofit/afcjk.c | 195 +- src/3rdparty/freetype/src/autofit/afcjk.h | 38 +- src/3rdparty/freetype/src/autofit/afcover.h | 32 +- src/3rdparty/freetype/src/autofit/afdummy.c | 42 +- src/3rdparty/freetype/src/autofit/afdummy.h | 34 +- src/3rdparty/freetype/src/autofit/aferrors.h | 48 +- src/3rdparty/freetype/src/autofit/afglobal.c | 98 +- src/3rdparty/freetype/src/autofit/afglobal.h | 46 +- src/3rdparty/freetype/src/autofit/afhints.c | 181 +- src/3rdparty/freetype/src/autofit/afhints.h | 238 +- src/3rdparty/freetype/src/autofit/afindic.c | 32 +- src/3rdparty/freetype/src/autofit/afindic.h | 34 +- src/3rdparty/freetype/src/autofit/aflatin.c | 304 +- src/3rdparty/freetype/src/autofit/aflatin.h | 44 +- src/3rdparty/freetype/src/autofit/aflatin2.c | 147 +- src/3rdparty/freetype/src/autofit/aflatin2.h | 34 +- src/3rdparty/freetype/src/autofit/afloader.c | 175 +- src/3rdparty/freetype/src/autofit/afloader.h | 42 +- src/3rdparty/freetype/src/autofit/afmodule.c | 88 +- src/3rdparty/freetype/src/autofit/afmodule.h | 36 +- src/3rdparty/freetype/src/autofit/afranges.c | 47 +- src/3rdparty/freetype/src/autofit/afranges.h | 32 +- src/3rdparty/freetype/src/autofit/afscript.h | 38 +- src/3rdparty/freetype/src/autofit/afshaper.c | 61 +- src/3rdparty/freetype/src/autofit/afshaper.h | 32 +- src/3rdparty/freetype/src/autofit/afstyles.h | 39 +- src/3rdparty/freetype/src/autofit/aftypes.h | 252 +- src/3rdparty/freetype/src/autofit/afwarp.c | 54 +- src/3rdparty/freetype/src/autofit/afwarp.h | 36 +- src/3rdparty/freetype/src/autofit/afwrtsys.h | 32 +- src/3rdparty/freetype/src/autofit/autofit.c | 33 +- src/3rdparty/freetype/src/autofit/module.mk | 2 +- src/3rdparty/freetype/src/autofit/rules.mk | 3 +- src/3rdparty/freetype/src/base/Jamfile | 7 +- src/3rdparty/freetype/src/base/ftadvanc.c | 32 +- src/3rdparty/freetype/src/base/ftbase.c | 36 +- src/3rdparty/freetype/src/base/ftbase.h | 32 +- src/3rdparty/freetype/src/base/ftbbox.c | 368 +- src/3rdparty/freetype/src/base/ftbdf.c | 32 +- src/3rdparty/freetype/src/base/ftbitmap.c | 376 +- src/3rdparty/freetype/src/base/ftcalc.c | 194 +- src/3rdparty/freetype/src/base/ftcid.c | 32 +- src/3rdparty/freetype/src/base/ftcolor.c | 157 + src/3rdparty/freetype/src/base/ftdbgmem.c | 60 +- src/3rdparty/freetype/src/base/ftdebug.c | 179 +- src/3rdparty/freetype/src/base/fterrors.c | 46 + src/3rdparty/freetype/src/base/ftfntfmt.c | 32 +- src/3rdparty/freetype/src/base/ftfstype.c | 32 +- src/3rdparty/freetype/src/base/ftgasp.c | 32 +- src/3rdparty/freetype/src/base/ftgloadr.c | 134 +- src/3rdparty/freetype/src/base/ftglyph.c | 141 +- src/3rdparty/freetype/src/base/ftgxval.c | 50 +- src/3rdparty/freetype/src/base/fthash.c | 28 +- src/3rdparty/freetype/src/base/ftinit.c | 217 +- src/3rdparty/freetype/src/base/ftlcdfil.c | 127 +- src/3rdparty/freetype/src/base/ftmac.c | 106 +- src/3rdparty/freetype/src/base/ftmm.c | 107 +- src/3rdparty/freetype/src/base/ftobjs.c | 589 +- src/3rdparty/freetype/src/base/ftotval.c | 32 +- src/3rdparty/freetype/src/base/ftoutln.c | 148 +- src/3rdparty/freetype/src/base/ftpatent.c | 34 +- src/3rdparty/freetype/src/base/ftpfr.c | 32 +- src/3rdparty/freetype/src/base/ftpsprop.c | 48 +- src/3rdparty/freetype/src/base/ftrfork.c | 72 +- src/3rdparty/freetype/src/base/ftsnames.c | 78 +- src/3rdparty/freetype/src/base/ftstream.c | 58 +- src/3rdparty/freetype/src/base/ftstroke.c | 120 +- src/3rdparty/freetype/src/base/ftsynth.c | 46 +- src/3rdparty/freetype/src/base/ftsystem.c | 281 +- src/3rdparty/freetype/src/base/fttrigon.c | 76 +- src/3rdparty/freetype/src/base/fttype1.c | 32 +- src/3rdparty/freetype/src/base/ftutil.c | 54 +- src/3rdparty/freetype/src/base/ftver.rc | 10 +- src/3rdparty/freetype/src/base/ftwinfnt.c | 32 +- src/3rdparty/freetype/src/base/rules.mk | 11 +- src/3rdparty/freetype/src/bdf/Jamfile | 2 +- src/3rdparty/freetype/src/bdf/bdf.h | 82 +- src/3rdparty/freetype/src/bdf/bdfdrivr.c | 69 +- src/3rdparty/freetype/src/bdf/bdfdrivr.h | 9 +- src/3rdparty/freetype/src/bdf/bdferror.h | 10 +- src/3rdparty/freetype/src/bdf/bdflib.c | 411 +- src/3rdparty/freetype/src/bzip2/Jamfile | 2 +- src/3rdparty/freetype/src/bzip2/ftbzip2.c | 52 +- src/3rdparty/freetype/src/bzip2/rules.mk | 2 +- src/3rdparty/freetype/src/cache/Jamfile | 2 +- src/3rdparty/freetype/src/cache/ftcache.c | 32 +- src/3rdparty/freetype/src/cache/ftcbasic.c | 36 +- src/3rdparty/freetype/src/cache/ftccache.c | 34 +- src/3rdparty/freetype/src/cache/ftccache.h | 64 +- src/3rdparty/freetype/src/cache/ftccback.h | 32 +- src/3rdparty/freetype/src/cache/ftccmap.c | 62 +- src/3rdparty/freetype/src/cache/ftcerror.h | 48 +- src/3rdparty/freetype/src/cache/ftcglyph.c | 32 +- src/3rdparty/freetype/src/cache/ftcglyph.h | 166 +- src/3rdparty/freetype/src/cache/ftcimage.c | 32 +- src/3rdparty/freetype/src/cache/ftcimage.h | 50 +- src/3rdparty/freetype/src/cache/ftcmanag.c | 38 +- src/3rdparty/freetype/src/cache/ftcmanag.h | 143 +- src/3rdparty/freetype/src/cache/ftcmru.c | 32 +- src/3rdparty/freetype/src/cache/ftcmru.h | 80 +- src/3rdparty/freetype/src/cache/ftcsbits.c | 92 +- src/3rdparty/freetype/src/cache/ftcsbits.h | 32 +- src/3rdparty/freetype/src/cache/rules.mk | 4 +- src/3rdparty/freetype/src/cff/Jamfile | 2 +- src/3rdparty/freetype/src/cff/cff.c | 33 +- src/3rdparty/freetype/src/cff/cffcmap.c | 35 +- src/3rdparty/freetype/src/cff/cffcmap.h | 32 +- src/3rdparty/freetype/src/cff/cffdrivr.c | 326 +- src/3rdparty/freetype/src/cff/cffdrivr.h | 34 +- src/3rdparty/freetype/src/cff/cfferrs.h | 46 +- src/3rdparty/freetype/src/cff/cffgload.c | 64 +- src/3rdparty/freetype/src/cff/cffgload.h | 32 +- src/3rdparty/freetype/src/cff/cffload.c | 61 +- src/3rdparty/freetype/src/cff/cffload.h | 32 +- src/3rdparty/freetype/src/cff/cffobjs.c | 118 +- src/3rdparty/freetype/src/cff/cffobjs.h | 48 +- src/3rdparty/freetype/src/cff/cffparse.c | 444 +- src/3rdparty/freetype/src/cff/cffparse.h | 55 +- src/3rdparty/freetype/src/cff/cfftoken.h | 32 +- src/3rdparty/freetype/src/cff/module.mk | 2 +- src/3rdparty/freetype/src/cff/rules.mk | 5 +- src/3rdparty/freetype/src/cid/Jamfile | 2 +- src/3rdparty/freetype/src/cid/ciderrs.h | 46 +- src/3rdparty/freetype/src/cid/cidgload.c | 49 +- src/3rdparty/freetype/src/cid/cidgload.h | 32 +- src/3rdparty/freetype/src/cid/cidload.c | 185 +- src/3rdparty/freetype/src/cid/cidload.h | 32 +- src/3rdparty/freetype/src/cid/cidobjs.c | 204 +- src/3rdparty/freetype/src/cid/cidobjs.h | 116 +- src/3rdparty/freetype/src/cid/cidparse.c | 46 +- src/3rdparty/freetype/src/cid/cidparse.h | 108 +- src/3rdparty/freetype/src/cid/cidriver.c | 56 +- src/3rdparty/freetype/src/cid/cidriver.h | 38 +- src/3rdparty/freetype/src/cid/cidtoken.h | 57 +- src/3rdparty/freetype/src/cid/module.mk | 2 +- src/3rdparty/freetype/src/cid/rules.mk | 2 +- src/3rdparty/freetype/src/cid/type1cid.c | 32 +- src/3rdparty/freetype/src/gxvalid/Jamfile | 2 +- src/3rdparty/freetype/src/gxvalid/README | 2 +- src/3rdparty/freetype/src/gxvalid/gxvalid.c | 34 +- src/3rdparty/freetype/src/gxvalid/gxvalid.h | 50 +- src/3rdparty/freetype/src/gxvalid/gxvbsln.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvcommn.c | 68 +- src/3rdparty/freetype/src/gxvalid/gxvcommn.h | 60 +- src/3rdparty/freetype/src/gxvalid/gxverror.h | 66 +- src/3rdparty/freetype/src/gxvalid/gxvfeat.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvfeat.h | 50 +- src/3rdparty/freetype/src/gxvalid/gxvfgen.c | 114 +- src/3rdparty/freetype/src/gxvalid/gxvjust.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvkern.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvlcar.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvmod.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvmod.h | 56 +- src/3rdparty/freetype/src/gxvalid/gxvmort.c | 65 +- src/3rdparty/freetype/src/gxvalid/gxvmort.h | 50 +- src/3rdparty/freetype/src/gxvalid/gxvmort0.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmort1.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmort2.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmort4.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmort5.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmorx.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvmorx.h | 50 +- src/3rdparty/freetype/src/gxvalid/gxvmorx0.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmorx1.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmorx2.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmorx4.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvmorx5.c | 66 +- src/3rdparty/freetype/src/gxvalid/gxvopbd.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvprop.c | 64 +- src/3rdparty/freetype/src/gxvalid/gxvtrak.c | 64 +- src/3rdparty/freetype/src/gxvalid/module.mk | 2 +- src/3rdparty/freetype/src/gxvalid/rules.mk | 2 +- src/3rdparty/freetype/src/gzip/Jamfile | 2 +- src/3rdparty/freetype/src/gzip/ftgzip.c | 64 +- src/3rdparty/freetype/src/gzip/infblock.c | 5 + src/3rdparty/freetype/src/gzip/infcodes.c | 4 + src/3rdparty/freetype/src/gzip/inflate.c | 10 + src/3rdparty/freetype/src/gzip/rules.mk | 2 +- src/3rdparty/freetype/src/lzw/Jamfile | 2 +- src/3rdparty/freetype/src/lzw/ftlzw.c | 56 +- src/3rdparty/freetype/src/lzw/ftzopen.c | 48 +- src/3rdparty/freetype/src/lzw/ftzopen.h | 116 +- src/3rdparty/freetype/src/lzw/rules.mk | 2 +- src/3rdparty/freetype/src/otvalid/Jamfile | 2 +- src/3rdparty/freetype/src/otvalid/module.mk | 2 +- src/3rdparty/freetype/src/otvalid/otvalid.c | 32 +- src/3rdparty/freetype/src/otvalid/otvalid.h | 32 +- src/3rdparty/freetype/src/otvalid/otvbase.c | 46 +- src/3rdparty/freetype/src/otvalid/otvcommn.c | 46 +- src/3rdparty/freetype/src/otvalid/otvcommn.h | 32 +- src/3rdparty/freetype/src/otvalid/otverror.h | 48 +- src/3rdparty/freetype/src/otvalid/otvgdef.c | 46 +- src/3rdparty/freetype/src/otvalid/otvgpos.c | 46 +- src/3rdparty/freetype/src/otvalid/otvgpos.h | 32 +- src/3rdparty/freetype/src/otvalid/otvgsub.c | 46 +- src/3rdparty/freetype/src/otvalid/otvjstf.c | 46 +- src/3rdparty/freetype/src/otvalid/otvmath.c | 50 +- src/3rdparty/freetype/src/otvalid/otvmod.c | 46 +- src/3rdparty/freetype/src/otvalid/otvmod.h | 38 +- src/3rdparty/freetype/src/otvalid/rules.mk | 2 +- src/3rdparty/freetype/src/pcf/Jamfile | 2 +- src/3rdparty/freetype/src/pcf/pcf.h | 59 +- src/3rdparty/freetype/src/pcf/pcfdrivr.c | 163 +- src/3rdparty/freetype/src/pcf/pcfdrivr.h | 5 +- src/3rdparty/freetype/src/pcf/pcferror.h | 46 +- src/3rdparty/freetype/src/pcf/pcfread.c | 407 +- src/3rdparty/freetype/src/pcf/pcfutil.c | 6 +- src/3rdparty/freetype/src/pfr/Jamfile | 2 +- src/3rdparty/freetype/src/pfr/module.mk | 2 +- src/3rdparty/freetype/src/pfr/pfr.c | 32 +- src/3rdparty/freetype/src/pfr/pfrcmap.c | 32 +- src/3rdparty/freetype/src/pfr/pfrcmap.h | 32 +- src/3rdparty/freetype/src/pfr/pfrdrivr.c | 48 +- src/3rdparty/freetype/src/pfr/pfrdrivr.h | 38 +- src/3rdparty/freetype/src/pfr/pfrerror.h | 46 +- src/3rdparty/freetype/src/pfr/pfrgload.c | 52 +- src/3rdparty/freetype/src/pfr/pfrgload.h | 32 +- src/3rdparty/freetype/src/pfr/pfrload.c | 162 +- src/3rdparty/freetype/src/pfr/pfrload.h | 32 +- src/3rdparty/freetype/src/pfr/pfrobjs.c | 40 +- src/3rdparty/freetype/src/pfr/pfrobjs.h | 32 +- src/3rdparty/freetype/src/pfr/pfrsbit.c | 34 +- src/3rdparty/freetype/src/pfr/pfrsbit.h | 32 +- src/3rdparty/freetype/src/pfr/pfrtypes.h | 32 +- src/3rdparty/freetype/src/pfr/rules.mk | 2 +- src/3rdparty/freetype/src/psaux/Jamfile | 2 +- src/3rdparty/freetype/src/psaux/afmparse.c | 59 +- src/3rdparty/freetype/src/psaux/afmparse.h | 32 +- src/3rdparty/freetype/src/psaux/cffdecode.c | 300 +- src/3rdparty/freetype/src/psaux/cffdecode.h | 32 +- src/3rdparty/freetype/src/psaux/module.mk | 2 +- src/3rdparty/freetype/src/psaux/psarrst.c | 72 +- src/3rdparty/freetype/src/psaux/psarrst.h | 72 +- src/3rdparty/freetype/src/psaux/psaux.c | 32 +- src/3rdparty/freetype/src/psaux/psauxerr.h | 48 +- src/3rdparty/freetype/src/psaux/psauxmod.c | 32 +- src/3rdparty/freetype/src/psaux/psauxmod.h | 36 +- src/3rdparty/freetype/src/psaux/psblues.c | 100 +- src/3rdparty/freetype/src/psaux/psblues.h | 72 +- src/3rdparty/freetype/src/psaux/psconv.c | 46 +- src/3rdparty/freetype/src/psaux/psconv.h | 32 +- src/3rdparty/freetype/src/psaux/pserror.c | 72 +- src/3rdparty/freetype/src/psaux/pserror.h | 72 +- src/3rdparty/freetype/src/psaux/psfixed.h | 75 +- src/3rdparty/freetype/src/psaux/psfont.c | 82 +- src/3rdparty/freetype/src/psaux/psfont.h | 72 +- src/3rdparty/freetype/src/psaux/psft.c | 95 +- src/3rdparty/freetype/src/psaux/psft.h | 72 +- src/3rdparty/freetype/src/psaux/psglue.h | 72 +- src/3rdparty/freetype/src/psaux/pshints.c | 117 +- src/3rdparty/freetype/src/psaux/pshints.h | 72 +- src/3rdparty/freetype/src/psaux/psintrp.c | 148 +- src/3rdparty/freetype/src/psaux/psintrp.h | 72 +- src/3rdparty/freetype/src/psaux/psobjs.c | 486 +- src/3rdparty/freetype/src/psaux/psobjs.h | 40 +- src/3rdparty/freetype/src/psaux/psread.c | 74 +- src/3rdparty/freetype/src/psaux/psread.h | 72 +- src/3rdparty/freetype/src/psaux/psstack.c | 75 +- src/3rdparty/freetype/src/psaux/psstack.h | 72 +- src/3rdparty/freetype/src/psaux/pstypes.h | 72 +- src/3rdparty/freetype/src/psaux/rules.mk | 2 +- src/3rdparty/freetype/src/psaux/t1cmap.c | 35 +- src/3rdparty/freetype/src/psaux/t1cmap.h | 32 +- src/3rdparty/freetype/src/psaux/t1decode.c | 341 +- src/3rdparty/freetype/src/psaux/t1decode.h | 32 +- src/3rdparty/freetype/src/pshinter/Jamfile | 2 +- src/3rdparty/freetype/src/pshinter/module.mk | 2 +- src/3rdparty/freetype/src/pshinter/pshalgo.c | 50 +- src/3rdparty/freetype/src/pshinter/pshalgo.h | 32 +- src/3rdparty/freetype/src/pshinter/pshglob.c | 39 +- src/3rdparty/freetype/src/pshinter/pshglob.h | 68 +- src/3rdparty/freetype/src/pshinter/pshinter.c | 33 +- src/3rdparty/freetype/src/pshinter/pshmod.c | 35 +- src/3rdparty/freetype/src/pshinter/pshmod.h | 32 +- src/3rdparty/freetype/src/pshinter/pshnterr.h | 46 +- src/3rdparty/freetype/src/pshinter/pshrec.c | 38 +- src/3rdparty/freetype/src/pshinter/pshrec.h | 56 +- src/3rdparty/freetype/src/pshinter/rules.mk | 3 +- src/3rdparty/freetype/src/psnames/Jamfile | 2 +- src/3rdparty/freetype/src/psnames/module.mk | 2 +- src/3rdparty/freetype/src/psnames/psmodule.c | 73 +- src/3rdparty/freetype/src/psnames/psmodule.h | 32 +- src/3rdparty/freetype/src/psnames/psnamerr.h | 48 +- src/3rdparty/freetype/src/psnames/psnames.c | 33 +- src/3rdparty/freetype/src/psnames/pstables.h | 44 +- src/3rdparty/freetype/src/psnames/rules.mk | 21 +- src/3rdparty/freetype/src/raster/Jamfile | 2 +- src/3rdparty/freetype/src/raster/ftmisc.h | 50 +- src/3rdparty/freetype/src/raster/ftraster.c | 1285 ++-- src/3rdparty/freetype/src/raster/ftraster.h | 42 +- src/3rdparty/freetype/src/raster/ftrend1.c | 41 +- src/3rdparty/freetype/src/raster/ftrend1.h | 32 +- src/3rdparty/freetype/src/raster/module.mk | 2 +- src/3rdparty/freetype/src/raster/raster.c | 33 +- src/3rdparty/freetype/src/raster/rasterrs.h | 48 +- src/3rdparty/freetype/src/raster/rules.mk | 5 +- src/3rdparty/freetype/src/sfnt/Jamfile | 4 +- src/3rdparty/freetype/src/sfnt/module.mk | 2 +- src/3rdparty/freetype/src/sfnt/pngshim.c | 35 +- src/3rdparty/freetype/src/sfnt/pngshim.h | 34 +- src/3rdparty/freetype/src/sfnt/rules.mk | 22 +- src/3rdparty/freetype/src/sfnt/sfdriver.c | 259 +- src/3rdparty/freetype/src/sfnt/sfdriver.h | 34 +- src/3rdparty/freetype/src/sfnt/sferrors.h | 46 +- src/3rdparty/freetype/src/sfnt/sfnt.c | 37 +- src/3rdparty/freetype/src/sfnt/sfobjs.c | 654 +- src/3rdparty/freetype/src/sfnt/sfobjs.h | 34 +- src/3rdparty/freetype/src/sfnt/sfwoff.c | 434 ++ src/3rdparty/freetype/src/sfnt/sfwoff.h | 41 + src/3rdparty/freetype/src/sfnt/ttbdf.c | 54 +- src/3rdparty/freetype/src/sfnt/ttbdf.h | 32 +- src/3rdparty/freetype/src/sfnt/ttcmap.c | 656 +- src/3rdparty/freetype/src/sfnt/ttcmap.h | 70 +- src/3rdparty/freetype/src/sfnt/ttcmapc.h | 32 +- src/3rdparty/freetype/src/sfnt/ttcolr.c | 451 ++ src/3rdparty/freetype/src/sfnt/ttcolr.h | 58 + src/3rdparty/freetype/src/sfnt/ttcpal.c | 311 + src/3rdparty/freetype/src/sfnt/ttcpal.h | 49 + src/3rdparty/freetype/src/sfnt/ttkern.c | 56 +- src/3rdparty/freetype/src/sfnt/ttkern.h | 34 +- src/3rdparty/freetype/src/sfnt/ttload.c | 569 +- src/3rdparty/freetype/src/sfnt/ttload.h | 34 +- src/3rdparty/freetype/src/sfnt/ttmtx.c | 187 +- src/3rdparty/freetype/src/sfnt/ttmtx.h | 32 +- src/3rdparty/freetype/src/sfnt/ttpost.c | 117 +- src/3rdparty/freetype/src/sfnt/ttpost.h | 34 +- src/3rdparty/freetype/src/sfnt/ttsbit.c | 64 +- src/3rdparty/freetype/src/sfnt/ttsbit.h | 32 +- src/3rdparty/freetype/src/smooth/Jamfile | 2 +- src/3rdparty/freetype/src/smooth/ftgrays.c | 724 +- src/3rdparty/freetype/src/smooth/ftgrays.h | 49 +- src/3rdparty/freetype/src/smooth/ftsmerrs.h | 48 +- src/3rdparty/freetype/src/smooth/ftsmooth.c | 127 +- src/3rdparty/freetype/src/smooth/ftsmooth.h | 32 +- src/3rdparty/freetype/src/smooth/module.mk | 2 +- src/3rdparty/freetype/src/smooth/rules.mk | 5 +- src/3rdparty/freetype/src/smooth/smooth.c | 33 +- src/3rdparty/freetype/src/tools/afblue.pl | 2 +- src/3rdparty/freetype/src/tools/apinames.c | 441 +- src/3rdparty/freetype/src/tools/glnames.py | 50 +- .../freetype/src/tools/update-copyright-year | 19 +- src/3rdparty/freetype/src/truetype/Jamfile | 2 +- src/3rdparty/freetype/src/truetype/module.mk | 2 +- src/3rdparty/freetype/src/truetype/rules.mk | 3 +- src/3rdparty/freetype/src/truetype/truetype.c | 33 +- src/3rdparty/freetype/src/truetype/ttdriver.c | 224 +- src/3rdparty/freetype/src/truetype/ttdriver.h | 34 +- src/3rdparty/freetype/src/truetype/tterrors.h | 48 +- src/3rdparty/freetype/src/truetype/ttgload.c | 555 +- src/3rdparty/freetype/src/truetype/ttgload.h | 32 +- src/3rdparty/freetype/src/truetype/ttgxvar.c | 1436 ++-- src/3rdparty/freetype/src/truetype/ttgxvar.h | 313 +- src/3rdparty/freetype/src/truetype/ttinterp.c | 3609 +++++----- src/3rdparty/freetype/src/truetype/ttinterp.h | 168 +- src/3rdparty/freetype/src/truetype/ttobjs.c | 493 +- src/3rdparty/freetype/src/truetype/ttobjs.h | 312 +- src/3rdparty/freetype/src/truetype/ttpload.c | 244 +- src/3rdparty/freetype/src/truetype/ttpload.h | 32 +- src/3rdparty/freetype/src/truetype/ttsubpix.c | 90 +- src/3rdparty/freetype/src/truetype/ttsubpix.h | 52 +- src/3rdparty/freetype/src/type1/Jamfile | 2 +- src/3rdparty/freetype/src/type1/module.mk | 2 +- src/3rdparty/freetype/src/type1/rules.mk | 2 +- src/3rdparty/freetype/src/type1/t1afm.c | 46 +- src/3rdparty/freetype/src/type1/t1afm.h | 32 +- src/3rdparty/freetype/src/type1/t1driver.c | 217 +- src/3rdparty/freetype/src/type1/t1driver.h | 38 +- src/3rdparty/freetype/src/type1/t1errors.h | 46 +- src/3rdparty/freetype/src/type1/t1gload.c | 77 +- src/3rdparty/freetype/src/type1/t1gload.h | 32 +- src/3rdparty/freetype/src/type1/t1load.c | 451 +- src/3rdparty/freetype/src/type1/t1load.h | 42 +- src/3rdparty/freetype/src/type1/t1objs.c | 213 +- src/3rdparty/freetype/src/type1/t1objs.h | 132 +- src/3rdparty/freetype/src/type1/t1parse.c | 110 +- src/3rdparty/freetype/src/type1/t1parse.h | 101 +- src/3rdparty/freetype/src/type1/t1tokens.h | 32 +- src/3rdparty/freetype/src/type1/type1.c | 32 +- src/3rdparty/freetype/src/type42/Jamfile | 2 +- src/3rdparty/freetype/src/type42/module.mk | 2 +- src/3rdparty/freetype/src/type42/rules.mk | 2 +- src/3rdparty/freetype/src/type42/t42drivr.c | 86 +- src/3rdparty/freetype/src/type42/t42drivr.h | 38 +- src/3rdparty/freetype/src/type42/t42error.h | 46 +- src/3rdparty/freetype/src/type42/t42objs.c | 87 +- src/3rdparty/freetype/src/type42/t42objs.h | 32 +- src/3rdparty/freetype/src/type42/t42parse.c | 100 +- src/3rdparty/freetype/src/type42/t42parse.h | 32 +- src/3rdparty/freetype/src/type42/t42types.h | 32 +- src/3rdparty/freetype/src/type42/type42.c | 32 +- src/3rdparty/freetype/src/winfonts/Jamfile | 2 +- src/3rdparty/freetype/src/winfonts/fnterrs.h | 48 +- src/3rdparty/freetype/src/winfonts/module.mk | 2 +- src/3rdparty/freetype/src/winfonts/rules.mk | 2 +- src/3rdparty/freetype/src/winfonts/winfnt.c | 58 +- src/3rdparty/freetype/src/winfonts/winfnt.h | 40 +- 505 files changed, 38415 insertions(+), 34977 deletions(-) create mode 100644 src/3rdparty/freetype/include/freetype/ftcolor.h create mode 100644 src/3rdparty/freetype/include/freetype/internal/wofftypes.h create mode 100644 src/3rdparty/freetype/src/base/ftcolor.c create mode 100644 src/3rdparty/freetype/src/base/fterrors.c create mode 100644 src/3rdparty/freetype/src/sfnt/sfwoff.c create mode 100644 src/3rdparty/freetype/src/sfnt/sfwoff.h create mode 100644 src/3rdparty/freetype/src/sfnt/ttcolr.c create mode 100644 src/3rdparty/freetype/src/sfnt/ttcolr.h create mode 100644 src/3rdparty/freetype/src/sfnt/ttcpal.c create mode 100644 src/3rdparty/freetype/src/sfnt/ttcpal.h (limited to 'src') diff --git a/src/3rdparty/freetype/README b/src/3rdparty/freetype/README index c23b99e18a..8f3e2bc03b 100644 --- a/src/3rdparty/freetype/README +++ b/src/3rdparty/freetype/README @@ -1,5 +1,5 @@ - FreeType 2.9.1 - ============== + FreeType 2.10.1 + =============== Homepage: https://www.freetype.org @@ -15,8 +15,8 @@ Read the files `docs/INSTALL*' for installation instructions; see the file `docs/LICENSE.TXT' for the available licenses. - The FreeType 2 API reference is located in `docs/reference'; use the - file `ft2-toc.html' as the top entry point. Additional + The FreeType 2 API reference is located in `docs/reference/site'; + use the file `index.html' as the top entry point. Additional documentation is available as a separate package from our sites. Go to @@ -24,13 +24,13 @@ and download one of the following files. - freetype-doc-2.9.1.tar.bz2 - freetype-doc-2.9.1.tar.gz - ftdoc291.zip + freetype-doc-2.10.1.tar.xz + freetype-doc-2.10.1.tar.gz + ftdoc2101.zip To view the documentation online, go to - https://www.freetype.org/freetype2/documentation.html + https://www.freetype.org/freetype2/docs/ Mailing Lists @@ -71,7 +71,7 @@ ---------------------------------------------------------------------- -Copyright 2006-2018 by +Copyright (C) 2006-2019 by David Turner, Robert Wilhelm, and Werner Lemberg. This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/builds/unix/ftsystem.c b/src/3rdparty/freetype/builds/unix/ftsystem.c index 8fdbeb0f62..826713f948 100644 --- a/src/3rdparty/freetype/builds/unix/ftsystem.c +++ b/src/3rdparty/freetype/builds/unix/ftsystem.c @@ -4,7 +4,7 @@ /* */ /* Unix-specific FreeType low-level system interface (body). */ /* */ -/* Copyright 1996-2018 by */ +/* Copyright (C) 1996-2019 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -173,7 +173,7 @@ /* messages during execution. */ /* */ #undef FT_COMPONENT -#define FT_COMPONENT trace_io +#define FT_COMPONENT io /* We use the macro STREAM_FILE for convenience to extract the */ /* system-specific stream handle from a given FreeType stream object */ diff --git a/src/3rdparty/freetype/docs/CHANGES b/src/3rdparty/freetype/docs/CHANGES index a6d088af49..f36cb19b7e 100644 --- a/src/3rdparty/freetype/docs/CHANGES +++ b/src/3rdparty/freetype/docs/CHANGES @@ -1,3 +1,184 @@ + +CHANGES BETWEEN 2.10.0 and 2.10.1 + + I. IMPORTANT BUG FIXES + + - The bytecode hinting of OpenType variation fonts was flawed, since + the data in the `CVAR' table wasn't correctly applied. + + + II. MISCELLANEOUS + + - Auto-hinter support for Mongolian. + + - For distribution, `.tar.bz2' packages are replaced with `.tar.xz' + bundles. + + - The handling of the default character in PCF fonts as introduced + in version 2.10.0 was partially broken, causing premature abortion + of charmap iteration for many fonts. + + - If `FT_Set_Named_Instance' was called with the same arguments + twice in a row, the function returned an incorrect error code the + second time. + + - Direct rendering using FT_RASTER_FLAG_DIRECT crashed (bug + introduced in version 2.10.0). + + - Increased precision while computing OpenType font variation + instances. + + - The flattening algorithm of cubic Bezier curves was slightly + changed to make it faster. This can cause very subtle rendering + changes, which aren't noticeable by the eye, however. + + - The auto-hinter now disables hinting if there are blue zones + defined for a `style' (i.e., a certain combination of a script and + its related typographic features) but the font doesn't contain any + characters needed to set up at least one blue zone. + + - The `ftmulti' demo program now supports multiple hidden axes with + the same name tag. + + - `ftview', `ftstring', and `ftgrid' got a `-k' command line option + to emulate a sequence of keystrokes at start-up. + + - `ftview', `ftstring', and `ftgrid' now support screen dumping to a + PNG file. + + - The bytecode debugger, `ttdebug', now supports variation TrueType + fonts; a variation font instance can be selected with the new `-d' + command line option. + + +====================================================================== + +CHANGES BETWEEN 2.9.1 and 2.10.0 + + I. IMPORTANT CHANGES + + - A bunch of new functions has been added to access and process + COLR/CPAL data of OpenType fonts with color-layered glyphs. + + FT_Palette_Data_Get + Retrieve color palette data. + FT_Palette_Select + Select and activate a color palette for color-layered + glyphs. + FT_Palette_Set_Foreground_Color + Set text foreground color for palette index 0xFFFF. + + FT_Get_Color_Glyph_Layer + Get color layers for a given glyph (using an interator + object). + + FT_Bitmap_Blend + Blend one bitmap onto another with a given color. + + - An experimental feature is the new behaviour of the + `FT_LOAD_COLOR' load flag for color-layered glyphs: Internally + it sets a flag so that if `FT_Render_Glyph' is called with + `FT_RENDER_MODE_NORMAL' (or `FT_Load_Glyph' with + `FT_LOAD_RENDER'), a default blending of the color glyph layers + will happen automatically for convenience. + + - As a GSoC 2018 project, Nikhil Ramakrishnan completely + overhauled and modernized the API reference. + + + II. MISCELLANEOUS + + - The logic for computing the global ascender, descender, and + height of OpenType fonts has been slightly adjusted for + consistency. + + . If the `useTypoMetrics' flag (i.e., bit 7 in the `fsSelection' + field) in the `OS/2' table is set, use the `sTypo' fields in + `OS/2' unconditionally. + . Otherwise use the metrics data from the `hhea' table (if not + zero). + . Otherwise use the `sTypo' fields from the `OS/2' table (if not + zero). + . Otherwise use the `usWin' data from the `OS/2' table as a last + resort. + + Variable fonts will apply the `MVAR' deltas to whichever metrics + were picked. + + - `TT_Set_MM_Blend' could fail if call repeatedly with the same + arguments. + + - The precision of handling deltas in Variation Fonts has been + increased. The problem did only show up with multidimensional + designspaces. + + - New function `FT_Library_SetLcdGeometry' to set up the geometry + of LCD subpixels. + + - FreeType now uses the `defaultChar' property of PCF fonts to set + the glyph for the undefined character at glyph index 0 (as + FreeType already does for all other supported font formats). As + a consequence, the order of glyphs of a PCF font if accessed + with FreeType can be different now compared to previous + versions. + + This change doesn't affect PCF font access with cmaps. + + - `FT_Select_Charmap' has been changed to allow parameter value + `FT_ENCODING_NONE', which is valid for BDF, PCF, and Windows FNT + formats to access built-in cmaps that don't have a predefined + `FT_Encoding' value. + + - A previously reserved field in the `FT_GlyphSlotRec' structure + now holds the glyph index. + + - On Win32 platforms, the use of `_DLL' to build the library has + been replaced with `DLL_EXPORT' and `DLL_IMPORT'. + + - The usual round of fuzzer bug fixes to better reject malformed + fonts. + + - `FT_Outline_New_Internal' and `FT_Outline_Done_Internal' have + been removed. These two functions were public by oversight only + and were never documented. + + - A new function `FT_Error_String' returns descriptions of error + codes if configuration macro FT_CONFIG_OPTION_ERROR_STRINGS is + defined. + + - `FT_Set_MM_WeightVector' and `FT_Get_MM_WeightVector' are new + functions limited to Adobe MultiMaster fonts to directly set and + get the weight vector. + + - Support for Position Independent Code as needed by systems that + prohibit automatic address fixups, such as BREW, has been + removed. [Compilation with modern compilers that use flags like + `-fPIC' or `-fPIE' is not affected.] + + - The `ftdump' demo program has new options `-c' and `-C' to + display charmaps in compact and detailed format, respectively. + Option `-V' has been removed. + + - The `ftview', `ftstring', and `ftgrid' demo programs use a new + command line option `-d' to specify the program window's width, + height, and color depth. + + - The `ftview' demo program now displays red boxes for zero-width + glyphs. + + - `ftglyph' has limited support to display fonts with + color-layered glyphs. This will be improved later on. + + - `ftgrid' can now display bitmap fonts also. + + - The `ttdebug' demo program has a new option `-f' to select a + member of a TrueType collection (TTC). + + - Other various improvements to the demo programs. + + +====================================================================== + CHANGES BETWEEN 2.9 and 2.9.1 I. IMPORTANT BUG FIXES @@ -8,7 +189,7 @@ CHANGES BETWEEN 2.9 and 2.9.1 - CVE-2018-6942: Older FreeType versions can crash with certain malformed variation fonts. - http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-6942 + https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-6942 II. MISCELLANEOUS @@ -232,7 +413,7 @@ CHANGES BETWEEN 2.7.1 and 2.8 following properties can be handled: stem darkening, LCD filter weights, and the random seed for the `random' CFF operator. - - The PCF change to show more `colourful' family names (introduced + - The PCF change to show more `colorful' family names (introduced in version 2.7.1) was too radical; it can now be configured with PCF_CONFIG_OPTION_LONG_FAMILY_NAMES at compile time. If activated, it can be switched off at run time with the new pcf @@ -383,7 +564,7 @@ CHANGES BETWEEN 2.7 and 2.7.1 and the number of CVT entries. Please report if you encounter a font where the selected values are not adequate. - - PCF family names are made more `colourful'; they now include the + - PCF family names are made more `colorful'; they now include the foundry and information whether they contain wide characters. For example, you no longer get `Fixed' but rather `Sony Fixed' or `Misc Fixed Wide'. @@ -667,8 +848,8 @@ CHANGES BETWEEN 2.6.1 and 2.6.2 - The `ftstring' demo program now supports subpixel rendering; use key `l' to cycle through the LCD modes. - - The `ftstring' demo program now supports colour rendering; use - the `space' key to cycle through various colour combinations. + - The `ftstring' demo program now supports color rendering; use + the `space' key to cycle through various color combinations. - The graphical demo programs now use a default gamma value of 1.8 (instead of 1.2). @@ -1325,7 +1506,7 @@ CHANGES BETWEEN 2.4.10 and 2.4.11 Originally, it was a separate patch available from - http://www.infinality.net/blog/ + https://web.archive.org/web/20150710073951/http://www.infinality.net:80/blog/ and which has been integrated. @@ -4047,7 +4228,7 @@ CHANGES BETWEEN beta8 and 2.0 untested for now. - Updated `docs/docmaker.py', a draft API reference is available at - http://www.freetype.org/ft2api.html. + https://web.archive.org/web/20001215173400/http://www.freetype.org:80/ft2api.html. - Changed `type1' to use `psaux'. @@ -5017,7 +5198,7 @@ Extensions support: ------------------------------------------------------------------------ -Copyright 2000-2018 by +Copyright (C) 2000-2019 by David Turner, Robert Wilhelm, and Werner Lemberg. This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/docs/CUSTOMIZE b/src/3rdparty/freetype/docs/CUSTOMIZE index 916be32754..f3f9f8edc1 100644 --- a/src/3rdparty/freetype/docs/CUSTOMIZE +++ b/src/3rdparty/freetype/docs/CUSTOMIZE @@ -139,7 +139,7 @@ IV. Overriding default configuration and module headers ---------------------------------------------------------------------- -Copyright 2003-2018 by +Copyright (C) 2003-2019 by David Turner, Robert Wilhelm, and Werner Lemberg. This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/docs/DEBUG b/src/3rdparty/freetype/docs/DEBUG index 751eaf028a..828f29434d 100644 --- a/src/3rdparty/freetype/docs/DEBUG +++ b/src/3rdparty/freetype/docs/DEBUG @@ -88,14 +88,13 @@ debugging its code: for example as in #undef FT_COMPONENT - #define FT_COMPONENT trace_io - - The value of the FT_COMPONENT macro is an enumeration named - `trace_XXXX' where `XXXX' is one of the component names defined in - the internal file `internal/fttrace.h'. If you modify FreeType - source and insert new `trace_XXXX' macro, you must register it in - `fttrace.h'. If you insert or remove many trace macros, you can - check the undefined or the unused trace macro by + #define FT_COMPONENT io + + The value of the FT_COMPONENT macro is one of the component + names defined in the internal file `internal/fttrace.h'. If you + modify FreeType source and insert new FT_COMPONENT macro, you must + register it in `fttrace.h'. If you insert or remove many trace + macros, you can check the undefined or the unused trace macro by `src/tools/chktrcmp.py'. Each such component is assigned a `debug level', ranging from 0 to @@ -138,8 +137,8 @@ behaviour of FreeType at runtime. component1:level1 component2:level2 component3:level3 ... where `componentX' is the name of a tracing component, as defined - in `fttrace.h', but without the `trace_' prefix. `levelX' is the - corresponding level to use at runtime. + in `fttrace.h'. `levelX' is the corresponding level to use at + runtime. `any' is a special component name that will be interpreted as `any/all components'. For example, the following definitions @@ -191,7 +190,7 @@ behaviour of FreeType at runtime. ------------------------------------------------------------------------ -Copyright 2002-2018 by +Copyright (C) 2002-2019 by David Turner, Robert Wilhelm, and Werner Lemberg. This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/docs/TODO b/src/3rdparty/freetype/docs/TODO index 1a443a2edc..1efccc68eb 100644 --- a/src/3rdparty/freetype/docs/TODO +++ b/src/3rdparty/freetype/docs/TODO @@ -27,7 +27,7 @@ Other bugs have been registered at the savannah bugzilla of FreeType. ------------------------------------------------------------------------ -Copyright 2001-2018 by +Copyright (C) 2001-2019 by David Turner, Robert Wilhelm, and Werner Lemberg. This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/include/freetype/config/ftconfig.h b/src/3rdparty/freetype/include/freetype/config/ftconfig.h index eedebf4082..9466603377 100644 --- a/src/3rdparty/freetype/include/freetype/config/ftconfig.h +++ b/src/3rdparty/freetype/include/freetype/config/ftconfig.h @@ -1,39 +1,38 @@ -/***************************************************************************/ -/* */ -/* ftconfig.h */ -/* */ -/* ANSI-specific configuration file (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This header file contains a number of macro definitions that are used */ - /* by the rest of the engine. Most of the macros here are automatically */ - /* determined at compile time, and you should not need to change it to */ - /* port FreeType, except to compile the library with a non-ANSI */ - /* compiler. */ - /* */ - /* Note however that if some specific modifications are needed, we */ - /* advise you to place a modified copy in your build directory. */ - /* */ - /* The build directory is usually `builds/', and contains */ - /* system-specific files that are always included first when building */ - /* the library. */ - /* */ - /* This ANSI version should stay in `include/config/'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftconfig.h + * + * ANSI-specific configuration file (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This header file contains a number of macro definitions that are used by + * the rest of the engine. Most of the macros here are automatically + * determined at compile time, and you should not need to change it to port + * FreeType, except to compile the library with a non-ANSI compiler. + * + * Note however that if some specific modifications are needed, we advise + * you to place a modified copy in your build directory. + * + * The build directory is usually `builds/`, and contains + * system-specific files that are always included first when building the + * library. + * + * This ANSI version should stay in `include/config/`. + * + */ #ifndef FTCONFIG_H_ #define FTCONFIG_H_ @@ -46,32 +45,32 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ - /* */ - /* These macros can be toggled to suit a specific system. The current */ - /* ones are defaults used to compile FreeType in an ANSI C environment */ - /* (16bit compilers are also supported). Copy this file to your own */ - /* `builds/' directory, and edit it to port the engine. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * PLATFORM-SPECIFIC CONFIGURATION MACROS + * + * These macros can be toggled to suit a specific system. The current ones + * are defaults used to compile FreeType in an ANSI C environment (16bit + * compilers are also supported). Copy this file to your own + * `builds/` directory, and edit it to port the engine. + * + */ - /* There are systems (like the Texas Instruments 'C54x) where a `char' */ - /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ - /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ - /* is probably unexpected. */ - /* */ - /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ - /* `char' type. */ + /* There are systems (like the Texas Instruments 'C54x) where a `char` */ + /* has 16~bits. ANSI~C says that `sizeof(char)` is always~1. Since an */ + /* `int` has 16~bits also for this system, `sizeof(int)` gives~1 which */ + /* is probably unexpected. */ + /* */ + /* `CHAR_BIT` (defined in `limits.h`) gives the number of bits in a */ + /* `char` type. */ #ifndef FT_CHAR_BIT #define FT_CHAR_BIT CHAR_BIT #endif - /* The size of an `int' type. */ + /* The size of an `int` type. */ #if FT_UINT_MAX == 0xFFFFUL #define FT_SIZEOF_INT ( 16 / FT_CHAR_BIT ) #elif FT_UINT_MAX == 0xFFFFFFFFUL @@ -82,7 +81,7 @@ FT_BEGIN_HEADER #error "Unsupported size of `int' type!" #endif - /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ + /* The size of a `long` type. A five-byte `long` (as used e.g. on the */ /* DM642) is recognized but avoided. */ #if FT_ULONG_MAX == 0xFFFFFFFFUL #define FT_SIZEOF_LONG ( 32 / FT_CHAR_BIT ) @@ -95,35 +94,35 @@ FT_BEGIN_HEADER #endif - /* FT_UNUSED is a macro used to indicate that a given parameter is not */ - /* used -- this is only used to get rid of unpleasant compiler warnings */ + /* `FT_UNUSED` indicates that a given parameter is not used -- */ + /* this is only used to get rid of unpleasant compiler warnings. */ #ifndef FT_UNUSED #define FT_UNUSED( arg ) ( (arg) = (arg) ) #endif - /*************************************************************************/ - /* */ - /* AUTOMATIC CONFIGURATION MACROS */ - /* */ - /* These macros are computed from the ones defined above. Don't touch */ - /* their definition, unless you know precisely what you are doing. No */ - /* porter should need to mess with them. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Mac support */ - /* */ - /* This is the only necessary change, so it is defined here instead */ - /* providing a new configuration file. */ - /* */ + /************************************************************************** + * + * AUTOMATIC CONFIGURATION MACROS + * + * These macros are computed from the ones defined above. Don't touch + * their definition, unless you know precisely what you are doing. No + * porter should need to mess with them. + * + */ + + + /************************************************************************** + * + * Mac support + * + * This is the only necessary change, so it is defined here instead + * providing a new configuration file. + */ #if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) - /* no Carbon frameworks for 64bit 10.4.x */ - /* AvailabilityMacros.h is available since Mac OS X 10.2, */ - /* so guess the system version by maximum errno before inclusion */ + /* No Carbon frameworks for 64bit 10.4.x. */ + /* `AvailabilityMacros.h` is available since Mac OS X 10.2, */ + /* so guess the system version by maximum errno before inclusion. */ #include #ifdef ECANCELED /* defined since 10.2 */ #include "AvailabilityMacros.h" @@ -143,7 +142,7 @@ FT_BEGIN_HEADER #endif - /* Fix compiler warning with sgi compiler */ + /* Fix compiler warning with sgi compiler. */ #if defined( __sgi ) && !defined( __GNUC__ ) #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) #pragma set woff 3505 @@ -151,33 +150,33 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /*
*/ - /* basic_types */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * basic_types + * + */ - /*************************************************************************/ - /* */ - /* */ - /* FT_Int16 */ - /* */ - /* */ - /* A typedef for a 16bit signed integer type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int16 + * + * @description: + * A typedef for a 16bit signed integer type. + */ typedef signed short FT_Int16; - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt16 */ - /* */ - /* */ - /* A typedef for a 16bit unsigned integer type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt16 + * + * @description: + * A typedef for a 16bit unsigned integer type. + */ typedef unsigned short FT_UInt16; /* */ @@ -186,50 +185,50 @@ FT_BEGIN_HEADER /* this #if 0 ... #endif clause is for documentation purposes */ #if 0 - /*************************************************************************/ - /* */ - /* */ - /* FT_Int32 */ - /* */ - /* */ - /* A typedef for a 32bit signed integer type. The size depends on */ - /* the configuration. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int32 + * + * @description: + * A typedef for a 32bit signed integer type. The size depends on the + * configuration. + */ typedef signed XXX FT_Int32; - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt32 */ - /* */ - /* A typedef for a 32bit unsigned integer type. The size depends on */ - /* the configuration. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt32 + * + * A typedef for a 32bit unsigned integer type. The size depends on the + * configuration. + */ typedef unsigned XXX FT_UInt32; - /*************************************************************************/ - /* */ - /* */ - /* FT_Int64 */ - /* */ - /* A typedef for a 64bit signed integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int64 + * + * A typedef for a 64bit signed integer type. The size depends on the + * configuration. Only defined if there is real 64bit support; + * otherwise, it gets emulated with a structure (if necessary). + */ typedef signed XXX FT_Int64; - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt64 */ - /* */ - /* A typedef for a 64bit unsigned integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt64 + * + * A typedef for a 64bit unsigned integer type. The size depends on the + * configuration. Only defined if there is real 64bit support; + * otherwise, it gets emulated with a structure (if necessary). + */ typedef unsigned XXX FT_UInt64; /* */ @@ -251,7 +250,7 @@ FT_BEGIN_HEADER #endif - /* look up an integer type that is at least 32 bits */ + /* look up an integer type that is at least 32~bits */ #if FT_SIZEOF_INT >= ( 32 / FT_CHAR_BIT ) typedef int FT_Fast; @@ -265,22 +264,22 @@ FT_BEGIN_HEADER #endif - /* determine whether we have a 64-bit int type for platforms without */ - /* Autoconf */ + /* determine whether we have a 64-bit `int` type for platforms without */ + /* Autoconf */ #if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT ) - /* FT_LONG64 must be defined if a 64-bit type is available */ + /* `FT_LONG64` must be defined if a 64-bit type is available */ #define FT_LONG64 #define FT_INT64 long #define FT_UINT64 unsigned long - /*************************************************************************/ - /* */ - /* A 64-bit data type may create compilation problems if you compile */ - /* in strict ANSI mode. To avoid them, we disable other 64-bit data */ - /* types if __STDC__ is defined. You can however ignore this rule */ - /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ - /* */ + /************************************************************************** + * + * A 64-bit data type may create compilation problems if you compile in + * strict ANSI mode. To avoid them, we disable other 64-bit data types if + * `__STDC__` is defined. You can however ignore this rule by defining the + * `FT_CONFIG_OPTION_FORCE_INT64` configuration macro. + */ #elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) #if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L @@ -289,19 +288,19 @@ FT_BEGIN_HEADER #define FT_INT64 long long int #define FT_UINT64 unsigned long long int -#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ +#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ - /* this compiler provides the __int64 type */ + /* this compiler provides the `__int64` type */ #define FT_LONG64 #define FT_INT64 __int64 #define FT_UINT64 unsigned __int64 #elif defined( __BORLANDC__ ) /* Borland C++ */ - /* XXXX: We should probably check the value of __BORLANDC__ in order */ - /* to test the compiler version. */ + /* XXXX: We should probably check the value of `__BORLANDC__` in order */ + /* to test the compiler version. */ - /* this compiler provides the __int64 type */ + /* this compiler provides the `__int64` type */ #define FT_LONG64 #define FT_INT64 __int64 #define FT_UINT64 unsigned __int64 @@ -318,7 +317,7 @@ FT_BEGIN_HEADER #elif defined( __GNUC__ ) - /* GCC provides the `long long' type */ + /* GCC provides the `long long` type */ #define FT_LONG64 #define FT_INT64 long long int #define FT_UINT64 unsigned long long int @@ -342,11 +341,11 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * miscellaneous + * + */ #define FT_BEGIN_STMNT do { @@ -354,7 +353,7 @@ FT_BEGIN_HEADER #define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT - /* typeof condition taken from gnulib's `intprops.h' header file */ + /* `typeof` condition taken from gnulib's `intprops.h` header file */ #if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \ ( defined( __IBMC__ ) && __IBMC__ >= 1210 && \ defined( __IBM__TYPEOF__ ) ) || \ @@ -365,14 +364,14 @@ FT_BEGIN_HEADER #endif - /* Use FT_LOCAL and FT_LOCAL_DEF to declare and define, respectively, */ - /* a function that gets used only within the scope of a module. */ - /* Normally, both the header and source code files for such a */ - /* function are within a single module directory. */ - /* */ - /* Intra-module arrays should be tagged with FT_LOCAL_ARRAY and */ - /* FT_LOCAL_ARRAY_DEF. */ - /* */ + /* Use `FT_LOCAL` and `FT_LOCAL_DEF` to declare and define, */ + /* respectively, a function that gets used only within the scope of a */ + /* module. Normally, both the header and source code files for such a */ + /* function are within a single module directory. */ + /* */ + /* Intra-module arrays should be tagged with `FT_LOCAL_ARRAY` and */ + /* `FT_LOCAL_ARRAY_DEF`. */ + /* */ #ifdef FT_MAKE_OPTION_SINGLE_OBJECT #define FT_LOCAL( x ) static x @@ -394,12 +393,12 @@ FT_BEGIN_HEADER #define FT_LOCAL_ARRAY_DEF( x ) const x - /* Use FT_BASE and FT_BASE_DEF to declare and define, respectively, */ - /* functions that are used in more than a single module. In the */ - /* current setup this implies that the declaration is in a header */ - /* file in the `include/freetype/internal' directory, and the */ - /* function body is in a file in `src/base'. */ - /* */ + /* Use `FT_BASE` and `FT_BASE_DEF` to declare and define, respectively, */ + /* functions that are used in more than a single module. In the */ + /* current setup this implies that the declaration is in a header file */ + /* in the `include/freetype/internal` directory, and the function body */ + /* is in a file in `src/base`. */ + /* */ #ifndef FT_BASE #ifdef __cplusplus @@ -422,45 +421,50 @@ FT_BEGIN_HEADER #endif /* !FT_BASE_DEF */ - /* When compiling FreeType as a DLL or DSO with hidden visibility */ - /* some systems/compilers need a special attribute in front OR after */ - /* the return type of function declarations. */ - /* */ - /* Two macros are used within the FreeType source code to define */ - /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ - /* */ - /* FT_EXPORT( return_type ) */ - /* */ - /* is used in a function declaration, as in */ - /* */ - /* FT_EXPORT( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ); */ - /* */ - /* */ - /* FT_EXPORT_DEF( return_type ) */ - /* */ - /* is used in a function definition, as in */ - /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ - /* { */ - /* ... some code ... */ - /* return FT_Err_Ok; */ - /* } */ - /* */ - /* You can provide your own implementation of FT_EXPORT and */ - /* FT_EXPORT_DEF here if you want. */ - /* */ - /* To export a variable, use FT_EXPORT_VAR. */ - /* */ + /* When compiling FreeType as a DLL or DSO with hidden visibility */ + /* some systems/compilers need a special attribute in front OR after */ + /* the return type of function declarations. */ + /* */ + /* Two macros are used within the FreeType source code to define */ + /* exported library functions: `FT_EXPORT` and `FT_EXPORT_DEF`. */ + /* */ + /* - `FT_EXPORT( return_type )` */ + /* */ + /* is used in a function declaration, as in */ + /* */ + /* ``` */ + /* FT_EXPORT( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ); */ + /* ``` */ + /* */ + /* - `FT_EXPORT_DEF( return_type )` */ + /* */ + /* is used in a function definition, as in */ + /* */ + /* ``` */ + /* FT_EXPORT_DEF( FT_Error ) */ + /* FT_Init_FreeType( FT_Library* alibrary ) */ + /* { */ + /* ... some code ... */ + /* return FT_Err_Ok; */ + /* } */ + /* ``` */ + /* */ + /* You can provide your own implementation of `FT_EXPORT` and */ + /* `FT_EXPORT_DEF` here if you want. */ + /* */ + /* To export a variable, use `FT_EXPORT_VAR`. */ + /* */ #ifndef FT_EXPORT #ifdef FT2_BUILD_LIBRARY -#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) ) +#if defined( _WIN32 ) && defined( DLL_EXPORT ) #define FT_EXPORT( x ) __declspec( dllexport ) x #elif defined( __GNUC__ ) && __GNUC__ >= 4 #define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x +#elif defined( __SUNPRO_C ) && __SUNPRO_C >= 0x550 +#define FT_EXPORT( x ) __global x #elif defined( __cplusplus ) #define FT_EXPORT( x ) extern "C" x #else @@ -469,7 +473,7 @@ FT_BEGIN_HEADER #else -#if defined( FT2_DLLIMPORT ) +#if defined( _WIN32 ) && defined( DLL_IMPORT ) #define FT_EXPORT( x ) __declspec( dllimport ) x #elif defined( __cplusplus ) #define FT_EXPORT( x ) extern "C" x @@ -508,7 +512,7 @@ FT_BEGIN_HEADER /* C++ compiler and with 16bit compilers. */ /* */ - /* This is special. Within C++, you must specify `extern "C"' for */ + /* This is special. Within C++, you must specify `extern "C"` for */ /* functions which are used via function pointers, and you also */ /* must do that for structures which contain function pointers to */ /* assure C linkage -- it's not possible to have (local) anonymous */ @@ -531,7 +535,7 @@ FT_BEGIN_HEADER /* */ /* */ /* Some 16bit compilers have to redefine these macros to insert */ - /* the infamous `_cdecl' or `__fastcall' declarations. */ + /* the infamous `_cdecl` or `__fastcall` declarations. */ /* */ #ifndef FT_CALLBACK_DEF #ifdef __cplusplus diff --git a/src/3rdparty/freetype/include/freetype/config/ftheader.h b/src/3rdparty/freetype/include/freetype/config/ftheader.h index 702f77cc42..696d6ba906 100644 --- a/src/3rdparty/freetype/include/freetype/config/ftheader.h +++ b/src/3rdparty/freetype/include/freetype/config/ftheader.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftheader.h */ -/* */ -/* Build macros of the FreeType 2 library. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftheader.h + * + * Build macros of the FreeType 2 library. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTHEADER_H_ #define FTHEADER_H_ @@ -27,7 +27,7 @@ /* */ /* This macro is used in association with @FT_END_HEADER in header */ /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* encapsulated in an `extern "C" { .. }` block when included from a */ /* C++ compiler. */ /* */ #ifdef __cplusplus @@ -45,7 +45,7 @@ /* */ /* This macro is used in association with @FT_BEGIN_HEADER in header */ /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ + /* encapsulated in an `extern "C" { .. }` block when included from a */ /* C++ compiler. */ /* */ #ifdef __cplusplus @@ -55,54 +55,54 @@ #endif - /*************************************************************************/ - /* */ - /* Aliases for the FreeType 2 public and configuration files. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Aliases for the FreeType 2 public and configuration files. + * + */ - /*************************************************************************/ - /* */ - /*
*/ - /* header_file_macros */ - /* */ - /* */ - /* Header File Macros */ - /* */ - /* <Abstract> */ - /* Macro definitions used to #include specific header files. */ - /* */ - /* <Description> */ - /* The following macros are defined to the name of specific */ - /* FreeType~2 header files. They can be used directly in #include */ - /* statements as in: */ - /* */ - /* { */ - /* #include FT_FREETYPE_H */ - /* #include FT_MULTIPLE_MASTERS_H */ - /* #include FT_GLYPH_H */ - /* } */ - /* */ - /* There are several reasons why we are now using macros to name */ - /* public header files. The first one is that such macros are not */ - /* limited to the infamous 8.3~naming rule required by DOS (and */ - /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */ - /* */ - /* The second reason is that it allows for more flexibility in the */ - /* way FreeType~2 is installed on a given system. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * header_file_macros + * + * @title: + * Header File Macros + * + * @abstract: + * Macro definitions used to `#include` specific header files. + * + * @description: + * The following macros are defined to the name of specific FreeType~2 + * header files. They can be used directly in `#include` statements as + * in: + * + * ``` + * #include FT_FREETYPE_H + * #include FT_MULTIPLE_MASTERS_H + * #include FT_GLYPH_H + * ``` + * + * There are several reasons why we are now using macros to name public + * header files. The first one is that such macros are not limited to + * the infamous 8.3~naming rule required by DOS (and + * `FT_MULTIPLE_MASTERS_H` is a lot more meaningful than `ftmm.h`). + * + * The second reason is that it allows for more flexibility in the way + * FreeType~2 is installed on a given system. + * + */ /* configuration files */ - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_CONFIG_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * FreeType~2 configuration data. * */ @@ -111,13 +111,13 @@ #endif - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_STANDARD_LIBRARY_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * FreeType~2 interface to the standard C library functions. * */ @@ -126,13 +126,13 @@ #endif - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_OPTIONS_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * FreeType~2 project-specific configuration options. * */ @@ -141,13 +141,13 @@ #endif - /************************************************************************* + /************************************************************************** * * @macro: * FT_CONFIG_MODULES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list of FreeType~2 modules that are statically linked to new library * instances in @FT_Init_FreeType. * @@ -160,26 +160,26 @@ /* public headers */ - /************************************************************************* + /************************************************************************** * * @macro: * FT_FREETYPE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * base FreeType~2 API. * */ #define FT_FREETYPE_H <freetype/freetype.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_ERRORS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list of FreeType~2 error codes (and messages). * * It is included by @FT_FREETYPE_H. @@ -188,26 +188,26 @@ #define FT_ERRORS_H <freetype/fterrors.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MODULE_ERRORS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list of FreeType~2 module error offsets (and messages). * */ #define FT_MODULE_ERRORS_H <freetype/ftmoderr.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SYSTEM_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 interface to low-level operations (i.e., memory management * and stream i/o). * @@ -217,13 +217,13 @@ #define FT_SYSTEM_H <freetype/ftsystem.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_IMAGE_H * * @description: - * A macro used in #include statements to name the file containing type + * A macro used in `#include` statements to name the file containing type * definitions related to glyph images (i.e., bitmaps, outlines, * scan-converter parameters). * @@ -233,13 +233,13 @@ #define FT_IMAGE_H <freetype/ftimage.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TYPES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * basic data types defined by FreeType~2. * * It is included by @FT_FREETYPE_H. @@ -248,13 +248,13 @@ #define FT_TYPES_H <freetype/fttypes.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_LIST_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * list management API of FreeType~2. * * (Most applications will never need to include this file.) @@ -263,151 +263,151 @@ #define FT_LIST_H <freetype/ftlist.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_OUTLINE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * scalable outline management API of FreeType~2. * */ #define FT_OUTLINE_H <freetype/ftoutln.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SIZES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API which manages multiple @FT_Size objects per face. * */ #define FT_SIZES_H <freetype/ftsizes.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MODULE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * module management API of FreeType~2. * */ #define FT_MODULE_H <freetype/ftmodapi.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_RENDER_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * renderer module management API of FreeType~2. * */ #define FT_RENDER_H <freetype/ftrender.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the driver modules. * */ #define FT_DRIVER_H <freetype/ftdriver.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_AUTOHINTER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the auto-hinting module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_AUTOHINTER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_CFF_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the CFF driver module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_CFF_DRIVER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the TrueType driver module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_TRUETYPE_DRIVER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_PCF_DRIVER_H * * @description: - * A macro used in #include statements to name the file containing + * A macro used in `#include` statements to name the file containing * structures and macros related to the PCF driver module. * - * Deprecated since version 2.9; use @FT_DRIVER_H instead. + * Deprecated since version~2.9; use @FT_DRIVER_H instead. * */ #define FT_PCF_DRIVER_H FT_DRIVER_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_TYPE1_TABLES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * types and API specific to the Type~1 format. * */ #define FT_TYPE1_TABLES_H <freetype/t1tables.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_IDS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * enumeration values which identify name strings, languages, encodings, * etc. This file really contains a _large_ set of constant macro * definitions, taken from the TrueType and OpenType specifications. @@ -416,174 +416,172 @@ #define FT_TRUETYPE_IDS_H <freetype/ttnameid.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_TABLES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * types and API specific to the TrueType (as well as OpenType) format. * */ #define FT_TRUETYPE_TABLES_H <freetype/tttables.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRUETYPE_TAGS_H * * @description: - * A macro used in #include statements to name the file containing the - * definitions of TrueType four-byte `tags' which identify blocks in + * A macro used in `#include` statements to name the file containing the + * definitions of TrueType four-byte 'tags' which identify blocks in * SFNT-based font formats (i.e., TrueType and OpenType). * */ #define FT_TRUETYPE_TAGS_H <freetype/tttags.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BDF_H * * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which accesses BDF-specific strings from a - * face. + * A macro used in `#include` statements to name the file containing the + * definitions of an API which accesses BDF-specific strings from a face. * */ #define FT_BDF_H <freetype/ftbdf.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_CID_H * * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which access CID font information from a - * face. + * A macro used in `#include` statements to name the file containing the + * definitions of an API which access CID font information from a face. * */ #define FT_CID_H <freetype/ftcid.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GZIP_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports gzip-compressed files. * */ #define FT_GZIP_H <freetype/ftgzip.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_LZW_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports LZW-compressed files. * */ #define FT_LZW_H <freetype/ftlzw.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BZIP2_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports bzip2-compressed files. * */ #define FT_BZIP2_H <freetype/ftbzip2.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_WINFONTS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * definitions of an API which supports Windows FNT files. * */ #define FT_WINFONTS_H <freetype/ftwinfnt.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GLYPH_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional glyph management component. * */ #define FT_GLYPH_H <freetype/ftglyph.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BITMAP_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional bitmap conversion component. * */ #define FT_BITMAP_H <freetype/ftbitmap.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_BBOX_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional exact bounding box computation routines. * */ #define FT_BBOX_H <freetype/ftbbox.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_CACHE_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * API of the optional FreeType~2 cache sub-system. * */ #define FT_CACHE_H <freetype/ftcache.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MAC_H * * @description: - * A macro used in #include statements to name the file containing the - * Macintosh-specific FreeType~2 API. The latter is used to access - * fonts embedded in resource forks. + * A macro used in `#include` statements to name the file containing the + * Macintosh-specific FreeType~2 API. The latter is used to access fonts + * embedded in resource forks. * * This header file must be explicitly included by client applications * compiled on the Mac (note that the base API still works though). @@ -592,105 +590,105 @@ #define FT_MAC_H <freetype/ftmac.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_MULTIPLE_MASTERS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * optional multiple-masters management API of FreeType~2. * */ #define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SFNT_NAMES_H * * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which accesses embedded `name' strings in + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which accesses embedded 'name' strings in * SFNT-based font formats (i.e., TrueType and OpenType). * */ #define FT_SFNT_NAMES_H <freetype/ftsnames.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_OPENTYPE_VALIDATE_H * * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates OpenType tables (BASE, GDEF, - * GPOS, GSUB, JSTF). + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which validates OpenType tables ('BASE', + * 'GDEF', 'GPOS', 'GSUB', 'JSTF'). * */ #define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GX_VALIDATE_H * * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat, - * mort, morx, bsln, just, kern, opbd, trak, prop). + * A macro used in `#include` statements to name the file containing the + * optional FreeType~2 API which validates TrueTypeGX/AAT tables ('feat', + * 'mort', 'morx', 'bsln', 'just', 'kern', 'opbd', 'trak', 'prop'). * */ #define FT_GX_VALIDATE_H <freetype/ftgxval.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_PFR_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which accesses PFR-specific data. * */ #define FT_PFR_H <freetype/ftpfr.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_STROKER_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which provides functions to stroke outline paths. */ #define FT_STROKER_H <freetype/ftstroke.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_SYNTHESIS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs artificial obliquing and emboldening. */ #define FT_SYNTHESIS_H <freetype/ftsynth.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_FONT_FORMATS_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which provides functions specific to font formats. */ #define FT_FONT_FORMATS_H <freetype/ftfntfmt.h> @@ -699,67 +697,79 @@ #define FT_XFREE86_H FT_FONT_FORMATS_H - /************************************************************************* + /************************************************************************** * * @macro: * FT_TRIGONOMETRY_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs trigonometric computations (e.g., * cosines and arc tangents). */ #define FT_TRIGONOMETRY_H <freetype/fttrigon.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_LCD_FILTER_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs color filtering for subpixel rendering. */ #define FT_LCD_FILTER_H <freetype/ftlcdfil.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_INCREMENTAL_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which performs incremental glyph loading. */ #define FT_INCREMENTAL_H <freetype/ftincrem.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_GASP_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which returns entries from the TrueType GASP table. */ #define FT_GASP_H <freetype/ftgasp.h> - /************************************************************************* + /************************************************************************** * * @macro: * FT_ADVANCES_H * * @description: - * A macro used in #include statements to name the file containing the + * A macro used in `#include` statements to name the file containing the * FreeType~2 API which returns individual and ranged glyph advances. */ #define FT_ADVANCES_H <freetype/ftadvanc.h> + /************************************************************************** + * + * @macro: + * FT_COLOR_H + * + * @description: + * A macro used in `#include` statements to name the file containing the + * FreeType~2 API which handles the OpenType 'CPAL' table. + */ +#define FT_COLOR_H <freetype/ftcolor.h> + + /* */ /* These header files don't need to be included by the user. */ @@ -770,14 +780,14 @@ #define FT_UNPATENTED_HINTING_H <freetype/ftparams.h> #define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h> - /* FT_CACHE_H is the only header file needed for the cache subsystem. */ + /* `FT_CACHE_H` is the only header file needed for the cache subsystem. */ #define FT_CACHE_IMAGE_H FT_CACHE_H #define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H #define FT_CACHE_CHARMAP_H FT_CACHE_H /* The internals of the cache sub-system are no longer exposed. We */ - /* default to FT_CACHE_H at the moment just in case, but we know of */ - /* no rogue client that uses them. */ + /* default to `FT_CACHE_H` at the moment just in case, but we know */ + /* of no rogue client that uses them. */ /* */ #define FT_CACHE_MANAGER_H FT_CACHE_H #define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H @@ -789,8 +799,8 @@ /* - * Include internal headers definitions from <internal/...> - * only when building the library. + * Include internal headers definitions from `<internal/...>` only when + * building the library. */ #ifdef FT2_BUILD_LIBRARY #define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> diff --git a/src/3rdparty/freetype/include/freetype/config/ftmodule.h b/src/3rdparty/freetype/include/freetype/config/ftmodule.h index 76d271a74b..7c603e5327 100644 --- a/src/3rdparty/freetype/include/freetype/config/ftmodule.h +++ b/src/3rdparty/freetype/include/freetype/config/ftmodule.h @@ -1,12 +1,12 @@ /* - * This file registers the FreeType modules compiled into the library. + * This file registers the FreeType modules compiled into the library. * - * If you use GNU make, this file IS NOT USED! Instead, it is created in - * the objects directory (normally `<topdir>/objs/') based on information - * from `<topdir>/modules.cfg'. + * If you use GNU make, this file IS NOT USED! Instead, it is created in + * the objects directory (normally `<topdir>/objs/`) based on information + * from `<topdir>/modules.cfg`. * - * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile - * FreeType without GNU make. + * Please read `docs/INSTALL.ANY` and `docs/CUSTOMIZE` how to compile + * FreeType without GNU make. * */ diff --git a/src/3rdparty/freetype/include/freetype/config/ftoption.h b/src/3rdparty/freetype/include/freetype/config/ftoption.h index 4bcab2af5c..12f47a82e8 100644 --- a/src/3rdparty/freetype/include/freetype/config/ftoption.h +++ b/src/3rdparty/freetype/include/freetype/config/ftoption.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftoption.h */ -/* */ -/* User-selectable configuration macros (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftoption.h + * + * User-selectable configuration macros (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTOPTION_H_ @@ -25,45 +25,47 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* USER-SELECTABLE CONFIGURATION MACROS */ - /* */ - /* This file contains the default configuration macro definitions for */ - /* a standard build of the FreeType library. There are three ways to */ - /* use this file to build project-specific versions of the library: */ - /* */ - /* - You can modify this file by hand, but this is not recommended in */ - /* cases where you would like to build several versions of the */ - /* library from a single source directory. */ - /* */ - /* - You can put a copy of this file in your build directory, more */ - /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ - /* is the name of a directory that is included _before_ the FreeType */ - /* include path during compilation. */ - /* */ - /* The default FreeType Makefiles and Jamfiles use the build */ - /* directory `builds/<system>' by default, but you can easily change */ - /* that for your own projects. */ - /* */ - /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */ - /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ - /* locate this file during the build. For example, */ - /* */ - /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */ - /* #include <freetype/config/ftheader.h> */ - /* */ - /* will use `$BUILD/myftoptions.h' instead of this file for macro */ - /* definitions. */ - /* */ - /* Note also that you can similarly pre-define the macro */ - /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ - /* that are statically linked to the library at compile time. By */ - /* default, this file is <freetype/config/ftmodule.h>. */ - /* */ - /* We highly recommend using the third method whenever possible. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * USER-SELECTABLE CONFIGURATION MACROS + * + * This file contains the default configuration macro definitions for a + * standard build of the FreeType library. There are three ways to use + * this file to build project-specific versions of the library: + * + * - You can modify this file by hand, but this is not recommended in + * cases where you would like to build several versions of the library + * from a single source directory. + * + * - You can put a copy of this file in your build directory, more + * precisely in `$BUILD/freetype/config/ftoption.h`, where `$BUILD` is + * the name of a directory that is included _before_ the FreeType include + * path during compilation. + * + * The default FreeType Makefiles and Jamfiles use the build directory + * `builds/<system>` by default, but you can easily change that for your + * own projects. + * + * - Copy the file <ft2build.h> to `$BUILD/ft2build.h` and modify it + * slightly to pre-define the macro `FT_CONFIG_OPTIONS_H` used to locate + * this file during the build. For example, + * + * ``` + * #define FT_CONFIG_OPTIONS_H <myftoptions.h> + * #include <freetype/config/ftheader.h> + * ``` + * + * will use `$BUILD/myftoptions.h` instead of this file for macro + * definitions. + * + * Note also that you can similarly pre-define the macro + * `FT_CONFIG_MODULES_H` used to locate the file listing of the modules + * that are statically linked to the library at compile time. By + * default, this file is `<freetype/config/ftmodule.h>`. + * + * We highly recommend using the third method whenever possible. + * + */ /*************************************************************************/ @@ -75,444 +77,433 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*#***********************************************************************/ - /* */ - /* If you enable this configuration option, FreeType recognizes an */ - /* environment variable called `FREETYPE_PROPERTIES', which can be used */ - /* to control the various font drivers and modules. The controllable */ - /* properties are listed in the section @properties. */ - /* */ - /* You have to undefine this configuration option on platforms that lack */ - /* the concept of environment variables (and thus don't have the */ - /* `getenv' function), for example Windows CE. */ - /* */ - /* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */ - /* multiple lines for better readability). */ - /* */ - /* { */ - /* <optional whitespace> */ - /* <module-name1> ':' */ - /* <property-name1> '=' <property-value1> */ - /* <whitespace> */ - /* <module-name2> ':' */ - /* <property-name2> '=' <property-value2> */ - /* ... */ - /* } */ - /* */ - /* Example: */ - /* */ - /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ - /* cff:no-stem-darkening=1 \ */ - /* autofitter:warping=1 */ - /* */ + /*#************************************************************************ + * + * If you enable this configuration option, FreeType recognizes an + * environment variable called `FREETYPE_PROPERTIES`, which can be used to + * control the various font drivers and modules. The controllable + * properties are listed in the section @properties. + * + * You have to undefine this configuration option on platforms that lack + * the concept of environment variables (and thus don't have the `getenv` + * function), for example Windows CE. + * + * `FREETYPE_PROPERTIES` has the following syntax form (broken here into + * multiple lines for better readability). + * + * ``` + * <optional whitespace> + * <module-name1> ':' + * <property-name1> '=' <property-value1> + * <whitespace> + * <module-name2> ':' + * <property-name2> '=' <property-value2> + * ... + * ``` + * + * Example: + * + * ``` + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=1 \ + * autofitter:warping=1 + * ``` + * + */ #define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - /*************************************************************************/ - /* */ - /* Uncomment the line below if you want to activate LCD rendering */ - /* technology similar to ClearType in this build of the library. This */ - /* technology triples the resolution in the direction color subpixels. */ - /* To mitigate color fringes inherent to this technology, you also need */ - /* to explicitly set up LCD filtering. */ - /* */ - /* Note that this feature is covered by several Microsoft patents */ - /* and should not be activated in any default build of the library. */ - /* When this macro is not defined, FreeType offers alternative LCD */ - /* rendering technology that produces excellent output without LCD */ - /* filtering. */ - /* */ + /************************************************************************** + * + * Uncomment the line below if you want to activate LCD rendering + * technology similar to ClearType in this build of the library. This + * technology triples the resolution in the direction color subpixels. To + * mitigate color fringes inherent to this technology, you also need to + * explicitly set up LCD filtering. + * + * Note that this feature is covered by several Microsoft patents and + * should not be activated in any default build of the library. When this + * macro is not defined, FreeType offers alternative LCD rendering + * technology that produces excellent output without LCD filtering. + */ /* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /*************************************************************************/ - /* */ - /* Many compilers provide a non-ANSI 64-bit data type that can be used */ - /* by FreeType to speed up some computations. However, this will create */ - /* some problems when compiling the library in strict ANSI mode. */ - /* */ - /* For this reason, the use of 64-bit integers is normally disabled when */ - /* the __STDC__ macro is defined. You can however disable this by */ - /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ - /* */ - /* For most compilers, this will only create compilation warnings when */ - /* building the library. */ - /* */ - /* ObNote: The compiler-specific 64-bit integers are detected in the */ - /* file `ftconfig.h' either statically or through the */ - /* `configure' script on supported platforms. */ - /* */ + /************************************************************************** + * + * Many compilers provide a non-ANSI 64-bit data type that can be used by + * FreeType to speed up some computations. However, this will create some + * problems when compiling the library in strict ANSI mode. + * + * For this reason, the use of 64-bit integers is normally disabled when + * the `__STDC__` macro is defined. You can however disable this by + * defining the macro `FT_CONFIG_OPTION_FORCE_INT64` here. + * + * For most compilers, this will only create compilation warnings when + * building the library. + * + * ObNote: The compiler-specific 64-bit integers are detected in the + * file `ftconfig.h` either statically or through the `configure` + * script on supported platforms. + */ #undef FT_CONFIG_OPTION_FORCE_INT64 - /*************************************************************************/ - /* */ - /* If this macro is defined, do not try to use an assembler version of */ - /* performance-critical functions (e.g. FT_MulFix). You should only do */ - /* that to verify that the assembler function works properly, or to */ - /* execute benchmark tests of the various implementations. */ + /************************************************************************** + * + * If this macro is defined, do not try to use an assembler version of + * performance-critical functions (e.g., @FT_MulFix). You should only do + * that to verify that the assembler function works properly, or to execute + * benchmark tests of the various implementations. + */ /* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ - /*************************************************************************/ - /* */ - /* If this macro is defined, try to use an inlined assembler version of */ - /* the `FT_MulFix' function, which is a `hotspot' when loading and */ - /* hinting glyphs, and which should be executed as fast as possible. */ - /* */ - /* Note that if your compiler or CPU is not supported, this will default */ - /* to the standard and portable implementation found in `ftcalc.c'. */ - /* */ + /************************************************************************** + * + * If this macro is defined, try to use an inlined assembler version of the + * @FT_MulFix function, which is a 'hotspot' when loading and hinting + * glyphs, and which should be executed as fast as possible. + * + * Note that if your compiler or CPU is not supported, this will default to + * the standard and portable implementation found in `ftcalc.c`. + */ #define FT_CONFIG_OPTION_INLINE_MULFIX - /*************************************************************************/ - /* */ - /* LZW-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `compress' program. This is mostly used to parse many of the PCF */ - /* files that come with various X11 distributions. The implementation */ - /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ - /* (see src/lzw/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ + /************************************************************************** + * + * LZW-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `compress` program. This is mostly used to parse many of the PCF + * files that come with various X11 distributions. The implementation + * uses NetBSD's `zopen` to partially uncompress the file on the fly (see + * `src/lzw/ftgzip.c`). + * + * Define this macro if you want to enable this 'feature'. + */ #define FT_CONFIG_OPTION_USE_LZW - /*************************************************************************/ - /* */ - /* Gzip-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `gzip' program. This is mostly used to parse many of the PCF files */ - /* that come with XFree86. The implementation uses `zlib' to */ - /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. See also */ - /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ - /* */ + /************************************************************************** + * + * Gzip-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `gzip` program. This is mostly used to parse many of the PCF files + * that come with XFree86. The implementation uses 'zlib' to partially + * uncompress the file on the fly (see `src/gzip/ftgzip.c`). + * + * Define this macro if you want to enable this 'feature'. See also the + * macro `FT_CONFIG_OPTION_SYSTEM_ZLIB` below. + */ #define FT_CONFIG_OPTION_USE_ZLIB - /*************************************************************************/ - /* */ - /* ZLib library selection */ - /* */ - /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ - /* It allows FreeType's `ftgzip' component to link to the system's */ - /* installation of the ZLib library. This is useful on systems like */ - /* Unix or VMS where it generally is already available. */ - /* */ - /* If you let it undefined, the component will use its own copy */ - /* of the zlib sources instead. These have been modified to be */ - /* included directly within the component and *not* export external */ - /* function names. This allows you to link any program with FreeType */ - /* _and_ ZLib without linking conflicts. */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * ZLib library selection + * + * This macro is only used when `FT_CONFIG_OPTION_USE_ZLIB` is defined. + * It allows FreeType's 'ftgzip' component to link to the system's + * installation of the ZLib library. This is useful on systems like + * Unix or VMS where it generally is already available. + * + * If you let it undefined, the component will use its own copy of the + * zlib sources instead. These have been modified to be included + * directly within the component and **not** export external function + * names. This allows you to link any program with FreeType _and_ ZLib + * without linking conflicts. + * + * Do not `#undef` this macro here since the build system might define + * it for certain configurations only. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ - /*************************************************************************/ - /* */ - /* Bzip2-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `bzip2' program. This is mostly used to parse many of the PCF */ - /* files that come with XFree86. The implementation uses `libbz2' to */ - /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ - /* Contrary to gzip, bzip2 currently is not included and need to use */ - /* the system available bzip2 implementation. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * Bzip2-compressed file support. + * + * FreeType now handles font files that have been compressed with the + * `bzip2` program. This is mostly used to parse many of the PCF files + * that come with XFree86. The implementation uses `libbz2` to partially + * uncompress the file on the fly (see `src/bzip2/ftbzip2.c`). Contrary + * to gzip, bzip2 currently is not included and need to use the system + * available bzip2 implementation. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_USE_BZIP2 */ - /*************************************************************************/ - /* */ - /* Define to disable the use of file stream functions and types, FILE, */ - /* fopen() etc. Enables the use of smaller system libraries on embedded */ - /* systems that have multiple system libraries, some with or without */ - /* file stream support, in the cases where file stream support is not */ - /* necessary such as memory loading of font files. */ - /* */ + /************************************************************************** + * + * Define to disable the use of file stream functions and types, `FILE`, + * `fopen`, etc. Enables the use of smaller system libraries on embedded + * systems that have multiple system libraries, some with or without file + * stream support, in the cases where file stream support is not necessary + * such as memory loading of font files. + */ /* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ - /*************************************************************************/ - /* */ - /* PNG bitmap support. */ - /* */ - /* FreeType now handles loading color bitmap glyphs in the PNG format. */ - /* This requires help from the external libpng library. Uncompressed */ - /* color bitmaps do not need any external libraries and will be */ - /* supported regardless of this configuration. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * PNG bitmap support. + * + * FreeType now handles loading color bitmap glyphs in the PNG format. + * This requires help from the external libpng library. Uncompressed + * color bitmaps do not need any external libraries and will be supported + * regardless of this configuration. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_USE_PNG */ - /*************************************************************************/ - /* */ - /* HarfBuzz support. */ - /* */ - /* FreeType uses the HarfBuzz library to improve auto-hinting of */ - /* OpenType fonts. If available, many glyphs not directly addressable */ - /* by a font's character map will be hinted also. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ - /* If you use a build system like cmake or the `configure' script, */ - /* options set by those programs have precendence, overwriting the */ - /* value here with the configured one. */ - /* */ + /************************************************************************** + * + * HarfBuzz support. + * + * FreeType uses the HarfBuzz library to improve auto-hinting of OpenType + * fonts. If available, many glyphs not directly addressable by a font's + * character map will be hinted also. + * + * Define this macro if you want to enable this 'feature'. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ /* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ - /*************************************************************************/ - /* */ - /* Glyph Postscript Names handling */ - /* */ - /* By default, FreeType 2 is compiled with the `psnames' module. This */ - /* module is in charge of converting a glyph name string into a */ - /* Unicode value, or return a Macintosh standard glyph name for the */ - /* use with the TrueType `post' table. */ - /* */ - /* Undefine this macro if you do not want `psnames' compiled in your */ - /* build of FreeType. This has the following effects: */ - /* */ - /* - The TrueType driver will provide its own set of glyph names, */ - /* if you build it to support postscript names in the TrueType */ - /* `post' table, but will not synthesize a missing Unicode charmap. */ - /* */ - /* - The Type 1 driver will not be able to synthesize a Unicode */ - /* charmap out of the glyphs found in the fonts. */ - /* */ - /* You would normally undefine this configuration macro when building */ - /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ - /* */ + /************************************************************************** + * + * Glyph Postscript Names handling + * + * By default, FreeType 2 is compiled with the 'psnames' module. This + * module is in charge of converting a glyph name string into a Unicode + * value, or return a Macintosh standard glyph name for the use with the + * TrueType 'post' table. + * + * Undefine this macro if you do not want 'psnames' compiled in your + * build of FreeType. This has the following effects: + * + * - The TrueType driver will provide its own set of glyph names, if you + * build it to support postscript names in the TrueType 'post' table, + * but will not synthesize a missing Unicode charmap. + * + * - The Type~1 driver will not be able to synthesize a Unicode charmap + * out of the glyphs found in the fonts. + * + * You would normally undefine this configuration macro when building a + * version of FreeType that doesn't contain a Type~1 or CFF driver. + */ #define FT_CONFIG_OPTION_POSTSCRIPT_NAMES - /*************************************************************************/ - /* */ - /* Postscript Names to Unicode Values support */ - /* */ - /* By default, FreeType 2 is built with the `PSNames' module compiled */ - /* in. Among other things, the module is used to convert a glyph name */ - /* into a Unicode value. This is especially useful in order to */ - /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ - /* through a big table named the `Adobe Glyph List' (AGL). */ - /* */ - /* Undefine this macro if you do not want the Adobe Glyph List */ - /* compiled in your `PSNames' module. The Type 1 driver will not be */ - /* able to synthesize a Unicode charmap out of the glyphs found in the */ - /* fonts. */ - /* */ + /************************************************************************** + * + * Postscript Names to Unicode Values support + * + * By default, FreeType~2 is built with the 'psnames' module compiled in. + * Among other things, the module is used to convert a glyph name into a + * Unicode value. This is especially useful in order to synthesize on + * the fly a Unicode charmap from the CFF/Type~1 driver through a big + * table named the 'Adobe Glyph List' (AGL). + * + * Undefine this macro if you do not want the Adobe Glyph List compiled + * in your 'psnames' module. The Type~1 driver will not be able to + * synthesize a Unicode charmap out of the glyphs found in the fonts. + */ #define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - /*************************************************************************/ - /* */ - /* Support for Mac fonts */ - /* */ - /* Define this macro if you want support for outline fonts in Mac */ - /* format (mac dfont, mac resource, macbinary containing a mac */ - /* resource) on non-Mac platforms. */ - /* */ - /* Note that the `FOND' resource isn't checked. */ - /* */ + /************************************************************************** + * + * Support for Mac fonts + * + * Define this macro if you want support for outline fonts in Mac format + * (mac dfont, mac resource, macbinary containing a mac resource) on + * non-Mac platforms. + * + * Note that the 'FOND' resource isn't checked. + */ #define FT_CONFIG_OPTION_MAC_FONTS - /*************************************************************************/ - /* */ - /* Guessing methods to access embedded resource forks */ - /* */ - /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ - /* GNU/Linux). */ - /* */ - /* Resource forks which include fonts data are stored sometimes in */ - /* locations which users or developers don't expected. In some cases, */ - /* resource forks start with some offset from the head of a file. In */ - /* other cases, the actual resource fork is stored in file different */ - /* from what the user specifies. If this option is activated, */ - /* FreeType tries to guess whether such offsets or different file */ - /* names must be used. */ - /* */ - /* Note that normal, direct access of resource forks is controlled via */ - /* the FT_CONFIG_OPTION_MAC_FONTS option. */ - /* */ + /************************************************************************** + * + * Guessing methods to access embedded resource forks + * + * Enable extra Mac fonts support on non-Mac platforms (e.g., GNU/Linux). + * + * Resource forks which include fonts data are stored sometimes in + * locations which users or developers don't expected. In some cases, + * resource forks start with some offset from the head of a file. In + * other cases, the actual resource fork is stored in file different from + * what the user specifies. If this option is activated, FreeType tries + * to guess whether such offsets or different file names must be used. + * + * Note that normal, direct access of resource forks is controlled via + * the `FT_CONFIG_OPTION_MAC_FONTS` option. + */ #ifdef FT_CONFIG_OPTION_MAC_FONTS #define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK #endif - /*************************************************************************/ - /* */ - /* Allow the use of FT_Incremental_Interface to load typefaces that */ - /* contain no glyph data, but supply it via a callback function. */ - /* This is required by clients supporting document formats which */ - /* supply font data incrementally as the document is parsed, such */ - /* as the Ghostscript interpreter for the PostScript language. */ - /* */ + /************************************************************************** + * + * Allow the use of `FT_Incremental_Interface` to load typefaces that + * contain no glyph data, but supply it via a callback function. This is + * required by clients supporting document formats which supply font data + * incrementally as the document is parsed, such as the Ghostscript + * interpreter for the PostScript language. + */ #define FT_CONFIG_OPTION_INCREMENTAL - /*************************************************************************/ - /* */ - /* The size in bytes of the render pool used by the scan-line converter */ - /* to do all of its work. */ - /* */ + /************************************************************************** + * + * The size in bytes of the render pool used by the scan-line converter to + * do all of its work. + */ #define FT_RENDER_POOL_SIZE 16384L - /*************************************************************************/ - /* */ - /* FT_MAX_MODULES */ - /* */ - /* The maximum number of modules that can be registered in a single */ - /* FreeType library object. 32 is the default. */ - /* */ + /************************************************************************** + * + * FT_MAX_MODULES + * + * The maximum number of modules that can be registered in a single + * FreeType library object. 32~is the default. + */ #define FT_MAX_MODULES 32 - /*************************************************************************/ - /* */ - /* Debug level */ - /* */ - /* FreeType can be compiled in debug or trace mode. In debug mode, */ - /* errors are reported through the `ftdebug' component. In trace */ - /* mode, additional messages are sent to the standard output during */ - /* execution. */ - /* */ - /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ - /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ - /* */ - /* Don't define any of these macros to compile in `release' mode! */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ + /************************************************************************** + * + * Debug level + * + * FreeType can be compiled in debug or trace mode. In debug mode, + * errors are reported through the 'ftdebug' component. In trace mode, + * additional messages are sent to the standard output during execution. + * + * Define `FT_DEBUG_LEVEL_ERROR` to build the library in debug mode. + * Define `FT_DEBUG_LEVEL_TRACE` to build it in trace mode. + * + * Don't define any of these macros to compile in 'release' mode! + * + * Do not `#undef` these macros here since the build system might define + * them for certain configurations only. + */ /* #define FT_DEBUG_LEVEL_ERROR */ /* #define FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* Autofitter debugging */ - /* */ - /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ - /* control the autofitter behaviour for debugging purposes with global */ - /* boolean variables (consequently, you should *never* enable this */ - /* while compiling in `release' mode): */ - /* */ - /* _af_debug_disable_horz_hints */ - /* _af_debug_disable_vert_hints */ - /* _af_debug_disable_blue_hints */ - /* */ - /* Additionally, the following functions provide dumps of various */ - /* internal autofit structures to stdout (using `printf'): */ - /* */ - /* af_glyph_hints_dump_points */ - /* af_glyph_hints_dump_segments */ - /* af_glyph_hints_dump_edges */ - /* af_glyph_hints_get_num_segments */ - /* af_glyph_hints_get_segment_offset */ - /* */ - /* As an argument, they use another global variable: */ - /* */ - /* _af_debug_hints */ - /* */ - /* Please have a look at the `ftgrid' demo program to see how those */ - /* variables and macros should be used. */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ + /************************************************************************** + * + * Autofitter debugging + * + * If `FT_DEBUG_AUTOFIT` is defined, FreeType provides some means to + * control the autofitter behaviour for debugging purposes with global + * boolean variables (consequently, you should **never** enable this + * while compiling in 'release' mode): + * + * ``` + * _af_debug_disable_horz_hints + * _af_debug_disable_vert_hints + * _af_debug_disable_blue_hints + * ``` + * + * Additionally, the following functions provide dumps of various + * internal autofit structures to stdout (using `printf`): + * + * ``` + * af_glyph_hints_dump_points + * af_glyph_hints_dump_segments + * af_glyph_hints_dump_edges + * af_glyph_hints_get_num_segments + * af_glyph_hints_get_segment_offset + * ``` + * + * As an argument, they use another global variable: + * + * ``` + * _af_debug_hints + * ``` + * + * Please have a look at the `ftgrid` demo program to see how those + * variables and macros should be used. + * + * Do not `#undef` these macros here since the build system might define + * them for certain configurations only. + */ /* #define FT_DEBUG_AUTOFIT */ - /*************************************************************************/ - /* */ - /* Memory Debugging */ - /* */ - /* FreeType now comes with an integrated memory debugger that is */ - /* capable of detecting simple errors like memory leaks or double */ - /* deletes. To compile it within your build of the library, you */ - /* should define FT_DEBUG_MEMORY here. */ - /* */ - /* Note that the memory debugger is only activated at runtime when */ - /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ + /************************************************************************** + * + * Memory Debugging + * + * FreeType now comes with an integrated memory debugger that is capable + * of detecting simple errors like memory leaks or double deletes. To + * compile it within your build of the library, you should define + * `FT_DEBUG_MEMORY` here. + * + * Note that the memory debugger is only activated at runtime when when + * the _environment_ variable `FT2_DEBUG_MEMORY` is defined also! + * + * Do not `#undef` this macro here since the build system might define it + * for certain configurations only. + */ /* #define FT_DEBUG_MEMORY */ - /*************************************************************************/ - /* */ - /* Module errors */ - /* */ - /* If this macro is set (which is _not_ the default), the higher byte */ - /* of an error code gives the module in which the error has occurred, */ - /* while the lower byte is the real error code. */ - /* */ - /* Setting this macro makes sense for debugging purposes only, since */ - /* it would break source compatibility of certain programs that use */ - /* FreeType 2. */ - /* */ - /* More details can be found in the files ftmoderr.h and fterrors.h. */ - /* */ + /************************************************************************** + * + * Module errors + * + * If this macro is set (which is _not_ the default), the higher byte of + * an error code gives the module in which the error has occurred, while + * the lower byte is the real error code. + * + * Setting this macro makes sense for debugging purposes only, since it + * would break source compatibility of certain programs that use + * FreeType~2. + * + * More details can be found in the files `ftmoderr.h` and `fterrors.h`. + */ #undef FT_CONFIG_OPTION_USE_MODULE_ERRORS - /*************************************************************************/ - /* */ - /* Position Independent Code */ - /* */ - /* If this macro is set (which is _not_ the default), FreeType2 will */ - /* avoid creating constants that require address fixups. Instead the */ - /* constants will be moved into a struct and additional intialization */ - /* code will be used. */ - /* */ - /* Setting this macro is needed for systems that prohibit address */ - /* fixups, such as BREW. [Note that standard compilers like gcc or */ - /* clang handle PIC generation automatically; you don't have to set */ - /* FT_CONFIG_OPTION_PIC, which is only necessary for very special */ - /* compilers.] */ - /* */ - /* Note that FT_CONFIG_OPTION_PIC support is not available for all */ - /* modules (see `modules.cfg' for a complete list). For building with */ - /* FT_CONFIG_OPTION_PIC support, do the following. */ - /* */ - /* 0. Clone the repository. */ - /* 1. Define FT_CONFIG_OPTION_PIC. */ - /* 2. Remove all subdirectories in `src' that don't have */ - /* FT_CONFIG_OPTION_PIC support. */ - /* 3. Comment out the corresponding modules in `modules.cfg'. */ - /* 4. Compile. */ - /* */ -/* #define FT_CONFIG_OPTION_PIC */ + /************************************************************************** + * + * Error Strings + * + * If this macro is set, `FT_Error_String` will return meaningful + * descriptions. This is not enabled by default to reduce the overall + * size of FreeType. + * + * More details can be found in the file `fterrors.h`. + */ +/* #define FT_CONFIG_OPTION_ERROR_STRINGS */ /*************************************************************************/ @@ -524,50 +515,60 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ - /* embedded bitmaps in all formats using the SFNT module (namely */ - /* TrueType & OpenType). */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_EMBEDDED_BITMAPS` if you want to support + * embedded bitmaps in all formats using the 'sfnt' module (namely + * TrueType~& OpenType). + */ #define TT_CONFIG_OPTION_EMBEDDED_BITMAPS - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ - /* load and enumerate the glyph Postscript names in a TrueType or */ - /* OpenType file. */ - /* */ - /* Note that when you do not compile the `PSNames' module by undefining */ - /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ - /* contain additional code used to read the PS Names table from a font. */ - /* */ - /* (By default, the module uses `PSNames' to extract glyph names.) */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_COLOR_LAYERS` if you want to support coloured + * outlines (from the 'COLR'/'CPAL' tables) in all formats using the 'sfnt' + * module (namely TrueType~& OpenType). + */ +#define TT_CONFIG_OPTION_COLOR_LAYERS + + + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_POSTSCRIPT_NAMES` if you want to be able to + * load and enumerate the glyph Postscript names in a TrueType or OpenType + * file. + * + * Note that when you do not compile the 'psnames' module by undefining the + * above `FT_CONFIG_OPTION_POSTSCRIPT_NAMES`, the 'sfnt' module will + * contain additional code used to read the PS Names table from a font. + * + * (By default, the module uses 'psnames' to extract glyph names.) + */ #define TT_CONFIG_OPTION_POSTSCRIPT_NAMES - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ - /* access the internal name table in a SFNT-based format like TrueType */ - /* or OpenType. The name table contains various strings used to */ - /* describe the font, like family name, copyright, version, etc. It */ - /* does not contain any glyph name though. */ - /* */ - /* Accessing SFNT names is done through the functions declared in */ - /* `ftsnames.h'. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_SFNT_NAMES` if your applications need to access + * the internal name table in a SFNT-based format like TrueType or + * OpenType. The name table contains various strings used to describe the + * font, like family name, copyright, version, etc. It does not contain + * any glyph name though. + * + * Accessing SFNT names is done through the functions declared in + * `ftsnames.h`. + */ #define TT_CONFIG_OPTION_SFNT_NAMES - /*************************************************************************/ - /* */ - /* TrueType CMap support */ - /* */ - /* Here you can fine-tune which TrueType CMap table format shall be */ - /* supported. */ + /************************************************************************** + * + * TrueType CMap support + * + * Here you can fine-tune which TrueType CMap table format shall be + * supported. + */ #define TT_CONFIG_CMAP_FORMAT_0 #define TT_CONFIG_CMAP_FORMAT_2 #define TT_CONFIG_CMAP_FORMAT_4 @@ -587,131 +588,130 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ - /* a bytecode interpreter in the TrueType driver. */ - /* */ - /* By undefining this, you will only compile the code necessary to load */ - /* TrueType glyphs without hinting. */ - /* */ - /* Do not #undef this macro here, since the build system might */ - /* define it for certain configurations only. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` if you want to compile a + * bytecode interpreter in the TrueType driver. + * + * By undefining this, you will only compile the code necessary to load + * TrueType glyphs without hinting. + * + * Do not `#undef` this macro here, since the build system might define it + * for certain configurations only. + */ #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ - /* subpixel hinting support into the TrueType driver. This modifies the */ - /* TrueType hinting mechanism when anything but FT_RENDER_MODE_MONO is */ - /* requested. */ - /* */ - /* In particular, it modifies the bytecode interpreter to interpret (or */ - /* not) instructions in a certain way so that all TrueType fonts look */ - /* like they do in a Windows ClearType (DirectWrite) environment. See */ - /* [1] for a technical overview on what this means. See `ttinterp.h' */ - /* for more details on the LEAN option. */ - /* */ - /* There are three possible values. */ - /* */ - /* Value 1: */ - /* This value is associated with the `Infinality' moniker, */ - /* contributed by an individual nicknamed Infinality with the goal of */ - /* making TrueType fonts render better than on Windows. A high */ - /* amount of configurability and flexibility, down to rules for */ - /* single glyphs in fonts, but also very slow. Its experimental and */ - /* slow nature and the original developer losing interest meant that */ - /* this option was never enabled in default builds. */ - /* */ - /* The corresponding interpreter version is v38. */ - /* */ - /* Value 2: */ - /* The new default mode for the TrueType driver. The Infinality code */ - /* base was stripped to the bare minimum and all configurability */ - /* removed in the name of speed and simplicity. The configurability */ - /* was mainly aimed at legacy fonts like Arial, Times New Roman, or */ - /* Courier. Legacy fonts are fonts that modify vertical stems to */ - /* achieve clean black-and-white bitmaps. The new mode focuses on */ - /* applying a minimal set of rules to all fonts indiscriminately so */ - /* that modern and web fonts render well while legacy fonts render */ - /* okay. */ - /* */ - /* The corresponding interpreter version is v40. */ - /* */ - /* Value 3: */ - /* Compile both, making both v38 and v40 available (the latter is the */ - /* default). */ - /* */ - /* By undefining these, you get rendering behavior like on Windows */ - /* without ClearType, i.e., Windows XP without ClearType enabled and */ - /* Win9x (interpreter version v35). Or not, depending on how much */ - /* hinting blood and testing tears the font designer put into a given */ - /* font. If you define one or both subpixel hinting options, you can */ - /* switch between between v35 and the ones you define (using */ - /* `FT_Property_Set'). */ - /* */ - /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ - /* defined. */ - /* */ - /* [1] https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_SUBPIXEL_HINTING` if you want to compile + * subpixel hinting support into the TrueType driver. This modifies the + * TrueType hinting mechanism when anything but `FT_RENDER_MODE_MONO` is + * requested. + * + * In particular, it modifies the bytecode interpreter to interpret (or + * not) instructions in a certain way so that all TrueType fonts look like + * they do in a Windows ClearType (DirectWrite) environment. See [1] for a + * technical overview on what this means. See `ttinterp.h` for more + * details on the LEAN option. + * + * There are three possible values. + * + * Value 1: + * This value is associated with the 'Infinality' moniker, contributed by + * an individual nicknamed Infinality with the goal of making TrueType + * fonts render better than on Windows. A high amount of configurability + * and flexibility, down to rules for single glyphs in fonts, but also + * very slow. Its experimental and slow nature and the original + * developer losing interest meant that this option was never enabled in + * default builds. + * + * The corresponding interpreter version is v38. + * + * Value 2: + * The new default mode for the TrueType driver. The Infinality code + * base was stripped to the bare minimum and all configurability removed + * in the name of speed and simplicity. The configurability was mainly + * aimed at legacy fonts like 'Arial', 'Times New Roman', or 'Courier'. + * Legacy fonts are fonts that modify vertical stems to achieve clean + * black-and-white bitmaps. The new mode focuses on applying a minimal + * set of rules to all fonts indiscriminately so that modern and web + * fonts render well while legacy fonts render okay. + * + * The corresponding interpreter version is v40. + * + * Value 3: + * Compile both, making both v38 and v40 available (the latter is the + * default). + * + * By undefining these, you get rendering behavior like on Windows without + * ClearType, i.e., Windows XP without ClearType enabled and Win9x + * (interpreter version v35). Or not, depending on how much hinting blood + * and testing tears the font designer put into a given font. If you + * define one or both subpixel hinting options, you can switch between + * between v35 and the ones you define (using `FT_Property_Set`). + * + * This option requires `TT_CONFIG_OPTION_BYTECODE_INTERPRETER` to be + * defined. + * + * [1] + * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx + */ /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */ #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2 /* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */ - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ - /* TrueType glyph loader to use Apple's definition of how to handle */ - /* component offsets in composite glyphs. */ - /* */ - /* Apple and MS disagree on the default behavior of component offsets */ - /* in composites. Apple says that they should be scaled by the scaling */ - /* factors in the transformation matrix (roughly, it's more complex) */ - /* while MS says they should not. OpenType defines two bits in the */ - /* composite flags array which can be used to disambiguate, but old */ - /* fonts will not have them. */ - /* */ - /* https://www.microsoft.com/typography/otspec/glyf.htm */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED` to compile the + * TrueType glyph loader to use Apple's definition of how to handle + * component offsets in composite glyphs. + * + * Apple and MS disagree on the default behavior of component offsets in + * composites. Apple says that they should be scaled by the scaling + * factors in the transformation matrix (roughly, it's more complex) while + * MS says they should not. OpenType defines two bits in the composite + * flags array which can be used to disambiguate, but old fonts will not + * have them. + * + * https://www.microsoft.com/typography/otspec/glyf.htm + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html + */ #undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ - /* support for Apple's distortable font technology (fvar, gvar, cvar, */ - /* and avar tables). This has many similarities to Type 1 Multiple */ - /* Masters support. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_GX_VAR_SUPPORT` if you want to include support + * for Apple's distortable font technology ('fvar', 'gvar', 'cvar', and + * 'avar' tables). Tagged 'Font Variations', this is now part of OpenType + * also. This has many similarities to Type~1 Multiple Masters support. + */ #define TT_CONFIG_OPTION_GX_VAR_SUPPORT - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ - /* an embedded `BDF ' table within SFNT-based bitmap formats. */ - /* */ + /************************************************************************** + * + * Define `TT_CONFIG_OPTION_BDF` if you want to include support for an + * embedded 'BDF~' table within SFNT-based bitmap formats. + */ #define TT_CONFIG_OPTION_BDF - /*************************************************************************/ - /* */ - /* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */ - /* number of bytecode instructions executed for a single run of the */ - /* bytecode interpreter, needed to prevent infinite loops. You don't */ - /* want to change this except for very special situations (e.g., making */ - /* a library fuzzer spend less time to handle broken fonts). */ - /* */ - /* It is not expected that this value is ever modified by a configuring */ - /* script; instead, it gets surrounded with #ifndef ... #endif so that */ - /* the value can be set as a preprocessor option on the compiler's */ - /* command line. */ - /* */ + /************************************************************************** + * + * Option `TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES` controls the maximum + * number of bytecode instructions executed for a single run of the + * bytecode interpreter, needed to prevent infinite loops. You don't want + * to change this except for very special situations (e.g., making a + * library fuzzer spend less time to handle broken fonts). + * + * It is not expected that this value is ever modified by a configuring + * script; instead, it gets surrounded with `#ifndef ... #endif` so that + * the value can be set as a preprocessor option on the compiler's command + * line. + */ #ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES #define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L #endif @@ -726,59 +726,58 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ - /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ - /* required. */ - /* */ + /************************************************************************** + * + * `T1_MAX_DICT_DEPTH` is the maximum depth of nest dictionaries and arrays + * in the Type~1 stream (see `t1load.c`). A minimum of~4 is required. + */ #define T1_MAX_DICT_DEPTH 5 - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ + /************************************************************************** + * + * `T1_MAX_SUBRS_CALLS` details the maximum number of nested sub-routine + * calls during glyph loading. + */ #define T1_MAX_SUBRS_CALLS 16 - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ - /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ - /* */ + /************************************************************************** + * + * `T1_MAX_CHARSTRING_OPERANDS` is the charstring stack's capacity. A + * minimum of~16 is required. + * + * The Chinese font 'MingTiEG-Medium' (covering the CNS 11643 character + * set) needs 256. + */ #define T1_MAX_CHARSTRINGS_OPERANDS 256 - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ - /* files into an existing face. Note that if set, the T1 driver will be */ - /* unable to produce kerning distances. */ - /* */ + /************************************************************************** + * + * Define this configuration macro if you want to prevent the compilation + * of the 't1afm' module, which is in charge of reading Type~1 AFM files + * into an existing face. Note that if set, the Type~1 driver will be + * unable to produce kerning distances. + */ #undef T1_CONFIG_OPTION_NO_AFM - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of the Multiple Masters font support in the Type 1 */ - /* driver. */ - /* */ + /************************************************************************** + * + * Define this configuration macro if you want to prevent the compilation + * of the Multiple Masters font support in the Type~1 driver. + */ #undef T1_CONFIG_OPTION_NO_MM_SUPPORT - /*************************************************************************/ - /* */ - /* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */ - /* engine gets compiled into FreeType. If defined, it is possible to */ - /* switch between the two engines using the `hinting-engine' property of */ - /* the type1 driver module. */ - /* */ + /************************************************************************** + * + * `T1_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe Type~1 + * engine gets compiled into FreeType. If defined, it is possible to + * switch between the two engines using the `hinting-engine` property of + * the 'type1' driver module. + */ /* #define T1_CONFIG_OPTION_OLD_ENGINE */ @@ -791,17 +790,16 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */ - /* possible to set up the default values of the four control points that */ - /* define the stem darkening behaviour of the (new) CFF engine. For */ - /* more details please read the documentation of the */ - /* `darkening-parameters' property (file `ftdriver.h'), which allows the */ - /* control at run-time. */ - /* */ - /* Do *not* undefine these macros! */ - /* */ + /************************************************************************** + * + * Using `CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4}` it is + * possible to set up the default values of the four control points that + * define the stem darkening behaviour of the (new) CFF engine. For more + * details please read the documentation of the `darkening-parameters` + * property (file `ftdriver.h`), which allows the control at run-time. + * + * Do **not** undefine these macros! + */ #define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 #define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 @@ -815,13 +813,13 @@ FT_BEGIN_HEADER #define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 - /*************************************************************************/ - /* */ - /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ - /* engine gets compiled into FreeType. If defined, it is possible to */ - /* switch between the two engines using the `hinting-engine' property of */ - /* the cff driver module. */ - /* */ + /************************************************************************** + * + * `CFF_CONFIG_OPTION_OLD_ENGINE` controls whether the pre-Adobe CFF engine + * gets compiled into FreeType. If defined, it is possible to switch + * between the two engines using the `hinting-engine` property of the 'cff' + * driver module. + */ /* #define CFF_CONFIG_OPTION_OLD_ENGINE */ @@ -834,21 +832,21 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* There are many PCF fonts just called `Fixed' which look completely */ - /* different, and which have nothing to do with each other. When */ - /* selecting `Fixed' in KDE or Gnome one gets results that appear rather */ - /* random, the style changes often if one changes the size and one */ - /* cannot select some fonts at all. This option makes the PCF module */ - /* prepend the foundry name (plus a space) to the family name. */ - /* */ - /* We also check whether we have `wide' characters; all put together, we */ - /* get family names like `Sony Fixed' or `Misc Fixed Wide'. */ - /* */ - /* If this option is activated, it can be controlled with the */ - /* `no-long-family-names' property of the pcf driver module. */ - /* */ + /************************************************************************** + * + * There are many PCF fonts just called 'Fixed' which look completely + * different, and which have nothing to do with each other. When selecting + * 'Fixed' in KDE or Gnome one gets results that appear rather random, the + * style changes often if one changes the size and one cannot select some + * fonts at all. This option makes the 'pcf' module prepend the foundry + * name (plus a space) to the family name. + * + * We also check whether we have 'wide' characters; all put together, we + * get family names like 'Sony Fixed' or 'Misc Fixed Wide'. + * + * If this option is activated, it can be controlled with the + * `no-long-family-names` property of the 'pcf' driver module. + */ /* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */ @@ -861,69 +859,76 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ - /* support. */ - /* */ + /************************************************************************** + * + * Compile 'autofit' module with CJK (Chinese, Japanese, Korean) script + * support. + */ #define AF_CONFIG_OPTION_CJK - /*************************************************************************/ - /* */ - /* Compile autofit module with fallback Indic script support, covering */ - /* some scripts that the `latin' submodule of the autofit module doesn't */ - /* (yet) handle. */ - /* */ + + /************************************************************************** + * + * Compile 'autofit' module with fallback Indic script support, covering + * some scripts that the 'latin' submodule of the 'autofit' module doesn't + * (yet) handle. + */ #define AF_CONFIG_OPTION_INDIC - /*************************************************************************/ - /* */ - /* Compile autofit module with warp hinting. The idea of the warping */ - /* code is to slightly scale and shift a glyph within a single dimension */ - /* so that as much of its segments are aligned (more or less) on the */ - /* grid. To find out the optimal scaling and shifting value, various */ - /* parameter combinations are tried and scored. */ - /* */ - /* This experimental option is active only if the rendering mode is */ - /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */ - /* `warping' property of the auto-hinter (see file `ftdriver.h' for more */ - /* information; by default it is switched off). */ - /* */ + + /************************************************************************** + * + * Compile 'autofit' module with warp hinting. The idea of the warping + * code is to slightly scale and shift a glyph within a single dimension so + * that as much of its segments are aligned (more or less) on the grid. To + * find out the optimal scaling and shifting value, various parameter + * combinations are tried and scored. + * + * You can switch warping on and off with the `warping` property of the + * auto-hinter (see file `ftdriver.h` for more information; by default it + * is switched off). + * + * This experimental option is not active if the rendering mode is + * `FT_RENDER_MODE_LIGHT`. + */ #define AF_CONFIG_OPTION_USE_WARPER - /*************************************************************************/ - /* */ - /* Use TrueType-like size metrics for `light' auto-hinting. */ - /* */ - /* It is strongly recommended to avoid this option, which exists only to */ - /* help some legacy applications retain its appearance and behaviour */ - /* with respect to auto-hinted TrueType fonts. */ - /* */ - /* The very reason this option exists at all are GNU/Linux distributions */ - /* like Fedora that did not un-patch the following change (which was */ - /* present in FreeType between versions 2.4.6 and 2.7.1, inclusive). */ - /* */ - /* 2011-07-16 Steven Chu <steven.f.chu@gmail.com> */ - /* */ - /* [truetype] Fix metrics on size request for scalable fonts. */ - /* */ - /* This problematic commit is now reverted (more or less). */ - /* */ + + /************************************************************************** + * + * Use TrueType-like size metrics for 'light' auto-hinting. + * + * It is strongly recommended to avoid this option, which exists only to + * help some legacy applications retain its appearance and behaviour with + * respect to auto-hinted TrueType fonts. + * + * The very reason this option exists at all are GNU/Linux distributions + * like Fedora that did not un-patch the following change (which was + * present in FreeType between versions 2.4.6 and 2.7.1, inclusive). + * + * ``` + * 2011-07-16 Steven Chu <steven.f.chu@gmail.com> + * + * [truetype] Fix metrics on size request for scalable fonts. + * ``` + * + * This problematic commit is now reverted (more or less). + */ /* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */ /* */ /* - * This macro is obsolete. Support has been removed in FreeType - * version 2.5. + * This macro is obsolete. Support has been removed in FreeType version + * 2.5. */ /* #define FT_CONFIG_OPTION_OLD_INTERNALS */ /* - * This macro is defined if native TrueType hinting is requested by the - * definitions above. + * The next three macros are defined if native TrueType hinting is + * requested by the definitions above. Don't change this. */ #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER #define TT_USE_BYTECODE_INTERPRETER @@ -942,7 +947,7 @@ FT_BEGIN_HEADER /* * Check CFF darkening parameters. The checks are the same as in function - * `cff_property_set' in file `cffdrivr.c'. + * `cff_property_set` in file `cffdrivr.c`. */ #if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ diff --git a/src/3rdparty/freetype/include/freetype/config/ftstdlib.h b/src/3rdparty/freetype/include/freetype/config/ftstdlib.h index 42f9a06e43..438b6145d5 100644 --- a/src/3rdparty/freetype/include/freetype/config/ftstdlib.h +++ b/src/3rdparty/freetype/include/freetype/config/ftstdlib.h @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* ftstdlib.h */ -/* */ -/* ANSI-specific library and header configuration file (specification */ -/* only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to group all #includes to the ANSI C library that */ - /* FreeType normally requires. It also defines macros to rename the */ - /* standard functions within the FreeType source code. */ - /* */ - /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftstdlib.h + * + * ANSI-specific library and header configuration file (specification + * only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to group all `#includes` to the ANSI~C library that + * FreeType normally requires. It also defines macros to rename the + * standard functions within the FreeType source code. + * + * Load a file which defines `FTSTDLIB_H_` before this one to override it. + * + */ #ifndef FTSTDLIB_H_ @@ -37,23 +37,23 @@ #define ft_ptrdiff_t ptrdiff_t - /**********************************************************************/ - /* */ - /* integer limits */ - /* */ - /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ - /* of `int' and `long' in bytes at compile-time. So far, this works */ - /* for all platforms the library has been tested on. */ - /* */ - /* Note that on the extremely rare platforms that do not provide */ - /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ - /* old Crays where `int' is 36 bits), we do not make any guarantee */ - /* about the correct behaviour of FT2 with all fonts. */ - /* */ - /* In these case, `ftconfig.h' will refuse to compile anyway with a */ - /* message like `couldn't find 32-bit type' or something similar. */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * integer limits + * + * `UINT_MAX` and `ULONG_MAX` are used to automatically compute the size of + * `int` and `long` in bytes at compile-time. So far, this works for all + * platforms the library has been tested on. + * + * Note that on the extremely rare platforms that do not provide integer + * types that are _exactly_ 16 and 32~bits wide (e.g., some old Crays where + * `int` is 36~bits), we do not make any guarantee about the correct + * behaviour of FreeType~2 with all fonts. + * + * In these cases, `ftconfig.h` will refuse to compile anyway with a + * message like 'couldn't find 32-bit type' or something similar. + * + */ #include <limits.h> @@ -68,11 +68,11 @@ #define FT_ULONG_MAX ULONG_MAX - /**********************************************************************/ - /* */ - /* character and string processing */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * character and string processing + * + */ #include <string.h> @@ -92,11 +92,11 @@ #define ft_strstr strstr - /**********************************************************************/ - /* */ - /* file handling */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * file handling + * + */ #include <stdio.h> @@ -110,11 +110,11 @@ #define ft_sprintf sprintf - /**********************************************************************/ - /* */ - /* sorting */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * sorting + * + */ #include <stdlib.h> @@ -122,11 +122,11 @@ #define ft_qsort qsort - /**********************************************************************/ - /* */ - /* memory allocation */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * memory allocation + * + */ #define ft_scalloc calloc @@ -135,36 +135,36 @@ #define ft_srealloc realloc - /**********************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * miscellaneous + * + */ #define ft_strtol strtol #define ft_getenv getenv - /**********************************************************************/ - /* */ - /* execution control */ - /* */ - /**********************************************************************/ + /************************************************************************** + * + * execution control + * + */ #include <setjmp.h> -#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ - /* jmp_buf is defined as a macro */ - /* on certain platforms */ +#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ + /* `jmp_buf` is defined as a macro */ + /* on certain platforms */ #define ft_longjmp longjmp #define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ - /* the following is only used for debugging purposes, i.e., if */ - /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ + /* The following is only used for debugging purposes, i.e., if */ + /* `FT_DEBUG_LEVEL_ERROR` or `FT_DEBUG_LEVEL_TRACE` are defined. */ #include <stdarg.h> diff --git a/src/3rdparty/freetype/include/freetype/freetype.h b/src/3rdparty/freetype/include/freetype/freetype.h index 96644046e4..a6bb667e3a 100644 --- a/src/3rdparty/freetype/include/freetype/freetype.h +++ b/src/3rdparty/freetype/include/freetype/freetype.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* freetype.h */ -/* */ -/* FreeType high-level API and common types (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * freetype.h + * + * FreeType high-level API and common types (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FREETYPE_H_ @@ -39,56 +39,55 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* header_inclusion */ - /* */ - /* <Title> */ - /* FreeType's header inclusion scheme */ - /* */ - /* <Abstract> */ - /* How client applications should include FreeType header files. */ - /* */ - /* <Description> */ - /* To be as flexible as possible (and for historical reasons), */ - /* FreeType uses a very special inclusion scheme to load header */ - /* files, for example */ - /* */ - /* { */ - /* #include <ft2build.h> */ - /* */ - /* #include FT_FREETYPE_H */ - /* #include FT_OUTLINE_H */ - /* } */ - /* */ - /* A compiler and its preprocessor only needs an include path to find */ - /* the file `ft2build.h'; the exact locations and names of the other */ - /* FreeType header files are hidden by preprocessor macro names, */ - /* loaded by `ft2build.h'. The API documentation always gives the */ - /* header macro name needed for a particular function. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * header_inclusion + * + * @title: + * FreeType's header inclusion scheme + * + * @abstract: + * How client applications should include FreeType header files. + * + * @description: + * To be as flexible as possible (and for historical reasons), FreeType + * uses a very special inclusion scheme to load header files, for example + * + * ``` + * #include <ft2build.h> + * + * #include FT_FREETYPE_H + * #include FT_OUTLINE_H + * ``` + * + * A compiler and its preprocessor only needs an include path to find the + * file `ft2build.h`; the exact locations and names of the other FreeType + * header files are hidden by @header_file_macros, loaded by + * `ft2build.h`. The API documentation always gives the header macro + * name needed for a particular function. + * + */ - /*************************************************************************/ - /* */ - /* <Section> */ - /* user_allocation */ - /* */ - /* <Title> */ - /* User allocation */ - /* */ - /* <Abstract> */ - /* How client applications should allocate FreeType data structures. */ - /* */ - /* <Description> */ - /* FreeType assumes that structures allocated by the user and passed */ - /* as arguments are zeroed out except for the actual data. In other */ - /* words, it is recommended to use `calloc' (or variants of it) */ - /* instead of `malloc' for allocation. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * user_allocation + * + * @title: + * User allocation + * + * @abstract: + * How client applications should allocate FreeType data structures. + * + * @description: + * FreeType assumes that structures allocated by the user and passed as + * arguments are zeroed out except for the actual data. In other words, + * it is recommended to use `calloc` (or variants of it) instead of + * `malloc` for allocation. + * + */ @@ -101,219 +100,219 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /* <Title> */ - /* Base Interface */ - /* */ - /* <Abstract> */ - /* The FreeType~2 base font interface. */ - /* */ - /* <Description> */ - /* This section describes the most important public high-level API */ - /* functions of FreeType~2. */ - /* */ - /* <Order> */ - /* FT_Library */ - /* FT_Face */ - /* FT_Size */ - /* FT_GlyphSlot */ - /* FT_CharMap */ - /* FT_Encoding */ - /* FT_ENC_TAG */ - /* */ - /* FT_FaceRec */ - /* */ - /* FT_FACE_FLAG_SCALABLE */ - /* FT_FACE_FLAG_FIXED_SIZES */ - /* FT_FACE_FLAG_FIXED_WIDTH */ - /* FT_FACE_FLAG_HORIZONTAL */ - /* FT_FACE_FLAG_VERTICAL */ - /* FT_FACE_FLAG_COLOR */ - /* FT_FACE_FLAG_SFNT */ - /* FT_FACE_FLAG_CID_KEYED */ - /* FT_FACE_FLAG_TRICKY */ - /* FT_FACE_FLAG_KERNING */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS */ - /* FT_FACE_FLAG_VARIATION */ - /* FT_FACE_FLAG_GLYPH_NAMES */ - /* FT_FACE_FLAG_EXTERNAL_STREAM */ - /* FT_FACE_FLAG_HINTER */ - /* */ - /* FT_HAS_HORIZONTAL */ - /* FT_HAS_VERTICAL */ - /* FT_HAS_KERNING */ - /* FT_HAS_FIXED_SIZES */ - /* FT_HAS_GLYPH_NAMES */ - /* FT_HAS_COLOR */ - /* FT_HAS_MULTIPLE_MASTERS */ - /* */ - /* FT_IS_SFNT */ - /* FT_IS_SCALABLE */ - /* FT_IS_FIXED_WIDTH */ - /* FT_IS_CID_KEYED */ - /* FT_IS_TRICKY */ - /* FT_IS_NAMED_INSTANCE */ - /* FT_IS_VARIATION */ - /* */ - /* FT_STYLE_FLAG_BOLD */ - /* FT_STYLE_FLAG_ITALIC */ - /* */ - /* FT_SizeRec */ - /* FT_Size_Metrics */ - /* */ - /* FT_GlyphSlotRec */ - /* FT_Glyph_Metrics */ - /* FT_SubGlyph */ - /* */ - /* FT_Bitmap_Size */ - /* */ - /* FT_Init_FreeType */ - /* FT_Done_FreeType */ - /* */ - /* FT_New_Face */ - /* FT_Done_Face */ - /* FT_Reference_Face */ - /* FT_New_Memory_Face */ - /* FT_Face_Properties */ - /* FT_Open_Face */ - /* FT_Open_Args */ - /* FT_Parameter */ - /* FT_Attach_File */ - /* FT_Attach_Stream */ - /* */ - /* FT_Set_Char_Size */ - /* FT_Set_Pixel_Sizes */ - /* FT_Request_Size */ - /* FT_Select_Size */ - /* FT_Size_Request_Type */ - /* FT_Size_RequestRec */ - /* FT_Size_Request */ - /* FT_Set_Transform */ - /* FT_Load_Glyph */ - /* FT_Get_Char_Index */ - /* FT_Get_First_Char */ - /* FT_Get_Next_Char */ - /* FT_Get_Name_Index */ - /* FT_Load_Char */ - /* */ - /* FT_OPEN_MEMORY */ - /* FT_OPEN_STREAM */ - /* FT_OPEN_PATHNAME */ - /* FT_OPEN_DRIVER */ - /* FT_OPEN_PARAMS */ - /* */ - /* FT_LOAD_DEFAULT */ - /* FT_LOAD_RENDER */ - /* FT_LOAD_MONOCHROME */ - /* FT_LOAD_LINEAR_DESIGN */ - /* FT_LOAD_NO_SCALE */ - /* FT_LOAD_NO_HINTING */ - /* FT_LOAD_NO_BITMAP */ - /* FT_LOAD_NO_AUTOHINT */ - /* FT_LOAD_COLOR */ - /* */ - /* FT_LOAD_VERTICAL_LAYOUT */ - /* FT_LOAD_IGNORE_TRANSFORM */ - /* FT_LOAD_FORCE_AUTOHINT */ - /* FT_LOAD_NO_RECURSE */ - /* FT_LOAD_PEDANTIC */ - /* */ - /* FT_LOAD_TARGET_NORMAL */ - /* FT_LOAD_TARGET_LIGHT */ - /* FT_LOAD_TARGET_MONO */ - /* FT_LOAD_TARGET_LCD */ - /* FT_LOAD_TARGET_LCD_V */ - /* */ - /* FT_LOAD_TARGET_MODE */ - /* */ - /* FT_Render_Glyph */ - /* FT_Render_Mode */ - /* FT_Get_Kerning */ - /* FT_Kerning_Mode */ - /* FT_Get_Track_Kerning */ - /* FT_Get_Glyph_Name */ - /* FT_Get_Postscript_Name */ - /* */ - /* FT_CharMapRec */ - /* FT_Select_Charmap */ - /* FT_Set_Charmap */ - /* FT_Get_Charmap_Index */ - /* */ - /* FT_Get_FSType_Flags */ - /* FT_Get_SubGlyph_Info */ - /* */ - /* FT_Face_Internal */ - /* FT_Size_Internal */ - /* FT_Slot_Internal */ - /* */ - /* FT_FACE_FLAG_XXX */ - /* FT_STYLE_FLAG_XXX */ - /* FT_OPEN_XXX */ - /* FT_LOAD_XXX */ - /* FT_LOAD_TARGET_XXX */ - /* FT_SUBGLYPH_FLAG_XXX */ - /* FT_FSTYPE_XXX */ - /* */ - /* FT_HAS_FAST_GLYPHS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * base_interface + * + * @title: + * Base Interface + * + * @abstract: + * The FreeType~2 base font interface. + * + * @description: + * This section describes the most important public high-level API + * functions of FreeType~2. + * + * @order: + * FT_Library + * FT_Face + * FT_Size + * FT_GlyphSlot + * FT_CharMap + * FT_Encoding + * FT_ENC_TAG + * + * FT_FaceRec + * + * FT_FACE_FLAG_SCALABLE + * FT_FACE_FLAG_FIXED_SIZES + * FT_FACE_FLAG_FIXED_WIDTH + * FT_FACE_FLAG_HORIZONTAL + * FT_FACE_FLAG_VERTICAL + * FT_FACE_FLAG_COLOR + * FT_FACE_FLAG_SFNT + * FT_FACE_FLAG_CID_KEYED + * FT_FACE_FLAG_TRICKY + * FT_FACE_FLAG_KERNING + * FT_FACE_FLAG_MULTIPLE_MASTERS + * FT_FACE_FLAG_VARIATION + * FT_FACE_FLAG_GLYPH_NAMES + * FT_FACE_FLAG_EXTERNAL_STREAM + * FT_FACE_FLAG_HINTER + * + * FT_HAS_HORIZONTAL + * FT_HAS_VERTICAL + * FT_HAS_KERNING + * FT_HAS_FIXED_SIZES + * FT_HAS_GLYPH_NAMES + * FT_HAS_COLOR + * FT_HAS_MULTIPLE_MASTERS + * + * FT_IS_SFNT + * FT_IS_SCALABLE + * FT_IS_FIXED_WIDTH + * FT_IS_CID_KEYED + * FT_IS_TRICKY + * FT_IS_NAMED_INSTANCE + * FT_IS_VARIATION + * + * FT_STYLE_FLAG_BOLD + * FT_STYLE_FLAG_ITALIC + * + * FT_SizeRec + * FT_Size_Metrics + * + * FT_GlyphSlotRec + * FT_Glyph_Metrics + * FT_SubGlyph + * + * FT_Bitmap_Size + * + * FT_Init_FreeType + * FT_Done_FreeType + * + * FT_New_Face + * FT_Done_Face + * FT_Reference_Face + * FT_New_Memory_Face + * FT_Face_Properties + * FT_Open_Face + * FT_Open_Args + * FT_Parameter + * FT_Attach_File + * FT_Attach_Stream + * + * FT_Set_Char_Size + * FT_Set_Pixel_Sizes + * FT_Request_Size + * FT_Select_Size + * FT_Size_Request_Type + * FT_Size_RequestRec + * FT_Size_Request + * FT_Set_Transform + * FT_Load_Glyph + * FT_Get_Char_Index + * FT_Get_First_Char + * FT_Get_Next_Char + * FT_Get_Name_Index + * FT_Load_Char + * + * FT_OPEN_MEMORY + * FT_OPEN_STREAM + * FT_OPEN_PATHNAME + * FT_OPEN_DRIVER + * FT_OPEN_PARAMS + * + * FT_LOAD_DEFAULT + * FT_LOAD_RENDER + * FT_LOAD_MONOCHROME + * FT_LOAD_LINEAR_DESIGN + * FT_LOAD_NO_SCALE + * FT_LOAD_NO_HINTING + * FT_LOAD_NO_BITMAP + * FT_LOAD_NO_AUTOHINT + * FT_LOAD_COLOR + * + * FT_LOAD_VERTICAL_LAYOUT + * FT_LOAD_IGNORE_TRANSFORM + * FT_LOAD_FORCE_AUTOHINT + * FT_LOAD_NO_RECURSE + * FT_LOAD_PEDANTIC + * + * FT_LOAD_TARGET_NORMAL + * FT_LOAD_TARGET_LIGHT + * FT_LOAD_TARGET_MONO + * FT_LOAD_TARGET_LCD + * FT_LOAD_TARGET_LCD_V + * + * FT_LOAD_TARGET_MODE + * + * FT_Render_Glyph + * FT_Render_Mode + * FT_Get_Kerning + * FT_Kerning_Mode + * FT_Get_Track_Kerning + * FT_Get_Glyph_Name + * FT_Get_Postscript_Name + * + * FT_CharMapRec + * FT_Select_Charmap + * FT_Set_Charmap + * FT_Get_Charmap_Index + * + * FT_Get_FSType_Flags + * FT_Get_SubGlyph_Info + * + * FT_Face_Internal + * FT_Size_Internal + * FT_Slot_Internal + * + * FT_FACE_FLAG_XXX + * FT_STYLE_FLAG_XXX + * FT_OPEN_XXX + * FT_LOAD_XXX + * FT_LOAD_TARGET_XXX + * FT_SUBGLYPH_FLAG_XXX + * FT_FSTYPE_XXX + * + * FT_HAS_FAST_GLYPHS + * + */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Glyph_Metrics */ - /* */ - /* <Description> */ - /* A structure to model the metrics of a single glyph. The values */ - /* are expressed in 26.6 fractional pixel format; if the flag */ - /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ - /* are expressed in font units instead. */ - /* */ - /* <Fields> */ - /* width :: */ - /* The glyph's width. */ - /* */ - /* height :: */ - /* The glyph's height. */ - /* */ - /* horiBearingX :: */ - /* Left side bearing for horizontal layout. */ - /* */ - /* horiBearingY :: */ - /* Top side bearing for horizontal layout. */ - /* */ - /* horiAdvance :: */ - /* Advance width for horizontal layout. */ - /* */ - /* vertBearingX :: */ - /* Left side bearing for vertical layout. */ - /* */ - /* vertBearingY :: */ - /* Top side bearing for vertical layout. Larger positive values */ - /* mean further below the vertical glyph origin. */ - /* */ - /* vertAdvance :: */ - /* Advance height for vertical layout. Positive values mean the */ - /* glyph has a positive advance downward. */ - /* */ - /* <Note> */ - /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ - /* dimensions of the hinted glyph (in case hinting is applicable). */ - /* */ - /* Stroking a glyph with an outside border does not increase */ - /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ - /* values to account for the added width and height. */ - /* */ - /* FreeType doesn't use the `VORG' table data for CFF fonts because */ - /* it doesn't have an interface to quickly retrieve the glyph height. */ - /* The y~coordinate of the vertical origin can be simply computed as */ - /* `vertBearingY + height' after loading a glyph. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Glyph_Metrics + * + * @description: + * A structure to model the metrics of a single glyph. The values are + * expressed in 26.6 fractional pixel format; if the flag + * @FT_LOAD_NO_SCALE has been used while loading the glyph, values are + * expressed in font units instead. + * + * @fields: + * width :: + * The glyph's width. + * + * height :: + * The glyph's height. + * + * horiBearingX :: + * Left side bearing for horizontal layout. + * + * horiBearingY :: + * Top side bearing for horizontal layout. + * + * horiAdvance :: + * Advance width for horizontal layout. + * + * vertBearingX :: + * Left side bearing for vertical layout. + * + * vertBearingY :: + * Top side bearing for vertical layout. Larger positive values mean + * further below the vertical glyph origin. + * + * vertAdvance :: + * Advance height for vertical layout. Positive values mean the glyph + * has a positive advance downward. + * + * @note: + * If not disabled with @FT_LOAD_NO_HINTING, the values represent + * dimensions of the hinted glyph (in case hinting is applicable). + * + * Stroking a glyph with an outside border does not increase + * `horiAdvance` or `vertAdvance`; you have to manually adjust these + * values to account for the added width and height. + * + * FreeType doesn't use the 'VORG' table data for CFF fonts because it + * doesn't have an interface to quickly retrieve the glyph height. The + * y~coordinate of the vertical origin can be simply computed as + * `vertBearingY + height` after loading a glyph. + */ typedef struct FT_Glyph_Metrics_ { FT_Pos width; @@ -330,44 +329,45 @@ FT_BEGIN_HEADER } FT_Glyph_Metrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap_Size */ - /* */ - /* <Description> */ - /* This structure models the metrics of a bitmap strike (i.e., a set */ - /* of glyphs for a given point size and resolution) in a bitmap font. */ - /* It is used for the `available_sizes' field of @FT_Face. */ - /* */ - /* <Fields> */ - /* height :: The vertical distance, in pixels, between two */ - /* consecutive baselines. It is always positive. */ - /* */ - /* width :: The average width, in pixels, of all glyphs in the */ - /* strike. */ - /* */ - /* size :: The nominal size of the strike in 26.6 fractional */ - /* points. This field is not very useful. */ - /* */ - /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ - /* pixels. */ - /* */ - /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ - /* pixels. */ - /* */ - /* <Note> */ - /* Windows FNT: */ - /* The nominal size given in a FNT font is not reliable. If the */ - /* driver finds it incorrect, it sets `size' to some calculated */ - /* values, and `x_ppem' and `y_ppem' to the pixel width and height */ - /* given in the font, respectively. */ - /* */ - /* TrueType embedded bitmaps: */ - /* `size', `width', and `height' values are not contained in the */ - /* bitmap strike itself. They are computed from the global font */ - /* parameters. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Bitmap_Size + * + * @description: + * This structure models the metrics of a bitmap strike (i.e., a set of + * glyphs for a given point size and resolution) in a bitmap font. It is + * used for the `available_sizes` field of @FT_Face. + * + * @fields: + * height :: + * The vertical distance, in pixels, between two consecutive baselines. + * It is always positive. + * + * width :: + * The average width, in pixels, of all glyphs in the strike. + * + * size :: + * The nominal size of the strike in 26.6 fractional points. This + * field is not very useful. + * + * x_ppem :: + * The horizontal ppem (nominal width) in 26.6 fractional pixels. + * + * y_ppem :: + * The vertical ppem (nominal height) in 26.6 fractional pixels. + * + * @note: + * Windows FNT: + * The nominal size given in a FNT font is not reliable. If the driver + * finds it incorrect, it sets `size` to some calculated values, and + * `x_ppem` and `y_ppem` to the pixel width and height given in the + * font, respectively. + * + * TrueType embedded bitmaps: + * `size`, `width`, and `height` values are not contained in the bitmap + * strike itself. They are computed from the global font parameters. + */ typedef struct FT_Bitmap_Size_ { FT_Short height; @@ -389,225 +389,218 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Library */ - /* */ - /* <Description> */ - /* A handle to a FreeType library instance. Each `library' is */ - /* completely independent from the others; it is the `root' of a set */ - /* of objects like fonts, faces, sizes, etc. */ - /* */ - /* It also embeds a memory manager (see @FT_Memory), as well as a */ - /* scan-line converter object (see @FT_Raster). */ - /* */ - /* In multi-threaded applications it is easiest to use one */ - /* `FT_Library' object per thread. In case this is too cumbersome, */ - /* a single `FT_Library' object across threads is possible also */ - /* (since FreeType version 2.5.6), as long as a mutex lock is used */ - /* around @FT_New_Face and @FT_Done_Face. */ - /* */ - /* <Note> */ - /* Library objects are normally created by @FT_Init_FreeType, and */ - /* destroyed with @FT_Done_FreeType. If you need reference-counting */ - /* (cf. @FT_Reference_Library), use @FT_New_Library and */ - /* @FT_Done_Library. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Library + * + * @description: + * A handle to a FreeType library instance. Each 'library' is completely + * independent from the others; it is the 'root' of a set of objects like + * fonts, faces, sizes, etc. + * + * It also embeds a memory manager (see @FT_Memory), as well as a + * scan-line converter object (see @FT_Raster). + * + * [Since 2.5.6] In multi-threaded applications it is easiest to use one + * `FT_Library` object per thread. In case this is too cumbersome, a + * single `FT_Library` object across threads is possible also, as long as + * a mutex lock is used around @FT_New_Face and @FT_Done_Face. + * + * @note: + * Library objects are normally created by @FT_Init_FreeType, and + * destroyed with @FT_Done_FreeType. If you need reference-counting + * (cf. @FT_Reference_Library), use @FT_New_Library and @FT_Done_Library. + */ typedef struct FT_LibraryRec_ *FT_Library; - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * module_management + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Module */ - /* */ - /* <Description> */ - /* A handle to a given FreeType module object. A module can be a */ - /* font driver, a renderer, or anything else that provides services */ - /* to the former. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Module + * + * @description: + * A handle to a given FreeType module object. A module can be a font + * driver, a renderer, or anything else that provides services to the + * former. + */ typedef struct FT_ModuleRec_* FT_Module; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Driver */ - /* */ - /* <Description> */ - /* A handle to a given FreeType font driver object. A font driver */ - /* is a module capable of creating faces from font files. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Driver + * + * @description: + * A handle to a given FreeType font driver object. A font driver is a + * module capable of creating faces from font files. + */ typedef struct FT_DriverRec_* FT_Driver; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Renderer */ - /* */ - /* <Description> */ - /* A handle to a given FreeType renderer. A renderer is a module in */ - /* charge of converting a glyph's outline image to a bitmap. It */ - /* supports a single glyph image format, and one or more target */ - /* surface depths. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Renderer + * + * @description: + * A handle to a given FreeType renderer. A renderer is a module in + * charge of converting a glyph's outline image to a bitmap. It supports + * a single glyph image format, and one or more target surface depths. + */ typedef struct FT_RendererRec_* FT_Renderer; - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * base_interface + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face */ - /* */ - /* <Description> */ - /* A handle to a typographic face object. A face object models a */ - /* given typeface, in a given style. */ - /* */ - /* <Note> */ - /* A face object also owns a single @FT_GlyphSlot object, as well */ - /* as one or more @FT_Size objects. */ - /* */ - /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ - /* a given filepath or a custom input stream. */ - /* */ - /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ - /* */ - /* An `FT_Face' object can only be safely used from one thread at a */ - /* time. Similarly, creation and destruction of `FT_Face' with the */ - /* same @FT_Library object can only be done from one thread at a */ - /* time. On the other hand, functions like @FT_Load_Glyph and its */ - /* siblings are thread-safe and do not need the lock to be held as */ - /* long as the same `FT_Face' object is not used from multiple */ - /* threads at the same time. */ - /* */ - /* <Also> */ - /* See @FT_FaceRec for the publicly accessible fields of a given face */ - /* object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Face + * + * @description: + * A handle to a typographic face object. A face object models a given + * typeface, in a given style. + * + * @note: + * A face object also owns a single @FT_GlyphSlot object, as well as one + * or more @FT_Size objects. + * + * Use @FT_New_Face or @FT_Open_Face to create a new face object from a + * given filepath or a custom input stream. + * + * Use @FT_Done_Face to destroy it (along with its slot and sizes). + * + * An `FT_Face` object can only be safely used from one thread at a time. + * Similarly, creation and destruction of `FT_Face` with the same + * @FT_Library object can only be done from one thread at a time. On the + * other hand, functions like @FT_Load_Glyph and its siblings are + * thread-safe and do not need the lock to be held as long as the same + * `FT_Face` object is not used from multiple threads at the same time. + * + * @also: + * See @FT_FaceRec for the publicly accessible fields of a given face + * object. + */ typedef struct FT_FaceRec_* FT_Face; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size */ - /* */ - /* <Description> */ - /* A handle to an object that models a face scaled to a given */ - /* character size. */ - /* */ - /* <Note> */ - /* An @FT_Face has one _active_ @FT_Size object that is used by */ - /* functions like @FT_Load_Glyph to determine the scaling */ - /* transformation that in turn is used to load and hint glyphs and */ - /* metrics. */ - /* */ - /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ - /* @FT_Request_Size or even @FT_Select_Size to change the content */ - /* (i.e., the scaling values) of the active @FT_Size. */ - /* */ - /* You can use @FT_New_Size to create additional size objects for a */ - /* given @FT_Face, but they won't be used by other functions until */ - /* you activate it through @FT_Activate_Size. Only one size can be */ - /* activated at any given time per face. */ - /* */ - /* <Also> */ - /* See @FT_SizeRec for the publicly accessible fields of a given size */ - /* object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Size + * + * @description: + * A handle to an object that models a face scaled to a given character + * size. + * + * @note: + * An @FT_Face has one _active_ @FT_Size object that is used by functions + * like @FT_Load_Glyph to determine the scaling transformation that in + * turn is used to load and hint glyphs and metrics. + * + * You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, @FT_Request_Size + * or even @FT_Select_Size to change the content (i.e., the scaling + * values) of the active @FT_Size. + * + * You can use @FT_New_Size to create additional size objects for a given + * @FT_Face, but they won't be used by other functions until you activate + * it through @FT_Activate_Size. Only one size can be activated at any + * given time per face. + * + * @also: + * See @FT_SizeRec for the publicly accessible fields of a given size + * object. + */ typedef struct FT_SizeRec_* FT_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a given `glyph slot'. A slot is a container that can */ - /* hold any of the glyphs contained in its parent face. */ - /* */ - /* In other words, each time you call @FT_Load_Glyph or */ - /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ - /* i.e., the glyph's metrics, its image (bitmap or outline), and */ - /* other control information. */ - /* */ - /* <Also> */ - /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ - /* */ + /************************************************************************** + * + * @type: + * FT_GlyphSlot + * + * @description: + * A handle to a given 'glyph slot'. A slot is a container that can hold + * any of the glyphs contained in its parent face. + * + * In other words, each time you call @FT_Load_Glyph or @FT_Load_Char, + * the slot's content is erased by the new glyph data, i.e., the glyph's + * metrics, its image (bitmap or outline), and other control information. + * + * @also: + * See @FT_GlyphSlotRec for the publicly accessible glyph fields. + */ typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_CharMap */ - /* */ - /* <Description> */ - /* A handle to a character map (usually abbreviated to `charmap'). A */ - /* charmap is used to translate character codes in a given encoding */ - /* into glyph indexes for its parent's face. Some font formats may */ - /* provide several charmaps per font. */ - /* */ - /* Each face object owns zero or more charmaps, but only one of them */ - /* can be `active', providing the data used by @FT_Get_Char_Index or */ - /* @FT_Load_Char. */ - /* */ - /* The list of available charmaps in a face is available through the */ - /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ - /* */ - /* The currently active charmap is available as `face->charmap'. */ - /* You should call @FT_Set_Charmap to change it. */ - /* */ - /* <Note> */ - /* When a new face is created (either through @FT_New_Face or */ - /* @FT_Open_Face), the library looks for a Unicode charmap within */ - /* the list and automatically activates it. If there is no Unicode */ - /* charmap, FreeType doesn't set an `active' charmap. */ - /* */ - /* <Also> */ - /* See @FT_CharMapRec for the publicly accessible fields of a given */ - /* character map. */ - /* */ + /************************************************************************** + * + * @type: + * FT_CharMap + * + * @description: + * A handle to a character map (usually abbreviated to 'charmap'). A + * charmap is used to translate character codes in a given encoding into + * glyph indexes for its parent's face. Some font formats may provide + * several charmaps per font. + * + * Each face object owns zero or more charmaps, but only one of them can + * be 'active', providing the data used by @FT_Get_Char_Index or + * @FT_Load_Char. + * + * The list of available charmaps in a face is available through the + * `face->num_charmaps` and `face->charmaps` fields of @FT_FaceRec. + * + * The currently active charmap is available as `face->charmap`. You + * should call @FT_Set_Charmap to change it. + * + * @note: + * When a new face is created (either through @FT_New_Face or + * @FT_Open_Face), the library looks for a Unicode charmap within the + * list and automatically activates it. If there is no Unicode charmap, + * FreeType doesn't set an 'active' charmap. + * + * @also: + * See @FT_CharMapRec for the publicly accessible fields of a given + * character map. + */ typedef struct FT_CharMapRec_* FT_CharMap; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_ENC_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags into an unsigned long. It is */ - /* used to define `encoding' identifiers (see @FT_Encoding). */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_ENC_TAG( value, a, b, c, d ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ + /************************************************************************** + * + * @macro: + * FT_ENC_TAG + * + * @description: + * This macro converts four-letter tags into an unsigned long. It is + * used to define 'encoding' identifiers (see @FT_Encoding). + * + * @note: + * Since many 16-bit compilers don't like 32-bit enumerations, you should + * redefine this macro in case of problems to something like this: + * + * ``` + * #define FT_ENC_TAG( value, a, b, c, d ) value + * ``` + * + * to get a simple enumeration without assigning special numbers. + */ #ifndef FT_ENC_TAG #define FT_ENC_TAG( value, a, b, c, d ) \ @@ -619,150 +612,147 @@ FT_BEGIN_HEADER #endif /* FT_ENC_TAG */ - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Encoding */ - /* */ - /* <Description> */ - /* An enumeration to specify character sets supported by charmaps. */ - /* Used in the @FT_Select_Charmap API function. */ - /* */ - /* <Note> */ - /* Despite the name, this enumeration lists specific character */ - /* repertories (i.e., charsets), and not text encoding methods (e.g., */ - /* UTF-8, UTF-16, etc.). */ - /* */ - /* Other encodings might be defined in the future. */ - /* */ - /* <Values> */ - /* FT_ENCODING_NONE :: */ - /* The encoding value~0 is reserved. */ - /* */ - /* FT_ENCODING_UNICODE :: */ - /* The Unicode character set. This value covers all versions of */ - /* the Unicode repertoire, including ASCII and Latin-1. Most fonts */ - /* include a Unicode charmap, but not all of them. */ - /* */ - /* For example, if you want to access Unicode value U+1F028 (and */ - /* the font contains it), use value 0x1F028 as the input value for */ - /* @FT_Get_Char_Index. */ - /* */ - /* FT_ENCODING_MS_SYMBOL :: */ - /* Microsoft Symbol encoding, used to encode mathematical symbols */ - /* and wingdings. For more information, see */ - /* `https://www.microsoft.com/typography/otspec/recom.htm', */ - /* `http://www.kostis.net/charsets/symbol.htm', and */ - /* `http://www.kostis.net/charsets/wingding.htm'. */ - /* */ - /* This encoding uses character codes from the PUA (Private Unicode */ - /* Area) in the range U+F020-U+F0FF. */ - /* */ - /* FT_ENCODING_SJIS :: */ - /* Shift JIS encoding for Japanese. More info at */ - /* `https://en.wikipedia.org/wiki/Shift_JIS'. See note on */ - /* multi-byte encodings below. */ - /* */ - /* FT_ENCODING_PRC :: */ - /* Corresponds to encoding systems mainly for Simplified Chinese as */ - /* used in People's Republic of China (PRC). The encoding layout */ - /* is based on GB~2312 and its supersets GBK and GB~18030. */ - /* */ - /* FT_ENCODING_BIG5 :: */ - /* Corresponds to an encoding system for Traditional Chinese as */ - /* used in Taiwan and Hong Kong. */ - /* */ - /* FT_ENCODING_WANSUNG :: */ - /* Corresponds to the Korean encoding system known as Extended */ - /* Wansung (MS Windows code page 949). */ - /* For more information see */ - /* `https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */ - /* */ - /* FT_ENCODING_JOHAB :: */ - /* The Korean standard character set (KS~C 5601-1992), which */ - /* corresponds to MS Windows code page 1361. This character set */ - /* includes all possible Hangul character combinations. */ - /* */ - /* FT_ENCODING_ADOBE_LATIN_1 :: */ - /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ - /* PostScript font. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_STANDARD :: */ - /* Adobe Standard encoding, as found in Type~1, CFF, and */ - /* OpenType/CFF fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_EXPERT :: */ - /* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */ - /* fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_CUSTOM :: */ - /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ - /* OpenType/CFF fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_APPLE_ROMAN :: */ - /* Apple roman encoding. Many TrueType and OpenType fonts contain */ - /* a charmap for this 8-bit encoding, since older versions of Mac */ - /* OS are able to use it. */ - /* */ - /* FT_ENCODING_OLD_LATIN_2 :: */ - /* This value is deprecated and was neither used nor reported by */ - /* FreeType. Don't use or test for it. */ - /* */ - /* FT_ENCODING_MS_SJIS :: */ - /* Same as FT_ENCODING_SJIS. Deprecated. */ - /* */ - /* FT_ENCODING_MS_GB2312 :: */ - /* Same as FT_ENCODING_PRC. Deprecated. */ - /* */ - /* FT_ENCODING_MS_BIG5 :: */ - /* Same as FT_ENCODING_BIG5. Deprecated. */ - /* */ - /* FT_ENCODING_MS_WANSUNG :: */ - /* Same as FT_ENCODING_WANSUNG. Deprecated. */ - /* */ - /* FT_ENCODING_MS_JOHAB :: */ - /* Same as FT_ENCODING_JOHAB. Deprecated. */ - /* */ - /* <Note> */ - /* By default, FreeType enables a Unicode charmap and tags it with */ - /* FT_ENCODING_UNICODE when it is either provided or can be generated */ - /* from PostScript glyph name dictionaries in the font file. */ - /* All other encodings are considered legacy and tagged only if */ - /* explicitly defined in the font file. Otherwise, FT_ENCODING_NONE */ - /* is used. */ - /* */ - /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ - /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ - /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ - /* which encoding is really present. If, for example, the */ - /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ - /* the font is encoded in KOI8-R. */ - /* */ - /* FT_ENCODING_NONE is always set (with a single exception) by the */ - /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ - /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ - /* which encoding is really present. For example, */ - /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ - /* Russian). */ - /* */ - /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ - /* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */ - /* FT_ENCODING_APPLE_ROMAN). */ - /* */ - /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ - /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ - /* be needed to be able to distinguish Apple encoding variants. See */ - /* */ - /* https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ - /* */ - /* to get an idea how to do that. Basically, if the language ID */ - /* is~0, don't use it, otherwise subtract 1 from the language ID. */ - /* Then examine `encoding_id'. If, for example, `encoding_id' is */ - /* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */ - /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ - /* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */ - /* variant the Arabic encoding. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Encoding + * + * @description: + * An enumeration to specify character sets supported by charmaps. Used + * in the @FT_Select_Charmap API function. + * + * @note: + * Despite the name, this enumeration lists specific character + * repertories (i.e., charsets), and not text encoding methods (e.g., + * UTF-8, UTF-16, etc.). + * + * Other encodings might be defined in the future. + * + * @values: + * FT_ENCODING_NONE :: + * The encoding value~0 is reserved for all formats except BDF, PCF, + * and Windows FNT; see below for more information. + * + * FT_ENCODING_UNICODE :: + * The Unicode character set. This value covers all versions of the + * Unicode repertoire, including ASCII and Latin-1. Most fonts include + * a Unicode charmap, but not all of them. + * + * For example, if you want to access Unicode value U+1F028 (and the + * font contains it), use value 0x1F028 as the input value for + * @FT_Get_Char_Index. + * + * FT_ENCODING_MS_SYMBOL :: + * Microsoft Symbol encoding, used to encode mathematical symbols and + * wingdings. For more information, see + * 'https://www.microsoft.com/typography/otspec/recom.htm#non-standard-symbol-fonts', + * 'http://www.kostis.net/charsets/symbol.htm', and + * 'http://www.kostis.net/charsets/wingding.htm'. + * + * This encoding uses character codes from the PUA (Private Unicode + * Area) in the range U+F020-U+F0FF. + * + * FT_ENCODING_SJIS :: + * Shift JIS encoding for Japanese. More info at + * 'https://en.wikipedia.org/wiki/Shift_JIS'. See note on multi-byte + * encodings below. + * + * FT_ENCODING_PRC :: + * Corresponds to encoding systems mainly for Simplified Chinese as + * used in People's Republic of China (PRC). The encoding layout is + * based on GB~2312 and its supersets GBK and GB~18030. + * + * FT_ENCODING_BIG5 :: + * Corresponds to an encoding system for Traditional Chinese as used in + * Taiwan and Hong Kong. + * + * FT_ENCODING_WANSUNG :: + * Corresponds to the Korean encoding system known as Extended Wansung + * (MS Windows code page 949). For more information see + * 'https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. + * + * FT_ENCODING_JOHAB :: + * The Korean standard character set (KS~C 5601-1992), which + * corresponds to MS Windows code page 1361. This character set + * includes all possible Hangul character combinations. + * + * FT_ENCODING_ADOBE_LATIN_1 :: + * Corresponds to a Latin-1 encoding as defined in a Type~1 PostScript + * font. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_STANDARD :: + * Adobe Standard encoding, as found in Type~1, CFF, and OpenType/CFF + * fonts. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_EXPERT :: + * Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF + * fonts. It is limited to 256 character codes. + * + * FT_ENCODING_ADOBE_CUSTOM :: + * Corresponds to a custom encoding, as found in Type~1, CFF, and + * OpenType/CFF fonts. It is limited to 256 character codes. + * + * FT_ENCODING_APPLE_ROMAN :: + * Apple roman encoding. Many TrueType and OpenType fonts contain a + * charmap for this 8-bit encoding, since older versions of Mac OS are + * able to use it. + * + * FT_ENCODING_OLD_LATIN_2 :: + * This value is deprecated and was neither used nor reported by + * FreeType. Don't use or test for it. + * + * FT_ENCODING_MS_SJIS :: + * Same as FT_ENCODING_SJIS. Deprecated. + * + * FT_ENCODING_MS_GB2312 :: + * Same as FT_ENCODING_PRC. Deprecated. + * + * FT_ENCODING_MS_BIG5 :: + * Same as FT_ENCODING_BIG5. Deprecated. + * + * FT_ENCODING_MS_WANSUNG :: + * Same as FT_ENCODING_WANSUNG. Deprecated. + * + * FT_ENCODING_MS_JOHAB :: + * Same as FT_ENCODING_JOHAB. Deprecated. + * + * @note: + * By default, FreeType enables a Unicode charmap and tags it with + * `FT_ENCODING_UNICODE` when it is either provided or can be generated + * from PostScript glyph name dictionaries in the font file. All other + * encodings are considered legacy and tagged only if explicitly defined + * in the font file. Otherwise, `FT_ENCODING_NONE` is used. + * + * `FT_ENCODING_NONE` is set by the BDF and PCF drivers if the charmap is + * neither Unicode nor ISO-8859-1 (otherwise it is set to + * `FT_ENCODING_UNICODE`). Use @FT_Get_BDF_Charset_ID to find out which + * encoding is really present. If, for example, the `cs_registry` field + * is 'KOI8' and the `cs_encoding` field is 'R', the font is encoded in + * KOI8-R. + * + * `FT_ENCODING_NONE` is always set (with a single exception) by the + * winfonts driver. Use @FT_Get_WinFNT_Header and examine the `charset` + * field of the @FT_WinFNT_HeaderRec structure to find out which encoding + * is really present. For example, @FT_WinFNT_ID_CP1251 (204) means + * Windows code page 1251 (for Russian). + * + * `FT_ENCODING_NONE` is set if `platform_id` is @TT_PLATFORM_MACINTOSH + * and `encoding_id` is not `TT_MAC_ID_ROMAN` (otherwise it is set to + * `FT_ENCODING_APPLE_ROMAN`). + * + * If `platform_id` is @TT_PLATFORM_MACINTOSH, use the function + * @FT_Get_CMap_Language_ID to query the Mac language ID that may be + * needed to be able to distinguish Apple encoding variants. See + * + * https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt + * + * to get an idea how to do that. Basically, if the language ID is~0, + * don't use it, otherwise subtract 1 from the language ID. Then examine + * `encoding_id`. If, for example, `encoding_id` is `TT_MAC_ID_ROMAN` + * and the language ID (minus~1) is `TT_MAC_LANGID_GREEK`, it is the + * Greek encoding, not Roman. `TT_MAC_ID_ARABIC` with + * `TT_MAC_LANGID_FARSI` means the Farsi variant the Arabic encoding. + */ typedef enum FT_Encoding_ { FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), @@ -796,7 +786,7 @@ FT_BEGIN_HEADER } FT_Encoding; - /* these constants are deprecated; use the corresponding `FT_Encoding' */ + /* these constants are deprecated; use the corresponding `FT_Encoding` */ /* values instead */ #define ft_encoding_none FT_ENCODING_NONE #define ft_encoding_unicode FT_ENCODING_UNICODE @@ -815,29 +805,31 @@ FT_BEGIN_HEADER #define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_CharMapRec */ - /* */ - /* <Description> */ - /* The base charmap structure. */ - /* */ - /* <Fields> */ - /* face :: A handle to the parent face object. */ - /* */ - /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ - /* this with @FT_Select_Charmap. */ - /* */ - /* platform_id :: An ID number describing the platform for the */ - /* following encoding ID. This comes directly from */ - /* the TrueType specification and gets emulated for */ - /* other formats. */ - /* */ - /* encoding_id :: A platform specific encoding number. This also */ - /* comes from the TrueType specification and gets */ - /* emulated similarly. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_CharMapRec + * + * @description: + * The base charmap structure. + * + * @fields: + * face :: + * A handle to the parent face object. + * + * encoding :: + * An @FT_Encoding tag identifying the charmap. Use this with + * @FT_Select_Charmap. + * + * platform_id :: + * An ID number describing the platform for the following encoding ID. + * This comes directly from the TrueType specification and gets + * emulated for other formats. + * + * encoding_id :: + * A platform-specific encoding number. This also comes from the + * TrueType specification and gets emulated similarly. + */ typedef struct FT_CharMapRec_ { FT_Face face; @@ -857,215 +849,195 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Face_InternalRec' structure that models */ - /* the private data of a given @FT_Face object. */ - /* */ - /* This structure might change between releases of FreeType~2 and is */ - /* not generally available to client applications. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Face_Internal + * + * @description: + * An opaque handle to an `FT_Face_InternalRec` structure that models the + * private data of a given @FT_Face object. + * + * This structure might change between releases of FreeType~2 and is not + * generally available to client applications. + */ typedef struct FT_Face_InternalRec_* FT_Face_Internal; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_FaceRec */ - /* */ - /* <Description> */ - /* FreeType root face class structure. A face object models a */ - /* typeface in a font file. */ - /* */ - /* <Fields> */ - /* num_faces :: The number of faces in the font file. Some */ - /* font formats can have multiple faces in */ - /* a single font file. */ - /* */ - /* face_index :: This field holds two different values. */ - /* Bits 0-15 are the index of the face in the */ - /* font file (starting with value~0). They */ - /* are set to~0 if there is only one face in */ - /* the font file. */ - /* */ - /* [Since 2.6.1] Bits 16-30 are relevant to GX */ - /* and OpenType variation fonts only, holding */ - /* the named instance index for the current */ - /* face index (starting with value~1; value~0 */ - /* indicates font access without a named */ - /* instance). For non-variation fonts, bits */ - /* 16-30 are ignored. If we have the third */ - /* named instance of face~4, say, `face_index' */ - /* is set to 0x00030004. */ - /* */ - /* Bit 31 is always zero (this is, */ - /* `face_index' is always a positive value). */ - /* */ - /* [Since 2.9] Changing the design coordinates */ - /* with @FT_Set_Var_Design_Coordinates or */ - /* @FT_Set_Var_Blend_Coordinates does not */ - /* influence the named instance index value */ - /* (only @FT_Set_Named_Instance does that). */ - /* */ - /* face_flags :: A set of bit flags that give important */ - /* information about the face; see */ - /* @FT_FACE_FLAG_XXX for the details. */ - /* */ - /* style_flags :: The lower 16~bits contain a set of bit */ - /* flags indicating the style of the face; see */ - /* @FT_STYLE_FLAG_XXX for the details. */ - /* */ - /* [Since 2.6.1] Bits 16-30 hold the number */ - /* of named instances available for the */ - /* current face if we have a GX or OpenType */ - /* variation (sub)font. Bit 31 is always zero */ - /* (this is, `style_flags' is always a */ - /* positive value). Note that a variation */ - /* font has always at least one named */ - /* instance, namely the default instance. */ - /* */ - /* num_glyphs :: The number of glyphs in the face. If the */ - /* face is scalable and has sbits (see */ - /* `num_fixed_sizes'), it is set to the number */ - /* of outline glyphs. */ - /* */ - /* For CID-keyed fonts (not in an SFNT */ - /* wrapper) this value gives the highest CID */ - /* used in the font. */ - /* */ - /* family_name :: The face's family name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's family (like `Times New */ - /* Roman', `Bodoni', `Garamond', etc). This */ - /* is a least common denominator used to list */ - /* fonts. Some formats (TrueType & OpenType) */ - /* provide localized and Unicode versions of */ - /* this string. Applications should use the */ - /* format specific interface to access them. */ - /* Can be NULL (e.g., in fonts embedded in a */ - /* PDF file). */ - /* */ - /* In case the font doesn't provide a specific */ - /* family name entry, FreeType tries to */ - /* synthesize one, deriving it from other name */ - /* entries. */ - /* */ - /* style_name :: The face's style name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's style (like `Italic', */ - /* `Bold', `Condensed', etc). Not all font */ - /* formats provide a style name, so this field */ - /* is optional, and can be set to NULL. As */ - /* for `family_name', some formats provide */ - /* localized and Unicode versions of this */ - /* string. Applications should use the format */ - /* specific interface to access them. */ - /* */ - /* num_fixed_sizes :: The number of bitmap strikes in the face. */ - /* Even if the face is scalable, there might */ - /* still be bitmap strikes, which are called */ - /* `sbits' in that case. */ - /* */ - /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ - /* strikes in the face. It is set to NULL if */ - /* there is no bitmap strike. */ - /* */ - /* Note that FreeType tries to sanitize the */ - /* strike data since they are sometimes sloppy */ - /* or incorrect, but this can easily fail. */ - /* */ - /* num_charmaps :: The number of charmaps in the face. */ - /* */ - /* charmaps :: An array of the charmaps of the face. */ - /* */ - /* generic :: A field reserved for client uses. See the */ - /* @FT_Generic type description. */ - /* */ - /* bbox :: The font bounding box. Coordinates are */ - /* expressed in font units (see */ - /* `units_per_EM'). The box is large enough */ - /* to contain any glyph from the font. Thus, */ - /* `bbox.yMax' can be seen as the `maximum */ - /* ascender', and `bbox.yMin' as the `minimum */ - /* descender'. Only relevant for scalable */ - /* formats. */ - /* */ - /* Note that the bounding box might be off by */ - /* (at least) one pixel for hinted fonts. See */ - /* @FT_Size_Metrics for further discussion. */ - /* */ - /* units_per_EM :: The number of font units per EM square for */ - /* this face. This is typically 2048 for */ - /* TrueType fonts, and 1000 for Type~1 fonts. */ - /* Only relevant for scalable formats. */ - /* */ - /* ascender :: The typographic ascender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMax'. Only relevant for scalable */ - /* formats. */ - /* */ - /* descender :: The typographic descender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMin'. Note that this field is */ - /* negative for values below the baseline. */ - /* Only relevant for scalable formats. */ - /* */ - /* height :: This value is the vertical distance */ - /* between two consecutive baselines, */ - /* expressed in font units. It is always */ - /* positive. Only relevant for scalable */ - /* formats. */ - /* */ - /* If you want the global glyph height, use */ - /* `ascender - descender'. */ - /* */ - /* max_advance_width :: The maximum advance width, in font units, */ - /* for all glyphs in this face. This can be */ - /* used to make word wrapping computations */ - /* faster. Only relevant for scalable */ - /* formats. */ - /* */ - /* max_advance_height :: The maximum advance height, in font units, */ - /* for all glyphs in this face. This is only */ - /* relevant for vertical layouts, and is set */ - /* to `height' for fonts that do not provide */ - /* vertical metrics. Only relevant for */ - /* scalable formats. */ - /* */ - /* underline_position :: The position, in font units, of the */ - /* underline line for this face. It is the */ - /* center of the underlining stem. Only */ - /* relevant for scalable formats. */ - /* */ - /* underline_thickness :: The thickness, in font units, of the */ - /* underline for this face. Only relevant for */ - /* scalable formats. */ - /* */ - /* glyph :: The face's associated glyph slot(s). */ - /* */ - /* size :: The current active size for this face. */ - /* */ - /* charmap :: The current active charmap for this face. */ - /* */ - /* <Note> */ - /* Fields may be changed after a call to @FT_Attach_File or */ - /* @FT_Attach_Stream. */ - /* */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `ascender', */ - /* `descender', `height', `underline_position', and */ - /* `underline_thickness'. */ - /* */ - /* Especially for TrueType fonts see also the documentation for */ - /* @FT_Size_Metrics. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_FaceRec + * + * @description: + * FreeType root face class structure. A face object models a typeface + * in a font file. + * + * @fields: + * num_faces :: + * The number of faces in the font file. Some font formats can have + * multiple faces in a single font file. + * + * face_index :: + * This field holds two different values. Bits 0-15 are the index of + * the face in the font file (starting with value~0). They are set + * to~0 if there is only one face in the font file. + * + * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation + * fonts only, holding the named instance index for the current face + * index (starting with value~1; value~0 indicates font access without + * a named instance). For non-variation fonts, bits 16-30 are ignored. + * If we have the third named instance of face~4, say, `face_index` is + * set to 0x00030004. + * + * Bit 31 is always zero (this is, `face_index` is always a positive + * value). + * + * [Since 2.9] Changing the design coordinates with + * @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does + * not influence the named instance index value (only + * @FT_Set_Named_Instance does that). + * + * face_flags :: + * A set of bit flags that give important information about the face; + * see @FT_FACE_FLAG_XXX for the details. + * + * style_flags :: + * The lower 16~bits contain a set of bit flags indicating the style of + * the face; see @FT_STYLE_FLAG_XXX for the details. + * + * [Since 2.6.1] Bits 16-30 hold the number of named instances + * available for the current face if we have a GX or OpenType variation + * (sub)font. Bit 31 is always zero (this is, `style_flags` is always + * a positive value). Note that a variation font has always at least + * one named instance, namely the default instance. + * + * num_glyphs :: + * The number of glyphs in the face. If the face is scalable and has + * sbits (see `num_fixed_sizes`), it is set to the number of outline + * glyphs. + * + * For CID-keyed fonts (not in an SFNT wrapper) this value gives the + * highest CID used in the font. + * + * family_name :: + * The face's family name. This is an ASCII string, usually in + * English, that describes the typeface's family (like 'Times New + * Roman', 'Bodoni', 'Garamond', etc). This is a least common + * denominator used to list fonts. Some formats (TrueType & OpenType) + * provide localized and Unicode versions of this string. Applications + * should use the format-specific interface to access them. Can be + * `NULL` (e.g., in fonts embedded in a PDF file). + * + * In case the font doesn't provide a specific family name entry, + * FreeType tries to synthesize one, deriving it from other name + * entries. + * + * style_name :: + * The face's style name. This is an ASCII string, usually in English, + * that describes the typeface's style (like 'Italic', 'Bold', + * 'Condensed', etc). Not all font formats provide a style name, so + * this field is optional, and can be set to `NULL`. As for + * `family_name`, some formats provide localized and Unicode versions + * of this string. Applications should use the format-specific + * interface to access them. + * + * num_fixed_sizes :: + * The number of bitmap strikes in the face. Even if the face is + * scalable, there might still be bitmap strikes, which are called + * 'sbits' in that case. + * + * available_sizes :: + * An array of @FT_Bitmap_Size for all bitmap strikes in the face. It + * is set to `NULL` if there is no bitmap strike. + * + * Note that FreeType tries to sanitize the strike data since they are + * sometimes sloppy or incorrect, but this can easily fail. + * + * num_charmaps :: + * The number of charmaps in the face. + * + * charmaps :: + * An array of the charmaps of the face. + * + * generic :: + * A field reserved for client uses. See the @FT_Generic type + * description. + * + * bbox :: + * The font bounding box. Coordinates are expressed in font units (see + * `units_per_EM`). The box is large enough to contain any glyph from + * the font. Thus, `bbox.yMax` can be seen as the 'maximum ascender', + * and `bbox.yMin` as the 'minimum descender'. Only relevant for + * scalable formats. + * + * Note that the bounding box might be off by (at least) one pixel for + * hinted fonts. See @FT_Size_Metrics for further discussion. + * + * units_per_EM :: + * The number of font units per EM square for this face. This is + * typically 2048 for TrueType fonts, and 1000 for Type~1 fonts. Only + * relevant for scalable formats. + * + * ascender :: + * The typographic ascender of the face, expressed in font units. For + * font formats not having this information, it is set to `bbox.yMax`. + * Only relevant for scalable formats. + * + * descender :: + * The typographic descender of the face, expressed in font units. For + * font formats not having this information, it is set to `bbox.yMin`. + * Note that this field is negative for values below the baseline. + * Only relevant for scalable formats. + * + * height :: + * This value is the vertical distance between two consecutive + * baselines, expressed in font units. It is always positive. Only + * relevant for scalable formats. + * + * If you want the global glyph height, use `ascender - descender`. + * + * max_advance_width :: + * The maximum advance width, in font units, for all glyphs in this + * face. This can be used to make word wrapping computations faster. + * Only relevant for scalable formats. + * + * max_advance_height :: + * The maximum advance height, in font units, for all glyphs in this + * face. This is only relevant for vertical layouts, and is set to + * `height` for fonts that do not provide vertical metrics. Only + * relevant for scalable formats. + * + * underline_position :: + * The position, in font units, of the underline line for this face. + * It is the center of the underlining stem. Only relevant for + * scalable formats. + * + * underline_thickness :: + * The thickness, in font units, of the underline for this face. Only + * relevant for scalable formats. + * + * glyph :: + * The face's associated glyph slot(s). + * + * size :: + * The current active size for this face. + * + * charmap :: + * The current active charmap for this face. + * + * @note: + * Fields may be changed after a call to @FT_Attach_File or + * @FT_Attach_Stream. + * + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `ascender`, `descender`, `height`, + * `underline_position`, and `underline_thickness`. + * + * Especially for TrueType fonts see also the documentation for + * @FT_Size_Metrics. + */ typedef struct FT_FaceRec_ { FT_Long num_faces; @@ -1087,7 +1059,7 @@ FT_BEGIN_HEADER FT_Generic generic; - /*# The following member variables (down to `underline_thickness') */ + /*# The following member variables (down to `underline_thickness`) */ /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ /*# for bitmap fonts. */ FT_BBox bbox; @@ -1125,117 +1097,116 @@ FT_BEGIN_HEADER } FT_FaceRec; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FACE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `face_flags' field of the */ - /* @FT_FaceRec structure. They inform client applications of */ - /* properties of the corresponding face. */ - /* */ - /* <Values> */ - /* FT_FACE_FLAG_SCALABLE :: */ - /* The face contains outline glyphs. Note that a face can contain */ - /* bitmap strikes also, i.e., a face can have both this flag and */ - /* @FT_FACE_FLAG_FIXED_SIZES set. */ - /* */ - /* FT_FACE_FLAG_FIXED_SIZES :: */ - /* The face contains bitmap strikes. See also the */ - /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ - /* */ - /* FT_FACE_FLAG_FIXED_WIDTH :: */ - /* The face contains fixed-width characters (like Courier, Lucida, */ - /* MonoType, etc.). */ - /* */ - /* FT_FACE_FLAG_SFNT :: */ - /* The face uses the SFNT storage scheme. For now, this means */ - /* TrueType and OpenType. */ - /* */ - /* FT_FACE_FLAG_HORIZONTAL :: */ - /* The face contains horizontal glyph metrics. This should be set */ - /* for all common formats. */ - /* */ - /* FT_FACE_FLAG_VERTICAL :: */ - /* The face contains vertical glyph metrics. This is only */ - /* available in some formats, not all of them. */ - /* */ - /* FT_FACE_FLAG_KERNING :: */ - /* The face contains kerning information. If set, the kerning */ - /* distance can be retrieved using the function @FT_Get_Kerning. */ - /* Otherwise the function always return the vector (0,0). Note */ - /* that FreeType doesn't handle kerning data from the SFNT `GPOS' */ - /* table (as present in many OpenType fonts). */ - /* */ - /* FT_FACE_FLAG_FAST_GLYPHS :: */ - /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ - /* */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ - /* The face contains multiple masters and is capable of */ - /* interpolating between them. Supported formats are Adobe MM, */ - /* TrueType GX, and OpenType variation fonts. */ - /* */ - /* See section @multiple_masters for API details. */ - /* */ - /* FT_FACE_FLAG_GLYPH_NAMES :: */ - /* The face contains glyph names, which can be retrieved using */ - /* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */ - /* broken glyph name tables. Use the function */ - /* @FT_Has_PS_Glyph_Names when needed. */ - /* */ - /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ - /* Used internally by FreeType to indicate that a face's stream was */ - /* provided by the client application and should not be destroyed */ - /* when @FT_Done_Face is called. Don't read or test this flag. */ - /* */ - /* FT_FACE_FLAG_HINTER :: */ - /* The font driver has a hinting machine of its own. For example, */ - /* with TrueType fonts, it makes sense to use data from the SFNT */ - /* `gasp' table only if the native TrueType hinting engine (with */ - /* the bytecode interpreter) is available and active. */ - /* */ - /* FT_FACE_FLAG_CID_KEYED :: */ - /* The face is CID-keyed. In that case, the face is not accessed */ - /* by glyph indices but by CID values. For subsetted CID-keyed */ - /* fonts this has the consequence that not all index values are a */ - /* valid argument to @FT_Load_Glyph. Only the CID values for which */ - /* corresponding glyphs in the subsetted font exist make */ - /* `FT_Load_Glyph' return successfully; in all other cases you get */ - /* an `FT_Err_Invalid_Argument' error. */ - /* */ - /* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */ - /* all OpenType/CFF fonts) don't have this flag set since the */ - /* glyphs are accessed in the normal way (using contiguous */ - /* indices); the `CID-ness' isn't visible to the application. */ - /* */ - /* FT_FACE_FLAG_TRICKY :: */ - /* The face is `tricky', this is, it always needs the font format's */ - /* native hinting engine to get a reasonable result. A typical */ - /* example is the old Chinese font `mingli.ttf' (but not */ - /* `mingliu.ttc') that uses TrueType bytecode instructions to move */ - /* and scale all of its subglyphs. */ - /* */ - /* It is not possible to auto-hint such fonts using */ - /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ - /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ - /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ - /* probably never want this except for demonstration purposes. */ - /* */ - /* Currently, there are about a dozen TrueType fonts in the list of */ - /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ - /* */ - /* FT_FACE_FLAG_COLOR :: */ - /* [Since 2.5.1] The face has color glyph tables. To access color */ - /* glyphs use @FT_LOAD_COLOR. */ - /* */ - /* FT_FACE_FLAG_VARIATION :: */ - /* [Since 2.9] Set if the current face (or named instance) has been */ - /* altered with @FT_Set_MM_Design_Coordinates, */ - /* @FT_Set_Var_Design_Coordinates, or */ - /* @FT_Set_Var_Blend_Coordinates. This flag is unset by a call to */ - /* @FT_Set_Named_Instance. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_FACE_FLAG_XXX + * + * @description: + * A list of bit flags used in the `face_flags` field of the @FT_FaceRec + * structure. They inform client applications of properties of the + * corresponding face. + * + * @values: + * FT_FACE_FLAG_SCALABLE :: + * The face contains outline glyphs. Note that a face can contain + * bitmap strikes also, i.e., a face can have both this flag and + * @FT_FACE_FLAG_FIXED_SIZES set. + * + * FT_FACE_FLAG_FIXED_SIZES :: + * The face contains bitmap strikes. See also the `num_fixed_sizes` + * and `available_sizes` fields of @FT_FaceRec. + * + * FT_FACE_FLAG_FIXED_WIDTH :: + * The face contains fixed-width characters (like Courier, Lucida, + * MonoType, etc.). + * + * FT_FACE_FLAG_SFNT :: + * The face uses the SFNT storage scheme. For now, this means TrueType + * and OpenType. + * + * FT_FACE_FLAG_HORIZONTAL :: + * The face contains horizontal glyph metrics. This should be set for + * all common formats. + * + * FT_FACE_FLAG_VERTICAL :: + * The face contains vertical glyph metrics. This is only available in + * some formats, not all of them. + * + * FT_FACE_FLAG_KERNING :: + * The face contains kerning information. If set, the kerning distance + * can be retrieved using the function @FT_Get_Kerning. Otherwise the + * function always return the vector (0,0). Note that FreeType doesn't + * handle kerning data from the SFNT 'GPOS' table (as present in many + * OpenType fonts). + * + * FT_FACE_FLAG_FAST_GLYPHS :: + * THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. + * + * FT_FACE_FLAG_MULTIPLE_MASTERS :: + * The face contains multiple masters and is capable of interpolating + * between them. Supported formats are Adobe MM, TrueType GX, and + * OpenType variation fonts. + * + * See section @multiple_masters for API details. + * + * FT_FACE_FLAG_GLYPH_NAMES :: + * The face contains glyph names, which can be retrieved using + * @FT_Get_Glyph_Name. Note that some TrueType fonts contain broken + * glyph name tables. Use the function @FT_Has_PS_Glyph_Names when + * needed. + * + * FT_FACE_FLAG_EXTERNAL_STREAM :: + * Used internally by FreeType to indicate that a face's stream was + * provided by the client application and should not be destroyed when + * @FT_Done_Face is called. Don't read or test this flag. + * + * FT_FACE_FLAG_HINTER :: + * The font driver has a hinting machine of its own. For example, with + * TrueType fonts, it makes sense to use data from the SFNT 'gasp' + * table only if the native TrueType hinting engine (with the bytecode + * interpreter) is available and active. + * + * FT_FACE_FLAG_CID_KEYED :: + * The face is CID-keyed. In that case, the face is not accessed by + * glyph indices but by CID values. For subsetted CID-keyed fonts this + * has the consequence that not all index values are a valid argument + * to @FT_Load_Glyph. Only the CID values for which corresponding + * glyphs in the subsetted font exist make `FT_Load_Glyph` return + * successfully; in all other cases you get an + * `FT_Err_Invalid_Argument` error. + * + * Note that CID-keyed fonts that are in an SFNT wrapper (this is, all + * OpenType/CFF fonts) don't have this flag set since the glyphs are + * accessed in the normal way (using contiguous indices); the + * 'CID-ness' isn't visible to the application. + * + * FT_FACE_FLAG_TRICKY :: + * The face is 'tricky', this is, it always needs the font format's + * native hinting engine to get a reasonable result. A typical example + * is the old Chinese font `mingli.ttf` (but not `mingliu.ttc`) that + * uses TrueType bytecode instructions to move and scale all of its + * subglyphs. + * + * It is not possible to auto-hint such fonts using + * @FT_LOAD_FORCE_AUTOHINT; it will also ignore @FT_LOAD_NO_HINTING. + * You have to set both @FT_LOAD_NO_HINTING and @FT_LOAD_NO_AUTOHINT to + * really disable hinting; however, you probably never want this except + * for demonstration purposes. + * + * Currently, there are about a dozen TrueType fonts in the list of + * tricky fonts; they are hard-coded in file `ttobjs.c`. + * + * FT_FACE_FLAG_COLOR :: + * [Since 2.5.1] The face has color glyph tables. See @FT_LOAD_COLOR + * for more information. + * + * FT_FACE_FLAG_VARIATION :: + * [Since 2.9] Set if the current face (or named instance) has been + * altered with @FT_Set_MM_Design_Coordinates, + * @FT_Set_Var_Design_Coordinates, or @FT_Set_Var_Blend_Coordinates. + * This flag is unset by a call to @FT_Set_Named_Instance. + */ #define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) #define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) #define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) @@ -1254,14 +1225,14 @@ FT_BEGIN_HEADER #define FT_FACE_FLAG_VARIATION ( 1L << 15 ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_HORIZONTAL( face ) + * FT_HAS_HORIZONTAL * * @description: - * A macro that returns true whenever a face object contains - * horizontal metrics (this is true for all font formats though). + * A macro that returns true whenever a face object contains horizontal + * metrics (this is true for all font formats though). * * @also: * @FT_HAS_VERTICAL can be used to check for vertical metrics. @@ -1271,10 +1242,10 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_VERTICAL( face ) + * FT_HAS_VERTICAL * * @description: * A macro that returns true whenever a face object contains real @@ -1285,45 +1256,45 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_KERNING( face ) + * FT_HAS_KERNING * * @description: - * A macro that returns true whenever a face object contains kerning - * data that can be accessed with @FT_Get_Kerning. + * A macro that returns true whenever a face object contains kerning data + * that can be accessed with @FT_Get_Kerning. * */ #define FT_HAS_KERNING( face ) \ ( (face)->face_flags & FT_FACE_FLAG_KERNING ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_SCALABLE( face ) + * FT_IS_SCALABLE * * @description: * A macro that returns true whenever a face object contains a scalable - * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, - * and PFR font formats). + * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, and + * PFR font formats). * */ #define FT_IS_SCALABLE( face ) \ ( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_SFNT( face ) + * FT_IS_SFNT * * @description: - * A macro that returns true whenever a face object contains a font - * whose format is based on the SFNT storage scheme. This usually - * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded - * bitmap fonts. + * A macro that returns true whenever a face object contains a font whose + * format is based on the SFNT storage scheme. This usually means: + * TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap + * fonts. * * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and * @FT_TRUETYPE_TABLES_H are available. @@ -1333,14 +1304,14 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_SFNT ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_FIXED_WIDTH( face ) + * FT_IS_FIXED_WIDTH * * @description: * A macro that returns true whenever a face object contains a font face - * that contains fixed-width (or `monospace', `fixed-pitch', etc.) + * that contains fixed-width (or 'monospace', 'fixed-pitch', etc.) * glyphs. * */ @@ -1348,25 +1319,25 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_FIXED_SIZES( face ) + * FT_HAS_FIXED_SIZES * * @description: * A macro that returns true whenever a face object contains some - * embedded bitmaps. See the `available_sizes' field of the - * @FT_FaceRec structure. + * embedded bitmaps. See the `available_sizes` field of the @FT_FaceRec + * structure. * */ #define FT_HAS_FIXED_SIZES( face ) \ ( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_FAST_GLYPHS( face ) + * FT_HAS_FAST_GLYPHS * * @description: * Deprecated. @@ -1375,10 +1346,10 @@ FT_BEGIN_HEADER #define FT_HAS_FAST_GLYPHS( face ) 0 - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_GLYPH_NAMES( face ) + * FT_HAS_GLYPH_NAMES * * @description: * A macro that returns true whenever a face object contains some glyph @@ -1389,10 +1360,10 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_MULTIPLE_MASTERS( face ) + * FT_HAS_MULTIPLE_MASTERS * * @description: * A macro that returns true whenever a face object contains some @@ -1404,10 +1375,10 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_NAMED_INSTANCE( face ) + * FT_IS_NAMED_INSTANCE * * @description: * A macro that returns true whenever a face object is a named instance @@ -1426,14 +1397,14 @@ FT_BEGIN_HEADER ( (face)->face_index & 0x7FFF0000L ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_VARIATION( face ) + * FT_IS_VARIATION * * @description: - * A macro that returns true whenever a face object has been altered - * by @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or + * A macro that returns true whenever a face object has been altered by + * @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or * @FT_Set_Var_Blend_Coordinates. * * @since: @@ -1444,15 +1415,14 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_VARIATION ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_CID_KEYED( face ) + * FT_IS_CID_KEYED * * @description: * A macro that returns true whenever a face object contains a CID-keyed - * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more - * details. + * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more details. * * If this macro is true, all functions defined in @FT_CID_H are * available. @@ -1462,13 +1432,13 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_IS_TRICKY( face ) + * FT_IS_TRICKY * * @description: - * A macro that returns true whenever a face represents a `tricky' font. + * A macro that returns true whenever a face represents a 'tricky' font. * See the discussion of @FT_FACE_FLAG_TRICKY for more details. * */ @@ -1476,14 +1446,14 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_TRICKY ) - /************************************************************************* + /************************************************************************** * * @macro: - * FT_HAS_COLOR( face ) + * FT_HAS_COLOR * * @description: - * A macro that returns true whenever a face object contains - * tables for color glyphs. + * A macro that returns true whenever a face object contains tables for + * color glyphs. * * @since: * 2.5.1 @@ -1493,149 +1463,148 @@ FT_BEGIN_HEADER ( (face)->face_flags & FT_FACE_FLAG_COLOR ) - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_STYLE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags to indicate the style of a given face. These */ - /* are used in the `style_flags' field of @FT_FaceRec. */ - /* */ - /* <Values> */ - /* FT_STYLE_FLAG_ITALIC :: */ - /* The face style is italic or oblique. */ - /* */ - /* FT_STYLE_FLAG_BOLD :: */ - /* The face is bold. */ - /* */ - /* <Note> */ - /* The style information as provided by FreeType is very basic. More */ - /* details are beyond the scope and should be done on a higher level */ - /* (for example, by analyzing various fields of the `OS/2' table in */ - /* SFNT based fonts). */ - /* */ + /************************************************************************** + * + * @enum: + * FT_STYLE_FLAG_XXX + * + * @description: + * A list of bit flags to indicate the style of a given face. These are + * used in the `style_flags` field of @FT_FaceRec. + * + * @values: + * FT_STYLE_FLAG_ITALIC :: + * The face style is italic or oblique. + * + * FT_STYLE_FLAG_BOLD :: + * The face is bold. + * + * @note: + * The style information as provided by FreeType is very basic. More + * details are beyond the scope and should be done on a higher level (for + * example, by analyzing various fields of the 'OS/2' table in SFNT based + * fonts). + */ #define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) #define FT_STYLE_FLAG_BOLD ( 1 << 1 ) - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ - /* model private data of a given @FT_Size object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Size_Internal + * + * @description: + * An opaque handle to an `FT_Size_InternalRec` structure, used to model + * private data of a given @FT_Size object. + */ typedef struct FT_Size_InternalRec_* FT_Size_Internal; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Metrics */ - /* */ - /* <Description> */ - /* The size metrics structure gives the metrics of a size object. */ - /* */ - /* <Fields> */ - /* x_ppem :: The width of the scaled EM square in pixels, hence */ - /* the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal width'. */ - /* */ - /* y_ppem :: The height of the scaled EM square in pixels, */ - /* hence the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal height'. */ - /* */ - /* x_scale :: A 16.16 fractional scaling value to convert */ - /* horizontal metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* y_scale :: A 16.16 fractional scaling value to convert */ - /* vertical metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* ascender :: The ascender in 26.6 fractional pixels, rounded up */ - /* to an integer value. See @FT_FaceRec for the */ - /* details. */ - /* */ - /* descender :: The descender in 26.6 fractional pixels, rounded */ - /* down to an integer value. See @FT_FaceRec for the */ - /* details. */ - /* */ - /* height :: The height in 26.6 fractional pixels, rounded to */ - /* an integer value. See @FT_FaceRec for the */ - /* details. */ - /* */ - /* max_advance :: The maximum advance width in 26.6 fractional */ - /* pixels, rounded to an integer value. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* <Note> */ - /* The scaling values, if relevant, are determined first during a */ - /* size changing operation. The remaining fields are then set by the */ - /* driver. For scalable formats, they are usually set to scaled */ - /* values of the corresponding fields in @FT_FaceRec. Some values */ - /* like ascender or descender are rounded for historical reasons; */ - /* more precise values (for outline fonts) can be derived by scaling */ - /* the corresponding @FT_FaceRec values manually, with code similar */ - /* to the following. */ - /* */ - /* { */ - /* scaled_ascender = FT_MulFix( face->ascender, */ - /* size_metrics->y_scale ); */ - /* } */ - /* */ - /* Note that due to glyph hinting and the selected rendering mode */ - /* these values are usually not exact; consequently, they must be */ - /* treated as unreliable with an error margin of at least one pixel! */ - /* */ - /* Indeed, the only way to get the exact metrics is to render _all_ */ - /* glyphs. As this would be a definite performance hit, it is up to */ - /* client applications to perform such computations. */ - /* */ - /* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */ - /* */ - /* */ - /* *TrueType* *fonts* *with* *native* *bytecode* *hinting* */ - /* */ - /* All applications that handle TrueType fonts with native hinting */ - /* must be aware that TTFs expect different rounding of vertical font */ - /* dimensions. The application has to cater for this, especially if */ - /* it wants to rely on a TTF's vertical data (for example, to */ - /* properly align box characters vertically). */ - /* */ - /* Only the application knows _in_ _advance_ that it is going to use */ - /* native hinting for TTFs! FreeType, on the other hand, selects the */ - /* hinting mode not at the time of creating an @FT_Size object but */ - /* much later, namely while calling @FT_Load_Glyph. */ - /* */ - /* Here is some pseudo code that illustrates a possible solution. */ - /* */ - /* { */ - /* font_format = FT_Get_Font_Format( face ); */ - /* */ - /* if ( !strcmp( font_format, "TrueType" ) && */ - /* do_native_bytecode_hinting ) */ - /* { */ - /* ascender = ROUND( FT_MulFix( face->ascender, */ - /* size_metrics->y_scale ) ); */ - /* descender = ROUND( FT_MulFix( face->descender, */ - /* size_metrics->y_scale ) ); */ - /* } */ - /* else */ - /* { */ - /* ascender = size_metrics->ascender; */ - /* descender = size_metrics->descender; */ - /* } */ - /* */ - /* height = size_metrics->height; */ - /* max_advance = size_metrics->max_advance; */ - /* } */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Size_Metrics + * + * @description: + * The size metrics structure gives the metrics of a size object. + * + * @fields: + * x_ppem :: + * The width of the scaled EM square in pixels, hence the term 'ppem' + * (pixels per EM). It is also referred to as 'nominal width'. + * + * y_ppem :: + * The height of the scaled EM square in pixels, hence the term 'ppem' + * (pixels per EM). It is also referred to as 'nominal height'. + * + * x_scale :: + * A 16.16 fractional scaling value to convert horizontal metrics from + * font units to 26.6 fractional pixels. Only relevant for scalable + * font formats. + * + * y_scale :: + * A 16.16 fractional scaling value to convert vertical metrics from + * font units to 26.6 fractional pixels. Only relevant for scalable + * font formats. + * + * ascender :: + * The ascender in 26.6 fractional pixels, rounded up to an integer + * value. See @FT_FaceRec for the details. + * + * descender :: + * The descender in 26.6 fractional pixels, rounded down to an integer + * value. See @FT_FaceRec for the details. + * + * height :: + * The height in 26.6 fractional pixels, rounded to an integer value. + * See @FT_FaceRec for the details. + * + * max_advance :: + * The maximum advance width in 26.6 fractional pixels, rounded to an + * integer value. See @FT_FaceRec for the details. + * + * @note: + * The scaling values, if relevant, are determined first during a size + * changing operation. The remaining fields are then set by the driver. + * For scalable formats, they are usually set to scaled values of the + * corresponding fields in @FT_FaceRec. Some values like ascender or + * descender are rounded for historical reasons; more precise values (for + * outline fonts) can be derived by scaling the corresponding @FT_FaceRec + * values manually, with code similar to the following. + * + * ``` + * scaled_ascender = FT_MulFix( face->ascender, + * size_metrics->y_scale ); + * ``` + * + * Note that due to glyph hinting and the selected rendering mode these + * values are usually not exact; consequently, they must be treated as + * unreliable with an error margin of at least one pixel! + * + * Indeed, the only way to get the exact metrics is to render _all_ + * glyphs. As this would be a definite performance hit, it is up to + * client applications to perform such computations. + * + * The `FT_Size_Metrics` structure is valid for bitmap fonts also. + * + * + * **TrueType fonts with native bytecode hinting** + * + * All applications that handle TrueType fonts with native hinting must + * be aware that TTFs expect different rounding of vertical font + * dimensions. The application has to cater for this, especially if it + * wants to rely on a TTF's vertical data (for example, to properly align + * box characters vertically). + * + * Only the application knows _in advance_ that it is going to use native + * hinting for TTFs! FreeType, on the other hand, selects the hinting + * mode not at the time of creating an @FT_Size object but much later, + * namely while calling @FT_Load_Glyph. + * + * Here is some pseudo code that illustrates a possible solution. + * + * ``` + * font_format = FT_Get_Font_Format( face ); + * + * if ( !strcmp( font_format, "TrueType" ) && + * do_native_bytecode_hinting ) + * { + * ascender = ROUND( FT_MulFix( face->ascender, + * size_metrics->y_scale ) ); + * descender = ROUND( FT_MulFix( face->descender, + * size_metrics->y_scale ) ); + * } + * else + * { + * ascender = size_metrics->ascender; + * descender = size_metrics->descender; + * } + * + * height = size_metrics->height; + * max_advance = size_metrics->max_advance; + * ``` + */ typedef struct FT_Size_Metrics_ { FT_UShort x_ppem; /* horizontal pixels per EM */ @@ -1652,25 +1621,27 @@ FT_BEGIN_HEADER } FT_Size_Metrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SizeRec */ - /* */ - /* <Description> */ - /* FreeType root size class structure. A size object models a face */ - /* object at a given size. */ - /* */ - /* <Fields> */ - /* face :: Handle to the parent face object. */ - /* */ - /* generic :: A typeless pointer, unused by the FreeType library or */ - /* any of its drivers. It can be used by client */ - /* applications to link their own data to each size */ - /* object. */ - /* */ - /* metrics :: Metrics for this size object. This field is read-only. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_SizeRec + * + * @description: + * FreeType root size class structure. A size object models a face + * object at a given size. + * + * @fields: + * face :: + * Handle to the parent face object. + * + * generic :: + * A typeless pointer, unused by the FreeType library or any of its + * drivers. It can be used by client applications to link their own + * data to each size object. + * + * metrics :: + * Metrics for this size object. This field is read-only. + */ typedef struct FT_SizeRec_ { FT_Face face; /* parent face object */ @@ -1681,237 +1652,241 @@ FT_BEGIN_HEADER } FT_SizeRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SubGlyph */ - /* */ - /* <Description> */ - /* The subglyph structure is an internal object used to describe */ - /* subglyphs (for example, in the case of composites). */ - /* */ - /* <Note> */ - /* The subglyph implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - /* You can however retrieve subglyph information with */ - /* @FT_Get_SubGlyph_Info. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_SubGlyph + * + * @description: + * The subglyph structure is an internal object used to describe + * subglyphs (for example, in the case of composites). + * + * @note: + * The subglyph implementation is not part of the high-level API, hence + * the forward structure declaration. + * + * You can however retrieve subglyph information with + * @FT_Get_SubGlyph_Info. + */ typedef struct FT_SubGlyphRec_* FT_SubGlyph; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Slot_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ - /* model private data of a given @FT_GlyphSlot object. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Slot_Internal + * + * @description: + * An opaque handle to an `FT_Slot_InternalRec` structure, used to model + * private data of a given @FT_GlyphSlot object. + */ typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphSlotRec */ - /* */ - /* <Description> */ - /* FreeType root glyph slot class structure. A glyph slot is a */ - /* container where individual glyphs can be loaded, be they in */ - /* outline or bitmap format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library instance */ - /* this slot belongs to. */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* next :: In some cases (like some font tools), several */ - /* glyph slots per face object can be a good */ - /* thing. As this is rare, the glyph slots are */ - /* listed through a direct, single-linked list */ - /* using its `next' field. */ - /* */ - /* generic :: A typeless pointer unused by the FreeType */ - /* library or any of its drivers. It can be */ - /* used by client applications to link their own */ - /* data to each glyph slot object. */ - /* */ - /* metrics :: The metrics of the last loaded glyph in the */ - /* slot. The returned values depend on the last */ - /* load flags (see the @FT_Load_Glyph API */ - /* function) and can be expressed either in 26.6 */ - /* fractional pixels or font units. */ - /* */ - /* Note that even when the glyph image is */ - /* transformed, the metrics are not. */ - /* */ - /* linearHoriAdvance :: The advance width of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* linearVertAdvance :: The advance height of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* advance :: This shorthand is, depending on */ - /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ - /* (hinted) advance width for the glyph, in 26.6 */ - /* fractional pixel format. As specified with */ - /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ - /* `horiAdvance' or the `vertAdvance' value of */ - /* `metrics' field. */ - /* */ - /* format :: This field indicates the format of the image */ - /* contained in the glyph slot. Typically */ - /* @FT_GLYPH_FORMAT_BITMAP, */ - /* @FT_GLYPH_FORMAT_OUTLINE, or */ - /* @FT_GLYPH_FORMAT_COMPOSITE, but other values */ - /* are possible. */ - /* */ - /* bitmap :: This field is used as a bitmap descriptor. */ - /* Note that the address and content of the */ - /* bitmap buffer can change between calls of */ - /* @FT_Load_Glyph and a few other functions. */ - /* */ - /* bitmap_left :: The bitmap's left bearing expressed in */ - /* integer pixels. */ - /* */ - /* bitmap_top :: The bitmap's top bearing expressed in integer */ - /* pixels. This is the distance from the */ - /* baseline to the top-most glyph scanline, */ - /* upwards y~coordinates being *positive*. */ - /* */ - /* outline :: The outline descriptor for the current glyph */ - /* image if its format is */ - /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ - /* loaded, `outline' can be transformed, */ - /* distorted, emboldened, etc. However, it must */ - /* not be freed. */ - /* */ - /* num_subglyphs :: The number of subglyphs in a composite glyph. */ - /* This field is only valid for the composite */ - /* glyph format that should normally only be */ - /* loaded with the @FT_LOAD_NO_RECURSE flag. */ - /* */ - /* subglyphs :: An array of subglyph descriptors for */ - /* composite glyphs. There are `num_subglyphs' */ - /* elements in there. Currently internal to */ - /* FreeType. */ - /* */ - /* control_data :: Certain font drivers can also return the */ - /* control data for a given glyph image (e.g. */ - /* TrueType bytecode, Type~1 charstrings, etc.). */ - /* This field is a pointer to such data; it is */ - /* currently internal to FreeType. */ - /* */ - /* control_len :: This is the length in bytes of the control */ - /* data. Currently internal to FreeType. */ - /* */ - /* other :: Reserved. */ - /* */ - /* lsb_delta :: The difference between hinted and unhinted */ - /* left side bearing while auto-hinting is */ - /* active. Zero otherwise. */ - /* */ - /* rsb_delta :: The difference between hinted and unhinted */ - /* right side bearing while auto-hinting is */ - /* active. Zero otherwise. */ - /* */ - /* <Note> */ - /* If @FT_Load_Glyph is called with default flags (see */ - /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ - /* its native format (e.g., an outline glyph for TrueType and Type~1 */ - /* formats). [Since 2.9] The prospective bitmap metrics are */ - /* calculated according to @FT_LOAD_TARGET_XXX and other flags even */ - /* for the outline glyph, even if @FT_LOAD_RENDER is not set. */ - /* */ - /* This image can later be converted into a bitmap by calling */ - /* @FT_Render_Glyph. This function searches the current renderer for */ - /* the native image's format, then invokes it. */ - /* */ - /* The renderer is in charge of transforming the native image through */ - /* the slot's face transformation fields, then converting it into a */ - /* bitmap that is returned in `slot->bitmap'. */ - /* */ - /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ - /* to specify the position of the bitmap relative to the current pen */ - /* position (e.g., coordinates (0,0) on the baseline). Of course, */ - /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ - /* */ - /* Here is a small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta' to do fractional positioning of */ - /* glyphs: */ - /* */ - /* { */ - /* FT_GlyphSlot slot = face->glyph; */ - /* FT_Pos origin_x = 0; */ - /* */ - /* */ - /* for all glyphs do */ - /* <load glyph with `FT_Load_Glyph'> */ - /* */ - /* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */ - /* */ - /* <save glyph image, or render glyph, or ...> */ - /* */ - /* <compute kern between current and next glyph */ - /* and add it to `origin_x'> */ - /* */ - /* origin_x += slot->advance.x; */ - /* origin_x += slot->rsb_delta - slot->lsb_delta; */ - /* endfor */ - /* } */ - /* */ - /* Here is another small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta' to improve integer positioning of */ - /* glyphs: */ - /* */ - /* { */ - /* FT_GlyphSlot slot = face->glyph; */ - /* FT_Pos origin_x = 0; */ - /* FT_Pos prev_rsb_delta = 0; */ - /* */ - /* */ - /* for all glyphs do */ - /* <compute kern between current and previous glyph */ - /* and add it to `origin_x'> */ - /* */ - /* <load glyph with `FT_Load_Glyph'> */ - /* */ - /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */ - /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */ - /* origin_x += 64; */ - /* */ - /* prev_rsb_delta = slot->rsb_delta; */ - /* */ - /* <save glyph image, or render glyph, or ...> */ - /* */ - /* origin_x += slot->advance.x; */ - /* endfor */ - /* } */ - /* */ - /* If you use strong auto-hinting, you *must* apply these delta */ - /* values! Otherwise you will experience far too large inter-glyph */ - /* spacing at small rendering sizes in most cases. Note that it */ - /* doesn't harm to use the above code for other hinting modes also, */ - /* since the delta values are zero then. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_GlyphSlotRec + * + * @description: + * FreeType root glyph slot class structure. A glyph slot is a container + * where individual glyphs can be loaded, be they in outline or bitmap + * format. + * + * @fields: + * library :: + * A handle to the FreeType library instance this slot belongs to. + * + * face :: + * A handle to the parent face object. + * + * next :: + * In some cases (like some font tools), several glyph slots per face + * object can be a good thing. As this is rare, the glyph slots are + * listed through a direct, single-linked list using its `next` field. + * + * glyph_index :: + * [Since 2.10] The glyph index passed as an argument to @FT_Load_Glyph + * while initializing the glyph slot. + * + * generic :: + * A typeless pointer unused by the FreeType library or any of its + * drivers. It can be used by client applications to link their own + * data to each glyph slot object. + * + * metrics :: + * The metrics of the last loaded glyph in the slot. The returned + * values depend on the last load flags (see the @FT_Load_Glyph API + * function) and can be expressed either in 26.6 fractional pixels or + * font units. + * + * Note that even when the glyph image is transformed, the metrics are + * not. + * + * linearHoriAdvance :: + * The advance width of the unhinted glyph. Its value is expressed in + * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when + * loading the glyph. This field can be important to perform correct + * WYSIWYG layout. Only relevant for outline glyphs. + * + * linearVertAdvance :: + * The advance height of the unhinted glyph. Its value is expressed in + * 16.16 fractional pixels, unless @FT_LOAD_LINEAR_DESIGN is set when + * loading the glyph. This field can be important to perform correct + * WYSIWYG layout. Only relevant for outline glyphs. + * + * advance :: + * This shorthand is, depending on @FT_LOAD_IGNORE_TRANSFORM, the + * transformed (hinted) advance width for the glyph, in 26.6 fractional + * pixel format. As specified with @FT_LOAD_VERTICAL_LAYOUT, it uses + * either the `horiAdvance` or the `vertAdvance` value of `metrics` + * field. + * + * format :: + * This field indicates the format of the image contained in the glyph + * slot. Typically @FT_GLYPH_FORMAT_BITMAP, @FT_GLYPH_FORMAT_OUTLINE, + * or @FT_GLYPH_FORMAT_COMPOSITE, but other values are possible. + * + * bitmap :: + * This field is used as a bitmap descriptor. Note that the address + * and content of the bitmap buffer can change between calls of + * @FT_Load_Glyph and a few other functions. + * + * bitmap_left :: + * The bitmap's left bearing expressed in integer pixels. + * + * bitmap_top :: + * The bitmap's top bearing expressed in integer pixels. This is the + * distance from the baseline to the top-most glyph scanline, upwards + * y~coordinates being **positive**. + * + * outline :: + * The outline descriptor for the current glyph image if its format is + * @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is loaded, `outline` can be + * transformed, distorted, emboldened, etc. However, it must not be + * freed. + * + * [Since 2.10.1] If @FT_LOAD_NO_SCALE is set, outline coordinates of + * OpenType variation fonts for a selected instance are internally + * handled as 26.6 fractional font units but returned as (rounded) + * integers, as expected. To get unrounded font units, don't use + * @FT_LOAD_NO_SCALE but load the glyph with @FT_LOAD_NO_HINTING and + * scale it, using the font's `units_per_EM` value as the ppem. + * + * num_subglyphs :: + * The number of subglyphs in a composite glyph. This field is only + * valid for the composite glyph format that should normally only be + * loaded with the @FT_LOAD_NO_RECURSE flag. + * + * subglyphs :: + * An array of subglyph descriptors for composite glyphs. There are + * `num_subglyphs` elements in there. Currently internal to FreeType. + * + * control_data :: + * Certain font drivers can also return the control data for a given + * glyph image (e.g. TrueType bytecode, Type~1 charstrings, etc.). + * This field is a pointer to such data; it is currently internal to + * FreeType. + * + * control_len :: + * This is the length in bytes of the control data. Currently internal + * to FreeType. + * + * other :: + * Reserved. + * + * lsb_delta :: + * The difference between hinted and unhinted left side bearing while + * auto-hinting is active. Zero otherwise. + * + * rsb_delta :: + * The difference between hinted and unhinted right side bearing while + * auto-hinting is active. Zero otherwise. + * + * @note: + * If @FT_Load_Glyph is called with default flags (see @FT_LOAD_DEFAULT) + * the glyph image is loaded in the glyph slot in its native format + * (e.g., an outline glyph for TrueType and Type~1 formats). [Since 2.9] + * The prospective bitmap metrics are calculated according to + * @FT_LOAD_TARGET_XXX and other flags even for the outline glyph, even + * if @FT_LOAD_RENDER is not set. + * + * This image can later be converted into a bitmap by calling + * @FT_Render_Glyph. This function searches the current renderer for the + * native image's format, then invokes it. + * + * The renderer is in charge of transforming the native image through the + * slot's face transformation fields, then converting it into a bitmap + * that is returned in `slot->bitmap`. + * + * Note that `slot->bitmap_left` and `slot->bitmap_top` are also used to + * specify the position of the bitmap relative to the current pen + * position (e.g., coordinates (0,0) on the baseline). Of course, + * `slot->format` is also changed to @FT_GLYPH_FORMAT_BITMAP. + * + * Here is a small pseudo code fragment that shows how to use `lsb_delta` + * and `rsb_delta` to do fractional positioning of glyphs: + * + * ``` + * FT_GlyphSlot slot = face->glyph; + * FT_Pos origin_x = 0; + * + * + * for all glyphs do + * <load glyph with `FT_Load_Glyph'> + * + * FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); + * + * <save glyph image, or render glyph, or ...> + * + * <compute kern between current and next glyph + * and add it to `origin_x'> + * + * origin_x += slot->advance.x; + * origin_x += slot->lsb_delta - slot->rsb_delta; + * endfor + * ``` + * + * Here is another small pseudo code fragment that shows how to use + * `lsb_delta` and `rsb_delta` to improve integer positioning of glyphs: + * + * ``` + * FT_GlyphSlot slot = face->glyph; + * FT_Pos origin_x = 0; + * FT_Pos prev_rsb_delta = 0; + * + * + * for all glyphs do + * <compute kern between current and previous glyph + * and add it to `origin_x'> + * + * <load glyph with `FT_Load_Glyph'> + * + * if ( prev_rsb_delta - slot->lsb_delta > 32 ) + * origin_x -= 64; + * else if ( prev_rsb_delta - slot->lsb_delta < -31 ) + * origin_x += 64; + * + * prev_rsb_delta = slot->rsb_delta; + * + * <save glyph image, or render glyph, or ...> + * + * origin_x += slot->advance.x; + * endfor + * ``` + * + * If you use strong auto-hinting, you **must** apply these delta values! + * Otherwise you will experience far too large inter-glyph spacing at + * small rendering sizes in most cases. Note that it doesn't harm to use + * the above code for other hinting modes also, since the delta values + * are zero then. + */ typedef struct FT_GlyphSlotRec_ { FT_Library library; FT_Face face; FT_GlyphSlot next; - FT_UInt reserved; /* retained for binary compatibility */ + FT_UInt glyph_index; /* new in 2.10; was reserved previously */ FT_Generic generic; FT_Glyph_Metrics metrics; @@ -1952,86 +1927,92 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Init_FreeType */ - /* */ - /* <Description> */ - /* Initialize a new FreeType library object. The set of modules */ - /* that are registered by this function is determined at build time. */ - /* */ - /* <Output> */ - /* alibrary :: A handle to a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case you want to provide your own memory allocating routines, */ - /* use @FT_New_Library instead, followed by a call to */ - /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */ - /* and @FT_Set_Default_Properties. */ - /* */ - /* See the documentation of @FT_Library and @FT_Face for */ - /* multi-threading issues. */ - /* */ - /* If you need reference-counting (cf. @FT_Reference_Library), use */ - /* @FT_New_Library and @FT_Done_Library. */ - /* */ - /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ - /* set, this function reads the `FREETYPE_PROPERTIES' environment */ - /* variable to control driver properties. See section @properties */ - /* for more. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Init_FreeType + * + * @description: + * Initialize a new FreeType library object. The set of modules that are + * registered by this function is determined at build time. + * + * @output: + * alibrary :: + * A handle to a new library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * In case you want to provide your own memory allocating routines, use + * @FT_New_Library instead, followed by a call to @FT_Add_Default_Modules + * (or a series of calls to @FT_Add_Module) and + * @FT_Set_Default_Properties. + * + * See the documentation of @FT_Library and @FT_Face for multi-threading + * issues. + * + * If you need reference-counting (cf. @FT_Reference_Library), use + * @FT_New_Library and @FT_Done_Library. + * + * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is + * set, this function reads the `FREETYPE_PROPERTIES` environment + * variable to control driver properties. See section @properties for + * more. + */ FT_EXPORT( FT_Error ) FT_Init_FreeType( FT_Library *alibrary ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_FreeType */ - /* */ - /* <Description> */ - /* Destroy a given FreeType library object and all of its children, */ - /* including resources, drivers, faces, sizes, etc. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_FreeType + * + * @description: + * Destroy a given FreeType library object and all of its children, + * including resources, drivers, faces, sizes, etc. + * + * @input: + * library :: + * A handle to the target library object. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Done_FreeType( FT_Library library ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OPEN_XXX */ - /* */ - /* <Description> */ - /* A list of bit field constants used within the `flags' field of the */ - /* @FT_Open_Args structure. */ - /* */ - /* <Values> */ - /* FT_OPEN_MEMORY :: This is a memory-based stream. */ - /* */ - /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ - /* */ - /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ - /* name. */ - /* */ - /* FT_OPEN_DRIVER :: Use the `driver' field. */ - /* */ - /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ - /* */ - /* <Note> */ - /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ - /* flags are mutually exclusive. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_OPEN_XXX + * + * @description: + * A list of bit field constants used within the `flags` field of the + * @FT_Open_Args structure. + * + * @values: + * FT_OPEN_MEMORY :: + * This is a memory-based stream. + * + * FT_OPEN_STREAM :: + * Copy the stream from the `stream` field. + * + * FT_OPEN_PATHNAME :: + * Create a new input stream from a C~path name. + * + * FT_OPEN_DRIVER :: + * Use the `driver` field. + * + * FT_OPEN_PARAMS :: + * Use the `num_params` and `params` fields. + * + * @note: + * The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags + * are mutually exclusive. + */ #define FT_OPEN_MEMORY 0x1 #define FT_OPEN_STREAM 0x2 #define FT_OPEN_PATHNAME 0x4 @@ -2039,7 +2020,7 @@ FT_BEGIN_HEADER #define FT_OPEN_PARAMS 0x10 - /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */ + /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */ /* values instead */ #define ft_open_memory FT_OPEN_MEMORY #define ft_open_stream FT_OPEN_STREAM @@ -2048,91 +2029,97 @@ FT_BEGIN_HEADER #define ft_open_params FT_OPEN_PARAMS - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Parameter */ - /* */ - /* <Description> */ - /* A simple structure to pass more or less generic parameters to */ - /* @FT_Open_Face and @FT_Face_Properties. */ - /* */ - /* <Fields> */ - /* tag :: A four-byte identification tag. */ - /* */ - /* data :: A pointer to the parameter data. */ - /* */ - /* <Note> */ - /* The ID and function of parameters are driver-specific. See */ - /* section @parameter_tags for more information. */ - /* */ - typedef struct FT_Parameter_ - { - FT_ULong tag; + /************************************************************************** + * + * @struct: + * FT_Parameter + * + * @description: + * A simple structure to pass more or less generic parameters to + * @FT_Open_Face and @FT_Face_Properties. + * + * @fields: + * tag :: + * A four-byte identification tag. + * + * data :: + * A pointer to the parameter data. + * + * @note: + * The ID and function of parameters are driver-specific. See section + * @parameter_tags for more information. + */ + typedef struct FT_Parameter_ + { + FT_ULong tag; FT_Pointer data; } FT_Parameter; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Open_Args */ - /* */ - /* <Description> */ - /* A structure to indicate how to open a new font file or stream. A */ - /* pointer to such a structure can be used as a parameter for the */ - /* functions @FT_Open_Face and @FT_Attach_Stream. */ - /* */ - /* <Fields> */ - /* flags :: A set of bit flags indicating how to use the */ - /* structure. */ - /* */ - /* memory_base :: The first byte of the file in memory. */ - /* */ - /* memory_size :: The size in bytes of the file in memory. */ - /* */ - /* pathname :: A pointer to an 8-bit file pathname. */ - /* */ - /* stream :: A handle to a source stream object. */ - /* */ - /* driver :: This field is exclusively used by @FT_Open_Face; */ - /* it simply specifies the font driver to use for */ - /* opening the face. If set to NULL, FreeType tries */ - /* to load the face with each one of the drivers in */ - /* its list. */ - /* */ - /* num_params :: The number of extra parameters. */ - /* */ - /* params :: Extra parameters passed to the font driver when */ - /* opening a new face. */ - /* */ - /* <Note> */ - /* The stream type is determined by the contents of `flags' that */ - /* are tested in the following order by @FT_Open_Face: */ - /* */ - /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */ - /* memory file of `memory_size' bytes, located at `memory_address'. */ - /* The data are not copied, and the client is responsible for */ - /* releasing and destroying them _after_ the corresponding call to */ - /* @FT_Done_Face. */ - /* */ - /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */ - /* custom input stream `stream' is used. */ - /* */ - /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */ - /* is a normal file and use `pathname' to open it. */ - /* */ - /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */ - /* open the file with the driver whose handler is in `driver'. */ - /* */ - /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */ - /* `num_params' and `params' is used. They are ignored otherwise. */ - /* */ - /* Ideally, both the `pathname' and `params' fields should be tagged */ - /* as `const'; this is missing for API backward compatibility. In */ - /* other words, applications should treat them as read-only. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Open_Args + * + * @description: + * A structure to indicate how to open a new font file or stream. A + * pointer to such a structure can be used as a parameter for the + * functions @FT_Open_Face and @FT_Attach_Stream. + * + * @fields: + * flags :: + * A set of bit flags indicating how to use the structure. + * + * memory_base :: + * The first byte of the file in memory. + * + * memory_size :: + * The size in bytes of the file in memory. + * + * pathname :: + * A pointer to an 8-bit file pathname. + * + * stream :: + * A handle to a source stream object. + * + * driver :: + * This field is exclusively used by @FT_Open_Face; it simply specifies + * the font driver to use for opening the face. If set to `NULL`, + * FreeType tries to load the face with each one of the drivers in its + * list. + * + * num_params :: + * The number of extra parameters. + * + * params :: + * Extra parameters passed to the font driver when opening a new face. + * + * @note: + * The stream type is determined by the contents of `flags` that are + * tested in the following order by @FT_Open_Face: + * + * If the @FT_OPEN_MEMORY bit is set, assume that this is a memory file + * of `memory_size` bytes, located at `memory_address`. The data are not + * copied, and the client is responsible for releasing and destroying + * them _after_ the corresponding call to @FT_Done_Face. + * + * Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a custom + * input stream `stream` is used. + * + * Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this is a + * normal file and use `pathname` to open it. + * + * If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to open + * the file with the driver whose handler is in `driver`. + * + * If the @FT_OPEN_PARAMS bit is set, the parameters given by + * `num_params` and `params` is used. They are ignored otherwise. + * + * Ideally, both the `pathname` and `params` fields should be tagged as + * 'const'; this is missing for API backward compatibility. In other + * words, applications should treat them as read-only. + */ typedef struct FT_Open_Args_ { FT_UInt flags; @@ -2147,34 +2134,37 @@ FT_BEGIN_HEADER } FT_Open_Args; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face */ - /* */ - /* <Description> */ - /* Call @FT_Open_Face to open a font by its pathname. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* pathname :: A path to the font file. */ - /* */ - /* face_index :: See @FT_Open_Face for a detailed description of this */ - /* parameter. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ - /* with its slot and sizes). */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face + * + * @description: + * Call @FT_Open_Face to open a font by its pathname. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * pathname :: + * A path to the font file. + * + * face_index :: + * See @FT_Open_Face for a detailed description of this parameter. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Use @FT_Done_Face to destroy the created @FT_Face object (along with + * its slot and sizes). + */ FT_EXPORT( FT_Error ) FT_New_Face( FT_Library library, const char* filepathname, @@ -2182,36 +2172,39 @@ FT_BEGIN_HEADER FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory_Face */ - /* */ - /* <Description> */ - /* Call @FT_Open_Face to open a font that has been loaded into */ - /* memory. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* file_base :: A pointer to the beginning of the font data. */ - /* */ - /* file_size :: The size of the memory chunk used by the font data. */ - /* */ - /* face_index :: See @FT_Open_Face for a detailed description of this */ - /* parameter. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You must not deallocate the memory before calling @FT_Done_Face. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Memory_Face + * + * @description: + * Call @FT_Open_Face to open a font that has been loaded into memory. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * file_base :: + * A pointer to the beginning of the font data. + * + * file_size :: + * The size of the memory chunk used by the font data. + * + * face_index :: + * See @FT_Open_Face for a detailed description of this parameter. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You must not deallocate the memory before calling @FT_Done_Face. + */ FT_EXPORT( FT_Error ) FT_New_Memory_Face( FT_Library library, const FT_Byte* file_base, @@ -2220,147 +2213,143 @@ FT_BEGIN_HEADER FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Open_Face */ - /* */ - /* <Description> */ - /* Create a face object from a given resource described by */ - /* @FT_Open_Args. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* args :: A pointer to an `FT_Open_Args' structure that must */ - /* be filled by the caller. */ - /* */ - /* face_index :: This field holds two different values. Bits 0-15 */ - /* are the index of the face in the font file (starting */ - /* with value~0). Set it to~0 if there is only one */ - /* face in the font file. */ - /* */ - /* [Since 2.6.1] Bits 16-30 are relevant to GX and */ - /* OpenType variation fonts only, specifying the named */ - /* instance index for the current face index (starting */ - /* with value~1; value~0 makes FreeType ignore named */ - /* instances). For non-variation fonts, bits 16-30 are */ - /* ignored. Assuming that you want to access the third */ - /* named instance in face~4, `face_index' should be set */ - /* to 0x00030004. If you want to access face~4 without */ - /* variation handling, simply set `face_index' to */ - /* value~4. */ - /* */ - /* `FT_Open_Face' and its siblings can be used to */ - /* quickly check whether the font format of a given */ - /* font resource is supported by FreeType. In general, */ - /* if the `face_index' argument is negative, the */ - /* function's return value is~0 if the font format is */ - /* recognized, or non-zero otherwise. The function */ - /* allocates a more or less empty face handle in */ - /* `*aface' (if `aface' isn't NULL); the only two */ - /* useful fields in this special case are */ - /* `face->num_faces' and `face->style_flags'. For any */ - /* negative value of `face_index', `face->num_faces' */ - /* gives the number of faces within the font file. For */ - /* the negative value `-(N+1)' (with `N' a non-negative */ - /* 16-bit value), bits 16-30 in `face->style_flags' */ - /* give the number of named instances in face `N' if we */ - /* have a variation font (or zero otherwise). After */ - /* examination, the returned @FT_Face structure should */ - /* be deallocated with a call to @FT_Done_Face. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object that can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Each new face object created with this function also owns a */ - /* default @FT_Size object, accessible as `face->size'. */ - /* */ - /* One @FT_Library instance can have multiple face objects, this is, */ - /* @FT_Open_Face and its siblings can be called multiple times using */ - /* the same `library' argument. */ - /* */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ - /* To loop over all faces, use code similar to the following snippet */ - /* (omitting the error handling). */ - /* */ - /* { */ - /* ... */ - /* FT_Face face; */ - /* FT_Long i, num_faces; */ - /* */ - /* */ - /* error = FT_Open_Face( library, args, -1, &face ); */ - /* if ( error ) { ... } */ - /* */ - /* num_faces = face->num_faces; */ - /* FT_Done_Face( face ); */ - /* */ - /* for ( i = 0; i < num_faces; i++ ) */ - /* { */ - /* ... */ - /* error = FT_Open_Face( library, args, i, &face ); */ - /* ... */ - /* FT_Done_Face( face ); */ - /* ... */ - /* } */ - /* } */ - /* */ - /* To loop over all valid values for `face_index', use something */ - /* similar to the following snippet, again without error handling. */ - /* The code accesses all faces immediately (thus only a single call */ - /* of `FT_Open_Face' within the do-loop), with and without named */ - /* instances. */ - /* */ - /* { */ - /* ... */ - /* FT_Face face; */ - /* */ - /* FT_Long num_faces = 0; */ - /* FT_Long num_instances = 0; */ - /* */ - /* FT_Long face_idx = 0; */ - /* FT_Long instance_idx = 0; */ - /* */ - /* */ - /* do */ - /* { */ - /* FT_Long id = ( instance_idx << 16 ) + face_idx; */ - /* */ - /* */ - /* error = FT_Open_Face( library, args, id, &face ); */ - /* if ( error ) { ... } */ - /* */ - /* num_faces = face->num_faces; */ - /* num_instances = face->style_flags >> 16; */ - /* */ - /* ... */ - /* */ - /* FT_Done_Face( face ); */ - /* */ - /* if ( instance_idx < num_instances ) */ - /* instance_idx++; */ - /* else */ - /* { */ - /* face_idx++; */ - /* instance_idx = 0; */ - /* } */ - /* */ - /* } while ( face_idx < num_faces ) */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_Open_Face + * + * @description: + * Create a face object from a given resource described by @FT_Open_Args. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * args :: + * A pointer to an `FT_Open_Args` structure that must be filled by the + * caller. + * + * face_index :: + * This field holds two different values. Bits 0-15 are the index of + * the face in the font file (starting with value~0). Set it to~0 if + * there is only one face in the font file. + * + * [Since 2.6.1] Bits 16-30 are relevant to GX and OpenType variation + * fonts only, specifying the named instance index for the current face + * index (starting with value~1; value~0 makes FreeType ignore named + * instances). For non-variation fonts, bits 16-30 are ignored. + * Assuming that you want to access the third named instance in face~4, + * `face_index` should be set to 0x00030004. If you want to access + * face~4 without variation handling, simply set `face_index` to + * value~4. + * + * `FT_Open_Face` and its siblings can be used to quickly check whether + * the font format of a given font resource is supported by FreeType. + * In general, if the `face_index` argument is negative, the function's + * return value is~0 if the font format is recognized, or non-zero + * otherwise. The function allocates a more or less empty face handle + * in `*aface` (if `aface` isn't `NULL`); the only two useful fields in + * this special case are `face->num_faces` and `face->style_flags`. + * For any negative value of `face_index`, `face->num_faces` gives the + * number of faces within the font file. For the negative value + * '-(N+1)' (with 'N' a non-negative 16-bit value), bits 16-30 in + * `face->style_flags` give the number of named instances in face 'N' + * if we have a variation font (or zero otherwise). After examination, + * the returned @FT_Face structure should be deallocated with a call to + * @FT_Done_Face. + * + * @output: + * aface :: + * A handle to a new face object. If `face_index` is greater than or + * equal to zero, it must be non-`NULL`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Unlike FreeType 1.x, this function automatically creates a glyph slot + * for the face object that can be accessed directly through + * `face->glyph`. + * + * Each new face object created with this function also owns a default + * @FT_Size object, accessible as `face->size`. + * + * One @FT_Library instance can have multiple face objects, this is, + * @FT_Open_Face and its siblings can be called multiple times using the + * same `library` argument. + * + * See the discussion of reference counters in the description of + * @FT_Reference_Face. + * + * @example: + * To loop over all faces, use code similar to the following snippet + * (omitting the error handling). + * + * ``` + * ... + * FT_Face face; + * FT_Long i, num_faces; + * + * + * error = FT_Open_Face( library, args, -1, &face ); + * if ( error ) { ... } + * + * num_faces = face->num_faces; + * FT_Done_Face( face ); + * + * for ( i = 0; i < num_faces; i++ ) + * { + * ... + * error = FT_Open_Face( library, args, i, &face ); + * ... + * FT_Done_Face( face ); + * ... + * } + * ``` + * + * To loop over all valid values for `face_index`, use something similar + * to the following snippet, again without error handling. The code + * accesses all faces immediately (thus only a single call of + * `FT_Open_Face` within the do-loop), with and without named instances. + * + * ``` + * ... + * FT_Face face; + * + * FT_Long num_faces = 0; + * FT_Long num_instances = 0; + * + * FT_Long face_idx = 0; + * FT_Long instance_idx = 0; + * + * + * do + * { + * FT_Long id = ( instance_idx << 16 ) + face_idx; + * + * + * error = FT_Open_Face( library, args, id, &face ); + * if ( error ) { ... } + * + * num_faces = face->num_faces; + * num_instances = face->style_flags >> 16; + * + * ... + * + * FT_Done_Face( face ); + * + * if ( instance_idx < num_instances ) + * instance_idx++; + * else + * { + * face_idx++; + * instance_idx = 0; + * } + * + * } while ( face_idx < num_faces ) + * ``` + */ FT_EXPORT( FT_Error ) FT_Open_Face( FT_Library library, const FT_Open_Args* args, @@ -2368,204 +2357,208 @@ FT_BEGIN_HEADER FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_File */ - /* */ - /* <Description> */ - /* Call @FT_Attach_Stream to attach a file. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* filepathname :: The pathname. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Attach_File + * + * @description: + * Call @FT_Attach_Stream to attach a file. + * + * @inout: + * face :: + * The target face object. + * + * @input: + * filepathname :: + * The pathname. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Attach_File( FT_Face face, const char* filepathname ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_Stream */ - /* */ - /* <Description> */ - /* `Attach' data to a face object. Normally, this is used to read */ - /* additional information for the face object. For example, you can */ - /* attach an AFM file that comes with a Type~1 font to get the */ - /* kerning values and other metrics. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* parameters :: A pointer to @FT_Open_Args that must be filled by */ - /* the caller. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The meaning of the `attach' (i.e., what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file or stream attachments. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Attach_Stream + * + * @description: + * 'Attach' data to a face object. Normally, this is used to read + * additional information for the face object. For example, you can + * attach an AFM file that comes with a Type~1 font to get the kerning + * values and other metrics. + * + * @inout: + * face :: + * The target face object. + * + * @input: + * parameters :: + * A pointer to @FT_Open_Args that must be filled by the caller. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The meaning of the 'attach' (i.e., what really happens when the new + * file is read) is not fixed by FreeType itself. It really depends on + * the font format (and thus the font driver). + * + * Client applications are expected to know what they are doing when + * invoking this function. Most drivers simply do not implement file or + * stream attachments. + */ FT_EXPORT( FT_Error ) FT_Attach_Stream( FT_Face face, FT_Open_Args* parameters ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Face */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Face structure */ - /* is created. This function increments the counter. @FT_Done_Face */ - /* then only destroys a face if the counter is~1, otherwise it simply */ - /* decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Face objects. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Reference_Face + * + * @description: + * A counter gets initialized to~1 at the time an @FT_Face structure is + * created. This function increments the counter. @FT_Done_Face then + * only destroys a face if the counter is~1, otherwise it simply + * decrements the counter. + * + * This function helps in managing life-cycles of structures that + * reference @FT_Face objects. + * + * @input: + * face :: + * A handle to a target face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.4.2 + */ FT_EXPORT( FT_Error ) FT_Reference_Face( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Face */ - /* */ - /* <Description> */ - /* Discard a given face object, as well as all of its child slots and */ - /* sizes. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Face + * + * @description: + * Discard a given face object, as well as all of its child slots and + * sizes. + * + * @input: + * face :: + * A handle to a target face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Face. + */ FT_EXPORT( FT_Error ) FT_Done_Face( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Size */ - /* */ - /* <Description> */ - /* Select a bitmap strike. To be more precise, this function sets */ - /* the scaling factors of the active @FT_Size object in a face so */ - /* that bitmaps from this particular strike are taken by */ - /* @FT_Load_Glyph and friends. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* strike_index :: The index of the bitmap strike in the */ - /* `available_sizes' field of @FT_FaceRec structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* For bitmaps embedded in outline fonts it is common that only a */ - /* subset of the available glyphs at a given ppem value is available. */ - /* FreeType silently uses outlines if there is no bitmap for a given */ - /* glyph index. */ - /* */ - /* For GX and OpenType variation fonts, a bitmap strike makes sense */ - /* only if the default instance is active (this is, no glyph */ - /* variation takes place); otherwise, FreeType simply ignores bitmap */ - /* strikes. The same is true for all named instances that are */ - /* different from the default instance. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Select_Size + * + * @description: + * Select a bitmap strike. To be more precise, this function sets the + * scaling factors of the active @FT_Size object in a face so that + * bitmaps from this particular strike are taken by @FT_Load_Glyph and + * friends. + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * strike_index :: + * The index of the bitmap strike in the `available_sizes` field of + * @FT_FaceRec structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * For bitmaps embedded in outline fonts it is common that only a subset + * of the available glyphs at a given ppem value is available. FreeType + * silently uses outlines if there is no bitmap for a given glyph index. + * + * For GX and OpenType variation fonts, a bitmap strike makes sense only + * if the default instance is active (this is, no glyph variation takes + * place); otherwise, FreeType simply ignores bitmap strikes. The same + * is true for all named instances that are different from the default + * instance. + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Select_Size( FT_Face face, FT_Int strike_index ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Size_Request_Type */ - /* */ - /* <Description> */ - /* An enumeration type that lists the supported size request types, */ - /* i.e., what input size (in font units) maps to the requested output */ - /* size (in pixels, as computed from the arguments of */ - /* @FT_Size_Request). */ - /* */ - /* <Values> */ - /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ - /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ - /* used to determine both scaling values. */ - /* */ - /* This is the standard scaling found in most applications. In */ - /* particular, use this size request type for TrueType fonts if */ - /* they provide optical scaling or something similar. Note, */ - /* however, that `units_per_EM' is a rather abstract value which */ - /* bears no relation to the actual size of the glyphs in a font. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ - /* The real dimension. The sum of the `ascender' and (minus of) */ - /* the `descender' fields of @FT_FaceRec is used to determine both */ - /* scaling values. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_BBOX :: */ - /* The font bounding box. The width and height of the `bbox' field */ - /* of @FT_FaceRec are used to determine the horizontal and vertical */ - /* scaling value, respectively. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_CELL :: */ - /* The `max_advance_width' field of @FT_FaceRec is used to */ - /* determine the horizontal scaling value; the vertical scaling */ - /* value is determined the same way as */ - /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ - /* values are set to the smaller one. This type is useful if you */ - /* want to specify the font size for, say, a window of a given */ - /* dimension and 80x24 cells. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_SCALES :: */ - /* Specify the scaling values directly. */ - /* */ - /* <Note> */ - /* The above descriptions only apply to scalable formats. For bitmap */ - /* formats, the behaviour is up to the driver. */ - /* */ - /* See the note section of @FT_Size_Metrics if you wonder how size */ - /* requesting relates to scaling values. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Size_Request_Type + * + * @description: + * An enumeration type that lists the supported size request types, i.e., + * what input size (in font units) maps to the requested output size (in + * pixels, as computed from the arguments of @FT_Size_Request). + * + * @values: + * FT_SIZE_REQUEST_TYPE_NOMINAL :: + * The nominal size. The `units_per_EM` field of @FT_FaceRec is used + * to determine both scaling values. + * + * This is the standard scaling found in most applications. In + * particular, use this size request type for TrueType fonts if they + * provide optical scaling or something similar. Note, however, that + * `units_per_EM` is a rather abstract value which bears no relation to + * the actual size of the glyphs in a font. + * + * FT_SIZE_REQUEST_TYPE_REAL_DIM :: + * The real dimension. The sum of the `ascender` and (minus of) the + * `descender` fields of @FT_FaceRec is used to determine both scaling + * values. + * + * FT_SIZE_REQUEST_TYPE_BBOX :: + * The font bounding box. The width and height of the `bbox` field of + * @FT_FaceRec are used to determine the horizontal and vertical + * scaling value, respectively. + * + * FT_SIZE_REQUEST_TYPE_CELL :: + * The `max_advance_width` field of @FT_FaceRec is used to determine + * the horizontal scaling value; the vertical scaling value is + * determined the same way as @FT_SIZE_REQUEST_TYPE_REAL_DIM does. + * Finally, both scaling values are set to the smaller one. This type + * is useful if you want to specify the font size for, say, a window of + * a given dimension and 80x24 cells. + * + * FT_SIZE_REQUEST_TYPE_SCALES :: + * Specify the scaling values directly. + * + * @note: + * The above descriptions only apply to scalable formats. For bitmap + * formats, the behaviour is up to the driver. + * + * See the note section of @FT_Size_Metrics if you wonder how size + * requesting relates to scaling values. + */ typedef enum FT_Size_Request_Type_ { FT_SIZE_REQUEST_TYPE_NOMINAL, @@ -2579,42 +2572,45 @@ FT_BEGIN_HEADER } FT_Size_Request_Type; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_RequestRec */ - /* */ - /* <Description> */ - /* A structure to model a size request. */ - /* */ - /* <Fields> */ - /* type :: See @FT_Size_Request_Type. */ - /* */ - /* width :: The desired width, given as a 26.6 fractional */ - /* point value (with 72pt = 1in). */ - /* */ - /* height :: The desired height, given as a 26.6 fractional */ - /* point value (with 72pt = 1in). */ - /* */ - /* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */ - /* inch). If set to zero, `width' is treated as a */ - /* 26.6 fractional *pixel* value, which gets */ - /* internally rounded to an integer. */ - /* */ - /* vertResolution :: The vertical resolution (dpi, i.e., pixels per */ - /* inch). If set to zero, `height' is treated as a */ - /* 26.6 fractional *pixel* value, which gets */ - /* internally rounded to an integer. */ - /* */ - /* <Note> */ - /* If `width' is zero, the horizontal scaling value is set equal */ - /* to the vertical scaling value, and vice versa. */ - /* */ - /* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */ - /* interpreted directly as 16.16 fractional scaling values, without */ - /* any further modification, and both `horiResolution' and */ - /* `vertResolution' are ignored. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Size_RequestRec + * + * @description: + * A structure to model a size request. + * + * @fields: + * type :: + * See @FT_Size_Request_Type. + * + * width :: + * The desired width, given as a 26.6 fractional point value (with 72pt + * = 1in). + * + * height :: + * The desired height, given as a 26.6 fractional point value (with + * 72pt = 1in). + * + * horiResolution :: + * The horizontal resolution (dpi, i.e., pixels per inch). If set to + * zero, `width` is treated as a 26.6 fractional **pixel** value, which + * gets internally rounded to an integer. + * + * vertResolution :: + * The vertical resolution (dpi, i.e., pixels per inch). If set to + * zero, `height` is treated as a 26.6 fractional **pixel** value, + * which gets internally rounded to an integer. + * + * @note: + * If `width` is zero, the horizontal scaling value is set equal to the + * vertical scaling value, and vice versa. + * + * If `type` is `FT_SIZE_REQUEST_TYPE_SCALES`, `width` and `height` are + * interpreted directly as 16.16 fractional scaling values, without any + * further modification, and both `horiResolution` and `vertResolution` + * are ignored. + */ typedef struct FT_Size_RequestRec_ { FT_Size_Request_Type type; @@ -2626,96 +2622,102 @@ FT_BEGIN_HEADER } FT_Size_RequestRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Request */ - /* */ - /* <Description> */ - /* A handle to a size request structure. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Size_Request + * + * @description: + * A handle to a size request structure. + */ typedef struct FT_Size_RequestRec_ *FT_Size_Request; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Request_Size */ - /* */ - /* <Description> */ - /* Resize the scale of the active @FT_Size object in a face. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* req :: A pointer to a @FT_Size_RequestRec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Although drivers may select the bitmap strike matching the */ - /* request, you should not rely on this if you intend to select a */ - /* particular bitmap strike. Use @FT_Select_Size instead in that */ - /* case. */ - /* */ - /* The relation between the requested size and the resulting glyph */ - /* size is dependent entirely on how the size is defined in the */ - /* source face. The font designer chooses the final size of each */ - /* glyph relative to this size. For more information refer to */ - /* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */ - /* */ - /* Contrary to @FT_Set_Char_Size, this function doesn't have special */ - /* code to normalize zero-valued widths, heights, or resolutions */ - /* (which lead to errors in most cases). */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Request_Size + * + * @description: + * Resize the scale of the active @FT_Size object in a face. + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * req :: + * A pointer to a @FT_Size_RequestRec. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Although drivers may select the bitmap strike matching the request, + * you should not rely on this if you intend to select a particular + * bitmap strike. Use @FT_Select_Size instead in that case. + * + * The relation between the requested size and the resulting glyph size + * is dependent entirely on how the size is defined in the source face. + * The font designer chooses the final size of each glyph relative to + * this size. For more information refer to + * 'https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. + * + * Contrary to @FT_Set_Char_Size, this function doesn't have special code + * to normalize zero-valued widths, heights, or resolutions (which lead + * to errors in most cases). + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Request_Size( FT_Face face, FT_Size_Request req ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Char_Size */ - /* */ - /* <Description> */ - /* Call @FT_Request_Size to request the nominal size (in points). */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* char_width :: The nominal width, in 26.6 fractional points. */ - /* */ - /* char_height :: The nominal height, in 26.6 fractional points. */ - /* */ - /* horz_resolution :: The horizontal resolution in dpi. */ - /* */ - /* vert_resolution :: The vertical resolution in dpi. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* While this function allows fractional points as input values, the */ - /* resulting ppem value for the given resolution is always rounded to */ - /* the nearest integer. */ - /* */ - /* If either the character width or height is zero, it is set equal */ - /* to the other value. */ - /* */ - /* If either the horizontal or vertical resolution is zero, it is set */ - /* equal to the other value. */ - /* */ - /* A character width or height smaller than 1pt is set to 1pt; if */ - /* both resolution values are zero, they are set to 72dpi. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Char_Size + * + * @description: + * Call @FT_Request_Size to request the nominal size (in points). + * + * @inout: + * face :: + * A handle to a target face object. + * + * @input: + * char_width :: + * The nominal width, in 26.6 fractional points. + * + * char_height :: + * The nominal height, in 26.6 fractional points. + * + * horz_resolution :: + * The horizontal resolution in dpi. + * + * vert_resolution :: + * The vertical resolution in dpi. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * While this function allows fractional points as input values, the + * resulting ppem value for the given resolution is always rounded to the + * nearest integer. + * + * If either the character width or height is zero, it is set equal to + * the other value. + * + * If either the horizontal or vertical resolution is zero, it is set + * equal to the other value. + * + * A character width or height smaller than 1pt is set to 1pt; if both + * resolution values are zero, they are set to 72dpi. + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Set_Char_Size( FT_Face face, FT_F26Dot6 char_width, @@ -2724,134 +2726,138 @@ FT_BEGIN_HEADER FT_UInt vert_resolution ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Pixel_Sizes */ - /* */ - /* <Description> */ - /* Call @FT_Request_Size to request the nominal size (in pixels). */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* pixel_width :: The nominal width, in pixels. */ - /* */ - /* pixel_height :: The nominal height, in pixels. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should not rely on the resulting glyphs matching or being */ - /* constrained to this pixel size. Refer to @FT_Request_Size to */ - /* understand how requested sizes relate to actual sizes. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Pixel_Sizes + * + * @description: + * Call @FT_Request_Size to request the nominal size (in pixels). + * + * @inout: + * face :: + * A handle to the target face object. + * + * @input: + * pixel_width :: + * The nominal width, in pixels. + * + * pixel_height :: + * The nominal height, in pixels. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You should not rely on the resulting glyphs matching or being + * constrained to this pixel size. Refer to @FT_Request_Size to + * understand how requested sizes relate to actual sizes. + * + * Don't use this function if you are using the FreeType cache API. + */ FT_EXPORT( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Glyph */ - /* */ - /* <Description> */ - /* Load a glyph into the glyph slot of a face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* glyph_index :: The index of the glyph in the font file. For */ - /* CID-keyed fonts (either in PS or in CFF format) */ - /* this argument specifies the CID value. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The loaded glyph may be transformed. See @FT_Set_Transform for */ - /* the details. */ - /* */ - /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ - /* returned for invalid CID values (this is, for CID values that */ - /* don't have a corresponding glyph in the font). See the discussion */ - /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ - /* */ - /* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */ - /* outline at EM size, then scale it manually and fill it as a */ - /* graphics operation. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Load_Glyph + * + * @description: + * Load a glyph into the glyph slot of a face object. + * + * @inout: + * face :: + * A handle to the target face object where the glyph is loaded. + * + * @input: + * glyph_index :: + * The index of the glyph in the font file. For CID-keyed fonts + * (either in PS or in CFF format) this argument specifies the CID + * value. + * + * load_flags :: + * A flag indicating what to load for this glyph. The @FT_LOAD_XXX + * constants can be used to control the glyph loading process (e.g., + * whether the outline should be scaled, whether to load bitmaps or + * not, whether to hint the outline, etc). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The loaded glyph may be transformed. See @FT_Set_Transform for the + * details. + * + * For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument` is returned + * for invalid CID values (this is, for CID values that don't have a + * corresponding glyph in the font). See the discussion of the + * @FT_FACE_FLAG_CID_KEYED flag for more details. + * + * If you receive `FT_Err_Glyph_Too_Big`, try getting the glyph outline + * at EM size, then scale it manually and fill it as a graphics + * operation. + */ FT_EXPORT( FT_Error ) FT_Load_Glyph( FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Char */ - /* */ - /* <Description> */ - /* Load a glyph into the glyph slot of a face object, accessed by its */ - /* character code. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* char_code :: The glyph's character code, according to the */ - /* current charmap used in the face. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ - /* */ - /* Many fonts contain glyphs that can't be loaded by this function */ - /* since its glyph indices are not listed in any of the font's */ - /* charmaps. */ - /* */ - /* If no active cmap is set up (i.e., `face->charmap' is zero), the */ - /* call to @FT_Get_Char_Index is omitted, and the function behaves */ - /* identically to @FT_Load_Glyph. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Load_Char + * + * @description: + * Load a glyph into the glyph slot of a face object, accessed by its + * character code. + * + * @inout: + * face :: + * A handle to a target face object where the glyph is loaded. + * + * @input: + * char_code :: + * The glyph's character code, according to the current charmap used in + * the face. + * + * load_flags :: + * A flag indicating what to load for this glyph. The @FT_LOAD_XXX + * constants can be used to control the glyph loading process (e.g., + * whether the outline should be scaled, whether to load bitmaps or + * not, whether to hint the outline, etc). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. + * + * Many fonts contain glyphs that can't be loaded by this function since + * its glyph indices are not listed in any of the font's charmaps. + * + * If no active cmap is set up (i.e., `face->charmap` is zero), the call + * to @FT_Get_Char_Index is omitted, and the function behaves identically + * to @FT_Load_Glyph. + */ FT_EXPORT( FT_Error ) FT_Load_Char( FT_Face face, FT_ULong char_code, FT_Int32 load_flags ); - /************************************************************************* + /************************************************************************** * * @enum: * FT_LOAD_XXX * * @description: - * A list of bit field constants for @FT_Load_Glyph to indicate what - * kind of operations to perform during glyph loading. + * A list of bit field constants for @FT_Load_Glyph to indicate what kind + * of operations to perform during glyph loading. * * @values: * FT_LOAD_DEFAULT :: @@ -2859,15 +2865,14 @@ FT_BEGIN_HEADER * operation. In this case, the following happens: * * 1. FreeType looks for a bitmap for the glyph corresponding to the - * face's current size. If one is found, the function returns. - * The bitmap data can be accessed from the glyph slot (see note - * below). + * face's current size. If one is found, the function returns. The + * bitmap data can be accessed from the glyph slot (see note below). * * 2. If no embedded bitmap is searched for or found, FreeType looks - * for a scalable outline. If one is found, it is loaded from - * the font file, scaled to device pixels, then `hinted' to the - * pixel grid in order to optimize it. The outline data can be - * accessed from the glyph slot (see note below). + * for a scalable outline. If one is found, it is loaded from the font + * file, scaled to device pixels, then 'hinted' to the pixel grid in + * order to optimize it. The outline data can be accessed from the + * glyph slot (see note below). * * Note that by default the glyph loader doesn't render outlines into * bitmaps. The following flags are used to modify this default @@ -2879,14 +2884,14 @@ FT_BEGIN_HEADER * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and * unsets @FT_LOAD_RENDER. * - * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using - * FT_LOAD_NO_SCALE usually yields meaningless outlines because the - * subglyphs must be scaled and positioned with hinting instructions. - * This can be solved by loading the font without FT_LOAD_NO_SCALE and - * setting the character size to `font->units_per_EM'. + * If the font is 'tricky' (see @FT_FACE_FLAG_TRICKY for more), using + * `FT_LOAD_NO_SCALE` usually yields meaningless outlines because the + * subglyphs must be scaled and positioned with hinting instructions. + * This can be solved by loading the font without `FT_LOAD_NO_SCALE` + * and setting the character size to `font->units_per_EM`. * * FT_LOAD_NO_HINTING :: - * Disable hinting. This generally generates `blurrier' bitmap glyphs + * Disable hinting. This generally generates 'blurrier' bitmap glyphs * when the glyph are rendered in any of the anti-aliased modes. See * also the note below. * @@ -2907,34 +2912,37 @@ FT_BEGIN_HEADER * * FT_LOAD_VERTICAL_LAYOUT :: * Load the glyph for vertical text layout. In particular, the - * `advance' value in the @FT_GlyphSlotRec structure is set to the - * `vertAdvance' value of the `metrics' field. + * `advance` value in the @FT_GlyphSlotRec structure is set to the + * `vertAdvance` value of the `metrics` field. * - * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use - * this flag currently. Reason is that in this case vertical metrics - * get synthesized, and those values are not always consistent across + * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use this + * flag currently. Reason is that in this case vertical metrics get + * synthesized, and those values are not always consistent across * various font formats. * * FT_LOAD_FORCE_AUTOHINT :: - * Prefer the auto-hinter over the font's native hinter. See also - * the note below. + * Prefer the auto-hinter over the font's native hinter. See also the + * note below. * * FT_LOAD_PEDANTIC :: * Make the font driver perform pedantic verifications during glyph - * loading. This is mostly used to detect broken glyphs in fonts. - * By default, FreeType tries to handle broken fonts also. + * loading and hinting. This is mostly used to detect broken glyphs in + * fonts. By default, FreeType tries to handle broken fonts also. * * In particular, errors from the TrueType bytecode engine are not - * passed to the application if this flag is not set; this might - * result in partially hinted or distorted glyphs in case a glyph's - * bytecode is buggy. + * passed to the application if this flag is not set; this might result + * in partially hinted or distorted glyphs in case a glyph's bytecode + * is buggy. * * FT_LOAD_NO_RECURSE :: - * Don't load composite glyphs recursively. Instead, the font - * driver should set the `num_subglyph' and `subglyphs' values of - * the glyph slot accordingly, and set `glyph->format' to - * @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can - * then be accessed with @FT_Get_SubGlyph_Info. + * Don't load composite glyphs recursively. Instead, the font driver + * fills the `num_subglyph` and `subglyphs` values of the glyph slot; + * it also sets `glyph->format` to @FT_GLYPH_FORMAT_COMPOSITE. The + * description of subglyphs can then be accessed with + * @FT_Get_SubGlyph_Info. + * + * Don't use this flag for retrieving metrics information since some + * font drivers only return rudimentary data. * * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. * @@ -2951,23 +2959,35 @@ FT_BEGIN_HEADER * monochrome-optimized hinting algorithm is used. * * FT_LOAD_LINEAR_DESIGN :: - * Keep `linearHoriAdvance' and `linearVertAdvance' fields of - * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for - * details. + * Keep `linearHoriAdvance` and `linearVertAdvance` fields of + * @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for details. * * FT_LOAD_NO_AUTOHINT :: * Disable the auto-hinter. See also the note below. * * FT_LOAD_COLOR :: + * Load colored glyphs. There are slight differences depending on the + * font format. + * * [Since 2.5] Load embedded color bitmap images. The resulting color - * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format. - * If the flag is not set and color bitmaps are found, they are - * converted to 256-level gray bitmaps transparently, using the - * @FT_PIXEL_MODE_GRAY format. + * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format, + * with pre-multiplied color channels. If the flag is not set and + * color bitmaps are found, they are converted to 256-level gray + * bitmaps, using the @FT_PIXEL_MODE_GRAY format. + * + * [Since 2.10, experimental] If the glyph index contains an entry in + * the face's 'COLR' table with a 'CPAL' palette table (as defined in + * the OpenType specification), make @FT_Render_Glyph provide a default + * blending of the color glyph layers associated with the glyph index, + * using the same bitmap format as embedded color bitmap images. This + * is mainly for convenience; for full control of color layers use + * @FT_Get_Color_Glyph_Layer and FreeType's color functions like + * @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering + * so that the client application can handle blending by itself. * * FT_LOAD_COMPUTE_METRICS :: - * [Since 2.6.1] Compute glyph metrics from the glyph data, without - * the use of bundled metrics tables (for example, the `hdmx' table in + * [Since 2.6.1] Compute glyph metrics from the glyph data, without the + * use of bundled metrics tables (for example, the 'hdmx' table in * TrueType fonts). This flag is mainly used by font validating or * font editing applications, which need to ignore, verify, or edit * those tables. @@ -2976,9 +2996,9 @@ FT_BEGIN_HEADER * * FT_LOAD_BITMAP_METRICS_ONLY :: * [Since 2.7.1] Request loading of the metrics and bitmap image - * information of a (possibly embedded) bitmap glyph without - * allocating or copying the bitmap image data itself. No effect if - * the target glyph is not a bitmap image. + * information of a (possibly embedded) bitmap glyph without allocating + * or copying the bitmap image data itself. No effect if the target + * glyph is not a bitmap image. * * This flag unsets @FT_LOAD_RENDER. * @@ -2993,8 +3013,8 @@ FT_BEGIN_HEADER * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can * disable hinting by setting @FT_LOAD_NO_HINTING or change the * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set - * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be - * used at all. + * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be used + * at all. * * See the description of @FT_FACE_FLAG_TRICKY for a special exception * (affecting only a handful of Asian fonts). @@ -3005,7 +3025,7 @@ FT_BEGIN_HEADER * Note that the auto-hinter needs a valid Unicode cmap (either a native * one or synthesized by FreeType) for producing correct results. If a * font provides an incorrect mapping (for example, assigning the - * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a + * character code U+005A, LATIN CAPITAL LETTER~Z, to a glyph depicting a * mathematical integral sign), the auto-hinter might produce useless * results. * @@ -3025,7 +3045,7 @@ FT_BEGIN_HEADER #define FT_LOAD_MONOCHROME ( 1L << 12 ) #define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) #define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) - /* Bits 16-19 are used by `FT_LOAD_TARGET_' */ + /* Bits 16-19 are used by `FT_LOAD_TARGET_` */ #define FT_LOAD_COLOR ( 1L << 20 ) #define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) #define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 ) @@ -3044,19 +3064,17 @@ FT_BEGIN_HEADER * * @description: * A list of values to select a specific hinting algorithm for the - * hinter. You should OR one of these values to your `load_flags' - * when calling @FT_Load_Glyph. + * hinter. You should OR one of these values to your `load_flags` when + * calling @FT_Load_Glyph. * - * Note that a font's native hinters may ignore the hinting algorithm - * you have specified (e.g., the TrueType bytecode interpreter). You - * can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is - * used. + * Note that a font's native hinters may ignore the hinting algorithm you + * have specified (e.g., the TrueType bytecode interpreter). You can set + * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. * * @values: * FT_LOAD_TARGET_NORMAL :: * The default hinting algorithm, optimized for standard gray-level - * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO - * instead. + * rendering. For monochrome output, use @FT_LOAD_TARGET_MONO instead. * * FT_LOAD_TARGET_LIGHT :: * A lighter hinting algorithm for gray-level modes. Many generated @@ -3069,13 +3087,13 @@ FT_BEGIN_HEADER * auto-hinter. * * Advance widths are rounded to integer values; however, using the - * `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is + * `lsb_delta` and `rsb_delta` fields of @FT_GlyphSlotRec, it is * possible to get fractional advance widths for subpixel positioning * (which is recommended to use). * - * If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active, - * TrueType-like metrics are used to make this mode behave similarly - * as in unpatched FreeType versions between 2.4.6 and 2.7.1 + * If configuration option `AF_CONFIG_OPTION_TT_SIZE_METRICS` is + * active, TrueType-like metrics are used to make this mode behave + * similarly as in unpatched FreeType versions between 2.4.6 and 2.7.1 * (inclusive). * * FT_LOAD_TARGET_MONO :: @@ -3083,6 +3101,12 @@ FT_BEGIN_HEADER * output. The result is probably unpleasant if the glyph is rendered * in non-monochrome modes. * + * Note that for outline fonts only the TrueType font driver has proper + * monochrome hinting support, provided the TTFs contain hints for B/W + * rendering (which most fonts no longer provide). If these conditions + * are not met it is very likely that you get ugly results at smaller + * sizes. + * * FT_LOAD_TARGET_LCD :: * A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally * decimated LCD displays. @@ -3092,25 +3116,25 @@ FT_BEGIN_HEADER * decimated LCD displays. * * @note: - * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your - * `load_flags'. They can't be ORed. + * You should use only _one_ of the `FT_LOAD_TARGET_XXX` values in your + * `load_flags`. They can't be ORed. * * If @FT_LOAD_RENDER is also set, the glyph is rendered in the * corresponding mode (i.e., the mode that matches the used algorithm - * best). An exception is FT_LOAD_TARGET_MONO since it implies + * best). An exception is `FT_LOAD_TARGET_MONO` since it implies * @FT_LOAD_MONOCHROME. * * You can use a hinting algorithm that doesn't correspond to the same - * rendering mode. As an example, it is possible to use the `light' + * rendering mode. As an example, it is possible to use the 'light' * hinting algorithm and have the results rendered in horizontal LCD * pixel mode, with code like * - * { - * FT_Load_Glyph( face, glyph_index, - * load_flags | FT_LOAD_TARGET_LIGHT ); + * ``` + * FT_Load_Glyph( face, glyph_index, + * load_flags | FT_LOAD_TARGET_LIGHT ); * - * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); - * } + * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); + * ``` * * In general, you should stick with one rendering mode. For example, * switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO @@ -3142,98 +3166,98 @@ FT_BEGIN_HEADER #define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Transform */ - /* */ - /* <Description> */ - /* Set the transformation that is applied to glyph images when they */ - /* are loaded into a glyph slot through @FT_Load_Glyph. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */ - /* for the identity matrix. */ - /* delta :: A pointer to the translation vector. Use NULL for the */ - /* null vector. */ - /* */ - /* <Note> */ - /* The transformation is only applied to scalable image formats after */ - /* the glyph has been loaded. It means that hinting is unaltered by */ - /* the transformation and is performed on the character size given in */ - /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Transform + * + * @description: + * Set the transformation that is applied to glyph images when they are + * loaded into a glyph slot through @FT_Load_Glyph. + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * matrix :: + * A pointer to the transformation's 2x2 matrix. Use `NULL` for the + * identity matrix. + * delta :: + * A pointer to the translation vector. Use `NULL` for the null vector. + * + * @note: + * The transformation is only applied to scalable image formats after the + * glyph has been loaded. It means that hinting is unaltered by the + * transformation and is performed on the character size given in the + * last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. + * + * Note that this also transforms the `face.glyph.advance` field, but + * **not** the values in `face.glyph.metrics`. + */ FT_EXPORT( void ) FT_Set_Transform( FT_Face face, FT_Matrix* matrix, FT_Vector* delta ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Render_Mode */ - /* */ - /* <Description> */ - /* Render modes supported by FreeType~2. Each mode corresponds to a */ - /* specific type of scanline conversion performed on the outline. */ - /* */ - /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ - /* field in the @FT_GlyphSlotRec structure gives the format of the */ - /* returned bitmap. */ - /* */ - /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */ - /* indicating pixel coverage. Use linear alpha blending and gamma */ - /* correction to correctly render non-monochrome glyph bitmaps onto a */ - /* surface; see @FT_Render_Glyph. */ - /* */ - /* <Values> */ - /* FT_RENDER_MODE_NORMAL :: */ - /* Default render mode; it corresponds to 8-bit anti-aliased */ - /* bitmaps. */ - /* */ - /* FT_RENDER_MODE_LIGHT :: */ - /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ - /* defined as a separate value because render modes are also used */ - /* indirectly to define hinting algorithm selectors. See */ - /* @FT_LOAD_TARGET_XXX for details. */ - /* */ - /* FT_RENDER_MODE_MONO :: */ - /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ - /* opacity). */ - /* */ - /* FT_RENDER_MODE_LCD :: */ - /* This mode corresponds to horizontal RGB and BGR subpixel */ - /* displays like LCD screens. It produces 8-bit bitmaps that are */ - /* 3~times the width of the original glyph outline in pixels, and */ - /* which use the @FT_PIXEL_MODE_LCD mode. */ - /* */ - /* FT_RENDER_MODE_LCD_V :: */ - /* This mode corresponds to vertical RGB and BGR subpixel displays */ - /* (like PDA screens, rotated LCD displays, etc.). It produces */ - /* 8-bit bitmaps that are 3~times the height of the original */ - /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ - /* */ - /* <Note> */ - /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */ - /* `ftoption.h', which enables patented ClearType-style rendering, */ - /* the LCD-optimized glyph bitmaps should be filtered to reduce color */ - /* fringes inherent to this technology. You can either set up LCD */ - /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */ - /* or do the filtering yourself. The default FreeType LCD rendering */ - /* technology does not require filtering. */ - /* */ - /* The selected render mode only affects vector glyphs of a font. */ - /* Embedded bitmaps often have a different pixel mode like */ - /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ - /* them into 8-bit pixmaps. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Render_Mode + * + * @description: + * Render modes supported by FreeType~2. Each mode corresponds to a + * specific type of scanline conversion performed on the outline. + * + * For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode` field + * in the @FT_GlyphSlotRec structure gives the format of the returned + * bitmap. + * + * All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, + * indicating pixel coverage. Use linear alpha blending and gamma + * correction to correctly render non-monochrome glyph bitmaps onto a + * surface; see @FT_Render_Glyph. + * + * @values: + * FT_RENDER_MODE_NORMAL :: + * Default render mode; it corresponds to 8-bit anti-aliased bitmaps. + * + * FT_RENDER_MODE_LIGHT :: + * This is equivalent to @FT_RENDER_MODE_NORMAL. It is only defined as + * a separate value because render modes are also used indirectly to + * define hinting algorithm selectors. See @FT_LOAD_TARGET_XXX for + * details. + * + * FT_RENDER_MODE_MONO :: + * This mode corresponds to 1-bit bitmaps (with 2~levels of opacity). + * + * FT_RENDER_MODE_LCD :: + * This mode corresponds to horizontal RGB and BGR subpixel displays + * like LCD screens. It produces 8-bit bitmaps that are 3~times the + * width of the original glyph outline in pixels, and which use the + * @FT_PIXEL_MODE_LCD mode. + * + * FT_RENDER_MODE_LCD_V :: + * This mode corresponds to vertical RGB and BGR subpixel displays + * (like PDA screens, rotated LCD displays, etc.). It produces 8-bit + * bitmaps that are 3~times the height of the original glyph outline in + * pixels and use the @FT_PIXEL_MODE_LCD_V mode. + * + * @note: + * Should you define `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` in your + * `ftoption.h`, which enables patented ClearType-style rendering, the + * LCD-optimized glyph bitmaps should be filtered to reduce color fringes + * inherent to this technology. You can either set up LCD filtering with + * @FT_Library_SetLcdFilter or @FT_Face_Properties, or do the filtering + * yourself. The default FreeType LCD rendering technology does not + * require filtering. + * + * The selected render mode only affects vector glyphs of a font. + * Embedded bitmaps often have a different pixel mode like + * @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform them + * into 8-bit pixmaps. + */ typedef enum FT_Render_Mode_ { FT_RENDER_MODE_NORMAL = 0, @@ -3248,147 +3272,149 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Render_Mode' values instead */ + /* `FT_Render_Mode` values instead */ #define ft_render_mode_normal FT_RENDER_MODE_NORMAL #define ft_render_mode_mono FT_RENDER_MODE_MONO - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Render_Glyph */ - /* */ - /* <Description> */ - /* Convert a given glyph image to a bitmap. It does so by inspecting */ - /* the glyph image format, finding the relevant renderer, and */ - /* invoking it. */ - /* */ - /* <InOut> */ - /* slot :: A handle to the glyph slot containing the image to */ - /* convert. */ - /* */ - /* <Input> */ - /* render_mode :: The render mode used to render the glyph image into */ - /* a bitmap. See @FT_Render_Mode for a list of */ - /* possible values. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */ - /* */ - /* When FreeType outputs a bitmap of a glyph, it really outputs an */ - /* alpha coverage map. If a pixel is completely covered by a */ - /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */ - /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */ - /* pixel is 100% black (or 0% bright). If a pixel is only 50% */ - /* covered (value 0x80), the pixel is made 50% black (50% bright or a */ - /* middle shade of grey). 0% covered means 0% black (100% bright or */ - /* white). */ - /* */ - /* On high-DPI screens like on smartphones and tablets, the pixels */ - /* are so small that their chance of being completely covered and */ - /* therefore completely black are fairly good. On the low-DPI */ - /* screens, however, the situation is different. The pixels are too */ - /* large for most of the details of a glyph and shades of gray are */ - /* the norm rather than the exception. */ - /* */ - /* This is relevant because all our screens have a second problem: */ - /* they are not linear. 1~+~1 is not~2. Twice the value does not */ - /* result in twice the brightness. When a pixel is only 50% covered, */ - /* the coverage map says 50% black, and this translates to a pixel */ - /* value of 128 when you use 8~bits per channel (0-255). However, */ - /* this does not translate to 50% brightness for that pixel on our */ - /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ - /* dwell longer in the darks and only a pixel value of about 186 */ - /* results in 50% brightness -- 128 ends up too dark on both bright */ - /* and dark backgrounds. The net result is that dark text looks */ - /* burnt-out, pixely and blotchy on bright background, bright text */ - /* too frail on dark backgrounds, and colored text on colored */ - /* background (for example, red on green) seems to have dark halos or */ - /* `dirt' around it. The situation is especially ugly for diagonal */ - /* stems like in `w' glyph shapes where the quality of FreeType's */ - /* anti-aliasing depends on the correct display of grays. On */ - /* high-DPI screens where smaller, fully black pixels reign supreme, */ - /* this doesn't matter, but on our low-DPI screens with all the gray */ - /* shades, it does. 0% and 100% brightness are the same things in */ - /* linear and non-linear space, just all the shades in-between */ - /* aren't. */ - /* */ - /* The blending function for placing text over a background is */ - /* */ - /* { */ - /* dst = alpha * src + (1 - alpha) * dst , */ - /* } */ - /* */ - /* which is known as the OVER operator. */ - /* */ - /* To correctly composite an antialiased pixel of a glyph onto a */ - /* surface, */ - /* */ - /* 1. take the foreground and background colors (e.g., in sRGB space) */ - /* and apply gamma to get them in a linear space, */ - /* */ - /* 2. use OVER to blend the two linear colors using the glyph pixel */ - /* as the alpha value (remember, the glyph bitmap is an alpha */ - /* coverage bitmap), and */ - /* */ - /* 3. apply inverse gamma to the blended pixel and write it back to */ - /* the image. */ - /* */ - /* Internal testing at Adobe found that a target inverse gamma of~1.8 */ - /* for step~3 gives good results across a wide range of displays with */ - /* an sRGB gamma curve or a similar one. */ - /* */ - /* This process can cost performance. There is an approximation that */ - /* does not need to know about the background color; see */ - /* https://bel.fi/alankila/lcd/ and */ - /* https://bel.fi/alankila/lcd/alpcor.html for details. */ - /* */ - /* *ATTENTION*: Linear blending is even more important when dealing */ - /* with subpixel-rendered glyphs to prevent color-fringing! A */ - /* subpixel-rendered glyph must first be filtered with a filter that */ - /* gives equal weight to the three color primaries and does not */ - /* exceed a sum of 0x100, see section @lcd_filtering. Then the */ - /* only difference to gray linear blending is that subpixel-rendered */ - /* linear blending is done 3~times per pixel: red foreground subpixel */ - /* to red background subpixel and so on for green and blue. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Render_Glyph + * + * @description: + * Convert a given glyph image to a bitmap. It does so by inspecting the + * glyph image format, finding the relevant renderer, and invoking it. + * + * @inout: + * slot :: + * A handle to the glyph slot containing the image to convert. + * + * @input: + * render_mode :: + * The render mode used to render the glyph image into a bitmap. See + * @FT_Render_Mode for a list of possible values. + * + * If @FT_RENDER_MODE_NORMAL is used, a previous call of @FT_Load_Glyph + * with flag @FT_LOAD_COLOR makes FT_Render_Glyph provide a default + * blending of colored glyph layers associated with the current glyph + * slot (provided the font contains such layers) instead of rendering + * the glyph slot's outline. This is an experimental feature; see + * @FT_LOAD_COLOR for more information. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * To get meaningful results, font scaling values must be set with + * functions like @FT_Set_Char_Size before calling `FT_Render_Glyph`. + * + * When FreeType outputs a bitmap of a glyph, it really outputs an alpha + * coverage map. If a pixel is completely covered by a filled-in + * outline, the bitmap contains 0xFF at that pixel, meaning that + * 0xFF/0xFF fraction of that pixel is covered, meaning the pixel is 100% + * black (or 0% bright). If a pixel is only 50% covered (value 0x80), + * the pixel is made 50% black (50% bright or a middle shade of grey). + * 0% covered means 0% black (100% bright or white). + * + * On high-DPI screens like on smartphones and tablets, the pixels are so + * small that their chance of being completely covered and therefore + * completely black are fairly good. On the low-DPI screens, however, + * the situation is different. The pixels are too large for most of the + * details of a glyph and shades of gray are the norm rather than the + * exception. + * + * This is relevant because all our screens have a second problem: they + * are not linear. 1~+~1 is not~2. Twice the value does not result in + * twice the brightness. When a pixel is only 50% covered, the coverage + * map says 50% black, and this translates to a pixel value of 128 when + * you use 8~bits per channel (0-255). However, this does not translate + * to 50% brightness for that pixel on our sRGB and gamma~2.2 screens. + * Due to their non-linearity, they dwell longer in the darks and only a + * pixel value of about 186 results in 50% brightness -- 128 ends up too + * dark on both bright and dark backgrounds. The net result is that dark + * text looks burnt-out, pixely and blotchy on bright background, bright + * text too frail on dark backgrounds, and colored text on colored + * background (for example, red on green) seems to have dark halos or + * 'dirt' around it. The situation is especially ugly for diagonal stems + * like in 'w' glyph shapes where the quality of FreeType's anti-aliasing + * depends on the correct display of grays. On high-DPI screens where + * smaller, fully black pixels reign supreme, this doesn't matter, but on + * our low-DPI screens with all the gray shades, it does. 0% and 100% + * brightness are the same things in linear and non-linear space, just + * all the shades in-between aren't. + * + * The blending function for placing text over a background is + * + * ``` + * dst = alpha * src + (1 - alpha) * dst , + * ``` + * + * which is known as the OVER operator. + * + * To correctly composite an antialiased pixel of a glyph onto a surface, + * + * 1. take the foreground and background colors (e.g., in sRGB space) + * and apply gamma to get them in a linear space, + * + * 2. use OVER to blend the two linear colors using the glyph pixel + * as the alpha value (remember, the glyph bitmap is an alpha coverage + * bitmap), and + * + * 3. apply inverse gamma to the blended pixel and write it back to + * the image. + * + * Internal testing at Adobe found that a target inverse gamma of~1.8 for + * step~3 gives good results across a wide range of displays with an sRGB + * gamma curve or a similar one. + * + * This process can cost performance. There is an approximation that + * does not need to know about the background color; see + * https://bel.fi/alankila/lcd/ and + * https://bel.fi/alankila/lcd/alpcor.html for details. + * + * **ATTENTION**: Linear blending is even more important when dealing + * with subpixel-rendered glyphs to prevent color-fringing! A + * subpixel-rendered glyph must first be filtered with a filter that + * gives equal weight to the three color primaries and does not exceed a + * sum of 0x100, see section @lcd_rendering. Then the only difference to + * gray linear blending is that subpixel-rendered linear blending is done + * 3~times per pixel: red foreground subpixel to red background subpixel + * and so on for green and blue. + */ FT_EXPORT( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot, FT_Render_Mode render_mode ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Kerning_Mode */ - /* */ - /* <Description> */ - /* An enumeration to specify the format of kerning values returned by */ - /* @FT_Get_Kerning. */ - /* */ - /* <Values> */ - /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ - /* 26.6 fractional pixels. */ - /* */ - /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ - /* 26.6 fractional pixels. */ - /* */ - /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ - /* units. */ - /* */ - /* <Note> */ - /* FT_KERNING_DEFAULT returns full pixel values; it also makes */ - /* FreeType heuristically scale down kerning distances at small ppem */ - /* values so that they don't become too big. */ - /* */ - /* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */ - /* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */ - /* convert font units to pixels. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Kerning_Mode + * + * @description: + * An enumeration to specify the format of kerning values returned by + * @FT_Get_Kerning. + * + * @values: + * FT_KERNING_DEFAULT :: + * Return grid-fitted kerning distances in 26.6 fractional pixels. + * + * FT_KERNING_UNFITTED :: + * Return un-grid-fitted kerning distances in 26.6 fractional pixels. + * + * FT_KERNING_UNSCALED :: + * Return the kerning vector in original font units. + * + * @note: + * `FT_KERNING_DEFAULT` returns full pixel values; it also makes FreeType + * heuristically scale down kerning distances at small ppem values so + * that they don't become too big. + * + * Both `FT_KERNING_DEFAULT` and `FT_KERNING_UNFITTED` use the current + * horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to + * convert font units to pixels. + */ typedef enum FT_Kerning_Mode_ { FT_KERNING_DEFAULT = 0, @@ -3399,50 +3425,53 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Kerning_Mode' values instead */ + /* `FT_Kerning_Mode` values instead */ #define ft_kerning_default FT_KERNING_DEFAULT #define ft_kerning_unfitted FT_KERNING_UNFITTED #define ft_kerning_unscaled FT_KERNING_UNSCALED - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Kerning */ - /* */ - /* <Description> */ - /* Return the kerning vector between two glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* kern_mode :: See @FT_Kerning_Mode for more information. */ - /* Determines the scale and dimension of the returned */ - /* kerning vector. */ - /* */ - /* <Output> */ - /* akerning :: The kerning vector. This is either in font units, */ - /* fractional pixels (26.6 format), or pixels for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this method. Other layouts, or more sophisticated */ - /* kernings, are out of the scope of this API function -- they can be */ - /* implemented through format-specific interfaces. */ - /* */ - /* Kerning for OpenType fonts implemented in a `GPOS' table is not */ - /* supported; use @FT_HAS_KERNING to find out whether a font has data */ - /* that can be extracted with `FT_Get_Kerning'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Kerning + * + * @description: + * Return the kerning vector between two glyphs of the same face. + * + * @input: + * face :: + * A handle to a source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * kern_mode :: + * See @FT_Kerning_Mode for more information. Determines the scale and + * dimension of the returned kerning vector. + * + * @output: + * akerning :: + * The kerning vector. This is either in font units, fractional pixels + * (26.6 format), or pixels for scalable formats, and in pixels for + * fixed-sizes formats. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Only horizontal layouts (left-to-right & right-to-left) are supported + * by this method. Other layouts, or more sophisticated kernings, are + * out of the scope of this API function -- they can be implemented + * through format-specific interfaces. + * + * Kerning for OpenType fonts implemented in a 'GPOS' table is not + * supported; use @FT_HAS_KERNING to find out whether a font has data + * that can be extracted with `FT_Get_Kerning`. + */ FT_EXPORT( FT_Error ) FT_Get_Kerning( FT_Face face, FT_UInt left_glyph, @@ -3451,39 +3480,42 @@ FT_BEGIN_HEADER FT_Vector *akerning ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Track_Kerning */ - /* */ - /* <Description> */ - /* Return the track kerning for a given face object at a given size. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* point_size :: The point size in 16.16 fractional points. */ - /* */ - /* degree :: The degree of tightness. Increasingly negative */ - /* values represent tighter track kerning, while */ - /* increasingly positive values represent looser track */ - /* kerning. Value zero means no track kerning. */ - /* */ - /* <Output> */ - /* akerning :: The kerning in 16.16 fractional points, to be */ - /* uniformly applied between all glyphs. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Currently, only the Type~1 font driver supports track kerning, */ - /* using data from AFM files (if attached with @FT_Attach_File or */ - /* @FT_Attach_Stream). */ - /* */ - /* Only very few AFM files come with track kerning data; please refer */ - /* to Adobe's AFM specification for more details. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Track_Kerning + * + * @description: + * Return the track kerning for a given face object at a given size. + * + * @input: + * face :: + * A handle to a source face object. + * + * point_size :: + * The point size in 16.16 fractional points. + * + * degree :: + * The degree of tightness. Increasingly negative values represent + * tighter track kerning, while increasingly positive values represent + * looser track kerning. Value zero means no track kerning. + * + * @output: + * akerning :: + * The kerning in 16.16 fractional points, to be uniformly applied + * between all glyphs. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Currently, only the Type~1 font driver supports track kerning, using + * data from AFM files (if attached with @FT_Attach_File or + * @FT_Attach_Stream). + * + * Only very few AFM files come with track kerning data; please refer to + * Adobe's AFM specification for more details. + */ FT_EXPORT( FT_Error ) FT_Get_Track_Kerning( FT_Face face, FT_Fixed point_size, @@ -3491,45 +3523,46 @@ FT_BEGIN_HEADER FT_Fixed* akerning ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII name of a given glyph in a face. This only */ - /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* buffer_max :: The maximum number of bytes available in the */ - /* buffer. */ - /* */ - /* <Output> */ - /* buffer :: A pointer to a target buffer where the name is */ - /* copied to. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error is returned if the face doesn't provide glyph names or if */ - /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' is set to~0 to indicate an empty name. */ - /* */ - /* The glyph name is truncated to fit within the buffer if it is too */ - /* long. The returned string is always zero-terminated. */ - /* */ - /* Be aware that FreeType reorders glyph indices internally so that */ - /* glyph index~0 always corresponds to the `missing glyph' (called */ - /* `.notdef'). */ - /* */ - /* This function always returns an error if the config macro */ - /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Glyph_Name + * + * @description: + * Retrieve the ASCII name of a given glyph in a face. This only works + * for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. + * + * @input: + * face :: + * A handle to a source face object. + * + * glyph_index :: + * The glyph index. + * + * buffer_max :: + * The maximum number of bytes available in the buffer. + * + * @output: + * buffer :: + * A pointer to a target buffer where the name is copied to. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An error is returned if the face doesn't provide glyph names or if the + * glyph index is invalid. In all cases of failure, the first byte of + * `buffer` is set to~0 to indicate an empty name. + * + * The glyph name is truncated to fit within the buffer if it is too + * long. The returned string is always zero-terminated. + * + * Be aware that FreeType reorders glyph indices internally so that glyph + * index~0 always corresponds to the 'missing glyph' (called '.notdef'). + * + * This function always returns an error if the config macro + * `FT_CONFIG_OPTION_NO_GLYPH_NAMES` is not defined in `ftoption.h`. + */ FT_EXPORT( FT_Error ) FT_Get_Glyph_Name( FT_Face face, FT_UInt glyph_index, @@ -3537,107 +3570,109 @@ FT_BEGIN_HEADER FT_UInt buffer_max ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Postscript_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII PostScript name of a given face, if available. */ - /* This only works with PostScript, TrueType, and OpenType fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to the face's PostScript name. NULL if unavailable. */ - /* */ - /* <Note> */ - /* The returned pointer is owned by the face and is destroyed with */ - /* it. */ - /* */ - /* For variation fonts, this string changes if you select a different */ - /* instance, and you have to call `FT_Get_PostScript_Name' again to */ - /* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */ - /* PostScript Names for Fonts Using OpenType Font Variations'. */ - /* */ - /* https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html */ - /* */ - /* [Since 2.9] Special PostScript names for named instances are only */ - /* returned if the named instance is set with @FT_Set_Named_Instance */ - /* (and the font has corresponding entries in its `fvar' table). If */ - /* @FT_IS_VARIATION returns true, the algorithmically derived */ - /* PostScript name is provided, not looking up special entries for */ - /* named instances. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Postscript_Name + * + * @description: + * Retrieve the ASCII PostScript name of a given face, if available. + * This only works with PostScript, TrueType, and OpenType fonts. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * A pointer to the face's PostScript name. `NULL` if unavailable. + * + * @note: + * The returned pointer is owned by the face and is destroyed with it. + * + * For variation fonts, this string changes if you select a different + * instance, and you have to call `FT_Get_PostScript_Name` again to + * retrieve it. FreeType follows Adobe TechNote #5902, 'Generating + * PostScript Names for Fonts Using OpenType Font Variations'. + * + * https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html + * + * [Since 2.9] Special PostScript names for named instances are only + * returned if the named instance is set with @FT_Set_Named_Instance (and + * the font has corresponding entries in its 'fvar' table). If + * @FT_IS_VARIATION returns true, the algorithmically derived PostScript + * name is provided, not looking up special entries for named instances. + */ FT_EXPORT( const char* ) FT_Get_Postscript_Name( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap by its encoding tag (as listed in */ - /* `freetype.h'). */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* encoding :: A handle to the selected encoding. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if no charmap in the face */ - /* corresponds to the encoding queried here. */ - /* */ - /* Because many fonts contain more than a single cmap for Unicode */ - /* encoding, this function has some special code to select the one */ - /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ - /* preferred to a UCS-2 cmap). It is thus preferable to */ - /* @FT_Set_Charmap in this case. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Select_Charmap + * + * @description: + * Select a given charmap by its encoding tag (as listed in + * `freetype.h`). + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * encoding :: + * A handle to the selected encoding. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function returns an error if no charmap in the face corresponds + * to the encoding queried here. + * + * Because many fonts contain more than a single cmap for Unicode + * encoding, this function has some special code to select the one that + * covers Unicode best ('best' in the sense that a UCS-4 cmap is + * preferred to a UCS-2 cmap). It is thus preferable to @FT_Set_Charmap + * in this case. + */ FT_EXPORT( FT_Error ) FT_Select_Charmap( FT_Face face, FT_Encoding encoding ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap for character code to glyph index mapping. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the selected charmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the `face->charmaps' */ - /* table). */ - /* */ - /* It also fails if an OpenType type~14 charmap is selected (which */ - /* doesn't map character codes to glyph indices at all). */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Charmap + * + * @description: + * Select a given charmap for character code to glyph index mapping. + * + * @inout: + * face :: + * A handle to the source face object. + * + * @input: + * charmap :: + * A handle to the selected charmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function returns an error if the charmap is not part of the face + * (i.e., if it is not listed in the `face->charmaps` table). + * + * It also fails if an OpenType type~14 charmap is selected (which + * doesn't map character codes to glyph indices at all). + */ FT_EXPORT( FT_Error ) FT_Set_Charmap( FT_Face face, FT_CharMap charmap ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Get_Charmap_Index @@ -3651,139 +3686,143 @@ FT_BEGIN_HEADER * * @return: * The index into the array of character maps within the face to which - * `charmap' belongs. If an error occurs, -1 is returned. + * `charmap` belongs. If an error occurs, -1 is returned. * */ FT_EXPORT( FT_Int ) FT_Get_Charmap_Index( FT_CharMap charmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Char_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code. This function */ - /* uses the currently selected charmap to do the mapping. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within the */ - /* file. This is done to ensure that value~0 always corresponds to */ - /* the `missing glyph'. If the first glyph is not named `.notdef', */ - /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ - /* the glyph ID~0 position, and whatever was there will be moved to */ - /* the position `.notdef' had. For Type~1 fonts, if there is no */ - /* `.notdef' glyph at all, then one will be created at index~0 and */ - /* whatever was there will be moved to the last index -- Type~42 */ - /* fonts are considered invalid under this condition. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Char_Index + * + * @description: + * Return the glyph index of a given character code. This function uses + * the currently selected charmap to do the mapping. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character code. + * + * @return: + * The glyph index. 0~means 'undefined character code'. + * + * @note: + * If you use FreeType to manipulate the contents of font files directly, + * be aware that the glyph index returned by this function doesn't always + * correspond to the internal indices used within the file. This is done + * to ensure that value~0 always corresponds to the 'missing glyph'. If + * the first glyph is not named '.notdef', then for Type~1 and Type~42 + * fonts, '.notdef' will be moved into the glyph ID~0 position, and + * whatever was there will be moved to the position '.notdef' had. For + * Type~1 fonts, if there is no '.notdef' glyph at all, then one will be + * created at index~0 and whatever was there will be moved to the last + * index -- Type~42 fonts are considered invalid under this condition. + */ FT_EXPORT( FT_UInt ) FT_Get_Char_Index( FT_Face face, FT_ULong charcode ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_First_Char */ - /* */ - /* <Description> */ - /* Return the first character code in the current charmap of a given */ - /* face, together with its corresponding glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of first character code. 0~if charmap is */ - /* empty. */ - /* */ - /* <Return> */ - /* The charmap's first character code. */ - /* */ - /* <Note> */ - /* You should use this function together with @FT_Get_Next_Char to */ - /* parse all character codes available in a given charmap. The code */ - /* should look like this: */ - /* */ - /* { */ - /* FT_ULong charcode; */ - /* FT_UInt gindex; */ - /* */ - /* */ - /* charcode = FT_Get_First_Char( face, &gindex ); */ - /* while ( gindex != 0 ) */ - /* { */ - /* ... do something with (charcode,gindex) pair ... */ - /* */ - /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ - /* } */ - /* } */ - /* */ - /* Be aware that character codes can have values up to 0xFFFFFFFF; */ - /* this might happen for non-Unicode or malformed cmaps. However, */ - /* even with regular Unicode encoding, so-called `last resort fonts' */ - /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */ - /* normally have entries for all Unicode characters up to 0x1FFFFF, */ - /* which can cause *a lot* of iterations. */ - /* */ - /* Note that `*agindex' is set to~0 if the charmap is empty. The */ - /* result itself can be~0 in two cases: if the charmap is empty or */ - /* if the value~0 is the first valid character code. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_First_Char + * + * @description: + * Return the first character code in the current charmap of a given + * face, together with its corresponding glyph index. + * + * @input: + * face :: + * A handle to the source face object. + * + * @output: + * agindex :: + * Glyph index of first character code. 0~if charmap is empty. + * + * @return: + * The charmap's first character code. + * + * @note: + * You should use this function together with @FT_Get_Next_Char to parse + * all character codes available in a given charmap. The code should + * look like this: + * + * ``` + * FT_ULong charcode; + * FT_UInt gindex; + * + * + * charcode = FT_Get_First_Char( face, &gindex ); + * while ( gindex != 0 ) + * { + * ... do something with (charcode,gindex) pair ... + * + * charcode = FT_Get_Next_Char( face, charcode, &gindex ); + * } + * ``` + * + * Be aware that character codes can have values up to 0xFFFFFFFF; this + * might happen for non-Unicode or malformed cmaps. However, even with + * regular Unicode encoding, so-called 'last resort fonts' (using SFNT + * cmap format 13, see function @FT_Get_CMap_Format) normally have + * entries for all Unicode characters up to 0x1FFFFF, which can cause *a + * lot* of iterations. + * + * Note that `*agindex` is set to~0 if the charmap is empty. The result + * itself can be~0 in two cases: if the charmap is empty or if the + * value~0 is the first valid character code. + */ FT_EXPORT( FT_ULong ) FT_Get_First_Char( FT_Face face, FT_UInt *agindex ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Next_Char */ - /* */ - /* <Description> */ - /* Return the next character code in the current charmap of a given */ - /* face following the value `char_code', as well as the corresponding */ - /* glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* char_code :: The starting character code. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of next character code. 0~if charmap */ - /* is empty. */ - /* */ - /* <Return> */ - /* The charmap's next character code. */ - /* */ - /* <Note> */ - /* You should use this function with @FT_Get_First_Char to walk */ - /* over all character codes available in a given charmap. See the */ - /* note for that function for a simple code example. */ - /* */ - /* Note that `*agindex' is set to~0 when there are no more codes in */ - /* the charmap. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Next_Char + * + * @description: + * Return the next character code in the current charmap of a given face + * following the value `char_code`, as well as the corresponding glyph + * index. + * + * @input: + * face :: + * A handle to the source face object. + * + * char_code :: + * The starting character code. + * + * @output: + * agindex :: + * Glyph index of next character code. 0~if charmap is empty. + * + * @return: + * The charmap's next character code. + * + * @note: + * You should use this function with @FT_Get_First_Char to walk over all + * character codes available in a given charmap. See the note for that + * function for a simple code example. + * + * Note that `*agindex` is set to~0 when there are no more codes in the + * charmap. + */ FT_EXPORT( FT_ULong ) FT_Get_Next_Char( FT_Face face, FT_ULong char_code, FT_UInt *agindex ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Face_Properties @@ -3791,27 +3830,26 @@ FT_BEGIN_HEADER * @description: * Set or override certain (library or module-wide) properties on a * face-by-face basis. Useful for finer-grained control and avoiding - * locks on shared structures (threads can modify their own faces as - * they see fit). + * locks on shared structures (threads can modify their own faces as they + * see fit). * - * Contrary to @FT_Property_Set, this function uses @FT_Parameter so - * that you can pass multiple properties to the target face in one call. - * Note that only a subset of the available properties can be - * controlled. + * Contrary to @FT_Property_Set, this function uses @FT_Parameter so that + * you can pass multiple properties to the target face in one call. Note + * that only a subset of the available properties can be controlled. * * * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the - * property `no-stem-darkening' provided by the `autofit', `cff', - * `type1', and `t1cid' modules; see @no-stem-darkening). + * property `no-stem-darkening` provided by the 'autofit', 'cff', + * 'type1', and 't1cid' modules; see @no-stem-darkening). * * * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding * to function @FT_Library_SetLcdFilterWeights). * * * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID - * `random' operator, corresponding to the `random-seed' property - * provided by the `cff', `type1', and `t1cid' modules; see + * 'random' operator, corresponding to the `random-seed` property + * provided by the 'cff', 'type1', and 't1cid' modules; see * @random-seed). * - * Pass NULL as `data' in @FT_Parameter for a given tag to reset the + * Pass `NULL` as `data` in @FT_Parameter for a given tag to reset the * option and use the library or module default again. * * @input: @@ -3822,17 +3860,17 @@ FT_BEGIN_HEADER * The number of properties that follow. * * properties :: - * A handle to an @FT_Parameter array with `num_properties' elements. + * A handle to an @FT_Parameter array with `num_properties` elements. * * @return: * FreeType error code. 0~means success. * - * @note: - * Here an example that sets three properties. You must define - * FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples + * @example: + * Here is an example that sets three properties. You must define + * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` to make the LCD filter examples * work. * - * { + * ``` * FT_Parameter property1; * FT_Bool darken_stems = 1; * @@ -3858,11 +3896,11 @@ FT_BEGIN_HEADER * property3.data = &random_seed; * * FT_Face_Properties( face, 3, properties ); - * } + * ``` * * The next example resets a single property to its default value. * - * { + * ``` * FT_Parameter property; * * @@ -3870,7 +3908,7 @@ FT_BEGIN_HEADER * property.data = NULL; * * FT_Face_Properties( face, 1, &property ); - * } + * ``` * * @since: * 2.8 @@ -3882,37 +3920,40 @@ FT_BEGIN_HEADER FT_Parameter* properties ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Name_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given glyph name. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* glyph_name :: The glyph name. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Name_Index + * + * @description: + * Return the glyph index of a given glyph name. + * + * @input: + * face :: + * A handle to the source face object. + * + * glyph_name :: + * The glyph name. + * + * @return: + * The glyph index. 0~means 'undefined character code'. + */ FT_EXPORT( FT_UInt ) - FT_Get_Name_Index( FT_Face face, - FT_String* glyph_name ); + FT_Get_Name_Index( FT_Face face, + const FT_String* glyph_name ); - /************************************************************************* + /************************************************************************** * - * @macro: + * @enum: * FT_SUBGLYPH_FLAG_XXX * * @description: - * A list of constants describing subglyphs. Please refer to the - * `glyf' table description in the OpenType specification for the - * meaning of the various flags (which get synthesized for - * non-OpenType subglyphs). + * A list of constants describing subglyphs. Please refer to the 'glyf' + * table description in the OpenType specification for the meaning of the + * various flags (which get synthesized for non-OpenType subglyphs). + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description * * @values: * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: @@ -3933,112 +3974,283 @@ FT_BEGIN_HEADER #define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 - /************************************************************************* + /************************************************************************** + * + * @function: + * FT_Get_SubGlyph_Info + * + * @description: + * Retrieve a description of a given subglyph. Only use it if + * `glyph->format` is @FT_GLYPH_FORMAT_COMPOSITE; an error is returned + * otherwise. + * + * @input: + * glyph :: + * The source glyph slot. + * + * sub_index :: + * The index of the subglyph. Must be less than + * `glyph->num_subglyphs`. + * + * @output: + * p_index :: + * The glyph index of the subglyph. + * + * p_flags :: + * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * + * p_arg1 :: + * The subglyph's first argument (if any). + * + * p_arg2 :: + * The subglyph's second argument (if any). + * + * p_transform :: + * The subglyph transformation (if any). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The values of `*p_arg1`, `*p_arg2`, and `*p_transform` must be + * interpreted depending on the flags returned in `*p_flags`. See the + * OpenType specification for details. + * + * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#composite-glyph-description + * + */ + FT_EXPORT( FT_Error ) + FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, + FT_UInt sub_index, + FT_Int *p_index, + FT_UInt *p_flags, + FT_Int *p_arg1, + FT_Int *p_arg2, + FT_Matrix *p_transform ); + + + /************************************************************************** + * + * @section: + * layer_management + * + * @title: + * Glyph Layer Management + * + * @abstract: + * Retrieving and manipulating OpenType's 'COLR' table data. + * + * @description: + * The functions described here allow access of colored glyph layer data + * in OpenType's 'COLR' tables. + */ + + + /************************************************************************** + * + * @struct: + * FT_LayerIterator + * + * @description: + * This iterator object is needed for @FT_Get_Color_Glyph_Layer. + * + * @fields: + * num_layers :: + * The number of glyph layers for the requested glyph index. Will be + * set by @FT_Get_Color_Glyph_Layer. + * + * layer :: + * The current layer. Will be set by @FT_Get_Color_Glyph_Layer. + * + * p :: + * An opaque pointer into 'COLR' table data. The caller must set this + * to `NULL` before the first call of @FT_Get_Color_Glyph_Layer. + */ + typedef struct FT_LayerIterator_ + { + FT_UInt num_layers; + FT_UInt layer; + FT_Byte* p; + + } FT_LayerIterator; + + + /************************************************************************** * - * @func: - * FT_Get_SubGlyph_Info + * @function: + * FT_Get_Color_Glyph_Layer * * @description: - * Retrieve a description of a given subglyph. Only use it if - * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is - * returned otherwise. + * This is an interface to the 'COLR' table in OpenType fonts to + * iteratively retrieve the colored glyph layers associated with the + * current glyph slot. * - * @input: - * glyph :: - * The source glyph slot. + * https://docs.microsoft.com/en-us/typography/opentype/spec/colr * - * sub_index :: - * The index of the subglyph. Must be less than - * `glyph->num_subglyphs'. + * The glyph layer data for a given glyph index, if present, provides an + * alternative, multi-colour glyph representation: Instead of rendering + * the outline or bitmap with the given glyph index, glyphs with the + * indices and colors returned by this function are rendered layer by + * layer. * - * @output: - * p_index :: - * The glyph index of the subglyph. + * The returned elements are ordered in the z~direction from bottom to + * top; the 'n'th element should be rendered with the associated palette + * color and blended on top of the already rendered layers (elements 0, + * 1, ..., n-1). * - * p_flags :: - * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. + * @input: + * face :: + * A handle to the parent face object. * - * p_arg1 :: - * The subglyph's first argument (if any). + * base_glyph :: + * The glyph index the colored glyph layers are associated with. * - * p_arg2 :: - * The subglyph's second argument (if any). + * @inout: + * iterator :: + * An @FT_LayerIterator object. For the first call you should set + * `iterator->p` to `NULL`. For all following calls, simply use the + * same object again. * - * p_transform :: - * The subglyph transformation (if any). + * @output: + * aglyph_index :: + * The glyph index of the current layer. + * + * acolor_index :: + * The color index into the font face's color palette of the current + * layer. The value 0xFFFF is special; it doesn't reference a palette + * entry but indicates that the text foreground color should be used + * instead (to be set up by the application outside of FreeType). + * + * The color palette can be retrieved with @FT_Palette_Select. * * @return: - * FreeType error code. 0~means success. + * Value~1 if everything is OK. If there are no more layers (or if there + * are no layers at all), value~0 gets returned. In case of an error, + * value~0 is returned also. * * @note: - * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be - * interpreted depending on the flags returned in `*p_flags'. See the - * OpenType specification for details. + * This function is necessary if you want to handle glyph layers by + * yourself. In particular, functions that operate with @FT_GlyphRec + * objects (like @FT_Get_Glyph or @FT_Glyph_To_Bitmap) don't have access + * to this information. + * + * Note that @FT_Render_Glyph is able to handle colored glyph layers + * automatically if the @FT_LOAD_COLOR flag is passed to a previous call + * to @FT_Load_Glyph. [This is an experimental feature.] + * + * @example: + * ``` + * FT_Color* palette; + * FT_LayerIterator iterator; + * + * FT_Bool have_layers; + * FT_UInt layer_glyph_index; + * FT_UInt layer_color_index; + * + * + * error = FT_Palette_Select( face, palette_index, &palette ); + * if ( error ) + * palette = NULL; * + * iterator.p = NULL; + * have_layers = FT_Get_Color_Glyph_Layer( face, + * glyph_index, + * &layer_glyph_index, + * &layer_color_index, + * &iterator ); + * + * if ( palette && have_layers ) + * { + * do + * { + * FT_Color layer_color; + * + * + * if ( layer_color_index == 0xFFFF ) + * layer_color = text_foreground_color; + * else + * layer_color = palette[layer_color_index]; + * + * // Load and render glyph `layer_glyph_index', then + * // blend resulting pixmap (using color `layer_color') + * // with previously created pixmaps. + * + * } while ( FT_Get_Color_Glyph_Layer( face, + * glyph_index, + * &layer_glyph_index, + * &layer_color_index, + * &iterator ) ); + * } + * ``` */ - FT_EXPORT( FT_Error ) - FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, - FT_UInt sub_index, - FT_Int *p_index, - FT_UInt *p_flags, - FT_Int *p_arg1, - FT_Int *p_arg2, - FT_Matrix *p_transform ); + FT_EXPORT( FT_Bool ) + FT_Get_Color_Glyph_Layer( FT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FSTYPE_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `fsType' field of the OS/2 table */ - /* in a TrueType or OpenType font and the `FSType' entry in a */ - /* PostScript font. These bit flags are returned by */ - /* @FT_Get_FSType_Flags; they inform client applications of embedding */ - /* and subsetting restrictions associated with a font. */ - /* */ - /* See */ - /* https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */ - /* for more details. */ - /* */ - /* <Values> */ - /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ - /* Fonts with no fsType bit set may be embedded and permanently */ - /* installed on the remote system by an application. */ - /* */ - /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ - /* Fonts that have only this bit set must not be modified, embedded */ - /* or exchanged in any manner without first obtaining permission of */ - /* the font software copyright owner. */ - /* */ - /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ - /* The font may be embedded and temporarily loaded on the remote */ - /* system. Documents containing Preview & Print fonts must be */ - /* opened `read-only'; no edits can be applied to the document. */ - /* */ - /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ - /* The font may be embedded but must only be installed temporarily */ - /* on other systems. In contrast to Preview & Print fonts, */ - /* documents containing editable fonts may be opened for reading, */ - /* editing is permitted, and changes may be saved. */ - /* */ - /* FT_FSTYPE_NO_SUBSETTING :: */ - /* The font may not be subsetted prior to embedding. */ - /* */ - /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ - /* Only bitmaps contained in the font may be embedded; no outline */ - /* data may be embedded. If there are no bitmaps available in the */ - /* font, then the font is unembeddable. */ - /* */ - /* <Note> */ - /* The flags are ORed together, thus more than a single value can be */ - /* returned. */ - /* */ - /* While the `fsType' flags can indicate that a font may be embedded, */ - /* a license with the font vendor may be separately required to use */ - /* the font in this way. */ - /* */ + /************************************************************************** + * + * @section: + * base_interface + * + */ + + /************************************************************************** + * + * @enum: + * FT_FSTYPE_XXX + * + * @description: + * A list of bit flags used in the `fsType` field of the OS/2 table in a + * TrueType or OpenType font and the `FSType` entry in a PostScript font. + * These bit flags are returned by @FT_Get_FSType_Flags; they inform + * client applications of embedding and subsetting restrictions + * associated with a font. + * + * See + * https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf + * for more details. + * + * @values: + * FT_FSTYPE_INSTALLABLE_EMBEDDING :: + * Fonts with no fsType bit set may be embedded and permanently + * installed on the remote system by an application. + * + * FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: + * Fonts that have only this bit set must not be modified, embedded or + * exchanged in any manner without first obtaining permission of the + * font software copyright owner. + * + * FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: + * The font may be embedded and temporarily loaded on the remote + * system. Documents containing Preview & Print fonts must be opened + * 'read-only'; no edits can be applied to the document. + * + * FT_FSTYPE_EDITABLE_EMBEDDING :: + * The font may be embedded but must only be installed temporarily on + * other systems. In contrast to Preview & Print fonts, documents + * containing editable fonts may be opened for reading, editing is + * permitted, and changes may be saved. + * + * FT_FSTYPE_NO_SUBSETTING :: + * The font may not be subsetted prior to embedding. + * + * FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: + * Only bitmaps contained in the font may be embedded; no outline data + * may be embedded. If there are no bitmaps available in the font, + * then the font is unembeddable. + * + * @note: + * The flags are ORed together, thus more than a single value can be + * returned. + * + * While the `fsType` flags can indicate that a font may be embedded, a + * license with the font vendor may be separately required to use the + * font in this way. + */ #define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 #define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 #define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 @@ -4047,548 +4259,563 @@ FT_BEGIN_HEADER #define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_FSType_Flags */ - /* */ - /* <Description> */ - /* Return the `fsType' flags for a font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* The `fsType' flags, see @FT_FSTYPE_XXX. */ - /* */ - /* <Note> */ - /* Use this function rather than directly reading the `fs_type' field */ - /* in the @PS_FontInfoRec structure, which is only guaranteed to */ - /* return the correct results for Type~1 fonts. */ - /* */ - /* <Since> */ - /* 2.3.8 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_FSType_Flags + * + * @description: + * Return the `fsType` flags for a font. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * The `fsType` flags, see @FT_FSTYPE_XXX. + * + * @note: + * Use this function rather than directly reading the `fs_type` field in + * the @PS_FontInfoRec structure, which is only guaranteed to return the + * correct results for Type~1 fonts. + * + * @since: + * 2.3.8 + */ FT_EXPORT( FT_UShort ) FT_Get_FSType_Flags( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_variants */ - /* */ - /* <Title> */ - /* Unicode Variation Sequences */ - /* */ - /* <Abstract> */ - /* The FreeType~2 interface to Unicode Variation Sequences (UVS), */ - /* using the SFNT cmap format~14. */ - /* */ - /* <Description> */ - /* Many characters, especially for CJK scripts, have variant forms. */ - /* They are a sort of grey area somewhere between being totally */ - /* irrelevant and semantically distinct; for this reason, the Unicode */ - /* consortium decided to introduce Variation Sequences (VS), */ - /* consisting of a Unicode base character and a variation selector */ - /* instead of further extending the already huge number of */ - /* characters. */ - /* */ - /* Unicode maintains two different sets, namely `Standardized */ - /* Variation Sequences' and registered `Ideographic Variation */ - /* Sequences' (IVS), collected in the `Ideographic Variation */ - /* Database' (IVD). */ - /* */ - /* https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */ - /* https://unicode.org/reports/tr37/ */ - /* https://unicode.org/ivd/ */ - /* */ - /* To date (January 2017), the character with the most ideographic */ - /* variations is U+9089, having 32 such IVS. */ - /* */ - /* Three Mongolian Variation Selectors have the values U+180B-U+180D; */ - /* 256 generic Variation Selectors are encoded in the ranges */ - /* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */ - /* Selectors from the range U+E0100-U+E01EF only. */ - /* */ - /* A VS consists of the base character value followed by a single */ - /* Variation Selector. For example, to get the first variation of */ - /* U+9089, you have to write the character sequence `U+9089 U+E0100'. */ - /* */ - /* Adobe and MS decided to support both standardized and ideographic */ - /* VS with a new cmap subtable (format~14). It is an odd subtable */ - /* because it is not a mapping of input code points to glyphs, but */ - /* contains lists of all variations supported by the font. */ - /* */ - /* A variation may be either `default' or `non-default' for a given */ - /* font. A default variation is the one you will get for that code */ - /* point if you look it up in the standard Unicode cmap. A */ - /* non-default variation is a different glyph. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * glyph_variants + * + * @title: + * Unicode Variation Sequences + * + * @abstract: + * The FreeType~2 interface to Unicode Variation Sequences (UVS), using + * the SFNT cmap format~14. + * + * @description: + * Many characters, especially for CJK scripts, have variant forms. They + * are a sort of grey area somewhere between being totally irrelevant and + * semantically distinct; for this reason, the Unicode consortium decided + * to introduce Variation Sequences (VS), consisting of a Unicode base + * character and a variation selector instead of further extending the + * already huge number of characters. + * + * Unicode maintains two different sets, namely 'Standardized Variation + * Sequences' and registered 'Ideographic Variation Sequences' (IVS), + * collected in the 'Ideographic Variation Database' (IVD). + * + * https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt + * https://unicode.org/reports/tr37/ https://unicode.org/ivd/ + * + * To date (January 2017), the character with the most ideographic + * variations is U+9089, having 32 such IVS. + * + * Three Mongolian Variation Selectors have the values U+180B-U+180D; 256 + * generic Variation Selectors are encoded in the ranges U+FE00-U+FE0F + * and U+E0100-U+E01EF. IVS currently use Variation Selectors from the + * range U+E0100-U+E01EF only. + * + * A VS consists of the base character value followed by a single + * Variation Selector. For example, to get the first variation of + * U+9089, you have to write the character sequence `U+9089 U+E0100`. + * + * Adobe and MS decided to support both standardized and ideographic VS + * with a new cmap subtable (format~14). It is an odd subtable because + * it is not a mapping of input code points to glyphs, but contains lists + * of all variations supported by the font. + * + * A variation may be either 'default' or 'non-default' for a given font. + * A default variation is the one you will get for that code point if you + * look it up in the standard Unicode cmap. A non-default variation is a + * different glyph. + * + */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIndex */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code as modified by */ - /* the variation selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character code point in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode code point of the variation selector. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means either `undefined character code', or */ - /* `undefined selector code', or `no variation selector cmap */ - /* subtable', or `current CharMap is not Unicode'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within */ - /* the file. This is done to ensure that value~0 always corresponds */ - /* to the `missing glyph'. */ - /* */ - /* This function is only meaningful if */ - /* a) the font has a variation selector cmap sub table, */ - /* and */ - /* b) the current charmap has a Unicode encoding. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetCharVariantIndex + * + * @description: + * Return the glyph index of a given character code as modified by the + * variation selector. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character code point in Unicode. + * + * variantSelector :: + * The Unicode code point of the variation selector. + * + * @return: + * The glyph index. 0~means either 'undefined character code', or + * 'undefined selector code', or 'no variation selector cmap subtable', + * or 'current CharMap is not Unicode'. + * + * @note: + * If you use FreeType to manipulate the contents of font files directly, + * be aware that the glyph index returned by this function doesn't always + * correspond to the internal indices used within the file. This is done + * to ensure that value~0 always corresponds to the 'missing glyph'. + * + * This function is only meaningful if + * a) the font has a variation selector cmap sub table, and + * b) the current charmap has a Unicode encoding. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt ) FT_Face_GetCharVariantIndex( FT_Face face, FT_ULong charcode, FT_ULong variantSelector ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIsDefault */ - /* */ - /* <Description> */ - /* Check whether this variation of this Unicode character is the one */ - /* to be found in the `cmap'. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode codepoint of the variation selector. */ - /* */ - /* <Return> */ - /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ - /* variation selector cmap, or -1 if it is not a variation. */ - /* */ - /* <Note> */ - /* This function is only meaningful if the font has a variation */ - /* selector cmap subtable. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetCharVariantIsDefault + * + * @description: + * Check whether this variation of this Unicode character is the one to + * be found in the charmap. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character codepoint in Unicode. + * + * variantSelector :: + * The Unicode codepoint of the variation selector. + * + * @return: + * 1~if found in the standard (Unicode) cmap, 0~if found in the variation + * selector cmap, or -1 if it is not a variation. + * + * @note: + * This function is only meaningful if the font has a variation selector + * cmap subtable. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_Int ) FT_Face_GetCharVariantIsDefault( FT_Face face, FT_ULong charcode, FT_ULong variantSelector ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantSelectors */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variation selectors found */ - /* in the font. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to an array of selector code points, or NULL if there is */ - /* no valid variation selector cmap subtable. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetVariantSelectors + * + * @description: + * Return a zero-terminated list of Unicode variation selectors found in + * the font. + * + * @input: + * face :: + * A handle to the source face object. + * + * @return: + * A pointer to an array of selector code points, or `NULL` if there is + * no valid variation selector cmap subtable. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt32* ) FT_Face_GetVariantSelectors( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantsOfChar */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variation selectors found */ - /* for the specified character code. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* <Return> */ - /* A pointer to an array of variation selector code points that are */ - /* active for the given character, or NULL if the corresponding list */ - /* is empty. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetVariantsOfChar + * + * @description: + * Return a zero-terminated list of Unicode variation selectors found for + * the specified character code. + * + * @input: + * face :: + * A handle to the source face object. + * + * charcode :: + * The character codepoint in Unicode. + * + * @return: + * A pointer to an array of variation selector code points that are + * active for the given character, or `NULL` if the corresponding list is + * empty. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt32* ) FT_Face_GetVariantsOfChar( FT_Face face, FT_ULong charcode ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharsOfVariant */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode character codes found for */ - /* the specified variation selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* variantSelector :: */ - /* The variation selector code point in Unicode. */ - /* */ - /* <Return> */ - /* A list of all the code points that are specified by this selector */ - /* (both default and non-default codes are returned) or NULL if there */ - /* is no valid cmap or the variation selector is invalid. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_GetCharsOfVariant + * + * @description: + * Return a zero-terminated list of Unicode character codes found for the + * specified variation selector. + * + * @input: + * face :: + * A handle to the source face object. + * + * variantSelector :: + * The variation selector code point in Unicode. + * + * @return: + * A list of all the code points that are specified by this selector + * (both default and non-default codes are returned) or `NULL` if there + * is no valid cmap or the variation selector is invalid. + * + * @note: + * The last item in the array is~0; the array is owned by the @FT_Face + * object but can be overwritten or released on the next call to a + * FreeType function. + * + * @since: + * 2.3.6 + */ FT_EXPORT( FT_UInt32* ) FT_Face_GetCharsOfVariant( FT_Face face, FT_ULong variantSelector ); - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /* <Title> */ - /* Computations */ - /* */ - /* <Abstract> */ - /* Crunching fixed numbers and vectors. */ - /* */ - /* <Description> */ - /* This section contains various functions used to perform */ - /* computations on 16.16 fixed-float numbers or 2d vectors. */ - /* */ - /* <Order> */ - /* FT_MulDiv */ - /* FT_MulFix */ - /* FT_DivFix */ - /* FT_RoundFix */ - /* FT_CeilFix */ - /* FT_FloorFix */ - /* FT_Vector_Transform */ - /* FT_Matrix_Multiply */ - /* FT_Matrix_Invert */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * computations + * + * @title: + * Computations + * + * @abstract: + * Crunching fixed numbers and vectors. + * + * @description: + * This section contains various functions used to perform computations + * on 16.16 fixed-float numbers or 2d vectors. + * + * **Attention**: Most arithmetic functions take `FT_Long` as arguments. + * For historical reasons, FreeType was designed under the assumption + * that `FT_Long` is a 32-bit integer; results can thus be undefined if + * the arguments don't fit into 32 bits. + * + * @order: + * FT_MulDiv + * FT_MulFix + * FT_DivFix + * FT_RoundFix + * FT_CeilFix + * FT_FloorFix + * FT_Vector_Transform + * FT_Matrix_Multiply + * FT_Matrix_Invert + * + */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv */ - /* */ - /* <Description> */ - /* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */ - /* intermediate integer whenever necessary. */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* */ - /* b :: The second multiplier. */ - /* */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_MulDiv + * + * @description: + * Compute `(a*b)/c` with maximum accuracy, using a 64-bit intermediate + * integer whenever necessary. + * + * This function isn't necessarily as fast as some processor-specific + * operations, but is at least completely portable. + * + * @input: + * a :: + * The first multiplier. + * + * b :: + * The second multiplier. + * + * c :: + * The divisor. + * + * @return: + * The result of `(a*b)/c`. This function never traps when trying to + * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on + * the signs of `a` and `b`. + */ FT_EXPORT( FT_Long ) FT_MulDiv( FT_Long a, FT_Long b, FT_Long c ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulFix */ - /* */ - /* <Description> */ - /* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */ - /* multiply a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* <Return> */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* <Note> */ - /* This function has been optimized for the case where the absolute */ - /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ - /* As this happens mainly when scaling from notional units to */ - /* fractional pixels in FreeType, it resulted in noticeable speed */ - /* improvements between versions 2.x and 1.x. */ - /* */ - /* As a conclusion, always try to place a 16.16 factor as the */ - /* _second_ argument of this function; this can make a great */ - /* difference. */ - /* */ + /************************************************************************** + * + * @function: + * FT_MulFix + * + * @description: + * Compute `(a*b)/0x10000` with maximum accuracy. Its main use is to + * multiply a given value by a 16.16 fixed-point factor. + * + * @input: + * a :: + * The first multiplier. + * + * b :: + * The second multiplier. Use a 16.16 factor here whenever possible + * (see note below). + * + * @return: + * The result of `(a*b)/0x10000`. + * + * @note: + * This function has been optimized for the case where the absolute value + * of `a` is less than 2048, and `b` is a 16.16 scaling factor. As this + * happens mainly when scaling from notional units to fractional pixels + * in FreeType, it resulted in noticeable speed improvements between + * versions 2.x and 1.x. + * + * As a conclusion, always try to place a 16.16 factor as the _second_ + * argument of this function; this can make a great difference. + */ FT_EXPORT( FT_Long ) FT_MulFix( FT_Long a, FT_Long b ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_DivFix */ - /* */ - /* <Description> */ - /* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */ - /* divide a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The numerator. */ - /* */ - /* b :: The denominator. Use a 16.16 factor here. */ - /* */ - /* <Return> */ - /* The result of `(a*0x10000)/b'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_DivFix + * + * @description: + * Compute `(a*0x10000)/b` with maximum accuracy. Its main use is to + * divide a given value by a 16.16 fixed-point factor. + * + * @input: + * a :: + * The numerator. + * + * b :: + * The denominator. Use a 16.16 factor here. + * + * @return: + * The result of `(a*0x10000)/b`. + */ FT_EXPORT( FT_Long ) FT_DivFix( FT_Long a, FT_Long b ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_RoundFix */ - /* */ - /* <Description> */ - /* Round a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number to be rounded. */ - /* */ - /* <Return> */ - /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */ - /* from zero. */ - /* */ - /* <Note> */ - /* The function uses wrap-around arithmetic. */ - /* */ + /************************************************************************** + * + * @function: + * FT_RoundFix + * + * @description: + * Round a 16.16 fixed number. + * + * @input: + * a :: + * The number to be rounded. + * + * @return: + * `a` rounded to the nearest 16.16 fixed integer, halfway cases away + * from zero. + * + * @note: + * The function uses wrap-around arithmetic. + */ FT_EXPORT( FT_Fixed ) FT_RoundFix( FT_Fixed a ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_CeilFix */ - /* */ - /* <Description> */ - /* Compute the smallest following integer of a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the ceiling function is to be computed. */ - /* */ - /* <Return> */ - /* `a' rounded towards plus infinity. */ - /* */ - /* <Note> */ - /* The function uses wrap-around arithmetic. */ - /* */ + /************************************************************************** + * + * @function: + * FT_CeilFix + * + * @description: + * Compute the smallest following integer of a 16.16 fixed number. + * + * @input: + * a :: + * The number for which the ceiling function is to be computed. + * + * @return: + * `a` rounded towards plus infinity. + * + * @note: + * The function uses wrap-around arithmetic. + */ FT_EXPORT( FT_Fixed ) FT_CeilFix( FT_Fixed a ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_FloorFix */ - /* */ - /* <Description> */ - /* Compute the largest previous integer of a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the floor function is to be computed. */ - /* */ - /* <Return> */ - /* `a' rounded towards minus infinity. */ - /* */ + /************************************************************************** + * + * @function: + * FT_FloorFix + * + * @description: + * Compute the largest previous integer of a 16.16 fixed number. + * + * @input: + * a :: + * The number for which the floor function is to be computed. + * + * @return: + * `a` rounded towards minus infinity. + */ FT_EXPORT( FT_Fixed ) FT_FloorFix( FT_Fixed a ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Vector_Transform */ - /* */ - /* <Description> */ - /* Transform a single vector through a 2x2 matrix. */ - /* */ - /* <InOut> */ - /* vector :: The target vector to transform. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* <Note> */ - /* The result is undefined if either `vector' or `matrix' is invalid. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Vector_Transform + * + * @description: + * Transform a single vector through a 2x2 matrix. + * + * @inout: + * vector :: + * The target vector to transform. + * + * @input: + * matrix :: + * A pointer to the source 2x2 matrix. + * + * @note: + * The result is undefined if either `vector` or `matrix` is invalid. + */ FT_EXPORT( void ) - FT_Vector_Transform( FT_Vector* vec, + FT_Vector_Transform( FT_Vector* vector, const FT_Matrix* matrix ); - /*************************************************************************/ - /* */ - /* <Section> */ - /* version */ - /* */ - /* <Title> */ - /* FreeType Version */ - /* */ - /* <Abstract> */ - /* Functions and macros related to FreeType versions. */ - /* */ - /* <Description> */ - /* Note that those functions and macros are of limited use because */ - /* even a new release of FreeType with only documentation changes */ - /* increases the version number. */ - /* */ - /* <Order> */ - /* FT_Library_Version */ - /* */ - /* FREETYPE_MAJOR */ - /* FREETYPE_MINOR */ - /* FREETYPE_PATCH */ - /* */ - /* FT_Face_CheckTrueTypePatents */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* FREETYPE_XXX */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * version + * + * @title: + * FreeType Version + * + * @abstract: + * Functions and macros related to FreeType versions. + * + * @description: + * Note that those functions and macros are of limited use because even a + * new release of FreeType with only documentation changes increases the + * version number. + * + * @order: + * FT_Library_Version + * + * FREETYPE_MAJOR + * FREETYPE_MINOR + * FREETYPE_PATCH + * + * FT_Face_CheckTrueTypePatents + * FT_Face_SetUnpatentedHinting + * + */ - /************************************************************************* + /************************************************************************** * * @enum: * FREETYPE_XXX * * @description: - * These three macros identify the FreeType source code version. - * Use @FT_Library_Version to access them at runtime. + * These three macros identify the FreeType source code version. Use + * @FT_Library_Version to access them at runtime. * * @values: - * FREETYPE_MAJOR :: The major version number. - * FREETYPE_MINOR :: The minor version number. - * FREETYPE_PATCH :: The patch level. + * FREETYPE_MAJOR :: + * The major version number. + * FREETYPE_MINOR :: + * The minor version number. + * FREETYPE_PATCH :: + * The patch level. * * @note: - * The version number of FreeType if built as a dynamic link library - * with the `libtool' package is _not_ controlled by these three - * macros. + * The version number of FreeType if built as a dynamic link library with + * the 'libtool' package is _not_ controlled by these three macros. * */ #define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 9 +#define FREETYPE_MINOR 10 #define FREETYPE_PATCH 1 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Library_Version */ - /* */ - /* <Description> */ - /* Return the version of the FreeType library being used. This is */ - /* useful when dynamically linking to the library, since one cannot */ - /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ - /* @FREETYPE_PATCH. */ - /* */ - /* <Input> */ - /* library :: A source library handle. */ - /* */ - /* <Output> */ - /* amajor :: The major version number. */ - /* */ - /* aminor :: The minor version number. */ - /* */ - /* apatch :: The patch version number. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' argument is because */ - /* certain programs implement library initialization in a custom way */ - /* that doesn't use @FT_Init_FreeType. */ - /* */ - /* In such cases, the library version might not be available before */ - /* the library object has been created. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Library_Version + * + * @description: + * Return the version of the FreeType library being used. This is useful + * when dynamically linking to the library, since one cannot use the + * macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and @FREETYPE_PATCH. + * + * @input: + * library :: + * A source library handle. + * + * @output: + * amajor :: + * The major version number. + * + * aminor :: + * The minor version number. + * + * apatch :: + * The patch version number. + * + * @note: + * The reason why this function takes a `library` argument is because + * certain programs implement library initialization in a custom way that + * doesn't use @FT_Init_FreeType. + * + * In such cases, the library version might not be available before the + * library object has been created. + */ FT_EXPORT( void ) FT_Library_Version( FT_Library library, FT_Int *amajor, @@ -4596,52 +4823,55 @@ FT_BEGIN_HEADER FT_Int *apatch ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_CheckTrueTypePatents */ - /* */ - /* <Description> */ - /* Deprecated, does nothing. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* <Return> */ - /* Always returns false. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_CheckTrueTypePatents + * + * @description: + * Deprecated, does nothing. + * + * @input: + * face :: + * A face handle. + * + * @return: + * Always returns false. + * + * @note: + * Since May 2010, TrueType hinting is no longer patented. + * + * @since: + * 2.3.5 + */ FT_EXPORT( FT_Bool ) FT_Face_CheckTrueTypePatents( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* <Description> */ - /* Deprecated, does nothing. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* value :: New boolean setting. */ - /* */ - /* <Return> */ - /* Always returns false. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Face_SetUnpatentedHinting + * + * @description: + * Deprecated, does nothing. + * + * @input: + * face :: + * A face handle. + * + * value :: + * New boolean setting. + * + * @return: + * Always returns false. + * + * @note: + * Since May 2010, TrueType hinting is no longer patented. + * + * @since: + * 2.3.5 + */ FT_EXPORT( FT_Bool ) FT_Face_SetUnpatentedHinting( FT_Face face, FT_Bool value ); diff --git a/src/3rdparty/freetype/include/freetype/ftadvanc.h b/src/3rdparty/freetype/include/freetype/ftadvanc.h index f78e8b1a9d..95c38f92bd 100644 --- a/src/3rdparty/freetype/include/freetype/ftadvanc.h +++ b/src/3rdparty/freetype/include/freetype/ftadvanc.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftadvanc.h */ -/* */ -/* Quick computation of advance widths (specification only). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftadvanc.h + * + * Quick computation of advance widths (specification only). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTADVANC_H_ @@ -56,68 +56,67 @@ FT_BEGIN_HEADER */ - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_ADVANCE_FLAG_FAST_ONLY */ - /* */ - /* <Description> */ - /* A bit-flag to be OR-ed with the `flags' parameter of the */ - /* @FT_Get_Advance and @FT_Get_Advances functions. */ - /* */ - /* If set, it indicates that you want these functions to fail if the */ - /* corresponding hinting mode or font driver doesn't allow for very */ - /* quick advance computation. */ - /* */ - /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */ - /* or light-hinted can have their advance width computed very */ - /* quickly. */ - /* */ - /* Normal and bytecode hinted modes that require loading, scaling, */ - /* and hinting of the glyph outline, are extremely slow by */ - /* comparison. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_ADVANCE_FLAG_FAST_ONLY + * + * @description: + * A bit-flag to be OR-ed with the `flags` parameter of the + * @FT_Get_Advance and @FT_Get_Advances functions. + * + * If set, it indicates that you want these functions to fail if the + * corresponding hinting mode or font driver doesn't allow for very quick + * advance computation. + * + * Typically, glyphs that are either unscaled, unhinted, bitmapped, or + * light-hinted can have their advance width computed very quickly. + * + * Normal and bytecode hinted modes that require loading, scaling, and + * hinting of the glyph outline, are extremely slow by comparison. + */ #define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advance */ - /* */ - /* <Description> */ - /* Retrieve the advance value of a given glyph outline in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph, used to determine what kind */ - /* of advances you need. */ - /* <Output> */ - /* padvance :: The advance value. If scaling is performed (based on */ - /* the value of `load_flags'), the advance value is in */ - /* 16.16 format. Otherwise, it is in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */ - /* vertical advance corresponding to a vertical layout. */ - /* Otherwise, it is the horizontal advance in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* A scaled advance is returned in 16.16 format but isn't transformed */ - /* by the affine transformation specified by @FT_Set_Transform. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Advance + * + * @description: + * Retrieve the advance value of a given glyph outline in an @FT_Face. + * + * @input: + * face :: + * The source @FT_Face handle. + * + * gindex :: + * The glyph index. + * + * load_flags :: + * A set of bit flags similar to those used when calling + * @FT_Load_Glyph, used to determine what kind of advances you need. + * @output: + * padvance :: + * The advance value. If scaling is performed (based on the value of + * `load_flags`), the advance value is in 16.16 format. Otherwise, it + * is in font units. + * + * If @FT_LOAD_VERTICAL_LAYOUT is set, this is the vertical advance + * corresponding to a vertical layout. Otherwise, it is the horizontal + * advance in a horizontal layout. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if + * the corresponding font backend doesn't have a quick way to retrieve + * the advances. + * + * A scaled advance is returned in 16.16 format but isn't transformed by + * the affine transformation specified by @FT_Set_Transform. + */ FT_EXPORT( FT_Error ) FT_Get_Advance( FT_Face face, FT_UInt gindex, @@ -125,50 +124,52 @@ FT_BEGIN_HEADER FT_Fixed *padvance ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advances */ - /* */ - /* <Description> */ - /* Retrieve the advance values of several glyph outlines in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* start :: The first glyph index. */ - /* */ - /* count :: The number of advance values you want to retrieve. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph. */ - /* */ - /* <Output> */ - /* padvance :: The advance values. This array, to be provided by the */ - /* caller, must contain at least `count' elements. */ - /* */ - /* If scaling is performed (based on the value of */ - /* `load_flags'), the advance values are in 16.16 format. */ - /* Otherwise, they are in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */ - /* vertical advances corresponding to a vertical layout. */ - /* Otherwise, they are the horizontal advances in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* Scaled advances are returned in 16.16 format but aren't */ - /* transformed by the affine transformation specified by */ - /* @FT_Set_Transform. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Advances + * + * @description: + * Retrieve the advance values of several glyph outlines in an @FT_Face. + * + * @input: + * face :: + * The source @FT_Face handle. + * + * start :: + * The first glyph index. + * + * count :: + * The number of advance values you want to retrieve. + * + * load_flags :: + * A set of bit flags similar to those used when calling + * @FT_Load_Glyph. + * + * @output: + * padvance :: + * The advance values. This array, to be provided by the caller, must + * contain at least `count` elements. + * + * If scaling is performed (based on the value of `load_flags`), the + * advance values are in 16.16 format. Otherwise, they are in font + * units. + * + * If @FT_LOAD_VERTICAL_LAYOUT is set, these are the vertical advances + * corresponding to a vertical layout. Otherwise, they are the + * horizontal advances in a horizontal layout. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and if + * the corresponding font backend doesn't have a quick way to retrieve + * the advances. + * + * Scaled advances are returned in 16.16 format but aren't transformed by + * the affine transformation specified by @FT_Set_Transform. + */ FT_EXPORT( FT_Error ) FT_Get_Advances( FT_Face face, FT_UInt start, diff --git a/src/3rdparty/freetype/include/freetype/ftbbox.h b/src/3rdparty/freetype/include/freetype/ftbbox.h index f9eb70b137..22da70c0dc 100644 --- a/src/3rdparty/freetype/include/freetype/ftbbox.h +++ b/src/3rdparty/freetype/include/freetype/ftbbox.h @@ -1,30 +1,30 @@ -/***************************************************************************/ -/* */ -/* ftbbox.h */ -/* */ -/* FreeType exact bbox computation (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /* It is separated from the rest of the engine for various technical */ - /* reasons. It may well be integrated in `ftoutln' later. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftbbox.h + * + * FreeType exact bbox computation (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component has a _single_ role: to compute exact outline bounding + * boxes. + * + * It is separated from the rest of the engine for various technical + * reasons. It may well be integrated in 'ftoutln' later. + * + */ #ifndef FTBBOX_H_ @@ -44,43 +44,44 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_BBox */ - /* */ - /* <Description> */ - /* Compute the exact bounding box of an outline. This is slower */ - /* than computing the control box. However, it uses an advanced */ - /* algorithm that returns _very_ quickly when the two boxes */ - /* coincide. Otherwise, the outline Bezier arcs are traversed to */ - /* extract their extrema. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline. */ - /* */ - /* <Output> */ - /* abbox :: The outline's exact bounding box. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ - /* reasonable values for the BBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the BBox, */ - /* which can be eventually converted back to font units. */ - /* */ + /************************************************************************** + * + * @section: + * outline_processing + * + */ + + + /************************************************************************** + * + * @function: + * FT_Outline_Get_BBox + * + * @description: + * Compute the exact bounding box of an outline. This is slower than + * computing the control box. However, it uses an advanced algorithm + * that returns _very_ quickly when the two boxes coincide. Otherwise, + * the outline Bezier arcs are traversed to extract their extrema. + * + * @input: + * outline :: + * A pointer to the source outline. + * + * @output: + * abbox :: + * The outline's exact bounding box. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the font is tricky and the glyph has been loaded with + * @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get + * reasonable values for the BBox it is necessary to load the glyph at a + * large ppem value (so that the hinting instructions can properly shift + * and scale the subglyphs), then extracting the BBox, which can be + * eventually converted back to font units. + */ FT_EXPORT( FT_Error ) FT_Outline_Get_BBox( FT_Outline* outline, FT_BBox *abbox ); diff --git a/src/3rdparty/freetype/include/freetype/ftbdf.h b/src/3rdparty/freetype/include/freetype/ftbdf.h index 1b6dea6586..1c46da5985 100644 --- a/src/3rdparty/freetype/include/freetype/ftbdf.h +++ b/src/3rdparty/freetype/include/freetype/ftbdf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbdf.h */ -/* */ -/* FreeType API for accessing BDF-specific strings (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbdf.h + * + * FreeType API for accessing BDF-specific strings (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBDF_H_ @@ -32,25 +32,25 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* bdf_fonts */ - /* */ - /* <Title> */ - /* BDF and PCF Files */ - /* */ - /* <Abstract> */ - /* BDF and PCF specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions specific to BDF */ - /* and PCF fonts. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * bdf_fonts + * + * @title: + * BDF and PCF Files + * + * @abstract: + * BDF and PCF specific API. + * + * @description: + * This section contains the declaration of functions specific to BDF and + * PCF fonts. + * + */ - /********************************************************************** + /************************************************************************** * * @enum: * BDF_PropertyType @@ -81,40 +81,40 @@ FT_BEGIN_HEADER } BDF_PropertyType; - /********************************************************************** + /************************************************************************** * * @type: * BDF_Property * * @description: - * A handle to a @BDF_PropertyRec structure to model a given - * BDF/PCF property. + * A handle to a @BDF_PropertyRec structure to model a given BDF/PCF + * property. */ typedef struct BDF_PropertyRec_* BDF_Property; - /********************************************************************** - * - * @struct: - * BDF_PropertyRec - * - * @description: - * This structure models a given BDF/PCF property. - * - * @fields: - * type :: - * The property type. - * - * u.atom :: - * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be - * NULL, indicating an empty string. - * - * u.integer :: - * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. - * - * u.cardinal :: - * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. - */ + /************************************************************************** + * + * @struct: + * BDF_PropertyRec + * + * @description: + * This structure models a given BDF/PCF property. + * + * @fields: + * type :: + * The property type. + * + * u.atom :: + * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be + * `NULL`, indicating an empty string. + * + * u.integer :: + * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. + * + * u.cardinal :: + * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. + */ typedef struct BDF_PropertyRec_ { BDF_PropertyType type; @@ -128,73 +128,76 @@ FT_BEGIN_HEADER } BDF_PropertyRec; - /********************************************************************** - * - * @function: - * FT_Get_BDF_Charset_ID - * - * @description: - * Retrieve a BDF font character set identity, according to - * the BDF specification. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * acharset_encoding :: - * Charset encoding, as a C~string, owned by the face. - * - * acharset_registry :: - * Charset registry, as a C~string, owned by the face. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with BDF faces, returning an error otherwise. - */ + /************************************************************************** + * + * @function: + * FT_Get_BDF_Charset_ID + * + * @description: + * Retrieve a BDF font character set identity, according to the BDF + * specification. + * + * @input: + * face :: + * A handle to the input face. + * + * @output: + * acharset_encoding :: + * Charset encoding, as a C~string, owned by the face. + * + * acharset_registry :: + * Charset registry, as a C~string, owned by the face. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with BDF faces, returning an error otherwise. + */ FT_EXPORT( FT_Error ) FT_Get_BDF_Charset_ID( FT_Face face, const char* *acharset_encoding, const char* *acharset_registry ); - /********************************************************************** - * - * @function: - * FT_Get_BDF_Property - * - * @description: - * Retrieve a BDF property from a BDF or PCF font file. - * - * @input: - * face :: A handle to the input face. - * - * name :: The property name. - * - * @output: - * aproperty :: The property. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function works with BDF _and_ PCF fonts. It returns an error - * otherwise. It also returns an error if the property is not in the - * font. - * - * A `property' is a either key-value pair within the STARTPROPERTIES - * ... ENDPROPERTIES block of a BDF font or a key-value pair from the - * `info->props' array within a `FontRec' structure of a PCF font. - * - * Integer properties are always stored as `signed' within PCF fonts; - * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value - * for BDF fonts only. - * - * In case of error, `aproperty->type' is always set to - * @BDF_PROPERTY_TYPE_NONE. - */ + /************************************************************************** + * + * @function: + * FT_Get_BDF_Property + * + * @description: + * Retrieve a BDF property from a BDF or PCF font file. + * + * @input: + * face :: + * A handle to the input face. + * + * name :: + * The property name. + * + * @output: + * aproperty :: + * The property. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function works with BDF _and_ PCF fonts. It returns an error + * otherwise. It also returns an error if the property is not in the + * font. + * + * A 'property' is a either key-value pair within the STARTPROPERTIES + * ... ENDPROPERTIES block of a BDF font or a key-value pair from the + * `info->props` array within a `FontRec` structure of a PCF font. + * + * Integer properties are always stored as 'signed' within PCF fonts; + * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value + * for BDF fonts only. + * + * In case of error, `aproperty->type` is always set to + * @BDF_PROPERTY_TYPE_NONE. + */ FT_EXPORT( FT_Error ) FT_Get_BDF_Property( FT_Face face, const char* prop_name, diff --git a/src/3rdparty/freetype/include/freetype/ftbitmap.h b/src/3rdparty/freetype/include/freetype/ftbitmap.h index a43187cad4..a6acdb9690 100644 --- a/src/3rdparty/freetype/include/freetype/ftbitmap.h +++ b/src/3rdparty/freetype/include/freetype/ftbitmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbitmap.h */ -/* */ -/* FreeType utility functions for bitmaps (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbitmap.h + * + * FreeType utility functions for bitmaps (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBITMAP_H_ @@ -22,6 +22,7 @@ #include <ft2build.h> #include FT_FREETYPE_H +#include FT_COLOR_H #ifdef FREETYPE_H #error "freetype.h of FreeType 1 has been loaded!" @@ -33,39 +34,46 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* bitmap_handling */ - /* */ - /* <Title> */ - /* Bitmap Handling */ - /* */ - /* <Abstract> */ - /* Handling FT_Bitmap objects. */ - /* */ - /* <Description> */ - /* This section contains functions for handling @FT_Bitmap objects. */ - /* Note that none of the functions changes the bitmap's `flow' (as */ - /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Init */ - /* */ - /* <Description> */ - /* Initialize a pointer to an @FT_Bitmap structure. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the bitmap structure. */ - /* */ - /* <Note> */ - /* A deprecated name for the same function is `FT_Bitmap_New'. */ - /* */ + /************************************************************************** + * + * @section: + * bitmap_handling + * + * @title: + * Bitmap Handling + * + * @abstract: + * Handling FT_Bitmap objects. + * + * @description: + * This section contains functions for handling @FT_Bitmap objects, + * automatically adjusting the target's bitmap buffer size as needed. + * + * Note that none of the functions changes the bitmap's 'flow' (as + * indicated by the sign of the `pitch` field in @FT_Bitmap). + * + * To set the flow, assign an appropriate positive or negative value to + * the `pitch` field of the target @FT_Bitmap object after calling + * @FT_Bitmap_Init but before calling any of the other functions + * described here. + */ + + + /************************************************************************** + * + * @function: + * FT_Bitmap_Init + * + * @description: + * Initialize a pointer to an @FT_Bitmap structure. + * + * @inout: + * abitmap :: + * A pointer to the bitmap structure. + * + * @note: + * A deprecated name for the same function is `FT_Bitmap_New`. + */ FT_EXPORT( void ) FT_Bitmap_Init( FT_Bitmap *abitmap ); @@ -75,66 +83,77 @@ FT_BEGIN_HEADER FT_Bitmap_New( FT_Bitmap *abitmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Copy */ - /* */ - /* <Description> */ - /* Copy a bitmap into another one. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: A handle to the source bitmap. */ - /* */ - /* <Output> */ - /* target :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Copy + * + * @description: + * Copy a bitmap into another one. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * A handle to the source bitmap. + * + * @output: + * target :: + * A handle to the target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + */ FT_EXPORT( FT_Error ) FT_Bitmap_Copy( FT_Library library, const FT_Bitmap *source, FT_Bitmap *target ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Embolden */ - /* */ - /* <Description> */ - /* Embolden a bitmap. The new bitmap will be about `xStrength' */ - /* pixels wider and `yStrength' pixels higher. The left and bottom */ - /* borders are kept unchanged. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* xStrength :: How strong the glyph is emboldened horizontally. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* yStrength :: How strong the glyph is emboldened vertically. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* <InOut> */ - /* bitmap :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The current implementation restricts `xStrength' to be less than */ - /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ - /* */ - /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ - /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ - /* */ - /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */ - /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Embolden + * + * @description: + * Embolden a bitmap. The new bitmap will be about `xStrength` pixels + * wider and `yStrength` pixels higher. The left and bottom borders are + * kept unchanged. + * + * @input: + * library :: + * A handle to a library object. + * + * xStrength :: + * How strong the glyph is emboldened horizontally. Expressed in 26.6 + * pixel format. + * + * yStrength :: + * How strong the glyph is emboldened vertically. Expressed in 26.6 + * pixel format. + * + * @inout: + * bitmap :: + * A handle to the target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The current implementation restricts `xStrength` to be less than or + * equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. + * + * If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you + * should call @FT_GlyphSlot_Own_Bitmap on the slot first. + * + * Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are + * converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). + */ FT_EXPORT( FT_Error ) FT_Bitmap_Embolden( FT_Library library, FT_Bitmap* bitmap, @@ -142,39 +161,46 @@ FT_BEGIN_HEADER FT_Pos yStrength ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Convert */ - /* */ - /* <Description> */ - /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */ - /* to a bitmap object with depth 8bpp, making the number of used */ - /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: The source bitmap. */ - /* */ - /* alignment :: The pitch of the bitmap is a multiple of this */ - /* parameter. Common values are 1, 2, or 4. */ - /* */ - /* <Output> */ - /* target :: The target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* It is possible to call @FT_Bitmap_Convert multiple times without */ - /* calling @FT_Bitmap_Done (the memory is simply reallocated). */ - /* */ - /* Use @FT_Bitmap_Done to finally remove the bitmap object. */ - /* */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Convert + * + * @description: + * Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to + * a bitmap object with depth 8bpp, making the number of used bytes per + * line (a.k.a. the 'pitch') a multiple of `alignment`. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * The source bitmap. + * + * alignment :: + * The pitch of the bitmap is a multiple of this argument. Common + * values are 1, 2, or 4. + * + * @output: + * target :: + * The target bitmap. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * It is possible to call @FT_Bitmap_Convert multiple times without + * calling @FT_Bitmap_Done (the memory is simply reallocated). + * + * Use @FT_Bitmap_Done to finally remove the bitmap object. + * + * The `library` argument is taken to have access to FreeType's memory + * handling functions. + * + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + */ FT_EXPORT( FT_Error ) FT_Bitmap_Convert( FT_Library library, const FT_Bitmap *source, @@ -182,48 +208,112 @@ FT_BEGIN_HEADER FT_Int alignment ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GlyphSlot_Own_Bitmap */ - /* */ - /* <Description> */ - /* Make sure that a glyph slot owns `slot->bitmap'. */ - /* */ - /* <Input> */ - /* slot :: The glyph slot. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function is to be used in combination with */ - /* @FT_Bitmap_Embolden. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Blend + * + * @description: + * Blend a bitmap onto another bitmap, using a given color. + * + * @input: + * library :: + * A handle to a library object. + * + * source :: + * The source bitmap, which can have any @FT_Pixel_Mode format. + * + * source_offset :: + * The offset vector to the upper left corner of the source bitmap in + * 26.6 pixel format. It should represent an integer offset; the + * function will set the lowest six bits to zero to enforce that. + * + * color :: + * The color used to draw `source` onto `target`. + * + * @inout: + * target :: + * A handle to an `FT_Bitmap` object. It should be either initialized + * as empty with a call to @FT_Bitmap_Init, or it should be of type + * @FT_PIXEL_MODE_BGRA. + * + * atarget_offset :: + * The offset vector to the upper left corner of the target bitmap in + * 26.6 pixel format. It should represent an integer offset; the + * function will set the lowest six bits to zero to enforce that. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function doesn't perform clipping. + * + * The bitmap in `target` gets allocated or reallocated as needed; the + * vector `atarget_offset` is updated accordingly. + * + * In case of allocation or reallocation, the bitmap's pitch is set to + * `4 * width`. Both `source` and `target` must have the same bitmap + * flow (as indicated by the sign of the `pitch` field). + * + * `source->buffer` and `target->buffer` must neither be equal nor + * overlap. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Bitmap_Blend( FT_Library library, + const FT_Bitmap* source, + const FT_Vector source_offset, + FT_Bitmap* target, + FT_Vector *atarget_offset, + FT_Color color ); + + + /************************************************************************** + * + * @function: + * FT_GlyphSlot_Own_Bitmap + * + * @description: + * Make sure that a glyph slot owns `slot->bitmap`. + * + * @input: + * slot :: + * The glyph slot. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function is to be used in combination with @FT_Bitmap_Embolden. + */ FT_EXPORT( FT_Error ) FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Done */ - /* */ - /* <Description> */ - /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* bitmap :: The bitmap object to be freed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Bitmap_Done + * + * @description: + * Destroy a bitmap object initialized with @FT_Bitmap_Init. + * + * @input: + * library :: + * A handle to a library object. + * + * bitmap :: + * The bitmap object to be freed. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `library` argument is taken to have access to FreeType's memory + * handling functions. + */ FT_EXPORT( FT_Error ) FT_Bitmap_Done( FT_Library library, FT_Bitmap *bitmap ); diff --git a/src/3rdparty/freetype/include/freetype/ftbzip2.h b/src/3rdparty/freetype/include/freetype/ftbzip2.h index 6edfa031b5..ae88cfdbdb 100644 --- a/src/3rdparty/freetype/include/freetype/ftbzip2.h +++ b/src/3rdparty/freetype/include/freetype/ftbzip2.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbzip2.h */ -/* */ -/* Bzip2-compressed stream support. */ -/* */ -/* Copyright 2010-2018 by */ -/* Joel Klinghed. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbzip2.h + * + * Bzip2-compressed stream support. + * + * Copyright (C) 2010-2019 by + * Joel Klinghed. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBZIP2_H_ @@ -31,62 +31,62 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* bzip2 */ - /* */ - /* <Title> */ - /* BZIP2 Streams */ - /* */ - /* <Abstract> */ - /* Using bzip2-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Bzip2-specific functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * bzip2 + * + * @title: + * BZIP2 Streams + * + * @abstract: + * Using bzip2-compressed font files. + * + * @description: + * This section contains the declaration of Bzip2-specific functions. + * + */ - /************************************************************************ - * - * @function: - * FT_Stream_OpenBzip2 - * - * @description: - * Open a new stream to parse bzip2-compressed font files. This is - * mainly used to support the compressed `*.pcf.bz2' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, bzip2 compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a bzip2 compressed stream - * from it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with bzip2 support. - */ + /************************************************************************** + * + * @function: + * FT_Stream_OpenBzip2 + * + * @description: + * Open a new stream to parse bzip2-compressed font files. This is + * mainly used to support the compressed `*.pcf.bz2` fonts that come with + * XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, bzip2 compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a bzip2 compressed + * stream from it and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with bzip2 support. + */ FT_EXPORT( FT_Error ) FT_Stream_OpenBzip2( FT_Stream stream, FT_Stream source ); diff --git a/src/3rdparty/freetype/include/freetype/ftcache.h b/src/3rdparty/freetype/include/freetype/ftcache.h index 52d5f00e06..0d589d0b34 100644 --- a/src/3rdparty/freetype/include/freetype/ftcache.h +++ b/src/3rdparty/freetype/include/freetype/ftcache.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcache.h */ -/* */ -/* FreeType Cache subsystem (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcache.h + * + * FreeType Cache subsystem (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCACHE_H_ @@ -27,24 +27,24 @@ FT_BEGIN_HEADER - /************************************************************************* + /************************************************************************** * - * <Section> - * cache_subsystem + * @section: + * cache_subsystem * - * <Title> - * Cache Sub-System + * @title: + * Cache Sub-System * - * <Abstract> - * How to cache face, size, and glyph data with FreeType~2. + * @abstract: + * How to cache face, size, and glyph data with FreeType~2. * - * <Description> + * @description: * This section describes the FreeType~2 cache sub-system, which is used * to limit the number of concurrently opened @FT_Face and @FT_Size * objects, as well as caching information like character maps and glyph * images while limiting their maximum memory usage. * - * Note that all types and functions begin with the `FTC_' prefix. + * Note that all types and functions begin with the `FTC_` prefix. * * The cache is highly portable and thus doesn't know anything about the * fonts installed on your system, or how to access them. This implies @@ -59,7 +59,7 @@ FT_BEGIN_HEADER * to convert an @FTC_FaceID into a new @FT_Face object. The latter is * then completely managed by the cache, including its termination * through @FT_Done_Face. To monitor termination of face objects, the - * finalizer callback in the `generic' field of the @FT_Face object can + * finalizer callback in the `generic` field of the @FT_Face object can * be used, which might also be used to store the @FTC_FaceID of the * face. * @@ -69,14 +69,14 @@ FT_BEGIN_HEADER * possible. * * Note that for the cache to work correctly, the face ID values must be - * *persistent*, which means that the contents they point to should not + * **persistent**, which means that the contents they point to should not * change at runtime, or that their value should not become invalid. * * If this is unavoidable (e.g., when a font is uninstalled at runtime), * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let - * the cache get rid of any references to the old @FTC_FaceID it may - * keep internally. Failure to do so will lead to incorrect behaviour - * or even crashes. + * the cache get rid of any references to the old @FTC_FaceID it may keep + * internally. Failure to do so will lead to incorrect behaviour or even + * crashes. * * To use the cache, start with calling @FTC_Manager_New to create a new * @FTC_Manager object, which models a single cache instance. You can @@ -91,16 +91,16 @@ FT_BEGIN_HEADER * later use @FTC_ImageCache_Lookup to retrieve the corresponding * @FT_Glyph objects from the cache. * - * If you need lots of small bitmaps, it is much more memory efficient - * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This - * returns @FTC_SBitRec structures, which are used to store small - * bitmaps directly. (A small bitmap is one whose metrics and - * dimensions all fit into 8-bit integers). + * If you need lots of small bitmaps, it is much more memory efficient to + * call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This + * returns @FTC_SBitRec structures, which are used to store small bitmaps + * directly. (A small bitmap is one whose metrics and dimensions all fit + * into 8-bit integers). * * We hope to also provide a kerning cache in the near future. * * - * <Order> + * @order: * FTC_Manager * FTC_FaceID * FTC_Face_Requester @@ -142,19 +142,20 @@ FT_BEGIN_HEADER /*************************************************************************/ - /************************************************************************* + /************************************************************************** * - * @type: FTC_FaceID + * @type: + * FTC_FaceID * * @description: * An opaque pointer type that is used to identity face objects. The * contents of such objects is application-dependent. * - * These pointers are typically used to point to a user-defined - * structure containing a font file path, and face index. + * These pointers are typically used to point to a user-defined structure + * containing a font file path, and face index. * * @note: - * Never use NULL as a valid @FTC_FaceID. + * Never use `NULL` as a valid @FTC_FaceID. * * Face IDs are passed by the client to the cache manager that calls, * when needed, the @FTC_Face_Requester to translate them into new @@ -165,13 +166,13 @@ FT_BEGIN_HEADER * immediately call @FTC_Manager_RemoveFaceID before any other cache * function. * - * Failure to do so will result in incorrect behaviour or even - * memory leaks and crashes. + * Failure to do so will result in incorrect behaviour or even memory + * leaks and crashes. */ typedef FT_Pointer FTC_FaceID; - /************************************************************************ + /************************************************************************** * * @functype: * FTC_Face_Requester @@ -181,7 +182,7 @@ FT_BEGIN_HEADER * the cache manager to translate a given @FTC_FaceID into a new valid * @FT_Face object, on demand. * - * <Input> + * @input: * face_id :: * The face ID to resolve. * @@ -191,15 +192,15 @@ FT_BEGIN_HEADER * req_data :: * Application-provided request data (see note below). * - * <Output> + * @output: * aface :: * A new @FT_Face handle. * - * <Return> + * @return: * FreeType error code. 0~means success. * - * <Note> - * The third parameter `req_data' is the same as the one passed by the + * @note: + * The third parameter `req_data` is the same as the one passed by the * client when @FTC_Manager_New is called. * * The face requester should not perform funny things on the returned @@ -226,84 +227,90 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Manager */ - /* */ - /* <Description> */ - /* This object corresponds to one instance of the cache-subsystem. */ - /* It is used to cache one or more @FT_Face objects, along with */ - /* corresponding @FT_Size objects. */ - /* */ - /* The manager intentionally limits the total number of opened */ - /* @FT_Face and @FT_Size objects to control memory usage. See the */ - /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */ - /* */ - /* The manager is also used to cache `nodes' of various types while */ - /* limiting their total memory usage. */ - /* */ - /* All limitations are enforced by keeping lists of managed objects */ - /* in most-recently-used order, and flushing old nodes to make room */ - /* for new ones. */ - /* */ + /************************************************************************** + * + * @type: + * FTC_Manager + * + * @description: + * This object corresponds to one instance of the cache-subsystem. It is + * used to cache one or more @FT_Face objects, along with corresponding + * @FT_Size objects. + * + * The manager intentionally limits the total number of opened @FT_Face + * and @FT_Size objects to control memory usage. See the `max_faces` and + * `max_sizes` parameters of @FTC_Manager_New. + * + * The manager is also used to cache 'nodes' of various types while + * limiting their total memory usage. + * + * All limitations are enforced by keeping lists of managed objects in + * most-recently-used order, and flushing old nodes to make room for new + * ones. + */ typedef struct FTC_ManagerRec_* FTC_Manager; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Node */ - /* */ - /* <Description> */ - /* An opaque handle to a cache node object. Each cache node is */ - /* reference-counted. A node with a count of~0 might be flushed */ - /* out of a full cache whenever a lookup request is performed. */ - /* */ - /* If you look up nodes, you have the ability to `acquire' them, */ - /* i.e., to increment their reference count. This will prevent the */ - /* node from being flushed out of the cache until you explicitly */ - /* `release' it (see @FTC_Node_Unref). */ - /* */ - /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ - /* */ + /************************************************************************** + * + * @type: + * FTC_Node + * + * @description: + * An opaque handle to a cache node object. Each cache node is + * reference-counted. A node with a count of~0 might be flushed out of a + * full cache whenever a lookup request is performed. + * + * If you look up nodes, you have the ability to 'acquire' them, i.e., to + * increment their reference count. This will prevent the node from + * being flushed out of the cache until you explicitly 'release' it (see + * @FTC_Node_Unref). + * + * See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. + */ typedef struct FTC_NodeRec_* FTC_Node; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_New */ - /* */ - /* <Description> */ - /* Create a new cache manager. */ - /* */ - /* <Input> */ - /* library :: The parent FreeType library handle to use. */ - /* */ - /* max_faces :: Maximum number of opened @FT_Face objects managed by */ - /* this cache instance. Use~0 for defaults. */ - /* */ - /* max_sizes :: Maximum number of opened @FT_Size objects managed by */ - /* this cache instance. Use~0 for defaults. */ - /* */ - /* max_bytes :: Maximum number of bytes to use for cached data nodes. */ - /* Use~0 for defaults. Note that this value does not */ - /* account for managed @FT_Face and @FT_Size objects. */ - /* */ - /* requester :: An application-provided callback used to translate */ - /* face IDs into real @FT_Face objects. */ - /* */ - /* req_data :: A generic pointer that is passed to the requester */ - /* each time it is called (see @FTC_Face_Requester). */ - /* */ - /* <Output> */ - /* amanager :: A handle to a new manager object. 0~in case of */ - /* failure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_Manager_New + * + * @description: + * Create a new cache manager. + * + * @input: + * library :: + * The parent FreeType library handle to use. + * + * max_faces :: + * Maximum number of opened @FT_Face objects managed by this cache + * instance. Use~0 for defaults. + * + * max_sizes :: + * Maximum number of opened @FT_Size objects managed by this cache + * instance. Use~0 for defaults. + * + * max_bytes :: + * Maximum number of bytes to use for cached data nodes. Use~0 for + * defaults. Note that this value does not account for managed + * @FT_Face and @FT_Size objects. + * + * requester :: + * An application-provided callback used to translate face IDs into + * real @FT_Face objects. + * + * req_data :: + * A generic pointer that is passed to the requester each time it is + * called (see @FTC_Face_Requester). + * + * @output: + * amanager :: + * A handle to a new manager object. 0~in case of failure. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FTC_Manager_New( FT_Library library, FT_UInt max_faces, @@ -314,114 +321,124 @@ FT_BEGIN_HEADER FTC_Manager *amanager ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Reset */ - /* */ - /* <Description> */ - /* Empty a given cache manager. This simply gets rid of all the */ - /* currently cached @FT_Face and @FT_Size objects within the manager. */ - /* */ - /* <InOut> */ - /* manager :: A handle to the manager. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_Manager_Reset + * + * @description: + * Empty a given cache manager. This simply gets rid of all the + * currently cached @FT_Face and @FT_Size objects within the manager. + * + * @inout: + * manager :: + * A handle to the manager. + */ FT_EXPORT( void ) FTC_Manager_Reset( FTC_Manager manager ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Done */ - /* */ - /* <Description> */ - /* Destroy a given manager after emptying it. */ - /* */ - /* <Input> */ - /* manager :: A handle to the target cache manager object. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_Manager_Done + * + * @description: + * Destroy a given manager after emptying it. + * + * @input: + * manager :: + * A handle to the target cache manager object. + */ FT_EXPORT( void ) FTC_Manager_Done( FTC_Manager manager ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_LookupFace */ - /* */ - /* <Description> */ - /* Retrieve the @FT_Face object that corresponds to a given face ID */ - /* through a cache manager. */ - /* */ - /* <Input> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* face_id :: The ID of the face object. */ - /* */ - /* <Output> */ - /* aface :: A handle to the face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned @FT_Face object is always owned by the manager. You */ - /* should never try to discard it yourself. */ - /* */ - /* The @FT_Face object doesn't necessarily have a current size object */ - /* (i.e., face->size can be~0). If you need a specific `font size', */ - /* use @FTC_Manager_LookupSize instead. */ - /* */ - /* Never change the face's transformation matrix (i.e., never call */ - /* the @FT_Set_Transform function) on a returned face! If you need */ - /* to transform glyphs, do it yourself after glyph loading. */ - /* */ - /* When you perform a lookup, out-of-memory errors are detected */ - /* _within_ the lookup and force incremental flushes of the cache */ - /* until enough memory is released for the lookup to succeed. */ - /* */ - /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ - /* already been completely flushed, and still no memory was available */ - /* for the operation. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_Manager_LookupFace + * + * @description: + * Retrieve the @FT_Face object that corresponds to a given face ID + * through a cache manager. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * face_id :: + * The ID of the face object. + * + * @output: + * aface :: + * A handle to the face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned @FT_Face object is always owned by the manager. You + * should never try to discard it yourself. + * + * The @FT_Face object doesn't necessarily have a current size object + * (i.e., face->size can be~0). If you need a specific 'font size', use + * @FTC_Manager_LookupSize instead. + * + * Never change the face's transformation matrix (i.e., never call the + * @FT_Set_Transform function) on a returned face! If you need to + * transform glyphs, do it yourself after glyph loading. + * + * When you perform a lookup, out-of-memory errors are detected _within_ + * the lookup and force incremental flushes of the cache until enough + * memory is released for the lookup to succeed. + * + * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already + * been completely flushed, and still no memory was available for the + * operation. + */ FT_EXPORT( FT_Error ) FTC_Manager_LookupFace( FTC_Manager manager, FTC_FaceID face_id, FT_Face *aface ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_ScalerRec */ - /* */ - /* <Description> */ - /* A structure used to describe a given character size in either */ - /* pixels or points to the cache manager. See */ - /* @FTC_Manager_LookupSize. */ - /* */ - /* <Fields> */ - /* face_id :: The source face ID. */ - /* */ - /* width :: The character width. */ - /* */ - /* height :: The character height. */ - /* */ - /* pixel :: A Boolean. If 1, the `width' and `height' fields are */ - /* interpreted as integer pixel character sizes. */ - /* Otherwise, they are expressed as 1/64th of points. */ - /* */ - /* x_res :: Only used when `pixel' is value~0 to indicate the */ - /* horizontal resolution in dpi. */ - /* */ - /* y_res :: Only used when `pixel' is value~0 to indicate the */ - /* vertical resolution in dpi. */ - /* */ - /* <Note> */ - /* This type is mainly used to retrieve @FT_Size objects through the */ - /* cache manager. */ - /* */ + /************************************************************************** + * + * @struct: + * FTC_ScalerRec + * + * @description: + * A structure used to describe a given character size in either pixels + * or points to the cache manager. See @FTC_Manager_LookupSize. + * + * @fields: + * face_id :: + * The source face ID. + * + * width :: + * The character width. + * + * height :: + * The character height. + * + * pixel :: + * A Boolean. If 1, the `width` and `height` fields are interpreted as + * integer pixel character sizes. Otherwise, they are expressed as + * 1/64th of points. + * + * x_res :: + * Only used when `pixel` is value~0 to indicate the horizontal + * resolution in dpi. + * + * y_res :: + * Only used when `pixel` is value~0 to indicate the vertical + * resolution in dpi. + * + * @note: + * This type is mainly used to retrieve @FT_Size objects through the + * cache manager. + */ typedef struct FTC_ScalerRec_ { FTC_FaceID face_id; @@ -434,89 +451,93 @@ FT_BEGIN_HEADER } FTC_ScalerRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_Scaler */ - /* */ - /* <Description> */ - /* A handle to an @FTC_ScalerRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * FTC_Scaler + * + * @description: + * A handle to an @FTC_ScalerRec structure. + */ typedef struct FTC_ScalerRec_* FTC_Scaler; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_LookupSize */ - /* */ - /* <Description> */ - /* Retrieve the @FT_Size object that corresponds to a given */ - /* @FTC_ScalerRec pointer through a cache manager. */ - /* */ - /* <Input> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* scaler :: A scaler handle. */ - /* */ - /* <Output> */ - /* asize :: A handle to the size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned @FT_Size object is always owned by the manager. You */ - /* should never try to discard it by yourself. */ - /* */ - /* You can access the parent @FT_Face object simply as `size->face' */ - /* if you need it. Note that this object is also owned by the */ - /* manager. */ - /* */ - /* <Note> */ - /* When you perform a lookup, out-of-memory errors are detected */ - /* _within_ the lookup and force incremental flushes of the cache */ - /* until enough memory is released for the lookup to succeed. */ - /* */ - /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ - /* already been completely flushed, and still no memory is available */ - /* for the operation. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_Manager_LookupSize + * + * @description: + * Retrieve the @FT_Size object that corresponds to a given + * @FTC_ScalerRec pointer through a cache manager. + * + * @input: + * manager :: + * A handle to the cache manager. + * + * scaler :: + * A scaler handle. + * + * @output: + * asize :: + * A handle to the size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned @FT_Size object is always owned by the manager. You + * should never try to discard it by yourself. + * + * You can access the parent @FT_Face object simply as `size->face` if + * you need it. Note that this object is also owned by the manager. + * + * @note: + * When you perform a lookup, out-of-memory errors are detected _within_ + * the lookup and force incremental flushes of the cache until enough + * memory is released for the lookup to succeed. + * + * If a lookup fails with `FT_Err_Out_Of_Memory` the cache has already + * been completely flushed, and still no memory is available for the + * operation. + */ FT_EXPORT( FT_Error ) FTC_Manager_LookupSize( FTC_Manager manager, FTC_Scaler scaler, FT_Size *asize ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Node_Unref */ - /* */ - /* <Description> */ - /* Decrement a cache node's internal reference count. When the count */ - /* reaches 0, it is not destroyed but becomes eligible for subsequent */ - /* cache flushes. */ - /* */ - /* <Input> */ - /* node :: The cache node handle. */ - /* */ - /* manager :: The cache manager handle. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_Node_Unref + * + * @description: + * Decrement a cache node's internal reference count. When the count + * reaches 0, it is not destroyed but becomes eligible for subsequent + * cache flushes. + * + * @input: + * node :: + * The cache node handle. + * + * manager :: + * The cache manager handle. + */ FT_EXPORT( void ) FTC_Node_Unref( FTC_Node node, FTC_Manager manager ); - /************************************************************************* + /************************************************************************** * * @function: * FTC_Manager_RemoveFaceID * * @description: - * A special function used to indicate to the cache manager that - * a given @FTC_FaceID is no longer valid, either because its - * content changed, or because it was deallocated or uninstalled. + * A special function used to indicate to the cache manager that a given + * @FTC_FaceID is no longer valid, either because its content changed, or + * because it was deallocated or uninstalled. * * @input: * manager :: @@ -527,11 +548,11 @@ FT_BEGIN_HEADER * * @note: * This function flushes all nodes from the cache corresponding to this - * `face_id', with the exception of nodes with a non-null reference + * `face_id`, with the exception of nodes with a non-null reference * count. * - * Such nodes are however modified internally so as to never appear - * in later lookups with the same `face_id' value, and to be immediately + * Such nodes are however modified internally so as to never appear in + * later lookups with the same `face_id` value, and to be immediately * destroyed when released by all their users. * */ @@ -540,20 +561,20 @@ FT_BEGIN_HEADER FTC_FaceID face_id ); - /************************************************************************* + /************************************************************************** * * @type: * FTC_CMapCache * * @description: - * An opaque handle used to model a charmap cache. This cache is to - * hold character codes -> glyph indices mappings. + * An opaque handle used to model a charmap cache. This cache is to hold + * character codes -> glyph indices mappings. * */ typedef struct FTC_CMapCacheRec_* FTC_CMapCache; - /************************************************************************* + /************************************************************************** * * @function: * FTC_CMapCache_New @@ -567,7 +588,7 @@ FT_BEGIN_HEADER * * @output: * acache :: - * A new cache handle. NULL in case of error. + * A new cache handle. `NULL` in case of error. * * @return: * FreeType error code. 0~means success. @@ -582,7 +603,7 @@ FT_BEGIN_HEADER FTC_CMapCache *acache ); - /************************************************************************ + /************************************************************************** * * @function: * FTC_CMapCache_Lookup @@ -606,7 +627,7 @@ FT_BEGIN_HEADER * The character code (in the corresponding charmap). * * @return: - * Glyph index. 0~means `no glyph'. + * Glyph index. 0~means 'no glyph'. * */ FT_EXPORT( FT_UInt ) @@ -627,7 +648,7 @@ FT_BEGIN_HEADER /*************************************************************************/ - /************************************************************************* + /************************************************************************** * * @struct: * FTC_ImageTypeRec @@ -659,7 +680,7 @@ FT_BEGIN_HEADER } FTC_ImageTypeRec; - /************************************************************************* + /************************************************************************** * * @type: * FTC_ImageType @@ -680,83 +701,87 @@ FT_BEGIN_HEADER (d1)->flags == (d2)->flags ) - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_ImageCache */ - /* */ - /* <Description> */ - /* A handle to a glyph image cache object. They are designed to */ - /* hold many distinct glyph images while not exceeding a certain */ - /* memory threshold. */ - /* */ + /************************************************************************** + * + * @type: + * FTC_ImageCache + * + * @description: + * A handle to a glyph image cache object. They are designed to hold + * many distinct glyph images while not exceeding a certain memory + * threshold. + */ typedef struct FTC_ImageCacheRec_* FTC_ImageCache; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_New */ - /* */ - /* <Description> */ - /* Create a new glyph image cache. */ - /* */ - /* <Input> */ - /* manager :: The parent manager for the image cache. */ - /* */ - /* <Output> */ - /* acache :: A handle to the new glyph image cache object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_ImageCache_New + * + * @description: + * Create a new glyph image cache. + * + * @input: + * manager :: + * The parent manager for the image cache. + * + * @output: + * acache :: + * A handle to the new glyph image cache object. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FTC_ImageCache_New( FTC_Manager manager, FTC_ImageCache *acache ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_Lookup */ - /* */ - /* <Description> */ - /* Retrieve a given glyph image from a glyph image cache. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* type :: A pointer to a glyph image type descriptor. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* <Output> */ - /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ - /* failure. */ - /* */ - /* anode :: Used to return the address of the corresponding cache */ - /* node after incrementing its reference count (see note */ - /* below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned glyph is owned and managed by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with @FT_Glyph_Copy and modify the new one. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the @FT_Glyph) will */ - /* always be kept in the cache until you call @FTC_Node_Unref to */ - /* `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the @FT_Glyph could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ + /************************************************************************** + * + * @function: + * FTC_ImageCache_Lookup + * + * @description: + * Retrieve a given glyph image from a glyph image cache. + * + * @input: + * cache :: + * A handle to the source glyph image cache. + * + * type :: + * A pointer to a glyph image type descriptor. + * + * gindex :: + * The glyph index to retrieve. + * + * @output: + * aglyph :: + * The corresponding @FT_Glyph object. 0~in case of failure. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned glyph is owned and managed by the glyph image cache. + * Never try to transform or discard it manually! You can however create + * a copy with @FT_Glyph_Copy and modify the new one. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the glyph image, after increasing its reference count. + * This ensures that the node (as well as the @FT_Glyph) will always be + * kept in the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the @FT_Glyph could be flushed out of the cache on the next call + * to one of the caching sub-system APIs. Don't assume that it is + * persistent! + */ FT_EXPORT( FT_Error ) FTC_ImageCache_Lookup( FTC_ImageCache cache, FTC_ImageType type, @@ -765,54 +790,57 @@ FT_BEGIN_HEADER FTC_Node *anode ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_LookupScaler */ - /* */ - /* <Description> */ - /* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */ - /* to specify the face ID and its size. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* scaler :: A pointer to a scaler descriptor. */ - /* */ - /* load_flags :: The corresponding load flags. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* <Output> */ - /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ - /* failure. */ - /* */ - /* anode :: Used to return the address of the corresponding */ - /* cache node after incrementing its reference count */ - /* (see note below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned glyph is owned and managed by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with @FT_Glyph_Copy and modify the new one. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the @FT_Glyph) will */ - /* always be kept in the cache until you call @FTC_Node_Unref to */ - /* `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the @FT_Glyph could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - /* Calls to @FT_Set_Char_Size and friends have no effect on cached */ - /* glyphs; you should always use the FreeType cache API instead. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_ImageCache_LookupScaler + * + * @description: + * A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec to + * specify the face ID and its size. + * + * @input: + * cache :: + * A handle to the source glyph image cache. + * + * scaler :: + * A pointer to a scaler descriptor. + * + * load_flags :: + * The corresponding load flags. + * + * gindex :: + * The glyph index to retrieve. + * + * @output: + * aglyph :: + * The corresponding @FT_Glyph object. 0~in case of failure. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The returned glyph is owned and managed by the glyph image cache. + * Never try to transform or discard it manually! You can however create + * a copy with @FT_Glyph_Copy and modify the new one. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the glyph image, after increasing its reference count. + * This ensures that the node (as well as the @FT_Glyph) will always be + * kept in the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the @FT_Glyph could be flushed out of the cache on the next call + * to one of the caching sub-system APIs. Don't assume that it is + * persistent! + * + * Calls to @FT_Set_Char_Size and friends have no effect on cached + * glyphs; you should always use the FreeType cache API instead. + */ FT_EXPORT( FT_Error ) FTC_ImageCache_LookupScaler( FTC_ImageCache cache, FTC_Scaler scaler, @@ -822,53 +850,60 @@ FT_BEGIN_HEADER FTC_Node *anode ); - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_SBit */ - /* */ - /* <Description> */ - /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */ - /* structure for details. */ - /* */ + /************************************************************************** + * + * @type: + * FTC_SBit + * + * @description: + * A handle to a small bitmap descriptor. See the @FTC_SBitRec structure + * for details. + */ typedef struct FTC_SBitRec_* FTC_SBit; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_SBitRec */ - /* */ - /* <Description> */ - /* A very compact structure used to describe a small glyph bitmap. */ - /* */ - /* <Fields> */ - /* width :: The bitmap width in pixels. */ - /* */ - /* height :: The bitmap height in pixels. */ - /* */ - /* left :: The horizontal distance from the pen position to the */ - /* left bitmap border (a.k.a. `left side bearing', or */ - /* `lsb'). */ - /* */ - /* top :: The vertical distance from the pen position (on the */ - /* baseline) to the upper bitmap border (a.k.a. `top */ - /* side bearing'). The distance is positive for upwards */ - /* y~coordinates. */ - /* */ - /* format :: The format of the glyph bitmap (monochrome or gray). */ - /* */ - /* max_grays :: Maximum gray level value (in the range 1 to~255). */ - /* */ - /* pitch :: The number of bytes per bitmap line. May be positive */ - /* or negative. */ - /* */ - /* xadvance :: The horizontal advance width in pixels. */ - /* */ - /* yadvance :: The vertical advance height in pixels. */ - /* */ - /* buffer :: A pointer to the bitmap pixels. */ - /* */ + /************************************************************************** + * + * @struct: + * FTC_SBitRec + * + * @description: + * A very compact structure used to describe a small glyph bitmap. + * + * @fields: + * width :: + * The bitmap width in pixels. + * + * height :: + * The bitmap height in pixels. + * + * left :: + * The horizontal distance from the pen position to the left bitmap + * border (a.k.a. 'left side bearing', or 'lsb'). + * + * top :: + * The vertical distance from the pen position (on the baseline) to the + * upper bitmap border (a.k.a. 'top side bearing'). The distance is + * positive for upwards y~coordinates. + * + * format :: + * The format of the glyph bitmap (monochrome or gray). + * + * max_grays :: + * Maximum gray level value (in the range 1 to~255). + * + * pitch :: + * The number of bytes per bitmap line. May be positive or negative. + * + * xadvance :: + * The horizontal advance width in pixels. + * + * yadvance :: + * The vertical advance height in pixels. + * + * buffer :: + * A pointer to the bitmap pixels. + */ typedef struct FTC_SBitRec_ { FT_Byte width; @@ -887,87 +922,93 @@ FT_BEGIN_HEADER } FTC_SBitRec; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_SBitCache */ - /* */ - /* <Description> */ - /* A handle to a small bitmap cache. These are special cache objects */ - /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */ - /* much more efficient way than the traditional glyph image cache */ - /* implemented by @FTC_ImageCache. */ - /* */ + /************************************************************************** + * + * @type: + * FTC_SBitCache + * + * @description: + * A handle to a small bitmap cache. These are special cache objects + * used to store small glyph bitmaps (and anti-aliased pixmaps) in a much + * more efficient way than the traditional glyph image cache implemented + * by @FTC_ImageCache. + */ typedef struct FTC_SBitCacheRec_* FTC_SBitCache; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_New */ - /* */ - /* <Description> */ - /* Create a new cache to store small glyph bitmaps. */ - /* */ - /* <Input> */ - /* manager :: A handle to the source cache manager. */ - /* */ - /* <Output> */ - /* acache :: A handle to the new sbit cache. NULL in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FTC_SBitCache_New + * + * @description: + * Create a new cache to store small glyph bitmaps. + * + * @input: + * manager :: + * A handle to the source cache manager. + * + * @output: + * acache :: + * A handle to the new sbit cache. `NULL` in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FTC_SBitCache_New( FTC_Manager manager, FTC_SBitCache *acache ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_Lookup */ - /* */ - /* <Description> */ - /* Look up a given small glyph bitmap in a given sbit cache and */ - /* `lock' it to prevent its flushing from the cache until needed. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source sbit cache. */ - /* */ - /* type :: A pointer to the glyph image type descriptor. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* sbit :: A handle to a small bitmap descriptor. */ - /* */ - /* anode :: Used to return the address of the corresponding cache */ - /* node after incrementing its reference count (see note */ - /* below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The small bitmap descriptor and its bit buffer are owned by the */ - /* cache and should never be freed by the application. They might */ - /* as well disappear from memory on the next cache lookup, so don't */ - /* treat them as persistent data. */ - /* */ - /* The descriptor's `buffer' field is set to~0 to indicate a missing */ - /* glyph bitmap. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the bitmap, after increasing its reference count. */ - /* This ensures that the node (as well as the image) will always be */ - /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the bitmap could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ + /************************************************************************** + * + * @function: + * FTC_SBitCache_Lookup + * + * @description: + * Look up a given small glyph bitmap in a given sbit cache and 'lock' it + * to prevent its flushing from the cache until needed. + * + * @input: + * cache :: + * A handle to the source sbit cache. + * + * type :: + * A pointer to the glyph image type descriptor. + * + * gindex :: + * The glyph index. + * + * @output: + * sbit :: + * A handle to a small bitmap descriptor. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The small bitmap descriptor and its bit buffer are owned by the cache + * and should never be freed by the application. They might as well + * disappear from memory on the next cache lookup, so don't treat them as + * persistent data. + * + * The descriptor's `buffer` field is set to~0 to indicate a missing + * glyph bitmap. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the bitmap, after increasing its reference count. This + * ensures that the node (as well as the image) will always be kept in + * the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the bitmap could be flushed out of the cache on the next call to + * one of the caching sub-system APIs. Don't assume that it is + * persistent! + */ FT_EXPORT( FT_Error ) FTC_SBitCache_Lookup( FTC_SBitCache cache, FTC_ImageType type, @@ -976,53 +1017,58 @@ FT_BEGIN_HEADER FTC_Node *anode ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_LookupScaler */ - /* */ - /* <Description> */ - /* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */ - /* to specify the face ID and its size. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source sbit cache. */ - /* */ - /* scaler :: A pointer to the scaler descriptor. */ - /* */ - /* load_flags :: The corresponding load flags. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* sbit :: A handle to a small bitmap descriptor. */ - /* */ - /* anode :: Used to return the address of the corresponding */ - /* cache node after incrementing its reference count */ - /* (see note below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The small bitmap descriptor and its bit buffer are owned by the */ - /* cache and should never be freed by the application. They might */ - /* as well disappear from memory on the next cache lookup, so don't */ - /* treat them as persistent data. */ - /* */ - /* The descriptor's `buffer' field is set to~0 to indicate a missing */ - /* glyph bitmap. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the bitmap, after increasing its reference count. */ - /* This ensures that the node (as well as the image) will always be */ - /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the bitmap could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ + /************************************************************************** + * + * @function: + * FTC_SBitCache_LookupScaler + * + * @description: + * A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec to + * specify the face ID and its size. + * + * @input: + * cache :: + * A handle to the source sbit cache. + * + * scaler :: + * A pointer to the scaler descriptor. + * + * load_flags :: + * The corresponding load flags. + * + * gindex :: + * The glyph index. + * + * @output: + * sbit :: + * A handle to a small bitmap descriptor. + * + * anode :: + * Used to return the address of the corresponding cache node after + * incrementing its reference count (see note below). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The small bitmap descriptor and its bit buffer are owned by the cache + * and should never be freed by the application. They might as well + * disappear from memory on the next cache lookup, so don't treat them as + * persistent data. + * + * The descriptor's `buffer` field is set to~0 to indicate a missing + * glyph bitmap. + * + * If `anode` is _not_ `NULL`, it receives the address of the cache node + * containing the bitmap, after increasing its reference count. This + * ensures that the node (as well as the image) will always be kept in + * the cache until you call @FTC_Node_Unref to 'release' it. + * + * If `anode` is `NULL`, the cache node is left unchanged, which means + * that the bitmap could be flushed out of the cache on the next call to + * one of the caching sub-system APIs. Don't assume that it is + * persistent! + */ FT_EXPORT( FT_Error ) FTC_SBitCache_LookupScaler( FTC_SBitCache cache, FTC_Scaler scaler, diff --git a/src/3rdparty/freetype/include/freetype/ftchapters.h b/src/3rdparty/freetype/include/freetype/ftchapters.h index 51257bb7ca..2ee26973e4 100644 --- a/src/3rdparty/freetype/include/freetype/ftchapters.h +++ b/src/3rdparty/freetype/include/freetype/ftchapters.h @@ -1,139 +1,145 @@ -/***************************************************************************/ -/* */ -/* This file defines the structure of the FreeType reference. */ -/* It is used by the python script that generates the HTML files. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* general_remarks */ -/* */ -/* <Title> */ -/* General Remarks */ -/* */ -/* <Sections> */ -/* header_inclusion */ -/* user_allocation */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* core_api */ -/* */ -/* <Title> */ -/* Core API */ -/* */ -/* <Sections> */ -/* version */ -/* basic_types */ -/* base_interface */ -/* glyph_variants */ -/* glyph_management */ -/* mac_specific */ -/* sizes_management */ -/* header_file_macros */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* format_specific */ -/* */ -/* <Title> */ -/* Format-Specific API */ -/* */ -/* <Sections> */ -/* multiple_masters */ -/* truetype_tables */ -/* type1_tables */ -/* sfnt_names */ -/* bdf_fonts */ -/* cid_fonts */ -/* pfr_fonts */ -/* winfnt_fonts */ -/* font_formats */ -/* gasp_table */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* module_specific */ -/* */ -/* <Title> */ -/* Controlling FreeType Modules */ -/* */ -/* <Sections> */ -/* auto_hinter */ -/* cff_driver */ -/* t1_cid_driver */ -/* tt_driver */ -/* pcf_driver */ -/* properties */ -/* parameter_tags */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* cache_subsystem */ -/* */ -/* <Title> */ -/* Cache Sub-System */ -/* */ -/* <Sections> */ -/* cache_subsystem */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* support_api */ -/* */ -/* <Title> */ -/* Support API */ -/* */ -/* <Sections> */ -/* computations */ -/* list_processing */ -/* outline_processing */ -/* quick_advance */ -/* bitmap_handling */ -/* raster */ -/* glyph_stroker */ -/* system_interface */ -/* module_management */ -/* gzip */ -/* lzw */ -/* bzip2 */ -/* lcd_filtering */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* error_codes */ -/* */ -/* <Title> */ -/* Error Codes */ -/* */ -/* <Sections> */ -/* error_enumerations */ -/* error_code_values */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * This file defines the structure of the FreeType reference. + * It is used by the python script that generates the HTML files. + * + */ + + + /************************************************************************** + * + * @chapter: + * general_remarks + * + * @title: + * General Remarks + * + * @sections: + * header_inclusion + * user_allocation + * + */ + + + /************************************************************************** + * + * @chapter: + * core_api + * + * @title: + * Core API + * + * @sections: + * version + * basic_types + * base_interface + * glyph_variants + * color_management + * layer_management + * glyph_management + * mac_specific + * sizes_management + * header_file_macros + * + */ + + + /************************************************************************** + * + * @chapter: + * format_specific + * + * @title: + * Format-Specific API + * + * @sections: + * multiple_masters + * truetype_tables + * type1_tables + * sfnt_names + * bdf_fonts + * cid_fonts + * pfr_fonts + * winfnt_fonts + * font_formats + * gasp_table + * + */ + + + /************************************************************************** + * + * @chapter: + * module_specific + * + * @title: + * Controlling FreeType Modules + * + * @sections: + * auto_hinter + * cff_driver + * t1_cid_driver + * tt_driver + * pcf_driver + * properties + * parameter_tags + * lcd_rendering + * + */ + + + /************************************************************************** + * + * @chapter: + * cache_subsystem + * + * @title: + * Cache Sub-System + * + * @sections: + * cache_subsystem + * + */ + + + /************************************************************************** + * + * @chapter: + * support_api + * + * @title: + * Support API + * + * @sections: + * computations + * list_processing + * outline_processing + * quick_advance + * bitmap_handling + * raster + * glyph_stroker + * system_interface + * module_management + * gzip + * lzw + * bzip2 + * + */ + + + /************************************************************************** + * + * @chapter: + * error_codes + * + * @title: + * Error Codes + * + * @sections: + * error_enumerations + * error_code_values + * + */ + + +/* END */ diff --git a/src/3rdparty/freetype/include/freetype/ftcid.h b/src/3rdparty/freetype/include/freetype/ftcid.h index 5e9100a67c..8eafc1c78f 100644 --- a/src/3rdparty/freetype/include/freetype/ftcid.h +++ b/src/3rdparty/freetype/include/freetype/ftcid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcid.h */ -/* */ -/* FreeType API for accessing CID font information (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* Dereg Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcid.h + * + * FreeType API for accessing CID font information (specification). + * + * Copyright (C) 2007-2019 by + * Dereg Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCID_H_ @@ -32,25 +32,25 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* cid_fonts */ - /* */ - /* <Title> */ - /* CID Fonts */ - /* */ - /* <Abstract> */ - /* CID-keyed font specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of CID-keyed font specific */ - /* functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * cid_fonts + * + * @title: + * CID Fonts + * + * @abstract: + * CID-keyed font-specific API. + * + * @description: + * This section contains the declaration of CID-keyed font-specific + * functions. + * + */ - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_CID_Registry_Ordering_Supplement @@ -61,17 +61,17 @@ FT_BEGIN_HEADER * * @input: * face :: - * A handle to the input face. + * A handle to the input face. * * @output: * registry :: - * The registry, as a C~string, owned by the face. + * The registry, as a C~string, owned by the face. * * ordering :: - * The ordering, as a C~string, owned by the face. + * The ordering, as a C~string, owned by the face. * * supplement :: - * The supplement. + * The supplement. * * @return: * FreeType error code. 0~means success. @@ -90,30 +90,30 @@ FT_BEGIN_HEADER FT_Int *supplement ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_CID_Is_Internally_CID_Keyed * * @description: - * Retrieve the type of the input face, CID keyed or not. In - * contrast to the @FT_IS_CID_KEYED macro this function returns - * successfully also for CID-keyed fonts in an SFNT wrapper. + * Retrieve the type of the input face, CID keyed or not. In contrast + * to the @FT_IS_CID_KEYED macro this function returns successfully also + * for CID-keyed fonts in an SFNT wrapper. * * @input: * face :: - * A handle to the input face. + * A handle to the input face. * * @output: * is_cid :: - * The type of the face as an @FT_Bool. + * The type of the face as an @FT_Bool. * * @return: * FreeType error code. 0~means success. * * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. + * This function only works with CID faces and OpenType fonts, returning + * an error otherwise. * * @since: * 2.3.9 @@ -123,7 +123,7 @@ FT_BEGIN_HEADER FT_Bool *is_cid ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_CID_From_Glyph_Index @@ -133,21 +133,21 @@ FT_BEGIN_HEADER * * @input: * face :: - * A handle to the input face. + * A handle to the input face. * * glyph_index :: - * The input glyph index. + * The input glyph index. * * @output: * cid :: - * The CID as an @FT_UInt. + * The CID as an @FT_UInt. * * @return: * FreeType error code. 0~means success. * * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. + * This function only works with CID faces and OpenType fonts, returning + * an error otherwise. * * @since: * 2.3.9 diff --git a/src/3rdparty/freetype/include/freetype/ftcolor.h b/src/3rdparty/freetype/include/freetype/ftcolor.h new file mode 100644 index 0000000000..cf18021953 --- /dev/null +++ b/src/3rdparty/freetype/include/freetype/ftcolor.h @@ -0,0 +1,311 @@ +/**************************************************************************** + * + * ftcolor.h + * + * FreeType's glyph color management (specification). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef FTCOLOR_H_ +#define FTCOLOR_H_ + +#include <ft2build.h> +#include FT_FREETYPE_H + +#ifdef FREETYPE_H +#error "freetype.h of FreeType 1 has been loaded!" +#error "Please fix the directory search order for header files" +#error "so that freetype.h of FreeType 2 is found first." +#endif + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @section: + * color_management + * + * @title: + * Glyph Color Management + * + * @abstract: + * Retrieving and manipulating OpenType's 'CPAL' table data. + * + * @description: + * The functions described here allow access and manipulation of color + * palette entries in OpenType's 'CPAL' tables. + */ + + + /************************************************************************** + * + * @struct: + * FT_Color + * + * @description: + * This structure models a BGRA color value of a 'CPAL' palette entry. + * + * The used color space is sRGB; the colors are not pre-multiplied, and + * alpha values must be explicitly set. + * + * @fields: + * blue :: + * Blue value. + * + * green :: + * Green value. + * + * red :: + * Red value. + * + * alpha :: + * Alpha value, giving the red, green, and blue color's opacity. + * + * @since: + * 2.10 + */ + typedef struct FT_Color_ + { + FT_Byte blue; + FT_Byte green; + FT_Byte red; + FT_Byte alpha; + + } FT_Color; + + + /************************************************************************** + * + * @enum: + * FT_PALETTE_XXX + * + * @description: + * A list of bit field constants used in the `palette_flags` array of the + * @FT_Palette_Data structure to indicate for which background a palette + * with a given index is usable. + * + * @values: + * FT_PALETTE_FOR_LIGHT_BACKGROUND :: + * The palette is appropriate to use when displaying the font on a + * light background such as white. + * + * FT_PALETTE_FOR_DARK_BACKGROUND :: + * The palette is appropriate to use when displaying the font on a dark + * background such as black. + * + * @since: + * 2.10 + */ +#define FT_PALETTE_FOR_LIGHT_BACKGROUND 0x01 +#define FT_PALETTE_FOR_DARK_BACKGROUND 0x02 + + + /************************************************************************** + * + * @struct: + * FT_Palette_Data + * + * @description: + * This structure holds the data of the 'CPAL' table. + * + * @fields: + * num_palettes :: + * The number of palettes. + * + * palette_name_ids :: + * A read-only array of palette name IDs with `num_palettes` elements, + * corresponding to entries like 'dark' or 'light' in the font's 'name' + * table. + * + * An empty name ID in the 'CPAL' table gets represented as value + * 0xFFFF. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * palette_flags :: + * A read-only array of palette flags with `num_palettes` elements. + * Possible values are an ORed combination of + * @FT_PALETTE_FOR_LIGHT_BACKGROUND and + * @FT_PALETTE_FOR_DARK_BACKGROUND. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * num_palette_entries :: + * The number of entries in a single palette. All palettes have the + * same size. + * + * palette_entry_name_ids :: + * A read-only array of palette entry name IDs with + * `num_palette_entries`. In each palette, entries with the same index + * have the same function. For example, index~0 might correspond to + * string 'outline' in the font's 'name' table to indicate that this + * palette entry is used for outlines, index~1 might correspond to + * 'fill' to indicate the filling color palette entry, etc. + * + * An empty entry name ID in the 'CPAL' table gets represented as value + * 0xFFFF. + * + * `NULL` if the font's 'CPAL' table doesn't contain appropriate data. + * + * @note: + * Use function @FT_Get_Sfnt_Name to map name IDs and entry name IDs to + * name strings. + * + * @since: + * 2.10 + */ + typedef struct FT_Palette_Data_ { + FT_UShort num_palettes; + const FT_UShort* palette_name_ids; + const FT_UShort* palette_flags; + + FT_UShort num_palette_entries; + const FT_UShort* palette_entry_name_ids; + + } FT_Palette_Data; + + + /************************************************************************** + * + * @function: + * FT_Palette_Data_Get + * + * @description: + * Retrieve the face's color palette data. + * + * @input: + * face :: + * The source face handle. + * + * @output: + * apalette :: + * A pointer to an @FT_Palette_Data structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * All arrays in the returned @FT_Palette_Data structure are read-only. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Data_Get( FT_Face face, + FT_Palette_Data *apalette ); + + + /************************************************************************** + * + * @function: + * FT_Palette_Select + * + * @description: + * This function has two purposes. + * + * (1) It activates a palette for rendering color glyphs, and + * + * (2) it retrieves all (unmodified) color entries of this palette. This + * function returns a read-write array, which means that a calling + * application can modify the palette entries on demand. + * + * A corollary of (2) is that calling the function, then modifying some + * values, then calling the function again with the same arguments resets + * all color entries to the original 'CPAL' values; all user modifications + * are lost. + * + * @input: + * face :: + * The source face handle. + * + * palette_index :: + * The palette index. + * + * @output: + * apalette :: + * An array of color entries for a palette with index `palette_index`, + * having `num_palette_entries` elements (as found in the + * `FT_Palette_Data` structure). If `apalette` is set to `NULL`, no + * array gets returned (and no color entries can be modified). + * + * In case the font doesn't support color palettes, `NULL` is returned. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The array pointed to by `apalette_entries` is owned and managed by + * FreeType. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Select( FT_Face face, + FT_UShort palette_index, + FT_Color* *apalette ); + + + /************************************************************************** + * + * @function: + * FT_Palette_Set_Foreground_Color + * + * @description: + * 'COLR' uses palette index 0xFFFF to indicate a 'text foreground + * color'. This function sets this value. + * + * @input: + * face :: + * The source face handle. + * + * foreground_color :: + * An `FT_Color` structure to define the text foreground color. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If this function isn't called, the text foreground color is set to + * white opaque (BGRA value 0xFFFFFFFF) if + * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette, + * and black opaque (BGRA value 0x000000FF) otherwise, including the case + * that no palette types are available in the 'CPAL' table. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Palette_Set_Foreground_Color( FT_Face face, + FT_Color foreground_color ); + + /* */ + + +FT_END_HEADER + +#endif /* FTCOLOR_H_ */ + + +/* END */ diff --git a/src/3rdparty/freetype/include/freetype/ftdriver.h b/src/3rdparty/freetype/include/freetype/ftdriver.h index e90475b2af..497bde9f6e 100644 --- a/src/3rdparty/freetype/include/freetype/ftdriver.h +++ b/src/3rdparty/freetype/include/freetype/ftdriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftdriver.h */ -/* */ -/* FreeType API for controlling driver modules (specification only). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdriver.h + * + * FreeType API for controlling driver modules (specification only). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTDRIVER_H_ @@ -50,8 +50,8 @@ FT_BEGIN_HEADER * @FT_Property_Get. The following lists the available properties * together with the necessary macros and structures. * - * Note that the auto-hinter's module name is `autofitter' for - * historical reasons. + * Note that the auto-hinter's module name is 'autofitter' for historical + * reasons. * * Available properties are @increase-x-height, @no-stem-darkening * (experimental), @darkening-parameters (experimental), @warping @@ -74,18 +74,18 @@ FT_BEGIN_HEADER * Controlling the CFF driver module. * * @description: - * While FreeType's CFF driver doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and + * While FreeType's CFF driver doesn't expose API functions by itself, it + * is possible to control its behaviour with @FT_Property_Set and * @FT_Property_Get. * - * The CFF driver's module name is `cff'. + * The CFF driver's module name is 'cff'. * * Available properties are @hinting-engine, @no-stem-darkening, * @darkening-parameters, and @random-seed, as documented in the * @properties section. * * - * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine* + * **Hinting and antialiasing principles of the new engine** * * The rasterizer is positioning horizontal features (e.g., ascender * height & x-height, or crossbars) on the pixel grid and minimizing the @@ -93,35 +93,34 @@ FT_BEGIN_HEADER * features (vertical stems) on the pixel grid without hinting, thus * representing the stem position and weight accurately. Sometimes the * vertical stems may be only partially black. In this context, - * `antialiasing' means that stems are not positioned exactly on pixel + * 'antialiasing' means that stems are not positioned exactly on pixel * borders, causing a fuzzy appearance. * * There are two principles behind this approach. * - * 1) No hinting in the horizontal direction: Unlike `superhinted' + * 1) No hinting in the horizontal direction: Unlike 'superhinted' * TrueType, which changes glyph widths to accommodate regular - * inter-glyph spacing, Adobe's approach is `faithful to the design' in - * representing both the glyph width and the inter-glyph spacing - * designed for the font. This makes the screen display as close as it - * can be to the result one would get with infinite resolution, while - * preserving what is considered the key characteristics of each glyph. - * Note that the distances between unhinted and grid-fitted positions at - * small sizes are comparable to kerning values and thus would be - * noticeable (and distracting) while reading if hinting were applied. + * inter-glyph spacing, Adobe's approach is 'faithful to the design' in + * representing both the glyph width and the inter-glyph spacing designed + * for the font. This makes the screen display as close as it can be to + * the result one would get with infinite resolution, while preserving + * what is considered the key characteristics of each glyph. Note that + * the distances between unhinted and grid-fitted positions at small + * sizes are comparable to kerning values and thus would be noticeable + * (and distracting) while reading if hinting were applied. * * One of the reasons to not hint horizontally is antialiasing for LCD - * screens: The pixel geometry of modern displays supplies three - * vertical subpixels as the eye moves horizontally across each visible - * pixel. On devices where we can be certain this characteristic is - * present a rasterizer can take advantage of the subpixels to add - * increments of weight. In Western writing systems this turns out to - * be the more critical direction anyway; the weights and spacing of - * vertical stems (see above) are central to Armenian, Cyrillic, Greek, - * and Latin type designs. Even when the rasterizer uses greyscale - * antialiasing instead of color (a necessary compromise when one - * doesn't know the screen characteristics), the unhinted vertical - * features preserve the design's weight and spacing much better than - * aliased type would. + * screens: The pixel geometry of modern displays supplies three vertical + * subpixels as the eye moves horizontally across each visible pixel. On + * devices where we can be certain this characteristic is present a + * rasterizer can take advantage of the subpixels to add increments of + * weight. In Western writing systems this turns out to be the more + * critical direction anyway; the weights and spacing of vertical stems + * (see above) are central to Armenian, Cyrillic, Greek, and Latin type + * designs. Even when the rasterizer uses greyscale antialiasing instead + * of color (a necessary compromise when one doesn't know the screen + * characteristics), the unhinted vertical features preserve the design's + * weight and spacing much better than aliased type would. * * 2) Alignment in the vertical direction: Weights and spacing along the * y~axis are less critical; what is much more important is the visual @@ -132,16 +131,16 @@ FT_BEGIN_HEADER * * On the technical side, horizontal alignment zones for ascender, * x-height, and other important height values (traditionally called - * `blue zones') as defined in the font are positioned independently, - * each being rounded to the nearest pixel edge, taking care of - * overshoot suppression at small sizes, stem darkening, and scaling. + * 'blue zones') as defined in the font are positioned independently, + * each being rounded to the nearest pixel edge, taking care of overshoot + * suppression at small sizes, stem darkening, and scaling. * * Hstems (this is, hint values defined in the font to help align * horizontal features) that fall within a blue zone are said to be - * `captured' and are aligned to that zone. Uncaptured stems are moved + * 'captured' and are aligned to that zone. Uncaptured stems are moved * in one of four ways, top edge up or down, bottom edge up or down. - * Unless there are conflicting hstems, the smallest movement is taken - * to minimize distortion. + * Unless there are conflicting hstems, the smallest movement is taken to + * minimize distortion. * */ @@ -158,13 +157,13 @@ FT_BEGIN_HEADER * Controlling the PCF driver module. * * @description: - * While FreeType's PCF driver doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and + * While FreeType's PCF driver doesn't expose API functions by itself, it + * is possible to control its behaviour with @FT_Property_Set and * @FT_Property_Get. Right now, there is a single property * @no-long-family-names available if FreeType is compiled with * PCF_CONFIG_OPTION_LONG_FAMILY_NAMES. * - * The PCF driver's module name is `pcf'. + * The PCF driver's module name is 'pcf'. * */ @@ -187,15 +186,15 @@ FT_BEGIN_HEADER * Behind the scenes, both drivers use the Adobe CFF engine for hinting; * however, the used properties must be specified separately. * - * The Type~1 driver's module name is `type1'; the CID driver's module - * name is `t1cid'. + * The Type~1 driver's module name is 'type1'; the CID driver's module + * name is 't1cid'. * * Available properties are @hinting-engine, @no-stem-darkening, * @darkening-parameters, and @random-seed, as documented in the * @properties section. * - * Please see the @cff_driver section for more details on the new - * hinting engine. + * Please see the @cff_driver section for more details on the new hinting + * engine. * */ @@ -217,7 +216,7 @@ FT_BEGIN_HEADER * and @FT_Property_Get. The following lists the available properties * together with the necessary macros and structures. * - * The TrueType driver's module name is `truetype'. + * The TrueType driver's module name is 'truetype'. * * A single property @interpreter-version is available, as documented in * the @properties section. @@ -225,36 +224,36 @@ FT_BEGIN_HEADER * We start with a list of definitions, kindly provided by Greg * Hitchcock. * - * _Bi-Level_ _Rendering_ + * _Bi-Level Rendering_ * * Monochromatic rendering, exclusively used in the early days of * TrueType by both Apple and Microsoft. Microsoft's GDI interface * supported hinting of the right-side bearing point, such that the * advance width could be non-linear. Most often this was done to * achieve some level of glyph symmetry. To enable reasonable - * performance (e.g., not having to run hinting on all glyphs just to - * get the widths) there was a bit in the head table indicating if the - * side bearing was hinted, and additional tables, `hdmx' and `LTSH', to - * cache hinting widths across multiple sizes and device aspect ratios. + * performance (e.g., not having to run hinting on all glyphs just to get + * the widths) there was a bit in the head table indicating if the side + * bearing was hinted, and additional tables, 'hdmx' and 'LTSH', to cache + * hinting widths across multiple sizes and device aspect ratios. * - * _Font_ _Smoothing_ + * _Font Smoothing_ * * Microsoft's GDI implementation of anti-aliasing. Not traditional * anti-aliasing as the outlines were hinted before the sampling. The * widths matched the bi-level rendering. * - * _ClearType_ _Rendering_ + * _ClearType Rendering_ * * Technique that uses physical subpixels to improve rendering on LCD * (and other) displays. Because of the higher resolution, many methods - * of improving symmetry in glyphs through hinting the right-side - * bearing were no longer necessary. This lead to what GDI calls - * `natural widths' ClearType, see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting + * of improving symmetry in glyphs through hinting the right-side bearing + * were no longer necessary. This lead to what GDI calls 'natural + * widths' ClearType, see + * http://rastertragedy.com/RTRCh4.htm#Sec21. Since hinting * has extra resolution, most non-linearity went away, but it is still * possible for hints to change the advance widths in this mode. * - * _ClearType_ _Compatible_ _Widths_ + * _ClearType Compatible Widths_ * * One of the earliest challenges with ClearType was allowing the * implementation in GDI to be selected without requiring all UI and @@ -263,41 +262,41 @@ FT_BEGIN_HEADER * to determine the width in bi-level rendering, and then re-run in * ClearType, with the difference in widths being absorbed in the font * hints for ClearType (mostly in the white space of hints); see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by + * http://rastertragedy.com/RTRCh4.htm#Sec20. Somewhat by * definition, compatible width ClearType allows for non-linear widths, * but only when the bi-level version has non-linear widths. * - * _ClearType_ _Subpixel_ _Positioning_ + * _ClearType Subpixel Positioning_ * * One of the nice benefits of ClearType is the ability to more crisply * display fractional widths; unfortunately, the GDI model of integer * bitmaps did not support this. However, the WPF and Direct Write - * frameworks do support fractional widths. DWrite calls this `natural - * mode', not to be confused with GDI's `natural widths'. Subpixel + * frameworks do support fractional widths. DWrite calls this 'natural + * mode', not to be confused with GDI's 'natural widths'. Subpixel * positioning, in the current implementation of Direct Write, * unfortunately does not support hinted advance widths, see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the + * http://rastertragedy.com/RTRCh4.htm#Sec22. Note that the * TrueType interpreter fully allows the advance width to be adjusted in * this mode, just the DWrite client will ignore those changes. * - * _ClearType_ _Backward_ _Compatibility_ + * _ClearType Backward Compatibility_ * * This is a set of exceptions made in the TrueType interpreter to * minimize hinting techniques that were problematic with the extra * resolution of ClearType; see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and + * http://rastertragedy.com/RTRCh4.htm#Sec1 and * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. - * This technique is not to be confused with ClearType compatible - * widths. ClearType backward compatibility has no direct impact on - * changing advance widths, but there might be an indirect impact on - * disabling some deltas. This could be worked around in backward - * compatibility mode. + * This technique is not to be confused with ClearType compatible widths. + * ClearType backward compatibility has no direct impact on changing + * advance widths, but there might be an indirect impact on disabling + * some deltas. This could be worked around in backward compatibility + * mode. * - * _Native_ _ClearType_ _Mode_ + * _Native ClearType Mode_ * - * (Not to be confused with `natural widths'.) This mode removes all - * the exceptions in the TrueType interpreter when running with - * ClearType. Any issues on widths would still apply, though. + * (Not to be confused with 'natural widths'.) This mode removes all the + * exceptions in the TrueType interpreter when running with ClearType. + * Any issues on widths would still apply, though. * */ @@ -328,8 +327,8 @@ FT_BEGIN_HEADER * FT_HINTING_XXX * * @description: - * A list of constants used for the @hinting-engine property to - * select the hinting engine for CFF, Type~1, and CID fonts. + * A list of constants used for the @hinting-engine property to select + * the hinting engine for CFF, Type~1, and CID fonts. * * @values: * FT_HINTING_FREETYPE :: @@ -356,45 +355,46 @@ FT_BEGIN_HEADER * hinting-engine * * @description: - * Thanks to Adobe, which contributed a new hinting (and parsing) - * engine, an application can select between `freetype' and `adobe' if - * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration - * macro isn't defined, `hinting-engine' does nothing. + * Thanks to Adobe, which contributed a new hinting (and parsing) engine, + * an application can select between 'freetype' and 'adobe' if compiled + * with `CFF_CONFIG_OPTION_OLD_ENGINE`. If this configuration macro + * isn't defined, 'hinting-engine' does nothing. * * The same holds for the Type~1 and CID modules if compiled with - * T1_CONFIG_OPTION_OLD_ENGINE. + * `T1_CONFIG_OPTION_OLD_ENGINE`. * - * For the `cff' module, the default engine is `freetype' if - * CFF_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' otherwise. + * For the 'cff' module, the default engine is 'freetype' if + * `CFF_CONFIG_OPTION_OLD_ENGINE` is defined, and 'adobe' otherwise. * - * For both the `type1' and `t1cid' modules, the default engine is - * `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' + * For both the 'type1' and 't1cid' modules, the default engine is + * 'freetype' if `T1_CONFIG_OPTION_OLD_ENGINE` is defined, and 'adobe' * otherwise. * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 'adobe' or 'freetype'). + * + * @example: * The following example code demonstrates how to select Adobe's hinting - * engine for the `cff' module (omitting the error handling). + * engine for the 'cff' module (omitting the error handling). * - * { + * ``` * FT_Library library; - * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; + * FT_UInt hinting_engine = FT_HINTING_ADOBE; * * * FT_Init_FreeType( &library ); * * FT_Property_Set( library, "cff", * "hinting-engine", &hinting_engine ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values `adobe' or `freetype'). + * ``` * * @since: - * 2.4.12 (for `cff' module) + * 2.4.12 (for 'cff' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -405,10 +405,10 @@ FT_BEGIN_HEADER * no-stem-darkening * * @description: - * All glyphs that pass through the auto-hinter will be emboldened - * unless this property is set to TRUE. The same is true for the CFF, - * Type~1, and CID font modules if the `Adobe' engine is selected (which - * is the default). + * All glyphs that pass through the auto-hinter will be emboldened unless + * this property is set to TRUE. The same is true for the CFF, Type~1, + * and CID font modules if the 'Adobe' engine is selected (which is the + * default). * * Stem darkening emboldens glyphs at smaller sizes to make them more * readable on common low-DPI screens when using linear alpha blending @@ -419,30 +419,38 @@ FT_BEGIN_HEADER * Gamma correction essentially lightens fonts since shades of grey are * shifted to higher pixel values (=~higher brightness) to match the * original intention to the reality of our screens. The side-effect is - * that glyphs `thin out'. Mac OS~X and Adobe's proprietary font + * that glyphs 'thin out'. Mac OS~X and Adobe's proprietary font * rendering library implement a counter-measure: stem darkening at * smaller sizes where shades of gray dominate. By emboldening a glyph * slightly in relation to its pixel size, individual pixels get higher - * coverage of filled-in outlines and are therefore `blacker'. This - * counteracts the `thinning out' of glyphs, making text remain readable + * coverage of filled-in outlines and are therefore 'blacker'. This + * counteracts the 'thinning out' of glyphs, making text remain readable * at smaller sizes. * * By default, the Adobe engines for CFF, Type~1, and CID fonts darken - * stems at smaller sizes, regardless of hinting, to enhance contrast. + * stems at smaller sizes, regardless of hinting, to enhance contrast. * Setting this property, stem darkening gets switched off. * - * For the auto-hinter, stem-darkening is experimental currently and - * thus switched off by default (this is, `no-stem-darkening' is set to - * TRUE by default). Total consistency with the CFF driver is not - * achieved right now because the emboldening method differs and glyphs - * must be scaled down on the Y-axis to keep outline points inside their + * For the auto-hinter, stem-darkening is experimental currently and thus + * switched off by default (this is, `no-stem-darkening` is set to TRUE + * by default). Total consistency with the CFF driver is not achieved + * right now because the emboldening method differs and glyphs must be + * scaled down on the Y-axis to keep outline points inside their * precomputed blue zones. The smaller the size (especially 9ppem and * down), the higher the loss of emboldening versus the CFF driver. * - * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is - * set. + * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set. + * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). It + * can also be set per face using @FT_Face_Properties with + * @FT_PARAM_TAG_STEM_DARKENING. * - * { + * @example: + * ``` * FT_Library library; * FT_Bool no_stem_darkening = TRUE; * @@ -451,22 +459,14 @@ FT_BEGIN_HEADER * * FT_Property_Set( library, "cff", * "no-stem-darkening", &no_stem_darkening ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values 1 and 0 for `on' and `off', respectively). - * It can also be set per face using @FT_Face_Properties with - * @FT_PARAM_TAG_STEM_DARKENING. + * ``` * * @since: - * 2.4.12 (for `cff' module) + * 2.4.12 (for 'cff' module) * - * 2.6.2 (for `autofitter' module) + * 2.6.2 (for 'autofitter' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -478,43 +478,29 @@ FT_BEGIN_HEADER * * @description: * By default, the Adobe hinting engine, as used by the CFF, Type~1, and - * CID font drivers, darkens stems as follows (if the - * `no-stem-darkening' property isn't set): + * CID font drivers, darkens stems as follows (if the `no-stem-darkening` + * property isn't set): * - * { + * ``` * stem width <= 0.5px: darkening amount = 0.4px * stem width = 1px: darkening amount = 0.275px * stem width = 1.667px: darkening amount = 0.275px * stem width >= 2.333px: darkening amount = 0px - * } + * ``` * * and piecewise linear in-between. At configuration time, these four * control points can be set with the macro - * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'; the CFF, Type~1, and CID + * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS`; the CFF, Type~1, and CID * drivers share these values. At runtime, the control points can be - * changed using the `darkening-parameters' property, as the following - * example demonstrates for the Type~1 driver. - * - * { - * FT_Library library; - * FT_Int darken_params[8] = { 500, 300, // x1, y1 - * 1000, 200, // x2, y2 - * 1500, 100, // x3, y3 - * 2000, 0 }; // x4, y4 - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "type1", - * "darkening-parameters", darken_params ); - * } + * changed using the `darkening-parameters` property (see the example + * below that demonstrates this for the Type~1 driver). * * The x~values give the stem width, and the y~values the darkening * amount. The unit is 1000th of pixels. All coordinate values must be - * positive; the x~values must be monotonically increasing; the - * y~values must be monotonically decreasing and smaller than or - * equal to 500 (corresponding to half a pixel); the slope of each - * linear piece must be shallower than -1 (e.g., -.4). + * positive; the x~values must be monotonically increasing; the y~values + * must be monotonically decreasing and smaller than or equal to 500 + * (corresponding to half a pixel); the slope of each linear piece must + * be shallower than -1 (e.g., -.4). * * The auto-hinter provides this property, too, as an experimental * feature. See @no-stem-darkening for more. @@ -522,21 +508,36 @@ FT_BEGIN_HEADER * @note: * This property can be used with @FT_Property_Get also. * - * This property can be set via the `FREETYPE_PROPERTIES' environment + * This property can be set via the `FREETYPE_PROPERTIES` environment * variable, using eight comma-separated integers without spaces. Here - * the above example, using `\' to break the line for readability. + * the above example, using `\` to break the line for readability. * - * { + * ``` * FREETYPE_PROPERTIES=\ * type1:darkening-parameters=500,300,1000,200,1500,100,2000,0 - * } + * ``` + * + * @example: + * ``` + * FT_Library library; + * FT_Int darken_params[8] = { 500, 300, // x1, y1 + * 1000, 200, // x2, y2 + * 1500, 100, // x3, y3 + * 2000, 0 }; // x4, y4 + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "type1", + * "darkening-parameters", darken_params ); + * ``` * * @since: - * 2.5.1 (for `cff' module) + * 2.5.1 (for 'cff' module) * - * 2.6.2 (for `autofitter' module) + * 2.6.2 (for 'autofitter' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -547,29 +548,29 @@ FT_BEGIN_HEADER * random-seed * * @description: - * By default, the seed value for the CFF `random' operator and the - * similar `0 28 callothersubr pop' command for the Type~1 and CID + * By default, the seed value for the CFF 'random' operator and the + * similar '0 28 callothersubr pop' command for the Type~1 and CID * drivers is set to a random value. However, mainly for debugging - * purposes, it is often necessary to use a known value as a seed so - * that the pseudo-random number sequences generated by `random' are + * purposes, it is often necessary to use a known value as a seed so that + * the pseudo-random number sequences generated by 'random' are * repeatable. * - * The `random-seed' property does that. Its argument is a signed 32bit + * The `random-seed` property does that. Its argument is a signed 32bit * integer; if the value is zero or negative, the seed given by the - * `intitialRandomSeed' private DICT operator in a CFF file gets used - * (or a default value if there is no such operator). If the value is - * positive, use it instead of `initialRandomSeed', which is - * consequently ignored. + * `intitialRandomSeed` private DICT operator in a CFF file gets used (or + * a default value if there is no such operator). If the value is + * positive, use it instead of `initialRandomSeed`, which is consequently + * ignored. * * @note: - * This property can be set via the `FREETYPE_PROPERTIES' environment + * This property can be set via the `FREETYPE_PROPERTIES` environment * variable. It can also be set per face using @FT_Face_Properties with * @FT_PARAM_TAG_RANDOM_SEED. * * @since: - * 2.8 (for `cff' module) + * 2.8 (for 'cff' module) * - * 2.9 (for `type1' and `t1cid' modules) + * 2.9 (for 'type1' and 't1cid' modules) * */ @@ -580,21 +581,28 @@ FT_BEGIN_HEADER * no-long-family-names * * @description: - * If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling + * If `PCF_CONFIG_OPTION_LONG_FAMILY_NAMES` is active while compiling * FreeType, the PCF driver constructs long family names. * - * There are many PCF fonts just called `Fixed' which look completely + * There are many PCF fonts just called 'Fixed' which look completely * different, and which have nothing to do with each other. When - * selecting `Fixed' in KDE or Gnome one gets results that appear rather - * random, the style changes often if one changes the size and one - * cannot select some fonts at all. The improve this situation, the PCF - * module prepends the foundry name (plus a space) to the family name. - * It also checks whether there are `wide' characters; all put together, - * family names like `Sony Fixed' or `Misc Fixed Wide' are constructed. + * selecting 'Fixed' in KDE or Gnome one gets results that appear rather + * random, the style changes often if one changes the size and one cannot + * select some fonts at all. The improve this situation, the PCF module + * prepends the foundry name (plus a space) to the family name. It also + * checks whether there are 'wide' characters; all put together, family + * names like 'Sony Fixed' or 'Misc Fixed Wide' are constructed. + * + * If `no-long-family-names` is set, this feature gets switched off. * - * If `no-long-family-names' is set, this feature gets switched off. + * @note: + * This property can be used with @FT_Property_Get also. * - * { + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). + * + * @example: + * ``` * FT_Library library; * FT_Bool no_long_family_names = TRUE; * @@ -604,13 +612,7 @@ FT_BEGIN_HEADER * FT_Property_Set( library, "pcf", * "no-long-family-names", * &no_long_family_names ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values 1 and 0 for `on' and `off', respectively). + * ``` * * @since: * 2.8 @@ -626,8 +628,8 @@ FT_BEGIN_HEADER * A list of constants used for the @interpreter-version property to * select the hinting engine for Truetype fonts. * - * The numeric value in the constant names represents the version - * number as returned by the `GETINFO' bytecode instruction. + * The numeric value in the constant names represents the version number + * as returned by the 'GETINFO' bytecode instruction. * * @values: * TT_INTERPRETER_VERSION_35 :: @@ -638,38 +640,37 @@ FT_BEGIN_HEADER * Version~38 corresponds to MS rasterizer v.1.9; it is roughly * equivalent to the hinting provided by DirectWrite ClearType (as can * be found, for example, in the Internet Explorer~9 running on - * Windows~7). It is used in FreeType to select the `Infinality' - * subpixel hinting code. The code may be removed in a future - * version. + * Windows~7). It is used in FreeType to select the 'Infinality' + * subpixel hinting code. The code may be removed in a future version. * * TT_INTERPRETER_VERSION_40 :: * Version~40 corresponds to MS rasterizer v.2.1; it is roughly * equivalent to the hinting provided by DirectWrite ClearType (as can * be found, for example, in Microsoft's Edge Browser on Windows~10). - * It is used in FreeType to select the `minimal' subpixel hinting + * It is used in FreeType to select the 'minimal' subpixel hinting * code, a stripped-down and higher performance version of the - * `Infinality' code. + * 'Infinality' code. * * @note: - * This property controls the behaviour of the bytecode interpreter - * and thus how outlines get hinted. It does *not* control how glyph - * get rasterized! In particular, it does not control subpixel color + * This property controls the behaviour of the bytecode interpreter and + * thus how outlines get hinted. It does **not** control how glyph get + * rasterized! In particular, it does not control subpixel color * filtering. * * If FreeType has not been compiled with the configuration option - * TT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes - * an `FT_Err_Unimplemented_Feature' error. + * `TT_CONFIG_OPTION_SUBPIXEL_HINTING`, selecting version~38 or~40 causes + * an `FT_Err_Unimplemented_Feature` error. * - * Depending on the graphics framework, Microsoft uses different - * bytecode and rendering engines. As a consequence, the version - * numbers returned by a call to the `GETINFO' bytecode instruction are - * more convoluted than desired. + * Depending on the graphics framework, Microsoft uses different bytecode + * and rendering engines. As a consequence, the version numbers returned + * by a call to the 'GETINFO' bytecode instruction are more convoluted + * than desired. * - * Here are two tables that try to shed some light on the possible - * values for the MS rasterizer engine, together with the additional - * features introduced by it. + * Here are two tables that try to shed some light on the possible values + * for the MS rasterizer engine, together with the additional features + * introduced by it. * - * { + * ``` * GETINFO framework version feature * ------------------------------------------------------------------- * 3 GDI (Win 3.1), v1.0 16-bit, first version @@ -692,15 +693,15 @@ FT_BEGIN_HEADER * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag * DWrite (Win 8) in GETINFO opcode, * Gray ClearType - * } + * ``` * - * The `version' field gives a rough orientation only, since some + * The 'version' field gives a rough orientation only, since some * applications provided certain features much earlier (as an example, * Microsoft Reader used subpixel and Y-direction ClearType already in * Windows 2000). Similarly, updates to a given framework might include * improved hinting support. * - * { + * ``` * version sampling rendering comment * x y x y * -------------------------------------------------------------- @@ -710,38 +711,38 @@ FT_BEGIN_HEADER * v1.9 high high color-filter gray Color ClearType * v2.1 high normal gray B/W Gray ClearType * v2.1 high high gray gray Gray ClearType - * } + * ``` * * Color and Gray ClearType are the two available variants of - * `Y-direction ClearType', meaning grayscale rasterization along the + * 'Y-direction ClearType', meaning grayscale rasterization along the * Y-direction; the name used in the TrueType specification for this - * feature is `symmetric smoothing'. `Classic ClearType' is the - * original algorithm used before introducing a modified version in - * Win~XP. Another name for v1.6's grayscale rendering is `font - * smoothing', and `Color ClearType' is sometimes also called `DWrite - * ClearType'. To differentiate between today's Color ClearType and the - * earlier ClearType variant with B/W rendering along the vertical axis, - * the latter is sometimes called `GDI ClearType'. - * - * `Normal' and `high' sampling describe the (virtual) resolution to - * access the rasterized outline after the hinting process. `Normal' + * feature is 'symmetric smoothing'. 'Classic ClearType' is the original + * algorithm used before introducing a modified version in Win~XP. + * Another name for v1.6's grayscale rendering is 'font smoothing', and + * 'Color ClearType' is sometimes also called 'DWrite ClearType'. To + * differentiate between today's Color ClearType and the earlier + * ClearType variant with B/W rendering along the vertical axis, the + * latter is sometimes called 'GDI ClearType'. + * + * 'Normal' and 'high' sampling describe the (virtual) resolution to + * access the rasterized outline after the hinting process. 'Normal' * means 1 sample per grid line (i.e., B/W). In the current Microsoft - * implementation, `high' means an extra virtual resolution of 16x16 (or - * 16x1) grid lines per pixel for bytecode instructions like `MIRP'. + * implementation, 'high' means an extra virtual resolution of 16x16 (or + * 16x1) grid lines per pixel for bytecode instructions like 'MIRP'. * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid * lines for color filtering if Color ClearType is activated. * - * Note that `Gray ClearType' is essentially the same as v1.6's - * grayscale rendering. However, the GETINFO instruction handles it - * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1 - * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing), - * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for - * the version~1 gasp table exclusively (like Color ClearType), while - * v1.6 only respects the values of version~0 (bits 0 and~1). + * Note that 'Gray ClearType' is essentially the same as v1.6's grayscale + * rendering. However, the GETINFO instruction handles it differently: + * v1.6 returns bit~12 (hinting for grayscale), while v2.1 returns + * bits~13 (hinting for ClearType), 18 (symmetrical smoothing), and~19 + * (Gray ClearType). Also, this mode respects bits 2 and~3 for the + * version~1 gasp table exclusively (like Color ClearType), while v1.6 + * only respects the values of version~0 (bits 0 and~1). * - * Keep in mind that the features of the above interpreter versions - * might not map exactly to FreeType features or behavior because it is - * a fundamentally different library with different internals. + * Keep in mind that the features of the above interpreter versions might + * not map exactly to FreeType features or behavior because it is a + * fundamentally different library with different internals. * */ #define TT_INTERPRETER_VERSION_35 35 @@ -755,33 +756,40 @@ FT_BEGIN_HEADER * interpreter-version * * @description: - * Currently, three versions are available, two representing the - * bytecode interpreter with subpixel hinting support (old `Infinality' - * code and new stripped-down and higher performance `minimal' code) and - * one without, respectively. The default is subpixel support if - * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel support - * otherwise (since it isn't available then). + * Currently, three versions are available, two representing the bytecode + * interpreter with subpixel hinting support (old 'Infinality' code and + * new stripped-down and higher performance 'minimal' code) and one + * without, respectively. The default is subpixel support if + * `TT_CONFIG_OPTION_SUBPIXEL_HINTING` is defined, and no subpixel + * support otherwise (since it isn't available then). * * If subpixel hinting is on, many TrueType bytecode instructions behave - * differently compared to B/W or grayscale rendering (except if `native + * differently compared to B/W or grayscale rendering (except if 'native * ClearType' is selected by the font). Microsoft's main idea is to * render at a much increased horizontal resolution, then sampling down * the created output to subpixel precision. However, many older fonts - * are not suited to this and must be specially taken care of by - * applying (hardcoded) tweaks in Microsoft's interpreter. + * are not suited to this and must be specially taken care of by applying + * (hardcoded) tweaks in Microsoft's interpreter. * * Details on subpixel hinting and some of the necessary tweaks can be * found in Greg Hitchcock's whitepaper at - * `https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. - * Note that FreeType currently doesn't really `subpixel hint' (6x1, 6x2, + * 'https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. + * Note that FreeType currently doesn't really 'subpixel hint' (6x1, 6x2, * or 6x5 supersampling) like discussed in the paper. Depending on the * chosen interpreter, it simply ignores instructions on vertical stems * to arrive at very similar results. * + * @note: + * This property can be used with @FT_Property_Get also. + * + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values '35', '38', or '40'). + * + * @example: * The following example code demonstrates how to deactivate subpixel * hinting (omitting the error handling). * - * { + * ``` * FT_Library library; * FT_Face face; * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35; @@ -792,13 +800,7 @@ FT_BEGIN_HEADER * FT_Property_Set( library, "truetype", * "interpreter-version", * &interpreter_version ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values `35', `38', or `40'). + * ``` * * @since: * 2.5 @@ -811,7 +813,7 @@ FT_BEGIN_HEADER * glyph-to-script-map * * @description: - * *Experimental* *only* + * **Experimental only** * * The auto-hinter provides various script modules to hint glyphs. * Examples of supported scripts are Latin or CJK. Before a glyph is @@ -819,25 +821,26 @@ FT_BEGIN_HEADER * the script is then determined based on Unicode character ranges, see * below. * - * OpenType fonts, however, often provide much more glyphs than - * character codes (small caps, superscripts, ligatures, swashes, etc.), - * to be controlled by so-called `features'. Handling OpenType features - * can be quite complicated and thus needs a separate library on top of + * OpenType fonts, however, often provide much more glyphs than character + * codes (small caps, superscripts, ligatures, swashes, etc.), to be + * controlled by so-called 'features'. Handling OpenType features can be + * quite complicated and thus needs a separate library on top of * FreeType. * * The mapping between glyph indices and scripts (in the auto-hinter - * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an - * array with `num_glyphs' elements, as found in the font's @FT_Face - * structure. The `glyph-to-script-map' property returns a pointer to - * this array, which can be modified as needed. Note that the - * modification should happen before the first glyph gets processed by - * the auto-hinter so that the global analysis of the font shapes - * actually uses the modified mapping. - * - * The following example code demonstrates how to access it (omitting - * the error handling). - * - * { + * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an array + * with `num_glyphs` elements, as found in the font's @FT_Face structure. + * The `glyph-to-script-map` property returns a pointer to this array, + * which can be modified as needed. Note that the modification should + * happen before the first glyph gets processed by the auto-hinter so + * that the global analysis of the font shapes actually uses the modified + * mapping. + * + * @example: + * The following example code demonstrates how to access it (omitting the + * error handling). + * + * ``` * FT_Library library; * FT_Face face; * FT_Prop_GlyphToScriptMap prop; @@ -854,7 +857,7 @@ FT_BEGIN_HEADER * // adjust `prop.map' as needed right here * * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); - * } + * ``` * * @since: * 2.4.11 @@ -868,7 +871,7 @@ FT_BEGIN_HEADER * FT_AUTOHINTER_SCRIPT_XXX * * @description: - * *Experimental* *only* + * **Experimental only** * * A list of constants used for the @glyph-to-script-map property to * specify the script submodule the auto-hinter should use for hinting a @@ -879,14 +882,14 @@ FT_BEGIN_HEADER * Don't auto-hint this glyph. * * FT_AUTOHINTER_SCRIPT_LATIN :: - * Apply the latin auto-hinter. For the auto-hinter, `latin' is a - * very broad term, including Cyrillic and Greek also since characters - * from those scripts share the same design constraints. + * Apply the latin auto-hinter. For the auto-hinter, 'latin' is a very + * broad term, including Cyrillic and Greek also since characters from + * those scripts share the same design constraints. * * By default, characters from the following Unicode ranges are * assigned to this submodule. * - * { + * ``` * U+0020 - U+007F // Basic Latin (no control characters) * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) * U+0100 - U+017F // Latin Extended-A @@ -915,7 +918,7 @@ FT_BEGIN_HEADER * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement - * } + * ``` * * FT_AUTOHINTER_SCRIPT_CJK :: * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old @@ -924,7 +927,7 @@ FT_BEGIN_HEADER * By default, characters from the following Unicode ranges are * assigned to this submodule. * - * { + * ``` * U+1100 - U+11FF // Hangul Jamo * U+2E80 - U+2EFF // CJK Radicals Supplement * U+2F00 - U+2FDF // Kangxi Radicals @@ -957,7 +960,7 @@ FT_BEGIN_HEADER * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement - * } + * ``` * * FT_AUTOHINTER_SCRIPT_INDIC :: * Apply the indic auto-hinter, covering all major scripts from the @@ -967,7 +970,7 @@ FT_BEGIN_HEADER * By default, characters from the following Unicode ranges are * assigned to this submodule. * - * { + * ``` * U+0900 - U+0DFF // Indic Range * U+0F00 - U+0FFF // Tibetan * U+1900 - U+194F // Limbu @@ -975,7 +978,7 @@ FT_BEGIN_HEADER * U+A800 - U+A82F // Syloti Nagri * U+ABC0 - U+ABFF // Meetei Mayek * U+11800 - U+118DF // Sharada - * } + * ``` * * Note that currently Indic support is rudimentary only, missing blue * zone support. @@ -996,7 +999,7 @@ FT_BEGIN_HEADER * FT_Prop_GlyphToScriptMap * * @description: - * *Experimental* *only* + * **Experimental only** * * The data exchange structure for the @glyph-to-script-map property. * @@ -1018,36 +1021,36 @@ FT_BEGIN_HEADER * fallback-script * * @description: - * *Experimental* *only* - * - * If no auto-hinter script module can be assigned to a glyph, a - * fallback script gets assigned to it (see also the - * @glyph-to-script-map property). By default, this is - * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, - * this fallback value can be changed. - * - * { - * FT_Library library; - * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); + * **Experimental only** * - * FT_Property_Set( library, "autofitter", - * "fallback-script", &fallback_script ); - * } + * If no auto-hinter script module can be assigned to a glyph, a fallback + * script gets assigned to it (see also the @glyph-to-script-map + * property). By default, this is @FT_AUTOHINTER_SCRIPT_CJK. Using the + * `fallback-script` property, this fallback value can be changed. * * @note: * This property can be used with @FT_Property_Get also. * * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * fallback script value gets triggered either by setting or reading a + * creation of the glyph-to-script map that eventually uses the fallback + * script value gets triggered either by setting or reading a * face-specific property like @glyph-to-script-map, or by auto-hinting * any glyph from that face. In particular, if you have already created * an @FT_Face structure but not loaded any glyph (using the * auto-hinter), a change of the fallback script will affect this face. * + * @example: + * ``` + * FT_Library library; + * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "fallback-script", &fallback_script ); + * ``` + * * @since: * 2.4.11 * @@ -1060,42 +1063,43 @@ FT_BEGIN_HEADER * default-script * * @description: - * *Experimental* *only* + * **Experimental only** * - * If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make - * the HarfBuzz library access OpenType features for getting better - * glyph coverages, this property sets the (auto-fitter) script to be - * used for the default (OpenType) script data of a font's GSUB table. - * Features for the default script are intended for all scripts not - * explicitly handled in GSUB; an example is a `dlig' feature, - * containing the combination of the characters `T', `E', and `L' to - * form a `TEL' ligature. + * If FreeType gets compiled with `FT_CONFIG_OPTION_USE_HARFBUZZ` to make + * the HarfBuzz library access OpenType features for getting better glyph + * coverages, this property sets the (auto-fitter) script to be used for + * the default (OpenType) script data of a font's GSUB table. Features + * for the default script are intended for all scripts not explicitly + * handled in GSUB; an example is a 'dlig' feature, containing the + * combination of the characters 'T', 'E', and 'L' to form a 'TEL' + * ligature. * * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the - * `default-script' property, this default value can be changed. - * - * { - * FT_Library library; - * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "default-script", &default_script ); - * } + * `default-script` property, this default value can be changed. * * @note: * This property can be used with @FT_Property_Get also. * * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * default script value gets triggered either by setting or reading a + * creation of the glyph-to-script map that eventually uses the default + * script value gets triggered either by setting or reading a * face-specific property like @glyph-to-script-map, or by auto-hinting * any glyph from that face. In particular, if you have already created * an @FT_Face structure but not loaded any glyph (using the * auto-hinter), a change of the default script will affect this face. * + * @example: + * ``` + * FT_Library library; + * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", + * "default-script", &default_script ); + * ``` + * * @since: * 2.5.3 * @@ -1108,13 +1112,20 @@ FT_BEGIN_HEADER * increase-x-height * * @description: - * For ppem values in the range 6~<= ppem <= `increase-x-height', round - * up the font's x~height much more often than normally. If the value - * is set to~0, which is the default, this feature is switched off. Use + * For ppem values in the range 6~<= ppem <= `increase-x-height`, round + * up the font's x~height much more often than normally. If the value is + * set to~0, which is the default, this feature is switched off. Use * this property to improve the legibility of small font sizes if * necessary. * - * { + * @note: + * This property can be used with @FT_Property_Get also. + * + * Set this value right after calling @FT_Set_Char_Size, but before + * loading any glyph (using the auto-hinter). + * + * @example: + * ``` * FT_Library library; * FT_Face face; * FT_Prop_IncreaseXHeight prop; @@ -1129,13 +1140,7 @@ FT_BEGIN_HEADER * * FT_Property_Set( library, "autofitter", * "increase-x-height", &prop ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * Set this value right after calling @FT_Set_Char_Size, but before - * loading any glyph (using the auto-hinter). + * ``` * * @since: * 2.4.11 @@ -1166,46 +1171,48 @@ FT_BEGIN_HEADER * warping * * @description: - * *Experimental* *only* + * **Experimental only** * - * If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to + * If FreeType gets compiled with option `AF_CONFIG_OPTION_USE_WARPER` to * activate the warp hinting code in the auto-hinter, this property * switches warping on and off. * - * Warping only works in `normal' auto-hinting mode replacing it. - * The idea of the code is to slightly scale and shift a glyph along - * the non-hinted dimension (which is usually the horizontal axis) so - * that as much of its segments are aligned (more or less) to the grid. - * To find out a glyph's optimal scaling and shifting value, various - * parameter combinations are tried and scored. + * Warping only works in 'normal' auto-hinting mode replacing it. The + * idea of the code is to slightly scale and shift a glyph along the + * non-hinted dimension (which is usually the horizontal axis) so that as + * much of its segments are aligned (more or less) to the grid. To find + * out a glyph's optimal scaling and shifting value, various parameter + * combinations are tried and scored. * - * By default, warping is off. The example below shows how to switch on - * warping (omitting the error handling). - * - * { - * FT_Library library; - * FT_Bool warping = 1; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "warping", &warping ); - * } + * By default, warping is off. * * @note: * This property can be used with @FT_Property_Get also. * - * This property can be set via the `FREETYPE_PROPERTIES' environment - * variable (using values 1 and 0 for `on' and `off', respectively). + * This property can be set via the `FREETYPE_PROPERTIES` environment + * variable (using values 1 and 0 for 'on' and 'off', respectively). * * The warping code can also change advance widths. Have a look at the - * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure + * `lsb_delta` and `rsb_delta` fields in the @FT_GlyphSlotRec structure * for details on improving inter-glyph distances while rendering. * * Since warping is a global property of the auto-hinter it is best to * change its value before rendering any face. Otherwise, you should - * reload all faces that get auto-hinted in `normal' hinting mode. + * reload all faces that get auto-hinted in 'normal' hinting mode. + * + * @example: + * This example shows how to switch on warping (omitting the error + * handling). + * + * ``` + * FT_Library library; + * FT_Bool warping = 1; + * + * + * FT_Init_FreeType( &library ); + * + * FT_Property_Set( library, "autofitter", "warping", &warping ); + * ``` * * @since: * 2.6 diff --git a/src/3rdparty/freetype/include/freetype/fterrdef.h b/src/3rdparty/freetype/include/freetype/fterrdef.h index 8ffd346ca8..9bc7dc65e3 100644 --- a/src/3rdparty/freetype/include/freetype/fterrdef.h +++ b/src/3rdparty/freetype/include/freetype/fterrdef.h @@ -1,58 +1,57 @@ -/***************************************************************************/ -/* */ -/* fterrdef.h */ -/* */ -/* FreeType error codes (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fterrdef.h + * + * FreeType error codes (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ - /*************************************************************************/ - /* */ - /* <Section> */ - /* error_code_values */ - /* */ - /* <Title> */ - /* Error Code Values */ - /* */ - /* <Abstract> */ - /* All possible error codes returned by FreeType functions. */ - /* */ - /* <Description> */ - /* The list below is taken verbatim from the file `fterrdef.h' */ - /* (loaded automatically by including `FT_FREETYPE_H'). The first */ - /* argument of the `FT_ERROR_DEF_' macro is the error label; by */ - /* default, the prefix `FT_Err_' gets added so that you get error */ - /* names like `FT_Err_Cannot_Open_Resource'. The second argument is */ - /* the error code, and the last argument an error string, which is not */ - /* used by FreeType. */ - /* */ - /* Within your application you should *only* use error names and */ - /* *never* its numeric values! The latter might (and actually do) */ - /* change in forthcoming FreeType versions. */ - /* */ - /* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */ - /* See the `Error Enumerations' subsection how to automatically */ - /* generate a list of error strings. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * error_code_values + * + * @title: + * Error Code Values + * + * @abstract: + * All possible error codes returned by FreeType functions. + * + * @description: + * The list below is taken verbatim from the file `fterrdef.h` (loaded + * automatically by including `FT_FREETYPE_H`). The first argument of the + * `FT_ERROR_DEF_` macro is the error label; by default, the prefix + * `FT_Err_` gets added so that you get error names like + * `FT_Err_Cannot_Open_Resource`. The second argument is the error code, + * and the last argument an error string, which is not used by FreeType. + * + * Within your application you should **only** use error names and + * **never** its numeric values! The latter might (and actually do) + * change in forthcoming FreeType versions. + * + * Macro `FT_NOERRORDEF_` defines `FT_Err_Ok`, which is always zero. See + * the 'Error Enumerations' subsection how to automatically generate a + * list of error strings. + * + */ - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Err_XXX */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @enum: + * FT_Err_XXX + * + */ /* generic errors */ diff --git a/src/3rdparty/freetype/include/freetype/fterrors.h b/src/3rdparty/freetype/include/freetype/fterrors.h index f6ee5c24e2..2b47eb2096 100644 --- a/src/3rdparty/freetype/include/freetype/fterrors.h +++ b/src/3rdparty/freetype/include/freetype/fterrors.h @@ -1,110 +1,120 @@ -/***************************************************************************/ -/* */ -/* fterrors.h */ -/* */ -/* FreeType error code handling (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* error_enumerations */ - /* */ - /* <Title> */ - /* Error Enumerations */ - /* */ - /* <Abstract> */ - /* How to handle errors and error strings. */ - /* */ - /* <Description> */ - /* The header file `fterrors.h' (which is automatically included by */ - /* `freetype.h' defines the handling of FreeType's enumeration */ - /* constants. It can also be used to generate error message strings */ - /* with a small macro trick explained below. */ - /* */ - /* *Error* *Formats* */ - /* */ - /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ - /* defined in `ftoption.h' in order to make the higher byte indicate */ - /* the module where the error has happened (this is not compatible */ - /* with standard builds of FreeType~2, however). See the file */ - /* `ftmoderr.h' for more details. */ - /* */ - /* *Error* *Message* *Strings* */ - /* */ - /* Error definitions are set up with special macros that allow client */ - /* applications to build a table of error message strings. The */ - /* strings are not included in a normal build of FreeType~2 to save */ - /* space (most client applications do not use them). */ - /* */ - /* To do so, you have to define the following macros before including */ - /* this file. */ - /* */ - /* { */ - /* FT_ERROR_START_LIST */ - /* } */ - /* */ - /* This macro is called before anything else to define the start of */ - /* the error list. It is followed by several FT_ERROR_DEF calls. */ - /* */ - /* { */ - /* FT_ERROR_DEF( e, v, s ) */ - /* } */ - /* */ - /* This macro is called to define one single error. `e' is the error */ - /* code identifier (e.g., `Invalid_Argument'), `v' is the error's */ - /* numerical value, and `s' is the corresponding error string. */ - /* */ - /* { */ - /* FT_ERROR_END_LIST */ - /* } */ - /* */ - /* This macro ends the list. */ - /* */ - /* Additionally, you have to undefine `FTERRORS_H_' before #including */ - /* this file. */ - /* */ - /* Here is a simple example. */ - /* */ - /* { */ - /* #undef FTERRORS_H_ */ - /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ - /* #define FT_ERROR_START_LIST { */ - /* #define FT_ERROR_END_LIST { 0, NULL } }; */ - /* */ - /* const struct */ - /* { */ - /* int err_code; */ - /* const char* err_msg; */ - /* } ft_errors[] = */ - /* */ - /* #include FT_ERRORS_H */ - /* } */ - /* */ - /* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */ - /* `FT_NOERRORDEF'; it is always zero. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * fterrors.h + * + * FreeType error code handling (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * @section: + * error_enumerations + * + * @title: + * Error Enumerations + * + * @abstract: + * How to handle errors and error strings. + * + * @description: + * The header file `fterrors.h` (which is automatically included by + * `freetype.h` defines the handling of FreeType's enumeration + * constants. It can also be used to generate error message strings + * with a small macro trick explained below. + * + * **Error Formats** + * + * The configuration macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` can be + * defined in `ftoption.h` in order to make the higher byte indicate the + * module where the error has happened (this is not compatible with + * standard builds of FreeType~2, however). See the file `ftmoderr.h` + * for more details. + * + * **Error Message Strings** + * + * Error definitions are set up with special macros that allow client + * applications to build a table of error message strings. The strings + * are not included in a normal build of FreeType~2 to save space (most + * client applications do not use them). + * + * To do so, you have to define the following macros before including + * this file. + * + * ``` + * FT_ERROR_START_LIST + * ``` + * + * This macro is called before anything else to define the start of the + * error list. It is followed by several `FT_ERROR_DEF` calls. + * + * ``` + * FT_ERROR_DEF( e, v, s ) + * ``` + * + * This macro is called to define one single error. 'e' is the error + * code identifier (e.g., `Invalid_Argument`), 'v' is the error's + * numerical value, and 's' is the corresponding error string. + * + * ``` + * FT_ERROR_END_LIST + * ``` + * + * This macro ends the list. + * + * Additionally, you have to undefine `FTERRORS_H_` before #including + * this file. + * + * Here is a simple example. + * + * ``` + * #undef FTERRORS_H_ + * #define FT_ERRORDEF( e, v, s ) { e, s }, + * #define FT_ERROR_START_LIST { + * #define FT_ERROR_END_LIST { 0, NULL } }; + * + * const struct + * { + * int err_code; + * const char* err_msg; + * } ft_errors[] = + * + * #include FT_ERRORS_H + * ``` + * + * An alternative to using an array is a switch statement. + * + * ``` + * #undef FTERRORS_H_ + * #define FT_ERROR_START_LIST switch ( error_code ) { + * #define FT_ERRORDEF( e, v, s ) case v: return s; + * #define FT_ERROR_END_LIST } + * ``` + * + * If you use `FT_CONFIG_OPTION_USE_MODULE_ERRORS`, `error_code` should + * be replaced with `FT_ERROR_BASE(error_code)` in the last example. + */ /* */ - /* In previous FreeType versions we used `__FTERRORS_H__'. However, */ + /* In previous FreeType versions we used `__FTERRORS_H__`. However, */ /* using two successive underscores in a non-system symbol name */ /* violates the C (and C++) standard, so it was changed to the */ /* current form. In spite of this, we have to make */ /* */ + /* ``` */ /* #undefine __FTERRORS_H__ */ + /* ``` */ /* */ /* work for backward compatibility. */ /* */ @@ -130,7 +140,7 @@ /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ - /* By default, we use `FT_Err_'. */ + /* By default, we use `FT_Err_`. */ /* */ #ifndef FT_ERR_PREFIX #define FT_ERR_PREFIX FT_Err_ @@ -158,6 +168,8 @@ /* */ #ifndef FT_ERRORDEF +#define FT_INCLUDE_ERR_PROTOS + #define FT_ERRORDEF( e, v, s ) e = v, #define FT_ERROR_START_LIST enum { #define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; @@ -220,6 +232,57 @@ #undef FT_ERR_PREFIX #endif + /* FT_INCLUDE_ERR_PROTOS: Control if function prototypes should be */ + /* included with `#include FT_ERRORS_H'. This is */ + /* only true where `FT_ERRORDEF` is undefined. */ + /* FT_ERR_PROTOS_DEFINED: Actual multiple-inclusion protection of */ + /* `fterrors.h`. */ +#ifdef FT_INCLUDE_ERR_PROTOS +#undef FT_INCLUDE_ERR_PROTOS + +#ifndef FT_ERR_PROTOS_DEFINED +#define FT_ERR_PROTOS_DEFINED + + +FT_BEGIN_HEADER + + /************************************************************************** + * + * @function: + * FT_Error_String + * + * @description: + * Retrieve the description of a valid FreeType error code. + * + * @input: + * error_code :: + * A valid FreeType error code. + * + * @return: + * A C~string or `NULL`, if any error occurred. + * + * @note: + * FreeType has to be compiled with `FT_CONFIG_OPTION_ERROR_STRINGS` or + * `FT_DEBUG_LEVEL_ERROR` to get meaningful descriptions. + * 'error_string' will be `NULL` otherwise. + * + * Module identification will be ignored: + * + * ```c + * strcmp( FT_Error_String( FT_Err_Unknown_File_Format ), + * FT_Error_String( BDF_Err_Unknown_File_Format ) ) == 0; + * ``` + */ + FT_EXPORT( const char* ) + FT_Error_String( FT_Error error_code ); + +FT_END_HEADER + + +#endif /* FT_ERR_PROTOS_DEFINED */ + +#endif /* FT_INCLUDE_ERR_PROTOS */ + #endif /* !(FTERRORS_H_ && __FTERRORS_H__) */ diff --git a/src/3rdparty/freetype/include/freetype/ftfntfmt.h b/src/3rdparty/freetype/include/freetype/ftfntfmt.h index cc86efac23..aae0b13264 100644 --- a/src/3rdparty/freetype/include/freetype/ftfntfmt.h +++ b/src/3rdparty/freetype/include/freetype/ftfntfmt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftfntfmt.h */ -/* */ -/* Support functions for font formats. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftfntfmt.h + * + * Support functions for font formats. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTFNTFMT_H_ @@ -32,49 +32,48 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* font_formats */ - /* */ - /* <Title> */ - /* Font Formats */ - /* */ - /* <Abstract> */ - /* Getting the font format. */ - /* */ - /* <Description> */ - /* The single function in this section can be used to get the font */ - /* format. Note that this information is not needed normally; */ - /* however, there are special cases (like in PDF devices) where it is */ - /* important to differentiate, in spite of FreeType's uniform API. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Font_Format */ - /* */ - /* <Description> */ - /* Return a string describing the format of a given face. Possible */ - /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ - /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ - /* */ - /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ - /* */ - /* <Input> */ - /* face :: */ - /* Input face handle. */ - /* */ - /* <Return> */ - /* Font format string. NULL in case of error. */ - /* */ - /* <Note> */ - /* A deprecated name for the same function is */ - /* `FT_Get_X11_Font_Format'. */ - /* */ + /************************************************************************** + * + * @section: + * font_formats + * + * @title: + * Font Formats + * + * @abstract: + * Getting the font format. + * + * @description: + * The single function in this section can be used to get the font format. + * Note that this information is not needed normally; however, there are + * special cases (like in PDF devices) where it is important to + * differentiate, in spite of FreeType's uniform API. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Get_Font_Format + * + * @description: + * Return a string describing the format of a given face. Possible values + * are 'TrueType', 'Type~1', 'BDF', 'PCF', 'Type~42', 'CID~Type~1', 'CFF', + * 'PFR', and 'Windows~FNT'. + * + * The return value is suitable to be used as an X11 FONT_PROPERTY. + * + * @input: + * face :: + * Input face handle. + * + * @return: + * Font format string. `NULL` in case of error. + * + * @note: + * A deprecated name for the same function is `FT_Get_X11_Font_Format`. + */ FT_EXPORT( const char* ) FT_Get_Font_Format( FT_Face face ); diff --git a/src/3rdparty/freetype/include/freetype/ftgasp.h b/src/3rdparty/freetype/include/freetype/ftgasp.h index fc1248ff48..24673d8ce1 100644 --- a/src/3rdparty/freetype/include/freetype/ftgasp.h +++ b/src/3rdparty/freetype/include/freetype/ftgasp.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgasp.h */ -/* */ -/* Access of TrueType's `gasp' table (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgasp.h + * + * Access of TrueType's 'gasp' table (specification). + * + * Copyright (C) 2007-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGASP_H_ @@ -32,7 +32,7 @@ FT_BEGIN_HEADER - /*************************************************************************** + /************************************************************************** * * @section: * gasp_table @@ -41,16 +41,16 @@ FT_BEGIN_HEADER * Gasp Table * * @abstract: - * Retrieving TrueType `gasp' table entries. + * Retrieving TrueType 'gasp' table entries. * * @description: * The function @FT_Get_Gasp can be used to query a TrueType or OpenType - * font for specific entries in its `gasp' table, if any. This is - * mainly useful when implementing native TrueType hinting with the - * bytecode interpreter to duplicate the Windows text rendering results. + * font for specific entries in its 'gasp' table, if any. This is mainly + * useful when implementing native TrueType hinting with the bytecode + * interpreter to duplicate the Windows text rendering results. */ - /************************************************************************* + /************************************************************************** * * @enum: * FT_GASP_XXX @@ -66,7 +66,7 @@ FT_BEGIN_HEADER * * FT_GASP_DO_GRIDFIT :: * Grid-fitting and hinting should be performed at the specified ppem. - * This *really* means TrueType bytecode interpretation. If this bit + * This **really** means TrueType bytecode interpretation. If this bit * is not set, no hinting gets applied. * * FT_GASP_DO_GRAY :: @@ -80,13 +80,13 @@ FT_BEGIN_HEADER * Grid-fitting must be used with ClearType's symmetric smoothing. * * @note: - * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be + * The bit-flags `FT_GASP_DO_GRIDFIT` and `FT_GASP_DO_GRAY` are to be * used for standard font rasterization only. Independently of that, - * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to - * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and - * `FT_GASP_DO_GRAY' are consequently ignored). + * `FT_GASP_SYMMETRIC_SMOOTHING` and `FT_GASP_SYMMETRIC_GRIDFIT` are to + * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT` and + * `FT_GASP_DO_GRAY` are consequently ignored). * - * `ClearType' is Microsoft's implementation of LCD rendering, partly + * 'ClearType' is Microsoft's implementation of LCD rendering, partly * protected by patents. * * @since: @@ -99,29 +99,31 @@ FT_BEGIN_HEADER #define FT_GASP_SYMMETRIC_SMOOTHING 0x08 - /************************************************************************* + /************************************************************************** * - * @func: + * @function: * FT_Get_Gasp * * @description: * For a TrueType or OpenType font file, return the rasterizer behaviour - * flags from the font's `gasp' table corresponding to a given - * character pixel size. + * flags from the font's 'gasp' table corresponding to a given character + * pixel size. * * @input: - * face :: The source face handle. + * face :: + * The source face handle. * - * ppem :: The vertical character pixel size. + * ppem :: + * The vertical character pixel size. * * @return: * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no - * `gasp' table in the face. + * 'gasp' table in the face. * * @note: * If you want to use the MM functionality of OpenType variation fonts * (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this - * function *after* setting an instance since the return values can + * function **after** setting an instance since the return values can * change. * * @since: diff --git a/src/3rdparty/freetype/include/freetype/ftglyph.h b/src/3rdparty/freetype/include/freetype/ftglyph.h index 5f3fc009cd..fedab8491e 100644 --- a/src/3rdparty/freetype/include/freetype/ftglyph.h +++ b/src/3rdparty/freetype/include/freetype/ftglyph.h @@ -1,32 +1,32 @@ -/***************************************************************************/ -/* */ -/* ftglyph.h */ -/* */ -/* FreeType convenience functions to handle glyphs (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftglyph.h + * + * FreeType convenience functions to handle glyphs (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file contains the definition of several convenience functions that + * can be used by client applications to easily retrieve glyph bitmaps and + * outlines from a given face. + * + * These functions should be optional if you are writing a font server or + * text layout engine on top of FreeType. However, they are pretty handy + * for many other simple uses of the library. + * + */ #ifndef FTGLYPH_H_ @@ -46,65 +46,70 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_management */ - /* */ - /* <Title> */ - /* Glyph Management */ - /* */ - /* <Abstract> */ - /* Generic interface to manage individual glyph data. */ - /* */ - /* <Description> */ - /* This section contains definitions used to manage glyph data */ - /* through generic FT_Glyph objects. Each of them can contain a */ - /* bitmap, a vector outline, or even images in other formats. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * glyph_management + * + * @title: + * Glyph Management + * + * @abstract: + * Generic interface to manage individual glyph data. + * + * @description: + * This section contains definitions used to manage glyph data through + * generic @FT_Glyph objects. Each of them can contain a bitmap, + * a vector outline, or even images in other formats. These objects are + * detached from @FT_Face, contrary to @FT_GlyphSlot. + * + */ /* forward declaration to a private type */ typedef struct FT_Glyph_Class_ FT_Glyph_Class; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Glyph */ - /* */ - /* <Description> */ - /* Handle to an object used to model generic glyph images. It is a */ - /* pointer to the @FT_GlyphRec structure and can contain a glyph */ - /* bitmap or pointer. */ - /* */ - /* <Note> */ - /* Glyph objects are not owned by the library. You must thus release */ - /* them manually (through @FT_Done_Glyph) _before_ calling */ - /* @FT_Done_FreeType. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Glyph + * + * @description: + * Handle to an object used to model generic glyph images. It is a + * pointer to the @FT_GlyphRec structure and can contain a glyph bitmap + * or pointer. + * + * @note: + * Glyph objects are not owned by the library. You must thus release + * them manually (through @FT_Done_Glyph) _before_ calling + * @FT_Done_FreeType. + */ typedef struct FT_GlyphRec_* FT_Glyph; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphRec */ - /* */ - /* <Description> */ - /* The root glyph structure contains a given glyph image plus its */ - /* advance width in 16.16 fixed-point format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library object. */ - /* */ - /* clazz :: A pointer to the glyph's class. Private. */ - /* */ - /* format :: The format of the glyph's image. */ - /* */ - /* advance :: A 16.16 vector that gives the glyph's advance width. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_GlyphRec + * + * @description: + * The root glyph structure contains a given glyph image plus its advance + * width in 16.16 fixed-point format. + * + * @fields: + * library :: + * A handle to the FreeType library object. + * + * clazz :: + * A pointer to the glyph's class. Private. + * + * format :: + * The format of the glyph's image. + * + * advance :: + * A 16.16 vector that gives the glyph's advance width. + */ typedef struct FT_GlyphRec_ { FT_Library library; @@ -115,48 +120,51 @@ FT_BEGIN_HEADER } FT_GlyphRec; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_BitmapGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model a bitmap glyph image. This is */ - /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ - /* */ + /************************************************************************** + * + * @type: + * FT_BitmapGlyph + * + * @description: + * A handle to an object used to model a bitmap glyph image. This is a + * sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. + */ typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BitmapGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for bitmap glyph images. This really is a */ - /* `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* left :: The left-side bearing, i.e., the horizontal distance */ - /* from the current pen position to the left border of the */ - /* glyph bitmap. */ - /* */ - /* top :: The top-side bearing, i.e., the vertical distance from */ - /* the current pen position to the top border of the glyph */ - /* bitmap. This distance is positive for upwards~y! */ - /* */ - /* bitmap :: A descriptor for the bitmap. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ - /* the bitmap's contents easily. */ - /* */ - /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ - /* and is thus created and destroyed with it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_BitmapGlyphRec + * + * @description: + * A structure used for bitmap glyph images. This really is a + * 'sub-class' of @FT_GlyphRec. + * + * @fields: + * root :: + * The root @FT_Glyph fields. + * + * left :: + * The left-side bearing, i.e., the horizontal distance from the + * current pen position to the left border of the glyph bitmap. + * + * top :: + * The top-side bearing, i.e., the vertical distance from the current + * pen position to the top border of the glyph bitmap. This distance + * is positive for upwards~y! + * + * bitmap :: + * A descriptor for the bitmap. + * + * @note: + * You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have + * `glyph->format == FT_GLYPH_FORMAT_BITMAP`. This lets you access the + * bitmap's contents easily. + * + * The corresponding pixel buffer is always owned by @FT_BitmapGlyph and + * is thus created and destroyed with it. + */ typedef struct FT_BitmapGlyphRec_ { FT_GlyphRec root; @@ -167,44 +175,46 @@ FT_BEGIN_HEADER } FT_BitmapGlyphRec; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_OutlineGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model an outline glyph image. This */ - /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ - /* */ + /************************************************************************** + * + * @type: + * FT_OutlineGlyph + * + * @description: + * A handle to an object used to model an outline glyph image. This is a + * sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. + */ typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_OutlineGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for outline (vectorial) glyph images. This */ - /* really is a `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* outline :: A descriptor for the outline. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ - /* the outline's content easily. */ - /* */ - /* As the outline is extracted from a glyph slot, its coordinates are */ - /* expressed normally in 26.6 pixels, unless the flag */ - /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ - /* */ - /* The outline's tables are always owned by the object and are */ - /* destroyed with it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_OutlineGlyphRec + * + * @description: + * A structure used for outline (vectorial) glyph images. This really is + * a 'sub-class' of @FT_GlyphRec. + * + * @fields: + * root :: + * The root @FT_Glyph fields. + * + * outline :: + * A descriptor for the outline. + * + * @note: + * You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have + * `glyph->format == FT_GLYPH_FORMAT_OUTLINE`. This lets you access the + * outline's content easily. + * + * As the outline is extracted from a glyph slot, its coordinates are + * expressed normally in 26.6 pixels, unless the flag @FT_LOAD_NO_SCALE + * was used in @FT_Load_Glyph or @FT_Load_Char. + * + * The outline's tables are always owned by the object and are destroyed + * with it. + */ typedef struct FT_OutlineGlyphRec_ { FT_GlyphRec root; @@ -213,113 +223,150 @@ FT_BEGIN_HEADER } FT_OutlineGlyphRec; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph */ - /* */ - /* <Description> */ - /* A function used to extract a glyph image from a slot. Note that */ - /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* slot :: A handle to the source glyph slot. */ - /* */ - /* <Output> */ - /* aglyph :: A handle to the glyph object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16 */ - /* fixed-point numbers, `slot->advance.x' and `slot->advance.y' */ - /* (which are in 26.6 fixed-point format) must be in the range */ - /* ]-32768;32768[. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Glyph + * + * @description: + * A function used to create a new empty glyph image. Note that the + * created @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * library :: + * A handle to the FreeType library object. + * + * format :: + * The format of the glyph's image. + * + * @output: + * aglyph :: + * A handle to the glyph object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_New_Glyph( FT_Library library, + FT_Glyph_Format format, + FT_Glyph *aglyph ); + + + /************************************************************************** + * + * @function: + * FT_Get_Glyph + * + * @description: + * A function used to extract a glyph image from a slot. Note that the + * created @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * slot :: + * A handle to the source glyph slot. + * + * @output: + * aglyph :: + * A handle to the glyph object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Because `*aglyph->advance.x` and `*aglyph->advance.y` are 16.16 + * fixed-point numbers, `slot->advance.x` and `slot->advance.y` (which + * are in 26.6 fixed-point format) must be in the range ]-32768;32768[. + */ FT_EXPORT( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot, FT_Glyph *aglyph ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Copy */ - /* */ - /* <Description> */ - /* A function used to copy a glyph image. Note that the created */ - /* @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* source :: A handle to the source glyph object. */ - /* */ - /* <Output> */ - /* target :: A handle to the target glyph object. 0~in case of */ - /* error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_Copy + * + * @description: + * A function used to copy a glyph image. Note that the created + * @FT_Glyph object must be released with @FT_Done_Glyph. + * + * @input: + * source :: + * A handle to the source glyph object. + * + * @output: + * target :: + * A handle to the target glyph object. 0~in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Glyph_Copy( FT_Glyph source, FT_Glyph *target ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Transform */ - /* */ - /* <Description> */ - /* Transform a glyph image if its format is scalable. */ - /* */ - /* <InOut> */ - /* glyph :: A handle to the target glyph object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to a 2x2 matrix to apply. */ - /* */ - /* delta :: A pointer to a 2d vector to apply. Coordinates are */ - /* expressed in 1/64th of a pixel. */ - /* */ - /* <Return> */ - /* FreeType error code (if not 0, the glyph format is not scalable). */ - /* */ - /* <Note> */ - /* The 2x2 transformation matrix is also applied to the glyph's */ - /* advance vector. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_Transform + * + * @description: + * Transform a glyph image if its format is scalable. + * + * @inout: + * glyph :: + * A handle to the target glyph object. + * + * @input: + * matrix :: + * A pointer to a 2x2 matrix to apply. + * + * delta :: + * A pointer to a 2d vector to apply. Coordinates are expressed in + * 1/64th of a pixel. + * + * @return: + * FreeType error code (if not 0, the glyph format is not scalable). + * + * @note: + * The 2x2 transformation matrix is also applied to the glyph's advance + * vector. + */ FT_EXPORT( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph, FT_Matrix* matrix, FT_Vector* delta ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_BBox_Mode */ - /* */ - /* <Description> */ - /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ - /* */ - /* <Values> */ - /* FT_GLYPH_BBOX_UNSCALED :: */ - /* Return unscaled font units. */ - /* */ - /* FT_GLYPH_BBOX_SUBPIXELS :: */ - /* Return unfitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_GRIDFIT :: */ - /* Return grid-fitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_TRUNCATE :: */ - /* Return coordinates in integer pixels. */ - /* */ - /* FT_GLYPH_BBOX_PIXELS :: */ - /* Return grid-fitted pixel coordinates. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Glyph_BBox_Mode + * + * @description: + * The mode how the values of @FT_Glyph_Get_CBox are returned. + * + * @values: + * FT_GLYPH_BBOX_UNSCALED :: + * Return unscaled font units. + * + * FT_GLYPH_BBOX_SUBPIXELS :: + * Return unfitted 26.6 coordinates. + * + * FT_GLYPH_BBOX_GRIDFIT :: + * Return grid-fitted 26.6 coordinates. + * + * FT_GLYPH_BBOX_TRUNCATE :: + * Return coordinates in integer pixels. + * + * FT_GLYPH_BBOX_PIXELS :: + * Return grid-fitted pixel coordinates. + */ typedef enum FT_Glyph_BBox_Mode_ { FT_GLYPH_BBOX_UNSCALED = 0, @@ -332,7 +379,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Glyph_BBox_Mode' values instead */ + /* `FT_Glyph_BBox_Mode` values instead */ #define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED #define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS #define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT @@ -340,187 +387,188 @@ FT_BEGIN_HEADER #define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Get_CBox */ - /* */ - /* <Description> */ - /* Return a glyph's `control box'. The control box encloses all the */ - /* outline's points, including Bezier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bezier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the source glyph object. */ - /* */ - /* mode :: The mode that indicates how to interpret the returned */ - /* bounding box values. */ - /* */ - /* <Output> */ - /* acbox :: The glyph coordinate bounding box. Coordinates are */ - /* expressed in 1/64th of pixels if it is grid-fitted. */ - /* */ - /* <Note> */ - /* Coordinates are relative to the glyph origin, using the y~upwards */ - /* convention. */ - /* */ - /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ - /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ - /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ - /* is another name for this constant. */ - /* */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ - /* reasonable values for the CBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the CBox, */ - /* which can be eventually converted back to font units. */ - /* */ - /* Note that the maximum coordinates are exclusive, which means that */ - /* one can compute the width and height of the glyph image (be it in */ - /* integer or 26.6 pixels) as: */ - /* */ - /* { */ - /* width = bbox.xMax - bbox.xMin; */ - /* height = bbox.yMax - bbox.yMin; */ - /* } */ - /* */ - /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ - /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ - /* which corresponds to: */ - /* */ - /* { */ - /* bbox.xMin = FLOOR(bbox.xMin); */ - /* bbox.yMin = FLOOR(bbox.yMin); */ - /* bbox.xMax = CEILING(bbox.xMax); */ - /* bbox.yMax = CEILING(bbox.yMax); */ - /* } */ - /* */ - /* To get the bbox in pixel coordinates, set `bbox_mode' to */ - /* @FT_GLYPH_BBOX_TRUNCATE. */ - /* */ - /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ - /* to @FT_GLYPH_BBOX_PIXELS. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_Get_CBox + * + * @description: + * Return a glyph's 'control box'. The control box encloses all the + * outline's points, including Bezier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline that + * contains Bezier outside arcs). + * + * Computing the control box is very fast, while getting the bounding box + * can take much more time as it needs to walk over all segments and arcs + * in the outline. To get the latter, you can use the 'ftbbox' + * component, which is dedicated to this single task. + * + * @input: + * glyph :: + * A handle to the source glyph object. + * + * mode :: + * The mode that indicates how to interpret the returned bounding box + * values. + * + * @output: + * acbox :: + * The glyph coordinate bounding box. Coordinates are expressed in + * 1/64th of pixels if it is grid-fitted. + * + * @note: + * Coordinates are relative to the glyph origin, using the y~upwards + * convention. + * + * If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode` must + * be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6 + * pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS is another name for + * this constant. + * + * If the font is tricky and the glyph has been loaded with + * @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get + * reasonable values for the CBox it is necessary to load the glyph at a + * large ppem value (so that the hinting instructions can properly shift + * and scale the subglyphs), then extracting the CBox, which can be + * eventually converted back to font units. + * + * Note that the maximum coordinates are exclusive, which means that one + * can compute the width and height of the glyph image (be it in integer + * or 26.6 pixels) as: + * + * ``` + * width = bbox.xMax - bbox.xMin; + * height = bbox.yMax - bbox.yMin; + * ``` + * + * Note also that for 26.6 coordinates, if `bbox_mode` is set to + * @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, + * which corresponds to: + * + * ``` + * bbox.xMin = FLOOR(bbox.xMin); + * bbox.yMin = FLOOR(bbox.yMin); + * bbox.xMax = CEILING(bbox.xMax); + * bbox.yMax = CEILING(bbox.yMax); + * ``` + * + * To get the bbox in pixel coordinates, set `bbox_mode` to + * @FT_GLYPH_BBOX_TRUNCATE. + * + * To get the bbox in grid-fitted pixel coordinates, set `bbox_mode` to + * @FT_GLYPH_BBOX_PIXELS. + */ FT_EXPORT( void ) FT_Glyph_Get_CBox( FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_To_Bitmap */ - /* */ - /* <Description> */ - /* Convert a given glyph object to a bitmap glyph object. */ - /* */ - /* <InOut> */ - /* the_glyph :: A pointer to a handle to the target glyph. */ - /* */ - /* <Input> */ - /* render_mode :: An enumeration that describes how the data is */ - /* rendered. */ - /* */ - /* origin :: A pointer to a vector used to translate the glyph */ - /* image before rendering. Can be~0 (if no */ - /* translation). The origin is expressed in */ - /* 26.6 pixels. */ - /* */ - /* destroy :: A boolean that indicates that the original glyph */ - /* image should be destroyed by this function. It is */ - /* never destroyed in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does nothing if the glyph format isn't scalable. */ - /* */ - /* The glyph image is translated with the `origin' vector before */ - /* rendering. */ - /* */ - /* The first parameter is a pointer to an @FT_Glyph handle, that will */ - /* be _replaced_ by this function (with newly allocated data). */ - /* Typically, you would use (omitting error handling): */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyph; */ - /* FT_BitmapGlyph glyph_bitmap; */ - /* */ - /* */ - /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); */ - /* */ - /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ - /* */ - /* // convert to a bitmap (default render mode + destroying old) */ - /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ - /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ - /* 0, 1 ); */ - /* if ( error ) // `glyph' unchanged */ - /* ... */ - /* } */ - /* */ - /* // access bitmap content by typecasting */ - /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ - /* */ - /* // do funny stuff with it, like blitting/drawing */ - /* ... */ - /* */ - /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ - /* } */ - /* */ - /* */ - /* Here another example, again without error handling: */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyphs[MAX_GLYPHS] */ - /* */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ - /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* { */ - /* FT_Glyph bitmap = glyphs[idx]; */ - /* */ - /* */ - /* ... */ - /* */ - /* // after this call, `bitmap' no longer points into */ - /* // the `glyphs' array (and the old value isn't destroyed) */ - /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ - /* */ - /* ... */ - /* */ - /* FT_Done_Glyph( bitmap ); */ - /* } */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* FT_Done_Glyph( glyphs[idx] ); */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_Glyph_To_Bitmap + * + * @description: + * Convert a given glyph object to a bitmap glyph object. + * + * @inout: + * the_glyph :: + * A pointer to a handle to the target glyph. + * + * @input: + * render_mode :: + * An enumeration that describes how the data is rendered. + * + * origin :: + * A pointer to a vector used to translate the glyph image before + * rendering. Can be~0 (if no translation). The origin is expressed + * in 26.6 pixels. + * + * destroy :: + * A boolean that indicates that the original glyph image should be + * destroyed by this function. It is never destroyed in case of error. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does nothing if the glyph format isn't scalable. + * + * The glyph image is translated with the `origin` vector before + * rendering. + * + * The first parameter is a pointer to an @FT_Glyph handle, that will be + * _replaced_ by this function (with newly allocated data). Typically, + * you would use (omitting error handling): + * + * ``` + * FT_Glyph glyph; + * FT_BitmapGlyph glyph_bitmap; + * + * + * // load glyph + * error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); + * + * // extract glyph image + * error = FT_Get_Glyph( face->glyph, &glyph ); + * + * // convert to a bitmap (default render mode + destroying old) + * if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) + * { + * error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, + * 0, 1 ); + * if ( error ) // `glyph' unchanged + * ... + * } + * + * // access bitmap content by typecasting + * glyph_bitmap = (FT_BitmapGlyph)glyph; + * + * // do funny stuff with it, like blitting/drawing + * ... + * + * // discard glyph image (bitmap or not) + * FT_Done_Glyph( glyph ); + * ``` + * + * Here is another example, again without error handling: + * + * ``` + * FT_Glyph glyphs[MAX_GLYPHS] + * + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || + * FT_Get_Glyph ( face->glyph, &glyphs[idx] ); + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * { + * FT_Glyph bitmap = glyphs[idx]; + * + * + * ... + * + * // after this call, `bitmap' no longer points into + * // the `glyphs' array (and the old value isn't destroyed) + * FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); + * + * ... + * + * FT_Done_Glyph( bitmap ); + * } + * + * ... + * + * for ( idx = 0; i < MAX_GLYPHS; i++ ) + * FT_Done_Glyph( glyphs[idx] ); + * ``` + */ FT_EXPORT( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, FT_Render_Mode render_mode, @@ -528,17 +576,18 @@ FT_BEGIN_HEADER FT_Bool destroy ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Glyph */ - /* */ - /* <Description> */ - /* Destroy a given glyph. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the target glyph object. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Glyph + * + * @description: + * Destroy a given glyph. + * + * @input: + * glyph :: + * A handle to the target glyph object. + */ FT_EXPORT( void ) FT_Done_Glyph( FT_Glyph glyph ); @@ -547,54 +596,56 @@ FT_BEGIN_HEADER /* other helpful functions */ - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Multiply */ - /* */ - /* <Description> */ - /* Perform the matrix operation `b = a*b'. */ - /* */ - /* <Input> */ - /* a :: A pointer to matrix `a'. */ - /* */ - /* <InOut> */ - /* b :: A pointer to matrix `b'. */ - /* */ - /* <Note> */ - /* The result is undefined if either `a' or `b' is zero. */ - /* */ - /* Since the function uses wrap-around arithmetic, results become */ - /* meaningless if the arguments are very large. */ - /* */ + /************************************************************************** + * + * @section: + * computations + * + */ + + + /************************************************************************** + * + * @function: + * FT_Matrix_Multiply + * + * @description: + * Perform the matrix operation `b = a*b`. + * + * @input: + * a :: + * A pointer to matrix `a`. + * + * @inout: + * b :: + * A pointer to matrix `b`. + * + * @note: + * The result is undefined if either `a` or `b` is zero. + * + * Since the function uses wrap-around arithmetic, results become + * meaningless if the arguments are very large. + */ FT_EXPORT( void ) FT_Matrix_Multiply( const FT_Matrix* a, FT_Matrix* b ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Invert */ - /* */ - /* <Description> */ - /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ - /* */ - /* <InOut> */ - /* matrix :: A pointer to the target matrix. Remains untouched in */ - /* case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Matrix_Invert + * + * @description: + * Invert a 2x2 matrix. Return an error if it can't be inverted. + * + * @inout: + * matrix :: + * A pointer to the target matrix. Remains untouched in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix ); diff --git a/src/3rdparty/freetype/include/freetype/ftgxval.h b/src/3rdparty/freetype/include/freetype/ftgxval.h index 8382d59954..b14f637c56 100644 --- a/src/3rdparty/freetype/include/freetype/ftgxval.h +++ b/src/3rdparty/freetype/include/freetype/ftgxval.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftgxval.h */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO, Redhat K.K, */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgxval.h + * + * FreeType API for validating TrueTypeGX/AAT tables (specification). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO, Redhat K.K, + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef FTGXVAL_H_ @@ -41,43 +41,43 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* gx_validation */ - /* */ - /* <Title> */ - /* TrueTypeGX/AAT Validation */ - /* */ - /* <Abstract> */ - /* An API to validate TrueTypeGX/AAT tables. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions to validate */ - /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ - /* trak, prop, lcar). */ - /* */ - /* <Order> */ - /* FT_TrueTypeGX_Validate */ - /* FT_TrueTypeGX_Free */ - /* */ - /* FT_ClassicKern_Validate */ - /* FT_ClassicKern_Free */ - /* */ - /* FT_VALIDATE_GX_LENGTH */ - /* FT_VALIDATE_GXXXX */ - /* FT_VALIDATE_CKERNXXX */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* */ - /* Warning: Use FT_VALIDATE_XXX to validate a table. */ - /* Following definitions are for gxvalid developers. */ - /* */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * gx_validation + * + * @title: + * TrueTypeGX/AAT Validation + * + * @abstract: + * An API to validate TrueTypeGX/AAT tables. + * + * @description: + * This section contains the declaration of functions to validate some + * TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, trak, + * prop, lcar). + * + * @order: + * FT_TrueTypeGX_Validate + * FT_TrueTypeGX_Free + * + * FT_ClassicKern_Validate + * FT_ClassicKern_Free + * + * FT_VALIDATE_GX_LENGTH + * FT_VALIDATE_GXXXX + * FT_VALIDATE_CKERNXXX + * + */ + + /************************************************************************** + * + * + * Warning: Use `FT_VALIDATE_XXX` to validate a table. + * Following definitions are for gxvalid developers. + * + * + */ #define FT_VALIDATE_feat_INDEX 0 #define FT_VALIDATE_mort_INDEX 1 @@ -92,14 +92,14 @@ FT_BEGIN_HEADER #define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX - /************************************************************************* + /************************************************************************** * * @macro: * FT_VALIDATE_GX_LENGTH * * @description: * The number of tables checked in this module. Use it as a parameter - * for the `table-length' argument of function @FT_TrueTypeGX_Validate. + * for the `table-length` argument of function @FT_TrueTypeGX_Validate. */ #define FT_VALIDATE_GX_LENGTH ( FT_VALIDATE_GX_LAST_INDEX + 1 ) @@ -112,51 +112,51 @@ FT_BEGIN_HEADER ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) - /********************************************************************** - * - * @enum: - * FT_VALIDATE_GXXXX - * - * @description: - * A list of bit-field constants used with @FT_TrueTypeGX_Validate to - * indicate which TrueTypeGX/AAT Type tables should be validated. - * - * @values: - * FT_VALIDATE_feat :: - * Validate `feat' table. - * - * FT_VALIDATE_mort :: - * Validate `mort' table. - * - * FT_VALIDATE_morx :: - * Validate `morx' table. - * - * FT_VALIDATE_bsln :: - * Validate `bsln' table. - * - * FT_VALIDATE_just :: - * Validate `just' table. - * - * FT_VALIDATE_kern :: - * Validate `kern' table. - * - * FT_VALIDATE_opbd :: - * Validate `opbd' table. - * - * FT_VALIDATE_trak :: - * Validate `trak' table. - * - * FT_VALIDATE_prop :: - * Validate `prop' table. - * - * FT_VALIDATE_lcar :: - * Validate `lcar' table. - * - * FT_VALIDATE_GX :: - * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, - * opbd, trak, prop and lcar). - * - */ + /************************************************************************** + * + * @enum: + * FT_VALIDATE_GXXXX + * + * @description: + * A list of bit-field constants used with @FT_TrueTypeGX_Validate to + * indicate which TrueTypeGX/AAT Type tables should be validated. + * + * @values: + * FT_VALIDATE_feat :: + * Validate 'feat' table. + * + * FT_VALIDATE_mort :: + * Validate 'mort' table. + * + * FT_VALIDATE_morx :: + * Validate 'morx' table. + * + * FT_VALIDATE_bsln :: + * Validate 'bsln' table. + * + * FT_VALIDATE_just :: + * Validate 'just' table. + * + * FT_VALIDATE_kern :: + * Validate 'kern' table. + * + * FT_VALIDATE_opbd :: + * Validate 'opbd' table. + * + * FT_VALIDATE_trak :: + * Validate 'trak' table. + * + * FT_VALIDATE_prop :: + * Validate 'prop' table. + * + * FT_VALIDATE_lcar :: + * Validate 'lcar' table. + * + * FT_VALIDATE_GX :: + * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, + * opbd, trak, prop and lcar). + * + */ #define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) #define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) @@ -181,47 +181,47 @@ FT_BEGIN_HEADER FT_VALIDATE_lcar ) - /********************************************************************** - * - * @function: - * FT_TrueTypeGX_Validate - * - * @description: - * Validate various TrueTypeGX tables to assure that all offsets and - * indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without - * error checking (which can be quite time consuming). - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the tables to be validated. See - * @FT_VALIDATE_GXXXX for possible values. - * - * table_length :: - * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH - * should be passed. - * - * @output: - * tables :: - * The array where all validated sfnt tables are stored. - * The array itself must be allocated by a client. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with TrueTypeGX fonts, returning an error - * otherwise. - * - * After use, the application should deallocate the buffers pointed to by - * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value - * indicates that the table either doesn't exist in the font, the - * application hasn't asked for validation, or the validator doesn't have - * the ability to validate the sfnt table. - */ + /************************************************************************** + * + * @function: + * FT_TrueTypeGX_Validate + * + * @description: + * Validate various TrueTypeGX tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_GXXXX for possible values. + * + * table_length :: + * The size of the `tables` array. Normally, @FT_VALIDATE_GX_LENGTH + * should be passed. + * + * @output: + * tables :: + * The array where all validated sfnt tables are stored. The array + * itself must be allocated by a client. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with TrueTypeGX fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the buffers pointed to by + * each `tables` element, by calling @FT_TrueTypeGX_Free. A `NULL` value + * indicates that the table either doesn't exist in the font, the + * application hasn't asked for validation, or the validator doesn't have + * the ability to validate the sfnt table. + */ FT_EXPORT( FT_Error ) FT_TrueTypeGX_Validate( FT_Face face, FT_UInt validation_flags, @@ -229,119 +229,117 @@ FT_BEGIN_HEADER FT_UInt table_length ); - /********************************************************************** - * - * @function: - * FT_TrueTypeGX_Free - * - * @description: - * Free the buffer allocated by TrueTypeGX validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer allocated by - * @FT_TrueTypeGX_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_TrueTypeGX_Validate only. - */ + /************************************************************************** + * + * @function: + * FT_TrueTypeGX_Free + * + * @description: + * Free the buffer allocated by TrueTypeGX validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer allocated by @FT_TrueTypeGX_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_TrueTypeGX_Validate only. + */ FT_EXPORT( void ) FT_TrueTypeGX_Free( FT_Face face, FT_Bytes table ); - /********************************************************************** - * - * @enum: - * FT_VALIDATE_CKERNXXX - * - * @description: - * A list of bit-field constants used with @FT_ClassicKern_Validate - * to indicate the classic kern dialect or dialects. If the selected - * type doesn't fit, @FT_ClassicKern_Validate regards the table as - * invalid. - * - * @values: - * FT_VALIDATE_MS :: - * Handle the `kern' table as a classic Microsoft kern table. - * - * FT_VALIDATE_APPLE :: - * Handle the `kern' table as a classic Apple kern table. - * - * FT_VALIDATE_CKERN :: - * Handle the `kern' as either classic Apple or Microsoft kern table. - */ + /************************************************************************** + * + * @enum: + * FT_VALIDATE_CKERNXXX + * + * @description: + * A list of bit-field constants used with @FT_ClassicKern_Validate to + * indicate the classic kern dialect or dialects. If the selected type + * doesn't fit, @FT_ClassicKern_Validate regards the table as invalid. + * + * @values: + * FT_VALIDATE_MS :: + * Handle the 'kern' table as a classic Microsoft kern table. + * + * FT_VALIDATE_APPLE :: + * Handle the 'kern' table as a classic Apple kern table. + * + * FT_VALIDATE_CKERN :: + * Handle the 'kern' as either classic Apple or Microsoft kern table. + */ #define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) #define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) #define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) - /********************************************************************** - * - * @function: - * FT_ClassicKern_Validate - * - * @description: - * Validate classic (16-bit format) kern table to assure that the offsets - * and indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without error - * checking (which can be quite time consuming). - * - * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both - * the new 32-bit format and the classic 16-bit format, while - * FT_ClassicKern_Validate only supports the classic 16-bit format. - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the dialect to be validated. See - * @FT_VALIDATE_CKERNXXX for possible values. - * - * @output: - * ckern_table :: - * A pointer to the kern table. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * After use, the application should deallocate the buffers pointed to by - * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value - * indicates that the table doesn't exist in the font. - */ + /************************************************************************** + * + * @function: + * FT_ClassicKern_Validate + * + * @description: + * Validate classic (16-bit format) kern table to assure that the + * offsets and indices are valid. The idea is that a higher-level + * library that actually does the text layout can access those tables + * without error checking (which can be quite time consuming). + * + * The 'kern' table validator in @FT_TrueTypeGX_Validate deals with both + * the new 32-bit format and the classic 16-bit format, while + * FT_ClassicKern_Validate only supports the classic 16-bit format. + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the dialect to be validated. See + * @FT_VALIDATE_CKERNXXX for possible values. + * + * @output: + * ckern_table :: + * A pointer to the kern table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * After use, the application should deallocate the buffers pointed to by + * `ckern_table`, by calling @FT_ClassicKern_Free. A `NULL` value + * indicates that the table doesn't exist in the font. + */ FT_EXPORT( FT_Error ) FT_ClassicKern_Validate( FT_Face face, FT_UInt validation_flags, FT_Bytes *ckern_table ); - /********************************************************************** - * - * @function: - * FT_ClassicKern_Free - * - * @description: - * Free the buffer allocated by classic Kern validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer that is allocated by - * @FT_ClassicKern_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_ClassicKern_Validate only. - */ + /************************************************************************** + * + * @function: + * FT_ClassicKern_Free + * + * @description: + * Free the buffer allocated by classic Kern validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_ClassicKern_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_ClassicKern_Validate only. + */ FT_EXPORT( void ) FT_ClassicKern_Free( FT_Face face, FT_Bytes table ); diff --git a/src/3rdparty/freetype/include/freetype/ftgzip.h b/src/3rdparty/freetype/include/freetype/ftgzip.h index db033da0ed..418c61228e 100644 --- a/src/3rdparty/freetype/include/freetype/ftgzip.h +++ b/src/3rdparty/freetype/include/freetype/ftgzip.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgzip.h */ -/* */ -/* Gzip-compressed stream support. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgzip.h + * + * Gzip-compressed stream support. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGZIP_H_ @@ -31,108 +31,108 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* gzip */ - /* */ - /* <Title> */ - /* GZIP Streams */ - /* */ - /* <Abstract> */ - /* Using gzip-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Gzip-specific functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************ - * - * @function: - * FT_Stream_OpenGzip - * - * @description: - * Open a new stream to parse gzip-compressed font files. This is - * mainly used to support the compressed `*.pcf.gz' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, gzip compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a gzipped stream from - * it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - */ + /************************************************************************** + * + * @section: + * gzip + * + * @title: + * GZIP Streams + * + * @abstract: + * Using gzip-compressed font files. + * + * @description: + * This section contains the declaration of Gzip-specific functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Stream_OpenGzip + * + * @description: + * Open a new stream to parse gzip-compressed font files. This is mainly + * used to support the compressed `*.pcf.gz` fonts that come with + * XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream. + * + * In certain builds of the library, gzip compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a gzipped stream from it + * and re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with zlib support. + */ FT_EXPORT( FT_Error ) FT_Stream_OpenGzip( FT_Stream stream, FT_Stream source ); - /************************************************************************ - * - * @function: - * FT_Gzip_Uncompress - * - * @description: - * Decompress a zipped input buffer into an output buffer. This function - * is modeled after zlib's `uncompress' function. - * - * @input: - * memory :: - * A FreeType memory handle. - * - * input :: - * The input buffer. - * - * input_len :: - * The length of the input buffer. - * - * @output: - * output:: - * The output buffer. - * - * @inout: - * output_len :: - * Before calling the function, this is the total size of the output - * buffer, which must be large enough to hold the entire uncompressed - * data (so the size of the uncompressed data must be known in - * advance). After calling the function, `output_len' is the size of - * the used data in `output'. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - * - * @since: - * 2.5.1 - */ + /************************************************************************** + * + * @function: + * FT_Gzip_Uncompress + * + * @description: + * Decompress a zipped input buffer into an output buffer. This function + * is modeled after zlib's `uncompress` function. + * + * @input: + * memory :: + * A FreeType memory handle. + * + * input :: + * The input buffer. + * + * input_len :: + * The length of the input buffer. + * + * @output: + * output :: + * The output buffer. + * + * @inout: + * output_len :: + * Before calling the function, this is the total size of the output + * buffer, which must be large enough to hold the entire uncompressed + * data (so the size of the uncompressed data must be known in + * advance). After calling the function, `output_len` is the size of + * the used data in `output`. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with zlib support. + * + * @since: + * 2.5.1 + */ FT_EXPORT( FT_Error ) FT_Gzip_Uncompress( FT_Memory memory, FT_Byte* output, diff --git a/src/3rdparty/freetype/include/freetype/ftimage.h b/src/3rdparty/freetype/include/freetype/ftimage.h index 79ede1959d..face34fe49 100644 --- a/src/3rdparty/freetype/include/freetype/ftimage.h +++ b/src/3rdparty/freetype/include/freetype/ftimage.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftimage.h */ -/* */ -/* FreeType glyph image formats and default raster interface */ -/* (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Note: A `raster' is simply a scan-line converter, used to render */ - /* FT_Outlines into FT_Bitmaps. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftimage.h + * + * FreeType glyph image formats and default raster interface + * (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Note: A 'raster' is simply a scan-line converter, used to render + * FT_Outlines into FT_Bitmaps. + * + */ #ifndef FTIMAGE_H_ @@ -37,40 +37,42 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pos */ - /* */ - /* <Description> */ - /* The type FT_Pos is used to store vectorial coordinates. Depending */ - /* on the context, these can represent distances in integer font */ - /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ - /* */ + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @type: + * FT_Pos + * + * @description: + * The type FT_Pos is used to store vectorial coordinates. Depending on + * the context, these can represent distances in integer font units, or + * 16.16, or 26.6 fixed-point pixel coordinates. + */ typedef signed long FT_Pos; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Vector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector; coordinates are of */ - /* the FT_Pos type. */ - /* */ - /* <Fields> */ - /* x :: The horizontal coordinate. */ - /* y :: The vertical coordinate. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Vector + * + * @description: + * A simple structure used to store a 2D vector; coordinates are of the + * FT_Pos type. + * + * @fields: + * x :: + * The horizontal coordinate. + * y :: + * The vertical coordinate. + */ typedef struct FT_Vector_ { FT_Pos x; @@ -79,39 +81,41 @@ FT_BEGIN_HEADER } FT_Vector; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BBox */ - /* */ - /* <Description> */ - /* A structure used to hold an outline's bounding box, i.e., the */ - /* coordinates of its extrema in the horizontal and vertical */ - /* directions. */ - /* */ - /* <Fields> */ - /* xMin :: The horizontal minimum (left-most). */ - /* */ - /* yMin :: The vertical minimum (bottom-most). */ - /* */ - /* xMax :: The horizontal maximum (right-most). */ - /* */ - /* yMax :: The vertical maximum (top-most). */ - /* */ - /* <Note> */ - /* The bounding box is specified with the coordinates of the lower */ - /* left and the upper right corner. In PostScript, those values are */ - /* often called (llx,lly) and (urx,ury), respectively. */ - /* */ - /* If `yMin' is negative, this value gives the glyph's descender. */ - /* Otherwise, the glyph doesn't descend below the baseline. */ - /* Similarly, if `ymax' is positive, this value gives the glyph's */ - /* ascender. */ - /* */ - /* `xMin' gives the horizontal distance from the glyph's origin to */ - /* the left edge of the glyph's bounding box. If `xMin' is negative, */ - /* the glyph extends to the left of the origin. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_BBox + * + * @description: + * A structure used to hold an outline's bounding box, i.e., the + * coordinates of its extrema in the horizontal and vertical directions. + * + * @fields: + * xMin :: + * The horizontal minimum (left-most). + * + * yMin :: + * The vertical minimum (bottom-most). + * + * xMax :: + * The horizontal maximum (right-most). + * + * yMax :: + * The vertical maximum (top-most). + * + * @note: + * The bounding box is specified with the coordinates of the lower left + * and the upper right corner. In PostScript, those values are often + * called (llx,lly) and (urx,ury), respectively. + * + * If `yMin` is negative, this value gives the glyph's descender. + * Otherwise, the glyph doesn't descend below the baseline. Similarly, + * if `ymax` is positive, this value gives the glyph's ascender. + * + * `xMin` gives the horizontal distance from the glyph's origin to the + * left edge of the glyph's bounding box. If `xMin` is negative, the + * glyph extends to the left of the origin. + */ typedef struct FT_BBox_ { FT_Pos xMin, yMin; @@ -120,63 +124,60 @@ FT_BEGIN_HEADER } FT_BBox; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Pixel_Mode */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of pixels in a */ - /* given bitmap. Note that additional formats may be added in the */ - /* future. */ - /* */ - /* <Values> */ - /* FT_PIXEL_MODE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_PIXEL_MODE_MONO :: */ - /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */ - /* are stored in most-significant order (MSB), which means that */ - /* the left-most pixel in a byte has value 128. */ - /* */ - /* FT_PIXEL_MODE_GRAY :: */ - /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ - /* images. Each pixel is stored in one byte. Note that the number */ - /* of `gray' levels is stored in the `num_grays' field of the */ - /* @FT_Bitmap structure (it generally is 256). */ - /* */ - /* FT_PIXEL_MODE_GRAY2 :: */ - /* A 2-bit per pixel bitmap, used to represent embedded */ - /* anti-aliased bitmaps in font files according to the OpenType */ - /* specification. We haven't found a single font using this */ - /* format, however. */ - /* */ - /* FT_PIXEL_MODE_GRAY4 :: */ - /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ - /* bitmaps in font files according to the OpenType specification. */ - /* We haven't found a single font using this format, however. */ - /* */ - /* FT_PIXEL_MODE_LCD :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on LCD displays; the bitmap is three times */ - /* wider than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD. */ - /* */ - /* FT_PIXEL_MODE_LCD_V :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on rotated LCD displays; the bitmap is three */ - /* times taller than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD_V. */ - /* */ - /* FT_PIXEL_MODE_BGRA :: */ - /* [Since 2.5] An image with four 8-bit channels per pixel, */ - /* representing a color image (such as emoticons) with alpha */ - /* channel. For each pixel, the format is BGRA, which means, the */ - /* blue channel comes first in memory. The color channels are */ - /* pre-multiplied and in the sRGB colorspace. For example, full */ - /* red at half-translucent opacity will be represented as */ - /* `00,00,80,80', not `00,00,FF,80'. See also @FT_LOAD_COLOR. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Pixel_Mode + * + * @description: + * An enumeration type used to describe the format of pixels in a given + * bitmap. Note that additional formats may be added in the future. + * + * @values: + * FT_PIXEL_MODE_NONE :: + * Value~0 is reserved. + * + * FT_PIXEL_MODE_MONO :: + * A monochrome bitmap, using 1~bit per pixel. Note that pixels are + * stored in most-significant order (MSB), which means that the + * left-most pixel in a byte has value 128. + * + * FT_PIXEL_MODE_GRAY :: + * An 8-bit bitmap, generally used to represent anti-aliased glyph + * images. Each pixel is stored in one byte. Note that the number of + * 'gray' levels is stored in the `num_grays` field of the @FT_Bitmap + * structure (it generally is 256). + * + * FT_PIXEL_MODE_GRAY2 :: + * A 2-bit per pixel bitmap, used to represent embedded anti-aliased + * bitmaps in font files according to the OpenType specification. We + * haven't found a single font using this format, however. + * + * FT_PIXEL_MODE_GRAY4 :: + * A 4-bit per pixel bitmap, representing embedded anti-aliased bitmaps + * in font files according to the OpenType specification. We haven't + * found a single font using this format, however. + * + * FT_PIXEL_MODE_LCD :: + * An 8-bit bitmap, representing RGB or BGR decimated glyph images used + * for display on LCD displays; the bitmap is three times wider than + * the original glyph image. See also @FT_RENDER_MODE_LCD. + * + * FT_PIXEL_MODE_LCD_V :: + * An 8-bit bitmap, representing RGB or BGR decimated glyph images used + * for display on rotated LCD displays; the bitmap is three times + * taller than the original glyph image. See also + * @FT_RENDER_MODE_LCD_V. + * + * FT_PIXEL_MODE_BGRA :: + * [Since 2.5] An image with four 8-bit channels per pixel, + * representing a color image (such as emoticons) with alpha channel. + * For each pixel, the format is BGRA, which means, the blue channel + * comes first in memory. The color channels are pre-multiplied and in + * the sRGB colorspace. For example, full red at half-translucent + * opacity will be represented as '00,00,80,80', not '00,00,FF,80'. + * See also @FT_LOAD_COLOR. + */ typedef enum FT_Pixel_Mode_ { FT_PIXEL_MODE_NONE = 0, @@ -193,7 +194,7 @@ FT_BEGIN_HEADER } FT_Pixel_Mode; - /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */ + /* these constants are deprecated; use the corresponding `FT_Pixel_Mode` */ /* values instead. */ #define ft_pixel_mode_none FT_PIXEL_MODE_NONE #define ft_pixel_mode_mono FT_PIXEL_MODE_MONO @@ -202,62 +203,61 @@ FT_BEGIN_HEADER #define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap */ - /* */ - /* <Description> */ - /* A structure used to describe a bitmap or pixmap to the raster. */ - /* Note that we now manage pixmaps of various depths through the */ - /* `pixel_mode' field. */ - /* */ - /* <Fields> */ - /* rows :: The number of bitmap rows. */ - /* */ - /* width :: The number of pixels in bitmap row. */ - /* */ - /* pitch :: The pitch's absolute value is the number of bytes */ - /* taken by one bitmap row, including padding. */ - /* However, the pitch is positive when the bitmap has */ - /* a `down' flow, and negative when it has an `up' */ - /* flow. In all cases, the pitch is an offset to add */ - /* to a bitmap pointer in order to go down one row. */ - /* */ - /* Note that `padding' means the alignment of a */ - /* bitmap to a byte border, and FreeType functions */ - /* normally align to the smallest possible integer */ - /* value. */ - /* */ - /* For the B/W rasterizer, `pitch' is always an even */ - /* number. */ - /* */ - /* To change the pitch of a bitmap (say, to make it a */ - /* multiple of 4), use @FT_Bitmap_Convert. */ - /* Alternatively, you might use callback functions to */ - /* directly render to the application's surface; see */ - /* the file `example2.cpp' in the tutorial for a */ - /* demonstration. */ - /* */ - /* buffer :: A typeless pointer to the bitmap buffer. This */ - /* value should be aligned on 32-bit boundaries in */ - /* most cases. */ - /* */ - /* num_grays :: This field is only used with */ - /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ - /* levels used in the bitmap. */ - /* */ - /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ - /* See @FT_Pixel_Mode for possible values. */ - /* */ - /* palette_mode :: This field is intended for paletted pixel modes; */ - /* it indicates how the palette is stored. Not */ - /* used currently. */ - /* */ - /* palette :: A typeless pointer to the bitmap palette; this */ - /* field is intended for paletted pixel modes. Not */ - /* used currently. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Bitmap + * + * @description: + * A structure used to describe a bitmap or pixmap to the raster. Note + * that we now manage pixmaps of various depths through the `pixel_mode` + * field. + * + * @fields: + * rows :: + * The number of bitmap rows. + * + * width :: + * The number of pixels in bitmap row. + * + * pitch :: + * The pitch's absolute value is the number of bytes taken by one + * bitmap row, including padding. However, the pitch is positive when + * the bitmap has a 'down' flow, and negative when it has an 'up' flow. + * In all cases, the pitch is an offset to add to a bitmap pointer in + * order to go down one row. + * + * Note that 'padding' means the alignment of a bitmap to a byte + * border, and FreeType functions normally align to the smallest + * possible integer value. + * + * For the B/W rasterizer, `pitch` is always an even number. + * + * To change the pitch of a bitmap (say, to make it a multiple of 4), + * use @FT_Bitmap_Convert. Alternatively, you might use callback + * functions to directly render to the application's surface; see the + * file `example2.cpp` in the tutorial for a demonstration. + * + * buffer :: + * A typeless pointer to the bitmap buffer. This value should be + * aligned on 32-bit boundaries in most cases. + * + * num_grays :: + * This field is only used with @FT_PIXEL_MODE_GRAY; it gives the + * number of gray levels used in the bitmap. + * + * pixel_mode :: + * The pixel mode, i.e., how pixel bits are stored. See @FT_Pixel_Mode + * for possible values. + * + * palette_mode :: + * This field is intended for paletted pixel modes; it indicates how + * the palette is stored. Not used currently. + * + * palette :: + * A typeless pointer to the bitmap palette; this field is intended for + * paletted pixel modes. Not used currently. + */ typedef struct FT_Bitmap_ { unsigned int rows; @@ -272,65 +272,68 @@ FT_BEGIN_HEADER } FT_Bitmap; - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline */ - /* */ - /* <Description> */ - /* This structure is used to describe an outline to the scan-line */ - /* converter. */ - /* */ - /* <Fields> */ - /* n_contours :: The number of contours in the outline. */ - /* */ - /* n_points :: The number of points in the outline. */ - /* */ - /* points :: A pointer to an array of `n_points' @FT_Vector */ - /* elements, giving the outline's point coordinates. */ - /* */ - /* tags :: A pointer to an array of `n_points' chars, giving */ - /* each outline point's type. */ - /* */ - /* If bit~0 is unset, the point is `off' the curve, */ - /* i.e., a Bezier control point, while it is `on' if */ - /* set. */ - /* */ - /* Bit~1 is meaningful for `off' points only. If set, */ - /* it indicates a third-order Bezier arc control point; */ - /* and a second-order control point if unset. */ - /* */ - /* If bit~2 is set, bits 5-7 contain the drop-out mode */ - /* (as defined in the OpenType specification; the value */ - /* is the same as the argument to the SCANMODE */ - /* instruction). */ - /* */ - /* Bits 3 and~4 are reserved for internal purposes. */ - /* */ - /* contours :: An array of `n_contours' shorts, giving the end */ - /* point of each contour within the outline. For */ - /* example, the first contour is defined by the points */ - /* `0' to `contours[0]', the second one is defined by */ - /* the points `contours[0]+1' to `contours[1]', etc. */ - /* */ - /* flags :: A set of bit flags used to characterize the outline */ - /* and give hints to the scan-converter and hinter on */ - /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */ - /* */ - /* <Note> */ - /* The B/W rasterizer only checks bit~2 in the `tags' array for the */ - /* first point of each contour. The drop-out mode as given with */ - /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */ - /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */ - /* */ + /************************************************************************** + * + * @section: + * outline_processing + * + */ + + + /************************************************************************** + * + * @struct: + * FT_Outline + * + * @description: + * This structure is used to describe an outline to the scan-line + * converter. + * + * @fields: + * n_contours :: + * The number of contours in the outline. + * + * n_points :: + * The number of points in the outline. + * + * points :: + * A pointer to an array of `n_points` @FT_Vector elements, giving the + * outline's point coordinates. + * + * tags :: + * A pointer to an array of `n_points` chars, giving each outline + * point's type. + * + * If bit~0 is unset, the point is 'off' the curve, i.e., a Bezier + * control point, while it is 'on' if set. + * + * Bit~1 is meaningful for 'off' points only. If set, it indicates a + * third-order Bezier arc control point; and a second-order control + * point if unset. + * + * If bit~2 is set, bits 5-7 contain the drop-out mode (as defined in + * the OpenType specification; the value is the same as the argument to + * the 'SCANMODE' instruction). + * + * Bits 3 and~4 are reserved for internal purposes. + * + * contours :: + * An array of `n_contours` shorts, giving the end point of each + * contour within the outline. For example, the first contour is + * defined by the points '0' to `contours[0]`, the second one is + * defined by the points `contours[0]+1` to `contours[1]`, etc. + * + * flags :: + * A set of bit flags used to characterize the outline and give hints + * to the scan-converter and hinter on how to convert/grid-fit it. See + * @FT_OUTLINE_XXX. + * + * @note: + * The B/W rasterizer only checks bit~2 in the `tags` array for the first + * point of each contour. The drop-out mode as given with + * @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and + * @FT_OUTLINE_INCLUDE_STUBS in `flags` is then overridden. + */ typedef struct FT_Outline_ { short n_contours; /* number of contours in glyph */ @@ -352,78 +355,76 @@ FT_BEGIN_HEADER #define FT_OUTLINE_POINTS_MAX SHRT_MAX - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OUTLINE_XXX */ - /* */ - /* <Description> */ - /* A list of bit-field constants use for the flags in an outline's */ - /* `flags' field. */ - /* */ - /* <Values> */ - /* FT_OUTLINE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_OUTLINE_OWNER :: */ - /* If set, this flag indicates that the outline's field arrays */ - /* (i.e., `points', `flags', and `contours') are `owned' by the */ - /* outline object, and should thus be freed when it is destroyed. */ - /* */ - /* FT_OUTLINE_EVEN_ODD_FILL :: */ - /* By default, outlines are filled using the non-zero winding rule. */ - /* If set to 1, the outline will be filled using the even-odd fill */ - /* rule (only works with the smooth rasterizer). */ - /* */ - /* FT_OUTLINE_REVERSE_FILL :: */ - /* By default, outside contours of an outline are oriented in */ - /* clock-wise direction, as defined in the TrueType specification. */ - /* This flag is set if the outline uses the opposite direction */ - /* (typically for Type~1 fonts). This flag is ignored by the scan */ - /* converter. */ - /* */ - /* FT_OUTLINE_IGNORE_DROPOUTS :: */ - /* By default, the scan converter will try to detect drop-outs in */ - /* an outline and correct the glyph bitmap to ensure consistent */ - /* shape continuity. If set, this flag hints the scan-line */ - /* converter to ignore such cases. See below for more information. */ - /* */ - /* FT_OUTLINE_SMART_DROPOUTS :: */ - /* Select smart dropout control. If unset, use simple dropout */ - /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */ - /* below for more information. */ - /* */ - /* FT_OUTLINE_INCLUDE_STUBS :: */ - /* If set, turn pixels on for `stubs', otherwise exclude them. */ - /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */ - /* more information. */ - /* */ - /* FT_OUTLINE_HIGH_PRECISION :: */ - /* This flag indicates that the scan-line converter should try to */ - /* convert this outline to bitmaps with the highest possible */ - /* quality. It is typically set for small character sizes. Note */ - /* that this is only a hint that might be completely ignored by a */ - /* given scan-converter. */ - /* */ - /* FT_OUTLINE_SINGLE_PASS :: */ - /* This flag is set to force a given scan-converter to only use a */ - /* single pass over the outline to render a bitmap glyph image. */ - /* Normally, it is set for very large character sizes. It is only */ - /* a hint that might be completely ignored by a given */ - /* scan-converter. */ - /* */ - /* <Note> */ - /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */ - /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */ - /* rasterizer. */ - /* */ - /* There exists a second mechanism to pass the drop-out mode to the */ - /* B/W rasterizer; see the `tags' field in @FT_Outline. */ - /* */ - /* Please refer to the description of the `SCANTYPE' instruction in */ - /* the OpenType specification (in file `ttinst1.doc') how simple */ - /* drop-outs, smart drop-outs, and stubs are defined. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_OUTLINE_XXX + * + * @description: + * A list of bit-field constants used for the flags in an outline's + * `flags` field. + * + * @values: + * FT_OUTLINE_NONE :: + * Value~0 is reserved. + * + * FT_OUTLINE_OWNER :: + * If set, this flag indicates that the outline's field arrays (i.e., + * `points`, `flags`, and `contours`) are 'owned' by the outline + * object, and should thus be freed when it is destroyed. + * + * FT_OUTLINE_EVEN_ODD_FILL :: + * By default, outlines are filled using the non-zero winding rule. If + * set to 1, the outline will be filled using the even-odd fill rule + * (only works with the smooth rasterizer). + * + * FT_OUTLINE_REVERSE_FILL :: + * By default, outside contours of an outline are oriented in + * clock-wise direction, as defined in the TrueType specification. + * This flag is set if the outline uses the opposite direction + * (typically for Type~1 fonts). This flag is ignored by the scan + * converter. + * + * FT_OUTLINE_IGNORE_DROPOUTS :: + * By default, the scan converter will try to detect drop-outs in an + * outline and correct the glyph bitmap to ensure consistent shape + * continuity. If set, this flag hints the scan-line converter to + * ignore such cases. See below for more information. + * + * FT_OUTLINE_SMART_DROPOUTS :: + * Select smart dropout control. If unset, use simple dropout control. + * Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more + * information. + * + * FT_OUTLINE_INCLUDE_STUBS :: + * If set, turn pixels on for 'stubs', otherwise exclude them. Ignored + * if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for more + * information. + * + * FT_OUTLINE_HIGH_PRECISION :: + * This flag indicates that the scan-line converter should try to + * convert this outline to bitmaps with the highest possible quality. + * It is typically set for small character sizes. Note that this is + * only a hint that might be completely ignored by a given + * scan-converter. + * + * FT_OUTLINE_SINGLE_PASS :: + * This flag is set to force a given scan-converter to only use a + * single pass over the outline to render a bitmap glyph image. + * Normally, it is set for very large character sizes. It is only a + * hint that might be completely ignored by a given scan-converter. + * + * @note: + * The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and + * @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth rasterizer. + * + * There exists a second mechanism to pass the drop-out mode to the B/W + * rasterizer; see the `tags` field in @FT_Outline. + * + * Please refer to the description of the 'SCANTYPE' instruction in the + * OpenType specification (in file `ttinst1.doc`) how simple drop-outs, + * smart drop-outs, and stubs are defined. + */ #define FT_OUTLINE_NONE 0x0 #define FT_OUTLINE_OWNER 0x1 #define FT_OUTLINE_EVEN_ODD_FILL 0x2 @@ -437,7 +438,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_OUTLINE_XXX' values instead */ + /* `FT_OUTLINE_XXX` values instead */ #define ft_outline_none FT_OUTLINE_NONE #define ft_outline_owner FT_OUTLINE_OWNER #define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL @@ -448,20 +449,25 @@ FT_BEGIN_HEADER /* */ -#define FT_CURVE_TAG( flag ) ( flag & 3 ) +#define FT_CURVE_TAG( flag ) ( flag & 0x03 ) -#define FT_CURVE_TAG_ON 1 -#define FT_CURVE_TAG_CONIC 0 -#define FT_CURVE_TAG_CUBIC 2 + /* see the `tags` field in `FT_Outline` for a description of the values */ +#define FT_CURVE_TAG_ON 0x01 +#define FT_CURVE_TAG_CONIC 0x00 +#define FT_CURVE_TAG_CUBIC 0x02 -#define FT_CURVE_TAG_HAS_SCANMODE 4 +#define FT_CURVE_TAG_HAS_SCANMODE 0x04 -#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ -#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_X 0x08 /* reserved for TrueType hinter */ +#define FT_CURVE_TAG_TOUCH_Y 0x10 /* reserved for TrueType hinter */ #define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ FT_CURVE_TAG_TOUCH_Y ) + /* values 0x20, 0x40, and 0x80 are reserved */ + + /* these constants are deprecated; use the corresponding */ + /* `FT_CURVE_TAG_XXX` values instead */ #define FT_Curve_Tag_On FT_CURVE_TAG_ON #define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC #define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC @@ -469,26 +475,28 @@ FT_BEGIN_HEADER #define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_MoveToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `move */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `move to' is emitted to start a new contour in an outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `move to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_MoveToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'move to' + * function during outline walking/decomposition. + * + * A 'move to' is emitted to start a new contour in an outline. + * + * @input: + * to :: + * A pointer to the target point of the 'move to'. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_MoveToFunc)( const FT_Vector* to, void* user ); @@ -496,26 +504,28 @@ FT_BEGIN_HEADER #define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_LineToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `line */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `line to' is emitted to indicate a segment in the outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `line to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_LineToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'line to' + * function during outline walking/decomposition. + * + * A 'line to' is emitted to indicate a segment in the outline. + * + * @input: + * to :: + * A pointer to the target point of the 'line to'. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_LineToFunc)( const FT_Vector* to, void* user ); @@ -523,30 +533,33 @@ FT_BEGIN_HEADER #define FT_Outline_LineTo_Func FT_Outline_LineToFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_ConicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `conic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `conic to' is emitted to indicate a second-order Bezier arc in */ - /* the outline. */ - /* */ - /* <Input> */ - /* control :: An intermediate control point between the last position */ - /* and the new target in `to'. */ - /* */ - /* to :: A pointer to the target end point of the conic arc. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_ConicToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'conic to' + * function during outline walking or decomposition. + * + * A 'conic to' is emitted to indicate a second-order Bezier arc in the + * outline. + * + * @input: + * control :: + * An intermediate control point between the last position and the new + * target in `to`. + * + * to :: + * A pointer to the target end point of the conic arc. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_ConicToFunc)( const FT_Vector* control, const FT_Vector* to, @@ -555,30 +568,34 @@ FT_BEGIN_HEADER #define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_CubicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `cubic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `cubic to' is emitted to indicate a third-order Bezier arc. */ - /* */ - /* <Input> */ - /* control1 :: A pointer to the first Bezier control point. */ - /* */ - /* control2 :: A pointer to the second Bezier control point. */ - /* */ - /* to :: A pointer to the target end point. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Outline_CubicToFunc + * + * @description: + * A function pointer type used to describe the signature of a 'cubic to' + * function during outline walking or decomposition. + * + * A 'cubic to' is emitted to indicate a third-order Bezier arc. + * + * @input: + * control1 :: + * A pointer to the first Bezier control point. + * + * control2 :: + * A pointer to the second Bezier control point. + * + * to :: + * A pointer to the target end point. + * + * user :: + * A typeless pointer, which is passed from the caller of the + * decomposition function. + * + * @return: + * Error code. 0~means success. + */ typedef int (*FT_Outline_CubicToFunc)( const FT_Vector* control1, const FT_Vector* control2, @@ -588,43 +605,49 @@ FT_BEGIN_HEADER #define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline_Funcs */ - /* */ - /* <Description> */ - /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Beziers. */ - /* */ - /* <Fields> */ - /* move_to :: The `move to' emitter. */ - /* */ - /* line_to :: The segment emitter. */ - /* */ - /* conic_to :: The second-order Bezier arc emitter. */ - /* */ - /* cubic_to :: The third-order Bezier arc emitter. */ - /* */ - /* shift :: The shift that is applied to coordinates before they */ - /* are sent to the emitter. */ - /* */ - /* delta :: The delta that is applied to coordinates before they */ - /* are sent to the emitter, but after the shift. */ - /* */ - /* <Note> */ - /* The point coordinates sent to the emitters are the transformed */ - /* version of the original coordinates (this is important for high */ - /* accuracy during scan-conversion). The transformation is simple: */ - /* */ - /* { */ - /* x' = (x << shift) - delta */ - /* y' = (y << shift) - delta */ - /* } */ - /* */ - /* Set the values of `shift' and `delta' to~0 to get the original */ - /* point coordinates. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Outline_Funcs + * + * @description: + * A structure to hold various function pointers used during outline + * decomposition in order to emit segments, conic, and cubic Beziers. + * + * @fields: + * move_to :: + * The 'move to' emitter. + * + * line_to :: + * The segment emitter. + * + * conic_to :: + * The second-order Bezier arc emitter. + * + * cubic_to :: + * The third-order Bezier arc emitter. + * + * shift :: + * The shift that is applied to coordinates before they are sent to the + * emitter. + * + * delta :: + * The delta that is applied to coordinates before they are sent to the + * emitter, but after the shift. + * + * @note: + * The point coordinates sent to the emitters are the transformed version + * of the original coordinates (this is important for high accuracy + * during scan-conversion). The transformation is simple: + * + * ``` + * x' = (x << shift) - delta + * y' = (y << shift) - delta + * ``` + * + * Set the values of `shift` and `delta` to~0 to get the original point + * coordinates. + */ typedef struct FT_Outline_Funcs_ { FT_Outline_MoveToFunc move_to; @@ -638,33 +661,32 @@ FT_BEGIN_HEADER } FT_Outline_Funcs; - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_IMAGE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags to an unsigned long type. */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ + /************************************************************************** + * + * @section: + * basic_types + * + */ + + + /************************************************************************** + * + * @macro: + * FT_IMAGE_TAG + * + * @description: + * This macro converts four-letter tags to an unsigned long type. + * + * @note: + * Since many 16-bit compilers don't like 32-bit enumerations, you should + * redefine this macro in case of problems to something like this: + * + * ``` + * #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value + * ``` + * + * to get a simple enumeration without assigning special numbers. + */ #ifndef FT_IMAGE_TAG #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ value = ( ( (unsigned long)_x1 << 24 ) | \ @@ -674,44 +696,43 @@ FT_BEGIN_HEADER #endif /* FT_IMAGE_TAG */ - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_Format */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of a given glyph */ - /* image. Note that this version of FreeType only supports two image */ - /* formats, even though future font drivers will be able to register */ - /* their own format. */ - /* */ - /* <Values> */ - /* FT_GLYPH_FORMAT_NONE :: */ - /* The value~0 is reserved. */ - /* */ - /* FT_GLYPH_FORMAT_COMPOSITE :: */ - /* The glyph image is a composite of several other images. This */ - /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */ - /* report compound glyphs (like accented characters). */ - /* */ - /* FT_GLYPH_FORMAT_BITMAP :: */ - /* The glyph image is a bitmap, and can be described as an */ - /* @FT_Bitmap. You generally need to access the `bitmap' field of */ - /* the @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_OUTLINE :: */ - /* The glyph image is a vectorial outline made of line segments */ - /* and Bezier arcs; it can be described as an @FT_Outline; you */ - /* generally want to access the `outline' field of the */ - /* @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_PLOTTER :: */ - /* The glyph image is a vectorial path with no inside and outside */ - /* contours. Some Type~1 fonts, like those in the Hershey family, */ - /* contain glyphs in this format. These are described as */ - /* @FT_Outline, but FreeType isn't currently capable of rendering */ - /* them correctly. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Glyph_Format + * + * @description: + * An enumeration type used to describe the format of a given glyph + * image. Note that this version of FreeType only supports two image + * formats, even though future font drivers will be able to register + * their own format. + * + * @values: + * FT_GLYPH_FORMAT_NONE :: + * The value~0 is reserved. + * + * FT_GLYPH_FORMAT_COMPOSITE :: + * The glyph image is a composite of several other images. This format + * is _only_ used with @FT_LOAD_NO_RECURSE, and is used to report + * compound glyphs (like accented characters). + * + * FT_GLYPH_FORMAT_BITMAP :: + * The glyph image is a bitmap, and can be described as an @FT_Bitmap. + * You generally need to access the `bitmap` field of the + * @FT_GlyphSlotRec structure to read it. + * + * FT_GLYPH_FORMAT_OUTLINE :: + * The glyph image is a vectorial outline made of line segments and + * Bezier arcs; it can be described as an @FT_Outline; you generally + * want to access the `outline` field of the @FT_GlyphSlotRec structure + * to read it. + * + * FT_GLYPH_FORMAT_PLOTTER :: + * The glyph image is a vectorial path with no inside and outside + * contours. Some Type~1 fonts, like those in the Hershey family, + * contain glyphs in this format. These are described as @FT_Outline, + * but FreeType isn't currently capable of rendering them correctly. + */ typedef enum FT_Glyph_Format_ { FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), @@ -725,7 +746,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `FT_Glyph_Format' values instead. */ + /* `FT_Glyph_Format` values instead. */ #define ft_glyph_format_none FT_GLYPH_FORMAT_NONE #define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE #define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP @@ -744,87 +765,89 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* A raster is a scan converter, in charge of rendering an outline into */ - /* a bitmap. This section contains the public API for rasters. */ - /* */ - /* Note that in FreeType 2, all rasters are now encapsulated within */ - /* specific modules called `renderers'. See `ftrender.h' for more */ - /* details on renderers. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* raster */ - /* */ - /* <Title> */ - /* Scanline Converter */ - /* */ - /* <Abstract> */ - /* How vectorial outlines are converted into bitmaps and pixmaps. */ - /* */ - /* <Description> */ - /* This section contains technical definitions. */ - /* */ - /* <Order> */ - /* FT_Raster */ - /* FT_Span */ - /* FT_SpanFunc */ - /* */ - /* FT_Raster_Params */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* FT_Raster_NewFunc */ - /* FT_Raster_DoneFunc */ - /* FT_Raster_ResetFunc */ - /* FT_Raster_SetModeFunc */ - /* FT_Raster_RenderFunc */ - /* FT_Raster_Funcs */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Raster */ - /* */ - /* <Description> */ - /* An opaque handle (pointer) to a raster object. Each object can be */ - /* used independently to convert an outline into a bitmap or pixmap. */ - /* */ + /************************************************************************** + * + * A raster is a scan converter, in charge of rendering an outline into a + * bitmap. This section contains the public API for rasters. + * + * Note that in FreeType 2, all rasters are now encapsulated within + * specific modules called 'renderers'. See `ftrender.h` for more details + * on renderers. + * + */ + + + /************************************************************************** + * + * @section: + * raster + * + * @title: + * Scanline Converter + * + * @abstract: + * How vectorial outlines are converted into bitmaps and pixmaps. + * + * @description: + * This section contains technical definitions. + * + * @order: + * FT_Raster + * FT_Span + * FT_SpanFunc + * + * FT_Raster_Params + * FT_RASTER_FLAG_XXX + * + * FT_Raster_NewFunc + * FT_Raster_DoneFunc + * FT_Raster_ResetFunc + * FT_Raster_SetModeFunc + * FT_Raster_RenderFunc + * FT_Raster_Funcs + * + */ + + + /************************************************************************** + * + * @type: + * FT_Raster + * + * @description: + * An opaque handle (pointer) to a raster object. Each object can be + * used independently to convert an outline into a bitmap or pixmap. + */ typedef struct FT_RasterRec_* FT_Raster; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Span */ - /* */ - /* <Description> */ - /* A structure used to model a single span of gray pixels when */ - /* rendering an anti-aliased bitmap. */ - /* */ - /* <Fields> */ - /* x :: The span's horizontal start position. */ - /* */ - /* len :: The span's length in pixels. */ - /* */ - /* coverage :: The span color/coverage, ranging from 0 (background) */ - /* to 255 (foreground). */ - /* */ - /* <Note> */ - /* This structure is used by the span drawing callback type named */ - /* @FT_SpanFunc that takes the y~coordinate of the span as a */ - /* parameter. */ - /* */ - /* The coverage value is always between 0 and 255. If you want less */ - /* gray values, the callback function has to reduce them. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Span + * + * @description: + * A structure used to model a single span of gray pixels when rendering + * an anti-aliased bitmap. + * + * @fields: + * x :: + * The span's horizontal start position. + * + * len :: + * The span's length in pixels. + * + * coverage :: + * The span color/coverage, ranging from 0 (background) to 255 + * (foreground). + * + * @note: + * This structure is used by the span drawing callback type named + * @FT_SpanFunc that takes the y~coordinate of the span as a parameter. + * + * The coverage value is always between 0 and 255. If you want less gray + * values, the callback function has to reduce them. + */ typedef struct FT_Span_ { short x; @@ -834,32 +857,36 @@ FT_BEGIN_HEADER } FT_Span; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_SpanFunc */ - /* */ - /* <Description> */ - /* A function used as a call-back by the anti-aliased renderer in */ - /* order to let client applications draw themselves the gray pixel */ - /* spans on each scan line. */ - /* */ - /* <Input> */ - /* y :: The scanline's y~coordinate. */ - /* */ - /* count :: The number of spans to draw on this scanline. */ - /* */ - /* spans :: A table of `count' spans to draw on the scanline. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* <Note> */ - /* This callback allows client applications to directly render the */ - /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ - /* */ - /* This can be used to write anti-aliased outlines directly to a */ - /* given background bitmap, and even perform translucency. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_SpanFunc + * + * @description: + * A function used as a call-back by the anti-aliased renderer in order + * to let client applications draw themselves the gray pixel spans on + * each scan line. + * + * @input: + * y :: + * The scanline's upward y~coordinate. + * + * count :: + * The number of spans to draw on this scanline. + * + * spans :: + * A table of `count` spans to draw on the scanline. + * + * user :: + * User-supplied data that is passed to the callback. + * + * @note: + * This callback allows client applications to directly render the gray + * spans of the anti-aliased bitmap to any kind of surfaces. + * + * This can be used to write anti-aliased outlines directly to a given + * background bitmap, and even perform translucency. + */ typedef void (*FT_SpanFunc)( int y, int count, @@ -869,131 +896,129 @@ FT_BEGIN_HEADER #define FT_Raster_Span_Func FT_SpanFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitTest_Func */ - /* */ - /* <Description> */ - /* Deprecated, unimplemented. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_BitTest_Func + * + * @description: + * Deprecated, unimplemented. + */ typedef int (*FT_Raster_BitTest_Func)( int y, int x, void* user ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitSet_Func */ - /* */ - /* <Description> */ - /* Deprecated, unimplemented. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_BitSet_Func + * + * @description: + * Deprecated, unimplemented. + */ typedef void (*FT_Raster_BitSet_Func)( int y, int x, void* user ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flag constants as used in the `flags' field of a */ - /* @FT_Raster_Params structure. */ - /* */ - /* <Values> */ - /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ - /* */ - /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ - /* anti-aliased glyph image should be */ - /* generated. Otherwise, it will be */ - /* monochrome (1-bit). */ - /* */ - /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ - /* rendering. In this mode, client */ - /* applications must provide their own span */ - /* callback. This lets them directly */ - /* draw or compose over an existing bitmap. */ - /* If this bit is not set, the target */ - /* pixmap's buffer _must_ be zeroed before */ - /* rendering. */ - /* */ - /* Direct rendering is only possible with */ - /* anti-aliased glyphs. */ - /* */ - /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ - /* rendering mode. If set, the output will */ - /* be clipped to a box specified in the */ - /* `clip_box' field of the */ - /* @FT_Raster_Params structure. */ - /* */ - /* Note that by default, the glyph bitmap */ - /* is clipped to the target pixmap, except */ - /* in direct rendering mode where all spans */ - /* are generated if no clipping box is set. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_RASTER_FLAG_XXX + * + * @description: + * A list of bit flag constants as used in the `flags` field of a + * @FT_Raster_Params structure. + * + * @values: + * FT_RASTER_FLAG_DEFAULT :: + * This value is 0. + * + * FT_RASTER_FLAG_AA :: + * This flag is set to indicate that an anti-aliased glyph image should + * be generated. Otherwise, it will be monochrome (1-bit). + * + * FT_RASTER_FLAG_DIRECT :: + * This flag is set to indicate direct rendering. In this mode, client + * applications must provide their own span callback. This lets them + * directly draw or compose over an existing bitmap. If this bit is + * _not_ set, the target pixmap's buffer _must_ be zeroed before + * rendering and the output will be clipped to its size. + * + * Direct rendering is only possible with anti-aliased glyphs. + * + * FT_RASTER_FLAG_CLIP :: + * This flag is only used in direct rendering mode. If set, the output + * will be clipped to a box specified in the `clip_box` field of the + * @FT_Raster_Params structure. Otherwise, the `clip_box` is + * effectively set to the bounding box and all spans are generated. + */ #define FT_RASTER_FLAG_DEFAULT 0x0 #define FT_RASTER_FLAG_AA 0x1 #define FT_RASTER_FLAG_DIRECT 0x2 #define FT_RASTER_FLAG_CLIP 0x4 /* these constants are deprecated; use the corresponding */ - /* `FT_RASTER_FLAG_XXX' values instead */ + /* `FT_RASTER_FLAG_XXX` values instead */ #define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT #define ft_raster_flag_aa FT_RASTER_FLAG_AA #define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT #define ft_raster_flag_clip FT_RASTER_FLAG_CLIP - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Params */ - /* */ - /* <Description> */ - /* A structure to hold the arguments used by a raster's render */ - /* function. */ - /* */ - /* <Fields> */ - /* target :: The target bitmap. */ - /* */ - /* source :: A pointer to the source glyph image (e.g., an */ - /* @FT_Outline). */ - /* */ - /* flags :: The rendering flags. */ - /* */ - /* gray_spans :: The gray span drawing callback. */ - /* */ - /* black_spans :: Unused. */ - /* */ - /* bit_test :: Unused. */ - /* */ - /* bit_set :: Unused. */ - /* */ - /* user :: User-supplied data that is passed to each drawing */ - /* callback. */ - /* */ - /* clip_box :: An optional clipping box. It is only used in */ - /* direct rendering mode. Note that coordinates here */ - /* should be expressed in _integer_ pixels (and not in */ - /* 26.6 fixed-point units). */ - /* */ - /* <Note> */ - /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ - /* bit flag is set in the `flags' field, otherwise a monochrome */ - /* bitmap is generated. */ - /* */ - /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ - /* raster will call the `gray_spans' callback to draw gray pixel */ - /* spans. This allows direct composition over a pre-existing bitmap */ - /* through user-provided callbacks to perform the span drawing and */ - /* composition. Not supported by the monochrome rasterizer. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Raster_Params + * + * @description: + * A structure to hold the parameters used by a raster's render function, + * passed as an argument to @FT_Outline_Render. + * + * @fields: + * target :: + * The target bitmap. + * + * source :: + * A pointer to the source glyph image (e.g., an @FT_Outline). + * + * flags :: + * The rendering flags. + * + * gray_spans :: + * The gray span drawing callback. + * + * black_spans :: + * Unused. + * + * bit_test :: + * Unused. + * + * bit_set :: + * Unused. + * + * user :: + * User-supplied data that is passed to each drawing callback. + * + * clip_box :: + * An optional clipping box. It is only used in direct rendering mode. + * Note that coordinates here should be expressed in _integer_ pixels + * (and not in 26.6 fixed-point units). + * + * @note: + * An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA bit + * flag is set in the `flags` field, otherwise a monochrome bitmap is + * generated. + * + * If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags`, the raster + * will call the `gray_spans` callback to draw gray pixel spans. This + * allows direct composition over a pre-existing bitmap through + * user-provided callbacks to perform the span drawing and composition. + * Not supported by the monochrome rasterizer. + */ typedef struct FT_Raster_Params_ { const FT_Bitmap* target; @@ -1009,30 +1034,32 @@ FT_BEGIN_HEADER } FT_Raster_Params; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_NewFunc */ - /* */ - /* <Description> */ - /* A function used to create a new raster object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory allocator. */ - /* */ - /* <Output> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `memory' parameter is a typeless pointer in order to avoid */ - /* un-wanted dependencies on the rest of the FreeType code. In */ - /* practice, it is an @FT_Memory object, i.e., a handle to the */ - /* standard FreeType memory allocator. However, this field can be */ - /* completely ignored by a given raster implementation. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_NewFunc + * + * @description: + * A function used to create a new raster object. + * + * @input: + * memory :: + * A handle to the memory allocator. + * + * @output: + * raster :: + * A handle to the new raster object. + * + * @return: + * Error code. 0~means success. + * + * @note: + * The `memory` parameter is a typeless pointer in order to avoid + * un-wanted dependencies on the rest of the FreeType code. In practice, + * it is an @FT_Memory object, i.e., a handle to the standard FreeType + * memory allocator. However, this field can be completely ignored by a + * given raster implementation. + */ typedef int (*FT_Raster_NewFunc)( void* memory, FT_Raster* raster ); @@ -1040,49 +1067,52 @@ FT_BEGIN_HEADER #define FT_Raster_New_Func FT_Raster_NewFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_DoneFunc */ - /* */ - /* <Description> */ - /* A function used to destroy a given raster object. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_DoneFunc + * + * @description: + * A function used to destroy a given raster object. + * + * @input: + * raster :: + * A handle to the raster object. + */ typedef void (*FT_Raster_DoneFunc)( FT_Raster raster ); #define FT_Raster_Done_Func FT_Raster_DoneFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_ResetFunc */ - /* */ - /* <Description> */ - /* FreeType used to provide an area of memory called the `render */ - /* pool' available to all registered rasterizers. This was not */ - /* thread safe, however, and now FreeType never allocates this pool. */ - /* */ - /* This function is called after a new raster object is created. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* pool_base :: Previously, the address in memory of the render pool. */ - /* Set this to NULL. */ - /* */ - /* pool_size :: Previously, the size in bytes of the render pool. */ - /* Set this to 0. */ - /* */ - /* <Note> */ - /* Rasterizers should rely on dynamic or stack allocation if they */ - /* want to (a handle to the memory allocator is passed to the */ - /* rasterizer constructor). */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_ResetFunc + * + * @description: + * FreeType used to provide an area of memory called the 'render pool' + * available to all registered rasterizers. This was not thread safe, + * however, and now FreeType never allocates this pool. + * + * This function is called after a new raster object is created. + * + * @input: + * raster :: + * A handle to the new raster object. + * + * pool_base :: + * Previously, the address in memory of the render pool. Set this to + * `NULL`. + * + * pool_size :: + * Previously, the size in bytes of the render pool. Set this to 0. + * + * @note: + * Rasterizers should rely on dynamic or stack allocation if they want to + * (a handle to the memory allocator is passed to the rasterizer + * constructor). + */ typedef void (*FT_Raster_ResetFunc)( FT_Raster raster, unsigned char* pool_base, @@ -1091,24 +1121,26 @@ FT_BEGIN_HEADER #define FT_Raster_Reset_Func FT_Raster_ResetFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_SetModeFunc */ - /* */ - /* <Description> */ - /* This function is a generic facility to change modes or attributes */ - /* in a given raster. This can be used for debugging purposes, or */ - /* simply to allow implementation-specific `features' in a given */ - /* raster module. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* mode :: A 4-byte tag used to name the mode or property. */ - /* */ - /* args :: A pointer to the new mode/property to use. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_SetModeFunc + * + * @description: + * This function is a generic facility to change modes or attributes in a + * given raster. This can be used for debugging purposes, or simply to + * allow implementation-specific 'features' in a given raster module. + * + * @input: + * raster :: + * A handle to the new raster object. + * + * mode :: + * A 4-byte tag used to name the mode or property. + * + * args :: + * A pointer to the new mode/property to use. + */ typedef int (*FT_Raster_SetModeFunc)( FT_Raster raster, unsigned long mode, @@ -1117,40 +1149,36 @@ FT_BEGIN_HEADER #define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_RenderFunc */ - /* */ - /* <Description> */ - /* Invoke a given raster to scan-convert a given glyph image into a */ - /* target bitmap. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* store the rendering parameters. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The exact format of the source image depends on the raster's glyph */ - /* format defined in its @FT_Raster_Funcs structure. It can be an */ - /* @FT_Outline or anything else in order to support a large array of */ - /* glyph formats. */ - /* */ - /* Note also that the render function can fail and return a */ - /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ - /* not support direct composition. */ - /* */ - /* XXX: For now, the standard raster doesn't support direct */ - /* composition but this should change for the final release (see */ - /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ - /* for examples of distinct implementations that support direct */ - /* composition). */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Raster_RenderFunc + * + * @description: + * Invoke a given raster to scan-convert a given glyph image into a + * target bitmap. + * + * @input: + * raster :: + * A handle to the raster object. + * + * params :: + * A pointer to an @FT_Raster_Params structure used to store the + * rendering parameters. + * + * @return: + * Error code. 0~means success. + * + * @note: + * The exact format of the source image depends on the raster's glyph + * format defined in its @FT_Raster_Funcs structure. It can be an + * @FT_Outline or anything else in order to support a large array of + * glyph formats. + * + * Note also that the render function can fail and return a + * `FT_Err_Unimplemented_Feature` error code if the raster used does not + * support direct composition. + */ typedef int (*FT_Raster_RenderFunc)( FT_Raster raster, const FT_Raster_Params* params ); @@ -1158,25 +1186,30 @@ FT_BEGIN_HEADER #define FT_Raster_Render_Func FT_Raster_RenderFunc - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Funcs */ - /* */ - /* <Description> */ - /* A structure used to describe a given raster class to the library. */ - /* */ - /* <Fields> */ - /* glyph_format :: The supported glyph format for this raster. */ - /* */ - /* raster_new :: The raster constructor. */ - /* */ - /* raster_reset :: Used to reset the render pool within the raster. */ - /* */ - /* raster_render :: A function to render a glyph into a given bitmap. */ - /* */ - /* raster_done :: The raster destructor. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Raster_Funcs + * + * @description: + * A structure used to describe a given raster class to the library. + * + * @fields: + * glyph_format :: + * The supported glyph format for this raster. + * + * raster_new :: + * The raster constructor. + * + * raster_reset :: + * Used to reset the render pool within the raster. + * + * raster_render :: + * A function to render a glyph into a given bitmap. + * + * raster_done :: + * The raster destructor. + */ typedef struct FT_Raster_Funcs_ { FT_Glyph_Format glyph_format; diff --git a/src/3rdparty/freetype/include/freetype/ftincrem.h b/src/3rdparty/freetype/include/freetype/ftincrem.h index 44619f941e..a4db02b585 100644 --- a/src/3rdparty/freetype/include/freetype/ftincrem.h +++ b/src/3rdparty/freetype/include/freetype/ftincrem.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftincrem.h */ -/* */ -/* FreeType incremental loading (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftincrem.h + * + * FreeType incremental loading (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTINCREM_H_ @@ -32,7 +32,7 @@ FT_BEGIN_HEADER - /*************************************************************************** + /************************************************************************** * * @section: * incremental @@ -45,7 +45,7 @@ FT_BEGIN_HEADER * * @description: * This section contains various functions used to perform so-called - * `incremental' glyph loading. This is a mode where all glyphs loaded + * 'incremental' glyph loading. This is a mode where all glyphs loaded * from a given @FT_Face are provided by the client application. * * Apart from that, all other tables are loaded normally from the font @@ -60,23 +60,24 @@ FT_BEGIN_HEADER */ - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental * * @description: * An opaque type describing a user-provided object used to implement - * `incremental' glyph loading within FreeType. This is used to support - * embedded fonts in certain environments (e.g., PostScript interpreters), - * where the glyph data isn't in the font file, or must be overridden by - * different values. + * 'incremental' glyph loading within FreeType. This is used to support + * embedded fonts in certain environments (e.g., PostScript + * interpreters), where the glyph data isn't in the font file, or must be + * overridden by different values. * * @note: - * It is up to client applications to create and implement @FT_Incremental - * objects, as long as they provide implementations for the methods - * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc - * and @FT_Incremental_GetGlyphMetricsFunc. + * It is up to client applications to create and implement + * @FT_Incremental objects, as long as they provide implementations for + * the methods @FT_Incremental_GetGlyphDataFunc, + * @FT_Incremental_FreeGlyphDataFunc and + * @FT_Incremental_GetGlyphMetricsFunc. * * See the description of @FT_Incremental_InterfaceRec to understand how * to use incremental objects with FreeType. @@ -85,14 +86,14 @@ FT_BEGIN_HEADER typedef struct FT_IncrementalRec_* FT_Incremental; - /*************************************************************************** + /************************************************************************** * * @struct: * FT_Incremental_MetricsRec * * @description: - * A small structure used to contain the basic glyph metrics returned - * by the @FT_Incremental_GetGlyphMetricsFunc method. + * A small structure used to contain the basic glyph metrics returned by + * the @FT_Incremental_GetGlyphMetricsFunc method. * * @fields: * bearing_x :: @@ -109,7 +110,7 @@ FT_BEGIN_HEADER * * @note: * These correspond to horizontal or vertical metrics depending on the - * value of the `vertical' argument to the function + * value of the `vertical` argument to the function * @FT_Incremental_GetGlyphMetricsFunc. * */ @@ -123,7 +124,7 @@ FT_BEGIN_HEADER } FT_Incremental_MetricsRec; - /*************************************************************************** + /************************************************************************** * * @struct: * FT_Incremental_Metrics @@ -135,7 +136,7 @@ FT_BEGIN_HEADER typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_GetGlyphDataFunc @@ -147,8 +148,8 @@ FT_BEGIN_HEADER * * Note that the format of the glyph's data bytes depends on the font * file format. For TrueType, it must correspond to the raw bytes within - * the `glyf' table. For PostScript formats, it must correspond to the - * *unencrypted* charstring bytes, without any `lenIV' header. It is + * the 'glyf' table. For PostScript formats, it must correspond to the + * **unencrypted** charstring bytes, without any `lenIV` header. It is * undefined for any other format. * * @input: @@ -169,8 +170,8 @@ FT_BEGIN_HEADER * * @note: * If this function returns successfully the method - * @FT_Incremental_FreeGlyphDataFunc will be called later to release - * the data bytes. + * @FT_Incremental_FreeGlyphDataFunc will be called later to release the + * data bytes. * * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for * compound glyphs. @@ -182,7 +183,7 @@ FT_BEGIN_HEADER FT_Data* adata ); - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_FreeGlyphDataFunc @@ -206,7 +207,7 @@ FT_BEGIN_HEADER FT_Data* data ); - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_GetGlyphMetricsFunc @@ -214,8 +215,8 @@ FT_BEGIN_HEADER * @description: * A function used to retrieve the basic metrics of a given glyph index * before accessing its data. This is necessary because, in certain - * formats like TrueType, the metrics are stored in a different place from - * the glyph images proper. + * formats like TrueType, the metrics are stored in a different place + * from the glyph images proper. * * @input: * incremental :: @@ -229,9 +230,9 @@ FT_BEGIN_HEADER * If true, return vertical metrics. * * ametrics :: - * This parameter is used for both input and output. - * The original glyph metrics, if any, in font units. If metrics are - * not available all the values must be set to zero. + * This parameter is used for both input and output. The original + * glyph metrics, if any, in font units. If metrics are not available + * all the values must be set to zero. * * @output: * ametrics :: @@ -252,8 +253,8 @@ FT_BEGIN_HEADER * FT_Incremental_FuncsRec * * @description: - * A table of functions for accessing fonts that load data - * incrementally. Used in @FT_Incremental_InterfaceRec. + * A table of functions for accessing fonts that load data incrementally. + * Used in @FT_Incremental_InterfaceRec. * * @fields: * get_glyph_data :: @@ -263,8 +264,8 @@ FT_BEGIN_HEADER * The function to release glyph data. Must not be null. * * get_glyph_metrics :: - * The function to get glyph metrics. May be null if the font does - * not provide overriding glyph metrics. + * The function to get glyph metrics. May be null if the font does not + * provide overriding glyph metrics. * */ typedef struct FT_Incremental_FuncsRec_ @@ -276,7 +277,7 @@ FT_BEGIN_HEADER } FT_Incremental_FuncsRec; - /*************************************************************************** + /************************************************************************** * * @struct: * FT_Incremental_InterfaceRec @@ -286,30 +287,30 @@ FT_BEGIN_HEADER * wants to support incremental glyph loading. You should use it with * @FT_PARAM_TAG_INCREMENTAL as in the following example: * - * { - * FT_Incremental_InterfaceRec inc_int; - * FT_Parameter parameter; - * FT_Open_Args open_args; + * ``` + * FT_Incremental_InterfaceRec inc_int; + * FT_Parameter parameter; + * FT_Open_Args open_args; * * - * // set up incremental descriptor - * inc_int.funcs = my_funcs; - * inc_int.object = my_object; + * // set up incremental descriptor + * inc_int.funcs = my_funcs; + * inc_int.object = my_object; * - * // set up optional parameter - * parameter.tag = FT_PARAM_TAG_INCREMENTAL; - * parameter.data = &inc_int; + * // set up optional parameter + * parameter.tag = FT_PARAM_TAG_INCREMENTAL; + * parameter.data = &inc_int; * - * // set up FT_Open_Args structure - * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; - * open_args.pathname = my_font_pathname; - * open_args.num_params = 1; - * open_args.params = ¶meter; // we use one optional argument + * // set up FT_Open_Args structure + * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; + * open_args.pathname = my_font_pathname; + * open_args.num_params = 1; + * open_args.params = ¶meter; // we use one optional argument * - * // open the font - * error = FT_Open_Face( library, &open_args, index, &face ); - * ... - * } + * // open the font + * error = FT_Open_Face( library, &open_args, index, &face ); + * ... + * ``` * */ typedef struct FT_Incremental_InterfaceRec_ @@ -320,7 +321,7 @@ FT_BEGIN_HEADER } FT_Incremental_InterfaceRec; - /*************************************************************************** + /************************************************************************** * * @type: * FT_Incremental_Interface diff --git a/src/3rdparty/freetype/include/freetype/ftlcdfil.h b/src/3rdparty/freetype/include/freetype/ftlcdfil.h index 2a27196cbb..3a19d043bb 100644 --- a/src/3rdparty/freetype/include/freetype/ftlcdfil.h +++ b/src/3rdparty/freetype/include/freetype/ftlcdfil.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftlcdfil.h */ -/* */ -/* FreeType API for color filtering of subpixel bitmap glyphs */ -/* (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftlcdfil.h + * + * FreeType API for color filtering of subpixel bitmap glyphs + * (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTLCDFIL_H_ @@ -33,105 +33,98 @@ FT_BEGIN_HEADER - /*************************************************************************** + /************************************************************************** * * @section: - * lcd_filtering + * lcd_rendering * * @title: - * LCD Filtering + * Subpixel Rendering * * @abstract: - * Reduce color fringes of subpixel-rendered bitmaps. + * API to control subpixel rendering. * * @description: - * Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your - * `ftoption.h', which enables patented ClearType-style rendering, - * the LCD-optimized glyph bitmaps should be filtered to reduce color - * fringes inherent to this technology. The default FreeType LCD - * rendering uses different technology, and API described below, - * although available, does nothing. + * FreeType provides two alternative subpixel rendering technologies. + * Should you define `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` in your + * `ftoption.h` file, this enables patented ClearType-style rendering. + * Otherwise, Harmony LCD rendering is enabled. These technologies are + * controlled differently and API described below, although always + * available, performs its function when appropriate method is enabled + * and does nothing otherwise. * * ClearType-style LCD rendering exploits the color-striped structure of * LCD pixels, increasing the available resolution in the direction of - * the stripe (usually horizontal RGB) by a factor of~3. Since these - * subpixels are color pixels, using them unfiltered creates severe - * color fringes. Use the @FT_Library_SetLcdFilter API to specify a - * low-pass filter, which is then applied to subpixel-rendered bitmaps - * generated through @FT_Render_Glyph. The filter sacrifices some of - * the higher resolution to reduce color fringes, making the glyph image - * slightly blurrier. Positional improvements will remain. - * - * A filter should have two properties: - * - * 1) It should be normalized, meaning the sum of the 5~components - * should be 256 (0x100). It is possible to go above or under this - * target sum, however: going under means tossing out contrast, going - * over means invoking clamping and thereby non-linearities that - * increase contrast somewhat at the expense of greater distortion - * and color-fringing. Contrast is better enhanced through stem - * darkening. - * - * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}' - * where a~+ b~=~c. It distributes the computed coverage for one - * subpixel to all subpixels equally, sacrificing some won resolution - * but drastically reducing color-fringing. Positioning improvements - * remain! Note that color-fringing can only really be minimized - * when using a color-balanced filter and alpha-blending the glyph - * onto a surface in linear space; see @FT_Render_Glyph. - * - * Regarding the form, a filter can be a `boxy' filter or a `beveled' - * filter. Boxy filters are sharper but are less forgiving of non-ideal - * gamma curves of a screen (viewing angles!), beveled filters are - * fuzzier but more tolerant. - * - * Examples: - * - * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor - * normalized. - * - * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not - * normalized. - * - * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not - * balanced. - * - * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not - * balanced. - * - * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost - * balanced. - * - * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost - * balanced. - * - * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, - * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output - * of @FT_Outline_Render and @FT_Outline_Get_Bitmap. - * - * If this feature is activated, the dimensions of LCD glyph bitmaps are - * either wider or taller than the dimensions of the corresponding - * outline with regard to the pixel grid. For example, for - * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and - * 3~subpixels to the right. The bitmap offset values are adjusted - * accordingly, so clients shouldn't need to modify their layout and - * glyph positioning code when enabling the filter. - * - * It is important to understand that linear alpha blending and gamma - * correction is critical for correctly rendering glyphs onto surfaces - * without artifacts and even more critical when subpixel rendering is - * involved. - * - * Each of the 3~alpha values (subpixels) is independently used to blend - * one color channel. That is, red alpha blends the red channel of the - * text color with the red channel of the background pixel. The - * distribution of density values by the color-balanced filter assumes - * alpha blending is done in linear space; only then color artifacts - * cancel out. + * the stripe (usually horizontal RGB) by a factor of~3. Using the + * subpixels coverages unfiltered can create severe color fringes + * especially when rendering thin features. Indeed, to produce + * black-on-white text, the nearby color subpixels must be dimmed + * equally. + * + * A good 5-tap FIR filter should be applied to subpixel coverages + * regardless of pixel boundaries and should have these properties: + * + * 1. It should be symmetrical, like {~a, b, c, b, a~}, to avoid + * any shifts in appearance. + * + * 2. It should be color-balanced, meaning a~+ b~=~c, to reduce color + * fringes by distributing the computed coverage for one subpixel to + * all subpixels equally. + * + * 3. It should be normalized, meaning 2a~+ 2b~+ c~=~1.0 to maintain + * overall brightness. + * + * Boxy 3-tap filter {0, 1/3, 1/3, 1/3, 0} is sharper but is less + * forgiving of non-ideal gamma curves of a screen (and viewing angles), + * beveled filters are fuzzier but more tolerant. + * + * Use the @FT_Library_SetLcdFilter or @FT_Library_SetLcdFilterWeights + * API to specify a low-pass filter, which is then applied to + * subpixel-rendered bitmaps generated through @FT_Render_Glyph. + * + * Harmony LCD rendering is suitable to panels with any regular subpixel + * structure, not just monitors with 3 color striped subpixels, as long + * as the color subpixels have fixed positions relative to the pixel + * center. In this case, each color channel is then rendered separately + * after shifting the outline opposite to the subpixel shift so that the + * coverage maps are aligned. This method is immune to color fringes + * because the shifts do not change integral coverage. + * + * The subpixel geometry must be specified by xy-coordinates for each + * subpixel. By convention they may come in the RGB order: {{-1/3, 0}, + * {0, 0}, {1/3, 0}} for standard RGB striped panel or {{-1/6, 1/4}, + * {-1/6, -1/4}, {1/3, 0}} for a certain PenTile panel. + * + * Use the @FT_Library_SetLcdGeometry API to specify subpixel positions. + * If one follows the RGB order convention, the same order applies to the + * resulting @FT_PIXEL_MODE_LCD and @FT_PIXEL_MODE_LCD_V bitmaps. Note, + * however, that the coordinate frame for the latter must be rotated + * clockwise. Harmony with default LCD geometry is equivalent to + * ClearType with light filter. + * + * As a result of ClearType filtering or Harmony rendering, the + * dimensions of LCD bitmaps can be either wider or taller than the + * dimensions of the corresponding outline with regard to the pixel grid. + * For example, for @FT_RENDER_MODE_LCD, the filter adds 2~subpixels to + * the left, and 2~subpixels to the right. The bitmap offset values are + * adjusted accordingly, so clients shouldn't need to modify their layout + * and glyph positioning code when enabling the filter. + * + * The ClearType and Harmony rendering is applicable to glyph bitmaps + * rendered through @FT_Render_Glyph, @FT_Load_Glyph, @FT_Load_Char, and + * @FT_Glyph_To_Bitmap, when @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V + * is specified. This API does not control @FT_Outline_Render and + * @FT_Outline_Get_Bitmap. + * + * The described algorithms can completely remove color artefacts when + * combined with gamma-corrected alpha blending in linear space. Each of + * the 3~alpha values (subpixels) must by independently used to blend one + * color channel. That is, red alpha blends the red channel of the text + * color with the red channel of the background pixel. */ - /**************************************************************************** + /************************************************************************** * * @enum: * FT_LcdFilter @@ -145,47 +138,25 @@ FT_BEGIN_HEADER * results in sometimes severe color fringes. * * FT_LCD_FILTER_DEFAULT :: - * The default filter reduces color fringes considerably, at the cost - * of a slight blurriness in the output. - * - * It is a beveled, normalized, and color-balanced five-tap filter - * that is more forgiving to screens with non-ideal gamma curves and - * viewing angles. Note that while color-fringing is reduced, it can - * only be minimized by using linear alpha blending and gamma - * correction to render glyphs onto surfaces. The default filter - * weights are [0x08 0x4D 0x56 0x4D 0x08]. + * This is a beveled, normalized, and color-balanced five-tap filter + * with weights of [0x08 0x4D 0x56 0x4D 0x08] in 1/256th units. * * FT_LCD_FILTER_LIGHT :: - * The light filter is a variant that is sharper at the cost of - * slightly more color fringes than the default one. - * - * It is a boxy, normalized, and color-balanced three-tap filter that - * is less forgiving to screens with non-ideal gamma curves and - * viewing angles. This filter works best when the rendering system - * uses linear alpha blending and gamma correction to render glyphs - * onto surfaces. The light filter weights are - * [0x00 0x55 0x56 0x55 0x00]. + * this is a boxy, normalized, and color-balanced three-tap filter with + * weights of [0x00 0x55 0x56 0x55 0x00] in 1/256th units. * * FT_LCD_FILTER_LEGACY :: + * FT_LCD_FILTER_LEGACY1 :: * This filter corresponds to the original libXft color filter. It * provides high contrast output but can exhibit really bad color * fringes if glyphs are not extremely well hinted to the pixel grid. - * In other words, it only works well if the TrueType bytecode - * interpreter is enabled *and* high-quality hinted fonts are used. - * * This filter is only provided for comparison purposes, and might be - * disabled or stay unsupported in the future. - * - * FT_LCD_FILTER_LEGACY1 :: - * For historical reasons, the FontConfig library returns a different - * enumeration value for legacy LCD filtering. To make code work that - * (incorrectly) forwards FontConfig's enumeration value to - * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest - * to have another enumeration value, which is completely equal to - * `FT_LCD_FILTER_LEGACY'. + * disabled or stay unsupported in the future. The second value is + * provided for compatibility with FontConfig, which historically used + * different enumeration, sometimes incorrectly forwarded to FreeType. * * @since: - * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2) + * 2.3.0 (`FT_LCD_FILTER_LEGACY1` since 2.6.2) */ typedef enum FT_LcdFilter_ { @@ -202,7 +173,7 @@ FT_BEGIN_HEADER /************************************************************************** * - * @func: + * @function: * FT_Library_SetLcdFilter * * @description: @@ -218,20 +189,20 @@ FT_BEGIN_HEADER * The filter type. * * You can use @FT_LCD_FILTER_NONE here to disable this feature, or - * @FT_LCD_FILTER_DEFAULT to use a default filter that should work - * well on most LCD screens. + * @FT_LCD_FILTER_DEFAULT to use a default filter that should work well + * on most LCD screens. * * @return: * FreeType error code. 0~means success. * * @note: * This feature is always disabled by default. Clients must make an - * explicit call to this function with a `filter' value other than + * explicit call to this function with a `filter` value other than * @FT_LCD_FILTER_NONE in order to enable it. * - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * Due to **PATENTS** covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature` if the + * configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is not * defined in your build of the library, which should correspond to all * default builds of FreeType. * @@ -245,7 +216,7 @@ FT_BEGIN_HEADER /************************************************************************** * - * @func: + * @function: * FT_Library_SetLcdFilterWeights * * @description: @@ -258,15 +229,15 @@ FT_BEGIN_HEADER * * weights :: * A pointer to an array; the function copies the first five bytes and - * uses them to specify the filter weights. + * uses them to specify the filter weights in 1/256th units. * * @return: * FreeType error code. 0~means success. * * @note: - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not + * Due to **PATENTS** covering subpixel rendering, this function doesn't + * do anything except returning `FT_Err_Unimplemented_Feature` if the + * configuration macro `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is not * defined in your build of the library, which should correspond to all * default builds of FreeType. * @@ -281,7 +252,8 @@ FT_BEGIN_HEADER unsigned char *weights ); - /* + /************************************************************************** + * * @type: * FT_LcdFiveTapFilter * @@ -298,6 +270,53 @@ FT_BEGIN_HEADER typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS]; + /************************************************************************** + * + * @function: + * FT_Library_SetLcdGeometry + * + * @description: + * This function can be used to modify default positions of color + * subpixels, which controls Harmony LCD rendering. + * + * @input: + * library :: + * A handle to the target library instance. + * + * sub :: + * A pointer to an array of 3 vectors in 26.6 fractional pixel format; + * the function modifies the default values, see the note below. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Subpixel geometry examples: + * + * - {{-21, 0}, {0, 0}, {21, 0}} is the default, corresponding to 3 color + * stripes shifted by a third of a pixel. This could be an RGB panel. + * + * - {{21, 0}, {0, 0}, {-21, 0}} looks the same as the default but can + * specify a BGR panel instead, while keeping the bitmap in the same + * RGB888 format. + * + * - {{0, 21}, {0, 0}, {0, -21}} is the vertical RGB, but the bitmap + * stays RGB888 as a result. + * + * - {{-11, 16}, {-11, -16}, {22, 0}} is a certain PenTile arrangement. + * + * This function does nothing and returns `FT_Err_Unimplemented_Feature` + * in the context of ClearType-style subpixel rendering when + * `FT_CONFIG_OPTION_SUBPIXEL_RENDERING` is defined in your build of the + * library. + * + * @since: + * 2.10.0 + */ + FT_EXPORT( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector sub[3] ); + /* */ diff --git a/src/3rdparty/freetype/include/freetype/ftlist.h b/src/3rdparty/freetype/include/freetype/ftlist.h index 117473b96a..4782892d1a 100644 --- a/src/3rdparty/freetype/include/freetype/ftlist.h +++ b/src/3rdparty/freetype/include/freetype/ftlist.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftlist.h */ -/* */ -/* Generic list support for FreeType (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype.h'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftlist.h + * + * Generic list support for FreeType (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file implements functions relative to list processing. Its data + * structures are defined in `freetype.h`. + * + */ #ifndef FTLIST_H_ @@ -41,224 +41,245 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /* <Title> */ - /* List Processing */ - /* */ - /* <Abstract> */ - /* Simple management of lists. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to list */ - /* processing using doubly-linked nodes. */ - /* */ - /* <Order> */ - /* FT_List */ - /* FT_ListNode */ - /* FT_ListRec */ - /* FT_ListNodeRec */ - /* */ - /* FT_List_Add */ - /* FT_List_Insert */ - /* FT_List_Find */ - /* FT_List_Remove */ - /* FT_List_Up */ - /* FT_List_Iterate */ - /* FT_List_Iterator */ - /* FT_List_Finalize */ - /* FT_List_Destructor */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Find */ - /* */ - /* <Description> */ - /* Find the list node for a given listed object. */ - /* */ - /* <Input> */ - /* list :: A pointer to the parent list. */ - /* data :: The address of the listed object. */ - /* */ - /* <Return> */ - /* List node. NULL if it wasn't found. */ - /* */ + /************************************************************************** + * + * @section: + * list_processing + * + * @title: + * List Processing + * + * @abstract: + * Simple management of lists. + * + * @description: + * This section contains various definitions related to list processing + * using doubly-linked nodes. + * + * @order: + * FT_List + * FT_ListNode + * FT_ListRec + * FT_ListNodeRec + * + * FT_List_Add + * FT_List_Insert + * FT_List_Find + * FT_List_Remove + * FT_List_Up + * FT_List_Iterate + * FT_List_Iterator + * FT_List_Finalize + * FT_List_Destructor + * + */ + + + /************************************************************************** + * + * @function: + * FT_List_Find + * + * @description: + * Find the list node for a given listed object. + * + * @input: + * list :: + * A pointer to the parent list. + * data :: + * The address of the listed object. + * + * @return: + * List node. `NULL` if it wasn't found. + */ FT_EXPORT( FT_ListNode ) FT_List_Find( FT_List list, void* data ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Add */ - /* */ - /* <Description> */ - /* Append an element to the end of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to append. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Add + * + * @description: + * Append an element to the end of a list. + * + * @inout: + * list :: + * A pointer to the parent list. + * node :: + * The node to append. + */ FT_EXPORT( void ) FT_List_Add( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Insert */ - /* */ - /* <Description> */ - /* Insert an element at the head of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to parent list. */ - /* node :: The node to insert. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Insert + * + * @description: + * Insert an element at the head of a list. + * + * @inout: + * list :: + * A pointer to parent list. + * node :: + * The node to insert. + */ FT_EXPORT( void ) FT_List_Insert( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Remove */ - /* */ - /* <Description> */ - /* Remove a node from a list. This function doesn't check whether */ - /* the node is in the list! */ - /* */ - /* <Input> */ - /* node :: The node to remove. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Remove + * + * @description: + * Remove a node from a list. This function doesn't check whether the + * node is in the list! + * + * @input: + * node :: + * The node to remove. + * + * @inout: + * list :: + * A pointer to the parent list. + */ FT_EXPORT( void ) FT_List_Remove( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Up */ - /* */ - /* <Description> */ - /* Move a node to the head/top of a list. Used to maintain LRU */ - /* lists. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to move. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Up + * + * @description: + * Move a node to the head/top of a list. Used to maintain LRU lists. + * + * @inout: + * list :: + * A pointer to the parent list. + * node :: + * The node to move. + */ FT_EXPORT( void ) FT_List_Up( FT_List list, FT_ListNode node ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Iterator */ - /* */ - /* <Description> */ - /* An FT_List iterator function that is called during a list parse */ - /* by @FT_List_Iterate. */ - /* */ - /* <Input> */ - /* node :: The current iteration list node. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. */ - /* Can be used to point to the iteration's state. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_List_Iterator + * + * @description: + * An FT_List iterator function that is called during a list parse by + * @FT_List_Iterate. + * + * @input: + * node :: + * The current iteration list node. + * + * user :: + * A typeless pointer passed to @FT_List_Iterate. Can be used to point + * to the iteration's state. + */ typedef FT_Error (*FT_List_Iterator)( FT_ListNode node, void* user ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Iterate */ - /* */ - /* <Description> */ - /* Parse a list and calls a given iterator function on each element. */ - /* Note that parsing is stopped as soon as one of the iterator calls */ - /* returns a non-zero value. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* iterator :: An iterator function, called on each node of the list. */ - /* user :: A user-supplied field that is passed as the second */ - /* argument to the iterator. */ - /* */ - /* <Return> */ - /* The result (a FreeType error code) of the last iterator call. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Iterate + * + * @description: + * Parse a list and calls a given iterator function on each element. + * Note that parsing is stopped as soon as one of the iterator calls + * returns a non-zero value. + * + * @input: + * list :: + * A handle to the list. + * iterator :: + * An iterator function, called on each node of the list. + * user :: + * A user-supplied field that is passed as the second argument to the + * iterator. + * + * @return: + * The result (a FreeType error code) of the last iterator call. + */ FT_EXPORT( FT_Error ) FT_List_Iterate( FT_List list, FT_List_Iterator iterator, void* user ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Destructor */ - /* */ - /* <Description> */ - /* An @FT_List iterator function that is called during a list */ - /* finalization by @FT_List_Finalize to destroy all elements in a */ - /* given list. */ - /* */ - /* <Input> */ - /* system :: The current system object. */ - /* */ - /* data :: The current object to destroy. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ - /* be used to point to the iteration's state. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_List_Destructor + * + * @description: + * An @FT_List iterator function that is called during a list + * finalization by @FT_List_Finalize to destroy all elements in a given + * list. + * + * @input: + * system :: + * The current system object. + * + * data :: + * The current object to destroy. + * + * user :: + * A typeless pointer passed to @FT_List_Iterate. It can be used to + * point to the iteration's state. + */ typedef void (*FT_List_Destructor)( FT_Memory memory, void* data, void* user ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Finalize */ - /* */ - /* <Description> */ - /* Destroy all elements in the list as well as the list itself. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* */ - /* destroy :: A list destructor that will be applied to each element */ - /* of the list. Set this to NULL if not needed. */ - /* */ - /* memory :: The current memory object that handles deallocation. */ - /* */ - /* user :: A user-supplied field that is passed as the last */ - /* argument to the destructor. */ - /* */ - /* <Note> */ - /* This function expects that all nodes added by @FT_List_Add or */ - /* @FT_List_Insert have been dynamically allocated. */ - /* */ + /************************************************************************** + * + * @function: + * FT_List_Finalize + * + * @description: + * Destroy all elements in the list as well as the list itself. + * + * @input: + * list :: + * A handle to the list. + * + * destroy :: + * A list destructor that will be applied to each element of the list. + * Set this to `NULL` if not needed. + * + * memory :: + * The current memory object that handles deallocation. + * + * user :: + * A user-supplied field that is passed as the last argument to the + * destructor. + * + * @note: + * This function expects that all nodes added by @FT_List_Add or + * @FT_List_Insert have been dynamically allocated. + */ FT_EXPORT( void ) FT_List_Finalize( FT_List list, FT_List_Destructor destroy, diff --git a/src/3rdparty/freetype/include/freetype/ftlzw.h b/src/3rdparty/freetype/include/freetype/ftlzw.h index 1615912d62..fd22968f5a 100644 --- a/src/3rdparty/freetype/include/freetype/ftlzw.h +++ b/src/3rdparty/freetype/include/freetype/ftlzw.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftlzw.h */ -/* */ -/* LZW-compressed stream support. */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftlzw.h + * + * LZW-compressed stream support. + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTLZW_H_ @@ -31,59 +31,60 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* lzw */ - /* */ - /* <Title> */ - /* LZW Streams */ - /* */ - /* <Abstract> */ - /* Using LZW-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of LZW-specific functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * lzw + * + * @title: + * LZW Streams + * + * @abstract: + * Using LZW-compressed font files. + * + * @description: + * This section contains the declaration of LZW-specific functions. + * + */ - /************************************************************************ - * - * @function: - * FT_Stream_OpenLZW - * - * @description: - * Open a new stream to parse LZW-compressed font files. This is - * mainly used to support the compressed `*.pcf.Z' fonts that come - * with XFree86. - * - * @input: - * stream :: The target embedding stream. - * - * source :: The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream - * - * In certain builds of the library, LZW compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a LZW stream from it - * and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with LZW support. - */ + /************************************************************************** + * + * @function: + * FT_Stream_OpenLZW + * + * @description: + * Open a new stream to parse LZW-compressed font files. This is mainly + * used to support the compressed `*.pcf.Z` fonts that come with XFree86. + * + * @input: + * stream :: + * The target embedding stream. + * + * source :: + * The source stream. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The source stream must be opened _before_ calling this function. + * + * Calling the internal function `FT_Stream_Close` on the new stream will + * **not** call `FT_Stream_Close` on the source stream. None of the + * stream objects will be released to the heap. + * + * The stream implementation is very basic and resets the decompression + * process each time seeking backwards is needed within the stream + * + * In certain builds of the library, LZW compression recognition is + * automatically handled when calling @FT_New_Face or @FT_Open_Face. + * This means that if no font driver is capable of handling the raw + * compressed file, the library will try to open a LZW stream from it and + * re-open the face with it. + * + * This function may return `FT_Err_Unimplemented_Feature` if your build + * of FreeType was not compiled with LZW support. + */ FT_EXPORT( FT_Error ) FT_Stream_OpenLZW( FT_Stream stream, FT_Stream source ); diff --git a/src/3rdparty/freetype/include/freetype/ftmac.h b/src/3rdparty/freetype/include/freetype/ftmac.h index c1e497ca2d..92b9f3dc0f 100644 --- a/src/3rdparty/freetype/include/freetype/ftmac.h +++ b/src/3rdparty/freetype/include/freetype/ftmac.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftmac.h */ -/* */ -/* Additional Mac-specific API. */ -/* */ -/* Copyright 1996-2018 by */ -/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmac.h + * + * Additional Mac-specific API. + * + * Copyright (C) 1996-2019 by + * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ -/***************************************************************************/ -/* */ -/* NOTE: Include this file after FT_FREETYPE_H and after any */ -/* Mac-specific headers (because this header uses Mac types such as */ -/* Handle, FSSpec, FSRef, etc.) */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * NOTE: Include this file after `FT_FREETYPE_H` and after any + * Mac-specific headers (because this header uses Mac types such as + * 'Handle', 'FSSpec', 'FSRef', etc.) + * + */ #ifndef FTMAC_H_ @@ -47,56 +47,59 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* <Section> */ - /* mac_specific */ - /* */ - /* <Title> */ - /* Mac Specific Interface */ - /* */ - /* <Abstract> */ - /* Only available on the Macintosh. */ - /* */ - /* <Description> */ - /* The following definitions are only available if FreeType is */ - /* compiled on a Macintosh. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * mac_specific + * + * @title: + * Mac Specific Interface + * + * @abstract: + * Only available on the Macintosh. + * + * @description: + * The following definitions are only available if FreeType is compiled + * on a Macintosh. + * + */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FOND */ - /* */ - /* <Description> */ - /* Create a new face object from a FOND resource. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* fond :: A FOND resource. */ - /* */ - /* face_index :: Only supported for the -1 `sanity check' special */ - /* case. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Notes> */ - /* This function can be used to create @FT_Face objects from fonts */ - /* that are installed in the system as follows. */ - /* */ - /* { */ - /* fond = GetResource( 'FOND', fontName ); */ - /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face_From_FOND + * + * @description: + * Create a new face object from a FOND resource. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * fond :: + * A FOND resource. + * + * face_index :: + * Only supported for the -1 'sanity check' special case. + * + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @example: + * This function can be used to create @FT_Face objects from fonts that + * are installed in the system as follows. + * + * ``` + * fond = GetResource( 'FOND', fontName ); + * error = FT_New_Face_From_FOND( library, fond, 0, &face ); + * ``` + */ FT_EXPORT( FT_Error ) FT_New_Face_From_FOND( FT_Library library, Handle fond, @@ -105,28 +108,28 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font (e.g., Times New Roman */ - /* Bold). */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_GetFile_From_Mac_Name + * + * @description: + * Return an FSSpec for the disk file containing the named font. + * + * @input: + * fontName :: + * Mac OS name of the font (e.g., Times New Roman Bold). + * + * @output: + * pathSpec :: + * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face_From_FSSpec. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_GetFile_From_Mac_Name( const char* fontName, FSSpec* pathSpec, @@ -134,27 +137,28 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_GetFile_From_Mac_ATS_Name + * + * @description: + * Return an FSSpec for the disk file containing the named font. + * + * @input: + * fontName :: + * Mac OS name of the font in ATS framework. + * + * @output: + * pathSpec :: + * FSSpec to the file. For passing to @FT_New_Face_From_FSSpec. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face_From_FSSpec. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_GetFile_From_Mac_ATS_Name( const char* fontName, FSSpec* pathSpec, @@ -162,30 +166,33 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFilePath_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return a pathname of the disk file and face index for given font */ - /* name that is handled by ATS framework. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* path :: Buffer to store pathname of the file. For passing */ - /* to @FT_New_Face. The client must allocate this */ - /* buffer before calling this function. */ - /* */ - /* maxPathSize :: Lengths of the buffer `path' that client allocated. */ - /* */ - /* face_index :: Index of the face. For passing to @FT_New_Face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_GetFilePath_From_Mac_ATS_Name + * + * @description: + * Return a pathname of the disk file and face index for given font name + * that is handled by ATS framework. + * + * @input: + * fontName :: + * Mac OS name of the font in ATS framework. + * + * @output: + * path :: + * Buffer to store pathname of the file. For passing to @FT_New_Face. + * The client must allocate this buffer before calling this function. + * + * maxPathSize :: + * Lengths of the buffer `path` that client allocated. + * + * face_index :: + * Index of the face. For passing to @FT_New_Face. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, UInt8* path, @@ -194,33 +201,37 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSSpec */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSSpec to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSSpec to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ - /* it accepts an FSSpec instead of a path. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face_From_FSSpec + * + * @description: + * Create a new face object from a given resource and typeface index + * using an FSSpec to the font file. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * spec :: + * FSSpec to the font file. + * + * face_index :: + * The index of the face within the resource. The first face has + * index~0. + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * @FT_New_Face_From_FSSpec is identical to @FT_New_Face except it + * accepts an FSSpec instead of a path. + */ FT_EXPORT( FT_Error ) FT_New_Face_From_FSSpec( FT_Library library, const FSSpec *spec, @@ -229,33 +240,37 @@ FT_BEGIN_HEADER FT_DEPRECATED_ATTRIBUTE; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSRef */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSRef to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSRef to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ - /* it accepts an FSRef instead of a path. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Face_From_FSRef + * + * @description: + * Create a new face object from a given resource and typeface index + * using an FSRef to the font file. + * + * @inout: + * library :: + * A handle to the library resource. + * + * @input: + * spec :: + * FSRef to the font file. + * + * face_index :: + * The index of the face within the resource. The first face has + * index~0. + * @output: + * aface :: + * A handle to a new face object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * @FT_New_Face_From_FSRef is identical to @FT_New_Face except it accepts + * an FSRef instead of a path. + */ FT_EXPORT( FT_Error ) FT_New_Face_From_FSRef( FT_Library library, const FSRef *ref, diff --git a/src/3rdparty/freetype/include/freetype/ftmm.h b/src/3rdparty/freetype/include/freetype/ftmm.h index 9948102c14..f2e16b6408 100644 --- a/src/3rdparty/freetype/include/freetype/ftmm.h +++ b/src/3rdparty/freetype/include/freetype/ftmm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmm.h */ -/* */ -/* FreeType Multiple Master font interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmm.h + * + * FreeType Multiple Master font interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTMM_H_ @@ -27,49 +27,52 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* multiple_masters */ - /* */ - /* <Title> */ - /* Multiple Masters */ - /* */ - /* <Abstract> */ - /* How to manage Multiple Masters fonts. */ - /* */ - /* <Description> */ - /* The following types and functions are used to manage Multiple */ - /* Master fonts, i.e., the selection of specific design instances by */ - /* setting design axis coordinates. */ - /* */ - /* Besides Adobe MM fonts, the interface supports Apple's TrueType GX */ - /* and OpenType variation fonts. Some of the routines only work with */ - /* Adobe MM fonts, others will work with all three types. They are */ - /* similar enough that a consistent interface makes sense. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Axis */ - /* */ - /* <Description> */ - /* A structure to model a given axis in design space for Multiple */ - /* Masters fonts. */ - /* */ - /* This structure can't be used for TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ + /************************************************************************** + * + * @section: + * multiple_masters + * + * @title: + * Multiple Masters + * + * @abstract: + * How to manage Multiple Masters fonts. + * + * @description: + * The following types and functions are used to manage Multiple Master + * fonts, i.e., the selection of specific design instances by setting + * design axis coordinates. + * + * Besides Adobe MM fonts, the interface supports Apple's TrueType GX and + * OpenType variation fonts. Some of the routines only work with Adobe + * MM fonts, others will work with all three types. They are similar + * enough that a consistent interface makes sense. + * + */ + + + /************************************************************************** + * + * @struct: + * FT_MM_Axis + * + * @description: + * A structure to model a given axis in design space for Multiple Masters + * fonts. + * + * This structure can't be used for TrueType GX or OpenType variation + * fonts. + * + * @fields: + * name :: + * The axis's name. + * + * minimum :: + * The axis's minimum design coordinate. + * + * maximum :: + * The axis's maximum design coordinate. + */ typedef struct FT_MM_Axis_ { FT_String* name; @@ -79,28 +82,29 @@ FT_BEGIN_HEADER } FT_MM_Axis; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Multi_Master */ - /* */ - /* <Description> */ - /* A structure to model the axes and space of a Multiple Masters */ - /* font. */ - /* */ - /* This structure can't be used for TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <Fields> */ - /* num_axis :: Number of axes. Cannot exceed~4. */ - /* */ - /* num_designs :: Number of designs; should be normally 2^num_axis */ - /* even though the Type~1 specification strangely */ - /* allows for intermediate designs to be present. */ - /* This number cannot exceed~16. */ - /* */ - /* axis :: A table of axis descriptors. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Multi_Master + * + * @description: + * A structure to model the axes and space of a Multiple Masters font. + * + * This structure can't be used for TrueType GX or OpenType variation + * fonts. + * + * @fields: + * num_axis :: + * Number of axes. Cannot exceed~4. + * + * num_designs :: + * Number of designs; should be normally 2^num_axis even though the + * Type~1 specification strangely allows for intermediate designs to be + * present. This number cannot exceed~16. + * + * axis :: + * A table of axis descriptors. + */ typedef struct FT_Multi_Master_ { FT_UInt num_axis; @@ -110,42 +114,45 @@ FT_BEGIN_HEADER } FT_Multi_Master; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Axis */ - /* */ - /* <Description> */ - /* A structure to model a given axis in design space for Multiple */ - /* Masters, TrueType GX, and OpenType variation fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* Not always meaningful for TrueType GX or OpenType */ - /* variation fonts. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* def :: The axis's default design coordinate. */ - /* FreeType computes meaningful default values for Adobe */ - /* MM fonts. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - /* tag :: The axis's tag (the equivalent to `name' for TrueType */ - /* GX and OpenType variation fonts). FreeType provides */ - /* default values for Adobe MM fonts if possible. */ - /* */ - /* strid :: The axis name entry in the font's `name' table. This */ - /* is another (and often better) version of the `name' */ - /* field for TrueType GX or OpenType variation fonts. Not */ - /* meaningful for Adobe MM fonts. */ - /* */ - /* <Note> */ - /* The fields `minimum', `def', and `maximum' are 16.16 fractional */ - /* values for TrueType GX and OpenType variation fonts. For Adobe MM */ - /* fonts, the values are integers. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Var_Axis + * + * @description: + * A structure to model a given axis in design space for Multiple + * Masters, TrueType GX, and OpenType variation fonts. + * + * @fields: + * name :: + * The axis's name. Not always meaningful for TrueType GX or OpenType + * variation fonts. + * + * minimum :: + * The axis's minimum design coordinate. + * + * def :: + * The axis's default design coordinate. FreeType computes meaningful + * default values for Adobe MM fonts. + * + * maximum :: + * The axis's maximum design coordinate. + * + * tag :: + * The axis's tag (the equivalent to 'name' for TrueType GX and + * OpenType variation fonts). FreeType provides default values for + * Adobe MM fonts if possible. + * + * strid :: + * The axis name entry in the font's 'name' table. This is another + * (and often better) version of the 'name' field for TrueType GX or + * OpenType variation fonts. Not meaningful for Adobe MM fonts. + * + * @note: + * The fields `minimum`, `def`, and `maximum` are 16.16 fractional values + * for TrueType GX and OpenType variation fonts. For Adobe MM fonts, the + * values are integers. + */ typedef struct FT_Var_Axis_ { FT_String* name; @@ -160,27 +167,29 @@ FT_BEGIN_HEADER } FT_Var_Axis; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Named_Style */ - /* */ - /* <Description> */ - /* A structure to model a named instance in a TrueType GX or OpenType */ - /* variation font. */ - /* */ - /* This structure can't be used for Adobe MM fonts. */ - /* */ - /* <Fields> */ - /* coords :: The design coordinates for this instance. */ - /* This is an array with one entry for each axis. */ - /* */ - /* strid :: The entry in `name' table identifying this instance. */ - /* */ - /* psid :: The entry in `name' table identifying a PostScript name */ - /* for this instance. Value 0xFFFF indicates a missing */ - /* entry. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Var_Named_Style + * + * @description: + * A structure to model a named instance in a TrueType GX or OpenType + * variation font. + * + * This structure can't be used for Adobe MM fonts. + * + * @fields: + * coords :: + * The design coordinates for this instance. This is an array with one + * entry for each axis. + * + * strid :: + * The entry in 'name' table identifying this instance. + * + * psid :: + * The entry in 'name' table identifying a PostScript name for this + * instance. Value 0xFFFF indicates a missing entry. + */ typedef struct FT_Var_Named_Style_ { FT_Fixed* coords; @@ -190,50 +199,47 @@ FT_BEGIN_HEADER } FT_Var_Named_Style; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Var */ - /* */ - /* <Description> */ - /* A structure to model the axes and space of an Adobe MM, TrueType */ - /* GX, or OpenType variation font. */ - /* */ - /* Some fields are specific to one format and not to the others. */ - /* */ - /* <Fields> */ - /* num_axis :: The number of axes. The maximum value is~4 for */ - /* Adobe MM fonts; no limit in TrueType GX or */ - /* OpenType variation fonts. */ - /* */ - /* num_designs :: The number of designs; should be normally */ - /* 2^num_axis for Adobe MM fonts. Not meaningful */ - /* for TrueType GX or OpenType variation fonts */ - /* (where every glyph could have a different */ - /* number of designs). */ - /* */ - /* num_namedstyles :: The number of named styles; a `named style' is */ - /* a tuple of design coordinates that has a string */ - /* ID (in the `name' table) associated with it. */ - /* The font can tell the user that, for example, */ - /* [Weight=1.5,Width=1.1] is `Bold'. Another name */ - /* for `named style' is `named instance'. */ - /* */ - /* For Adobe Multiple Masters fonts, this value is */ - /* always zero because the format does not support */ - /* named styles. */ - /* */ - /* axis :: An axis descriptor table. */ - /* TrueType GX and OpenType variation fonts */ - /* contain slightly more data than Adobe MM fonts. */ - /* Memory management of this pointer is done */ - /* internally by FreeType. */ - /* */ - /* namedstyle :: A named style (instance) table. */ - /* Only meaningful for TrueType GX and OpenType */ - /* variation fonts. Memory management of this */ - /* pointer is done internally by FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_MM_Var + * + * @description: + * A structure to model the axes and space of an Adobe MM, TrueType GX, + * or OpenType variation font. + * + * Some fields are specific to one format and not to the others. + * + * @fields: + * num_axis :: + * The number of axes. The maximum value is~4 for Adobe MM fonts; no + * limit in TrueType GX or OpenType variation fonts. + * + * num_designs :: + * The number of designs; should be normally 2^num_axis for Adobe MM + * fonts. Not meaningful for TrueType GX or OpenType variation fonts + * (where every glyph could have a different number of designs). + * + * num_namedstyles :: + * The number of named styles; a 'named style' is a tuple of design + * coordinates that has a string ID (in the 'name' table) associated + * with it. The font can tell the user that, for example, + * [Weight=1.5,Width=1.1] is 'Bold'. Another name for 'named style' is + * 'named instance'. + * + * For Adobe Multiple Masters fonts, this value is always zero because + * the format does not support named styles. + * + * axis :: + * An axis descriptor table. TrueType GX and OpenType variation fonts + * contain slightly more data than Adobe MM fonts. Memory management + * of this pointer is done internally by FreeType. + * + * namedstyle :: + * A named style (instance) table. Only meaningful for TrueType GX and + * OpenType variation fonts. Memory management of this pointer is done + * internally by FreeType. + */ typedef struct FT_MM_Var_ { FT_UInt num_axis; @@ -245,384 +251,493 @@ FT_BEGIN_HEADER } FT_MM_Var; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Multi_Master */ - /* */ - /* <Description> */ - /* Retrieve a variation descriptor of a given Adobe MM font. */ - /* */ - /* This function can't be used with TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The Multiple Masters descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Multi_Master + * + * @description: + * Retrieve a variation descriptor of a given Adobe MM font. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * amaster :: + * The Multiple Masters descriptor. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Get_Multi_Master( FT_Face face, FT_Multi_Master *amaster ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_MM_Var */ - /* */ - /* <Description> */ - /* Retrieve a variation descriptor for a given font. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The variation descriptor. */ - /* Allocates a data structure, which the user must */ - /* deallocate with a call to @FT_Done_MM_Var after use. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_MM_Var + * + * @description: + * Retrieve a variation descriptor for a given font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * @output: + * amaster :: + * The variation descriptor. Allocates a data structure, which the + * user must deallocate with a call to @FT_Done_MM_Var after use. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Get_MM_Var( FT_Face face, FT_MM_Var* *amaster ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_MM_Var */ - /* */ - /* <Description> */ - /* Free the memory allocated by @FT_Get_MM_Var. */ - /* */ - /* <Input> */ - /* library :: A handle of the face's parent library object that was */ - /* used in the call to @FT_Get_MM_Var to create `amaster'. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_MM_Var + * + * @description: + * Free the memory allocated by @FT_Get_MM_Var. + * + * @input: + * library :: + * A handle of the face's parent library object that was used in the + * call to @FT_Get_MM_Var to create `amaster`. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Done_MM_Var( FT_Library library, FT_MM_Var *amaster ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Design_Coordinates */ - /* */ - /* <Description> */ - /* For Adobe MM fonts, choose an interpolated font design through */ - /* design coordinates. */ - /* */ - /* This function can't be used with TrueType GX or OpenType variation */ - /* fonts. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* [Since 2.8.1] To reset all axes to the default values, call the */ - /* function with `num_coords' set to zero and `coords' set to NULL. */ - /* */ - /* [Since 2.9] If `num_coords' is larger than zero, this function */ - /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ - /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ - /* is zero, this bit flag gets unset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_MM_Design_Coordinates + * + * @description: + * For Adobe MM fonts, choose an interpolated font design through design + * coordinates. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * An array of design coordinates. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ FT_EXPORT( FT_Error ) FT_Set_MM_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Long* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Design_Coordinates */ - /* */ - /* <Description> */ - /* Choose an interpolated font design through design coordinates. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* [Since 2.8.1] To reset all axes to the default values, call the */ - /* function with `num_coords' set to zero and `coords' set to NULL. */ - /* [Since 2.9] `Default values' means the currently selected named */ - /* instance (or the base font if no named instance is selected). */ - /* */ - /* [Since 2.9] If `num_coords' is larger than zero, this function */ - /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ - /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ - /* is zero, this bit flag gets unset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Var_Design_Coordinates + * + * @description: + * Choose an interpolated font design through design coordinates. + * + * This function works with all supported variation formats. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * An array of design coordinates. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * [Since 2.9] 'Default values' means the currently selected named + * instance (or the base font if no named instance is selected). + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ FT_EXPORT( FT_Error ) FT_Set_Var_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Var_Design_Coordinates */ - /* */ - /* <Description> */ - /* Get the design coordinates of the currently selected interpolated */ - /* font. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* num_coords :: The number of design coordinates to retrieve. If it */ - /* is larger than the number of axes, set the excess */ - /* values to~0. */ - /* */ - /* <Output> */ - /* coords :: The design coordinates array. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.7.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Var_Design_Coordinates + * + * @description: + * Get the design coordinates of the currently selected interpolated + * font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of design coordinates to retrieve. If it is larger than + * the number of axes, set the excess values to~0. + * + * @output: + * coords :: + * The design coordinates array. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.7.1 + */ FT_EXPORT( FT_Error ) FT_Get_Var_Design_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Blend_Coordinates */ - /* */ - /* <Description> */ - /* Choose an interpolated font design through normalized blend */ - /* coordinates. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: The design coordinates array (each element must be */ - /* between 0 and 1.0 for Adobe MM fonts, and between */ - /* -1.0 and 1.0 for TrueType GX and OpenType variation */ - /* fonts). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* [Since 2.8.1] To reset all axes to the default values, call the */ - /* function with `num_coords' set to zero and `coords' set to NULL. */ - /* [Since 2.9] `Default values' means the currently selected named */ - /* instance (or the base font if no named instance is selected). */ - /* */ - /* [Since 2.9] If `num_coords' is larger than zero, this function */ - /* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */ - /* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */ - /* is zero, this bit flag gets unset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_MM_Blend_Coordinates + * + * @description: + * Choose an interpolated font design through normalized blend + * coordinates. + * + * This function works with all supported variation formats. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * num_coords :: + * The number of available design coordinates. If it is larger than + * the number of axes, ignore the excess values. If it is smaller than + * the number of axes, use default values for the remaining axes. + * + * coords :: + * The design coordinates array (each element must be between 0 and 1.0 + * for Adobe MM fonts, and between -1.0 and 1.0 for TrueType GX and + * OpenType variation fonts). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * [Since 2.8.1] To reset all axes to the default values, call the + * function with `num_coords` set to zero and `coords` set to `NULL`. + * [Since 2.9] 'Default values' means the currently selected named + * instance (or the base font if no named instance is selected). + * + * [Since 2.9] If `num_coords` is larger than zero, this function sets + * the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field + * (i.e., @FT_IS_VARIATION will return true). If `num_coords` is zero, + * this bit flag gets unset. + */ FT_EXPORT( FT_Error ) FT_Set_MM_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_MM_Blend_Coordinates */ - /* */ - /* <Description> */ - /* Get the normalized blend coordinates of the currently selected */ - /* interpolated font. */ - /* */ - /* This function works with all supported variation formats. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* num_coords :: The number of normalized blend coordinates to */ - /* retrieve. If it is larger than the number of axes, */ - /* set the excess values to~0.5 for Adobe MM fonts, and */ - /* to~0 for TrueType GX and OpenType variation fonts. */ - /* */ - /* <Output> */ - /* coords :: The normalized blend coordinates array. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.7.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_MM_Blend_Coordinates + * + * @description: + * Get the normalized blend coordinates of the currently selected + * interpolated font. + * + * This function works with all supported variation formats. + * + * @input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of normalized blend coordinates to retrieve. If it is + * larger than the number of axes, set the excess values to~0.5 for + * Adobe MM fonts, and to~0 for TrueType GX and OpenType variation + * fonts. + * + * @output: + * coords :: + * The normalized blend coordinates array. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.7.1 + */ FT_EXPORT( FT_Error ) FT_Get_MM_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Blend_Coordinates */ - /* */ - /* <Description> */ - /* This is another name of @FT_Set_MM_Blend_Coordinates. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Var_Blend_Coordinates + * + * @description: + * This is another name of @FT_Set_MM_Blend_Coordinates. + */ FT_EXPORT( FT_Error ) FT_Set_Var_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Var_Blend_Coordinates */ - /* */ - /* <Description> */ - /* This is another name of @FT_Get_MM_Blend_Coordinates. */ - /* */ - /* <Since> */ - /* 2.7.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Var_Blend_Coordinates + * + * @description: + * This is another name of @FT_Get_MM_Blend_Coordinates. + * + * @since: + * 2.7.1 + */ FT_EXPORT( FT_Error ) FT_Get_Var_Blend_Coordinates( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_VAR_AXIS_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the return value of */ - /* @FT_Get_Var_Axis_Flags. */ - /* */ - /* <Values> */ - /* FT_VAR_AXIS_FLAG_HIDDEN :: */ - /* The variation axis should not be exposed to user interfaces. */ - /* */ - /* <Since> */ - /* 2.8.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_MM_WeightVector + * + * @description: + * For Adobe MM fonts, choose an interpolated font design by directly + * setting the weight vector. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * @input: + * len :: + * The length of the weight vector array. If it is larger than the + * number of designs, the extra values are ignored. If it is less than + * the number of designs, the remaining values are set to zero. + * + * weightvector :: + * An array representing the weight vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Adobe Multiple Master fonts limit the number of designs, and thus the + * length of the weight vector to~16. + * + * If `len` is zero and `weightvector` is `NULL`, the weight vector array + * is reset to the default values. + * + * The Adobe documentation also states that the values in the + * WeightVector array must total 1.0 +/-~0.001. In practice this does + * not seem to be enforced, so is not enforced here, either. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Set_MM_WeightVector( FT_Face face, + FT_UInt len, + FT_Fixed* weightvector ); + + + /************************************************************************** + * + * @function: + * FT_Get_MM_WeightVector + * + * @description: + * For Adobe MM fonts, retrieve the current weight vector of the font. + * + * This function can't be used with TrueType GX or OpenType variation + * fonts. + * + * @inout: + * face :: + * A handle to the source face. + * + * len :: + * A pointer to the size of the array to be filled. If the size of the + * array is less than the number of designs, `FT_Err_Invalid_Argument` + * is returned, and `len` is set to the required size (the number of + * designs). If the size of the array is greater than the number of + * designs, the remaining entries are set to~0. On successful + * completion, `len` is set to the number of designs (i.e., the number + * of values written to the array). + * + * @output: + * weightvector :: + * An array to be filled. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * Adobe Multiple Master fonts limit the number of designs, and thus the + * length of the WeightVector to~16. + * + * @since: + * 2.10 + */ + FT_EXPORT( FT_Error ) + FT_Get_MM_WeightVector( FT_Face face, + FT_UInt* len, + FT_Fixed* weightvector ); + + + /************************************************************************** + * + * @enum: + * FT_VAR_AXIS_FLAG_XXX + * + * @description: + * A list of bit flags used in the return value of + * @FT_Get_Var_Axis_Flags. + * + * @values: + * FT_VAR_AXIS_FLAG_HIDDEN :: + * The variation axis should not be exposed to user interfaces. + * + * @since: + * 2.8.1 + */ #define FT_VAR_AXIS_FLAG_HIDDEN 1 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Var_Axis_Flags */ - /* */ - /* <Description> */ - /* Get the `flags' field of an OpenType Variation Axis Record. */ - /* */ - /* Not meaningful for Adobe MM fonts (`*flags' is always zero). */ - /* */ - /* <Input> */ - /* master :: The variation descriptor. */ - /* */ - /* axis_index :: The index of the requested variation axis. */ - /* */ - /* <Output> */ - /* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */ - /* possible values. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.8.1 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Var_Axis_Flags + * + * @description: + * Get the 'flags' field of an OpenType Variation Axis Record. + * + * Not meaningful for Adobe MM fonts (`*flags` is always zero). + * + * @input: + * master :: + * The variation descriptor. + * + * axis_index :: + * The index of the requested variation axis. + * + * @output: + * flags :: + * The 'flags' field. See @FT_VAR_AXIS_FLAG_XXX for possible values. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.8.1 + */ FT_EXPORT( FT_Error ) FT_Get_Var_Axis_Flags( FT_MM_Var* master, FT_UInt axis_index, FT_UInt* flags ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Named_Instance */ - /* */ - /* <Description> */ - /* Set or change the current named instance. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* instance_index :: The index of the requested instance, starting */ - /* with value 1. If set to value 0, FreeType */ - /* switches to font access without a named */ - /* instance. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The function uses the value of `instance_index' to set bits 16-30 */ - /* of the face's `face_index' field. It also resets any variation */ - /* applied to the font, and the @FT_FACE_FLAG_VARIATION bit of the */ - /* face's `face_flags' field gets reset to zero (i.e., */ - /* @FT_IS_VARIATION will return false). */ - /* */ - /* For Adobe MM fonts (which don't have named instances) this */ - /* function simply resets the current face to the default instance. */ - /* */ - /* <Since> */ - /* 2.9 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Named_Instance + * + * @description: + * Set or change the current named instance. + * + * @input: + * face :: + * A handle to the source face. + * + * instance_index :: + * The index of the requested instance, starting with value 1. If set + * to value 0, FreeType switches to font access without a named + * instance. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The function uses the value of `instance_index` to set bits 16-30 of + * the face's `face_index` field. It also resets any variation applied + * to the font, and the @FT_FACE_FLAG_VARIATION bit of the face's + * `face_flags` field gets reset to zero (i.e., @FT_IS_VARIATION will + * return false). + * + * For Adobe MM fonts (which don't have named instances) this function + * simply resets the current face to the default instance. + * + * @since: + * 2.9 + */ FT_EXPORT( FT_Error ) FT_Set_Named_Instance( FT_Face face, FT_UInt instance_index ); diff --git a/src/3rdparty/freetype/include/freetype/ftmodapi.h b/src/3rdparty/freetype/include/freetype/ftmodapi.h index a6eb876ebe..8d039c4f3a 100644 --- a/src/3rdparty/freetype/include/freetype/ftmodapi.h +++ b/src/3rdparty/freetype/include/freetype/ftmodapi.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmodapi.h */ -/* */ -/* FreeType modules public interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmodapi.h + * + * FreeType modules public interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTMODAPI_H_ @@ -33,77 +33,77 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /* <Title> */ - /* Module Management */ - /* */ - /* <Abstract> */ - /* How to add, upgrade, remove, and control modules from FreeType. */ - /* */ - /* <Description> */ - /* The definitions below are used to manage modules within FreeType. */ - /* Modules can be added, upgraded, and removed at runtime. */ - /* Additionally, some module properties can be controlled also. */ - /* */ - /* Here is a list of possible values of the `module_name' field in */ - /* the @FT_Module_Class structure. */ - /* */ - /* { */ - /* autofitter */ - /* bdf */ - /* cff */ - /* gxvalid */ - /* otvalid */ - /* pcf */ - /* pfr */ - /* psaux */ - /* pshinter */ - /* psnames */ - /* raster1 */ - /* sfnt */ - /* smooth, smooth-lcd, smooth-lcdv */ - /* truetype */ - /* type1 */ - /* type42 */ - /* t1cid */ - /* winfonts */ - /* } */ - /* */ - /* Note that the FreeType Cache sub-system is not a FreeType module. */ - /* */ - /* <Order> */ - /* FT_Module */ - /* FT_Module_Constructor */ - /* FT_Module_Destructor */ - /* FT_Module_Requester */ - /* FT_Module_Class */ - /* */ - /* FT_Add_Module */ - /* FT_Get_Module */ - /* FT_Remove_Module */ - /* FT_Add_Default_Modules */ - /* */ - /* FT_Property_Set */ - /* FT_Property_Get */ - /* FT_Set_Default_Properties */ - /* */ - /* FT_New_Library */ - /* FT_Done_Library */ - /* FT_Reference_Library */ - /* */ - /* FT_Renderer */ - /* FT_Renderer_Class */ - /* */ - /* FT_Get_Renderer */ - /* FT_Set_Renderer */ - /* */ - /* FT_Set_Debug_Hook */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * module_management + * + * @title: + * Module Management + * + * @abstract: + * How to add, upgrade, remove, and control modules from FreeType. + * + * @description: + * The definitions below are used to manage modules within FreeType. + * Modules can be added, upgraded, and removed at runtime. Additionally, + * some module properties can be controlled also. + * + * Here is a list of possible values of the `module_name` field in the + * @FT_Module_Class structure. + * + * ``` + * autofitter + * bdf + * cff + * gxvalid + * otvalid + * pcf + * pfr + * psaux + * pshinter + * psnames + * raster1 + * sfnt + * smooth, smooth-lcd, smooth-lcdv + * truetype + * type1 + * type42 + * t1cid + * winfonts + * ``` + * + * Note that the FreeType Cache sub-system is not a FreeType module. + * + * @order: + * FT_Module + * FT_Module_Constructor + * FT_Module_Destructor + * FT_Module_Requester + * FT_Module_Class + * + * FT_Add_Module + * FT_Get_Module + * FT_Remove_Module + * FT_Add_Default_Modules + * + * FT_Property_Set + * FT_Property_Get + * FT_Set_Default_Properties + * + * FT_New_Library + * FT_Done_Library + * FT_Reference_Library + * + * FT_Renderer + * FT_Renderer_Class + * + * FT_Get_Renderer + * FT_Set_Renderer + * + * FT_Set_Debug_Hook + * + */ /* module bit flags */ @@ -137,83 +137,99 @@ FT_BEGIN_HEADER typedef FT_Pointer FT_Module_Interface; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Constructor */ - /* */ - /* <Description> */ - /* A function used to initialize (not create) a new module object. */ - /* */ - /* <Input> */ - /* module :: The module to initialize. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Module_Constructor + * + * @description: + * A function used to initialize (not create) a new module object. + * + * @input: + * module :: + * The module to initialize. + */ typedef FT_Error (*FT_Module_Constructor)( FT_Module module ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destructor */ - /* */ - /* <Description> */ - /* A function used to finalize (not destroy) a given module object. */ - /* */ - /* <Input> */ - /* module :: The module to finalize. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Module_Destructor + * + * @description: + * A function used to finalize (not destroy) a given module object. + * + * @input: + * module :: + * The module to finalize. + */ typedef void (*FT_Module_Destructor)( FT_Module module ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Requester */ - /* */ - /* <Description> */ - /* A function used to query a given module for a specific interface. */ - /* */ - /* <Input> */ - /* module :: The module to be searched. */ - /* */ - /* name :: The name of the interface in the module. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Module_Requester + * + * @description: + * A function used to query a given module for a specific interface. + * + * @input: + * module :: + * The module to be searched. + * + * name :: + * The name of the interface in the module. + */ typedef FT_Module_Interface (*FT_Module_Requester)( FT_Module module, const char* name ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Module_Class */ - /* */ - /* <Description> */ - /* The module class descriptor. */ - /* */ - /* <Fields> */ - /* module_flags :: Bit flags describing the module. */ - /* */ - /* module_size :: The size of one module object/instance in */ - /* bytes. */ - /* */ - /* module_name :: The name of the module. */ - /* */ - /* module_version :: The version, as a 16.16 fixed number */ - /* (major.minor). */ - /* */ - /* module_requires :: The version of FreeType this module requires, */ - /* as a 16.16 fixed number (major.minor). Starts */ - /* at version 2.0, i.e., 0x20000. */ - /* */ - /* module_init :: The initializing function. */ - /* */ - /* module_done :: The finalizing function. */ - /* */ - /* get_interface :: The interface requesting function. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Module_Class + * + * @description: + * The module class descriptor. While being a public structure necessary + * for FreeType's module bookkeeping, most of the fields are essentially + * internal, not to be used directly by an application. + * + * @fields: + * module_flags :: + * Bit flags describing the module. + * + * module_size :: + * The size of one module object/instance in bytes. + * + * module_name :: + * The name of the module. + * + * module_version :: + * The version, as a 16.16 fixed number (major.minor). + * + * module_requires :: + * The version of FreeType this module requires, as a 16.16 fixed + * number (major.minor). Starts at version 2.0, i.e., 0x20000. + * + * module_interface :: + * A typeless pointer to a structure (which varies between different + * modules) that holds the module's interface functions. This is + * essentially what `get_interface` returns. + * + * module_init :: + * The initializing function. + * + * module_done :: + * The finalizing function. + * + * get_interface :: + * The interface requesting function. + */ typedef struct FT_Module_Class_ { FT_ULong module_flags; @@ -231,83 +247,89 @@ FT_BEGIN_HEADER } FT_Module_Class; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Module */ - /* */ - /* <Description> */ - /* Add a new module to a given library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* clazz :: A pointer to class descriptor for the module. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Add_Module + * + * @description: + * Add a new module to a given library instance. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * clazz :: + * A pointer to class descriptor for the module. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An error will be returned if a module already exists by that name, or + * if the module requires a version of FreeType that is too great. + */ FT_EXPORT( FT_Error ) FT_Add_Module( FT_Library library, const FT_Module_Class* clazz ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module */ - /* */ - /* <Description> */ - /* Find a module by its name. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module handle. 0~if none was found. */ - /* */ - /* <Note> */ - /* FreeType's internal modules aren't documented very well, and you */ - /* should look up the source code for details. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Module + * + * @description: + * Find a module by its name. + * + * @input: + * library :: + * A handle to the library object. + * + * module_name :: + * The module's name (as an ASCII string). + * + * @return: + * A module handle. 0~if none was found. + * + * @note: + * FreeType's internal modules aren't documented very well, and you + * should look up the source code for details. + */ FT_EXPORT( FT_Module ) FT_Get_Module( FT_Library library, const char* module_name ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Remove_Module */ - /* */ - /* <Description> */ - /* Remove a given module from a library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to a library object. */ - /* */ - /* <Input> */ - /* module :: A handle to a module object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The module object is destroyed by the function in case of success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Remove_Module + * + * @description: + * Remove a given module from a library instance. + * + * @inout: + * library :: + * A handle to a library object. + * + * @input: + * module :: + * A handle to a module object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The module object is destroyed by the function in case of success. + */ FT_EXPORT( FT_Error ) FT_Remove_Module( FT_Library library, FT_Module module ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Property_Set @@ -317,53 +339,51 @@ FT_BEGIN_HEADER * * @input: * library :: - * A handle to the library the module is part of. + * A handle to the library the module is part of. * * module_name :: - * The module name. + * The module name. * * property_name :: - * The property name. Properties are described in section - * @properties. + * The property name. Properties are described in section + * @properties. * - * Note that only a few modules have properties. + * Note that only a few modules have properties. * * value :: - * A generic pointer to a variable or structure that gives the new - * value of the property. The exact definition of `value' is - * dependent on the property; see section @properties. + * A generic pointer to a variable or structure that gives the new + * value of the property. The exact definition of `value` is + * dependent on the property; see section @properties. * * @return: * FreeType error code. 0~means success. * * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a + * If `module_name` isn't a valid module name, or `property_name` + * doesn't specify a valid property, or if `value` doesn't represent a * valid value for the given property, an error is returned. * - * The following example sets property `bar' (a simple integer) in - * module `foo' to value~1. + * The following example sets property 'bar' (a simple integer) in + * module 'foo' to value~1. * - * { + * ``` * FT_UInt bar; * * * bar = 1; * FT_Property_Set( library, "foo", "bar", &bar ); - * } + * ``` * * Note that the FreeType Cache sub-system doesn't recognize module * property changes. To avoid glyph lookup confusion within the cache - * you should call @FTC_Manager_Reset to completely flush the cache if - * a module property gets changed after @FTC_Manager_New has been - * called. + * you should call @FTC_Manager_Reset to completely flush the cache if a + * module property gets changed after @FTC_Manager_New has been called. * - * It is not possible to set properties of the FreeType Cache - * sub-system itself with FT_Property_Set; use @FTC_Property_Set - * instead. + * It is not possible to set properties of the FreeType Cache sub-system + * itself with FT_Property_Set; use @FTC_Property_Set instead. * - * @since: - * 2.4.11 + * @since: + * 2.4.11 * */ FT_EXPORT( FT_Error ) @@ -373,7 +393,7 @@ FT_BEGIN_HEADER const void* value ); - /********************************************************************** + /************************************************************************** * * @function: * FT_Property_Get @@ -383,32 +403,32 @@ FT_BEGIN_HEADER * * @input: * library :: - * A handle to the library the module is part of. + * A handle to the library the module is part of. * * module_name :: - * The module name. + * The module name. * * property_name :: - * The property name. Properties are described in section - * @properties. + * The property name. Properties are described in section + * @properties. * * @inout: * value :: - * A generic pointer to a variable or structure that gives the - * value of the property. The exact definition of `value' is - * dependent on the property; see section @properties. + * A generic pointer to a variable or structure that gives the value + * of the property. The exact definition of `value` is dependent on + * the property; see section @properties. * * @return: * FreeType error code. 0~means success. * * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a + * If `module_name` isn't a valid module name, or `property_name` + * doesn't specify a valid property, or if `value` doesn't represent a * valid value for the given property, an error is returned. * - * The following example gets property `baz' (a range) in module `foo'. + * The following example gets property 'baz' (a range) in module 'foo'. * - * { + * ``` * typedef range_ * { * FT_Int32 min; @@ -420,13 +440,13 @@ FT_BEGIN_HEADER * * * FT_Property_Get( library, "foo", "baz", &baz ); - * } + * ``` * * It is not possible to retrieve properties of the FreeType Cache * sub-system with FT_Property_Get; use @FTC_Property_Get instead. * - * @since: - * 2.4.11 + * @since: + * 2.4.11 * */ FT_EXPORT( FT_Error ) @@ -436,189 +456,243 @@ FT_BEGIN_HEADER void* value ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Default_Properties */ - /* */ - /* <Description> */ - /* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */ - /* set, this function reads the `FREETYPE_PROPERTIES' environment */ - /* variable to control driver properties. See section @properties */ - /* for more. */ - /* */ - /* If the compilation option is not set, this function does nothing. */ - /* */ - /* `FREETYPE_PROPERTIES' has the following syntax form (broken here */ - /* into multiple lines for better readability). */ - /* */ - /* { */ - /* <optional whitespace> */ - /* <module-name1> ':' */ - /* <property-name1> '=' <property-value1> */ - /* <whitespace> */ - /* <module-name2> ':' */ - /* <property-name2> '=' <property-value2> */ - /* ... */ - /* } */ - /* */ - /* Example: */ - /* */ - /* { */ - /* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */ - /* cff:no-stem-darkening=1 \ */ - /* autofitter:warping=1 */ - /* } */ - /* */ - /* <InOut> */ - /* library :: A handle to a new library object. */ - /* */ - /* <Since> */ - /* 2.8 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Default_Properties + * + * @description: + * If compilation option `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES` is + * set, this function reads the `FREETYPE_PROPERTIES` environment + * variable to control driver properties. See section @properties for + * more. + * + * If the compilation option is not set, this function does nothing. + * + * `FREETYPE_PROPERTIES` has the following syntax form (broken here into + * multiple lines for better readability). + * + * ``` + * <optional whitespace> + * <module-name1> ':' + * <property-name1> '=' <property-value1> + * <whitespace> + * <module-name2> ':' + * <property-name2> '=' <property-value2> + * ... + * ``` + * + * Example: + * + * ``` + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=1 \ + * autofitter:warping=1 + * ``` + * + * @inout: + * library :: + * A handle to a new library object. + * + * @since: + * 2.8 + */ FT_EXPORT( void ) FT_Set_Default_Properties( FT_Library library ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Library */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Library */ - /* structure is created. This function increments the counter. */ - /* @FT_Done_Library then only destroys a library if the counter is~1, */ - /* otherwise it simply decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Library objects. */ - /* */ - /* <Input> */ - /* library :: A handle to a target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Reference_Library + * + * @description: + * A counter gets initialized to~1 at the time an @FT_Library structure + * is created. This function increments the counter. @FT_Done_Library + * then only destroys a library if the counter is~1, otherwise it simply + * decrements the counter. + * + * This function helps in managing life-cycles of structures that + * reference @FT_Library objects. + * + * @input: + * library :: + * A handle to a target library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @since: + * 2.4.2 + */ FT_EXPORT( FT_Error ) FT_Reference_Library( FT_Library library ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Library */ - /* */ - /* <Description> */ - /* This function is used to create a new FreeType library instance */ - /* from a given memory object. It is thus possible to use libraries */ - /* with distinct memory allocators within the same program. Note, */ - /* however, that the used @FT_Memory structure is expected to remain */ - /* valid for the life of the @FT_Library object. */ - /* */ - /* Normally, you would call this function (followed by a call to */ - /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, */ - /* and a call to @FT_Set_Default_Properties) instead of */ - /* @FT_Init_FreeType to initialize the FreeType library. */ - /* */ - /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ - /* library instance. */ - /* */ - /* <Input> */ - /* memory :: A handle to the original memory object. */ - /* */ - /* <Output> */ - /* alibrary :: A pointer to handle of a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Library + * + * @description: + * This function is used to create a new FreeType library instance from a + * given memory object. It is thus possible to use libraries with + * distinct memory allocators within the same program. Note, however, + * that the used @FT_Memory structure is expected to remain valid for the + * life of the @FT_Library object. + * + * Normally, you would call this function (followed by a call to + * @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, and a + * call to @FT_Set_Default_Properties) instead of @FT_Init_FreeType to + * initialize the FreeType library. + * + * Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a library + * instance. + * + * @input: + * memory :: + * A handle to the original memory object. + * + * @output: + * alibrary :: + * A pointer to handle of a new library object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Library. + */ FT_EXPORT( FT_Error ) FT_New_Library( FT_Memory memory, FT_Library *alibrary ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Library */ - /* */ - /* <Description> */ - /* Discard a given library object. This closes all drivers and */ - /* discards all resource objects. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Library + * + * @description: + * Discard a given library object. This closes all drivers and discards + * all resource objects. + * + * @input: + * library :: + * A handle to the target library. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * See the discussion of reference counters in the description of + * @FT_Reference_Library. + */ FT_EXPORT( FT_Error ) FT_Done_Library( FT_Library library ); - /* */ - typedef void + /************************************************************************** + * + * @functype: + * FT_DebugHook_Func + * + * @description: + * A drop-in replacement (or rather a wrapper) for the bytecode or + * charstring interpreter's main loop function. + * + * Its job is essentially + * + * - to activate debug mode to enforce single-stepping, + * + * - to call the main loop function to interpret the next opcode, and + * + * - to show the changed context to the user. + * + * An example for such a main loop function is `TT_RunIns` (declared in + * FreeType's internal header file `src/truetype/ttinterp.h`). + * + * Have a look at the source code of the `ttdebug` FreeType demo program + * for an example of a drop-in replacement. + * + * @inout: + * arg :: + * A typeless pointer, to be cast to the main loop function's data + * structure (which depends on the font module). For TrueType fonts + * it is bytecode interpreter's execution context, `TT_ExecContext`, + * which is declared in FreeType's internal header file `tttypes.h`. + */ + typedef FT_Error (*FT_DebugHook_Func)( void* arg ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Debug_Hook */ - /* */ - /* <Description> */ - /* Set a debug hook function for debugging the interpreter of a font */ - /* format. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in `ftobjs.h', e.g., */ - /* `FT_DEBUG_HOOK_TRUETYPE'. */ - /* */ - /* debug_hook :: The function used to debug the interpreter. */ - /* */ - /* <Note> */ - /* Currently, four debug hook slots are available, but only two (for */ - /* the TrueType and the Type~1 interpreter) are defined. */ - /* */ - /* Since the internal headers of FreeType are no longer installed, */ - /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ - /* This is a bug and will be fixed in a forthcoming release. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_DEBUG_HOOK_XXX + * + * @description: + * A list of named debug hook indices. + * + * @values: + * FT_DEBUG_HOOK_TRUETYPE:: + * This hook index identifies the TrueType bytecode debugger. + */ +#define FT_DEBUG_HOOK_TRUETYPE 0 + + + /************************************************************************** + * + * @function: + * FT_Set_Debug_Hook + * + * @description: + * Set a debug hook function for debugging the interpreter of a font + * format. + * + * While this is a public API function, an application needs access to + * FreeType's internal header files to do something useful. + * + * Have a look at the source code of the `ttdebug` FreeType demo program + * for an example of its usage. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * hook_index :: + * The index of the debug hook. You should use defined enumeration + * macros like @FT_DEBUG_HOOK_TRUETYPE. + * + * debug_hook :: + * The function used to debug the interpreter. + * + * @note: + * Currently, four debug hook slots are available, but only one (for the + * TrueType interpreter) is defined. + */ FT_EXPORT( void ) FT_Set_Debug_Hook( FT_Library library, FT_UInt hook_index, FT_DebugHook_Func debug_hook ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Default_Modules */ - /* */ - /* <Description> */ - /* Add the set of default drivers to a given library object. */ - /* This is only useful when you create a library object with */ - /* @FT_New_Library (usually to plug a custom memory manager). */ - /* */ - /* <InOut> */ - /* library :: A handle to a new library object. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Add_Default_Modules + * + * @description: + * Add the set of default drivers to a given library object. This is + * only useful when you create a library object with @FT_New_Library + * (usually to plug a custom memory manager). + * + * @inout: + * library :: + * A handle to a new library object. + */ FT_EXPORT( void ) FT_Add_Default_Modules( FT_Library library ); @@ -644,28 +718,28 @@ FT_BEGIN_HEADER /************************************************************************** * - * @enum: - * FT_TrueTypeEngineType + * @enum: + * FT_TrueTypeEngineType * - * @description: - * A list of values describing which kind of TrueType bytecode - * engine is implemented in a given FT_Library instance. It is used - * by the @FT_Get_TrueType_Engine_Type function. + * @description: + * A list of values describing which kind of TrueType bytecode engine is + * implemented in a given FT_Library instance. It is used by the + * @FT_Get_TrueType_Engine_Type function. * - * @values: - * FT_TRUETYPE_ENGINE_TYPE_NONE :: - * The library doesn't implement any kind of bytecode interpreter. + * @values: + * FT_TRUETYPE_ENGINE_TYPE_NONE :: + * The library doesn't implement any kind of bytecode interpreter. * - * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: - * Deprecated and removed. + * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: + * Deprecated and removed. * - * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: - * The library implements a bytecode interpreter that covers - * the full instruction set of the TrueType virtual machine (this - * was governed by patents until May 2010, hence the name). + * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: + * The library implements a bytecode interpreter that covers the full + * instruction set of the TrueType virtual machine (this was governed + * by patents until May 2010, hence the name). * - * @since: - * 2.2 + * @since: + * 2.2 * */ typedef enum FT_TrueTypeEngineType_ @@ -679,22 +753,22 @@ FT_BEGIN_HEADER /************************************************************************** * - * @func: - * FT_Get_TrueType_Engine_Type + * @function: + * FT_Get_TrueType_Engine_Type * - * @description: - * Return an @FT_TrueTypeEngineType value to indicate which level of - * the TrueType virtual machine a given library instance supports. + * @description: + * Return an @FT_TrueTypeEngineType value to indicate which level of the + * TrueType virtual machine a given library instance supports. * - * @input: - * library :: - * A library instance. + * @input: + * library :: + * A library instance. * - * @return: - * A value indicating which level is supported. + * @return: + * A value indicating which level is supported. * - * @since: - * 2.2 + * @since: + * 2.2 * */ FT_EXPORT( FT_TrueTypeEngineType ) diff --git a/src/3rdparty/freetype/include/freetype/ftmoderr.h b/src/3rdparty/freetype/include/freetype/ftmoderr.h index e0fc1312bd..e16993572c 100644 --- a/src/3rdparty/freetype/include/freetype/ftmoderr.h +++ b/src/3rdparty/freetype/include/freetype/ftmoderr.h @@ -1,94 +1,103 @@ -/***************************************************************************/ -/* */ -/* ftmoderr.h */ -/* */ -/* FreeType module error offsets (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the FreeType module error codes. */ - /* */ - /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */ - /* set, the lower byte of an error value identifies the error code as */ - /* usual. In addition, the higher byte identifies the module. For */ - /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */ - /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */ - /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */ - /* */ - /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */ - /* including the high byte. */ - /* */ - /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */ - /* an error value is set to zero. */ - /* */ - /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ - /* provides some macros in `fttypes.h'. */ - /* */ - /* FT_ERR( err ) */ - /* Add current error module prefix (as defined with the */ - /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ - /* the line */ - /* */ - /* error = FT_ERR( Invalid_Outline ); */ - /* */ - /* expands to */ - /* */ - /* error = BDF_Err_Invalid_Outline; */ - /* */ - /* For simplicity, you can always use `FT_Err_Ok' directly instead */ - /* of `FT_ERR( Ok )'. */ - /* */ - /* FT_ERR_EQ( errcode, err ) */ - /* FT_ERR_NEQ( errcode, err ) */ - /* Compare error code `errcode' with the error `err' for equality */ - /* and inequality, respectively. Example: */ - /* */ - /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ - /* ... */ - /* */ - /* Using this macro you don't have to think about error prefixes. */ - /* Of course, if module errors are not active, the above example is */ - /* the same as */ - /* */ - /* if ( error == FT_Err_Invalid_Outline ) */ - /* ... */ - /* */ - /* FT_ERROR_BASE( errcode ) */ - /* FT_ERROR_MODULE( errcode ) */ - /* Get base error and module error code, respectively. */ - /* */ - /* */ - /* It can also be used to create a module error message table easily */ - /* with something like */ - /* */ - /* { */ - /* #undef FTMODERR_H_ */ - /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ - /* #define FT_MODERR_START_LIST { */ - /* #define FT_MODERR_END_LIST { 0, 0 } }; */ - /* */ - /* const struct */ - /* { */ - /* int mod_err_offset; */ - /* const char* mod_err_msg */ - /* } ft_mod_errors[] = */ - /* */ - /* #include FT_MODULE_ERRORS_H */ - /* } */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftmoderr.h + * + * FreeType module error offsets (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the FreeType module error codes. + * + * If the macro `FT_CONFIG_OPTION_USE_MODULE_ERRORS` in `ftoption.h` is + * set, the lower byte of an error value identifies the error code as + * usual. In addition, the higher byte identifies the module. For + * example, the error `FT_Err_Invalid_File_Format` has value 0x0003, the + * error `TT_Err_Invalid_File_Format` has value 0x1303, the error + * `T1_Err_Invalid_File_Format` has value 0x1403, etc. + * + * Note that `FT_Err_Ok`, `TT_Err_Ok`, etc. are always equal to zero, + * including the high byte. + * + * If `FT_CONFIG_OPTION_USE_MODULE_ERRORS` isn't set, the higher byte of an + * error value is set to zero. + * + * To hide the various `XXX_Err_` prefixes in the source code, FreeType + * provides some macros in `fttypes.h`. + * + * FT_ERR( err ) + * + * Add current error module prefix (as defined with the `FT_ERR_PREFIX` + * macro) to `err`. For example, in the BDF module the line + * + * ``` + * error = FT_ERR( Invalid_Outline ); + * ``` + * + * expands to + * + * ``` + * error = BDF_Err_Invalid_Outline; + * ``` + * + * For simplicity, you can always use `FT_Err_Ok` directly instead of + * `FT_ERR( Ok )`. + * + * FT_ERR_EQ( errcode, err ) + * FT_ERR_NEQ( errcode, err ) + * + * Compare error code `errcode` with the error `err` for equality and + * inequality, respectively. Example: + * + * ``` + * if ( FT_ERR_EQ( error, Invalid_Outline ) ) + * ... + * ``` + * + * Using this macro you don't have to think about error prefixes. Of + * course, if module errors are not active, the above example is the + * same as + * + * ``` + * if ( error == FT_Err_Invalid_Outline ) + * ... + * ``` + * + * FT_ERROR_BASE( errcode ) + * FT_ERROR_MODULE( errcode ) + * + * Get base error and module error code, respectively. + * + * It can also be used to create a module error message table easily with + * something like + * + * ``` + * #undef FTMODERR_H_ + * #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, + * #define FT_MODERR_START_LIST { + * #define FT_MODERR_END_LIST { 0, 0 } }; + * + * const struct + * { + * int mod_err_offset; + * const char* mod_err_msg + * } ft_mod_errors[] = + * + * #include FT_MODULE_ERRORS_H + * ``` + * + */ #ifndef FTMODERR_H_ diff --git a/src/3rdparty/freetype/include/freetype/ftotval.h b/src/3rdparty/freetype/include/freetype/ftotval.h index 26731c2b9f..c034f48959 100644 --- a/src/3rdparty/freetype/include/freetype/ftotval.h +++ b/src/3rdparty/freetype/include/freetype/ftotval.h @@ -1,30 +1,30 @@ -/***************************************************************************/ -/* */ -/* ftotval.h */ -/* */ -/* FreeType API for validating OpenType tables (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* */ -/* Warning: This module might be moved to a different library in the */ -/* future to avoid a tight dependency between FreeType and the */ -/* OpenType specification. */ -/* */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftotval.h + * + * FreeType API for validating OpenType tables (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +/**************************************************************************** + * + * + * Warning: This module might be moved to a different library in the + * future to avoid a tight dependency between FreeType and the + * OpenType specification. + * + * + */ #ifndef FTOTVAL_H_ @@ -43,62 +43,62 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* ot_validation */ - /* */ - /* <Title> */ - /* OpenType Validation */ - /* */ - /* <Abstract> */ - /* An API to validate OpenType tables. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions to validate */ - /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */ - /* */ - /* <Order> */ - /* FT_OpenType_Validate */ - /* FT_OpenType_Free */ - /* */ - /* FT_VALIDATE_OTXXX */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_OTXXX - * - * @description: - * A list of bit-field constants used with @FT_OpenType_Validate to - * indicate which OpenType tables should be validated. - * - * @values: - * FT_VALIDATE_BASE :: - * Validate BASE table. - * - * FT_VALIDATE_GDEF :: - * Validate GDEF table. - * - * FT_VALIDATE_GPOS :: - * Validate GPOS table. - * - * FT_VALIDATE_GSUB :: - * Validate GSUB table. - * - * FT_VALIDATE_JSTF :: - * Validate JSTF table. - * - * FT_VALIDATE_MATH :: - * Validate MATH table. - * - * FT_VALIDATE_OT :: - * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). - * - */ + /************************************************************************** + * + * @section: + * ot_validation + * + * @title: + * OpenType Validation + * + * @abstract: + * An API to validate OpenType tables. + * + * @description: + * This section contains the declaration of functions to validate some + * OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). + * + * @order: + * FT_OpenType_Validate + * FT_OpenType_Free + * + * FT_VALIDATE_OTXXX + * + */ + + + /************************************************************************** + * + * @enum: + * FT_VALIDATE_OTXXX + * + * @description: + * A list of bit-field constants used with @FT_OpenType_Validate to + * indicate which OpenType tables should be validated. + * + * @values: + * FT_VALIDATE_BASE :: + * Validate BASE table. + * + * FT_VALIDATE_GDEF :: + * Validate GDEF table. + * + * FT_VALIDATE_GPOS :: + * Validate GPOS table. + * + * FT_VALIDATE_GSUB :: + * Validate GSUB table. + * + * FT_VALIDATE_JSTF :: + * Validate JSTF table. + * + * FT_VALIDATE_MATH :: + * Validate MATH table. + * + * FT_VALIDATE_OT :: + * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). + * + */ #define FT_VALIDATE_BASE 0x0100 #define FT_VALIDATE_GDEF 0x0200 #define FT_VALIDATE_GPOS 0x0400 @@ -113,53 +113,54 @@ FT_BEGIN_HEADER FT_VALIDATE_JSTF | \ FT_VALIDATE_MATH ) - /********************************************************************** - * - * @function: - * FT_OpenType_Validate - * - * @description: - * Validate various OpenType tables to assure that all offsets and - * indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without - * error checking (which can be quite time consuming). - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the tables to be validated. See - * @FT_VALIDATE_OTXXX for possible values. - * - * @output: - * BASE_table :: - * A pointer to the BASE table. - * - * GDEF_table :: - * A pointer to the GDEF table. - * - * GPOS_table :: - * A pointer to the GPOS table. - * - * GSUB_table :: - * A pointer to the GSUB table. - * - * JSTF_table :: - * A pointer to the JSTF table. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with OpenType fonts, returning an error - * otherwise. - * - * After use, the application should deallocate the five tables with - * @FT_OpenType_Free. A NULL value indicates that the table either - * doesn't exist in the font, or the application hasn't asked for - * validation. - */ + + /************************************************************************** + * + * @function: + * FT_OpenType_Validate + * + * @description: + * Validate various OpenType tables to assure that all offsets and + * indices are valid. The idea is that a higher-level library that + * actually does the text layout can access those tables without error + * checking (which can be quite time consuming). + * + * @input: + * face :: + * A handle to the input face. + * + * validation_flags :: + * A bit field that specifies the tables to be validated. See + * @FT_VALIDATE_OTXXX for possible values. + * + * @output: + * BASE_table :: + * A pointer to the BASE table. + * + * GDEF_table :: + * A pointer to the GDEF table. + * + * GPOS_table :: + * A pointer to the GPOS table. + * + * GSUB_table :: + * A pointer to the GSUB table. + * + * JSTF_table :: + * A pointer to the JSTF table. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function only works with OpenType fonts, returning an error + * otherwise. + * + * After use, the application should deallocate the five tables with + * @FT_OpenType_Free. A `NULL` value indicates that the table either + * doesn't exist in the font, or the application hasn't asked for + * validation. + */ FT_EXPORT( FT_Error ) FT_OpenType_Validate( FT_Face face, FT_UInt validation_flags, @@ -169,30 +170,32 @@ FT_BEGIN_HEADER FT_Bytes *GSUB_table, FT_Bytes *JSTF_table ); - /********************************************************************** - * - * @function: - * FT_OpenType_Free - * - * @description: - * Free the buffer allocated by OpenType validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer that is allocated by - * @FT_OpenType_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_OpenType_Validate only. - */ + + /************************************************************************** + * + * @function: + * FT_OpenType_Free + * + * @description: + * Free the buffer allocated by OpenType validator. + * + * @input: + * face :: + * A handle to the input face. + * + * table :: + * The pointer to the buffer that is allocated by + * @FT_OpenType_Validate. + * + * @note: + * This function must be used to free the buffer allocated by + * @FT_OpenType_Validate only. + */ FT_EXPORT( void ) FT_OpenType_Free( FT_Face face, FT_Bytes table ); + /* */ diff --git a/src/3rdparty/freetype/include/freetype/ftoutln.h b/src/3rdparty/freetype/include/freetype/ftoutln.h index 89389a49b7..b72327b703 100644 --- a/src/3rdparty/freetype/include/freetype/ftoutln.h +++ b/src/3rdparty/freetype/include/freetype/ftoutln.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftoutln.h */ -/* */ -/* Support for the FT_Outline type used to store glyph shapes of */ -/* most scalable font formats (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftoutln.h + * + * Support for the FT_Outline type used to store glyph shapes of + * most scalable font formats (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTOUTLN_H_ @@ -34,127 +34,131 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /* <Title> */ - /* Outline Processing */ - /* */ - /* <Abstract> */ - /* Functions to create, transform, and render vectorial glyph images. */ - /* */ - /* <Description> */ - /* This section contains routines used to create and destroy scalable */ - /* glyph images known as `outlines'. These can also be measured, */ - /* transformed, and converted into bitmaps and pixmaps. */ - /* */ - /* <Order> */ - /* FT_Outline */ - /* FT_Outline_New */ - /* FT_Outline_Done */ - /* FT_Outline_Copy */ - /* FT_Outline_Translate */ - /* FT_Outline_Transform */ - /* FT_Outline_Embolden */ - /* FT_Outline_EmboldenXY */ - /* FT_Outline_Reverse */ - /* FT_Outline_Check */ - /* */ - /* FT_Outline_Get_CBox */ - /* FT_Outline_Get_BBox */ - /* */ - /* FT_Outline_Get_Bitmap */ - /* FT_Outline_Render */ - /* FT_Outline_Decompose */ - /* FT_Outline_Funcs */ - /* FT_Outline_MoveToFunc */ - /* FT_Outline_LineToFunc */ - /* FT_Outline_ConicToFunc */ - /* FT_Outline_CubicToFunc */ - /* */ - /* FT_Orientation */ - /* FT_Outline_Get_Orientation */ - /* */ - /* FT_OUTLINE_XXX */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Decompose */ - /* */ - /* <Description> */ - /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bezier arcs. This function also emits `move to' */ - /* operations to indicate the start of new contours in the outline. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source target. */ - /* */ - /* func_interface :: A table of `emitters', i.e., function pointers */ - /* called during decomposition to indicate path */ - /* operations. */ - /* */ - /* <InOut> */ - /* user :: A typeless pointer that is passed to each */ - /* emitter during the decomposition. It can be */ - /* used to store the state during the */ - /* decomposition. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* A contour that contains a single point only is represented by a */ - /* `move to' operation followed by `line to' to the same point. In */ - /* most cases, it is best to filter this out before using the */ - /* outline for stroking purposes (otherwise it would result in a */ - /* visible dot when round caps are used). */ - /* */ - /* Similarly, the function returns success for an empty outline also */ - /* (doing nothing, this is, not calling any emitter); if necessary, */ - /* you should filter this out, too. */ - /* */ + /************************************************************************** + * + * @section: + * outline_processing + * + * @title: + * Outline Processing + * + * @abstract: + * Functions to create, transform, and render vectorial glyph images. + * + * @description: + * This section contains routines used to create and destroy scalable + * glyph images known as 'outlines'. These can also be measured, + * transformed, and converted into bitmaps and pixmaps. + * + * @order: + * FT_Outline + * FT_Outline_New + * FT_Outline_Done + * FT_Outline_Copy + * FT_Outline_Translate + * FT_Outline_Transform + * FT_Outline_Embolden + * FT_Outline_EmboldenXY + * FT_Outline_Reverse + * FT_Outline_Check + * + * FT_Outline_Get_CBox + * FT_Outline_Get_BBox + * + * FT_Outline_Get_Bitmap + * FT_Outline_Render + * FT_Outline_Decompose + * FT_Outline_Funcs + * FT_Outline_MoveToFunc + * FT_Outline_LineToFunc + * FT_Outline_ConicToFunc + * FT_Outline_CubicToFunc + * + * FT_Orientation + * FT_Outline_Get_Orientation + * + * FT_OUTLINE_XXX + * + */ + + + /************************************************************************** + * + * @function: + * FT_Outline_Decompose + * + * @description: + * Walk over an outline's structure to decompose it into individual + * segments and Bezier arcs. This function also emits 'move to' + * operations to indicate the start of new contours in the outline. + * + * @input: + * outline :: + * A pointer to the source target. + * + * func_interface :: + * A table of 'emitters', i.e., function pointers called during + * decomposition to indicate path operations. + * + * @inout: + * user :: + * A typeless pointer that is passed to each emitter during the + * decomposition. It can be used to store the state during the + * decomposition. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * A contour that contains a single point only is represented by a 'move + * to' operation followed by 'line to' to the same point. In most cases, + * it is best to filter this out before using the outline for stroking + * purposes (otherwise it would result in a visible dot when round caps + * are used). + * + * Similarly, the function returns success for an empty outline also + * (doing nothing, this is, not calling any emitter); if necessary, you + * should filter this out, too. + */ FT_EXPORT( FT_Error ) FT_Outline_Decompose( FT_Outline* outline, const FT_Outline_Funcs* func_interface, void* user ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_New */ - /* */ - /* <Description> */ - /* Create a new outline of a given size. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object from where the */ - /* outline is allocated. Note however that the new */ - /* outline will *not* necessarily be *freed*, when */ - /* destroying the library, by @FT_Done_FreeType. */ - /* */ - /* numPoints :: The maximum number of points within the outline. */ - /* Must be smaller than or equal to 0xFFFF (65535). */ - /* */ - /* numContours :: The maximum number of contours within the outline. */ - /* This value must be in the range 0 to `numPoints'. */ - /* */ - /* <Output> */ - /* anoutline :: A handle to the new outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' parameter is simply */ - /* to use the library's memory allocator. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_New + * + * @description: + * Create a new outline of a given size. + * + * @input: + * library :: + * A handle to the library object from where the outline is allocated. + * Note however that the new outline will **not** necessarily be + * **freed**, when destroying the library, by @FT_Done_FreeType. + * + * numPoints :: + * The maximum number of points within the outline. Must be smaller + * than or equal to 0xFFFF (65535). + * + * numContours :: + * The maximum number of contours within the outline. This value must + * be in the range 0 to `numPoints`. + * + * @output: + * anoutline :: + * A handle to the new outline. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The reason why this function takes a `library` parameter is simply to + * use the library's memory allocator. + */ FT_EXPORT( FT_Error ) FT_Outline_New( FT_Library library, FT_UInt numPoints, @@ -162,372 +166,378 @@ FT_BEGIN_HEADER FT_Outline *anoutline ); - FT_EXPORT( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Done */ - /* */ - /* <Description> */ - /* Destroy an outline created with @FT_Outline_New. */ - /* */ - /* <Input> */ - /* library :: A handle of the library object used to allocate the */ - /* outline. */ - /* */ - /* outline :: A pointer to the outline object to be discarded. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the outline's `owner' field is not set, only the outline */ - /* descriptor will be released. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Done + * + * @description: + * Destroy an outline created with @FT_Outline_New. + * + * @input: + * library :: + * A handle of the library object used to allocate the outline. + * + * outline :: + * A pointer to the outline object to be discarded. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the outline's 'owner' field is not set, only the outline descriptor + * will be released. + */ FT_EXPORT( FT_Error ) FT_Outline_Done( FT_Library library, FT_Outline* outline ); - FT_EXPORT( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Check */ - /* */ - /* <Description> */ - /* Check the contents of an outline descriptor. */ - /* */ - /* <Input> */ - /* outline :: A handle to a source outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An empty outline, or an outline with a single point only is also */ - /* valid. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Check + * + * @description: + * Check the contents of an outline descriptor. + * + * @input: + * outline :: + * A handle to a source outline. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * An empty outline, or an outline with a single point only is also + * valid. + */ FT_EXPORT( FT_Error ) FT_Outline_Check( FT_Outline* outline ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_CBox */ - /* */ - /* <Description> */ - /* Return an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bezier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bezier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <Output> */ - /* acbox :: The outline's control box. */ - /* */ - /* <Note> */ - /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Get_CBox + * + * @description: + * Return an outline's 'control box'. The control box encloses all the + * outline's points, including Bezier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline that + * contains Bezier outside arcs). + * + * Computing the control box is very fast, while getting the bounding box + * can take much more time as it needs to walk over all segments and arcs + * in the outline. To get the latter, you can use the 'ftbbox' + * component, which is dedicated to this single task. + * + * @input: + * outline :: + * A pointer to the source outline descriptor. + * + * @output: + * acbox :: + * The outline's control box. + * + * @note: + * See @FT_Glyph_Get_CBox for a discussion of tricky fonts. + */ FT_EXPORT( void ) FT_Outline_Get_CBox( const FT_Outline* outline, FT_BBox *acbox ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Translate */ - /* */ - /* <Description> */ - /* Apply a simple translation to the points of an outline. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* xOffset :: The horizontal offset. */ - /* */ - /* yOffset :: The vertical offset. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Translate + * + * @description: + * Apply a simple translation to the points of an outline. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @input: + * xOffset :: + * The horizontal offset. + * + * yOffset :: + * The vertical offset. + */ FT_EXPORT( void ) FT_Outline_Translate( const FT_Outline* outline, FT_Pos xOffset, FT_Pos yOffset ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Copy */ - /* */ - /* <Description> */ - /* Copy an outline into another one. Both objects must have the */ - /* same sizes (number of points & number of contours) when this */ - /* function is called. */ - /* */ - /* <Input> */ - /* source :: A handle to the source outline. */ - /* */ - /* <Output> */ - /* target :: A handle to the target outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Copy + * + * @description: + * Copy an outline into another one. Both objects must have the same + * sizes (number of points & number of contours) when this function is + * called. + * + * @input: + * source :: + * A handle to the source outline. + * + * @output: + * target :: + * A handle to the target outline. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Outline_Copy( const FT_Outline* source, FT_Outline *target ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Transform */ - /* */ - /* <Description> */ - /* Apply a simple 2x2 matrix to all of an outline's points. Useful */ - /* for applying rotations, slanting, flipping, etc. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation matrix. */ - /* */ - /* <Note> */ - /* You can use @FT_Outline_Translate if you need to translate the */ - /* outline's points. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Transform + * + * @description: + * Apply a simple 2x2 matrix to all of an outline's points. Useful for + * applying rotations, slanting, flipping, etc. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @input: + * matrix :: + * A pointer to the transformation matrix. + * + * @note: + * You can use @FT_Outline_Translate if you need to translate the + * outline's points. + */ FT_EXPORT( void ) FT_Outline_Transform( const FT_Outline* outline, const FT_Matrix* matrix ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Embolden */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be at most 4~times */ - /* `strength' pixels wider and higher. You may think of the left and */ - /* bottom borders as unchanged. */ - /* */ - /* Negative `strength' values to reduce the outline thickness are */ - /* possible also. */ - /* */ - /* <InOut> */ - /* outline :: A handle to the target outline. */ - /* */ - /* <Input> */ - /* strength :: How strong the glyph is emboldened. Expressed in */ - /* 26.6 pixel format. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The used algorithm to increase or decrease the thickness of the */ - /* glyph doesn't change the number of points; this means that certain */ - /* situations like acute angles or intersections are sometimes */ - /* handled incorrectly. */ - /* */ - /* If you need `better' metrics values you should call */ - /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */ - /* */ - /* Example call: */ - /* */ - /* { */ - /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ - /* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */ - /* FT_Outline_Embolden( &face->glyph->outline, strength ); */ - /* } */ - /* */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Embolden + * + * @description: + * Embolden an outline. The new outline will be at most 4~times + * `strength` pixels wider and higher. You may think of the left and + * bottom borders as unchanged. + * + * Negative `strength` values to reduce the outline thickness are + * possible also. + * + * @inout: + * outline :: + * A handle to the target outline. + * + * @input: + * strength :: + * How strong the glyph is emboldened. Expressed in 26.6 pixel format. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The used algorithm to increase or decrease the thickness of the glyph + * doesn't change the number of points; this means that certain + * situations like acute angles or intersections are sometimes handled + * incorrectly. + * + * If you need 'better' metrics values you should call + * @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. + * + * To get meaningful results, font scaling values must be set with + * functions like @FT_Set_Char_Size before calling FT_Render_Glyph. + * + * @example: + * ``` + * FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); + * + * if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) + * FT_Outline_Embolden( &face->glyph->outline, strength ); + * ``` + * + */ FT_EXPORT( FT_Error ) FT_Outline_Embolden( FT_Outline* outline, FT_Pos strength ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_EmboldenXY */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be `xstrength' pixels */ - /* wider and `ystrength' pixels higher. Otherwise, it is similar to */ - /* @FT_Outline_Embolden, which uses the same strength in both */ - /* directions. */ - /* */ - /* <Since> */ - /* 2.4.10 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_EmboldenXY + * + * @description: + * Embolden an outline. The new outline will be `xstrength` pixels wider + * and `ystrength` pixels higher. Otherwise, it is similar to + * @FT_Outline_Embolden, which uses the same strength in both directions. + * + * @since: + * 2.4.10 + */ FT_EXPORT( FT_Error ) FT_Outline_EmboldenXY( FT_Outline* outline, FT_Pos xstrength, FT_Pos ystrength ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Reverse */ - /* */ - /* <Description> */ - /* Reverse the drawing direction of an outline. This is used to */ - /* ensure consistent fill conventions for mirrored glyphs. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Note> */ - /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ - /* the outline's `flags' field. */ - /* */ - /* It shouldn't be used by a normal client application, unless it */ - /* knows what it is doing. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Reverse + * + * @description: + * Reverse the drawing direction of an outline. This is used to ensure + * consistent fill conventions for mirrored glyphs. + * + * @inout: + * outline :: + * A pointer to the target outline descriptor. + * + * @note: + * This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the + * outline's `flags` field. + * + * It shouldn't be used by a normal client application, unless it knows + * what it is doing. + */ FT_EXPORT( void ) FT_Outline_Reverse( FT_Outline* outline ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_Bitmap */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap. The outline's image is simply */ - /* OR-ed to the target bitmap. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the target bitmap descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does NOT CREATE the bitmap, it only renders an */ - /* outline image within the one you pass to it! Consequently, the */ - /* various fields in `abitmap' should be set accordingly. */ - /* */ - /* It will use the raster corresponding to the default glyph format. */ - /* */ - /* The value of the `num_grays' field in `abitmap' is ignored. If */ - /* you select the gray-level rasterizer, and you want less than 256 */ - /* gray levels, you have to use @FT_Outline_Render directly. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Get_Bitmap + * + * @description: + * Render an outline within a bitmap. The outline's image is simply + * OR-ed to the target bitmap. + * + * @input: + * library :: + * A handle to a FreeType library object. + * + * outline :: + * A pointer to the source outline descriptor. + * + * @inout: + * abitmap :: + * A pointer to the target bitmap descriptor. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function does **not create** the bitmap, it only renders an + * outline image within the one you pass to it! Consequently, the + * various fields in `abitmap` should be set accordingly. + * + * It will use the raster corresponding to the default glyph format. + * + * The value of the `num_grays` field in `abitmap` is ignored. If you + * select the gray-level rasterizer, and you want less than 256 gray + * levels, you have to use @FT_Outline_Render directly. + */ FT_EXPORT( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library, FT_Outline* outline, const FT_Bitmap *abitmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Render */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap using the current scan-convert. */ - /* This function uses an @FT_Raster_Params structure as an argument, */ - /* allowing advanced features like direct composition, translucency, */ - /* etc. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* describe the rendering operation. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should know what you are doing and how @FT_Raster_Params works */ - /* to use this function. */ - /* */ - /* The field `params.source' will be set to `outline' before the scan */ - /* converter is called, which means that the value you give to it is */ - /* actually ignored. */ - /* */ - /* The gray-level rasterizer always uses 256 gray levels. If you */ - /* want less gray levels, you have to provide your own span callback. */ - /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ - /* @FT_Raster_Params structure for more details. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Outline_Render + * + * @description: + * Render an outline within a bitmap using the current scan-convert. + * + * @input: + * library :: + * A handle to a FreeType library object. + * + * outline :: + * A pointer to the source outline descriptor. + * + * @inout: + * params :: + * A pointer to an @FT_Raster_Params structure used to describe the + * rendering operation. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This advanced function uses @FT_Raster_Params as an argument, + * allowing FreeType rasterizer to be used for direct composition, + * translucency, etc. You should know how to set up @FT_Raster_Params + * for this function to work. + * + * The field `params.source` will be set to `outline` before the scan + * converter is called, which means that the value you give to it is + * actually ignored. + * + * The gray-level rasterizer always uses 256 gray levels. If you want + * less gray levels, you have to provide your own span callback. See the + * @FT_RASTER_FLAG_DIRECT value of the `flags` field in the + * @FT_Raster_Params structure for more details. + */ FT_EXPORT( FT_Error ) FT_Outline_Render( FT_Library library, FT_Outline* outline, FT_Raster_Params* params ); - /************************************************************************** - * - * @enum: - * FT_Orientation - * - * @description: - * A list of values used to describe an outline's contour orientation. - * - * The TrueType and PostScript specifications use different conventions - * to determine whether outline contours should be filled or unfilled. - * - * @values: - * FT_ORIENTATION_TRUETYPE :: - * According to the TrueType specification, clockwise contours must - * be filled, and counter-clockwise ones must be unfilled. - * - * FT_ORIENTATION_POSTSCRIPT :: - * According to the PostScript specification, counter-clockwise contours - * must be filled, and clockwise ones must be unfilled. - * - * FT_ORIENTATION_FILL_RIGHT :: - * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to - * remember that in TrueType, everything that is to the right of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_FILL_LEFT :: - * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to - * remember that in PostScript, everything that is to the left of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_NONE :: - * The orientation cannot be determined. That is, different parts of - * the glyph have different orientation. - * - */ + /************************************************************************** + * + * @enum: + * FT_Orientation + * + * @description: + * A list of values used to describe an outline's contour orientation. + * + * The TrueType and PostScript specifications use different conventions + * to determine whether outline contours should be filled or unfilled. + * + * @values: + * FT_ORIENTATION_TRUETYPE :: + * According to the TrueType specification, clockwise contours must be + * filled, and counter-clockwise ones must be unfilled. + * + * FT_ORIENTATION_POSTSCRIPT :: + * According to the PostScript specification, counter-clockwise + * contours must be filled, and clockwise ones must be unfilled. + * + * FT_ORIENTATION_FILL_RIGHT :: + * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to + * remember that in TrueType, everything that is to the right of the + * drawing direction of a contour must be filled. + * + * FT_ORIENTATION_FILL_LEFT :: + * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to + * remember that in PostScript, everything that is to the left of the + * drawing direction of a contour must be filled. + * + * FT_ORIENTATION_NONE :: + * The orientation cannot be determined. That is, different parts of + * the glyph have different orientation. + * + */ typedef enum FT_Orientation_ { FT_ORIENTATION_TRUETYPE = 0, @@ -539,33 +549,34 @@ FT_BEGIN_HEADER } FT_Orientation; - /************************************************************************** - * - * @function: - * FT_Outline_Get_Orientation - * - * @description: - * This function analyzes a glyph outline and tries to compute its - * fill orientation (see @FT_Orientation). This is done by integrating - * the total area covered by the outline. The positive integral - * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT - * is returned. The negative integral corresponds to the counter-clockwise - * orientation and @FT_ORIENTATION_TRUETYPE is returned. - * - * Note that this will return @FT_ORIENTATION_TRUETYPE for empty - * outlines. - * - * @input: - * outline :: - * A handle to the source outline. - * - * @return: - * The orientation. - * - */ + /************************************************************************** + * + * @function: + * FT_Outline_Get_Orientation + * + * @description: + * This function analyzes a glyph outline and tries to compute its fill + * orientation (see @FT_Orientation). This is done by integrating the + * total area covered by the outline. The positive integral corresponds + * to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is + * returned. The negative integral corresponds to the counter-clockwise + * orientation and @FT_ORIENTATION_TRUETYPE is returned. + * + * Note that this will return @FT_ORIENTATION_TRUETYPE for empty + * outlines. + * + * @input: + * outline :: + * A handle to the source outline. + * + * @return: + * The orientation. + * + */ FT_EXPORT( FT_Orientation ) FT_Outline_Get_Orientation( FT_Outline* outline ); + /* */ diff --git a/src/3rdparty/freetype/include/freetype/ftparams.h b/src/3rdparty/freetype/include/freetype/ftparams.h index 5a9006c505..c374ee2f2f 100644 --- a/src/3rdparty/freetype/include/freetype/ftparams.h +++ b/src/3rdparty/freetype/include/freetype/ftparams.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftparams.h */ -/* */ -/* FreeType API for possible FT_Parameter tags (specification only). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftparams.h + * + * FreeType API for possible FT_Parameter tags (specification only). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTPARAMS_H_ @@ -51,16 +51,16 @@ FT_BEGIN_HEADER */ - /*************************************************************************** + /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY * * @description: * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic - * family names in the `name' table (introduced in OpenType version - * 1.4). Use this for backward compatibility with legacy systems that - * have a four-faces-per-family restriction. + * family names in the 'name' table (introduced in OpenType version 1.4). + * Use this for backward compatibility with legacy systems that have a + * four-faces-per-family restriction. * * @since: * 2.8 @@ -75,14 +75,14 @@ FT_BEGIN_HEADER FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY - /*************************************************************************** + /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY * * @description: * A tag for @FT_Parameter to make @FT_Open_Face ignore typographic - * subfamily names in the `name' table (introduced in OpenType version + * subfamily names in the 'name' table (introduced in OpenType version * 1.4). Use this for backward compatibility with legacy systems that * have a four-faces-per-family restriction. * @@ -99,9 +99,9 @@ FT_BEGIN_HEADER FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY - /*************************************************************************** + /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_INCREMENTAL * * @description: @@ -115,14 +115,14 @@ FT_BEGIN_HEADER /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_LCD_FILTER_WEIGHTS * * @description: * An @FT_Parameter tag to be used with @FT_Face_Properties. The * corresponding argument specifies the five LCD filter weights for a - * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding - * the global default values or the values set up with + * given face (if using @FT_LOAD_TARGET_LCD, for example), overriding the + * global default values or the values set up with * @FT_Library_SetLcdFilterWeights. * * @since: @@ -135,14 +135,13 @@ FT_BEGIN_HEADER /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_RANDOM_SEED * * @description: * An @FT_Parameter tag to be used with @FT_Face_Properties. The * corresponding 32bit signed integer argument overrides the font - * driver's random seed value with a face-specific one; see - * @random-seed. + * driver's random seed value with a face-specific one; see @random-seed. * * @since: * 2.8 @@ -154,7 +153,7 @@ FT_BEGIN_HEADER /************************************************************************** * - * @constant: + * @enum: * FT_PARAM_TAG_STEM_DARKENING * * @description: @@ -163,10 +162,10 @@ FT_BEGIN_HEADER * darkening, overriding the global default values or the values set up * with @FT_Property_Set (see @no-stem-darkening). * - * This is a passive setting that only takes effect if the font driver - * or autohinter honors it, which the CFF, Type~1, and CID drivers - * always do, but the autohinter only in `light' hinting mode (as of - * version 2.9). + * This is a passive setting that only takes effect if the font driver or + * autohinter honors it, which the CFF, Type~1, and CID drivers always + * do, but the autohinter only in 'light' hinting mode (as of version + * 2.9). * * @since: * 2.8 @@ -176,19 +175,19 @@ FT_BEGIN_HEADER FT_MAKE_TAG( 'd', 'a', 'r', 'k' ) - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_UNPATENTED_HINTING - * - * @description: - * Deprecated, no effect. - * - * Previously: A constant used as the tag of an @FT_Parameter structure to - * indicate that unpatented methods only should be used by the TrueType - * bytecode interpreter for a typeface opened by @FT_Open_Face. - * - */ + /************************************************************************** + * + * @enum: + * FT_PARAM_TAG_UNPATENTED_HINTING + * + * @description: + * Deprecated, no effect. + * + * Previously: A constant used as the tag of an @FT_Parameter structure + * to indicate that unpatented methods only should be used by the + * TrueType bytecode interpreter for a typeface opened by @FT_Open_Face. + * + */ #define FT_PARAM_TAG_UNPATENTED_HINTING \ FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) diff --git a/src/3rdparty/freetype/include/freetype/ftpfr.h b/src/3rdparty/freetype/include/freetype/ftpfr.h index a69cc482dc..b4eca76eb7 100644 --- a/src/3rdparty/freetype/include/freetype/ftpfr.h +++ b/src/3rdparty/freetype/include/freetype/ftpfr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftpfr.h */ -/* */ -/* FreeType API for accessing PFR-specific data (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpfr.h + * + * FreeType API for accessing PFR-specific data (specification only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTPFR_H_ @@ -32,60 +32,61 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* pfr_fonts */ - /* */ - /* <Title> */ - /* PFR Fonts */ - /* */ - /* <Abstract> */ - /* PFR/TrueDoc specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of PFR-specific functions. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Metrics - * - * @description: - * Return the outline and metrics resolutions of a given PFR face. - * - * @input: - * face :: Handle to the input face. It can be a non-PFR face. - * - * @output: - * aoutline_resolution :: - * Outline resolution. This is equivalent to `face->units_per_EM' - * for non-PFR fonts. Optional (parameter can be NULL). - * - * ametrics_resolution :: - * Metrics resolution. This is equivalent to `outline_resolution' - * for non-PFR fonts. Optional (parameter can be NULL). - * - * ametrics_x_scale :: - * A 16.16 fixed-point number used to scale distance expressed - * in metrics units to device subpixels. This is equivalent to - * `face->size->x_scale', but for metrics only. Optional (parameter - * can be NULL). - * - * ametrics_y_scale :: - * Same as `ametrics_x_scale' but for the vertical direction. - * optional (parameter can be NULL). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If the input face is not a PFR, this function will return an error. - * However, in all cases, it will return valid values. - */ + /************************************************************************** + * + * @section: + * pfr_fonts + * + * @title: + * PFR Fonts + * + * @abstract: + * PFR/TrueDoc-specific API. + * + * @description: + * This section contains the declaration of PFR-specific functions. + * + */ + + + /************************************************************************** + * + * @function: + * FT_Get_PFR_Metrics + * + * @description: + * Return the outline and metrics resolutions of a given PFR face. + * + * @input: + * face :: + * Handle to the input face. It can be a non-PFR face. + * + * @output: + * aoutline_resolution :: + * Outline resolution. This is equivalent to `face->units_per_EM` for + * non-PFR fonts. Optional (parameter can be `NULL`). + * + * ametrics_resolution :: + * Metrics resolution. This is equivalent to `outline_resolution` for + * non-PFR fonts. Optional (parameter can be `NULL`). + * + * ametrics_x_scale :: + * A 16.16 fixed-point number used to scale distance expressed in + * metrics units to device subpixels. This is equivalent to + * `face->size->x_scale`, but for metrics only. Optional (parameter + * can be `NULL`). + * + * ametrics_y_scale :: + * Same as `ametrics_x_scale` but for the vertical direction. + * optional (parameter can be `NULL`). + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If the input face is not a PFR, this function will return an error. + * However, in all cases, it will return valid values. + */ FT_EXPORT( FT_Error ) FT_Get_PFR_Metrics( FT_Face face, FT_UInt *aoutline_resolution, @@ -94,37 +95,41 @@ FT_BEGIN_HEADER FT_Fixed *ametrics_y_scale ); - /********************************************************************** - * - * @function: - * FT_Get_PFR_Kerning - * - * @description: - * Return the kerning pair corresponding to two glyphs in a PFR face. - * The distance is expressed in metrics units, unlike the result of - * @FT_Get_Kerning. - * - * @input: - * face :: A handle to the input face. - * - * left :: Index of the left glyph. - * - * right :: Index of the right glyph. - * - * @output: - * avector :: A kerning vector. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function always return distances in original PFR metrics - * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED - * mode, which always returns distances converted to outline units. - * - * You can use the value of the `x_scale' and `y_scale' parameters - * returned by @FT_Get_PFR_Metrics to scale these to device subpixels. - */ + /************************************************************************** + * + * @function: + * FT_Get_PFR_Kerning + * + * @description: + * Return the kerning pair corresponding to two glyphs in a PFR face. + * The distance is expressed in metrics units, unlike the result of + * @FT_Get_Kerning. + * + * @input: + * face :: + * A handle to the input face. + * + * left :: + * Index of the left glyph. + * + * right :: + * Index of the right glyph. + * + * @output: + * avector :: + * A kerning vector. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * This function always return distances in original PFR metrics units. + * This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED mode, + * which always returns distances converted to outline units. + * + * You can use the value of the `x_scale` and `y_scale` parameters + * returned by @FT_Get_PFR_Metrics to scale these to device subpixels. + */ FT_EXPORT( FT_Error ) FT_Get_PFR_Kerning( FT_Face face, FT_UInt left, @@ -132,30 +137,33 @@ FT_BEGIN_HEADER FT_Vector *avector ); - /********************************************************************** - * - * @function: - * FT_Get_PFR_Advance - * - * @description: - * Return a given glyph advance, expressed in original metrics units, - * from a PFR font. - * - * @input: - * face :: A handle to the input face. - * - * gindex :: The glyph index. - * - * @output: - * aadvance :: The glyph advance in metrics units. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics - * to convert the advance to device subpixels (i.e., 1/64th of pixels). - */ + /************************************************************************** + * + * @function: + * FT_Get_PFR_Advance + * + * @description: + * Return a given glyph advance, expressed in original metrics units, + * from a PFR font. + * + * @input: + * face :: + * A handle to the input face. + * + * gindex :: + * The glyph index. + * + * @output: + * aadvance :: + * The glyph advance in metrics units. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You can use the `x_scale` or `y_scale` results of @FT_Get_PFR_Metrics + * to convert the advance to device subpixels (i.e., 1/64th of pixels). + */ FT_EXPORT( FT_Error ) FT_Get_PFR_Advance( FT_Face face, FT_UInt gindex, diff --git a/src/3rdparty/freetype/include/freetype/ftrender.h b/src/3rdparty/freetype/include/freetype/ftrender.h index fa8ad22b98..a01c774272 100644 --- a/src/3rdparty/freetype/include/freetype/ftrender.h +++ b/src/3rdparty/freetype/include/freetype/ftrender.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftrender.h */ -/* */ -/* FreeType renderer modules public interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrender.h + * + * FreeType renderer modules public interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTRENDER_H_ @@ -28,12 +28,12 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * module_management + * + */ /* create a new glyph object */ @@ -116,32 +116,38 @@ FT_BEGIN_HEADER #define FTRenderer_setMode FT_Renderer_SetModeFunc - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Renderer_Class */ - /* */ - /* <Description> */ - /* The renderer module class descriptor. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Module_Class fields. */ - /* */ - /* glyph_format :: The glyph image format this renderer handles. */ - /* */ - /* render_glyph :: A method used to render the image that is in a */ - /* given glyph slot into a bitmap. */ - /* */ - /* transform_glyph :: A method used to transform the image that is in */ - /* a given glyph slot. */ - /* */ - /* get_glyph_cbox :: A method used to access the glyph's cbox. */ - /* */ - /* set_mode :: A method used to pass additional parameters. */ - /* */ - /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ - /* This is a pointer to its raster's class. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Renderer_Class + * + * @description: + * The renderer module class descriptor. + * + * @fields: + * root :: + * The root @FT_Module_Class fields. + * + * glyph_format :: + * The glyph image format this renderer handles. + * + * render_glyph :: + * A method used to render the image that is in a given glyph slot into + * a bitmap. + * + * transform_glyph :: + * A method used to transform the image that is in a given glyph slot. + * + * get_glyph_cbox :: + * A method used to access the glyph's cbox. + * + * set_mode :: + * A method used to pass additional parameters. + * + * raster_class :: + * For @FT_GLYPH_FORMAT_OUTLINE renderers only. This is a pointer to + * its raster's class. + */ typedef struct FT_Renderer_Class_ { FT_Module_Class root; @@ -158,64 +164,70 @@ FT_BEGIN_HEADER } FT_Renderer_Class; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Renderer */ - /* */ - /* <Description> */ - /* Retrieve the current renderer for a given glyph format. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* format :: The glyph format. */ - /* */ - /* <Return> */ - /* A renderer handle. 0~if none found. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ - /* renderer by its name, use @FT_Get_Module. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Renderer + * + * @description: + * Retrieve the current renderer for a given glyph format. + * + * @input: + * library :: + * A handle to the library object. + * + * format :: + * The glyph format. + * + * @return: + * A renderer handle. 0~if none found. + * + * @note: + * An error will be returned if a module already exists by that name, or + * if the module requires a version of FreeType that is too great. + * + * To add a new renderer, simply use @FT_Add_Module. To retrieve a + * renderer by its name, use @FT_Get_Module. + */ FT_EXPORT( FT_Renderer ) FT_Get_Renderer( FT_Library library, FT_Glyph_Format format ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Renderer */ - /* */ - /* <Description> */ - /* Set the current renderer to use, and set additional mode. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* renderer :: A handle to the renderer object. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* parameters :: Additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case of success, the renderer will be used to convert glyph */ - /* images in the renderer's known format into bitmaps. */ - /* */ - /* This doesn't change the current renderer for other formats. */ - /* */ - /* Currently, no FreeType renderer module uses `parameters'; you */ - /* should thus always pass NULL as the value. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Set_Renderer + * + * @description: + * Set the current renderer to use, and set additional mode. + * + * @inout: + * library :: + * A handle to the library object. + * + * @input: + * renderer :: + * A handle to the renderer object. + * + * num_params :: + * The number of additional parameters. + * + * parameters :: + * Additional parameters. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * In case of success, the renderer will be used to convert glyph images + * in the renderer's known format into bitmaps. + * + * This doesn't change the current renderer for other formats. + * + * Currently, no FreeType renderer module uses `parameters`; you should + * thus always pass `NULL` as the value. + */ FT_EXPORT( FT_Error ) FT_Set_Renderer( FT_Library library, FT_Renderer renderer, diff --git a/src/3rdparty/freetype/include/freetype/ftsizes.h b/src/3rdparty/freetype/include/freetype/ftsizes.h index 72cb08bf2a..6c63cef2bf 100644 --- a/src/3rdparty/freetype/include/freetype/ftsizes.h +++ b/src/3rdparty/freetype/include/freetype/ftsizes.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftsizes.h */ -/* */ -/* FreeType size objects management (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Typical application would normally not need to use these functions. */ - /* However, they have been placed in a public API for the rare cases */ - /* where they are needed. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftsizes.h + * + * FreeType size objects management (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * Typical application would normally not need to use these functions. + * However, they have been placed in a public API for the rare cases where + * they are needed. + * + */ #ifndef FTSIZES_H_ @@ -42,109 +42,110 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* sizes_management */ - /* */ - /* <Title> */ - /* Size Management */ - /* */ - /* <Abstract> */ - /* Managing multiple sizes per face. */ - /* */ - /* <Description> */ - /* When creating a new face object (e.g., with @FT_New_Face), an */ - /* @FT_Size object is automatically created and used to store all */ - /* pixel-size dependent information, available in the `face->size' */ - /* field. */ - /* */ - /* It is however possible to create more sizes for a given face, */ - /* mostly in order to manage several character pixel sizes of the */ - /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ - /* */ - /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ - /* modify the contents of the current `active' size; you thus need */ - /* to use @FT_Activate_Size to change it. */ - /* */ - /* 99% of applications won't need the functions provided here, */ - /* especially if they use the caching sub-system, so be cautious */ - /* when using these. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Size */ - /* */ - /* <Description> */ - /* Create a new size object from a given face object. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* asize :: A handle to a new size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You need to call @FT_Activate_Size in order to select the new size */ - /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ - /* @FT_Load_Glyph, @FT_Load_Char, etc. */ - /* */ + /************************************************************************** + * + * @section: + * sizes_management + * + * @title: + * Size Management + * + * @abstract: + * Managing multiple sizes per face. + * + * @description: + * When creating a new face object (e.g., with @FT_New_Face), an @FT_Size + * object is automatically created and used to store all pixel-size + * dependent information, available in the `face->size` field. + * + * It is however possible to create more sizes for a given face, mostly + * in order to manage several character pixel sizes of the same font + * family and style. See @FT_New_Size and @FT_Done_Size. + * + * Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only modify the + * contents of the current 'active' size; you thus need to use + * @FT_Activate_Size to change it. + * + * 99% of applications won't need the functions provided here, especially + * if they use the caching sub-system, so be cautious when using these. + * + */ + + + /************************************************************************** + * + * @function: + * FT_New_Size + * + * @description: + * Create a new size object from a given face object. + * + * @input: + * face :: + * A handle to a parent face object. + * + * @output: + * asize :: + * A handle to a new size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * You need to call @FT_Activate_Size in order to select the new size for + * upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, + * @FT_Load_Glyph, @FT_Load_Char, etc. + */ FT_EXPORT( FT_Error ) FT_New_Size( FT_Face face, FT_Size* size ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Size */ - /* */ - /* <Description> */ - /* Discard a given size object. Note that @FT_Done_Face */ - /* automatically discards all size objects allocated with */ - /* @FT_New_Size. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Size + * + * @description: + * Discard a given size object. Note that @FT_Done_Face automatically + * discards all size objects allocated with @FT_New_Size. + * + * @input: + * size :: + * A handle to a target size object. + * + * @return: + * FreeType error code. 0~means success. + */ FT_EXPORT( FT_Error ) FT_Done_Size( FT_Size size ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Activate_Size */ - /* */ - /* <Description> */ - /* Even though it is possible to create several size objects for a */ - /* given face (see @FT_New_Size for details), functions like */ - /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ - /* activated last to determine the `current character pixel size'. */ - /* */ - /* This function can be used to `activate' a previously created size */ - /* object. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If `face' is the size's parent face object, this function changes */ - /* the value of `face->size' to the input size handle. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Activate_Size + * + * @description: + * Even though it is possible to create several size objects for a given + * face (see @FT_New_Size for details), functions like @FT_Load_Glyph or + * @FT_Load_Char only use the one that has been activated last to + * determine the 'current character pixel size'. + * + * This function can be used to 'activate' a previously created size + * object. + * + * @input: + * size :: + * A handle to a target size object. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `face` is the size's parent face object, this function changes the + * value of `face->size` to the input size handle. + */ FT_EXPORT( FT_Error ) FT_Activate_Size( FT_Size size ); diff --git a/src/3rdparty/freetype/include/freetype/ftsnames.h b/src/3rdparty/freetype/include/freetype/ftsnames.h index 8eb8d70ff7..4d43602a42 100644 --- a/src/3rdparty/freetype/include/freetype/ftsnames.h +++ b/src/3rdparty/freetype/include/freetype/ftsnames.h @@ -1,22 +1,22 @@ -/***************************************************************************/ -/* */ -/* ftsnames.h */ -/* */ -/* Simple interface to access SFNT `name' tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (specification). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsnames.h + * + * Simple interface to access SFNT 'name' tables (which are used + * to hold font names, copyright info, notices, etc.) (specification). + * + * This is _not_ used to retrieve glyph names! + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSNAMES_H_ @@ -37,72 +37,74 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* sfnt_names */ - /* */ - /* <Title> */ - /* SFNT Names */ - /* */ - /* <Abstract> */ - /* Access the names embedded in TrueType and OpenType files. */ - /* */ - /* <Description> */ - /* The TrueType and OpenType specifications allow the inclusion of */ - /* a special names table (`name') in font files. This table contains */ - /* textual (and internationalized) information regarding the font, */ - /* like family name, copyright, version, etc. */ - /* */ - /* The definitions below are used to access them if available. */ - /* */ - /* Note that this has nothing to do with glyph names! */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SfntName */ - /* */ - /* <Description> */ - /* A structure used to model an SFNT `name' table entry. */ - /* */ - /* <Fields> */ - /* platform_id :: The platform ID for `string'. */ - /* See @TT_PLATFORM_XXX for possible values. */ - /* */ - /* encoding_id :: The encoding ID for `string'. */ - /* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ - /* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */ - /* for possible values. */ - /* */ - /* language_id :: The language ID for `string'. */ - /* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */ - /* possible values. */ - /* */ - /* Registered OpenType values for `language_id' are */ - /* always smaller than 0x8000; values equal or larger */ - /* than 0x8000 usually indicate a language tag string */ - /* (introduced in OpenType version 1.6). Use function */ - /* @FT_Get_Sfnt_LangTag with `language_id' as its */ - /* argument to retrieve the associated language tag. */ - /* */ - /* name_id :: An identifier for `string'. */ - /* See @TT_NAME_ID_XXX for possible values. */ - /* */ - /* string :: The `name' string. Note that its format differs */ - /* depending on the (platform,encoding) pair, being */ - /* either a string of bytes (without a terminating */ - /* NULL byte) or containing UTF-16BE entities. */ - /* */ - /* string_len :: The length of `string' in bytes. */ - /* */ - /* <Note> */ - /* Please refer to the TrueType or OpenType specification for more */ - /* details. */ - /* */ + /************************************************************************** + * + * @section: + * sfnt_names + * + * @title: + * SFNT Names + * + * @abstract: + * Access the names embedded in TrueType and OpenType files. + * + * @description: + * The TrueType and OpenType specifications allow the inclusion of a + * special names table ('name') in font files. This table contains + * textual (and internationalized) information regarding the font, like + * family name, copyright, version, etc. + * + * The definitions below are used to access them if available. + * + * Note that this has nothing to do with glyph names! + * + */ + + + /************************************************************************** + * + * @struct: + * FT_SfntName + * + * @description: + * A structure used to model an SFNT 'name' table entry. + * + * @fields: + * platform_id :: + * The platform ID for `string`. See @TT_PLATFORM_XXX for possible + * values. + * + * encoding_id :: + * The encoding ID for `string`. See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, + * @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX for possible + * values. + * + * language_id :: + * The language ID for `string`. See @TT_MAC_LANGID_XXX and + * @TT_MS_LANGID_XXX for possible values. + * + * Registered OpenType values for `language_id` are always smaller than + * 0x8000; values equal or larger than 0x8000 usually indicate a + * language tag string (introduced in OpenType version 1.6). Use + * function @FT_Get_Sfnt_LangTag with `language_id` as its argument to + * retrieve the associated language tag. + * + * name_id :: + * An identifier for `string`. See @TT_NAME_ID_XXX for possible + * values. + * + * string :: + * The 'name' string. Note that its format differs depending on the + * (platform,encoding) pair, being either a string of bytes (without a + * terminating `NULL` byte) or containing UTF-16BE entities. + * + * string_len :: + * The length of `string` in bytes. + * + * @note: + * Please refer to the TrueType or OpenType specification for more + * details. + */ typedef struct FT_SfntName_ { FT_UShort platform_id; @@ -116,83 +118,95 @@ FT_BEGIN_HEADER } FT_SfntName; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name_Count */ - /* */ - /* <Description> */ - /* Retrieve the number of name strings in the SFNT `name' table. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Return> */ - /* The number of strings in the `name' table. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Name_Count + * + * @description: + * Retrieve the number of name strings in the SFNT 'name' table. + * + * @input: + * face :: + * A handle to the source face. + * + * @return: + * The number of strings in the 'name' table. + * + * @note: + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + */ FT_EXPORT( FT_UInt ) FT_Get_Sfnt_Name_Count( FT_Face face ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name */ - /* */ - /* <Description> */ - /* Retrieve a string of the SFNT `name' table for a given index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* idx :: The index of the `name' string. */ - /* */ - /* <Output> */ - /* aname :: The indexed @FT_SfntName structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `string' array returned in the `aname' structure is not */ - /* null-terminated. Note that you don't have to deallocate `string' */ - /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ - /* */ - /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ - /* `name' table entries, then do a loop until you get the right */ - /* platform, encoding, and name ID. */ - /* */ - /* `name' table format~1 entries can use language tags also, see */ - /* @FT_Get_Sfnt_LangTag. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Name + * + * @description: + * Retrieve a string of the SFNT 'name' table for a given index. + * + * @input: + * face :: + * A handle to the source face. + * + * idx :: + * The index of the 'name' string. + * + * @output: + * aname :: + * The indexed @FT_SfntName structure. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `string` array returned in the `aname` structure is not + * null-terminated. Note that you don't have to deallocate `string` by + * yourself; FreeType takes care of it if you call @FT_Done_Face. + * + * Use @FT_Get_Sfnt_Name_Count to get the total number of available + * 'name' table entries, then do a loop until you get the right platform, + * encoding, and name ID. + * + * 'name' table format~1 entries can use language tags also, see + * @FT_Get_Sfnt_LangTag. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + */ FT_EXPORT( FT_Error ) FT_Get_Sfnt_Name( FT_Face face, FT_UInt idx, FT_SfntName *aname ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SfntLangTag */ - /* */ - /* <Description> */ - /* A structure to model a language tag entry from an SFNT `name' */ - /* table. */ - /* */ - /* <Fields> */ - /* string :: The language tag string, encoded in UTF-16BE */ - /* (without trailing NULL bytes). */ - /* */ - /* string_len :: The length of `string' in *bytes*. */ - /* */ - /* <Note> */ - /* Please refer to the TrueType or OpenType specification for more */ - /* details. */ - /* */ - /* <Since> */ - /* 2.8 */ - /* */ + /************************************************************************** + * + * @struct: + * FT_SfntLangTag + * + * @description: + * A structure to model a language tag entry from an SFNT 'name' table. + * + * @fields: + * string :: + * The language tag string, encoded in UTF-16BE (without trailing + * `NULL` bytes). + * + * string_len :: + * The length of `string` in **bytes**. + * + * @note: + * Please refer to the TrueType or OpenType specification for more + * details. + * + * @since: + * 2.8 + */ typedef struct FT_SfntLangTag_ { FT_Byte* string; /* this string is *not* null-terminated! */ @@ -201,41 +215,47 @@ FT_BEGIN_HEADER } FT_SfntLangTag; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_LangTag */ - /* */ - /* <Description> */ - /* Retrieve the language tag associated with a language ID of an SFNT */ - /* `name' table entry. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */ - /* This is always a value larger than 0x8000. */ - /* */ - /* <Output> */ - /* alangTag :: The language tag associated with the `name' table */ - /* entry's language ID. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `string' array returned in the `alangTag' structure is not */ - /* null-terminated. Note that you don't have to deallocate `string' */ - /* by yourself; FreeType takes care of it if you call @FT_Done_Face. */ - /* */ - /* Only `name' table format~1 supports language tags. For format~0 */ - /* tables, this function always returns FT_Err_Invalid_Table. For */ - /* invalid format~1 language ID values, FT_Err_Invalid_Argument is */ - /* returned. */ - /* */ - /* <Since> */ - /* 2.8 */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_LangTag + * + * @description: + * Retrieve the language tag associated with a language ID of an SFNT + * 'name' table entry. + * + * @input: + * face :: + * A handle to the source face. + * + * langID :: + * The language ID, as returned by @FT_Get_Sfnt_Name. This is always a + * value larger than 0x8000. + * + * @output: + * alangTag :: + * The language tag associated with the 'name' table entry's language + * ID. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * The `string` array returned in the `alangTag` structure is not + * null-terminated. Note that you don't have to deallocate `string` by + * yourself; FreeType takes care of it if you call @FT_Done_Face. + * + * Only 'name' table format~1 supports language tags. For format~0 + * tables, this function always returns FT_Err_Invalid_Table. For + * invalid format~1 language ID values, FT_Err_Invalid_Argument is + * returned. + * + * This function always returns an error if the config macro + * `TT_CONFIG_OPTION_SFNT_NAMES` is not defined in `ftoption.h`. + * + * @since: + * 2.8 + */ FT_EXPORT( FT_Error ) FT_Get_Sfnt_LangTag( FT_Face face, FT_UInt langID, diff --git a/src/3rdparty/freetype/include/freetype/ftstroke.h b/src/3rdparty/freetype/include/freetype/ftstroke.h index 44b6fbe19f..01a9c1811c 100644 --- a/src/3rdparty/freetype/include/freetype/ftstroke.h +++ b/src/3rdparty/freetype/include/freetype/ftstroke.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstroke.h */ -/* */ -/* FreeType path stroker (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstroke.h + * + * FreeType path stroker (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSTROKE_H_ @@ -27,116 +27,113 @@ FT_BEGIN_HEADER - /************************************************************************ - * - * @section: - * glyph_stroker - * - * @title: - * Glyph Stroker - * - * @abstract: - * Generating bordered and stroked glyphs. - * - * @description: - * This component generates stroked outlines of a given vectorial - * glyph. It also allows you to retrieve the `outside' and/or the - * `inside' borders of the stroke. - * - * This can be useful to generate `bordered' glyph, i.e., glyphs - * displayed with a coloured (and anti-aliased) border around their - * shape. - * - * @order: - * FT_Stroker - * - * FT_Stroker_LineJoin - * FT_Stroker_LineCap - * FT_StrokerBorder - * - * FT_Outline_GetInsideBorder - * FT_Outline_GetOutsideBorder - * - * FT_Glyph_Stroke - * FT_Glyph_StrokeBorder - * - * FT_Stroker_New - * FT_Stroker_Set - * FT_Stroker_Rewind - * FT_Stroker_ParseOutline - * FT_Stroker_Done - * - * FT_Stroker_BeginSubPath - * FT_Stroker_EndSubPath - * - * FT_Stroker_LineTo - * FT_Stroker_ConicTo - * FT_Stroker_CubicTo - * - * FT_Stroker_GetBorderCounts - * FT_Stroker_ExportBorder - * FT_Stroker_GetCounts - * FT_Stroker_Export - * - */ - - - /************************************************************** - * - * @type: - * FT_Stroker - * - * @description: - * Opaque handle to a path stroker object. - */ + /************************************************************************** + * + * @section: + * glyph_stroker + * + * @title: + * Glyph Stroker + * + * @abstract: + * Generating bordered and stroked glyphs. + * + * @description: + * This component generates stroked outlines of a given vectorial glyph. + * It also allows you to retrieve the 'outside' and/or the 'inside' + * borders of the stroke. + * + * This can be useful to generate 'bordered' glyph, i.e., glyphs + * displayed with a coloured (and anti-aliased) border around their + * shape. + * + * @order: + * FT_Stroker + * + * FT_Stroker_LineJoin + * FT_Stroker_LineCap + * FT_StrokerBorder + * + * FT_Outline_GetInsideBorder + * FT_Outline_GetOutsideBorder + * + * FT_Glyph_Stroke + * FT_Glyph_StrokeBorder + * + * FT_Stroker_New + * FT_Stroker_Set + * FT_Stroker_Rewind + * FT_Stroker_ParseOutline + * FT_Stroker_Done + * + * FT_Stroker_BeginSubPath + * FT_Stroker_EndSubPath + * + * FT_Stroker_LineTo + * FT_Stroker_ConicTo + * FT_Stroker_CubicTo + * + * FT_Stroker_GetBorderCounts + * FT_Stroker_ExportBorder + * FT_Stroker_GetCounts + * FT_Stroker_Export + * + */ + + + /************************************************************************** + * + * @type: + * FT_Stroker + * + * @description: + * Opaque handle to a path stroker object. + */ typedef struct FT_StrokerRec_* FT_Stroker; - /************************************************************** + /************************************************************************** * * @enum: * FT_Stroker_LineJoin * * @description: - * These values determine how two joining lines are rendered - * in a stroker. + * These values determine how two joining lines are rendered in a + * stroker. * * @values: * FT_STROKER_LINEJOIN_ROUND :: - * Used to render rounded line joins. Circular arcs are used - * to join two lines smoothly. + * Used to render rounded line joins. Circular arcs are used to join + * two lines smoothly. * * FT_STROKER_LINEJOIN_BEVEL :: - * Used to render beveled line joins. The outer corner of - * the joined lines is filled by enclosing the triangular - * region of the corner with a straight line between the - * outer corners of each stroke. + * Used to render beveled line joins. The outer corner of the joined + * lines is filled by enclosing the triangular region of the corner + * with a straight line between the outer corners of each stroke. * * FT_STROKER_LINEJOIN_MITER_FIXED :: - * Used to render mitered line joins, with fixed bevels if the - * miter limit is exceeded. The outer edges of the strokes - * for the two segments are extended until they meet at an - * angle. If the segments meet at too sharp an angle (such - * that the miter would extend from the intersection of the - * segments a distance greater than the product of the miter - * limit value and the border radius), then a bevel join (see - * above) is used instead. This prevents long spikes being - * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter - * line join as used in PostScript and PDF. + * Used to render mitered line joins, with fixed bevels if the miter + * limit is exceeded. The outer edges of the strokes for the two + * segments are extended until they meet at an angle. If the segments + * meet at too sharp an angle (such that the miter would extend from + * the intersection of the segments a distance greater than the product + * of the miter limit value and the border radius), then a bevel join + * (see above) is used instead. This prevents long spikes being + * created. `FT_STROKER_LINEJOIN_MITER_FIXED` generates a miter line + * join as used in PostScript and PDF. * * FT_STROKER_LINEJOIN_MITER_VARIABLE :: * FT_STROKER_LINEJOIN_MITER :: - * Used to render mitered line joins, with variable bevels if - * the miter limit is exceeded. The intersection of the - * strokes is clipped at a line perpendicular to the bisector - * of the angle between the strokes, at the distance from the - * intersection of the segments equal to the product of the - * miter limit value and the border radius. This prevents - * long spikes being created. - * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line - * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias - * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for - * backward compatibility. + * Used to render mitered line joins, with variable bevels if the miter + * limit is exceeded. The intersection of the strokes is clipped at a + * line perpendicular to the bisector of the angle between the strokes, + * at the distance from the intersection of the segments equal to the + * product of the miter limit value and the border radius. This + * prevents long spikes being created. + * `FT_STROKER_LINEJOIN_MITER_VARIABLE` generates a mitered line join + * as used in XPS. `FT_STROKER_LINEJOIN_MITER` is an alias for + * `FT_STROKER_LINEJOIN_MITER_VARIABLE`, retained for backward + * compatibility. */ typedef enum FT_Stroker_LineJoin_ { @@ -149,27 +146,25 @@ FT_BEGIN_HEADER } FT_Stroker_LineJoin; - /************************************************************** + /************************************************************************** * * @enum: * FT_Stroker_LineCap * * @description: - * These values determine how the end of opened sub-paths are - * rendered in a stroke. + * These values determine how the end of opened sub-paths are rendered in + * a stroke. * * @values: * FT_STROKER_LINECAP_BUTT :: - * The end of lines is rendered as a full stop on the last - * point itself. + * The end of lines is rendered as a full stop on the last point + * itself. * * FT_STROKER_LINECAP_ROUND :: - * The end of lines is rendered as a half-circle around the - * last point. + * The end of lines is rendered as a half-circle around the last point. * * FT_STROKER_LINECAP_SQUARE :: - * The end of lines is rendered as a square around the - * last point. + * The end of lines is rendered as a square around the last point. */ typedef enum FT_Stroker_LineCap_ { @@ -180,14 +175,14 @@ FT_BEGIN_HEADER } FT_Stroker_LineCap; - /************************************************************** + /************************************************************************** * * @enum: * FT_StrokerBorder * * @description: - * These values are used to select a given stroke border - * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. + * These values are used to select a given stroke border in + * @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. * * @values: * FT_STROKER_BORDER_LEFT :: @@ -197,9 +192,9 @@ FT_BEGIN_HEADER * Select the right border, relative to the drawing direction. * * @note: - * Applications are generally interested in the `inside' and `outside' + * Applications are generally interested in the 'inside' and 'outside' * borders. However, there is no direct mapping between these and the - * `left' and `right' ones, since this really depends on the glyph's + * 'left' and 'right' ones, since this really depends on the glyph's * drawing orientation, which varies between font formats. * * You can however use @FT_Outline_GetInsideBorder and @@ -213,14 +208,14 @@ FT_BEGIN_HEADER } FT_StrokerBorder; - /************************************************************** + /************************************************************************** * * @function: * FT_Outline_GetInsideBorder * * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `inside' borders of a given outline. + * Retrieve the @FT_StrokerBorder value corresponding to the 'inside' + * borders of a given outline. * * @input: * outline :: @@ -234,14 +229,14 @@ FT_BEGIN_HEADER FT_Outline_GetInsideBorder( FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Outline_GetOutsideBorder * * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `outside' borders of a given outline. + * Retrieve the @FT_StrokerBorder value corresponding to the 'outside' + * borders of a given outline. * * @input: * outline :: @@ -255,7 +250,7 @@ FT_BEGIN_HEADER FT_Outline_GetOutsideBorder( FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_New @@ -269,7 +264,7 @@ FT_BEGIN_HEADER * * @output: * astroker :: - * A new stroker object handle. NULL in case of error. + * A new stroker object handle. `NULL` in case of error. * * @return: * FreeType error code. 0~means success. @@ -279,7 +274,7 @@ FT_BEGIN_HEADER FT_Stroker *astroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Set @@ -301,13 +296,12 @@ FT_BEGIN_HEADER * The line join style. * * miter_limit :: - * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and - * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, - * expressed as 16.16 fixed-point value. + * The miter limit for the `FT_STROKER_LINEJOIN_MITER_FIXED` and + * `FT_STROKER_LINEJOIN_MITER_VARIABLE` line join styles, expressed as + * 16.16 fixed-point value. * * @note: - * The radius is expressed in the same units as the outline - * coordinates. + * The radius is expressed in the same units as the outline coordinates. * * This function calls @FT_Stroker_Rewind automatically. */ @@ -319,16 +313,15 @@ FT_BEGIN_HEADER FT_Fixed miter_limit ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Rewind * * @description: - * Reset a stroker object without changing its attributes. - * You should call this function before beginning a new - * series of calls to @FT_Stroker_BeginSubPath or - * @FT_Stroker_EndSubPath. + * Reset a stroker object without changing its attributes. You should + * call this function before beginning a new series of calls to + * @FT_Stroker_BeginSubPath or @FT_Stroker_EndSubPath. * * @input: * stroker :: @@ -338,15 +331,15 @@ FT_BEGIN_HEADER FT_Stroker_Rewind( FT_Stroker stroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_ParseOutline * * @description: - * A convenience function used to parse a whole outline with - * the stroker. The resulting outline(s) can be retrieved - * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export. + * A convenience function used to parse a whole outline with the stroker. + * The resulting outline(s) can be retrieved later by functions like + * @FT_Stroker_GetCounts and @FT_Stroker_Export. * * @input: * stroker :: @@ -356,18 +349,18 @@ FT_BEGIN_HEADER * The source outline. * * opened :: - * A boolean. If~1, the outline is treated as an open path instead - * of a closed one. + * A boolean. If~1, the outline is treated as an open path instead of + * a closed one. * * @return: * FreeType error code. 0~means success. * * @note: - * If `opened' is~0 (the default), the outline is treated as a closed - * path, and the stroker generates two distinct `border' outlines. + * If `opened` is~0 (the default), the outline is treated as a closed + * path, and the stroker generates two distinct 'border' outlines. * - * If `opened' is~1, the outline is processed as an open path, and the - * stroker generates a single `stroke' outline. + * If `opened` is~1, the outline is processed as an open path, and the + * stroker generates a single 'stroke' outline. * * This function calls @FT_Stroker_Rewind automatically. */ @@ -377,7 +370,7 @@ FT_BEGIN_HEADER FT_Bool opened ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_BeginSubPath @@ -399,8 +392,8 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * This function is useful when you need to stroke a path that is - * not stored as an @FT_Outline object. + * This function is useful when you need to stroke a path that is not + * stored as an @FT_Outline object. */ FT_EXPORT( FT_Error ) FT_Stroker_BeginSubPath( FT_Stroker stroker, @@ -408,7 +401,7 @@ FT_BEGIN_HEADER FT_Bool open ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_EndSubPath @@ -424,22 +417,22 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * You should call this function after @FT_Stroker_BeginSubPath. - * If the subpath was not `opened', this function `draws' a - * single line segment to the start position when needed. + * You should call this function after @FT_Stroker_BeginSubPath. If the + * subpath was not 'opened', this function 'draws' a single line segment + * to the start position when needed. */ FT_EXPORT( FT_Error ) FT_Stroker_EndSubPath( FT_Stroker stroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_LineTo * * @description: - * `Draw' a single line segment in the stroker's current sub-path, - * from the last position. + * 'Draw' a single line segment in the stroker's current sub-path, from + * the last position. * * @input: * stroker :: @@ -460,13 +453,13 @@ FT_BEGIN_HEADER FT_Vector* to ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_ConicTo * * @description: - * `Draw' a single quadratic Bezier in the stroker's current sub-path, + * 'Draw' a single quadratic Bezier in the stroker's current sub-path, * from the last position. * * @input: @@ -492,14 +485,14 @@ FT_BEGIN_HEADER FT_Vector* to ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_CubicTo * * @description: - * `Draw' a single cubic Bezier in the stroker's current sub-path, - * from the last position. + * 'Draw' a single cubic Bezier in the stroker's current sub-path, from + * the last position. * * @input: * stroker :: @@ -528,16 +521,16 @@ FT_BEGIN_HEADER FT_Vector* to ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_GetBorderCounts * * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export one of the `border' or `stroke' - * outlines generated by the stroker. + * Call this function once you have finished parsing your paths with the + * stroker. It returns the number of points and contours necessary to + * export one of the 'border' or 'stroke' outlines generated by the + * stroker. * * @input: * stroker :: @@ -557,15 +550,15 @@ FT_BEGIN_HEADER * FreeType error code. 0~means success. * * @note: - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. + * When an outline, or a sub-path, is 'closed', the stroker generates two + * independent 'border' outlines, named 'left' and 'right'. * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. + * When the outline, or a sub-path, is 'opened', the stroker merges the + * 'border' outlines with caps. The 'left' border receives all points, + * while the 'right' border becomes empty. * - * Use the function @FT_Stroker_GetCounts instead if you want to - * retrieve the counts associated to both borders. + * Use the function @FT_Stroker_GetCounts instead if you want to retrieve + * the counts associated to both borders. */ FT_EXPORT( FT_Error ) FT_Stroker_GetBorderCounts( FT_Stroker stroker, @@ -574,19 +567,17 @@ FT_BEGIN_HEADER FT_UInt *anum_contours ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_ExportBorder * * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export the corresponding border to your own @FT_Outline - * structure. + * Call this function after @FT_Stroker_GetBorderCounts to export the + * corresponding border to your own @FT_Outline structure. * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. + * Note that this function appends the border points and contours to your + * outline, but does not try to resize its arrays. * * @input: * stroker :: @@ -599,19 +590,19 @@ FT_BEGIN_HEADER * The target outline handle. * * @note: - * Always call this function after @FT_Stroker_GetBorderCounts to - * get sure that there is enough room in your @FT_Outline object to - * receive all new data. + * Always call this function after @FT_Stroker_GetBorderCounts to get + * sure that there is enough room in your @FT_Outline object to receive + * all new data. * - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. + * When an outline, or a sub-path, is 'closed', the stroker generates two + * independent 'border' outlines, named 'left' and 'right'. * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. + * When the outline, or a sub-path, is 'opened', the stroker merges the + * 'border' outlines with caps. The 'left' border receives all points, + * while the 'right' border becomes empty. * - * Use the function @FT_Stroker_Export instead if you want to - * retrieve all borders at once. + * Use the function @FT_Stroker_Export instead if you want to retrieve + * all borders at once. */ FT_EXPORT( void ) FT_Stroker_ExportBorder( FT_Stroker stroker, @@ -619,16 +610,15 @@ FT_BEGIN_HEADER FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_GetCounts * * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export all points/borders from the stroked - * outline/path. + * Call this function once you have finished parsing your paths with the + * stroker. It returns the number of points and contours necessary to + * export all points/borders from the stroked outline/path. * * @input: * stroker :: @@ -650,18 +640,17 @@ FT_BEGIN_HEADER FT_UInt *anum_contours ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Export * * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export all borders to your own @FT_Outline structure. + * Call this function after @FT_Stroker_GetBorderCounts to export all + * borders to your own @FT_Outline structure. * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. + * Note that this function appends the border points and contours to your + * outline, but does not try to resize its arrays. * * @input: * stroker :: @@ -675,7 +664,7 @@ FT_BEGIN_HEADER FT_Outline* outline ); - /************************************************************** + /************************************************************************** * * @function: * FT_Stroker_Done @@ -685,13 +674,13 @@ FT_BEGIN_HEADER * * @input: * stroker :: - * A stroker handle. Can be NULL. + * A stroker handle. Can be `NULL`. */ FT_EXPORT( void ) FT_Stroker_Done( FT_Stroker stroker ); - /************************************************************** + /************************************************************************** * * @function: * FT_Glyph_Stroke @@ -708,8 +697,7 @@ FT_BEGIN_HEADER * A stroker handle. * * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. + * A Boolean. If~1, the source glyph object is destroyed on success. * * @return: * FreeType error code. 0~means success. @@ -719,8 +707,8 @@ FT_BEGIN_HEADER * * Adding stroke may yield a significantly wider and taller glyph * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. + * may need to manually adjust horizontal and vertical advance amounts to + * account for this added size. */ FT_EXPORT( FT_Error ) FT_Glyph_Stroke( FT_Glyph *pglyph, @@ -728,14 +716,14 @@ FT_BEGIN_HEADER FT_Bool destroy ); - /************************************************************** + /************************************************************************** * * @function: * FT_Glyph_StrokeBorder * * @description: - * Stroke a given outline glyph object with a given stroker, but - * only return either its inside or outside border. + * Stroke a given outline glyph object with a given stroker, but only + * return either its inside or outside border. * * @inout: * pglyph :: @@ -746,12 +734,11 @@ FT_BEGIN_HEADER * A stroker handle. * * inside :: - * A Boolean. If~1, return the inside border, otherwise - * the outside border. + * A Boolean. If~1, return the inside border, otherwise the outside + * border. * * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. + * A Boolean. If~1, the source glyph object is destroyed on success. * * @return: * FreeType error code. 0~means success. @@ -761,8 +748,8 @@ FT_BEGIN_HEADER * * Adding stroke may yield a significantly wider and taller glyph * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. + * may need to manually adjust horizontal and vertical advance amounts to + * account for this added size. */ FT_EXPORT( FT_Error ) FT_Glyph_StrokeBorder( FT_Glyph *pglyph, diff --git a/src/3rdparty/freetype/include/freetype/ftsynth.h b/src/3rdparty/freetype/include/freetype/ftsynth.h index ff9fb43d96..8754f97cee 100644 --- a/src/3rdparty/freetype/include/freetype/ftsynth.h +++ b/src/3rdparty/freetype/include/freetype/ftsynth.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftsynth.h */ -/* */ -/* FreeType synthesizing code for emboldening and slanting */ -/* (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsynth.h + * + * FreeType synthesizing code for emboldening and slanting + * (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /*************************************************************************/ @@ -35,7 +35,7 @@ /* Main reason for not lifting the functions in this module to a */ - /* `standard' API is that the used parameters for emboldening and */ + /* 'standard' API is that the used parameters for emboldening and */ /* slanting are not configurable. Consider the functions as a */ /* code resource that should be copied into the application and */ /* adapted to the particular needs. */ @@ -57,7 +57,7 @@ FT_BEGIN_HEADER - /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ + /* Embolden a glyph by a 'reasonable' value (which is highly a matter of */ /* taste). This function is actually a convenience function, providing */ /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ /* */ diff --git a/src/3rdparty/freetype/include/freetype/ftsystem.h b/src/3rdparty/freetype/include/freetype/ftsystem.h index f6b1629ef2..889a6ba172 100644 --- a/src/3rdparty/freetype/include/freetype/ftsystem.h +++ b/src/3rdparty/freetype/include/freetype/ftsystem.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsystem.h */ -/* */ -/* FreeType low-level system interface definition (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsystem.h + * + * FreeType low-level system interface definition (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSYSTEM_H_ @@ -26,34 +26,33 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* system_interface */ - /* */ - /* <Title> */ - /* System Interface */ - /* */ - /* <Abstract> */ - /* How FreeType manages memory and i/o. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to memory */ - /* management and i/o access. You need to understand this */ - /* information if you want to use a custom memory manager or you own */ - /* i/o streams. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * system_interface + * + * @title: + * System Interface + * + * @abstract: + * How FreeType manages memory and i/o. + * + * @description: + * This section contains various definitions related to memory management + * and i/o access. You need to understand this information if you want to + * use a custom memory manager or you own i/o streams. + * + */ - /*************************************************************************/ - /* */ - /* M E M O R Y M A N A G E M E N T */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * M E M O R Y M A N A G E M E N T + * + */ - /************************************************************************* + /************************************************************************** * * @type: * FT_Memory @@ -66,13 +65,13 @@ FT_BEGIN_HEADER typedef struct FT_MemoryRec_* FT_Memory; - /************************************************************************* + /************************************************************************** * * @functype: * FT_Alloc_Func * * @description: - * A function used to allocate `size' bytes from `memory'. + * A function used to allocate `size` bytes from `memory`. * * @input: * memory :: @@ -90,7 +89,7 @@ FT_BEGIN_HEADER long size ); - /************************************************************************* + /************************************************************************** * * @functype: * FT_Free_Func @@ -111,7 +110,7 @@ FT_BEGIN_HEADER void* block ); - /************************************************************************* + /************************************************************************** * * @functype: * FT_Realloc_Func @@ -146,7 +145,7 @@ FT_BEGIN_HEADER void* block ); - /************************************************************************* + /************************************************************************** * * @struct: * FT_MemoryRec @@ -177,14 +176,14 @@ FT_BEGIN_HEADER }; - /*************************************************************************/ - /* */ - /* I / O M A N A G E M E N T */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * I / O M A N A G E M E N T + * + */ - /************************************************************************* + /************************************************************************** * * @type: * FT_Stream @@ -193,21 +192,21 @@ FT_BEGIN_HEADER * A handle to an input stream. * * @also: - * See @FT_StreamRec for the publicly accessible fields of a given - * stream object. + * See @FT_StreamRec for the publicly accessible fields of a given stream + * object. * */ typedef struct FT_StreamRec_* FT_Stream; - /************************************************************************* + /************************************************************************** * * @struct: * FT_StreamDesc * * @description: * A union type used to store either a long or a pointer. This is used - * to store a file descriptor or a `FILE*' in an input stream. + * to store a file descriptor or a `FILE*` in an input stream. * */ typedef union FT_StreamDesc_ @@ -218,7 +217,7 @@ FT_BEGIN_HEADER } FT_StreamDesc; - /************************************************************************* + /************************************************************************** * * @functype: * FT_Stream_IoFunc @@ -243,9 +242,8 @@ FT_BEGIN_HEADER * The number of bytes effectively read by the stream. * * @note: - * This function might be called to perform a seek or skip operation - * with a `count' of~0. A non-zero return value then indicates an - * error. + * This function might be called to perform a seek or skip operation with + * a `count` of~0. A non-zero return value then indicates an error. * */ typedef unsigned long @@ -255,7 +253,7 @@ FT_BEGIN_HEADER unsigned long count ); - /************************************************************************* + /************************************************************************** * * @functype: * FT_Stream_CloseFunc @@ -265,14 +263,14 @@ FT_BEGIN_HEADER * * @input: * stream :: - * A handle to the target stream. + * A handle to the target stream. * */ typedef void (*FT_Stream_CloseFunc)( FT_Stream stream ); - /************************************************************************* + /************************************************************************** * * @struct: * FT_StreamRec @@ -283,7 +281,7 @@ FT_BEGIN_HEADER * @input: * base :: * For memory-based streams, this is the address of the first stream - * byte in memory. This field should always be set to NULL for + * byte in memory. This field should always be set to `NULL` for * disk-based streams. * * size :: @@ -299,7 +297,7 @@ FT_BEGIN_HEADER * * descriptor :: * This field is a union that can hold an integer or a pointer. It is - * used by stream implementations to store file descriptors or `FILE*' + * used by stream implementations to store file descriptors or `FILE*` * pointers. * * pathname :: @@ -314,13 +312,13 @@ FT_BEGIN_HEADER * The stream's close function. * * memory :: - * The memory manager to use to preload frames. This is set - * internally by FreeType and shouldn't be touched by stream - * implementations. + * The memory manager to use to preload frames. This is set internally + * by FreeType and shouldn't be touched by stream implementations. * * cursor :: * This field is set and used internally by FreeType when parsing - * frames. + * frames. In particular, the `FT_GET_XXX` macros use this instead of + * the `pos` field. * * limit :: * This field is set and used internally by FreeType when parsing diff --git a/src/3rdparty/freetype/include/freetype/fttrigon.h b/src/3rdparty/freetype/include/freetype/fttrigon.h index 2e3f3f1f73..37e1412fdf 100644 --- a/src/3rdparty/freetype/include/freetype/fttrigon.h +++ b/src/3rdparty/freetype/include/freetype/fttrigon.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttrigon.h */ -/* */ -/* FreeType trigonometric functions (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttrigon.h + * + * FreeType trigonometric functions (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTTRIGON_H_ @@ -31,15 +31,15 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * computations + * + */ - /************************************************************************* + /************************************************************************** * * @type: * FT_Angle @@ -52,7 +52,7 @@ FT_BEGIN_HEADER typedef FT_Fixed FT_Angle; - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_PI @@ -64,7 +64,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_PI ( 180L << 16 ) - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_2PI @@ -76,7 +76,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_PI2 @@ -88,7 +88,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) - /************************************************************************* + /************************************************************************** * * @macro: * FT_ANGLE_PI4 @@ -100,7 +100,7 @@ FT_BEGIN_HEADER #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) - /************************************************************************* + /************************************************************************** * * @function: * FT_Sin @@ -124,7 +124,7 @@ FT_BEGIN_HEADER FT_Sin( FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Cos @@ -148,7 +148,7 @@ FT_BEGIN_HEADER FT_Cos( FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Tan @@ -168,14 +168,14 @@ FT_BEGIN_HEADER FT_Tan( FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Atan2 * * @description: - * Return the arc-tangent corresponding to a given vector (x,y) in - * the 2d plane. + * Return the arc-tangent corresponding to a given vector (x,y) in the 2d + * plane. * * @input: * x :: @@ -193,7 +193,7 @@ FT_BEGIN_HEADER FT_Fixed y ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Angle_Diff @@ -210,7 +210,7 @@ FT_BEGIN_HEADER * Second angle. * * @return: - * Constrained value of `value2-value1'. + * Constrained value of `angle2-angle1`. * */ FT_EXPORT( FT_Angle ) @@ -218,15 +218,15 @@ FT_BEGIN_HEADER FT_Angle angle2 ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Unit * * @description: * Return the unit vector corresponding to a given angle. After the - * call, the value of `vec.x' will be `cos(angle)', and the value of - * `vec.y' will be `sin(angle)'. + * call, the value of `vec.x` will be `cos(angle)`, and the value of + * `vec.y` will be `sin(angle)`. * * This function is useful to retrieve both the sinus and cosinus of a * given angle quickly. @@ -245,7 +245,7 @@ FT_BEGIN_HEADER FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Rotate @@ -267,7 +267,7 @@ FT_BEGIN_HEADER FT_Angle angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Length @@ -288,7 +288,7 @@ FT_BEGIN_HEADER FT_Vector_Length( FT_Vector* vec ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_Polarize @@ -314,7 +314,7 @@ FT_BEGIN_HEADER FT_Angle *angle ); - /************************************************************************* + /************************************************************************** * * @function: * FT_Vector_From_Polar diff --git a/src/3rdparty/freetype/include/freetype/fttypes.h b/src/3rdparty/freetype/include/freetype/fttypes.h index f638c2e54f..10571505a5 100644 --- a/src/3rdparty/freetype/include/freetype/fttypes.h +++ b/src/3rdparty/freetype/include/freetype/fttypes.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttypes.h */ -/* */ -/* FreeType simple types definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttypes.h + * + * FreeType simple types definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTTYPES_H_ @@ -31,326 +31,327 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /* <Title> */ - /* Basic Data Types */ - /* */ - /* <Abstract> */ - /* The basic data types defined by the library. */ - /* */ - /* <Description> */ - /* This section contains the basic data types defined by FreeType~2, */ - /* ranging from simple scalar types to bitmap descriptors. More */ - /* font-specific structures are defined in a different section. */ - /* */ - /* <Order> */ - /* FT_Byte */ - /* FT_Bytes */ - /* FT_Char */ - /* FT_Int */ - /* FT_UInt */ - /* FT_Int16 */ - /* FT_UInt16 */ - /* FT_Int32 */ - /* FT_UInt32 */ - /* FT_Int64 */ - /* FT_UInt64 */ - /* FT_Short */ - /* FT_UShort */ - /* FT_Long */ - /* FT_ULong */ - /* FT_Bool */ - /* FT_Offset */ - /* FT_PtrDist */ - /* FT_String */ - /* FT_Tag */ - /* FT_Error */ - /* FT_Fixed */ - /* FT_Pointer */ - /* FT_Pos */ - /* FT_Vector */ - /* FT_BBox */ - /* FT_Matrix */ - /* FT_FWord */ - /* FT_UFWord */ - /* FT_F2Dot14 */ - /* FT_UnitVector */ - /* FT_F26Dot6 */ - /* FT_Data */ - /* */ - /* FT_MAKE_TAG */ - /* */ - /* FT_Generic */ - /* FT_Generic_Finalizer */ - /* */ - /* FT_Bitmap */ - /* FT_Pixel_Mode */ - /* FT_Palette_Mode */ - /* FT_Glyph_Format */ - /* FT_IMAGE_TAG */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bool */ - /* */ - /* <Description> */ - /* A typedef of unsigned char, used for simple booleans. As usual, */ - /* values 1 and~0 represent true and false, respectively. */ - /* */ + /************************************************************************** + * + * @section: + * basic_types + * + * @title: + * Basic Data Types + * + * @abstract: + * The basic data types defined by the library. + * + * @description: + * This section contains the basic data types defined by FreeType~2, + * ranging from simple scalar types to bitmap descriptors. More + * font-specific structures are defined in a different section. + * + * @order: + * FT_Byte + * FT_Bytes + * FT_Char + * FT_Int + * FT_UInt + * FT_Int16 + * FT_UInt16 + * FT_Int32 + * FT_UInt32 + * FT_Int64 + * FT_UInt64 + * FT_Short + * FT_UShort + * FT_Long + * FT_ULong + * FT_Bool + * FT_Offset + * FT_PtrDist + * FT_String + * FT_Tag + * FT_Error + * FT_Fixed + * FT_Pointer + * FT_Pos + * FT_Vector + * FT_BBox + * FT_Matrix + * FT_FWord + * FT_UFWord + * FT_F2Dot14 + * FT_UnitVector + * FT_F26Dot6 + * FT_Data + * + * FT_MAKE_TAG + * + * FT_Generic + * FT_Generic_Finalizer + * + * FT_Bitmap + * FT_Pixel_Mode + * FT_Palette_Mode + * FT_Glyph_Format + * FT_IMAGE_TAG + * + */ + + + /************************************************************************** + * + * @type: + * FT_Bool + * + * @description: + * A typedef of unsigned char, used for simple booleans. As usual, + * values 1 and~0 represent true and false, respectively. + */ typedef unsigned char FT_Bool; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_FWord */ - /* */ - /* <Description> */ - /* A signed 16-bit integer used to store a distance in original font */ - /* units. */ - /* */ + /************************************************************************** + * + * @type: + * FT_FWord + * + * @description: + * A signed 16-bit integer used to store a distance in original font + * units. + */ typedef signed short FT_FWord; /* distance in FUnits */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UFWord */ - /* */ - /* <Description> */ - /* An unsigned 16-bit integer used to store a distance in original */ - /* font units. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UFWord + * + * @description: + * An unsigned 16-bit integer used to store a distance in original font + * units. + */ typedef unsigned short FT_UFWord; /* unsigned distance */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Char */ - /* */ - /* <Description> */ - /* A simple typedef for the _signed_ char type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Char + * + * @description: + * A simple typedef for the _signed_ char type. + */ typedef signed char FT_Char; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Byte */ - /* */ - /* <Description> */ - /* A simple typedef for the _unsigned_ char type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Byte + * + * @description: + * A simple typedef for the _unsigned_ char type. + */ typedef unsigned char FT_Byte; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bytes */ - /* */ - /* <Description> */ - /* A typedef for constant memory areas. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Bytes + * + * @description: + * A typedef for constant memory areas. + */ typedef const FT_Byte* FT_Bytes; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Tag */ - /* */ - /* <Description> */ - /* A typedef for 32-bit tags (as used in the SFNT format). */ - /* */ + /************************************************************************** + * + * @type: + * FT_Tag + * + * @description: + * A typedef for 32-bit tags (as used in the SFNT format). + */ typedef FT_UInt32 FT_Tag; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_String */ - /* */ - /* <Description> */ - /* A simple typedef for the char type, usually used for strings. */ - /* */ + /************************************************************************** + * + * @type: + * FT_String + * + * @description: + * A simple typedef for the char type, usually used for strings. + */ typedef char FT_String; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Short */ - /* */ - /* <Description> */ - /* A typedef for signed short. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Short + * + * @description: + * A typedef for signed short. + */ typedef signed short FT_Short; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UShort */ - /* */ - /* <Description> */ - /* A typedef for unsigned short. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UShort + * + * @description: + * A typedef for unsigned short. + */ typedef unsigned short FT_UShort; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Int */ - /* */ - /* <Description> */ - /* A typedef for the int type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Int + * + * @description: + * A typedef for the int type. + */ typedef signed int FT_Int; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UInt */ - /* */ - /* <Description> */ - /* A typedef for the unsigned int type. */ - /* */ + /************************************************************************** + * + * @type: + * FT_UInt + * + * @description: + * A typedef for the unsigned int type. + */ typedef unsigned int FT_UInt; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Long */ - /* */ - /* <Description> */ - /* A typedef for signed long. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Long + * + * @description: + * A typedef for signed long. + */ typedef signed long FT_Long; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ULong */ - /* */ - /* <Description> */ - /* A typedef for unsigned long. */ - /* */ + /************************************************************************** + * + * @type: + * FT_ULong + * + * @description: + * A typedef for unsigned long. + */ typedef unsigned long FT_ULong; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F2Dot14 */ - /* */ - /* <Description> */ - /* A signed 2.14 fixed-point type used for unit vectors. */ - /* */ + /************************************************************************** + * + * @type: + * FT_F2Dot14 + * + * @description: + * A signed 2.14 fixed-point type used for unit vectors. + */ typedef signed short FT_F2Dot14; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F26Dot6 */ - /* */ - /* <Description> */ - /* A signed 26.6 fixed-point type used for vectorial pixel */ - /* coordinates. */ - /* */ + /************************************************************************** + * + * @type: + * FT_F26Dot6 + * + * @description: + * A signed 26.6 fixed-point type used for vectorial pixel coordinates. + */ typedef signed long FT_F26Dot6; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Fixed */ - /* */ - /* <Description> */ - /* This type is used to store 16.16 fixed-point values, like scaling */ - /* values or matrix coefficients. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Fixed + * + * @description: + * This type is used to store 16.16 fixed-point values, like scaling + * values or matrix coefficients. + */ typedef signed long FT_Fixed; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Error */ - /* */ - /* <Description> */ - /* The FreeType error code type. A value of~0 is always interpreted */ - /* as a successful operation. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Error + * + * @description: + * The FreeType error code type. A value of~0 is always interpreted as a + * successful operation. + */ typedef int FT_Error; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pointer */ - /* */ - /* <Description> */ - /* A simple typedef for a typeless pointer. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Pointer + * + * @description: + * A simple typedef for a typeless pointer. + */ typedef void* FT_Pointer; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Offset */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */ - /* _unsigned_ integer type used to express a file size or position, */ - /* or a memory block size. */ - /* */ + /************************************************************************** + * + * @type: + * FT_Offset + * + * @description: + * This is equivalent to the ANSI~C `size_t` type, i.e., the largest + * _unsigned_ integer type used to express a file size or position, or a + * memory block size. + */ typedef size_t FT_Offset; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_PtrDist */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */ - /* largest _signed_ integer type used to express the distance */ - /* between two pointers. */ - /* */ + /************************************************************************** + * + * @type: + * FT_PtrDist + * + * @description: + * This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest + * _signed_ integer type used to express the distance between two + * pointers. + */ typedef ft_ptrdiff_t FT_PtrDist; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_UnitVector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector unit vector. Uses */ - /* FT_F2Dot14 types. */ - /* */ - /* <Fields> */ - /* x :: Horizontal coordinate. */ - /* */ - /* y :: Vertical coordinate. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_UnitVector + * + * @description: + * A simple structure used to store a 2D vector unit vector. Uses + * FT_F2Dot14 types. + * + * @fields: + * x :: + * Horizontal coordinate. + * + * y :: + * Vertical coordinate. + */ typedef struct FT_UnitVector_ { FT_F2Dot14 x; @@ -359,29 +360,33 @@ FT_BEGIN_HEADER } FT_UnitVector; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Matrix */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2x2 matrix. Coefficients are */ - /* in 16.16 fixed-point format. The computation performed is: */ - /* */ - /* { */ - /* x' = x*xx + y*xy */ - /* y' = x*yx + y*yy */ - /* } */ - /* */ - /* <Fields> */ - /* xx :: Matrix coefficient. */ - /* */ - /* xy :: Matrix coefficient. */ - /* */ - /* yx :: Matrix coefficient. */ - /* */ - /* yy :: Matrix coefficient. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Matrix + * + * @description: + * A simple structure used to store a 2x2 matrix. Coefficients are in + * 16.16 fixed-point format. The computation performed is: + * + * ``` + * x' = x*xx + y*xy + * y' = x*yx + y*yy + * ``` + * + * @fields: + * xx :: + * Matrix coefficient. + * + * xy :: + * Matrix coefficient. + * + * yx :: + * Matrix coefficient. + * + * yy :: + * Matrix coefficient. + */ typedef struct FT_Matrix_ { FT_Fixed xx, xy; @@ -390,19 +395,21 @@ FT_BEGIN_HEADER } FT_Matrix; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Data */ - /* */ - /* <Description> */ - /* Read-only binary data represented as a pointer and a length. */ - /* */ - /* <Fields> */ - /* pointer :: The data. */ - /* */ - /* length :: The length of the data in bytes. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Data + * + * @description: + * Read-only binary data represented as a pointer and a length. + * + * @fields: + * pointer :: + * The data. + * + * length :: + * The length of the data in bytes. + */ typedef struct FT_Data_ { const FT_Byte* pointer; @@ -411,51 +418,52 @@ FT_BEGIN_HEADER } FT_Data; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Generic_Finalizer */ - /* */ - /* <Description> */ - /* Describe a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the @FT_Generic type for */ - /* details of usage. */ - /* */ - /* <Input> */ - /* The address of the FreeType object that is under finalization. */ - /* Its client data is accessed through its `generic' field. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_Generic_Finalizer + * + * @description: + * Describe a function used to destroy the 'client' data of any FreeType + * object. See the description of the @FT_Generic type for details of + * usage. + * + * @input: + * The address of the FreeType object that is under finalization. Its + * client data is accessed through its `generic` field. + */ typedef void (*FT_Generic_Finalizer)( void* object ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Generic */ - /* */ - /* <Description> */ - /* Client applications often need to associate their own data to a */ - /* variety of FreeType core objects. For example, a text layout API */ - /* might want to associate a glyph cache to a given size object. */ - /* */ - /* Some FreeType object contains a `generic' field, of type */ - /* FT_Generic, which usage is left to client applications and font */ - /* servers. */ - /* */ - /* It can be used to store a pointer to client-specific data, as well */ - /* as the address of a `finalizer' function, which will be called by */ - /* FreeType when the object is destroyed (for example, the previous */ - /* client example would put the address of the glyph cache destructor */ - /* in the `finalizer' field). */ - /* */ - /* <Fields> */ - /* data :: A typeless pointer to any client-specified data. This */ - /* field is completely ignored by the FreeType library. */ - /* */ - /* finalizer :: A pointer to a `generic finalizer' function, which */ - /* will be called when the object is destroyed. If this */ - /* field is set to NULL, no code will be called. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Generic + * + * @description: + * Client applications often need to associate their own data to a + * variety of FreeType core objects. For example, a text layout API + * might want to associate a glyph cache to a given size object. + * + * Some FreeType object contains a `generic` field, of type `FT_Generic`, + * which usage is left to client applications and font servers. + * + * It can be used to store a pointer to client-specific data, as well as + * the address of a 'finalizer' function, which will be called by + * FreeType when the object is destroyed (for example, the previous + * client example would put the address of the glyph cache destructor in + * the `finalizer` field). + * + * @fields: + * data :: + * A typeless pointer to any client-specified data. This field is + * completely ignored by the FreeType library. + * + * finalizer :: + * A pointer to a 'generic finalizer' function, which will be called + * when the object is destroyed. If this field is set to `NULL`, no + * code will be called. + */ typedef struct FT_Generic_ { void* data; @@ -464,19 +472,19 @@ FT_BEGIN_HEADER } FT_Generic; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_MAKE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags that are used to label */ - /* TrueType tables into an unsigned long, to be used within FreeType. */ - /* */ - /* <Note> */ - /* The produced values *must* be 32-bit integers. Don't redefine */ - /* this macro. */ - /* */ + /************************************************************************** + * + * @macro: + * FT_MAKE_TAG + * + * @description: + * This macro converts four-letter tags that are used to label TrueType + * tables into an unsigned long, to be used within FreeType. + * + * @note: + * The produced values **must** be 32-bit integers. Don't redefine this + * macro. + */ #define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ (FT_Tag) \ ( ( (FT_ULong)_x1 << 24 ) | \ @@ -494,53 +502,56 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * list_processing + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ListNode */ - /* */ - /* <Description> */ - /* Many elements and objects in FreeType are listed through an */ - /* @FT_List record (see @FT_ListRec). As its name suggests, an */ - /* FT_ListNode is a handle to a single list element. */ - /* */ + /************************************************************************** + * + * @type: + * FT_ListNode + * + * @description: + * Many elements and objects in FreeType are listed through an @FT_List + * record (see @FT_ListRec). As its name suggests, an FT_ListNode is a + * handle to a single list element. + */ typedef struct FT_ListNodeRec_* FT_ListNode; - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_List */ - /* */ - /* <Description> */ - /* A handle to a list record (see @FT_ListRec). */ - /* */ + /************************************************************************** + * + * @type: + * FT_List + * + * @description: + * A handle to a list record (see @FT_ListRec). + */ typedef struct FT_ListRec_* FT_List; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListNodeRec */ - /* */ - /* <Description> */ - /* A structure used to hold a single list element. */ - /* */ - /* <Fields> */ - /* prev :: The previous element in the list. NULL if first. */ - /* */ - /* next :: The next element in the list. NULL if last. */ - /* */ - /* data :: A typeless pointer to the listed object. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_ListNodeRec + * + * @description: + * A structure used to hold a single list element. + * + * @fields: + * prev :: + * The previous element in the list. `NULL` if first. + * + * next :: + * The next element in the list. `NULL` if last. + * + * data :: + * A typeless pointer to the listed object. + */ typedef struct FT_ListNodeRec_ { FT_ListNode prev; @@ -550,20 +561,22 @@ FT_BEGIN_HEADER } FT_ListNodeRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListRec */ - /* */ - /* <Description> */ - /* A structure used to hold a simple doubly-linked list. These are */ - /* used in many parts of FreeType. */ - /* */ - /* <Fields> */ - /* head :: The head (first element) of doubly-linked list. */ - /* */ - /* tail :: The tail (last element) of doubly-linked list. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_ListRec + * + * @description: + * A structure used to hold a simple doubly-linked list. These are used + * in many parts of FreeType. + * + * @fields: + * head :: + * The head (first element) of doubly-linked list. + * + * tail :: + * The tail (last element) of doubly-linked list. + */ typedef struct FT_ListRec_ { FT_ListNode head; @@ -575,13 +588,13 @@ FT_BEGIN_HEADER #define FT_IS_EMPTY( list ) ( (list).head == 0 ) -#define FT_BOOL( x ) ( (FT_Bool)( x ) ) +#define FT_BOOL( x ) ( (FT_Bool)( (x) != 0 ) ) /* concatenate C tokens */ #define FT_ERR_XCAT( x, y ) x ## y #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) - /* see `ftmoderr.h' for descriptions of the following macros */ + /* see `ftmoderr.h` for descriptions of the following macros */ #define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) diff --git a/src/3rdparty/freetype/include/freetype/ftwinfnt.h b/src/3rdparty/freetype/include/freetype/ftwinfnt.h index 461c65b779..a2fba903d2 100644 --- a/src/3rdparty/freetype/include/freetype/ftwinfnt.h +++ b/src/3rdparty/freetype/include/freetype/ftwinfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftwinfnt.h */ -/* */ -/* FreeType API for accessing Windows fnt-specific data. */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftwinfnt.h + * + * FreeType API for accessing Windows fnt-specific data. + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTWINFNT_H_ @@ -32,44 +32,43 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* winfnt_fonts */ - /* */ - /* <Title> */ - /* Window FNT Files */ - /* */ - /* <Abstract> */ - /* Windows FNT specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Windows FNT specific */ - /* functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * winfnt_fonts + * + * @title: + * Window FNT Files + * + * @abstract: + * Windows FNT-specific API. + * + * @description: + * This section contains the declaration of Windows FNT-specific + * functions. + * + */ - /************************************************************************* + /************************************************************************** * * @enum: * FT_WinFNT_ID_XXX * * @description: - * A list of valid values for the `charset' byte in - * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX - * encodings (except for cp1361) can be found at - * ftp://ftp.unicode.org/Public in the MAPPINGS/VENDORS/MICSFT/WINDOWS - * subdirectory. cp1361 is roughly a superset of - * MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT. + * A list of valid values for the `charset` byte in @FT_WinFNT_HeaderRec. + * Exact mapping tables for the various 'cpXXXX' encodings (except for + * 'cp1361') can be found at 'ftp://ftp.unicode.org/Public/' in the + * `MAPPINGS/VENDORS/MICSFT/WINDOWS` subdirectory. 'cp1361' is roughly a + * superset of `MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT`. * * @values: * FT_WinFNT_ID_DEFAULT :: - * This is used for font enumeration and font creation as a - * `don't care' value. Valid font files don't contain this value. - * When querying for information about the character set of the font - * that is currently selected into a specified device context, this - * return value (of the related Windows API) simply denotes failure. + * This is used for font enumeration and font creation as a 'don't + * care' value. Valid font files don't contain this value. When + * querying for information about the character set of the font that is + * currently selected into a specified device context, this return + * value (of the related Windows API) simply denotes failure. * * FT_WinFNT_ID_SYMBOL :: * There is no known mapping table available. @@ -80,26 +79,27 @@ FT_BEGIN_HEADER * FT_WinFNT_ID_OEM :: * From Michael Poettgen <michael@poettgen.de>: * - * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM - * is used for the charset of vector fonts, like `modern.fon', - * `roman.fon', and `script.fon' on Windows. + * The 'Windows Font Mapping' article says that `FT_WinFNT_ID_OEM` is + * used for the charset of vector fonts, like `modern.fon`, + * `roman.fon`, and `script.fon` on Windows. * - * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value - * specifies a character set that is operating-system dependent. + * The 'CreateFont' documentation says: The `FT_WinFNT_ID_OEM` value + * specifies a character set that is operating-system dependent. * - * The `IFIMETRICS' documentation from the `Windows Driver - * Development Kit' says: This font supports an OEM-specific - * character set. The OEM character set is system dependent. + * The 'IFIMETRICS' documentation from the 'Windows Driver Development + * Kit' says: This font supports an OEM-specific character set. The + * OEM character set is system dependent. * - * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the - * second default codepage that most international versions of - * Windows have. It is one of the OEM codepages from + * In general OEM, as opposed to ANSI (i.e., 'cp1252'), denotes the + * second default codepage that most international versions of Windows + * have. It is one of the OEM codepages from * - * https://msdn.microsoft.com/en-us/goglobal/bb964655, + * https://docs.microsoft.com/en-us/windows/desktop/intl/code-page-identifiers + * , * - * and is used for the `DOS boxes', to support legacy applications. - * A German Windows version for example usually uses ANSI codepage - * 1252 and OEM codepage 850. + * and is used for the 'DOS boxes', to support legacy applications. A + * German Windows version for example usually uses ANSI codepage 1252 + * and OEM codepage 850. * * FT_WinFNT_ID_CP874 :: * A superset of Thai TIS 620 and ISO 8859-11. @@ -112,8 +112,8 @@ FT_BEGIN_HEADER * ordering and minor deviations). * * FT_WinFNT_ID_CP949 :: - * A superset of Korean Hangul KS~C 5601-1987 (with different - * ordering and minor deviations). + * A superset of Korean Hangul KS~C 5601-1987 (with different ordering + * and minor deviations). * * FT_WinFNT_ID_CP950 :: * A superset of traditional Chinese Big~5 ETen (with different @@ -173,14 +173,14 @@ FT_BEGIN_HEADER #define FT_WinFNT_ID_OEM 255 - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_WinFNT_HeaderRec */ - /* */ - /* <Description> */ - /* Windows FNT Header info. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_WinFNT_HeaderRec + * + * @description: + * Windows FNT Header info. + */ typedef struct FT_WinFNT_HeaderRec_ { FT_UShort version; @@ -223,18 +223,18 @@ FT_BEGIN_HEADER } FT_WinFNT_HeaderRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_WinFNT_Header */ - /* */ - /* <Description> */ - /* A handle to an @FT_WinFNT_HeaderRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_WinFNT_Header + * + * @description: + * A handle to an @FT_WinFNT_HeaderRec structure. + */ typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header; - /********************************************************************** + /************************************************************************** * * @function: * FT_Get_WinFNT_Header @@ -243,10 +243,12 @@ FT_BEGIN_HEADER * Retrieve a Windows FNT font info header. * * @input: - * face :: A handle to the input face. + * face :: + * A handle to the input face. * * @output: - * aheader :: The WinFNT header. + * aheader :: + * The WinFNT header. * * @return: * FreeType error code. 0~means success. diff --git a/src/3rdparty/freetype/include/freetype/internal/autohint.h b/src/3rdparty/freetype/include/freetype/internal/autohint.h index f4d308f68c..f64c28bb2c 100644 --- a/src/3rdparty/freetype/include/freetype/internal/autohint.h +++ b/src/3rdparty/freetype/include/freetype/internal/autohint.h @@ -1,73 +1,73 @@ -/***************************************************************************/ -/* */ -/* autohint.h */ -/* */ -/* High-level `autohint' module-specific interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The auto-hinter is used to load and automatically hint glyphs if a */ - /* format-specific hinter isn't available. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * autohint.h + * + * High-level 'autohint' module-specific interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * The auto-hinter is used to load and automatically hint glyphs if a + * format-specific hinter isn't available. + * + */ #ifndef AUTOHINT_H_ #define AUTOHINT_H_ - /*************************************************************************/ - /* */ - /* A small technical note regarding automatic hinting in order to */ - /* clarify this module interface. */ - /* */ - /* An automatic hinter might compute two kinds of data for a given face: */ - /* */ - /* - global hints: Usually some metrics that describe global properties */ - /* of the face. It is computed by scanning more or less */ - /* aggressively the glyphs in the face, and thus can be */ - /* very slow to compute (even if the size of global */ - /* hints is really small). */ - /* */ - /* - glyph hints: These describe some important features of the glyph */ - /* outline, as well as how to align them. They are */ - /* generally much faster to compute than global hints. */ - /* */ - /* The current FreeType auto-hinter does a pretty good job while */ - /* performing fast computations for both global and glyph hints. */ - /* However, we might be interested in introducing more complex and */ - /* powerful algorithms in the future, like the one described in the John */ - /* D. Hobby paper, which unfortunately requires a lot more horsepower. */ - /* */ - /* Because a sufficiently sophisticated font management system would */ - /* typically implement an LRU cache of opened face objects to reduce */ - /* memory usage, it is a good idea to be able to avoid recomputing */ - /* global hints every time the same face is re-opened. */ - /* */ - /* We thus provide the ability to cache global hints outside of the face */ - /* object, in order to speed up font re-opening time. Of course, this */ - /* feature is purely optional, so most client programs won't even notice */ - /* it. */ - /* */ - /* I initially thought that it would be a good idea to cache the glyph */ - /* hints too. However, my general idea now is that if you really need */ - /* to cache these too, you are simply in need of a new font format, */ - /* where all this information could be stored within the font file and */ - /* decoded on the fly. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * A small technical note regarding automatic hinting in order to clarify + * this module interface. + * + * An automatic hinter might compute two kinds of data for a given face: + * + * - global hints: Usually some metrics that describe global properties + * of the face. It is computed by scanning more or less + * aggressively the glyphs in the face, and thus can be + * very slow to compute (even if the size of global hints + * is really small). + * + * - glyph hints: These describe some important features of the glyph + * outline, as well as how to align them. They are + * generally much faster to compute than global hints. + * + * The current FreeType auto-hinter does a pretty good job while performing + * fast computations for both global and glyph hints. However, we might be + * interested in introducing more complex and powerful algorithms in the + * future, like the one described in the John D. Hobby paper, which + * unfortunately requires a lot more horsepower. + * + * Because a sufficiently sophisticated font management system would + * typically implement an LRU cache of opened face objects to reduce memory + * usage, it is a good idea to be able to avoid recomputing global hints + * every time the same face is re-opened. + * + * We thus provide the ability to cache global hints outside of the face + * object, in order to speed up font re-opening time. Of course, this + * feature is purely optional, so most client programs won't even notice + * it. + * + * I initially thought that it would be a good idea to cache the glyph + * hints too. However, my general idea now is that if you really need to + * cache these too, you are simply in need of a new font format, where all + * this information could be stored within the font file and decoded on the + * fly. + * + */ #include <ft2build.h> @@ -80,27 +80,31 @@ FT_BEGIN_HEADER typedef struct FT_AutoHinterRec_ *FT_AutoHinter; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalGetFunc */ - /* */ - /* <Description> */ - /* Retrieve the global hints computed for a given face object. The */ - /* resulting data is dissociated from the face and will survive a */ - /* call to FT_Done_Face(). It must be discarded through the API */ - /* FT_AutoHinter_GlobalDoneFunc(). */ - /* */ - /* <Input> */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* global_hints :: A typeless pointer to the global hints. */ - /* */ - /* global_len :: The size in bytes of the global hints. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalGetFunc + * + * @description: + * Retrieve the global hints computed for a given face object. The + * resulting data is dissociated from the face and will survive a call to + * FT_Done_Face(). It must be discarded through the API + * FT_AutoHinter_GlobalDoneFunc(). + * + * @input: + * hinter :: + * A handle to the source auto-hinter. + * + * face :: + * A handle to the source face object. + * + * @output: + * global_hints :: + * A typeless pointer to the global hints. + * + * global_len :: + * The size in bytes of the global hints. + */ typedef void (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter, FT_Face face, @@ -108,69 +112,76 @@ FT_BEGIN_HEADER long* global_len ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalDoneFunc */ - /* */ - /* <Description> */ - /* Discard the global hints retrieved through */ - /* FT_AutoHinter_GlobalGetFunc(). This is the only way these hints */ - /* are freed from memory. */ - /* */ - /* <Input> */ - /* hinter :: A handle to the auto-hinter module. */ - /* */ - /* global :: A pointer to retrieved global hints to discard. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalDoneFunc + * + * @description: + * Discard the global hints retrieved through + * FT_AutoHinter_GlobalGetFunc(). This is the only way these hints are + * freed from memory. + * + * @input: + * hinter :: + * A handle to the auto-hinter module. + * + * global :: + * A pointer to retrieved global hints to discard. + */ typedef void (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter, void* global ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalResetFunc */ - /* */ - /* <Description> */ - /* This function is used to recompute the global metrics in a given */ - /* font. This is useful when global font data changes (e.g. Multiple */ - /* Masters fonts where blend coordinates change). */ - /* */ - /* <Input> */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the face. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlobalResetFunc + * + * @description: + * This function is used to recompute the global metrics in a given font. + * This is useful when global font data changes (e.g. Multiple Masters + * fonts where blend coordinates change). + * + * @input: + * hinter :: + * A handle to the source auto-hinter. + * + * face :: + * A handle to the face. + */ typedef void (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter, FT_Face face ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlyphLoadFunc */ - /* */ - /* <Description> */ - /* This function is used to load, scale, and automatically hint a */ - /* glyph from a given face. */ - /* */ - /* <Input> */ - /* face :: A handle to the face. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* load_flags :: The load flags. */ - /* */ - /* <Note> */ - /* This function is capable of loading composite glyphs by hinting */ - /* each sub-glyph independently (which improves quality). */ - /* */ - /* It will call the font driver with @FT_Load_Glyph, with */ - /* @FT_LOAD_NO_SCALE set. */ - /* */ + /************************************************************************** + * + * @functype: + * FT_AutoHinter_GlyphLoadFunc + * + * @description: + * This function is used to load, scale, and automatically hint a glyph + * from a given face. + * + * @input: + * face :: + * A handle to the face. + * + * glyph_index :: + * The glyph index. + * + * load_flags :: + * The load flags. + * + * @note: + * This function is capable of loading composite glyphs by hinting each + * sub-glyph independently (which improves quality). + * + * It will call the font driver with @FT_Load_Glyph, with + * @FT_LOAD_NO_SCALE set. + */ typedef FT_Error (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter, FT_GlyphSlot slot, @@ -179,14 +190,14 @@ FT_BEGIN_HEADER FT_Int32 load_flags ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_AutoHinter_InterfaceRec */ - /* */ - /* <Description> */ - /* The auto-hinter module's interface. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_AutoHinter_InterfaceRec + * + * @description: + * The auto-hinter module's interface. + */ typedef struct FT_AutoHinter_InterfaceRec_ { FT_AutoHinter_GlobalResetFunc reset_face; @@ -197,8 +208,6 @@ FT_BEGIN_HEADER } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_AUTOHINTER_INTERFACE( \ class_, \ reset_face_, \ @@ -214,27 +223,6 @@ FT_BEGIN_HEADER load_glyph_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_AUTOHINTER_INTERFACE( \ - class_, \ - reset_face_, \ - get_global_hints_, \ - done_global_hints_, \ - load_glyph_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_AutoHinter_InterfaceRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->reset_face = reset_face_; \ - clazz->get_global_hints = get_global_hints_; \ - clazz->done_global_hints = done_global_hints_; \ - clazz->load_glyph = load_glyph_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/3rdparty/freetype/include/freetype/internal/cffotypes.h b/src/3rdparty/freetype/include/freetype/internal/cffotypes.h index 57e7591d41..b26893eab3 100644 --- a/src/3rdparty/freetype/include/freetype/internal/cffotypes.h +++ b/src/3rdparty/freetype/include/freetype/internal/cffotypes.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffotypes.h */ -/* */ -/* Basic OpenType/CFF object type definitions (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffotypes.h + * + * Basic OpenType/CFF object type definitions (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFOTYPES_H_ @@ -33,14 +33,14 @@ FT_BEGIN_HEADER typedef TT_Face CFF_Face; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Size */ - /* */ - /* <Description> */ - /* A handle to an OpenType size object. */ - /* */ + /************************************************************************** + * + * @type: + * CFF_Size + * + * @description: + * A handle to an OpenType size object. + */ typedef struct CFF_SizeRec_ { FT_SizeRec root; @@ -49,14 +49,14 @@ FT_BEGIN_HEADER } CFF_SizeRec, *CFF_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to an OpenType glyph slot object. */ - /* */ + /************************************************************************** + * + * @type: + * CFF_GlyphSlot + * + * @description: + * A handle to an OpenType glyph slot object. + */ typedef struct CFF_GlyphSlotRec_ { FT_GlyphSlotRec root; @@ -70,14 +70,14 @@ FT_BEGIN_HEADER } CFF_GlyphSlotRec, *CFF_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CFF_Internal */ - /* */ - /* <Description> */ - /* The interface to the `internal' field of `FT_Size'. */ - /* */ + /************************************************************************** + * + * @type: + * CFF_Internal + * + * @description: + * The interface to the 'internal' field of `FT_Size`. + */ typedef struct CFF_InternalRec_ { PSH_Globals topfont; @@ -86,10 +86,10 @@ FT_BEGIN_HEADER } CFF_InternalRec, *CFF_Internal; - /*************************************************************************/ - /* */ - /* Subglyph transformation record. */ - /* */ + /************************************************************************** + * + * Subglyph transformation record. + */ typedef struct CFF_Transform_ { FT_Fixed xx, xy; /* transformation matrix coefficients */ diff --git a/src/3rdparty/freetype/include/freetype/internal/cfftypes.h b/src/3rdparty/freetype/include/freetype/internal/cfftypes.h index 7c07e1a376..2fc905ec79 100644 --- a/src/3rdparty/freetype/include/freetype/internal/cfftypes.h +++ b/src/3rdparty/freetype/include/freetype/internal/cfftypes.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* cfftypes.h */ -/* */ -/* Basic OpenType/CFF type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cfftypes.h + * + * Basic OpenType/CFF type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFTYPES_H_ @@ -33,34 +33,39 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CFF_IndexRec */ - /* */ - /* <Description> */ - /* A structure used to model a CFF Index table. */ - /* */ - /* <Fields> */ - /* stream :: The source input stream. */ - /* */ - /* start :: The position of the first index byte in the */ - /* input stream. */ - /* */ - /* count :: The number of elements in the index. */ - /* */ - /* off_size :: The size in bytes of object offsets in index. */ - /* */ - /* data_offset :: The position of first data byte in the index's */ - /* bytes. */ - /* */ - /* data_size :: The size of the data table in this index. */ - /* */ - /* offsets :: A table of element offsets in the index. Must be */ - /* loaded explicitly. */ - /* */ - /* bytes :: If the index is loaded in memory, its bytes. */ - /* */ + /************************************************************************** + * + * @struct: + * CFF_IndexRec + * + * @description: + * A structure used to model a CFF Index table. + * + * @fields: + * stream :: + * The source input stream. + * + * start :: + * The position of the first index byte in the input stream. + * + * count :: + * The number of elements in the index. + * + * off_size :: + * The size in bytes of object offsets in index. + * + * data_offset :: + * The position of first data byte in the index's bytes. + * + * data_size :: + * The size of the data table in this index. + * + * offsets :: + * A table of element offsets in the index. Must be loaded explicitly. + * + * bytes :: + * If the index is loaded in memory, its bytes. + */ typedef struct CFF_IndexRec_ { FT_Stream stream; diff --git a/src/3rdparty/freetype/include/freetype/internal/ftcalc.h b/src/3rdparty/freetype/include/freetype/internal/ftcalc.h index 818a812359..1811fcd1ea 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftcalc.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftcalc.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcalc.h */ -/* */ -/* Arithmetic computations (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcalc.h + * + * Arithmetic computations (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCALC_H_ @@ -27,11 +27,11 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * FT_MulDiv() and FT_MulFix() are declared in freetype.h. + * + */ #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER /* Provide assembler fragments for performance-critical functions. */ @@ -246,29 +246,32 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv_No_Round */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation `(a*b)/c' */ - /* (without rounding) with maximum accuracy (it uses a 64-bit */ - /* intermediate integer whenever necessary). */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_MulDiv_No_Round + * + * @description: + * A very simple function used to perform the computation '(a*b)/c' + * (without rounding) with maximum accuracy (it uses a 64-bit + * intermediate integer whenever necessary). + * + * This function isn't necessarily as fast as some processor-specific + * operations, but is at least completely portable. + * + * @input: + * a :: + * The first multiplier. + * b :: + * The second multiplier. + * c :: + * The divisor. + * + * @return: + * The result of '(a*b)/c'. This function never traps when trying to + * divide by zero; it simply returns 'MaxInt' or 'MinInt' depending on + * the signs of 'a' and 'b'. + */ FT_BASE( FT_Long ) FT_MulDiv_No_Round( FT_Long a, FT_Long b, @@ -276,12 +279,11 @@ FT_BEGIN_HEADER /* - * A variant of FT_Matrix_Multiply which scales its result afterwards. - * The idea is that both `a' and `b' are scaled by factors of 10 so that - * the values are as precise as possible to get a correct result during - * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of - * `a' and `b', respectively, then the scaling factor of the result is - * `sa*sb'. + * A variant of FT_Matrix_Multiply which scales its result afterwards. The + * idea is that both `a' and `b' are scaled by factors of 10 so that the + * values are as precise as possible to get a correct result during the + * 64bit multiplication. Let `sa' and `sb' be the scaling factors of `a' + * and `b', respectively, then the scaling factor of the result is `sa*sb'. */ FT_BASE( void ) FT_Matrix_Multiply_Scaled( const FT_Matrix* a, @@ -290,8 +292,23 @@ FT_BEGIN_HEADER /* - * A variant of FT_Vector_Transform. See comments for - * FT_Matrix_Multiply_Scaled. + * Check a matrix. If the transformation would lead to extreme shear or + * extreme scaling, for example, return 0. If everything is OK, return 1. + * + * Based on geometric considerations we use the following inequality to + * identify a degenerate matrix. + * + * 50 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2 + * + * Value 50 is heuristic. + */ + FT_BASE( FT_Bool ) + FT_Matrix_Check( const FT_Matrix* matrix ); + + + /* + * A variant of FT_Vector_Transform. See comments for + * FT_Matrix_Multiply_Scaled. */ FT_BASE( void ) FT_Vector_Transform_Scaled( FT_Vector* vector, @@ -300,22 +317,22 @@ FT_BEGIN_HEADER /* - * This function normalizes a vector and returns its original length. - * The normalized vector is a 16.16 fixed-point unit vector with length - * close to 0x10000. The accuracy of the returned length is limited to - * 16 bits also. The function utilizes quick inverse square root - * approximation without divisions and square roots relying on Newton's - * iterations instead. + * This function normalizes a vector and returns its original length. The + * normalized vector is a 16.16 fixed-point unit vector with length close + * to 0x10000. The accuracy of the returned length is limited to 16 bits + * also. The function utilizes quick inverse square root approximation + * without divisions and square roots relying on Newton's iterations + * instead. */ FT_BASE( FT_UInt32 ) FT_Vector_NormLen( FT_Vector* vector ); /* - * Return -1, 0, or +1, depending on the orientation of a given corner. - * We use the Cartesian coordinate system, with positive vertical values - * going upwards. The function returns +1 if the corner turns to the - * left, -1 to the right, and 0 for undecidable cases. + * Return -1, 0, or +1, depending on the orientation of a given corner. We + * use the Cartesian coordinate system, with positive vertical values going + * upwards. The function returns +1 if the corner turns to the left, -1 to + * the right, and 0 for undecidable cases. */ FT_BASE( FT_Int ) ft_corner_orientation( FT_Pos in_x, @@ -325,9 +342,9 @@ FT_BEGIN_HEADER /* - * Return TRUE if a corner is flat or nearly flat. This is equivalent to - * saying that the corner point is close to its neighbors, or inside an - * ellipse defined by the neighbor focal points to be more precise. + * Return TRUE if a corner is flat or nearly flat. This is equivalent to + * saying that the corner point is close to its neighbors, or inside an + * ellipse defined by the neighbor focal points to be more precise. */ FT_BASE( FT_Int ) ft_corner_is_flat( FT_Pos in_x, @@ -337,10 +354,11 @@ FT_BEGIN_HEADER /* - * Return the most significant bit index. + * Return the most significant bit index. */ #ifndef FT_CONFIG_OPTION_NO_ASSEMBLER + #if defined( __GNUC__ ) && \ ( __GNUC__ > 3 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4 ) ) @@ -352,9 +370,34 @@ FT_BEGIN_HEADER #define FT_MSB( x ) ( 31 - __builtin_clzl( x ) ) +#endif /* __GNUC__ */ + + +#elif defined( _MSC_VER ) && ( _MSC_VER >= 1400 ) + +#if FT_SIZEOF_INT == 4 + +#include <intrin.h> +#pragma intrinsic( _BitScanReverse ) + + static __inline FT_Int32 + FT_MSB_i386( FT_UInt32 x ) + { + unsigned long where; + + + _BitScanReverse( &where, x ); + + return (FT_Int32)where; + } + +#define FT_MSB( x ) ( FT_MSB_i386( x ) ) + #endif -#endif /* __GNUC__ */ +#endif /* _MSC_VER */ + + #endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ #ifndef FT_MSB @@ -366,8 +409,8 @@ FT_BEGIN_HEADER /* - * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses - * two fixed-point arguments instead. + * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses + * two fixed-point arguments instead. */ FT_BASE( FT_Fixed ) FT_Hypot( FT_Fixed x, @@ -376,23 +419,24 @@ FT_BEGIN_HEADER #if 0 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_SqrtFixed */ - /* */ - /* <Description> */ - /* Computes the square root of a 16.16 fixed-point value. */ - /* */ - /* <Input> */ - /* x :: The value to compute the root for. */ - /* */ - /* <Return> */ - /* The result of `sqrt(x)'. */ - /* */ - /* <Note> */ - /* This function is not very fast. */ - /* */ + /************************************************************************** + * + * @function: + * FT_SqrtFixed + * + * @description: + * Computes the square root of a 16.16 fixed-point value. + * + * @input: + * x :: + * The value to compute the root for. + * + * @return: + * The result of 'sqrt(x)'. + * + * @note: + * This function is not very fast. + */ FT_BASE( FT_Int32 ) FT_SqrtFixed( FT_Int32 x ); @@ -409,14 +453,23 @@ FT_BEGIN_HEADER : ( -( ( 32 - (x) ) & -64 ) ) ) /* - * The following macros have two purposes. + * The following macros have two purposes. * - * . Tag places where overflow is expected and harmless. + * - Tag places where overflow is expected and harmless. * - * . Avoid run-time sanitizer errors. + * - Avoid run-time sanitizer errors. * - * Use with care! + * Use with care! */ +#define ADD_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) + (FT_UInt)(b) ) +#define SUB_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) - (FT_UInt)(b) ) +#define MUL_INT( a, b ) \ + (FT_Int)( (FT_UInt)(a) * (FT_UInt)(b) ) +#define NEG_INT( a ) \ + (FT_Int)( (FT_UInt)0 - (FT_UInt)(a) ) + #define ADD_LONG( a, b ) \ (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) ) #define SUB_LONG( a, b ) \ @@ -435,6 +488,19 @@ FT_BEGIN_HEADER #define NEG_INT32( a ) \ (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) ) +#ifdef FT_LONG64 + +#define ADD_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) + (FT_UInt64)(b) ) +#define SUB_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) - (FT_UInt64)(b) ) +#define MUL_INT64( a, b ) \ + (FT_Int64)( (FT_UInt64)(a) * (FT_UInt64)(b) ) +#define NEG_INT64( a ) \ + (FT_Int64)( (FT_UInt64)0 - (FT_UInt64)(a) ) + +#endif /* FT_LONG64 */ + FT_END_HEADER diff --git a/src/3rdparty/freetype/include/freetype/internal/ftdebug.h b/src/3rdparty/freetype/include/freetype/internal/ftdebug.h index 292a4eedb8..54a9673afa 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftdebug.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftdebug.h @@ -1,24 +1,24 @@ -/***************************************************************************/ -/* */ -/* ftdebug.h */ -/* */ -/* Debugging and logging component (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* */ -/* IMPORTANT: A description of FreeType's debugging support can be */ -/* found in `docs/DEBUG.TXT'. Read it if you need to use or */ -/* understand this code. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdebug.h + * + * Debugging and logging component (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * IMPORTANT: A description of FreeType's debugging support can be + * found in 'docs/DEBUG.TXT'. Read it if you need to use or + * understand this code. + * + */ #ifndef FTDEBUG_H_ @@ -42,12 +42,12 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* Define the trace enums as well as the trace levels array when they */ - /* are needed. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the trace enums as well as the trace levels array when they are + * needed. + * + */ #ifdef FT_DEBUG_LEVEL_TRACE @@ -62,32 +62,37 @@ FT_BEGIN_HEADER } FT_Trace; - /* defining the array of trace levels, provided by `src/base/ftdebug.c' */ - extern int ft_trace_levels[trace_count]; + /* a pointer to the array of trace levels, */ + /* provided by `src/base/ftdebug.c' */ + extern int* ft_trace_levels; #undef FT_TRACE_DEF #endif /* FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* Define the FT_TRACE macro */ - /* */ - /* IMPORTANT! */ - /* */ - /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */ - /* value before using any TRACE macro. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the FT_TRACE macro + * + * IMPORTANT! + * + * Each component must define the macro FT_COMPONENT to a valid FT_Trace + * value before using any TRACE macro. + * + */ #ifdef FT_DEBUG_LEVEL_TRACE -#define FT_TRACE( level, varformat ) \ - do \ - { \ - if ( ft_trace_levels[FT_COMPONENT] >= level ) \ - FT_Message varformat; \ + /* we need two macros here to make cpp expand `FT_COMPONENT' */ +#define FT_TRACE_COMP( x ) FT_TRACE_COMP_( x ) +#define FT_TRACE_COMP_( x ) trace_ ## x + +#define FT_TRACE( level, varformat ) \ + do \ + { \ + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] >= level ) \ + FT_Message varformat; \ } while ( 0 ) #else /* !FT_DEBUG_LEVEL_TRACE */ @@ -97,62 +102,85 @@ FT_BEGIN_HEADER #endif /* !FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Trace_Get_Count */ - /* */ - /* <Description> */ - /* Return the number of available trace components. */ - /* */ - /* <Return> */ - /* The number of trace components. 0 if FreeType 2 is not built with */ - /* FT_DEBUG_LEVEL_TRACE definition. */ - /* */ - /* <Note> */ - /* This function may be useful if you want to access elements of */ - /* the internal `ft_trace_levels' array by an index. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Trace_Get_Count + * + * @description: + * Return the number of available trace components. + * + * @return: + * The number of trace components. 0 if FreeType 2 is not built with + * FT_DEBUG_LEVEL_TRACE definition. + * + * @note: + * This function may be useful if you want to access elements of the + * internal trace levels array by an index. + */ FT_BASE( FT_Int ) FT_Trace_Get_Count( void ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Trace_Get_Name */ - /* */ - /* <Description> */ - /* Return the name of a trace component. */ - /* */ - /* <Input> */ - /* The index of the trace component. */ - /* */ - /* <Return> */ - /* The name of the trace component. This is a statically allocated */ - /* C string, so do not free it after use. NULL if FreeType 2 is not */ - /* built with FT_DEBUG_LEVEL_TRACE definition. */ - /* */ - /* <Note> */ - /* Use @FT_Trace_Get_Count to get the number of available trace */ - /* components. */ - /* */ - /* This function may be useful if you want to control FreeType 2's */ - /* debug level in your application. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Trace_Get_Name + * + * @description: + * Return the name of a trace component. + * + * @input: + * The index of the trace component. + * + * @return: + * The name of the trace component. This is a statically allocated + * C~string, so do not free it after use. `NULL` if FreeType is not + * built with FT_DEBUG_LEVEL_TRACE definition. + * + * @note: + * Use @FT_Trace_Get_Count to get the number of available trace + * components. + */ FT_BASE( const char* ) FT_Trace_Get_Name( FT_Int idx ); - /*************************************************************************/ - /* */ - /* You need two opening and closing parentheses! */ - /* */ - /* Example: FT_TRACE0(( "Value is %i", foo )) */ - /* */ - /* Output of the FT_TRACEX macros is sent to stderr. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @function: + * FT_Trace_Disable + * + * @description: + * Switch off tracing temporarily. It can be activated again with + * @FT_Trace_Enable. + */ + FT_BASE( void ) + FT_Trace_Disable( void ); + + + /************************************************************************** + * + * @function: + * FT_Trace_Enable + * + * @description: + * Activate tracing. Use it after tracing has been switched off with + * @FT_Trace_Disable. + */ + FT_BASE( void ) + FT_Trace_Enable( void ); + + + /************************************************************************** + * + * You need two opening and closing parentheses! + * + * Example: FT_TRACE0(( "Value is %i", foo )) + * + * Output of the FT_TRACEX macros is sent to stderr. + * + */ #define FT_TRACE0( varformat ) FT_TRACE( 0, varformat ) #define FT_TRACE1( varformat ) FT_TRACE( 1, varformat ) @@ -164,13 +192,13 @@ FT_BEGIN_HEADER #define FT_TRACE7( varformat ) FT_TRACE( 7, varformat ) - /*************************************************************************/ - /* */ - /* Define the FT_ERROR macro. */ - /* */ - /* Output of this macro is sent to stderr. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the FT_ERROR macro. + * + * Output of this macro is sent to stderr. + * + */ #ifdef FT_DEBUG_LEVEL_ERROR @@ -183,12 +211,12 @@ FT_BEGIN_HEADER #endif /* !FT_DEBUG_LEVEL_ERROR */ - /*************************************************************************/ - /* */ - /* Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw' */ - /* makes it possible to easily set a breakpoint at this function. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw` makes + * it possible to easily set a breakpoint at this function. + * + */ #ifdef FT_DEBUG_LEVEL_ERROR @@ -215,11 +243,11 @@ FT_BEGIN_HEADER #endif /* !FT_DEBUG_LEVEL_ERROR */ - /*************************************************************************/ - /* */ - /* Define `FT_Message' and `FT_Panic' when needed. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define `FT_Message` and `FT_Panic` when needed. + * + */ #ifdef FT_DEBUG_LEVEL_ERROR diff --git a/src/3rdparty/freetype/include/freetype/internal/ftdrv.h b/src/3rdparty/freetype/include/freetype/internal/ftdrv.h index 58dd35a933..09e846e1c7 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftdrv.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftdrv.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftdrv.h */ -/* */ -/* FreeType internal font driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdrv.h + * + * FreeType internal font driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTDRV_H_ @@ -87,73 +87,80 @@ FT_BEGIN_HEADER FT_Fixed* advances ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Driver_ClassRec */ - /* */ - /* <Description> */ - /* The font driver class. This structure mostly contains pointers to */ - /* driver methods. */ - /* */ - /* <Fields> */ - /* root :: The parent module. */ - /* */ - /* face_object_size :: The size of a face object in bytes. */ - /* */ - /* size_object_size :: The size of a size object in bytes. */ - /* */ - /* slot_object_size :: The size of a glyph object in bytes. */ - /* */ - /* init_face :: The format-specific face constructor. */ - /* */ - /* done_face :: The format-specific face destructor. */ - /* */ - /* init_size :: The format-specific size constructor. */ - /* */ - /* done_size :: The format-specific size destructor. */ - /* */ - /* init_slot :: The format-specific slot constructor. */ - /* */ - /* done_slot :: The format-specific slot destructor. */ - /* */ - /* */ - /* load_glyph :: A function handle to load a glyph to a slot. */ - /* This field is mandatory! */ - /* */ - /* get_kerning :: A function handle to return the unscaled */ - /* kerning for a given pair of glyphs. Can be */ - /* set to 0 if the format doesn't support */ - /* kerning. */ - /* */ - /* attach_file :: This function handle is used to read */ - /* additional data for a face from another */ - /* file/stream. For example, this can be used to */ - /* add data from AFM or PFM files on a Type 1 */ - /* face, or a CIDMap on a CID-keyed face. */ - /* */ - /* get_advances :: A function handle used to return advance */ - /* widths of `count' glyphs (in font units), */ - /* starting at `first'. The `vertical' flag must */ - /* be set to get vertical advance heights. The */ - /* `advances' buffer is caller-allocated. */ - /* The idea of this function is to be able to */ - /* perform device-independent text layout without */ - /* loading a single glyph image. */ - /* */ - /* request_size :: A handle to a function used to request the new */ - /* character size. Can be set to 0 if the */ - /* scaling done in the base layer suffices. */ - /* */ - /* select_size :: A handle to a function used to select a new */ - /* fixed size. It is used only if */ - /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ - /* to 0 if the scaling done in the base layer */ - /* suffices. */ - /* <Note> */ - /* Most function pointers, with the exception of `load_glyph', can be */ - /* set to 0 to indicate a default behaviour. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Driver_ClassRec + * + * @description: + * The font driver class. This structure mostly contains pointers to + * driver methods. + * + * @fields: + * root :: + * The parent module. + * + * face_object_size :: + * The size of a face object in bytes. + * + * size_object_size :: + * The size of a size object in bytes. + * + * slot_object_size :: + * The size of a glyph object in bytes. + * + * init_face :: + * The format-specific face constructor. + * + * done_face :: + * The format-specific face destructor. + * + * init_size :: + * The format-specific size constructor. + * + * done_size :: + * The format-specific size destructor. + * + * init_slot :: + * The format-specific slot constructor. + * + * done_slot :: + * The format-specific slot destructor. + * + * + * load_glyph :: + * A function handle to load a glyph to a slot. This field is + * mandatory! + * + * get_kerning :: + * A function handle to return the unscaled kerning for a given pair of + * glyphs. Can be set to 0 if the format doesn't support kerning. + * + * attach_file :: + * This function handle is used to read additional data for a face from + * another file/stream. For example, this can be used to add data from + * AFM or PFM files on a Type 1 face, or a CIDMap on a CID-keyed face. + * + * get_advances :: + * A function handle used to return advance widths of 'count' glyphs + * (in font units), starting at 'first'. The 'vertical' flag must be + * set to get vertical advance heights. The 'advances' buffer is + * caller-allocated. The idea of this function is to be able to + * perform device-independent text layout without loading a single + * glyph image. + * + * request_size :: + * A handle to a function used to request the new character size. Can + * be set to 0 if the scaling done in the base layer suffices. + * + * select_size :: + * A handle to a function used to select a new fixed size. It is used + * only if @FT_FACE_FLAG_FIXED_SIZES is set. Can be set to 0 if the + * scaling done in the base layer suffices. + * @note: + * Most function pointers, with the exception of `load_glyph`, can be set + * to 0 to indicate a default behaviour. + */ typedef struct FT_Driver_ClassRec_ { FT_Module_Class root; @@ -184,45 +191,28 @@ FT_BEGIN_HEADER } FT_Driver_ClassRec, *FT_Driver_Class; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_DRIVER */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of an FT_Driver_ClassRec */ - /* struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_DRIVER */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Driver_ClassRec struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */ - /* called with a pointer where the allocated structure is returned. */ - /* And when it is no longer needed a `destroy' function needs to be */ - /* called to release that allocation. */ - /* */ - /* `ftinit.c' (ft_create_default_module_classes) already contains a */ - /* mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by driver definition calling `FT_DEFINE_DRIVER' in following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro is */ - /* used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DECLARE_DRIVER + * + * @description: + * Used to create a forward declaration of an FT_Driver_ClassRec struct + * instance. + * + * @macro: + * FT_DEFINE_DRIVER + * + * @description: + * Used to initialize an instance of FT_Driver_ClassRec struct. + * + * `ftinit.c` (ft_create_default_module_classes) already contains a + * mechanism to call these functions for the default modules described in + * `ftmodule.h`. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DECLARE_DRIVER( class_ ) \ FT_CALLBACK_TABLE \ const FT_Driver_ClassRec class_; @@ -289,108 +279,6 @@ FT_BEGIN_HEADER select_size_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ ) - -#define FT_DEFINE_DRIVER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - face_object_size_, \ - size_object_size_, \ - slot_object_size_, \ - init_face_, \ - done_face_, \ - init_size_, \ - done_size_, \ - init_slot_, \ - done_slot_, \ - load_glyph_, \ - get_kerning_, \ - attach_file_, \ - get_advances_, \ - request_size_, \ - select_size_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( dclazz ) \ - FT_FREE( dclazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Driver_Class clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - clazz->face_object_size = face_object_size_; \ - clazz->size_object_size = size_object_size_; \ - clazz->slot_object_size = slot_object_size_; \ - \ - clazz->init_face = init_face_; \ - clazz->done_face = done_face_; \ - \ - clazz->init_size = init_size_; \ - clazz->done_size = done_size_; \ - \ - clazz->init_slot = init_slot_; \ - clazz->done_slot = done_slot_; \ - \ - clazz->load_glyph = load_glyph_; \ - \ - clazz->get_kerning = get_kerning_; \ - clazz->attach_file = attach_file_; \ - clazz->get_advances = get_advances_; \ - \ - clazz->request_size = request_size_; \ - clazz->select_size = select_size_; \ - \ - *output_class = (FT_Module_Class*)clazz; \ - \ - return FT_Err_Ok; \ - } - - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/3rdparty/freetype/include/freetype/internal/ftgloadr.h b/src/3rdparty/freetype/include/freetype/internal/ftgloadr.h index a002fdbfca..770871d81b 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftgloadr.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftgloadr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgloadr.h */ -/* */ -/* The FreeType glyph loader (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgloadr.h + * + * The FreeType glyph loader (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGLOADR_H_ @@ -27,15 +27,15 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphLoader */ - /* */ - /* <Description> */ - /* The glyph loader is an internal object used to load several glyphs */ - /* together (for example, in the case of composites). */ - /* */ + /************************************************************************** + * + * @struct: + * FT_GlyphLoader + * + * @description: + * The glyph loader is an internal object used to load several glyphs + * together (for example, in the case of composites). + */ typedef struct FT_SubGlyphRec_ { FT_Int index; @@ -138,11 +138,6 @@ FT_BEGIN_HEADER FT_BASE( void ) FT_GlyphLoader_Add( FT_GlyphLoader loader ); - /* copy points from one glyph loader to another */ - FT_BASE( FT_Error ) - FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, - FT_GlyphLoader source ); - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/fthash.h b/src/3rdparty/freetype/include/freetype/internal/fthash.h index f22f9d5d39..249188040b 100644 --- a/src/3rdparty/freetype/include/freetype/internal/fthash.h +++ b/src/3rdparty/freetype/include/freetype/internal/fthash.h @@ -1,10 +1,10 @@ -/***************************************************************************/ -/* */ -/* fthash.h */ -/* */ -/* Hashing functions (specification). */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fthash.h + * + * Hashing functions (specification). + * + */ /* * Copyright 2000 Computing Research Labs, New Mexico State University @@ -30,13 +30,13 @@ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /*************************************************************************/ - /* */ - /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ - /* */ - /* taken from Mark Leisher's xmbdfed package */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 + * + * taken from Mark Leisher's xmbdfed package + * + */ #ifndef FTHASH_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/ftmemory.h b/src/3rdparty/freetype/include/freetype/internal/ftmemory.h index 054eaec31f..78bd3bc229 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftmemory.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftmemory.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmemory.h */ -/* */ -/* The FreeType memory management macros (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmemory.h + * + * The FreeType memory management macros (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTMEMORY_H_ @@ -28,16 +28,16 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_SET_ERROR */ - /* */ - /* <Description> */ - /* This macro is used to set an implicit `error' variable to a given */ - /* expression's value (usually a function call), and convert it to a */ - /* boolean which is set whenever the value is != 0. */ - /* */ + /************************************************************************** + * + * @macro: + * FT_SET_ERROR + * + * @description: + * This macro is used to set an implicit 'error' variable to a given + * expression's value (usually a function call), and convert it to a + * boolean which is set whenever the value is != 0. + */ #undef FT_SET_ERROR #define FT_SET_ERROR( expression ) \ ( ( error = (expression) ) != 0 ) @@ -58,9 +58,9 @@ FT_BEGIN_HEADER /* - * C++ refuses to handle statements like p = (void*)anything, with `p' a - * typed pointer. Since we don't have a `typeof' operator in standard - * C++, we have to use a template to emulate it. + * C++ refuses to handle statements like p = (void*)anything, with `p' a + * typed pointer. Since we don't have a `typeof' operator in standard C++, + * we have to use a template to emulate it. */ #ifdef __cplusplus @@ -107,8 +107,8 @@ extern "C++" /* - * The allocation functions return a pointer, and the error code - * is written to through the `p_error' parameter. + * The allocation functions return a pointer, and the error code is written + * to through the `p_error' parameter. */ /* The `q' variants of the functions below (`q' for `quick') don't fill */ @@ -253,20 +253,19 @@ extern "C++" /* - * Return the maximum number of addressable elements in an array. - * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid - * any problems. + * Return the maximum number of addressable elements in an array. We limit + * ourselves to INT_MAX, rather than UINT_MAX, to avoid any problems. */ #define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) ) #define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) - /*************************************************************************/ - /* */ - /* The following functions macros expect that their pointer argument is */ - /* _typed_ in order to automatically compute array element sizes. */ - /* */ + /************************************************************************** + * + * The following functions macros expect that their pointer argument is + * _typed_ in order to automatically compute array element sizes. + */ #define FT_MEM_NEW_ARRAY( ptr, count ) \ FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ diff --git a/src/3rdparty/freetype/include/freetype/internal/ftobjs.h b/src/3rdparty/freetype/include/freetype/internal/ftobjs.h index 1c3c6ad456..0c1d3e5bf2 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftobjs.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftobjs.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* ftobjs.h */ -/* */ -/* The FreeType private base classes (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of all internal FreeType classes. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftobjs.h + * + * The FreeType private base classes (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file contains the definition of all internal FreeType classes. + * + */ #ifndef FTOBJS_H_ @@ -35,7 +35,6 @@ #include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_AUTOHINT_H #include FT_INTERNAL_SERVICE_H -#include FT_INTERNAL_PIC_H #include FT_INTERNAL_CALC_H #ifdef FT_CONFIG_OPTION_INCREMENTAL @@ -46,10 +45,10 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* Some generic definitions. */ - /* */ + /************************************************************************** + * + * Some generic definitions. + */ #ifndef TRUE #define TRUE 1 #endif @@ -63,20 +62,20 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /* */ - /* The min and max functions missing in C. As usual, be careful not to */ - /* write things like FT_MIN( a++, b++ ) to avoid side effects. */ - /* */ + /************************************************************************** + * + * The min and max functions missing in C. As usual, be careful not to + * write things like FT_MIN( a++, b++ ) to avoid side effects. + */ #define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) ) #define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) ) #define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) ) /* - * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' - * algorithm. We use alpha = 1, beta = 3/8, giving us results with a - * largest error less than 7% compared to the exact value. + * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' algorithm. + * We use alpha = 1, beta = 3/8, giving us results with a largest error + * less than 7% compared to the exact value. */ #define FT_HYPOT( x, y ) \ ( x = FT_ABS( x ), \ @@ -111,9 +110,8 @@ FT_BEGIN_HEADER /* - * character classification functions -- since these are used to parse - * font files, we must not use those in <ctypes.h> which are - * locale-dependent + * character classification functions -- since these are used to parse font + * files, we must not use those in <ctypes.h> which are locale-dependent */ #define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U ) @@ -187,7 +185,7 @@ FT_BEGIN_HEADER FT_UInt32 char_code, FT_UInt32 variant_selector ); - typedef FT_Bool + typedef FT_Int (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap, FT_UInt32 char_code, FT_UInt32 variant_selector ); @@ -228,8 +226,6 @@ FT_BEGIN_HEADER } FT_CMap_ClassRec; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DECLARE_CMAP_CLASS( class_ ) \ FT_CALLBACK_TABLE const FT_CMap_ClassRec class_; @@ -260,45 +256,6 @@ FT_BEGIN_HEADER variantchar_list_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_CMAP_CLASS( class_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_CMap_ClassRec* clazz ); - -#define FT_DEFINE_CMAP_CLASS( \ - class_, \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_CMap_ClassRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->size = size_; \ - clazz->init = init_; \ - clazz->done = done_; \ - clazz->char_index = char_index_; \ - clazz->char_next = char_next_; \ - clazz->char_var_index = char_var_index_; \ - clazz->char_var_default = char_var_default_; \ - clazz->variant_list = variant_list_; \ - clazz->charvariant_list = charvariant_list_; \ - clazz->variantchar_list = variantchar_list_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* create a new charmap and add it to charmap->face */ FT_BASE( FT_Error ) @@ -312,95 +269,91 @@ FT_BEGIN_HEADER FT_CMap_Done( FT_CMap cmap ); - /* adds LCD padding to Min and Max boundaries */ + /* add LCD padding to CBox */ FT_BASE( void ) - ft_lcd_padding( FT_Pos* Min, - FT_Pos* Max, - FT_GlyphSlot slot ); + ft_lcd_padding( FT_BBox* cbox, + FT_GlyphSlot slot, + FT_Render_Mode mode ); #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap, - FT_Render_Mode render_mode, FT_Byte* weights ); /* This is the default LCD filter, an in-place, 5-tap FIR filter. */ FT_BASE( void ) ft_lcd_filter_fir( FT_Bitmap* bitmap, - FT_Render_Mode mode, FT_LcdFiveTapFilter weights ); #endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Face_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_Face */ - /* object. These fields may change between different releases of */ - /* FreeType. */ - /* */ - /* <Fields> */ - /* max_points :: */ - /* The maximum number of points used to store the vectorial outline */ - /* of any glyph in this face. If this value cannot be known in */ - /* advance, or if the face isn't scalable, this should be set to 0. */ - /* Only relevant for scalable formats. */ - /* */ - /* max_contours :: */ - /* The maximum number of contours used to store the vectorial */ - /* outline of any glyph in this face. If this value cannot be */ - /* known in advance, or if the face isn't scalable, this should be */ - /* set to 0. Only relevant for scalable formats. */ - /* */ - /* transform_matrix :: */ - /* A 2x2 matrix of 16.16 coefficients used to transform glyph */ - /* outlines after they are loaded from the font. Only used by the */ - /* convenience functions. */ - /* */ - /* transform_delta :: */ - /* A translation vector used to transform glyph outlines after they */ - /* are loaded from the font. Only used by the convenience */ - /* functions. */ - /* */ - /* transform_flags :: */ - /* Some flags used to classify the transform. Only used by the */ - /* convenience functions. */ - /* */ - /* services :: */ - /* A cache for frequently used services. It should be only */ - /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */ - /* */ - /* incremental_interface :: */ - /* If non-null, the interface through which glyph data and metrics */ - /* are loaded incrementally for faces that do not provide all of */ - /* this data when first opened. This field exists only if */ - /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ - /* */ - /* no_stem_darkening :: */ - /* Overrides the module-level default, see @stem-darkening[cff], */ - /* for example. FALSE and TRUE toggle stem darkening on and off, */ - /* respectively, value~-1 means to use the module/driver default. */ - /* */ - /* random_seed :: */ - /* If positive, override the seed value for the CFF `random' */ - /* operator. Value~0 means to use the font's value. Value~-1 */ - /* means to use the CFF driver's default. */ - /* */ - /* lcd_weights :: */ - /* lcd_filter_func :: */ - /* If subpixel rendering is activated, the LCD filtering weights */ - /* and callback function. */ - /* */ - /* refcount :: */ - /* A counter initialized to~1 at the time an @FT_Face structure is */ - /* created. @FT_Reference_Face increments this counter, and */ - /* @FT_Done_Face only destroys a face if the counter is~1, */ - /* otherwise it simply decrements it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Face_InternalRec + * + * @description: + * This structure contains the internal fields of each FT_Face object. + * These fields may change between different releases of FreeType. + * + * @fields: + * max_points :: + * The maximum number of points used to store the vectorial outline of + * any glyph in this face. If this value cannot be known in advance, + * or if the face isn't scalable, this should be set to 0. Only + * relevant for scalable formats. + * + * max_contours :: + * The maximum number of contours used to store the vectorial outline + * of any glyph in this face. If this value cannot be known in + * advance, or if the face isn't scalable, this should be set to 0. + * Only relevant for scalable formats. + * + * transform_matrix :: + * A 2x2 matrix of 16.16 coefficients used to transform glyph outlines + * after they are loaded from the font. Only used by the convenience + * functions. + * + * transform_delta :: + * A translation vector used to transform glyph outlines after they are + * loaded from the font. Only used by the convenience functions. + * + * transform_flags :: + * Some flags used to classify the transform. Only used by the + * convenience functions. + * + * services :: + * A cache for frequently used services. It should be only accessed + * with the macro `FT_FACE_LOOKUP_SERVICE`. + * + * incremental_interface :: + * If non-null, the interface through which glyph data and metrics are + * loaded incrementally for faces that do not provide all of this data + * when first opened. This field exists only if + * @FT_CONFIG_OPTION_INCREMENTAL is defined. + * + * no_stem_darkening :: + * Overrides the module-level default, see @stem-darkening[cff], for + * example. FALSE and TRUE toggle stem darkening on and off, + * respectively, value~-1 means to use the module/driver default. + * + * random_seed :: + * If positive, override the seed value for the CFF 'random' operator. + * Value~0 means to use the font's value. Value~-1 means to use the + * CFF driver's default. + * + * lcd_weights :: + * lcd_filter_func :: + * These fields specify the LCD filtering weights and callback function + * for ClearType-style subpixel rendering. + * + * refcount :: + * A counter initialized to~1 at the time an @FT_Face structure is + * created. @FT_Reference_Face increments this counter, and + * @FT_Done_Face only destroys a face if the counter is~1, otherwise it + * simply decrements it. + */ typedef struct FT_Face_InternalRec_ { FT_Matrix transform_matrix; @@ -426,39 +379,44 @@ FT_BEGIN_HEADER } FT_Face_InternalRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Slot_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_GlyphSlot */ - /* object. These fields may change between different releases of */ - /* FreeType. */ - /* */ - /* <Fields> */ - /* loader :: The glyph loader object used to load outlines */ - /* into the glyph slot. */ - /* */ - /* flags :: Possible values are zero or */ - /* FT_GLYPH_OWN_BITMAP. The latter indicates */ - /* that the FT_GlyphSlot structure owns the */ - /* bitmap buffer. */ - /* */ - /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */ - /* must be transformed through a specific */ - /* font transformation. This is _not_ the same */ - /* as the face transform set through */ - /* FT_Set_Transform(). */ - /* */ - /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */ - /* transformation, if necessary. */ - /* */ - /* glyph_delta :: The 2d translation vector corresponding to */ - /* the glyph transformation, if necessary. */ - /* */ - /* glyph_hints :: Format-specific glyph hints management. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_Slot_InternalRec + * + * @description: + * This structure contains the internal fields of each FT_GlyphSlot + * object. These fields may change between different releases of + * FreeType. + * + * @fields: + * loader :: + * The glyph loader object used to load outlines into the glyph slot. + * + * flags :: + * Possible values are zero or FT_GLYPH_OWN_BITMAP. The latter + * indicates that the FT_GlyphSlot structure owns the bitmap buffer. + * + * glyph_transformed :: + * Boolean. Set to TRUE when the loaded glyph must be transformed + * through a specific font transformation. This is _not_ the same as + * the face transform set through FT_Set_Transform(). + * + * glyph_matrix :: + * The 2x2 matrix corresponding to the glyph transformation, if + * necessary. + * + * glyph_delta :: + * The 2d translation vector corresponding to the glyph transformation, + * if necessary. + * + * glyph_hints :: + * Format-specific glyph hints management. + * + * load_flags :: + * The load flags passed as an argument to @FT_Load_Glyph while + * initializing the glyph slot. + */ #define FT_GLYPH_OWN_BITMAP 0x1U @@ -471,26 +429,30 @@ FT_BEGIN_HEADER FT_Vector glyph_delta; void* glyph_hints; + FT_Int32 load_flags; + } FT_GlyphSlot_InternalRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_Size */ - /* object. */ - /* */ - /* <Fields> */ - /* module_data :: Data specific to a driver module. */ - /* */ - /* autohint_mode :: The used auto-hinting mode. */ - /* */ - /* autohint_metrics :: Metrics used by the auto-hinter. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @struct: + * FT_Size_InternalRec + * + * @description: + * This structure contains the internal fields of each FT_Size object. + * + * @fields: + * module_data :: + * Data specific to a driver module. + * + * autohint_mode :: + * The used auto-hinting mode. + * + * autohint_metrics :: + * Metrics used by the auto-hinter. + * + */ typedef struct FT_Size_InternalRec_ { @@ -515,21 +477,24 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ModuleRec */ - /* */ - /* <Description> */ - /* A module object instance. */ - /* */ - /* <Fields> */ - /* clazz :: A pointer to the module's class. */ - /* */ - /* library :: A handle to the parent library object. */ - /* */ - /* memory :: A handle to the memory manager. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_ModuleRec + * + * @description: + * A module object instance. + * + * @fields: + * clazz :: + * A pointer to the module's class. + * + * library :: + * A handle to the parent library object. + * + * memory :: + * A handle to the memory manager. + */ typedef struct FT_ModuleRec_ { FT_Module_Class* clazz; @@ -572,27 +537,29 @@ FT_BEGIN_HEADER FT_MODULE_DRIVER_HINTS_LIGHTLY ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module_Interface */ - /* */ - /* <Description> */ - /* Finds a module and returns its specific interface as a typeless */ - /* pointer. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module-specific interface if available, 0 otherwise. */ - /* */ - /* <Note> */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for, and what its interface is :-) */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Module_Interface + * + * @description: + * Finds a module and returns its specific interface as a typeless + * pointer. + * + * @input: + * library :: + * A handle to the library object. + * + * module_name :: + * The module's name (as an ASCII string). + * + * @return: + * A module-specific interface if available, 0 otherwise. + * + * @note: + * You should better be familiar with FreeType internals to know which + * module to look for, and what its interface is :-) + */ FT_BASE( const void* ) FT_Get_Module_Interface( FT_Library library, const char* mod_name ); @@ -643,44 +610,46 @@ FT_BEGIN_HEADER #define FT_FACE_SIZE( x ) FT_FACE( x )->size - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_GlyphSlot */ - /* */ - /* <Description> */ - /* It is sometimes useful to have more than one glyph slot for a */ - /* given face object. This function is used to create additional */ - /* slots. All of them are automatically discarded when the face is */ - /* destroyed. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* aslot :: A handle to a new glyph slot object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_GlyphSlot + * + * @description: + * It is sometimes useful to have more than one glyph slot for a given + * face object. This function is used to create additional slots. All + * of them are automatically discarded when the face is destroyed. + * + * @input: + * face :: + * A handle to a parent face object. + * + * @output: + * aslot :: + * A handle to a new glyph slot object. + * + * @return: + * FreeType error code. 0 means success. + */ FT_BASE( FT_Error ) FT_New_GlyphSlot( FT_Face face, FT_GlyphSlot *aslot ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_GlyphSlot */ - /* */ - /* <Description> */ - /* Destroys a given glyph slot. Remember however that all slots are */ - /* automatically destroyed with its parent. Using this function is */ - /* not always mandatory. */ - /* */ - /* <Input> */ - /* slot :: A handle to a target glyph slot. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_GlyphSlot + * + * @description: + * Destroys a given glyph slot. Remember however that all slots are + * automatically destroyed with its parent. Using this function is not + * always mandatory. + * + * @input: + * slot :: + * A handle to a target glyph slot. + */ FT_BASE( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot ); @@ -730,8 +699,9 @@ FT_BEGIN_HEADER ft_glyphslot_free_bitmap( FT_GlyphSlot slot ); - /* Preset bitmap metrics of an outline glyphslot prior to rendering. */ - FT_BASE( void ) + /* Preset bitmap metrics of an outline glyphslot prior to rendering */ + /* and check whether the truncated bbox is too large for rendering. */ + FT_BASE( FT_Bool ) ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ); @@ -802,28 +772,30 @@ FT_BEGIN_HEADER #define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_DriverRec */ - /* */ - /* <Description> */ - /* The root font driver class. A font driver is responsible for */ - /* managing and loading font files of a given format. */ - /* */ - /* <Fields> */ - /* root :: Contains the fields of the root module class. */ - /* */ - /* clazz :: A pointer to the font driver's class. Note that */ - /* this is NOT root.clazz. `class' wasn't used */ - /* as it is a reserved word in C++. */ - /* */ - /* faces_list :: The list of faces currently opened by this */ - /* driver. */ - /* */ - /* glyph_loader :: Unused. Used to be glyph loader for all faces */ - /* managed by this driver. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_DriverRec + * + * @description: + * The root font driver class. A font driver is responsible for managing + * and loading font files of a given format. + * + * @fields: + * root :: + * Contains the fields of the root module class. + * + * clazz :: + * A pointer to the font driver's class. Note that this is NOT + * root.clazz. 'class' wasn't used as it is a reserved word in C++. + * + * faces_list :: + * The list of faces currently opened by this driver. + * + * glyph_loader :: + * Unused. Used to be glyph loader for all faces managed by this + * driver. + */ typedef struct FT_DriverRec_ { FT_ModuleRec root; @@ -847,72 +819,77 @@ FT_BEGIN_HEADER /*************************************************************************/ - /* This hook is used by the TrueType debugger. It must be set to an */ - /* alternate truetype bytecode interpreter function. */ -#define FT_DEBUG_HOOK_TRUETYPE 0 - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_LibraryRec */ - /* */ - /* <Description> */ - /* The FreeType library class. This is the root of all FreeType */ - /* data. Use FT_New_Library() to create a library object, and */ - /* FT_Done_Library() to discard it and all child objects. */ - /* */ - /* <Fields> */ - /* memory :: The library's memory object. Manages memory */ - /* allocation. */ - /* */ - /* version_major :: The major version number of the library. */ - /* */ - /* version_minor :: The minor version number of the library. */ - /* */ - /* version_patch :: The current patch level of the library. */ - /* */ - /* num_modules :: The number of modules currently registered */ - /* within this library. This is set to 0 for new */ - /* libraries. New modules are added through the */ - /* FT_Add_Module() API function. */ - /* */ - /* modules :: A table used to store handles to the currently */ - /* registered modules. Note that each font driver */ - /* contains a list of its opened faces. */ - /* */ - /* renderers :: The list of renderers currently registered */ - /* within the library. */ - /* */ - /* cur_renderer :: The current outline renderer. This is a */ - /* shortcut used to avoid parsing the list on */ - /* each call to FT_Outline_Render(). It is a */ - /* handle to the current renderer for the */ - /* FT_GLYPH_FORMAT_OUTLINE format. */ - /* */ - /* auto_hinter :: The auto-hinter module interface. */ - /* */ - /* debug_hooks :: An array of four function pointers that allow */ - /* debuggers to hook into a font format's */ - /* interpreter. Currently, only the TrueType */ - /* bytecode debugger uses this. */ - /* */ - /* lcd_weights :: If subpixel rendering is activated, the LCD */ - /* filter weights, if any. */ - /* */ - /* lcd_filter_func :: If subpixel rendering is activated, the LCD */ - /* filtering callback function. */ - /* */ - /* pic_container :: Contains global structs and tables, instead */ - /* of defining them globally. */ - /* */ - /* refcount :: A counter initialized to~1 at the time an */ - /* @FT_Library structure is created. */ - /* @FT_Reference_Library increments this counter, */ - /* and @FT_Done_Library only destroys a library */ - /* if the counter is~1, otherwise it simply */ - /* decrements it. */ - /* */ + /************************************************************************** + * + * @struct: + * FT_LibraryRec + * + * @description: + * The FreeType library class. This is the root of all FreeType data. + * Use FT_New_Library() to create a library object, and FT_Done_Library() + * to discard it and all child objects. + * + * @fields: + * memory :: + * The library's memory object. Manages memory allocation. + * + * version_major :: + * The major version number of the library. + * + * version_minor :: + * The minor version number of the library. + * + * version_patch :: + * The current patch level of the library. + * + * num_modules :: + * The number of modules currently registered within this library. + * This is set to 0 for new libraries. New modules are added through + * the FT_Add_Module() API function. + * + * modules :: + * A table used to store handles to the currently registered + * modules. Note that each font driver contains a list of its opened + * faces. + * + * renderers :: + * The list of renderers currently registered within the library. + * + * cur_renderer :: + * The current outline renderer. This is a shortcut used to avoid + * parsing the list on each call to FT_Outline_Render(). It is a + * handle to the current renderer for the FT_GLYPH_FORMAT_OUTLINE + * format. + * + * auto_hinter :: + * The auto-hinter module interface. + * + * debug_hooks :: + * An array of four function pointers that allow debuggers to hook into + * a font format's interpreter. Currently, only the TrueType bytecode + * debugger uses this. + * + * lcd_weights :: + * The LCD filter weights for ClearType-style subpixel rendering. + * + * lcd_filter_func :: + * The LCD filtering callback function for for ClearType-style subpixel + * rendering. + * + * lcd_geometry :: + * This array specifies LCD subpixel geometry and controls Harmony LCD + * rendering technique, alternative to ClearType. + * + * pic_container :: + * Contains global structs and tables, instead of defining them + * globally. + * + * refcount :: + * A counter initialized to~1 at the time an @FT_Library structure is + * created. @FT_Reference_Library increments this counter, and + * @FT_Done_Library only destroys a library if the counter is~1, + * otherwise it simply decrements it. + */ typedef struct FT_LibraryRec_ { FT_Memory memory; /* library's memory manager */ @@ -933,10 +910,8 @@ FT_BEGIN_HEADER #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ -#endif - -#ifdef FT_CONFIG_OPTION_PIC - FT_PIC_Container pic_container; +#else + FT_Vector lcd_geometry[3]; /* RGB subpixel positions */ #endif FT_Int refcount; @@ -964,38 +939,39 @@ FT_BEGIN_HEADER FT_UInt buffer_max ); typedef FT_UInt - (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face, - FT_String* glyph_name ); + (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face, + const FT_String* glyph_name ); #ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory */ - /* */ - /* <Description> */ - /* Creates a new memory object. */ - /* */ - /* <Return> */ - /* A pointer to the new memory object. 0 in case of error. */ - /* */ + /************************************************************************** + * + * @function: + * FT_New_Memory + * + * @description: + * Creates a new memory object. + * + * @return: + * A pointer to the new memory object. 0 in case of error. + */ FT_BASE( FT_Memory ) FT_New_Memory( void ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Memory */ - /* */ - /* <Description> */ - /* Discards memory manager. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Done_Memory + * + * @description: + * Discards memory manager. + * + * @input: + * memory :: + * A handle to the memory manager. + */ FT_BASE( void ) FT_Done_Memory( FT_Memory memory ); @@ -1013,37 +989,16 @@ FT_BEGIN_HEADER #endif - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** P I C S U P P O R T ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* PIC support macros for ftimage.h */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_OUTLINE_FUNCS */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Outline_Funcs struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ - /* to be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DEFINE_OUTLINE_FUNCS + * + * @description: + * Used to initialize an instance of FT_Outline_Funcs struct. The struct + * will be allocated in the global scope (or the scope where the macro is + * used). + */ #define FT_DEFINE_OUTLINE_FUNCS( \ class_, \ move_to_, \ @@ -1062,47 +1017,17 @@ FT_BEGIN_HEADER delta_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_OUTLINE_FUNCS( \ - class_, \ - move_to_, \ - line_to_, \ - conic_to_, \ - cubic_to_, \ - shift_, \ - delta_ ) \ - static FT_Error \ - Init_Class_ ## class_( FT_Outline_Funcs* clazz ) \ - { \ - clazz->move_to = move_to_; \ - clazz->line_to = line_to_; \ - clazz->conic_to = conic_to_; \ - clazz->cubic_to = cubic_to_; \ - clazz->shift = shift_; \ - clazz->delta = delta_; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_RASTER_FUNCS */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Raster_Funcs struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ - /* to be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC + /************************************************************************** + * + * @macro: + * FT_DEFINE_RASTER_FUNCS + * + * @description: + * Used to initialize an instance of FT_Raster_Funcs struct. The struct + * will be allocated in the global scope (or the scope where the macro is + * used). + */ #define FT_DEFINE_RASTER_FUNCS( \ class_, \ glyph_format_, \ @@ -1121,48 +1046,17 @@ FT_BEGIN_HEADER raster_done_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_RASTER_FUNCS( \ - class_, \ - glyph_format_, \ - raster_new_, \ - raster_reset_, \ - raster_set_mode_, \ - raster_render_, \ - raster_done_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Raster_Funcs* clazz ) \ - { \ - clazz->glyph_format = glyph_format_; \ - clazz->raster_new = raster_new_; \ - clazz->raster_reset = raster_reset_; \ - clazz->raster_set_mode = raster_set_mode_; \ - clazz->raster_render = raster_render_; \ - clazz->raster_done = raster_done_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* PIC support macros for ftrender.h */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_GLYPH */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Glyph_Class struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init function will need */ - /* to be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DEFINE_GLYPH + * + * @description: + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DEFINE_GLYPH( \ class_, \ size_, \ @@ -1186,73 +1080,25 @@ FT_BEGIN_HEADER prepare_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_GLYPH( \ - class_, \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Glyph_Class* clazz ) \ - { \ - clazz->glyph_size = size_; \ - clazz->glyph_format = format_; \ - clazz->glyph_init = init_; \ - clazz->glyph_done = done_; \ - clazz->glyph_copy = copy_; \ - clazz->glyph_transform = transform_; \ - clazz->glyph_bbox = bbox_; \ - clazz->glyph_prepare = prepare_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_RENDERER */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of a */ - /* FT_Renderer_Class struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_RENDERER */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Renderer_Class struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function will */ - /* need to be called with a pointer where the allocated structure is */ - /* returned. And when it is no longer needed a `destroy' function */ - /* needs to be called to release that allocation. */ - /* `ftinit.c' (ft_create_default_module_classes) already contains */ - /* a mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by the renderer definition calling `FT_DEFINE_RENDERER' in the */ - /* following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC + /************************************************************************** + * + * @macro: + * FT_DECLARE_RENDERER + * + * @description: + * Used to create a forward declaration of a FT_Renderer_Class struct + * instance. + * + * @macro: + * FT_DEFINE_RENDERER + * + * @description: + * Used to initialize an instance of FT_Renderer_Class struct. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DECLARE_RENDERER( class_ ) \ FT_EXPORT_VAR( const FT_Renderer_Class ) class_; @@ -1295,176 +1141,33 @@ FT_BEGIN_HEADER raster_class_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_RENDERER( class_ ) FT_DECLARE_MODULE( class_ ) - -#define FT_DEFINE_RENDERER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - glyph_format_, \ - render_glyph_, \ - transform_glyph_, \ - get_glyph_cbox_, \ - set_mode_, \ - raster_class_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \ - FT_Memory memory = library->memory; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( rclazz ) \ - FT_FREE( rclazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Renderer_Class* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - clazz->glyph_format = glyph_format_; \ - \ - clazz->render_glyph = render_glyph_; \ - clazz->transform_glyph = transform_glyph_; \ - clazz->get_glyph_cbox = get_glyph_cbox_; \ - clazz->set_mode = set_mode_; \ - \ - clazz->raster_class = raster_class_; \ - \ - *output_class = (FT_Module_Class*)clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /* PIC support macros for ftmodapi.h **/ - - -#ifdef FT_CONFIG_OPTION_PIC - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Creator */ - /* */ - /* <Description> */ - /* A function used to create (allocate) a new module class object. */ - /* The object's members are initialized, but the module itself is */ - /* not. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* output_class :: Initialized with the newly allocated class. */ - /* */ - typedef FT_Error - (*FT_Module_Creator)( FT_Memory memory, - FT_Module_Class** output_class ); - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destroyer */ - /* */ - /* <Description> */ - /* A function used to destroy (deallocate) a module class object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* clazz :: Module class to destroy. */ - /* */ - typedef void - (*FT_Module_Destroyer)( FT_Memory memory, - FT_Module_Class* clazz ); - -#endif - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_MODULE */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of a */ - /* FT_Module_Class struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_MODULE */ - /* */ - /* <Description> */ - /* Used to initialize an instance of an FT_Module_Class struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs */ - /* to be called with a pointer where the allocated structure is */ - /* returned. And when it is no longer needed a `destroy' function */ - /* needs to be called to release that allocation. */ - /* `ftinit.c' (ft_create_default_module_classes) already contains */ - /* a mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by the module definition calling `FT_DEFINE_MODULE' in the */ - /* following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ - /* <Macro> */ - /* FT_DEFINE_ROOT_MODULE */ - /* */ - /* <Description> */ - /* Used to initialize an instance of an FT_Module_Class struct inside */ - /* another struct that contains it or in a function that initializes */ - /* that containing struct. */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC + /************************************************************************** + * + * @macro: + * FT_DECLARE_MODULE + * + * @description: + * Used to create a forward declaration of a FT_Module_Class struct + * instance. + * + * @macro: + * FT_DEFINE_MODULE + * + * @description: + * Used to initialize an instance of an FT_Module_Class struct. + * + * The struct will be allocated in the global scope (or the scope where + * the macro is used). + * + * @macro: + * FT_DEFINE_ROOT_MODULE + * + * @description: + * Used to initialize an instance of an FT_Module_Class struct inside + * another struct that contains it or in a function that initializes that + * containing struct. + */ #define FT_DECLARE_MODULE( class_ ) \ FT_CALLBACK_TABLE \ const FT_Module_Class class_; @@ -1523,100 +1226,6 @@ FT_BEGIN_HEADER }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_MODULE( class_ ) \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ); \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ); - -#define FT_DEFINE_ROOT_MODULE( \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - clazz->root.module_flags = flags_; \ - clazz->root.module_size = size_; \ - clazz->root.module_name = name_; \ - clazz->root.module_version = version_; \ - clazz->root.module_requires = requires_; \ - \ - clazz->root.module_interface = interface_; \ - \ - clazz->root.module_init = init_; \ - clazz->root.module_done = done_; \ - clazz->root.get_interface = get_interface_; - -#define FT_DEFINE_MODULE( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Memory memory = library->memory; \ - FT_Module_Class* clazz = NULL; \ - FT_Error error; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - clazz->module_flags = flags_; \ - clazz->module_size = size_; \ - clazz->module_name = name_; \ - clazz->module_version = version_; \ - clazz->module_requires = requires_; \ - \ - clazz->module_interface = interface_; \ - \ - clazz->module_init = init_; \ - clazz->module_done = done_; \ - clazz->get_interface = get_interface_; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - FT_END_HEADER #endif /* FTOBJS_H_ */ diff --git a/src/3rdparty/freetype/include/freetype/internal/ftpsprop.h b/src/3rdparty/freetype/include/freetype/internal/ftpsprop.h index abbb62862b..574837f6d4 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftpsprop.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftpsprop.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftpsprop.h */ -/* */ -/* Get and set properties of PostScript drivers (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpsprop.h + * + * Get and set properties of PostScript drivers (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTPSPROP_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/ftrfork.h b/src/3rdparty/freetype/include/freetype/internal/ftrfork.h index 1aca48a0e7..75b3e531bb 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftrfork.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftrfork.h @@ -1,24 +1,24 @@ -/***************************************************************************/ -/* */ -/* ftrfork.h */ -/* */ -/* Embedded resource forks accessor (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* Development of the code in this file is support of */ -/* Information-technology Promotion Agency, Japan. */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrfork.h + * + * Embedded resource forks accessor (specification). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO and Redhat K.K. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * Development of the code in this file is support of + * Information-technology Promotion Agency, Japan. + */ #ifndef FTRFORK_H_ @@ -72,85 +72,65 @@ FT_BEGIN_HEADER } FT_RFork_Rule; /* For fast translation between rule index and rule type, - * the macros FT_RFORK_xxx should be kept consistent with - * the raccess_guess_funcs table + * the macros FT_RFORK_xxx should be kept consistent with the + * raccess_guess_funcs table */ typedef struct ft_raccess_guess_rec_ { ft_raccess_guess_func func; FT_RFork_Rule type; } ft_raccess_guess_rec; -#ifndef FT_CONFIG_OPTION_PIC - /* this array is a storage in non-PIC mode, so ; is needed in END */ #define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ static const type name[] = { #define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ { raccess_guess_ ## func_suffix, \ FT_RFork_Rule_ ## type_suffix }, + /* this array is a storage, thus a final `;' is needed */ #define CONST_FT_RFORK_RULE_ARRAY_END }; -#else /* FT_CONFIG_OPTION_PIC */ - - /* this array is a function in PIC mode, so no ; is needed in END */ -#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ - void \ - FT_Init_Table_ ## name( type* storage ) \ - { \ - type* local = storage; \ - \ - \ - int i = 0; -#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ - local[i].func = raccess_guess_ ## func_suffix; \ - local[i].type = FT_RFork_Rule_ ## type_suffix; \ - i++; -#define CONST_FT_RFORK_RULE_ARRAY_END } - -#endif /* FT_CONFIG_OPTION_PIC */ - #endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Guess */ - /* */ - /* <Description> */ - /* Guess a file name and offset where the actual resource fork is */ - /* stored. The macro FT_RACCESS_N_RULES holds the number of */ - /* guessing rules; the guessed result for the Nth rule is */ - /* represented as a triplet: a new file name (new_names[N]), a file */ - /* offset (offsets[N]), and an error code (errors[N]). */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* base_name :: */ - /* The (base) file name of the resource fork used for some */ - /* guessing rules. */ - /* */ - /* <Output> */ - /* new_names :: */ - /* An array of guessed file names in which the resource forks may */ - /* exist. If `new_names[N]' is NULL, the guessed file name is */ - /* equal to `base_name'. */ - /* */ - /* offsets :: */ - /* An array of guessed file offsets. `offsets[N]' holds the file */ - /* offset of the possible start of the resource fork in file */ - /* `new_names[N]'. */ - /* */ - /* errors :: */ - /* An array of FreeType error codes. `errors[N]' is the error */ - /* code of Nth guessing rule function. If `errors[N]' is not */ - /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Raccess_Guess + * + * @description: + * Guess a file name and offset where the actual resource fork is stored. + * The macro FT_RACCESS_N_RULES holds the number of guessing rules; the + * guessed result for the Nth rule is represented as a triplet: a new + * file name (new_names[N]), a file offset (offsets[N]), and an error + * code (errors[N]). + * + * @input: + * library :: + * A FreeType library instance. + * + * stream :: + * A file stream containing the resource fork. + * + * base_name :: + * The (base) file name of the resource fork used for some guessing + * rules. + * + * @output: + * new_names :: + * An array of guessed file names in which the resource forks may + * exist. If 'new_names[N]' is `NULL`, the guessed file name is equal + * to `base_name`. + * + * offsets :: + * An array of guessed file offsets. 'offsets[N]' holds the file + * offset of the possible start of the resource fork in file + * 'new_names[N]'. + * + * errors :: + * An array of FreeType error codes. 'errors[N]' is the error code of + * Nth guessing rule function. If 'errors[N]' is not FT_Err_Ok, + * 'new_names[N]' and 'offsets[N]' are meaningless. + */ FT_BASE( void ) FT_Raccess_Guess( FT_Library library, FT_Stream stream, @@ -160,37 +140,37 @@ FT_BEGIN_HEADER FT_Error* errors ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Get_HeaderInfo */ - /* */ - /* <Description> */ - /* Get the information from the header of resource fork. The */ - /* information includes the file offset where the resource map */ - /* starts, and the file offset where the resource data starts. */ - /* `FT_Raccess_Get_DataOffsets' requires these two data. */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* rfork_offset :: */ - /* The file offset where the resource fork starts. */ - /* */ - /* <Output> */ - /* map_offset :: */ - /* The file offset where the resource map starts. */ - /* */ - /* rdata_pos :: */ - /* The file offset where the resource data starts. */ - /* */ - /* <Return> */ - /* FreeType error code. FT_Err_Ok means success. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Raccess_Get_HeaderInfo + * + * @description: + * Get the information from the header of resource fork. The information + * includes the file offset where the resource map starts, and the file + * offset where the resource data starts. `FT_Raccess_Get_DataOffsets` + * requires these two data. + * + * @input: + * library :: + * A FreeType library instance. + * + * stream :: + * A file stream containing the resource fork. + * + * rfork_offset :: + * The file offset where the resource fork starts. + * + * @output: + * map_offset :: + * The file offset where the resource map starts. + * + * rdata_pos :: + * The file offset where the resource data starts. + * + * @return: + * FreeType error code. FT_Err_Ok means success. + */ FT_BASE( FT_Error ) FT_Raccess_Get_HeaderInfo( FT_Library library, FT_Stream stream, @@ -199,55 +179,54 @@ FT_BEGIN_HEADER FT_Long *rdata_pos ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Get_DataOffsets */ - /* */ - /* <Description> */ - /* Get the data offsets for a tag in a resource fork. Offsets are */ - /* stored in an array because, in some cases, resources in a resource */ - /* fork have the same tag. */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* map_offset :: */ - /* The file offset where the resource map starts. */ - /* */ - /* rdata_pos :: */ - /* The file offset where the resource data starts. */ - /* */ - /* tag :: */ - /* The resource tag. */ - /* */ - /* sort_by_res_id :: */ - /* A Boolean to sort the fragmented resource by their ids. */ - /* The fragmented resources for `POST' resource should be sorted */ - /* to restore Type1 font properly. For `sfnt' resources, sorting */ - /* may induce a different order of the faces in comparison to that */ - /* by QuickDraw API. */ - /* */ - /* <Output> */ - /* offsets :: */ - /* The stream offsets for the resource data specified by `tag'. */ - /* This array is allocated by the function, so you have to call */ - /* @ft_mem_free after use. */ - /* */ - /* count :: */ - /* The length of offsets array. */ - /* */ - /* <Return> */ - /* FreeType error code. FT_Err_Ok means success. */ - /* */ - /* <Note> */ - /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */ - /* value for `map_offset' and `rdata_pos'. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Raccess_Get_DataOffsets + * + * @description: + * Get the data offsets for a tag in a resource fork. Offsets are stored + * in an array because, in some cases, resources in a resource fork have + * the same tag. + * + * @input: + * library :: + * A FreeType library instance. + * + * stream :: + * A file stream containing the resource fork. + * + * map_offset :: + * The file offset where the resource map starts. + * + * rdata_pos :: + * The file offset where the resource data starts. + * + * tag :: + * The resource tag. + * + * sort_by_res_id :: + * A Boolean to sort the fragmented resource by their ids. The + * fragmented resources for 'POST' resource should be sorted to restore + * Type1 font properly. For 'sfnt' resources, sorting may induce a + * different order of the faces in comparison to that by QuickDraw API. + * + * @output: + * offsets :: + * The stream offsets for the resource data specified by 'tag'. This + * array is allocated by the function, so you have to call @ft_mem_free + * after use. + * + * count :: + * The length of offsets array. + * + * @return: + * FreeType error code. FT_Err_Ok means success. + * + * @note: + * Normally you should use `FT_Raccess_Get_HeaderInfo` to get the value + * for `map_offset` and `rdata_pos`. + */ FT_BASE( FT_Error ) FT_Raccess_Get_DataOffsets( FT_Library library, FT_Stream stream, diff --git a/src/3rdparty/freetype/include/freetype/internal/ftserv.h b/src/3rdparty/freetype/include/freetype/internal/ftserv.h index e01c1679b5..8836cf3f18 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftserv.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftserv.h @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* ftserv.h */ -/* */ -/* The FreeType services (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Each module can export one or more `services'. Each service is */ - /* identified by a constant string and modeled by a pointer; the latter */ - /* generally corresponds to a structure containing function pointers. */ - /* */ - /* Note that a service's data cannot be a mere function pointer because */ - /* in C it is possible that function pointers might be implemented */ - /* differently than data pointers (e.g. 48 bits instead of 32). */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftserv.h + * + * The FreeType services (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Each module can export one or more 'services'. Each service is + * identified by a constant string and modeled by a pointer; the latter + * generally corresponds to a structure containing function pointers. + * + * Note that a service's data cannot be a mere function pointer because in + * C it is possible that function pointers might be implemented differently + * than data pointers (e.g. 48 bits instead of 32). + * + */ #ifndef FTSERV_H_ @@ -34,7 +34,8 @@ FT_BEGIN_HEADER - /* + /************************************************************************** + * * @macro: * FT_FACE_FIND_SERVICE * @@ -46,15 +47,15 @@ FT_BEGIN_HEADER * The source face handle. * * id :: - * A string describing the service as defined in the service's - * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It is automatically prefixed with - * `FT_SERVICE_ID_'. + * A string describing the service as defined in the service's header + * files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to + * 'multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_`. * * @output: * ptr :: - * A variable that receives the service pointer. Will be NULL - * if not found. + * A variable that receives the service pointer. Will be `NULL` if not + * found. */ #ifdef __cplusplus @@ -85,7 +86,8 @@ FT_BEGIN_HEADER #endif /* !C++ */ - /* + /************************************************************************** + * * @macro: * FT_FACE_FIND_GLOBAL_SERVICE * @@ -97,15 +99,15 @@ FT_BEGIN_HEADER * The source face handle. * * id :: - * A string describing the service as defined in the service's - * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It is automatically prefixed with - * `FT_SERVICE_ID_'. + * A string describing the service as defined in the service's header + * files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to + * 'multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_`. * * @output: * ptr :: - * A variable that receives the service pointer. Will be NULL - * if not found. + * A variable that receives the service pointer. Will be `NULL` if not + * found. */ #ifdef __cplusplus @@ -144,8 +146,8 @@ FT_BEGIN_HEADER /*************************************************************************/ /* - * The following structure is used to _describe_ a given service - * to the library. This is useful to build simple static service lists. + * The following structure is used to _describe_ a given service to the + * library. This is useful to build simple static service lists. */ typedef struct FT_ServiceDescRec_ { @@ -157,35 +159,26 @@ FT_BEGIN_HEADER typedef const FT_ServiceDescRec* FT_ServiceDesc; - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_SERVICEDESCREC1 */ - /* FT_DEFINE_SERVICEDESCREC2 */ - /* FT_DEFINE_SERVICEDESCREC3 */ - /* FT_DEFINE_SERVICEDESCREC4 */ - /* FT_DEFINE_SERVICEDESCREC5 */ - /* FT_DEFINE_SERVICEDESCREC6 */ - /* FT_DEFINE_SERVICEDESCREC7 */ - /* FT_DEFINE_SERVICEDESCREC8 */ - /* */ - /* <Description> */ - /* Used to initialize an array of FT_ServiceDescRec structures. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs to */ - /* be called with a pointer to return an allocated array. As soon as */ - /* it is no longer needed, a `destroy' function needs to be called to */ - /* release that allocation. */ - /* */ - /* These functions should be manually called from the `pic_init' and */ - /* `pic_free' functions of your module (see FT_DEFINE_MODULE). */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the array will be */ - /* allocated in the global scope (or the scope where the macro is */ - /* used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - + /************************************************************************** + * + * @macro: + * FT_DEFINE_SERVICEDESCREC1 + * FT_DEFINE_SERVICEDESCREC2 + * FT_DEFINE_SERVICEDESCREC3 + * FT_DEFINE_SERVICEDESCREC4 + * FT_DEFINE_SERVICEDESCREC5 + * FT_DEFINE_SERVICEDESCREC6 + * FT_DEFINE_SERVICEDESCREC7 + * FT_DEFINE_SERVICEDESCREC8 + * FT_DEFINE_SERVICEDESCREC9 + * FT_DEFINE_SERVICEDESCREC10 + * + * @description: + * Used to initialize an array of FT_ServiceDescRec structures. + * + * The array will be allocated in the global scope (or the scope where + * the macro is used). + */ #define FT_DEFINE_SERVICEDESCREC1( class_, \ serv_id_1, serv_data_1 ) \ static const FT_ServiceDescRec class_[] = \ @@ -356,504 +349,15 @@ FT_BEGIN_HEADER { NULL, NULL } \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICEDESCREC1( class_, \ - serv_id_1, serv_data_1 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 2 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = NULL; \ - clazz[1].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC2( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 3 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = NULL; \ - clazz[2].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC3( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 4 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = NULL; \ - clazz[3].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC4( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 5 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = NULL; \ - clazz[4].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC5( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 6 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = NULL; \ - clazz[5].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC6( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 7 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = NULL; \ - clazz[6].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC7( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 8 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = NULL; \ - clazz[7].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC8( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7, \ - serv_id_8, serv_data_8 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 9 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = serv_id_8; \ - clazz[7].serv_data = serv_data_8; \ - clazz[8].serv_id = NULL; \ - clazz[8].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC9( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7, \ - serv_id_8, serv_data_8, \ - serv_id_9, serv_data_9 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 10 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = serv_id_8; \ - clazz[7].serv_data = serv_data_8; \ - clazz[8].serv_id = serv_id_9; \ - clazz[8].serv_data = serv_data_9; \ - clazz[9].serv_id = NULL; \ - clazz[9].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC10( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7, \ - serv_id_8, serv_data_8, \ - serv_id_9, serv_data_9, \ - serv_id_10, serv_data_10 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 11 ) ) \ - return error; \ - \ - clazz[ 0].serv_id = serv_id_1; \ - clazz[ 0].serv_data = serv_data_1; \ - clazz[ 1].serv_id = serv_id_2; \ - clazz[ 1].serv_data = serv_data_2; \ - clazz[ 2].serv_id = serv_id_3; \ - clazz[ 2].serv_data = serv_data_3; \ - clazz[ 3].serv_id = serv_id_4; \ - clazz[ 3].serv_data = serv_data_4; \ - clazz[ 4].serv_id = serv_id_5; \ - clazz[ 4].serv_data = serv_data_5; \ - clazz[ 5].serv_id = serv_id_6; \ - clazz[ 5].serv_data = serv_data_6; \ - clazz[ 6].serv_id = serv_id_7; \ - clazz[ 6].serv_data = serv_data_7; \ - clazz[ 7].serv_id = serv_id_8; \ - clazz[ 7].serv_data = serv_data_8; \ - clazz[ 8].serv_id = serv_id_9; \ - clazz[ 8].serv_data = serv_data_9; \ - clazz[ 9].serv_id = serv_id_10; \ - clazz[ 9].serv_data = serv_data_10; \ - clazz[10].serv_id = NULL; \ - clazz[10].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* - * Parse a list of FT_ServiceDescRec descriptors and look for - * a specific service by ID. Note that the last element in the - * array must be { NULL, NULL }, and that the function should - * return NULL if the service isn't available. + * Parse a list of FT_ServiceDescRec descriptors and look for a specific + * service by ID. Note that the last element in the array must be { NULL, + * NULL }, and that the function should return NULL if the service isn't + * available. * - * This function can be used by modules to implement their - * `get_service' method. + * This function can be used by modules to implement their `get_service' + * method. */ FT_BASE( FT_Pointer ) ft_service_list_lookup( FT_ServiceDesc service_descriptors, @@ -869,16 +373,16 @@ FT_BEGIN_HEADER /*************************************************************************/ /* - * This structure is used to store a cache for several frequently used - * services. It is the type of `face->internal->services'. You - * should only use FT_FACE_LOOKUP_SERVICE to access it. + * This structure is used to store a cache for several frequently used + * services. It is the type of `face->internal->services'. You should + * only use FT_FACE_LOOKUP_SERVICE to access it. * - * All fields should have the type FT_Pointer to relax compilation - * dependencies. We assume the developer isn't completely stupid. + * All fields should have the type FT_Pointer to relax compilation + * dependencies. We assume the developer isn't completely stupid. * - * Each field must be named `service_XXXX' where `XXX' corresponds to - * the correct FT_SERVICE_ID_XXXX macro. See the definition of - * FT_FACE_LOOKUP_SERVICE below how this is implemented. + * Each field must be named `service_XXXX' where `XXX' corresponds to the + * correct FT_SERVICE_ID_XXXX macro. See the definition of + * FT_FACE_LOOKUP_SERVICE below how this is implemented. * */ typedef struct FT_ServiceCacheRec_ @@ -894,14 +398,15 @@ FT_BEGIN_HEADER /* - * A magic number used within the services cache. + * A magic number used within the services cache. */ /* ensure that value `1' has the same width as a pointer */ #define FT_SERVICE_UNAVAILABLE ((FT_Pointer)~(FT_PtrDist)1) - /* + /************************************************************************** + * * @macro: * FT_FACE_LOOKUP_SERVICE * @@ -910,7 +415,7 @@ FT_BEGIN_HEADER * using its cache. * * @input: - * face:: + * face :: * The source face handle containing the cache. * * field :: @@ -921,7 +426,7 @@ FT_BEGIN_HEADER * * @output: * ptr :: - * A variable receiving the service data. NULL if not available. + * A variable receiving the service data. `NULL` if not available. */ #ifdef __cplusplus @@ -969,7 +474,7 @@ FT_BEGIN_HEADER #endif /* !C++ */ /* - * A macro used to define new service structure types. + * A macro used to define new service structure types. */ #define FT_DEFINE_SERVICE( name ) \ @@ -982,7 +487,7 @@ FT_BEGIN_HEADER /* */ /* - * The header files containing the services. + * The header files containing the services. */ #define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h> diff --git a/src/3rdparty/freetype/include/freetype/internal/ftstream.h b/src/3rdparty/freetype/include/freetype/internal/ftstream.h index f90002fe77..a579a039b9 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftstream.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftstream.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstream.h */ -/* */ -/* Stream handling (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstream.h + * + * Stream handling (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSTREAM_H_ @@ -96,13 +96,13 @@ FT_BEGIN_HEADER /* The structure type must be set in the FT_STRUCTURE macro before */ /* calling the FT_FRAME_START() macro. */ /* */ -#define FT_FIELD_SIZE( f ) \ +#define FT_FIELD_SIZE( f ) \ (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) -#define FT_FIELD_SIZE_DELTA( f ) \ +#define FT_FIELD_SIZE_DELTA( f ) \ (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) -#define FT_FIELD_OFFSET( f ) \ +#define FT_FIELD_OFFSET( f ) \ (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) #define FT_FRAME_FIELD( frame_op, field ) \ @@ -147,11 +147,11 @@ FT_BEGIN_HEADER #define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } - /*************************************************************************/ - /* */ - /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ - /* type `char*' or equivalent (1-byte elements). */ - /* */ + /************************************************************************** + * + * Integer extraction macros -- the 'buffer' parameter must ALWAYS be of + * type 'char*' or equivalent (1-byte elements). + */ #define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) @@ -165,6 +165,21 @@ FT_BEGIN_HEADER #define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) + /* + * function acts on increases does range for emits + * pointer checking frames error + * ------------------------------------------------------------------- + * FT_PEEK_XXX buffer pointer no no no no + * FT_NEXT_XXX buffer pointer yes no no no + * FT_GET_XXX stream->cursor yes yes yes no + * FT_READ_XXX stream->pos yes yes no yes + */ + + + /* + * `FT_PEEK_XXX' are generic macros to get data from a buffer position. No + * safety checks are performed. + */ #define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8 ) | \ FT_BYTE_U16( p, 1, 0 ) ) @@ -213,7 +228,10 @@ FT_BEGIN_HEADER FT_BYTE_U32( p, 1, 8 ) | \ FT_BYTE_U32( p, 0, 0 ) ) - + /* + * `FT_NEXT_XXX' are generic macros to get data from a buffer position + * which is then increased appropriately. No safety checks are performed. + */ #define FT_NEXT_CHAR( buffer ) \ ( (signed char)*buffer++ ) @@ -258,10 +276,14 @@ FT_BEGIN_HEADER ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) - /*************************************************************************/ - /* */ - /* Each GET_xxxx() macro uses an implicit `stream' variable. */ - /* */ + /************************************************************************** + * + * The `FT_GET_XXX` macros use an implicit 'stream' variable. + * + * Note that a call to `FT_STREAM_SEEK` or `FT_STREAM_POS` has **no** + * effect on `FT_GET_XXX`! They operate on `stream->pos`, while + * `FT_GET_XXX` use `stream->cursor`. + */ #if 0 #define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor ) @@ -299,10 +321,18 @@ FT_BEGIN_HEADER #define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong ) #endif + #define FT_READ_MACRO( func, type, var ) \ ( var = (type)func( stream, &error ), \ error != FT_Err_Ok ) + /* + * The `FT_READ_XXX' macros use implicit `stream' and `error' variables. + * + * `FT_READ_XXX' can be controlled with `FT_STREAM_SEEK' and + * `FT_STREAM_POS'. They use the full machinery to check whether a read is + * valid. + */ #define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) #define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) #define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var ) @@ -387,12 +417,14 @@ FT_BEGIN_HEADER /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ /* error if the frame could not be read/accessed. The caller can use */ - /* the FT_Stream_Get_XXX functions to retrieve frame data without */ + /* the `FT_Stream_GetXXX' functions to retrieve frame data without */ /* error checks. */ /* */ - /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ + /* You must _always_ call `FT_Stream_ExitFrame' once you have entered */ /* a stream frame! */ /* */ + /* Nested frames are not permitted. */ + /* */ FT_BASE( FT_Error ) FT_Stream_EnterFrame( FT_Stream stream, FT_ULong count ); @@ -401,25 +433,29 @@ FT_BEGIN_HEADER FT_BASE( void ) FT_Stream_ExitFrame( FT_Stream stream ); + /* Extract a stream frame. If the stream is disk-based, a heap block */ /* is allocated and the frame bytes are read into it. If the stream */ - /* is memory-based, this function simply set a pointer to the data. */ + /* is memory-based, this function simply sets a pointer to the data. */ /* */ /* Useful to optimize access to memory-based streams transparently. */ /* */ - /* All extracted frames must be `freed' with a call to the function */ - /* FT_Stream_ReleaseFrame(). */ + /* `FT_Stream_GetXXX' functions can't be used. */ + /* */ + /* An extracted frame must be `freed' with a call to the function */ + /* `FT_Stream_ReleaseFrame'. */ /* */ FT_BASE( FT_Error ) FT_Stream_ExtractFrame( FT_Stream stream, FT_ULong count, FT_Byte** pbytes ); - /* release an extract frame (see FT_Stream_ExtractFrame) */ + /* release an extract frame (see `FT_Stream_ExtractFrame') */ FT_BASE( void ) FT_Stream_ReleaseFrame( FT_Stream stream, FT_Byte** pbytes ); + /* read a byte from an entered frame */ FT_BASE( FT_Char ) FT_Stream_GetChar( FT_Stream stream ); diff --git a/src/3rdparty/freetype/include/freetype/internal/fttrace.h b/src/3rdparty/freetype/include/freetype/internal/fttrace.h index 8092e41fd7..f5f9598046 100644 --- a/src/3rdparty/freetype/include/freetype/internal/fttrace.h +++ b/src/3rdparty/freetype/include/freetype/internal/fttrace.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttrace.h */ -/* */ -/* Tracing handling (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttrace.h + * + * Tracing handling (specification only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* definitions of trace levels for FreeType 2 */ @@ -23,23 +23,24 @@ FT_TRACE_DEF( any ) /* base components */ FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */ +FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ +FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */ -FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ +FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */ FT_TRACE_DEF( list ) /* list management (ftlist.c) */ -FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ -FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ -FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ +FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ -FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ -FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ +FT_TRACE_DEF( bitmap ) /* bitmap manipulation (ftbitmap.c) */ +FT_TRACE_DEF( checksum ) /* bitmap checksum (ftobjs.c) */ FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ +FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */ FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ +FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ +FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ -FT_TRACE_DEF( bitmap ) /* bitmap checksum (ftobjs.c) */ -FT_TRACE_DEF( psprops ) /* PS driver properties (ftpsprop.c) */ /* Cache sub-system */ FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ @@ -47,21 +48,24 @@ FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ /* SFNT driver components */ FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */ FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ +FT_TRACE_DEF( sfwoff ) /* WOFF format handler (sfwoff.c) */ +FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ +FT_TRACE_DEF( ttcolr ) /* glyph layer table (ttcolr.c) */ +FT_TRACE_DEF( ttcpal ) /* color palette table (ttcpal.c) */ FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ -FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ /* TrueType driver components */ FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */ +FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */ FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */ FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */ -FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ /* Type 1 driver components */ FT_TRACE_DEF( t1afm ) @@ -72,14 +76,14 @@ FT_TRACE_DEF( t1objs ) FT_TRACE_DEF( t1parse ) /* PostScript helper module `psaux' */ -FT_TRACE_DEF( t1decode ) FT_TRACE_DEF( cffdecode ) -FT_TRACE_DEF( psobjs ) FT_TRACE_DEF( psconv ) +FT_TRACE_DEF( psobjs ) +FT_TRACE_DEF( t1decode ) /* PostScript hinting module `pshinter' */ -FT_TRACE_DEF( pshrec ) FT_TRACE_DEF( pshalgo ) +FT_TRACE_DEF( pshrec ) /* Type 2 driver components */ FT_TRACE_DEF( cffdriver ) @@ -117,7 +121,6 @@ FT_TRACE_DEF( bdflib ) FT_TRACE_DEF( pfr ) /* OpenType validation components */ -FT_TRACE_DEF( otvmodule ) FT_TRACE_DEF( otvcommon ) FT_TRACE_DEF( otvbase ) FT_TRACE_DEF( otvgdef ) @@ -125,29 +128,30 @@ FT_TRACE_DEF( otvgpos ) FT_TRACE_DEF( otvgsub ) FT_TRACE_DEF( otvjstf ) FT_TRACE_DEF( otvmath ) +FT_TRACE_DEF( otvmodule ) /* TrueTypeGX/AAT validation components */ -FT_TRACE_DEF( gxvmodule ) +FT_TRACE_DEF( gxvbsln ) FT_TRACE_DEF( gxvcommon ) FT_TRACE_DEF( gxvfeat ) -FT_TRACE_DEF( gxvmort ) -FT_TRACE_DEF( gxvmorx ) -FT_TRACE_DEF( gxvbsln ) FT_TRACE_DEF( gxvjust ) FT_TRACE_DEF( gxvkern ) +FT_TRACE_DEF( gxvmodule ) +FT_TRACE_DEF( gxvmort ) +FT_TRACE_DEF( gxvmorx ) +FT_TRACE_DEF( gxvlcar ) FT_TRACE_DEF( gxvopbd ) -FT_TRACE_DEF( gxvtrak ) FT_TRACE_DEF( gxvprop ) -FT_TRACE_DEF( gxvlcar ) +FT_TRACE_DEF( gxvtrak ) /* autofit components */ -FT_TRACE_DEF( afmodule ) -FT_TRACE_DEF( afhints ) FT_TRACE_DEF( afcjk ) +FT_TRACE_DEF( afglobal ) +FT_TRACE_DEF( afhints ) +FT_TRACE_DEF( afmodule ) FT_TRACE_DEF( aflatin ) FT_TRACE_DEF( aflatin2 ) -FT_TRACE_DEF( afwarp ) FT_TRACE_DEF( afshaper ) -FT_TRACE_DEF( afglobal ) +FT_TRACE_DEF( afwarp ) /* END */ diff --git a/src/3rdparty/freetype/include/freetype/internal/ftvalid.h b/src/3rdparty/freetype/include/freetype/internal/ftvalid.h index cad47a556d..38aa06cc4e 100644 --- a/src/3rdparty/freetype/include/freetype/internal/ftvalid.h +++ b/src/3rdparty/freetype/include/freetype/internal/ftvalid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftvalid.h */ -/* */ -/* FreeType validation support (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftvalid.h + * + * FreeType validation support (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTVALID_H_ @@ -42,31 +42,31 @@ FT_BEGIN_HEADER typedef struct FT_ValidatorRec_ volatile* FT_Validator; - /*************************************************************************/ - /* */ - /* There are three distinct validation levels defined here: */ - /* */ - /* FT_VALIDATE_DEFAULT :: */ - /* A table that passes this validation level can be used reliably by */ - /* FreeType. It generally means that all offsets have been checked to */ - /* prevent out-of-bound reads, that array counts are correct, etc. */ - /* */ - /* FT_VALIDATE_TIGHT :: */ - /* A table that passes this validation level can be used reliably and */ - /* doesn't contain invalid data. For example, a charmap table that */ - /* returns invalid glyph indices will not pass, even though it can */ - /* be used with FreeType in default mode (the library will simply */ - /* return an error later when trying to load the glyph). */ - /* */ - /* It also checks that fields which must be a multiple of 2, 4, or 8, */ - /* don't have incorrect values, etc. */ - /* */ - /* FT_VALIDATE_PARANOID :: */ - /* Only for font debugging. Checks that a table follows the */ - /* specification by 100%. Very few fonts will be able to pass this */ - /* level anyway but it can be useful for certain tools like font */ - /* editors/converters. */ - /* */ + /************************************************************************** + * + * There are three distinct validation levels defined here: + * + * FT_VALIDATE_DEFAULT :: + * A table that passes this validation level can be used reliably by + * FreeType. It generally means that all offsets have been checked to + * prevent out-of-bound reads, that array counts are correct, etc. + * + * FT_VALIDATE_TIGHT :: + * A table that passes this validation level can be used reliably and + * doesn't contain invalid data. For example, a charmap table that + * returns invalid glyph indices will not pass, even though it can be + * used with FreeType in default mode (the library will simply return an + * error later when trying to load the glyph). + * + * It also checks that fields which must be a multiple of 2, 4, or 8, + * don't have incorrect values, etc. + * + * FT_VALIDATE_PARANOID :: + * Only for font debugging. Checks that a table follows the + * specification by 100%. Very few fonts will be able to pass this level + * anyway but it can be useful for certain tools like font + * editors/converters. + */ typedef enum FT_ValidationLevel_ { FT_VALIDATE_DEFAULT = 0, diff --git a/src/3rdparty/freetype/include/freetype/internal/internal.h b/src/3rdparty/freetype/include/freetype/internal/internal.h index 8f546e443b..3c8830f7e4 100644 --- a/src/3rdparty/freetype/include/freetype/internal/internal.h +++ b/src/3rdparty/freetype/include/freetype/internal/internal.h @@ -1,31 +1,30 @@ -/***************************************************************************/ -/* */ -/* internal.h */ -/* */ -/* Internal header files (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * internal.h + * + * Internal header files (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ - /*************************************************************************/ - /* */ - /* This file is automatically included by `ft2build.h'. */ - /* Do not include it manually! */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is automatically included by `ft2build.h`. Do not include it + * manually! + * + */ #define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h> -#define FT_INTERNAL_PIC_H <freetype/internal/ftpic.h> #define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h> #define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h> #define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h> @@ -41,6 +40,7 @@ #define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h> #define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h> +#define FT_INTERNAL_WOFF_TYPES_H <freetype/internal/wofftypes.h> #define FT_INTERNAL_POSTSCRIPT_AUX_H <freetype/internal/psaux.h> #define FT_INTERNAL_POSTSCRIPT_HINTS_H <freetype/internal/pshints.h> diff --git a/src/3rdparty/freetype/include/freetype/internal/psaux.h b/src/3rdparty/freetype/include/freetype/internal/psaux.h index f77380d25f..f962a973de 100644 --- a/src/3rdparty/freetype/include/freetype/internal/psaux.h +++ b/src/3rdparty/freetype/include/freetype/internal/psaux.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* psaux.h */ -/* */ -/* Auxiliary functions and data structures related to PostScript fonts */ -/* (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psaux.h + * + * Auxiliary functions and data structures related to PostScript fonts + * (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSAUX_H_ @@ -35,10 +35,10 @@ FT_BEGIN_HEADER - /***********************************************************************/ - /* */ - /* PostScript modules driver class. */ - /* */ + /************************************************************************** + * + * PostScript modules driver class. + */ typedef struct PS_DriverRec_ { FT_DriverRec root; @@ -64,23 +64,27 @@ FT_BEGIN_HEADER typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Table_FuncsRec */ - /* */ - /* <Description> */ - /* A set of function pointers to manage PS_Table objects. */ - /* */ - /* <Fields> */ - /* table_init :: Used to initialize a table. */ - /* */ - /* table_done :: Finalizes resp. destroy a given table. */ - /* */ - /* table_add :: Adds a new object to a table. */ - /* */ - /* table_release :: Releases table data, then finalizes it. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_Table_FuncsRec + * + * @description: + * A set of function pointers to manage PS_Table objects. + * + * @fields: + * table_init :: + * Used to initialize a table. + * + * table_done :: + * Finalizes resp. destroy a given table. + * + * table_add :: + * Adds a new object to a table. + * + * table_release :: + * Releases table data, then finalizes it. + */ typedef struct PS_Table_FuncsRec_ { FT_Error @@ -92,10 +96,10 @@ FT_BEGIN_HEADER (*done)( PS_Table table ); FT_Error - (*add)( PS_Table table, - FT_Int idx, - void* object, - FT_UInt length ); + (*add)( PS_Table table, + FT_Int idx, + const void* object, + FT_UInt length ); void (*release)( PS_Table table ); @@ -103,41 +107,47 @@ FT_BEGIN_HEADER } PS_Table_FuncsRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_TableRec */ - /* */ - /* <Description> */ - /* A PS_Table is a simple object used to store an array of objects in */ - /* a single memory block. */ - /* */ - /* <Fields> */ - /* block :: The address in memory of the growheap's block. This */ - /* can change between two object adds, due to */ - /* reallocation. */ - /* */ - /* cursor :: The current top of the grow heap within its block. */ - /* */ - /* capacity :: The current size of the heap block. Increments by */ - /* 1kByte chunks. */ - /* */ - /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */ - /* been allocated. */ - /* */ - /* max_elems :: The maximum number of elements in table. */ - /* */ - /* num_elems :: The current number of elements in table. */ - /* */ - /* elements :: A table of element addresses within the block. */ - /* */ - /* lengths :: A table of element sizes within the block. */ - /* */ - /* memory :: The object used for memory operations */ - /* (alloc/realloc). */ - /* */ - /* funcs :: A table of method pointers for this object. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_TableRec + * + * @description: + * A PS_Table is a simple object used to store an array of objects in a + * single memory block. + * + * @fields: + * block :: + * The address in memory of the growheap's block. This can change + * between two object adds, due to reallocation. + * + * cursor :: + * The current top of the grow heap within its block. + * + * capacity :: + * The current size of the heap block. Increments by 1kByte chunks. + * + * init :: + * Set to 0xDEADBEEF if 'elements' and 'lengths' have been allocated. + * + * max_elems :: + * The maximum number of elements in table. + * + * num_elems :: + * The current number of elements in table. + * + * elements :: + * A table of element addresses within the block. + * + * lengths :: + * A table of element sizes within the block. + * + * memory :: + * The object used for memory operations (alloc/realloc). + * + * funcs :: + * A table of method pointers for this object. + */ typedef struct PS_TableRec_ { FT_Byte* block; /* current memory block */ @@ -425,27 +435,33 @@ FT_BEGIN_HEADER } PS_Parser_FuncsRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_ParserRec */ - /* */ - /* <Description> */ - /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ - /* */ - /* <Fields> */ - /* cursor :: The current position in the text. */ - /* */ - /* base :: Start of the processed text. */ - /* */ - /* limit :: End of the processed text. */ - /* */ - /* error :: The last error returned. */ - /* */ - /* memory :: The object used for memory operations (alloc/realloc). */ - /* */ - /* funcs :: A table of functions for the parser. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_ParserRec + * + * @description: + * A PS_Parser is an object used to parse a Type 1 font very quickly. + * + * @fields: + * cursor :: + * The current position in the text. + * + * base :: + * Start of the processed text. + * + * limit :: + * End of the processed text. + * + * error :: + * The last error returned. + * + * memory :: + * The object used for memory operations (alloc/realloc). + * + * funcs :: + * A table of functions for the parser. + */ typedef struct PS_ParserRec_ { FT_Byte* cursor; @@ -484,51 +500,67 @@ FT_BEGIN_HEADER } PS_Builder_FuncsRec; - /*************************************************************************/ - /* */ - /* <Structure> */ - /* PS_Builder */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: XXX */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* path_begun :: A flag which indicates that a new path has begun. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* is_t1 :: Set if current font type is Type 1. */ - /* */ - /* funcs :: An array of function pointers for the builder. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_Builder + * + * @description: + * A structure used during glyph loading to store its outline. + * + * @fields: + * memory :: + * The current memory object. + * + * face :: + * The current face object. + * + * glyph :: + * The current glyph slot. + * + * loader :: + * XXX + * + * base :: + * The base glyph outline. + * + * current :: + * The current glyph outline. + * + * pos_x :: + * The horizontal translation (if composite glyph). + * + * pos_y :: + * The vertical translation (if composite glyph). + * + * left_bearing :: + * The left side bearing point. + * + * advance :: + * The horizontal advance vector. + * + * bbox :: + * Unused. + * + * path_begun :: + * A flag which indicates that a new path has begun. + * + * load_points :: + * If this flag is not set, no points are loaded. + * + * no_recurse :: + * Set but not used. + * + * metrics_only :: + * A boolean indicating that we only want to compute the metrics of a + * given glyph, not load all of its points. + * + * is_t1 :: + * Set if current font type is Type 1. + * + * funcs :: + * An array of function pointers for the builder. + */ struct PS_Builder_ { FT_Memory memory; @@ -729,54 +761,70 @@ FT_BEGIN_HEADER } T1_ParseState; - /*************************************************************************/ - /* */ - /* <Structure> */ - /* T1_BuilderRec */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: XXX */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* max_points :: maximum points in builder outline */ - /* */ - /* max_contours :: Maximum number of contours in builder outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* parse_state :: An enumeration which controls the charstring */ - /* parsing state. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* funcs :: An array of function pointers for the builder. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_BuilderRec + * + * @description: + * A structure used during glyph loading to store its outline. + * + * @fields: + * memory :: + * The current memory object. + * + * face :: + * The current face object. + * + * glyph :: + * The current glyph slot. + * + * loader :: + * XXX + * + * base :: + * The base glyph outline. + * + * current :: + * The current glyph outline. + * + * max_points :: + * maximum points in builder outline + * + * max_contours :: + * Maximum number of contours in builder outline. + * + * pos_x :: + * The horizontal translation (if composite glyph). + * + * pos_y :: + * The vertical translation (if composite glyph). + * + * left_bearing :: + * The left side bearing point. + * + * advance :: + * The horizontal advance vector. + * + * bbox :: + * Unused. + * + * parse_state :: + * An enumeration which controls the charstring parsing state. + * + * load_points :: + * If this flag is not set, no points are loaded. + * + * no_recurse :: + * Set but not used. + * + * metrics_only :: + * A boolean indicating that we only want to compute the metrics of a + * given glyph, not load all of its points. + * + * funcs :: + * An array of function pointers for the builder. + */ typedef struct T1_BuilderRec_ { FT_Memory memory; @@ -817,19 +865,19 @@ FT_BEGIN_HEADER #if 0 - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ + /************************************************************************** + * + * T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine + * calls during glyph loading. + */ #define T1_MAX_SUBRS_CALLS 8 - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ + /************************************************************************** + * + * T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A + * minimum of 16 is required. + */ #define T1_MAX_CHARSTRINGS_OPERANDS 32 #endif /* 0 */ @@ -993,53 +1041,70 @@ FT_BEGIN_HEADER } CFF_Builder_FuncsRec; - /*************************************************************************/ - /* */ - /* <Structure> */ - /* CFF_Builder */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: The current glyph loader. */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* path_begun :: A flag which indicates that a new path has begun. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* hints_funcs :: Auxiliary pointer for hinting. */ - /* */ - /* hints_globals :: Auxiliary pointer for hinting. */ - /* */ - /* funcs :: A table of method pointers for this object. */ - /* */ + /************************************************************************** + * + * @struct: + * CFF_Builder + * + * @description: + * A structure used during glyph loading to store its outline. + * + * @fields: + * memory :: + * The current memory object. + * + * face :: + * The current face object. + * + * glyph :: + * The current glyph slot. + * + * loader :: + * The current glyph loader. + * + * base :: + * The base glyph outline. + * + * current :: + * The current glyph outline. + * + * pos_x :: + * The horizontal translation (if composite glyph). + * + * pos_y :: + * The vertical translation (if composite glyph). + * + * left_bearing :: + * The left side bearing point. + * + * advance :: + * The horizontal advance vector. + * + * bbox :: + * Unused. + * + * path_begun :: + * A flag which indicates that a new path has begun. + * + * load_points :: + * If this flag is not set, no points are loaded. + * + * no_recurse :: + * Set but not used. + * + * metrics_only :: + * A boolean indicating that we only want to compute the metrics of a + * given glyph, not load all of its points. + * + * hints_funcs :: + * Auxiliary pointer for hinting. + * + * hints_globals :: + * Auxiliary pointer for hinting. + * + * funcs :: + * A table of method pointers for this object. + */ struct CFF_Builder_ { FT_Memory memory; @@ -1211,25 +1276,27 @@ FT_BEGIN_HEADER typedef struct AFM_StreamRec_* AFM_Stream; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AFM_ParserRec */ - /* */ - /* <Description> */ - /* An AFM_Parser is a parser for the AFM files. */ - /* */ - /* <Fields> */ - /* memory :: The object used for memory operations (alloc and */ - /* realloc). */ - /* */ - /* stream :: This is an opaque object. */ - /* */ - /* FontInfo :: The result will be stored here. */ - /* */ - /* get_index :: A user provided function to get a glyph index by its */ - /* name. */ - /* */ + /************************************************************************** + * + * @struct: + * AFM_ParserRec + * + * @description: + * An AFM_Parser is a parser for the AFM files. + * + * @fields: + * memory :: + * The object used for memory operations (alloc and realloc). + * + * stream :: + * This is an opaque object. + * + * FontInfo :: + * The result will be stored here. + * + * get_index :: + * A user provided function to get a glyph index by its name. + */ typedef struct AFM_ParserRec_ { FT_Memory memory; diff --git a/src/3rdparty/freetype/include/freetype/internal/pshints.h b/src/3rdparty/freetype/include/freetype/internal/pshints.h index d29314ec2e..699acea6f5 100644 --- a/src/3rdparty/freetype/include/freetype/internal/pshints.h +++ b/src/3rdparty/freetype/include/freetype/internal/pshints.h @@ -1,21 +1,21 @@ -/***************************************************************************/ -/* */ -/* pshints.h */ -/* */ -/* Interface to Postscript-specific (Type 1 and Type 2) hints */ -/* recorders (specification only). These are used to support native */ -/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshints.h + * + * Interface to Postscript-specific (Type 1 and Type 2) hints + * recorders (specification only). These are used to support native + * T1/T2 hints in the 'type1', 'cid', and 'cff' font drivers. + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHINTS_H_ @@ -73,7 +73,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /************************************************************************* + /************************************************************************** * * @type: * T1_Hints @@ -86,16 +86,16 @@ FT_BEGIN_HEADER * @T1_Hints_FuncsRec structure. Recording glyph hints is normally * achieved through the following scheme: * - * - Open a new hint recording session by calling the `open' method. + * - Open a new hint recording session by calling the 'open' method. * This rewinds the recorder and prepare it for new input. * * - For each hint found in the glyph charstring, call the corresponding - * method (`stem', `stem3', or `reset'). Note that these functions do + * method ('stem', 'stem3', or 'reset'). Note that these functions do * not return an error code. * - * - Close the recording session by calling the `close' method. It - * returns an error code if the hints were invalid or something - * strange happened (e.g., memory shortage). + * - Close the recording session by calling the 'close' method. It + * returns an error code if the hints were invalid or something strange + * happened (e.g., memory shortage). * * The hints accumulated in the object can later be used by the * PostScript hinter. @@ -104,7 +104,7 @@ FT_BEGIN_HEADER typedef struct T1_HintsRec_* T1_Hints; - /************************************************************************* + /************************************************************************** * * @type: * T1_Hints_Funcs @@ -117,7 +117,7 @@ FT_BEGIN_HEADER typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs; - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_OpenFunc @@ -139,14 +139,14 @@ FT_BEGIN_HEADER (*T1_Hints_OpenFunc)( T1_Hints hints ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_SetStemFunc * * @description: * A method of the @T1_Hints class used to record a new horizontal or - * vertical stem. This corresponds to the Type 1 `hstem' and `vstem' + * vertical stem. This corresponds to the Type 1 'hstem' and 'vstem' * operators. * * @input: @@ -164,15 +164,15 @@ FT_BEGIN_HEADER * Use vertical coordinates (y) for horizontal stems (dim=0). Use * horizontal coordinates (x) for vertical stems (dim=1). * - * `coords[0]' is the absolute stem position (lowest coordinate); - * `coords[1]' is the length. + * 'coords[0]' is the absolute stem position (lowest coordinate); + * 'coords[1]' is the length. * * The length can be negative, in which case it must be either -20 or - * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * -21. It is interpreted as a 'ghost' stem, according to the Type 1 * specification. * - * If the length is -21 (corresponding to a bottom ghost stem), then - * the real stem position is `coords[0]+coords[1]'. + * If the length is -21 (corresponding to a bottom ghost stem), then the + * real stem position is 'coords[0]+coords[1]'. * */ typedef void @@ -181,7 +181,7 @@ FT_BEGIN_HEADER FT_Fixed* coords ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_SetStem3Func @@ -215,7 +215,7 @@ FT_BEGIN_HEADER FT_Fixed* coords ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_ResetFunc @@ -238,7 +238,7 @@ FT_BEGIN_HEADER FT_UInt end_point ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_CloseFunc @@ -267,7 +267,7 @@ FT_BEGIN_HEADER FT_UInt end_point ); - /************************************************************************* + /************************************************************************** * * @functype: * T1_Hints_ApplyFunc @@ -297,7 +297,7 @@ FT_BEGIN_HEADER * On input, all points within the outline are in font coordinates. On * output, they are in 1/64th of pixels. * - * The scaling transformation is taken from the `globals' object which + * The scaling transformation is taken from the 'globals' object which * must correspond to the same font as the glyph. * */ @@ -308,7 +308,7 @@ FT_BEGIN_HEADER FT_Render_Mode hint_mode ); - /************************************************************************* + /************************************************************************** * * @struct: * T1_Hints_FuncsRec @@ -360,7 +360,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /************************************************************************* + /************************************************************************** * * @type: * T2_Hints @@ -373,16 +373,16 @@ FT_BEGIN_HEADER * @T2_Hints_FuncsRec structure. Recording glyph hints is normally * achieved through the following scheme: * - * - Open a new hint recording session by calling the `open' method. + * - Open a new hint recording session by calling the 'open' method. * This rewinds the recorder and prepare it for new input. * * - For each hint found in the glyph charstring, call the corresponding - * method (`stems', `hintmask', `counters'). Note that these - * functions do not return an error code. + * method ('stems', 'hintmask', 'counters'). Note that these functions + * do not return an error code. * - * - Close the recording session by calling the `close' method. It - * returns an error code if the hints were invalid or something - * strange happened (e.g., memory shortage). + * - Close the recording session by calling the 'close' method. It + * returns an error code if the hints were invalid or something strange + * happened (e.g., memory shortage). * * The hints accumulated in the object can later be used by the * Postscript hinter. @@ -391,7 +391,7 @@ FT_BEGIN_HEADER typedef struct T2_HintsRec_* T2_Hints; - /************************************************************************* + /************************************************************************** * * @type: * T2_Hints_Funcs @@ -404,7 +404,7 @@ FT_BEGIN_HEADER typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs; - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_OpenFunc @@ -426,7 +426,7 @@ FT_BEGIN_HEADER (*T2_Hints_OpenFunc)( T2_Hints hints ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_StemsFunc @@ -434,7 +434,7 @@ FT_BEGIN_HEADER * @description: * A method of the @T2_Hints class used to set the table of stems in * either the vertical or horizontal dimension. Equivalent to the - * `hstem', `vstem', `hstemhm', and `vstemhm' Type 2 operators. + * 'hstem', 'vstem', 'hstemhm', and 'vstemhm' Type 2 operators. * * @input: * hints :: @@ -447,18 +447,18 @@ FT_BEGIN_HEADER * The number of stems. * * coords :: - * An array of `count' (position,length) pairs in 16.16 format. + * An array of 'count' (position,length) pairs in 16.16 format. * * @note: * Use vertical coordinates (y) for horizontal stems (dim=0). Use * horizontal coordinates (x) for vertical stems (dim=1). * - * There are `2*count' elements in the `coords' array. Each even - * element is an absolute position in font units, each odd element is a - * length in font units. + * There are '2*count' elements in the 'coords' array. Each even element + * is an absolute position in font units, each odd element is a length in + * font units. * - * A length can be negative, in which case it must be either -20 or - * -21. It is interpreted as a `ghost' stem, according to the Type 1 + * A length can be negative, in which case it must be either -20 or -21. + * It is interpreted as a 'ghost' stem, according to the Type 1 * specification. * */ @@ -469,22 +469,22 @@ FT_BEGIN_HEADER FT_Fixed* coordinates ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_MaskFunc * * @description: * A method of the @T2_Hints class used to set a given hintmask (this - * corresponds to the `hintmask' Type 2 operator). + * corresponds to the 'hintmask' Type 2 operator). * * @input: * hints :: * A handle to the Type 2 hints recorder. * * end_point :: - * The glyph index of the last point to which the previously defined - * or activated hints apply. + * The glyph index of the last point to which the previously defined or + * activated hints apply. * * bit_count :: * The number of bits in the hint mask. @@ -494,13 +494,13 @@ FT_BEGIN_HEADER * * @note: * If the hintmask starts the charstring (before any glyph point - * definition), the value of `end_point' should be 0. + * definition), the value of `end_point` should be 0. * - * `bit_count' is the number of meaningful bits in the `bytes' array; it + * `bit_count` is the number of meaningful bits in the 'bytes' array; it * must be equal to the total number of hints defined so far (i.e., * horizontal+verticals). * - * The `bytes' array can come directly from the Type 2 charstring and + * The 'bytes' array can come directly from the Type 2 charstring and * respects the same format. * */ @@ -511,14 +511,14 @@ FT_BEGIN_HEADER const FT_Byte* bytes ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_CounterFunc * * @description: - * A method of the @T2_Hints class used to set a given counter mask - * (this corresponds to the `hintmask' Type 2 operator). + * A method of the @T2_Hints class used to set a given counter mask (this + * corresponds to the 'hintmask' Type 2 operator). * * @input: * hints :: @@ -536,13 +536,13 @@ FT_BEGIN_HEADER * * @note: * If the hintmask starts the charstring (before any glyph point - * definition), the value of `end_point' should be 0. + * definition), the value of `end_point` should be 0. * - * `bit_count' is the number of meaningful bits in the `bytes' array; it + * `bit_count` is the number of meaningful bits in the 'bytes' array; it * must be equal to the total number of hints defined so far (i.e., * horizontal+verticals). * - * The `bytes' array can come directly from the Type 2 charstring and + * The 'bytes' array can come directly from the Type 2 charstring and * respects the same format. * */ @@ -552,7 +552,7 @@ FT_BEGIN_HEADER const FT_Byte* bytes ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_CloseFunc @@ -581,15 +581,14 @@ FT_BEGIN_HEADER FT_UInt end_point ); - /************************************************************************* + /************************************************************************** * * @functype: * T2_Hints_ApplyFunc * * @description: * A method of the @T2_Hints class used to apply hints to the - * corresponding glyph outline. Must be called after the `close' - * method. + * corresponding glyph outline. Must be called after the 'close' method. * * @input: * hints :: @@ -611,7 +610,7 @@ FT_BEGIN_HEADER * On input, all points within the outline are in font coordinates. On * output, they are in 1/64th of pixels. * - * The scaling transformation is taken from the `globals' object which + * The scaling transformation is taken from the 'globals' object which * must correspond to the same font than the glyph. * */ @@ -622,7 +621,7 @@ FT_BEGIN_HEADER FT_Render_Mode hint_mode ); - /************************************************************************* + /************************************************************************** * * @struct: * T2_Hints_FuncsRec @@ -680,8 +679,6 @@ FT_BEGIN_HEADER typedef PSHinter_Interface* PSHinter_Service; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_PSHINTER_INTERFACE( \ class_, \ get_globals_funcs_, \ @@ -694,25 +691,6 @@ FT_BEGIN_HEADER get_t2_funcs_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_PSHINTER_INTERFACE( \ - class_, \ - get_globals_funcs_, \ - get_t1_funcs_, \ - get_t2_funcs_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - PSHinter_Interface* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_globals_funcs = get_globals_funcs_; \ - clazz->get_t1_funcs = get_t1_funcs_; \ - clazz->get_t2_funcs = get_t2_funcs_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svbdf.h b/src/3rdparty/freetype/include/freetype/internal/services/svbdf.h index 4a9ec20075..e4786ed038 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svbdf.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svbdf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svbdf.h */ -/* */ -/* The FreeType BDF services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svbdf.h + * + * The FreeType BDF services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVBDF_H_ @@ -46,8 +46,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_BDFRec( class_, \ get_charset_id_, \ get_property_ ) \ @@ -56,20 +54,6 @@ FT_BEGIN_HEADER get_charset_id_, get_property_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_BDFRec( class_, \ - get_charset_id_, \ - get_property_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_BDFRec* clazz ) \ - { \ - clazz->get_charset_id = get_charset_id_; \ - clazz->get_property = get_property_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svcfftl.h b/src/3rdparty/freetype/include/freetype/internal/services/svcfftl.h index db623e6840..6c621732da 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svcfftl.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svcfftl.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svcfftl.h */ -/* */ -/* The FreeType CFF tables loader service (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svcfftl.h + * + * The FreeType CFF tables loader service (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVCFFTL_H_ @@ -65,8 +65,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_CFFLOADREC( class_, \ get_standard_encoding_, \ load_private_dict_, \ @@ -82,26 +80,6 @@ FT_BEGIN_HEADER blend_build_vector_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \ - get_standard_encoding_, \ - load_private_dict_, \ - fd_select_get_, \ - blend_check_vector_, \ - blend_build_vector_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_CFFLoadRec* clazz ) \ - { \ - clazz->get_standard_encoding = get_standard_encoding_; \ - clazz->load_private_dict = load_private_dict_; \ - clazz->fd_select_get = fd_select_get_; \ - clazz->blend_check_vector = blend_check_vector_; \ - clazz->blend_build_vector = blend_build_vector_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - FT_END_HEADER diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svcid.h b/src/3rdparty/freetype/include/freetype/internal/services/svcid.h index cb59ac6a29..555a5af5b9 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svcid.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svcid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svcid.h */ -/* */ -/* The FreeType CID font services (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* Derek Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svcid.h + * + * The FreeType CID font services (specification). + * + * Copyright (C) 2007-2019 by + * Derek Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVCID_H_ @@ -48,8 +48,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_CIDREC( class_, \ get_ros_, \ get_is_cid_, \ @@ -59,25 +57,6 @@ FT_BEGIN_HEADER get_ros_, get_is_cid_, get_cid_from_glyph_index_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_CIDREC( class_, \ - get_ros_, \ - get_is_cid_, \ - get_cid_from_glyph_index_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_CIDRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_ros = get_ros_; \ - clazz->get_is_cid = get_is_cid_; \ - clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svfntfmt.h b/src/3rdparty/freetype/include/freetype/internal/services/svfntfmt.h index 3b732be1a1..6f4285ea8c 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svfntfmt.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svfntfmt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svfntfmt.h */ -/* */ -/* The FreeType font format service (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svfntfmt.h + * + * The FreeType font format service (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVFNTFMT_H_ @@ -26,9 +26,9 @@ FT_BEGIN_HEADER /* - * A trivial service used to return the name of a face's font driver, - * according to the XFree86 nomenclature. Note that the service data - * is a simple constant string pointer. + * A trivial service used to return the name of a face's font driver, + * according to the XFree86 nomenclature. Note that the service data is a + * simple constant string pointer. */ #define FT_SERVICE_ID_FONT_FORMAT "font-format" diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svgldict.h b/src/3rdparty/freetype/include/freetype/internal/services/svgldict.h index f1a68e3110..0949621835 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svgldict.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svgldict.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svgldict.h */ -/* */ -/* The FreeType glyph dictionary services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svgldict.h + * + * The FreeType glyph dictionary services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVGLDICT_H_ @@ -26,8 +26,8 @@ FT_BEGIN_HEADER /* - * A service used to retrieve glyph names, as well as to find the - * index of a given glyph name in a font. + * A service used to retrieve glyph names, as well as to find the index of + * a given glyph name in a font. * */ @@ -41,8 +41,8 @@ FT_BEGIN_HEADER FT_UInt buffer_max ); typedef FT_UInt - (*FT_GlyphDict_NameIndexFunc)( FT_Face face, - FT_String* glyph_name ); + (*FT_GlyphDict_NameIndexFunc)( FT_Face face, + const FT_String* glyph_name ); FT_DEFINE_SERVICE( GlyphDict ) @@ -52,8 +52,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ get_name_, \ name_index_ ) \ @@ -62,23 +60,6 @@ FT_BEGIN_HEADER get_name_, name_index_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ - get_name_, \ - name_index_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_GlyphDictRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_name = get_name_; \ - clazz->name_index = name_index_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svgxval.h b/src/3rdparty/freetype/include/freetype/internal/services/svgxval.h index ed79ebeaa8..0bb76f3144 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svgxval.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svgxval.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* svgxval.h */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svgxval.h + * + * FreeType API for validating TrueTypeGX/AAT tables (specification). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef SVGXVAL_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svkern.h b/src/3rdparty/freetype/include/freetype/internal/services/svkern.h index c7e8f6ef27..f992a327c1 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svkern.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svkern.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svkern.h */ -/* */ -/* The FreeType Kerning service (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svkern.h + * + * The FreeType Kerning service (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVKERN_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svmetric.h b/src/3rdparty/freetype/include/freetype/internal/services/svmetric.h index abaacddbbe..d688bc7c60 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svmetric.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svmetric.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svmetric.h */ -/* */ -/* The FreeType services for metrics variations (specification). */ -/* */ -/* Copyright 2016-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svmetric.h + * + * The FreeType services for metrics variations (specification). + * + * Copyright (C) 2016-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVMETRIC_H_ @@ -26,7 +26,7 @@ FT_BEGIN_HEADER /* - * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables. + * A service to manage the `HVAR, `MVAR', and `VVAR' OpenType tables. * */ @@ -93,8 +93,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ hadvance_adjust_, \ lsb_adjust_, \ @@ -116,32 +114,6 @@ FT_BEGIN_HEADER metrics_adjust_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_METRICSVARIATIONSREC( class_, \ - hadvance_adjust_, \ - lsb_adjust_, \ - rsb_adjust_, \ - vadvance_adjust_, \ - tsb_adjust_, \ - bsb_adjust_, \ - vorg_adjust_, \ - metrics_adjust_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_MetricsVariationsRec* clazz ) \ - { \ - clazz->hadvance_adjust = hadvance_adjust_; \ - clazz->lsb_adjust = lsb_adjust_; \ - clazz->rsb_adjust = rsb_adjust_; \ - clazz->vadvance_adjust = vadvance_adjust_; \ - clazz->tsb_adjust = tsb_adjust_; \ - clazz->bsb_adjust = bsb_adjust_; \ - clazz->vorg_adjust = vorg_adjust_; \ - clazz->metrics_adjust = metrics_adjust_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svmm.h b/src/3rdparty/freetype/include/freetype/internal/services/svmm.h index bcbb38e2ce..3652f2050a 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svmm.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svmm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svmm.h */ -/* */ -/* The FreeType Multiple Masters and GX var services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svmm.h + * + * The FreeType Multiple Masters and GX var services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVMM_H_ @@ -26,9 +26,9 @@ FT_BEGIN_HEADER /* - * A service used to manage multiple-masters data in a given face. + * A service used to manage multiple-masters data in a given face. * - * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). + * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). * */ @@ -86,81 +86,65 @@ FT_BEGIN_HEADER typedef void (*FT_Done_Blend_Func)( FT_Face ); + typedef FT_Error + (*FT_Set_MM_WeightVector_Func)( FT_Face face, + FT_UInt len, + FT_Fixed* weight_vector ); + + typedef FT_Error + (*FT_Get_MM_WeightVector_Func)( FT_Face face, + FT_UInt* len, + FT_Fixed* weight_vector ); + FT_DEFINE_SERVICE( MultiMasters ) { - FT_Get_MM_Func get_mm; - FT_Set_MM_Design_Func set_mm_design; - FT_Set_MM_Blend_Func set_mm_blend; - FT_Get_MM_Blend_Func get_mm_blend; - FT_Get_MM_Var_Func get_mm_var; - FT_Set_Var_Design_Func set_var_design; - FT_Get_Var_Design_Func get_var_design; - FT_Set_Instance_Func set_instance; + FT_Get_MM_Func get_mm; + FT_Set_MM_Design_Func set_mm_design; + FT_Set_MM_Blend_Func set_mm_blend; + FT_Get_MM_Blend_Func get_mm_blend; + FT_Get_MM_Var_Func get_mm_var; + FT_Set_Var_Design_Func set_var_design; + FT_Get_Var_Design_Func get_var_design; + FT_Set_Instance_Func set_instance; + FT_Set_MM_WeightVector_Func set_mm_weightvector; + FT_Get_MM_WeightVector_Func get_mm_weightvector; /* for internal use; only needed for code sharing between modules */ - FT_Get_Var_Blend_Func get_var_blend; - FT_Done_Blend_Func done_blend; + FT_Get_Var_Blend_Func get_var_blend; + FT_Done_Blend_Func done_blend; }; -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_blend_, \ - get_mm_var_, \ - set_var_design_, \ - get_var_design_, \ - set_instance_, \ - get_var_blend_, \ - done_blend_ ) \ - static const FT_Service_MultiMastersRec class_ = \ - { \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_blend_, \ - get_mm_var_, \ - set_var_design_, \ - get_var_design_, \ - set_instance_, \ - get_var_blend_, \ - done_blend_ \ +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + set_weightvector_, \ + get_weightvector_, \ + get_var_blend_, \ + done_blend_ ) \ + static const FT_Service_MultiMastersRec class_ = \ + { \ + get_mm_, \ + set_mm_design_, \ + set_mm_blend_, \ + get_mm_blend_, \ + get_mm_var_, \ + set_var_design_, \ + get_var_design_, \ + set_instance_, \ + set_weightvector_, \ + get_weightvector_, \ + get_var_blend_, \ + done_blend_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_blend_, \ - get_mm_var_, \ - set_var_design_, \ - get_var_design_, \ - set_instance_, \ - get_var_blend_, \ - done_blend_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ - { \ - clazz->get_mm = get_mm_; \ - clazz->set_mm_design = set_mm_design_; \ - clazz->set_mm_blend = set_mm_blend_; \ - clazz->get_mm_blend = get_mm_blend_; \ - clazz->get_mm_var = get_mm_var_; \ - clazz->set_var_design = set_var_design_; \ - clazz->get_var_design = get_var_design_; \ - clazz->set_instance = set_instance_; \ - clazz->get_var_blend = get_var_blend_; \ - clazz->done_blend = done_blend_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svotval.h b/src/3rdparty/freetype/include/freetype/internal/services/svotval.h index 31294296a6..cab4c6efbb 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svotval.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svotval.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svotval.h */ -/* */ -/* The FreeType OpenType validation service (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svotval.h + * + * The FreeType OpenType validation service (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVOTVAL_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svpfr.h b/src/3rdparty/freetype/include/freetype/internal/services/svpfr.h index e65d57e91b..fd01d614dd 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svpfr.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svpfr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpfr.h */ -/* */ -/* Internal PFR service functions (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpfr.h + * + * Internal PFR service functions (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPFR_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svpostnm.h b/src/3rdparty/freetype/include/freetype/internal/services/svpostnm.h index 4a49d8b053..18e3843cbe 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svpostnm.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svpostnm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpostnm.h */ -/* */ -/* The FreeType PostScript name services (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpostnm.h + * + * The FreeType PostScript name services (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPOSTNM_H_ @@ -25,13 +25,13 @@ FT_BEGIN_HEADER /* - * A trivial service used to retrieve the PostScript name of a given - * font when available. The `get_name' field should never be NULL. + * A trivial service used to retrieve the PostScript name of a given font + * when available. The `get_name' field should never be `NULL`. * - * The corresponding function can return NULL to indicate that the - * PostScript name is not available. + * The corresponding function can return `NULL` to indicate that the + * PostScript name is not available. * - * The name is owned by the face and will be destroyed with it. + * The name is owned by the face and will be destroyed with it. */ #define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" @@ -47,28 +47,12 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ static const FT_Service_PsFontNameRec class_ = \ { \ get_ps_font_name_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsFontNameRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_ps_font_name = get_ps_font_name_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svprop.h b/src/3rdparty/freetype/include/freetype/internal/services/svprop.h index adc0bcf439..e48d0151ec 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svprop.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svprop.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svprop.h */ -/* */ -/* The FreeType property service (specification). */ -/* */ -/* Copyright 2012-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svprop.h + * + * The FreeType property service (specification). + * + * Copyright (C) 2012-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPROP_H_ @@ -45,8 +45,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ set_property_, \ get_property_ ) \ @@ -56,20 +54,6 @@ FT_BEGIN_HEADER get_property_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ - set_property_, \ - get_property_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_PropertiesRec* clazz ) \ - { \ - clazz->set_property = set_property_; \ - clazz->get_property = get_property_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svpscmap.h b/src/3rdparty/freetype/include/freetype/internal/services/svpscmap.h index 5589575b92..dfac3bafa9 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svpscmap.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svpscmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpscmap.h */ -/* */ -/* The FreeType PostScript charmap service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpscmap.h + * + * The FreeType PostScript charmap service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPSCMAP_H_ @@ -29,27 +29,26 @@ FT_BEGIN_HEADER /* - * Adobe glyph name to unicode value. + * Adobe glyph name to unicode value. */ typedef FT_UInt32 (*PS_Unicode_ValueFunc)( const char* glyph_name ); /* - * Macintosh name id to glyph name. NULL if invalid index. + * Macintosh name id to glyph name. `NULL` if invalid index. */ typedef const char* (*PS_Macintosh_NameFunc)( FT_UInt name_index ); /* - * Adobe standard string ID to glyph name. NULL if invalid index. + * Adobe standard string ID to glyph name. `NULL` if invalid index. */ typedef const char* (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index ); /* - * Simple unicode -> glyph index charmap built from font glyph names - * table. + * Simple unicode -> glyph index charmap built from font glyph names table. */ typedef struct PS_UniMap_ { @@ -71,16 +70,16 @@ FT_BEGIN_HEADER /* - * A function which returns a glyph name for a given index. Returns - * NULL if invalid index. + * A function which returns a glyph name for a given index. Returns + * `NULL` if invalid index. */ typedef const char* (*PS_GetGlyphNameFunc)( FT_Pointer data, FT_UInt string_index ); /* - * A function used to release the glyph name returned by - * PS_GetGlyphNameFunc, when needed + * A function used to release the glyph name returned by + * PS_GetGlyphNameFunc, when needed */ typedef void (*PS_FreeGlyphNameFunc)( FT_Pointer data, @@ -118,8 +117,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ unicode_value_, \ unicodes_init_, \ @@ -136,35 +133,6 @@ FT_BEGIN_HEADER adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ - unicode_value_, \ - unicodes_init_, \ - unicodes_char_index_, \ - unicodes_char_next_, \ - macintosh_name_, \ - adobe_std_strings_, \ - adobe_std_encoding_, \ - adobe_expert_encoding_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsCMapsRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->unicode_value = unicode_value_; \ - clazz->unicodes_init = unicodes_init_; \ - clazz->unicodes_char_index = unicodes_char_index_; \ - clazz->unicodes_char_next = unicodes_char_next_; \ - clazz->macintosh_name = macintosh_name_; \ - clazz->adobe_std_strings = adobe_std_strings_; \ - clazz->adobe_std_encoding = adobe_std_encoding_; \ - clazz->adobe_expert_encoding = adobe_expert_encoding_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svpsinfo.h b/src/3rdparty/freetype/include/freetype/internal/services/svpsinfo.h index 408f406dfa..fb4e0e3fa9 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svpsinfo.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svpsinfo.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svpsinfo.h */ -/* */ -/* The FreeType PostScript info service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svpsinfo.h + * + * The FreeType PostScript info service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVPSINFO_H_ @@ -62,8 +62,6 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_PSINFOREC( class_, \ get_font_info_, \ ps_get_font_extra_, \ @@ -76,29 +74,6 @@ FT_BEGIN_HEADER get_font_private_, get_font_value_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSINFOREC( class_, \ - get_font_info_, \ - ps_get_font_extra_, \ - has_glyph_names_, \ - get_font_private_, \ - get_font_value_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsInfoRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->ps_get_font_info = get_font_info_; \ - clazz->ps_get_font_extra = ps_get_font_extra_; \ - clazz->ps_has_glyph_names = has_glyph_names_; \ - clazz->ps_get_font_private = get_font_private_; \ - clazz->ps_get_font_value = get_font_value_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svsfnt.h b/src/3rdparty/freetype/include/freetype/internal/services/svsfnt.h index e8b37bc47f..464aa209f7 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svsfnt.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svsfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svsfnt.h */ -/* */ -/* The FreeType SFNT table loading service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svsfnt.h + * + * The FreeType SFNT table loading service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVSFNT_H_ @@ -27,7 +27,7 @@ FT_BEGIN_HEADER /* - * SFNT table loading service. + * SFNT table loading service. */ #define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" @@ -70,27 +70,12 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ static const FT_Service_SFNT_TableRec class_ = \ { \ load_, get_, info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_SFNT_TableRec* clazz ) \ - { \ - clazz->load_table = load_; \ - clazz->get_table = get_; \ - clazz->table_info = info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svttcmap.h b/src/3rdparty/freetype/include/freetype/internal/services/svttcmap.h index cd0e6fda6f..0fcb81371d 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svttcmap.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svttcmap.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* svttcmap.h */ -/* */ -/* The FreeType TrueType/sfnt cmap extra information service. */ -/* */ -/* Copyright 2003-2018 by */ -/* Masatake YAMATO, Redhat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svttcmap.h + * + * The FreeType TrueType/sfnt cmap extra information service. + * + * Copyright (C) 2003-2019 by + * Masatake YAMATO, Redhat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* Development of this service is support of Information-technology Promotion Agency, Japan. */ @@ -32,29 +32,28 @@ FT_BEGIN_HEADER #define FT_SERVICE_ID_TT_CMAP "tt-cmaps" - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_CMapInfo */ - /* */ - /* <Description> */ - /* A structure used to store TrueType/sfnt specific cmap information */ - /* which is not covered by the generic @FT_CharMap structure. This */ - /* structure can be accessed with the @FT_Get_TT_CMap_Info function. */ - /* */ - /* <Fields> */ - /* language :: */ - /* The language ID used in Mac fonts. Definitions of values are in */ - /* `ttnameid.h'. */ - /* */ - /* format :: */ - /* The cmap format. OpenType 1.6 defines the formats 0 (byte */ - /* encoding table), 2~(high-byte mapping through table), 4~(segment */ - /* mapping to delta values), 6~(trimmed table mapping), 8~(mixed */ - /* 16-bit and 32-bit coverage), 10~(trimmed array), 12~(segmented */ - /* coverage), 13~(last resort font), and 14 (Unicode Variation */ - /* Sequences). */ - /* */ + /************************************************************************** + * + * @struct: + * TT_CMapInfo + * + * @description: + * A structure used to store TrueType/sfnt specific cmap information + * which is not covered by the generic @FT_CharMap structure. This + * structure can be accessed with the @FT_Get_TT_CMap_Info function. + * + * @fields: + * language :: + * The language ID used in Mac fonts. Definitions of values are in + * `ttnameid.h`. + * + * format :: + * The cmap format. OpenType 1.6 defines the formats 0 (byte encoding + * table), 2~(high-byte mapping through table), 4~(segment mapping to + * delta values), 6~(trimmed table mapping), 8~(mixed 16-bit and 32-bit + * coverage), 10~(trimmed array), 12~(segmented coverage), 13~(last + * resort font), and 14 (Unicode Variation Sequences). + */ typedef struct TT_CMapInfo_ { FT_ULong language; @@ -73,7 +72,6 @@ FT_BEGIN_HEADER TT_CMap_Info_GetFunc get_cmap_info; }; -#ifndef FT_CONFIG_OPTION_PIC #define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ static const FT_Service_TTCMapsRec class_ = \ @@ -81,20 +79,6 @@ FT_BEGIN_HEADER get_cmap_info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_TTCMapsRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_cmap_info = get_cmap_info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svtteng.h b/src/3rdparty/freetype/include/freetype/internal/services/svtteng.h index 92e3c541f5..a852f5c6fb 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svtteng.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svtteng.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svtteng.h */ -/* */ -/* The FreeType TrueType engine query service (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svtteng.h + * + * The FreeType TrueType engine query service (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVTTENG_H_ @@ -27,7 +27,7 @@ FT_BEGIN_HEADER /* - * SFNT table loading service. + * SFNT table loading service. */ #define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svttglyf.h b/src/3rdparty/freetype/include/freetype/internal/services/svttglyf.h index 16fac1ca18..c8798771fb 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svttglyf.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svttglyf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svttglyf.h */ -/* */ -/* The FreeType TrueType glyph service. */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svttglyf.h + * + * The FreeType TrueType glyph service. + * + * Copyright (C) 2007-2019 by + * David Turner. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVTTGLYF_H_ #define SVTTGLYF_H_ @@ -39,25 +39,12 @@ FT_BEGIN_HEADER }; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ static const FT_Service_TTGlyfRec class_ = \ { \ get_location_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_TTGlyfRec* clazz ) \ - { \ - clazz->get_location = get_location_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - /* */ diff --git a/src/3rdparty/freetype/include/freetype/internal/services/svwinfnt.h b/src/3rdparty/freetype/include/freetype/internal/services/svwinfnt.h index 80d481cbd1..38ee020965 100644 --- a/src/3rdparty/freetype/include/freetype/internal/services/svwinfnt.h +++ b/src/3rdparty/freetype/include/freetype/internal/services/svwinfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* svwinfnt.h */ -/* */ -/* The FreeType Windows FNT/FONT service (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * svwinfnt.h + * + * The FreeType Windows FNT/FONT service (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SVWINFNT_H_ diff --git a/src/3rdparty/freetype/include/freetype/internal/sfnt.h b/src/3rdparty/freetype/include/freetype/internal/sfnt.h index fb1e327aeb..b19241c306 100644 --- a/src/3rdparty/freetype/include/freetype/internal/sfnt.h +++ b/src/3rdparty/freetype/include/freetype/internal/sfnt.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfnt.h */ -/* */ -/* High-level `sfnt' driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfnt.h + * + * High-level 'sfnt' driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SFNT_H_ @@ -23,48 +23,52 @@ #include <ft2build.h> #include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_TRUETYPE_TYPES_H +#include FT_INTERNAL_WOFF_TYPES_H FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Init_Face_Func */ - /* */ - /* <Description> */ - /* First part of the SFNT face object initialization. This finds */ - /* the face in a SFNT file or collection, and load its format tag in */ - /* face->format_tag. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection, in bits 0-15. The numbered instance */ - /* index~+~1 of a GX (sub)font, if applicable, in bits */ - /* 16-30. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ - /* This function recognizes fonts embedded in a `TrueType */ - /* collection'. */ - /* */ - /* Once the format tag has been validated by the font driver, it */ - /* should then call the TT_Load_Face_Func() callback to read the rest */ - /* of the SFNT tables in the object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Init_Face_Func + * + * @description: + * First part of the SFNT face object initialization. This finds the + * face in a SFNT file or collection, and load its format tag in + * face->format_tag. + * + * @input: + * stream :: + * The input stream. + * + * face :: + * A handle to the target face object. + * + * face_index :: + * The index of the TrueType font, if we are opening a collection, in + * bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if + * applicable, in bits 16-30. + * + * num_params :: + * The number of additional parameters. + * + * params :: + * Optional additional parameters. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The stream cursor must be at the font file's origin. + * + * This function recognizes fonts embedded in a 'TrueType collection'. + * + * Once the format tag has been validated by the font driver, it should + * then call the TT_Load_Face_Func() callback to read the rest of the + * SFNT tables in the object. + */ typedef FT_Error (*TT_Init_Face_Func)( FT_Stream stream, TT_Face face, @@ -73,36 +77,40 @@ FT_BEGIN_HEADER FT_Parameter* params ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Face_Func */ - /* */ - /* <Description> */ - /* Second part of the SFNT face object initialization. This loads */ - /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */ - /* face object. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection, in bits 0-15. The numbered instance */ - /* index~+~1 of a GX (sub)font, if applicable, in bits */ - /* 16-30. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function must be called after TT_Init_Face_Func(). */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Face_Func + * + * @description: + * Second part of the SFNT face object initialization. This loads the + * common SFNT tables (head, OS/2, maxp, metrics, etc.) in the face + * object. + * + * @input: + * stream :: + * The input stream. + * + * face :: + * A handle to the target face object. + * + * face_index :: + * The index of the TrueType font, if we are opening a collection, in + * bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if + * applicable, in bits 16-30. + * + * num_params :: + * The number of additional parameters. + * + * params :: + * Optional additional parameters. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function must be called after TT_Init_Face_Func(). + */ typedef FT_Error (*TT_Load_Face_Func)( FT_Stream stream, TT_Face face, @@ -111,64 +119,64 @@ FT_BEGIN_HEADER FT_Parameter* params ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Done_Face_Func */ - /* */ - /* <Description> */ - /* A callback used to delete the common SFNT data from a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Note> */ - /* This function does NOT destroy the face object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Done_Face_Func + * + * @description: + * A callback used to delete the common SFNT data from a face. + * + * @input: + * face :: + * A handle to the target face object. + * + * @note: + * This function does NOT destroy the face object. + */ typedef void (*TT_Done_Face_Func)( TT_Face face ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Any_Func */ - /* */ - /* <Description> */ - /* Load any font table into client memory. */ - /* */ - /* <Input> */ - /* face :: The face object to look for. */ - /* */ - /* tag :: The tag of table to load. Use the value 0 if you want */ - /* to access the whole font file, else set this parameter */ - /* to a valid TrueType table tag that you can forge with */ - /* the MAKE_TT_TAG macro. */ - /* */ - /* offset :: The starting offset in the table (or the file if */ - /* tag == 0). */ - /* */ - /* length :: The address of the decision variable: */ - /* */ - /* If length == NULL: */ - /* Loads the whole table. Returns an error if */ - /* `offset' == 0! */ - /* */ - /* If *length == 0: */ - /* Exits immediately; returning the length of the given */ - /* table or of the font file, depending on the value of */ - /* `tag'. */ - /* */ - /* If *length != 0: */ - /* Loads the next `length' bytes of table or font, */ - /* starting at offset `offset' (in table or font too). */ - /* */ - /* <Output> */ - /* buffer :: The address of target buffer. */ - /* */ - /* <Return> */ - /* TrueType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Any_Func + * + * @description: + * Load any font table into client memory. + * + * @input: + * face :: + * The face object to look for. + * + * tag :: + * The tag of table to load. Use the value 0 if you want to access the + * whole font file, else set this parameter to a valid TrueType table + * tag that you can forge with the MAKE_TT_TAG macro. + * + * offset :: + * The starting offset in the table (or the file if tag == 0). + * + * length :: + * The address of the decision variable: + * + * If `length == NULL`: Loads the whole table. Returns an error if + * 'offset' == 0! + * + * If `*length == 0`: Exits immediately; returning the length of the + * given table or of the font file, depending on the value of 'tag'. + * + * If `*length != 0`: Loads the next 'length' bytes of table or font, + * starting at offset 'offset' (in table or font too). + * + * @output: + * buffer :: + * The address of target buffer. + * + * @return: + * TrueType error code. 0 means success. + */ typedef FT_Error (*TT_Load_Any_Func)( TT_Face face, FT_ULong tag, @@ -177,34 +185,39 @@ FT_BEGIN_HEADER FT_ULong* length ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Find_SBit_Image_Func */ - /* */ - /* <Description> */ - /* Check whether an embedded bitmap (an `sbit') exists for a given */ - /* glyph, at a given strike. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* strike_index :: The current strike index. */ - /* */ - /* <Output> */ - /* arange :: The SBit range containing the glyph index. */ - /* */ - /* astrike :: The SBit strike containing the glyph index. */ - /* */ - /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns */ - /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */ - /* glyph. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Find_SBit_Image_Func + * + * @description: + * Check whether an embedded bitmap (an 'sbit') exists for a given glyph, + * at a given strike. + * + * @input: + * face :: + * The target face object. + * + * glyph_index :: + * The glyph index. + * + * strike_index :: + * The current strike index. + * + * @output: + * arange :: + * The SBit range containing the glyph index. + * + * astrike :: + * The SBit strike containing the glyph index. + * + * aglyph_offset :: + * The offset of the glyph data in 'EBDT' table. + * + * @return: + * FreeType error code. 0 means success. Returns + * SFNT_Err_Invalid_Argument if no sbit exists for the requested glyph. + */ typedef FT_Error (*TT_Find_SBit_Image_Func)( TT_Face face, FT_UInt glyph_index, @@ -214,78 +227,81 @@ FT_BEGIN_HEADER FT_ULong *aglyph_offset ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_SBit_Metrics_Func */ - /* */ - /* <Description> */ - /* Get the big metrics for a given embedded bitmap. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* range :: The SBit range containing the glyph. */ - /* */ - /* <Output> */ - /* big_metrics :: A big SBit metrics structure for the glyph. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be positioned at the glyph's offset within */ - /* the `EBDT' table before the call. */ - /* */ - /* If the image format uses variable metrics, the stream cursor is */ - /* positioned just after the metrics header in the `EBDT' table on */ - /* function exit. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_SBit_Metrics_Func + * + * @description: + * Get the big metrics for a given embedded bitmap. + * + * @input: + * stream :: + * The input stream. + * + * range :: + * The SBit range containing the glyph. + * + * @output: + * big_metrics :: + * A big SBit metrics structure for the glyph. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The stream cursor must be positioned at the glyph's offset within the + * 'EBDT' table before the call. + * + * If the image format uses variable metrics, the stream cursor is + * positioned just after the metrics header in the 'EBDT' table on + * function exit. + */ typedef FT_Error (*TT_Load_SBit_Metrics_Func)( FT_Stream stream, TT_SBit_Range range, TT_SBit_Metrics metrics ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_SBit_Image_Func */ - /* */ - /* <Description> */ - /* Load a given glyph sbit image from the font resource. This also */ - /* returns its metrics. */ - /* */ - /* <Input> */ - /* face :: */ - /* The target face object. */ - /* */ - /* strike_index :: */ - /* The strike index. */ - /* */ - /* glyph_index :: */ - /* The current glyph index. */ - /* */ - /* load_flags :: */ - /* The current load flags. */ - /* */ - /* stream :: */ - /* The input stream. */ - /* */ - /* <Output> */ - /* amap :: */ - /* The target pixmap. */ - /* */ - /* ametrics :: */ - /* A big sbit metrics structure for the glyph image. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* glyph sbit exists for the index. */ - /* */ - /* <Note> */ - /* The `map.buffer' field is always freed before the glyph is loaded. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_SBit_Image_Func + * + * @description: + * Load a given glyph sbit image from the font resource. This also + * returns its metrics. + * + * @input: + * face :: + * The target face object. + * + * strike_index :: + * The strike index. + * + * glyph_index :: + * The current glyph index. + * + * load_flags :: + * The current load flags. + * + * stream :: + * The input stream. + * + * @output: + * amap :: + * The target pixmap. + * + * ametrics :: + * A big sbit metrics structure for the glyph image. + * + * @return: + * FreeType error code. 0 means success. Returns an error if no glyph + * sbit exists for the index. + * + * @note: + * The `map.buffer` field is always freed before the glyph is loaded. + */ typedef FT_Error (*TT_Load_SBit_Image_Func)( TT_Face face, FT_ULong strike_index, @@ -296,130 +312,144 @@ FT_BEGIN_HEADER TT_SBit_MetricsRec *ametrics ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Set_SBit_Strike_Func */ - /* */ - /* <Description> */ - /* Select an sbit strike for a given size request. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* req :: The size request. */ - /* */ - /* <Output> */ - /* astrike_index :: The index of the sbit strike. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* sbit strike exists for the selected ppem values. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Set_SBit_Strike_Func + * + * @description: + * Select an sbit strike for a given size request. + * + * @input: + * face :: + * The target face object. + * + * req :: + * The size request. + * + * @output: + * astrike_index :: + * The index of the sbit strike. + * + * @return: + * FreeType error code. 0 means success. Returns an error if no sbit + * strike exists for the selected ppem values. + */ typedef FT_Error (*TT_Set_SBit_Strike_Func)( TT_Face face, FT_Size_Request req, FT_ULong* astrike_index ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Strike_Metrics_Func */ - /* */ - /* <Description> */ - /* Load the metrics of a given strike. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* strike_index :: The strike index. */ - /* */ - /* <Output> */ - /* metrics :: the metrics of the strike. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* such sbit strike exists. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Strike_Metrics_Func + * + * @description: + * Load the metrics of a given strike. + * + * @input: + * face :: + * The target face object. + * + * strike_index :: + * The strike index. + * + * @output: + * metrics :: + * the metrics of the strike. + * + * @return: + * FreeType error code. 0 means success. Returns an error if no such + * sbit strike exists. + */ typedef FT_Error (*TT_Load_Strike_Metrics_Func)( TT_Face face, FT_ULong strike_index, FT_Size_Metrics* metrics ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_PS_Name_Func */ - /* */ - /* <Description> */ - /* Get the PostScript glyph name of a glyph. */ - /* */ - /* <Input> */ - /* idx :: The glyph index. */ - /* */ - /* PSname :: The address of a string pointer. Will be NULL in case */ - /* of error, otherwise it is a pointer to the glyph name. */ - /* */ - /* You must not modify the returned string! */ - /* */ - /* <Output> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Get_PS_Name_Func + * + * @description: + * Get the PostScript glyph name of a glyph. + * + * @input: + * idx :: + * The glyph index. + * + * PSname :: + * The address of a string pointer. Will be `NULL` in case of error, + * otherwise it is a pointer to the glyph name. + * + * You must not modify the returned string! + * + * @output: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Get_PS_Name_Func)( TT_Face face, FT_UInt idx, FT_String** PSname ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Metrics_Func */ - /* */ - /* <Description> */ - /* Load a metrics table, which is a table with a horizontal and a */ - /* vertical version. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load the vertical one. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Metrics_Func + * + * @description: + * Load a metrics table, which is a table with a horizontal and a + * vertical version. + * + * @input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * vertical :: + * A boolean flag. If set, load the vertical one. + * + * @return: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Load_Metrics_Func)( TT_Face face, FT_Stream stream, FT_Bool vertical ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Metrics_Func */ - /* */ - /* <Description> */ - /* Load the horizontal or vertical header in a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* abearing :: The horizontal (or vertical) bearing. Set to zero in */ - /* case of error. */ - /* */ - /* aadvance :: The horizontal (or vertical) advance. Set to zero in */ - /* case of error. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Get_Metrics_Func + * + * @description: + * Load the horizontal or vertical header in a face object. + * + * @input: + * face :: + * A handle to the target face object. + * + * vertical :: + * A boolean flag. If set, load vertical metrics. + * + * gindex :: + * The glyph index. + * + * @output: + * abearing :: + * The horizontal (or vertical) bearing. Set to zero in case of error. + * + * aadvance :: + * The horizontal (or vertical) advance. Set to zero in case of error. + */ typedef void (*TT_Get_Metrics_Func)( TT_Face face, FT_Bool vertical, @@ -428,57 +458,168 @@ FT_BEGIN_HEADER FT_UShort* aadvance ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Name_Func */ - /* */ - /* <Description> */ - /* From the `name' table, return a given ENGLISH name record in */ - /* ASCII. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* nameid :: The name id of the name record to return. */ - /* */ - /* <InOut> */ - /* name :: The address of an allocated string pointer. NULL if */ - /* no name is present. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Set_Palette_Func + * + * @description: + * Load the colors into `face->palette` for a given palette index. + * + * @input: + * face :: + * The target face object. + * + * idx :: + * The palette index. + * + * @return: + * FreeType error code. 0 means success. + */ + typedef FT_Error + (*TT_Set_Palette_Func)( TT_Face face, + FT_UInt idx ); + + + /************************************************************************** + * + * @functype: + * TT_Get_Colr_Layer_Func + * + * @description: + * Iteratively get the color layer data of a given glyph index. + * + * @input: + * face :: + * The target face object. + * + * base_glyph :: + * The glyph index the colored glyph layers are associated with. + * + * @inout: + * iterator :: + * An @FT_LayerIterator object. For the first call you should set + * `iterator->p` to `NULL`. For all following calls, simply use the + * same object again. + * + * @output: + * aglyph_index :: + * The glyph index of the current layer. + * + * acolor_index :: + * The color index into the font face's color palette of the current + * layer. The value 0xFFFF is special; it doesn't reference a palette + * entry but indicates that the text foreground color should be used + * instead (to be set up by the application outside of FreeType). + * + * @return: + * Value~1 if everything is OK. If there are no more layers (or if there + * are no layers at all), value~0 gets returned. In case of an error, + * value~0 is returned also. + */ + typedef FT_Bool + (*TT_Get_Colr_Layer_Func)( TT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); + + + /************************************************************************** + * + * @functype: + * TT_Blend_Colr_Func + * + * @description: + * Blend the bitmap in `new_glyph` into `base_glyph` using the color + * specified by `color_index`. If `color_index` is 0xFFFF, use + * `face->foreground_color` if `face->have_foreground_color` is set. + * Otherwise check `face->palette_data.palette_flags`: If present and + * @FT_PALETTE_FOR_DARK_BACKGROUND is set, use BGRA value 0xFFFFFFFF + * (white opaque). Otherwise use BGRA value 0x000000FF (black opaque). + * + * @input: + * face :: + * The target face object. + * + * color_index :: + * Color index from the COLR table. + * + * base_glyph :: + * Slot for bitmap to be merged into. The underlying bitmap may get + * reallocated. + * + * new_glyph :: + * Slot to be incooperated into `base_glyph`. + * + * @return: + * FreeType error code. 0 means success. Returns an error if + * color_index is invalid or reallocation fails. + */ + typedef FT_Error + (*TT_Blend_Colr_Func)( TT_Face face, + FT_UInt color_index, + FT_GlyphSlot base_glyph, + FT_GlyphSlot new_glyph ); + + + /************************************************************************** + * + * @functype: + * TT_Get_Name_Func + * + * @description: + * From the 'name' table, return a given ENGLISH name record in ASCII. + * + * @input: + * face :: + * A handle to the source face object. + * + * nameid :: + * The name id of the name record to return. + * + * @inout: + * name :: + * The address of an allocated string pointer. `NULL` if no name is + * present. + * + * @return: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Get_Name_Func)( TT_Face face, FT_UShort nameid, FT_String** name ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Name_ID_Func */ - /* */ - /* <Description> */ - /* Search whether an ENGLISH version for a given name ID is in the */ - /* `name' table. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* nameid :: The name id of the name record to return. */ - /* */ - /* <Out> */ - /* win :: If non-negative, an index into the `name' table with */ - /* the corresponding (3,1) or (3,0) Windows entry. */ - /* */ - /* apple :: If non-negative, an index into the `name' table with */ - /* the corresponding (1,0) Apple entry. */ - /* */ - /* <Return> */ - /* 1 if there is either a win or apple entry (or both), 0 otheriwse. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Get_Name_ID_Func + * + * @description: + * Search whether an ENGLISH version for a given name ID is in the 'name' + * table. + * + * @input: + * face :: + * A handle to the source face object. + * + * nameid :: + * The name id of the name record to return. + * + * @output: + * win :: + * If non-negative, an index into the 'name' table with the + * corresponding (3,1) or (3,0) Windows entry. + * + * apple :: + * If non-negative, an index into the 'name' table with the + * corresponding (1,0) Apple entry. + * + * @return: + * 1 if there is either a win or apple entry (or both), 0 otheriwse. + */ typedef FT_Bool (*TT_Get_Name_ID_Func)( TT_Face face, FT_UShort nameid, @@ -486,42 +627,45 @@ FT_BEGIN_HEADER FT_Int *apple ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Table_Func */ - /* */ - /* <Description> */ - /* Load a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The function uses `face->goto_table' to seek the stream to the */ - /* start of the table, except while loading the font directory. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Load_Table_Func + * + * @description: + * Load a given TrueType table. + * + * @input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The function uses `face->goto_table` to seek the stream to the start + * of the table, except while loading the font directory. + */ typedef FT_Error (*TT_Load_Table_Func)( TT_Face face, FT_Stream stream ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Free_Table_Func */ - /* */ - /* <Description> */ - /* Free a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Free_Table_Func + * + * @description: + * Free a given TrueType table. + * + * @input: + * face :: + * A handle to the target face object. + */ typedef void (*TT_Free_Table_Func)( TT_Face face ); @@ -534,9 +678,14 @@ FT_BEGIN_HEADER * Return the horizontal kerning value between two glyphs. * * @input: - * face :: A handle to the source face object. - * left_glyph :: The left glyph index. - * right_glyph :: The right glyph index. + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The left glyph index. + * + * right_glyph :: + * The right glyph index. * * @return: * The kerning value in font units. @@ -547,18 +696,18 @@ FT_BEGIN_HEADER FT_UInt right_glyph ); - /*************************************************************************/ - /* */ - /* <Struct> */ - /* SFNT_Interface */ - /* */ - /* <Description> */ - /* This structure holds pointers to the functions used to load and */ - /* free the basic tables that are required in a `sfnt' font file. */ - /* */ - /* <Fields> */ - /* Check the various xxx_Func() descriptions for details. */ - /* */ + /************************************************************************** + * + * @struct: + * SFNT_Interface + * + * @description: + * This structure holds pointers to the functions used to load and free + * the basic tables that are required in a 'sfnt' font file. + * + * @fields: + * Check the various xxx_Func() descriptions for details. + */ typedef struct SFNT_Interface_ { TT_Loader_GotoTableFunc goto_table; @@ -616,6 +765,14 @@ FT_BEGIN_HEADER TT_Set_SBit_Strike_Func set_sbit_strike; TT_Load_Strike_Metrics_Func load_strike_metrics; + TT_Load_Table_Func load_cpal; + TT_Load_Table_Func load_colr; + TT_Free_Table_Func free_cpal; + TT_Free_Table_Func free_colr; + TT_Set_Palette_Func set_palette; + TT_Get_Colr_Layer_Func get_colr_layer; + TT_Blend_Colr_Func colr_blend; + TT_Get_Metrics_Func get_metrics; TT_Get_Name_Func get_name; @@ -627,7 +784,6 @@ FT_BEGIN_HEADER /* transitional */ typedef SFNT_Interface* SFNT_Service; -#ifndef FT_CONFIG_OPTION_PIC #define FT_DEFINE_SFNT_INTERFACE( \ class_, \ @@ -659,6 +815,13 @@ FT_BEGIN_HEADER free_eblc_, \ set_sbit_strike_, \ load_strike_metrics_, \ + load_cpal_, \ + load_colr_, \ + free_cpal_, \ + free_colr_, \ + set_palette_, \ + get_colr_layer_, \ + colr_blend_, \ get_metrics_, \ get_name_, \ get_name_id_ ) \ @@ -692,89 +855,18 @@ FT_BEGIN_HEADER free_eblc_, \ set_sbit_strike_, \ load_strike_metrics_, \ + load_cpal_, \ + load_colr_, \ + free_cpal_, \ + free_colr_, \ + set_palette_, \ + get_colr_layer_, \ + colr_blend_, \ get_metrics_, \ get_name_, \ get_name_id_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_INTERNAL( a, a_ ) \ - clazz->a = a_; - -#define FT_DEFINE_SFNT_INTERFACE( \ - class_, \ - goto_table_, \ - init_face_, \ - load_face_, \ - done_face_, \ - get_interface_, \ - load_any_, \ - load_head_, \ - load_hhea_, \ - load_cmap_, \ - load_maxp_, \ - load_os2_, \ - load_post_, \ - load_name_, \ - free_name_, \ - load_kern_, \ - load_gasp_, \ - load_pclt_, \ - load_bhed_, \ - load_sbit_image_, \ - get_psname_, \ - free_psnames_, \ - get_kerning_, \ - load_font_dir_, \ - load_hmtx_, \ - load_eblc_, \ - free_eblc_, \ - set_sbit_strike_, \ - load_strike_metrics_, \ - get_metrics_, \ - get_name_, \ - get_name_id_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - SFNT_Interface* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->goto_table = goto_table_; \ - clazz->init_face = init_face_; \ - clazz->load_face = load_face_; \ - clazz->done_face = done_face_; \ - clazz->get_interface = get_interface_; \ - clazz->load_any = load_any_; \ - clazz->load_head = load_head_; \ - clazz->load_hhea = load_hhea_; \ - clazz->load_cmap = load_cmap_; \ - clazz->load_maxp = load_maxp_; \ - clazz->load_os2 = load_os2_; \ - clazz->load_post = load_post_; \ - clazz->load_name = load_name_; \ - clazz->free_name = free_name_; \ - clazz->load_kern = load_kern_; \ - clazz->load_gasp = load_gasp_; \ - clazz->load_pclt = load_pclt_; \ - clazz->load_bhed = load_bhed_; \ - clazz->load_sbit_image = load_sbit_image_; \ - clazz->get_psname = get_psname_; \ - clazz->free_psnames = free_psnames_; \ - clazz->get_kerning = get_kerning_; \ - clazz->load_font_dir = load_font_dir_; \ - clazz->load_hmtx = load_hmtx_; \ - clazz->load_eblc = load_eblc_; \ - clazz->free_eblc = free_eblc_; \ - clazz->set_sbit_strike = set_sbit_strike_; \ - clazz->load_strike_metrics = load_strike_metrics_; \ - clazz->get_metrics = get_metrics_; \ - clazz->get_name = get_name_; \ - clazz->get_name_id = get_name_id_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ FT_END_HEADER diff --git a/src/3rdparty/freetype/include/freetype/internal/t1types.h b/src/3rdparty/freetype/include/freetype/internal/t1types.h index 2118e33674..d94c8c1284 100644 --- a/src/3rdparty/freetype/include/freetype/internal/t1types.h +++ b/src/3rdparty/freetype/include/freetype/internal/t1types.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* t1types.h */ -/* */ -/* Basic Type1/Type2 type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1types.h + * + * Basic Type1/Type2 type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1TYPES_H_ @@ -45,36 +45,39 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_EncodingRec */ - /* */ - /* <Description> */ - /* A structure modeling a custom encoding. */ - /* */ - /* <Fields> */ - /* num_chars :: The number of character codes in the encoding. */ - /* Usually 256. */ - /* */ - /* code_first :: The lowest valid character code in the encoding. */ - /* */ - /* code_last :: The highest valid character code in the encoding */ - /* + 1. When equal to code_first there are no valid */ - /* character codes. */ - /* */ - /* char_index :: An array of corresponding glyph indices. */ - /* */ - /* char_name :: An array of corresponding glyph names. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_EncodingRec + * + * @description: + * A structure modeling a custom encoding. + * + * @fields: + * num_chars :: + * The number of character codes in the encoding. Usually 256. + * + * code_first :: + * The lowest valid character code in the encoding. + * + * code_last :: + * The highest valid character code in the encoding + 1. When equal to + * code_first there are no valid character codes. + * + * char_index :: + * An array of corresponding glyph indices. + * + * char_name :: + * An array of corresponding glyph names. + */ typedef struct T1_EncodingRecRec_ { FT_Int num_chars; FT_Int code_first; FT_Int code_last; - FT_UShort* char_index; - FT_String** char_name; + FT_UShort* char_index; + const FT_String** char_name; } T1_EncodingRec, *T1_Encoding; diff --git a/src/3rdparty/freetype/include/freetype/internal/tttypes.h b/src/3rdparty/freetype/include/freetype/internal/tttypes.h index 10dd336a89..23db240e7c 100644 --- a/src/3rdparty/freetype/include/freetype/internal/tttypes.h +++ b/src/3rdparty/freetype/include/freetype/internal/tttypes.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* tttypes.h */ -/* */ -/* Basic SFNT/TrueType type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * tttypes.h + * + * Basic SFNT/TrueType type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTTYPES_H_ @@ -24,6 +24,7 @@ #include <ft2build.h> #include FT_TRUETYPE_TABLES_H #include FT_INTERNAL_OBJECTS_H +#include FT_COLOR_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H @@ -46,27 +47,30 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TTC_HeaderRec */ - /* */ - /* <Description> */ - /* TrueType collection header. This table contains the offsets of */ - /* the font headers of each distinct TrueType face in the file. */ - /* */ - /* <Fields> */ - /* tag :: Must be `ttc ' to indicate a TrueType collection. */ - /* */ - /* version :: The version number. */ - /* */ - /* count :: The number of faces in the collection. The */ - /* specification says this should be an unsigned long, but */ - /* we use a signed long since we need the value -1 for */ - /* specific purposes. */ - /* */ - /* offsets :: The offsets of the font headers, one per face. */ - /* */ + /************************************************************************** + * + * @struct: + * TTC_HeaderRec + * + * @description: + * TrueType collection header. This table contains the offsets of the + * font headers of each distinct TrueType face in the file. + * + * @fields: + * tag :: + * Must be 'ttc~' to indicate a TrueType collection. + * + * version :: + * The version number. + * + * count :: + * The number of faces in the collection. The specification says this + * should be an unsigned long, but we use a signed long since we need + * the value -1 for specific purposes. + * + * offsets :: + * The offsets of the font headers, one per face. + */ typedef struct TTC_HeaderRec_ { FT_ULong tag; @@ -77,25 +81,30 @@ FT_BEGIN_HEADER } TTC_HeaderRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* SFNT_HeaderRec */ - /* */ - /* <Description> */ - /* SFNT file format header. */ - /* */ - /* <Fields> */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of tables in file. */ - /* */ - /* search_range :: Must be `16 * (max power of 2 <= num_tables)'. */ - /* */ - /* entry_selector :: Must be log2 of `search_range / 16'. */ - /* */ - /* range_shift :: Must be `num_tables * 16 - search_range'. */ - /* */ + /************************************************************************** + * + * @struct: + * SFNT_HeaderRec + * + * @description: + * SFNT file format header. + * + * @fields: + * format_tag :: + * The font format tag. + * + * num_tables :: + * The number of tables in file. + * + * search_range :: + * Must be '16 * (max power of 2 <= num_tables)'. + * + * entry_selector :: + * Must be log2 of 'search_range / 16'. + * + * range_shift :: + * Must be 'num_tables * 16 - search_range'. + */ typedef struct SFNT_HeaderRec_ { FT_ULong format_tag; @@ -109,24 +118,28 @@ FT_BEGIN_HEADER } SFNT_HeaderRec, *SFNT_Header; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_TableRec */ - /* */ - /* <Description> */ - /* This structure describes a given table of a TrueType font. */ - /* */ - /* <Fields> */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* Offset :: The offset of the table from the start of the TrueType */ - /* font in its resource. */ - /* */ - /* Length :: The table length (in bytes). */ - /* */ + /************************************************************************** + * + * @struct: + * TT_TableRec + * + * @description: + * This structure describes a given table of a TrueType font. + * + * @fields: + * Tag :: + * A four-bytes tag describing the table. + * + * CheckSum :: + * The table checksum. This value can be ignored. + * + * Offset :: + * The offset of the table from the start of the TrueType font in its + * resource. + * + * Length :: + * The table length (in bytes). + */ typedef struct TT_TableRec_ { FT_ULong Tag; /* table type */ @@ -137,89 +150,22 @@ FT_BEGIN_HEADER } TT_TableRec, *TT_Table; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* WOFF_HeaderRec */ - /* */ - /* <Description> */ - /* WOFF file format header. */ - /* */ - /* <Fields> */ - /* See */ - /* */ - /* https://www.w3.org/TR/WOFF/#WOFFHeader */ - /* */ - typedef struct WOFF_HeaderRec_ - { - FT_ULong signature; - FT_ULong flavor; - FT_ULong length; - FT_UShort num_tables; - FT_UShort reserved; - FT_ULong totalSfntSize; - FT_UShort majorVersion; - FT_UShort minorVersion; - FT_ULong metaOffset; - FT_ULong metaLength; - FT_ULong metaOrigLength; - FT_ULong privOffset; - FT_ULong privLength; - - } WOFF_HeaderRec, *WOFF_Header; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* WOFF_TableRec */ - /* */ - /* <Description> */ - /* This structure describes a given table of a WOFF font. */ - /* */ - /* <Fields> */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* Offset :: The offset of the table from the start of the WOFF */ - /* font in its resource. */ - /* */ - /* CompLength :: Compressed table length (in bytes). */ - /* */ - /* OrigLength :: Uncompressed table length (in bytes). */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* OrigOffset :: The uncompressed table file offset. This value gets */ - /* computed while constructing the (uncompressed) SFNT */ - /* header. It is not contained in the WOFF file. */ - /* */ - typedef struct WOFF_TableRec_ - { - FT_ULong Tag; /* table ID */ - FT_ULong Offset; /* table file offset */ - FT_ULong CompLength; /* compressed table length */ - FT_ULong OrigLength; /* uncompressed table length */ - FT_ULong CheckSum; /* uncompressed checksum */ - - FT_ULong OrigOffset; /* uncompressed table file offset */ - /* (not in the WOFF file) */ - } WOFF_TableRec, *WOFF_Table; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_LongMetricsRec */ - /* */ - /* <Description> */ - /* A structure modeling the long metrics of the `hmtx' and `vmtx' */ - /* TrueType tables. The values are expressed in font units. */ - /* */ - /* <Fields> */ - /* advance :: The advance width or height for the glyph. */ - /* */ - /* bearing :: The left-side or top-side bearing for the glyph. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_LongMetricsRec + * + * @description: + * A structure modeling the long metrics of the 'hmtx' and 'vmtx' + * TrueType tables. The values are expressed in font units. + * + * @fields: + * advance :: + * The advance width or height for the glyph. + * + * bearing :: + * The left-side or top-side bearing for the glyph. + */ typedef struct TT_LongMetricsRec_ { FT_UShort advance; @@ -228,45 +174,51 @@ FT_BEGIN_HEADER } TT_LongMetricsRec, *TT_LongMetrics; - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_ShortMetrics */ - /* */ - /* <Description> */ - /* A simple type to model the short metrics of the `hmtx' and `vmtx' */ - /* tables. */ - /* */ + /************************************************************************** + * + * @type: + * TT_ShortMetrics + * + * @description: + * A simple type to model the short metrics of the 'hmtx' and 'vmtx' + * tables. + */ typedef FT_Short TT_ShortMetrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_NameRec */ - /* */ - /* <Description> */ - /* A structure modeling TrueType name records. Name records are used */ - /* to store important strings like family name, style name, */ - /* copyright, etc. in _localized_ versions (i.e., language, encoding, */ - /* etc). */ - /* */ - /* <Fields> */ - /* platformID :: The ID of the name's encoding platform. */ - /* */ - /* encodingID :: The platform-specific ID for the name's encoding. */ - /* */ - /* languageID :: The platform-specific ID for the name's language. */ - /* */ - /* nameID :: The ID specifying what kind of name this is. */ - /* */ - /* stringLength :: The length of the string in bytes. */ - /* */ - /* stringOffset :: The offset to the string in the `name' table. */ - /* */ - /* string :: A pointer to the string's bytes. Note that these */ - /* are usually UTF-16 encoded characters. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_NameRec + * + * @description: + * A structure modeling TrueType name records. Name records are used to + * store important strings like family name, style name, copyright, + * etc. in _localized_ versions (i.e., language, encoding, etc). + * + * @fields: + * platformID :: + * The ID of the name's encoding platform. + * + * encodingID :: + * The platform-specific ID for the name's encoding. + * + * languageID :: + * The platform-specific ID for the name's language. + * + * nameID :: + * The ID specifying what kind of name this is. + * + * stringLength :: + * The length of the string in bytes. + * + * stringOffset :: + * The offset to the string in the 'name' table. + * + * string :: + * A pointer to the string's bytes. Note that these are usually UTF-16 + * encoded characters. + */ typedef struct TT_NameRec_ { FT_UShort platformID; @@ -284,23 +236,26 @@ FT_BEGIN_HEADER } TT_NameRec, *TT_Name; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_LangTagRec */ - /* */ - /* <Description> */ - /* A structure modeling language tag records in SFNT `name' tables, */ - /* introduced in OpenType version 1.6. */ - /* */ - /* <Fields> */ - /* stringLength :: The length of the string in bytes. */ - /* */ - /* stringOffset :: The offset to the string in the `name' table. */ - /* */ - /* string :: A pointer to the string's bytes. Note that these */ - /* are UTF-16BE encoded characters. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_LangTagRec + * + * @description: + * A structure modeling language tag records in SFNT 'name' tables, + * introduced in OpenType version 1.6. + * + * @fields: + * stringLength :: + * The length of the string in bytes. + * + * stringOffset :: + * The offset to the string in the 'name' table. + * + * string :: + * A pointer to the string's bytes. Note that these are UTF-16BE + * encoded characters. + */ typedef struct TT_LangTagRec_ { FT_UShort stringLength; @@ -314,30 +269,36 @@ FT_BEGIN_HEADER } TT_LangTagRec, *TT_LangTag; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_NameTableRec */ - /* */ - /* <Description> */ - /* A structure modeling the TrueType name table. */ - /* */ - /* <Fields> */ - /* format :: The format of the name table. */ - /* */ - /* numNameRecords :: The number of names in table. */ - /* */ - /* storageOffset :: The offset of the name table in the `name' */ - /* TrueType table. */ - /* */ - /* names :: An array of name records. */ - /* */ - /* numLangTagRecords :: The number of language tags in table. */ - /* */ - /* langTags :: An array of language tag records. */ - /* */ - /* stream :: The file's input stream. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_NameTableRec + * + * @description: + * A structure modeling the TrueType name table. + * + * @fields: + * format :: + * The format of the name table. + * + * numNameRecords :: + * The number of names in table. + * + * storageOffset :: + * The offset of the name table in the 'name' TrueType table. + * + * names :: + * An array of name records. + * + * numLangTagRecords :: + * The number of language tags in table. + * + * langTags :: + * An array of language tag records. + * + * stream :: + * The file's input stream. + */ typedef struct TT_NameTableRec_ { FT_UShort format; @@ -364,21 +325,23 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GaspRangeRec */ - /* */ - /* <Description> */ - /* A tiny structure used to model a gasp range according to the */ - /* TrueType specification. */ - /* */ - /* <Fields> */ - /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */ - /* */ - /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */ - /* modes to be used. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_GaspRangeRec + * + * @description: + * A tiny structure used to model a gasp range according to the TrueType + * specification. + * + * @fields: + * maxPPEM :: + * The maximum ppem value to which `gaspFlag` applies. + * + * gaspFlag :: + * A flag describing the grid-fitting and anti-aliasing modes to be + * used. + */ typedef struct TT_GaspRangeRec_ { FT_UShort maxPPEM; @@ -391,22 +354,25 @@ FT_BEGIN_HEADER #define TT_GASP_DOGRAY 0x02 - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GaspRec */ - /* */ - /* <Description> */ - /* A structure modeling the TrueType `gasp' table used to specify */ - /* grid-fitting and anti-aliasing behaviour. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numRanges :: The number of gasp ranges in table. */ - /* */ - /* gaspRanges :: An array of gasp ranges. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_GaspRec + * + * @description: + * A structure modeling the TrueType 'gasp' table used to specify + * grid-fitting and anti-aliasing behaviour. + * + * @fields: + * version :: + * The version number. + * + * numRanges :: + * The number of gasp ranges in table. + * + * gaspRanges :: + * An array of gasp ranges. + */ typedef struct TT_Gasp_ { FT_UShort version; @@ -429,33 +395,41 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_MetricsRec */ - /* */ - /* <Description> */ - /* A structure used to hold the big metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or `bloc' (Apple) table. */ - /* */ - /* <Fields> */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* horiBearingX :: The horizontal left bearing. */ - /* */ - /* horiBearingY :: The horizontal top bearing. */ - /* */ - /* horiAdvance :: The horizontal advance. */ - /* */ - /* vertBearingX :: The vertical left bearing. */ - /* */ - /* vertBearingY :: The vertical top bearing. */ - /* */ - /* vertAdvance :: The vertical advance. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_MetricsRec + * + * @description: + * A structure used to hold the big metrics of a given glyph bitmap in a + * TrueType or OpenType font. These are usually found in the 'EBDT' + * (Microsoft) or 'bloc' (Apple) table. + * + * @fields: + * height :: + * The glyph height in pixels. + * + * width :: + * The glyph width in pixels. + * + * horiBearingX :: + * The horizontal left bearing. + * + * horiBearingY :: + * The horizontal top bearing. + * + * horiAdvance :: + * The horizontal advance. + * + * vertBearingX :: + * The vertical left bearing. + * + * vertBearingY :: + * The vertical top bearing. + * + * vertAdvance :: + * The vertical advance. + */ typedef struct TT_SBit_MetricsRec_ { FT_UShort height; @@ -472,27 +446,32 @@ FT_BEGIN_HEADER } TT_SBit_MetricsRec, *TT_SBit_Metrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_SmallMetricsRec */ - /* */ - /* <Description> */ - /* A structure used to hold the small metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */ - /* */ - /* <Fields> */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* bearingX :: The left-side bearing. */ - /* */ - /* bearingY :: The top-side bearing. */ - /* */ - /* advance :: The advance width or height. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_SmallMetricsRec + * + * @description: + * A structure used to hold the small metrics of a given glyph bitmap in + * a TrueType or OpenType font. These are usually found in the 'EBDT' + * (Microsoft) or the 'bdat' (Apple) table. + * + * @fields: + * height :: + * The glyph height in pixels. + * + * width :: + * The glyph width in pixels. + * + * bearingX :: + * The left-side bearing. + * + * bearingY :: + * The top-side bearing. + * + * advance :: + * The advance width or height. + */ typedef struct TT_SBit_Small_Metrics_ { FT_Byte height; @@ -505,57 +484,60 @@ FT_BEGIN_HEADER } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_LineMetricsRec */ - /* */ - /* <Description> */ - /* A structure used to describe the text line metrics of a given */ - /* bitmap strike, for either a horizontal or vertical layout. */ - /* */ - /* <Fields> */ - /* ascender :: The ascender in pixels. */ - /* */ - /* descender :: The descender in pixels. */ - /* */ - /* max_width :: The maximum glyph width in pixels. */ - /* */ - /* caret_slope_enumerator :: Rise of the caret slope, typically set */ - /* to 1 for non-italic fonts. */ - /* */ - /* caret_slope_denominator :: Rise of the caret slope, typically set */ - /* to 0 for non-italic fonts. */ - /* */ - /* caret_offset :: Offset in pixels to move the caret for */ - /* proper positioning. */ - /* */ - /* min_origin_SB :: Minimum of horiBearingX (resp. */ - /* vertBearingY). */ - /* min_advance_SB :: Minimum of */ - /* */ - /* horizontal advance - */ - /* ( horiBearingX + width ) */ - /* */ - /* resp. */ - /* */ - /* vertical advance - */ - /* ( vertBearingY + height ) */ - /* */ - /* max_before_BL :: Maximum of horiBearingY (resp. */ - /* vertBearingY). */ - /* */ - /* min_after_BL :: Minimum of */ - /* */ - /* horiBearingY - height */ - /* */ - /* resp. */ - /* */ - /* vertBearingX - width */ - /* */ - /* pads :: Unused (to make the size of the record */ - /* a multiple of 32 bits. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_LineMetricsRec + * + * @description: + * A structure used to describe the text line metrics of a given bitmap + * strike, for either a horizontal or vertical layout. + * + * @fields: + * ascender :: + * The ascender in pixels. + * + * descender :: + * The descender in pixels. + * + * max_width :: + * The maximum glyph width in pixels. + * + * caret_slope_enumerator :: + * Rise of the caret slope, typically set to 1 for non-italic fonts. + * + * caret_slope_denominator :: + * Rise of the caret slope, typically set to 0 for non-italic fonts. + * + * caret_offset :: + * Offset in pixels to move the caret for proper positioning. + * + * min_origin_SB :: + * Minimum of horiBearingX (resp. vertBearingY). + * min_advance_SB :: + * Minimum of + * + * horizontal advance - ( horiBearingX + width ) + * + * resp. + * + * vertical advance - ( vertBearingY + height ) + * + * max_before_BL :: + * Maximum of horiBearingY (resp. vertBearingY). + * + * min_after_BL :: + * Minimum of + * + * horiBearingY - height + * + * resp. + * + * vertBearingX - width + * + * pads :: + * Unused (to make the size of the record a multiple of 32 bits. + */ typedef struct TT_SBit_LineMetricsRec_ { FT_Char ascender; @@ -573,43 +555,53 @@ FT_BEGIN_HEADER } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_RangeRec */ - /* */ - /* <Description> */ - /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* <Fields> */ - /* first_glyph :: The first glyph index in the range. */ - /* */ - /* last_glyph :: The last glyph index in the range. */ - /* */ - /* index_format :: The format of index table. Valid values are 1 */ - /* to 5. */ - /* */ - /* image_format :: The format of `EBDT' image data. */ - /* */ - /* image_offset :: The offset to image data in `EBDT'. */ - /* */ - /* image_size :: For index formats 2 and 5. This is the size in */ - /* bytes of each glyph bitmap. */ - /* */ - /* big_metrics :: For index formats 2 and 5. This is the big */ - /* metrics for each glyph bitmap. */ - /* */ - /* num_glyphs :: For index formats 4 and 5. This is the number of */ - /* glyphs in the code array. */ - /* */ - /* glyph_offsets :: For index formats 1 and 3. */ - /* */ - /* glyph_codes :: For index formats 4 and 5. */ - /* */ - /* table_offset :: The offset of the index table in the `EBLC' */ - /* table. Only used during strike loading. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_RangeRec + * + * @description: + * A TrueType/OpenType subIndexTable as defined in the 'EBLC' (Microsoft) + * or 'bloc' (Apple) tables. + * + * @fields: + * first_glyph :: + * The first glyph index in the range. + * + * last_glyph :: + * The last glyph index in the range. + * + * index_format :: + * The format of index table. Valid values are 1 to 5. + * + * image_format :: + * The format of 'EBDT' image data. + * + * image_offset :: + * The offset to image data in 'EBDT'. + * + * image_size :: + * For index formats 2 and 5. This is the size in bytes of each glyph + * bitmap. + * + * big_metrics :: + * For index formats 2 and 5. This is the big metrics for each glyph + * bitmap. + * + * num_glyphs :: + * For index formats 4 and 5. This is the number of glyphs in the code + * array. + * + * glyph_offsets :: + * For index formats 1 and 3. + * + * glyph_codes :: + * For index formats 4 and 5. + * + * table_offset :: + * The offset of the index table in the 'EBLC' table. Only used during + * strike loading. + */ typedef struct TT_SBit_RangeRec_ { FT_UShort first_glyph; @@ -631,47 +623,55 @@ FT_BEGIN_HEADER } TT_SBit_RangeRec, *TT_SBit_Range; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_StrikeRec */ - /* */ - /* <Description> */ - /* A structure used describe a given bitmap strike in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* <Fields> */ - /* num_index_ranges :: The number of index ranges. */ - /* */ - /* index_ranges :: An array of glyph index ranges. */ - /* */ - /* color_ref :: Unused. `color_ref' is put in for future */ - /* enhancements, but these fields are already */ - /* in use by other platforms (e.g. Newton). */ - /* For details, please see */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */ - /* */ - /* hori :: The line metrics for horizontal layouts. */ - /* */ - /* vert :: The line metrics for vertical layouts. */ - /* */ - /* start_glyph :: The lowest glyph index for this strike. */ - /* */ - /* end_glyph :: The highest glyph index for this strike. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */ - /* and 8. */ - /* */ - /* flags :: Is this a vertical or horizontal strike? For */ - /* details, please see */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_StrikeRec + * + * @description: + * A structure used describe a given bitmap strike in the 'EBLC' + * (Microsoft) or 'bloc' (Apple) tables. + * + * @fields: + * num_index_ranges :: + * The number of index ranges. + * + * index_ranges :: + * An array of glyph index ranges. + * + * color_ref :: + * Unused. `color_ref` is put in for future enhancements, but these + * fields are already in use by other platforms (e.g. Newton). For + * details, please see + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html + * + * hori :: + * The line metrics for horizontal layouts. + * + * vert :: + * The line metrics for vertical layouts. + * + * start_glyph :: + * The lowest glyph index for this strike. + * + * end_glyph :: + * The highest glyph index for this strike. + * + * x_ppem :: + * The number of horizontal pixels per EM. + * + * y_ppem :: + * The number of vertical pixels per EM. + * + * bit_depth :: + * The bit depth. Valid values are 1, 2, 4, and 8. + * + * flags :: + * Is this a vertical or horizontal strike? For details, please see + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html + */ typedef struct TT_SBit_StrikeRec_ { FT_Int num_ranges; @@ -695,21 +695,24 @@ FT_BEGIN_HEADER } TT_SBit_StrikeRec, *TT_SBit_Strike; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_ComponentRec */ - /* */ - /* <Description> */ - /* A simple structure to describe a compound sbit element. */ - /* */ - /* <Fields> */ - /* glyph_code :: The element's glyph index. */ - /* */ - /* x_offset :: The element's left bearing. */ - /* */ - /* y_offset :: The element's top bearing. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_ComponentRec + * + * @description: + * A simple structure to describe a compound sbit element. + * + * @fields: + * glyph_code :: + * The element's glyph index. + * + * x_offset :: + * The element's left bearing. + * + * y_offset :: + * The element's top bearing. + */ typedef struct TT_SBit_ComponentRec_ { FT_UShort glyph_code; @@ -719,28 +722,34 @@ FT_BEGIN_HEADER } TT_SBit_ComponentRec, *TT_SBit_Component; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_ScaleRec */ - /* */ - /* <Description> */ - /* A structure used describe a given bitmap scaling table, as defined */ - /* in the `EBSC' table. */ - /* */ - /* <Fields> */ - /* hori :: The horizontal line metrics. */ - /* */ - /* vert :: The vertical line metrics. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* x_ppem_substitute :: Substitution x_ppem value. */ - /* */ - /* y_ppem_substitute :: Substitution y_ppem value. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_SBit_ScaleRec + * + * @description: + * A structure used describe a given bitmap scaling table, as defined in + * the 'EBSC' table. + * + * @fields: + * hori :: + * The horizontal line metrics. + * + * vert :: + * The vertical line metrics. + * + * x_ppem :: + * The number of horizontal pixels per EM. + * + * y_ppem :: + * The number of vertical pixels per EM. + * + * x_ppem_substitute :: + * Substitution x_ppem value. + * + * y_ppem_substitute :: + * Substitution y_ppem value. + */ typedef struct TT_SBit_ScaleRec_ { TT_SBit_LineMetricsRec hori; @@ -768,24 +777,28 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_20Rec */ - /* */ - /* <Description> */ - /* Postscript names sub-table, format 2.0. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* <Fields> */ - /* num_glyphs :: The number of named glyphs in the table. */ - /* */ - /* num_names :: The number of PS names stored in the table. */ - /* */ - /* glyph_indices :: The indices of the glyphs in the names arrays. */ - /* */ - /* glyph_names :: The PS names not in Mac Encoding. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Post_20Rec + * + * @description: + * Postscript names sub-table, format 2.0. Stores the PS name of each + * glyph in the font face. + * + * @fields: + * num_glyphs :: + * The number of named glyphs in the table. + * + * num_names :: + * The number of PS names stored in the table. + * + * glyph_indices :: + * The indices of the glyphs in the names arrays. + * + * glyph_names :: + * The PS names not in Mac Encoding. + */ typedef struct TT_Post_20Rec_ { FT_UShort num_glyphs; @@ -796,21 +809,22 @@ FT_BEGIN_HEADER } TT_Post_20Rec, *TT_Post_20; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_25Rec */ - /* */ - /* <Description> */ - /* Postscript names sub-table, format 2.5. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* <Fields> */ - /* num_glyphs :: The number of glyphs in the table. */ - /* */ - /* offsets :: An array of signed offsets in a normal Mac */ - /* Postscript name encoding. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Post_25Rec + * + * @description: + * Postscript names sub-table, format 2.5. Stores the PS name of each + * glyph in the font face. + * + * @fields: + * num_glyphs :: + * The number of glyphs in the table. + * + * offsets :: + * An array of signed offsets in a normal Mac Postscript name encoding. + */ typedef struct TT_Post_25_ { FT_UShort num_glyphs; @@ -819,21 +833,24 @@ FT_BEGIN_HEADER } TT_Post_25Rec, *TT_Post_25; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_NamesRec */ - /* */ - /* <Description> */ - /* Postscript names table, either format 2.0 or 2.5. */ - /* */ - /* <Fields> */ - /* loaded :: A flag to indicate whether the PS names are loaded. */ - /* */ - /* format_20 :: The sub-table used for format 2.0. */ - /* */ - /* format_25 :: The sub-table used for format 2.5. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Post_NamesRec + * + * @description: + * Postscript names table, either format 2.0 or 2.5. + * + * @fields: + * loaded :: + * A flag to indicate whether the PS names are loaded. + * + * format_20 :: + * The sub-table used for format 2.0. + * + * format_25 :: + * The sub-table used for format 2.5. + */ typedef struct TT_Post_NamesRec_ { FT_Bool loaded; @@ -879,25 +896,25 @@ FT_BEGIN_HEADER /* * These types are used to support a `BDF ' table that isn't part of the - * official TrueType specification. It is mainly used in SFNT-based - * bitmap fonts that were generated from a set of BDF fonts. + * official TrueType specification. It is mainly used in SFNT-based bitmap + * fonts that were generated from a set of BDF fonts. * * The format of the table is as follows. * - * USHORT version `BDF ' table version number, should be 0x0001. - * USHORT strikeCount Number of strikes (bitmap sizes) in this table. - * ULONG stringTable Offset (from start of BDF table) to string + * USHORT version `BDF ' table version number, should be 0x0001. USHORT + * strikeCount Number of strikes (bitmap sizes) in this table. ULONG + * stringTable Offset (from start of BDF table) to string * table. * * This is followed by an array of `strikeCount' descriptors, having the * following format. * - * USHORT ppem Vertical pixels per EM for this strike. - * USHORT numItems Number of items for this strike (properties and + * USHORT ppem Vertical pixels per EM for this strike. USHORT numItems + * Number of items for this strike (properties and * atoms). Maximum is 255. * - * This array in turn is followed by `strikeCount' value sets. Each - * `value set' is an array of `numItems' items with the following format. + * This array in turn is followed by `strikeCount' value sets. Each `value + * set' is an array of `numItems' items with the following format. * * ULONG item_name Offset in string table to item name. * USHORT item_type The item type. Possible values are @@ -945,31 +962,30 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* This structure/class is defined here because it is common to the */ - /* following formats: TTF, OpenType-TT, and OpenType-CFF. */ - /* */ - /* Note, however, that the classes TT_Size and TT_GlyphSlot are not */ - /* shared between font drivers, and are thus defined in `ttobjs.h'. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This structure/class is defined here because it is common to the + * following formats: TTF, OpenType-TT, and OpenType-CFF. + * + * Note, however, that the classes TT_Size and TT_GlyphSlot are not shared + * between font drivers, and are thus defined in `ttobjs.h`. + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Face */ - /* */ - /* <Description> */ - /* A handle to a TrueType face/font object. A TT_Face encapsulates */ - /* the resolution and scaling independent parts of a TrueType font */ - /* resource. */ - /* */ - /* <Note> */ - /* The TT_Face structure is also used as a `parent class' for the */ - /* OpenType-CFF class (T2_Face). */ - /* */ + /************************************************************************** + * + * @type: + * TT_Face + * + * @description: + * A handle to a TrueType face/font object. A TT_Face encapsulates the + * resolution and scaling independent parts of a TrueType font resource. + * + * @note: + * The TT_Face structure is also used as a 'parent class' for the + * OpenType-CFF class (T2_Face). + */ typedef struct TT_FaceRec_* TT_Face; @@ -981,31 +997,34 @@ FT_BEGIN_HEADER typedef struct TT_LoaderRec_* TT_Loader; - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_GotoTableFunc */ - /* */ - /* <Description> */ - /* Seeks a stream to the start of a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* tag :: A 4-byte tag used to name the table. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Output> */ - /* length :: The length of the table in bytes. Set to 0 if not */ - /* needed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_GotoTableFunc + * + * @description: + * Seeks a stream to the start of a given TrueType table. + * + * @input: + * face :: + * A handle to the target face object. + * + * tag :: + * A 4-byte tag used to name the table. + * + * stream :: + * The input stream. + * + * @output: + * length :: + * The length of the table in bytes. Set to 0 if not needed. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The stream cursor must be at the font file's origin. + */ typedef FT_Error (*TT_Loader_GotoTableFunc)( TT_Face face, FT_ULong tag, @@ -1013,34 +1032,36 @@ FT_BEGIN_HEADER FT_ULong* length ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_StartGlyphFunc */ - /* */ - /* <Description> */ - /* Seeks a stream to the start of a given glyph element, and opens a */ - /* frame for it. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* glyph index :: The index of the glyph to access. */ - /* */ - /* offset :: The offset of the glyph according to the */ - /* `locations' table. */ - /* */ - /* byte_count :: The size of the frame in bytes. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function is normally equivalent to FT_STREAM_SEEK(offset) */ - /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */ - /* but alternative formats (e.g. compressed ones) might use something */ - /* different. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_StartGlyphFunc + * + * @description: + * Seeks a stream to the start of a given glyph element, and opens a + * frame for it. + * + * @input: + * loader :: + * The current TrueType glyph loader object. + * + * glyph index :: The index of the glyph to access. + * + * offset :: + * The offset of the glyph according to the 'locations' table. + * + * byte_count :: + * The size of the frame in bytes. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * This function is normally equivalent to FT_STREAM_SEEK(offset) + * followed by FT_FRAME_ENTER(byte_count) with the loader's stream, but + * alternative formats (e.g. compressed ones) might use something + * different. + */ typedef FT_Error (*TT_Loader_StartGlyphFunc)( TT_Loader loader, FT_UInt glyph_index, @@ -1048,36 +1069,38 @@ FT_BEGIN_HEADER FT_UInt byte_count ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_ReadGlyphFunc */ - /* */ - /* <Description> */ - /* Reads one glyph element (its header, a simple glyph, or a */ - /* composite) from the loader's current stream frame. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_ReadGlyphFunc + * + * @description: + * Reads one glyph element (its header, a simple glyph, or a composite) + * from the loader's current stream frame. + * + * @input: + * loader :: + * The current TrueType glyph loader object. + * + * @return: + * FreeType error code. 0 means success. + */ typedef FT_Error (*TT_Loader_ReadGlyphFunc)( TT_Loader loader ); - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_EndGlyphFunc */ - /* */ - /* <Description> */ - /* Closes the current loader stream frame for the glyph. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ + /************************************************************************** + * + * @functype: + * TT_Loader_EndGlyphFunc + * + * @description: + * Closes the current loader stream frame for the glyph. + * + * @input: + * loader :: + * The current TrueType glyph loader object. + */ typedef void (*TT_Loader_EndGlyphFunc)( TT_Loader loader ); @@ -1124,270 +1147,319 @@ FT_BEGIN_HEADER #define TT_FACE_FLAG_VAR_MVAR ( 1 << 8 ) - /*************************************************************************/ - /* */ - /* TrueType Face Type */ - /* */ - /* <Struct> */ - /* TT_Face */ - /* */ - /* <Description> */ - /* The TrueType face class. These objects model the resolution and */ - /* point-size independent data found in a TrueType font file. */ - /* */ - /* <Fields> */ - /* root :: The base FT_Face structure, managed by the */ - /* base layer. */ - /* */ - /* ttc_header :: The TrueType collection header, used when */ - /* the file is a `ttc' rather than a `ttf'. */ - /* For ordinary font files, the field */ - /* `ttc_header.count' is set to 0. */ - /* */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of TrueType tables in this font */ - /* file. */ - /* */ - /* dir_tables :: The directory of TrueType tables for this */ - /* font file. */ - /* */ - /* header :: The font's font header (`head' table). */ - /* Read on font opening. */ - /* */ - /* horizontal :: The font's horizontal header (`hhea' */ - /* table). This field also contains the */ - /* associated horizontal metrics table */ - /* (`hmtx'). */ - /* */ - /* max_profile :: The font's maximum profile table. Read on */ - /* font opening. Note that some maximum */ - /* values cannot be taken directly from this */ - /* table. We thus define additional fields */ - /* below to hold the computed maxima. */ - /* */ - /* vertical_info :: A boolean which is set when the font file */ - /* contains vertical metrics. If not, the */ - /* value of the `vertical' field is */ - /* undefined. */ - /* */ - /* vertical :: The font's vertical header (`vhea' table). */ - /* This field also contains the associated */ - /* vertical metrics table (`vmtx'), if found. */ - /* IMPORTANT: The contents of this field is */ - /* undefined if the `vertical_info' field is */ - /* unset. */ - /* */ - /* num_names :: The number of name records within this */ - /* TrueType font. */ - /* */ - /* name_table :: The table of name records (`name'). */ - /* */ - /* os2 :: The font's OS/2 table (`OS/2'). */ - /* */ - /* postscript :: The font's PostScript table (`post' */ - /* table). The PostScript glyph names are */ - /* not loaded by the driver on face opening. */ - /* See the `ttpost' module for more details. */ - /* */ - /* cmap_table :: Address of the face's `cmap' SFNT table */ - /* in memory (it's an extracted frame). */ - /* */ - /* cmap_size :: The size in bytes of the `cmap_table' */ - /* described above. */ - /* */ - /* goto_table :: A function called by each TrueType table */ - /* loader to position a stream's cursor to */ - /* the start of a given table according to */ - /* its tag. It defaults to TT_Goto_Face but */ - /* can be different for strange formats (e.g. */ - /* Type 42). */ - /* */ - /* access_glyph_frame :: A function used to access the frame of a */ - /* given glyph within the face's font file. */ - /* */ - /* forget_glyph_frame :: A function used to forget the frame of a */ - /* given glyph when all data has been loaded. */ - /* */ - /* read_glyph_header :: A function used to read a glyph header. */ - /* It must be called between an `access' and */ - /* `forget'. */ - /* */ - /* read_simple_glyph :: A function used to read a simple glyph. */ - /* It must be called after the header was */ - /* read, and before the `forget'. */ - /* */ - /* read_composite_glyph :: A function used to read a composite glyph. */ - /* It must be called after the header was */ - /* read, and before the `forget'. */ - /* */ - /* sfnt :: A pointer to the SFNT service. */ - /* */ - /* psnames :: A pointer to the PostScript names service. */ - /* */ - /* mm :: A pointer to the Multiple Masters service. */ - /* */ - /* var :: A pointer to the Metrics Variations */ - /* service. */ - /* */ - /* hdmx :: The face's horizontal device metrics */ - /* (`hdmx' table). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* gasp :: The grid-fitting and scaling properties */ - /* table (`gasp'). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* pclt :: The `pclt' SFNT table. */ - /* */ - /* num_sbit_scales :: The number of sbit scales for this font. */ - /* */ - /* sbit_scales :: Array of sbit scales embedded in this */ - /* font. This table is optional in a */ - /* TrueType/OpenType font. */ - /* */ - /* postscript_names :: A table used to store the Postscript names */ - /* of the glyphs for this font. See the */ - /* file `ttconfig.h' for comments on the */ - /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */ - /* */ - /* font_program_size :: Size in bytecodes of the face's font */ - /* program. 0 if none defined. Ignored for */ - /* Type 2 fonts. */ - /* */ - /* font_program :: The face's font program (bytecode stream) */ - /* executed at load time, also used during */ - /* glyph rendering. Comes from the `fpgm' */ - /* table. Ignored for Type 2 font fonts. */ - /* */ - /* cvt_program_size :: The size in bytecodes of the face's cvt */ - /* program. Ignored for Type 2 fonts. */ - /* */ - /* cvt_program :: The face's cvt program (bytecode stream) */ - /* executed each time an instance/size is */ - /* changed/reset. Comes from the `prep' */ - /* table. Ignored for Type 2 fonts. */ - /* */ - /* cvt_size :: Size of the control value table (in */ - /* entries). Ignored for Type 2 fonts. */ - /* */ - /* cvt :: The face's original control value table. */ - /* Coordinates are expressed in unscaled font */ - /* units. Comes from the `cvt ' table. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* interpreter :: A pointer to the TrueType bytecode */ - /* interpreters field is also used to hook */ - /* the debugger in `ttdebug'. */ - /* */ - /* extra :: Reserved for third-party font drivers. */ - /* */ - /* postscript_name :: The PS name of the font. Used by the */ - /* postscript name service. */ - /* */ - /* glyf_len :: The length of the `glyf' table. Needed */ - /* for malformed `loca' tables. */ - /* */ - /* glyf_offset :: The file offset of the `glyf' table. */ - /* */ - /* is_cff2 :: Set if the font format is CFF2. */ - /* */ - /* doblend :: A boolean which is set if the font should */ - /* be blended (this is for GX var). */ - /* */ - /* blend :: Contains the data needed to control GX */ - /* variation tables (rather like Multiple */ - /* Master data). */ - /* */ - /* variation_support :: Flags that indicate which OpenType */ - /* functionality related to font variation */ - /* support is present, valid, and usable. */ - /* For example, TT_FACE_FLAG_VAR_FVAR is only */ - /* set if we have at least one design axis. */ - /* */ - /* var_postscript_prefix :: */ - /* The PostScript name prefix needed for */ - /* constructing a variation font instance's */ - /* PS name . */ - /* */ - /* var_postscript_prefix_len :: */ - /* The length of the `var_postscript_prefix' */ - /* string. */ - /* */ - /* horz_metrics_size :: The size of the `hmtx' table. */ - /* */ - /* vert_metrics_size :: The size of the `vmtx' table. */ - /* */ - /* num_locations :: The number of glyph locations in this */ - /* TrueType file. This should be */ - /* identical to the number of glyphs. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* glyph_locations :: An array of longs. These are offsets to */ - /* glyph data within the `glyf' table. */ - /* Ignored for Type 2 font faces. */ - /* */ - /* hdmx_table :: A pointer to the `hdmx' table. */ - /* */ - /* hdmx_table_size :: The size of the `hdmx' table. */ - /* */ - /* hdmx_record_count :: The number of hdmx records. */ - /* */ - /* hdmx_record_size :: The size of a single hdmx record. */ - /* */ - /* hdmx_record_sizes :: An array holding the ppem sizes available */ - /* in the `hdmx' table. */ - /* */ - /* sbit_table :: A pointer to the font's embedded bitmap */ - /* location table. */ - /* */ - /* sbit_table_size :: The size of `sbit_table'. */ - /* */ - /* sbit_table_type :: The sbit table type (CBLC, sbix, etc.). */ - /* */ - /* sbit_num_strikes :: The number of sbit strikes exposed by */ - /* FreeType's API, omitting invalid strikes. */ - /* */ - /* sbit_strike_map :: A mapping between the strike indices */ - /* exposed by the API and the indices used in */ - /* the font's sbit table. */ - /* */ - /* kern_table :: A pointer to the `kern' table. */ - /* */ - /* kern_table_size :: The size of the `kern' table. */ - /* */ - /* num_kern_tables :: The number of supported kern subtables */ - /* (up to 32; FreeType recognizes only */ - /* horizontal ones with format 0). */ - /* */ - /* kern_avail_bits :: The availability status of kern subtables; */ - /* if bit n is set, table n is available. */ - /* */ - /* kern_order_bits :: The sortedness status of kern subtables; */ - /* if bit n is set, table n is sorted. */ - /* */ - /* bdf :: Data related to an SFNT font's `bdf' */ - /* table; see `tttypes.h'. */ - /* */ - /* horz_metrics_offset :: The file offset of the `hmtx' table. */ - /* */ - /* vert_metrics_offset :: The file offset of the `vmtx' table. */ - /* */ - /* sph_found_func_flags :: Flags identifying special bytecode */ - /* functions (used by the v38 implementation */ - /* of the bytecode interpreter). */ - /* */ - /* sph_compatibility_mode :: */ - /* This flag is set if we are in ClearType */ - /* backward compatibility mode (used by the */ - /* v38 implementation of the bytecode */ - /* interpreter). */ - /* */ - /* ebdt_start :: The file offset of the sbit data table */ - /* (CBDT, bdat, etc.). */ - /* */ - /* ebdt_size :: The size of the sbit data table. */ - /* */ + /************************************************************************** + * + * TrueType Face Type + * + * @struct: + * TT_Face + * + * @description: + * The TrueType face class. These objects model the resolution and + * point-size independent data found in a TrueType font file. + * + * @fields: + * root :: + * The base FT_Face structure, managed by the base layer. + * + * ttc_header :: + * The TrueType collection header, used when the file is a 'ttc' rather + * than a 'ttf'. For ordinary font files, the field `ttc_header.count` + * is set to 0. + * + * format_tag :: + * The font format tag. + * + * num_tables :: + * The number of TrueType tables in this font file. + * + * dir_tables :: + * The directory of TrueType tables for this font file. + * + * header :: + * The font's font header ('head' table). Read on font opening. + * + * horizontal :: + * The font's horizontal header ('hhea' table). This field also + * contains the associated horizontal metrics table ('hmtx'). + * + * max_profile :: + * The font's maximum profile table. Read on font opening. Note that + * some maximum values cannot be taken directly from this table. We + * thus define additional fields below to hold the computed maxima. + * + * vertical_info :: + * A boolean which is set when the font file contains vertical metrics. + * If not, the value of the 'vertical' field is undefined. + * + * vertical :: + * The font's vertical header ('vhea' table). This field also contains + * the associated vertical metrics table ('vmtx'), if found. + * IMPORTANT: The contents of this field is undefined if the + * `vertical_info` field is unset. + * + * num_names :: + * The number of name records within this TrueType font. + * + * name_table :: + * The table of name records ('name'). + * + * os2 :: + * The font's OS/2 table ('OS/2'). + * + * postscript :: + * The font's PostScript table ('post' table). The PostScript glyph + * names are not loaded by the driver on face opening. See the + * 'ttpost' module for more details. + * + * cmap_table :: + * Address of the face's 'cmap' SFNT table in memory (it's an extracted + * frame). + * + * cmap_size :: + * The size in bytes of the `cmap_table` described above. + * + * goto_table :: + * A function called by each TrueType table loader to position a + * stream's cursor to the start of a given table according to its tag. + * It defaults to TT_Goto_Face but can be different for strange formats + * (e.g. Type 42). + * + * access_glyph_frame :: + * A function used to access the frame of a given glyph within the + * face's font file. + * + * forget_glyph_frame :: + * A function used to forget the frame of a given glyph when all data + * has been loaded. + * + * read_glyph_header :: + * A function used to read a glyph header. It must be called between + * an 'access' and 'forget'. + * + * read_simple_glyph :: + * A function used to read a simple glyph. It must be called after the + * header was read, and before the 'forget'. + * + * read_composite_glyph :: + * A function used to read a composite glyph. It must be called after + * the header was read, and before the 'forget'. + * + * sfnt :: + * A pointer to the SFNT service. + * + * psnames :: + * A pointer to the PostScript names service. + * + * mm :: + * A pointer to the Multiple Masters service. + * + * var :: + * A pointer to the Metrics Variations service. + * + * hdmx :: + * The face's horizontal device metrics ('hdmx' table). This table is + * optional in TrueType/OpenType fonts. + * + * gasp :: + * The grid-fitting and scaling properties table ('gasp'). This table + * is optional in TrueType/OpenType fonts. + * + * pclt :: + * The 'pclt' SFNT table. + * + * num_sbit_scales :: + * The number of sbit scales for this font. + * + * sbit_scales :: + * Array of sbit scales embedded in this font. This table is optional + * in a TrueType/OpenType font. + * + * postscript_names :: + * A table used to store the Postscript names of the glyphs for this + * font. See the file `ttconfig.h` for comments on the + * TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. + * + * palette_data :: + * Some fields from the 'CPAL' table that are directly indexed. + * + * palette_index :: + * The current palette index, as set by @FT_Palette_Select. + * + * palette :: + * An array containing the current palette's colors. + * + * have_foreground_color :: + * There was a call to @FT_Palette_Set_Foreground_Color. + * + * foreground_color :: + * The current foreground color corresponding to 'CPAL' color index + * 0xFFFF. Only valid if `have_foreground_color` is set. + * + * font_program_size :: + * Size in bytecodes of the face's font program. 0 if none defined. + * Ignored for Type 2 fonts. + * + * font_program :: + * The face's font program (bytecode stream) executed at load time, + * also used during glyph rendering. Comes from the 'fpgm' table. + * Ignored for Type 2 font fonts. + * + * cvt_program_size :: + * The size in bytecodes of the face's cvt program. Ignored for Type 2 + * fonts. + * + * cvt_program :: + * The face's cvt program (bytecode stream) executed each time an + * instance/size is changed/reset. Comes from the 'prep' table. + * Ignored for Type 2 fonts. + * + * cvt_size :: + * Size of the control value table (in entries). Ignored for Type 2 + * fonts. + * + * cvt :: + * The face's original control value table. Coordinates are expressed + * in unscaled font units (in 26.6 format). Comes from the 'cvt~' + * table. Ignored for Type 2 fonts. + * + * If varied by the `CVAR' table, non-integer values are possible. + * + * interpreter :: + * A pointer to the TrueType bytecode interpreters field is also used + * to hook the debugger in 'ttdebug'. + * + * extra :: + * Reserved for third-party font drivers. + * + * postscript_name :: + * The PS name of the font. Used by the postscript name service. + * + * glyf_len :: + * The length of the 'glyf' table. Needed for malformed 'loca' tables. + * + * glyf_offset :: + * The file offset of the 'glyf' table. + * + * is_cff2 :: + * Set if the font format is CFF2. + * + * doblend :: + * A boolean which is set if the font should be blended (this is for GX + * var). + * + * blend :: + * Contains the data needed to control GX variation tables (rather like + * Multiple Master data). + * + * variation_support :: + * Flags that indicate which OpenType functionality related to font + * variation support is present, valid, and usable. For example, + * TT_FACE_FLAG_VAR_FVAR is only set if we have at least one design + * axis. + * + * var_postscript_prefix :: + * The PostScript name prefix needed for constructing a variation font + * instance's PS name . + * + * var_postscript_prefix_len :: + * The length of the `var_postscript_prefix` string. + * + * horz_metrics_size :: + * The size of the 'hmtx' table. + * + * vert_metrics_size :: + * The size of the 'vmtx' table. + * + * num_locations :: + * The number of glyph locations in this TrueType file. This should be + * identical to the number of glyphs. Ignored for Type 2 fonts. + * + * glyph_locations :: + * An array of longs. These are offsets to glyph data within the + * 'glyf' table. Ignored for Type 2 font faces. + * + * hdmx_table :: + * A pointer to the 'hdmx' table. + * + * hdmx_table_size :: + * The size of the 'hdmx' table. + * + * hdmx_record_count :: + * The number of hdmx records. + * + * hdmx_record_size :: + * The size of a single hdmx record. + * + * hdmx_record_sizes :: + * An array holding the ppem sizes available in the 'hdmx' table. + * + * sbit_table :: + * A pointer to the font's embedded bitmap location table. + * + * sbit_table_size :: + * The size of `sbit_table`. + * + * sbit_table_type :: + * The sbit table type (CBLC, sbix, etc.). + * + * sbit_num_strikes :: + * The number of sbit strikes exposed by FreeType's API, omitting + * invalid strikes. + * + * sbit_strike_map :: + * A mapping between the strike indices exposed by the API and the + * indices used in the font's sbit table. + * + * cpal :: + * A pointer to data related to the 'CPAL' table. `NULL` if the table + * is not available. + * + * colr :: + * A pointer to data related to the 'COLR' table. `NULL` if the table + * is not available. + * + * kern_table :: + * A pointer to the 'kern' table. + * + * kern_table_size :: + * The size of the 'kern' table. + * + * num_kern_tables :: + * The number of supported kern subtables (up to 32; FreeType + * recognizes only horizontal ones with format 0). + * + * kern_avail_bits :: + * The availability status of kern subtables; if bit n is set, table n + * is available. + * + * kern_order_bits :: + * The sortedness status of kern subtables; if bit n is set, table n is + * sorted. + * + * bdf :: + * Data related to an SFNT font's 'bdf' table; see `tttypes.h`. + * + * horz_metrics_offset :: + * The file offset of the 'hmtx' table. + * + * vert_metrics_offset :: + * The file offset of the 'vmtx' table. + * + * sph_found_func_flags :: + * Flags identifying special bytecode functions (used by the v38 + * implementation of the bytecode interpreter). + * + * sph_compatibility_mode :: + * This flag is set if we are in ClearType backward compatibility mode + * (used by the v38 implementation of the bytecode interpreter). + * + * ebdt_start :: + * The file offset of the sbit data table (CBDT, bdat, etc.). + * + * ebdt_size :: + * The size of the sbit data table. + */ typedef struct TT_FaceRec_ { FT_FaceRec root; @@ -1445,11 +1517,11 @@ FT_BEGIN_HEADER void* psaux; - /***********************************************************************/ - /* */ - /* Optional TrueType/OpenType tables */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * Optional TrueType/OpenType tables + * + */ /* grid-fitting and scaling table */ TT_GaspRec gasp; /* the `gasp' table */ @@ -1464,12 +1536,19 @@ FT_BEGIN_HEADER /* postscript names table */ TT_Post_NamesRec postscript_names; + /* glyph colors */ + FT_Palette_Data palette_data; /* since 2.10 */ + FT_UShort palette_index; + FT_Color* palette; + FT_Bool have_foreground_color; + FT_Color foreground_color; + - /***********************************************************************/ - /* */ - /* TrueType-specific fields (ignored by the CFF driver) */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * TrueType-specific fields (ignored by the CFF driver) + * + */ /* the font program, if any */ FT_ULong font_program_size; @@ -1481,19 +1560,19 @@ FT_BEGIN_HEADER /* the original, unscaled, control value table */ FT_ULong cvt_size; - FT_Short* cvt; + FT_Int32* cvt; /* A pointer to the bytecode interpreter to use. This is also */ /* used to hook the debugger for the `ttdebug' utility. */ TT_Interpreter interpreter; - /***********************************************************************/ - /* */ - /* Other tables or fields. This is used by derivative formats like */ - /* OpenType. */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * Other tables or fields. This is used by derivative formats like + * OpenType. + * + */ FT_Generic extra; @@ -1562,40 +1641,53 @@ FT_BEGIN_HEADER FT_ULong ebdt_size; #endif + /* since 2.10 */ + void* cpal; + void* colr; + } TT_FaceRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GlyphZoneRec */ - /* */ - /* <Description> */ - /* A glyph zone is used to load, scale and hint glyph outline */ - /* coordinates. */ - /* */ - /* <Fields> */ - /* memory :: A handle to the memory manager. */ - /* */ - /* max_points :: The maximum size in points of the zone. */ - /* */ - /* max_contours :: Max size in links contours of the zone. */ - /* */ - /* n_points :: The current number of points in the zone. */ - /* */ - /* n_contours :: The current number of contours in the zone. */ - /* */ - /* org :: The original glyph coordinates (font */ - /* units/scaled). */ - /* */ - /* cur :: The current glyph coordinates (scaled/hinted). */ - /* */ - /* tags :: The point control tags. */ - /* */ - /* contours :: The contours end points. */ - /* */ - /* first_point :: Offset of the current subglyph's first point. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_GlyphZoneRec + * + * @description: + * A glyph zone is used to load, scale and hint glyph outline + * coordinates. + * + * @fields: + * memory :: + * A handle to the memory manager. + * + * max_points :: + * The maximum size in points of the zone. + * + * max_contours :: + * Max size in links contours of the zone. + * + * n_points :: + * The current number of points in the zone. + * + * n_contours :: + * The current number of contours in the zone. + * + * org :: + * The original glyph coordinates (font units/scaled). + * + * cur :: + * The current glyph coordinates (scaled/hinted). + * + * tags :: + * The point control tags. + * + * contours :: + * The contours end points. + * + * first_point :: + * Offset of the current subglyph's first point. + */ typedef struct TT_GlyphZoneRec_ { FT_Memory memory; @@ -1620,14 +1712,14 @@ FT_BEGIN_HEADER typedef struct TT_ExecContextRec_* TT_ExecContext; - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Size */ - /* */ - /* <Description> */ - /* A handle to a TrueType size object. */ - /* */ + /************************************************************************** + * + * @type: + * TT_Size + * + * @description: + * A handle to a TrueType size object. + */ typedef struct TT_SizeRec_* TT_Size; diff --git a/src/3rdparty/freetype/include/freetype/internal/wofftypes.h b/src/3rdparty/freetype/include/freetype/internal/wofftypes.h new file mode 100644 index 0000000000..ba55bf883e --- /dev/null +++ b/src/3rdparty/freetype/include/freetype/internal/wofftypes.h @@ -0,0 +1,112 @@ +/**************************************************************************** + * + * wofftypes.h + * + * Basic WOFF/WOFF2 type definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef WOFFTYPES_H_ +#define WOFFTYPES_H_ + + +#include <ft2build.h> +#include FT_TRUETYPE_TABLES_H +#include FT_INTERNAL_OBJECTS_H + + +FT_BEGIN_HEADER + + + /************************************************************************** + * + * @struct: + * WOFF_HeaderRec + * + * @description: + * WOFF file format header. + * + * @fields: + * See + * + * https://www.w3.org/TR/WOFF/#WOFFHeader + */ + typedef struct WOFF_HeaderRec_ + { + FT_ULong signature; + FT_ULong flavor; + FT_ULong length; + FT_UShort num_tables; + FT_UShort reserved; + FT_ULong totalSfntSize; + FT_UShort majorVersion; + FT_UShort minorVersion; + FT_ULong metaOffset; + FT_ULong metaLength; + FT_ULong metaOrigLength; + FT_ULong privOffset; + FT_ULong privLength; + + } WOFF_HeaderRec, *WOFF_Header; + + + /************************************************************************** + * + * @struct: + * WOFF_TableRec + * + * @description: + * This structure describes a given table of a WOFF font. + * + * @fields: + * Tag :: + * A four-bytes tag describing the table. + * + * Offset :: + * The offset of the table from the start of the WOFF font in its + * resource. + * + * CompLength :: + * Compressed table length (in bytes). + * + * OrigLength :: + * Uncompressed table length (in bytes). + * + * CheckSum :: + * The table checksum. This value can be ignored. + * + * OrigOffset :: + * The uncompressed table file offset. This value gets computed while + * constructing the (uncompressed) SFNT header. It is not contained in + * the WOFF file. + */ + typedef struct WOFF_TableRec_ + { + FT_ULong Tag; /* table ID */ + FT_ULong Offset; /* table file offset */ + FT_ULong CompLength; /* compressed table length */ + FT_ULong OrigLength; /* uncompressed table length */ + FT_ULong CheckSum; /* uncompressed checksum */ + + FT_ULong OrigOffset; /* uncompressed table file offset */ + /* (not in the WOFF file) */ + } WOFF_TableRec, *WOFF_Table; + + +FT_END_HEADER + +#endif /* WOFFTYPES_H_ */ + + +/* END */ diff --git a/src/3rdparty/freetype/include/freetype/t1tables.h b/src/3rdparty/freetype/include/freetype/t1tables.h index 3503c2616b..645e645720 100644 --- a/src/3rdparty/freetype/include/freetype/t1tables.h +++ b/src/3rdparty/freetype/include/freetype/t1tables.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* t1tables.h */ -/* */ -/* Basic Type 1/Type 2 tables definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1tables.h + * + * Basic Type 1/Type 2 tables definitions and interface (specification + * only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1TABLES_H_ @@ -34,58 +34,58 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* type1_tables */ - /* */ - /* <Title> */ - /* Type 1 Tables */ - /* */ - /* <Abstract> */ - /* Type~1 (PostScript) specific font tables. */ - /* */ - /* <Description> */ - /* This section contains the definition of Type 1-specific tables, */ - /* including structures related to other PostScript font formats. */ - /* */ - /* <Order> */ - /* PS_FontInfoRec */ - /* PS_FontInfo */ - /* PS_PrivateRec */ - /* PS_Private */ - /* */ - /* CID_FaceDictRec */ - /* CID_FaceDict */ - /* CID_FaceInfoRec */ - /* CID_FaceInfo */ - /* */ - /* FT_Has_PS_Glyph_Names */ - /* FT_Get_PS_Font_Info */ - /* FT_Get_PS_Font_Private */ - /* FT_Get_PS_Font_Value */ - /* */ - /* T1_Blend_Flags */ - /* T1_EncodingType */ - /* PS_Dict_Keys */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @section: + * type1_tables + * + * @title: + * Type 1 Tables + * + * @abstract: + * Type~1-specific font tables. + * + * @description: + * This section contains the definition of Type~1-specific tables, + * including structures related to other PostScript font formats. + * + * @order: + * PS_FontInfoRec + * PS_FontInfo + * PS_PrivateRec + * PS_Private + * + * CID_FaceDictRec + * CID_FaceDict + * CID_FaceInfoRec + * CID_FaceInfo + * + * FT_Has_PS_Glyph_Names + * FT_Get_PS_Font_Info + * FT_Get_PS_Font_Private + * FT_Get_PS_Font_Value + * + * T1_Blend_Flags + * T1_EncodingType + * PS_Dict_Keys + * + */ /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ /* structures in order to support Multiple Master fonts. */ - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfoRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* FontInfo dictionary. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_FontInfoRec + * + * @description: + * A structure used to model a Type~1 or Type~2 FontInfo dictionary. + * Note that for Multiple Master fonts, each instance has its own + * FontInfo dictionary. + */ typedef struct PS_FontInfoRec_ { FT_String* version; @@ -101,40 +101,39 @@ FT_BEGIN_HEADER } PS_FontInfoRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfo */ - /* */ - /* <Description> */ - /* A handle to a @PS_FontInfoRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_FontInfo + * + * @description: + * A handle to a @PS_FontInfoRec structure. + */ typedef struct PS_FontInfoRec_* PS_FontInfo; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_FontInfo */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_FontInfo + * + * @description: + * This type is equivalent to @PS_FontInfoRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ typedef PS_FontInfoRec T1_FontInfo; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_PrivateRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 private dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* Private dictionary. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_PrivateRec + * + * @description: + * A structure used to model a Type~1 or Type~2 private dictionary. Note + * that for Multiple Master fonts, each instance has its own Private + * dictionary. + */ typedef struct PS_PrivateRec_ { FT_Int unique_id; @@ -176,56 +175,55 @@ FT_BEGIN_HEADER } PS_PrivateRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Private */ - /* */ - /* <Description> */ - /* A handle to a @PS_PrivateRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * PS_Private + * + * @description: + * A handle to a @PS_PrivateRec structure. + */ typedef struct PS_PrivateRec_* PS_Private; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_Private */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_PrivateRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * T1_Private + * + * @description: + * This type is equivalent to @PS_PrivateRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ typedef PS_PrivateRec T1_Private; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_Blend_Flags */ - /* */ - /* <Description> */ - /* A set of flags used to indicate which fields are present in a */ - /* given blend dictionary (font info or private). Used to support */ - /* Multiple Masters fonts. */ - /* */ - /* <Values> */ - /* T1_BLEND_UNDERLINE_POSITION :: */ - /* T1_BLEND_UNDERLINE_THICKNESS :: */ - /* T1_BLEND_ITALIC_ANGLE :: */ - /* T1_BLEND_BLUE_VALUES :: */ - /* T1_BLEND_OTHER_BLUES :: */ - /* T1_BLEND_STANDARD_WIDTH :: */ - /* T1_BLEND_STANDARD_HEIGHT :: */ - /* T1_BLEND_STEM_SNAP_WIDTHS :: */ - /* T1_BLEND_STEM_SNAP_HEIGHTS :: */ - /* T1_BLEND_BLUE_SCALE :: */ - /* T1_BLEND_BLUE_SHIFT :: */ - /* T1_BLEND_FAMILY_BLUES :: */ - /* T1_BLEND_FAMILY_OTHER_BLUES :: */ - /* T1_BLEND_FORCE_BOLD :: */ - /* */ + /************************************************************************** + * + * @enum: + * T1_Blend_Flags + * + * @description: + * A set of flags used to indicate which fields are present in a given + * blend dictionary (font info or private). Used to support Multiple + * Masters fonts. + * + * @values: + * T1_BLEND_UNDERLINE_POSITION :: + * T1_BLEND_UNDERLINE_THICKNESS :: + * T1_BLEND_ITALIC_ANGLE :: + * T1_BLEND_BLUE_VALUES :: + * T1_BLEND_OTHER_BLUES :: + * T1_BLEND_STANDARD_WIDTH :: + * T1_BLEND_STANDARD_HEIGHT :: + * T1_BLEND_STEM_SNAP_WIDTHS :: + * T1_BLEND_STEM_SNAP_HEIGHTS :: + * T1_BLEND_BLUE_SCALE :: + * T1_BLEND_BLUE_SHIFT :: + * T1_BLEND_FAMILY_BLUES :: + * T1_BLEND_FAMILY_OTHER_BLUES :: + * T1_BLEND_FORCE_BOLD :: + */ typedef enum T1_Blend_Flags_ { /* required fields in a FontInfo blend dictionary */ @@ -252,7 +250,7 @@ FT_BEGIN_HEADER /* these constants are deprecated; use the corresponding */ - /* `T1_Blend_Flags' values instead */ + /* `T1_Blend_Flags` values instead */ #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE @@ -330,14 +328,23 @@ FT_BEGIN_HEADER typedef PS_BlendRec T1_Blend; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDictRec */ - /* */ - /* <Description> */ - /* A structure used to represent data in a CID top-level dictionary. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceDictRec + * + * @description: + * A structure used to represent data in a CID top-level dictionary. In + * most cases, they are part of the font's '/FDArray' array. Within a + * CID font file, such (internal) subfont dictionaries are enclosed by + * '%ADOBeginFontDict' and '%ADOEndFontDict' comments. + * + * Note that `CID_FaceDictRec` misses a field for the '/FontName' + * keyword, specifying the subfont's name (the top-level font name is + * given by the '/CIDFontName' keyword). This is an oversight, but it + * doesn't limit the 'cid' font module's functionality because FreeType + * neither needs this entry nor gives access to CID subfonts. + */ typedef struct CID_FaceDictRec_ { PS_PrivateRec private_dict; @@ -345,8 +352,8 @@ FT_BEGIN_HEADER FT_UInt len_buildchar; FT_Fixed forcebold_threshold; FT_Pos stroke_width; - FT_Fixed expansion_factor; - + FT_Fixed expansion_factor; /* this is a duplicate of */ + /* `private_dict->expansion_factor' */ FT_Byte paint_type; FT_Byte font_type; FT_Matrix font_matrix; @@ -359,38 +366,38 @@ FT_BEGIN_HEADER } CID_FaceDictRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDict */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceDictRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceDict + * + * @description: + * A handle to a @CID_FaceDictRec structure. + */ typedef struct CID_FaceDictRec_* CID_FaceDict; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FontDict */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FontDict + * + * @description: + * This type is equivalent to @CID_FaceDictRec. It is deprecated but + * kept to maintain source compatibility between various versions of + * FreeType. + */ typedef CID_FaceDictRec CID_FontDict; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfoRec */ - /* */ - /* <Description> */ - /* A structure used to represent CID Face information. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceInfoRec + * + * @description: + * A structure used to represent CID Face information. + */ typedef struct CID_FaceInfoRec_ { FT_String* cid_font_name; @@ -421,47 +428,45 @@ FT_BEGIN_HEADER } CID_FaceInfoRec; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfo */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceInfoRec structure. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_FaceInfo + * + * @description: + * A handle to a @CID_FaceInfoRec structure. + */ typedef struct CID_FaceInfoRec_* CID_FaceInfo; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_Info */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ + /************************************************************************** + * + * @struct: + * CID_Info + * + * @description: + * This type is equivalent to @CID_FaceInfoRec. It is deprecated but kept + * to maintain source compatibility between various versions of FreeType. + */ typedef CID_FaceInfoRec CID_Info; - /************************************************************************ + /************************************************************************** * * @function: * FT_Has_PS_Glyph_Names * * @description: - * Return true if a given face provides reliable PostScript glyph - * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, - * except that certain fonts (mostly TrueType) contain incorrect - * glyph name tables. + * Return true if a given face provides reliable PostScript glyph names. + * This is similar to using the @FT_HAS_GLYPH_NAMES macro, except that + * certain fonts (mostly TrueType) contain incorrect glyph name tables. * * When this function returns true, the caller is sure that the glyph * names returned by @FT_Get_Glyph_Name are reliable. * * @input: * face :: - * face handle + * face handle * * @return: * Boolean. True if glyph names are reliable. @@ -471,7 +476,7 @@ FT_BEGIN_HEADER FT_Has_PS_Glyph_Names( FT_Face face ); - /************************************************************************ + /************************************************************************** * * @function: * FT_Get_PS_Font_Info @@ -482,22 +487,22 @@ FT_BEGIN_HEADER * * @input: * face :: - * PostScript face handle. + * PostScript face handle. * * @output: * afont_info :: - * Output font info structure pointer. + * Output font info structure pointer. * * @return: * FreeType error code. 0~means success. * * @note: - * String pointers within the @PS_FontInfoRec structure are owned by - * the face and don't need to be freed by the caller. Missing entries - * in the font's FontInfo dictionary are represented by NULL pointers. + * String pointers within the @PS_FontInfoRec structure are owned by the + * face and don't need to be freed by the caller. Missing entries in + * the font's FontInfo dictionary are represented by `NULL` pointers. * * If the font's format is not PostScript-based, this function will - * return the `FT_Err_Invalid_Argument' error code. + * return the `FT_Err_Invalid_Argument` error code. * */ FT_EXPORT( FT_Error ) @@ -505,7 +510,7 @@ FT_BEGIN_HEADER PS_FontInfo afont_info ); - /************************************************************************ + /************************************************************************** * * @function: * FT_Get_PS_Font_Private @@ -516,11 +521,11 @@ FT_BEGIN_HEADER * * @input: * face :: - * PostScript face handle. + * PostScript face handle. * * @output: * afont_private :: - * Output private dictionary structure pointer. + * Output private dictionary structure pointer. * * @return: * FreeType error code. 0~means success. @@ -530,7 +535,7 @@ FT_BEGIN_HEADER * the face and don't need to be freed by the caller. * * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. + * the `FT_Err_Invalid_Argument` error code. * */ FT_EXPORT( FT_Error ) @@ -538,25 +543,24 @@ FT_BEGIN_HEADER PS_Private afont_private ); - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_EncodingType */ - /* */ - /* <Description> */ - /* An enumeration describing the `Encoding' entry in a Type 1 */ - /* dictionary. */ - /* */ - /* <Values> */ - /* T1_ENCODING_TYPE_NONE :: */ - /* T1_ENCODING_TYPE_ARRAY :: */ - /* T1_ENCODING_TYPE_STANDARD :: */ - /* T1_ENCODING_TYPE_ISOLATIN1 :: */ - /* T1_ENCODING_TYPE_EXPERT :: */ - /* */ - /* <Since> */ - /* 2.4.8 */ - /* */ + /************************************************************************** + * + * @enum: + * T1_EncodingType + * + * @description: + * An enumeration describing the 'Encoding' entry in a Type 1 dictionary. + * + * @values: + * T1_ENCODING_TYPE_NONE :: + * T1_ENCODING_TYPE_ARRAY :: + * T1_ENCODING_TYPE_STANDARD :: + * T1_ENCODING_TYPE_ISOLATIN1 :: + * T1_ENCODING_TYPE_EXPERT :: + * + * @since: + * 2.4.8 + */ typedef enum T1_EncodingType_ { T1_ENCODING_TYPE_NONE = 0, @@ -568,66 +572,66 @@ FT_BEGIN_HEADER } T1_EncodingType; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* PS_Dict_Keys */ - /* */ - /* <Description> */ - /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */ - /* the Type~1 dictionary entry to retrieve. */ - /* */ - /* <Values> */ - /* PS_DICT_FONT_TYPE :: */ - /* PS_DICT_FONT_MATRIX :: */ - /* PS_DICT_FONT_BBOX :: */ - /* PS_DICT_PAINT_TYPE :: */ - /* PS_DICT_FONT_NAME :: */ - /* PS_DICT_UNIQUE_ID :: */ - /* PS_DICT_NUM_CHAR_STRINGS :: */ - /* PS_DICT_CHAR_STRING_KEY :: */ - /* PS_DICT_CHAR_STRING :: */ - /* PS_DICT_ENCODING_TYPE :: */ - /* PS_DICT_ENCODING_ENTRY :: */ - /* PS_DICT_NUM_SUBRS :: */ - /* PS_DICT_SUBR :: */ - /* PS_DICT_STD_HW :: */ - /* PS_DICT_STD_VW :: */ - /* PS_DICT_NUM_BLUE_VALUES :: */ - /* PS_DICT_BLUE_VALUE :: */ - /* PS_DICT_BLUE_FUZZ :: */ - /* PS_DICT_NUM_OTHER_BLUES :: */ - /* PS_DICT_OTHER_BLUE :: */ - /* PS_DICT_NUM_FAMILY_BLUES :: */ - /* PS_DICT_FAMILY_BLUE :: */ - /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */ - /* PS_DICT_FAMILY_OTHER_BLUE :: */ - /* PS_DICT_BLUE_SCALE :: */ - /* PS_DICT_BLUE_SHIFT :: */ - /* PS_DICT_NUM_STEM_SNAP_H :: */ - /* PS_DICT_STEM_SNAP_H :: */ - /* PS_DICT_NUM_STEM_SNAP_V :: */ - /* PS_DICT_STEM_SNAP_V :: */ - /* PS_DICT_FORCE_BOLD :: */ - /* PS_DICT_RND_STEM_UP :: */ - /* PS_DICT_MIN_FEATURE :: */ - /* PS_DICT_LEN_IV :: */ - /* PS_DICT_PASSWORD :: */ - /* PS_DICT_LANGUAGE_GROUP :: */ - /* PS_DICT_VERSION :: */ - /* PS_DICT_NOTICE :: */ - /* PS_DICT_FULL_NAME :: */ - /* PS_DICT_FAMILY_NAME :: */ - /* PS_DICT_WEIGHT :: */ - /* PS_DICT_IS_FIXED_PITCH :: */ - /* PS_DICT_UNDERLINE_POSITION :: */ - /* PS_DICT_UNDERLINE_THICKNESS :: */ - /* PS_DICT_FS_TYPE :: */ - /* PS_DICT_ITALIC_ANGLE :: */ - /* */ - /* <Since> */ - /* 2.4.8 */ - /* */ + /************************************************************************** + * + * @enum: + * PS_Dict_Keys + * + * @description: + * An enumeration used in calls to @FT_Get_PS_Font_Value to identify the + * Type~1 dictionary entry to retrieve. + * + * @values: + * PS_DICT_FONT_TYPE :: + * PS_DICT_FONT_MATRIX :: + * PS_DICT_FONT_BBOX :: + * PS_DICT_PAINT_TYPE :: + * PS_DICT_FONT_NAME :: + * PS_DICT_UNIQUE_ID :: + * PS_DICT_NUM_CHAR_STRINGS :: + * PS_DICT_CHAR_STRING_KEY :: + * PS_DICT_CHAR_STRING :: + * PS_DICT_ENCODING_TYPE :: + * PS_DICT_ENCODING_ENTRY :: + * PS_DICT_NUM_SUBRS :: + * PS_DICT_SUBR :: + * PS_DICT_STD_HW :: + * PS_DICT_STD_VW :: + * PS_DICT_NUM_BLUE_VALUES :: + * PS_DICT_BLUE_VALUE :: + * PS_DICT_BLUE_FUZZ :: + * PS_DICT_NUM_OTHER_BLUES :: + * PS_DICT_OTHER_BLUE :: + * PS_DICT_NUM_FAMILY_BLUES :: + * PS_DICT_FAMILY_BLUE :: + * PS_DICT_NUM_FAMILY_OTHER_BLUES :: + * PS_DICT_FAMILY_OTHER_BLUE :: + * PS_DICT_BLUE_SCALE :: + * PS_DICT_BLUE_SHIFT :: + * PS_DICT_NUM_STEM_SNAP_H :: + * PS_DICT_STEM_SNAP_H :: + * PS_DICT_NUM_STEM_SNAP_V :: + * PS_DICT_STEM_SNAP_V :: + * PS_DICT_FORCE_BOLD :: + * PS_DICT_RND_STEM_UP :: + * PS_DICT_MIN_FEATURE :: + * PS_DICT_LEN_IV :: + * PS_DICT_PASSWORD :: + * PS_DICT_LANGUAGE_GROUP :: + * PS_DICT_VERSION :: + * PS_DICT_NOTICE :: + * PS_DICT_FULL_NAME :: + * PS_DICT_FAMILY_NAME :: + * PS_DICT_WEIGHT :: + * PS_DICT_IS_FIXED_PITCH :: + * PS_DICT_UNDERLINE_POSITION :: + * PS_DICT_UNDERLINE_THICKNESS :: + * PS_DICT_FS_TYPE :: + * PS_DICT_ITALIC_ANGLE :: + * + * @since: + * 2.4.8 + */ typedef enum PS_Dict_Keys_ { /* conventionally in the font dictionary */ @@ -687,7 +691,7 @@ FT_BEGIN_HEADER } PS_Dict_Keys; - /************************************************************************ + /************************************************************************** * * @function: * FT_Get_PS_Font_Value @@ -697,57 +701,57 @@ FT_BEGIN_HEADER * * @input: * face :: - * PostScript face handle. + * PostScript face handle. * * key :: - * An enumeration value representing the dictionary key to retrieve. + * An enumeration value representing the dictionary key to retrieve. * * idx :: - * For array values, this specifies the index to be returned. + * For array values, this specifies the index to be returned. * * value :: - * A pointer to memory into which to write the value. + * A pointer to memory into which to write the value. * * valen_len :: - * The size, in bytes, of the memory supplied for the value. + * The size, in bytes, of the memory supplied for the value. * * @output: * value :: - * The value matching the above key, if it exists. + * The value matching the above key, if it exists. * * @return: - * The amount of memory (in bytes) required to hold the requested - * value (if it exists, -1 otherwise). + * The amount of memory (in bytes) required to hold the requested value + * (if it exists, -1 otherwise). * * @note: * The values returned are not pointers into the internal structures of - * the face, but are `fresh' copies, so that the memory containing them + * the face, but are 'fresh' copies, so that the memory containing them * belongs to the calling application. This also enforces the - * `read-only' nature of these values, i.e., this function cannot be + * 'read-only' nature of these values, i.e., this function cannot be * used to manipulate the face. * - * `value' is a void pointer because the values returned can be of + * `value` is a void pointer because the values returned can be of * various types. * - * If either `value' is NULL or `value_len' is too small, just the + * If either `value` is `NULL` or `value_len` is too small, just the * required memory size for the requested entry is returned. * - * The `idx' parameter is used, not only to retrieve elements of, for + * The `idx` parameter is used, not only to retrieve elements of, for * example, the FontMatrix or FontBBox, but also to retrieve name keys * from the CharStrings dictionary, and the charstrings themselves. It * is ignored for atomic values. * - * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To - * get the value as in the font stream, you need to divide by - * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale). + * `PS_DICT_BLUE_SCALE` returns a value that is scaled up by 1000. To + * get the value as in the font stream, you need to divide by 65536000.0 + * (to remove the FT_Fixed scale, and the x1000 scale). * * IMPORTANT: Only key/value pairs read by the FreeType interpreter can - * be retrieved. So, for example, PostScript procedures such as NP, - * ND, and RD are not available. Arbitrary keys are, obviously, not be + * be retrieved. So, for example, PostScript procedures such as NP, ND, + * and RD are not available. Arbitrary keys are, obviously, not be * available either. * * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. + * the `FT_Err_Invalid_Argument` error code. * * @since: * 2.4.8 diff --git a/src/3rdparty/freetype/include/freetype/ttnameid.h b/src/3rdparty/freetype/include/freetype/ttnameid.h index 8605183dc7..cc677de75a 100644 --- a/src/3rdparty/freetype/include/freetype/ttnameid.h +++ b/src/3rdparty/freetype/include/freetype/ttnameid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttnameid.h */ -/* */ -/* TrueType name ID definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttnameid.h + * + * TrueType name ID definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTNAMEID_H_ @@ -26,53 +26,54 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ + /************************************************************************** + * + * @section: + * truetype_tables + */ - /*************************************************************************/ - /* */ - /* Possible values for the `platform' identifier code in the name */ - /* records of an SFNT `name' table. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Possible values for the 'platform' identifier code in the name records + * of an SFNT 'name' table. + * + */ - /*********************************************************************** + /************************************************************************** * * @enum: * TT_PLATFORM_XXX * * @description: - * A list of valid values for the `platform_id' identifier code in + * A list of valid values for the `platform_id` identifier code in * @FT_CharMapRec and @FT_SfntName structures. * * @values: * TT_PLATFORM_APPLE_UNICODE :: * Used by Apple to indicate a Unicode character map and/or name entry. - * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note + * See @TT_APPLE_ID_XXX for corresponding `encoding_id` values. Note * that name entries in this format are coded as big-endian UCS-2 * character codes _only_. * * TT_PLATFORM_MACINTOSH :: - * Used by Apple to indicate a MacOS-specific charmap and/or name entry. - * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that - * most TrueType fonts contain an Apple roman charmap to be usable on - * MacOS systems (even if they contain a Microsoft charmap as well). + * Used by Apple to indicate a MacOS-specific charmap and/or name + * entry. See @TT_MAC_ID_XXX for corresponding `encoding_id` values. + * Note that most TrueType fonts contain an Apple roman charmap to be + * usable on MacOS systems (even if they contain a Microsoft charmap as + * well). * * TT_PLATFORM_ISO :: - * This value was used to specify ISO/IEC 10646 charmaps. It is however - * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding - * `encoding_id' values. + * This value was used to specify ISO/IEC 10646 charmaps. It is + * however now deprecated. See @TT_ISO_ID_XXX for a list of + * corresponding `encoding_id` values. * * TT_PLATFORM_MICROSOFT :: * Used by Microsoft to indicate Windows-specific charmaps. See - * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. + * @TT_MS_ID_XXX for a list of corresponding `encoding_id` values. * Note that most fonts contain a Unicode charmap using - * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). + * (`TT_PLATFORM_MICROSOFT`, @TT_MS_ID_UNICODE_CS). * * TT_PLATFORM_CUSTOM :: * Used to indicate application-specific charmaps. @@ -91,13 +92,13 @@ FT_BEGIN_HEADER #define TT_PLATFORM_ADOBE 7 /* artificial */ - /*********************************************************************** + /************************************************************************** * * @enum: * TT_APPLE_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for + * A list of valid values for the `encoding_id` for * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. * * @values: @@ -117,8 +118,8 @@ FT_BEGIN_HEADER * Unicode 3.1 and beyond, using UTF-32. * * TT_APPLE_ID_VARIANT_SELECTOR :: - * From Adobe, not Apple. Not a normal cmap. Specifies variations - * on a real cmap. + * From Adobe, not Apple. Not a normal cmap. Specifies variations on + * a real cmap. * * TT_APPLE_ID_FULL_UNICODE :: * Used for fallback fonts that provide complete Unicode coverage with @@ -134,13 +135,13 @@ FT_BEGIN_HEADER #define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */ - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MAC_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for + * A list of valid values for the `encoding_id` for * @TT_PLATFORM_MACINTOSH charmaps and name entries. */ @@ -180,14 +181,14 @@ FT_BEGIN_HEADER #define TT_MAC_ID_UNINTERP 32 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_ISO_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ISO charmaps and name entries. + * A list of valid values for the `encoding_id` for @TT_PLATFORM_ISO + * charmaps and name entries. * * Their use is now deprecated. * @@ -205,13 +206,13 @@ FT_BEGIN_HEADER #define TT_ISO_ID_8859_1 2 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MS_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for + * A list of valid values for the `encoding_id` for * @TT_PLATFORM_MICROSOFT charmaps and name entries. * * @values: @@ -219,16 +220,15 @@ FT_BEGIN_HEADER * Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL. * * TT_MS_ID_UNICODE_CS :: - * Microsoft WGL4 charmap, matching Unicode. See - * @FT_ENCODING_UNICODE. + * Microsoft WGL4 charmap, matching Unicode. See @FT_ENCODING_UNICODE. * * TT_MS_ID_SJIS :: * Shift JIS Japanese encoding. See @FT_ENCODING_SJIS. * * TT_MS_ID_PRC :: * Chinese encodings as used in the People's Republic of China (PRC). - * This means the encodings GB~2312 and its supersets GBK and - * GB~18030. See @FT_ENCODING_PRC. + * This means the encodings GB~2312 and its supersets GBK and GB~18030. + * See @FT_ENCODING_PRC. * * TT_MS_ID_BIG_5 :: * Traditional Chinese as used in Taiwan and Hong Kong. See @@ -258,14 +258,14 @@ FT_BEGIN_HEADER #define TT_MS_ID_GB2312 TT_MS_ID_PRC - /*********************************************************************** + /************************************************************************** * * @enum: * TT_ADOBE_ID_XXX * * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! + * A list of valid values for the `encoding_id` for @TT_PLATFORM_ADOBE + * charmaps. This is a FreeType-specific extension! * * @values: * TT_ADOBE_ID_STANDARD :: @@ -284,14 +284,14 @@ FT_BEGIN_HEADER #define TT_ADOBE_ID_LATIN_1 3 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MAC_LANGID_XXX * * @description: * Possible values of the language identifier field in the name records - * of the SFNT `name' table if the `platform' identifier code is + * of the SFNT 'name' table if the 'platform' identifier code is * @TT_PLATFORM_MACINTOSH. These values are also used as return values * for function @FT_Get_CMap_Language_ID. * @@ -424,24 +424,24 @@ FT_BEGIN_HEADER #define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 - /*********************************************************************** + /************************************************************************** * * @enum: * TT_MS_LANGID_XXX * * @description: * Possible values of the language identifier field in the name records - * of the SFNT `name' table if the `platform' identifier code is + * of the SFNT 'name' table if the 'platform' identifier code is * @TT_PLATFORM_MICROSOFT. These values are also used as return values * for function @FT_Get_CMap_Language_ID. * * The canonical source for Microsoft's IDs is * - * https://www.microsoft.com/globaldev/reference/lcid-all.mspx , + * https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings , * * however, we only provide macros for language identifiers present in * the OpenType specification: Microsoft has abandoned the concept of - * LCIDs (language code identifiers), and format~1 of the `name' table + * LCIDs (language code identifiers), and format~1 of the 'name' table * provides a better mechanism for languages not covered here. * * More legacy values not listed in the reference can be found in the @@ -780,14 +780,14 @@ FT_BEGIN_HEADER TT_MS_LANGID_UIGHUR_PRC - /*********************************************************************** + /************************************************************************** * * @enum: * TT_NAME_ID_XXX * * @description: - * Possible values of the `name' identifier field in the name records of - * an SFNT `name' table. These values are platform independent. + * Possible values of the 'name' identifier field in the name records of + * an SFNT 'name' table. These values are platform independent. */ #define TT_NAME_ID_COPYRIGHT 0 @@ -834,14 +834,14 @@ FT_BEGIN_HEADER #define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY - /*********************************************************************** + /************************************************************************** * * @enum: * TT_UCR_XXX * * @description: - * Possible bit mask values for the `ulUnicodeRangeX' fields in an SFNT - * `OS/2' table. + * Possible bit mask values for the `ulUnicodeRangeX` fields in an SFNT + * 'OS/2' table. */ /* ulUnicodeRange1 */ diff --git a/src/3rdparty/freetype/include/freetype/tttables.h b/src/3rdparty/freetype/include/freetype/tttables.h index ce6a61779c..d04f810218 100644 --- a/src/3rdparty/freetype/include/freetype/tttables.h +++ b/src/3rdparty/freetype/include/freetype/tttables.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* tttables.h */ -/* */ -/* Basic SFNT/TrueType tables definitions and interface */ -/* (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * tttables.h + * + * Basic SFNT/TrueType tables definitions and interface + * (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTTABLES_H_ @@ -33,53 +33,55 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ - /* <Title> */ - /* TrueType Tables */ - /* */ - /* <Abstract> */ - /* TrueType specific table types and functions. */ - /* */ - /* <Description> */ - /* This section contains definitions of some basic tables specific to */ - /* TrueType and OpenType as well as some routines used to access and */ - /* process them. */ - /* */ - /* <Order> */ - /* TT_Header */ - /* TT_HoriHeader */ - /* TT_VertHeader */ - /* TT_OS2 */ - /* TT_Postscript */ - /* TT_PCLT */ - /* TT_MaxProfile */ - /* */ - /* FT_Sfnt_Tag */ - /* FT_Get_Sfnt_Table */ - /* FT_Load_Sfnt_Table */ - /* FT_Sfnt_Table_Info */ - /* */ - /* FT_Get_CMap_Language_ID */ - /* FT_Get_CMap_Format */ - /* */ - /* FT_PARAM_TAG_UNPATENTED_HINTING */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Header */ - /* */ - /* <Description> */ - /* A structure to model a TrueType font header table. All fields */ - /* follow the OpenType specification. */ - /* */ + /************************************************************************** + * + * @section: + * truetype_tables + * + * @title: + * TrueType Tables + * + * @abstract: + * TrueType-specific table types and functions. + * + * @description: + * This section contains definitions of some basic tables specific to + * TrueType and OpenType as well as some routines used to access and + * process them. + * + * @order: + * TT_Header + * TT_HoriHeader + * TT_VertHeader + * TT_OS2 + * TT_Postscript + * TT_PCLT + * TT_MaxProfile + * + * FT_Sfnt_Tag + * FT_Get_Sfnt_Table + * FT_Load_Sfnt_Table + * FT_Sfnt_Table_Info + * + * FT_Get_CMap_Language_ID + * FT_Get_CMap_Format + * + * FT_PARAM_TAG_UNPATENTED_HINTING + * + */ + + + /************************************************************************** + * + * @struct: + * TT_Header + * + * @description: + * A structure to model a TrueType font header table. All fields follow + * the OpenType specification. The 64-bit timestamps are stored in + * two-element arrays `Created` and `Modified`, first the upper then + * the lower 32~bits. + */ typedef struct TT_Header_ { FT_Fixed Table_Version; @@ -91,8 +93,8 @@ FT_BEGIN_HEADER FT_UShort Flags; FT_UShort Units_Per_EM; - FT_Long Created [2]; - FT_Long Modified[2]; + FT_ULong Created [2]; + FT_ULong Modified[2]; FT_Short xMin; FT_Short yMin; @@ -109,93 +111,93 @@ FT_BEGIN_HEADER } TT_Header; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_HoriHeader */ - /* */ - /* <Description> */ - /* A structure to model a TrueType horizontal header, the `hhea' */ - /* table, as well as the corresponding horizontal metrics table, */ - /* `hmtx'. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of all */ - /* glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoAscender' field */ - /* of the `OS/2' table instead if you want */ - /* the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the distance */ - /* from the baseline to the bottom-most of */ - /* all glyph points found in the font. It */ - /* is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the `OS/2' table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Width_Max :: This field is the maximum of all advance */ - /* widths found in the font. It can be */ - /* used to compute the maximum width of an */ - /* arbitrary string of text. */ - /* */ - /* min_Left_Side_Bearing :: The minimum left side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Right_Side_Bearing :: The minimum right side bearing of all */ - /* glyphs within the font. */ - /* */ - /* xMax_Extent :: The maximum horizontal extent (i.e., the */ - /* `width' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ - /* table -- this value can be smaller than */ - /* the total number of glyphs in the font. */ - /* */ - /* long_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */ - /* `caret_Slope_Run', and `caret_Offset'. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_HoriHeader + * + * @description: + * A structure to model a TrueType horizontal header, the 'hhea' table, + * as well as the corresponding horizontal metrics table, 'hmtx'. + * + * @fields: + * Version :: + * The table version. + * + * Ascender :: + * The font's ascender, i.e., the distance from the baseline to the + * top-most of all glyph points found in the font. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoAscender` field of the 'OS/2' table instead + * if you want the correct one. + * + * Descender :: + * The font's descender, i.e., the distance from the baseline to the + * bottom-most of all glyph points found in the font. It is negative. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoDescender` field of the 'OS/2' table + * instead if you want the correct one. + * + * Line_Gap :: + * The font's line gap, i.e., the distance to add to the ascender and + * descender to get the BTB, i.e., the baseline-to-baseline distance + * for the font. + * + * advance_Width_Max :: + * This field is the maximum of all advance widths found in the font. + * It can be used to compute the maximum width of an arbitrary string + * of text. + * + * min_Left_Side_Bearing :: + * The minimum left side bearing of all glyphs within the font. + * + * min_Right_Side_Bearing :: + * The minimum right side bearing of all glyphs within the font. + * + * xMax_Extent :: + * The maximum horizontal extent (i.e., the 'width' of a glyph's + * bounding box) for all glyphs in the font. + * + * caret_Slope_Rise :: + * The rise coefficient of the cursor's slope of the cursor + * (slope=rise/run). + * + * caret_Slope_Run :: + * The run coefficient of the cursor's slope. + * + * caret_Offset :: + * The cursor's offset for slanted fonts. + * + * Reserved :: + * 8~reserved bytes. + * + * metric_Data_Format :: + * Always~0. + * + * number_Of_HMetrics :: + * Number of HMetrics entries in the 'hmtx' table -- this value can be + * smaller than the total number of glyphs in the font. + * + * long_metrics :: + * A pointer into the 'hmtx' table. + * + * short_metrics :: + * A pointer into the 'hmtx' table. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `caret_Slope_Rise`, + * `caret_Slope_Run`, and `caret_Offset`. + */ typedef struct TT_HoriHeader_ { FT_Fixed Version; @@ -219,7 +221,7 @@ FT_BEGIN_HEADER /* The following fields are not defined by the OpenType specification */ /* but they are used to connect the metrics header to the relevant */ - /* `hmtx' table. */ + /* 'hmtx' table. */ void* long_metrics; void* short_metrics; @@ -227,97 +229,93 @@ FT_BEGIN_HEADER } TT_HoriHeader; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_VertHeader */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType vertical header, the `vhea' */ - /* table, as well as the corresponding vertical metrics table, */ - /* `vmtx'. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of */ - /* all glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoAscender' */ - /* field of the `OS/2' table instead if */ - /* you want the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the */ - /* distance from the baseline to the */ - /* bottom-most of all glyph points found */ - /* in the font. It is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the `OS/2' table instead if */ - /* you want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Height_Max :: This field is the maximum of all */ - /* advance heights found in the font. It */ - /* can be used to compute the maximum */ - /* height of an arbitrary string of text. */ - /* */ - /* min_Top_Side_Bearing :: The minimum top side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ - /* glyphs within the font. */ - /* */ - /* yMax_Extent :: The maximum vertical extent (i.e., the */ - /* `height' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_VMetrics :: Number of VMetrics entries in the */ - /* `vmtx' table -- this value can be */ - /* smaller than the total number of glyphs */ - /* in the font. */ - /* */ - /* long_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `Ascender', */ - /* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */ - /* and `caret_Offset'. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_VertHeader + * + * @description: + * A structure used to model a TrueType vertical header, the 'vhea' + * table, as well as the corresponding vertical metrics table, 'vmtx'. + * + * @fields: + * Version :: + * The table version. + * + * Ascender :: + * The font's ascender, i.e., the distance from the baseline to the + * top-most of all glyph points found in the font. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoAscender` field of the 'OS/2' table instead + * if you want the correct one. + * + * Descender :: + * The font's descender, i.e., the distance from the baseline to the + * bottom-most of all glyph points found in the font. It is negative. + * + * This value is invalid in many fonts, as it is usually set by the + * font designer, and often reflects only a portion of the glyphs found + * in the font (maybe ASCII). + * + * You should use the `sTypoDescender` field of the 'OS/2' table + * instead if you want the correct one. + * + * Line_Gap :: + * The font's line gap, i.e., the distance to add to the ascender and + * descender to get the BTB, i.e., the baseline-to-baseline distance + * for the font. + * + * advance_Height_Max :: + * This field is the maximum of all advance heights found in the font. + * It can be used to compute the maximum height of an arbitrary string + * of text. + * + * min_Top_Side_Bearing :: + * The minimum top side bearing of all glyphs within the font. + * + * min_Bottom_Side_Bearing :: + * The minimum bottom side bearing of all glyphs within the font. + * + * yMax_Extent :: + * The maximum vertical extent (i.e., the 'height' of a glyph's + * bounding box) for all glyphs in the font. + * + * caret_Slope_Rise :: + * The rise coefficient of the cursor's slope of the cursor + * (slope=rise/run). + * + * caret_Slope_Run :: + * The run coefficient of the cursor's slope. + * + * caret_Offset :: + * The cursor's offset for slanted fonts. + * + * Reserved :: + * 8~reserved bytes. + * + * metric_Data_Format :: + * Always~0. + * + * number_Of_VMetrics :: + * Number of VMetrics entries in the 'vmtx' table -- this value can be + * smaller than the total number of glyphs in the font. + * + * long_metrics :: + * A pointer into the 'vmtx' table. + * + * short_metrics :: + * A pointer into the 'vmtx' table. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `Ascender`, `Descender`, + * `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`. + */ typedef struct TT_VertHeader_ { FT_Fixed Version; @@ -341,7 +339,7 @@ FT_BEGIN_HEADER /* The following fields are not defined by the OpenType specification */ /* but they are used to connect the metrics header to the relevant */ - /* `vmtx' table. */ + /* 'vmtx' table. */ void* long_metrics; void* short_metrics; @@ -349,33 +347,31 @@ FT_BEGIN_HEADER } TT_VertHeader; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_OS2 */ - /* */ - /* <Description> */ - /* A structure to model a TrueType `OS/2' table. All fields comply */ - /* to the OpenType specification. */ - /* */ - /* Note that we now support old Mac fonts that do not include an */ - /* `OS/2' table. In this case, the `version' field is always set to */ - /* 0xFFFF. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `sCapHeight', */ - /* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */ - /* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */ - /* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */ - /* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */ - /* `ySuperscriptXSize', `ySuperscriptYOffset', and */ - /* `ySuperscriptYSize'. */ - /* */ - /* Possible values for bits in the `ulUnicodeRangeX' fields are given */ - /* by the @TT_UCR_XXX macros. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_OS2 + * + * @description: + * A structure to model a TrueType 'OS/2' table. All fields comply to + * the OpenType specification. + * + * Note that we now support old Mac fonts that do not include an 'OS/2' + * table. In this case, the `version` field is always set to 0xFFFF. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`, + * `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`, + * `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`, + * `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`, + * `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`, + * `ySuperscriptYOffset`, and `ySuperscriptYSize`. + * + * Possible values for bits in the `ulUnicodeRangeX` fields are given by + * the @TT_UCR_XXX macros. + */ typedef struct TT_OS2_ { @@ -435,23 +431,23 @@ FT_BEGIN_HEADER } TT_OS2; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Postscript */ - /* */ - /* <Description> */ - /* A structure to model a TrueType `post' table. All fields comply */ - /* to the OpenType specification. This structure does not reference */ - /* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */ - /* retrieve them. */ - /* */ - /* <Note> */ - /* For an OpenType variation font, the values of the following fields */ - /* can change after a call to @FT_Set_Var_Design_Coordinates (and */ - /* friends) if the font contains an `MVAR' table: `underlinePosition' */ - /* and `underlineThickness'. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_Postscript + * + * @description: + * A structure to model a TrueType 'post' table. All fields comply to + * the OpenType specification. This structure does not reference a + * font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve + * them. + * + * @note: + * For an OpenType variation font, the values of the following fields can + * change after a call to @FT_Set_Var_Design_Coordinates (and friends) if + * the font contains an 'MVAR' table: `underlinePosition` and + * `underlineThickness`. + */ typedef struct TT_Postscript_ { FT_Fixed FormatType; @@ -464,21 +460,21 @@ FT_BEGIN_HEADER FT_ULong minMemType1; FT_ULong maxMemType1; - /* Glyph names follow in the `post' table, but we don't */ + /* Glyph names follow in the 'post' table, but we don't */ /* load them by default. */ } TT_Postscript; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_PCLT */ - /* */ - /* <Description> */ - /* A structure to model a TrueType `PCLT' table. All fields comply */ - /* to the OpenType specification. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_PCLT + * + * @description: + * A structure to model a TrueType 'PCLT' table. All fields comply to + * the OpenType specification. + */ typedef struct TT_PCLT_ { FT_Fixed Version; @@ -500,70 +496,75 @@ FT_BEGIN_HEADER } TT_PCLT; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_MaxProfile */ - /* */ - /* <Description> */ - /* The maximum profile (`maxp') table contains many max values, which */ - /* can be used to pre-allocate arrays for speeding up glyph loading */ - /* and hinting. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numGlyphs :: The number of glyphs in this TrueType */ - /* font. */ - /* */ - /* maxPoints :: The maximum number of points in a */ - /* non-composite TrueType glyph. See also */ - /* `maxCompositePoints'. */ - /* */ - /* maxContours :: The maximum number of contours in a */ - /* non-composite TrueType glyph. See also */ - /* `maxCompositeContours'. */ - /* */ - /* maxCompositePoints :: The maximum number of points in a */ - /* composite TrueType glyph. See also */ - /* `maxPoints'. */ - /* */ - /* maxCompositeContours :: The maximum number of contours in a */ - /* composite TrueType glyph. See also */ - /* `maxContours'. */ - /* */ - /* maxZones :: The maximum number of zones used for */ - /* glyph hinting. */ - /* */ - /* maxTwilightPoints :: The maximum number of points in the */ - /* twilight zone used for glyph hinting. */ - /* */ - /* maxStorage :: The maximum number of elements in the */ - /* storage area used for glyph hinting. */ - /* */ - /* maxFunctionDefs :: The maximum number of function */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxInstructionDefs :: The maximum number of instruction */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxStackElements :: The maximum number of stack elements used */ - /* during bytecode interpretation. */ - /* */ - /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ - /* used for glyph hinting. */ - /* */ - /* maxComponentElements :: The maximum number of simple (i.e., non- */ - /* composite) glyphs in a composite glyph. */ - /* */ - /* maxComponentDepth :: The maximum nesting depth of composite */ - /* glyphs. */ - /* */ - /* <Note> */ - /* This structure is only used during font loading. */ - /* */ + /************************************************************************** + * + * @struct: + * TT_MaxProfile + * + * @description: + * The maximum profile ('maxp') table contains many max values, which can + * be used to pre-allocate arrays for speeding up glyph loading and + * hinting. + * + * @fields: + * version :: + * The version number. + * + * numGlyphs :: + * The number of glyphs in this TrueType font. + * + * maxPoints :: + * The maximum number of points in a non-composite TrueType glyph. See + * also `maxCompositePoints`. + * + * maxContours :: + * The maximum number of contours in a non-composite TrueType glyph. + * See also `maxCompositeContours`. + * + * maxCompositePoints :: + * The maximum number of points in a composite TrueType glyph. See + * also `maxPoints`. + * + * maxCompositeContours :: + * The maximum number of contours in a composite TrueType glyph. See + * also `maxContours`. + * + * maxZones :: + * The maximum number of zones used for glyph hinting. + * + * maxTwilightPoints :: + * The maximum number of points in the twilight zone used for glyph + * hinting. + * + * maxStorage :: + * The maximum number of elements in the storage area used for glyph + * hinting. + * + * maxFunctionDefs :: + * The maximum number of function definitions in the TrueType bytecode + * for this font. + * + * maxInstructionDefs :: + * The maximum number of instruction definitions in the TrueType + * bytecode for this font. + * + * maxStackElements :: + * The maximum number of stack elements used during bytecode + * interpretation. + * + * maxSizeOfInstructions :: + * The maximum number of TrueType opcodes used for glyph hinting. + * + * maxComponentElements :: + * The maximum number of simple (i.e., non-composite) glyphs in a + * composite glyph. + * + * maxComponentDepth :: + * The maximum nesting depth of composite glyphs. + * + * @note: + * This structure is only used during font loading. + */ typedef struct TT_MaxProfile_ { FT_Fixed version; @@ -585,31 +586,38 @@ FT_BEGIN_HEADER } TT_MaxProfile; - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Sfnt_Tag */ - /* */ - /* <Description> */ - /* An enumeration to specify indices of SFNT tables loaded and parsed */ - /* by FreeType during initialization of an SFNT font. Used in the */ - /* @FT_Get_Sfnt_Table API function. */ - /* */ - /* <Values> */ - /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ - /* */ - /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */ - /* */ - /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */ - /* */ - /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */ - /* */ - /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader structure. */ - /* */ - /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */ - /* */ - /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */ - /* */ + /************************************************************************** + * + * @enum: + * FT_Sfnt_Tag + * + * @description: + * An enumeration to specify indices of SFNT tables loaded and parsed by + * FreeType during initialization of an SFNT font. Used in the + * @FT_Get_Sfnt_Table API function. + * + * @values: + * FT_SFNT_HEAD :: + * To access the font's @TT_Header structure. + * + * FT_SFNT_MAXP :: + * To access the font's @TT_MaxProfile structure. + * + * FT_SFNT_OS2 :: + * To access the font's @TT_OS2 structure. + * + * FT_SFNT_HHEA :: + * To access the font's @TT_HoriHeader structure. + * + * FT_SFNT_VHEA :: + * To access the font's @TT_VertHeader structure. + * + * FT_SFNT_POST :: + * To access the font's @TT_Postscript structure. + * + * FT_SFNT_PCLT :: + * To access the font's @TT_PCLT structure. + */ typedef enum FT_Sfnt_Tag_ { FT_SFNT_HEAD, @@ -624,7 +632,7 @@ FT_BEGIN_HEADER } FT_Sfnt_Tag; - /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */ + /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */ /* values instead */ #define ft_sfnt_head FT_SFNT_HEAD #define ft_sfnt_maxp FT_SFNT_MAXP @@ -635,44 +643,46 @@ FT_BEGIN_HEADER #define ft_sfnt_pclt FT_SFNT_PCLT - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Table */ - /* */ - /* <Description> */ - /* Return a pointer to a given SFNT table stored within a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source. */ - /* */ - /* tag :: The index of the SFNT table. */ - /* */ - /* <Return> */ - /* A type-less pointer to the table. This will be NULL in case of */ - /* error, or if the corresponding table was not found *OR* loaded */ - /* from the file. */ - /* */ - /* Use a typecast according to `tag' to access the structure */ - /* elements. */ - /* */ - /* <Note> */ - /* The table is owned by the face object and disappears with it. */ - /* */ - /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ - /* a list. */ - /* */ - /* Here an example how to access the `vhea' table: */ - /* */ - /* { */ - /* TT_VertHeader* vert_header; */ - /* */ - /* */ - /* vert_header = */ - /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */ - /* } */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_Sfnt_Table + * + * @description: + * Return a pointer to a given SFNT table stored within a face. + * + * @input: + * face :: + * A handle to the source. + * + * tag :: + * The index of the SFNT table. + * + * @return: + * A type-less pointer to the table. This will be `NULL` in case of + * error, or if the corresponding table was not found **OR** loaded from + * the file. + * + * Use a typecast according to `tag` to access the structure elements. + * + * @note: + * The table is owned by the face object and disappears with it. + * + * This function is only useful to access SFNT tables that are loaded by + * the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a + * list. + * + * @example: + * Here is an example demonstrating access to the 'vhea' table. + * + * ``` + * TT_VertHeader* vert_header; + * + * + * vert_header = + * (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); + * ``` + */ FT_EXPORT( void* ) FT_Get_Sfnt_Table( FT_Face face, FT_Sfnt_Tag tag ); @@ -691,8 +701,8 @@ FT_BEGIN_HEADER * A handle to the source face. * * tag :: - * The four-byte tag of the table to load. Use value~0 if you want - * to access the whole font file. Otherwise, you can use one of the + * The four-byte tag of the table to load. Use value~0 if you want to + * access the whole font file. Otherwise, you can use one of the * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new * one with @FT_MAKE_TAG. * @@ -706,10 +716,10 @@ FT_BEGIN_HEADER * * @inout: * length :: - * If the `length' parameter is NULL, try to load the whole table. + * If the `length` parameter is `NULL`, try to load the whole table. * Return an error code if it fails. * - * Else, if `*length' is~0, exit immediately while returning the + * Else, if `*length` is~0, exit immediately while returning the * table's (or file) full size in it. * * Else the number of bytes to read from the table or file, from the @@ -720,21 +730,21 @@ FT_BEGIN_HEADER * * @note: * If you need to determine the table's length you should first call this - * function with `*length' set to~0, as in the following example: + * function with `*length` set to~0, as in the following example: * - * { - * FT_ULong length = 0; + * ``` + * FT_ULong length = 0; * * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } + * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); + * if ( error ) { ... table does not exist ... } * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } + * buffer = malloc( length ); + * if ( buffer == NULL ) { ... not enough memory ... } * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } - * } + * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); + * if ( error ) { ... could not load table ... } + * ``` * * Note that structures like @TT_Header or @TT_OS2 can't be used with * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that @@ -768,14 +778,14 @@ FT_BEGIN_HEADER * * @inout: * tag :: - * The name tag of the SFNT table. If the value is NULL, `table_index' - * is ignored, and `length' returns the number of SFNT tables in the - * font. + * The name tag of the SFNT table. If the value is `NULL`, + * `table_index` is ignored, and `length` returns the number of SFNT + * tables in the font. * * @output: * length :: - * The length of the SFNT table (or the number of SFNT tables, depending - * on `tag'). + * The length of the SFNT table (or the number of SFNT tables, + * depending on `tag`). * * @return: * FreeType error code. 0~means success. @@ -792,46 +802,46 @@ FT_BEGIN_HEADER FT_ULong *length ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Language_ID */ - /* */ - /* <Description> */ - /* Return cmap language ID as specified in the OpenType standard. */ - /* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The language ID of `charmap'. If `charmap' doesn't belong to an */ - /* SFNT face, just return~0 as the default value. */ - /* */ - /* For a format~14 cmap (to access Unicode IVS), the return value is */ - /* 0xFFFFFFFF. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_CMap_Language_ID + * + * @description: + * Return cmap language ID as specified in the OpenType standard. + * Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. + * + * @input: + * charmap :: + * The target charmap. + * + * @return: + * The language ID of `charmap`. If `charmap` doesn't belong to an SFNT + * face, just return~0 as the default value. + * + * For a format~14 cmap (to access Unicode IVS), the return value is + * 0xFFFFFFFF. + */ FT_EXPORT( FT_ULong ) FT_Get_CMap_Language_ID( FT_CharMap charmap ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Format */ - /* */ - /* <Description> */ - /* Return the format of an SFNT `cmap' table. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The format of `charmap'. If `charmap' doesn't belong to an SFNT */ - /* face, return -1. */ - /* */ + /************************************************************************** + * + * @function: + * FT_Get_CMap_Format + * + * @description: + * Return the format of an SFNT 'cmap' table. + * + * @input: + * charmap :: + * The target charmap. + * + * @return: + * The format of `charmap`. If `charmap` doesn't belong to an SFNT face, + * return -1. + */ FT_EXPORT( FT_Long ) FT_Get_CMap_Format( FT_CharMap charmap ); diff --git a/src/3rdparty/freetype/include/freetype/tttags.h b/src/3rdparty/freetype/include/freetype/tttags.h index e5cee68a15..bd0986eff0 100644 --- a/src/3rdparty/freetype/include/freetype/tttags.h +++ b/src/3rdparty/freetype/include/freetype/tttags.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* tttags.h */ -/* */ -/* Tags for TrueType and OpenType tables (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * tttags.h + * + * Tags for TrueType and OpenType tables (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTAGS_H_ @@ -46,6 +46,8 @@ FT_BEGIN_HEADER #define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' ) #define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_COLR FT_MAKE_TAG( 'C', 'O', 'L', 'R' ) +#define TTAG_CPAL FT_MAKE_TAG( 'C', 'P', 'A', 'L' ) #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) #define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) #define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) diff --git a/src/3rdparty/freetype/include/ft2build.h b/src/3rdparty/freetype/include/ft2build.h index e7ce99bc94..e3f4887943 100644 --- a/src/3rdparty/freetype/include/ft2build.h +++ b/src/3rdparty/freetype/include/ft2build.h @@ -1,34 +1,36 @@ -/***************************************************************************/ -/* */ -/* ft2build.h */ -/* */ -/* FreeType 2 build and setup macros. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is the `entry point' for FreeType header file inclusions. It is */ - /* the only header file which should be included directly; all other */ - /* FreeType header files should be accessed with macro names (after */ - /* including `ft2build.h'). */ - /* */ - /* A typical example is */ - /* */ - /* #include <ft2build.h> */ - /* #include FT_FREETYPE_H */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ft2build.h + * + * FreeType 2 build and setup macros. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This is the 'entry point' for FreeType header file inclusions. It is + * the only header file which should be included directly; all other + * FreeType header files should be accessed with macro names (after + * including `ft2build.h`). + * + * A typical example is + * + * ``` + * #include <ft2build.h> + * #include FT_FREETYPE_H + * ``` + * + */ #ifndef FT2BUILD_H_ diff --git a/src/3rdparty/freetype/qt_attribution.json b/src/3rdparty/freetype/qt_attribution.json index b046ebc860..93a48ce208 100644 --- a/src/3rdparty/freetype/qt_attribution.json +++ b/src/3rdparty/freetype/qt_attribution.json @@ -7,7 +7,7 @@ "Description": "FreeType is a freely available software library to render fonts.", "Homepage": "http://www.freetype.org", - "Version": "2.9.1", + "Version": "2.10.1", "License": "Freetype Project License or GNU General Public License v2.0 only", "LicenseId": "FTL OR GPL-2.0", diff --git a/src/3rdparty/freetype/src/Jamfile b/src/3rdparty/freetype/src/Jamfile index 562480c94a..3ad2d5c962 100644 --- a/src/3rdparty/freetype/src/Jamfile +++ b/src/3rdparty/freetype/src/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/autofit/Jamfile b/src/3rdparty/freetype/src/autofit/Jamfile index 01b866ec61..ea69dee377 100644 --- a/src/3rdparty/freetype/src/autofit/Jamfile +++ b/src/3rdparty/freetype/src/autofit/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/autofit Jamfile # -# Copyright 2003-2018 by +# Copyright (C) 2003-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/autofit/afangles.c b/src/3rdparty/freetype/src/autofit/afangles.c index c65a3ae23e..9e1f7a21ff 100644 --- a/src/3rdparty/freetype/src/autofit/afangles.c +++ b/src/3rdparty/freetype/src/autofit/afangles.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* afangles.c */ -/* */ -/* Routines used to compute vector angles with limited accuracy */ -/* and very high speed. It also contains sorting routines (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afangles.c + * + * Routines used to compute vector angles with limited accuracy + * and very high speed. It also contains sorting routines (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" /* - * We are not using `af_angle_atan' anymore, but we keep the source - * code below just in case... + * We are not using `af_angle_atan' anymore, but we keep the source + * code below just in case... */ @@ -30,16 +30,16 @@ /* - * The trick here is to realize that we don't need a very accurate angle - * approximation. We are going to use the result of `af_angle_atan' to - * only compare the sign of angle differences, or check whether its - * magnitude is very small. + * The trick here is to realize that we don't need a very accurate angle + * approximation. We are going to use the result of `af_angle_atan' to + * only compare the sign of angle differences, or check whether its + * magnitude is very small. * - * The approximation + * The approximation * - * dy * PI / (|dx|+|dy|) + * dy * PI / (|dx|+|dy|) * - * should be enough, and much faster to compute. + * should be enough, and much faster to compute. */ FT_LOCAL_DEF( AF_Angle ) af_angle_atan( FT_Fixed dx, diff --git a/src/3rdparty/freetype/src/autofit/afangles.h b/src/3rdparty/freetype/src/autofit/afangles.h index f33f9e108e..18d7dae3a6 100644 --- a/src/3rdparty/freetype/src/autofit/afangles.h +++ b/src/3rdparty/freetype/src/autofit/afangles.h @@ -1,7 +1,7 @@ /* - * afangles.h + * afangles.h * - * This is a dummy file, used to please the build system. It is never - * included by the auto-fitter sources. + * This is a dummy file, used to please the build system. It is never + * included by the auto-fitter sources. * */ diff --git a/src/3rdparty/freetype/src/autofit/afblue.c b/src/3rdparty/freetype/src/autofit/afblue.c index e4078fd044..b99dbeb19c 100644 --- a/src/3rdparty/freetype/src/autofit/afblue.c +++ b/src/3rdparty/freetype/src/autofit/afblue.c @@ -1,22 +1,22 @@ /* This file has been generated by the Perl script `afblue.pl', */ /* using data from file `afblue.dat'. */ -/***************************************************************************/ -/* */ -/* afblue.c */ -/* */ -/* Auto-fitter data for blue strings (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.c + * + * Auto-fitter data for blue strings (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" @@ -296,6 +296,10 @@ '\0', '\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xA7', ' ', '\xE0', '\xB4', '\xB6', ' ', '\xE0', '\xB4', '\x98', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xA5', ' ', '\xE0', '\xB4', '\xB2', /* ട ഠ ധ ശ ഘ ച ഥ ല */ '\0', + '\xE1', '\xA0', '\xB3', ' ', '\xE1', '\xA0', '\xB4', ' ', '\xE1', '\xA0', '\xB6', ' ', '\xE1', '\xA0', '\xBD', ' ', '\xE1', '\xA1', '\x82', ' ', '\xE1', '\xA1', '\x8A', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xA1', '\xE2', '\x80', '\x8D', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xB3', '\xE2', '\x80', '\x8D', /* ᠳ ᠴ ᠶ ᠽ ᡂ ᡊ ‍ᡡ‍ ‍ᡳ‍ */ + '\0', + '\xE1', '\xA1', '\x83', /* ᡃ */ + '\0', '\xE1', '\x80', '\x81', ' ', '\xE1', '\x80', '\x82', ' ', '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\xA5', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* ခ ဂ င ဒ ဝ ၥ ၊ ။ */ '\0', '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x8E', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x95', ' ', '\xE1', '\x80', '\x97', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* င ဎ ဒ ပ ဗ ဝ ၊ ။ */ @@ -649,6 +653,9 @@ { AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, { AF_BLUE_STRING_MYANMAR_BOTTOM, 0 }, diff --git a/src/3rdparty/freetype/src/autofit/afblue.cin b/src/3rdparty/freetype/src/autofit/afblue.cin index 4913e2eb6f..6545d1fd43 100644 --- a/src/3rdparty/freetype/src/autofit/afblue.cin +++ b/src/3rdparty/freetype/src/autofit/afblue.cin @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afblue.c */ -/* */ -/* Auto-fitter data for blue strings (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.c + * + * Auto-fitter data for blue strings (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" diff --git a/src/3rdparty/freetype/src/autofit/afblue.dat b/src/3rdparty/freetype/src/autofit/afblue.dat index bc2f0d2754..46db43fe22 100644 --- a/src/3rdparty/freetype/src/autofit/afblue.dat +++ b/src/3rdparty/freetype/src/autofit/afblue.dat @@ -1,15 +1,15 @@ -// afblue.dat +// afblue.dat // -// Auto-fitter data for blue strings. +// Auto-fitter data for blue strings. // -// Copyright 2013-2018 by -// David Turner, Robert Wilhelm, and Werner Lemberg. +// Copyright (C) 2013-2019 by +// David Turner, Robert Wilhelm, and Werner Lemberg. // -// This file is part of the FreeType project, and may only be used, -// modified, and distributed under the terms of the FreeType project -// license, LICENSE.TXT. By continuing to use, modify, or distribute -// this file you indicate that you have read the license and -// understand and accept it fully. +// This file is part of the FreeType project, and may only be used, +// modified, and distributed under the terms of the FreeType project +// license, LICENSE.TXT. By continuing to use, modify, or distribute +// this file you indicate that you have read the license and +// understand and accept it fully. // This file contains data specific to blue zones. It gets processed by @@ -392,6 +392,11 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: AF_BLUE_STRING_MALAYALAM_BOTTOM "ട ഠ ധ ശ ഘ ച ഥ ല" + AF_BLUE_STRING_MONGOLIAN_TOP_BASE + "ᠳ ᠴ ᠶ ᠽ ᡂ ᡊ ‍ᡡ‍ ‍ᡳ‍" + AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE + "ᡃ" + AF_BLUE_STRING_MYANMAR_TOP "ခ ဂ င ဒ ဝ ၥ ၊ ။" AF_BLUE_STRING_MYANMAR_BOTTOM @@ -947,6 +952,11 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_MONG + { AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_MYMR { AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT } diff --git a/src/3rdparty/freetype/src/autofit/afblue.h b/src/3rdparty/freetype/src/autofit/afblue.h index de31e259c3..b69b1df521 100644 --- a/src/3rdparty/freetype/src/autofit/afblue.h +++ b/src/3rdparty/freetype/src/autofit/afblue.h @@ -1,22 +1,22 @@ /* This file has been generated by the Perl script `afblue.pl', */ /* using data from file `afblue.dat'. */ -/***************************************************************************/ -/* */ -/* afblue.h */ -/* */ -/* Auto-fitter data for blue strings (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.h + * + * Auto-fitter data for blue strings (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFBLUE_H_ @@ -212,56 +212,58 @@ FT_BEGIN_HEADER AF_BLUE_STRING_LISU_BOTTOM = 3506, AF_BLUE_STRING_MALAYALAM_TOP = 3538, AF_BLUE_STRING_MALAYALAM_BOTTOM = 3582, - AF_BLUE_STRING_MYANMAR_TOP = 3614, - AF_BLUE_STRING_MYANMAR_BOTTOM = 3646, - AF_BLUE_STRING_MYANMAR_ASCENDER = 3678, - AF_BLUE_STRING_MYANMAR_DESCENDER = 3706, - AF_BLUE_STRING_NKO_TOP = 3738, - AF_BLUE_STRING_NKO_BOTTOM = 3762, - AF_BLUE_STRING_NKO_SMALL_TOP = 3777, - AF_BLUE_STRING_NKO_SMALL_BOTTOM = 3786, - AF_BLUE_STRING_OL_CHIKI = 3798, - AF_BLUE_STRING_OLD_TURKIC_TOP = 3822, - AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 3837, - AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 3857, - AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 3897, - AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 3927, - AF_BLUE_STRING_OSAGE_SMALL_TOP = 3942, - AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 3982, - AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4022, - AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4047, - AF_BLUE_STRING_OSMANYA_TOP = 4062, - AF_BLUE_STRING_OSMANYA_BOTTOM = 4102, - AF_BLUE_STRING_SAURASHTRA_TOP = 4142, - AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4174, - AF_BLUE_STRING_SHAVIAN_TOP = 4194, - AF_BLUE_STRING_SHAVIAN_BOTTOM = 4204, - AF_BLUE_STRING_SHAVIAN_DESCENDER = 4229, - AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4239, - AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4274, - AF_BLUE_STRING_SINHALA_TOP = 4289, - AF_BLUE_STRING_SINHALA_BOTTOM = 4321, - AF_BLUE_STRING_SINHALA_DESCENDER = 4353, - AF_BLUE_STRING_SUNDANESE_TOP = 4397, - AF_BLUE_STRING_SUNDANESE_BOTTOM = 4421, - AF_BLUE_STRING_SUNDANESE_DESCENDER = 4453, - AF_BLUE_STRING_TAI_VIET_TOP = 4461, - AF_BLUE_STRING_TAI_VIET_BOTTOM = 4481, - AF_BLUE_STRING_TAMIL_TOP = 4493, - AF_BLUE_STRING_TAMIL_BOTTOM = 4525, - AF_BLUE_STRING_TELUGU_TOP = 4557, - AF_BLUE_STRING_TELUGU_BOTTOM = 4585, - AF_BLUE_STRING_THAI_TOP = 4613, - AF_BLUE_STRING_THAI_BOTTOM = 4637, - AF_BLUE_STRING_THAI_ASCENDER = 4665, - AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4677, - AF_BLUE_STRING_THAI_DESCENDER = 4689, - AF_BLUE_STRING_THAI_LARGE_DESCENDER = 4705, - AF_BLUE_STRING_THAI_DIGIT_TOP = 4713, - AF_BLUE_STRING_TIFINAGH = 4725, - AF_BLUE_STRING_VAI_TOP = 4757, - AF_BLUE_STRING_VAI_BOTTOM = 4789, - af_blue_1_1 = 4820, + AF_BLUE_STRING_MONGOLIAN_TOP_BASE = 3614, + AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE = 3658, + AF_BLUE_STRING_MYANMAR_TOP = 3662, + AF_BLUE_STRING_MYANMAR_BOTTOM = 3694, + AF_BLUE_STRING_MYANMAR_ASCENDER = 3726, + AF_BLUE_STRING_MYANMAR_DESCENDER = 3754, + AF_BLUE_STRING_NKO_TOP = 3786, + AF_BLUE_STRING_NKO_BOTTOM = 3810, + AF_BLUE_STRING_NKO_SMALL_TOP = 3825, + AF_BLUE_STRING_NKO_SMALL_BOTTOM = 3834, + AF_BLUE_STRING_OL_CHIKI = 3846, + AF_BLUE_STRING_OLD_TURKIC_TOP = 3870, + AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 3885, + AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 3905, + AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 3945, + AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 3975, + AF_BLUE_STRING_OSAGE_SMALL_TOP = 3990, + AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 4030, + AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4070, + AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4095, + AF_BLUE_STRING_OSMANYA_TOP = 4110, + AF_BLUE_STRING_OSMANYA_BOTTOM = 4150, + AF_BLUE_STRING_SAURASHTRA_TOP = 4190, + AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4222, + AF_BLUE_STRING_SHAVIAN_TOP = 4242, + AF_BLUE_STRING_SHAVIAN_BOTTOM = 4252, + AF_BLUE_STRING_SHAVIAN_DESCENDER = 4277, + AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4287, + AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4322, + AF_BLUE_STRING_SINHALA_TOP = 4337, + AF_BLUE_STRING_SINHALA_BOTTOM = 4369, + AF_BLUE_STRING_SINHALA_DESCENDER = 4401, + AF_BLUE_STRING_SUNDANESE_TOP = 4445, + AF_BLUE_STRING_SUNDANESE_BOTTOM = 4469, + AF_BLUE_STRING_SUNDANESE_DESCENDER = 4501, + AF_BLUE_STRING_TAI_VIET_TOP = 4509, + AF_BLUE_STRING_TAI_VIET_BOTTOM = 4529, + AF_BLUE_STRING_TAMIL_TOP = 4541, + AF_BLUE_STRING_TAMIL_BOTTOM = 4573, + AF_BLUE_STRING_TELUGU_TOP = 4605, + AF_BLUE_STRING_TELUGU_BOTTOM = 4633, + AF_BLUE_STRING_THAI_TOP = 4661, + AF_BLUE_STRING_THAI_BOTTOM = 4685, + AF_BLUE_STRING_THAI_ASCENDER = 4713, + AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4725, + AF_BLUE_STRING_THAI_DESCENDER = 4737, + AF_BLUE_STRING_THAI_LARGE_DESCENDER = 4753, + AF_BLUE_STRING_THAI_DIGIT_TOP = 4761, + AF_BLUE_STRING_TIFINAGH = 4773, + AF_BLUE_STRING_VAI_TOP = 4805, + AF_BLUE_STRING_VAI_BOTTOM = 4837, + af_blue_1_1 = 4868, #ifdef AF_CONFIG_OPTION_CJK AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1, AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203, @@ -355,24 +357,25 @@ FT_BEGIN_HEADER AF_BLUE_STRINGSET_LATP = 166, AF_BLUE_STRINGSET_LISU = 173, AF_BLUE_STRINGSET_MLYM = 176, - AF_BLUE_STRINGSET_MYMR = 179, - AF_BLUE_STRINGSET_NKOO = 184, - AF_BLUE_STRINGSET_NONE = 189, - AF_BLUE_STRINGSET_OLCK = 190, - AF_BLUE_STRINGSET_ORKH = 193, - AF_BLUE_STRINGSET_OSGE = 196, - AF_BLUE_STRINGSET_OSMA = 204, - AF_BLUE_STRINGSET_SAUR = 207, - AF_BLUE_STRINGSET_SHAW = 210, - AF_BLUE_STRINGSET_SINH = 216, - AF_BLUE_STRINGSET_SUND = 220, - AF_BLUE_STRINGSET_TAML = 224, - AF_BLUE_STRINGSET_TAVT = 227, - AF_BLUE_STRINGSET_TELU = 230, - AF_BLUE_STRINGSET_TFNG = 233, - AF_BLUE_STRINGSET_THAI = 236, - AF_BLUE_STRINGSET_VAII = 244, - af_blue_2_1 = 247, + AF_BLUE_STRINGSET_MONG = 179, + AF_BLUE_STRINGSET_MYMR = 182, + AF_BLUE_STRINGSET_NKOO = 187, + AF_BLUE_STRINGSET_NONE = 192, + AF_BLUE_STRINGSET_OLCK = 193, + AF_BLUE_STRINGSET_ORKH = 196, + AF_BLUE_STRINGSET_OSGE = 199, + AF_BLUE_STRINGSET_OSMA = 207, + AF_BLUE_STRINGSET_SAUR = 210, + AF_BLUE_STRINGSET_SHAW = 213, + AF_BLUE_STRINGSET_SINH = 219, + AF_BLUE_STRINGSET_SUND = 223, + AF_BLUE_STRINGSET_TAML = 227, + AF_BLUE_STRINGSET_TAVT = 230, + AF_BLUE_STRINGSET_TELU = 233, + AF_BLUE_STRINGSET_TFNG = 236, + AF_BLUE_STRINGSET_THAI = 239, + AF_BLUE_STRINGSET_VAII = 247, + af_blue_2_1 = 250, #ifdef AF_CONFIG_OPTION_CJK AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0, af_blue_2_1_1 = af_blue_2_1 + 2, diff --git a/src/3rdparty/freetype/src/autofit/afblue.hin b/src/3rdparty/freetype/src/autofit/afblue.hin index 682147cb30..30a28dafa5 100644 --- a/src/3rdparty/freetype/src/autofit/afblue.hin +++ b/src/3rdparty/freetype/src/autofit/afblue.hin @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afblue.h */ -/* */ -/* Auto-fitter data for blue strings (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afblue.h + * + * Auto-fitter data for blue strings (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFBLUE_H_ diff --git a/src/3rdparty/freetype/src/autofit/afcjk.c b/src/3rdparty/freetype/src/autofit/afcjk.c index 21b6bffa33..a61689bee3 100644 --- a/src/3rdparty/freetype/src/autofit/afcjk.c +++ b/src/3rdparty/freetype/src/autofit/afcjk.c @@ -1,24 +1,24 @@ -/***************************************************************************/ -/* */ -/* afcjk.c */ -/* */ -/* Auto-fitter hinting routines for CJK writing system (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afcjk.c + * + * Auto-fitter hinting routines for CJK writing system (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* - * The algorithm is based on akito's autohint patch, archived at + * The algorithm is based on akito's autohint patch, archived at * - * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/ + * https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/ * */ @@ -27,7 +27,6 @@ #include FT_INTERNAL_DEBUG_H #include "afglobal.h" -#include "afpic.h" #include "aflatin.h" #include "afcjk.h" @@ -44,14 +43,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afcjk +#define FT_COMPONENT afcjk /*************************************************************************/ @@ -92,23 +91,29 @@ AF_CJKMetricsRec dummy[1]; AF_Scaler scaler = &dummy->root.scaler; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = metrics->root.globals; -#endif - AF_StyleClass style_class = metrics->root.style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; + + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif - void* shaper_buf; const char* p; #ifdef FT_DEBUG_LEVEL_TRACE FT_ULong ch = 0; #endif - p = script_class->standard_charstring; + p = script_class->standard_charstring; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif /* We check a list of standard characters. The first match wins. */ @@ -193,10 +198,10 @@ goto Exit; /* - * We assume that the glyphs selected for the stem width - * computation are `featureless' enough so that the linking - * algorithm works fine without adjustments of its scoring - * function. + * We assume that the glyphs selected for the stem width + * computation are `featureless' enough so that the linking + * algorithm works fine without adjustments of its scoring + * function. */ af_latin_hints_link_segments( hints, 0, @@ -296,7 +301,14 @@ AF_Blue_Stringset bss = sc->blue_stringset; const AF_Blue_StringRec* bs = &af_blue_stringsets[bss]; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* we walk over the blue character strings as specified in the */ @@ -307,7 +319,9 @@ "==========================\n" "\n" )); +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ ) { @@ -483,8 +497,8 @@ if ( num_flats == 0 && num_fills == 0 ) { /* - * we couldn't find a single glyph to compute this blue zone, - * we will simply ignore it then + * we couldn't find a single glyph to compute this blue zone, + * we will simply ignore it then */ FT_TRACE5(( " empty\n" )); continue; @@ -565,15 +579,25 @@ FT_Bool started = 0, same_width = 1; FT_Fixed advance = 0, old_advance = 0; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* in all supported charmaps, digits have character codes 0x30-0x39 */ const char digits[] = "0 1 2 3 4 5 6 7 8 9"; const char* p; - p = digits; + p = digits; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif while ( *p ) { @@ -890,11 +914,11 @@ } /* - * now compute the `serif' segments + * now compute the `serif' segments * - * In Hanzi, some strokes are wider on one or both of the ends. - * We either identify the stems on the ends as serifs or remove - * the linkage, depending on the length of the stems. + * In Hanzi, some strokes are wider on one or both of the ends. + * We either identify the stems on the ends as serifs or remove + * the linkage, depending on the length of the stems. * */ @@ -1000,21 +1024,21 @@ scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale : hints->y_scale; - /*********************************************************************/ - /* */ - /* We begin by generating a sorted table of edges for the current */ - /* direction. To do so, we simply scan each segment and try to find */ - /* an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which is then processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the edges table is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ + /********************************************************************** + * + * We begin by generating a sorted table of edges for the current + * direction. To do so, we simply scan each segment and try to find + * an edge in our table that corresponds to its position. + * + * If no edge is found, we create and insert a new edge in the + * sorted table. Otherwise, we simply add the segment to the edge's + * list which is then processed in the second step to compute the + * edge's properties. + * + * Note that the edges table is sorted along the segment/edge + * position. + * + */ edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold, scale ); @@ -1114,17 +1138,17 @@ } } - /******************************************************************/ - /* */ - /* Good, we now compute each edge's properties according to the */ - /* segments found on its position. Basically, these are */ - /* */ - /* - the edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straight or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /******************************************************************/ + /******************************************************************* + * + * Good, we now compute each edge's properties according to the + * segments found on its position. Basically, these are + * + * - the edge's main direction + * - stem edge, serif edge or both (which defaults to stem then) + * - rounded edge, straight or both (which defaults to straight) + * - link for edge + * + */ /* first of all, set the `edge' field in each segment -- this is */ /* required in order to compute edge links */ @@ -1160,6 +1184,8 @@ seg = edge->first; + if ( !seg ) + goto Skip_Loop; do { @@ -1174,7 +1200,7 @@ /* check for links -- if seg->serif is set, then seg->link must */ /* be ignored */ - is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge ); + is_serif = FT_BOOL( seg->serif && seg->serif->edge != edge ); if ( seg->link || is_serif ) { @@ -1215,13 +1241,14 @@ edge2->flags |= AF_EDGE_SERIF; } else - edge->link = edge2; + edge->link = edge2; } seg = seg->edge_next; } while ( seg != edge->first ); + Skip_Loop: /* set the round/straight flags */ edge->flags = AF_EDGE_NORMAL; @@ -1364,8 +1391,8 @@ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics ); /* - * correct x_scale and y_scale when needed, since they may have - * been modified af_cjk_scale_dim above + * correct x_scale and y_scale when needed, since they may have + * been modified af_cjk_scale_dim above */ hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale; hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta; @@ -1384,21 +1411,21 @@ other_flags = 0; /* - * We snap the width of vertical stems for the monochrome and - * horizontal LCD rendering targets only. + * We snap the width of vertical stems for the monochrome and + * horizontal LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_HORZ_SNAP; /* - * We snap the width of horizontal stems for the monochrome and - * vertical LCD rendering targets only. + * We snap the width of horizontal stems for the monochrome and + * vertical LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels unless in `light' or `lcd' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; @@ -2094,8 +2121,8 @@ goto Exit; /* - * now hint the remaining edges (serifs and single) in order - * to complete our processing + * now hint the remaining edges (serifs and single) in order + * to complete our processing */ for ( edge = edges; edge < edge_limit; edge++ ) { diff --git a/src/3rdparty/freetype/src/autofit/afcjk.h b/src/3rdparty/freetype/src/autofit/afcjk.h index d229c0c9cf..59acae5342 100644 --- a/src/3rdparty/freetype/src/autofit/afcjk.h +++ b/src/3rdparty/freetype/src/autofit/afcjk.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afcjk.h */ -/* */ -/* Auto-fitter hinting routines for CJK writing system (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afcjk.h + * + * Auto-fitter hinting routines for CJK writing system (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFCJK_H_ @@ -41,9 +41,9 @@ FT_BEGIN_HEADER /* - * CJK glyphs tend to fill the square. So we have both vertical and - * horizontal blue zones. But some glyphs have flat bounding strokes that - * leave some space between neighbour glyphs. + * CJK glyphs tend to fill the square. So we have both vertical and + * horizontal blue zones. But some glyphs have flat bounding strokes that + * leave some space between neighbour glyphs. */ #define AF_CJK_IS_TOP_BLUE( b ) \ diff --git a/src/3rdparty/freetype/src/autofit/afcover.h b/src/3rdparty/freetype/src/autofit/afcover.h index 6eeb8fc9fb..ff207a97e0 100644 --- a/src/3rdparty/freetype/src/autofit/afcover.h +++ b/src/3rdparty/freetype/src/autofit/afcover.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afcover.h */ -/* */ -/* Auto-fitter coverages (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afcover.h + * + * Auto-fitter coverages (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* This header file can be included multiple times. */ diff --git a/src/3rdparty/freetype/src/autofit/afdummy.c b/src/3rdparty/freetype/src/autofit/afdummy.c index f30c517cbb..7e07a41e7d 100644 --- a/src/3rdparty/freetype/src/autofit/afdummy.c +++ b/src/3rdparty/freetype/src/autofit/afdummy.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afdummy.c */ -/* */ -/* Auto-fitter dummy routines to be used if no hinting should be */ -/* performed (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afdummy.c + * + * Auto-fitter dummy routines to be used if no hinting should be + * performed (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afdummy.h" @@ -38,13 +38,15 @@ static FT_Error - af_dummy_hints_apply( FT_UInt glyph_index, - AF_GlyphHints hints, - FT_Outline* outline ) + af_dummy_hints_apply( FT_UInt glyph_index, + AF_GlyphHints hints, + FT_Outline* outline, + AF_StyleMetrics metrics ) { FT_Error error; FT_UNUSED( glyph_index ); + FT_UNUSED( metrics ); error = af_glyph_hints_reload( hints, outline ); diff --git a/src/3rdparty/freetype/src/autofit/afdummy.h b/src/3rdparty/freetype/src/autofit/afdummy.h index b382acd92a..ab9227d35d 100644 --- a/src/3rdparty/freetype/src/autofit/afdummy.h +++ b/src/3rdparty/freetype/src/autofit/afdummy.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afdummy.h */ -/* */ -/* Auto-fitter dummy routines to be used if no hinting should be */ -/* performed (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afdummy.h + * + * Auto-fitter dummy routines to be used if no hinting should be + * performed (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFDUMMY_H_ diff --git a/src/3rdparty/freetype/src/autofit/aferrors.h b/src/3rdparty/freetype/src/autofit/aferrors.h index e5de54360f..2ec336f72c 100644 --- a/src/3rdparty/freetype/src/autofit/aferrors.h +++ b/src/3rdparty/freetype/src/autofit/aferrors.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* aferrors.h */ -/* */ -/* Autofitter error codes (specification only). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the Autofitter error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * aferrors.h + * + * Autofitter error codes (specification only). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the Autofitter error enumeration + * constants. + * + */ #ifndef AFERRORS_H_ #define AFERRORS_H_ diff --git a/src/3rdparty/freetype/src/autofit/afglobal.c b/src/3rdparty/freetype/src/autofit/afglobal.c index 3d09c53e8a..6a9a1e5aaa 100644 --- a/src/3rdparty/freetype/src/autofit/afglobal.c +++ b/src/3rdparty/freetype/src/autofit/afglobal.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afglobal.c */ -/* */ -/* Auto-fitter routines to compute global hinting values (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afglobal.c + * + * Auto-fitter routines to compute global hinting values (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afglobal.h" @@ -22,14 +22,14 @@ #include FT_INTERNAL_DEBUG_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afglobal +#define FT_COMPONENT afglobal /* get writing system specific header files */ @@ -38,7 +38,6 @@ #include "afwrtsys.h" #include "aferrors.h" -#include "afpic.h" #undef SCRIPT @@ -67,8 +66,6 @@ #include "afstyles.h" -#ifndef FT_CONFIG_OPTION_PIC - #undef WRITING_SYSTEM #define WRITING_SYSTEM( ws, WS ) \ &af_ ## ws ## _writing_system_class, @@ -110,8 +107,6 @@ NULL /* do not remove */ }; -#endif /* !FT_CONFIG_OPTION_PIC */ - #ifdef FT_DEBUG_LEVEL_TRACE @@ -159,12 +154,12 @@ } /* scan each style in a Unicode charmap */ - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { AF_StyleClass style_class = - AF_STYLE_CLASSES_GET[ss]; + af_style_classes[ss]; AF_ScriptClass script_class = - AF_SCRIPT_CLASSES_GET[style_class->script]; + af_script_classes[style_class->script]; AF_Script_UniRange range; @@ -172,8 +167,8 @@ continue; /* - * Scan all Unicode points in the range and set the corresponding - * glyph style index. + * Scan all Unicode points in the range and set the corresponding + * glyph style index. */ if ( style_class->coverage == AF_COVERAGE_DEFAULT ) { @@ -246,9 +241,9 @@ } /* handle the remaining default OpenType features ... */ - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; + AF_StyleClass style_class = af_style_classes[ss]; if ( style_class->coverage == AF_COVERAGE_DEFAULT ) @@ -256,7 +251,7 @@ } /* ... and finally the default OpenType features of the default script */ - af_shaper_get_coverage( globals, AF_STYLE_CLASSES_GET[dflt], gstyles, 1 ); + af_shaper_get_coverage( globals, af_style_classes[dflt], gstyles, 1 ); /* mark ASCII digits */ for ( i = 0x30; i <= 0x39; i++ ) @@ -270,8 +265,8 @@ Exit: /* - * By default, all uncovered glyphs are set to the fallback style. - * XXX: Shouldn't we disable hinting or do something similar? + * By default, all uncovered glyphs are set to the fallback style. + * XXX: Shouldn't we disable hinting or do something similar? */ if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED ) { @@ -295,9 +290,9 @@ "==============\n" "\n" )); - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; + AF_StyleClass style_class = af_style_classes[ss]; FT_UInt count = 0; FT_Long idx; @@ -397,9 +392,9 @@ if ( globals->metrics[nn] ) { AF_StyleClass style_class = - AF_STYLE_CLASSES_GET[nn]; + af_style_classes[nn]; AF_WritingSystemClass writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; + af_writing_system_classes[style_class->writing_system]; if ( writing_system_class->style_metrics_done ) @@ -448,8 +443,9 @@ style = (AF_Style)( globals->glyph_styles[gindex] & AF_STYLE_UNASSIGNED ); - style_class = AF_STYLE_CLASSES_GET[style]; - writing_system_class = AF_WRITING_SYSTEM_CLASSES_GET + Again: + style_class = af_style_classes[style]; + writing_system_class = af_writing_system_classes [style_class->writing_system]; metrics = globals->metrics[style]; @@ -475,6 +471,16 @@ writing_system_class->style_metrics_done( metrics ); FT_FREE( metrics ); + + /* internal error code -1 indicates */ + /* that no blue zones have been found */ + if ( error == -1 ) + { + style = (AF_Style)( globals->glyph_styles[gindex] & + AF_STYLE_UNASSIGNED ); + goto Again; + } + goto Exit; } } @@ -494,9 +500,9 @@ FT_UInt gindex ) { if ( gindex < (FT_ULong)globals->glyph_count ) - return (FT_Bool)( globals->glyph_styles[gindex] & AF_DIGIT ); + return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT ); - return (FT_Bool)0; + return FT_BOOL( 0 ); } diff --git a/src/3rdparty/freetype/src/autofit/afglobal.h b/src/3rdparty/freetype/src/autofit/afglobal.h index 489ed46d9e..52f38350db 100644 --- a/src/3rdparty/freetype/src/autofit/afglobal.h +++ b/src/3rdparty/freetype/src/autofit/afglobal.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afglobal.h */ -/* */ -/* Auto-fitter routines to compute global hinting values */ -/* (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afglobal.h + * + * Auto-fitter routines to compute global hinting values + * (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFGLOBAL_H_ @@ -60,8 +60,8 @@ FT_BEGIN_HEADER /* - * Default values and flags for both autofitter globals (found in - * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec). + * Default values and flags for both autofitter globals (found in + * AF_ModuleRec) and face globals (in AF_FaceGlobalsRec). */ /* index of fallback style in `af_style_classes' */ @@ -98,8 +98,8 @@ FT_BEGIN_HEADER /* - * Note that glyph_styles[] maps each glyph to an index into the - * `af_style_classes' array. + * Note that glyph_styles[] maps each glyph to an index into the + * `af_style_classes' array. * */ typedef struct AF_FaceGlobalsRec_ @@ -140,8 +140,8 @@ FT_BEGIN_HEADER /* - * model the global hints data for a given face, decomposed into - * style-specific items + * model the global hints data for a given face, decomposed into + * style-specific items */ FT_LOCAL( FT_Error ) diff --git a/src/3rdparty/freetype/src/autofit/afhints.c b/src/3rdparty/freetype/src/autofit/afhints.c index 0666dbc8e2..ed111c4117 100644 --- a/src/3rdparty/freetype/src/autofit/afhints.c +++ b/src/3rdparty/freetype/src/autofit/afhints.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afhints.c */ -/* */ -/* Auto-fitter hinting routines (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afhints.c + * + * Auto-fitter hinting routines (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afhints.h" @@ -22,14 +22,14 @@ #include FT_INTERNAL_DEBUG_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afhints +#define FT_COMPONENT afhints /* Get new segment for given axis. */ @@ -297,6 +297,19 @@ } + static int + af_get_strong_edge_index( AF_GlyphHints hints, + AF_Edge* strong_edges, + int dimension ) + { + AF_AxisHints axis = &hints->axis[dimension]; + AF_Edge edges = axis->edges; + + + return AF_INDEX_NUM( strong_edges[dimension], edges ); + } + + #ifdef __cplusplus extern "C" { #endif @@ -317,8 +330,10 @@ { AF_DUMP(( " index hedge hseg vedge vseg flags " /* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */ - " xorg yorg xscale yscale xfit yfit" )); + " xorg yorg xscale yscale xfit yfit " /* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */ + " hbef haft vbef vaft" )); + /* " XXXXX XXXXX XXXXX XXXXX" */ } else AF_DUMP(( " (none)\n" )); @@ -330,6 +345,7 @@ int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 ); char buf1[16], buf2[16], buf3[16], buf4[16]; + char buf5[16], buf6[16], buf7[16], buf8[16]; /* insert extra newline at the beginning of a contour */ @@ -340,7 +356,8 @@ } AF_DUMP(( " %5d %5s %5s %5s %5s %s" - " %5d %5d %7.2f %7.2f %7.2f %7.2f\n", + " %5d %5d %7.2f %7.2f %7.2f %7.2f" + " %5s %5s %5s %5s\n", point_idx, af_print_idx( buf1, af_get_edge_index( hints, segment_idx_1, 1 ) ), @@ -359,7 +376,20 @@ point->ox / 64.0, point->oy / 64.0, point->x / 64.0, - point->y / 64.0 )); + point->y / 64.0, + + af_print_idx( buf5, af_get_strong_edge_index( hints, + point->before, + 1 ) ), + af_print_idx( buf6, af_get_strong_edge_index( hints, + point->after, + 1 ) ), + af_print_idx( buf7, af_get_strong_edge_index( hints, + point->before, + 0 ) ), + af_print_idx( buf8, af_get_strong_edge_index( hints, + point->after, + 0 ) ) )); } AF_DUMP(( "\n" )); } @@ -519,7 +549,7 @@ *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx : seg->first->fy; if ( seg->edge ) - *is_blue = (FT_Bool)( seg->edge->blue_edge != 0 ); + *is_blue = FT_BOOL( seg->edge->blue_edge ); else *is_blue = FALSE; @@ -558,8 +588,8 @@ /* - * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges - * since they have a constant X coordinate. + * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges + * since they have a constant X coordinate. */ if ( dimension == AF_DIMENSION_HORZ ) AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n", @@ -681,8 +711,8 @@ memory = hints->memory; /* - * note that we don't need to free the segment and edge - * buffers since they are really within the hints->points array + * note that we don't need to free the segment and edge + * buffers since they are really within the hints->points array */ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) { @@ -776,9 +806,9 @@ } /* - * then reallocate the points arrays if necessary -- - * note that we reserve two additional point positions, used to - * hint metrics appropriately + * then reallocate the points arrays if necessary -- + * note that we reserve two additional point positions, used to + * hint metrics appropriately */ new_max = (FT_UInt)( outline->n_points + 2 ); old_max = (FT_UInt)hints->max_points; @@ -898,6 +928,14 @@ prev = end; } } + +#ifdef FT_DEBUG_AUTOFIT + point->before[0] = NULL; + point->before[1] = NULL; + point->after[0] = NULL; + point->after[1] = NULL; +#endif + } } @@ -918,15 +956,15 @@ { /* - * Compute directions of `in' and `out' vectors. + * Compute directions of `in' and `out' vectors. * - * Note that distances between points that are very near to each - * other are accumulated. In other words, the auto-hinter either - * prepends the small vectors between near points to the first - * non-near vector, or the sum of small vector lengths exceeds a - * threshold, thus `grouping' the small vectors. All intermediate - * points are tagged as weak; the directions are adjusted also to - * be equal to the accumulated one. + * Note that distances between points that are very near to each + * other are accumulated. In other words, the auto-hinter either + * prepends the small vectors between near points to the first + * non-near vector, or the sum of small vector lengths exceeds a + * threshold, thus `grouping' the small vectors. All intermediate + * points are tagged as weak; the directions are adjusted also to + * be equal to the accumulated one. */ FT_Int near_limit2 = 2 * near_limit - 1; @@ -956,12 +994,12 @@ out_y = point->fy - prev->fy; /* - * We use Taxicab metrics to measure the vector length. + * We use Taxicab metrics to measure the vector length. * - * Note that the accumulated distances so far could have the - * opposite direction of the distance measured here. For this - * reason we use `near_limit2' for the comparison to get a - * non-near point even in the worst case. + * Note that the accumulated distances so far could have the + * opposite direction of the distance measured here. For this + * reason we use `near_limit2' for the comparison to get a + * non-near point even in the worst case. */ if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 ) break; @@ -979,11 +1017,11 @@ curr = first; /* - * We abuse the `u' and `v' fields to store index deltas to the - * next and previous non-near point, respectively. + * We abuse the `u' and `v' fields to store index deltas to the + * next and previous non-near point, respectively. * - * To avoid problems with not having non-near points, we point to - * `first' by default as the next non-near point. + * To avoid problems with not having non-near points, we point to + * `first' by default as the next non-near point. * */ curr->u = (FT_Pos)( first - curr ); @@ -1035,12 +1073,12 @@ } /* - * The next step is to `simplify' an outline's topology so that we - * can identify local extrema more reliably: A series of - * non-horizontal or non-vertical vectors pointing into the same - * quadrant are handled as a single, long vector. From a - * topological point of the view, the intermediate points are of no - * interest and thus tagged as weak. + * The next step is to `simplify' an outline's topology so that we + * can identify local extrema more reliably: A series of + * non-horizontal or non-vertical vectors pointing into the same + * quadrant are handled as a single, long vector. From a + * topological point of the view, the intermediate points are of no + * interest and thus tagged as weak. */ for ( point = points; point < point_limit; point++ ) @@ -1080,9 +1118,9 @@ } /* - * Finally, check for remaining weak points. Everything else not - * collected in edges so far is then implicitly classified as strong - * points. + * Finally, check for remaining weak points. Everything else not + * collected in edges so far is then implicitly classified as strong + * points. */ for ( point = points; point < point_limit; point++ ) @@ -1309,6 +1347,12 @@ if ( delta >= 0 ) { u = edge->pos - ( edge->opos - ou ); + +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = edge; + point->after[dim] = NULL; +#endif + goto Store_Point; } @@ -1318,6 +1362,12 @@ if ( delta >= 0 ) { u = edge->pos + ( ou - edge->opos ); + +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = NULL; + point->after[dim] = edge; +#endif + goto Store_Point; } @@ -1364,6 +1414,12 @@ { /* we are on the edge */ u = edge->pos; + +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = NULL; + point->after[dim] = NULL; +#endif + goto Store_Point; } } @@ -1374,6 +1430,11 @@ AF_Edge after = edges + min + 0; +#ifdef FT_DEBUG_AUTOFIT + point->before[dim] = before; + point->after[dim] = after; +#endif + /* assert( before && after && before != after ) */ if ( before->scale == 0 ) before->scale = FT_DivFix( after->pos - before->pos, diff --git a/src/3rdparty/freetype/src/autofit/afhints.h b/src/3rdparty/freetype/src/autofit/afhints.h index 3326ebc44e..e0cf612f0c 100644 --- a/src/3rdparty/freetype/src/autofit/afhints.h +++ b/src/3rdparty/freetype/src/autofit/afhints.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afhints.h */ -/* */ -/* Auto-fitter hinting routines (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afhints.h + * + * Auto-fitter hinting routines (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFHINTS_H_ @@ -26,8 +26,8 @@ FT_BEGIN_HEADER /* - * The definition of outline glyph hints. These are shared by all - * writing system analysis routines (until now). + * The definition of outline glyph hints. These are shared by all + * writing system analysis routines (until now). */ typedef enum AF_Dimension_ @@ -56,153 +56,153 @@ FT_BEGIN_HEADER /* - * The following explanations are mostly taken from the article + * The following explanations are mostly taken from the article * - * Real-Time Grid Fitting of Typographic Outlines + * Real-Time Grid Fitting of Typographic Outlines * - * by David Turner and Werner Lemberg + * by David Turner and Werner Lemberg * - * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf + * https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf * - * with appropriate updates. + * with appropriate updates. * * - * Segments + * Segments * - * `af_{cjk,latin,...}_hints_compute_segments' are the functions to - * find segments in an outline. + * `af_{cjk,latin,...}_hints_compute_segments' are the functions to + * find segments in an outline. * - * A segment is a series of at least two consecutive points that are - * approximately aligned along a coordinate axis. The analysis to do - * so is specific to a writing system. + * A segment is a series of at least two consecutive points that are + * approximately aligned along a coordinate axis. The analysis to do + * so is specific to a writing system. * * - * Edges + * Edges * - * `af_{cjk,latin,...}_hints_compute_edges' are the functions to find - * edges. + * `af_{cjk,latin,...}_hints_compute_edges' are the functions to find + * edges. * - * As soon as segments are defined, the auto-hinter groups them into - * edges. An edge corresponds to a single position on the main - * dimension that collects one or more segments (allowing for a small - * threshold). + * As soon as segments are defined, the auto-hinter groups them into + * edges. An edge corresponds to a single position on the main + * dimension that collects one or more segments (allowing for a small + * threshold). * - * As an example, the `latin' writing system first tries to grid-fit - * edges, then to align segments on the edges unless it detects that - * they form a serif. + * As an example, the `latin' writing system first tries to grid-fit + * edges, then to align segments on the edges unless it detects that + * they form a serif. * * - * A H - * | | - * | | - * | | - * | | - * C | | F - * +------<-----+ +-----<------+ - * | B G | - * | | - * | | - * +--------------->------------------+ - * D E + * A H + * | | + * | | + * | | + * | | + * C | | F + * +------<-----+ +-----<------+ + * | B G | + * | | + * | | + * +--------------->------------------+ + * D E * * - * Stems + * Stems * - * Stems are detected by `af_{cjk,latin,...}_hint_edges'. + * Stems are detected by `af_{cjk,latin,...}_hint_edges'. * - * Segments need to be `linked' to other ones in order to detect stems. - * A stem is made of two segments that face each other in opposite - * directions and that are sufficiently close to each other. Using - * vocabulary from the TrueType specification, stem segments form a - * `black distance'. + * Segments need to be `linked' to other ones in order to detect stems. + * A stem is made of two segments that face each other in opposite + * directions and that are sufficiently close to each other. Using + * vocabulary from the TrueType specification, stem segments form a + * `black distance'. * - * In the above ASCII drawing, the horizontal segments are BC, DE, and - * FG; the vertical segments are AB, CD, EF, and GH. + * In the above ASCII drawing, the horizontal segments are BC, DE, and + * FG; the vertical segments are AB, CD, EF, and GH. * - * Each segment has at most one `best' candidate to form a black - * distance, or no candidate at all. Notice that two distinct segments - * can have the same candidate, which frequently means a serif. + * Each segment has at most one `best' candidate to form a black + * distance, or no candidate at all. Notice that two distinct segments + * can have the same candidate, which frequently means a serif. * - * A stem is recognized by the following condition: + * A stem is recognized by the following condition: * - * best segment_1 = segment_2 && best segment_2 = segment_1 + * best segment_1 = segment_2 && best segment_2 = segment_1 * - * The best candidate is stored in field `link' in structure - * `AF_Segment'. + * The best candidate is stored in field `link' in structure + * `AF_Segment'. * - * In the above ASCII drawing, the best candidate for both AB and CD is - * GH, while the best candidate for GH is AB. Similarly, the best - * candidate for EF and GH is AB, while the best candidate for AB is - * GH. + * In the above ASCII drawing, the best candidate for both AB and CD is + * GH, while the best candidate for GH is AB. Similarly, the best + * candidate for EF and GH is AB, while the best candidate for AB is + * GH. * - * The detection and handling of stems is dependent on the writing - * system. + * The detection and handling of stems is dependent on the writing + * system. * * - * Serifs + * Serifs * - * Serifs are detected by `af_{cjk,latin,...}_hint_edges'. + * Serifs are detected by `af_{cjk,latin,...}_hint_edges'. * - * In comparison to a stem, a serif (as handled by the auto-hinter - * module that takes care of the `latin' writing system) has + * In comparison to a stem, a serif (as handled by the auto-hinter + * module that takes care of the `latin' writing system) has * - * best segment_1 = segment_2 && best segment_2 != segment_1 + * best segment_1 = segment_2 && best segment_2 != segment_1 * - * where segment_1 corresponds to the serif segment (CD and EF in the - * above ASCII drawing). + * where segment_1 corresponds to the serif segment (CD and EF in the + * above ASCII drawing). * - * The best candidate is stored in field `serif' in structure - * `AF_Segment' (and `link' is set to NULL). + * The best candidate is stored in field `serif' in structure + * `AF_Segment' (and `link' is set to NULL). * * - * Touched points + * Touched points * - * A point is called `touched' if it has been processed somehow by the - * auto-hinter. It basically means that it shouldn't be moved again - * (or moved only under certain constraints to preserve the already - * applied processing). + * A point is called `touched' if it has been processed somehow by the + * auto-hinter. It basically means that it shouldn't be moved again + * (or moved only under certain constraints to preserve the already + * applied processing). * * - * Flat and round segments + * Flat and round segments * - * Segments are `round' or `flat', depending on the series of points - * that define them. A segment is round if the next and previous point - * of an extremum (which can be either a single point or sequence of - * points) are both conic or cubic control points. Otherwise, a - * segment with an extremum is flat. + * Segments are `round' or `flat', depending on the series of points + * that define them. A segment is round if the next and previous point + * of an extremum (which can be either a single point or sequence of + * points) are both conic or cubic control points. Otherwise, a + * segment with an extremum is flat. * * - * Strong Points + * Strong Points * - * Experience has shown that points not part of an edge need to be - * interpolated linearly between their two closest edges, even if these - * are not part of the contour of those particular points. Typical - * candidates for this are + * Experience has shown that points not part of an edge need to be + * interpolated linearly between their two closest edges, even if these + * are not part of the contour of those particular points. Typical + * candidates for this are * - * - angle points (i.e., points where the `in' and `out' direction - * differ greatly) + * - angle points (i.e., points where the `in' and `out' direction + * differ greatly) * - * - inflection points (i.e., where the `in' and `out' angles are the - * same, but the curvature changes sign) [currently, such points - * aren't handled specially in the auto-hinter] + * - inflection points (i.e., where the `in' and `out' angles are the + * same, but the curvature changes sign) [currently, such points + * aren't handled specially in the auto-hinter] * - * `af_glyph_hints_align_strong_points' is the function that takes - * care of such situations; it is equivalent to the TrueType `IP' - * hinting instruction. + * `af_glyph_hints_align_strong_points' is the function that takes + * care of such situations; it is equivalent to the TrueType `IP' + * hinting instruction. * * - * Weak Points + * Weak Points * - * Other points in the outline must be interpolated using the - * coordinates of their previous and next unfitted contour neighbours. - * These are called `weak points' and are touched by the function - * `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP' - * hinting instruction. Typical candidates are control points and - * points on the contour without a major direction. + * Other points in the outline must be interpolated using the + * coordinates of their previous and next unfitted contour neighbours. + * These are called `weak points' and are touched by the function + * `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP' + * hinting instruction. Typical candidates are control points and + * points on the contour without a major direction. * - * The major effect is to reduce possible distortion caused by - * alignment of edges and strong points, thus weak points are processed - * after strong points. + * The major effect is to reduce possible distortion caused by + * alignment of edges and strong points, thus weak points are processed + * after strong points. */ @@ -252,6 +252,12 @@ FT_BEGIN_HEADER AF_Point next; /* next point in contour */ AF_Point prev; /* previous point in contour */ +#ifdef FT_DEBUG_AUTOFIT + /* track `before' and `after' edges for strong points */ + AF_Edge before[2]; + AF_Edge after[2]; +#endif + } AF_PointRec; diff --git a/src/3rdparty/freetype/src/autofit/afindic.c b/src/3rdparty/freetype/src/autofit/afindic.c index dfbea5f34c..a17117c712 100644 --- a/src/3rdparty/freetype/src/autofit/afindic.c +++ b/src/3rdparty/freetype/src/autofit/afindic.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afindic.c */ -/* */ -/* Auto-fitter hinting routines for Indic writing system (body). */ -/* */ -/* Copyright 2007-2018 by */ -/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afindic.c + * + * Auto-fitter hinting routines for Indic writing system (body). + * + * Copyright (C) 2007-2019 by + * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "aftypes.h" diff --git a/src/3rdparty/freetype/src/autofit/afindic.h b/src/3rdparty/freetype/src/autofit/afindic.h index 5688738e6e..bc5bc59fa5 100644 --- a/src/3rdparty/freetype/src/autofit/afindic.h +++ b/src/3rdparty/freetype/src/autofit/afindic.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* afindic.h */ -/* */ -/* Auto-fitter hinting routines for Indic writing system */ -/* (specification). */ -/* */ -/* Copyright 2007-2018 by */ -/* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afindic.h + * + * Auto-fitter hinting routines for Indic writing system + * (specification). + * + * Copyright (C) 2007-2019 by + * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFINDIC_H_ diff --git a/src/3rdparty/freetype/src/autofit/aflatin.c b/src/3rdparty/freetype/src/autofit/aflatin.c index 9f1b54056f..27d4024882 100644 --- a/src/3rdparty/freetype/src/autofit/aflatin.c +++ b/src/3rdparty/freetype/src/autofit/aflatin.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* aflatin.c */ -/* */ -/* Auto-fitter hinting routines for latin writing system (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aflatin.c + * + * Auto-fitter hinting routines for latin writing system (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,7 +21,6 @@ #include FT_INTERNAL_DEBUG_H #include "afglobal.h" -#include "afpic.h" #include "aflatin.h" #include "aferrors.h" @@ -31,14 +30,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_aflatin +#define FT_COMPONENT aflatin /* needed for computation of round vs. flat segments */ @@ -83,24 +82,30 @@ AF_LatinMetricsRec dummy[1]; AF_Scaler scaler = &dummy->root.scaler; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = metrics->root.globals; -#endif - AF_StyleClass style_class = metrics->root.style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; + + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif - void* shaper_buf; const char* p; #ifdef FT_DEBUG_LEVEL_TRACE FT_ULong ch = 0; #endif - p = script_class->standard_charstring; - shaper_buf = af_shaper_buf_create( face ); + p = script_class->standard_charstring; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + shaper_buf = af_shaper_buf_create( face ); +#endif /* * We check a list of standard characters to catch features like * `c2sc' (small caps from caps) that don't contain lowercase letters @@ -144,7 +149,11 @@ af_shaper_buf_destroy( face, shaper_buf ); if ( !glyph_index ) + { + FT_TRACE5(( "standard character missing;" + " using fallback stem widths\n" )); goto Exit; + } FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n", ch, glyph_index )); @@ -186,10 +195,10 @@ goto Exit; /* - * We assume that the glyphs selected for the stem width - * computation are `featureless' enough so that the linking - * algorithm works fine without adjustments of its scoring - * function. + * We assume that the glyphs selected for the stem width + * computation are `featureless' enough so that the linking + * algorithm works fine without adjustments of its scoring + * function. */ af_latin_hints_link_segments( hints, 0, @@ -307,7 +316,7 @@ /* Find all blue zones. Flat segments give the reference points, */ /* round segments the overshoot positions. */ - static void + static int af_latin_metrics_init_blues( AF_LatinMetrics metrics, FT_Face face ) { @@ -329,7 +338,14 @@ FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em ); - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* we walk over the blue character strings as specified in the */ @@ -339,7 +355,9 @@ "============================\n" "\n" )); +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ ) { @@ -884,8 +902,8 @@ if ( num_flats == 0 && num_rounds == 0 ) { /* - * we couldn't find a single glyph to compute this blue zone, - * we will simply ignore it then + * we couldn't find a single glyph to compute this blue zone, + * we will simply ignore it then */ FT_TRACE5(( " empty\n" )); continue; @@ -967,10 +985,11 @@ af_shaper_buf_destroy( face, shaper_buf ); - /* we finally check whether blue zones are ordered; */ - /* `ref' and `shoot' values of two blue zones must not overlap */ if ( axis->blue_count ) { + /* we finally check whether blue zones are ordered; */ + /* `ref' and `shoot' values of two blue zones must not overlap */ + FT_UInt i; AF_LatinBlue blue_sorted[AF_BLUE_STRINGSET_MAX_LEN + 2]; @@ -1019,11 +1038,34 @@ *a )); } } + + FT_TRACE5(( "\n" )); + + return 0; } + else + { + /* disable hinting for the current style if there are no blue zones */ - FT_TRACE5(( "\n" )); + AF_FaceGlobals globals = metrics->root.globals; + FT_UShort* gstyles = globals->glyph_styles; + + FT_Long i; + + + FT_TRACE5(( "no blue zones found:" + " hinting disabled for this style\n" )); + + for ( i = 0; i < globals->glyph_count; i++ ) + { + if ( ( gstyles[i] & AF_STYLE_MASK ) == sc->style ) + gstyles[i] = AF_STYLE_NONE_DFLT; + } - return; + FT_TRACE5(( "\n" )); + + return 1; + } } @@ -1036,15 +1078,25 @@ FT_Bool started = 0, same_width = 1; FT_Fixed advance = 0, old_advance = 0; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* in all supported charmaps, digits have character codes 0x30-0x39 */ const char digits[] = "0 1 2 3 4 5 6 7 8 9"; const char* p; - p = digits; + p = digits; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif while ( *p ) { @@ -1092,6 +1144,8 @@ af_latin_metrics_init( AF_LatinMetrics metrics, FT_Face face ) { + FT_Error error = FT_Err_Ok; + FT_CharMap oldmap = face->charmap; @@ -1100,12 +1154,18 @@ if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) ) { af_latin_metrics_init_widths( metrics, face ); - af_latin_metrics_init_blues( metrics, face ); + if ( af_latin_metrics_init_blues( metrics, face ) ) + { + /* use internal error code to indicate missing blue zones */ + error = -1; + goto Exit; + } af_latin_metrics_check_digits( metrics, face ); } + Exit: FT_Set_Charmap( face, oldmap ); - return FT_Err_Ok; + return error; } @@ -1283,7 +1343,7 @@ /* an extra-light axis corresponds to a standard width that is */ /* smaller than 5/8 pixels */ axis->extra_light = - (FT_Bool)( FT_MulFix( axis->standard_width, scale ) < 32 + 8 ); + FT_BOOL( FT_MulFix( axis->standard_width, scale ) < 32 + 8 ); #ifdef FT_DEBUG_LEVEL_TRACE if ( axis->extra_light ) @@ -1419,13 +1479,13 @@ nn, blue->ref.org, blue->ref.fit / 64.0, - blue->flags & AF_LATIN_BLUE_ACTIVE ? "" - : " (inactive)", + ( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? "" + : " (inactive)", nn, blue->shoot.org, blue->shoot.fit / 64.0, - blue->flags & AF_LATIN_BLUE_ACTIVE ? "" - : " (inactive)" )); + ( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? "" + : " (inactive)" )); } #endif } @@ -1967,17 +2027,17 @@ if ( len >= len_threshold ) { /* - * The score is the sum of two demerits indicating the - * `badness' of a fit, measured along the segments' main axis - * and orthogonal to it, respectively. + * The score is the sum of two demerits indicating the + * `badness' of a fit, measured along the segments' main axis + * and orthogonal to it, respectively. * - * o The less overlapping along the main axis, the worse it - * is, causing a larger demerit. + * - The less overlapping along the main axis, the worse it + * is, causing a larger demerit. * - * o The nearer the orthogonal distance to a stem width, the - * better it is, causing a smaller demerit. For simplicity, - * however, we only increase the demerit for values that - * exceed the largest stem width. + * - The nearer the orthogonal distance to a stem width, the + * better it is, causing a smaller demerit. For simplicity, + * however, we only increase the demerit for values that + * exceed the largest stem width. */ FT_Pos dist = pos2 - pos1; @@ -2049,13 +2109,8 @@ FT_Memory memory = hints->memory; AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim]; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = hints->metrics->globals; -#endif - AF_StyleClass style_class = hints->metrics->style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; FT_Bool top_to_bottom_hinting = 0; @@ -2086,9 +2141,9 @@ top_to_bottom_hinting = script_class->top_to_bottom_hinting; /* - * We ignore all segments that are less than 1 pixel in length - * to avoid many problems with serif fonts. We compute the - * corresponding threshold in font units. + * We ignore all segments that are less than 1 pixel in length + * to avoid many problems with serif fonts. We compute the + * corresponding threshold in font units. */ if ( dim == AF_DIMENSION_HORZ ) segment_length_threshold = FT_DivFix( 64, hints->y_scale ); @@ -2096,26 +2151,26 @@ segment_length_threshold = 0; /* - * Similarly, we ignore segments that have a width delta - * larger than 0.5px (i.e., a width larger than 1px). + * Similarly, we ignore segments that have a width delta + * larger than 0.5px (i.e., a width larger than 1px). */ segment_width_threshold = FT_DivFix( 32, scale ); - /*********************************************************************/ - /* */ - /* We begin by generating a sorted table of edges for the current */ - /* direction. To do so, we simply scan each segment and try to find */ - /* an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which gets processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the table of edges is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ + /********************************************************************** + * + * We begin by generating a sorted table of edges for the current + * direction. To do so, we simply scan each segment and try to find + * an edge in our table that corresponds to its position. + * + * If no edge is found, we create and insert a new edge in the + * sorted table. Otherwise, we simply add the segment to the edge's + * list which gets processed in the second step to compute the + * edge's properties. + * + * Note that the table of edges is sorted along the segment/edge + * position. + * + */ /* assure that edge distance threshold is at most 0.25px */ edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold, @@ -2237,17 +2292,17 @@ } - /******************************************************************/ - /* */ - /* Good, we now compute each edge's properties according to the */ - /* segments found on its position. Basically, these are */ - /* */ - /* - the edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straight or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /******************************************************************/ + /******************************************************************* + * + * Good, we now compute each edge's properties according to the + * segments found on its position. Basically, these are + * + * - the edge's main direction + * - stem edge, serif edge or both (which defaults to stem then) + * - rounded edge, straight or both (which defaults to straight) + * - link for edge + * + */ /* first of all, set the `edge' field in each segment -- this is */ /* required in order to compute edge links */ @@ -2309,9 +2364,9 @@ /* check for links -- if seg->serif is set, then seg->link must */ /* be ignored */ - is_serif = (FT_Bool)( seg->serif && - seg->serif->edge && - seg->serif->edge != edge ); + is_serif = FT_BOOL( seg->serif && + seg->serif->edge && + seg->serif->edge != edge ); if ( ( seg->link && seg->link->edge ) || is_serif ) { @@ -2546,8 +2601,8 @@ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics ); /* - * correct x_scale and y_scale if needed, since they may have - * been modified by `af_latin_metrics_scale_dim' above + * correct x_scale and y_scale if needed, since they may have + * been modified by `af_latin_metrics_scale_dim' above */ hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale; hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta; @@ -2566,21 +2621,21 @@ other_flags = 0; /* - * We snap the width of vertical stems for the monochrome and - * horizontal LCD rendering targets only. + * We snap the width of vertical stems for the monochrome and + * horizontal LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_HORZ_SNAP; /* - * We snap the width of horizontal stems for the monochrome and - * vertical LCD rendering targets only. + * We snap the width of horizontal stems for the monochrome and + * vertical LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels unless in `light' or `lcd' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; @@ -2589,11 +2644,11 @@ other_flags |= AF_LATIN_HINTS_MONO; /* - * In `light' or `lcd' mode we disable horizontal hinting completely. - * We also do it if the face is italic. + * In `light' or `lcd' mode we disable horizontal hinting completely. + * We also do it if the face is italic. * - * However, if warping is enabled (which only works in `light' hinting - * mode), advance widths get adjusted, too. + * However, if warping is enabled (which only works in `light' hinting + * mode), advance widths get adjusted, too. */ if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD || ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) @@ -2936,13 +2991,8 @@ AF_Edge anchor = NULL; FT_Int has_serifs = 0; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = hints->metrics->globals; -#endif - AF_StyleClass style_class = hints->metrics->style_class; - AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET - [style_class->script]; + AF_ScriptClass script_class = af_script_classes[style_class->script]; FT_Bool top_to_bottom_hinting = 0; @@ -2976,12 +3026,12 @@ edge2 = edge->link; /* - * If a stem contains both a neutral and a non-neutral blue zone, - * skip the neutral one. Otherwise, outlines with different - * directions might be incorrectly aligned at the same vertical - * position. + * If a stem contains both a neutral and a non-neutral blue zone, + * skip the neutral one. Otherwise, outlines with different + * directions might be incorrectly aligned at the same vertical + * position. * - * If we have two neutral blue zones, skip one of them. + * If we have two neutral blue zones, skip one of them. * */ if ( edge->blue_edge && edge2 && edge2->blue_edge ) @@ -3344,8 +3394,8 @@ if ( has_serifs || !anchor ) { /* - * now hint the remaining edges (serifs and single) in order - * to complete our processing + * now hint the remaining edges (serifs and single) in order + * to complete our processing */ for ( edge = edges; edge < edge_limit; edge++ ) { diff --git a/src/3rdparty/freetype/src/autofit/aflatin.h b/src/3rdparty/freetype/src/autofit/aflatin.h index 432cccce4e..40479538c2 100644 --- a/src/3rdparty/freetype/src/autofit/aflatin.h +++ b/src/3rdparty/freetype/src/autofit/aflatin.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* aflatin.h */ -/* */ -/* Auto-fitter hinting routines for latin writing system */ -/* (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aflatin.h + * + * Auto-fitter hinting routines for latin writing system + * (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFLATIN_H_ @@ -45,9 +45,9 @@ FT_BEGIN_HEADER /* - * The following declarations could be embedded in the file `aflatin.c'; - * they have been made semi-public to allow alternate writing system - * hinters to re-use some of them. + * The following declarations could be embedded in the file `aflatin.c'; + * they have been made semi-public to allow alternate writing system + * hinters to re-use some of them. */ @@ -161,8 +161,8 @@ FT_BEGIN_HEADER /* - * The next functions shouldn't normally be exported. However, other - * writing systems might like to use these functions as-is. + * The next functions shouldn't normally be exported. However, other + * writing systems might like to use these functions as-is. */ FT_LOCAL( FT_Error ) af_latin_hints_compute_segments( AF_GlyphHints hints, diff --git a/src/3rdparty/freetype/src/autofit/aflatin2.c b/src/3rdparty/freetype/src/autofit/aflatin2.c index 5c71378118..c601ab8d9a 100644 --- a/src/3rdparty/freetype/src/autofit/aflatin2.c +++ b/src/3rdparty/freetype/src/autofit/aflatin2.c @@ -3,22 +3,22 @@ /* marked as experimental. */ -/***************************************************************************/ -/* */ -/* aflatin2.c */ -/* */ -/* Auto-fitter hinting routines for latin writing system (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aflatin2.c + * + * Auto-fitter hinting routines for latin writing system (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include FT_ADVANCES_H @@ -37,14 +37,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_aflatin2 +#define FT_COMPONENT aflatin2 FT_LOCAL_DEF( FT_Error ) @@ -265,7 +265,7 @@ /* Avoid single-point contours since they are never rasterized. */ /* In some fonts, they correspond to mark attachment points */ /* which are way outside of the glyph's real outline. */ - if ( last == first ) + if ( last <= first ) continue; if ( AF_LATIN_IS_TOP_BLUE( bb ) ) @@ -299,6 +299,7 @@ /* now check whether the point belongs to a straight or round */ /* segment; we first need to find in which contour the extremum */ /* lies, then inspect its previous and next points */ + if ( best_point >= 0 ) { FT_Pos best_x = points[best_point].x; FT_Int start, end, prev, next; @@ -358,8 +359,8 @@ if ( num_flats == 0 && num_rounds == 0 ) { /* - * we couldn't find a single glyph to compute this blue zone, - * we will simply ignore it then + * we couldn't find a single glyph to compute this blue zone, + * we will simply ignore it then */ FT_TRACE5(( " empty\n" )); continue; @@ -632,7 +633,7 @@ /* an extra-light axis corresponds to a standard width that is */ /* smaller than 5/8 pixels */ axis->extra_light = - (FT_Bool)( FT_MulFix( axis->standard_width, scale ) < 32 + 8 ); + FT_BOOL( FT_MulFix( axis->standard_width, scale ) < 32 + 8 ); if ( dim == AF_DIMENSION_VERT ) { @@ -1108,13 +1109,13 @@ : AF_DIR_RIGHT; /* - * We want to ignore very small (mostly serif) segments, we do that - * by ignoring those that whose length is less than a given fraction - * of the standard width. If there is no standard width, we ignore - * those that are less than a given size in pixels + * We want to ignore very small (mostly serif) segments, we do that + * by ignoring those that whose length is less than a given fraction + * of the standard width. If there is no standard width, we ignore + * those that are less than a given size in pixels * - * also, unlink serif segments that are linked to segments farther - * than 50% of the standard width + * also, unlink serif segments that are linked to segments farther + * than 50% of the standard width */ if ( dim == AF_DIMENSION_HORZ ) { @@ -1126,21 +1127,21 @@ else segment_length_threshold = 0; - /*********************************************************************/ - /* */ - /* We will begin by generating a sorted table of edges for the */ - /* current direction. To do so, we simply scan each segment and try */ - /* to find an edge in our table that corresponds to its position. */ - /* */ - /* If no edge is found, we create and insert a new edge in the */ - /* sorted table. Otherwise, we simply add the segment to the edge's */ - /* list which will be processed in the second step to compute the */ - /* edge's properties. */ - /* */ - /* Note that the edges table is sorted along the segment/edge */ - /* position. */ - /* */ - /*********************************************************************/ + /********************************************************************** + * + * We will begin by generating a sorted table of edges for the + * current direction. To do so, we simply scan each segment and try + * to find an edge in our table that corresponds to its position. + * + * If no edge is found, we create and insert a new edge in the + * sorted table. Otherwise, we simply add the segment to the edge's + * list which will be processed in the second step to compute the + * edge's properties. + * + * Note that the edges table is sorted along the segment/edge + * position. + * + */ edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold, scale ); @@ -1230,17 +1231,17 @@ } - /*********************************************************************/ - /* */ - /* Good, we will now compute each edge's properties according to */ - /* segments found on its position. Basically, these are: */ - /* */ - /* - edge's main direction */ - /* - stem edge, serif edge or both (which defaults to stem then) */ - /* - rounded edge, straight or both (which defaults to straight) */ - /* - link for edge */ - /* */ - /*********************************************************************/ + /********************************************************************** + * + * Good, we will now compute each edge's properties according to + * segments found on its position. Basically, these are: + * + * - edge's main direction + * - stem edge, serif edge or both (which defaults to stem then) + * - rounded edge, straight or both (which defaults to straight) + * - link for edge + * + */ /* first of all, set the `edge' field in each segment -- this is */ /* required in order to compute edge links */ @@ -1302,9 +1303,9 @@ /* check for links -- if seg->serif is set, then seg->link must */ /* be ignored */ - is_serif = (FT_Bool)( seg->serif && - seg->serif->edge && - seg->serif->edge != edge ); + is_serif = FT_BOOL( seg->serif && + seg->serif->edge && + seg->serif->edge != edge ); if ( ( seg->link && seg->link->edge ) || is_serif ) { @@ -1524,8 +1525,8 @@ af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics ); /* - * correct x_scale and y_scale if needed, since they may have - * been modified `af_latin2_metrics_scale_dim' above + * correct x_scale and y_scale if needed, since they may have + * been modified `af_latin2_metrics_scale_dim' above */ hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale; hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta; @@ -1544,21 +1545,21 @@ other_flags = 0; /* - * We snap the width of vertical stems for the monochrome and - * horizontal LCD rendering targets only. + * We snap the width of vertical stems for the monochrome and + * horizontal LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_HORZ_SNAP; /* - * We snap the width of horizontal stems for the monochrome and - * vertical LCD rendering targets only. + * We snap the width of horizontal stems for the monochrome and + * vertical LCD rendering targets only. */ if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V ) other_flags |= AF_LATIN_HINTS_VERT_SNAP; /* - * We adjust stems to full pixels unless in `light' or `lcd' mode. + * We adjust stems to full pixels unless in `light' or `lcd' mode. */ if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD ) other_flags |= AF_LATIN_HINTS_STEM_ADJUST; @@ -1567,8 +1568,8 @@ other_flags |= AF_LATIN_HINTS_MONO; /* - * In `light' or `lcd' mode we disable horizontal hinting completely. - * We also do it if the face is italic. + * In `light' or `lcd' mode we disable horizontal hinting completely. + * We also do it if the face is italic. */ if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD || ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 ) @@ -2233,8 +2234,8 @@ if ( has_serifs || !anchor ) { /* - * now hint the remaining edges (serifs and single) in order - * to complete our processing + * now hint the remaining edges (serifs and single) in order + * to complete our processing */ for ( edge = edges; edge < edge_limit; edge++ ) { diff --git a/src/3rdparty/freetype/src/autofit/aflatin2.h b/src/3rdparty/freetype/src/autofit/aflatin2.h index 0129dc707e..507cef3df2 100644 --- a/src/3rdparty/freetype/src/autofit/aflatin2.h +++ b/src/3rdparty/freetype/src/autofit/aflatin2.h @@ -3,23 +3,23 @@ /* marked as experimental. */ -/***************************************************************************/ -/* */ -/* aflatin2.h */ -/* */ -/* Auto-fitter hinting routines for latin writing system */ -/* (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aflatin2.h + * + * Auto-fitter hinting routines for latin writing system + * (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFLATIN2_H_ diff --git a/src/3rdparty/freetype/src/autofit/afloader.c b/src/3rdparty/freetype/src/autofit/afloader.c index a55550b338..83743b7be1 100644 --- a/src/3rdparty/freetype/src/autofit/afloader.c +++ b/src/3rdparty/freetype/src/autofit/afloader.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afloader.c */ -/* */ -/* Auto-fitter glyph loading routines (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afloader.c + * + * Auto-fitter glyph loading routines (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afglobal.h" @@ -21,7 +21,6 @@ #include "afhints.h" #include "aferrors.h" #include "afmodule.h" -#include "afpic.h" #include FT_INTERNAL_CALC_H @@ -119,12 +118,12 @@ } /* - * We depend on the writing system (script analyzers) to supply - * standard widths for the script of the glyph we are looking at. If - * it can't deliver, stem darkening is disabled. + * We depend on the writing system (script analyzers) to supply + * standard widths for the script of the glyph we are looking at. If + * it can't deliver, stem darkening is disabled. */ writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_metrics->style_class->writing_system]; + af_writing_system_classes[style_metrics->style_class->writing_system]; if ( writing_system_class->style_metrics_getstdw ) writing_system_class->style_metrics_getstdw( style_metrics, @@ -174,22 +173,22 @@ globals->darken_y = af_fixedToInt( darken_y ); /* - * Scale outlines down on the Y-axis to keep them inside their blue - * zones. The stronger the emboldening, the stronger the downscaling - * (plus heuristical padding to prevent outlines still falling out - * their zones due to rounding). + * Scale outlines down on the Y-axis to keep them inside their blue + * zones. The stronger the emboldening, the stronger the downscaling + * (plus heuristical padding to prevent outlines still falling out + * their zones due to rounding). * - * Reason: `FT_Outline_Embolden' works by shifting the rightmost - * points of stems farther to the right, and topmost points farther - * up. This positions points on the Y-axis outside their - * pre-computed blue zones and leads to distortion when applying the - * hints in the code further below. Code outside this emboldening - * block doesn't know we are presenting it with modified outlines the - * analyzer didn't see! + * Reason: `FT_Outline_Embolden' works by shifting the rightmost + * points of stems farther to the right, and topmost points farther + * up. This positions points on the Y-axis outside their + * pre-computed blue zones and leads to distortion when applying the + * hints in the code further below. Code outside this emboldening + * block doesn't know we are presenting it with modified outlines the + * analyzer didn't see! * - * An unfortunate side effect of downscaling is that the emboldening - * effect is slightly decreased. The loss becomes more pronounced - * versus the CFF driver at smaller sizes, e.g., at 9ppem and below. + * An unfortunate side effect of downscaling is that the emboldening + * effect is slightly decreased. The loss becomes more pronounced + * versus the CFF driver at smaller sizes, e.g., at 9ppem and below. */ globals->scale_down_factor = FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ), @@ -232,10 +231,6 @@ AF_StyleClass style_class; AF_WritingSystemClass writing_system_class; -#ifdef FT_CONFIG_OPTION_PIC - AF_FaceGlobals globals = loader->globals; -#endif - if ( !size ) return FT_THROW( Invalid_Size_Handle ); @@ -282,13 +277,13 @@ } /* - * TODO: This code currently doesn't support fractional advance widths, - * i.e., placing hinted glyphs at anything other than integer - * x-positions. This is only relevant for the warper code, which - * scales and shifts glyphs to optimize blackness of stems (hinting on - * the x-axis by nature places things on pixel integers, hinting on the - * y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta - * values of the scaler would need to be adjusted. + * TODO: This code currently doesn't support fractional advance widths, + * i.e., placing hinted glyphs at anything other than integer + * x-positions. This is only relevant for the warper code, which + * scales and shifts glyphs to optimize blackness of stems (hinting on + * the x-axis by nature places things on pixel integers, hinting on the + * y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta + * values of the scaler would need to be adjusted. */ scaler.face = face; scaler.x_scale = size_internal->autohint_metrics.x_scale; @@ -312,10 +307,10 @@ #endif /* - * Glyphs (really code points) are assigned to scripts. Script - * analysis is done lazily: For each glyph that passes through here, - * the corresponding script analyzer is called, but returns immediately - * if it has been run already. + * Glyphs (really code points) are assigned to scripts. Script + * analysis is done lazily: For each glyph that passes through here, + * the corresponding script analyzer is called, but returns immediately + * if it has been run already. */ error = af_face_globals_get_metrics( loader->globals, glyph_index, style_options, &style_metrics ); @@ -324,7 +319,7 @@ style_class = style_metrics->style_class; writing_system_class = - AF_WRITING_SYSTEM_CLASSES_GET[style_class->writing_system]; + af_writing_system_classes[style_class->writing_system]; loader->metrics = style_metrics; @@ -342,11 +337,11 @@ } /* - * Do the main work of `af_loader_load_glyph'. Note that we never have - * to deal with composite glyphs as those get loaded into - * FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. - * In the rare cases where FT_LOAD_NO_RECURSE is set, it implies - * FT_LOAD_NO_SCALE and as such the auto-hinter is never called. + * Do the main work of `af_loader_load_glyph'. Note that we never have + * to deal with composite glyphs as those get loaded into + * FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function. + * In the rare cases where FT_LOAD_NO_RECURSE is set, it implies + * FT_LOAD_NO_SCALE and as such the auto-hinter is never called. */ load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM | @@ -358,26 +353,26 @@ goto Exit; /* - * Apply stem darkening (emboldening) here before hints are applied to - * the outline. Glyphs are scaled down proportionally to the - * emboldening so that curve points don't fall outside their - * precomputed blue zones. + * Apply stem darkening (emboldening) here before hints are applied to + * the outline. Glyphs are scaled down proportionally to the + * emboldening so that curve points don't fall outside their + * precomputed blue zones. * - * Any emboldening done by the font driver (e.g., the CFF driver) - * doesn't reach here because the autohinter loads the unprocessed - * glyphs in font units for analysis (functions `af_*_metrics_init_*') - * and then above to prepare it for the rasterizers by itself, - * independently of the font driver. So emboldening must be done here, - * within the autohinter. + * Any emboldening done by the font driver (e.g., the CFF driver) + * doesn't reach here because the autohinter loads the unprocessed + * glyphs in font units for analysis (functions `af_*_metrics_init_*') + * and then above to prepare it for the rasterizers by itself, + * independently of the font driver. So emboldening must be done here, + * within the autohinter. * - * All glyphs to be autohinted pass through here one by one. The - * standard widths can therefore change from one glyph to the next, - * depending on what script a glyph is assigned to (each script has its - * own set of standard widths and other metrics). The darkening amount - * must therefore be recomputed for each size and - * `standard_{vertical,horizontal}_width' change. + * All glyphs to be autohinted pass through here one by one. The + * standard widths can therefore change from one glyph to the next, + * depending on what script a glyph is assigned to (each script has its + * own set of standard widths and other metrics). The darkening amount + * must therefore be recomputed for each size and + * `standard_{vertical,horizontal}_width' change. * - * Ignore errors and carry on without emboldening. + * Ignore errors and carry on without emboldening. * */ @@ -426,35 +421,39 @@ /* now load the slot image into the auto-outline */ /* and run the automatic hinting process */ if ( writing_system_class->style_hints_apply ) - writing_system_class->style_hints_apply( glyph_index, - hints, - &gloader->base.outline, - style_metrics ); + { + error = writing_system_class->style_hints_apply( + glyph_index, + hints, + &gloader->base.outline, + style_metrics ); + if ( error ) + goto Exit; + } /* we now need to adjust the metrics according to the change in */ /* width/positioning that occurred during the hinting process */ if ( scaler.render_mode != FT_RENDER_MODE_LIGHT ) { - FT_Pos old_rsb, old_lsb, new_lsb; - FT_Pos pp1x_uh, pp2x_uh; - AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ]; - AF_Edge edge1 = axis->edges; /* leftmost edge */ - AF_Edge edge2 = edge1 + - axis->num_edges - 1; /* rightmost edge */ if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) ) { - old_rsb = loader->pp2.x - edge2->opos; + AF_Edge edge1 = axis->edges; /* leftmost edge */ + AF_Edge edge2 = edge1 + + axis->num_edges - 1; /* rightmost edge */ + + FT_Pos old_rsb = loader->pp2.x - edge2->opos; /* loader->pp1.x is always zero at this point of time */ - old_lsb = edge1->opos /* - loader->pp1.x */; - new_lsb = edge1->pos; + FT_Pos old_lsb = edge1->opos; /* - loader->pp1.x */ + FT_Pos new_lsb = edge1->pos; /* remember unhinted values to later account */ /* for rounding errors */ - pp1x_uh = new_lsb - old_lsb; - pp2x_uh = edge2->pos + old_rsb; + FT_Pos pp1x_uh = new_lsb - old_lsb; + FT_Pos pp2x_uh = edge2->pos + old_rsb; + /* prefer too much space over too little space */ /* for very small sizes */ diff --git a/src/3rdparty/freetype/src/autofit/afloader.h b/src/3rdparty/freetype/src/autofit/afloader.h index d4d72d1583..d1e0f3c093 100644 --- a/src/3rdparty/freetype/src/autofit/afloader.h +++ b/src/3rdparty/freetype/src/autofit/afloader.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afloader.h */ -/* */ -/* Auto-fitter glyph loading routines (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afloader.h + * + * Auto-fitter glyph loading routines (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFLOADER_H_ @@ -27,11 +27,11 @@ FT_BEGIN_HEADER /* - * The autofitter module's (global) data structure to communicate with - * actual fonts. If necessary, `local' data like the current face, the - * current face's auto-hint data, or the current glyph's parameters - * relevant to auto-hinting are `swapped in'. Cf. functions like - * `af_loader_reset' and `af_loader_load_g'. + * The autofitter module's (global) data structure to communicate with + * actual fonts. If necessary, `local' data like the current face, the + * current face's auto-hint data, or the current glyph's parameters + * relevant to auto-hinting are `swapped in'. Cf. functions like + * `af_loader_reset' and `af_loader_load_g'. */ typedef struct AF_LoaderRec_ diff --git a/src/3rdparty/freetype/src/autofit/afmodule.c b/src/3rdparty/freetype/src/autofit/afmodule.c index dcaa17a27e..3e46a3655a 100644 --- a/src/3rdparty/freetype/src/autofit/afmodule.c +++ b/src/3rdparty/freetype/src/autofit/afmodule.c @@ -1,26 +1,25 @@ -/***************************************************************************/ -/* */ -/* afmodule.c */ -/* */ -/* Auto-fitter module implementation (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmodule.c + * + * Auto-fitter module implementation (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afglobal.h" #include "afmodule.h" #include "afloader.h" #include "aferrors.h" -#include "afpic.h" #ifdef FT_DEBUG_AUTOFIT @@ -60,14 +59,14 @@ #include FT_SERVICE_PROPERTIES_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afmodule +#define FT_COMPONENT afmodule static FT_Error @@ -104,19 +103,6 @@ } -#ifdef FT_CONFIG_OPTION_PIC - -#undef AF_SCRIPT_CLASSES_GET -#define AF_SCRIPT_CLASSES_GET \ - ( GET_PIC( ft_module->library )->af_script_classes ) - -#undef AF_STYLE_CLASSES_GET -#define AF_STYLE_CLASSES_GET \ - ( GET_PIC( ft_module->library )->af_style_classes ) - -#endif - - static FT_Error af_property_set( FT_Module ft_module, const char* property_name, @@ -147,9 +133,9 @@ /* We translate the fallback script to a fallback style that uses */ /* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */ /* coverage value. */ - for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ ) + for ( ss = 0; af_style_classes[ss]; ss++ ) { - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss]; + AF_StyleClass style_class = af_style_classes[ss]; if ( (FT_UInt)style_class->script == *fallback_script && @@ -160,7 +146,7 @@ } } - if ( !AF_STYLE_CLASSES_GET[ss] ) + if ( !af_style_classes[ss] ) { FT_TRACE0(( "af_property_set: Invalid value %d for property `%s'\n", fallback_script, property_name )); @@ -357,7 +343,7 @@ { FT_UInt* val = (FT_UInt*)value; - AF_StyleClass style_class = AF_STYLE_CLASSES_GET[fallback_style]; + AF_StyleClass style_class = af_style_classes[fallback_style]; *val = style_class->script; @@ -440,28 +426,16 @@ FT_DEFINE_SERVICEDESCREC1( af_services, - FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET ) + FT_SERVICE_ID_PROPERTIES, &af_service_properties ) FT_CALLBACK_DEF( FT_Module_Interface ) af_get_interface( FT_Module module, const char* module_interface ) { - /* AF_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library; - - - if ( !module ) - return NULL; - library = module->library; - if ( !library ) - return NULL; -#else FT_UNUSED( module ); -#endif - return ft_service_list_lookup( AF_SERVICES_GET, module_interface ); + return ft_service_list_lookup( af_services, module_interface ); } @@ -533,7 +507,7 @@ glyph_index, load_flags ); #ifdef FT_DEBUG_LEVEL_TRACE - if ( ft_trace_levels[FT_COMPONENT] ) + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] ) { #endif af_glyph_hints_dump_points( hints, 0 ); @@ -589,7 +563,7 @@ 0x10000L, /* version 1.0 of the autofitter */ 0x20000L, /* requires FreeType 2.0 or above */ - (const void*)&AF_INTERFACE_GET, + (const void*)&af_autofitter_interface, (FT_Module_Constructor)af_autofitter_init, /* module_init */ (FT_Module_Destructor) af_autofitter_done, /* module_done */ diff --git a/src/3rdparty/freetype/src/autofit/afmodule.h b/src/3rdparty/freetype/src/autofit/afmodule.h index 56f64eaf23..b410809aa8 100644 --- a/src/3rdparty/freetype/src/autofit/afmodule.h +++ b/src/3rdparty/freetype/src/autofit/afmodule.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afmodule.h */ -/* */ -/* Auto-fitter module implementation (specification). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmodule.h + * + * Auto-fitter module implementation (specification). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFMODULE_H_ @@ -28,8 +28,8 @@ FT_BEGIN_HEADER /* - * This is the `extended' FT_Module structure that holds the - * autofitter's global data. + * This is the `extended' FT_Module structure that holds the + * autofitter's global data. */ typedef struct AF_ModuleRec_ diff --git a/src/3rdparty/freetype/src/autofit/afranges.c b/src/3rdparty/freetype/src/autofit/afranges.c index cf67fafb11..45c8bbfc95 100644 --- a/src/3rdparty/freetype/src/autofit/afranges.c +++ b/src/3rdparty/freetype/src/autofit/afranges.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afranges.c */ -/* */ -/* Auto-fitter Unicode script ranges (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afranges.c + * + * Auto-fitter Unicode script ranges (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "afranges.h" @@ -664,6 +664,21 @@ }; + const AF_Script_UniRangeRec af_mong_uniranges[] = + { + AF_UNIRANGE_REC( 0x1800, 0x18AF ), /* Mongolian */ + AF_UNIRANGE_REC( 0x11660, 0x1167F ), /* Mongolian Supplement */ + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_mong_nonbase_uniranges[] = + { + AF_UNIRANGE_REC( 0x1885, 0x1886 ), + AF_UNIRANGE_REC( 0x18A9, 0x18A9 ), + AF_UNIRANGE_REC( 0, 0 ) + }; + + const AF_Script_UniRangeRec af_mymr_uniranges[] = { AF_UNIRANGE_REC( 0x1000, 0x109F ), /* Myanmar */ diff --git a/src/3rdparty/freetype/src/autofit/afranges.h b/src/3rdparty/freetype/src/autofit/afranges.h index ba3b5e7ccb..d5917aefed 100644 --- a/src/3rdparty/freetype/src/autofit/afranges.h +++ b/src/3rdparty/freetype/src/autofit/afranges.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afranges.h */ -/* */ -/* Auto-fitter Unicode script ranges (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afranges.h + * + * Auto-fitter Unicode script ranges (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFRANGES_H_ diff --git a/src/3rdparty/freetype/src/autofit/afscript.h b/src/3rdparty/freetype/src/autofit/afscript.h index 623a1734a6..2da8c70183 100644 --- a/src/3rdparty/freetype/src/autofit/afscript.h +++ b/src/3rdparty/freetype/src/autofit/afscript.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afscript.h */ -/* */ -/* Auto-fitter scripts (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afscript.h + * + * Auto-fitter scripts (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* The following part can be included multiple times. */ @@ -243,6 +243,12 @@ HINTING_BOTTOM_TO_TOP, "\xE0\xB4\xA0 \xE0\xB4\xB1" ) /* ഠ റ */ + SCRIPT( mong, MONG, + "Mongolian", + HB_SCRIPT_MONGOLIAN, + HINTING_TOP_TO_BOTTOM, + "\xE1\xA1\x82 \xE1\xA0\xAA" ) /* ᡂ ᠪ */ + SCRIPT( mymr, MYMR, "Myanmar", HB_SCRIPT_MYANMAR, diff --git a/src/3rdparty/freetype/src/autofit/afshaper.c b/src/3rdparty/freetype/src/autofit/afshaper.c index f30828173c..a5191c6915 100644 --- a/src/3rdparty/freetype/src/autofit/afshaper.c +++ b/src/3rdparty/freetype/src/autofit/afshaper.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afshaper.c */ -/* */ -/* HarfBuzz interface for accessing OpenType features (body). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afshaper.c + * + * HarfBuzz interface for accessing OpenType features (body). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afshaper +#define FT_COMPONENT afshaper /* @@ -591,14 +591,9 @@ void* af_shaper_buf_create( FT_Face face ) { - FT_Error error; - FT_Memory memory = face->memory; - FT_ULong* buf; - - - FT_MEM_ALLOC( buf, sizeof ( FT_ULong ) ); + FT_UNUSED( face ); - return (void*)buf; + return NULL; } @@ -606,10 +601,8 @@ af_shaper_buf_destroy( FT_Face face, void* buf ) { - FT_Memory memory = face->memory; - - - FT_FREE( buf ); + FT_UNUSED( face ); + FT_UNUSED( buf ); } diff --git a/src/3rdparty/freetype/src/autofit/afshaper.h b/src/3rdparty/freetype/src/autofit/afshaper.h index 7efd9f6a4e..06a1e06616 100644 --- a/src/3rdparty/freetype/src/autofit/afshaper.h +++ b/src/3rdparty/freetype/src/autofit/afshaper.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afshaper.h */ -/* */ -/* HarfBuzz interface for accessing OpenType features (specification). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afshaper.h + * + * HarfBuzz interface for accessing OpenType features (specification). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFSHAPER_H_ diff --git a/src/3rdparty/freetype/src/autofit/afstyles.h b/src/3rdparty/freetype/src/autofit/afstyles.h index e2688b3fc2..8d1d70812f 100644 --- a/src/3rdparty/freetype/src/autofit/afstyles.h +++ b/src/3rdparty/freetype/src/autofit/afstyles.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afstyles.h */ -/* */ -/* Auto-fitter styles (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afstyles.h + * + * Auto-fitter styles (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* The following part can be included multiple times. */ @@ -322,6 +322,13 @@ AF_BLUE_STRINGSET_MLYM, AF_COVERAGE_DEFAULT ) + STYLE( mong_dflt, MONG_DFLT, + "Mongolian default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_MONG, + AF_BLUE_STRINGSET_MONG, + AF_COVERAGE_DEFAULT ) + STYLE( mymr_dflt, MYMR_DFLT, "Myanmar default style", AF_WRITING_SYSTEM_LATIN, diff --git a/src/3rdparty/freetype/src/autofit/aftypes.h b/src/3rdparty/freetype/src/autofit/aftypes.h index 6bd8c895b2..579003d27d 100644 --- a/src/3rdparty/freetype/src/autofit/aftypes.h +++ b/src/3rdparty/freetype/src/autofit/aftypes.h @@ -1,30 +1,30 @@ -/***************************************************************************/ -/* */ -/* aftypes.h */ -/* */ -/* Auto-fitter types (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * aftypes.h + * + * Auto-fitter types (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /************************************************************************* * - * The auto-fitter is a complete rewrite of the old auto-hinter. - * Its main feature is the ability to differentiate between different - * writing systems and scripts in order to apply specific rules. + * The auto-fitter is a complete rewrite of the old auto-hinter. + * Its main feature is the ability to differentiate between different + * writing systems and scripts in order to apply specific rules. * - * The code has also been compartmentalized into several entities that - * should make algorithmic experimentation easier than with the old - * code. + * The code has also been compartmentalized into several entities that + * should make algorithmic experimentation easier than with the old + * code. * *************************************************************************/ @@ -102,9 +102,9 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * The auto-fitter doesn't need a very high angular accuracy; - * this allows us to speed up some computations considerably with a - * light Cordic algorithm (see afangles.c). + * The auto-fitter doesn't need a very high angular accuracy; + * this allows us to speed up some computations considerably with a + * light Cordic algorithm (see afangles.c). */ typedef FT_Int AF_Angle; @@ -118,7 +118,7 @@ extern void* _af_debug_hints; #if 0 /* - * compute the angle of a given 2-D vector + * compute the angle of a given 2-D vector */ FT_LOCAL( AF_Angle ) af_angle_atan( FT_Pos dx, @@ -126,8 +126,8 @@ extern void* _af_debug_hints; /* - * compute `angle2 - angle1'; the result is always within - * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1] + * compute `angle2 - angle1'; the result is always within + * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1] */ FT_LOCAL( AF_Angle ) af_angle_diff( AF_Angle angle1, @@ -150,8 +150,9 @@ extern void* _af_debug_hints; FT_END_STMNT - /* opaque handle to glyph-specific hints -- see `afhints.h' for more - * details + /* + * opaque handle to glyph-specific hints -- see `afhints.h' for more + * details */ typedef struct AF_GlyphHintsRec_* AF_GlyphHints; @@ -165,8 +166,8 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * A scaler models the target pixel device that will receive the - * auto-hinted glyph image. + * A scaler models the target pixel device that will receive the + * auto-hinted glyph image. */ #define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */ @@ -197,8 +198,9 @@ extern void* _af_debug_hints; typedef struct AF_StyleMetricsRec_* AF_StyleMetrics; - /* This function parses an FT_Face to compute global metrics for - * a specific style. + /* + * This function parses an FT_Face to compute global metrics for + * a specific style. */ typedef FT_Error (*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics, @@ -237,22 +239,22 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * For the auto-hinter, a writing system consists of multiple scripts that - * can be handled similarly *in a typographical way*; the relationship is - * not based on history. For example, both the Greek and the unrelated - * Armenian scripts share the same features like ascender, descender, - * x-height, etc. Essentially, a writing system is covered by a - * submodule of the auto-fitter; it contains + * For the auto-hinter, a writing system consists of multiple scripts that + * can be handled similarly *in a typographical way*; the relationship is + * not based on history. For example, both the Greek and the unrelated + * Armenian scripts share the same features like ascender, descender, + * x-height, etc. Essentially, a writing system is covered by a + * submodule of the auto-fitter; it contains * - * - a specific global analyzer that computes global metrics specific to - * the script (based on script-specific characters to identify ascender - * height, x-height, etc.), + * - a specific global analyzer that computes global metrics specific to + * the script (based on script-specific characters to identify ascender + * height, x-height, etc.), * - * - a specific glyph analyzer that computes segments and edges for each - * glyph covered by the script, + * - a specific glyph analyzer that computes segments and edges for each + * glyph covered by the script, * - * - a specific grid-fitting algorithm that distorts the scaled glyph - * outline according to the results of the glyph analyzer. + * - a specific grid-fitting algorithm that distorts the scaled glyph + * outline according to the results of the glyph analyzer. */ #define AFWRTSYS_H_ /* don't load header files */ @@ -300,12 +302,12 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * Each script is associated with two sets of Unicode ranges to test - * whether the font face supports the script, and which non-base - * characters the script contains. + * Each script is associated with two sets of Unicode ranges to test + * whether the font face supports the script, and which non-base + * characters the script contains. * - * We use four-letter script tags from the OpenType specification, - * extended by `NONE', which indicates `no script'. + * We use four-letter script tags from the OpenType specification, + * extended by `NONE', which indicates `no script'. */ #undef SCRIPT @@ -361,41 +363,41 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * Usually, a font contains more glyphs than can be addressed by its - * character map. + * Usually, a font contains more glyphs than can be addressed by its + * character map. * - * In the PostScript font world, encoding vectors specific to a given - * task are used to select such glyphs, and these glyphs can be often - * recognized by having a suffix in its glyph names. For example, a - * superscript glyph `A' might be called `A.sup'. Unfortunately, this - * naming scheme is not standardized and thus unusable for us. + * In the PostScript font world, encoding vectors specific to a given + * task are used to select such glyphs, and these glyphs can be often + * recognized by having a suffix in its glyph names. For example, a + * superscript glyph `A' might be called `A.sup'. Unfortunately, this + * naming scheme is not standardized and thus unusable for us. * - * In the OpenType world, a better solution was invented, namely - * `features', which cleanly separate a character's input encoding from - * the corresponding glyph's appearance, and which don't use glyph names - * at all. For our purposes, and slightly generalized, an OpenType - * feature is a name of a mapping that maps character codes to - * non-standard glyph indices (features get used for other things also). - * For example, the `sups' feature provides superscript glyphs, thus - * mapping character codes like `A' or `B' to superscript glyph - * representation forms. How this mapping happens is completely - * uninteresting to us. + * In the OpenType world, a better solution was invented, namely + * `features', which cleanly separate a character's input encoding from + * the corresponding glyph's appearance, and which don't use glyph names + * at all. For our purposes, and slightly generalized, an OpenType + * feature is a name of a mapping that maps character codes to + * non-standard glyph indices (features get used for other things also). + * For example, the `sups' feature provides superscript glyphs, thus + * mapping character codes like `A' or `B' to superscript glyph + * representation forms. How this mapping happens is completely + * uninteresting to us. * - * For the auto-hinter, a `coverage' represents all glyphs of an OpenType - * feature collected in a set (as listed below) that can be hinted - * together. To continue the above example, superscript glyphs must not - * be hinted together with normal glyphs because the blue zones - * completely differ. + * For the auto-hinter, a `coverage' represents all glyphs of an OpenType + * feature collected in a set (as listed below) that can be hinted + * together. To continue the above example, superscript glyphs must not + * be hinted together with normal glyphs because the blue zones + * completely differ. * - * Note that FreeType itself doesn't compute coverages; it only provides - * the glyphs addressable by the default Unicode character map. Instead, - * we use the HarfBuzz library (if available), which has many functions - * exactly for this purpose. + * Note that FreeType itself doesn't compute coverages; it only provides + * the glyphs addressable by the default Unicode character map. Instead, + * we use the HarfBuzz library (if available), which has many functions + * exactly for this purpose. * - * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't - * listed separately (including the glyphs addressable by the character - * map). In case HarfBuzz isn't available, it exactly covers the glyphs - * addressable by the character map. + * AF_COVERAGE_DEFAULT is special: It should cover everything that isn't + * listed separately (including the glyphs addressable by the character + * map). In case HarfBuzz isn't available, it exactly covers the glyphs + * addressable by the character map. * */ @@ -423,8 +425,8 @@ extern void* _af_debug_hints; /*************************************************************************/ /* - * The topmost structure for modelling the auto-hinter glyph input data - * is a `style class', grouping everything together. + * The topmost structure for modelling the auto-hinter glyph input data + * is a `style class', grouping everything together. */ #undef STYLE @@ -486,8 +488,6 @@ extern void* _af_debug_hints; /* Declare and define vtables for classes */ -#ifndef FT_CONFIG_OPTION_PIC - #define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \ FT_CALLBACK_TABLE const AF_WritingSystemClassRec \ writing_system_class; @@ -562,87 +562,9 @@ extern void* _af_debug_hints; coverage \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \ - FT_LOCAL( void ) \ - FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ); - -#define AF_DEFINE_WRITING_SYSTEM_CLASS( \ - writing_system_class, \ - system, \ - m_size, \ - m_init, \ - m_scale, \ - m_done, \ - m_stdw, \ - h_init, \ - h_apply ) \ - FT_LOCAL_DEF( void ) \ - FT_Init_Class_ ## writing_system_class( AF_WritingSystemClassRec* ac ) \ - { \ - ac->writing_system = system; \ - \ - ac->style_metrics_size = m_size; \ - \ - ac->style_metrics_init = m_init; \ - ac->style_metrics_scale = m_scale; \ - ac->style_metrics_done = m_done; \ - ac->style_metrics_getstdw = m_stdw; \ - \ - ac->style_hints_init = h_init; \ - ac->style_hints_apply = h_apply; \ - } - - -#define AF_DECLARE_SCRIPT_CLASS( script_class ) \ - FT_LOCAL( void ) \ - FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ); - -#define AF_DEFINE_SCRIPT_CLASS( \ - script_class, \ - script_, \ - ranges, \ - nonbase_ranges, \ - top_to_bottom, \ - std_charstring ) \ - FT_LOCAL_DEF( void ) \ - FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \ - { \ - ac->script = script_; \ - ac->script_uni_ranges = ranges; \ - ac->script_uni_nonbase_ranges = nonbase_ranges; \ - ac->top_to_bottom_hinting = top_to_bottom; \ - ac->standard_charstring = std_charstring; \ - } - - -#define AF_DECLARE_STYLE_CLASS( style_class ) \ - FT_LOCAL( void ) \ - FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ); - -#define AF_DEFINE_STYLE_CLASS( \ - style_class, \ - style_, \ - writing_system_, \ - script_, \ - blue_stringset_, \ - coverage_ ) \ - FT_LOCAL_DEF( void ) \ - FT_Init_Class_ ## style_class( AF_StyleClassRec* ac ) \ - { \ - ac->style = style_; \ - ac->writing_system = writing_system_; \ - ac->script = script_; \ - ac->blue_stringset = blue_stringset_; \ - ac->coverage = coverage_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ + FT_END_HEADER #endif /* AFTYPES_H_ */ diff --git a/src/3rdparty/freetype/src/autofit/afwarp.c b/src/3rdparty/freetype/src/autofit/afwarp.c index 2a75ea7b35..84e9753ad9 100644 --- a/src/3rdparty/freetype/src/autofit/afwarp.c +++ b/src/3rdparty/freetype/src/autofit/afwarp.c @@ -1,40 +1,40 @@ -/***************************************************************************/ -/* */ -/* afwarp.c */ -/* */ -/* Auto-fitter warping algorithm (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afwarp.c + * + * Auto-fitter warping algorithm (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* - * The idea of the warping code is to slightly scale and shift a glyph - * within a single dimension so that as much of its segments are aligned - * (more or less) on the grid. To find out the optimal scaling and - * shifting value, various parameter combinations are tried and scored. + * The idea of the warping code is to slightly scale and shift a glyph + * within a single dimension so that as much of its segments are aligned + * (more or less) on the grid. To find out the optimal scaling and + * shifting value, various parameter combinations are tried and scored. */ #include "afwarp.h" #ifdef AF_CONFIG_OPTION_USE_WARPER - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_afwarp +#define FT_COMPONENT afwarp /* The weights cover the range 0/64 - 63/64 of a pixel. Obviously, */ diff --git a/src/3rdparty/freetype/src/autofit/afwarp.h b/src/3rdparty/freetype/src/autofit/afwarp.h index 520b1be907..9a2c9a42c1 100644 --- a/src/3rdparty/freetype/src/autofit/afwarp.h +++ b/src/3rdparty/freetype/src/autofit/afwarp.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afwarp.h */ -/* */ -/* Auto-fitter warping algorithm (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afwarp.h + * + * Auto-fitter warping algorithm (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFWARP_H_ @@ -47,12 +47,14 @@ FT_BEGIN_HEADER } AF_WarperRec, *AF_Warper; +#ifdef AF_CONFIG_OPTION_USE_WARPER FT_LOCAL( void ) af_warper_compute( AF_Warper warper, AF_GlyphHints hints, AF_Dimension dim, FT_Fixed *a_scale, - FT_Fixed *a_delta ); + FT_Pos *a_delta ); +#endif FT_END_HEADER diff --git a/src/3rdparty/freetype/src/autofit/afwrtsys.h b/src/3rdparty/freetype/src/autofit/afwrtsys.h index 4675f3242d..5611cf441a 100644 --- a/src/3rdparty/freetype/src/autofit/afwrtsys.h +++ b/src/3rdparty/freetype/src/autofit/afwrtsys.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afwrtsys.h */ -/* */ -/* Auto-fitter writing systems (specification only). */ -/* */ -/* Copyright 2013-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afwrtsys.h + * + * Auto-fitter writing systems (specification only). + * + * Copyright (C) 2013-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFWRTSYS_H_ diff --git a/src/3rdparty/freetype/src/autofit/autofit.c b/src/3rdparty/freetype/src/autofit/autofit.c index c1605160a1..facfec1744 100644 --- a/src/3rdparty/freetype/src/autofit/autofit.c +++ b/src/3rdparty/freetype/src/autofit/autofit.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* autofit.c */ -/* */ -/* Auto-fitter module (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * autofit.c + * + * Auto-fitter module (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -30,7 +30,6 @@ #include "aflatin2.c" #include "afloader.c" #include "afmodule.c" -#include "afpic.c" #include "afranges.c" #include "afshaper.c" #include "afwarp.c" diff --git a/src/3rdparty/freetype/src/autofit/module.mk b/src/3rdparty/freetype/src/autofit/module.mk index ff05f83e7e..cf77b169f7 100644 --- a/src/3rdparty/freetype/src/autofit/module.mk +++ b/src/3rdparty/freetype/src/autofit/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2003-2018 by +# Copyright (C) 2003-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/autofit/rules.mk b/src/3rdparty/freetype/src/autofit/rules.mk index 75171b412c..c59da33a55 100644 --- a/src/3rdparty/freetype/src/autofit/rules.mk +++ b/src/3rdparty/freetype/src/autofit/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2003-2018 by +# Copyright (C) 2003-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -38,7 +38,6 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \ $(AUTOF_DIR)/aflatin.c \ $(AUTOF_DIR)/afloader.c \ $(AUTOF_DIR)/afmodule.c \ - $(AUTOF_DIR)/afpic.c \ $(AUTOF_DIR)/afranges.c \ $(AUTOF_DIR)/afshaper.c \ $(AUTOF_DIR)/afwarp.c diff --git a/src/3rdparty/freetype/src/base/Jamfile b/src/3rdparty/freetype/src/base/Jamfile index 4994c1b4ca..8e1ec42756 100644 --- a/src/3rdparty/freetype/src/base/Jamfile +++ b/src/3rdparty/freetype/src/base/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/base Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -20,7 +20,9 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ; _sources = basepic ftadvanc ftcalc + ftcolor ftdbgmem + fterrors ftfntfmt ftgloadr fthash @@ -47,8 +49,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ; # Add the optional/replaceable files. # { - local _sources = ftapi - ftbbox + local _sources = ftbbox ftbdf ftbitmap ftcid diff --git a/src/3rdparty/freetype/src/base/ftadvanc.c b/src/3rdparty/freetype/src/base/ftadvanc.c index 230c84d6ad..0dfba57036 100644 --- a/src/3rdparty/freetype/src/base/ftadvanc.c +++ b/src/3rdparty/freetype/src/base/ftadvanc.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftadvanc.c */ -/* */ -/* Quick computation of advance widths (body). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftadvanc.c + * + * Quick computation of advance widths (body). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftbase.c b/src/3rdparty/freetype/src/base/ftbase.c index f914b9b247..fb8cbfcc27 100644 --- a/src/3rdparty/freetype/src/base/ftbase.c +++ b/src/3rdparty/freetype/src/base/ftbase.c @@ -1,28 +1,29 @@ -/***************************************************************************/ -/* */ -/* ftbase.c */ -/* */ -/* Single object library component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbase.c + * + * Single object library component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #define FT_MAKE_OPTION_SINGLE_OBJECT -#include "basepic.c" #include "ftadvanc.c" #include "ftcalc.c" +#include "ftcolor.c" #include "ftdbgmem.c" +#include "fterrors.c" #include "ftfntfmt.c" #include "ftgloadr.c" #include "fthash.c" @@ -30,7 +31,6 @@ #include "ftmac.c" #include "ftobjs.c" #include "ftoutln.c" -#include "ftpic.c" #include "ftpsprop.c" #include "ftrfork.c" #include "ftsnames.c" diff --git a/src/3rdparty/freetype/src/base/ftbase.h b/src/3rdparty/freetype/src/base/ftbase.h index 7e8cfad959..35b1c47fd9 100644 --- a/src/3rdparty/freetype/src/base/ftbase.h +++ b/src/3rdparty/freetype/src/base/ftbase.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbase.h */ -/* */ -/* Private functions used in the `base' module (specification). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbase.h + * + * Private functions used in the `base' module (specification). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTBASE_H_ diff --git a/src/3rdparty/freetype/src/base/ftbbox.c b/src/3rdparty/freetype/src/base/ftbbox.c index 151e85c97a..a0b2c46f7b 100644 --- a/src/3rdparty/freetype/src/base/ftbbox.c +++ b/src/3rdparty/freetype/src/base/ftbbox.c @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftbbox.c */ -/* */ -/* FreeType bbox computation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftbbox.c + * + * FreeType bbox computation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component has a _single_ role: to compute exact outline bounding + * boxes. + * + */ #include <ft2build.h> @@ -61,26 +61,28 @@ ( p->y < bbox.yMin || p->y > bbox.yMax ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Move_To */ - /* */ - /* <Description> */ - /* This function is used as a `move_to' emitter during */ - /* FT_Outline_Decompose(). It simply records the destination point */ - /* in `user->last'. We also update bbox in case contour starts with */ - /* an implicit `on' point. */ - /* */ - /* <Input> */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: A pointer to the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Move_To + * + * @Description: + * This function is used as a `move_to' emitter during + * FT_Outline_Decompose(). It simply records the destination point + * in `user->last'. We also update bbox in case contour starts with + * an implicit `on' point. + * + * @Input: + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * A pointer to the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + */ static int BBox_Move_To( FT_Vector* to, TBBox_Rec* user ) @@ -93,26 +95,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Line_To */ - /* */ - /* <Description> */ - /* This function is used as a `line_to' emitter during */ - /* FT_Outline_Decompose(). It simply records the destination point */ - /* in `user->last'; no further computations are necessary because */ - /* bbox already contains both explicit ends of the line segment. */ - /* */ - /* <Input> */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: A pointer to the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Line_To + * + * @Description: + * This function is used as a `line_to' emitter during + * FT_Outline_Decompose(). It simply records the destination point + * in `user->last'; no further computations are necessary because + * bbox already contains both explicit ends of the line segment. + * + * @Input: + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * A pointer to the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + */ static int BBox_Line_To( FT_Vector* to, TBBox_Rec* user ) @@ -123,28 +127,33 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Conic_Check */ - /* */ - /* <Description> */ - /* Find the extrema of a 1-dimensional conic Bezier curve and update */ - /* a bounding range. This version uses direct computation, as it */ - /* doesn't need square roots. */ - /* */ - /* <Input> */ - /* y1 :: The start coordinate. */ - /* */ - /* y2 :: The coordinate of the control point. */ - /* */ - /* y3 :: The end coordinate. */ - /* */ - /* <InOut> */ - /* min :: The address of the current minimum. */ - /* */ - /* max :: The address of the current maximum. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Conic_Check + * + * @Description: + * Find the extrema of a 1-dimensional conic Bezier curve and update + * a bounding range. This version uses direct computation, as it + * doesn't need square roots. + * + * @Input: + * y1 :: + * The start coordinate. + * + * y2 :: + * The coordinate of the control point. + * + * y3 :: + * The end coordinate. + * + * @InOut: + * min :: + * The address of the current minimum. + * + * max :: + * The address of the current maximum. + */ static void BBox_Conic_Check( FT_Pos y1, FT_Pos y2, @@ -168,32 +177,35 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Conic_To */ - /* */ - /* <Description> */ - /* This function is used as a `conic_to' emitter during */ - /* FT_Outline_Decompose(). It checks a conic Bezier curve with the */ - /* current bounding box, and computes its extrema if necessary to */ - /* update it. */ - /* */ - /* <Input> */ - /* control :: A pointer to a control point. */ - /* */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: The address of the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ - /* <Note> */ - /* In the case of a non-monotonous arc, we compute directly the */ - /* extremum coordinates, as it is sufficiently fast. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Conic_To + * + * @Description: + * This function is used as a `conic_to' emitter during + * FT_Outline_Decompose(). It checks a conic Bezier curve with the + * current bounding box, and computes its extrema if necessary to + * update it. + * + * @Input: + * control :: + * A pointer to a control point. + * + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * The address of the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + * + * @Note: + * In the case of a non-monotonous arc, we compute directly the + * extremum coordinates, as it is sufficiently fast. + */ static int BBox_Conic_To( FT_Vector* control, FT_Vector* to, @@ -222,30 +234,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Cubic_Check */ - /* */ - /* <Description> */ - /* Find the extrema of a 1-dimensional cubic Bezier curve and */ - /* update a bounding range. This version uses iterative splitting */ - /* because it is faster than the exact solution with square roots. */ - /* */ - /* <Input> */ - /* p1 :: The start coordinate. */ - /* */ - /* p2 :: The coordinate of the first control point. */ - /* */ - /* p3 :: The coordinate of the second control point. */ - /* */ - /* p4 :: The end coordinate. */ - /* */ - /* <InOut> */ - /* min :: The address of the current minimum. */ - /* */ - /* max :: The address of the current maximum. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Cubic_Check + * + * @Description: + * Find the extrema of a 1-dimensional cubic Bezier curve and + * update a bounding range. This version uses iterative splitting + * because it is faster than the exact solution with square roots. + * + * @Input: + * p1 :: + * The start coordinate. + * + * p2 :: + * The coordinate of the first control point. + * + * p3 :: + * The coordinate of the second control point. + * + * p4 :: + * The end coordinate. + * + * @InOut: + * min :: + * The address of the current minimum. + * + * max :: + * The address of the current maximum. + */ static FT_Pos cubic_peak( FT_Pos q1, FT_Pos q2, @@ -301,9 +319,9 @@ q2 = q2 + q1; q4 = q4 + q3; q3 = q3 + q2; - q4 = ( q4 + q3 ) / 8; - q3 = q3 / 4; - q2 = q2 / 2; + q4 = ( q4 + q3 ) >> 3; + q3 = q3 >> 2; + q2 = q2 >> 1; } else /* second half */ { @@ -312,9 +330,9 @@ q3 = q3 + q4; q1 = q1 + q2; q2 = q2 + q3; - q1 = ( q1 + q2 ) / 8; - q2 = q2 / 4; - q3 = q3 / 2; + q1 = ( q1 + q2 ) >> 3; + q2 = q2 >> 2; + q3 = q3 >> 1; } /* check whether either end reached the maximum */ @@ -361,34 +379,38 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* BBox_Cubic_To */ - /* */ - /* <Description> */ - /* This function is used as a `cubic_to' emitter during */ - /* FT_Outline_Decompose(). It checks a cubic Bezier curve with the */ - /* current bounding box, and computes its extrema if necessary to */ - /* update it. */ - /* */ - /* <Input> */ - /* control1 :: A pointer to the first control point. */ - /* */ - /* control2 :: A pointer to the second control point. */ - /* */ - /* to :: A pointer to the destination vector. */ - /* */ - /* <InOut> */ - /* user :: The address of the current walk context. */ - /* */ - /* <Return> */ - /* Always 0. Needed for the interface only. */ - /* */ - /* <Note> */ - /* In the case of a non-monotonous arc, we don't compute directly */ - /* extremum coordinates, we subdivide instead. */ - /* */ + /************************************************************************** + * + * @Function: + * BBox_Cubic_To + * + * @Description: + * This function is used as a `cubic_to' emitter during + * FT_Outline_Decompose(). It checks a cubic Bezier curve with the + * current bounding box, and computes its extrema if necessary to + * update it. + * + * @Input: + * control1 :: + * A pointer to the first control point. + * + * control2 :: + * A pointer to the second control point. + * + * to :: + * A pointer to the destination vector. + * + * @InOut: + * user :: + * The address of the current walk context. + * + * @Return: + * Always 0. Needed for the interface only. + * + * @Note: + * In the case of a non-monotonous arc, we don't compute directly + * extremum coordinates, we subdivide instead. + */ static int BBox_Cubic_To( FT_Vector* control1, FT_Vector* control2, @@ -490,12 +512,6 @@ FT_Error error; TBBox_Rec user; -#ifdef FT_CONFIG_OPTION_PIC - FT_Outline_Funcs bbox_interface; - - - Init_Class_bbox_interface( &bbox_interface ); -#endif user.bbox = bbox; diff --git a/src/3rdparty/freetype/src/base/ftbdf.c b/src/3rdparty/freetype/src/base/ftbdf.c index c4ea502fbc..c0fccd7b7c 100644 --- a/src/3rdparty/freetype/src/base/ftbdf.c +++ b/src/3rdparty/freetype/src/base/ftbdf.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbdf.c */ -/* */ -/* FreeType API for accessing BDF-specific strings (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbdf.c + * + * FreeType API for accessing BDF-specific strings (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftbitmap.c b/src/3rdparty/freetype/src/base/ftbitmap.c index a9746663fa..0e0a76fe40 100644 --- a/src/3rdparty/freetype/src/base/ftbitmap.c +++ b/src/3rdparty/freetype/src/base/ftbitmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftbitmap.c */ -/* */ -/* FreeType utility functions for bitmaps (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbitmap.c + * + * FreeType utility functions for bitmaps (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,8 +24,18 @@ #include FT_INTERNAL_OBJECTS_H + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT bitmap + + static - const FT_Bitmap null_bitmap = { 0, 0, 0, 0, 0, 0, 0, 0 }; + const FT_Bitmap null_bitmap = { 0, 0, 0, NULL, 0, 0, 0, NULL }; /* documentation is in ftbitmap.h */ @@ -783,6 +793,338 @@ } + /* documentation is in ftbitmap.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Bitmap_Blend( FT_Library library, + const FT_Bitmap* source_, + const FT_Vector source_offset_, + FT_Bitmap* target, + FT_Vector *atarget_offset, + FT_Color color ) + { + FT_Error error = FT_Err_Ok; + FT_Memory memory; + + FT_Bitmap source_bitmap; + const FT_Bitmap* source; + + FT_Vector source_offset; + FT_Vector target_offset; + + FT_Bool free_source_bitmap = 0; + FT_Bool free_target_bitmap_on_error = 0; + + FT_Pos source_llx, source_lly, source_urx, source_ury; + FT_Pos target_llx, target_lly, target_urx, target_ury; + FT_Pos final_llx, final_lly, final_urx, final_ury; + + unsigned int final_rows, final_width; + long x, y; + + + if ( !library || !target || !source_ || !atarget_offset ) + return FT_THROW( Invalid_Argument ); + + memory = library->memory; + + if ( !( target->pixel_mode == FT_PIXEL_MODE_NONE || + ( target->pixel_mode == FT_PIXEL_MODE_BGRA && + target->buffer ) ) ) + return FT_THROW( Invalid_Argument ); + + if ( source_->pixel_mode == FT_PIXEL_MODE_NONE ) + return FT_Err_Ok; /* nothing to do */ + + /* pitches must have the same sign */ + if ( target->pixel_mode == FT_PIXEL_MODE_BGRA && + ( source_->pitch ^ target->pitch ) < 0 ) + return FT_THROW( Invalid_Argument ); + + if ( !( source_->width && source_->rows ) ) + return FT_Err_Ok; /* nothing to do */ + + /* assure integer pixel offsets */ + source_offset.x = FT_PIX_FLOOR( source_offset_.x ); + source_offset.y = FT_PIX_FLOOR( source_offset_.y ); + target_offset.x = FT_PIX_FLOOR( atarget_offset->x ); + target_offset.y = FT_PIX_FLOOR( atarget_offset->y ); + + /* get source bitmap dimensions */ + source_llx = source_offset.x; + if ( FT_LONG_MIN + (FT_Pos)( source_->rows << 6 ) + 64 > source_offset.y ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: y coordinate overflow in source bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + source_lly = source_offset.y - ( source_->rows << 6 ); + + if ( FT_LONG_MAX - (FT_Pos)( source_->width << 6 ) - 64 < source_llx ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: x coordinate overflow in source bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + source_urx = source_llx + ( source_->width << 6 ); + source_ury = source_offset.y; + + /* get target bitmap dimensions */ + if ( target->width && target->rows ) + { + target_llx = target_offset.x; + if ( FT_LONG_MIN + (FT_Pos)( target->rows << 6 ) > target_offset.y ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: y coordinate overflow in target bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + target_lly = target_offset.y - ( target->rows << 6 ); + + if ( FT_LONG_MAX - (FT_Pos)( target->width << 6 ) < target_llx ) + { + FT_TRACE5(( + "FT_Bitmap_Blend: x coordinate overflow in target bitmap\n" )); + return FT_THROW( Invalid_Argument ); + } + target_urx = target_llx + ( target->width << 6 ); + target_ury = target_offset.y; + } + else + { + target_llx = FT_LONG_MAX; + target_lly = FT_LONG_MAX; + target_urx = FT_LONG_MIN; + target_ury = FT_LONG_MIN; + } + + /* compute final bitmap dimensions */ + final_llx = FT_MIN( source_llx, target_llx ); + final_lly = FT_MIN( source_lly, target_lly ); + final_urx = FT_MAX( source_urx, target_urx ); + final_ury = FT_MAX( source_ury, target_ury ); + + final_width = ( final_urx - final_llx ) >> 6; + final_rows = ( final_ury - final_lly ) >> 6; + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE5(( "FT_Bitmap_Blend:\n" + " source bitmap: (%d, %d) -- (%d, %d); %d x %d\n", + source_llx / 64, source_lly / 64, + source_urx / 64, source_ury / 64, + source_->width, source_->rows )); + + if ( target->width && target->rows ) + FT_TRACE5(( " target bitmap: (%d, %d) -- (%d, %d); %d x %d\n", + target_llx / 64, target_lly / 64, + target_urx / 64, target_ury / 64, + target->width, target->rows )); + else + FT_TRACE5(( " target bitmap: empty\n" )); + + if ( final_width && final_rows ) + FT_TRACE5(( " final bitmap: (%d, %d) -- (%d, %d); %d x %d\n", + final_llx / 64, final_lly / 64, + final_urx / 64, final_ury / 64, + final_width, final_rows )); + else + FT_TRACE5(( " final bitmap: empty\n" )); +#endif /* FT_DEBUG_LEVEL_TRACE */ + + if ( !( final_width && final_rows ) ) + return FT_Err_Ok; /* nothing to do */ + + /* for blending, set offset vector of final bitmap */ + /* temporarily to (0,0) */ + source_llx -= final_llx; + source_lly -= final_lly; + + if ( target->width && target->rows ) + { + target_llx -= final_llx; + target_lly -= final_lly; + } + + /* set up target bitmap */ + if ( target->pixel_mode == FT_PIXEL_MODE_NONE ) + { + /* create new empty bitmap */ + target->width = final_width; + target->rows = final_rows; + target->pixel_mode = FT_PIXEL_MODE_BGRA; + target->pitch = (int)final_width * 4; + target->num_grays = 256; + + if ( FT_LONG_MAX / target->pitch < (int)target->rows ) + { + FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n", + final_width, final_rows )); + return FT_THROW( Invalid_Argument ); + } + + if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) ) + return error; + + free_target_bitmap_on_error = 1; + } + else if ( target->width != final_width || + target->rows != final_rows ) + { + /* adjust old bitmap to enlarged size */ + int pitch, new_pitch; + + unsigned char* buffer = NULL; + + + pitch = target->pitch; + + if ( pitch < 0 ) + pitch = -pitch; + + new_pitch = (int)final_width * 4; + + if ( FT_LONG_MAX / new_pitch < (int)final_rows ) + { + FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n", + final_width, final_rows )); + return FT_THROW( Invalid_Argument ); + } + + /* TODO: provide an in-buffer solution for large bitmaps */ + /* to avoid allocation of a new buffer */ + if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) ) + goto Error; + + /* copy data to new buffer */ + x = target_llx >> 6; + y = target_lly >> 6; + + /* the bitmap flow is from top to bottom, */ + /* but y is measured from bottom to top */ + if ( target->pitch < 0 ) + { + /* XXX */ + } + else + { + unsigned char* p = + target->buffer; + unsigned char* q = + buffer + + ( final_rows - y - target->rows ) * new_pitch + + x * 4; + unsigned char* limit_p = + p + pitch * (int)target->rows; + + + while ( p < limit_p ) + { + FT_MEM_COPY( q, p, pitch ); + + p += pitch; + q += new_pitch; + } + } + + FT_FREE( target->buffer ); + + target->width = final_width; + target->rows = final_rows; + + if ( target->pitch < 0 ) + target->pitch = -new_pitch; + else + target->pitch = new_pitch; + + target->buffer = buffer; + } + + /* adjust source bitmap if necessary */ + if ( source_->pixel_mode != FT_PIXEL_MODE_GRAY ) + { + FT_Bitmap_Init( &source_bitmap ); + error = FT_Bitmap_Convert( library, source_, &source_bitmap, 1 ); + if ( error ) + goto Error; + + source = &source_bitmap; + free_source_bitmap = 1; + } + else + source = source_; + + /* do blending; the code below returns pre-multiplied channels, */ + /* similar to what FreeType gets from `CBDT' tables */ + x = source_llx >> 6; + y = source_lly >> 6; + + /* the bitmap flow is from top to bottom, */ + /* but y is measured from bottom to top */ + if ( target->pitch < 0 ) + { + /* XXX */ + } + else + { + unsigned char* p = + source->buffer; + unsigned char* q = + target->buffer + + ( target->rows - y - source->rows ) * target->pitch + + x * 4; + unsigned char* limit_p = + p + source->pitch * (int)source->rows; + + + while ( p < limit_p ) + { + unsigned char* r = p; + unsigned char* s = q; + unsigned char* limit_r = r + source->width; + + + while ( r < limit_r ) + { + int aa = *r++; + int fa = color.alpha * aa / 255; + + int fb = color.blue * fa / 255; + int fg = color.green * fa / 255; + int fr = color.red * fa / 255; + + int ba2 = 255 - fa; + + int bb = s[0]; + int bg = s[1]; + int br = s[2]; + int ba = s[3]; + + + *s++ = (unsigned char)( bb * ba2 / 255 + fb ); + *s++ = (unsigned char)( bg * ba2 / 255 + fg ); + *s++ = (unsigned char)( br * ba2 / 255 + fr ); + *s++ = (unsigned char)( ba * ba2 / 255 + fa ); + } + + p += source->pitch; + q += target->pitch; + } + } + + atarget_offset->x = final_llx; + atarget_offset->y = final_lly + ( final_rows << 6 ); + + Error: + if ( error && free_target_bitmap_on_error ) + FT_Bitmap_Done( library, target ); + + if ( free_source_bitmap ) + FT_Bitmap_Done( library, &source_bitmap ); + + return error; + } + + /* documentation is in ftbitmap.h */ FT_EXPORT_DEF( FT_Error ) diff --git a/src/3rdparty/freetype/src/base/ftcalc.c b/src/3rdparty/freetype/src/base/ftcalc.c index f4ff45f8ef..315dc44185 100644 --- a/src/3rdparty/freetype/src/base/ftcalc.c +++ b/src/3rdparty/freetype/src/base/ftcalc.c @@ -1,35 +1,35 @@ -/***************************************************************************/ -/* */ -/* ftcalc.c */ -/* */ -/* Arithmetic computations (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Support for 1-complement arithmetic has been totally dropped in this */ - /* release. You can still write your own code if you need it. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* Implementing basic computation routines. */ - /* */ - /* FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), */ - /* and FT_FloorFix() are declared in freetype.h. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftcalc.c + * + * Arithmetic computations (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * Support for 1-complement arithmetic has been totally dropped in this + * release. You can still write your own code if you need it. + * + */ + + /************************************************************************** + * + * Implementing basic computation routines. + * + * FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), + * and FT_FloorFix() are declared in freetype.h. + * + */ #include <ft2build.h> @@ -58,14 +58,14 @@ #endif /* !FT_LONG64 */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_calc +#define FT_COMPONENT calc /* transfer sign, leaving a positive number; */ @@ -516,10 +516,10 @@ #elif 0 /* - * This code is nonportable. See comment below. + * This code is nonportable. See comment below. * - * However, on a platform where right-shift of a signed quantity fills - * the leftmost bits by copying the sign bit, it might be faster. + * However, on a platform where right-shift of a signed quantity fills + * the leftmost bits by copying the sign bit, it might be faster. */ FT_Long sa, sb; @@ -527,22 +527,22 @@ /* - * This is a clever way of converting a signed number `a' into its - * absolute value (stored back into `a') and its sign. The sign is - * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a' - * was negative. (Similarly for `b' and `sb'). + * This is a clever way of converting a signed number `a' into its + * absolute value (stored back into `a') and its sign. The sign is + * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a' + * was negative. (Similarly for `b' and `sb'). * - * Unfortunately, it doesn't work (at least not portably). + * Unfortunately, it doesn't work (at least not portably). * - * It makes the assumption that right-shift on a negative signed value - * fills the leftmost bits by copying the sign bit. This is wrong. - * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, - * the result of right-shift of a negative signed value is - * implementation-defined. At least one implementation fills the - * leftmost bits with 0s (i.e., it is exactly the same as an unsigned - * right shift). This means that when `a' is negative, `sa' ends up - * with the value 1 rather than -1. After that, everything else goes - * wrong. + * It makes the assumption that right-shift on a negative signed value + * fills the leftmost bits by copying the sign bit. This is wrong. + * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206, + * the result of right-shift of a negative signed value is + * implementation-defined. At least one implementation fills the + * leftmost bits with 0s (i.e., it is exactly the same as an unsigned + * right shift). This means that when `a' is negative, `sa' ends up + * with the value 1 rather than -1. After that, everything else goes + * wrong. */ sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) ); a = ( a_ ^ sa ) - sa; @@ -701,8 +701,8 @@ if ( !delta ) return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */ - matrix->xy = - FT_DivFix( matrix->xy, delta ); - matrix->yx = - FT_DivFix( matrix->yx, delta ); + matrix->xy = -FT_DivFix( matrix->xy, delta ); + matrix->yx = -FT_DivFix( matrix->yx, delta ); xx = matrix->xx; yy = matrix->yy; @@ -745,6 +745,76 @@ } + /* documentation is in ftcalc.h */ + + FT_BASE_DEF( FT_Bool ) + FT_Matrix_Check( const FT_Matrix* matrix ) + { + FT_Matrix m; + FT_Fixed val[4]; + FT_Fixed nonzero_minval, maxval; + FT_Fixed temp1, temp2; + FT_UInt i; + + + if ( !matrix ) + return 0; + + val[0] = FT_ABS( matrix->xx ); + val[1] = FT_ABS( matrix->xy ); + val[2] = FT_ABS( matrix->yx ); + val[3] = FT_ABS( matrix->yy ); + + /* + * To avoid overflow, we ensure that each value is not larger than + * + * int(sqrt(2^31 / 4)) = 23170 ; + * + * we also check that no value becomes zero if we have to scale. + */ + + maxval = 0; + nonzero_minval = FT_LONG_MAX; + + for ( i = 0; i < 4; i++ ) + { + if ( val[i] > maxval ) + maxval = val[i]; + if ( val[i] && val[i] < nonzero_minval ) + nonzero_minval = val[i]; + } + + /* we only handle 32bit values */ + if ( maxval > 0x7FFFFFFFL ) + return 0; + + if ( maxval > 23170 ) + { + FT_Fixed scale = FT_DivFix( maxval, 23170 ); + + + if ( !FT_DivFix( nonzero_minval, scale ) ) + return 0; /* value range too large */ + + m.xx = FT_DivFix( matrix->xx, scale ); + m.xy = FT_DivFix( matrix->xy, scale ); + m.yx = FT_DivFix( matrix->yx, scale ); + m.yy = FT_DivFix( matrix->yy, scale ); + } + else + m = *matrix; + + temp1 = FT_ABS( m.xx * m.yy - m.xy * m.yx ); + temp2 = m.xx * m.xx + m.xy * m.xy + m.yx * m.yx + m.yy * m.yy; + + if ( temp1 == 0 || + temp2 / temp1 > 50 ) + return 0; + + return 1; + } + + /* documentation is in ftcalc.h */ FT_BASE_DEF( void ) @@ -913,9 +983,13 @@ FT_Pos out_x, FT_Pos out_y ) { + /* we silently ignore overflow errors since such large values */ + /* lead to even more (harmless) rendering errors later on */ + #ifdef FT_LONG64 - FT_Int64 delta = (FT_Int64)in_x * out_y - (FT_Int64)in_y * out_x; + FT_Int64 delta = SUB_INT64( MUL_INT64( in_x, out_y ), + MUL_INT64( in_y, out_x ) ); return ( delta > 0 ) - ( delta < 0 ); @@ -925,8 +999,6 @@ FT_Int result; - /* we silently ignore overflow errors, since such large values */ - /* lead to even more (harmless) rendering errors later on */ if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L && ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L ) { diff --git a/src/3rdparty/freetype/src/base/ftcid.c b/src/3rdparty/freetype/src/base/ftcid.c index f5184649bf..190b23f357 100644 --- a/src/3rdparty/freetype/src/base/ftcid.c +++ b/src/3rdparty/freetype/src/base/ftcid.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcid.c */ -/* */ -/* FreeType API for accessing CID font information. */ -/* */ -/* Copyright 2007-2018 by */ -/* Derek Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcid.c + * + * FreeType API for accessing CID font information. + * + * Copyright (C) 2007-2019 by + * Derek Clegg and Michael Toftdal. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftcolor.c b/src/3rdparty/freetype/src/base/ftcolor.c new file mode 100644 index 0000000000..8cb057a365 --- /dev/null +++ b/src/3rdparty/freetype/src/base/ftcolor.c @@ -0,0 +1,157 @@ +/**************************************************************************** + * + * ftcolor.c + * + * FreeType's glyph color management (body). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_TRUETYPE_TYPES_H +#include FT_COLOR_H + + +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS + + static + const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL }; + + + /* documentation is in ftcolor.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Palette_Data_Get( FT_Face face, + FT_Palette_Data *apalette_data ) + { + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + if ( !apalette_data) + return FT_THROW( Invalid_Argument ); + + if ( FT_IS_SFNT( face ) ) + *apalette_data = ( (TT_Face)face )->palette_data; + else + *apalette_data = null_palette_data; + + return FT_Err_Ok; + } + + + /* documentation is in ftcolor.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Palette_Select( FT_Face face, + FT_UShort palette_index, + FT_Color* *apalette ) + { + FT_Error error; + + TT_Face ttface; + SFNT_Service sfnt; + + + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + + if ( !FT_IS_SFNT( face ) ) + { + if ( apalette ) + *apalette = NULL; + + return FT_Err_Ok; + } + + ttface = (TT_Face)face; + sfnt = (SFNT_Service)ttface->sfnt; + + error = sfnt->set_palette( ttface, palette_index ); + if ( error ) + return error; + + ttface->palette_index = palette_index; + + if ( apalette ) + *apalette = ttface->palette; + + return FT_Err_Ok; + } + + + /* documentation is in ftcolor.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Palette_Set_Foreground_Color( FT_Face face, + FT_Color foreground_color ) + { + TT_Face ttface; + + + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + + if ( !FT_IS_SFNT( face ) ) + return FT_Err_Ok; + + ttface = (TT_Face)face; + + ttface->foreground_color = foreground_color; + ttface->have_foreground_color = 1; + + return FT_Err_Ok; + } + +#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + + FT_EXPORT_DEF( FT_Error ) + FT_Palette_Data_Get( FT_Face face, + FT_Palette_Data *apalette_data ) + { + FT_UNUSED( face ); + FT_UNUSED( apalette_data ); + + + return FT_THROW( Unimplemented_Feature ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Palette_Select( FT_Face face, + FT_UShort palette_index, + FT_Color* *apalette ) + { + FT_UNUSED( face ); + FT_UNUSED( palette_index ); + FT_UNUSED( apalette ); + + + return FT_THROW( Unimplemented_Feature ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Palette_Set_Foreground_Color( FT_Face face, + FT_Color foreground_color ) + { + FT_UNUSED( face ); + FT_UNUSED( foreground_color ); + + + return FT_THROW( Unimplemented_Feature ); + } + +#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + + +/* END */ diff --git a/src/3rdparty/freetype/src/base/ftdbgmem.c b/src/3rdparty/freetype/src/base/ftdbgmem.c index c33d8acb4e..55cd269e1f 100644 --- a/src/3rdparty/freetype/src/base/ftdbgmem.c +++ b/src/3rdparty/freetype/src/base/ftdbgmem.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftdbgmem.c */ -/* */ -/* Memory debugger (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftdbgmem.c + * + * Memory debugger (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -50,9 +50,9 @@ #define FT_MEM_VAL( addr ) ( (FT_PtrDist)(FT_Pointer)( addr ) ) /* - * This structure holds statistics for a single allocation/release - * site. This is useful to know where memory operations happen the - * most. + * This structure holds statistics for a single allocation/release + * site. This is useful to know where memory operations happen the + * most. */ typedef struct FT_MemSourceRec_ { @@ -76,17 +76,17 @@ /* - * We don't need a resizable array for the memory sources because - * their number is pretty limited within FreeType. + * We don't need a resizable array for the memory sources because + * their number is pretty limited within FreeType. */ #define FT_MEM_SOURCE_BUCKETS 128 /* - * This structure holds information related to a single allocated - * memory block. If KEEPALIVE is defined, blocks that are freed by - * FreeType are never released to the system. Instead, their `size' - * field is set to `-size'. This is mainly useful to detect double - * frees, at the price of a large memory footprint during execution. + * This structure holds information related to a single allocated + * memory block. If KEEPALIVE is defined, blocks that are freed by + * FreeType are never released to the system. Instead, their `size' + * field is set to `-size'. This is mainly useful to detect double + * frees, at the price of a large memory footprint during execution. */ typedef struct FT_MemNodeRec_ { @@ -106,8 +106,8 @@ /* - * The global structure, containing compound statistics and all hash - * tables. + * The global structure, containing compound statistics and all hash + * tables. */ typedef struct FT_MemTableRec_ { @@ -146,8 +146,8 @@ /* - * Prime numbers are ugly to handle. It would be better to implement - * L-Hashing, which is 10% faster and doesn't require divisions. + * Prime numbers are ugly to handle. It would be better to implement + * L-Hashing, which is 10% faster and doesn't require divisions. */ static const FT_Int ft_mem_primes[] = { diff --git a/src/3rdparty/freetype/src/base/ftdebug.c b/src/3rdparty/freetype/src/base/ftdebug.c index fe26309101..ec72337873 100644 --- a/src/3rdparty/freetype/src/base/ftdebug.c +++ b/src/3rdparty/freetype/src/base/ftdebug.c @@ -1,44 +1,44 @@ -/***************************************************************************/ -/* */ -/* ftdebug.c */ -/* */ -/* Debugging and logging component (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component contains various macros and functions used to ease the */ - /* debugging of the FreeType engine. Its main purpose is in assertion */ - /* checking, tracing, and error detection. */ - /* */ - /* There are now three debugging modes: */ - /* */ - /* - trace mode */ - /* */ - /* Error and trace messages are sent to the log file (which can be the */ - /* standard error output). */ - /* */ - /* - error mode */ - /* */ - /* Only error messages are generated. */ - /* */ - /* - release mode: */ - /* */ - /* No error message is sent or generated. The code is free from any */ - /* debugging parts. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftdebug.c + * + * Debugging and logging component (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This component contains various macros and functions used to ease the + * debugging of the FreeType engine. Its main purpose is in assertion + * checking, tracing, and error detection. + * + * There are now three debugging modes: + * + * - trace mode + * + * Error and trace messages are sent to the log file (which can be the + * standard error output). + * + * - error mode + * + * Only error messages are generated. + * + * - release mode: + * + * No error message is sent or generated. The code is free from any + * debugging parts. + * + */ #include <ft2build.h> @@ -87,9 +87,19 @@ int line, const char* file ) { +#if 0 + /* activating the code in this block makes FreeType very chatty */ + fprintf( stderr, + "%s:%d: error 0x%02x: %s\n", + file, + line, + error, + FT_Error_String( error ) ); +#else FT_UNUSED( error ); FT_UNUSED( line ); FT_UNUSED( file ); +#endif return 0; } @@ -100,9 +110,16 @@ #ifdef FT_DEBUG_LEVEL_TRACE - /* array of trace levels, initialized to 0 */ - int ft_trace_levels[trace_count]; + /* array of trace levels, initialized to 0; */ + /* this gets adjusted at run-time */ + static int ft_trace_levels_enabled[trace_count]; + /* array of trace levels, always initialized to 0 */ + static int ft_trace_levels_disabled[trace_count]; + + /* a pointer to either `ft_trace_levels_enabled' */ + /* or `ft_trace_levels_disabled' */ + int* ft_trace_levels; /* define array of trace toggle names */ #define FT_TRACE_DEF( x ) #x , @@ -140,24 +157,42 @@ } - /*************************************************************************/ - /* */ - /* Initialize the tracing sub-system. This is done by retrieving the */ - /* value of the `FT2_DEBUG' environment variable. It must be a list of */ - /* toggles, separated by spaces, `;', or `,'. Example: */ - /* */ - /* export FT2_DEBUG="any:3 memory:7 stream:5" */ - /* */ - /* This requests that all levels be set to 3, except the trace level for */ - /* the memory and stream components which are set to 7 and 5, */ - /* respectively. */ - /* */ - /* See the file `include/freetype/internal/fttrace.h' for details of */ - /* the available toggle names. */ - /* */ - /* The level must be between 0 and 7; 0 means quiet (except for serious */ - /* runtime errors), and 7 means _very_ verbose. */ - /* */ + /* documentation is in ftdebug.h */ + + FT_BASE_DEF( void ) + FT_Trace_Disable( void ) + { + ft_trace_levels = ft_trace_levels_disabled; + } + + + /* documentation is in ftdebug.h */ + + FT_BASE_DEF( void ) + FT_Trace_Enable( void ) + { + ft_trace_levels = ft_trace_levels_enabled; + } + + + /************************************************************************** + * + * Initialize the tracing sub-system. This is done by retrieving the + * value of the `FT2_DEBUG' environment variable. It must be a list of + * toggles, separated by spaces, `;', or `,'. Example: + * + * export FT2_DEBUG="any:3 memory:7 stream:5" + * + * This requests that all levels be set to 3, except the trace level for + * the memory and stream components which are set to 7 and 5, + * respectively. + * + * See the file `include/freetype/internal/fttrace.h' for details of + * the available toggle names. + * + * The level must be between 0 and 7; 0 means quiet (except for serious + * runtime errors), and 7 means _very_ verbose. + */ FT_BASE_DEF( void ) ft_debug_init( void ) { @@ -223,14 +258,16 @@ { /* special case for `any' */ for ( n = 0; n < trace_count; n++ ) - ft_trace_levels[n] = level; + ft_trace_levels_enabled[n] = level; } else - ft_trace_levels[found] = level; + ft_trace_levels_enabled[found] = level; } } } } + + ft_trace_levels = ft_trace_levels_enabled; } @@ -260,6 +297,22 @@ } + FT_BASE_DEF( void ) + FT_Trace_Disable( void ) + { + /* nothing */ + } + + + /* documentation is in ftdebug.h */ + + FT_BASE_DEF( void ) + FT_Trace_Enable( void ) + { + /* nothing */ + } + + #endif /* !FT_DEBUG_LEVEL_TRACE */ diff --git a/src/3rdparty/freetype/src/base/fterrors.c b/src/3rdparty/freetype/src/base/fterrors.c new file mode 100644 index 0000000000..84fe590289 --- /dev/null +++ b/src/3rdparty/freetype/src/base/fterrors.c @@ -0,0 +1,46 @@ +/**************************************************************************** + * + * fterrors.c + * + * FreeType API for error code handling. + * + * Copyright (C) 2018-2019 by + * Armin Hasitzka, David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_ERRORS_H + + + /* documentation is in fterrors.h */ + + FT_EXPORT_DEF( const char* ) + FT_Error_String( FT_Error error_code ) + { + if ( error_code < 0 || + error_code >= FT_ERR_CAT( FT_ERR_PREFIX, Max ) ) + return NULL; + +#if defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || \ + defined( FT_DEBUG_LEVEL_ERROR ) + +#undef FTERRORS_H_ +#define FT_ERROR_START_LIST switch ( FT_ERROR_BASE( error_code ) ) { +#define FT_ERRORDEF( e, v, s ) case v: return s; +#define FT_ERROR_END_LIST } + +#include FT_ERRORS_H + +#endif /* defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || ... */ + + return NULL; + } diff --git a/src/3rdparty/freetype/src/base/ftfntfmt.c b/src/3rdparty/freetype/src/base/ftfntfmt.c index a2900ceb09..54ba537416 100644 --- a/src/3rdparty/freetype/src/base/ftfntfmt.c +++ b/src/3rdparty/freetype/src/base/ftfntfmt.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftfntfmt.c */ -/* */ -/* FreeType utility file for font formats (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftfntfmt.c + * + * FreeType utility file for font formats (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftfstype.c b/src/3rdparty/freetype/src/base/ftfstype.c index e6cdf6e2ec..45e2d8089b 100644 --- a/src/3rdparty/freetype/src/base/ftfstype.c +++ b/src/3rdparty/freetype/src/base/ftfstype.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftfstype.c */ -/* */ -/* FreeType utility file to access FSType data (body). */ -/* */ -/* Copyright 2008-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftfstype.c + * + * FreeType utility file to access FSType data (body). + * + * Copyright (C) 2008-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_TYPE1_TABLES_H diff --git a/src/3rdparty/freetype/src/base/ftgasp.c b/src/3rdparty/freetype/src/base/ftgasp.c index 4f80bba630..720fb113ca 100644 --- a/src/3rdparty/freetype/src/base/ftgasp.c +++ b/src/3rdparty/freetype/src/base/ftgasp.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgasp.c */ -/* */ -/* Access of TrueType's `gasp' table (body). */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgasp.c + * + * Access of TrueType's `gasp' table (body). + * + * Copyright (C) 2007-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftgloadr.c b/src/3rdparty/freetype/src/base/ftgloadr.c index 47202496b9..bfeed461a8 100644 --- a/src/3rdparty/freetype/src/base/ftgloadr.c +++ b/src/3rdparty/freetype/src/base/ftgloadr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgloadr.c */ -/* */ -/* The FreeType glyph loader (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgloadr.c + * + * The FreeType glyph loader (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -23,7 +23,7 @@ #include FT_INTERNAL_OBJECTS_H #undef FT_COMPONENT -#define FT_COMPONENT trace_gloader +#define FT_COMPONENT gloader /*************************************************************************/ @@ -38,31 +38,31 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* The glyph loader is a simple object which is used to load a set of */ - /* glyphs easily. It is critical for the correct loading of composites. */ - /* */ - /* Ideally, one can see it as a stack of abstract `glyph' objects. */ - /* */ - /* loader.base Is really the bottom of the stack. It describes a */ - /* single glyph image made of the juxtaposition of */ - /* several glyphs (those `in the stack'). */ - /* */ - /* loader.current Describes the top of the stack, on which a new */ - /* glyph can be loaded. */ - /* */ - /* Rewind Clears the stack. */ - /* Prepare Set up `loader.current' for addition of a new glyph */ - /* image. */ - /* Add Add the `current' glyph image to the `base' one, */ - /* and prepare for another one. */ - /* */ - /* The glyph loader is now a base object. Each driver used to */ - /* re-implement it in one way or the other, which wasted code and */ - /* energy. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * The glyph loader is a simple object which is used to load a set of + * glyphs easily. It is critical for the correct loading of composites. + * + * Ideally, one can see it as a stack of abstract `glyph' objects. + * + * loader.base Is really the bottom of the stack. It describes a + * single glyph image made of the juxtaposition of + * several glyphs (those `in the stack'). + * + * loader.current Describes the top of the stack, on which a new + * glyph can be loaded. + * + * Rewind Clears the stack. + * Prepare Set up `loader.current' for addition of a new glyph + * image. + * Add Add the `current' glyph image to the `base' one, + * and prepare for another one. + * + * The glyph loader is now a base object. Each driver used to + * re-implement it in one way or the other, which wasted code and + * energy. + * + */ /* create a new glyph loader */ @@ -99,12 +99,12 @@ } - /* reset the glyph loader, frees all allocated tables */ - /* and starts from zero */ + /* reset glyph loader, free all allocated tables, */ + /* and start from zero */ FT_BASE_DEF( void ) FT_GlyphLoader_Reset( FT_GlyphLoader loader ) { - FT_Memory memory = loader->memory; + FT_Memory memory = loader->memory; FT_FREE( loader->base.outline.points ); @@ -129,7 +129,7 @@ { if ( loader ) { - FT_Memory memory = loader->memory; + FT_Memory memory = loader->memory; FT_GlyphLoader_Reset( loader ); @@ -361,46 +361,4 @@ } - FT_BASE_DEF( FT_Error ) - FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, - FT_GlyphLoader source ) - { - FT_Error error; - FT_UInt num_points = (FT_UInt)source->base.outline.n_points; - FT_UInt num_contours = (FT_UInt)source->base.outline.n_contours; - - - error = FT_GlyphLoader_CheckPoints( target, num_points, num_contours ); - if ( !error ) - { - FT_Outline* out = &target->base.outline; - FT_Outline* in = &source->base.outline; - - - FT_ARRAY_COPY( out->points, in->points, - num_points ); - FT_ARRAY_COPY( out->tags, in->tags, - num_points ); - FT_ARRAY_COPY( out->contours, in->contours, - num_contours ); - - /* do we need to copy the extra points? */ - if ( target->use_extra && source->use_extra ) - { - FT_ARRAY_COPY( target->base.extra_points, source->base.extra_points, - num_points ); - FT_ARRAY_COPY( target->base.extra_points2, source->base.extra_points2, - num_points ); - } - - out->n_points = (short)num_points; - out->n_contours = (short)num_contours; - - FT_GlyphLoader_Adjust_Points( target ); - } - - return error; - } - - /* END */ diff --git a/src/3rdparty/freetype/src/base/ftglyph.c b/src/3rdparty/freetype/src/base/ftglyph.c index 6759aa25d0..e6b1327901 100644 --- a/src/3rdparty/freetype/src/base/ftglyph.c +++ b/src/3rdparty/freetype/src/base/ftglyph.c @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* ftglyph.c */ -/* */ -/* FreeType convenience functions to handle glyphs (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftglyph.c + * + * FreeType convenience functions to handle glyphs (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file contains the definition of several convenience functions + * that can be used by client applications to easily retrieve glyph + * bitmaps and outlines from a given face. + * + * These functions should be optional if you are writing a font server + * or text layout engine on top of FreeType. However, they are pretty + * handy for many other simple uses of the library. + * + */ #include <ft2build.h> @@ -36,16 +36,15 @@ #include FT_BITMAP_H #include FT_INTERNAL_OBJECTS_H -#include "basepic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_glyph +#define FT_COMPONENT glyph /*************************************************************************/ @@ -77,7 +76,7 @@ /* do lazy copying whenever possible */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { - glyph->bitmap = slot->bitmap; + glyph->bitmap = slot->bitmap; slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } else @@ -359,37 +358,28 @@ /* documentation is in ftglyph.h */ - FT_EXPORT_DEF( FT_Error ) - FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph *aglyph ) + FT_EXPORT( FT_Error ) + FT_New_Glyph( FT_Library library, + FT_Glyph_Format format, + FT_Glyph *aglyph ) { - FT_Library library; - FT_Error error; - FT_Glyph glyph; - const FT_Glyph_Class* clazz = NULL; - - if ( !slot ) - return FT_THROW( Invalid_Slot_Handle ); - - library = slot->library; - - if ( !aglyph ) + if ( !library || !aglyph ) return FT_THROW( Invalid_Argument ); /* if it is a bitmap, that's easy :-) */ - if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) - clazz = FT_BITMAP_GLYPH_CLASS_GET; + if ( format == FT_GLYPH_FORMAT_BITMAP ) + clazz = &ft_bitmap_glyph_class; /* if it is an outline */ - else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) - clazz = FT_OUTLINE_GLYPH_CLASS_GET; + else if ( format == FT_GLYPH_FORMAT_OUTLINE ) + clazz = &ft_outline_glyph_class; else { /* try to find a renderer that supports the glyph image format */ - FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 ); + FT_Renderer render = FT_Lookup_Renderer( library, format, 0 ); if ( render ) @@ -397,13 +387,31 @@ } if ( !clazz ) - { - error = FT_THROW( Invalid_Glyph_Format ); - goto Exit; - } + return FT_THROW( Invalid_Glyph_Format ); + + /* create FT_Glyph object */ + return ft_new_glyph( library, clazz, aglyph ); + } + + + /* documentation is in ftglyph.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Glyph( FT_GlyphSlot slot, + FT_Glyph *aglyph ) + { + FT_Error error; + FT_Glyph glyph; + + + if ( !slot ) + return FT_THROW( Invalid_Slot_Handle ); + + if ( !aglyph ) + return FT_THROW( Invalid_Argument ); /* create FT_Glyph object */ - error = ft_new_glyph( library, clazz, &glyph ); + error = FT_New_Glyph( slot->library, slot->format, &glyph ); if ( error ) goto Exit; @@ -427,7 +435,7 @@ glyph->advance.y = slot->advance.y * 1024; /* now import the image from the glyph slot */ - error = clazz->glyph_init( glyph, slot ); + error = glyph->clazz->glyph_init( glyph, slot ); Exit2: /* if an error occurred, destroy the glyph */ @@ -505,8 +513,8 @@ { acbox->xMin = FT_PIX_FLOOR( acbox->xMin ); acbox->yMin = FT_PIX_FLOOR( acbox->yMin ); - acbox->xMax = FT_PIX_CEIL( acbox->xMax ); - acbox->yMax = FT_PIX_CEIL( acbox->yMax ); + acbox->xMax = FT_PIX_CEIL_LONG( acbox->xMax ); + acbox->yMax = FT_PIX_CEIL_LONG( acbox->yMax ); } /* convert to integer pixels if needed */ @@ -536,7 +544,6 @@ FT_BitmapGlyph bitmap = NULL; const FT_Glyph_Class* clazz; - /* FT_BITMAP_GLYPH_CLASS_GET dereferences `library' in PIC mode */ FT_Library library; @@ -553,7 +560,7 @@ goto Bad; /* when called with a bitmap glyph, do nothing and return successfully */ - if ( clazz == FT_BITMAP_GLYPH_CLASS_GET ) + if ( clazz == &ft_bitmap_glyph_class ) goto Exit; if ( !clazz->glyph_prepare ) @@ -569,7 +576,7 @@ dummy.format = clazz->glyph_format; /* create result bitmap glyph */ - error = ft_new_glyph( library, FT_BITMAP_GLYPH_CLASS_GET, &b ); + error = ft_new_glyph( library, &ft_bitmap_glyph_class, &b ); if ( error ) goto Exit; bitmap = (FT_BitmapGlyph)b; diff --git a/src/3rdparty/freetype/src/base/ftgxval.c b/src/3rdparty/freetype/src/base/ftgxval.c index 19e2d6acb5..0677d26faa 100644 --- a/src/3rdparty/freetype/src/base/ftgxval.c +++ b/src/3rdparty/freetype/src/base/ftgxval.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftgxval.c */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO, Redhat K.K, */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgxval.c + * + * FreeType API for validating TrueTypeGX/AAT tables (body). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO, Redhat K.K, + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/fthash.c b/src/3rdparty/freetype/src/base/fthash.c index 21bc8dd5b4..387e6d26db 100644 --- a/src/3rdparty/freetype/src/base/fthash.c +++ b/src/3rdparty/freetype/src/base/fthash.c @@ -1,10 +1,10 @@ -/***************************************************************************/ -/* */ -/* fthash.c */ -/* */ -/* Hashing functions (body). */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fthash.c + * + * Hashing functions (body). + * + */ /* * Copyright 2000 Computing Research Labs, New Mexico State University @@ -30,13 +30,13 @@ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /*************************************************************************/ - /* */ - /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ - /* */ - /* taken from Mark Leisher's xmbdfed package */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 + * + * taken from Mark Leisher's xmbdfed package + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftinit.c b/src/3rdparty/freetype/src/base/ftinit.c index 1fa4721094..c73cd78b83 100644 --- a/src/3rdparty/freetype/src/base/ftinit.c +++ b/src/3rdparty/freetype/src/base/ftinit.c @@ -1,40 +1,40 @@ -/***************************************************************************/ -/* */ -/* ftinit.c */ -/* */ -/* FreeType initialization layer (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* The purpose of this file is to implement the following two */ - /* functions: */ - /* */ - /* FT_Add_Default_Modules(): */ - /* This function is used to add the set of default modules to a */ - /* fresh new library object. The set is taken from the header file */ - /* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */ - /* Build System' for more information. */ - /* */ - /* FT_Init_FreeType(): */ - /* This function creates a system object for the current platform, */ - /* builds a library out of it, then calls FT_Default_Drivers(). */ - /* */ - /* Note that even if FT_Init_FreeType() uses the implementation of the */ - /* system object defined at build time, client applications are still */ - /* able to provide their own `ftsystem.c'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftinit.c + * + * FreeType initialization layer (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * The purpose of this file is to implement the following two + * functions: + * + * FT_Add_Default_Modules(): + * This function is used to add the set of default modules to a + * fresh new library object. The set is taken from the header file + * `freetype/config/ftmodule.h'. See the document `FreeType 2.0 + * Build System' for more information. + * + * FT_Init_FreeType(): + * This function creates a system object for the current platform, + * builds a library out of it, then calls FT_Default_Drivers(). + * + * Note that even if FT_Init_FreeType() uses the implementation of the + * system object defined at build time, client applications are still + * able to provide their own `ftsystem.c'. + * + */ #include <ft2build.h> @@ -42,20 +42,16 @@ #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_MODULE_H -#include "basepic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_init - - -#ifndef FT_CONFIG_OPTION_PIC +#define FT_COMPONENT init #undef FT_USE_MODULE @@ -78,120 +74,6 @@ }; -#else /* FT_CONFIG_OPTION_PIC */ - - -#ifdef __cplusplus -#define FT_EXTERNC extern "C" -#else -#define FT_EXTERNC extern -#endif - - /* declare the module's class creation/destruction functions */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) \ - FT_EXTERNC FT_Error \ - FT_Create_Class_ ## x( FT_Library library, \ - FT_Module_Class* *output_class ); \ - FT_EXTERNC void \ - FT_Destroy_Class_ ## x( FT_Library library, \ - FT_Module_Class* clazz ); - -#include FT_CONFIG_MODULES_H - - /* count all module classes */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x, - - enum - { -#include FT_CONFIG_MODULES_H - FT_NUM_MODULE_CLASSES - }; - - /* destroy all module classes */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) \ - if ( classes[i] ) \ - { \ - FT_Destroy_Class_ ## x( library, classes[i] ); \ - } \ - i++; - - - FT_BASE_DEF( void ) - ft_destroy_default_module_classes( FT_Library library ) - { - FT_Module_Class* *classes; - FT_Memory memory; - FT_UInt i; - BasePIC* pic_container = (BasePIC*)library->pic_container.base; - - - if ( !pic_container->default_module_classes ) - return; - - memory = library->memory; - classes = pic_container->default_module_classes; - i = 0; - -#include FT_CONFIG_MODULES_H - - FT_FREE( classes ); - pic_container->default_module_classes = NULL; - } - - - /* initialize all module classes and the pointer table */ -#undef FT_USE_MODULE -#define FT_USE_MODULE( type, x ) \ - error = FT_Create_Class_ ## x( library, &clazz ); \ - if ( error ) \ - goto Exit; \ - classes[i++] = clazz; - - - FT_BASE_DEF( FT_Error ) - ft_create_default_module_classes( FT_Library library ) - { - FT_Error error; - FT_Memory memory; - FT_Module_Class* *classes = NULL; - FT_Module_Class* clazz; - FT_UInt i; - BasePIC* pic_container = (BasePIC*)library->pic_container.base; - - - memory = library->memory; - - pic_container->default_module_classes = NULL; - - if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) * - ( FT_NUM_MODULE_CLASSES + 1 ) ) ) - return error; - - /* initialize all pointers to 0, especially the last one */ - for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ ) - classes[i] = NULL; - classes[FT_NUM_MODULE_CLASSES] = NULL; - - i = 0; - -#include FT_CONFIG_MODULES_H - - Exit: - if ( error ) - ft_destroy_default_module_classes( library ); - else - pic_container->default_module_classes = classes; - - return error; - } - - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* documentation is in ftmodapi.h */ FT_EXPORT_DEF( void ) @@ -201,16 +83,10 @@ const FT_Module_Class* const* cur; - /* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - if ( !library ) - return; -#endif - /* GCC 4.6 warns the type difference: * FT_Module_Class** != const FT_Module_Class* const* */ - cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET; + cur = (const FT_Module_Class* const*)ft_default_modules; /* test for valid `library' delayed to FT_Add_Module() */ while ( *cur ) @@ -300,6 +176,9 @@ module_name, property_name, property_value ); + + if ( !*p ) + break; } } diff --git a/src/3rdparty/freetype/src/base/ftlcdfil.c b/src/3rdparty/freetype/src/base/ftlcdfil.c index 8d314df080..d9f4af4293 100644 --- a/src/3rdparty/freetype/src/base/ftlcdfil.c +++ b/src/3rdparty/freetype/src/base/ftlcdfil.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftlcdfil.c */ -/* */ -/* FreeType API for color filtering of subpixel bitmap glyphs (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftlcdfil.c + * + * FreeType API for color filtering of subpixel bitmap glyphs (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -34,9 +34,9 @@ /* add padding according to filter weights */ FT_BASE_DEF (void) - ft_lcd_padding( FT_Pos* Min, - FT_Pos* Max, - FT_GlyphSlot slot ) + ft_lcd_padding( FT_BBox* cbox, + FT_GlyphSlot slot, + FT_Render_Mode mode ) { FT_Byte* lcd_weights; FT_Bitmap_LcdFilterFunc lcd_filter_func; @@ -56,10 +56,20 @@ if ( lcd_filter_func == ft_lcd_filter_fir ) { - *Min -= lcd_weights[0] ? 43 : - lcd_weights[1] ? 22 : 0; - *Max += lcd_weights[4] ? 43 : - lcd_weights[3] ? 22 : 0; + if ( mode == FT_RENDER_MODE_LCD ) + { + cbox->xMin -= lcd_weights[0] ? 43 : + lcd_weights[1] ? 22 : 0; + cbox->xMax += lcd_weights[4] ? 43 : + lcd_weights[3] ? 22 : 0; + } + else if ( mode == FT_RENDER_MODE_LCD_V ) + { + cbox->yMin -= lcd_weights[0] ? 43 : + lcd_weights[1] ? 22 : 0; + cbox->yMax += lcd_weights[4] ? 43 : + lcd_weights[3] ? 22 : 0; + } } } @@ -67,13 +77,13 @@ /* FIR filter used by the default and light filters */ FT_BASE_DEF( void ) ft_lcd_filter_fir( FT_Bitmap* bitmap, - FT_Render_Mode mode, FT_LcdFiveTapFilter weights ) { FT_UInt width = (FT_UInt)bitmap->width; FT_UInt height = (FT_UInt)bitmap->rows; FT_Int pitch = bitmap->pitch; FT_Byte* origin = bitmap->buffer; + FT_Byte mode = bitmap->pixel_mode; /* take care of bitmap flow */ @@ -81,7 +91,7 @@ origin += pitch * (FT_Int)( height - 1 ); /* horizontal in-place FIR filter */ - if ( mode == FT_RENDER_MODE_LCD && width >= 2 ) + if ( mode == FT_PIXEL_MODE_LCD && width >= 2 ) { FT_Byte* line = origin; @@ -124,7 +134,7 @@ } /* vertical in-place FIR filter */ - else if ( mode == FT_RENDER_MODE_LCD_V && height >= 2 ) + else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 ) { FT_Byte* column = origin; @@ -173,13 +183,13 @@ /* intra-pixel filter used by the legacy filter */ static void _ft_lcd_filter_legacy( FT_Bitmap* bitmap, - FT_Render_Mode mode, FT_Byte* weights ) { FT_UInt width = (FT_UInt)bitmap->width; FT_UInt height = (FT_UInt)bitmap->rows; FT_Int pitch = bitmap->pitch; FT_Byte* origin = bitmap->buffer; + FT_Byte mode = bitmap->pixel_mode; static const unsigned int filters[3][3] = { @@ -196,7 +206,7 @@ origin += pitch * (FT_Int)( height - 1 ); /* horizontal in-place intra-pixel filter */ - if ( mode == FT_RENDER_MODE_LCD && width >= 3 ) + if ( mode == FT_PIXEL_MODE_LCD && width >= 3 ) { FT_Byte* line = origin; @@ -233,7 +243,7 @@ } } } - else if ( mode == FT_RENDER_MODE_LCD_V && height >= 3 ) + else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 ) { FT_Byte* column = origin; @@ -275,6 +285,8 @@ #endif /* USE_LEGACY */ + /* documentation in ftlcdfil.h */ + FT_EXPORT_DEF( FT_Error ) FT_Library_SetLcdFilterWeights( FT_Library library, unsigned char *weights ) @@ -292,6 +304,8 @@ } + /* documentation in ftlcdfil.h */ + FT_EXPORT_DEF( FT_Error ) FT_Library_SetLcdFilter( FT_Library library, FT_LcdFilter filter ) @@ -341,18 +355,41 @@ return FT_Err_Ok; } + + FT_EXPORT_DEF( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector* sub ) + { + FT_UNUSED( library ); + FT_UNUSED( sub ); + + return FT_THROW( Unimplemented_Feature ); + } + #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /* add padding according to accommodate outline shifts */ + /* add padding to accommodate outline shifts */ FT_BASE_DEF (void) - ft_lcd_padding( FT_Pos* Min, - FT_Pos* Max, - FT_GlyphSlot slot ) + ft_lcd_padding( FT_BBox* cbox, + FT_GlyphSlot slot, + FT_Render_Mode mode ) { - FT_UNUSED( slot ); + FT_Vector* sub = slot->library->lcd_geometry; - *Min -= 21; - *Max += 21; + if ( mode == FT_RENDER_MODE_LCD ) + { + cbox->xMin -= FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x ); + cbox->xMax -= FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x ); + cbox->yMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y ); + cbox->yMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y ); + } + else if ( mode == FT_RENDER_MODE_LCD_V ) + { + cbox->xMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y ); + cbox->xMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y ); + cbox->yMin += FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x ); + cbox->yMax += FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x ); + } } @@ -377,6 +414,24 @@ return FT_THROW( Unimplemented_Feature ); } + + /* documentation in ftlcdfil.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Library_SetLcdGeometry( FT_Library library, + FT_Vector sub[3] ) + { + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + if ( !sub ) + return FT_THROW( Invalid_Argument ); + + ft_memcpy( library->lcd_geometry, sub, 3 * sizeof( FT_Vector ) ); + + return FT_THROW( Unimplemented_Feature ); + } + #endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ diff --git a/src/3rdparty/freetype/src/base/ftmac.c b/src/3rdparty/freetype/src/base/ftmac.c index fd4c0cc274..5f23ceea9f 100644 --- a/src/3rdparty/freetype/src/base/ftmac.c +++ b/src/3rdparty/freetype/src/base/ftmac.c @@ -1,23 +1,23 @@ -/***************************************************************************/ -/* */ -/* ftmac.c */ -/* */ -/* Mac FOND support. Written by just@letterror.com. */ -/* Heavily modified by mpsuzuki, George Williams, and Sean McBride. */ -/* */ -/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */ -/* classic platforms built by MPW. */ -/* */ -/* Copyright 1996-2018 by */ -/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmac.c + * + * Mac FOND support. Written by just@letterror.com. + * Heavily modified by mpsuzuki, George Williams, and Sean McBride. + * + * This file is for Mac OS X only; see builds/mac/ftoldmac.c for + * classic platforms built by MPW. + * + * Copyright (C) 1996-2019 by + * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* @@ -954,17 +954,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face */ - /* */ - /* <Description> */ - /* This is the Mac-specific implementation of FT_New_Face. In */ - /* addition to the standard FT_New_Face() functionality, it also */ - /* accepts pathnames to Mac suitcase files. For further */ - /* documentation see the original FT_New_Face() in freetype.h. */ - /* */ + /************************************************************************** + * + * @Function: + * FT_New_Face + * + * @Description: + * This is the Mac-specific implementation of FT_New_Face. In + * addition to the standard FT_New_Face() functionality, it also + * accepts pathnames to Mac suitcase files. For further + * documentation see the original FT_New_Face() in freetype.h. + */ FT_EXPORT_DEF( FT_Error ) FT_New_Face( FT_Library library, const char* pathname, @@ -995,17 +995,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSRef */ - /* */ - /* <Description> */ - /* FT_New_Face_From_FSRef is identical to FT_New_Face except it */ - /* accepts an FSRef instead of a path. */ - /* */ - /* This function is deprecated because Carbon data types (FSRef) */ - /* are not cross-platform, and thus not suitable for the FreeType API. */ + /************************************************************************** + * + * @Function: + * FT_New_Face_From_FSRef + * + * @Description: + * FT_New_Face_From_FSRef is identical to FT_New_Face except it + * accepts an FSRef instead of a path. + * + * This function is deprecated because Carbon data types (FSRef) + * are not cross-platform, and thus not suitable for the FreeType API. + */ FT_EXPORT_DEF( FT_Error ) FT_New_Face_From_FSRef( FT_Library library, const FSRef* ref, @@ -1040,16 +1041,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSSpec */ - /* */ - /* <Description> */ - /* FT_New_Face_From_FSSpec is identical to FT_New_Face except it */ - /* accepts an FSSpec instead of a path. */ - /* */ - /* This function is deprecated because FSSpec is deprecated in Mac OS X */ + /************************************************************************** + * + * @Function: + * FT_New_Face_From_FSSpec + * + * @Description: + * FT_New_Face_From_FSSpec is identical to FT_New_Face except it + * accepts an FSSpec instead of a path. + * + * This function is deprecated because FSSpec is deprecated in Mac OS X + */ FT_EXPORT_DEF( FT_Error ) FT_New_Face_From_FSSpec( FT_Library library, const FSSpec* spec, diff --git a/src/3rdparty/freetype/src/base/ftmm.c b/src/3rdparty/freetype/src/base/ftmm.c index 800441bcac..ba9e67f008 100644 --- a/src/3rdparty/freetype/src/base/ftmm.c +++ b/src/3rdparty/freetype/src/base/ftmm.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftmm.c */ -/* */ -/* Multiple Master font support (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftmm.c + * + * Multiple Master font support (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,14 +25,14 @@ #include FT_SERVICE_METRICS_VARIATIONS_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_mm +#define FT_COMPONENT mm static FT_Error @@ -199,6 +199,67 @@ } + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Set_MM_WeightVector( FT_Face face, + FT_UInt len, + FT_Fixed* weightvector ) + { + FT_Error error; + FT_Service_MultiMasters service; + + + /* check of `face' delayed to `ft_face_get_mm_service' */ + + if ( len && !weightvector ) + return FT_THROW( Invalid_Argument ); + + error = ft_face_get_mm_service( face, &service ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service->set_mm_weightvector ) + error = service->set_mm_weightvector( face, len, weightvector ); + } + + /* enforce recomputation of auto-hinting data */ + if ( !error && face->autohint.finalizer ) + { + face->autohint.finalizer( face->autohint.data ); + face->autohint.data = NULL; + } + + return error; + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_MM_WeightVector( FT_Face face, + FT_UInt* len, + FT_Fixed* weightvector ) + { + FT_Error error; + FT_Service_MultiMasters service; + + + /* check of `face' delayed to `ft_face_get_mm_service' */ + + if ( len && !weightvector ) + return FT_THROW( Invalid_Argument ); + + error = ft_face_get_mm_service( face, &service ); + if ( !error ) + { + error = FT_ERR( Invalid_Argument ); + if ( service->get_mm_weightvector ) + error = service->get_mm_weightvector( face, len, weightvector ); + } + + return error; + } + + /* documentation is in ftmm.h */ FT_EXPORT_DEF( FT_Error ) diff --git a/src/3rdparty/freetype/src/base/ftobjs.c b/src/3rdparty/freetype/src/base/ftobjs.c index 8d07e35ae3..e301f8f11a 100644 --- a/src/3rdparty/freetype/src/base/ftobjs.c +++ b/src/3rdparty/freetype/src/base/ftobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftobjs.c */ -/* */ -/* The FreeType private base classes (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftobjs.c + * + * The FreeType private base classes (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -79,6 +79,18 @@ #pragma warning( pop ) #endif + static const char* const pixel_modes[] = + { + "none", + "monochrome bitmap", + "gray 8-bit bitmap", + "gray 2-bit bitmap", + "gray 4-bit bitmap", + "LCD 8-bit bitmap", + "vertical LCD 8-bit bitmap", + "BGRA 32-bit color image bitmap" + }; + #endif /* FT_DEBUG_LEVEL_TRACE */ @@ -259,14 +271,14 @@ } - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs /*************************************************************************/ @@ -330,7 +342,9 @@ } - FT_BASE_DEF( void ) + /* overflow-resistant presetting of bitmap position and dimensions; */ + /* also check whether the size is too large for rendering */ + FT_BASE_DEF( FT_Bool ) ft_glyphslot_preset_bitmap( FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) @@ -340,15 +354,15 @@ FT_Pixel_Mode pixel_mode; - FT_BBox cbox; + FT_BBox cbox, pbox; FT_Pos x_shift = 0; FT_Pos y_shift = 0; FT_Pos x_left, y_top; FT_Pos width, height, pitch; - if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) - return; + if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) + return 1; if ( origin ) { @@ -360,76 +374,89 @@ /* taking into account the origin shift */ FT_Outline_Get_CBox( outline, &cbox ); - cbox.xMin += x_shift; - cbox.yMin += y_shift; - cbox.xMax += x_shift; - cbox.yMax += y_shift; + /* rough estimate of pixel box */ + pbox.xMin = ( cbox.xMin >> 6 ) + ( x_shift >> 6 ); + pbox.yMin = ( cbox.yMin >> 6 ) + ( y_shift >> 6 ); + pbox.xMax = ( cbox.xMax >> 6 ) + ( x_shift >> 6 ); + pbox.yMax = ( cbox.yMax >> 6 ) + ( y_shift >> 6 ); + + /* tiny remainder box */ + cbox.xMin = ( cbox.xMin & 63 ) + ( x_shift & 63 ); + cbox.yMin = ( cbox.yMin & 63 ) + ( y_shift & 63 ); + cbox.xMax = ( cbox.xMax & 63 ) + ( x_shift & 63 ); + cbox.yMax = ( cbox.yMax & 63 ) + ( y_shift & 63 ); switch ( mode ) { case FT_RENDER_MODE_MONO: pixel_mode = FT_PIXEL_MODE_MONO; #if 1 - /* undocumented but confirmed: bbox values get rounded */ - /* unless the rounded box can collapse for a narrow glyph */ - if ( cbox.xMax - cbox.xMin < 64 ) - { - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); - } - else - { - cbox.xMin = FT_PIX_ROUND_LONG( cbox.xMin ); - cbox.xMax = FT_PIX_ROUND_LONG( cbox.xMax ); - } + /* x */ + + /* undocumented but confirmed: bbox values get rounded; */ + /* we do asymmetric rounding so that the center of a pixel */ + /* gets always included */ + + pbox.xMin += ( cbox.xMin + 31 ) >> 6; + pbox.xMax += ( cbox.xMax + 32 ) >> 6; - if ( cbox.yMax - cbox.yMin < 64 ) + /* if the bbox collapsed, we add a pixel based on the total */ + /* rounding remainder to cover most of the original cbox */ + + if ( pbox.xMin == pbox.xMax ) { - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + if ( ( ( cbox.xMin + 31 ) & 63 ) - 31 + + ( ( cbox.xMax + 32 ) & 63 ) - 32 < 0 ) + pbox.xMin -= 1; + else + pbox.xMax += 1; } - else + + /* y */ + + pbox.yMin += ( cbox.yMin + 31 ) >> 6; + pbox.yMax += ( cbox.yMax + 32 ) >> 6; + + if ( pbox.yMin == pbox.yMax ) { - cbox.yMin = FT_PIX_ROUND_LONG( cbox.yMin ); - cbox.yMax = FT_PIX_ROUND_LONG( cbox.yMax ); + if ( ( ( cbox.yMin + 31 ) & 63 ) - 31 + + ( ( cbox.yMax + 32 ) & 63 ) - 32 < 0 ) + pbox.yMin -= 1; + else + pbox.yMax += 1; } + + break; #else - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + goto Adjust; #endif - break; case FT_RENDER_MODE_LCD: pixel_mode = FT_PIXEL_MODE_LCD; - ft_lcd_padding( &cbox.xMin, &cbox.xMax, slot ); - goto Round; + ft_lcd_padding( &cbox, slot, mode ); + goto Adjust; case FT_RENDER_MODE_LCD_V: pixel_mode = FT_PIXEL_MODE_LCD_V; - ft_lcd_padding( &cbox.yMin, &cbox.yMax, slot ); - goto Round; + ft_lcd_padding( &cbox, slot, mode ); + goto Adjust; case FT_RENDER_MODE_NORMAL: case FT_RENDER_MODE_LIGHT: default: pixel_mode = FT_PIXEL_MODE_GRAY; - Round: - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL_LONG( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL_LONG( cbox.yMax ); + Adjust: + pbox.xMin += cbox.xMin >> 6; + pbox.yMin += cbox.yMin >> 6; + pbox.xMax += ( cbox.xMax + 63 ) >> 6; + pbox.yMax += ( cbox.yMax + 63 ) >> 6; } - x_shift = SUB_LONG( x_shift, cbox.xMin ); - y_shift = SUB_LONG( y_shift, cbox.yMin ); + x_left = pbox.xMin; + y_top = pbox.yMax; - x_left = cbox.xMin >> 6; - y_top = cbox.yMax >> 6; - - width = ( (FT_ULong)cbox.xMax - (FT_ULong)cbox.xMin ) >> 6; - height = ( (FT_ULong)cbox.yMax - (FT_ULong)cbox.yMin ) >> 6; + width = pbox.xMax - pbox.xMin; + height = pbox.yMax - pbox.yMin; switch ( pixel_mode ) { @@ -459,6 +486,16 @@ bitmap->width = (unsigned int)width; bitmap->rows = (unsigned int)height; bitmap->pitch = pitch; + + if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF || + pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF ) + { + FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n", + pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax )); + return 1; + } + + return 0; } @@ -807,7 +844,7 @@ * - Do only auto-hinting if we have * * - a hinter module, - * - a scalable font format dealing with outlines, + * - a scalable font, * - not a tricky font, and * - no transforms except simple slants and/or rotations by * integer multiples of 90 degrees. @@ -825,8 +862,7 @@ if ( hinter && !( load_flags & FT_LOAD_NO_HINTING ) && !( load_flags & FT_LOAD_NO_AUTOHINT ) && - FT_DRIVER_IS_SCALABLE( driver ) && - FT_DRIVER_USES_OUTLINES( driver ) && + FT_IS_SCALABLE( face ) && !FT_IS_TRICKY( face ) && ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) || ( face->internal->transform_matrix.yx == 0 && @@ -846,7 +882,7 @@ /* only the new Adobe engine (for both CFF and Type 1) is `light'; */ /* we use `strstr' to catch both `Type 1' and `CID Type 1' */ is_light_type1 = - ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL && + ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL && ((PS_Driver)driver)->hinting_engine == FT_HINTING_ADOBE; /* the check for `num_locations' assures that we actually */ @@ -926,8 +962,9 @@ #ifdef GRID_FIT_METRICS if ( !( load_flags & FT_LOAD_NO_HINTING ) ) - ft_glyphslot_grid_fit_metrics( slot, - FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); + ft_glyphslot_grid_fit_metrics( + slot, + FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); #endif } } @@ -995,6 +1032,9 @@ } } + slot->glyph_index = glyph_index; + slot->internal->load_flags = load_flags; + /* do we need to render the image or preset the bitmap now? */ if ( !error && ( load_flags & FT_LOAD_NO_SCALE ) == 0 && @@ -1014,17 +1054,21 @@ ft_glyphslot_preset_bitmap( slot, mode, NULL ); } - FT_TRACE5(( "FT_Load_Glyph: index %d, flags %x\n", - glyph_index, load_flags )); +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n", + glyph_index, load_flags )); FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 )); FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 )); FT_TRACE5(( " linear x advance: %f\n", slot->linearHoriAdvance / 65536.0 )); FT_TRACE5(( " linear y advance: %f\n", slot->linearVertAdvance / 65536.0 )); - FT_TRACE5(( " bitmap %dx%d, mode %d\n", - slot->bitmap.width, slot->bitmap.rows, - slot->bitmap.pixel_mode )); + FT_TRACE5(( " bitmap %dx%d, %s (mode %d)\n", + slot->bitmap.width, + slot->bitmap.rows, + pixel_modes[slot->bitmap.pixel_mode], + slot->bitmap.pixel_mode )); +#endif Exit: return error; @@ -1162,20 +1206,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* find_unicode_charmap */ - /* */ - /* <Description> */ - /* This function finds a Unicode charmap, if there is one. */ - /* And if there is more than one, it tries to favour the more */ - /* extensive one, i.e., one that supports UCS-4 against those which */ - /* are limited to the BMP (said UCS-2 encoding.) */ - /* */ - /* This function is called from open_face() (just below), and also */ - /* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). */ - /* */ + /************************************************************************** + * + * @Function: + * find_unicode_charmap + * + * @Description: + * This function finds a Unicode charmap, if there is one. + * And if there is more than one, it tries to favour the more + * extensive one, i.e., one that supports UCS-4 against those which + * are limited to the BMP (said UCS-2 encoding.) + * + * This function is called from open_face() (just below), and also + * from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ). + */ static FT_Error find_unicode_charmap( FT_Face face ) { @@ -1192,26 +1236,26 @@ return FT_THROW( Invalid_CharMap_Handle ); /* - * The original TrueType specification(s) only specified charmap - * formats that are capable of mapping 8 or 16 bit character codes to - * glyph indices. + * The original TrueType specification(s) only specified charmap + * formats that are capable of mapping 8 or 16 bit character codes to + * glyph indices. * - * However, recent updates to the Apple and OpenType specifications - * introduced new formats that are capable of mapping 32-bit character - * codes as well. And these are already used on some fonts, mainly to - * map non-BMP Asian ideographs as defined in Unicode. + * However, recent updates to the Apple and OpenType specifications + * introduced new formats that are capable of mapping 32-bit character + * codes as well. And these are already used on some fonts, mainly to + * map non-BMP Asian ideographs as defined in Unicode. * - * For compatibility purposes, these fonts generally come with - * *several* Unicode charmaps: + * For compatibility purposes, these fonts generally come with + * *several* Unicode charmaps: * - * - One of them in the "old" 16-bit format, that cannot access - * all glyphs in the font. + * - One of them in the "old" 16-bit format, that cannot access + * all glyphs in the font. * - * - Another one in the "new" 32-bit format, that can access all - * the glyphs. + * - Another one in the "new" 32-bit format, that can access all + * the glyphs. * - * This function has been written to always favor a 32-bit charmap - * when found. Otherwise, a 16-bit one is returned when found. + * This function has been written to always favor a 32-bit charmap + * when found. Otherwise, a 16-bit one is returned when found. */ /* Since the `interesting' table, with IDs (3,10), is normally the */ @@ -1255,15 +1299,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* find_variant_selector_charmap */ - /* */ - /* <Description> */ - /* This function finds the variant selector charmap, if there is one. */ - /* There can only be one (platform=0, specific=5, format=14). */ - /* */ + /************************************************************************** + * + * @Function: + * find_variant_selector_charmap + * + * @Description: + * This function finds the variant selector charmap, if there is one. + * There can only be one (platform=0, specific=5, format=14). + */ static FT_CharMap find_variant_selector_charmap( FT_Face face ) { @@ -1294,14 +1338,14 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* open_face */ - /* */ - /* <Description> */ - /* This function does some work for FT_Open_Face(). */ - /* */ + /************************************************************************** + * + * @Function: + * open_face + * + * @Description: + * This function does some work for FT_Open_Face(). + */ static FT_Error open_face( FT_Driver driver, FT_Stream *astream, @@ -2176,13 +2220,13 @@ { #undef FT_COMPONENT -#define FT_COMPONENT trace_raccess +#define FT_COMPONENT raccess FT_Memory memory = library->memory; FT_Error error = FT_ERR( Unknown_File_Format ); FT_UInt i; - char * file_names[FT_RACCESS_N_RULES]; + char* file_names[FT_RACCESS_N_RULES]; FT_Long offsets[FT_RACCESS_N_RULES]; FT_Error errors[FT_RACCESS_N_RULES]; FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */ @@ -2254,7 +2298,7 @@ return error; #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs } @@ -2282,7 +2326,7 @@ { #undef FT_COMPONENT -#define FT_COMPONENT trace_raccess +#define FT_COMPONENT raccess #ifdef FT_DEBUG_LEVEL_TRACE FT_TRACE3(( "Try as dfont: " )); @@ -2295,7 +2339,7 @@ FT_TRACE3(( "%s\n", error ? "failed" : "successful" )); #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs } @@ -2693,8 +2737,8 @@ /* close the attached stream */ FT_Stream_Free( stream, - (FT_Bool)( parameters->stream && - ( parameters->flags & FT_OPEN_STREAM ) ) ); + FT_BOOL( parameters->stream && + ( parameters->flags & FT_OPEN_STREAM ) ) ); Exit: return error; @@ -3464,7 +3508,8 @@ if ( !face ) return FT_THROW( Invalid_Face_Handle ); - if ( encoding == FT_ENCODING_NONE ) + /* FT_ENCODING_NONE is a valid encoding for BDF, PCF, and Windows FNT */ + if ( encoding == FT_ENCODING_NONE && !face->num_charmaps ) return FT_THROW( Invalid_Argument ); /* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */ @@ -3485,7 +3530,7 @@ if ( cur[0]->encoding == encoding ) { face->charmap = cur[0]; - return 0; + return FT_Err_Ok; } } @@ -3510,14 +3555,12 @@ if ( !cur || !charmap ) return FT_THROW( Invalid_CharMap_Handle ); - if ( FT_Get_CMap_Format( charmap ) == 14 ) - return FT_THROW( Invalid_Argument ); - limit = cur + face->num_charmaps; for ( ; cur < limit; cur++ ) { - if ( cur[0] == charmap ) + if ( cur[0] == charmap && + FT_Get_CMap_Format ( charmap ) != 14 ) { face->charmap = cur[0]; return FT_Err_Ok; @@ -4016,8 +4059,8 @@ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_UInt ) - FT_Get_Name_Index( FT_Face face, - FT_String* glyph_name ) + FT_Get_Name_Index( FT_Face face, + const FT_String* glyph_name ) { FT_UInt result = 0; @@ -4487,16 +4530,89 @@ FT_Render_Mode render_mode ) { FT_Error error = FT_Err_Ok; + FT_Face face = slot->face; FT_Renderer renderer; - /* if it is already a bitmap, no need to do anything */ switch ( slot->format ) { case FT_GLYPH_FORMAT_BITMAP: /* already a bitmap, don't do anything */ break; default: + if ( slot->internal->load_flags & FT_LOAD_COLOR ) + { + FT_LayerIterator iterator; + + FT_UInt base_glyph = slot->glyph_index; + + FT_Bool have_layers; + FT_UInt glyph_index; + FT_UInt color_index; + + + /* check whether we have colored glyph layers */ + iterator.p = NULL; + have_layers = FT_Get_Color_Glyph_Layer( face, + base_glyph, + &glyph_index, + &color_index, + &iterator ); + if ( have_layers ) + { + error = FT_New_GlyphSlot( face, NULL ); + if ( !error ) + { + TT_Face ttface = (TT_Face)face; + SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; + + + do + { + FT_Int32 load_flags = slot->internal->load_flags; + + + /* disable the `FT_LOAD_COLOR' flag to avoid recursion */ + /* right here in this function */ + load_flags &= ~FT_LOAD_COLOR; + + /* render into the new `face->glyph' glyph slot */ + load_flags |= FT_LOAD_RENDER; + + error = FT_Load_Glyph( face, glyph_index, load_flags ); + if ( error ) + break; + + /* blend new `face->glyph' into old `slot'; */ + /* at the first call, `slot' is still empty */ + error = sfnt->colr_blend( ttface, + color_index, + slot, + face->glyph ); + if ( error ) + break; + + } while ( FT_Get_Color_Glyph_Layer( face, + base_glyph, + &glyph_index, + &color_index, + &iterator ) ); + + if ( !error ) + slot->format = FT_GLYPH_FORMAT_BITMAP; + + /* this call also restores `slot' as the glyph slot */ + FT_Done_GlyphSlot( face->glyph ); + } + + if ( !error ) + return error; + + /* Failed to do the colored layer. Draw outline instead. */ + slot->format = FT_GLYPH_FORMAT_OUTLINE; + } + } + { FT_ListNode node = NULL; @@ -4532,7 +4648,7 @@ #ifdef FT_DEBUG_LEVEL_TRACE #undef FT_COMPONENT -#define FT_COMPONENT trace_bitmap +#define FT_COMPONENT checksum /* * Computing the MD5 checksum is expensive, unnecessarily distorting a @@ -4542,9 +4658,9 @@ */ /* we use FT_TRACE3 in this block */ - if ( !error && - ft_trace_levels[trace_bitmap] >= 3 && - slot->bitmap.buffer ) + if ( !error && + ft_trace_levels[trace_checksum] >= 3 && + slot->bitmap.buffer ) { FT_Bitmap bitmap; FT_Error err; @@ -4565,8 +4681,11 @@ int pitch = bitmap.pitch; - FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, mode %d\n", - rows, pitch, slot->bitmap.pixel_mode )); + FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, %s (mode %d)\n", + pitch, + rows, + pixel_modes[slot->bitmap.pixel_mode], + slot->bitmap.pixel_mode )); for ( i = 0; i < rows; i++ ) for ( j = 0; j < pitch; j++ ) @@ -4594,49 +4713,56 @@ */ /* we use FT_TRACE7 in this block */ - if ( !error && - ft_trace_levels[trace_bitmap] >= 7 && - slot->bitmap.rows < 128U && - slot->bitmap.width < 128U && - slot->bitmap.buffer ) + if ( !error && + ft_trace_levels[trace_checksum] >= 7 ) { - int rows = (int)slot->bitmap.rows; - int width = (int)slot->bitmap.width; - int pitch = slot->bitmap.pitch; - int i, j, m; - unsigned char* topleft = slot->bitmap.buffer; + if ( slot->bitmap.rows < 128U && + slot->bitmap.width < 128U && + slot->bitmap.buffer ) + { + int rows = (int)slot->bitmap.rows; + int width = (int)slot->bitmap.width; + int pitch = slot->bitmap.pitch; + int i, j, m; - if ( pitch < 0 ) - topleft -= pitch * ( rows - 1 ); + unsigned char* topleft = slot->bitmap.buffer; - FT_TRACE7(( "Netpbm image: start\n" )); - switch ( slot->bitmap.pixel_mode ) - { - case FT_PIXEL_MODE_MONO: - FT_TRACE7(( "P1 %d %d\n", width, rows )); - for ( i = 0; i < rows; i++ ) - { - for ( j = 0; j < width; ) - for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) - FT_TRACE7(( " %d", ( topleft[i * pitch + j / 8] & m ) != 0 )); - FT_TRACE7(( "\n" )); - } - break; - default: - FT_TRACE7(( "P2 %d %d 255\n", width, rows )); - for ( i = 0; i < rows; i++ ) + if ( pitch < 0 ) + topleft -= pitch * ( rows - 1 ); + + FT_TRACE7(( "Netpbm image: start\n" )); + switch ( slot->bitmap.pixel_mode ) { - for ( j = 0; j < width; j += 1 ) - FT_TRACE7(( " %3u", topleft[i * pitch + j] )); - FT_TRACE7(( "\n" )); + case FT_PIXEL_MODE_MONO: + FT_TRACE7(( "P1 %d %d\n", width, rows )); + for ( i = 0; i < rows; i++ ) + { + for ( j = 0; j < width; ) + for ( m = 128; m > 0 && j < width; m >>= 1, j++ ) + FT_TRACE7(( " %d", + ( topleft[i * pitch + j / 8] & m ) != 0 )); + FT_TRACE7(( "\n" )); + } + break; + + default: + FT_TRACE7(( "P2 %d %d 255\n", width, rows )); + for ( i = 0; i < rows; i++ ) + { + for ( j = 0; j < width; j += 1 ) + FT_TRACE7(( " %3u", topleft[i * pitch + j] )); + FT_TRACE7(( "\n" )); + } } + FT_TRACE7(( "Netpbm image: end\n" )); } - FT_TRACE7(( "Netpbm image: end\n" )); + else + FT_TRACE7(( "Netpbm image: too large, omitted\n" )); } #undef FT_COMPONENT -#define FT_COMPONENT trace_objs +#define FT_COMPONENT objs #endif /* FT_DEBUG_LEVEL_TRACE */ @@ -4675,21 +4801,22 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* Destroy_Module */ - /* */ - /* <Description> */ - /* Destroys a given module object. For drivers, this also destroys */ - /* all child faces. */ - /* */ - /* <InOut> */ - /* module :: A handle to the target driver object. */ - /* */ - /* <Note> */ - /* The driver _must_ be LOCKED! */ - /* */ + /************************************************************************** + * + * @Function: + * Destroy_Module + * + * @Description: + * Destroys a given module object. For drivers, this also destroys + * all child faces. + * + * @InOut: + * module :: + * A handle to the target driver object. + * + * @Note: + * The driver _must_ be LOCKED! + */ static void Destroy_Module( FT_Module module ) { @@ -5028,9 +5155,9 @@ service = (FT_Service_Properties)interface; if ( set ) - missing_func = (FT_Bool)( !service->set_property ); + missing_func = FT_BOOL( !service->set_property ); else - missing_func = (FT_Bool)( !service->get_property ); + missing_func = FT_BOOL( !service->get_property ); if ( missing_func ) { @@ -5156,13 +5283,6 @@ library->memory = memory; -#ifdef FT_CONFIG_OPTION_PIC - /* initialize position independent code containers */ - error = ft_pic_container_init( library ); - if ( error ) - goto Fail; -#endif - library->version_major = FREETYPE_MAJOR; library->version_minor = FREETYPE_MINOR; library->version_patch = FREETYPE_PATCH; @@ -5173,13 +5293,6 @@ *alibrary = library; return FT_Err_Ok; - -#ifdef FT_CONFIG_OPTION_PIC - Fail: - ft_pic_container_destroy( library ); - FT_FREE( library ); - return error; -#endif } @@ -5237,10 +5350,10 @@ * * Example: * - * - the cff font driver uses the pshinter module in cff_size_done - * - if the pshinter module is destroyed before the cff font driver, - * opened FT_Face objects managed by the driver are not properly - * destroyed, resulting in a memory leak + * - the cff font driver uses the pshinter module in cff_size_done + * - if the pshinter module is destroyed before the cff font driver, + * opened FT_Face objects managed by the driver are not properly + * destroyed, resulting in a memory leak * * Some faces are dependent on other faces, like Type42 faces that * depend on TrueType faces synthesized internally. @@ -5310,11 +5423,6 @@ } #endif -#ifdef FT_CONFIG_OPTION_PIC - /* Destroy pic container contents */ - ft_pic_container_destroy( library ); -#endif - FT_FREE( library ); Exit: @@ -5402,4 +5510,41 @@ } + /* documentation is in freetype.h */ + + FT_EXPORT_DEF( FT_Bool ) + FT_Get_Color_Glyph_Layer( FT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ) + { + TT_Face ttface; + SFNT_Service sfnt; + + + if ( !face || + !aglyph_index || + !acolor_index || + !iterator || + base_glyph >= (FT_UInt)face->num_glyphs ) + return 0; + + if ( !FT_IS_SFNT( face ) ) + return 0; + + ttface = (TT_Face)face; + sfnt = (SFNT_Service)ttface->sfnt; + + if ( sfnt->get_colr_layer ) + return sfnt->get_colr_layer( ttface, + base_glyph, + aglyph_index, + acolor_index, + iterator ); + else + return 0; + } + + /* END */ diff --git a/src/3rdparty/freetype/src/base/ftotval.c b/src/3rdparty/freetype/src/base/ftotval.c index a2944a7950..007576ce6e 100644 --- a/src/3rdparty/freetype/src/base/ftotval.c +++ b/src/3rdparty/freetype/src/base/ftotval.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftotval.c */ -/* */ -/* FreeType API for validating OpenType tables (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftotval.c + * + * FreeType API for validating OpenType tables (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H diff --git a/src/3rdparty/freetype/src/base/ftoutln.c b/src/3rdparty/freetype/src/base/ftoutln.c index cb91321deb..0e2ba3475d 100644 --- a/src/3rdparty/freetype/src/base/ftoutln.c +++ b/src/3rdparty/freetype/src/base/ftoutln.c @@ -1,26 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftoutln.c */ -/* */ -/* FreeType outline management (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* All functions are declared in freetype.h. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftoutln.c + * + * FreeType outline management (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +24,14 @@ #include FT_TRIGONOMETRY_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_outline +#define FT_COMPONENT outline static @@ -53,8 +46,7 @@ void* user ) { #undef SCALED -#define SCALED( x ) ( ( (x) < 0 ? -( -(x) << shift ) \ - : ( (x) << shift ) ) - delta ) +#define SCALED( x ) ( (x) * ( 1L << shift ) - delta ) FT_Vector v_last; FT_Vector v_control; @@ -296,14 +288,22 @@ } + /* documentation is in ftoutln.h */ + FT_EXPORT_DEF( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ) + FT_Outline_New( FT_Library library, + FT_UInt numPoints, + FT_Int numContours, + FT_Outline *anoutline ) { - FT_Error error; + FT_Error error; + FT_Memory memory; + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + + memory = library->memory; if ( !anoutline || !memory ) return FT_THROW( Invalid_Argument ); @@ -330,28 +330,12 @@ Fail: anoutline->flags |= FT_OUTLINE_OWNER; - FT_Outline_Done_Internal( memory, anoutline ); + FT_Outline_Done( library, anoutline ); return error; } - /* documentation is in ftoutln.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_Outline_New( FT_Library library, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ) - { - if ( !library ) - return FT_THROW( Invalid_Library_Handle ); - - return FT_Outline_New_Internal( library->memory, numPoints, - numContours, anoutline ); - } - - /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) @@ -436,13 +420,23 @@ } + /* documentation is in ftoutln.h */ + FT_EXPORT_DEF( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ) + FT_Outline_Done( FT_Library library, + FT_Outline* outline ) { + FT_Memory memory; + + + if ( !library ) + return FT_THROW( Invalid_Library_Handle ); + if ( !outline ) return FT_THROW( Invalid_Outline ); + memory = library->memory; + if ( !memory ) return FT_THROW( Invalid_Argument ); @@ -458,21 +452,6 @@ } - /* documentation is in ftoutln.h */ - - FT_EXPORT_DEF( FT_Error ) - FT_Outline_Done( FT_Library library, - FT_Outline* outline ) - { - /* check for valid `outline' in FT_Outline_Done_Internal() */ - - if ( !library ) - return FT_THROW( Invalid_Library_Handle ); - - return FT_Outline_Done_Internal( library->memory, outline ); - } - - /* documentation is in ftoutln.h */ FT_EXPORT_DEF( void ) @@ -619,6 +598,7 @@ FT_Error error; FT_Renderer renderer; FT_ListNode node; + FT_BBox cbox; if ( !library ) @@ -630,11 +610,26 @@ if ( !params ) return FT_THROW( Invalid_Argument ); + FT_Outline_Get_CBox( outline, &cbox ); + if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L || + cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L ) + return FT_THROW( Invalid_Outline ); + renderer = library->cur_renderer; node = library->renderers.head; params->source = (void*)outline; + /* preset clip_box for direct mode */ + if ( params->flags & FT_RASTER_FLAG_DIRECT && + !( params->flags & FT_RASTER_FLAG_CLIP ) ) + { + params->clip_box.xMin = cbox.xMin >> 6; + params->clip_box.yMin = cbox.yMin >> 6; + params->clip_box.xMax = ( cbox.xMax + 63 ) >> 6; + params->clip_box.yMax = ( cbox.yMax + 63 ) >> 6; + } + error = FT_ERR( Cannot_Render_Glyph ); while ( renderer ) { @@ -911,9 +906,9 @@ FT_Pos xstrength, FT_Pos ystrength ) { - FT_Vector* points; - FT_Int c, first, last; - FT_Int orientation; + FT_Vector* points; + FT_Int c, first, last; + FT_Orientation orientation; if ( !outline ) @@ -1044,7 +1039,7 @@ FT_EXPORT_DEF( FT_Orientation ) FT_Outline_Get_Orientation( FT_Outline* outline ) { - FT_BBox cbox; + FT_BBox cbox = { 0, 0, 0, 0 }; FT_Int xshift, yshift; FT_Vector* points; FT_Vector v_prev, v_cur; @@ -1090,7 +1085,8 @@ v_cur.y = points[n].y >> yshift; area = ADD_LONG( area, - ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ) ); + MUL_LONG( v_cur.y - v_prev.y, + v_cur.x + v_prev.x ) ); v_prev = v_cur; } diff --git a/src/3rdparty/freetype/src/base/ftpatent.c b/src/3rdparty/freetype/src/base/ftpatent.c index e23ee2e3f4..020f4646eb 100644 --- a/src/3rdparty/freetype/src/base/ftpatent.c +++ b/src/3rdparty/freetype/src/base/ftpatent.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftpatent.c */ -/* */ -/* FreeType API for checking patented TrueType bytecode instructions */ -/* (body). Obsolete, retained for backward compatibility. */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpatent.c + * + * FreeType API for checking patented TrueType bytecode instructions + * (body). Obsolete, retained for backward compatibility. + * + * Copyright (C) 2007-2019 by + * David Turner. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_FREETYPE_H diff --git a/src/3rdparty/freetype/src/base/ftpfr.c b/src/3rdparty/freetype/src/base/ftpfr.c index bfe13520eb..aeff1db8bd 100644 --- a/src/3rdparty/freetype/src/base/ftpfr.c +++ b/src/3rdparty/freetype/src/base/ftpfr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftpfr.c */ -/* */ -/* FreeType API for accessing PFR-specific data (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpfr.c + * + * FreeType API for accessing PFR-specific data (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H diff --git a/src/3rdparty/freetype/src/base/ftpsprop.c b/src/3rdparty/freetype/src/base/ftpsprop.c index 459b5e6054..52b9d453ad 100644 --- a/src/3rdparty/freetype/src/base/ftpsprop.c +++ b/src/3rdparty/freetype/src/base/ftpsprop.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ftpsprop.c */ -/* */ -/* Get and set properties of PostScript drivers (body). */ -/* See `ftdriver.h' for available properties. */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftpsprop.c + * + * Get and set properties of PostScript drivers (body). + * See `ftdriver.h' for available properties. + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,14 +25,14 @@ #include FT_INTERNAL_POSTSCRIPT_PROPS_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_psprops +#define FT_COMPONENT psprops FT_BASE_CALLBACK_DEF( FT_Error ) diff --git a/src/3rdparty/freetype/src/base/ftrfork.c b/src/3rdparty/freetype/src/base/ftrfork.c index c3a2b9151a..73b7eb0ded 100644 --- a/src/3rdparty/freetype/src/base/ftrfork.c +++ b/src/3rdparty/freetype/src/base/ftrfork.c @@ -1,38 +1,38 @@ -/***************************************************************************/ -/* */ -/* ftrfork.c */ -/* */ -/* Embedded resource forks accessor (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */ -/* derived from ftobjs.c. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* Development of the code in this file is support of */ -/* Information-technology Promotion Agency, Japan. */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrfork.c + * + * Embedded resource forks accessor (body). + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO and Redhat K.K. + * + * FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are + * derived from ftobjs.c. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * Development of the code in this file is support of + * Information-technology Promotion Agency, Japan. + */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_RFORK_H -#include "basepic.h" + #include "ftbase.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_raccess +#define FT_COMPONENT raccess /*************************************************************************/ @@ -438,7 +438,7 @@ static FT_Error raccess_guess_linux_double_from_file_name( FT_Library library, - char * file_name, + char* file_name, FT_Long *result_offset ); static char * @@ -468,10 +468,10 @@ if ( errors[i] ) continue; - errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library, - stream, base_name, - &(new_names[i]), - &(offsets[i]) ); + errors[i] = ft_raccess_guess_table[i].func( library, + stream, base_name, + &(new_names[i]), + &(offsets[i]) ); } return; @@ -488,7 +488,7 @@ if ( rule_index >= FT_RACCESS_N_RULES ) return FT_RFork_Rule_invalid; - return FT_RACCESS_GUESS_TABLE_GET[rule_index].type; + return ft_raccess_guess_table[rule_index].type; } @@ -847,7 +847,7 @@ { FT_Open_Args args2; FT_Stream stream2; - char * nouse = NULL; + char* nouse = NULL; FT_Error error; @@ -909,9 +909,9 @@ #else /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ - /*************************************************************************/ - /* Dummy function; just sets errors */ - /*************************************************************************/ + /************************************************************************** + * Dummy function; just sets errors + */ FT_BASE_DEF( void ) FT_Raccess_Guess( FT_Library library, diff --git a/src/3rdparty/freetype/src/base/ftsnames.c b/src/3rdparty/freetype/src/base/ftsnames.c index 90ea1e2be7..7ab3fe3cfa 100644 --- a/src/3rdparty/freetype/src/base/ftsnames.c +++ b/src/3rdparty/freetype/src/base/ftsnames.c @@ -1,22 +1,22 @@ -/***************************************************************************/ -/* */ -/* ftsnames.c */ -/* */ -/* Simple interface to access SFNT name tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (body). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsnames.c + * + * Simple interface to access SFNT name tables (which are used + * to hold font names, copyright info, notices, etc.) (body). + * + * This is _not_ used to retrieve glyph names! + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -142,7 +142,45 @@ } -#endif /* TT_CONFIG_OPTION_SFNT_NAMES */ +#else /* !TT_CONFIG_OPTION_SFNT_NAMES */ + + + FT_EXPORT_DEF( FT_UInt ) + FT_Get_Sfnt_Name_Count( FT_Face face ) + { + FT_UNUSED( face ); + + return 0; + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Sfnt_Name( FT_Face face, + FT_UInt idx, + FT_SfntName *aname ) + { + FT_UNUSED( face ); + FT_UNUSED( idx ); + FT_UNUSED( aname ); + + return FT_THROW( Unimplemented_Feature ); + } + + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Sfnt_LangTag( FT_Face face, + FT_UInt langID, + FT_SfntLangTag *alangTag ) + { + FT_UNUSED( face ); + FT_UNUSED( langID ); + FT_UNUSED( alangTag ); + + return FT_THROW( Unimplemented_Feature ); + } + + +#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */ /* END */ diff --git a/src/3rdparty/freetype/src/base/ftstream.c b/src/3rdparty/freetype/src/base/ftstream.c index 18df7dcfef..4b0890d7fd 100644 --- a/src/3rdparty/freetype/src/base/ftstream.c +++ b/src/3rdparty/freetype/src/base/ftstream.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstream.c */ -/* */ -/* I/O stream support (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstream.c + * + * I/O stream support (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,14 +21,14 @@ #include FT_INTERNAL_DEBUG_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_stream +#define FT_COMPONENT stream FT_BASE_DEF( void ) @@ -219,13 +219,14 @@ { FT_Memory memory = stream->memory; + #ifdef FT_DEBUG_MEMORY ft_mem_free( memory, *pbytes ); - *pbytes = NULL; #else FT_FREE( *pbytes ); #endif } + *pbytes = NULL; } @@ -238,6 +239,8 @@ FT_ULong read_bytes; + FT_TRACE7(( "FT_Stream_EnterFrame: %ld bytes\n", count )); + /* check for nested frame access */ FT_ASSERT( stream && stream->cursor == 0 ); @@ -281,6 +284,7 @@ FT_FREE( stream->base ); error = FT_THROW( Invalid_Stream_Operation ); } + stream->cursor = stream->base; stream->limit = stream->cursor + count; stream->pos += read_bytes; @@ -321,13 +325,16 @@ /* In this case, the loader code handles the 0-length table */ /* gracefully; however, stream.cursor is really set to 0 by the */ /* FT_Stream_EnterFrame() call, and this is not an error. */ - /* */ + + FT_TRACE7(( "FT_Stream_ExitFrame\n" )); + FT_ASSERT( stream ); if ( stream->read ) { FT_Memory memory = stream->memory; + #ifdef FT_DEBUG_MEMORY ft_mem_free( memory, stream->base ); stream->base = NULL; @@ -335,6 +342,7 @@ FT_FREE( stream->base ); #endif } + stream->cursor = NULL; stream->limit = NULL; } diff --git a/src/3rdparty/freetype/src/base/ftstroke.c b/src/3rdparty/freetype/src/base/ftstroke.c index 6ae1819067..1b2c0f657c 100644 --- a/src/3rdparty/freetype/src/base/ftstroke.c +++ b/src/3rdparty/freetype/src/base/ftstroke.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftstroke.c */ -/* */ -/* FreeType path stroker (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftstroke.c + * + * FreeType path stroker (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,15 +24,10 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_OBJECTS_H -#include "basepic.h" - - /* declare an extern to access `ft_outline_glyph_class' globally */ - /* allocated in `ftglyph.c', and use the FT_OUTLINE_GLYPH_CLASS_GET */ - /* macro to access it when FT_CONFIG_OPTION_PIC is defined */ -#ifndef FT_CONFIG_OPTION_PIC + /* declare an extern to access `ft_outline_glyph_class' globally */ + /* allocated in `ftglyph.c' */ FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class; -#endif /* documentation is in ftstroke.h */ @@ -91,16 +86,18 @@ base[4].x = base[2].x; - b = base[1].x; - a = base[3].x = ( base[2].x + b ) / 2; - b = base[1].x = ( base[0].x + b ) / 2; - base[2].x = ( a + b ) / 2; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + base[3].x = b >> 1; + base[2].x = ( a + b ) >> 2; + base[1].x = a >> 1; base[4].y = base[2].y; - b = base[1].y; - a = base[3].y = ( base[2].y + b ) / 2; - b = base[1].y = ( base[0].y + b ) / 2; - base[2].y = ( a + b ) / 2; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + base[3].y = b >> 1; + base[2].y = ( a + b ) >> 2; + base[1].y = a >> 1; } @@ -158,28 +155,32 @@ static void ft_cubic_split( FT_Vector* base ) { - FT_Pos a, b, c, d; + FT_Pos a, b, c; base[6].x = base[3].x; - c = base[1].x; - d = base[2].x; - base[1].x = a = ( base[0].x + c ) / 2; - base[5].x = b = ( base[3].x + d ) / 2; - c = ( c + d ) / 2; - base[2].x = a = ( a + c ) / 2; - base[4].x = b = ( b + c ) / 2; - base[3].x = ( a + b ) / 2; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + c = base[2].x + base[3].x; + base[5].x = c >> 1; + c += b; + base[4].x = c >> 2; + base[1].x = a >> 1; + a += b; + base[2].x = a >> 2; + base[3].x = ( a + c ) >> 3; base[6].y = base[3].y; - c = base[1].y; - d = base[2].y; - base[1].y = a = ( base[0].y + c ) / 2; - base[5].y = b = ( base[3].y + d ) / 2; - c = ( c + d ) / 2; - base[2].y = a = ( a + c ) / 2; - base[4].y = b = ( b + c ) / 2; - base[3].y = ( a + b ) / 2; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + c = base[2].y + base[3].y; + base[5].y = c >> 1; + c += b; + base[4].y = c >> 2; + base[1].y = a >> 1; + a += b; + base[2].y = a >> 2; + base[3].y = ( a + c ) >> 3; } @@ -372,6 +373,7 @@ /* it contains the `adjusted' starting coordinates */ border->num_points = --count; border->points[start] = border->points[count]; + border->tags[start] = border->tags[count]; if ( reverse ) { @@ -436,8 +438,8 @@ } else { - /* don't add zero-length lineto */ - if ( border->num_points > 0 && + /* don't add zero-length lineto, but always add moveto */ + if ( border->num_points > (FT_UInt)border->start && FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) && FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) ) return error; @@ -2087,8 +2089,8 @@ /* documentation is in ftstroke.h */ /* - * The following is very similar to FT_Outline_Decompose, except - * that we do support opened paths, and do not scale the outline. + * The following is very similar to FT_Outline_Decompose, except + * that we do support opened paths, and do not scale the outline. */ FT_EXPORT_DEF( FT_Error ) FT_Stroker_ParseOutline( FT_Stroker stroker, @@ -2306,17 +2308,12 @@ FT_Error error = FT_ERR( Invalid_Argument ); FT_Glyph glyph = NULL; - /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */ - FT_Library library = stroker->library; - - FT_UNUSED( library ); - if ( !pglyph ) goto Exit; glyph = *pglyph; - if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) + if ( !glyph || glyph->clazz != &ft_outline_glyph_class ) goto Exit; { @@ -2386,17 +2383,12 @@ FT_Error error = FT_ERR( Invalid_Argument ); FT_Glyph glyph = NULL; - /* for FT_OUTLINE_GLYPH_CLASS_GET (in PIC mode) */ - FT_Library library = stroker->library; - - FT_UNUSED( library ); - if ( !pglyph ) goto Exit; glyph = *pglyph; - if ( !glyph || glyph->clazz != FT_OUTLINE_GLYPH_CLASS_GET ) + if ( !glyph || glyph->clazz != &ft_outline_glyph_class ) goto Exit; { diff --git a/src/3rdparty/freetype/src/base/ftsynth.c b/src/3rdparty/freetype/src/base/ftsynth.c index c28346707b..f87ed65e75 100644 --- a/src/3rdparty/freetype/src/base/ftsynth.c +++ b/src/3rdparty/freetype/src/base/ftsynth.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsynth.c */ -/* */ -/* FreeType synthesizing code for emboldening and slanting (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsynth.c + * + * FreeType synthesizing code for emboldening and slanting (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,14 +24,14 @@ #include FT_BITMAP_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_synth +#define FT_COMPONENT synth /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/base/ftsystem.c b/src/3rdparty/freetype/src/base/ftsystem.c index 6adebdb938..f92b3a03d5 100644 --- a/src/3rdparty/freetype/src/base/ftsystem.c +++ b/src/3rdparty/freetype/src/base/ftsystem.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftsystem.c */ -/* */ -/* ANSI-specific FreeType low-level system interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file contains the default interface used by FreeType to access */ - /* low-level, i.e. memory management, i/o access as well as thread */ - /* synchronisation. It can be replaced by user-specific routines if */ - /* necessary. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftsystem.c + * + * ANSI-specific FreeType low-level system interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file contains the default interface used by FreeType to access + * low-level, i.e. memory management, i/o access as well as thread + * synchronisation. It can be replaced by user-specific routines if + * necessary. + * + */ #include <ft2build.h> @@ -34,37 +34,39 @@ #include FT_TYPES_H - /*************************************************************************/ - /* */ - /* MEMORY MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* It is not necessary to do any error checking for the */ - /* allocation-related functions. This will be done by the higher level */ - /* routines like ft_mem_alloc() or ft_mem_realloc(). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_alloc */ - /* */ - /* <Description> */ - /* The memory allocation function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* size :: The requested size in bytes. */ - /* */ - /* <Return> */ - /* The address of newly allocated block. */ - /* */ + /************************************************************************** + * + * MEMORY MANAGEMENT INTERFACE + * + */ + + /************************************************************************** + * + * It is not necessary to do any error checking for the + * allocation-related functions. This will be done by the higher level + * routines like ft_mem_alloc() or ft_mem_realloc(). + * + */ + + + /************************************************************************** + * + * @Function: + * ft_alloc + * + * @Description: + * The memory allocation function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * size :: + * The requested size in bytes. + * + * @Return: + * The address of newly allocated block. + */ FT_CALLBACK_DEF( void* ) ft_alloc( FT_Memory memory, long size ) @@ -75,26 +77,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_realloc */ - /* */ - /* <Description> */ - /* The memory reallocation function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* cur_size :: The current size of the allocated memory block. */ - /* */ - /* new_size :: The newly requested size in bytes. */ - /* */ - /* block :: The current address of the block in memory. */ - /* */ - /* <Return> */ - /* The address of the reallocated memory block. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_realloc + * + * @Description: + * The memory reallocation function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * cur_size :: + * The current size of the allocated memory block. + * + * new_size :: + * The newly requested size in bytes. + * + * block :: + * The current address of the block in memory. + * + * @Return: + * The address of the reallocated memory block. + */ FT_CALLBACK_DEF( void* ) ft_realloc( FT_Memory memory, long cur_size, @@ -108,19 +114,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_free */ - /* */ - /* <Description> */ - /* The memory release function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* block :: The address of block in memory to be freed. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_free + * + * @Description: + * The memory release function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * block :: + * The address of block in memory to be freed. + */ FT_CALLBACK_DEF( void ) ft_free( FT_Memory memory, void* block ) @@ -131,39 +139,40 @@ } - /*************************************************************************/ - /* */ - /* RESOURCE MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * RESOURCE MANAGEMENT INTERFACE + * + */ #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_io +#define FT_COMPONENT io /* We use the macro STREAM_FILE for convenience to extract the */ /* system-specific stream handle from a given FreeType stream object */ #define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_ansi_stream_close */ - /* */ - /* <Description> */ - /* The function to close a stream. */ - /* */ - /* <Input> */ - /* stream :: A pointer to the stream object. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_ansi_stream_close + * + * @Description: + * The function to close a stream. + * + * @Input: + * stream :: + * A pointer to the stream object. + */ FT_CALLBACK_DEF( void ) ft_ansi_stream_close( FT_Stream stream ) { @@ -175,28 +184,32 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_ansi_stream_io */ - /* */ - /* <Description> */ - /* The function to open a stream. */ - /* */ - /* <Input> */ - /* stream :: A pointer to the stream object. */ - /* */ - /* offset :: The position in the data stream to start reading. */ - /* */ - /* buffer :: The address of buffer to store the read data. */ - /* */ - /* count :: The number of bytes to read from the stream. */ - /* */ - /* <Return> */ - /* The number of bytes actually read. If `count' is zero (this is, */ - /* the function is used for seeking), a non-zero return value */ - /* indicates an error. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_ansi_stream_io + * + * @Description: + * The function to open a stream. + * + * @Input: + * stream :: + * A pointer to the stream object. + * + * offset :: + * The position in the data stream to start reading. + * + * buffer :: + * The address of buffer to store the read data. + * + * count :: + * The number of bytes to read from the stream. + * + * @Return: + * The number of bytes actually read. If `count' is zero (this is, + * the function is used for seeking), a non-zero return value + * indicates an error. + */ FT_CALLBACK_DEF( unsigned long ) ft_ansi_stream_io( FT_Stream stream, unsigned long offset, diff --git a/src/3rdparty/freetype/src/base/fttrigon.c b/src/3rdparty/freetype/src/base/fttrigon.c index d6dd098c42..38721977c7 100644 --- a/src/3rdparty/freetype/src/base/fttrigon.c +++ b/src/3rdparty/freetype/src/base/fttrigon.c @@ -1,33 +1,33 @@ -/***************************************************************************/ -/* */ -/* fttrigon.c */ -/* */ -/* FreeType trigonometric functions (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This is a fixed-point CORDIC implementation of trigonometric */ - /* functions as well as transformations between Cartesian and polar */ - /* coordinates. The angles are represented as 16.16 fixed-point values */ - /* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */ - /* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */ - /* discrete Cartesian grid can have the same or better angular */ - /* resolution. Therefore, to maintain this precision, some functions */ - /* require an interim upscaling of the vectors, whereas others operate */ - /* with 24-bit long vectors directly. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * fttrigon.c + * + * FreeType trigonometric functions (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This is a fixed-point CORDIC implementation of trigonometric + * functions as well as transformations between Cartesian and polar + * coordinates. The angles are represented as 16.16 fixed-point values + * in degrees, i.e., the angular resolution is 2^-16 degrees. Note that + * only vectors longer than 2^16*180/pi (or at least 22 bits) on a + * discrete Cartesian grid can have the same or better angular + * resolution. Therefore, to maintain this precision, some functions + * require an interim upscaling of the vectors, whereas others operate + * with 24-bit long vectors directly. + * + */ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H @@ -325,10 +325,10 @@ FT_EXPORT_DEF( FT_Fixed ) FT_Tan( FT_Angle angle ) { - FT_Vector v; + FT_Vector v = { 1 << 24, 0 }; - FT_Vector_Unit( &v, angle ); + ft_trig_pseudo_rotate( &v, angle ); return FT_DivFix( v.y, v.x ); } @@ -372,14 +372,6 @@ } - /* these macros return 0 for positive numbers, - and -1 for negative ones */ -#define FT_SIGN_LONG( x ) ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) ) -#define FT_SIGN_INT( x ) ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) ) -#define FT_SIGN_INT32( x ) ( (x) >> 31 ) -#define FT_SIGN_INT16( x ) ( (x) >> 15 ) - - /* documentation is in fttrigon.h */ FT_EXPORT_DEF( void ) @@ -408,8 +400,8 @@ FT_Int32 half = (FT_Int32)1L << ( shift - 1 ); - vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; - vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift; + vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift; + vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift; } else { diff --git a/src/3rdparty/freetype/src/base/fttype1.c b/src/3rdparty/freetype/src/base/fttype1.c index aa8f8ccbbb..26d4f1c3a8 100644 --- a/src/3rdparty/freetype/src/base/fttype1.c +++ b/src/3rdparty/freetype/src/base/fttype1.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* fttype1.c */ -/* */ -/* FreeType utility file for PS names support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * fttype1.c + * + * FreeType utility file for PS names support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/ftutil.c b/src/3rdparty/freetype/src/base/ftutil.c index 4de5f2c145..92bd857e92 100644 --- a/src/3rdparty/freetype/src/base/ftutil.c +++ b/src/3rdparty/freetype/src/base/ftutil.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftutil.c */ -/* */ -/* FreeType utility file for memory and list management (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftutil.c + * + * FreeType utility file for memory and list management (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -23,14 +23,14 @@ #include FT_LIST_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_memory +#define FT_COMPONENT memory /*************************************************************************/ @@ -54,7 +54,7 @@ FT_Error error; FT_Pointer block = ft_mem_qalloc( memory, size, &error ); - if ( !error && size > 0 ) + if ( !error && block && size > 0 ) FT_MEM_ZERO( block, size ); *p_error = error; @@ -101,7 +101,7 @@ block = ft_mem_qrealloc( memory, item_size, cur_count, new_count, block, &error ); - if ( !error && new_count > cur_count ) + if ( !error && block && new_count > cur_count ) FT_MEM_ZERO( (char*)block + cur_count * item_size, ( new_count - cur_count ) * item_size ); @@ -185,7 +185,7 @@ FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error ); - if ( !error && address ) + if ( !error && address && size > 0 ) ft_memcpy( p, address, size ); *p_error = error; @@ -236,7 +236,7 @@ /*************************************************************************/ #undef FT_COMPONENT -#define FT_COMPONENT trace_list +#define FT_COMPONENT list /* documentation is in ftlist.h */ diff --git a/src/3rdparty/freetype/src/base/ftver.rc b/src/3rdparty/freetype/src/base/ftver.rc index a2903d5883..1354497423 100644 --- a/src/3rdparty/freetype/src/base/ftver.rc +++ b/src/3rdparty/freetype/src/base/ftver.rc @@ -4,7 +4,7 @@ /* */ /* FreeType VERSIONINFO resource for Windows DLLs. */ /* */ -/* Copyright 2018 by */ +/* Copyright (C) 2018-2019 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,8 +18,8 @@ #include<windows.h> -#define FT_VERSION 2,9,1,0 -#define FT_VERSION_STR "2.9.1" +#define FT_VERSION 2,10,1,0 +#define FT_VERSION_STR "2.10.1" VS_VERSION_INFO VERSIONINFO FILEVERSION FT_VERSION @@ -28,7 +28,7 @@ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG #endif -#ifdef _DLL +#ifdef DLL_EXPORT FILETYPE VFT_DLL #define FT_FILENAME "freetype.dll" #else @@ -45,7 +45,7 @@ BEGIN VALUE "FileVersion", FT_VERSION_STR VALUE "ProductName", "FreeType" VALUE "ProductVersion", FT_VERSION_STR - VALUE "LegalCopyright", "\251 2018 The FreeType Project www.freetype.org. All rights reserved." + VALUE "LegalCopyright", "\251 2018-2019 The FreeType Project www.freetype.org. All rights reserved." VALUE "InternalName", "freetype" VALUE "OriginalFilename", FT_FILENAME END diff --git a/src/3rdparty/freetype/src/base/ftwinfnt.c b/src/3rdparty/freetype/src/base/ftwinfnt.c index 11bd28afb7..59daa77031 100644 --- a/src/3rdparty/freetype/src/base/ftwinfnt.c +++ b/src/3rdparty/freetype/src/base/ftwinfnt.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftwinfnt.c */ -/* */ -/* FreeType API for accessing Windows FNT specific info (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftwinfnt.c + * + * FreeType API for accessing Windows FNT specific info (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/base/rules.mk b/src/3rdparty/freetype/src/base/rules.mk index e9805bd068..4b24c6dce7 100644 --- a/src/3rdparty/freetype/src/base/rules.mk +++ b/src/3rdparty/freetype/src/base/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -36,17 +36,17 @@ BASE_COMPILE := $(CC) $(ANSIFLAGS) \ # All files listed here should be included in `ftbase.c' (for a `single' # build). # -BASE_SRC := $(BASE_DIR)/basepic.c \ - $(BASE_DIR)/ftadvanc.c \ +BASE_SRC := $(BASE_DIR)/ftadvanc.c \ $(BASE_DIR)/ftcalc.c \ + $(BASE_DIR)/ftcolor.c \ $(BASE_DIR)/ftdbgmem.c \ + $(BASE_DIR)/fterrors.c \ $(BASE_DIR)/ftfntfmt.c \ $(BASE_DIR)/ftgloadr.c \ $(BASE_DIR)/fthash.c \ $(BASE_DIR)/ftlcdfil.c \ $(BASE_DIR)/ftobjs.c \ $(BASE_DIR)/ftoutln.c \ - $(BASE_DIR)/ftpic.c \ $(BASE_DIR)/ftpsprop.c \ $(BASE_DIR)/ftrfork.c \ $(BASE_DIR)/ftsnames.c \ @@ -60,8 +60,7 @@ ifneq ($(ftmac_c),) endif # for simplicity, we also handle `md5.c' (which gets included by `ftobjs.h') -BASE_H := $(BASE_DIR)/basepic.h \ - $(BASE_DIR)/ftbase.h \ +BASE_H := $(BASE_DIR)/ftbase.h \ $(BASE_DIR)/md5.c \ $(BASE_DIR)/md5.h diff --git a/src/3rdparty/freetype/src/bdf/Jamfile b/src/3rdparty/freetype/src/bdf/Jamfile index d9e441c188..a49c7f5d33 100644 --- a/src/3rdparty/freetype/src/bdf/Jamfile +++ b/src/3rdparty/freetype/src/bdf/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/bdf Jamfile # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/bdf/bdf.h b/src/3rdparty/freetype/src/bdf/bdf.h index 9012727c7e..d9abd2378f 100644 --- a/src/3rdparty/freetype/src/bdf/bdf.h +++ b/src/3rdparty/freetype/src/bdf/bdf.h @@ -51,11 +51,11 @@ FT_BEGIN_HEADER /* end of bdfP.h */ - /*************************************************************************/ - /* */ - /* BDF font options macros and types. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * BDF font options macros and types. + * + */ #define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */ @@ -93,11 +93,11 @@ FT_BEGIN_HEADER void* client_data ); - /*************************************************************************/ - /* */ - /* BDF font property macros and types. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * BDF font property macros and types. + * + */ #define BDF_ATOM 1 @@ -109,9 +109,9 @@ FT_BEGIN_HEADER /* There are a set of defaults and each font has their own. */ typedef struct bdf_property_t_ { - char* name; /* Name of the property. */ - int format; /* Format of the property. */ - int builtin; /* A builtin property. */ + const char* name; /* Name of the property. */ + int format; /* Format of the property. */ + int builtin; /* A builtin property. */ union { char* atom; @@ -123,11 +123,11 @@ FT_BEGIN_HEADER } bdf_property_t; - /*************************************************************************/ - /* */ - /* BDF font metric and glyph types. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * BDF font metric and glyph types. + * + */ typedef struct bdf_bbx_t_ @@ -147,7 +147,7 @@ FT_BEGIN_HEADER typedef struct bdf_glyph_t_ { char* name; /* Glyph name. */ - long encoding; /* Glyph encoding. */ + unsigned long encoding; /* Glyph encoding. */ unsigned short swidth; /* Scalable width. */ unsigned short dwidth; /* Device width. */ bdf_bbx_t bbx; /* Glyph bounding box. */ @@ -158,20 +158,6 @@ FT_BEGIN_HEADER } bdf_glyph_t; - typedef struct bdf_glyphlist_t_ - { - unsigned short pad; /* Pad to 4-byte boundary. */ - unsigned short bpp; /* Bits per pixel. */ - long start; /* Beginning encoding value of glyphs. */ - long end; /* Ending encoding value of glyphs. */ - bdf_glyph_t* glyphs; /* Glyphs themselves. */ - unsigned long glyphs_size; /* Glyph structures allocated. */ - unsigned long glyphs_used; /* Glyph structures used. */ - bdf_bbx_t bbx; /* Overall bounding box of glyphs. */ - - } bdf_glyphlist_t; - - typedef struct bdf_font_t_ { char* name; /* Name of the font. */ @@ -185,7 +171,7 @@ FT_BEGIN_HEADER unsigned short monowidth; /* Logical width for monowidth font. */ - long default_char; /* Encoding of the default glyph. */ + unsigned long default_char; /* Encoding of the default glyph. */ long font_ascent; /* Font ascent. */ long font_descent; /* Font descent. */ @@ -205,16 +191,8 @@ FT_BEGIN_HEADER char* comments; /* Font comments. */ unsigned long comments_len; /* Length of comment string. */ - bdf_glyphlist_t overflow; /* Storage used for glyph insertion. */ - void* internal; /* Internal data for the font. */ - /* The size of the next two arrays must be in sync with the */ - /* size of the `have' array in the `bdf_parse_t' structure. */ - unsigned long nmod[34816]; /* Bitmap indicating modified glyphs. */ - unsigned long umod[34816]; /* Bitmap indicating modified */ - /* unencoded glyphs. */ - unsigned short modified; /* Boolean indicating font modified. */ unsigned short bpp; /* Bits per pixel. */ FT_Memory memory; @@ -226,11 +204,11 @@ FT_BEGIN_HEADER } bdf_font_t; - /*************************************************************************/ - /* */ - /* Types for load/save callbacks. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Types for load/save callbacks. + * + */ /* Error codes. */ @@ -247,11 +225,11 @@ FT_BEGIN_HEADER #define BDF_INVALID_LINE -100 - /*************************************************************************/ - /* */ - /* BDF font API. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * BDF font API. + * + */ FT_LOCAL( FT_Error ) bdf_load_font( FT_Stream stream, diff --git a/src/3rdparty/freetype/src/bdf/bdfdrivr.c b/src/3rdparty/freetype/src/bdf/bdfdrivr.c index ca937f89ce..60eb93305e 100644 --- a/src/3rdparty/freetype/src/bdf/bdfdrivr.c +++ b/src/3rdparty/freetype/src/bdf/bdfdrivr.c @@ -41,14 +41,14 @@ THE SOFTWARE. #include "bdferror.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_bdfdriver +#define FT_COMPONENT bdfdriver typedef struct BDF_CMapRec_ @@ -99,14 +99,17 @@ THE SOFTWARE. min = 0; max = cmap->num_encodings; + mid = ( min + max ) >> 1; while ( min < max ) { FT_ULong code; - mid = ( min + max ) >> 1; - code = (FT_ULong)encodings[mid].enc; + if ( mid >= max || mid < min ) + mid = ( min + max ) >> 1; + + code = encodings[mid].enc; if ( charcode == code ) { @@ -120,6 +123,9 @@ THE SOFTWARE. max = mid; else min = mid + 1; + + /* prediction in a continuous block */ + mid += charcode - code; } return result; @@ -139,14 +145,17 @@ THE SOFTWARE. min = 0; max = cmap->num_encodings; + mid = ( min + max ) >> 1; while ( min < max ) { FT_ULong code; /* same as BDF_encoding_el.enc */ - mid = ( min + max ) >> 1; - code = (FT_ULong)encodings[mid].enc; + if ( mid >= max || mid < min ) + mid = ( min + max ) >> 1; + + code = encodings[mid].enc; if ( charcode == code ) { @@ -160,12 +169,15 @@ THE SOFTWARE. max = mid; else min = mid + 1; + + /* prediction in a continuous block */ + mid += charcode - code; } charcode = 0; if ( min < cmap->num_encodings ) { - charcode = (FT_ULong)encodings[min].enc; + charcode = encodings[min].enc; result = encodings[min].glyph + 1; } @@ -204,13 +216,13 @@ THE SOFTWARE. bdf_font_t* font = bdf->bdffont; bdf_property_t* prop; - char* strings[4] = { NULL, NULL, NULL, NULL }; - size_t nn, len, lengths[4]; + const char* strings[4] = { NULL, NULL, NULL, NULL }; + size_t lengths[4], nn, len; face->style_flags = 0; - prop = bdf_get_font_property( font, (char *)"SLANT" ); + prop = bdf_get_font_property( font, "SLANT" ); if ( prop && prop->format == BDF_ATOM && prop->value.atom && ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' || @@ -218,30 +230,30 @@ THE SOFTWARE. { face->style_flags |= FT_STYLE_FLAG_ITALIC; strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ) - ? (char *)"Oblique" - : (char *)"Italic"; + ? "Oblique" + : "Italic"; } - prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" ); + prop = bdf_get_font_property( font, "WEIGHT_NAME" ); if ( prop && prop->format == BDF_ATOM && prop->value.atom && ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) ) { face->style_flags |= FT_STYLE_FLAG_BOLD; - strings[1] = (char *)"Bold"; + strings[1] = "Bold"; } - prop = bdf_get_font_property( font, (char *)"SETWIDTH_NAME" ); + prop = bdf_get_font_property( font, "SETWIDTH_NAME" ); if ( prop && prop->format == BDF_ATOM && prop->value.atom && *(prop->value.atom) && !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) - strings[3] = (char *)(prop->value.atom); + strings[3] = (const char *)(prop->value.atom); - prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" ); + prop = bdf_get_font_property( font, "ADD_STYLE_NAME" ); if ( prop && prop->format == BDF_ATOM && prop->value.atom && *(prop->value.atom) && !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) - strings[0] = (char *)(prop->value.atom); + strings[0] = (const char *)(prop->value.atom); for ( len = 0, nn = 0; nn < 4; nn++ ) { @@ -255,7 +267,7 @@ THE SOFTWARE. if ( len == 0 ) { - strings[0] = (char *)"Regular"; + strings[0] = "Regular"; lengths[0] = ft_strlen( strings[0] ); len = lengths[0] + 1; } @@ -271,7 +283,7 @@ THE SOFTWARE. for ( nn = 0; nn < 4; nn++ ) { - char* src = strings[nn]; + const char* src = strings[nn]; len = lengths[nn]; @@ -401,8 +413,7 @@ THE SOFTWARE. bdfface->face_index = 0; bdfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES | - FT_FACE_FLAG_HORIZONTAL | - FT_FACE_FLAG_FAST_GLYPHS; + FT_FACE_FLAG_HORIZONTAL; prop = bdf_get_font_property( font, "SPACING" ); if ( prop && prop->format == BDF_ATOM && @@ -863,7 +874,7 @@ THE SOFTWARE. /* * - * BDF SERVICE + * BDF SERVICE * */ @@ -939,7 +950,7 @@ THE SOFTWARE. /* * - * SERVICES LIST + * SERVICES LIST * */ diff --git a/src/3rdparty/freetype/src/bdf/bdfdrivr.h b/src/3rdparty/freetype/src/bdf/bdfdrivr.h index 94550818c1..b37b84ea31 100644 --- a/src/3rdparty/freetype/src/bdf/bdfdrivr.h +++ b/src/3rdparty/freetype/src/bdf/bdfdrivr.h @@ -36,14 +36,10 @@ THE SOFTWARE. FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - typedef struct BDF_encoding_el_ { - FT_Long enc; + FT_ULong enc; FT_UShort glyph; } BDF_encoding_el; @@ -60,9 +56,6 @@ FT_BEGIN_HEADER BDF_encoding_el* en_table; - FT_CharMap charmap_handle; - FT_CharMapRec charmap; /* a single charmap per face */ - FT_UInt default_glyph; } BDF_FaceRec, *BDF_Face; diff --git a/src/3rdparty/freetype/src/bdf/bdferror.h b/src/3rdparty/freetype/src/bdf/bdferror.h index b462c7d3b5..dbe41c02ab 100644 --- a/src/3rdparty/freetype/src/bdf/bdferror.h +++ b/src/3rdparty/freetype/src/bdf/bdferror.h @@ -20,11 +20,11 @@ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /*************************************************************************/ - /* */ - /* This file is used to define the BDF error enumeration constants. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is used to define the BDF error enumeration constants. + * + */ #ifndef BDFERROR_H_ #define BDFERROR_H_ diff --git a/src/3rdparty/freetype/src/bdf/bdflib.c b/src/3rdparty/freetype/src/bdf/bdflib.c index 2f5c99d544..63813f7edc 100644 --- a/src/3rdparty/freetype/src/bdf/bdflib.c +++ b/src/3rdparty/freetype/src/bdf/bdflib.c @@ -22,13 +22,13 @@ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /*************************************************************************/ - /* */ - /* This file is based on bdf.c,v 1.22 2000/03/16 20:08:50 */ - /* */ - /* taken from Mark Leisher's xmbdfed package */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * This file is based on bdf.c,v 1.22 2000/03/16 20:08:50 + * + * taken from Mark Leisher's xmbdfed package + * + */ #include <ft2build.h> @@ -42,21 +42,21 @@ #include "bdferror.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_bdflib +#define FT_COMPONENT bdflib - /*************************************************************************/ - /* */ - /* Default BDF font options. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Default BDF font options. + * + */ static const bdf_options_t _bdf_opts = @@ -68,100 +68,100 @@ }; - /*************************************************************************/ - /* */ - /* Builtin BDF font properties. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Builtin BDF font properties. + * + */ /* List of most properties that might appear in a font. Doesn't include */ /* the RAW_* and AXIS_* properties in X11R6 polymorphic fonts. */ static const bdf_property_t _bdf_properties[] = { - { (char *)"ADD_STYLE_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"AVERAGE_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"AVG_CAPITAL_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"AVG_LOWERCASE_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"CAP_HEIGHT", BDF_INTEGER, 1, { 0 } }, - { (char *)"CHARSET_COLLECTIONS", BDF_ATOM, 1, { 0 } }, - { (char *)"CHARSET_ENCODING", BDF_ATOM, 1, { 0 } }, - { (char *)"CHARSET_REGISTRY", BDF_ATOM, 1, { 0 } }, - { (char *)"COMMENT", BDF_ATOM, 1, { 0 } }, - { (char *)"COPYRIGHT", BDF_ATOM, 1, { 0 } }, - { (char *)"DEFAULT_CHAR", BDF_CARDINAL, 1, { 0 } }, - { (char *)"DESTINATION", BDF_CARDINAL, 1, { 0 } }, - { (char *)"DEVICE_FONT_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"END_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"FACE_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"FAMILY_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"FIGURE_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"FONT", BDF_ATOM, 1, { 0 } }, - { (char *)"FONTNAME_REGISTRY", BDF_ATOM, 1, { 0 } }, - { (char *)"FONT_ASCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"FONT_DESCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"FOUNDRY", BDF_ATOM, 1, { 0 } }, - { (char *)"FULL_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"ITALIC_ANGLE", BDF_INTEGER, 1, { 0 } }, - { (char *)"MAX_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"MIN_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"NORM_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"NOTICE", BDF_ATOM, 1, { 0 } }, - { (char *)"PIXEL_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"POINT_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"QUAD_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_ASCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_AVERAGE_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_AVG_CAPITAL_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_AVG_LOWERCASE_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_CAP_HEIGHT", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_DESCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_END_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_FIGURE_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_MAX_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_MIN_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_NORM_SPACE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_PIXEL_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_POINT_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_PIXELSIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_POINTSIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_QUAD_WIDTH", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SMALL_CAP_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_STRIKEOUT_ASCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_STRIKEOUT_DESCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SUBSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SUBSCRIPT_X", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SUBSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SUPERSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SUPERSCRIPT_X", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_SUPERSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_UNDERLINE_POSITION", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_UNDERLINE_THICKNESS", BDF_INTEGER, 1, { 0 } }, - { (char *)"RAW_X_HEIGHT", BDF_INTEGER, 1, { 0 } }, - { (char *)"RELATIVE_SETWIDTH", BDF_CARDINAL, 1, { 0 } }, - { (char *)"RELATIVE_WEIGHT", BDF_CARDINAL, 1, { 0 } }, - { (char *)"RESOLUTION", BDF_INTEGER, 1, { 0 } }, - { (char *)"RESOLUTION_X", BDF_CARDINAL, 1, { 0 } }, - { (char *)"RESOLUTION_Y", BDF_CARDINAL, 1, { 0 } }, - { (char *)"SETWIDTH_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"SLANT", BDF_ATOM, 1, { 0 } }, - { (char *)"SMALL_CAP_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"SPACING", BDF_ATOM, 1, { 0 } }, - { (char *)"STRIKEOUT_ASCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"STRIKEOUT_DESCENT", BDF_INTEGER, 1, { 0 } }, - { (char *)"SUBSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"SUBSCRIPT_X", BDF_INTEGER, 1, { 0 } }, - { (char *)"SUBSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, - { (char *)"SUPERSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, - { (char *)"SUPERSCRIPT_X", BDF_INTEGER, 1, { 0 } }, - { (char *)"SUPERSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, - { (char *)"UNDERLINE_POSITION", BDF_INTEGER, 1, { 0 } }, - { (char *)"UNDERLINE_THICKNESS", BDF_INTEGER, 1, { 0 } }, - { (char *)"WEIGHT", BDF_CARDINAL, 1, { 0 } }, - { (char *)"WEIGHT_NAME", BDF_ATOM, 1, { 0 } }, - { (char *)"X_HEIGHT", BDF_INTEGER, 1, { 0 } }, - { (char *)"_MULE_BASELINE_OFFSET", BDF_INTEGER, 1, { 0 } }, - { (char *)"_MULE_RELATIVE_COMPOSE", BDF_INTEGER, 1, { 0 } }, + { "ADD_STYLE_NAME", BDF_ATOM, 1, { 0 } }, + { "AVERAGE_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "AVG_CAPITAL_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "AVG_LOWERCASE_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "CAP_HEIGHT", BDF_INTEGER, 1, { 0 } }, + { "CHARSET_COLLECTIONS", BDF_ATOM, 1, { 0 } }, + { "CHARSET_ENCODING", BDF_ATOM, 1, { 0 } }, + { "CHARSET_REGISTRY", BDF_ATOM, 1, { 0 } }, + { "COMMENT", BDF_ATOM, 1, { 0 } }, + { "COPYRIGHT", BDF_ATOM, 1, { 0 } }, + { "DEFAULT_CHAR", BDF_CARDINAL, 1, { 0 } }, + { "DESTINATION", BDF_CARDINAL, 1, { 0 } }, + { "DEVICE_FONT_NAME", BDF_ATOM, 1, { 0 } }, + { "END_SPACE", BDF_INTEGER, 1, { 0 } }, + { "FACE_NAME", BDF_ATOM, 1, { 0 } }, + { "FAMILY_NAME", BDF_ATOM, 1, { 0 } }, + { "FIGURE_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "FONT", BDF_ATOM, 1, { 0 } }, + { "FONTNAME_REGISTRY", BDF_ATOM, 1, { 0 } }, + { "FONT_ASCENT", BDF_INTEGER, 1, { 0 } }, + { "FONT_DESCENT", BDF_INTEGER, 1, { 0 } }, + { "FOUNDRY", BDF_ATOM, 1, { 0 } }, + { "FULL_NAME", BDF_ATOM, 1, { 0 } }, + { "ITALIC_ANGLE", BDF_INTEGER, 1, { 0 } }, + { "MAX_SPACE", BDF_INTEGER, 1, { 0 } }, + { "MIN_SPACE", BDF_INTEGER, 1, { 0 } }, + { "NORM_SPACE", BDF_INTEGER, 1, { 0 } }, + { "NOTICE", BDF_ATOM, 1, { 0 } }, + { "PIXEL_SIZE", BDF_INTEGER, 1, { 0 } }, + { "POINT_SIZE", BDF_INTEGER, 1, { 0 } }, + { "QUAD_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "RAW_ASCENT", BDF_INTEGER, 1, { 0 } }, + { "RAW_AVERAGE_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "RAW_AVG_CAPITAL_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "RAW_AVG_LOWERCASE_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "RAW_CAP_HEIGHT", BDF_INTEGER, 1, { 0 } }, + { "RAW_DESCENT", BDF_INTEGER, 1, { 0 } }, + { "RAW_END_SPACE", BDF_INTEGER, 1, { 0 } }, + { "RAW_FIGURE_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "RAW_MAX_SPACE", BDF_INTEGER, 1, { 0 } }, + { "RAW_MIN_SPACE", BDF_INTEGER, 1, { 0 } }, + { "RAW_NORM_SPACE", BDF_INTEGER, 1, { 0 } }, + { "RAW_PIXEL_SIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_POINT_SIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_PIXELSIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_POINTSIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_QUAD_WIDTH", BDF_INTEGER, 1, { 0 } }, + { "RAW_SMALL_CAP_SIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_STRIKEOUT_ASCENT", BDF_INTEGER, 1, { 0 } }, + { "RAW_STRIKEOUT_DESCENT", BDF_INTEGER, 1, { 0 } }, + { "RAW_SUBSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_SUBSCRIPT_X", BDF_INTEGER, 1, { 0 } }, + { "RAW_SUBSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, + { "RAW_SUPERSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, + { "RAW_SUPERSCRIPT_X", BDF_INTEGER, 1, { 0 } }, + { "RAW_SUPERSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, + { "RAW_UNDERLINE_POSITION", BDF_INTEGER, 1, { 0 } }, + { "RAW_UNDERLINE_THICKNESS", BDF_INTEGER, 1, { 0 } }, + { "RAW_X_HEIGHT", BDF_INTEGER, 1, { 0 } }, + { "RELATIVE_SETWIDTH", BDF_CARDINAL, 1, { 0 } }, + { "RELATIVE_WEIGHT", BDF_CARDINAL, 1, { 0 } }, + { "RESOLUTION", BDF_INTEGER, 1, { 0 } }, + { "RESOLUTION_X", BDF_CARDINAL, 1, { 0 } }, + { "RESOLUTION_Y", BDF_CARDINAL, 1, { 0 } }, + { "SETWIDTH_NAME", BDF_ATOM, 1, { 0 } }, + { "SLANT", BDF_ATOM, 1, { 0 } }, + { "SMALL_CAP_SIZE", BDF_INTEGER, 1, { 0 } }, + { "SPACING", BDF_ATOM, 1, { 0 } }, + { "STRIKEOUT_ASCENT", BDF_INTEGER, 1, { 0 } }, + { "STRIKEOUT_DESCENT", BDF_INTEGER, 1, { 0 } }, + { "SUBSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, + { "SUBSCRIPT_X", BDF_INTEGER, 1, { 0 } }, + { "SUBSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, + { "SUPERSCRIPT_SIZE", BDF_INTEGER, 1, { 0 } }, + { "SUPERSCRIPT_X", BDF_INTEGER, 1, { 0 } }, + { "SUPERSCRIPT_Y", BDF_INTEGER, 1, { 0 } }, + { "UNDERLINE_POSITION", BDF_INTEGER, 1, { 0 } }, + { "UNDERLINE_THICKNESS", BDF_INTEGER, 1, { 0 } }, + { "WEIGHT", BDF_CARDINAL, 1, { 0 } }, + { "WEIGHT_NAME", BDF_ATOM, 1, { 0 } }, + { "X_HEIGHT", BDF_INTEGER, 1, { 0 } }, + { "_MULE_BASELINE_OFFSET", BDF_INTEGER, 1, { 0 } }, + { "_MULE_RELATIVE_COMPOSE", BDF_INTEGER, 1, { 0 } }, }; static const unsigned long @@ -196,11 +196,10 @@ #define ACMSG9 "SWIDTH field missing at line %ld. Set automatically.\n" #define ACMSG10 "DWIDTH field missing at line %ld. Set to glyph width.\n" #define ACMSG11 "SIZE bits per pixel field adjusted to %hd.\n" -#define ACMSG12 "Duplicate encoding %ld (%s) changed to unencoded.\n" -#define ACMSG13 "Glyph %ld extra rows removed.\n" -#define ACMSG14 "Glyph %ld extra columns removed.\n" +#define ACMSG13 "Glyph %lu extra rows removed.\n" +#define ACMSG14 "Glyph %lu extra columns removed.\n" #define ACMSG15 "Incorrect glyph count: %ld indicated but %ld found.\n" -#define ACMSG16 "Glyph %ld missing columns padded with zero bits.\n" +#define ACMSG16 "Glyph %lu missing columns padded with zero bits.\n" #define ACMSG17 "Adjusting number of glyphs to %ld.\n" /* Error messages. */ @@ -219,11 +218,11 @@ #define DBGMSG2 " (0x%lX)\n" - /*************************************************************************/ - /* */ - /* Utility types and functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Utility types and functions. + * + */ /* Function type for parsing lines of a BDF font. */ @@ -270,8 +269,6 @@ bdf_font_t* font; bdf_options_t* opts; - unsigned long have[34816]; /* must be in sync with `nmod' and `umod' */ - /* arrays from `bdf_font_t' structure */ _bdf_list_t list; FT_Memory memory; @@ -367,7 +364,7 @@ /* An empty string for empty fields. */ - static const char empty[1] = { 0 }; /* XXX eliminate this */ + static const char empty[] = ""; /* XXX eliminate this */ static char * @@ -410,13 +407,14 @@ static FT_Error _bdf_list_split( _bdf_list_t* list, - char* separators, + const char* separators, char* line, unsigned long linelen ) { unsigned long final_empty; int mult; - char *sp, *ep, *end; + const char *sp, *end; + char *ep; char seps[32]; FT_Error error = FT_Err_Ok; @@ -476,7 +474,7 @@ } /* Assign the field appropriately. */ - list->field[list->used++] = ( ep > sp ) ? sp : (char*)empty; + list->field[list->used++] = ( ep > sp ) ? (char*)sp : (char*)empty; sp = ep; @@ -695,7 +693,7 @@ /* Routine to convert a decimal ASCII string to an unsigned long integer. */ static unsigned long - _bdf_atoul( char* s ) + _bdf_atoul( const char* s ) { unsigned long v; @@ -720,7 +718,7 @@ /* Routine to convert a decimal ASCII string to a signed long integer. */ static long - _bdf_atol( char* s ) + _bdf_atol( const char* s ) { long v, neg; @@ -753,7 +751,7 @@ /* Routine to convert a decimal ASCII string to an unsigned short integer. */ static unsigned short - _bdf_atous( char* s ) + _bdf_atous( const char* s ) { unsigned short v; @@ -778,7 +776,7 @@ /* Routine to convert a decimal ASCII string to a signed short integer. */ static short - _bdf_atos( char* s ) + _bdf_atos( const char* s ) { short v, neg; @@ -831,7 +829,7 @@ static FT_Error - bdf_create_property( char* name, + bdf_create_property( const char* name, int format, bdf_font_t* font ) { @@ -900,11 +898,11 @@ } - /*************************************************************************/ - /* */ - /* BDF font file parsing flags and functions. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * BDF font file parsing flags and functions. + * + */ /* Parse flags. */ @@ -1001,7 +999,7 @@ FT_MEM_COPY( name, font->name, len ); - error = _bdf_list_split( &list, (char *)"-", name, (unsigned long)len ); + error = _bdf_list_split( &list, "-", name, (unsigned long)len ); if ( error ) goto Fail; @@ -1100,7 +1098,7 @@ static FT_Error _bdf_add_property( bdf_font_t* font, - char* name, + const char* name, char* value, unsigned long lineno ) { @@ -1232,7 +1230,7 @@ /* present, and the SPACING property should override the default */ /* spacing. */ if ( _bdf_strncmp( name, "DEFAULT_CHAR", 12 ) == 0 ) - font->default_char = fp->value.l; + font->default_char = fp->value.ul; else if ( _bdf_strncmp( name, "FONT_ASCENT", 11 ) == 0 ) font->font_ascent = fp->value.l; else if ( _bdf_strncmp( name, "FONT_DESCENT", 12 ) == 0 ) @@ -1265,6 +1263,25 @@ }; + static FT_Error + _bdf_parse_end( char* line, + unsigned long linelen, + unsigned long lineno, + void* call_data, + void* client_data ) + { + /* a no-op; we ignore everything after `ENDFONT' */ + + FT_UNUSED( line ); + FT_UNUSED( linelen ); + FT_UNUSED( lineno ); + FT_UNUSED( call_data ); + FT_UNUSED( client_data ); + + return FT_Err_Ok; + } + + /* Actually parse the glyph info and bitmaps. */ static FT_Error _bdf_parse_glyphs( char* line, @@ -1278,6 +1295,7 @@ unsigned char* bp; unsigned long i, slen, nibbles; + _bdf_line_func_t* next; _bdf_parse_t* p; bdf_glyph_t* glyph; bdf_font_t* font; @@ -1285,11 +1303,11 @@ FT_Memory memory; FT_Error error = FT_Err_Ok; - FT_UNUSED( call_data ); FT_UNUSED( lineno ); /* only used in debug mode */ - p = (_bdf_parse_t *)client_data; + next = (_bdf_line_func_t *)call_data; + p = (_bdf_parse_t *) client_data; font = p->font; memory = font->memory; @@ -1319,7 +1337,7 @@ goto Exit; } - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1] ); @@ -1370,6 +1388,7 @@ by_encoding ); p->flags &= ~BDF_START_; + *next = _bdf_parse_end; goto Exit; } @@ -1405,7 +1424,7 @@ /* encoding can be checked for an unencoded character. */ FT_FREE( p->glyph_name ); - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -1443,7 +1462,7 @@ goto Exit; } - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -1458,40 +1477,11 @@ if ( p->glyph_enc == -1 && p->list.used > 2 ) p->glyph_enc = _bdf_atol( p->list.field[2] ); - if ( p->glyph_enc < -1 ) + if ( p->glyph_enc < -1 || p->glyph_enc >= 0x110000L ) p->glyph_enc = -1; FT_TRACE4(( DBGMSG2, p->glyph_enc )); - /* Check that the encoding is in the Unicode range because */ - /* otherwise p->have (a bitmap with static size) overflows. */ - if ( p->glyph_enc > 0 && - (size_t)p->glyph_enc >= sizeof ( p->have ) / - sizeof ( unsigned long ) * 32 ) - { - FT_ERROR(( "_bdf_parse_glyphs: " ERRMSG5, lineno, "ENCODING" )); - error = FT_THROW( Invalid_File_Format ); - goto Exit; - } - - /* Check whether this encoding has already been encountered. */ - /* If it has then change it to unencoded so it gets added if */ - /* indicated. */ - if ( p->glyph_enc >= 0 ) - { - if ( _bdf_glyph_modified( p->have, p->glyph_enc ) ) - { - /* Emit a message saying a glyph has been moved to the */ - /* unencoded area. */ - FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG12, - p->glyph_enc, p->glyph_name )); - p->glyph_enc = -1; - font->modified = 1; - } - else - _bdf_set_glyph_modified( p->have, p->glyph_enc ); - } - if ( p->glyph_enc >= 0 ) { /* Make sure there are enough glyphs allocated in case the */ @@ -1508,7 +1498,7 @@ glyph = font->glyphs + font->glyphs_used++; glyph->name = p->glyph_name; - glyph->encoding = p->glyph_enc; + glyph->encoding = (unsigned long)p->glyph_enc; /* Reset the initial glyph info. */ p->glyph_name = NULL; @@ -1532,7 +1522,7 @@ glyph = font->unencoded + font->unencoded_used; glyph->name = p->glyph_name; - glyph->encoding = (long)font->unencoded_used++; + glyph->encoding = font->unencoded_used++; /* Reset the initial glyph info. */ p->glyph_name = NULL; @@ -1556,6 +1546,9 @@ goto Exit; } + if ( !( p->flags & BDF_ENCODING_ ) ) + goto Missing_Encoding; + /* Point at the glyph being constructed. */ if ( p->glyph_enc == -1 ) glyph = font->unencoded + ( font->unencoded_used - 1 ); @@ -1573,7 +1566,6 @@ { FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG13, glyph->encoding )); p->flags |= BDF_GLYPH_HEIGHT_CHECK_; - font->modified = 1; } goto Exit; @@ -1601,7 +1593,6 @@ { FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG16, glyph->encoding )); p->flags |= BDF_GLYPH_WIDTH_CHECK_; - font->modified = 1; } /* Remove possible garbage at the right. */ @@ -1616,7 +1607,6 @@ { FT_TRACE2(( "_bdf_parse_glyphs: " ACMSG14, glyph->encoding )); p->flags |= BDF_GLYPH_WIDTH_CHECK_; - font->modified = 1; } p->row++; @@ -1626,10 +1616,7 @@ /* Expect the SWIDTH (scalable width) field next. */ if ( _bdf_strncmp( line, "SWIDTH", 6 ) == 0 ) { - if ( !( p->flags & BDF_ENCODING_ ) ) - goto Missing_Encoding; - - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -1642,10 +1629,7 @@ /* Expect the DWIDTH (scalable width) field next. */ if ( _bdf_strncmp( line, "DWIDTH", 6 ) == 0 ) { - if ( !( p->flags & BDF_ENCODING_ ) ) - goto Missing_Encoding; - - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -1670,10 +1654,7 @@ /* Expect the BBX field next. */ if ( _bdf_strncmp( line, "BBX", 3 ) == 0 ) { - if ( !( p->flags & BDF_ENCODING_ ) ) - goto Missing_Encoding; - - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -1720,14 +1701,7 @@ { glyph->swidth = sw; - if ( p->glyph_enc == -1 ) - _bdf_set_glyph_modified( font->umod, - font->unencoded_used - 1 ); - else - _bdf_set_glyph_modified( font->nmod, glyph->encoding ); - p->flags |= BDF_SWIDTH_ADJ_; - font->modified = 1; } } @@ -1823,26 +1797,24 @@ { p->font->font_ascent = p->font->bbx.ascent; ft_sprintf( nbuf, "%hd", p->font->bbx.ascent ); - error = _bdf_add_property( p->font, (char *)"FONT_ASCENT", + error = _bdf_add_property( p->font, "FONT_ASCENT", nbuf, lineno ); if ( error ) goto Exit; FT_TRACE2(( "_bdf_parse_properties: " ACMSG1, p->font->bbx.ascent )); - p->font->modified = 1; } if ( bdf_get_font_property( p->font, "FONT_DESCENT" ) == 0 ) { p->font->font_descent = p->font->bbx.descent; ft_sprintf( nbuf, "%hd", p->font->bbx.descent ); - error = _bdf_add_property( p->font, (char *)"FONT_DESCENT", + error = _bdf_add_property( p->font, "FONT_DESCENT", nbuf, lineno ); if ( error ) goto Exit; FT_TRACE2(( "_bdf_parse_properties: " ACMSG2, p->font->bbx.descent )); - p->font->modified = 1; } p->flags &= ~BDF_PROPS_; @@ -1875,7 +1847,7 @@ } else { - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; name = p->list.field[0]; @@ -1989,7 +1961,7 @@ if ( error ) goto Exit; p->font->spacing = p->opts->font_spacing; - p->font->default_char = -1; + p->font->default_char = ~0UL; goto Exit; } @@ -2005,7 +1977,7 @@ goto Exit; } - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -2044,7 +2016,7 @@ goto Exit; } - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -2067,7 +2039,7 @@ /* The next thing to check for is the FONT field. */ if ( _bdf_strncmp( line, "FONT", 4 ) == 0 ) { - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; _bdf_list_shift( &p->list, 1 ); @@ -2110,7 +2082,7 @@ goto Exit; } - error = _bdf_list_split( &p->list, (char *)" +", line, linelen ); + error = _bdf_list_split( &p->list, " +", line, linelen ); if ( error ) goto Exit; @@ -2165,7 +2137,7 @@ /* for compiling fonts. */ p->font->font_ascent = p->font->bbx.ascent; ft_sprintf( nbuf, "%hd", p->font->bbx.ascent ); - error = _bdf_add_property( p->font, (char *)"FONT_ASCENT", + error = _bdf_add_property( p->font, "FONT_ASCENT", nbuf, lineno ); if ( error ) goto Exit; @@ -2173,14 +2145,12 @@ p->font->font_descent = p->font->bbx.descent; ft_sprintf( nbuf, "%hd", p->font->bbx.descent ); - error = _bdf_add_property( p->font, (char *)"FONT_DESCENT", + error = _bdf_add_property( p->font, "FONT_DESCENT", nbuf, lineno ); if ( error ) goto Exit; FT_TRACE2(( "_bdf_parse_properties: " ACMSG2, p->font->bbx.descent )); - p->font->modified = 1; - *next = _bdf_parse_glyphs; /* A special return value. */ @@ -2196,11 +2166,11 @@ } - /*************************************************************************/ - /* */ - /* API. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * API. + * + */ FT_LOCAL_DEF( FT_Error ) @@ -2246,7 +2216,6 @@ { FT_TRACE2(( "bdf_load_font: " ACMSG15, p->cnt, p->font->glyphs_used + p->font->unencoded_used )); - p->font->modified = 1; } /* Once the font has been loaded, adjust the overall font metrics if */ @@ -2259,7 +2228,6 @@ FT_TRACE2(( "bdf_load_font: " ACMSG3, p->font->bbx.width, p->maxrb - p->minlb )); p->font->bbx.width = (unsigned short)( p->maxrb - p->minlb ); - p->font->modified = 1; } if ( p->font->bbx.x_offset != p->minlb ) @@ -2267,7 +2235,6 @@ FT_TRACE2(( "bdf_load_font: " ACMSG4, p->font->bbx.x_offset, p->minlb )); p->font->bbx.x_offset = p->minlb; - p->font->modified = 1; } if ( p->font->bbx.ascent != p->maxas ) @@ -2275,7 +2242,6 @@ FT_TRACE2(( "bdf_load_font: " ACMSG5, p->font->bbx.ascent, p->maxas )); p->font->bbx.ascent = p->maxas; - p->font->modified = 1; } if ( p->font->bbx.descent != p->maxds ) @@ -2284,7 +2250,6 @@ p->font->bbx.descent, p->maxds )); p->font->bbx.descent = p->maxds; p->font->bbx.y_offset = (short)( -p->maxds ); - p->font->modified = 1; } if ( p->maxas + p->maxds != p->font->bbx.height ) @@ -2415,16 +2380,6 @@ FT_FREE( font->glyphs ); FT_FREE( font->unencoded ); - /* Free up the overflow storage if it was used. */ - for ( i = 0, glyphs = font->overflow.glyphs; - i < font->overflow.glyphs_used; i++, glyphs++ ) - { - FT_FREE( glyphs->name ); - FT_FREE( glyphs->bitmap ); - } - - FT_FREE( font->overflow.glyphs ); - /* bdf_cleanup */ ft_hash_str_free( &(font->proptbl), memory ); diff --git a/src/3rdparty/freetype/src/bzip2/Jamfile b/src/3rdparty/freetype/src/bzip2/Jamfile index 3548eab597..4b77916a8d 100644 --- a/src/3rdparty/freetype/src/bzip2/Jamfile +++ b/src/3rdparty/freetype/src/bzip2/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/bzip2 Jamfile # -# Copyright 2010-2018 by +# Copyright (C) 2010-2019 by # Joel Klinghed # # based on `src/lzw/Jamfile' diff --git a/src/3rdparty/freetype/src/bzip2/ftbzip2.c b/src/3rdparty/freetype/src/bzip2/ftbzip2.c index 16019485a9..1fda59b60c 100644 --- a/src/3rdparty/freetype/src/bzip2/ftbzip2.c +++ b/src/3rdparty/freetype/src/bzip2/ftbzip2.c @@ -1,25 +1,25 @@ -/***************************************************************************/ -/* */ -/* ftbzip2.c */ -/* */ -/* FreeType support for .bz2 compressed files. */ -/* */ -/* This optional component relies on libbz2. It should mainly be used to */ -/* parse compressed PCF fonts, as found with many X11 server */ -/* distributions. */ -/* */ -/* Copyright 2010-2018 by */ -/* Joel Klinghed. */ -/* */ -/* based on `src/gzip/ftgzip.c' */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftbzip2.c + * + * FreeType support for .bz2 compressed files. + * + * This optional component relies on libbz2. It should mainly be used to + * parse compressed PCF fonts, as found with many X11 server + * distributions. + * + * Copyright (C) 2010-2019 by + * Joel Klinghed. + * + * based on `src/gzip/ftgzip.c' + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -43,10 +43,6 @@ #ifdef FT_CONFIG_OPTION_USE_BZIP2 -#ifdef FT_CONFIG_OPTION_PIC -#error "bzip2 code does not support PIC yet" -#endif - #define BZ_NO_STDIO /* Do not need FILE */ #include <bzlib.h> @@ -475,8 +471,8 @@ memory = source->memory; /* - * check the header right now; this prevents allocating unnecessary - * objects when we don't need them + * check the header right now; this prevents allocating unnecessary + * objects when we don't need them */ error = ft_bzip2_check_header( source ); if ( error ) diff --git a/src/3rdparty/freetype/src/bzip2/rules.mk b/src/3rdparty/freetype/src/bzip2/rules.mk index 95954d7520..f365c1f76d 100644 --- a/src/3rdparty/freetype/src/bzip2/rules.mk +++ b/src/3rdparty/freetype/src/bzip2/rules.mk @@ -2,7 +2,7 @@ # FreeType 2 BZIP2 support configuration rules # -# Copyright 2010-2018 by +# Copyright (C) 2010-2019 by # Joel Klinghed. # # based on `src/lzw/rules.mk' diff --git a/src/3rdparty/freetype/src/cache/Jamfile b/src/3rdparty/freetype/src/cache/Jamfile index 53f4c7b603..51f7196d1b 100644 --- a/src/3rdparty/freetype/src/cache/Jamfile +++ b/src/3rdparty/freetype/src/cache/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cache Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/cache/ftcache.c b/src/3rdparty/freetype/src/cache/ftcache.c index 1b425af911..a6a3e63ef0 100644 --- a/src/3rdparty/freetype/src/cache/ftcache.c +++ b/src/3rdparty/freetype/src/cache/ftcache.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcache.c */ -/* */ -/* The FreeType Caching sub-system (body only). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcache.c + * + * The FreeType Caching sub-system (body only). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/cache/ftcbasic.c b/src/3rdparty/freetype/src/cache/ftcbasic.c index 994aa12286..a473585ebc 100644 --- a/src/3rdparty/freetype/src/cache/ftcbasic.c +++ b/src/3rdparty/freetype/src/cache/ftcbasic.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcbasic.c */ -/* */ -/* The FreeType basic cache interface (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcbasic.c + * + * The FreeType basic cache interface (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -27,11 +27,11 @@ #include "ftccback.h" #include "ftcerror.h" -#define FT_COMPONENT trace_cache +#define FT_COMPONENT cache /* - * Basic Families + * Basic Families * */ typedef struct FTC_BasicAttrRec_ diff --git a/src/3rdparty/freetype/src/cache/ftccache.c b/src/3rdparty/freetype/src/cache/ftccache.c index 12ec585a25..f38ca44ddd 100644 --- a/src/3rdparty/freetype/src/cache/ftccache.c +++ b/src/3rdparty/freetype/src/cache/ftccache.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftccache.c */ -/* */ -/* The FreeType internal cache interface (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftccache.c + * + * The FreeType internal cache interface (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,7 +25,7 @@ #include "ftcerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_cache +#define FT_COMPONENT cache #define FTC_HASH_MAX_LOAD 2 diff --git a/src/3rdparty/freetype/src/cache/ftccache.h b/src/3rdparty/freetype/src/cache/ftccache.h index 859c547e46..140ceadb11 100644 --- a/src/3rdparty/freetype/src/cache/ftccache.h +++ b/src/3rdparty/freetype/src/cache/ftccache.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftccache.h */ -/* */ -/* FreeType internal cache interface (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftccache.h + * + * FreeType internal cache interface (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCCACHE_H_ @@ -42,17 +42,17 @@ FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Each cache controls one or more cache nodes. Each node is part of */ - /* the global_lru list of the manager. Its `data' field however is used */ - /* as a reference count for now. */ - /* */ - /* A node can be anything, depending on the type of information held by */ - /* the cache. It can be an individual glyph image, a set of bitmaps */ - /* glyphs for a given size, some metrics, etc. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Each cache controls one or more cache nodes. Each node is part of + * the global_lru list of the manager. Its `data' field however is used + * as a reference count for now. + * + * A node can be anything, depending on the type of information held by + * the cache. It can be an individual glyph image, a set of bitmaps + * glyphs for a given size, some metrics, etc. + * + */ /* structure size should be 20 bytes on 32-bits machines */ typedef struct FTC_NodeRec_ @@ -302,11 +302,11 @@ FT_BEGIN_HEADER * * Example: * - * { - * FTC_CACHE_TRYLOOP( cache ) - * error = load_data( ... ); - * FTC_CACHE_TRYLOOP_END() - * } + * { + * FTC_CACHE_TRYLOOP( cache ) + * error = load_data( ... ); + * FTC_CACHE_TRYLOOP_END() + * } * */ #define FTC_CACHE_TRYLOOP( cache ) \ diff --git a/src/3rdparty/freetype/src/cache/ftccback.h b/src/3rdparty/freetype/src/cache/ftccback.h index e51d8d6e55..9321bc3d4e 100644 --- a/src/3rdparty/freetype/src/cache/ftccback.h +++ b/src/3rdparty/freetype/src/cache/ftccback.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftccback.h */ -/* */ -/* Callback functions of the caching sub-system (specification only). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftccback.h + * + * Callback functions of the caching sub-system (specification only). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCCBACK_H_ #define FTCCBACK_H_ diff --git a/src/3rdparty/freetype/src/cache/ftccmap.c b/src/3rdparty/freetype/src/cache/ftccmap.c index d20b0f48fe..76ba10e3e9 100644 --- a/src/3rdparty/freetype/src/cache/ftccmap.c +++ b/src/3rdparty/freetype/src/cache/ftccmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftccmap.c */ -/* */ -/* FreeType CharMap cache (body) */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftccmap.c + * + * FreeType CharMap cache (body) + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -28,21 +28,21 @@ #include "ftcerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_cache - - - /*************************************************************************/ - /* */ - /* Each FTC_CMapNode contains a simple array to map a range of character */ - /* codes to equivalent glyph indices. */ - /* */ - /* For now, the implementation is very basic: Each node maps a range of */ - /* 128 consecutive character codes to their corresponding glyph indices. */ - /* */ - /* We could do more complex things, but I don't think it is really very */ - /* useful. */ - /* */ - /*************************************************************************/ +#define FT_COMPONENT cache + + + /************************************************************************** + * + * Each FTC_CMapNode contains a simple array to map a range of character + * codes to equivalent glyph indices. + * + * For now, the implementation is very basic: Each node maps a range of + * 128 consecutive character codes to their corresponding glyph indices. + * + * We could do more complex things, but I don't think it is really very + * useful. + * + */ /* number of glyph indices / character code per node */ diff --git a/src/3rdparty/freetype/src/cache/ftcerror.h b/src/3rdparty/freetype/src/cache/ftcerror.h index a26cd5935b..e2d6417180 100644 --- a/src/3rdparty/freetype/src/cache/ftcerror.h +++ b/src/3rdparty/freetype/src/cache/ftcerror.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftcerror.h */ -/* */ -/* Caching sub-system error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the caching sub-system error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftcerror.h + * + * Caching sub-system error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the caching sub-system error enumeration + * constants. + * + */ #ifndef FTCERROR_H_ #define FTCERROR_H_ diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.c b/src/3rdparty/freetype/src/cache/ftcglyph.c index 782cc0ed09..2a0e97d4af 100644 --- a/src/3rdparty/freetype/src/cache/ftcglyph.c +++ b/src/3rdparty/freetype/src/cache/ftcglyph.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcglyph.c */ -/* */ -/* FreeType Glyph Image (FT_Glyph) cache (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcglyph.c + * + * FreeType Glyph Image (FT_Glyph) cache (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/cache/ftcglyph.h b/src/3rdparty/freetype/src/cache/ftcglyph.h index 23c24d223f..5a1f0e2a74 100644 --- a/src/3rdparty/freetype/src/cache/ftcglyph.h +++ b/src/3rdparty/freetype/src/cache/ftcglyph.h @@ -1,101 +1,101 @@ -/***************************************************************************/ -/* */ -/* ftcglyph.h */ -/* */ -/* FreeType abstract glyph cache (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcglyph.h + * + * FreeType abstract glyph cache (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* * - * FTC_GCache is an _abstract_ cache object optimized to store glyph - * data. It works as follows: + * FTC_GCache is an _abstract_ cache object optimized to store glyph + * data. It works as follows: * - * - It manages FTC_GNode objects. Each one of them can hold one or more - * glyph `items'. Item types are not specified in the FTC_GCache but - * in classes that extend it. + * - It manages FTC_GNode objects. Each one of them can hold one or more + * glyph `items'. Item types are not specified in the FTC_GCache but + * in classes that extend it. * - * - Glyph attributes, like face ID, character size, render mode, etc., - * can be grouped into abstract `glyph families'. This avoids storing - * the attributes within the FTC_GCache, since it is likely that many - * FTC_GNodes will belong to the same family in typical uses. + * - Glyph attributes, like face ID, character size, render mode, etc., + * can be grouped into abstract `glyph families'. This avoids storing + * the attributes within the FTC_GCache, since it is likely that many + * FTC_GNodes will belong to the same family in typical uses. * - * - Each FTC_GNode is thus an FTC_Node with two additional fields: + * - Each FTC_GNode is thus an FTC_Node with two additional fields: * - * * gindex: A glyph index, or the first index in a glyph range. - * * family: A pointer to a glyph `family'. + * * gindex: A glyph index, or the first index in a glyph range. + * * family: A pointer to a glyph `family'. * - * - Family types are not fully specific in the FTC_Family type, but - * by classes that extend it. + * - Family types are not fully specific in the FTC_Family type, but + * by classes that extend it. * - * Note that both FTC_ImageCache and FTC_SBitCache extend FTC_GCache. - * They share an FTC_Family sub-class called FTC_BasicFamily which is - * used to store the following data: face ID, pixel/point sizes, load - * flags. For more details see the file `src/cache/ftcbasic.c'. + * Note that both FTC_ImageCache and FTC_SBitCache extend FTC_GCache. + * They share an FTC_Family sub-class called FTC_BasicFamily which is + * used to store the following data: face ID, pixel/point sizes, load + * flags. For more details see the file `src/cache/ftcbasic.c'. * - * Client applications can extend FTC_GNode with their own FTC_GNode - * and FTC_Family sub-classes to implement more complex caches (e.g., - * handling automatic synthesis, like obliquing & emboldening, colored - * glyphs, etc.). + * Client applications can extend FTC_GNode with their own FTC_GNode + * and FTC_Family sub-classes to implement more complex caches (e.g., + * handling automatic synthesis, like obliquing & emboldening, colored + * glyphs, etc.). * - * See also the FTC_ICache & FTC_SCache classes in `ftcimage.h' and - * `ftcsbits.h', which both extend FTC_GCache with additional - * optimizations. + * See also the FTC_ICache & FTC_SCache classes in `ftcimage.h' and + * `ftcsbits.h', which both extend FTC_GCache with additional + * optimizations. * - * A typical FTC_GCache implementation must provide at least the - * following: + * A typical FTC_GCache implementation must provide at least the + * following: * - * - FTC_GNode sub-class, e.g. MyNode, with relevant methods: - * my_node_new (must call FTC_GNode_Init) - * my_node_free (must call FTC_GNode_Done) - * my_node_compare (must call FTC_GNode_Compare) - * my_node_remove_faceid (must call ftc_gnode_unselect in case - * of match) + * - FTC_GNode sub-class, e.g. MyNode, with relevant methods: + * my_node_new (must call FTC_GNode_Init) + * my_node_free (must call FTC_GNode_Done) + * my_node_compare (must call FTC_GNode_Compare) + * my_node_remove_faceid (must call ftc_gnode_unselect in case + * of match) * - * - FTC_Family sub-class, e.g. MyFamily, with relevant methods: - * my_family_compare - * my_family_init - * my_family_reset (optional) - * my_family_done + * - FTC_Family sub-class, e.g. MyFamily, with relevant methods: + * my_family_compare + * my_family_init + * my_family_reset (optional) + * my_family_done * - * - FTC_GQuery sub-class, e.g. MyQuery, to hold cache-specific query - * data. + * - FTC_GQuery sub-class, e.g. MyQuery, to hold cache-specific query + * data. * - * - Constant structures for a FTC_GNodeClass. + * - Constant structures for a FTC_GNodeClass. * - * - MyCacheNew() can be implemented easily as a call to the convenience - * function FTC_GCache_New. + * - MyCacheNew() can be implemented easily as a call to the convenience + * function FTC_GCache_New. * - * - MyCacheLookup with a call to FTC_GCache_Lookup. This function will - * automatically: + * - MyCacheLookup with a call to FTC_GCache_Lookup. This function will + * automatically: * - * - Search for the corresponding family in the cache, or create - * a new one if necessary. Put it in FTC_GQUERY(myquery).family + * - Search for the corresponding family in the cache, or create + * a new one if necessary. Put it in FTC_GQUERY(myquery).family * - * - Call FTC_Cache_Lookup. + * - Call FTC_Cache_Lookup. * - * If it returns NULL, you should create a new node, then call - * ftc_cache_add as usual. + * If it returns NULL, you should create a new node, then call + * ftc_cache_add as usual. */ - /*************************************************************************/ - /* */ - /* Important: The functions defined in this file are only used to */ - /* implement an abstract glyph cache class. You need to */ - /* provide additional logic to implement a complete cache. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Important: The functions defined in this file are only used to + * implement an abstract glyph cache class. You need to + * provide additional logic to implement a complete cache. + * + */ /*************************************************************************/ @@ -125,11 +125,11 @@ FT_BEGIN_HEADER /* - * We can group glyphs into `families'. Each family correspond to a - * given face ID, character size, transform, etc. + * We can group glyphs into `families'. Each family correspond to a + * given face ID, character size, transform, etc. * - * Families are implemented as MRU list nodes. They are - * reference-counted. + * Families are implemented as MRU list nodes. They are + * reference-counted. */ typedef struct FTC_FamilyRec_ @@ -167,12 +167,12 @@ FT_BEGIN_HEADER #define FTC_GQUERY( x ) ( (FTC_GQuery)(x) ) - /*************************************************************************/ - /* */ - /* These functions are exported so that they can be called from */ - /* user-provided cache classes; otherwise, they are really part of the */ - /* cache sub-system internals. */ - /* */ + /************************************************************************** + * + * These functions are exported so that they can be called from + * user-provided cache classes; otherwise, they are really part of the + * cache sub-system internals. + */ /* must be called by derived FTC_Node_InitFunc routines */ FT_LOCAL( void ) diff --git a/src/3rdparty/freetype/src/cache/ftcimage.c b/src/3rdparty/freetype/src/cache/ftcimage.c index 77a100153e..9e64d51a22 100644 --- a/src/3rdparty/freetype/src/cache/ftcimage.c +++ b/src/3rdparty/freetype/src/cache/ftcimage.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcimage.c */ -/* */ -/* FreeType Image cache (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcimage.c + * + * FreeType Image cache (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/cache/ftcimage.h b/src/3rdparty/freetype/src/cache/ftcimage.h index 24a221053b..dcb101fabc 100644 --- a/src/3rdparty/freetype/src/cache/ftcimage.h +++ b/src/3rdparty/freetype/src/cache/ftcimage.h @@ -1,35 +1,35 @@ -/***************************************************************************/ -/* */ -/* ftcimage.h */ -/* */ -/* FreeType Generic Image cache (specification) */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcimage.h + * + * FreeType Generic Image cache (specification) + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* - * FTC_ICache is an _abstract_ cache used to store a single FT_Glyph - * image per cache node. + * FTC_ICache is an _abstract_ cache used to store a single FT_Glyph + * image per cache node. * - * FTC_ICache extends FTC_GCache. For an implementation example, - * see FTC_ImageCache in `src/cache/ftbasic.c'. + * FTC_ICache extends FTC_GCache. For an implementation example, + * see FTC_ImageCache in `src/cache/ftbasic.c'. */ - /*************************************************************************/ - /* */ - /* Each image cache really manages FT_Glyph objects. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Each image cache really manages FT_Glyph objects. + * + */ #ifndef FTCIMAGE_H_ diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.c b/src/3rdparty/freetype/src/cache/ftcmanag.c index 2bcd9df502..bd585968e3 100644 --- a/src/3rdparty/freetype/src/cache/ftcmanag.c +++ b/src/3rdparty/freetype/src/cache/ftcmanag.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcmanag.c */ -/* */ -/* FreeType Cache Manager (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcmanag.c + * + * FreeType Cache Manager (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,13 +26,9 @@ #include "ftccback.h" #include "ftcerror.h" -#ifdef FT_CONFIG_OPTION_PIC -#error "cache system does not support PIC yet" -#endif - #undef FT_COMPONENT -#define FT_COMPONENT trace_cache +#define FT_COMPONENT cache static FT_Error diff --git a/src/3rdparty/freetype/src/cache/ftcmanag.h b/src/3rdparty/freetype/src/cache/ftcmanag.h index b4b4755356..60c66c8fc8 100644 --- a/src/3rdparty/freetype/src/cache/ftcmanag.h +++ b/src/3rdparty/freetype/src/cache/ftcmanag.h @@ -1,47 +1,47 @@ -/***************************************************************************/ -/* */ -/* ftcmanag.h */ -/* */ -/* FreeType Cache Manager (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* A cache manager is in charge of the following: */ - /* */ - /* - Maintain a mapping between generic FTC_FaceIDs and live FT_Face */ - /* objects. The mapping itself is performed through a user-provided */ - /* callback. However, the manager maintains a small cache of FT_Face */ - /* and FT_Size objects in order to speed up things considerably. */ - /* */ - /* - Manage one or more cache objects. Each cache is in charge of */ - /* holding a varying number of `cache nodes'. Each cache node */ - /* represents a minimal amount of individually accessible cached */ - /* data. For example, a cache node can be an FT_Glyph image */ - /* containing a vector outline, or some glyph metrics, or anything */ - /* else. */ - /* */ - /* Each cache node has a certain size in bytes that is added to the */ - /* total amount of `cache memory' within the manager. */ - /* */ - /* All cache nodes are located in a global LRU list, where the oldest */ - /* node is at the tail of the list. */ - /* */ - /* Each node belongs to a single cache, and includes a reference */ - /* count to avoid destroying it (due to caching). */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftcmanag.h + * + * FreeType Cache Manager (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * A cache manager is in charge of the following: + * + * - Maintain a mapping between generic FTC_FaceIDs and live FT_Face + * objects. The mapping itself is performed through a user-provided + * callback. However, the manager maintains a small cache of FT_Face + * and FT_Size objects in order to speed up things considerably. + * + * - Manage one or more cache objects. Each cache is in charge of + * holding a varying number of `cache nodes'. Each cache node + * represents a minimal amount of individually accessible cached + * data. For example, a cache node can be an FT_Glyph image + * containing a vector outline, or some glyph metrics, or anything + * else. + * + * Each cache node has a certain size in bytes that is added to the + * total amount of `cache memory' within the manager. + * + * All cache nodes are located in a global LRU list, where the oldest + * node is at the tail of the list. + * + * Each node belongs to a single cache, and includes a reference + * count to avoid destroying it (due to caching). + * + */ /*************************************************************************/ @@ -72,12 +72,12 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Section> */ - /* cache_subsystem */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * @Section: + * cache_subsystem + * + */ #define FTC_MAX_FACES_DEFAULT 2 @@ -110,27 +110,28 @@ FT_BEGIN_HEADER } FTC_ManagerRec; - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Compress */ - /* */ - /* <Description> */ - /* This function is used to check the state of the cache manager if */ - /* its `num_bytes' field is greater than its `max_bytes' field. It */ - /* will flush as many old cache nodes as possible (ignoring cache */ - /* nodes with a non-zero reference count). */ - /* */ - /* <InOut> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* <Note> */ - /* Client applications should not call this function directly. It is */ - /* normally invoked by specific cache implementations. */ - /* */ - /* The reason this function is exported is to allow client-specific */ - /* cache classes. */ - /* */ + /************************************************************************** + * + * @Function: + * FTC_Manager_Compress + * + * @Description: + * This function is used to check the state of the cache manager if + * its `num_bytes' field is greater than its `max_bytes' field. It + * will flush as many old cache nodes as possible (ignoring cache + * nodes with a non-zero reference count). + * + * @InOut: + * manager :: + * A handle to the cache manager. + * + * @Note: + * Client applications should not call this function directly. It is + * normally invoked by specific cache implementations. + * + * The reason this function is exported is to allow client-specific + * cache classes. + */ FT_LOCAL( void ) FTC_Manager_Compress( FTC_Manager manager ); diff --git a/src/3rdparty/freetype/src/cache/ftcmru.c b/src/3rdparty/freetype/src/cache/ftcmru.c index 1087be4d89..18a7b80054 100644 --- a/src/3rdparty/freetype/src/cache/ftcmru.c +++ b/src/3rdparty/freetype/src/cache/ftcmru.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcmru.c */ -/* */ -/* FreeType MRU support (body). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcmru.c + * + * FreeType MRU support (body). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/cache/ftcmru.h b/src/3rdparty/freetype/src/cache/ftcmru.h index 82396b917d..58721ed340 100644 --- a/src/3rdparty/freetype/src/cache/ftcmru.h +++ b/src/3rdparty/freetype/src/cache/ftcmru.h @@ -1,43 +1,43 @@ -/***************************************************************************/ -/* */ -/* ftcmru.h */ -/* */ -/* Simple MRU list-cache (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* An MRU is a list that cannot hold more than a certain number of */ - /* elements (`max_elements'). All elements in the list are sorted in */ - /* least-recently-used order, i.e., the `oldest' element is at the tail */ - /* of the list. */ - /* */ - /* When doing a lookup (either through `Lookup()' or `Lookup_Node()'), */ - /* the list is searched for an element with the corresponding key. If */ - /* it is found, the element is moved to the head of the list and is */ - /* returned. */ - /* */ - /* If no corresponding element is found, the lookup routine will try to */ - /* obtain a new element with the relevant key. If the list is already */ - /* full, the oldest element from the list is discarded and replaced by a */ - /* new one; a new element is added to the list otherwise. */ - /* */ - /* Note that it is possible to pre-allocate the element list nodes. */ - /* This is handy if `max_elements' is sufficiently small, as it saves */ - /* allocations/releases during the lookup process. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftcmru.h + * + * Simple MRU list-cache (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * An MRU is a list that cannot hold more than a certain number of + * elements (`max_elements'). All elements in the list are sorted in + * least-recently-used order, i.e., the `oldest' element is at the tail + * of the list. + * + * When doing a lookup (either through `Lookup()' or `Lookup_Node()'), + * the list is searched for an element with the corresponding key. If + * it is found, the element is moved to the head of the list and is + * returned. + * + * If no corresponding element is found, the lookup routine will try to + * obtain a new element with the relevant key. If the list is already + * full, the oldest element from the list is discarded and replaced by a + * new one; a new element is added to the list otherwise. + * + * Note that it is possible to pre-allocate the element list nodes. + * This is handy if `max_elements' is sufficiently small, as it saves + * allocations/releases during the lookup process. + * + */ #ifndef FTCMRU_H_ diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.c b/src/3rdparty/freetype/src/cache/ftcsbits.c index 018f1ecdb7..06b46c896e 100644 --- a/src/3rdparty/freetype/src/cache/ftcsbits.c +++ b/src/3rdparty/freetype/src/cache/ftcsbits.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcsbits.c */ -/* */ -/* FreeType sbits manager (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcsbits.c + * + * FreeType sbits manager (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -27,7 +27,7 @@ #include "ftcerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_cache +#define FT_COMPONENT cache /*************************************************************************/ @@ -91,14 +91,14 @@ /* - * This function tries to load a small bitmap within a given FTC_SNode. - * Note that it returns a non-zero error code _only_ in the case of - * out-of-memory condition. For all other errors (e.g., corresponding - * to a bad font file), this function will mark the sbit as `unavailable' - * and return a value of 0. + * This function tries to load a small bitmap within a given FTC_SNode. + * Note that it returns a non-zero error code _only_ in the case of + * out-of-memory condition. For all other errors (e.g., corresponding + * to a bad font file), this function will mark the sbit as `unavailable' + * and return a value of 0. * - * You should also read the comment within the @ftc_snode_compare - * function below to see how out-of-memory is handled during a lookup. + * You should also read the comment within the @ftc_snode_compare + * function below to see how out-of-memory is handled during a lookup. */ static FT_Error ftc_snode_load( FTC_SNode snode, @@ -347,34 +347,34 @@ /* - * The following code illustrates what to do when you want to - * perform operations that may fail within a lookup function. + * The following code illustrates what to do when you want to + * perform operations that may fail within a lookup function. * - * Here, we want to load a small bitmap on-demand; we thus - * need to call the `ftc_snode_load' function which may return - * a non-zero error code only when we are out of memory (OOM). + * Here, we want to load a small bitmap on-demand; we thus + * need to call the `ftc_snode_load' function which may return + * a non-zero error code only when we are out of memory (OOM). * - * The correct thing to do is to use @FTC_CACHE_TRYLOOP and - * @FTC_CACHE_TRYLOOP_END in order to implement a retry loop - * that is capable of flushing the cache incrementally when - * an OOM errors occur. + * The correct thing to do is to use @FTC_CACHE_TRYLOOP and + * @FTC_CACHE_TRYLOOP_END in order to implement a retry loop + * that is capable of flushing the cache incrementally when + * an OOM errors occur. * - * However, we need to `lock' the node before this operation to - * prevent it from being flushed within the loop. + * However, we need to `lock' the node before this operation to + * prevent it from being flushed within the loop. * - * When we exit the loop, we unlock the node, then check the `error' - * variable. If it is non-zero, this means that the cache was - * completely flushed and that no usable memory was found to load - * the bitmap. + * When we exit the loop, we unlock the node, then check the `error' + * variable. If it is non-zero, this means that the cache was + * completely flushed and that no usable memory was found to load + * the bitmap. * - * We then prefer to return a value of 0 (i.e., NO MATCH). This - * ensures that the caller will try to allocate a new node. - * This operation consequently _fail_ and the lookup function - * returns the appropriate OOM error code. + * We then prefer to return a value of 0 (i.e., NO MATCH). This + * ensures that the caller will try to allocate a new node. + * This operation consequently _fail_ and the lookup function + * returns the appropriate OOM error code. * - * Note that `buffer == NULL && width == 255' is a hack used to - * tag `unavailable' bitmaps in the array. We should never try - * to load these. + * Note that `buffer == NULL && width == 255' is a hack used to + * tag `unavailable' bitmaps in the array. We should never try + * to load these. * */ diff --git a/src/3rdparty/freetype/src/cache/ftcsbits.h b/src/3rdparty/freetype/src/cache/ftcsbits.h index 206a1bb3fc..f1b71c2835 100644 --- a/src/3rdparty/freetype/src/cache/ftcsbits.h +++ b/src/3rdparty/freetype/src/cache/ftcsbits.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftcsbits.h */ -/* */ -/* A small-bitmap cache (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftcsbits.h + * + * A small-bitmap cache (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTCSBITS_H_ diff --git a/src/3rdparty/freetype/src/cache/rules.mk b/src/3rdparty/freetype/src/cache/rules.mk index 558935976d..1618d98303 100644 --- a/src/3rdparty/freetype/src/cache/rules.mk +++ b/src/3rdparty/freetype/src/cache/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2000-2018 by +# Copyright (C) 2000-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -15,7 +15,7 @@ # Cache driver directory # -CACHE_DIR := $(SRC_DIR)/cache +CACHE_DIR := $(SRC_DIR)/cache # compilation flags for the driver diff --git a/src/3rdparty/freetype/src/cff/Jamfile b/src/3rdparty/freetype/src/cff/Jamfile index 53c904fcfe..10f49cef12 100644 --- a/src/3rdparty/freetype/src/cff/Jamfile +++ b/src/3rdparty/freetype/src/cff/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cff Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/cff/cff.c b/src/3rdparty/freetype/src/cff/cff.c index 1a755d5dad..a34ba9b710 100644 --- a/src/3rdparty/freetype/src/cff/cff.c +++ b/src/3rdparty/freetype/src/cff/cff.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cff.c */ -/* */ -/* FreeType OpenType driver component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cff.c + * + * FreeType OpenType driver component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -23,7 +23,6 @@ #include "cffdrivr.c" #include "cffgload.c" #include "cffparse.c" -#include "cffpic.c" #include "cffload.c" #include "cffobjs.c" diff --git a/src/3rdparty/freetype/src/cff/cffcmap.c b/src/3rdparty/freetype/src/cff/cffcmap.c index e45ae1127b..15cc94cafb 100644 --- a/src/3rdparty/freetype/src/cff/cffcmap.c +++ b/src/3rdparty/freetype/src/cff/cffcmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffcmap.c */ -/* */ -/* CFF character mapping table (cmap) support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffcmap.c + * + * CFF character mapping table (cmap) support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -161,6 +161,9 @@ if ( !charset->sids ) return FT_THROW( No_Unicode_Glyph_Name ); + if ( !psnames->unicodes_init ) + return FT_THROW( Unimplemented_Feature ); + return psnames->unicodes_init( memory, unicodes, cff->num_glyphs, diff --git a/src/3rdparty/freetype/src/cff/cffcmap.h b/src/3rdparty/freetype/src/cff/cffcmap.h index 856a43dd1b..07366bc748 100644 --- a/src/3rdparty/freetype/src/cff/cffcmap.h +++ b/src/3rdparty/freetype/src/cff/cffcmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffcmap.h */ -/* */ -/* CFF character mapping table (cmap) support (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffcmap.h + * + * CFF character mapping table (cmap) support (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFCMAP_H_ diff --git a/src/3rdparty/freetype/src/cff/cffdrivr.c b/src/3rdparty/freetype/src/cff/cffdrivr.c index df896848da..2324989811 100644 --- a/src/3rdparty/freetype/src/cff/cffdrivr.c +++ b/src/3rdparty/freetype/src/cff/cffdrivr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdrivr.c */ -/* */ -/* OpenType font driver implementation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdrivr.c + * + * OpenType font driver implementation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -42,7 +42,6 @@ #endif #include "cfferrs.h" -#include "cffpic.h" #include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_GLYPH_DICT_H @@ -50,14 +49,14 @@ #include FT_DRIVER_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffdriver +#define FT_COMPONENT cffdriver /*************************************************************************/ @@ -73,38 +72,42 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_get_kerning */ - /* */ - /* <Description> */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* <Output> */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this function. Other layouts, or more sophisticated */ - /* kernings, are out of scope of this method (the basic driver */ - /* interface is meant to be simple). */ - /* */ - /* They can be implemented by format-specific interfaces. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_get_kerning + * + * @Description: + * A driver method used to return the kerning vector between two + * glyphs of the same face. + * + * @Input: + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * @Output: + * kerning :: + * The kerning vector. This is in font units for + * scalable formats, and in pixels for fixed-sizes + * formats. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only horizontal layouts (left-to-right & right-to-left) are + * supported by this function. Other layouts, or more sophisticated + * kernings, are out of scope of this method (the basic driver + * interface is meant to be simple). + * + * They can be implemented by format-specific interfaces. + */ FT_CALLBACK_DEF( FT_Error ) cff_get_kerning( FT_Face ttface, /* TT_Face */ FT_UInt left_glyph, @@ -125,32 +128,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_glyph_load */ - /* */ - /* <Description> */ - /* A driver method used to load a glyph within a given glyph slot. */ - /* */ - /* <Input> */ - /* slot :: A handle to the target slot object where the glyph */ - /* will be loaded. */ - /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled, loaded, etc. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_??? constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_glyph_load + * + * @Description: + * A driver method used to load a glyph within a given glyph slot. + * + * @Input: + * slot :: + * A handle to the target slot object where the glyph + * will be loaded. + * + * size :: + * A handle to the source face size at which the glyph + * must be scaled, loaded, etc. + * + * glyph_index :: + * The index of the glyph in the font file. + * + * load_flags :: + * A flag indicating what to load for this glyph. The + * FT_LOAD_??? constants can be used to control the + * glyph loading process (e.g., whether the outline + * should be scaled, whether to load bitmaps or not, + * whether to hint the outline, etc). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_CALLBACK_DEF( FT_Error ) cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ FT_Size cffsize, /* CFF_Size */ @@ -302,7 +309,7 @@ /* - * GLYPH DICT SERVICE + * GLYPH DICT SERVICE * */ @@ -341,7 +348,7 @@ FT_ERROR(( "cff_get_glyph_name:" " cannot get glyph name from a CFF2 font\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } @@ -352,7 +359,7 @@ FT_ERROR(( "cff_get_glyph_name:" " cannot get glyph name from CFF & CEF fonts\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } @@ -374,8 +381,8 @@ static FT_UInt - cff_get_name_index( CFF_Face face, - FT_String* glyph_name ) + cff_get_name_index( CFF_Face face, + const FT_String* glyph_name ) { CFF_Font cff; CFF_Charset charset; @@ -408,7 +415,7 @@ FT_ERROR(( "cff_get_name_index:" " cannot get glyph index from a CFF2 font\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); return 0; } } @@ -446,7 +453,7 @@ /* - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -593,7 +600,7 @@ /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -654,8 +661,8 @@ FT_Library library = FT_FACE_LIBRARY( face ); - if ( cmap->clazz != &CFF_CMAP_ENCODING_CLASS_REC_GET && - cmap->clazz != &CFF_CMAP_UNICODE_CLASS_REC_GET ) + if ( cmap->clazz != &cff_cmap_encoding_class_rec && + cmap->clazz != &cff_cmap_unicode_class_rec ) { FT_Module sfnt = FT_Get_Module( library, "sfnt" ); FT_Service_TTCMaps service = @@ -682,7 +689,7 @@ /* - * CID INFO SERVICE + * CID INFO SERVICE * */ static FT_Error @@ -788,7 +795,7 @@ goto Fail; } - if ( glyph_index > cff->num_glyphs ) + if ( glyph_index >= cff->num_glyphs ) { error = FT_THROW( Invalid_Argument ); goto Fail; @@ -818,7 +825,7 @@ /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ @@ -832,7 +839,7 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* - * MULTIPLE MASTER SERVICE + * MULTIPLE MASTER SERVICE * */ @@ -860,6 +867,30 @@ } + static FT_Error + cff_set_mm_weightvector( CFF_Face face, + FT_UInt len, + FT_Fixed* weightvector ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->set_mm_weightvector( FT_FACE( face ), len, weightvector ); + } + + + static FT_Error + cff_get_mm_weightvector( CFF_Face face, + FT_UInt* len, + FT_Fixed* weightvector ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->get_mm_weightvector( FT_FACE( face ), len, weightvector ); + } + + static FT_Error cff_get_mm_var( CFF_Face face, FT_MM_Var* *master ) @@ -909,22 +940,24 @@ FT_DEFINE_SERVICE_MULTIMASTERSREC( cff_service_multi_masters, - (FT_Get_MM_Func) NULL, /* get_mm */ - (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ - (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ - (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ - (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ - (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */ - (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */ - (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ - - (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ - (FT_Done_Blend_Func) cff_done_blend /* done_blend */ + (FT_Get_MM_Func) NULL, /* get_mm */ + (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ + (FT_Set_MM_Blend_Func) cff_set_mm_blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) cff_get_mm_blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ + (FT_Set_Var_Design_Func) cff_set_var_design, /* set_var_design */ + (FT_Get_Var_Design_Func) cff_get_var_design, /* get_var_design */ + (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ + (FT_Set_MM_WeightVector_Func)cff_set_mm_weightvector, /* set_mm_weightvector */ + (FT_Get_MM_WeightVector_Func)cff_get_mm_weightvector, /* get_mm_weightvector */ + + (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ + (FT_Done_Blend_Func) cff_done_blend /* done_blend */ ) /* - * METRICS VARIATIONS SERVICE + * METRICS VARIATIONS SERVICE * */ @@ -968,7 +1001,7 @@ /* - * CFFLOAD SERVICE + * CFFLOAD SERVICE * */ @@ -1001,54 +1034,54 @@ cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, - FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters, + FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_variations, + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES FT_DEFINE_SERVICEDESCREC8( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_DEFINE_SERVICEDESCREC9( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET, - FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_MULTI_MASTERS, &cff_service_multi_masters, + FT_SERVICE_ID_METRICS_VARIATIONS, &cff_service_metrics_var, + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #else FT_DEFINE_SERVICEDESCREC7( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, - FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, - FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, - FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET + FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name, + FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info, + FT_SERVICE_ID_CID, &cff_service_cid_info, + FT_SERVICE_ID_PROPERTIES, &cff_service_properties, + FT_SERVICE_ID_CFF_LOAD, &cff_service_cff_load ) #endif @@ -1062,27 +1095,16 @@ FT_Module_Interface result; - /* CFF_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - if ( !driver ) - return NULL; - library = driver->library; - if ( !library ) - return NULL; -#endif - - result = ft_service_list_lookup( CFF_SERVICES_GET, module_interface ); + result = ft_service_list_lookup( cff_services, module_interface ); if ( result ) return result; - /* `driver' is not yet evaluated in non-PIC mode */ -#ifndef FT_CONFIG_OPTION_PIC + /* `driver' is not yet evaluated */ if ( !driver ) return NULL; library = driver->library; if ( !library ) return NULL; -#endif /* we pass our request to the `sfnt' module */ sfnt = FT_Get_Module( library, "sfnt" ); diff --git a/src/3rdparty/freetype/src/cff/cffdrivr.h b/src/3rdparty/freetype/src/cff/cffdrivr.h index ad7c3ad70a..f2bbcfe4f1 100644 --- a/src/3rdparty/freetype/src/cff/cffdrivr.h +++ b/src/3rdparty/freetype/src/cff/cffdrivr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdrivr.h */ -/* */ -/* High-level OpenType driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdrivr.h + * + * High-level OpenType driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFDRIVER_H_ @@ -26,10 +26,8 @@ FT_BEGIN_HEADER - FT_DECLARE_DRIVER( cff_driver_class ) - FT_END_HEADER #endif /* CFFDRIVER_H_ */ diff --git a/src/3rdparty/freetype/src/cff/cfferrs.h b/src/3rdparty/freetype/src/cff/cfferrs.h index b2e1bfaf9d..78d47a156d 100644 --- a/src/3rdparty/freetype/src/cff/cfferrs.h +++ b/src/3rdparty/freetype/src/cff/cfferrs.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* cfferrs.h */ -/* */ -/* CFF error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the CFF error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * cfferrs.h + * + * CFF error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the CFF error enumeration constants. + * + */ #ifndef CFFERRS_H_ #define CFFERRS_H_ diff --git a/src/3rdparty/freetype/src/cff/cffgload.c b/src/3rdparty/freetype/src/cff/cffgload.c index c58471ce86..36aa7d1b9c 100644 --- a/src/3rdparty/freetype/src/cff/cffgload.c +++ b/src/3rdparty/freetype/src/cff/cffgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffgload.c */ -/* */ -/* OpenType Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffgload.c + * + * OpenType Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +31,14 @@ #include "cfferrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffgload +#define FT_COMPONENT cffgload FT_LOCAL_DEF( FT_Error ) @@ -280,16 +280,16 @@ glyph->root.outline.n_points = 0; glyph->root.outline.n_contours = 0; - glyph->root.metrics.width = (FT_Pos)metrics.width << 6; - glyph->root.metrics.height = (FT_Pos)metrics.height << 6; + glyph->root.metrics.width = (FT_Pos)metrics.width * 64; + glyph->root.metrics.height = (FT_Pos)metrics.height * 64; - glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6; - glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6; - glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6; + glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX * 64; + glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY * 64; + glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance * 64; - glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6; - glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6; - glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6; + glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX * 64; + glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY * 64; + glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance * 64; glyph->root.format = FT_GLYPH_FORMAT_BITMAP; @@ -414,7 +414,7 @@ decoder.width_only = TRUE; decoder.builder.no_recurse = - (FT_Bool)( load_flags & FT_LOAD_NO_RECURSE ); + FT_BOOL( load_flags & FT_LOAD_NO_RECURSE ); /* now load the unscaled outline */ error = cff_get_glyph_data( face, glyph_index, diff --git a/src/3rdparty/freetype/src/cff/cffgload.h b/src/3rdparty/freetype/src/cff/cffgload.h index 803f3974fc..754c55acf9 100644 --- a/src/3rdparty/freetype/src/cff/cffgload.h +++ b/src/3rdparty/freetype/src/cff/cffgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffgload.h */ -/* */ -/* OpenType Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffgload.h + * + * OpenType Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFGLOAD_H_ diff --git a/src/3rdparty/freetype/src/cff/cffload.c b/src/3rdparty/freetype/src/cff/cffload.c index 1c6fe51566..12efd18dc4 100644 --- a/src/3rdparty/freetype/src/cff/cffload.c +++ b/src/3rdparty/freetype/src/cff/cffload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffload.c */ -/* */ -/* OpenType and CFF data/program tables loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffload.c + * + * OpenType and CFF data/program tables loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -196,14 +196,14 @@ } - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffload +#define FT_COMPONENT cffload /* read an offset from the index's stream current position */ @@ -1398,7 +1398,14 @@ FT_UInt master; - FT_ASSERT( lenNDV == 0 || NDV ); + /* protect against malformed fonts */ + if ( !( lenNDV == 0 || NDV ) ) + { + FT_TRACE4(( " cff_blend_build_vector:" + " Malformed Normalize Design Vector data\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } blend->builtBV = FALSE; @@ -2080,13 +2087,13 @@ /* * Initialize the random number generator. * - * . If we have a face-specific seed, use it. + * - If we have a face-specific seed, use it. * If non-zero, update it to a positive value. * - * . Otherwise, use the seed from the CFF driver. + * - Otherwise, use the seed from the CFF driver. * If non-zero, update it to a positive value. * - * . If the random value is zero, use the seed given by the subfont's + * - If the random value is zero, use the seed given by the subfont's * `initialRandomSeed' value. * */ diff --git a/src/3rdparty/freetype/src/cff/cffload.h b/src/3rdparty/freetype/src/cff/cffload.h index 14d14e2112..42d2696f33 100644 --- a/src/3rdparty/freetype/src/cff/cffload.h +++ b/src/3rdparty/freetype/src/cff/cffload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffload.h */ -/* */ -/* OpenType & CFF data/program tables loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffload.h + * + * OpenType & CFF data/program tables loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFLOAD_H_ diff --git a/src/3rdparty/freetype/src/cff/cffobjs.c b/src/3rdparty/freetype/src/cff/cffobjs.c index a2d7aec65e..f76245f30b 100644 --- a/src/3rdparty/freetype/src/cff/cffobjs.c +++ b/src/3rdparty/freetype/src/cff/cffobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffobjs.c */ -/* */ -/* OpenType objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffobjs.c + * + * OpenType objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -37,7 +37,6 @@ #include "cffobjs.h" #include "cffload.h" #include "cffcmap.h" -#include "cffpic.h" #include "cfferrs.h" @@ -45,21 +44,21 @@ #include FT_SERVICE_CFF_TABLE_LOAD_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffobjs +#define FT_COMPONENT cffobjs - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ static PSH_Globals_Funcs @@ -341,11 +340,11 @@ } - /*************************************************************************/ - /* */ - /* SLOT FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SLOT FUNCTIONS + * + */ FT_LOCAL_DEF( void ) cff_slot_done( FT_GlyphSlot slot ) @@ -383,11 +382,11 @@ } - /*************************************************************************/ - /* */ - /* FACE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * FACE FUNCTIONS + * + */ static FT_String* cff_strcpy( FT_Memory memory, @@ -645,14 +644,14 @@ dict = &cff->top_font.font_dict; - /* we need the `PSNames' module for CFF and CEF formats */ + /* we need the `psnames' module for CFF and CEF formats */ /* which aren't CID-keyed */ if ( dict->cid_registry == 0xFFFFU && !psnames ) { FT_ERROR(( "cff_face_init:" " cannot open CFF & CEF fonts\n" " " - " without the `PSNames' module\n" )); + " without the `psnames' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } @@ -963,12 +962,12 @@ cffface->style_name = style_name; else /* assume "Regular" style if we don't know better */ - cffface->style_name = cff_strcpy( memory, (char *)"Regular" ); + cffface->style_name = cff_strcpy( memory, "Regular" ); - /*******************************************************************/ - /* */ - /* Compute face flags. */ - /* */ + /******************************************************************** + * + * Compute face flags. + */ flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ FT_FACE_FLAG_HINTER; /* has native hinter */ @@ -989,10 +988,10 @@ cffface->face_flags |= flags; - /*******************************************************************/ - /* */ - /* Compute style flags. */ - /* */ + /******************************************************************** + * + * Compute style flags. + */ flags = 0; if ( dict->italic_angle ) @@ -1028,10 +1027,10 @@ if ( dict->cid_registry != 0xFFFFU && pure_cff ) cffface->face_flags |= FT_FACE_FLAG_CID_KEYED; - /*******************************************************************/ - /* */ - /* Compute char maps. */ - /* */ + /******************************************************************** + * + * Compute char maps. + */ /* Try to synthesize a Unicode charmap if there is none available */ /* already. If an OpenType font contains a Unicode "cmap", we */ @@ -1070,10 +1069,11 @@ nn = (FT_UInt)cffface->num_charmaps; - error = FT_CMap_New( &CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, + error = FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -1094,19 +1094,19 @@ { cmaprec.encoding_id = TT_ADOBE_ID_STANDARD; cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD; - clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; + clazz = &cff_cmap_encoding_class_rec; } else if ( encoding->offset == 1 ) { cmaprec.encoding_id = TT_ADOBE_ID_EXPERT; cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT; - clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; + clazz = &cff_cmap_encoding_class_rec; } else { cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM; cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM; - clazz = &CFF_CMAP_ENCODING_CLASS_REC_GET; + clazz = &cff_cmap_encoding_class_rec; } error = FT_CMap_New( clazz, NULL, &cmaprec, NULL ); diff --git a/src/3rdparty/freetype/src/cff/cffobjs.h b/src/3rdparty/freetype/src/cff/cffobjs.h index 616a25b3b5..03bc78a67f 100644 --- a/src/3rdparty/freetype/src/cff/cffobjs.h +++ b/src/3rdparty/freetype/src/cff/cffobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffobjs.h */ -/* */ -/* OpenType objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffobjs.h + * + * OpenType objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFOBJS_H_ @@ -51,10 +51,10 @@ FT_BEGIN_HEADER cff_slot_init( FT_GlyphSlot slot ); - /*************************************************************************/ - /* */ - /* Face functions */ - /* */ + /************************************************************************** + * + * Face functions + */ FT_LOCAL( FT_Error ) cff_face_init( FT_Stream stream, FT_Face face, /* CFF_Face */ @@ -66,10 +66,10 @@ FT_BEGIN_HEADER cff_face_done( FT_Face face ); /* CFF_Face */ - /*************************************************************************/ - /* */ - /* Driver functions */ - /* */ + /************************************************************************** + * + * Driver functions + */ FT_LOCAL( FT_Error ) cff_driver_init( FT_Module module ); /* PS_Driver */ diff --git a/src/3rdparty/freetype/src/cff/cffparse.c b/src/3rdparty/freetype/src/cff/cffparse.c index b9611cf548..008752c3ae 100644 --- a/src/3rdparty/freetype/src/cff/cffparse.c +++ b/src/3rdparty/freetype/src/cff/cffparse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffparse.c */ -/* */ -/* CFF token stream parser (body) */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffparse.c + * + * CFF token stream parser (body) + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -22,20 +22,20 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_CALC_H #include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_LIST_H #include "cfferrs.h" -#include "cffpic.h" #include "cffload.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffparse +#define FT_COMPONENT cffparse FT_LOCAL_DEF( FT_Error ) @@ -77,6 +77,23 @@ } +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + static void + finalize_t2_strings( FT_Memory memory, + void* data, + void* user ) + { + CFF_T2_String t2 = (CFF_T2_String)data; + + + FT_UNUSED( user ); + + memory->free( memory, t2->start ); + memory->free( memory, data ); + } +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + + FT_LOCAL_DEF( void ) cff_parser_done( CFF_Parser parser ) { @@ -84,13 +101,65 @@ FT_FREE( parser->stack ); + +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_List_Finalize( &parser->t2_strings, + finalize_t2_strings, + memory, + NULL ); +#endif + } + + + /* Assuming `first >= last'. */ + + static FT_Error + cff_parser_within_limits( CFF_Parser parser, + FT_Byte* first, + FT_Byte* last ) + { +#ifndef CFF_CONFIG_OPTION_OLD_ENGINE + + /* Fast path for regular FreeType builds with the "new" engine; */ + /* `first >= parser->start' can be assumed. */ + + FT_UNUSED( first ); + + return last < parser->limit ? FT_Err_Ok : FT_THROW( Invalid_Argument ); + +#else /* CFF_CONFIG_OPTION_OLD_ENGINE */ + + FT_ListNode node; + + + if ( first >= parser->start && + last < parser->limit ) + return FT_Err_Ok; + + node = parser->t2_strings.head; + + while ( node ) + { + CFF_T2_String t2 = (CFF_T2_String)node->data; + + + if ( first >= t2->start && + last < t2->limit ) + return FT_Err_Ok; + + node = node->next; + } + + return FT_THROW( Invalid_Argument ); + +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ } /* read an integer */ static FT_Long - cff_parse_integer( FT_Byte* start, - FT_Byte* limit ) + cff_parse_integer( CFF_Parser parser, + FT_Byte* start ) { FT_Byte* p = start; FT_Int v = *p++; @@ -99,14 +168,14 @@ if ( v == 28 ) { - if ( p + 2 > limit ) + if ( cff_parser_within_limits( parser, p, p + 1 ) ) goto Bad; val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] ); } else if ( v == 29 ) { - if ( p + 4 > limit ) + if ( cff_parser_within_limits( parser, p, p + 3 ) ) goto Bad; val = (FT_Long)( ( (FT_ULong)p[0] << 24 ) | @@ -120,14 +189,14 @@ } else if ( v < 251 ) { - if ( p + 1 > limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; val = ( v - 247 ) * 256 + p[0] + 108; } else { - if ( p + 1 > limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; val = -( v - 251 ) * 256 - p[0] - 108; @@ -176,10 +245,10 @@ /* read a real */ static FT_Fixed - cff_parse_real( FT_Byte* start, - FT_Byte* limit, - FT_Long power_ten, - FT_Long* scaling ) + cff_parse_real( CFF_Parser parser, + FT_Byte* start, + FT_Long power_ten, + FT_Long* scaling ) { FT_Byte* p = start; FT_Int nib; @@ -214,7 +283,7 @@ p++; /* Make sure we don't read past the end. */ - if ( p >= limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; } @@ -251,7 +320,7 @@ p++; /* Make sure we don't read past the end. */ - if ( p >= limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; } @@ -290,7 +359,7 @@ p++; /* Make sure we don't read past the end. */ - if ( p >= limit ) + if ( cff_parser_within_limits( parser, p, p ) ) goto Bad; } @@ -457,7 +526,7 @@ if ( **d == 30 ) { /* binary-coded decimal is truncated to integer */ - return cff_parse_real( *d, parser->limit, 0, NULL ) >> 16; + return cff_parse_real( parser, *d, 0, NULL ) >> 16; } else if ( **d == 255 ) @@ -483,7 +552,7 @@ } else - return cff_parse_integer( *d, parser->limit ); + return cff_parse_integer( parser, *d ); } @@ -494,10 +563,10 @@ FT_Long scaling ) { if ( **d == 30 ) - return cff_parse_real( *d, parser->limit, scaling, NULL ); + return cff_parse_real( parser, *d, scaling, NULL ); else { - FT_Long val = cff_parse_integer( *d, parser->limit ); + FT_Long val = cff_parse_integer( parser, *d ); if ( scaling ) @@ -562,14 +631,14 @@ FT_ASSERT( scaling ); if ( **d == 30 ) - return cff_parse_real( *d, parser->limit, 0, scaling ); + return cff_parse_real( parser, *d, 0, scaling ); else { FT_Long number; FT_Int integer_length; - number = cff_parse_integer( d[0], d[1] ); + number = cff_parse_integer( parser, d[0] ); if ( number > 0x7FFFL ) { @@ -605,7 +674,6 @@ FT_Vector* offset = &dict->font_offset; FT_ULong* upm = &dict->units_per_em; FT_Byte** data = parser->stack; - FT_Error error = FT_ERR( Stack_Underflow ); if ( parser->top >= parser->stack + 6 ) @@ -617,8 +685,6 @@ int i; - error = FT_Err_Ok; - dict->has_font_matrix = TRUE; /* We expect a well-formed font matrix, this is, the matrix elements */ @@ -647,22 +713,11 @@ ( max_scaling - min_scaling ) < 0 || ( max_scaling - min_scaling ) > 9 ) { - /* Return default matrix in case of unlikely values. */ - FT_TRACE1(( "cff_parse_font_matrix:" " strange scaling values (minimum %d, maximum %d),\n" " " " using default matrix\n", min_scaling, max_scaling )); - - matrix->xx = 0x10000L; - matrix->yx = 0; - matrix->xy = 0; - matrix->yy = 0x10000L; - offset->x = 0; - offset->y = 0; - *upm = 1; - - goto Exit; + goto Unlikely; } for ( i = 0; i < 6; i++ ) @@ -709,10 +764,31 @@ (double)matrix->yy / *upm / 65536, (double)offset->x / *upm / 65536, (double)offset->y / *upm / 65536 )); + + if ( !FT_Matrix_Check( matrix ) ) + { + FT_TRACE1(( "cff_parse_font_matrix:" + " degenerate values, using default matrix\n" )); + goto Unlikely; + } + + return FT_Err_Ok; } + else + return FT_THROW( Stack_Underflow ); - Exit: - return error; + Unlikely: + /* Return default matrix in case of unlikely values. */ + + matrix->xx = 0x10000L; + matrix->yx = 0; + matrix->xy = 0; + matrix->yy = 0x10000L; + offset->x = 0; + offset->y = 0; + *upm = 1; + + return FT_Err_Ok; } @@ -802,7 +878,7 @@ #ifdef FT_DEBUG_LEVEL_TRACE /* beautify tracing message */ - if ( ft_trace_levels[FT_COMPONENT] < 4 ) + if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] < 4 ) FT_TRACE1(( "Multiple Master CFFs not supported yet," " handling first master design only\n" )); else @@ -1003,9 +1079,6 @@ CFF_FIELD( code, name, id, cff_kind_bool ) -#ifndef FT_CONFIG_OPTION_PIC - - #undef CFF_FIELD #undef CFF_FIELD_DELTA @@ -1118,199 +1191,20 @@ #endif /* FT_DEBUG_LEVEL_TRACE */ -#else /* FT_CONFIG_OPTION_PIC */ - - - void - FT_Destroy_Class_cff_field_handlers( FT_Library library, - CFF_Field_Handler* clazz ) - { - FT_Memory memory = library->memory; - - - if ( clazz ) - FT_FREE( clazz ); - } - - - FT_Error - FT_Create_Class_cff_field_handlers( FT_Library library, - CFF_Field_Handler** output_class ) - { - CFF_Field_Handler* clazz = NULL; - FT_Error error; - FT_Memory memory = library->memory; - - int i = 0; - - -#undef CFF_FIELD -#define CFF_FIELD( code, name, id, kind ) i++; -#undef CFF_FIELD_DELTA -#define CFF_FIELD_DELTA( code, name, max, id ) i++; -#undef CFF_FIELD_CALLBACK -#define CFF_FIELD_CALLBACK( code, name, id ) i++; -#undef CFF_FIELD_BLEND -#define CFF_FIELD_BLEND( code, id ) i++; - -#include "cfftoken.h" - - i++; /* { 0, 0, 0, 0, 0, 0, 0 } */ - - if ( FT_ALLOC( clazz, sizeof ( CFF_Field_Handler ) * i ) ) - return error; - - i = 0; - - -#ifndef FT_DEBUG_LEVEL_TRACE - - -#undef CFF_FIELD_CALLBACK -#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \ - clazz[i].kind = cff_kind_callback; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_ ## name_; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - i++; - -#undef CFF_FIELD -#define CFF_FIELD( code_, name_, id_, kind_ ) \ - clazz[i].kind = kind_; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - i++; \ - -#undef CFF_FIELD_DELTA -#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \ - clazz[i].kind = cff_kind_delta; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = max_; \ - clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \ - i++; - -#undef CFF_FIELD_BLEND -#define CFF_FIELD_BLEND( code_, id_ ) \ - clazz[i].kind = cff_kind_blend; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_blend; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - i++; - -#include "cfftoken.h" - - clazz[i].kind = 0; - clazz[i].code = 0; - clazz[i].offset = 0; - clazz[i].size = 0; - clazz[i].reader = 0; - clazz[i].array_max = 0; - clazz[i].count_offset = 0; - - -#else /* FT_DEBUG_LEVEL_TRACE */ - - -#undef CFF_FIELD_CALLBACK -#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \ - clazz[i].kind = cff_kind_callback; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_ ## name_; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - clazz[i].id = id_; \ - i++; - -#undef CFF_FIELD -#define CFF_FIELD( code_, name_, id_, kind_ ) \ - clazz[i].kind = kind_; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - clazz[i].id = id_; \ - i++; \ - -#undef CFF_FIELD_DELTA -#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \ - clazz[i].kind = cff_kind_delta; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = FT_FIELD_OFFSET( name_ ); \ - clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \ - clazz[i].reader = 0; \ - clazz[i].array_max = max_; \ - clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \ - clazz[i].id = id_; \ - i++; - -#undef CFF_FIELD_BLEND -#define CFF_FIELD_BLEND( code_, id_ ) \ - clazz[i].kind = cff_kind_blend; \ - clazz[i].code = code_ | CFFCODE; \ - clazz[i].offset = 0; \ - clazz[i].size = 0; \ - clazz[i].reader = cff_parse_blend; \ - clazz[i].array_max = 0; \ - clazz[i].count_offset = 0; \ - clazz[i].id = id_; \ - i++; - -#include "cfftoken.h" - - clazz[i].kind = 0; - clazz[i].code = 0; - clazz[i].offset = 0; - clazz[i].size = 0; - clazz[i].reader = 0; - clazz[i].array_max = 0; - clazz[i].count_offset = 0; - clazz[i].id = 0; - - -#endif /* FT_DEBUG_LEVEL_TRACE */ - - - *output_class = clazz; - - return FT_Err_Ok; - } - - -#endif /* FT_CONFIG_OPTION_PIC */ - - FT_LOCAL_DEF( FT_Error ) cff_parser_run( CFF_Parser parser, FT_Byte* start, FT_Byte* limit ) { + FT_Byte* p = start; + FT_Error error = FT_Err_Ok; + #ifdef CFF_CONFIG_OPTION_OLD_ENGINE PSAux_Service psaux; -#endif - FT_Byte* p = start; - FT_Error error = FT_Err_Ok; FT_Library library = parser->library; - - FT_UNUSED( library ); - + FT_Memory memory = library->memory; +#endif parser->top = parser->stack; parser->start = start; @@ -1321,6 +1215,7 @@ { FT_UInt v = *p; + /* Opcode 31 is legacy MM T2 operator, not a number. */ /* Opcode 255 is reserved and should not appear in fonts; */ /* it is used internally for CFF2 blends. */ @@ -1369,8 +1264,11 @@ FT_Byte* charstring_base; FT_ULong charstring_len; - FT_Fixed* stack; - FT_Byte* q; + FT_Fixed* stack; + FT_ListNode node; + CFF_T2_String t2; + size_t t2_size; + FT_Byte* q; charstring_base = ++p; @@ -1405,17 +1303,39 @@ error = psaux->cff_decoder_funcs->parse_charstrings_old( &decoder, charstring_base, charstring_len, 1 ); + if ( error ) + goto Exit; /* Now copy the stack data in the temporary decoder object, */ /* converting it back to charstring number representations */ /* (this is ugly, I know). */ - /* */ - /* We overwrite the original top DICT charstring under the */ - /* assumption that the charstring representation of the result */ - /* of `cff_decoder_parse_charstrings' is shorter, which should */ - /* be always true. */ - q = charstring_base - 1; + node = (FT_ListNode)memory->alloc( memory, + sizeof ( FT_ListNodeRec ) ); + if ( !node ) + goto Out_Of_Memory_Error; + + FT_List_Add( &parser->t2_strings, node ); + + t2 = (CFF_T2_String)memory->alloc( memory, + sizeof ( CFF_T2_StringRec ) ); + if ( !t2 ) + goto Out_Of_Memory_Error; + + node->data = t2; + + /* `5' is the conservative upper bound of required bytes per stack */ + /* element. */ + + t2_size = 5 * ( decoder.top - decoder.stack ); + + q = (FT_Byte*)memory->alloc( memory, t2_size ); + if ( !q ) + goto Out_Of_Memory_Error; + + t2->start = q; + t2->limit = q + t2_size; + stack = decoder.stack; while ( stack < decoder.top ) @@ -1431,7 +1351,7 @@ if ( *stack < 0 ) { - num = (FT_ULong)-*stack; + num = (FT_ULong)NEG_LONG( *stack ); neg = 1; } else @@ -1523,7 +1443,7 @@ } code = code | parser->object_code; - for ( field = CFF_FIELD_HANDLERS_GET; field->kind; field++ ) + for ( field = cff_field_handlers; field->kind; field++ ) { if ( field->code == (FT_Int)code ) { @@ -1672,11 +1592,17 @@ parser->top = parser->stack; } p++; - } + } /* while ( p < limit ) */ Exit: return error; +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + Out_Of_Memory_Error: + error = FT_THROW( Out_Of_Memory ); + goto Exit; +#endif + Stack_Overflow: error = FT_THROW( Invalid_Argument ); goto Exit; diff --git a/src/3rdparty/freetype/src/cff/cffparse.h b/src/3rdparty/freetype/src/cff/cffparse.h index 8a8caeca44..4e74709a2d 100644 --- a/src/3rdparty/freetype/src/cff/cffparse.h +++ b/src/3rdparty/freetype/src/cff/cffparse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffparse.h */ -/* */ -/* CFF token stream parser (specification) */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffparse.h + * + * CFF token stream parser (specification) + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFPARSE_H_ @@ -33,11 +33,11 @@ FT_BEGIN_HEADER #define CFF_MAX_STACK_DEPTH 96 /* - * There are plans to remove the `maxstack' operator in a forthcoming - * revision of the CFF2 specification, increasing the (then static) stack - * size to 513. By making the default stack size equal to the maximum - * stack size, the operator is essentially disabled, which has the - * desired effect in FreeType. + * There are plans to remove the `maxstack' operator in a forthcoming + * revision of the CFF2 specification, increasing the (then static) stack + * size to 513. By making the default stack size equal to the maximum + * stack size, the operator is essentially disabled, which has the + * desired effect in FreeType. */ #define CFF2_MAX_STACK 513 #define CFF2_DEFAULT_STACK 513 @@ -60,6 +60,10 @@ FT_BEGIN_HEADER FT_Byte** top; FT_UInt stackSize; /* allocated size */ +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + FT_ListRec t2_strings; +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + FT_UInt object_code; void* object; @@ -130,6 +134,15 @@ FT_BEGIN_HEADER FT_END_HEADER +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + typedef struct CFF_T2_String_ + { + FT_Byte* start; + FT_Byte* limit; + + } CFF_T2_StringRec, *CFF_T2_String; +#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ + #endif /* CFFPARSE_H_ */ diff --git a/src/3rdparty/freetype/src/cff/cfftoken.h b/src/3rdparty/freetype/src/cff/cfftoken.h index fec1ca20bd..063a7b3be0 100644 --- a/src/3rdparty/freetype/src/cff/cfftoken.h +++ b/src/3rdparty/freetype/src/cff/cfftoken.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cfftoken.h */ -/* */ -/* CFF token definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cfftoken.h + * + * CFF token definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #undef FT_STRUCTURE diff --git a/src/3rdparty/freetype/src/cff/module.mk b/src/3rdparty/freetype/src/cff/module.mk index 8013d5dcab..8c610959d3 100644 --- a/src/3rdparty/freetype/src/cff/module.mk +++ b/src/3rdparty/freetype/src/cff/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/cff/rules.mk b/src/3rdparty/freetype/src/cff/rules.mk index bce672927e..6e2dc476ef 100644 --- a/src/3rdparty/freetype/src/cff/rules.mk +++ b/src/3rdparty/freetype/src/cff/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -31,8 +31,7 @@ CFF_DRV_SRC := $(CFF_DIR)/cffcmap.c \ $(CFF_DIR)/cffgload.c \ $(CFF_DIR)/cffload.c \ $(CFF_DIR)/cffobjs.c \ - $(CFF_DIR)/cffparse.c \ - $(CFF_DIR)/cffpic.c + $(CFF_DIR)/cffparse.c # CFF driver headers diff --git a/src/3rdparty/freetype/src/cid/Jamfile b/src/3rdparty/freetype/src/cid/Jamfile index 1c232fda3f..1cfb702574 100644 --- a/src/3rdparty/freetype/src/cid/Jamfile +++ b/src/3rdparty/freetype/src/cid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cid Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/cid/ciderrs.h b/src/3rdparty/freetype/src/cid/ciderrs.h index a5a86e3fc6..be80bed3be 100644 --- a/src/3rdparty/freetype/src/cid/ciderrs.h +++ b/src/3rdparty/freetype/src/cid/ciderrs.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* ciderrs.h */ -/* */ -/* CID error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the CID error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ciderrs.h + * + * CID error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the CID error enumeration constants. + * + */ #ifndef CIDERRS_H_ #define CIDERRS_H_ diff --git a/src/3rdparty/freetype/src/cid/cidgload.c b/src/3rdparty/freetype/src/cid/cidgload.c index d14f9a2cc9..f59f2880f0 100644 --- a/src/3rdparty/freetype/src/cid/cidgload.c +++ b/src/3rdparty/freetype/src/cid/cidgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidgload.c */ -/* */ -/* CID-keyed Type1 Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidgload.c + * + * CID-keyed Type1 Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +31,14 @@ #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidgload +#define FT_COMPONENT cidgload FT_CALLBACK_DEF( FT_Error ) @@ -393,8 +393,7 @@ must_finish_decoder = TRUE; /* set up the decoder */ - decoder.builder.no_recurse = FT_BOOL( - ( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) ); + decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE ); error = cid_load_glyph( &decoder, glyph_index ); if ( error ) diff --git a/src/3rdparty/freetype/src/cid/cidgload.h b/src/3rdparty/freetype/src/cid/cidgload.h index 4811852ae4..37eba7ca7b 100644 --- a/src/3rdparty/freetype/src/cid/cidgload.h +++ b/src/3rdparty/freetype/src/cid/cidgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidgload.h */ -/* */ -/* OpenType Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidgload.h + * + * OpenType Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDGLOAD_H_ diff --git a/src/3rdparty/freetype/src/cid/cidload.c b/src/3rdparty/freetype/src/cid/cidload.c index 27cd09b3c3..fce3e37da7 100644 --- a/src/3rdparty/freetype/src/cid/cidload.c +++ b/src/3rdparty/freetype/src/cid/cidload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidload.c */ -/* */ -/* CID-keyed Type1 font loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidload.c + * + * CID-keyed Type1 font loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,20 +21,21 @@ #include FT_CONFIG_CONFIG_H #include FT_MULTIPLE_MASTERS_H #include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include "cidload.h" #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidload +#define FT_COMPONENT cidload /* read a single offset */ @@ -81,6 +82,8 @@ /* if the keyword has a dedicated callback, call it */ if ( keyword->type == T1_FIELD_TYPE_CALLBACK ) { + FT_TRACE4(( " %s", keyword->ident )); + keyword->reader( (FT_Face)face, parser ); error = parser->root.error; goto Exit; @@ -131,6 +134,8 @@ } } + FT_TRACE4(( " %s", keyword->ident )); + dummy_object = object; /* now, load the keyword data in the object's field(s) */ @@ -141,12 +146,15 @@ else error = cid_parser_load_field( &loader->parser, keyword, &dummy_object ); + + FT_TRACE4(( "\n" )); + Exit: return error; } - FT_CALLBACK_DEF( FT_Error ) + FT_CALLBACK_DEF( void ) cid_parse_font_matrix( CID_Face face, CID_Parser* parser ) { @@ -171,14 +179,25 @@ result = cid_parser_to_fixed_array( parser, 6, temp, 3 ); if ( result < 6 ) - return FT_THROW( Invalid_File_Format ); + { + FT_ERROR(( "cid_parse_font_matrix: not enough matrix elements\n" )); + goto Exit; + } + + FT_TRACE4(( " [%f %f %f %f %f %f]\n", + (double)temp[0] / 65536 / 1000, + (double)temp[1] / 65536 / 1000, + (double)temp[2] / 65536 / 1000, + (double)temp[3] / 65536 / 1000, + (double)temp[4] / 65536 / 1000, + (double)temp[5] / 65536 / 1000 )); temp_scale = FT_ABS( temp[3] ); if ( temp_scale == 0 ) { FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" )); - return FT_THROW( Invalid_File_Format ); + goto Exit; } /* atypical case */ @@ -200,16 +219,24 @@ matrix->xy = temp[2]; matrix->yy = temp[3]; + if ( !FT_Matrix_Check( matrix ) ) + { + FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" )); + parser->root.error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + /* note that the font offsets are expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; } - return FT_Err_Ok; + Exit: + return; } - FT_CALLBACK_DEF( FT_Error ) + FT_CALLBACK_DEF( void ) parse_fd_array( CID_Face face, CID_Parser* parser ) { @@ -224,10 +251,11 @@ if ( num_dicts < 0 ) { FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" )); - error = FT_THROW( Invalid_File_Format ); goto Exit; } + FT_TRACE4(( " %d\n", num_dicts )); + /* * A single entry in the FDArray must (at least) contain the following * structure elements. @@ -263,27 +291,31 @@ cid->num_dicts = num_dicts; - /* don't forget to set a few defaults */ + /* set some default values (the same as for Type 1 fonts) */ for ( n = 0; n < cid->num_dicts; n++ ) { CID_FaceDict dict = cid->font_dicts + n; - /* default value for lenIV */ - dict->private_dict.lenIV = 4; + dict->private_dict.blue_shift = 7; + dict->private_dict.blue_fuzz = 1; + dict->private_dict.lenIV = 4; + dict->private_dict.expansion_factor = (FT_Fixed)( 0.06 * 0x10000L ); + dict->private_dict.blue_scale = (FT_Fixed)( + 0.039625 * 0x10000L * 1000 ); } } Exit: - return error; + return; } - /* by mistake, `expansion_factor' appears both in PS_PrivateRec */ + /* By mistake, `expansion_factor' appears both in PS_PrivateRec */ /* and CID_FaceDictRec (both are public header files and can't */ - /* changed); we simply copy the value */ + /* changed). We simply copy the value. */ - FT_CALLBACK_DEF( FT_Error ) + FT_CALLBACK_DEF( void ) parse_expansion_factor( CID_Face face, CID_Parser* parser ) { @@ -296,9 +328,43 @@ dict->expansion_factor = cid_parser_to_fixed( parser, 0 ); dict->private_dict.expansion_factor = dict->expansion_factor; + + FT_TRACE4(( "%d\n", dict->expansion_factor )); + } + + return; + } + + + /* By mistake, `CID_FaceDictRec' doesn't contain a field for the */ + /* `FontName' keyword. FreeType doesn't need it, but it is nice */ + /* to catch it for producing better trace output. */ + + FT_CALLBACK_DEF( void ) + parse_font_name( CID_Face face, + CID_Parser* parser ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts ) + { + T1_TokenRec token; + FT_UInt len; + + + cid_parser_to_token( parser, &token ); + + len = (FT_UInt)( token.limit - token.start ); + if ( len ) + FT_TRACE4(( " %.*s\n", len, token.start )); + else + FT_TRACE4(( " <no value>\n" )); } +#else + FT_UNUSED( face ); + FT_UNUSED( parser ); +#endif - return FT_Err_Ok; + return; } @@ -311,6 +377,7 @@ T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 ) T1_FIELD_CALLBACK( "FontMatrix", cid_parse_font_matrix, 0 ) T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 ) + T1_FIELD_CALLBACK( "FontName", parse_font_name, 0 ) { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 } }; @@ -356,7 +423,16 @@ /* if /FDArray was found, then cid->num_dicts is > 0, and */ /* we can start increasing parser->num_dict */ if ( face->cid.num_dicts > 0 ) + { parser->num_dict++; + +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " FontDict %d", parser->num_dict )); + if ( parser->num_dict > face->cid.num_dicts ) + FT_TRACE4(( " (ignored)" )); + FT_TRACE4(( "\n" )); +#endif + } } } @@ -757,7 +833,7 @@ if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 ) { - FT_ERROR(( "cid_parse_dict:" + FT_ERROR(( "cid_face_open:" " Invalid `FDBytes' or `GDBytes' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; @@ -766,7 +842,7 @@ /* allow at most 32bit offsets */ if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 ) { - FT_ERROR(( "cid_parse_dict:" + FT_ERROR(( "cid_face_open:" " Values of `FDBytes' or `GDBytes' larger than 4\n" " " " are not supported\n" )); @@ -782,17 +858,36 @@ CID_FaceDict dict = cid->font_dicts + n; + /* the upper limits are ad-hoc values */ + if ( dict->private_dict.blue_shift > 1000 || + dict->private_dict.blue_shift < 0 ) + { + FT_TRACE2(( "cid_face_open:" + " setting unlikely BlueShift value %d to default (7)\n", + dict->private_dict.blue_shift )); + dict->private_dict.blue_shift = 7; + } + + if ( dict->private_dict.blue_fuzz > 1000 || + dict->private_dict.blue_fuzz < 0 ) + { + FT_TRACE2(( "cid_face_open:" + " setting unlikely BlueFuzz value %d to default (1)\n", + dict->private_dict.blue_fuzz )); + dict->private_dict.blue_fuzz = 1; + } + if ( dict->sd_bytes < 0 || ( dict->num_subrs && dict->sd_bytes < 1 ) ) { - FT_ERROR(( "cid_parse_dict: Invalid `SDBytes' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `SDBytes' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } if ( dict->sd_bytes > 4 ) { - FT_ERROR(( "cid_parse_dict:" + FT_ERROR(( "cid_face_open:" " Values of `SDBytes' larger than 4" " are not supported\n" )); error = FT_THROW( Invalid_File_Format ); @@ -801,7 +896,7 @@ if ( dict->subrmap_offset > binary_length ) { - FT_ERROR(( "cid_parse_dict: Invalid `SubrMapOffset' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `SubrMapOffset' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -812,7 +907,7 @@ dict->num_subrs > ( binary_length - dict->subrmap_offset ) / (FT_UInt)dict->sd_bytes ) ) { - FT_ERROR(( "cid_parse_dict: Invalid `SubrCount' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `SubrCount' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -820,7 +915,7 @@ if ( cid->cidmap_offset > binary_length ) { - FT_ERROR(( "cid_parse_dict: Invalid `CIDMapOffset' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `CIDMapOffset' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } @@ -829,7 +924,7 @@ cid->cid_count > ( binary_length - cid->cidmap_offset ) / entry_len ) { - FT_ERROR(( "cid_parse_dict: Invalid `CIDCount' value\n" )); + FT_ERROR(( "cid_face_open: Invalid `CIDCount' value\n" )); error = FT_THROW( Invalid_File_Format ); goto Exit; } diff --git a/src/3rdparty/freetype/src/cid/cidload.h b/src/3rdparty/freetype/src/cid/cidload.h index 3f8bd08620..fb9d46216d 100644 --- a/src/3rdparty/freetype/src/cid/cidload.h +++ b/src/3rdparty/freetype/src/cid/cidload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidload.h */ -/* */ -/* CID-keyed Type1 font loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidload.h + * + * CID-keyed Type1 font loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDLOAD_H_ diff --git a/src/3rdparty/freetype/src/cid/cidobjs.c b/src/3rdparty/freetype/src/cid/cidobjs.c index 77afe1c875..4e9728719b 100644 --- a/src/3rdparty/freetype/src/cid/cidobjs.c +++ b/src/3rdparty/freetype/src/cid/cidobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidobjs.c */ -/* */ -/* CID objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidobjs.c + * + * CID objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,21 +31,21 @@ #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidobjs +#define FT_COMPONENT cidobjs - /*************************************************************************/ - /* */ - /* SLOT FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SLOT FUNCTIONS + * + */ FT_LOCAL_DEF( void ) cid_slot_done( FT_GlyphSlot slot ) @@ -85,11 +85,11 @@ } - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ static PSH_Globals_Funcs @@ -174,23 +174,24 @@ } - /*************************************************************************/ - /* */ - /* FACE FUNCTIONS */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_face_done */ - /* */ - /* <Description> */ - /* Finalizes a given face object. */ - /* */ - /* <Input> */ - /* face :: A pointer to the face object to destroy. */ - /* */ + /************************************************************************** + * + * FACE FUNCTIONS + * + */ + + /************************************************************************** + * + * @Function: + * cid_face_done + * + * @Description: + * Finalizes a given face object. + * + * @Input: + * face :: + * A pointer to the face object to destroy. + */ FT_LOCAL_DEF( void ) cid_face_done( FT_Face cidface ) /* CID_Face */ { @@ -252,29 +253,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_face_init */ - /* */ - /* <Description> */ - /* Initializes a given CID face object. */ - /* */ - /* <Input> */ - /* stream :: The source font stream. */ - /* */ - /* face_index :: The index of the font face in the resource. */ - /* */ - /* num_params :: Number of additional generic parameters. Ignored. */ - /* */ - /* params :: Additional generic parameters. Ignored. */ - /* */ - /* <InOut> */ - /* face :: The newly built face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cid_face_init + * + * @Description: + * Initializes a given CID face object. + * + * @Input: + * stream :: + * The source font stream. + * + * face_index :: + * The index of the font face in the resource. + * + * num_params :: + * Number of additional generic parameters. Ignored. + * + * params :: + * Additional generic parameters. Ignored. + * + * @InOut: + * face :: + * The newly built face object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) cid_face_init( FT_Stream stream, FT_Face cidface, /* CID_Face */ @@ -449,20 +455,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_driver_init */ - /* */ - /* <Description> */ - /* Initializes a given CID driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cid_driver_init + * + * @Description: + * Initializes a given CID driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) cid_driver_init( FT_Module module ) { @@ -505,17 +512,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cid_driver_done */ - /* */ - /* <Description> */ - /* Finalizes a given CID driver. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target CID driver. */ - /* */ + /************************************************************************** + * + * @Function: + * cid_driver_done + * + * @Description: + * Finalizes a given CID driver. + * + * @Input: + * driver :: + * A handle to the target CID driver. + */ FT_LOCAL_DEF( void ) cid_driver_done( FT_Module driver ) { diff --git a/src/3rdparty/freetype/src/cid/cidobjs.h b/src/3rdparty/freetype/src/cid/cidobjs.h index 0221f017dd..89c9aa74ab 100644 --- a/src/3rdparty/freetype/src/cid/cidobjs.h +++ b/src/3rdparty/freetype/src/cid/cidobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidobjs.h */ -/* */ -/* CID objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidobjs.h + * + * CID objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDOBJS_H_ @@ -34,60 +34,60 @@ FT_BEGIN_HEADER typedef struct CID_Glyph_Hints_ CID_Glyph_Hints; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_Driver */ - /* */ - /* <Description> */ - /* A handle to a Type 1 driver object. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_Driver + * + * @Description: + * A handle to a Type 1 driver object. + */ typedef struct CID_DriverRec_* CID_Driver; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_Size */ - /* */ - /* <Description> */ - /* A handle to a Type 1 size object. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_Size + * + * @Description: + * A handle to a Type 1 size object. + */ typedef struct CID_SizeRec_* CID_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a Type 1 glyph slot object. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_GlyphSlot + * + * @Description: + * A handle to a Type 1 glyph slot object. + */ typedef struct CID_GlyphSlotRec_* CID_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* CID_CharMap */ - /* */ - /* <Description> */ - /* A handle to a Type 1 character mapping object. */ - /* */ - /* <Note> */ - /* The Type 1 format doesn't use a charmap but an encoding table. */ - /* The driver is responsible for making up charmap objects */ - /* corresponding to these tables. */ - /* */ + /************************************************************************** + * + * @Type: + * CID_CharMap + * + * @Description: + * A handle to a Type 1 character mapping object. + * + * @Note: + * The Type 1 format doesn't use a charmap but an encoding table. + * The driver is responsible for making up charmap objects + * corresponding to these tables. + */ typedef struct CID_CharMapRec_* CID_CharMap; - /*************************************************************************/ - /* */ - /* HERE BEGINS THE TYPE 1 SPECIFIC STUFF */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * HERE BEGINS THE TYPE 1 SPECIFIC STUFF + * + */ typedef struct CID_SizeRec_ diff --git a/src/3rdparty/freetype/src/cid/cidparse.c b/src/3rdparty/freetype/src/cid/cidparse.c index b1c7f3cb2c..1be46ec328 100644 --- a/src/3rdparty/freetype/src/cid/cidparse.c +++ b/src/3rdparty/freetype/src/cid/cidparse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidparse.c */ -/* */ -/* CID-keyed Type1 parser (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidparse.c + * + * CID-keyed Type1 parser (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #include "ciderrs.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cidparse +#define FT_COMPONENT cidparse /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/cid/cidparse.h b/src/3rdparty/freetype/src/cid/cidparse.h index 61602f7674..ec1f6a346d 100644 --- a/src/3rdparty/freetype/src/cid/cidparse.h +++ b/src/3rdparty/freetype/src/cid/cidparse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidparse.h */ -/* */ -/* CID-keyed Type1 parser (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidparse.h + * + * CID-keyed Type1 parser (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDPARSE_H_ @@ -29,35 +29,43 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_Parser */ - /* */ - /* <Description> */ - /* A CID_Parser is an object used to parse a Type 1 fonts very */ - /* quickly. */ - /* */ - /* <Fields> */ - /* root :: The root PS_ParserRec fields. */ - /* */ - /* stream :: The current input stream. */ - /* */ - /* postscript :: A pointer to the data to be parsed. */ - /* */ - /* postscript_len :: The length of the data to be parsed. */ - /* */ - /* data_offset :: The start position of the binary data (i.e., the */ - /* end of the data to be parsed. */ - /* */ - /* binary_length :: The length of the data after the `StartData' */ - /* command if the data format is hexadecimal. */ - /* */ - /* cid :: A structure which holds the information about */ - /* the current font. */ - /* */ - /* num_dict :: The number of font dictionaries. */ - /* */ + /************************************************************************** + * + * @Struct: + * CID_Parser + * + * @Description: + * A CID_Parser is an object used to parse a Type 1 fonts very + * quickly. + * + * @Fields: + * root :: + * The root PS_ParserRec fields. + * + * stream :: + * The current input stream. + * + * postscript :: + * A pointer to the data to be parsed. + * + * postscript_len :: + * The length of the data to be parsed. + * + * data_offset :: + * The start position of the binary data (i.e., the + * end of the data to be parsed. + * + * binary_length :: + * The length of the data after the `StartData' + * command if the data format is hexadecimal. + * + * cid :: + * A structure which holds the information about + * the current font. + * + * num_dict :: + * The number of font dictionaries. + */ typedef struct CID_Parser_ { PS_ParserRec root; @@ -86,11 +94,11 @@ FT_BEGIN_HEADER cid_parser_done( CID_Parser* parser ); - /*************************************************************************/ - /* */ - /* PARSING ROUTINES */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * PARSING ROUTINES + * + */ #define cid_parser_skip_spaces( p ) \ (p)->root.funcs.skip_spaces( &(p)->root ) diff --git a/src/3rdparty/freetype/src/cid/cidriver.c b/src/3rdparty/freetype/src/cid/cidriver.c index d9faf353ea..4d91e87529 100644 --- a/src/3rdparty/freetype/src/cid/cidriver.c +++ b/src/3rdparty/freetype/src/cid/cidriver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidriver.c */ -/* */ -/* CID driver interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidriver.c + * + * CID driver interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -34,18 +34,18 @@ #include FT_INTERNAL_POSTSCRIPT_AUX_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ciddriver +#define FT_COMPONENT ciddriver /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -69,7 +69,7 @@ /* - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -105,7 +105,7 @@ /* - * CID INFO SERVICE + * CID INFO SERVICE * */ static FT_Error @@ -173,7 +173,7 @@ /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ @@ -185,7 +185,7 @@ /* - * SERVICE LIST + * SERVICE LIST * */ diff --git a/src/3rdparty/freetype/src/cid/cidriver.h b/src/3rdparty/freetype/src/cid/cidriver.h index 59d9ded901..3402fd7e99 100644 --- a/src/3rdparty/freetype/src/cid/cidriver.h +++ b/src/3rdparty/freetype/src/cid/cidriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidriver.h */ -/* */ -/* High-level CID driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidriver.h + * + * High-level CID driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CIDRIVER_H_ @@ -26,15 +26,9 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - - FT_CALLBACK_TABLE const FT_Driver_ClassRec t1cid_driver_class; - FT_END_HEADER #endif /* CIDRIVER_H_ */ diff --git a/src/3rdparty/freetype/src/cid/cidtoken.h b/src/3rdparty/freetype/src/cid/cidtoken.h index b0e2dac6aa..f505c9e166 100644 --- a/src/3rdparty/freetype/src/cid/cidtoken.h +++ b/src/3rdparty/freetype/src/cid/cidtoken.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cidtoken.h */ -/* */ -/* CID token definitions (specification only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cidtoken.h + * + * CID token definitions (specification only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #undef FT_STRUCTURE @@ -21,17 +21,20 @@ #undef T1CODE #define T1CODE T1_FIELD_LOCATION_CID_INFO - T1_FIELD_KEY ( "CIDFontName", cid_font_name, 0 ) - T1_FIELD_FIXED ( "CIDFontVersion", cid_version, 0 ) - T1_FIELD_NUM ( "CIDFontType", cid_font_type, 0 ) - T1_FIELD_STRING( "Registry", registry, 0 ) - T1_FIELD_STRING( "Ordering", ordering, 0 ) - T1_FIELD_NUM ( "Supplement", supplement, 0 ) - T1_FIELD_NUM ( "UIDBase", uid_base, 0 ) - T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset, 0 ) - T1_FIELD_NUM ( "FDBytes", fd_bytes, 0 ) - T1_FIELD_NUM ( "GDBytes", gd_bytes, 0 ) - T1_FIELD_NUM ( "CIDCount", cid_count, 0 ) + T1_FIELD_KEY ( "CIDFontName", cid_font_name, 0 ) + T1_FIELD_FIXED ( "CIDFontVersion", cid_version, 0 ) + T1_FIELD_NUM ( "CIDFontType", cid_font_type, 0 ) + T1_FIELD_STRING ( "Registry", registry, 0 ) + T1_FIELD_STRING ( "Ordering", ordering, 0 ) + T1_FIELD_NUM ( "Supplement", supplement, 0 ) + T1_FIELD_NUM ( "UIDBase", uid_base, 0 ) + + T1_FIELD_NUM_TABLE( "XUID", xuid, 16, 0 ) + + T1_FIELD_NUM ( "CIDMapOffset", cidmap_offset, 0 ) + T1_FIELD_NUM ( "FDBytes", fd_bytes, 0 ) + T1_FIELD_NUM ( "GDBytes", gd_bytes, 0 ) + T1_FIELD_NUM ( "CIDCount", cid_count, 0 ) #undef FT_STRUCTURE diff --git a/src/3rdparty/freetype/src/cid/module.mk b/src/3rdparty/freetype/src/cid/module.mk index 9010e339a4..875c683c72 100644 --- a/src/3rdparty/freetype/src/cid/module.mk +++ b/src/3rdparty/freetype/src/cid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/cid/rules.mk b/src/3rdparty/freetype/src/cid/rules.mk index 94333bda06..2b68dd48a0 100644 --- a/src/3rdparty/freetype/src/cid/rules.mk +++ b/src/3rdparty/freetype/src/cid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/cid/type1cid.c b/src/3rdparty/freetype/src/cid/type1cid.c index 61770e3f1e..d21801cec1 100644 --- a/src/3rdparty/freetype/src/cid/type1cid.c +++ b/src/3rdparty/freetype/src/cid/type1cid.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* type1cid.c */ -/* */ -/* FreeType OpenType driver component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * type1cid.c + * + * FreeType OpenType driver component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/gxvalid/Jamfile b/src/3rdparty/freetype/src/gxvalid/Jamfile index 74f3c51ff0..a08e7a998d 100644 --- a/src/3rdparty/freetype/src/gxvalid/Jamfile +++ b/src/3rdparty/freetype/src/gxvalid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/gxvalid Jamfile # -# Copyright 2005-2018 by +# Copyright (C) 2005-2019 by # suzuki toshiya, Masatake YAMATO and Red Hat K.K. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/gxvalid/README b/src/3rdparty/freetype/src/gxvalid/README index af8128e0e7..d493587842 100644 --- a/src/3rdparty/freetype/src/gxvalid/README +++ b/src/3rdparty/freetype/src/gxvalid/README @@ -518,7 +518,7 @@ gxvalid: TrueType GX validator ------------------------------------------------------------------------ -Copyright 2004-2018 by +Copyright (C) 2004-2019 by suzuki toshiya, Masatake YAMATO, Red hat K.K., David Turner, Robert Wilhelm, and Werner Lemberg. diff --git a/src/3rdparty/freetype/src/gxvalid/gxvalid.c b/src/3rdparty/freetype/src/gxvalid/gxvalid.c index d0577a247e..462e461bf2 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvalid.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvalid.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* gxvalid.c */ -/* */ -/* FreeType validator for TrueTypeGX/AAT tables (body only). */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvalid.c + * + * FreeType validator for TrueTypeGX/AAT tables (body only). + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/gxvalid/gxvalid.h b/src/3rdparty/freetype/src/gxvalid/gxvalid.h index 19f0379982..969cd0927a 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvalid.h +++ b/src/3rdparty/freetype/src/gxvalid/gxvalid.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvalid.h */ -/* */ -/* TrueTypeGX/AAT table validation (specification only). */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvalid.h + * + * TrueTypeGX/AAT table validation (specification only). + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef GXVALID_H_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvbsln.c b/src/3rdparty/freetype/src/gxvalid/gxvbsln.c index c367d38483..f22f2545fa 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvbsln.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvbsln.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvbsln.c */ -/* */ -/* TrueTypeGX/AAT bsln table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvbsln.c + * + * TrueTypeGX/AAT bsln table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvbsln +#define FT_COMPONENT gxvbsln /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvcommn.c b/src/3rdparty/freetype/src/gxvalid/gxvcommn.c index b96601108b..c5cb8ebe8b 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvcommn.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvcommn.c @@ -1,41 +1,41 @@ -/***************************************************************************/ -/* */ -/* gxvcommn.c */ -/* */ -/* TrueTypeGX/AAT common tables validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvcommn.c + * + * TrueTypeGX/AAT common tables validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvcommon +#define FT_COMPONENT gxvcommon /*************************************************************************/ @@ -384,8 +384,8 @@ ( P += 2, gxv_lookup_value_load( P - 2, SIGNSPEC ) ) static GXV_LookupValueDesc - gxv_lookup_value_load( FT_Bytes p, - int signspec ) + gxv_lookup_value_load( FT_Bytes p, + GXV_LookupValue_SignSpec signspec ) { GXV_LookupValueDesc v; diff --git a/src/3rdparty/freetype/src/gxvalid/gxvcommn.h b/src/3rdparty/freetype/src/gxvalid/gxvcommn.h index 8e4ff9cafc..334dc9dfb3 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvcommn.h +++ b/src/3rdparty/freetype/src/gxvalid/gxvcommn.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* gxvcommn.h */ -/* */ -/* TrueTypeGX/AAT common tables validation (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvcommn.h + * + * TrueTypeGX/AAT common tables validation (specification). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ /* * keywords in variable naming * --------------------------- - * table: Of type FT_Bytes, pointing to the start of this table/subtable. - * limit: Of type FT_Bytes, pointing to the end of this table/subtable, + * table: Of type FT_Bytes, pointing to the start of this table/subtable. + * limit: Of type FT_Bytes, pointing to the end of this table/subtable, * including padding for alignment. - * offset: Of type FT_UInt, the number of octets from the start to target. - * length: Of type FT_UInt, the number of octets from the start to the - * end in this table/subtable, including padding for alignment. + * offset: Of type FT_UInt, the number of octets from the start to target. + * length: Of type FT_UInt, the number of octets from the start to the + * end in this table/subtable, including padding for alignment. * * _MIN, _MAX: Should be added to the tail of macros, as INT_MIN, etc. */ diff --git a/src/3rdparty/freetype/src/gxvalid/gxverror.h b/src/3rdparty/freetype/src/gxvalid/gxverror.h index d1151258a9..da0edb35f9 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxverror.h +++ b/src/3rdparty/freetype/src/gxvalid/gxverror.h @@ -1,36 +1,36 @@ -/***************************************************************************/ -/* */ -/* gxverror.h */ -/* */ -/* TrueTypeGX/AAT validation module error codes (specification only). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the OpenType validation module error */ - /* enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * gxverror.h + * + * TrueTypeGX/AAT validation module error codes (specification only). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ + + + /************************************************************************** + * + * This file is used to define the OpenType validation module error + * enumeration constants. + * + */ #ifndef GXVERROR_H_ #define GXVERROR_H_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfeat.c b/src/3rdparty/freetype/src/gxvalid/gxvfeat.c index 2c805d1d11..e1a12a18ed 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvfeat.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvfeat.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvfeat.c */ -/* */ -/* TrueTypeGX/AAT feat table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvfeat.c + * + * TrueTypeGX/AAT feat table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" @@ -30,14 +30,14 @@ #include "gxvfeat.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvfeat +#define FT_COMPONENT gxvfeat /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfeat.h b/src/3rdparty/freetype/src/gxvalid/gxvfeat.h index 2d943806c1..6c9892910c 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvfeat.h +++ b/src/3rdparty/freetype/src/gxvalid/gxvfeat.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvfeat.h */ -/* */ -/* TrueTypeGX/AAT feat table validation (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvfeat.h + * + * TrueTypeGX/AAT feat table validation (specification). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef GXVFEAT_H_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvfgen.c b/src/3rdparty/freetype/src/gxvalid/gxvfgen.c index 840c0f3524..5ecb9443c3 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvfgen.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvfgen.c @@ -1,62 +1,62 @@ -/***************************************************************************/ -/* */ -/* gxfgen.c */ -/* */ -/* Generate feature registry data for gxv `feat' validator. */ -/* This program is derived from gxfeatreg.c in gxlayout. */ -/* */ -/* Copyright 2004-2018 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* This file may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxfgen.c + * + * Generate feature registry data for gxv `feat' validator. + * This program is derived from gxfeatreg.c in gxlayout. + * + * Copyright (C) 2004-2019 by + * Masatake YAMATO and Redhat K.K. + * + * This file may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ -/***************************************************************************/ -/* */ -/* gxfeatreg.c */ -/* */ -/* Database of font features pre-defined by Apple Computer, Inc. */ -/* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html */ -/* (body). */ -/* */ -/* Copyright 2003 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* This file may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxfeatreg.c + * + * Database of font features pre-defined by Apple Computer, Inc. + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html + * (body). + * + * Copyright 2003 by + * Masatake YAMATO and Redhat K.K. + * + * This file may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ -/***************************************************************************/ -/* */ -/* Development of gxfeatreg.c is supported by */ -/* Information-technology Promotion Agency, Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * Development of gxfeatreg.c is supported by + * Information-technology Promotion Agency, Japan. + * + */ -/***************************************************************************/ -/* */ -/* This file is compiled as a stand-alone executable. */ -/* This file is never compiled into `libfreetype2'. */ -/* The output of this file is used in `gxvfeat.c'. */ -/* ----------------------------------------------------------------------- */ -/* Compile: gcc `pkg-config --cflags freetype2` gxvfgen.c -o gxvfgen */ -/* Run: ./gxvfgen > tmp.c */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * This file is compiled as a stand-alone executable. + * This file is never compiled into `libfreetype2'. + * The output of this file is used in `gxvfeat.c'. + * ----------------------------------------------------------------------- + * Compile: gcc `pkg-config --cflags freetype2` gxvfgen.c -o gxvfgen + * Run: ./gxvfgen > tmp.c + * + */ - /*******************************************************************/ - /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ - /*******************************************************************/ + /******************************************************************** + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ /* * If you add a new setting to a feature, check the number of settings @@ -65,9 +65,9 @@ */ #define FEATREG_MAX_SETTING 12 - /*******************************************************************/ - /* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING */ - /*******************************************************************/ + /******************************************************************** + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ #include <stdio.h> diff --git a/src/3rdparty/freetype/src/gxvalid/gxvjust.c b/src/3rdparty/freetype/src/gxvalid/gxvjust.c index 00c4293195..a582377859 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvjust.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvjust.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvjust.c */ -/* */ -/* TrueTypeGX/AAT just table validation (body). */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvjust.c + * + * TrueTypeGX/AAT just table validation (body). + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" @@ -31,14 +31,14 @@ #include FT_SFNT_NAMES_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvjust +#define FT_COMPONENT gxvjust /* * referred `just' table format specification: @@ -72,6 +72,8 @@ const FT_String* msg_tag, GXV_Validator gxvalid ) { + FT_UNUSED( msg_tag ); + if ( gid < gxvalid->face->num_glyphs ) return; diff --git a/src/3rdparty/freetype/src/gxvalid/gxvkern.c b/src/3rdparty/freetype/src/gxvalid/gxvkern.c index 9c0efd7a4f..a7532335a5 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvkern.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvkern.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvkern.c */ -/* */ -/* TrueTypeGX/AAT kern table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvkern.c + * + * TrueTypeGX/AAT kern table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" @@ -32,14 +32,14 @@ #include FT_SERVICE_GX_VALIDATE_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvkern +#define FT_COMPONENT gxvkern /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvlcar.c b/src/3rdparty/freetype/src/gxvalid/gxvlcar.c index 0f261a9ace..13b3de3eaa 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvlcar.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvlcar.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvlcar.c */ -/* */ -/* TrueTypeGX/AAT lcar table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvlcar.c + * + * TrueTypeGX/AAT lcar table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvlcar +#define FT_COMPONENT gxvlcar /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmod.c b/src/3rdparty/freetype/src/gxvalid/gxvmod.c index 1a3c862927..eeadeb3e1d 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmod.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmod.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvmod.c */ -/* */ -/* FreeType's TrueTypeGX/AAT validation module implementation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmod.c + * + * FreeType's TrueTypeGX/AAT validation module implementation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include <ft2build.h> @@ -37,14 +37,14 @@ #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmodule +#define FT_COMPONENT gxvmodule static FT_Error diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmod.h b/src/3rdparty/freetype/src/gxvalid/gxvmod.h index 745c62e105..6ecd7312c9 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmod.h +++ b/src/3rdparty/freetype/src/gxvalid/gxvmod.h @@ -1,29 +1,29 @@ -/***************************************************************************/ -/* */ -/* gxvmod.h */ -/* */ -/* FreeType's TrueTypeGX/AAT validation module implementation */ -/* (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmod.h + * + * FreeType's TrueTypeGX/AAT validation module implementation + * (specification). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef GXVMOD_H_ @@ -35,10 +35,6 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - FT_EXPORT_VAR( const FT_Module_Class ) gxv_module_class; diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort.c b/src/3rdparty/freetype/src/gxvalid/gxvmort.c index b361cb2b9d..288ef6988b 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmort.c */ -/* */ -/* TrueTypeGX/AAT mort table validation (body). */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort.c + * + * TrueTypeGX/AAT mort table validation (body). + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmort.h" #include "gxvfeat.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmort +#define FT_COMPONENT gxvmort static void @@ -123,6 +123,7 @@ GXV_Validator gxvalid ) { FT_UNUSED( gxvalid ); + FT_UNUSED( coverage ); #ifdef FT_DEBUG_LEVEL_TRACE if ( coverage & 0x8000U ) diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort.h b/src/3rdparty/freetype/src/gxvalid/gxvmort.h index d8030645e9..0619e24fb9 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort.h +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvmort.h */ -/* */ -/* TrueTypeGX/AAT common definition for mort table (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort.h + * + * TrueTypeGX/AAT common definition for mort table (specification). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef GXVMORT_H_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort0.c b/src/3rdparty/freetype/src/gxvalid/gxvmort0.c index 95cf53d5eb..2c01bf95ec 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort0.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort0.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmort0.c */ -/* */ -/* TrueTypeGX/AAT mort table validation */ -/* body for type0 (Indic Script Rearrangement) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort0.c + * + * TrueTypeGX/AAT mort table validation + * body for type0 (Indic Script Rearrangement) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmort.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmort +#define FT_COMPONENT gxvmort static const char* GXV_Mort_IndicScript_Msg[] = diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort1.c b/src/3rdparty/freetype/src/gxvalid/gxvmort1.c index a7683a17b0..c71ba13351 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort1.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort1.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmort1.c */ -/* */ -/* TrueTypeGX/AAT mort table validation */ -/* body for type1 (Contextual Substitution) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort1.c + * + * TrueTypeGX/AAT mort table validation + * body for type1 (Contextual Substitution) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmort.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmort +#define FT_COMPONENT gxvmort typedef struct GXV_mort_subtable_type1_StateOptRec_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort2.c b/src/3rdparty/freetype/src/gxvalid/gxvmort2.c index c23c2775a1..889d3bd582 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort2.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort2.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmort2.c */ -/* */ -/* TrueTypeGX/AAT mort table validation */ -/* body for type2 (Ligature Substitution) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort2.c + * + * TrueTypeGX/AAT mort table validation + * body for type2 (Ligature Substitution) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmort.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmort +#define FT_COMPONENT gxvmort typedef struct GXV_mort_subtable_type2_StateOptRec_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort4.c b/src/3rdparty/freetype/src/gxvalid/gxvmort4.c index 9d21a5fc29..f8ce6cf789 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort4.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort4.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmort4.c */ -/* */ -/* TrueTypeGX/AAT mort table validation */ -/* body for type4 (Non-Contextual Glyph Substitution) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort4.c + * + * TrueTypeGX/AAT mort table validation + * body for type4 (Non-Contextual Glyph Substitution) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmort.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmort +#define FT_COMPONENT gxvmort static void diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmort5.c b/src/3rdparty/freetype/src/gxvalid/gxvmort5.c index 42cb428aa8..1ba1e5ded0 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmort5.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmort5.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmort5.c */ -/* */ -/* TrueTypeGX/AAT mort table validation */ -/* body for type5 (Contextual Glyph Insertion) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmort5.c + * + * TrueTypeGX/AAT mort table validation + * body for type5 (Contextual Glyph Insertion) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmort.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmort +#define FT_COMPONENT gxvmort /* diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx.c index 9fd6e6b971..8bd45c27e6 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx.c @@ -1,41 +1,41 @@ -/***************************************************************************/ -/* */ -/* gxvmorx.c */ -/* */ -/* TrueTypeGX/AAT morx table validation (body). */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx.c + * + * TrueTypeGX/AAT morx table validation (body). + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmorx.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmorx +#define FT_COMPONENT gxvmorx static void diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx.h b/src/3rdparty/freetype/src/gxvalid/gxvmorx.h index 6d9925e92b..e257270342 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx.h +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* gxvmorx.h */ -/* */ -/* TrueTypeGX/AAT common definition for morx table (specification). */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx.h + * + * TrueTypeGX/AAT common definition for morx table (specification). + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #ifndef GXVMORX_H_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c index 302261b7fa..d7764a0ae8 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx0.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmorx0.c */ -/* */ -/* TrueTypeGX/AAT morx table validation */ -/* body for type0 (Indic Script Rearrangement) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx0.c + * + * TrueTypeGX/AAT morx table validation + * body for type0 (Indic Script Rearrangement) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmorx.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmorx +#define FT_COMPONENT gxvmorx static void diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c index 890ca74b1d..5b41b3605f 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx1.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmorx1.c */ -/* */ -/* TrueTypeGX/AAT morx table validation */ -/* body for type1 (Contextual Substitution) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx1.c + * + * TrueTypeGX/AAT morx table validation + * body for type1 (Contextual Substitution) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmorx.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmorx +#define FT_COMPONENT gxvmorx typedef struct GXV_morx_subtable_type1_StateOptRec_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c index 3135031d45..ec4c81299d 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx2.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmorx2.c */ -/* */ -/* TrueTypeGX/AAT morx table validation */ -/* body for type2 (Ligature Substitution) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx2.c + * + * TrueTypeGX/AAT morx table validation + * body for type2 (Ligature Substitution) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmorx.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmorx +#define FT_COMPONENT gxvmorx typedef struct GXV_morx_subtable_type2_StateOptRec_ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c index 1e2397b0c5..7b041534c0 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx4.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmorx4.c */ -/* */ -/* TrueTypeGX/AAT morx table validation */ -/* body for "morx" type4 (Non-Contextual Glyph Substitution) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx4.c + * + * TrueTypeGX/AAT morx table validation + * body for "morx" type4 (Non-Contextual Glyph Substitution) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmorx.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmorx +#define FT_COMPONENT gxvmorx FT_LOCAL_DEF( void ) diff --git a/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c b/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c index db4f9290c8..70a4623656 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvmorx5.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvmorx5.c */ -/* */ -/* TrueTypeGX/AAT morx table validation */ -/* body for type5 (Contextual Glyph Insertion) subtable. */ -/* */ -/* Copyright 2005-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvmorx5.c + * + * TrueTypeGX/AAT morx table validation + * body for type5 (Contextual Glyph Insertion) subtable. + * + * Copyright (C) 2005-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvmorx.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvmorx +#define FT_COMPONENT gxvmorx /* diff --git a/src/3rdparty/freetype/src/gxvalid/gxvopbd.c b/src/3rdparty/freetype/src/gxvalid/gxvopbd.c index e2c167ea59..f055a22054 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvopbd.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvopbd.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvopbd.c */ -/* */ -/* TrueTypeGX/AAT opbd table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvopbd.c + * + * TrueTypeGX/AAT opbd table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvopbd +#define FT_COMPONENT gxvopbd /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvprop.c b/src/3rdparty/freetype/src/gxvalid/gxvprop.c index a67b6bdd00..e1911edd48 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvprop.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvprop.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvprop.c */ -/* */ -/* TrueTypeGX/AAT prop table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvprop.c + * + * TrueTypeGX/AAT prop table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvprop +#define FT_COMPONENT gxvprop /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/gxvtrak.c b/src/3rdparty/freetype/src/gxvalid/gxvtrak.c index d501b5014b..b7794b7af4 100644 --- a/src/3rdparty/freetype/src/gxvalid/gxvtrak.c +++ b/src/3rdparty/freetype/src/gxvalid/gxvtrak.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* gxvtrak.c */ -/* */ -/* TrueTypeGX/AAT trak table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * gxvtrak.c + * + * TrueTypeGX/AAT trak table validation (body). + * + * Copyright (C) 2004-2019 by + * suzuki toshiya, Masatake YAMATO, Red Hat K.K., + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + +/**************************************************************************** + * + * gxvalid is derived from both gxlayout module and otvalid module. + * Development of gxlayout is supported by the Information-technology + * Promotion Agency(IPA), Japan. + * + */ #include "gxvalid.h" #include "gxvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_gxvtrak +#define FT_COMPONENT gxvtrak /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/gxvalid/module.mk b/src/3rdparty/freetype/src/gxvalid/module.mk index b64879dcee..04067ce617 100644 --- a/src/3rdparty/freetype/src/gxvalid/module.mk +++ b/src/3rdparty/freetype/src/gxvalid/module.mk @@ -2,7 +2,7 @@ # FreeType 2 gxvalid module definition # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # suzuki toshiya, Masatake YAMATO, Red Hat K.K., # David Turner, Robert Wilhelm, and Werner Lemberg. # diff --git a/src/3rdparty/freetype/src/gxvalid/rules.mk b/src/3rdparty/freetype/src/gxvalid/rules.mk index 3a17c030a6..4ef463bc21 100644 --- a/src/3rdparty/freetype/src/gxvalid/rules.mk +++ b/src/3rdparty/freetype/src/gxvalid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # suzuki toshiya, Masatake YAMATO, Red Hat K.K., # David Turner, Robert Wilhelm, and Werner Lemberg. # diff --git a/src/3rdparty/freetype/src/gzip/Jamfile b/src/3rdparty/freetype/src/gzip/Jamfile index a7b4c8c950..2c808b74a5 100644 --- a/src/3rdparty/freetype/src/gzip/Jamfile +++ b/src/3rdparty/freetype/src/gzip/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/gzip Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/gzip/ftgzip.c b/src/3rdparty/freetype/src/gzip/ftgzip.c index f8011c2dd8..5e78bc6f8d 100644 --- a/src/3rdparty/freetype/src/gzip/ftgzip.c +++ b/src/3rdparty/freetype/src/gzip/ftgzip.c @@ -1,23 +1,23 @@ -/***************************************************************************/ -/* */ -/* ftgzip.c */ -/* */ -/* FreeType support for .gz compressed files. */ -/* */ -/* This optional component relies on zlib. It should mainly be used to */ -/* parse compressed PCF fonts, as found with many X11 server */ -/* distributions. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgzip.c + * + * FreeType support for .gz compressed files. + * + * This optional component relies on zlib. It should mainly be used to + * parse compressed PCF fonts, as found with many X11 server + * distributions. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -41,10 +41,6 @@ #ifdef FT_CONFIG_OPTION_USE_ZLIB -#ifdef FT_CONFIG_OPTION_PIC -#error "gzip code does not support PIC yet" -#endif - #ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB #include <zlib.h> @@ -637,8 +633,8 @@ memory = source->memory; /* - * check the header right now; this prevents allocating un-necessary - * objects when we don't need them + * check the header right now; this prevents allocating un-necessary + * objects when we don't need them */ error = ft_gzip_check_header( source ); if ( error ) @@ -660,12 +656,12 @@ } /* - * We use the following trick to try to dramatically improve the - * performance while dealing with small files. If the original stream - * size is less than a certain threshold, we try to load the whole font - * file into memory. This saves us from using the 32KB buffer needed - * to inflate the file, plus the two 4KB intermediate input/output - * buffers used in the `FT_GZipFile' structure. + * We use the following trick to try to dramatically improve the + * performance while dealing with small files. If the original stream + * size is less than a certain threshold, we try to load the whole font + * file into memory. This saves us from using the 32KB buffer needed + * to inflate the file, plus the two 4KB intermediate input/output + * buffers used in the `FT_GZipFile' structure. */ { FT_ULong zip_size = ft_gzip_get_uncompressed_size( source ); @@ -735,7 +731,7 @@ /* check for `input' delayed to `inflate' */ - if ( !memory || ! output_len || !output ) + if ( !memory || !output_len || !output ) return FT_THROW( Invalid_Argument ); /* this function is modeled after zlib's `uncompress' function */ @@ -750,7 +746,7 @@ stream.zfree = (free_func) ft_gzip_free; stream.opaque = memory; - err = inflateInit2( &stream, MAX_WBITS ); + err = inflateInit2( &stream, MAX_WBITS|32 ); if ( err != Z_OK ) return FT_THROW( Invalid_Argument ); diff --git a/src/3rdparty/freetype/src/gzip/infblock.c b/src/3rdparty/freetype/src/gzip/infblock.c index d6e2dc297d..2b4f0c2b53 100644 --- a/src/3rdparty/freetype/src/gzip/infblock.c +++ b/src/3rdparty/freetype/src/gzip/infblock.c @@ -235,6 +235,7 @@ int r ) s->sub.trees.index = 0; Tracev((stderr, "inflate: table sizes ok\n")); s->mode = BTREE; + /* fall through */ case BTREE: while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) { @@ -260,6 +261,7 @@ int r ) s->sub.trees.index = 0; Tracev((stderr, "inflate: bits tree ok\n")); s->mode = DTREE; + /* fall through */ case DTREE: while (t = s->sub.trees.table, s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) @@ -335,6 +337,7 @@ int r ) } ZFREE(z, s->sub.trees.blens); s->mode = CODES; + /* fall through */ case CODES: UPDATE if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) @@ -351,11 +354,13 @@ int r ) break; } s->mode = DRY; + /* fall through */ case DRY: FLUSH if (s->read != s->write) LEAVE s->mode = DONE; + /* fall through */ case DONE: r = Z_STREAM_END; LEAVE diff --git a/src/3rdparty/freetype/src/gzip/infcodes.c b/src/3rdparty/freetype/src/gzip/infcodes.c index f7bfd58c4f..ba30654990 100644 --- a/src/3rdparty/freetype/src/gzip/infcodes.c +++ b/src/3rdparty/freetype/src/gzip/infcodes.c @@ -117,6 +117,7 @@ int r ) c->sub.code.need = c->lbits; c->sub.code.tree = c->ltree; c->mode = LEN; + /* fall through */ case LEN: /* i: get length/literal/eob next */ j = c->sub.code.need; NEEDBITS(j) @@ -164,6 +165,7 @@ int r ) c->sub.code.tree = c->dtree; Tracevv((stderr, "inflate: length %u\n", c->len)); c->mode = DIST; + /* fall through */ case DIST: /* i: get distance next */ j = c->sub.code.need; NEEDBITS(j) @@ -194,6 +196,7 @@ int r ) DUMPBITS(j) Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); c->mode = COPY; + /* fall through */ case COPY: /* o: copying bytes in window, waiting for space */ f = q - c->sub.copy.dist; while (f < s->window) /* modulo window size-"while" instead */ @@ -225,6 +228,7 @@ int r ) if (s->read != s->write) LEAVE c->mode = END; + /* fall through */ case END: r = Z_STREAM_END; LEAVE diff --git a/src/3rdparty/freetype/src/gzip/inflate.c b/src/3rdparty/freetype/src/gzip/inflate.c index 8877fa3eb2..95e2653662 100644 --- a/src/3rdparty/freetype/src/gzip/inflate.c +++ b/src/3rdparty/freetype/src/gzip/inflate.c @@ -174,6 +174,7 @@ int f ) break; } z->state->mode = FLAG; + /* fall through */ case FLAG: NEEDBYTE b = NEXTBYTE; @@ -191,18 +192,22 @@ int f ) break; } z->state->mode = DICT4; + /* fall through */ case DICT4: NEEDBYTE z->state->sub.check.need = (uLong)NEXTBYTE << 24; z->state->mode = DICT3; + /* fall through */ case DICT3: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 16; z->state->mode = DICT2; + /* fall through */ case DICT2: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 8; z->state->mode = DICT1; + /* fall through */ case DICT1: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE; @@ -234,18 +239,22 @@ int f ) break; } z->state->mode = CHECK4; + /* fall through */ case CHECK4: NEEDBYTE z->state->sub.check.need = (uLong)NEXTBYTE << 24; z->state->mode = CHECK3; + /* fall through */ case CHECK3: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 16; z->state->mode = CHECK2; + /* fall through */ case CHECK2: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 8; z->state->mode = CHECK1; + /* fall through */ case CHECK1: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE; @@ -259,6 +268,7 @@ int f ) } Tracev((stderr, "inflate: zlib check ok\n")); z->state->mode = DONE; + /* fall through */ case DONE: return Z_STREAM_END; case BAD: diff --git a/src/3rdparty/freetype/src/gzip/rules.mk b/src/3rdparty/freetype/src/gzip/rules.mk index 1a2e48bebd..44206a1dae 100644 --- a/src/3rdparty/freetype/src/gzip/rules.mk +++ b/src/3rdparty/freetype/src/gzip/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/lzw/Jamfile b/src/3rdparty/freetype/src/lzw/Jamfile index cb83aa4a56..ba2d6ebb45 100644 --- a/src/3rdparty/freetype/src/lzw/Jamfile +++ b/src/3rdparty/freetype/src/lzw/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/lzw Jamfile # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/lzw/ftlzw.c b/src/3rdparty/freetype/src/lzw/ftlzw.c index cb46f93c68..9805a1e3bd 100644 --- a/src/3rdparty/freetype/src/lzw/ftlzw.c +++ b/src/3rdparty/freetype/src/lzw/ftlzw.c @@ -1,25 +1,25 @@ -/***************************************************************************/ -/* */ -/* ftlzw.c */ -/* */ -/* FreeType support for .Z compressed files. */ -/* */ -/* This optional component relies on NetBSD's zopen(). It should mainly */ -/* be used to parse compressed PCF fonts, as found with many X11 server */ -/* distributions. */ -/* */ -/* Copyright 2004-2018 by */ -/* Albert Chin-A-Young. */ -/* */ -/* based on code in `src/gzip/ftgzip.c' */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftlzw.c + * + * FreeType support for .Z compressed files. + * + * This optional component relies on NetBSD's zopen(). It should mainly + * be used to parse compressed PCF fonts, as found with many X11 server + * distributions. + * + * Copyright (C) 2004-2019 by + * Albert Chin-A-Young. + * + * based on code in `src/gzip/ftgzip.c' + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_MEMORY_H @@ -42,10 +42,6 @@ #ifdef FT_CONFIG_OPTION_USE_LZW -#ifdef FT_CONFIG_OPTION_PIC -#error "lzw code does not support PIC yet" -#endif - #include "ftzopen.h" @@ -361,11 +357,11 @@ memory = source->memory; /* - * Check the header right now; this prevents allocation of a huge - * LZWFile object (400 KByte of heap memory) if not necessary. + * Check the header right now; this prevents allocation of a huge + * LZWFile object (400 KByte of heap memory) if not necessary. * - * Did I mention that you should never use .Z compressed font - * files? + * Did I mention that you should never use .Z compressed font + * files? */ error = ft_lzw_check_header( source ); if ( error ) diff --git a/src/3rdparty/freetype/src/lzw/ftzopen.c b/src/3rdparty/freetype/src/lzw/ftzopen.c index 2b868ba9f2..67e6760f95 100644 --- a/src/3rdparty/freetype/src/lzw/ftzopen.c +++ b/src/3rdparty/freetype/src/lzw/ftzopen.c @@ -1,23 +1,23 @@ -/***************************************************************************/ -/* */ -/* ftzopen.c */ -/* */ -/* FreeType support for .Z compressed files. */ -/* */ -/* This optional component relies on NetBSD's zopen(). It should mainly */ -/* be used to parse compressed PCF fonts, as found with many X11 server */ -/* distributions. */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftzopen.c + * + * FreeType support for .Z compressed files. + * + * This optional component relies on NetBSD's zopen(). It should mainly + * be used to parse compressed PCF fonts, as found with many X11 server + * distributions. + * + * Copyright (C) 2005-2019 by + * David Turner. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "ftzopen.h" #include FT_INTERNAL_MEMORY_H @@ -167,11 +167,11 @@ new_size += new_size >> 2; /* don't grow too fast */ /* - * Note that the `suffix' array is located in the same memory block - * pointed to by `prefix'. + * Note that the `suffix' array is located in the same memory block + * pointed to by `prefix'. * - * I know that sizeof(FT_Byte) == 1 by definition, but it is clearer - * to write it literally. + * I know that sizeof(FT_Byte) == 1 by definition, but it is clearer + * to write it literally. * */ if ( FT_REALLOC_MULT( state->prefix, old_size, new_size, diff --git a/src/3rdparty/freetype/src/lzw/ftzopen.h b/src/3rdparty/freetype/src/lzw/ftzopen.h index 4fd267eb90..44fe36d6c5 100644 --- a/src/3rdparty/freetype/src/lzw/ftzopen.h +++ b/src/3rdparty/freetype/src/lzw/ftzopen.h @@ -1,23 +1,23 @@ -/***************************************************************************/ -/* */ -/* ftzopen.h */ -/* */ -/* FreeType support for .Z compressed files. */ -/* */ -/* This optional component relies on NetBSD's zopen(). It should mainly */ -/* be used to parse compressed PCF fonts, as found with many X11 server */ -/* distributions. */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftzopen.h + * + * FreeType support for .Z compressed files. + * + * This optional component relies on NetBSD's zopen(). It should mainly + * be used to parse compressed PCF fonts, as found with many X11 server + * distributions. + * + * Copyright (C) 2005-2019 by + * David Turner. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTZOPEN_H_ #define FTZOPEN_H_ @@ -27,9 +27,9 @@ /* - * This is a complete re-implementation of the LZW file reader, - * since the old one was incredibly badly written, using - * 400 KByte of heap memory before decompressing anything. + * This is a complete re-implementation of the LZW file reader, + * since the old one was incredibly badly written, using + * 400 KByte of heap memory before decompressing anything. * */ @@ -58,56 +58,56 @@ /* - * state of LZW decompressor + * state of LZW decompressor * - * small technical note - * -------------------- + * small technical note + * -------------------- * - * We use a few tricks in this implementation that are explained here to - * ease debugging and maintenance. + * We use a few tricks in this implementation that are explained here to + * ease debugging and maintenance. * - * - First of all, the `prefix' and `suffix' arrays contain the suffix - * and prefix for codes over 256; this means that + * - First of all, the `prefix' and `suffix' arrays contain the suffix + * and prefix for codes over 256; this means that * - * prefix_of(code) == state->prefix[code-256] - * suffix_of(code) == state->suffix[code-256] + * prefix_of(code) == state->prefix[code-256] + * suffix_of(code) == state->suffix[code-256] * - * Each prefix is a 16-bit code, and each suffix an 8-bit byte. + * Each prefix is a 16-bit code, and each suffix an 8-bit byte. * - * Both arrays are stored in a single memory block, pointed to by - * `state->prefix'. This means that the following equality is always - * true: + * Both arrays are stored in a single memory block, pointed to by + * `state->prefix'. This means that the following equality is always + * true: * - * state->suffix == (FT_Byte*)(state->prefix + state->prefix_size) + * state->suffix == (FT_Byte*)(state->prefix + state->prefix_size) * - * Of course, state->prefix_size is the number of prefix/suffix slots - * in the arrays, corresponding to codes 256..255+prefix_size. + * Of course, state->prefix_size is the number of prefix/suffix slots + * in the arrays, corresponding to codes 256..255+prefix_size. * - * - `free_ent' is the index of the next free entry in the `prefix' - * and `suffix' arrays. This means that the corresponding `next free - * code' is really `256+free_ent'. + * - `free_ent' is the index of the next free entry in the `prefix' + * and `suffix' arrays. This means that the corresponding `next free + * code' is really `256+free_ent'. * - * Moreover, `max_free' is the maximum value that `free_ent' can reach. + * Moreover, `max_free' is the maximum value that `free_ent' can reach. * - * `max_free' corresponds to `(1 << max_bits) - 256'. Note that this - * value is always <= 0xFF00, which means that both `free_ent' and - * `max_free' can be stored in an FT_UInt variable, even on 16-bit - * machines. + * `max_free' corresponds to `(1 << max_bits) - 256'. Note that this + * value is always <= 0xFF00, which means that both `free_ent' and + * `max_free' can be stored in an FT_UInt variable, even on 16-bit + * machines. * - * If `free_ent == max_free', you cannot add new codes to the - * prefix/suffix table. + * If `free_ent == max_free', you cannot add new codes to the + * prefix/suffix table. * - * - `num_bits' is the current number of code bits, starting at 9 and - * growing each time `free_ent' reaches the value of `free_bits'. The - * latter is computed as follows + * - `num_bits' is the current number of code bits, starting at 9 and + * growing each time `free_ent' reaches the value of `free_bits'. The + * latter is computed as follows * - * if num_bits < max_bits: - * free_bits = (1 << num_bits)-256 - * else: - * free_bits = max_free + 1 + * if num_bits < max_bits: + * free_bits = (1 << num_bits)-256 + * else: + * free_bits = max_free + 1 * - * Since the value of `max_free + 1' can never be reached by - * `free_ent', `num_bits' cannot grow larger than `max_bits'. + * Since the value of `max_free + 1' can never be reached by + * `free_ent', `num_bits' cannot grow larger than `max_bits'. */ typedef struct FT_LzwStateRec_ diff --git a/src/3rdparty/freetype/src/lzw/rules.mk b/src/3rdparty/freetype/src/lzw/rules.mk index 18933c41c2..930b32e6b1 100644 --- a/src/3rdparty/freetype/src/lzw/rules.mk +++ b/src/3rdparty/freetype/src/lzw/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # Albert Chin-A-Young. # # based on `src/lzw/rules.mk' diff --git a/src/3rdparty/freetype/src/otvalid/Jamfile b/src/3rdparty/freetype/src/otvalid/Jamfile index 21b8e0cb0f..36db0e1f83 100644 --- a/src/3rdparty/freetype/src/otvalid/Jamfile +++ b/src/3rdparty/freetype/src/otvalid/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/otvalid Jamfile # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/otvalid/module.mk b/src/3rdparty/freetype/src/otvalid/module.mk index 34f3dab32f..5ea5b7b57b 100644 --- a/src/3rdparty/freetype/src/otvalid/module.mk +++ b/src/3rdparty/freetype/src/otvalid/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/otvalid/otvalid.c b/src/3rdparty/freetype/src/otvalid/otvalid.c index 4423ca1012..e3964b99ae 100644 --- a/src/3rdparty/freetype/src/otvalid/otvalid.c +++ b/src/3rdparty/freetype/src/otvalid/otvalid.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvalid.c */ -/* */ -/* FreeType validator for OpenType tables (body only). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvalid.c + * + * FreeType validator for OpenType tables (body only). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/otvalid/otvalid.h b/src/3rdparty/freetype/src/otvalid/otvalid.h index d7801abae5..5ca819f261 100644 --- a/src/3rdparty/freetype/src/otvalid/otvalid.h +++ b/src/3rdparty/freetype/src/otvalid/otvalid.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvalid.h */ -/* */ -/* OpenType table validation (specification only). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvalid.h + * + * OpenType table validation (specification only). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef OTVALID_H_ diff --git a/src/3rdparty/freetype/src/otvalid/otvbase.c b/src/3rdparty/freetype/src/otvalid/otvbase.c index a01d45c707..be69d7ca31 100644 --- a/src/3rdparty/freetype/src/otvalid/otvbase.c +++ b/src/3rdparty/freetype/src/otvalid/otvbase.c @@ -1,33 +1,33 @@ -/***************************************************************************/ -/* */ -/* otvbase.c */ -/* */ -/* OpenType BASE table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvbase.c + * + * OpenType BASE table validation (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvalid.h" #include "otvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvbase +#define FT_COMPONENT otvbase static void diff --git a/src/3rdparty/freetype/src/otvalid/otvcommn.c b/src/3rdparty/freetype/src/otvalid/otvcommn.c index 0ccfb03c08..5ed1723506 100644 --- a/src/3rdparty/freetype/src/otvalid/otvcommn.c +++ b/src/3rdparty/freetype/src/otvalid/otvcommn.c @@ -1,32 +1,32 @@ -/***************************************************************************/ -/* */ -/* otvcommn.c */ -/* */ -/* OpenType common tables validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvcommn.c + * + * OpenType common tables validation (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvcommon +#define FT_COMPONENT otvcommon /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/otvalid/otvcommn.h b/src/3rdparty/freetype/src/otvalid/otvcommn.h index a392784cf1..bfcc5b974a 100644 --- a/src/3rdparty/freetype/src/otvalid/otvcommn.h +++ b/src/3rdparty/freetype/src/otvalid/otvcommn.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvcommn.h */ -/* */ -/* OpenType common tables validation (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvcommn.h + * + * OpenType common tables validation (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef OTVCOMMN_H_ diff --git a/src/3rdparty/freetype/src/otvalid/otverror.h b/src/3rdparty/freetype/src/otvalid/otverror.h index 2fcf42e387..a7d35acf1a 100644 --- a/src/3rdparty/freetype/src/otvalid/otverror.h +++ b/src/3rdparty/freetype/src/otvalid/otverror.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* otverror.h */ -/* */ -/* OpenType validation module error codes (specification only). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the OpenType validation module error */ - /* enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * otverror.h + * + * OpenType validation module error codes (specification only). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the OpenType validation module error + * enumeration constants. + * + */ #ifndef OTVERROR_H_ #define OTVERROR_H_ diff --git a/src/3rdparty/freetype/src/otvalid/otvgdef.c b/src/3rdparty/freetype/src/otvalid/otvgdef.c index 08f3171541..2529b544d2 100644 --- a/src/3rdparty/freetype/src/otvalid/otvgdef.c +++ b/src/3rdparty/freetype/src/otvalid/otvgdef.c @@ -1,33 +1,33 @@ -/***************************************************************************/ -/* */ -/* otvgdef.c */ -/* */ -/* OpenType GDEF table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvgdef.c + * + * OpenType GDEF table validation (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvalid.h" #include "otvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvgdef +#define FT_COMPONENT otvgdef /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/otvalid/otvgpos.c b/src/3rdparty/freetype/src/otvalid/otvgpos.c index 696b35cae6..f3bddeac6c 100644 --- a/src/3rdparty/freetype/src/otvalid/otvgpos.c +++ b/src/3rdparty/freetype/src/otvalid/otvgpos.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvgpos.c */ -/* */ -/* OpenType GPOS table validation (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvgpos.c + * + * OpenType GPOS table validation (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvalid.h" @@ -21,14 +21,14 @@ #include "otvgpos.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvgpos +#define FT_COMPONENT otvgpos static void diff --git a/src/3rdparty/freetype/src/otvalid/otvgpos.h b/src/3rdparty/freetype/src/otvalid/otvgpos.h index 95f9ac3ee8..b3154312eb 100644 --- a/src/3rdparty/freetype/src/otvalid/otvgpos.h +++ b/src/3rdparty/freetype/src/otvalid/otvgpos.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvgpos.h */ -/* */ -/* OpenType GPOS table validator (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvgpos.h + * + * OpenType GPOS table validator (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef OTVGPOS_H_ diff --git a/src/3rdparty/freetype/src/otvalid/otvgsub.c b/src/3rdparty/freetype/src/otvalid/otvgsub.c index d35ea67f30..97da997d3d 100644 --- a/src/3rdparty/freetype/src/otvalid/otvgsub.c +++ b/src/3rdparty/freetype/src/otvalid/otvgsub.c @@ -1,33 +1,33 @@ -/***************************************************************************/ -/* */ -/* otvgsub.c */ -/* */ -/* OpenType GSUB table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvgsub.c + * + * OpenType GSUB table validation (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvalid.h" #include "otvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvgsub +#define FT_COMPONENT otvgsub /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/otvalid/otvjstf.c b/src/3rdparty/freetype/src/otvalid/otvjstf.c index 94d4af90f6..d4e6d87178 100644 --- a/src/3rdparty/freetype/src/otvalid/otvjstf.c +++ b/src/3rdparty/freetype/src/otvalid/otvjstf.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvjstf.c */ -/* */ -/* OpenType JSTF table validation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvjstf.c + * + * OpenType JSTF table validation (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvalid.h" @@ -21,14 +21,14 @@ #include "otvgpos.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvjstf +#define FT_COMPONENT otvjstf #define JstfPriorityFunc otv_JstfPriority_validate diff --git a/src/3rdparty/freetype/src/otvalid/otvmath.c b/src/3rdparty/freetype/src/otvalid/otvmath.c index b9800f60a2..3aaf0ec0ec 100644 --- a/src/3rdparty/freetype/src/otvalid/otvmath.c +++ b/src/3rdparty/freetype/src/otvalid/otvmath.c @@ -1,21 +1,21 @@ -/***************************************************************************/ -/* */ -/* otvmath.c */ -/* */ -/* OpenType MATH table validation (body). */ -/* */ -/* Copyright 2007-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* Written by George Williams. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvmath.c + * + * OpenType MATH table validation (body). + * + * Copyright (C) 2007-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Written by George Williams. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "otvalid.h" @@ -23,14 +23,14 @@ #include "otvgpos.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvmath +#define FT_COMPONENT otvmath diff --git a/src/3rdparty/freetype/src/otvalid/otvmod.c b/src/3rdparty/freetype/src/otvalid/otvmod.c index 89ee449d16..f417bd220f 100644 --- a/src/3rdparty/freetype/src/otvalid/otvmod.c +++ b/src/3rdparty/freetype/src/otvalid/otvmod.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* otvmod.c */ -/* */ -/* FreeType's OpenType validation module implementation (body). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvmod.c + * + * FreeType's OpenType validation module implementation (body). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -28,14 +28,14 @@ #include "otvcommn.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_otvmodule +#define FT_COMPONENT otvmodule static FT_Error diff --git a/src/3rdparty/freetype/src/otvalid/otvmod.h b/src/3rdparty/freetype/src/otvalid/otvmod.h index 6917bccee5..5539de7ec6 100644 --- a/src/3rdparty/freetype/src/otvalid/otvmod.h +++ b/src/3rdparty/freetype/src/otvalid/otvmod.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* otvmod.h */ -/* */ -/* FreeType's OpenType validation module implementation */ -/* (specification). */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * otvmod.h + * + * FreeType's OpenType validation module implementation + * (specification). + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef OTVMOD_H_ @@ -27,10 +27,6 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - FT_EXPORT_VAR( const FT_Module_Class ) otv_module_class; diff --git a/src/3rdparty/freetype/src/otvalid/rules.mk b/src/3rdparty/freetype/src/otvalid/rules.mk index d4fc723740..3c6ece1c19 100644 --- a/src/3rdparty/freetype/src/otvalid/rules.mk +++ b/src/3rdparty/freetype/src/otvalid/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2004-2018 by +# Copyright (C) 2004-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/pcf/Jamfile b/src/3rdparty/freetype/src/pcf/Jamfile index 7b92b12ddc..fd17d53f0d 100644 --- a/src/3rdparty/freetype/src/pcf/Jamfile +++ b/src/3rdparty/freetype/src/pcf/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pcf Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/pcf/pcf.h b/src/3rdparty/freetype/src/pcf/pcf.h index f0390cb1eb..33be4bcd85 100644 --- a/src/3rdparty/freetype/src/pcf/pcf.h +++ b/src/3rdparty/freetype/src/pcf/pcf.h @@ -99,11 +99,25 @@ FT_BEGIN_HEADER FT_Short ascent; FT_Short descent; FT_Short attributes; - FT_ULong bits; + + FT_ULong bits; /* offset into the PCF_BITMAPS table */ } PCF_MetricRec, *PCF_Metric; + typedef struct PCF_EncRec_ + { + FT_UShort firstCol; + FT_UShort lastCol; + FT_UShort firstRow; + FT_UShort lastRow; + FT_UShort defaultChar; + + FT_UShort* offset; + + } PCF_EncRec, *PCF_Enc; + + typedef struct PCF_AccelRec_ { FT_Byte noOverlap; @@ -124,41 +138,32 @@ FT_BEGIN_HEADER } PCF_AccelRec, *PCF_Accel; - typedef struct PCF_EncodingRec_ - { - FT_Long enc; - FT_UShort glyph; - - } PCF_EncodingRec, *PCF_Encoding; - - + /* + * This file uses X11 terminology for PCF data; an `encoding' in X11 speak + * is the same as a `character code' in FreeType speak. + */ typedef struct PCF_FaceRec_ { - FT_FaceRec root; - - FT_StreamRec comp_stream; - FT_Stream comp_source; + FT_FaceRec root; - char* charset_encoding; - char* charset_registry; + FT_StreamRec comp_stream; + FT_Stream comp_source; - PCF_TocRec toc; - PCF_AccelRec accel; + char* charset_encoding; + char* charset_registry; - int nprops; - PCF_Property properties; + PCF_TocRec toc; + PCF_AccelRec accel; - FT_ULong nmetrics; - PCF_Metric metrics; - FT_ULong nencodings; - PCF_Encoding encodings; + int nprops; + PCF_Property properties; - FT_Short defaultChar; + FT_ULong nmetrics; + PCF_Metric metrics; - FT_ULong bitmapsFormat; + PCF_EncRec enc; - FT_CharMap charmap_handle; - FT_CharMapRec charmap; /* a single charmap per face */ + FT_ULong bitmapsFormat; } PCF_FaceRec, *PCF_Face; diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.c b/src/3rdparty/freetype/src/pcf/pcfdrivr.c index 0119d94853..b39592c794 100644 --- a/src/3rdparty/freetype/src/pcf/pcfdrivr.c +++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.c @@ -45,7 +45,7 @@ THE SOFTWARE. #include "pcfutil.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pcfread +#define FT_COMPONENT pcfread #include FT_SERVICE_BDF_H #include FT_SERVICE_FONT_FORMAT_H @@ -53,21 +53,24 @@ THE SOFTWARE. #include FT_DRIVER_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_pcfdriver +#define FT_COMPONENT pcfdriver + /* + * This file uses X11 terminology for PCF data; an `encoding' in X11 speak + * is the same as a `character code' in FreeType speak. + */ typedef struct PCF_CMapRec_ { - FT_CMapRec root; - FT_ULong num_encodings; - PCF_Encoding encodings; + FT_CMapRec root; + PCF_Enc enc; } PCF_CMapRec, *PCF_CMap; @@ -82,8 +85,7 @@ THE SOFTWARE. FT_UNUSED( init_data ); - cmap->num_encodings = face->nencodings; - cmap->encodings = face->encodings; + cmap->enc = &face->enc; return FT_Err_Ok; } @@ -95,8 +97,7 @@ THE SOFTWARE. PCF_CMap cmap = (PCF_CMap)pcfcmap; - cmap->encodings = NULL; - cmap->num_encodings = 0; + cmap->enc = NULL; } @@ -104,36 +105,26 @@ THE SOFTWARE. pcf_cmap_char_index( FT_CMap pcfcmap, /* PCF_CMap */ FT_UInt32 charcode ) { - PCF_CMap cmap = (PCF_CMap)pcfcmap; - PCF_Encoding encodings = cmap->encodings; - FT_ULong min, max, mid; - FT_UInt result = 0; + PCF_CMap cmap = (PCF_CMap)pcfcmap; + PCF_Enc enc = cmap->enc; + FT_UShort charcodeRow; + FT_UShort charcodeCol; - min = 0; - max = cmap->num_encodings; + if ( charcode > (FT_UInt32)( enc->lastRow * 256 + enc->lastCol ) || + charcode < (FT_UInt32)( enc->firstRow * 256 + enc->firstCol ) ) + return 0; - while ( min < max ) - { - FT_ULong code; + charcodeRow = (FT_UShort)( charcode >> 8 ); + charcodeCol = (FT_UShort)( charcode & 0xFF ); + if ( charcodeCol < enc->firstCol || + charcodeCol > enc->lastCol ) + return 0; - mid = ( min + max ) >> 1; - code = (FT_ULong)encodings[mid].enc; - - if ( charcode == code ) - { - result = encodings[mid].glyph + 1; - break; - } - - if ( charcode < code ) - max = mid; - else - min = mid + 1; - } - - return result; + return (FT_UInt)enc->offset[( charcodeRow - enc->firstRow ) * + ( enc->lastCol - enc->firstCol + 1 ) + + charcodeCol - enc->firstCol]; } @@ -141,52 +132,43 @@ THE SOFTWARE. pcf_cmap_char_next( FT_CMap pcfcmap, /* PCF_CMap */ FT_UInt32 *acharcode ) { - PCF_CMap cmap = (PCF_CMap)pcfcmap; - PCF_Encoding encodings = cmap->encodings; - FT_ULong min, max, mid; - FT_ULong charcode = *acharcode + 1; - FT_UInt result = 0; - + PCF_CMap cmap = (PCF_CMap)pcfcmap; + PCF_Enc enc = cmap->enc; + FT_UInt32 charcode = *acharcode; + FT_UShort charcodeRow; + FT_UShort charcodeCol; + FT_Int result = 0; - min = 0; - max = cmap->num_encodings; - while ( min < max ) + while ( charcode < (FT_UInt32)( enc->lastRow * 256 + enc->lastCol ) ) { - FT_ULong code; + charcode++; + if ( charcode < (FT_UInt32)( enc->firstRow * 256 + enc->firstCol ) ) + charcode = (FT_UInt32)( enc->firstRow * 256 + enc->firstCol ); - mid = ( min + max ) >> 1; - code = (FT_ULong)encodings[mid].enc; + charcodeRow = (FT_UShort)( charcode >> 8 ); + charcodeCol = (FT_UShort)( charcode & 0xFF ); - if ( charcode == code ) + if ( charcodeCol < enc->firstCol ) + charcodeCol = enc->firstCol; + else if ( charcodeCol > enc->lastCol ) { - result = encodings[mid].glyph + 1; - goto Exit; + charcodeRow++; + charcodeCol = enc->firstCol; } - if ( charcode < code ) - max = mid; - else - min = mid + 1; - } + charcode = (FT_UInt32)( charcodeRow * 256 + charcodeCol ); - charcode = 0; - if ( min < cmap->num_encodings ) - { - charcode = (FT_ULong)encodings[min].enc; - result = encodings[min].glyph + 1; + result = (FT_UInt)enc->offset[( charcodeRow - enc->firstRow ) * + ( enc->lastCol - enc->firstCol + 1 ) + + charcodeCol - enc->firstCol]; + if ( result != 0xFFFFU ) + break; } - Exit: - if ( charcode > 0xFFFFFFFFUL ) - { - FT_TRACE1(( "pcf_cmap_char_next: charcode 0x%x > 32bit API" )); - *acharcode = 0; - /* XXX: result should be changed to indicate an overflow error */ - } - else - *acharcode = (FT_UInt32)charcode; + *acharcode = charcode; + return result; } @@ -216,8 +198,8 @@ THE SOFTWARE. memory = FT_FACE_MEMORY( face ); - FT_FREE( face->encodings ); FT_FREE( face->metrics ); + FT_FREE( face->enc.offset ); /* free properties */ if ( face->properties ) @@ -512,9 +494,6 @@ THE SOFTWARE. stream = face->root.stream; - if ( glyph_index > 0 ) - glyph_index--; - metric = face->metrics + glyph_index; bitmap->rows = (unsigned int)( metric->ascent + @@ -601,11 +580,11 @@ THE SOFTWARE. } - /* - * - * BDF SERVICE - * - */ + /* + * + * BDF SERVICE + * + */ static FT_Error pcf_get_bdf_property( PCF_Face face, @@ -633,9 +612,9 @@ THE SOFTWARE. } /* - * The PCF driver loads all properties as signed integers. - * This really doesn't seem to be a problem, because this is - * sufficient for any meaningful values. + * The PCF driver loads all properties as signed integers. + * This really doesn't seem to be a problem, because this is + * sufficient for any meaningful values. */ aproperty->type = BDF_PROPERTY_TYPE_INTEGER; aproperty->u.integer = (FT_Int32)prop->value.l; @@ -668,7 +647,7 @@ THE SOFTWARE. /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ static FT_Error @@ -777,11 +756,11 @@ THE SOFTWARE. (FT_Properties_GetFunc)pcf_property_get ) /* get_property */ - /* - * - * SERVICE LIST - * - */ + /* + * + * SERVICE LIST + * + */ static const FT_ServiceDescRec pcf_services[] = { diff --git a/src/3rdparty/freetype/src/pcf/pcfdrivr.h b/src/3rdparty/freetype/src/pcf/pcfdrivr.h index 29d30497cd..73db0823d2 100644 --- a/src/3rdparty/freetype/src/pcf/pcfdrivr.h +++ b/src/3rdparty/freetype/src/pcf/pcfdrivr.h @@ -31,11 +31,8 @@ THE SOFTWARE. #include <ft2build.h> #include FT_INTERNAL_DRIVER_H -FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Driver_ClassRec ) pcf_driver_class; diff --git a/src/3rdparty/freetype/src/pcf/pcferror.h b/src/3rdparty/freetype/src/pcf/pcferror.h index add8ef2230..2e69d1d219 100644 --- a/src/3rdparty/freetype/src/pcf/pcferror.h +++ b/src/3rdparty/freetype/src/pcf/pcferror.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* pcferror.h */ -/* */ -/* PCF error codes (specification only). */ -/* */ -/* Copyright 2001, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PCF error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * pcferror.h + * + * PCF error codes (specification only). + * + * Copyright 2001, 2012 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PCF error enumeration constants. + * + */ #ifndef PCFERROR_H_ #define PCFERROR_H_ diff --git a/src/3rdparty/freetype/src/pcf/pcfread.c b/src/3rdparty/freetype/src/pcf/pcfread.c index 537da0dc79..2ffe22d71c 100644 --- a/src/3rdparty/freetype/src/pcf/pcfread.c +++ b/src/3rdparty/freetype/src/pcf/pcfread.c @@ -37,14 +37,14 @@ THE SOFTWARE. #include "pcferror.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_pcfread +#define FT_COMPONENT pcfread #ifdef FT_DEBUG_LEVEL_TRACE @@ -178,23 +178,23 @@ THE SOFTWARE. } /* - * We now check whether the `size' and `offset' values are reasonable: - * `offset' + `size' must not exceed the stream size. + * We now check whether the `size' and `offset' values are reasonable: + * `offset' + `size' must not exceed the stream size. * - * Note, however, that X11's `pcfWriteFont' routine (used by the - * `bdftopcf' program to create PDF font files) has two special - * features. + * Note, however, that X11's `pcfWriteFont' routine (used by the + * `bdftopcf' program to create PCF font files) has two special + * features. * - * - It always assigns the accelerator table a size of 100 bytes in the - * TOC, regardless of its real size, which can vary between 34 and 72 - * bytes. + * - It always assigns the accelerator table a size of 100 bytes in the + * TOC, regardless of its real size, which can vary between 34 and 72 + * bytes. * - * - Due to the way the routine is designed, it ships out the last font - * table with its real size, ignoring the TOC's size value. Since - * the TOC size values are always rounded up to a multiple of 4, the - * difference can be up to three bytes for all tables except the - * accelerator table, for which the difference can be as large as 66 - * bytes. + * - Due to the way the routine is designed, it ships out the last font + * table with its real size, ignoring the TOC's size value. Since + * the TOC size values are always rounded up to a multiple of 4, the + * difference can be up to three bytes for all tables except the + * accelerator table, for which the difference can be as large as 66 + * bytes. * */ @@ -743,33 +743,39 @@ THE SOFTWARE. if ( !orig_nmetrics ) return FT_THROW( Invalid_Table ); - /* PCF is a format from ancient times; Unicode was in its */ - /* infancy, and widely used two-byte character sets for CJK */ - /* scripts (Big 5, GB 2312, JIS X 0208, etc.) did have at most */ - /* 15000 characters. Even the more exotic CNS 11643 and CCCII */ - /* standards, which were essentially three-byte character sets, */ - /* provided less then 65536 assigned characters. */ - /* */ - /* While technically possible to have a larger number of glyphs */ - /* in PCF files, we thus limit the number to 65536. */ - if ( orig_nmetrics > 65536 ) + /* + * PCF is a format from ancient times; Unicode was in its infancy, and + * widely used two-byte character sets for CJK scripts (Big 5, GB 2312, + * JIS X 0208, etc.) did have at most 15000 characters. Even the more + * exotic CNS 11643 and CCCII standards, which were essentially + * three-byte character sets, provided less then 65536 assigned + * characters. + * + * While technically possible to have a larger number of glyphs in PCF + * files, we thus limit the number to 65535, taking into account that we + * synthesize the metrics of glyph 0 to be a copy of the `default + * character', and that 0xFFFF in the encodings array indicates a + * missing glyph. + */ + if ( orig_nmetrics > 65534 ) { FT_TRACE0(( "pcf_get_metrics:" - " only loading first 65536 metrics\n" )); - nmetrics = 65536; + " only loading first 65534 metrics\n" )); + nmetrics = 65534; } else nmetrics = orig_nmetrics; - face->nmetrics = nmetrics; + face->nmetrics = nmetrics + 1; - if ( FT_NEW_ARRAY( face->metrics, nmetrics ) ) + if ( FT_NEW_ARRAY( face->metrics, face->nmetrics ) ) return error; - metrics = face->metrics; + /* we handle glyph index 0 later on */ + metrics = face->metrics + 1; FT_TRACE4(( "\n" )); - for ( i = 0; i < nmetrics; i++, metrics++ ) + for ( i = 1; i < face->nmetrics; i++, metrics++ ) { FT_TRACE5(( " idx %ld:", i )); error = pcf_get_metric( stream, format, metrics ); @@ -808,12 +814,10 @@ THE SOFTWARE. pcf_get_bitmaps( FT_Stream stream, PCF_Face face ) { - FT_Error error; - FT_Memory memory = FT_FACE( face )->memory; - FT_Long* offsets = NULL; - FT_Long bitmapSizes[GLYPHPADOPTIONS]; - FT_ULong format, size; - FT_ULong nbitmaps, orig_nbitmaps, i, sizebitmaps = 0; + FT_Error error; + FT_ULong bitmapSizes[GLYPHPADOPTIONS]; + FT_ULong format, size, pos; + FT_ULong nbitmaps, orig_nbitmaps, i, sizebitmaps = 0; error = pcf_seek_to_table_type( stream, @@ -859,31 +863,46 @@ THE SOFTWARE. FT_TRACE4(( " number of bitmaps: %ld\n", orig_nbitmaps )); /* see comment in `pcf_get_metrics' */ - if ( orig_nbitmaps > 65536 ) + if ( orig_nbitmaps > 65534 ) { FT_TRACE0(( "pcf_get_bitmaps:" - " only loading first 65536 bitmaps\n" )); - nbitmaps = 65536; + " only loading first 65534 bitmaps\n" )); + nbitmaps = 65534; } else nbitmaps = orig_nbitmaps; - if ( nbitmaps != face->nmetrics ) + /* no extra bitmap for glyph 0 */ + if ( nbitmaps != face->nmetrics - 1 ) return FT_THROW( Invalid_File_Format ); - if ( FT_NEW_ARRAY( offsets, nbitmaps ) ) - return error; + /* start position of bitmap data */ + pos = stream->pos + nbitmaps * 4 + 4 * 4; FT_TRACE5(( "\n" )); - for ( i = 0; i < nbitmaps; i++ ) + for ( i = 1; i <= nbitmaps; i++ ) { + FT_ULong offset; + + if ( PCF_BYTE_ORDER( format ) == MSBFirst ) - (void)FT_READ_LONG( offsets[i] ); + (void)FT_READ_ULONG( offset ); else - (void)FT_READ_LONG_LE( offsets[i] ); + (void)FT_READ_ULONG_LE( offset ); + + FT_TRACE5(( " bitmap %lu: offset %lu (0x%lX)\n", + i, offset, offset )); - FT_TRACE5(( " bitmap %ld: offset %ld (0x%lX)\n", - i, offsets[i], offsets[i] )); + /* right now, we only check the offset with a rough estimate; */ + /* actual bitmaps are only loaded on demand */ + if ( offset > size ) + { + FT_TRACE0(( "pcf_get_bitmaps:" + " invalid offset to bitmap data of glyph %lu\n", i )); + face->metrics[i].bits = pos; + } + else + face->metrics[i].bits = pos + offset; } if ( error ) goto Bail; @@ -891,62 +910,84 @@ THE SOFTWARE. for ( i = 0; i < GLYPHPADOPTIONS; i++ ) { if ( PCF_BYTE_ORDER( format ) == MSBFirst ) - (void)FT_READ_LONG( bitmapSizes[i] ); + (void)FT_READ_ULONG( bitmapSizes[i] ); else - (void)FT_READ_LONG_LE( bitmapSizes[i] ); + (void)FT_READ_ULONG_LE( bitmapSizes[i] ); if ( error ) goto Bail; - sizebitmaps = (FT_ULong)bitmapSizes[PCF_GLYPH_PAD_INDEX( format )]; + sizebitmaps = bitmapSizes[PCF_GLYPH_PAD_INDEX( format )]; - FT_TRACE4(( " %ld-bit padding implies a size of %ld\n", + FT_TRACE4(( " %ld-bit padding implies a size of %lu\n", 8 << i, bitmapSizes[i] )); } - FT_TRACE4(( " %ld bitmaps, using %ld-bit padding\n", + FT_TRACE4(( " %lu bitmaps, using %ld-bit padding\n", nbitmaps, 8 << PCF_GLYPH_PAD_INDEX( format ) )); - FT_TRACE4(( " bitmap size: %ld\n", sizebitmaps )); + FT_TRACE4(( " bitmap size: %lu\n", sizebitmaps )); FT_UNUSED( sizebitmaps ); /* only used for debugging */ - /* right now, we only check the bitmap offsets; */ - /* actual bitmaps are only loaded on demand */ - for ( i = 0; i < nbitmaps; i++ ) - { - /* rough estimate */ - if ( ( offsets[i] < 0 ) || - ( (FT_ULong)offsets[i] > size ) ) - { - FT_TRACE0(( "pcf_get_bitmaps:" - " invalid offset to bitmap data of glyph %ld\n", i )); - } - else - face->metrics[i].bits = stream->pos + (FT_ULong)offsets[i]; - } - face->bitmapsFormat = format; Bail: - FT_FREE( offsets ); return error; } + /* + * This file uses X11 terminology for PCF data; an `encoding' in X11 speak + * is the same as a character code in FreeType speak. + */ +#define PCF_ENC_SIZE 10 + + static + const FT_Frame_Field pcf_enc_header[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE PCF_EncRec + + FT_FRAME_START( PCF_ENC_SIZE ), + FT_FRAME_USHORT_LE( firstCol ), + FT_FRAME_USHORT_LE( lastCol ), + FT_FRAME_USHORT_LE( firstRow ), + FT_FRAME_USHORT_LE( lastRow ), + FT_FRAME_USHORT_LE( defaultChar ), + FT_FRAME_END + }; + + + static + const FT_Frame_Field pcf_enc_msb_header[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE PCF_EncRec + + FT_FRAME_START( PCF_ENC_SIZE ), + FT_FRAME_USHORT( firstCol ), + FT_FRAME_USHORT( lastCol ), + FT_FRAME_USHORT( firstRow ), + FT_FRAME_USHORT( lastRow ), + FT_FRAME_USHORT( defaultChar ), + FT_FRAME_END + }; + + static FT_Error pcf_get_encodings( FT_Stream stream, PCF_Face face ) { - FT_Error error; - FT_Memory memory = FT_FACE( face )->memory; - FT_ULong format, size; - int firstCol, lastCol; - int firstRow, lastRow; - FT_ULong nencoding; - FT_UShort encodingOffset; - int i, j; - FT_ULong k; - PCF_Encoding encoding = NULL; + FT_Error error; + FT_Memory memory = FT_FACE( face )->memory; + FT_ULong format, size; + PCF_Enc enc = &face->enc; + FT_ULong nencoding; + FT_UShort* offset; + FT_UShort defaultCharRow, defaultCharCol; + FT_UShort encodingOffset, defaultCharEncodingOffset; + FT_UShort i, j; + FT_Byte* pos; error = pcf_seek_to_table_type( stream, @@ -956,105 +997,148 @@ THE SOFTWARE. &format, &size ); if ( error ) - return error; + goto Bail; - error = FT_Stream_EnterFrame( stream, 14 ); - if ( error ) - return error; + if ( FT_READ_ULONG_LE( format ) ) + goto Bail; - format = FT_GET_ULONG_LE(); + FT_TRACE4(( "pcf_get_encodings:\n" + " format: 0x%lX (%s)\n", + format, + PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" )); + + if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) && + !PCF_FORMAT_MATCH( format, PCF_BDF_ENCODINGS ) ) + return FT_THROW( Invalid_File_Format ); if ( PCF_BYTE_ORDER( format ) == MSBFirst ) { - firstCol = FT_GET_SHORT(); - lastCol = FT_GET_SHORT(); - firstRow = FT_GET_SHORT(); - lastRow = FT_GET_SHORT(); - face->defaultChar = FT_GET_SHORT(); + if ( FT_STREAM_READ_FIELDS( pcf_enc_msb_header, enc ) ) + goto Bail; } else { - firstCol = FT_GET_SHORT_LE(); - lastCol = FT_GET_SHORT_LE(); - firstRow = FT_GET_SHORT_LE(); - lastRow = FT_GET_SHORT_LE(); - face->defaultChar = FT_GET_SHORT_LE(); + if ( FT_STREAM_READ_FIELDS( pcf_enc_header, enc ) ) + goto Bail; } - FT_Stream_ExitFrame( stream ); - - FT_TRACE4(( "pcf_get_encodings:\n" - " format: 0x%lX (%s)\n", - format, - PCF_BYTE_ORDER( format ) == MSBFirst ? "MSB" : "LSB" )); - - if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) - return FT_THROW( Invalid_File_Format ); - FT_TRACE4(( " firstCol 0x%X, lastCol 0x%X\n" - " firstRow 0x%X, lastRow 0x%X\n", - firstCol, lastCol, - firstRow, lastRow )); + " firstRow 0x%X, lastRow 0x%X\n" + " defaultChar 0x%X\n", + enc->firstCol, enc->lastCol, + enc->firstRow, enc->lastRow, + enc->defaultChar )); /* sanity checks; we limit numbers of rows and columns to 256 */ - if ( firstCol < 0 || - firstCol > lastCol || - lastCol > 0xFF || - firstRow < 0 || - firstRow > lastRow || - lastRow > 0xFF ) + if ( enc->firstCol > enc->lastCol || + enc->lastCol > 0xFF || + enc->firstRow > enc->lastRow || + enc->lastRow > 0xFF ) return FT_THROW( Invalid_Table ); - nencoding = (FT_ULong)( lastCol - firstCol + 1 ) * - (FT_ULong)( lastRow - firstRow + 1 ); + nencoding = (FT_ULong)( enc->lastCol - enc->firstCol + 1 ) * + (FT_ULong)( enc->lastRow - enc->firstRow + 1 ); - if ( FT_NEW_ARRAY( encoding, nencoding ) ) - return error; + if ( FT_NEW_ARRAY( enc->offset, nencoding ) ) + goto Bail; error = FT_Stream_EnterFrame( stream, 2 * nencoding ); if ( error ) - goto Bail; + goto Exit; FT_TRACE5(( "\n" )); - k = 0; - for ( i = firstRow; i <= lastRow; i++ ) + defaultCharRow = enc->defaultChar >> 8; + defaultCharCol = enc->defaultChar & 0xFF; + + /* validate default character */ + if ( defaultCharRow < enc->firstRow || + defaultCharRow > enc->lastRow || + defaultCharCol < enc->firstCol || + defaultCharCol > enc->lastCol ) + { + enc->defaultChar = enc->firstRow * 256U + enc->firstCol; + FT_TRACE0(( "pcf_get_encodings:" + " Invalid default character set to %u\n", + enc->defaultChar )); + + defaultCharRow = enc->firstRow; + defaultCharCol = enc->firstCol; + } + + /* + * FreeType mandates that glyph index 0 is the `undefined glyph', which + * PCF calls the `default character'. However, FreeType needs glyph + * index 0 to be used for the undefined glyph only, which is is not the + * case for PCF. For this reason, we add one slot for glyph index 0 and + * simply copy the default character to it. + * + * `stream->cursor' still points to the beginning of the frame; we can + * thus easily get the offset to the default character. + */ + pos = stream->cursor + + 2 * ( ( defaultCharRow - enc->firstRow ) * + ( enc->lastCol - enc->firstCol + 1 ) + + defaultCharCol - enc->firstCol ); + + if ( PCF_BYTE_ORDER( format ) == MSBFirst ) + defaultCharEncodingOffset = FT_PEEK_USHORT( pos ); + else + defaultCharEncodingOffset = FT_PEEK_USHORT_LE( pos ); + + if ( defaultCharEncodingOffset == 0xFFFF ) + { + FT_TRACE0(( "pcf_get_encodings:" + " No glyph for default character,\n" + " " + " setting it to the first glyph of the font\n" )); + defaultCharEncodingOffset = 1; + } + else + { + defaultCharEncodingOffset++; + + if ( defaultCharEncodingOffset >= face->nmetrics ) + { + FT_TRACE0(( "pcf_get_encodings:" + " Invalid glyph index for default character,\n" + " " + " setting it to the first glyph of the font\n" )); + defaultCharEncodingOffset = 1; + } + } + + /* copy metrics of default character to index 0 */ + face->metrics[0] = face->metrics[defaultCharEncodingOffset]; + + /* now loop over all values */ + offset = enc->offset; + for ( i = enc->firstRow; i <= enc->lastRow; i++ ) { - for ( j = firstCol; j <= lastCol; j++ ) + for ( j = enc->firstCol; j <= enc->lastCol; j++ ) { /* X11's reference implementation uses the equivalent to */ /* `FT_GET_SHORT', however PCF fonts with more than 32768 */ - /* characters (e.g. `unifont.pcf') clearly show that an */ + /* characters (e.g., `unifont.pcf') clearly show that an */ /* unsigned value is needed. */ if ( PCF_BYTE_ORDER( format ) == MSBFirst ) encodingOffset = FT_GET_USHORT(); else encodingOffset = FT_GET_USHORT_LE(); - if ( encodingOffset != 0xFFFFU ) - { - encoding[k].enc = i * 256 + j; - encoding[k].glyph = encodingOffset; - - FT_TRACE5(( " code %d (0x%04X): idx %d\n", - encoding[k].enc, encoding[k].enc, encoding[k].glyph )); - - k++; - } + /* everything is off by 1 due to the artificial glyph 0 */ + *offset++ = encodingOffset == 0xFFFF ? 0xFFFF + : encodingOffset + 1; } } FT_Stream_ExitFrame( stream ); - if ( FT_RENEW_ARRAY( encoding, nencoding, k ) ) - goto Bail; - - face->nencodings = k; - face->encodings = encoding; - return error; + Exit: + FT_FREE( enc->offset ); + Bail: - FT_FREE( encoding ); return error; } @@ -1228,9 +1312,8 @@ THE SOFTWARE. PCF_Property prop; - size_t nn, len; - char* strings[4] = { NULL, NULL, NULL, NULL }; - size_t lengths[4]; + const char* strings[4] = { NULL, NULL, NULL, NULL }; + size_t lengths[4], nn, len; face->style_flags = 0; @@ -1242,8 +1325,8 @@ THE SOFTWARE. { face->style_flags |= FT_STYLE_FLAG_ITALIC; strings[2] = ( *(prop->value.atom) == 'O' || - *(prop->value.atom) == 'o' ) ? (char *)"Oblique" - : (char *)"Italic"; + *(prop->value.atom) == 'o' ) ? "Oblique" + : "Italic"; } prop = pcf_find_property( pcf, "WEIGHT_NAME" ); @@ -1251,20 +1334,20 @@ THE SOFTWARE. ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) ) { face->style_flags |= FT_STYLE_FLAG_BOLD; - strings[1] = (char*)"Bold"; + strings[1] = "Bold"; } prop = pcf_find_property( pcf, "SETWIDTH_NAME" ); if ( prop && prop->isString && *(prop->value.atom) && !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) - strings[3] = (char*)( prop->value.atom ); + strings[3] = (const char*)( prop->value.atom ); prop = pcf_find_property( pcf, "ADD_STYLE_NAME" ); if ( prop && prop->isString && *(prop->value.atom) && !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) - strings[0] = (char*)( prop->value.atom ); + strings[0] = (const char*)( prop->value.atom ); for ( len = 0, nn = 0; nn < 4; nn++ ) { @@ -1278,7 +1361,7 @@ THE SOFTWARE. if ( len == 0 ) { - strings[0] = (char*)"Regular"; + strings[0] = "Regular"; lengths[0] = ft_strlen( strings[0] ); len = lengths[0] + 1; } @@ -1294,7 +1377,7 @@ THE SOFTWARE. for ( nn = 0; nn < 4; nn++ ) { - char* src = strings[nn]; + const char* src = strings[nn]; len = lengths[nn]; @@ -1397,8 +1480,7 @@ THE SOFTWARE. root->face_flags |= FT_FACE_FLAG_FIXED_SIZES | - FT_FACE_FLAG_HORIZONTAL | - FT_FACE_FLAG_FAST_GLYPHS; + FT_FACE_FLAG_HORIZONTAL; if ( face->accel.constantWidth ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; @@ -1482,14 +1564,7 @@ THE SOFTWARE. else root->family_name = NULL; - /* - * Note: We shift all glyph indices by +1 since we must - * respect the convention that glyph 0 always corresponds - * to the `missing glyph'. - * - * This implies bumping the number of `available' glyphs by 1. - */ - root->num_glyphs = (FT_Long)( face->nmetrics + 1 ); + root->num_glyphs = (FT_Long)face->nmetrics; root->num_fixed_sizes = 1; if ( FT_NEW_ARRAY( root->available_sizes, 1 ) ) diff --git a/src/3rdparty/freetype/src/pcf/pcfutil.c b/src/3rdparty/freetype/src/pcf/pcfutil.c index 0451ee8def..045c42d60f 100644 --- a/src/3rdparty/freetype/src/pcf/pcfutil.c +++ b/src/3rdparty/freetype/src/pcf/pcfutil.c @@ -37,7 +37,7 @@ in this Software without prior written authorization from The Open Group. /* - * Invert bit order within each BYTE of an array. + * Invert bit order within each BYTE of an array. */ FT_LOCAL_DEF( void ) @@ -59,7 +59,7 @@ in this Software without prior written authorization from The Open Group. /* - * Invert byte order within each 16-bits of an array. + * Invert byte order within each 16-bits of an array. */ FT_LOCAL_DEF( void ) @@ -78,7 +78,7 @@ in this Software without prior written authorization from The Open Group. } /* - * Invert byte order within each 32-bits of an array. + * Invert byte order within each 32-bits of an array. */ FT_LOCAL_DEF( void ) diff --git a/src/3rdparty/freetype/src/pfr/Jamfile b/src/3rdparty/freetype/src/pfr/Jamfile index cb55a7ee89..fbca8065c4 100644 --- a/src/3rdparty/freetype/src/pfr/Jamfile +++ b/src/3rdparty/freetype/src/pfr/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pfr Jamfile # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/pfr/module.mk b/src/3rdparty/freetype/src/pfr/module.mk index 27fec8e5f6..30d876d4c8 100644 --- a/src/3rdparty/freetype/src/pfr/module.mk +++ b/src/3rdparty/freetype/src/pfr/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/pfr/pfr.c b/src/3rdparty/freetype/src/pfr/pfr.c index 1760882fcd..6d885ea47f 100644 --- a/src/3rdparty/freetype/src/pfr/pfr.c +++ b/src/3rdparty/freetype/src/pfr/pfr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfr.c */ -/* */ -/* FreeType PFR driver component. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfr.c + * + * FreeType PFR driver component. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.c b/src/3rdparty/freetype/src/pfr/pfrcmap.c index 60643780a1..bfa1b9ea05 100644 --- a/src/3rdparty/freetype/src/pfr/pfrcmap.c +++ b/src/3rdparty/freetype/src/pfr/pfrcmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrcmap.c */ -/* */ -/* FreeType PFR cmap handling (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrcmap.c + * + * FreeType PFR cmap handling (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/pfr/pfrcmap.h b/src/3rdparty/freetype/src/pfr/pfrcmap.h index c70a0c83c5..1e203a0514 100644 --- a/src/3rdparty/freetype/src/pfr/pfrcmap.h +++ b/src/3rdparty/freetype/src/pfr/pfrcmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrcmap.h */ -/* */ -/* FreeType PFR cmap handling (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrcmap.h + * + * FreeType PFR cmap handling (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFRCMAP_H_ diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.c b/src/3rdparty/freetype/src/pfr/pfrdrivr.c index 6c7e50128a..f67eebf118 100644 --- a/src/3rdparty/freetype/src/pfr/pfrdrivr.c +++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrdrivr.c */ -/* */ -/* FreeType PFR driver interface (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrdrivr.c + * + * FreeType PFR driver interface (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -57,10 +57,10 @@ } - /* - * PFR METRICS SERVICE - * - */ + /* + * PFR METRICS SERVICE + * + */ FT_CALLBACK_DEF( FT_Error ) pfr_get_advance( FT_Face pfrface, /* PFR_Face */ @@ -145,10 +145,10 @@ }; - /* - * SERVICE LIST - * - */ + /* + * SERVICE LIST + * + */ static const FT_ServiceDescRec pfr_services[] = { diff --git a/src/3rdparty/freetype/src/pfr/pfrdrivr.h b/src/3rdparty/freetype/src/pfr/pfrdrivr.h index cab852789b..33b7b9413f 100644 --- a/src/3rdparty/freetype/src/pfr/pfrdrivr.h +++ b/src/3rdparty/freetype/src/pfr/pfrdrivr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrdrivr.h */ -/* */ -/* High-level Type PFR driver interface (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrdrivr.h + * + * High-level Type PFR driver interface (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFRDRIVR_H_ @@ -26,14 +26,8 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - - FT_EXPORT_VAR( const FT_Driver_ClassRec ) pfr_driver_class; - FT_END_HEADER diff --git a/src/3rdparty/freetype/src/pfr/pfrerror.h b/src/3rdparty/freetype/src/pfr/pfrerror.h index 7027c818e8..4829cfc000 100644 --- a/src/3rdparty/freetype/src/pfr/pfrerror.h +++ b/src/3rdparty/freetype/src/pfr/pfrerror.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* pfrerror.h */ -/* */ -/* PFR error codes (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PFR error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * pfrerror.h + * + * PFR error codes (specification only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PFR error enumeration constants. + * + */ #ifndef PFRERROR_H_ #define PFRERROR_H_ diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.c b/src/3rdparty/freetype/src/pfr/pfrgload.c index b7990196b6..6ef5856a8d 100644 --- a/src/3rdparty/freetype/src/pfr/pfrgload.c +++ b/src/3rdparty/freetype/src/pfr/pfrgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrgload.c */ -/* */ -/* FreeType PFR glyph loader (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrgload.c + * + * FreeType PFR glyph loader (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "pfrgload.h" @@ -24,7 +24,7 @@ #include "pfrerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pfr +#define FT_COMPONENT pfr /*************************************************************************/ @@ -359,9 +359,9 @@ FT_UInt format, format_low, args_format = 0, args_count, n; - /***************************************************************/ - /* read instruction */ - /* */ + /**************************************************************** + * read instruction + */ PFR_CHECK( 1 ); format = PFR_NEXT_BYTE( p ); format_low = format & 15; @@ -426,9 +426,9 @@ args_format = format_low; } - /***********************************************************/ - /* now read arguments */ - /* */ + /************************************************************ + * now read arguments + */ cur = pos; for ( n = 0; n < args_count; n++ ) { @@ -513,9 +513,9 @@ FT_TRACE7(( "\n" )); - /***********************************************************/ - /* finally, execute instruction */ - /* */ + /************************************************************ + * finally, execute instruction + */ switch ( format >> 4 ) { case 0: /* end glyph => EXIT */ diff --git a/src/3rdparty/freetype/src/pfr/pfrgload.h b/src/3rdparty/freetype/src/pfr/pfrgload.h index 01f48d7706..d0e1420b67 100644 --- a/src/3rdparty/freetype/src/pfr/pfrgload.h +++ b/src/3rdparty/freetype/src/pfr/pfrgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrgload.h */ -/* */ -/* FreeType PFR glyph loader (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrgload.h + * + * FreeType PFR glyph loader (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFRGLOAD_H_ diff --git a/src/3rdparty/freetype/src/pfr/pfrload.c b/src/3rdparty/freetype/src/pfr/pfrload.c index 2776da462a..ccf0b7e1f8 100644 --- a/src/3rdparty/freetype/src/pfr/pfrload.c +++ b/src/3rdparty/freetype/src/pfr/pfrload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrload.c */ -/* */ -/* FreeType PFR loader (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrload.c + * + * FreeType PFR loader (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "pfrload.h" @@ -23,92 +23,92 @@ #include "pfrerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pfr +#define FT_COMPONENT pfr /* - * The overall structure of a PFR file is as follows. + * The overall structure of a PFR file is as follows. * - * PFR header - * 58 bytes (contains nPhysFonts) + * PFR header + * 58 bytes (contains nPhysFonts) * - * Logical font directory (size at most 2^16 bytes) - * 2 bytes (nLogFonts) - * + nLogFonts * 5 bytes + * Logical font directory (size at most 2^16 bytes) + * 2 bytes (nLogFonts) + * + nLogFonts * 5 bytes * - * ==> nLogFonts <= 13106 + * ==> nLogFonts <= 13106 * - * Logical font section (size at most 2^24 bytes) - * nLogFonts * logFontRecord + * Logical font section (size at most 2^24 bytes) + * nLogFonts * logFontRecord * - * logFontRecord (size at most 2^16 bytes) - * 12 bytes (fontMatrix) - * + 1 byte (flags) - * + 0-5 bytes (depending on `flags') - * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags') - * + 5 bytes (physical font info) - * + 0-1 bytes (depending on PFR header) + * logFontRecord (size at most 2^16 bytes) + * 12 bytes (fontMatrix) + * + 1 byte (flags) + * + 0-5 bytes (depending on `flags') + * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags') + * + 5 bytes (physical font info) + * + 0-1 bytes (depending on PFR header) * - * ==> minimum size 18 bytes + * ==> minimum size 18 bytes * - * Physical font section (size at most 2^24 bytes) - * nPhysFonts * (physFontRecord - * + nBitmapSizes * nBmapChars * bmapCharRecord) + * Physical font section (size at most 2^24 bytes) + * nPhysFonts * (physFontRecord + * + nBitmapSizes * nBmapChars * bmapCharRecord) * - * physFontRecord (size at most 2^24 bytes) - * 14 bytes (font info) - * + 1 byte (flags) - * + 0-2 (depending on `flags') - * + 0-? (structure too complicated to be shown here; depending on - * `flags'; contains `nBitmapSizes' and `nBmapChars') - * + 3 bytes (nAuxBytes) - * + nAuxBytes - * + 1 byte (nBlueValues) - * + 2 * nBlueValues - * + 6 bytes (hinting data) - * + 2 bytes (nCharacters) - * + nCharacters * (4-10 bytes) (depending on `flags') + * physFontRecord (size at most 2^24 bytes) + * 14 bytes (font info) + * + 1 byte (flags) + * + 0-2 (depending on `flags') + * + 0-? (structure too complicated to be shown here; depending on + * `flags'; contains `nBitmapSizes' and `nBmapChars') + * + 3 bytes (nAuxBytes) + * + nAuxBytes + * + 1 byte (nBlueValues) + * + 2 * nBlueValues + * + 6 bytes (hinting data) + * + 2 bytes (nCharacters) + * + nCharacters * (4-10 bytes) (depending on `flags') * - * ==> minimum size 27 bytes + * ==> minimum size 27 bytes * - * bmapCharRecord - * 4-7 bytes + * bmapCharRecord + * 4-7 bytes * - * Glyph program strings (three possible types: simpleGps, compoundGps, - * and bitmapGps; size at most 2^24 bytes) - * simpleGps (size at most 2^16 bytes) - * 1 byte (flags) - * 1-2 bytes (n[XY]orus, depending on `flags') - * 0-(64+512*2) = 0-1088 bytes (depending on `n[XY]orus') - * 0-? (structure too complicated to be shown here; depending on - * `flags') - * 1-? glyph data (faintly resembling PS Type 1 charstrings) + * Glyph program strings (three possible types: simpleGps, compoundGps, + * and bitmapGps; size at most 2^24 bytes) + * simpleGps (size at most 2^16 bytes) + * 1 byte (flags) + * 1-2 bytes (n[XY]orus, depending on `flags') + * 0-(64+512*2) = 0-1088 bytes (depending on `n[XY]orus') + * 0-? (structure too complicated to be shown here; depending on + * `flags') + * 1-? glyph data (faintly resembling PS Type 1 charstrings) * - * ==> minimum size 3 bytes + * ==> minimum size 3 bytes * - * compoundGps (size at most 2^16 bytes) - * 1 byte (nElements <= 63, flags) - * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags') - * + nElements * (6-14 bytes) + * compoundGps (size at most 2^16 bytes) + * 1 byte (nElements <= 63, flags) + * + 0-(1+255*(2+255)) = 0-65536 (depending on `flags') + * + nElements * (6-14 bytes) * - * bitmapGps (size at most 2^16 bytes) - * 1 byte (flags) - * 3-13 bytes (position info, depending on `flags') - * 0-? bitmap data + * bitmapGps (size at most 2^16 bytes) + * 1 byte (flags) + * 3-13 bytes (position info, depending on `flags') + * 0-? bitmap data * - * ==> minimum size 4 bytes + * ==> minimum size 4 bytes * - * PFR trailer - * 8 bytes + * PFR trailer + * 8 bytes * * - * ==> minimum size of a valid PFR: - * 58 (header) - * + 2 (nLogFonts) - * + 27 (1 physFontRecord) - * + 8 (trailer) - * ----- - * 95 bytes + * ==> minimum size of a valid PFR: + * 58 (header) + * + 2 (nLogFonts) + * + 27 (1 physFontRecord) + * + 8 (trailer) + * ----- + * 95 bytes * */ diff --git a/src/3rdparty/freetype/src/pfr/pfrload.h b/src/3rdparty/freetype/src/pfr/pfrload.h index 36e809a762..2e7ffd0127 100644 --- a/src/3rdparty/freetype/src/pfr/pfrload.h +++ b/src/3rdparty/freetype/src/pfr/pfrload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrload.h */ -/* */ -/* FreeType PFR loader (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrload.h + * + * FreeType PFR loader (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFRLOAD_H_ diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.c b/src/3rdparty/freetype/src/pfr/pfrobjs.c index 737b97b5ff..9765f95c2f 100644 --- a/src/3rdparty/freetype/src/pfr/pfrobjs.c +++ b/src/3rdparty/freetype/src/pfr/pfrobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrobjs.c */ -/* */ -/* FreeType PFR object methods (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrobjs.c + * + * FreeType PFR object methods (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "pfrobjs.h" @@ -29,7 +29,7 @@ #include "pfrerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pfr +#define FT_COMPONENT pfr /*************************************************************************/ @@ -122,7 +122,7 @@ stream, (FT_UInt)( face_index & 0xFFFF ), face->header.log_dir_offset, - FT_BOOL( face->header.phy_font_max_size_high != 0 ) ); + FT_BOOL( face->header.phy_font_max_size_high ) ); if ( error ) goto Exit; @@ -370,7 +370,7 @@ FT_Bool scaling; - scaling = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ); + scaling = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) ); /* copy outline data */ *outline = slot->glyph.loader->base.outline; @@ -378,7 +378,7 @@ outline->flags &= ~FT_OUTLINE_OWNER; outline->flags |= FT_OUTLINE_REVERSE_FILL; - if ( size && pfrsize->metrics.y_ppem < 24 ) + if ( pfrsize->metrics.y_ppem < 24 ) outline->flags |= FT_OUTLINE_HIGH_PRECISION; /* compute the advance vector */ diff --git a/src/3rdparty/freetype/src/pfr/pfrobjs.h b/src/3rdparty/freetype/src/pfr/pfrobjs.h index 59c709f58d..39cffd07c5 100644 --- a/src/3rdparty/freetype/src/pfr/pfrobjs.h +++ b/src/3rdparty/freetype/src/pfr/pfrobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrobjs.h */ -/* */ -/* FreeType PFR object methods (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrobjs.h + * + * FreeType PFR object methods (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFROBJS_H_ diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.c b/src/3rdparty/freetype/src/pfr/pfrsbit.c index ba909ddca7..00a9616455 100644 --- a/src/3rdparty/freetype/src/pfr/pfrsbit.c +++ b/src/3rdparty/freetype/src/pfr/pfrsbit.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrsbit.c */ -/* */ -/* FreeType PFR bitmap loader (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrsbit.c + * + * FreeType PFR bitmap loader (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "pfrsbit.h" @@ -24,7 +24,7 @@ #include "pfrerror.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pfr +#define FT_COMPONENT pfr /*************************************************************************/ diff --git a/src/3rdparty/freetype/src/pfr/pfrsbit.h b/src/3rdparty/freetype/src/pfr/pfrsbit.h index 07b27bc06c..6568b90943 100644 --- a/src/3rdparty/freetype/src/pfr/pfrsbit.h +++ b/src/3rdparty/freetype/src/pfr/pfrsbit.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrsbit.h */ -/* */ -/* FreeType PFR bitmap loader (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrsbit.h + * + * FreeType PFR bitmap loader (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFRSBIT_H_ diff --git a/src/3rdparty/freetype/src/pfr/pfrtypes.h b/src/3rdparty/freetype/src/pfr/pfrtypes.h index 058d6aadc9..6a5f9d571b 100644 --- a/src/3rdparty/freetype/src/pfr/pfrtypes.h +++ b/src/3rdparty/freetype/src/pfr/pfrtypes.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pfrtypes.h */ -/* */ -/* FreeType PFR data structures (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pfrtypes.h + * + * FreeType PFR data structures (specification only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PFRTYPES_H_ diff --git a/src/3rdparty/freetype/src/pfr/rules.mk b/src/3rdparty/freetype/src/pfr/rules.mk index 3acb795696..f14ca699e2 100644 --- a/src/3rdparty/freetype/src/pfr/rules.mk +++ b/src/3rdparty/freetype/src/pfr/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/psaux/Jamfile b/src/3rdparty/freetype/src/psaux/Jamfile index a231d5974f..30bcc1c097 100644 --- a/src/3rdparty/freetype/src/psaux/Jamfile +++ b/src/3rdparty/freetype/src/psaux/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/psaux Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/psaux/afmparse.c b/src/3rdparty/freetype/src/psaux/afmparse.c index 0c33d5949b..f78adbba3d 100644 --- a/src/3rdparty/freetype/src/psaux/afmparse.c +++ b/src/3rdparty/freetype/src/psaux/afmparse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afmparse.c */ -/* */ -/* AFM parser (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmparse.c + * + * AFM parser (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_FREETYPE_H @@ -28,13 +28,13 @@ #include "psauxerr.h" -/***************************************************************************/ -/* */ -/* AFM_Stream */ -/* */ -/* The use of AFM_Stream is largely inspired by parseAFM.[ch] from t1lib. */ -/* */ -/* */ + /************************************************************************** + * + * AFM_Stream + * + * The use of AFM_Stream is largely inspired by parseAFM.[ch] from t1lib. + * + */ enum { @@ -193,11 +193,11 @@ } - /*************************************************************************/ - /* */ - /* AFM_Parser */ - /* */ - /* */ + /************************************************************************** + * + * AFM_Parser + * + */ /* all keys defined in Ch. 7-10 of 5004.AFM_Spec.pdf */ typedef enum AFM_Token_ @@ -953,7 +953,8 @@ error = afm_parse_kern_data( parser ); if ( error ) goto Fail; - /* fall through since we only support kern data */ + /* we only support kern data, so ... */ + /* fall through */ case AFM_TOKEN_ENDFONTMETRICS: return FT_Err_Ok; diff --git a/src/3rdparty/freetype/src/psaux/afmparse.h b/src/3rdparty/freetype/src/psaux/afmparse.h index 86f852a247..2ceb77553b 100644 --- a/src/3rdparty/freetype/src/psaux/afmparse.h +++ b/src/3rdparty/freetype/src/psaux/afmparse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* afmparse.h */ -/* */ -/* AFM parser (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * afmparse.h + * + * AFM parser (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef AFMPARSE_H_ diff --git a/src/3rdparty/freetype/src/psaux/cffdecode.c b/src/3rdparty/freetype/src/psaux/cffdecode.c index 80d622c0e1..17cccf818b 100644 --- a/src/3rdparty/freetype/src/psaux/cffdecode.c +++ b/src/3rdparty/freetype/src/psaux/cffdecode.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdecode.c */ -/* */ -/* PostScript CFF (Type 2) decoding routines (body). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdecode.c + * + * PostScript CFF (Type 2) decoding routines (body). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -28,14 +28,14 @@ #include "psauxerr.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cffdecode +#define FT_COMPONENT cffdecode #ifdef CFF_CONFIG_OPTION_OLD_ENGINE @@ -235,8 +235,8 @@ return FT_THROW( Syntax_Error ); } - adx += decoder->builder.left_bearing.x; - ady += decoder->builder.left_bearing.y; + adx = ADD_LONG( adx, decoder->builder.left_bearing.x ); + ady = ADD_LONG( ady, decoder->builder.left_bearing.y ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* Incremental fonts don't necessarily have valid charsets. */ @@ -378,23 +378,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_compute_bias */ - /* */ - /* <Description> */ - /* Computes the bias value in dependence of the number of glyph */ - /* subroutines. */ - /* */ - /* <Input> */ - /* in_charstring_type :: The `CharstringType' value of the top DICT */ - /* dictionary. */ - /* */ - /* num_subrs :: The number of glyph subroutines. */ - /* */ - /* <Return> */ - /* The bias value. */ + /************************************************************************** + * + * @Function: + * cff_compute_bias + * + * @Description: + * Computes the bias value in dependence of the number of glyph + * subroutines. + * + * @Input: + * in_charstring_type :: + * The `CharstringType' value of the top DICT + * dictionary. + * + * num_subrs :: + * The number of glyph subroutines. + * + * @Return: + * The bias value. + */ static FT_Int cff_compute_bias( FT_Int in_charstring_type, FT_UInt num_subrs ) @@ -464,28 +467,32 @@ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_decoder_parse_charstrings */ - /* */ - /* <Description> */ - /* Parses a given Type 2 charstrings program. */ - /* */ - /* <InOut> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* <Input> */ - /* charstring_base :: The base of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* in_dict :: Set to 1 if function is called from top or */ - /* private DICT (needed for Multiple Master CFFs). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_decoder_parse_charstrings + * + * @Description: + * Parses a given Type 2 charstrings program. + * + * @InOut: + * decoder :: + * The current Type 1 decoder. + * + * @Input: + * charstring_base :: + * The base of the charstring stream. + * + * charstring_len :: + * The length in bytes of the charstring stream. + * + * in_dict :: + * Set to 1 if function is called from top or + * private DICT (needed for Multiple Master CFFs). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) cff_decoder_parse_charstrings( CFF_Decoder* decoder, FT_Byte* charstring_base, @@ -543,10 +550,10 @@ FT_Byte v; - /********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ + /********************************************************************* + * + * Decode operator or operand + */ v = *ip++; if ( v >= 32 || v == 28 ) { @@ -853,6 +860,15 @@ case cff_op_flex1: case cff_op_callsubr: case cff_op_callgsubr: + /* deprecated opcodes */ + case cff_op_dotsection: + /* invalid Type 1 opcodes */ + case cff_op_hsbw: + case cff_op_closepath: + case cff_op_callothersubr: + case cff_op_seac: + case cff_op_sbw: + case cff_op_setcurrentpoint: goto MM_Error; default: @@ -948,10 +964,10 @@ case cff_op_hstemhm: case cff_op_vstemhm: /* the number of arguments is always even here */ - FT_TRACE4(( - op == cff_op_hstem ? " hstem\n" : - ( op == cff_op_vstem ? " vstem\n" : - ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) )); + FT_TRACE4(( "%s\n", + op == cff_op_hstem ? " hstem" : + ( op == cff_op_vstem ? " vstem" : + ( op == cff_op_hstemhm ? " hstemhm" : " vstemhm" ) ) )); if ( hinter ) hinter->stems( hinter->hints, @@ -965,7 +981,8 @@ case cff_op_hintmask: case cff_op_cntrmask: - FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" )); + FT_TRACE4(( "%s", op == cff_op_hintmask ? " hintmask" + : " cntrmask" )); /* implement vstem when needed -- */ /* the specification doesn't say it, but this also works */ @@ -1078,8 +1095,8 @@ FT_Int phase = ( op == cff_op_hlineto ); - FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n" - : " vlineto\n" )); + FT_TRACE4(( "%s\n", op == cff_op_hlineto ? " hlineto" + : " vlineto" )); if ( num_args < 0 ) goto Stack_Underflow; @@ -1250,8 +1267,8 @@ FT_Int nargs; - FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n" - : " hvcurveto\n" )); + FT_TRACE4(( "%s\n", op == cff_op_vhcurveto ? " vhcurveto" + : " hvcurveto" )); if ( cff_builder_start_point( builder, x, y ) ) goto Fail; @@ -1539,9 +1556,9 @@ } if ( dx < 0 ) - dx = -dx; + dx = NEG_LONG( dx ); if ( dy < 0 ) - dy = -dy; + dy = NEG_LONG( dy ); /* strange test, but here it is... */ horizontal = ( dx > dy ); @@ -1551,7 +1568,7 @@ x = ADD_LONG( x, args[0] ); y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 3 ) ); + FT_BOOL( count == 3 ) ); args += 2; } @@ -1589,7 +1606,7 @@ x = ADD_LONG( x, args[0] ); y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 4 || count == 1 ) ); + FT_BOOL( count == 4 || count == 1 ) ); args += 2; } @@ -1705,16 +1722,20 @@ break; case cff_op_random: - FT_TRACE4(( " random\n" )); + { + FT_UInt32* randval = in_dict ? &decoder->cff->top_font.random + : &decoder->current_subfont->random; - /* only use the lower 16 bits of `random' */ - /* to generate a number in the range (0;1] */ - args[0] = (FT_Fixed) - ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); - args++; - decoder->current_subfont->random = - cff_random( decoder->current_subfont->random ); + FT_TRACE4(( " random\n" )); + + /* only use the lower 16 bits of `random' */ + /* to generate a number in the range (0;1] */ + args[0] = (FT_Fixed)( ( *randval & 0xFFFF ) + 1 ); + args++; + + *randval = cff_random( *randval ); + } break; case cff_op_mul: @@ -1727,7 +1748,10 @@ case cff_op_sqrt: FT_TRACE4(( " sqrt\n" )); - if ( args[0] > 0 ) + /* without upper limit the loop below might not finish */ + if ( args[0] > 0x7FFFFFFFL ) + args[0] = 46341; + else if ( args[0] > 0 ) { FT_Fixed root = args[0]; FT_Fixed new_root; @@ -1800,6 +1824,7 @@ if ( idx >= 0 ) { + idx = idx % count; while ( idx > 0 ) { FT_Fixed tmp = args[count - 1]; @@ -1814,6 +1839,10 @@ } else { + /* before C99 it is implementation-defined whether */ + /* the result of `%' is negative if the first operand */ + /* is negative */ + idx = -( NEG_INT( idx ) % count ); while ( idx < 0 ) { FT_Fixed tmp = args[0]; @@ -1914,6 +1943,7 @@ case cff_op_blend: /* this operator was removed from the Type2 specification */ /* in version 16-March-2000 */ + if ( num_designs ) { FT_Int num_results = (FT_Int)( args[0] >> 16 ); @@ -1923,7 +1953,8 @@ if ( num_results < 0 ) goto Syntax_Error; - if ( num_results * (FT_Int)num_designs > num_args ) + if ( num_results > num_args || + num_results * (FT_Int)num_designs > num_args ) goto Stack_Underflow; /* since we currently don't handle interpolation of multiple */ @@ -1932,6 +1963,8 @@ args -= num_results * ( num_designs - 1 ); num_args -= num_results * ( num_designs - 1 ); } + else + goto Syntax_Error; break; case cff_op_dotsection: @@ -1998,20 +2031,31 @@ break; case cff_op_callothersubr: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ + { + FT_Fixed arg; - FT_TRACE4(( " callothersubr (invalid op)\n" )); - /* subsequent `pop' operands should add the arguments, */ - /* this is the implementation described for `unknown' other */ - /* subroutines in the Type1 spec. */ - /* */ - /* XXX Fix return arguments (see discussion below). */ - args -= 2 + ( args[-2] >> 16 ); - if ( args < stack ) - goto Stack_Underflow; + /* this is an invalid Type 2 operator; however, there */ + /* exist fonts which are incorrectly converted from */ + /* probably Type 1 to CFF, and some parsers seem to accept */ + /* it */ + + FT_TRACE4(( " callothersubr (invalid op)\n" )); + + /* subsequent `pop' operands should add the arguments, */ + /* this is the implementation described for `unknown' */ + /* other subroutines in the Type1 spec. */ + /* */ + /* XXX Fix return arguments (see discussion below). */ + + arg = 2 + ( args[-2] >> 16 ); + if ( arg >= CFF_MAX_OPERANDS ) + goto Stack_Underflow; + + args -= arg; + if ( args < stack ) + goto Stack_Underflow; + } break; case cff_op_pop: @@ -2251,28 +2295,34 @@ #endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_decoder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph decoder. */ - /* */ - /* <InOut> */ - /* decoder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* slot :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ - /* hint_mode :: The hinting mode. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_decoder_init + * + * @Description: + * Initializes a given glyph decoder. + * + * @InOut: + * decoder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * slot :: + * The current glyph object. + * + * hinting :: + * Whether hinting is active. + * + * hint_mode :: + * The hinting mode. + */ FT_LOCAL_DEF( void ) cff_decoder_init( CFF_Decoder* decoder, TT_Face face, diff --git a/src/3rdparty/freetype/src/psaux/cffdecode.h b/src/3rdparty/freetype/src/psaux/cffdecode.h index 0d4f5fef63..a6691979f0 100644 --- a/src/3rdparty/freetype/src/psaux/cffdecode.h +++ b/src/3rdparty/freetype/src/psaux/cffdecode.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* cffdecode.h */ -/* */ -/* PostScript CFF (Type 2) decoding routines (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * cffdecode.h + * + * PostScript CFF (Type 2) decoding routines (specification). + * + * Copyright (C) 2017-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef CFFDECODE_H_ diff --git a/src/3rdparty/freetype/src/psaux/module.mk b/src/3rdparty/freetype/src/psaux/module.mk index 6584d075a2..bb0886abdf 100644 --- a/src/3rdparty/freetype/src/psaux/module.mk +++ b/src/3rdparty/freetype/src/psaux/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/psaux/psarrst.c b/src/3rdparty/freetype/src/psaux/psarrst.c index a8780947f9..011803b416 100644 --- a/src/3rdparty/freetype/src/psaux/psarrst.c +++ b/src/3rdparty/freetype/src/psaux/psarrst.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psarrst.c */ -/* */ -/* Adobe's code for Array Stacks (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psarrst.c + * + * Adobe's code for Array Stacks (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" diff --git a/src/3rdparty/freetype/src/psaux/psarrst.h b/src/3rdparty/freetype/src/psaux/psarrst.h index b3568eb61f..098617b257 100644 --- a/src/3rdparty/freetype/src/psaux/psarrst.h +++ b/src/3rdparty/freetype/src/psaux/psarrst.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psarrst.h */ -/* */ -/* Adobe's code for Array Stacks (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psarrst.h + * + * Adobe's code for Array Stacks (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSARRST_H_ diff --git a/src/3rdparty/freetype/src/psaux/psaux.c b/src/3rdparty/freetype/src/psaux/psaux.c index fb447fcdbb..1db0462551 100644 --- a/src/3rdparty/freetype/src/psaux/psaux.c +++ b/src/3rdparty/freetype/src/psaux/psaux.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psaux.c */ -/* */ -/* FreeType auxiliary PostScript driver component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psaux.c + * + * FreeType auxiliary PostScript driver component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/psaux/psauxerr.h b/src/3rdparty/freetype/src/psaux/psauxerr.h index cc33fd2eea..523e1886c2 100644 --- a/src/3rdparty/freetype/src/psaux/psauxerr.h +++ b/src/3rdparty/freetype/src/psaux/psauxerr.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* psauxerr.h */ -/* */ -/* PS auxiliary module error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PS auxiliary module error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * psauxerr.h + * + * PS auxiliary module error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PS auxiliary module error enumeration + * constants. + * + */ #ifndef PSAUXERR_H_ #define PSAUXERR_H_ diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.c b/src/3rdparty/freetype/src/psaux/psauxmod.c index ee497085cc..5df8e69056 100644 --- a/src/3rdparty/freetype/src/psaux/psauxmod.c +++ b/src/3rdparty/freetype/src/psaux/psauxmod.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psauxmod.c */ -/* */ -/* FreeType auxiliary PostScript module implementation (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psauxmod.c + * + * FreeType auxiliary PostScript module implementation (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> diff --git a/src/3rdparty/freetype/src/psaux/psauxmod.h b/src/3rdparty/freetype/src/psaux/psauxmod.h index f30978f022..a0eda0bfc0 100644 --- a/src/3rdparty/freetype/src/psaux/psauxmod.h +++ b/src/3rdparty/freetype/src/psaux/psauxmod.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psauxmod.h */ -/* */ -/* FreeType auxiliary PostScript module implementation (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psauxmod.h + * + * FreeType auxiliary PostScript module implementation (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSAUXMOD_H_ @@ -28,10 +28,6 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - FT_CALLBACK_TABLE const CFF_Builder_FuncsRec cff_builder_funcs; diff --git a/src/3rdparty/freetype/src/psaux/psblues.c b/src/3rdparty/freetype/src/psaux/psblues.c index ae39d03c77..89738ce474 100644 --- a/src/3rdparty/freetype/src/psaux/psblues.c +++ b/src/3rdparty/freetype/src/psaux/psblues.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psblues.c */ -/* */ -/* Adobe's code for handling Blue Zones (body). */ -/* */ -/* Copyright 2009-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psblues.c + * + * Adobe's code for handling Blue Zones (body). + * + * Copyright 2009-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -44,14 +44,14 @@ #include "psfont.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cf2blues +#define FT_COMPONENT cf2blues /* @@ -452,13 +452,13 @@ * zones in the same pass (see `BlueLock'). If a hint is captured, * return true and position the edge(s) in one of 3 ways: * - * 1) If `BlueScale' suppresses overshoot, position the captured edge - * at the flat edge of the zone. - * 2) If overshoot is not suppressed and `BlueShift' requires - * overshoot, position the captured edge a minimum of 1 device pixel - * from the flat edge. - * 3) If overshoot is not suppressed or required, position the captured - * edge at the nearest device pixel. + * 1) If `BlueScale' suppresses overshoot, position the captured edge + * at the flat edge of the zone. + * 2) If overshoot is not suppressed and `BlueShift' requires + * overshoot, position the captured edge a minimum of 1 device pixel + * from the flat edge. + * 3) If overshoot is not suppressed or required, position the captured + * edge at the nearest device pixel. * */ FT_LOCAL_DEF( FT_Bool ) diff --git a/src/3rdparty/freetype/src/psaux/psblues.h b/src/3rdparty/freetype/src/psaux/psblues.h index 25ef6849c7..55fb88ecdd 100644 --- a/src/3rdparty/freetype/src/psaux/psblues.h +++ b/src/3rdparty/freetype/src/psaux/psblues.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psblues.h */ -/* */ -/* Adobe's code for handling Blue Zones (specification). */ -/* */ -/* Copyright 2009-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psblues.h + * + * Adobe's code for handling Blue Zones (specification). + * + * Copyright 2009-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ /* diff --git a/src/3rdparty/freetype/src/psaux/psconv.c b/src/3rdparty/freetype/src/psaux/psconv.c index a03385000d..c88761681c 100644 --- a/src/3rdparty/freetype/src/psaux/psconv.c +++ b/src/3rdparty/freetype/src/psaux/psconv.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psconv.c */ -/* */ -/* Some convenience conversions (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psconv.c + * + * Some convenience conversions (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,14 +24,14 @@ #include "psauxerr.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_psconv +#define FT_COMPONENT psconv /* The following array is used by various functions to quickly convert */ diff --git a/src/3rdparty/freetype/src/psaux/psconv.h b/src/3rdparty/freetype/src/psaux/psconv.h index d643ffcfc2..6b24bf6fc9 100644 --- a/src/3rdparty/freetype/src/psaux/psconv.h +++ b/src/3rdparty/freetype/src/psaux/psconv.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psconv.h */ -/* */ -/* Some convenience conversions (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psconv.h + * + * Some convenience conversions (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSCONV_H_ diff --git a/src/3rdparty/freetype/src/psaux/pserror.c b/src/3rdparty/freetype/src/psaux/pserror.c index 9169e5222d..98cebcf74d 100644 --- a/src/3rdparty/freetype/src/psaux/pserror.c +++ b/src/3rdparty/freetype/src/psaux/pserror.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pserror.c */ -/* */ -/* Adobe's code for error handling (body). */ -/* */ -/* Copyright 2006-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pserror.c + * + * Adobe's code for error handling (body). + * + * Copyright 2006-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" diff --git a/src/3rdparty/freetype/src/psaux/pserror.h b/src/3rdparty/freetype/src/psaux/pserror.h index 13d52062bf..b2156b3318 100644 --- a/src/3rdparty/freetype/src/psaux/pserror.h +++ b/src/3rdparty/freetype/src/psaux/pserror.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pserror.h */ -/* */ -/* Adobe's code for error handling (specification). */ -/* */ -/* Copyright 2006-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pserror.h + * + * Adobe's code for error handling (specification). + * + * Copyright 2006-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSERROR_H_ diff --git a/src/3rdparty/freetype/src/psaux/psfixed.h b/src/3rdparty/freetype/src/psaux/psfixed.h index 219589e7fc..7dff9ef1bd 100644 --- a/src/3rdparty/freetype/src/psaux/psfixed.h +++ b/src/3rdparty/freetype/src/psaux/psfixed.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psfixed.h */ -/* */ -/* Adobe's code for Fixed Point Mathematics (specification only). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psfixed.h + * + * Adobe's code for Fixed Point Mathematics (specification only). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSFIXED_H_ @@ -72,8 +72,7 @@ FT_BEGIN_HEADER #define cf2_fixedFraction( x ) \ ( (x) - cf2_fixedFloor( x ) ) #define cf2_fracToFixed( x ) \ - ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \ - : ( ( (x) + 0x2000 ) >> 14 ) ) + ( ( (x) + 0x2000 - ( (x) < 0 ) ) >> 14 ) /* signed numeric types */ diff --git a/src/3rdparty/freetype/src/psaux/psfont.c b/src/3rdparty/freetype/src/psaux/psfont.c index dde67a739d..00e4210819 100644 --- a/src/3rdparty/freetype/src/psaux/psfont.c +++ b/src/3rdparty/freetype/src/psaux/psfont.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psfont.c */ -/* */ -/* Adobe's code for font instances (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psfont.c + * + * Adobe's code for font instances (body). + * + * Copyright 2007-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include <ft2build.h> @@ -274,9 +274,6 @@ if ( !font->isT1 ) { - FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload; - - /* check for variation vectors */ vstore = cf2_getVStore( decoder ); hasVariations = ( vstore->dataCount != 0 ); @@ -284,6 +281,9 @@ if ( hasVariations ) { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload; + + /* check whether Private DICT in this subfont needs to be reparsed */ font->error = cf2_getNormalizedVector( decoder, &lenNormalizedV, @@ -331,7 +331,7 @@ } /* copy hinted flag on each call */ - font->hinted = (FT_Bool)( font->renderingFlags & CF2_FlagsHinted ); + font->hinted = FT_BOOL( font->renderingFlags & CF2_FlagsHinted ); /* determine if transform has changed; */ /* include Fontmatrix but ignore translation */ @@ -366,7 +366,7 @@ if ( font->stemDarkened != ( font->renderingFlags & CF2_FlagsDarkened ) ) { font->stemDarkened = - (FT_Bool)( font->renderingFlags & CF2_FlagsDarkened ); + FT_BOOL( font->renderingFlags & CF2_FlagsDarkened ); /* blue zones depend on darkened flag */ needExtraSetup = TRUE; diff --git a/src/3rdparty/freetype/src/psaux/psfont.h b/src/3rdparty/freetype/src/psaux/psfont.h index e611ac4bdc..8fbacbb6e3 100644 --- a/src/3rdparty/freetype/src/psaux/psfont.h +++ b/src/3rdparty/freetype/src/psaux/psfont.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psfont.h */ -/* */ -/* Adobe's code for font instances (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psfont.h + * + * Adobe's code for font instances (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSFONT_H_ diff --git a/src/3rdparty/freetype/src/psaux/psft.c b/src/3rdparty/freetype/src/psaux/psft.c index 1f750174a1..54be468343 100644 --- a/src/3rdparty/freetype/src/psaux/psft.c +++ b/src/3rdparty/freetype/src/psaux/psft.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psft.c */ -/* */ -/* FreeType Glue Component to Adobe's Interpreter (body). */ -/* */ -/* Copyright 2013-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psft.c + * + * FreeType Glue Component to Adobe's Interpreter (body). + * + * Copyright 2013-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -120,12 +120,12 @@ } - /********************************************/ - /* */ - /* functions for handling client outline; */ - /* FreeType uses coordinates in 26.6 format */ - /* */ - /********************************************/ + /********************************************* + * + * functions for handling client outline; + * FreeType uses coordinates in 26.6 format + * + */ static void cf2_builder_moveTo( CF2_OutlineCallbacks callbacks, @@ -767,13 +767,14 @@ cf2_freeT1SeacComponent( PS_Decoder* decoder, CF2_Buffer buf ) { +#ifdef FT_CONFIG_OPTION_INCREMENTAL + T1_Face face; FT_Data data; FT_ASSERT( decoder ); -#ifdef FT_CONFIG_OPTION_INCREMENTAL face = (T1_Face)decoder->builder.face; data.pointer = buf->start; @@ -783,7 +784,13 @@ face->root.internal->incremental_interface->funcs->free_glyph_data( face->root.internal->incremental_interface->object, &data ); -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ + +#else /* !FT_CONFIG_OPTION_INCREMENTAL */ + + FT_UNUSED( decoder ); + FT_UNUSED( buf ); + +#endif /* !FT_CONFIG_OPTION_INCREMENTAL */ } diff --git a/src/3rdparty/freetype/src/psaux/psft.h b/src/3rdparty/freetype/src/psaux/psft.h index ab172110bb..4c930f0d73 100644 --- a/src/3rdparty/freetype/src/psaux/psft.h +++ b/src/3rdparty/freetype/src/psaux/psft.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psft.h */ -/* */ -/* FreeType Glue Component to Adobe's Interpreter (specification). */ -/* */ -/* Copyright 2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psft.h + * + * FreeType Glue Component to Adobe's Interpreter (specification). + * + * Copyright 2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSFT_H_ diff --git a/src/3rdparty/freetype/src/psaux/psglue.h b/src/3rdparty/freetype/src/psaux/psglue.h index 5545e12a5b..022aafbfca 100644 --- a/src/3rdparty/freetype/src/psaux/psglue.h +++ b/src/3rdparty/freetype/src/psaux/psglue.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psglue.h */ -/* */ -/* Adobe's code for shared stuff (specification only). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psglue.h + * + * Adobe's code for shared stuff (specification only). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSGLUE_H_ diff --git a/src/3rdparty/freetype/src/psaux/pshints.c b/src/3rdparty/freetype/src/psaux/pshints.c index 3615196425..1cbecd2b19 100644 --- a/src/3rdparty/freetype/src/psaux/pshints.c +++ b/src/3rdparty/freetype/src/psaux/pshints.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pshints.c */ -/* */ -/* Adobe's code for handling CFF hints (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshints.c + * + * Adobe's code for handling CFF hints (body). + * + * Copyright 2007-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -45,14 +45,14 @@ #include "psintrp.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cf2hints +#define FT_COMPONENT cf2hints typedef struct CF2_HintMoveRec_ @@ -217,52 +217,49 @@ FT_LOCAL_DEF( FT_Bool ) cf2_hint_isValid( const CF2_Hint hint ) { - return (FT_Bool)( hint->flags != 0 ); + return FT_BOOL( hint->flags ); } static FT_Bool cf2_hint_isPair( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & - ( CF2_PairBottom | CF2_PairTop ) ) != 0 ); + return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_PairTop ) ); } static FT_Bool cf2_hint_isPairTop( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & CF2_PairTop ) != 0 ); + return FT_BOOL( hint->flags & CF2_PairTop ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isTop( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & - ( CF2_PairTop | CF2_GhostTop ) ) != 0 ); + return FT_BOOL( hint->flags & ( CF2_PairTop | CF2_GhostTop ) ); } FT_LOCAL_DEF( FT_Bool ) cf2_hint_isBottom( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & - ( CF2_PairBottom | CF2_GhostBottom ) ) != 0 ); + return FT_BOOL( hint->flags & ( CF2_PairBottom | CF2_GhostBottom ) ); } static FT_Bool cf2_hint_isLocked( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & CF2_Locked ) != 0 ); + return FT_BOOL( hint->flags & CF2_Locked ); } static FT_Bool cf2_hint_isSynthetic( const CF2_Hint hint ) { - return (FT_Bool)( ( hint->flags & CF2_Synthetic ) != 0 ); + return FT_BOOL( hint->flags & CF2_Synthetic ); } @@ -334,7 +331,7 @@ cf2_hintmap_map( CF2_HintMap hintmap, CF2_Fixed csCoord ) { - if ( hintmap->count == 0 || ! hintmap->hinted ) + if ( hintmap->count == 0 || !hintmap->hinted ) { /* there are no hints; use uniform scale and zero offset */ return FT_MulFix( csCoord, hintmap->scale ); @@ -497,7 +494,7 @@ { move = moveDown; /* true if non-optimum move */ - saveEdge = (FT_Bool)( moveUp < -moveDown ); + saveEdge = FT_BOOL( moveUp < -moveDown ); } else { @@ -1025,10 +1022,10 @@ } } - FT_TRACE6(( initialMap ? "flags: [p]air [g]host [t]op " - "[b]ottom [L]ocked [S]ynthetic\n" - "Initial hintmap\n" - : "Hints:\n" )); + FT_TRACE6(( "%s\n", initialMap ? "flags: [p]air [g]host [t]op" + " [b]ottom [L]ocked [S]ynthetic\n" + "Initial hintmap" + : "Hints:" )); cf2_hintmap_dump( hintmap ); /* @@ -1215,7 +1212,7 @@ * (`u'). * * See notation in - * http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm. + * http://geomalgorithms.com/a05-_intersect-1.html. * Calculations are done in 16.16, but must handle the squaring of * line lengths in character space. We scale all vectors by 1/32 to * avoid overflow. This allows values up to 4095 to be squared. The diff --git a/src/3rdparty/freetype/src/psaux/pshints.h b/src/3rdparty/freetype/src/psaux/pshints.h index 92e37e98ae..31a8230364 100644 --- a/src/3rdparty/freetype/src/psaux/pshints.h +++ b/src/3rdparty/freetype/src/psaux/pshints.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pshints.h */ -/* */ -/* Adobe's code for handling CFF hints (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshints.h + * + * Adobe's code for handling CFF hints (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSHINT_H_ diff --git a/src/3rdparty/freetype/src/psaux/psintrp.c b/src/3rdparty/freetype/src/psaux/psintrp.c index da5a8dad1d..e2f3accdd5 100644 --- a/src/3rdparty/freetype/src/psaux/psintrp.c +++ b/src/3rdparty/freetype/src/psaux/psintrp.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psintrp.c */ -/* */ -/* Adobe's CFF Interpreter (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psintrp.c + * + * Adobe's CFF Interpreter (body). + * + * Copyright 2007-2014 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -52,14 +52,14 @@ #include "t1decode.h" /* for t1 seac */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_cf2interp +#define FT_COMPONENT cf2interp FT_LOCAL_DEF( void ) @@ -287,7 +287,7 @@ { CF2_UInt i; CF2_UInt count = cf2_stack_count( opStack ); - FT_Bool hasWidthArg = (FT_Bool)( count & 1 ); + FT_Bool hasWidthArg = FT_BOOL( count & 1 ); /* variable accumulates delta values from operand stack */ CF2_Fixed position = hintOffset; @@ -364,7 +364,7 @@ if ( doConditionalLastRead ) { - FT_Bool lastIsX = (FT_Bool)( + FT_Bool lastIsX = FT_BOOL( cf2_fixedAbs( SUB_INT32( vals[10], *curX ) ) > cf2_fixedAbs( SUB_INT32( vals[11], *curY ) ) ); CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx ); @@ -612,14 +612,14 @@ cf2_arrstack_setCount( &subrStack, CF2_MAX_SUBR + 1 ); charstring = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack ); - *charstring = *buf; /* structure copy */ - - charstringIndex = 0; /* entry is valid now */ /* catch errors so far */ if ( *error ) goto exit; + *charstring = *buf; /* structure copy */ + charstringIndex = 0; /* entry is valid now */ + /* main interpreter loop */ while ( 1 ) { @@ -663,6 +663,7 @@ /* Skip outline commands first time round. */ /* `endchar' will trigger initial hintmap build */ /* and rewind the charstring. */ + FT_TRACE4(( " <outline command skipped>\n" )); cf2_stack_clear( opStack ); continue; } @@ -775,7 +776,8 @@ case cf2_cmdHSTEMHM: case cf2_cmdHSTEM: - FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" )); + FT_TRACE4(( "%s\n", op1 == cf2_cmdHSTEMHM ? " hstemhm" + : " hstem" )); if ( !font->isT1 ) { @@ -805,7 +807,8 @@ case cf2_cmdVSTEMHM: case cf2_cmdVSTEM: - FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" )); + FT_TRACE4(( "%s\n", op1 == cf2_cmdVSTEMHM ? " vstemhm" + : " vstem" )); if ( !font->isT1 ) { @@ -888,7 +891,7 @@ FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO ); - FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" )); + FT_TRACE4(( "%s\n", isX ? " hlineto" : " vlineto" )); for ( idx = 0; idx < count; idx++ ) { @@ -916,8 +919,8 @@ CF2_UInt idx = 0; - FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n" - : " rrcurveto\n" )); + FT_TRACE4(( "%s\n", op1 == cf2_cmdRCURVELINE ? " rcurveline" + : " rrcurveto" )); while ( idx + 6 <= count ) { @@ -957,10 +960,10 @@ FT_TRACE4(( " unknown op (%d)\n", op1 )); else { - FT_TRACE4(( " closepath" )); + FT_TRACE4(( " closepath\n" )); /* if there is no path, `closepath' is a no-op */ - ps_builder_close_contour( &decoder->builder ); + cf2_glyphpath_closeOpenPath( &glyphPath ); haveWidth = TRUE; } @@ -972,8 +975,8 @@ CF2_Int subrNum; - FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr" - : " callsubr" )); + FT_TRACE4(( "%s", op1 == cf2_cmdCALLGSUBR ? " callgsubr" + : " callsubr" )); if ( ( !font->isT1 && charstringIndex > CF2_MAX_SUBR ) || ( font->isT1 && charstringIndex > T1_MAX_SUBRS_CALLS ) ) @@ -1212,8 +1215,8 @@ FT_Bool isV = FT_BOOL( op2 == cf2_escVSTEM3 ); - FT_TRACE4(( isV ? " vstem3\n" - : " hstem3\n" )); + FT_TRACE4(( "%s\n", isV ? " vstem3" + : " hstem3" )); FT_ASSERT( cf2_stack_count( opStack ) == 6 ); @@ -1644,16 +1647,17 @@ subr_no = cf2_stack_popInt( opStack ); arg_cnt = cf2_stack_popInt( opStack ); - /*******************************************************/ - /* */ - /* remove all operands to callothersubr from the stack */ - /* */ - /* for handled othersubrs, where we know the number of */ - /* arguments, we increase the stack by the value of */ - /* known_othersubr_result_cnt */ - /* */ - /* for unhandled othersubrs the following pops adjust */ - /* the stack pointer as necessary */ + /******************************************************** + * + * remove all operands to callothersubr from the stack + * + * for handled othersubrs, where we know the number of + * arguments, we increase the stack by the value of + * known_othersubr_result_cnt + * + * for unhandled othersubrs the following pops adjust + * the stack pointer as necessary + */ count = cf2_stack_count( opStack ); FT_ASSERT( (CF2_UInt)arg_cnt <= count ); @@ -2416,7 +2420,7 @@ PS_Builder* builder; - FT_TRACE4(( " hsbw" )); + FT_TRACE4(( " hsbw\n" )); builder = &decoder->builder; @@ -2562,7 +2566,7 @@ case cf2_cmdHINTMASK: /* the final \n in the tracing message gets added in */ /* `cf2_hintmask_read' (which also traces the mask bytes) */ - FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" )); + FT_TRACE4(( "%s", op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" )); /* never add hints after the mask is computed */ if ( cf2_stack_count( opStack ) > 1 && @@ -2828,7 +2832,7 @@ count = count1 & ~2U; idx += count1 - count; - FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" )); + FT_TRACE4(( "%s\n", alternate ? " hvcurveto" : " vhcurveto" )); while ( idx < count ) { diff --git a/src/3rdparty/freetype/src/psaux/psintrp.h b/src/3rdparty/freetype/src/psaux/psintrp.h index 4790aaa302..669c09c0ae 100644 --- a/src/3rdparty/freetype/src/psaux/psintrp.h +++ b/src/3rdparty/freetype/src/psaux/psintrp.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psintrp.h */ -/* */ -/* Adobe's CFF Interpreter (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psintrp.h + * + * Adobe's CFF Interpreter (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSINTRP_H_ diff --git a/src/3rdparty/freetype/src/psaux/psobjs.c b/src/3rdparty/freetype/src/psaux/psobjs.c index f54bc7e416..8bfdb92332 100644 --- a/src/3rdparty/freetype/src/psaux/psobjs.c +++ b/src/3rdparty/freetype/src/psaux/psobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psobjs.c */ -/* */ -/* Auxiliary functions for PostScript fonts (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psobjs.c + * + * Auxiliary functions for PostScript fonts (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -29,14 +29,14 @@ #include "psauxmod.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_psobjs +#define FT_COMPONENT psobjs /*************************************************************************/ @@ -47,26 +47,29 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_table_new */ - /* */ - /* <Description> */ - /* Initializes a PS_Table. */ - /* */ - /* <InOut> */ - /* table :: The address of the target table. */ - /* */ - /* <Input> */ - /* count :: The table size = the maximum number of elements. */ - /* */ - /* memory :: The memory object to use for all subsequent */ - /* reallocations. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_table_new + * + * @Description: + * Initializes a PS_Table. + * + * @InOut: + * table :: + * The address of the target table. + * + * @Input: + * count :: + * The table size = the maximum number of elements. + * + * memory :: + * The memory object to use for all subsequent + * reallocations. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) ps_table_new( PS_Table table, FT_Int count, @@ -144,33 +147,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_table_add */ - /* */ - /* <Description> */ - /* Adds an object to a PS_Table, possibly growing its memory block. */ - /* */ - /* <InOut> */ - /* table :: The target table. */ - /* */ - /* <Input> */ - /* idx :: The index of the object in the table. */ - /* */ - /* object :: The address of the object to copy in memory. */ - /* */ - /* length :: The length in bytes of the source object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. An error is returned if a */ - /* reallocation fails. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_table_add + * + * @Description: + * Adds an object to a PS_Table, possibly growing its memory block. + * + * @InOut: + * table :: + * The target table. + * + * @Input: + * idx :: + * The index of the object in the table. + * + * object :: + * The address of the object to copy in memory. + * + * length :: + * The length in bytes of the source object. + * + * @Return: + * FreeType error code. 0 means success. An error is returned if a + * reallocation fails. + */ FT_LOCAL_DEF( FT_Error ) - ps_table_add( PS_Table table, - FT_Int idx, - void* object, - FT_UInt length ) + ps_table_add( PS_Table table, + FT_Int idx, + const void* object, + FT_UInt length ) { if ( idx < 0 || idx >= table->max_elems ) { @@ -216,22 +223,23 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_table_done */ - /* */ - /* <Description> */ - /* Finalizes a PS_TableRec (i.e., reallocate it to its current */ - /* cursor). */ - /* */ - /* <InOut> */ - /* table :: The target table. */ - /* */ - /* <Note> */ - /* This function does NOT release the heap's memory block. It is up */ - /* to the caller to clean it, or reference it in its own structures. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_table_done + * + * @Description: + * Finalizes a PS_TableRec (i.e., reallocate it to its current + * cursor). + * + * @InOut: + * table :: + * The target table. + * + * @Note: + * This function does NOT release the heap's memory block. It is up + * to the caller to clean it, or reference it in its own structures. + */ FT_LOCAL_DEF( void ) ps_table_done( PS_Table table ) { @@ -498,12 +506,12 @@ } - /***********************************************************************/ - /* */ - /* All exported parsing routines handle leading whitespace and stop at */ - /* the first character which isn't part of the just handled token. */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * All exported parsing routines handle leading whitespace and stop at + * the first character which isn't part of the just handled token. + * + */ FT_LOCAL_DEF( void ) @@ -1100,18 +1108,22 @@ { case T1_FIELD_TYPE_BOOL: val = ps_tobool( &cur, limit ); + FT_TRACE4(( " %s", val ? "true" : "false" )); goto Store_Integer; case T1_FIELD_TYPE_FIXED: val = PS_Conv_ToFixed( &cur, limit, 0 ); + FT_TRACE4(( " %f", (double)val / 65536 )); goto Store_Integer; case T1_FIELD_TYPE_FIXED_1000: val = PS_Conv_ToFixed( &cur, limit, 3 ); + FT_TRACE4(( " %f", (double)val / 65536 / 1000 )); goto Store_Integer; case T1_FIELD_TYPE_INTEGER: val = PS_Conv_ToInt( &cur, limit ); + FT_TRACE4(( " %ld", val )); /* fall through */ Store_Integer: @@ -1188,6 +1200,13 @@ FT_MEM_COPY( string, cur, len ); string[len] = 0; +#ifdef FT_DEBUG_LEVEL_TRACE + if ( token.type == T1_TOKEN_TYPE_STRING ) + FT_TRACE4(( " (%s)", string )); + else + FT_TRACE4(( " /%s", string )); +#endif + *(FT_String**)q = string; } break; @@ -1213,6 +1232,12 @@ bbox->yMin = FT_RoundFix( temp[1] ); bbox->xMax = FT_RoundFix( temp[2] ); bbox->yMax = FT_RoundFix( temp[3] ); + + FT_TRACE4(( " [%d %d %d %d]", + bbox->xMin / 65536, + bbox->yMin / 65536, + bbox->xMax / 65536, + bbox->yMax / 65536 )); } break; @@ -1251,6 +1276,7 @@ skip_spaces( &cur, limit ); } + FT_TRACE4(( " [" )); for ( i = 0; i < max_objects; i++ ) { FT_BBox* bbox = (FT_BBox*)objects[i]; @@ -1260,7 +1286,14 @@ bbox->yMin = FT_RoundFix( temp[i + max_objects] ); bbox->xMax = FT_RoundFix( temp[i + 2 * max_objects] ); bbox->yMax = FT_RoundFix( temp[i + 3 * max_objects] ); + + FT_TRACE4(( " [%d %d %d %d]", + bbox->xMin / 65536, + bbox->yMin / 65536, + bbox->xMax / 65536, + bbox->yMax / 65536 )); } + FT_TRACE4(( "]" )); FT_FREE( temp ); } @@ -1333,6 +1366,8 @@ *(FT_Byte*)( (FT_Byte*)objects[0] + field->count_offset ) = (FT_Byte)num_elements; + FT_TRACE4(( " [" )); + /* we now load each element, adjusting the field.offset on each one */ token = elements; for ( ; num_elements > 0; num_elements--, token++ ) @@ -1351,6 +1386,8 @@ fieldrec.offset += fieldrec.size; } + FT_TRACE4(( "]" )); + #if 0 /* obsolete -- keep for reference */ if ( pflags ) *pflags |= 1L << field->flag_bit; @@ -1410,6 +1447,8 @@ bytes, max_bytes ); + parser->cursor = cur; + if ( delimiters ) { if ( cur < parser->limit && *cur != '>' ) @@ -1419,11 +1458,9 @@ goto Exit; } - cur++; + parser->cursor++; } - parser->cursor = cur; - Exit: return error; } @@ -1509,26 +1546,31 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting should be applied. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_builder_init + * + * @Description: + * Initializes a given glyph builder. + * + * @InOut: + * builder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * glyph :: + * The current glyph object. + * + * hinting :: + * Whether hinting should be applied. + */ FT_LOCAL_DEF( void ) t1_builder_init( T1_Builder builder, FT_Face face, @@ -1572,19 +1614,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_builder_done + * + * @Description: + * Finalizes a given glyph builder. Its contents can still be used + * after the call, but the function saves important information + * within the corresponding glyph slot. + * + * @Input: + * builder :: + * A pointer to the glyph builder to finalize. + */ FT_LOCAL_DEF( void ) t1_builder_done( T1_Builder builder ) { @@ -1769,26 +1812,31 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_builder_init + * + * @Description: + * Initializes a given glyph builder. + * + * @InOut: + * builder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * glyph :: + * The current glyph object. + * + * hinting :: + * Whether hinting is active. + */ FT_LOCAL_DEF( void ) cff_builder_init( CFF_Builder* builder, TT_Face face, @@ -1841,19 +1889,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* cff_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ + /************************************************************************** + * + * @Function: + * cff_builder_done + * + * @Description: + * Finalizes a given glyph builder. Its contents can still be used + * after the call, but the function saves important information + * within the corresponding glyph slot. + * + * @Input: + * builder :: + * A pointer to the glyph builder to finalize. + */ FT_LOCAL_DEF( void ) cff_builder_done( CFF_Builder* builder ) { @@ -1993,6 +2042,14 @@ first = outline->n_contours <= 1 ? 0 : outline->contours[outline->n_contours - 2] + 1; + /* in malformed fonts it can happen that a contour was started */ + /* but no points were added */ + if ( outline->n_contours && first == outline->n_points ) + { + outline->n_contours--; + return; + } + /* We must not include the last point in the path if it */ /* is located on the first point. */ if ( outline->n_points > 1 ) @@ -2033,26 +2090,31 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_builder_init */ - /* */ - /* <Description> */ - /* Initializes a given glyph builder. */ - /* */ - /* <InOut> */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting should be applied. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_builder_init + * + * @Description: + * Initializes a given glyph builder. + * + * @InOut: + * builder :: + * A pointer to the glyph builder to initialize. + * + * @Input: + * face :: + * The current face object. + * + * size :: + * The current size object. + * + * glyph :: + * The current glyph object. + * + * hinting :: + * Whether hinting should be applied. + */ FT_LOCAL_DEF( void ) ps_builder_init( PS_Builder* ps_builder, void* builder, @@ -2116,19 +2178,20 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_builder_done */ - /* */ - /* <Description> */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* <Input> */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ + /************************************************************************** + * + * @Function: + * ps_builder_done + * + * @Description: + * Finalizes a given glyph builder. Its contents can still be used + * after the call, but the function saves important information + * within the corresponding glyph slot. + * + * @Input: + * builder :: + * A pointer to the glyph builder to finalize. + */ FT_LOCAL_DEF( void ) ps_builder_done( PS_Builder* builder ) { @@ -2336,23 +2399,26 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* ps_decoder_init */ - /* */ - /* <Description> */ - /* Creates a wrapper decoder for use in the combined */ - /* Type 1 / CFF interpreter. */ - /* */ - /* <InOut> */ - /* ps_decoder :: A pointer to the decoder to initialize. */ - /* */ - /* <Input> */ - /* decoder :: A pointer to the original decoder. */ - /* */ - /* is_t1 :: Flag indicating Type 1 or CFF */ - /* */ + /************************************************************************** + * + * @Function: + * ps_decoder_init + * + * @Description: + * Creates a wrapper decoder for use in the combined + * Type 1 / CFF interpreter. + * + * @InOut: + * ps_decoder :: + * A pointer to the decoder to initialize. + * + * @Input: + * decoder :: + * A pointer to the original decoder. + * + * is_t1 :: + * Flag indicating Type 1 or CFF + */ FT_LOCAL_DEF( void ) ps_decoder_init( PS_Decoder* ps_decoder, void* decoder, diff --git a/src/3rdparty/freetype/src/psaux/psobjs.h b/src/3rdparty/freetype/src/psaux/psobjs.h index 8e0fe5fa4c..c44dc450ec 100644 --- a/src/3rdparty/freetype/src/psaux/psobjs.h +++ b/src/3rdparty/freetype/src/psaux/psobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psobjs.h */ -/* */ -/* Auxiliary functions for PostScript fonts (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psobjs.h + * + * Auxiliary functions for PostScript fonts (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSOBJS_H_ @@ -53,10 +53,10 @@ FT_BEGIN_HEADER FT_Memory memory ); FT_LOCAL( FT_Error ) - ps_table_add( PS_Table table, - FT_Int idx, - void* object, - FT_UInt length ); + ps_table_add( PS_Table table, + FT_Int idx, + const void* object, + FT_UInt length ); FT_LOCAL( void ) ps_table_done( PS_Table table ); diff --git a/src/3rdparty/freetype/src/psaux/psread.c b/src/3rdparty/freetype/src/psaux/psread.c index 719863ce17..86bfc03c6e 100644 --- a/src/3rdparty/freetype/src/psaux/psread.c +++ b/src/3rdparty/freetype/src/psaux/psread.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psread.c */ -/* */ -/* Adobe's code for stream handling (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psread.c + * + * Adobe's code for stream handling (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -105,7 +105,7 @@ FT_LOCAL_DEF( FT_Bool ) cf2_buf_isEnd( CF2_Buffer buf ) { - return (FT_Bool)( buf->ptr >= buf->end ); + return FT_BOOL( buf->ptr >= buf->end ); } diff --git a/src/3rdparty/freetype/src/psaux/psread.h b/src/3rdparty/freetype/src/psaux/psread.h index 464b29ba74..9e55fe0447 100644 --- a/src/3rdparty/freetype/src/psaux/psread.h +++ b/src/3rdparty/freetype/src/psaux/psread.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psread.h */ -/* */ -/* Adobe's code for stream handling (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psread.h + * + * Adobe's code for stream handling (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSREAD_H_ diff --git a/src/3rdparty/freetype/src/psaux/psstack.c b/src/3rdparty/freetype/src/psaux/psstack.c index 69d063349a..6659068001 100644 --- a/src/3rdparty/freetype/src/psaux/psstack.c +++ b/src/3rdparty/freetype/src/psaux/psstack.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psstack.c */ -/* */ -/* Adobe's code for emulating a CFF stack (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psstack.c + * + * Adobe's code for emulating a CFF stack (body). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #include "psft.h" @@ -258,6 +258,9 @@ return; } + /* before C99 it is implementation-defined whether */ + /* the result of `%' is negative if the first operand */ + /* is negative */ if ( shift < 0 ) shift = -( ( -shift ) % count ); else diff --git a/src/3rdparty/freetype/src/psaux/psstack.h b/src/3rdparty/freetype/src/psaux/psstack.h index 38f7b41c68..18cd39bc6a 100644 --- a/src/3rdparty/freetype/src/psaux/psstack.h +++ b/src/3rdparty/freetype/src/psaux/psstack.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* psstack.h */ -/* */ -/* Adobe's code for emulating a CFF stack (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psstack.h + * + * Adobe's code for emulating a CFF stack (specification). + * + * Copyright 2007-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSSTACK_H_ diff --git a/src/3rdparty/freetype/src/psaux/pstypes.h b/src/3rdparty/freetype/src/psaux/pstypes.h index dfbaa3d475..041287e8d5 100644 --- a/src/3rdparty/freetype/src/psaux/pstypes.h +++ b/src/3rdparty/freetype/src/psaux/pstypes.h @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* pstypes.h */ -/* */ -/* Adobe's code for defining data types (specification only). */ -/* */ -/* Copyright 2011-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pstypes.h + * + * Adobe's code for defining data types (specification only). + * + * Copyright 2011-2013 Adobe Systems Incorporated. + * + * This software, and all works of authorship, whether in source or + * object code form as indicated by the copyright notice(s) included + * herein (collectively, the "Work") is made available, and may only be + * used, modified, and distributed under the FreeType Project License, + * LICENSE.TXT. Additionally, subject to the terms and conditions of the + * FreeType Project License, each contributor to the Work hereby grants + * to any individual or legal entity exercising permissions granted by + * the FreeType Project License and this section (hereafter, "You" or + * "Your") a perpetual, worldwide, non-exclusive, no-charge, + * royalty-free, irrevocable (except as stated in this section) patent + * license to make, have made, use, offer to sell, sell, import, and + * otherwise transfer the Work, where such license applies only to those + * patent claims licensable by such contributor that are necessarily + * infringed by their contribution(s) alone or by combination of their + * contribution(s) with the Work to which such contribution(s) was + * submitted. If You institute patent litigation against any entity + * (including a cross-claim or counterclaim in a lawsuit) alleging that + * the Work or a contribution incorporated within the Work constitutes + * direct or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate as of + * the date such litigation is filed. + * + * By using, modifying, or distributing the Work you indicate that you + * have read and understood the terms and conditions of the + * FreeType Project License as well as those provided in this section, + * and you accept them fully. + * + */ #ifndef PSTYPES_H_ diff --git a/src/3rdparty/freetype/src/psaux/rules.mk b/src/3rdparty/freetype/src/psaux/rules.mk index a87bfe9687..2de734d547 100644 --- a/src/3rdparty/freetype/src/psaux/rules.mk +++ b/src/3rdparty/freetype/src/psaux/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/psaux/t1cmap.c b/src/3rdparty/freetype/src/psaux/t1cmap.c index 112a7892ba..d62d2d5c81 100644 --- a/src/3rdparty/freetype/src/psaux/t1cmap.c +++ b/src/3rdparty/freetype/src/psaux/t1cmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1cmap.c */ -/* */ -/* Type 1 character map support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1cmap.c + * + * Type 1 character map support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "t1cmap.h" @@ -305,6 +305,9 @@ FT_UNUSED( pointer ); + if ( !psnames->unicodes_init ) + return FT_THROW( Unimplemented_Feature ); + return psnames->unicodes_init( memory, unicodes, (FT_UInt)face->type1.num_glyphs, diff --git a/src/3rdparty/freetype/src/psaux/t1cmap.h b/src/3rdparty/freetype/src/psaux/t1cmap.h index 4308e31d2d..d325e7b5a6 100644 --- a/src/3rdparty/freetype/src/psaux/t1cmap.h +++ b/src/3rdparty/freetype/src/psaux/t1cmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1cmap.h */ -/* */ -/* Type 1 character map support (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1cmap.h + * + * Type 1 character map support (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1CMAP_H_ diff --git a/src/3rdparty/freetype/src/psaux/t1decode.c b/src/3rdparty/freetype/src/psaux/t1decode.c index 6ad145661f..c2b3729b53 100644 --- a/src/3rdparty/freetype/src/psaux/t1decode.c +++ b/src/3rdparty/freetype/src/psaux/t1decode.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1decode.c */ -/* */ -/* PostScript Type 1 decoding routines (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1decode.c + * + * PostScript Type 1 decoding routines (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,14 +31,14 @@ /* ensure proper sign extension */ #define Fix2Int( f ) ( (FT_Int)(FT_Short)( (f) >> 16 ) ) - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1decode +#define FT_COMPONENT t1decode typedef enum T1_Operator_ @@ -109,24 +109,26 @@ }; - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_lookup_glyph_by_stdcharcode_ps */ - /* */ - /* <Description> */ - /* Looks up a given glyph by its StandardEncoding charcode. Used to */ - /* implement the SEAC Type 1 operator in the Adobe engine */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* charcode :: The character code to look for. */ - /* */ - /* <Return> */ - /* A glyph index in the font face. Returns -1 if the corresponding */ - /* glyph wasn't found. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_lookup_glyph_by_stdcharcode_ps + * + * @Description: + * Looks up a given glyph by its StandardEncoding charcode. Used to + * implement the SEAC Type 1 operator in the Adobe engine + * + * @Input: + * face :: + * The current face object. + * + * charcode :: + * The character code to look for. + * + * @Return: + * A glyph index in the font face. Returns -1 if the corresponding + * glyph wasn't found. + */ FT_LOCAL_DEF( FT_Int ) t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder, FT_Int charcode ) @@ -159,24 +161,27 @@ #ifdef T1_CONFIG_OPTION_OLD_ENGINE - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_lookup_glyph_by_stdcharcode */ - /* */ - /* <Description> */ - /* Looks up a given glyph by its StandardEncoding charcode. Used to */ - /* implement the SEAC Type 1 operator. */ - /* */ - /* <Input> */ - /* face :: The current face object. */ - /* */ - /* charcode :: The character code to look for. */ - /* */ - /* <Return> */ - /* A glyph index in the font face. Returns -1 if the corresponding */ - /* glyph wasn't found. */ - /* */ + + /************************************************************************** + * + * @Function: + * t1_lookup_glyph_by_stdcharcode + * + * @Description: + * Looks up a given glyph by its StandardEncoding charcode. Used to + * implement the SEAC Type 1 operator. + * + * @Input: + * face :: + * The current face object. + * + * charcode :: + * The character code to look for. + * + * @Return: + * A glyph index in the font face. Returns -1 if the corresponding + * glyph wasn't found. + */ static FT_Int t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder, FT_Int charcode ) @@ -217,30 +222,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1operator_seac */ - /* */ - /* <Description> */ - /* Implements the `seac' Type 1 operator for a Type 1 decoder. */ - /* */ - /* <Input> */ - /* decoder :: The current CID decoder. */ - /* */ - /* asb :: The accent's side bearing. */ - /* */ - /* adx :: The horizontal offset of the accent. */ - /* */ - /* ady :: The vertical offset of the accent. */ - /* */ - /* bchar :: The base character's StandardEncoding charcode. */ - /* */ - /* achar :: The accent character's StandardEncoding charcode. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * t1operator_seac + * + * @Description: + * Implements the `seac' Type 1 operator for a Type 1 decoder. + * + * @Input: + * decoder :: + * The current CID decoder. + * + * asb :: + * The accent's side bearing. + * + * adx :: + * The horizontal offset of the accent. + * + * ady :: + * The vertical offset of the accent. + * + * bchar :: + * The base character's StandardEncoding charcode. + * + * achar :: + * The accent character's StandardEncoding charcode. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error t1operator_seac( T1_Decoder decoder, FT_Pos asb, @@ -399,24 +410,27 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_decoder_parse_charstrings */ - /* */ - /* <Description> */ - /* Parses a given Type 1 charstrings program. */ - /* */ - /* <Input> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* charstring_base :: The base address of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * t1_decoder_parse_charstrings + * + * @Description: + * Parses a given Type 1 charstrings program. + * + * @Input: + * decoder :: + * The current Type 1 decoder. + * + * charstring_base :: + * The base address of the charstring stream. + * + * charstring_len :: + * The length in bytes of the charstring stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* charstring_base, @@ -466,9 +480,6 @@ if ( decoder->buildchar && decoder->len_buildchar > 0 ) FT_ARRAY_ZERO( decoder->buildchar, decoder->len_buildchar ); - FT_TRACE4(( "\n" - "Start charstring\n" )); - zone->base = charstring_base; limit = zone->limit = charstring_base + charstring_len; ip = zone->cursor = zone->base; @@ -503,11 +514,11 @@ } #endif - /*********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - /* */ + /********************************************************************** + * + * Decode operator or operand + * + */ /* first of all, decompress operator or value */ switch ( *ip++ ) @@ -710,11 +721,11 @@ large_int = FALSE; } - /*********************************************************************/ - /* */ - /* Push value on stack, or process operator */ - /* */ - /* */ + /********************************************************************** + * + * Push value on stack, or process operator + * + */ if ( op == op_none ) { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) @@ -752,16 +763,17 @@ subr_no = Fix2Int( top[1] ); arg_cnt = Fix2Int( top[0] ); - /***********************************************************/ - /* */ - /* remove all operands to callothersubr from the stack */ - /* */ - /* for handled othersubrs, where we know the number of */ - /* arguments, we increase the stack by the value of */ - /* known_othersubr_result_cnt */ - /* */ - /* for unhandled othersubrs the following pops adjust the */ - /* stack pointer as necessary */ + /************************************************************ + * + * remove all operands to callothersubr from the stack + * + * for handled othersubrs, where we know the number of + * arguments, we increase the stack by the value of + * known_othersubr_result_cnt + * + * for unhandled othersubrs the following pops adjust the + * stack pointer as necessary + */ if ( arg_cnt > top - decoder->stack ) goto Stack_Underflow; @@ -1223,7 +1235,10 @@ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) + { + FT_TRACE4(( "\n" )); return FT_Err_Ok; + } break; @@ -1255,7 +1270,10 @@ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) + { + FT_TRACE4(( "\n" )); return FT_Err_Ok; + } break; @@ -1638,26 +1656,31 @@ return FT_THROW( Stack_Underflow ); } -#else /* T1_CONFIG_OPTION_OLD_ENGINE */ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* t1_decoder_parse_metrics */ - /* */ - /* <Description> */ - /* Parses a given Type 1 charstrings program to extract width */ - /* */ - /* <Input> */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* charstring_base :: The base address of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + +#else /* !T1_CONFIG_OPTION_OLD_ENGINE */ + + + /************************************************************************** + * + * @Function: + * t1_decoder_parse_metrics + * + * @Description: + * Parses a given Type 1 charstrings program to extract width + * + * @Input: + * decoder :: + * The current Type 1 decoder. + * + * charstring_base :: + * The base address of the charstring stream. + * + * charstring_len :: + * The length in bytes of the charstring stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) t1_decoder_parse_metrics( T1_Decoder decoder, FT_Byte* charstring_base, @@ -1680,9 +1703,6 @@ builder->parse_state = T1_Parse_Start; - FT_TRACE4(( "\n" - "Start charstring: get width\n" )); - zone->base = charstring_base; limit = zone->limit = charstring_base + charstring_len; ip = zone->cursor = zone->base; @@ -1703,11 +1723,11 @@ } #endif - /*********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - /* */ + /********************************************************************** + * + * Decode operator or operand + * + */ /* first of all, decompress operator or value */ switch ( *ip++ ) @@ -1817,11 +1837,11 @@ } } - /*********************************************************************/ - /* */ - /* Push value on stack, or process operator */ - /* */ - /* */ + /********************************************************************** + * + * Push value on stack, or process operator + * + */ if ( op == op_none ) { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) @@ -1875,6 +1895,7 @@ /* we only want to compute the glyph's metrics */ /* (lsb + advance width), not load the rest of */ /* it; so exit immediately */ + FT_TRACE4(( "\n" )); return FT_Err_Ok; case op_sbw: @@ -1893,6 +1914,7 @@ /* we only want to compute the glyph's metrics */ /* (lsb + advance width), not load the rest of */ /* it; so exit immediately */ + FT_TRACE4(( "\n" )); return FT_Err_Ok; default: @@ -1917,7 +1939,8 @@ Stack_Underflow: return FT_THROW( Stack_Underflow ); } -#endif /* T1_CONFIG_OPTION_OLD_ENGINE */ + +#endif /* !T1_CONFIG_OPTION_OLD_ENGINE */ /* initialize T1 decoder */ @@ -1934,7 +1957,7 @@ { FT_ZERO( decoder ); - /* retrieve PSNames interface from list of current modules */ + /* retrieve `psnames' interface from list of current modules */ { FT_Service_PsCMaps psnames; diff --git a/src/3rdparty/freetype/src/psaux/t1decode.h b/src/3rdparty/freetype/src/psaux/t1decode.h index 1d9718d678..1b5d6263d3 100644 --- a/src/3rdparty/freetype/src/psaux/t1decode.h +++ b/src/3rdparty/freetype/src/psaux/t1decode.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1decode.h */ -/* */ -/* PostScript Type 1 decoding routines (specification). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1decode.h + * + * PostScript Type 1 decoding routines (specification). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1DECODE_H_ diff --git a/src/3rdparty/freetype/src/pshinter/Jamfile b/src/3rdparty/freetype/src/pshinter/Jamfile index 3f5f0ae40e..0e44c19148 100644 --- a/src/3rdparty/freetype/src/pshinter/Jamfile +++ b/src/3rdparty/freetype/src/pshinter/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/pshinter Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/pshinter/module.mk b/src/3rdparty/freetype/src/pshinter/module.mk index 06707be3b4..0a12a260e1 100644 --- a/src/3rdparty/freetype/src/pshinter/module.mk +++ b/src/3rdparty/freetype/src/pshinter/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/pshinter/pshalgo.c b/src/3rdparty/freetype/src/pshinter/pshalgo.c index b98077c62e..0c5ae62699 100644 --- a/src/3rdparty/freetype/src/pshinter/pshalgo.c +++ b/src/3rdparty/freetype/src/pshinter/pshalgo.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshalgo.c */ -/* */ -/* PostScript hinting algorithm (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshalgo.c + * + * PostScript hinting algorithm (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,7 +26,7 @@ #undef FT_COMPONENT -#define FT_COMPONENT trace_pshalgo +#define FT_COMPONENT pshalgo #ifdef DEBUG_HINTER @@ -53,8 +53,8 @@ psh_hint_overlap( PSH_Hint hint1, PSH_Hint hint2 ) { - return hint1->org_pos + hint1->org_len >= hint2->org_pos && - hint2->org_pos + hint2->org_len >= hint1->org_pos; + return ADD_INT( hint1->org_pos, hint1->org_len ) >= hint2->org_pos && + ADD_INT( hint2->org_pos, hint2->org_len ) >= hint1->org_pos; } @@ -479,7 +479,7 @@ if ( dimension == 1 ) psh_blues_snap_stem( &globals->blues, - hint->org_pos + hint->org_len, + ADD_INT( hint->org_pos, hint->org_len ), hint->org_pos, &align ); @@ -658,8 +658,8 @@ #if 0 /* not used for now, experimental */ /* - * A variant to perform "light" hinting (i.e. FT_RENDER_MODE_LIGHT) - * of stems + * A variant to perform "light" hinting (i.e. FT_RENDER_MODE_LIGHT) + * of stems */ static void psh_hint_align_light( PSH_Hint hint, @@ -703,7 +703,7 @@ if ( dimension == 1 ) psh_blues_snap_stem( &globals->blues, - hint->org_pos + hint->org_len, + ADD_INT( hint->org_pos, hint->org_len ), hint->org_pos, &align ); @@ -1538,8 +1538,8 @@ PSH_Hint hint = sort[nn]; - if ( org_u >= hint->org_pos && - org_u <= hint->org_pos + hint->org_len ) + if ( org_u >= hint->org_pos && + org_u <= ADD_INT( hint->org_pos, hint->org_len ) ) { point->hint = hint; break; diff --git a/src/3rdparty/freetype/src/pshinter/pshalgo.h b/src/3rdparty/freetype/src/pshinter/pshalgo.h index c50683fbec..6859e95cd2 100644 --- a/src/3rdparty/freetype/src/pshinter/pshalgo.h +++ b/src/3rdparty/freetype/src/pshinter/pshalgo.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshalgo.h */ -/* */ -/* PostScript hinting algorithm (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshalgo.h + * + * PostScript hinting algorithm (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHALGO_H_ diff --git a/src/3rdparty/freetype/src/pshinter/pshglob.c b/src/3rdparty/freetype/src/pshinter/pshglob.c index accc04921d..b021e6e42a 100644 --- a/src/3rdparty/freetype/src/pshinter/pshglob.c +++ b/src/3rdparty/freetype/src/pshinter/pshglob.c @@ -1,25 +1,26 @@ -/***************************************************************************/ -/* */ -/* pshglob.c */ -/* */ -/* PostScript hinter global hinting management (body). */ -/* Inspired by the new auto-hinter module. */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshglob.c + * + * PostScript hinter global hinting management (body). + * Inspired by the new auto-hinter module. + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_CALC_H #include "pshglob.h" #ifdef DEBUG_HINTER @@ -568,7 +569,7 @@ for ( ; count > 0; count--, zone++ ) { - delta = stem_top - zone->org_bottom; + delta = SUB_LONG( stem_top, zone->org_bottom ); if ( delta < -blues->blue_fuzz ) break; @@ -590,7 +591,7 @@ for ( ; count > 0; count--, zone-- ) { - delta = zone->org_top - stem_bot; + delta = SUB_LONG( zone->org_top, stem_bot ); if ( delta < -blues->blue_fuzz ) break; diff --git a/src/3rdparty/freetype/src/pshinter/pshglob.h b/src/3rdparty/freetype/src/pshinter/pshglob.h index cf80bf40e6..0049d4c0bc 100644 --- a/src/3rdparty/freetype/src/pshinter/pshglob.h +++ b/src/3rdparty/freetype/src/pshinter/pshglob.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshglob.h */ -/* */ -/* PostScript hinter global hinting management. */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshglob.h + * + * PostScript hinter global hinting management. + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHGLOB_H_ @@ -36,27 +36,27 @@ FT_BEGIN_HEADER /*************************************************************************/ - /*************************************************************************/ - /* */ - /* @constant: */ - /* PS_GLOBALS_MAX_BLUE_ZONES */ - /* */ - /* @description: */ - /* The maximum number of blue zones in a font global hints structure. */ - /* See @PS_Globals_BluesRec. */ - /* */ + /************************************************************************** + * + * @constant: + * PS_GLOBALS_MAX_BLUE_ZONES + * + * @description: + * The maximum number of blue zones in a font global hints structure. + * See @PS_Globals_BluesRec. + */ #define PS_GLOBALS_MAX_BLUE_ZONES 16 - /*************************************************************************/ - /* */ - /* @constant: */ - /* PS_GLOBALS_MAX_STD_WIDTHS */ - /* */ - /* @description: */ - /* The maximum number of standard and snap widths in either the */ - /* horizontal or vertical direction. See @PS_Globals_WidthsRec. */ - /* */ + /************************************************************************** + * + * @constant: + * PS_GLOBALS_MAX_STD_WIDTHS + * + * @description: + * The maximum number of standard and snap widths in either the + * horizontal or vertical direction. See @PS_Globals_WidthsRec. + */ #define PS_GLOBALS_MAX_STD_WIDTHS 16 diff --git a/src/3rdparty/freetype/src/pshinter/pshinter.c b/src/3rdparty/freetype/src/pshinter/pshinter.c index 0eedac452d..16c3a0a117 100644 --- a/src/3rdparty/freetype/src/pshinter/pshinter.c +++ b/src/3rdparty/freetype/src/pshinter/pshinter.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshinter.c */ -/* */ -/* FreeType PostScript Hinting module */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshinter.c + * + * FreeType PostScript Hinting module + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -22,7 +22,6 @@ #include "pshalgo.c" #include "pshglob.c" #include "pshmod.c" -#include "pshpic.c" #include "pshrec.c" diff --git a/src/3rdparty/freetype/src/pshinter/pshmod.c b/src/3rdparty/freetype/src/pshinter/pshmod.c index 0b8f6f99b8..2d36ea2a6a 100644 --- a/src/3rdparty/freetype/src/pshinter/pshmod.c +++ b/src/3rdparty/freetype/src/pshinter/pshmod.c @@ -1,26 +1,25 @@ -/***************************************************************************/ -/* */ -/* pshmod.c */ -/* */ -/* FreeType PostScript hinter module implementation (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshmod.c + * + * FreeType PostScript hinter module implementation (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include "pshrec.h" #include "pshalgo.h" -#include "pshpic.h" /* the Postscript Hinter module structure */ @@ -111,7 +110,7 @@ 0x10000L, 0x20000L, - &PSHINTER_INTERFACE_GET, /* module-specific interface */ + &pshinter_interface, /* module-specific interface */ (FT_Module_Constructor)ps_hinter_init, /* module_init */ (FT_Module_Destructor) ps_hinter_done, /* module_done */ diff --git a/src/3rdparty/freetype/src/pshinter/pshmod.h b/src/3rdparty/freetype/src/pshinter/pshmod.h index 556de2fbc0..ea8771308a 100644 --- a/src/3rdparty/freetype/src/pshinter/pshmod.h +++ b/src/3rdparty/freetype/src/pshinter/pshmod.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshmod.h */ -/* */ -/* PostScript hinter module interface (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshmod.h + * + * PostScript hinter module interface (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSHMOD_H_ diff --git a/src/3rdparty/freetype/src/pshinter/pshnterr.h b/src/3rdparty/freetype/src/pshinter/pshnterr.h index b9d02d2956..fb9dbca2b1 100644 --- a/src/3rdparty/freetype/src/pshinter/pshnterr.h +++ b/src/3rdparty/freetype/src/pshinter/pshnterr.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* pshnterr.h */ -/* */ -/* PS Hinter error codes (specification only). */ -/* */ -/* Copyright 2003-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PSHinter error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * pshnterr.h + * + * PS Hinter error codes (specification only). + * + * Copyright (C) 2003-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PSHinter error enumeration constants. + * + */ #ifndef PSHNTERR_H_ #define PSHNTERR_H_ diff --git a/src/3rdparty/freetype/src/pshinter/pshrec.c b/src/3rdparty/freetype/src/pshinter/pshrec.c index 6648d13d60..9dd09efe4c 100644 --- a/src/3rdparty/freetype/src/pshinter/pshrec.c +++ b/src/3rdparty/freetype/src/pshinter/pshrec.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pshrec.c */ -/* */ -/* FreeType PostScript hints recorder (body). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pshrec.c + * + * FreeType PostScript hints recorder (body). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -28,7 +28,7 @@ #include "pshnterr.h" #undef FT_COMPONENT -#define FT_COMPONENT trace_pshrec +#define FT_COMPONENT pshrec #ifdef DEBUG_HINTER PS_Hints ps_debug_hints = NULL; @@ -666,7 +666,7 @@ if ( len == -21 ) { flags |= PS_HINT_FLAG_BOTTOM; - pos += len; + pos = ADD_INT( pos, len ); } len = 0; } @@ -1187,7 +1187,7 @@ /* compute integer stem positions in font units */ for ( n = 0; n < count * 2; n++ ) { - y += coords[n]; + y = ADD_LONG( y, coords[n] ); stems[n] = FIXED_TO_INT( y ); } diff --git a/src/3rdparty/freetype/src/pshinter/pshrec.h b/src/3rdparty/freetype/src/pshinter/pshrec.h index 7e3dfe0d53..02cc2102ec 100644 --- a/src/3rdparty/freetype/src/pshinter/pshrec.h +++ b/src/3rdparty/freetype/src/pshinter/pshrec.h @@ -1,31 +1,31 @@ -/***************************************************************************/ -/* */ -/* pshrec.h */ -/* */ -/* Postscript (Type1/Type2) hints recorder (specification). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /**************************************************************************/ - /* */ - /* The functions defined here are called from the Type 1, CID and CFF */ - /* font drivers to record the hints of a given character/glyph. */ - /* */ - /* The hints are recorded in a unified format, and are later processed */ - /* by the `optimizer' and `fitter' to adjust the outlines to the pixel */ - /* grid. */ - /* */ - /**************************************************************************/ +/**************************************************************************** + * + * pshrec.h + * + * Postscript (Type1/Type2) hints recorder (specification). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /*************************************************************************** + * + * The functions defined here are called from the Type 1, CID and CFF + * font drivers to record the hints of a given character/glyph. + * + * The hints are recorded in a unified format, and are later processed + * by the `optimizer' and `fitter' to adjust the outlines to the pixel + * grid. + * + */ #ifndef PSHREC_H_ diff --git a/src/3rdparty/freetype/src/pshinter/rules.mk b/src/3rdparty/freetype/src/pshinter/rules.mk index 966690efc2..58227d10f2 100644 --- a/src/3rdparty/freetype/src/pshinter/rules.mk +++ b/src/3rdparty/freetype/src/pshinter/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -31,7 +31,6 @@ PSHINTER_COMPILE := $(CC) $(ANSIFLAGS) \ PSHINTER_DRV_SRC := $(PSHINTER_DIR)/pshalgo.c \ $(PSHINTER_DIR)/pshglob.c \ $(PSHINTER_DIR)/pshmod.c \ - $(PSHINTER_DIR)/pshpic.c \ $(PSHINTER_DIR)/pshrec.c diff --git a/src/3rdparty/freetype/src/psnames/Jamfile b/src/3rdparty/freetype/src/psnames/Jamfile index a0fd37397a..75978a8787 100644 --- a/src/3rdparty/freetype/src/psnames/Jamfile +++ b/src/3rdparty/freetype/src/psnames/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/psnames Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/psnames/module.mk b/src/3rdparty/freetype/src/psnames/module.mk index 410f48a191..0806a318a7 100644 --- a/src/3rdparty/freetype/src/psnames/module.mk +++ b/src/3rdparty/freetype/src/psnames/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/psnames/psmodule.c b/src/3rdparty/freetype/src/psnames/psmodule.c index 8929ebe751..0ec440e67b 100644 --- a/src/3rdparty/freetype/src/psnames/psmodule.c +++ b/src/3rdparty/freetype/src/psnames/psmodule.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psmodule.c */ -/* */ -/* PSNames module implementation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psmodule.c + * + * psnames module implementation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -24,16 +24,16 @@ #include "psmodule.h" /* - * The file `pstables.h' with its arrays and its function - * `ft_get_adobe_glyph_index' is useful for other projects also (for - * example, `pdfium' is using it). However, if used as a C++ header, - * including it in two different source files makes it necessary to use - * `extern const' for the declaration of its arrays, otherwise the data - * would be duplicated as mandated by the C++ standard. + * The file `pstables.h' with its arrays and its function + * `ft_get_adobe_glyph_index' is useful for other projects also (for + * example, `pdfium' is using it). However, if used as a C++ header, + * including it in two different source files makes it necessary to use + * `extern const' for the declaration of its arrays, otherwise the data + * would be duplicated as mandated by the C++ standard. * - * For this reason, we use `DEFINE_PS_TABLES' to guard the function - * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array - * declarations and definitions. + * For this reason, we use `DEFINE_PS_TABLES' to guard the function + * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array + * declarations and definitions. */ #include "pstables.h" #define DEFINE_PS_TABLES @@ -41,7 +41,6 @@ #include "pstables.h" #include "psnamerr.h" -#include "pspic.h" #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES @@ -393,7 +392,9 @@ /* Reallocate if the number of used entries is much smaller. */ if ( count < num_glyphs / 2 ) { - (void)FT_RENEW_ARRAY( table->maps, num_glyphs, count ); + (void)FT_RENEW_ARRAY( table->maps, + num_glyphs + EXTRA_GLYPH_LIST_SIZE, + count ); error = FT_Err_Ok; } @@ -577,28 +578,16 @@ FT_DEFINE_SERVICEDESCREC1( pscmaps_services, - FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET ) + FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface ) static FT_Pointer psnames_get_service( FT_Module module, const char* service_id ) { - /* PSCMAPS_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library; - - - if ( !module ) - return NULL; - library = module->library; - if ( !library ) - return NULL; -#else FT_UNUSED( module ); -#endif - return ft_service_list_lookup( PSCMAPS_SERVICES_GET, service_id ); + return ft_service_list_lookup( pscmaps_services, service_id ); } #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ @@ -621,7 +610,7 @@ 0x20000L, /* driver requires FreeType 2 or above */ PUT_PS_NAMES_SERVICE( - (void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */ + (void*)&pscmaps_interface ), /* module specific interface */ (FT_Module_Constructor)NULL, /* module_init */ (FT_Module_Destructor) NULL, /* module_done */ diff --git a/src/3rdparty/freetype/src/psnames/psmodule.h b/src/3rdparty/freetype/src/psnames/psmodule.h index 3e94f8b437..0df9a7d889 100644 --- a/src/3rdparty/freetype/src/psnames/psmodule.h +++ b/src/3rdparty/freetype/src/psnames/psmodule.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* psmodule.h */ -/* */ -/* High-level PSNames module interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psmodule.h + * + * High-level psnames module interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PSMODULE_H_ diff --git a/src/3rdparty/freetype/src/psnames/psnamerr.h b/src/3rdparty/freetype/src/psnames/psnamerr.h index 14eb76c99c..67ab1765d3 100644 --- a/src/3rdparty/freetype/src/psnames/psnamerr.h +++ b/src/3rdparty/freetype/src/psnames/psnamerr.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* psnamerr.h */ -/* */ -/* PS names module error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the PS names module error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * psnamerr.h + * + * PS names module error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the PS names module error enumeration + * constants. + * + */ #ifndef PSNAMERR_H_ #define PSNAMERR_H_ diff --git a/src/3rdparty/freetype/src/psnames/psnames.c b/src/3rdparty/freetype/src/psnames/psnames.c index febb80d594..4722f98831 100644 --- a/src/3rdparty/freetype/src/psnames/psnames.c +++ b/src/3rdparty/freetype/src/psnames/psnames.c @@ -1,26 +1,25 @@ -/***************************************************************************/ -/* */ -/* psnames.c */ -/* */ -/* FreeType PSNames module component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * psnames.c + * + * FreeType psnames module component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "psmodule.c" -#include "pspic.c" /* END */ diff --git a/src/3rdparty/freetype/src/psnames/pstables.h b/src/3rdparty/freetype/src/psnames/pstables.h index 79545ee039..c0139bbc60 100644 --- a/src/3rdparty/freetype/src/psnames/pstables.h +++ b/src/3rdparty/freetype/src/psnames/pstables.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* pstables.h */ -/* */ -/* PostScript glyph names. */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pstables.h + * + * PostScript glyph names. + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* This file has been generated automatically -- do not edit! */ @@ -609,12 +609,12 @@ /* - * This table is a compressed version of the Adobe Glyph List (AGL), - * optimized for efficient searching. It has been generated by the - * `glnames.py' python script located in the `src/tools' directory. + * This table is a compressed version of the Adobe Glyph List (AGL), + * optimized for efficient searching. It has been generated by the + * `glnames.py' python script located in the `src/tools' directory. * - * The lookup function to get the Unicode value for a given string - * is defined below the table. + * The lookup function to get the Unicode value for a given string + * is defined below the table. */ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST @@ -4137,7 +4137,7 @@ #ifdef DEFINE_PS_TABLES /* - * This function searches the compressed table efficiently. + * This function searches the compressed table efficiently. */ static unsigned long ft_get_adobe_glyph_index( const char* name, diff --git a/src/3rdparty/freetype/src/psnames/rules.mk b/src/3rdparty/freetype/src/psnames/rules.mk index 4d629d841c..dcc203e391 100644 --- a/src/3rdparty/freetype/src/psnames/rules.mk +++ b/src/3rdparty/freetype/src/psnames/rules.mk @@ -1,9 +1,9 @@ # -# FreeType 2 PSNames driver configuration rules +# FreeType 2 psnames driver configuration rules # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -13,7 +13,7 @@ # fully. -# PSNames driver directory +# psnames driver directory # PSNAMES_DIR := $(SRC_DIR)/psnames @@ -26,20 +26,19 @@ PSNAMES_COMPILE := $(CC) $(ANSIFLAGS) \ $(FT_CFLAGS) -# PSNames driver sources (i.e., C files) +# psnames driver sources (i.e., C files) # -PSNAMES_DRV_SRC := $(PSNAMES_DIR)/psmodule.c \ - $(PSNAMES_DIR)/pspic.c +PSNAMES_DRV_SRC := $(PSNAMES_DIR)/psmodule.c -# PSNames driver headers +# psnames driver headers # PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \ $(PSNAMES_DIR)/psnamerr.h \ $(PSNAMES_DIR)/pstables.h -# PSNames driver object(s) +# psnames driver object(s) # # PSNAMES_DRV_OBJ_M is used during `multi' builds # PSNAMES_DRV_OBJ_S is used during `single' builds @@ -47,19 +46,19 @@ PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \ PSNAMES_DRV_OBJ_M := $(PSNAMES_DRV_SRC:$(PSNAMES_DIR)/%.c=$(OBJ_DIR)/%.$O) PSNAMES_DRV_OBJ_S := $(OBJ_DIR)/psnames.$O -# PSNames driver source file for single build +# psnames driver source file for single build # PSNAMES_DRV_SRC_S := $(PSNAMES_DIR)/psnames.c -# PSNames driver - single object +# psnames driver - single object # $(PSNAMES_DRV_OBJ_S): $(PSNAMES_DRV_SRC_S) $(PSNAMES_DRV_SRC) \ $(FREETYPE_H) $(PSNAMES_DRV_H) $(PSNAMES_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(PSNAMES_DRV_SRC_S)) -# PSNames driver - multiple objects +# psnames driver - multiple objects # $(OBJ_DIR)/%.$O: $(PSNAMES_DIR)/%.c $(FREETYPE_H) $(PSNAMES_DRV_H) $(PSNAMES_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) diff --git a/src/3rdparty/freetype/src/raster/Jamfile b/src/3rdparty/freetype/src/raster/Jamfile index 838e7ef57e..3990c05cd8 100644 --- a/src/3rdparty/freetype/src/raster/Jamfile +++ b/src/3rdparty/freetype/src/raster/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/raster Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/raster/ftmisc.h b/src/3rdparty/freetype/src/raster/ftmisc.h index 7e40119071..a246569e3b 100644 --- a/src/3rdparty/freetype/src/raster/ftmisc.h +++ b/src/3rdparty/freetype/src/raster/ftmisc.h @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ftmisc.h */ -/* */ -/* Miscellaneous macros for stand-alone rasterizer (specification */ -/* only). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /***************************************************/ - /* */ - /* This file is *not* portable! You have to adapt */ - /* its definitions to your platform. */ - /* */ - /***************************************************/ +/**************************************************************************** + * + * ftmisc.h + * + * Miscellaneous macros for stand-alone rasterizer (specification + * only). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /**************************************************** + * + * This file is *not* portable! You have to adapt + * its definitions to your platform. + * + */ #ifndef FTMISC_H_ #define FTMISC_H_ diff --git a/src/3rdparty/freetype/src/raster/ftraster.c b/src/3rdparty/freetype/src/raster/ftraster.c index 4354730d54..023b6c1eff 100644 --- a/src/3rdparty/freetype/src/raster/ftraster.c +++ b/src/3rdparty/freetype/src/raster/ftraster.c @@ -1,51 +1,51 @@ -/***************************************************************************/ -/* */ -/* ftraster.c */ -/* */ -/* The FreeType glyph rasterizer (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file can be compiled without the rest of the FreeType engine, by */ - /* defining the STANDALONE_ macro when compiling it. You also need to */ - /* put the files `ftimage.h' and `ftmisc.h' into the $(incdir) */ - /* directory. Typically, you should do something like */ - /* */ - /* - copy `src/raster/ftraster.c' (this file) to your current directory */ - /* */ - /* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' to your */ - /* current directory */ - /* */ - /* - compile `ftraster' with the STANDALONE_ macro defined, as in */ - /* */ - /* cc -c -DSTANDALONE_ ftraster.c */ - /* */ - /* The renderer can be initialized with a call to */ - /* `ft_standard_raster.raster_new'; a bitmap can be generated */ - /* with a call to `ft_standard_raster.raster_render'. */ - /* */ - /* See the comments and documentation in the file `ftimage.h' for more */ - /* details on how the raster works. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is a rewrite of the FreeType 1.x scan-line converter */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftraster.c + * + * The FreeType glyph rasterizer (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file can be compiled without the rest of the FreeType engine, by + * defining the STANDALONE_ macro when compiling it. You also need to + * put the files `ftimage.h' and `ftmisc.h' into the $(incdir) + * directory. Typically, you should do something like + * + * - copy `src/raster/ftraster.c' (this file) to your current directory + * + * - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' to your + * current directory + * + * - compile `ftraster' with the STANDALONE_ macro defined, as in + * + * cc -c -DSTANDALONE_ ftraster.c + * + * The renderer can be initialized with a call to + * `ft_standard_raster.raster_new'; a bitmap can be generated + * with a call to `ft_standard_raster.raster_render'. + * + * See the comments and documentation in the file `ftimage.h' for more + * details on how the raster works. + * + */ + + + /************************************************************************** + * + * This is a rewrite of the FreeType 1.x scan-line converter + * + */ #ifdef STANDALONE_ @@ -65,82 +65,81 @@ #include <ft2build.h> #include "ftraster.h" #include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */ - -#include "rastpic.h" +#include FT_OUTLINE_H /* for FT_Outline_Get_CBox */ #endif /* !STANDALONE_ */ - /*************************************************************************/ - /* */ - /* A simple technical note on how the raster works */ - /* ----------------------------------------------- */ - /* */ - /* Converting an outline into a bitmap is achieved in several steps: */ - /* */ - /* 1 - Decomposing the outline into successive `profiles'. Each */ - /* profile is simply an array of scanline intersections on a given */ - /* dimension. A profile's main attributes are */ - /* */ - /* o its scanline position boundaries, i.e. `Ymin' and `Ymax' */ - /* */ - /* o an array of intersection coordinates for each scanline */ - /* between `Ymin' and `Ymax' */ - /* */ - /* o a direction, indicating whether it was built going `up' or */ - /* `down', as this is very important for filling rules */ - /* */ - /* o its drop-out mode */ - /* */ - /* 2 - Sweeping the target map's scanlines in order to compute segment */ - /* `spans' which are then filled. Additionally, this pass */ - /* performs drop-out control. */ - /* */ - /* The outline data is parsed during step 1 only. The profiles are */ - /* built from the bottom of the render pool, used as a stack. The */ - /* following graphics shows the profile list under construction: */ - /* */ - /* __________________________________________________________ _ _ */ - /* | | | | | */ - /* | profile | coordinates for | profile | coordinates for |--> */ - /* | 1 | profile 1 | 2 | profile 2 |--> */ - /* |_________|_________________|_________|_________________|__ _ _ */ - /* */ - /* ^ ^ */ - /* | | */ - /* start of render pool top */ - /* */ - /* The top of the profile stack is kept in the `top' variable. */ - /* */ - /* As you can see, a profile record is pushed on top of the render */ - /* pool, which is then followed by its coordinates/intersections. If */ - /* a change of direction is detected in the outline, a new profile is */ - /* generated until the end of the outline. */ - /* */ - /* Note that when all profiles have been generated, the function */ - /* Finalize_Profile_Table() is used to record, for each profile, its */ - /* bottom-most scanline as well as the scanline above its upmost */ - /* boundary. These positions are called `y-turns' because they (sort */ - /* of) correspond to local extrema. They are stored in a sorted list */ - /* built from the top of the render pool as a downwards stack: */ - /* */ - /* _ _ _______________________________________ */ - /* | | */ - /* <--| sorted list of | */ - /* <--| extrema scanlines | */ - /* _ _ __________________|____________________| */ - /* */ - /* ^ ^ */ - /* | | */ - /* maxBuff sizeBuff = end of pool */ - /* */ - /* This list is later used during the sweep phase in order to */ - /* optimize performance (see technical note on the sweep below). */ - /* */ - /* Of course, the raster detects whether the two stacks collide and */ - /* handles the situation properly. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * A simple technical note on how the raster works + * ----------------------------------------------- + * + * Converting an outline into a bitmap is achieved in several steps: + * + * 1 - Decomposing the outline into successive `profiles'. Each + * profile is simply an array of scanline intersections on a given + * dimension. A profile's main attributes are + * + * o its scanline position boundaries, i.e. `Ymin' and `Ymax' + * + * o an array of intersection coordinates for each scanline + * between `Ymin' and `Ymax' + * + * o a direction, indicating whether it was built going `up' or + * `down', as this is very important for filling rules + * + * o its drop-out mode + * + * 2 - Sweeping the target map's scanlines in order to compute segment + * `spans' which are then filled. Additionally, this pass + * performs drop-out control. + * + * The outline data is parsed during step 1 only. The profiles are + * built from the bottom of the render pool, used as a stack. The + * following graphics shows the profile list under construction: + * + * __________________________________________________________ _ _ + * | | | | | + * | profile | coordinates for | profile | coordinates for |--> + * | 1 | profile 1 | 2 | profile 2 |--> + * |_________|_________________|_________|_________________|__ _ _ + * + * ^ ^ + * | | + * start of render pool top + * + * The top of the profile stack is kept in the `top' variable. + * + * As you can see, a profile record is pushed on top of the render + * pool, which is then followed by its coordinates/intersections. If + * a change of direction is detected in the outline, a new profile is + * generated until the end of the outline. + * + * Note that when all profiles have been generated, the function + * Finalize_Profile_Table() is used to record, for each profile, its + * bottom-most scanline as well as the scanline above its upmost + * boundary. These positions are called `y-turns' because they (sort + * of) correspond to local extrema. They are stored in a sorted list + * built from the top of the render pool as a downwards stack: + * + * _ _ _______________________________________ + * | | + * <--| sorted list of | + * <--| extrema scanlines | + * _ _ __________________|____________________| + * + * ^ ^ + * | | + * maxBuff sizeBuff = end of pool + * + * This list is later used during the sweep phase in order to + * optimize performance (see technical note on the sweep below). + * + * Of course, the raster detects whether the two stacks collide and + * handles the situation properly. + * + */ /*************************************************************************/ @@ -163,14 +162,14 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_raster +#define FT_COMPONENT raster #ifdef STANDALONE_ @@ -400,7 +399,7 @@ #define RAS_ARGS /* void */ -#define RAS_ARG /* void */ +#define RAS_ARG void #define RAS_VARS /* void */ #define RAS_VAR /* void */ @@ -452,9 +451,9 @@ #define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision ) #define TRUNC( x ) ( (Long)(x) >> ras.precision_bits ) #define FRAC( x ) ( (x) & ( ras.precision - 1 ) ) -#define SCALED( x ) ( ( (x) < 0 ? -( -(x) << ras.scale_shift ) \ - : ( (x) << ras.scale_shift ) ) \ - - ras.precision_half ) + + /* scale and shift grid to pixel centers */ +#define SCALED( x ) ( (x) * ras.precision_scale - ras.precision_half ) #define IS_BOTTOM_OVERSHOOT( x ) \ (Bool)( CEILING( x ) - x >= ras.precision_half ) @@ -476,13 +475,10 @@ Int precision_bits; /* precision related variables */ Int precision; Int precision_half; - Int precision_shift; + Int precision_scale; Int precision_step; Int precision_jitter; - Int scale_shift; /* == precision_shift for bitmaps */ - /* == precision_shift+1 for pixmaps */ - PLong buff; /* The profiles buffer */ PLong sizeBuff; /* Render pool size */ PLong maxBuff; /* Profiles buffer size */ @@ -495,8 +491,7 @@ TPoint* arc; /* current Bezier arc pointer */ UShort bWidth; /* target bitmap width */ - PByte bTarget; /* target bitmap buffer */ - PByte gTarget; /* target pixmap buffer */ + PByte bOrigin; /* target bitmap bottom-left origin */ Long lastX, lastY; Long minY, maxY; @@ -519,8 +514,6 @@ FT_Outline outline; Long traceOfs; /* current offset in target bitmap */ - Long traceG; /* current offset in target pixmap */ - Short traceIncr; /* sweep's increment in target bitmap */ /* dispatch variables */ @@ -553,8 +546,7 @@ #ifdef FT_STATIC_RASTER - static black_TWorker cur_ras; -#define ras cur_ras + static black_TWorker ras; #else /* !FT_STATIC_RASTER */ @@ -572,18 +564,19 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* Set_High_Precision */ - /* */ - /* <Description> */ - /* Set precision variables according to param flag. */ - /* */ - /* <Input> */ - /* High :: Set to True for high precision (typically for ppem < 24), */ - /* false otherwise. */ - /* */ + /************************************************************************** + * + * @Function: + * Set_High_Precision + * + * @Description: + * Set precision variables according to param flag. + * + * @Input: + * High :: + * Set to True for high precision (typically for ppem < 24), + * false otherwise. + */ static void Set_High_Precision( RAS_ARGS Int High ) { @@ -625,29 +618,31 @@ FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" )); ras.precision = 1 << ras.precision_bits; - ras.precision_half = ras.precision / 2; - ras.precision_shift = ras.precision_bits - Pixel_Bits; + ras.precision_half = ras.precision >> 1; + ras.precision_scale = ras.precision >> Pixel_Bits; } - /*************************************************************************/ - /* */ - /* <Function> */ - /* New_Profile */ - /* */ - /* <Description> */ - /* Create a new profile in the render pool. */ - /* */ - /* <Input> */ - /* aState :: The state/orientation of the new profile. */ - /* */ - /* overshoot :: Whether the profile's unrounded start position */ - /* differs by at least a half pixel. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow or of incoherent */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * New_Profile + * + * @Description: + * Create a new profile in the render pool. + * + * @Input: + * aState :: + * The state/orientation of the new profile. + * + * overshoot :: + * Whether the profile's unrounded start position + * differs by at least a half pixel. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow or of incoherent + * profile. + */ static Bool New_Profile( RAS_ARGS TStates aState, Bool overshoot ) @@ -665,7 +660,6 @@ return FAILURE; } - ras.cProfile->flags = 0; ras.cProfile->start = 0; ras.cProfile->height = 0; ras.cProfile->offset = ras.top; @@ -706,21 +700,22 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* End_Profile */ - /* */ - /* <Description> */ - /* Finalize the current profile. */ - /* */ - /* <Input> */ - /* overshoot :: Whether the profile's unrounded end position differs */ - /* by at least a half pixel. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow or incoherency. */ - /* */ + /************************************************************************** + * + * @Function: + * End_Profile + * + * @Description: + * Finalize the current profile. + * + * @Input: + * overshoot :: + * Whether the profile's unrounded end position differs + * by at least a half pixel. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow or incoherency. + */ static Bool End_Profile( RAS_ARGS Bool overshoot ) { @@ -778,21 +773,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Insert_Y_Turn */ - /* */ - /* <Description> */ - /* Insert a salient into the sorted list placed on top of the render */ - /* pool. */ - /* */ - /* <Input> */ - /* New y scanline position. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Insert_Y_Turn + * + * @Description: + * Insert a salient into the sorted list placed on top of the render + * pool. + * + * @Input: + * New y scanline position. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow. + */ static Bool Insert_Y_Turn( RAS_ARGS Int y ) { @@ -834,17 +829,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Finalize_Profile_Table */ - /* */ - /* <Description> */ - /* Adjust all links in the profiles list. */ - /* */ - /* <Return> */ - /* SUCCESS on success. FAILURE in case of overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Finalize_Profile_Table + * + * @Description: + * Adjust all links in the profiles list. + * + * @Return: + * SUCCESS on success. FAILURE in case of overflow. + */ static Bool Finalize_Profile_Table( RAS_ARG ) { @@ -894,22 +889,22 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Split_Conic */ - /* */ - /* <Description> */ - /* Subdivide one conic Bezier into two joint sub-arcs in the Bezier */ - /* stack. */ - /* */ - /* <Input> */ - /* None (subdivided Bezier is taken from the top of the stack). */ - /* */ - /* <Note> */ - /* This routine is the `beef' of this component. It is _the_ inner */ - /* loop that should be optimized to hell to get the best performance. */ - /* */ + /************************************************************************** + * + * @Function: + * Split_Conic + * + * @Description: + * Subdivide one conic Bezier into two joint sub-arcs in the Bezier + * stack. + * + * @Input: + * None (subdivided Bezier is taken from the top of the stack). + * + * @Note: + * This routine is the `beef' of this component. It is _the_ inner + * loop that should be optimized to hell to get the best performance. + */ static void Split_Conic( TPoint* base ) { @@ -917,89 +912,101 @@ base[4].x = base[2].x; - b = base[1].x; - a = base[3].x = ( base[2].x + b ) / 2; - b = base[1].x = ( base[0].x + b ) / 2; - base[2].x = ( a + b ) / 2; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + base[3].x = b >> 1; + base[2].x = ( a + b ) >> 2; + base[1].x = a >> 1; base[4].y = base[2].y; - b = base[1].y; - a = base[3].y = ( base[2].y + b ) / 2; - b = base[1].y = ( base[0].y + b ) / 2; - base[2].y = ( a + b ) / 2; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + base[3].y = b >> 1; + base[2].y = ( a + b ) >> 2; + base[1].y = a >> 1; /* hand optimized. gcc doesn't seem to be too good at common */ /* expression substitution and instruction scheduling ;-) */ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Split_Cubic */ - /* */ - /* <Description> */ - /* Subdivide a third-order Bezier arc into two joint sub-arcs in the */ - /* Bezier stack. */ - /* */ - /* <Note> */ - /* This routine is the `beef' of the component. It is one of _the_ */ - /* inner loops that should be optimized like hell to get the best */ - /* performance. */ - /* */ + /************************************************************************** + * + * @Function: + * Split_Cubic + * + * @Description: + * Subdivide a third-order Bezier arc into two joint sub-arcs in the + * Bezier stack. + * + * @Note: + * This routine is the `beef' of the component. It is one of _the_ + * inner loops that should be optimized like hell to get the best + * performance. + */ static void Split_Cubic( TPoint* base ) { - Long a, b, c, d; + Long a, b, c; base[6].x = base[3].x; - c = base[1].x; - d = base[2].x; - base[1].x = a = ( base[0].x + c + 1 ) >> 1; - base[5].x = b = ( base[3].x + d + 1 ) >> 1; - c = ( c + d + 1 ) >> 1; - base[2].x = a = ( a + c + 1 ) >> 1; - base[4].x = b = ( b + c + 1 ) >> 1; - base[3].x = ( a + b + 1 ) >> 1; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + c = base[2].x + base[3].x; + base[5].x = c >> 1; + c += b; + base[4].x = c >> 2; + base[1].x = a >> 1; + a += b; + base[2].x = a >> 2; + base[3].x = ( a + c ) >> 3; base[6].y = base[3].y; - c = base[1].y; - d = base[2].y; - base[1].y = a = ( base[0].y + c + 1 ) >> 1; - base[5].y = b = ( base[3].y + d + 1 ) >> 1; - c = ( c + d + 1 ) >> 1; - base[2].y = a = ( a + c + 1 ) >> 1; - base[4].y = b = ( b + c + 1 ) >> 1; - base[3].y = ( a + b + 1 ) >> 1; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + c = base[2].y + base[3].y; + base[5].y = c >> 1; + c += b; + base[4].y = c >> 2; + base[1].y = a >> 1; + a += b; + base[2].y = a >> 2; + base[3].y = ( a + c ) >> 3; } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Line_Up */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an ascending line segment and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* x1 :: The x-coordinate of the segment's start point. */ - /* */ - /* y1 :: The y-coordinate of the segment's start point. */ - /* */ - /* x2 :: The x-coordinate of the segment's end point. */ - /* */ - /* y2 :: The y-coordinate of the segment's end point. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Line_Up + * + * @Description: + * Compute the x-coordinates of an ascending line segment and store + * them in the render pool. + * + * @Input: + * x1 :: + * The x-coordinate of the segment's start point. + * + * y1 :: + * The y-coordinate of the segment's start point. + * + * x2 :: + * The x-coordinate of the segment's end point. + * + * y2 :: + * The y-coordinate of the segment's end point. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Line_Up( RAS_ARGS Long x1, Long y1, @@ -1114,31 +1121,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Line_Down */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an descending line segment and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* x1 :: The x-coordinate of the segment's start point. */ - /* */ - /* y1 :: The y-coordinate of the segment's start point. */ - /* */ - /* x2 :: The x-coordinate of the segment's end point. */ - /* */ - /* y2 :: The y-coordinate of the segment's end point. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Line_Down + * + * @Description: + * Compute the x-coordinates of an descending line segment and store + * them in the render pool. + * + * @Input: + * x1 :: + * The x-coordinate of the segment's start point. + * + * y1 :: + * The y-coordinate of the segment's start point. + * + * x2 :: + * The x-coordinate of the segment's end point. + * + * y2 :: + * The y-coordinate of the segment's end point. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Line_Down( RAS_ARGS Long x1, Long y1, @@ -1165,27 +1178,31 @@ typedef void (*TSplitter)( TPoint* base ); - /*************************************************************************/ - /* */ - /* <Function> */ - /* Bezier_Up */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an ascending Bezier arc and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* degree :: The degree of the Bezier arc (either 2 or 3). */ - /* */ - /* splitter :: The function to split Bezier arcs. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Bezier_Up + * + * @Description: + * Compute the x-coordinates of an ascending Bezier arc and store + * them in the render pool. + * + * @Input: + * degree :: + * The degree of the Bezier arc (either 2 or 3). + * + * splitter :: + * The function to split Bezier arcs. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Bezier_Up( RAS_ARGS Int degree, TSplitter splitter, @@ -1298,27 +1315,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Bezier_Down */ - /* */ - /* <Description> */ - /* Compute the x-coordinates of an descending Bezier arc and store */ - /* them in the render pool. */ - /* */ - /* <Input> */ - /* degree :: The degree of the Bezier arc (either 2 or 3). */ - /* */ - /* splitter :: The function to split Bezier arcs. */ - /* */ - /* miny :: A lower vertical clipping bound value. */ - /* */ - /* maxy :: An upper vertical clipping bound value. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow. */ - /* */ + /************************************************************************** + * + * @Function: + * Bezier_Down + * + * @Description: + * Compute the x-coordinates of an descending Bezier arc and store + * them in the render pool. + * + * @Input: + * degree :: + * The degree of the Bezier arc (either 2 or 3). + * + * splitter :: + * The function to split Bezier arcs. + * + * miny :: + * A lower vertical clipping bound value. + * + * maxy :: + * An upper vertical clipping bound value. + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow. + */ static Bool Bezier_Down( RAS_ARGS Int degree, TSplitter splitter, @@ -1347,25 +1368,27 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Line_To */ - /* */ - /* <Description> */ - /* Inject a new line segment and adjust the Profiles list. */ - /* */ - /* <Input> */ - /* x :: The x-coordinate of the segment's end point (its start point */ - /* is stored in `lastX'). */ - /* */ - /* y :: The y-coordinate of the segment's end point (its start point */ - /* is stored in `lastY'). */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow or incorrect */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * Line_To + * + * @Description: + * Inject a new line segment and adjust the Profiles list. + * + * @Input: + * x :: + * The x-coordinate of the segment's end point (its start point + * is stored in `lastX'). + * + * y :: + * The y-coordinate of the segment's end point (its start point + * is stored in `lastY'). + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow or incorrect + * profile. + */ static Bool Line_To( RAS_ARGS Long x, Long y ) @@ -1441,29 +1464,33 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Conic_To */ - /* */ - /* <Description> */ - /* Inject a new conic arc and adjust the profile list. */ - /* */ - /* <Input> */ - /* cx :: The x-coordinate of the arc's new control point. */ - /* */ - /* cy :: The y-coordinate of the arc's new control point. */ - /* */ - /* x :: The x-coordinate of the arc's end point (its start point is */ - /* stored in `lastX'). */ - /* */ - /* y :: The y-coordinate of the arc's end point (its start point is */ - /* stored in `lastY'). */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow or incorrect */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * Conic_To + * + * @Description: + * Inject a new conic arc and adjust the profile list. + * + * @Input: + * cx :: + * The x-coordinate of the arc's new control point. + * + * cy :: + * The y-coordinate of the arc's new control point. + * + * x :: + * The x-coordinate of the arc's end point (its start point is + * stored in `lastX'). + * + * y :: + * The y-coordinate of the arc's end point (its start point is + * stored in `lastY'). + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow or incorrect + * profile. + */ static Bool Conic_To( RAS_ARGS Long cx, Long cy, @@ -1558,33 +1585,39 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Cubic_To */ - /* */ - /* <Description> */ - /* Inject a new cubic arc and adjust the profile list. */ - /* */ - /* <Input> */ - /* cx1 :: The x-coordinate of the arc's first new control point. */ - /* */ - /* cy1 :: The y-coordinate of the arc's first new control point. */ - /* */ - /* cx2 :: The x-coordinate of the arc's second new control point. */ - /* */ - /* cy2 :: The y-coordinate of the arc's second new control point. */ - /* */ - /* x :: The x-coordinate of the arc's end point (its start point is */ - /* stored in `lastX'). */ - /* */ - /* y :: The y-coordinate of the arc's end point (its start point is */ - /* stored in `lastY'). */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on render pool overflow or incorrect */ - /* profile. */ - /* */ + /************************************************************************** + * + * @Function: + * Cubic_To + * + * @Description: + * Inject a new cubic arc and adjust the profile list. + * + * @Input: + * cx1 :: + * The x-coordinate of the arc's first new control point. + * + * cy1 :: + * The y-coordinate of the arc's first new control point. + * + * cx2 :: + * The x-coordinate of the arc's second new control point. + * + * cy2 :: + * The y-coordinate of the arc's second new control point. + * + * x :: + * The x-coordinate of the arc's end point (its start point is + * stored in `lastX'). + * + * y :: + * The y-coordinate of the arc's end point (its start point is + * stored in `lastY'). + * + * @Return: + * SUCCESS on success, FAILURE on render pool overflow or incorrect + * profile. + */ static Bool Cubic_To( RAS_ARGS Long cx1, Long cy1, @@ -1705,27 +1738,30 @@ } while ( 0 ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* Decompose_Curve */ - /* */ - /* <Description> */ - /* Scan the outline arrays in order to emit individual segments and */ - /* Beziers by calling Line_To() and Bezier_To(). It handles all */ - /* weird cases, like when the first point is off the curve, or when */ - /* there are simply no `on' points in the contour! */ - /* */ - /* <Input> */ - /* first :: The index of the first point in the contour. */ - /* */ - /* last :: The index of the last point in the contour. */ - /* */ - /* flipped :: If set, flip the direction of the curve. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE on error. */ - /* */ + /************************************************************************** + * + * @Function: + * Decompose_Curve + * + * @Description: + * Scan the outline arrays in order to emit individual segments and + * Beziers by calling Line_To() and Bezier_To(). It handles all + * weird cases, like when the first point is off the curve, or when + * there are simply no `on' points in the contour! + * + * @Input: + * first :: + * The index of the first point in the contour. + * + * last :: + * The index of the last point in the contour. + * + * flipped :: + * If set, flip the direction of the curve. + * + * @Return: + * SUCCESS on success, FAILURE on error. + */ static Bool Decompose_Curve( RAS_ARGS UShort first, UShort last, @@ -1934,22 +1970,23 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Convert_Glyph */ - /* */ - /* <Description> */ - /* Convert a glyph into a series of segments and arcs and make a */ - /* profiles list with them. */ - /* */ - /* <Input> */ - /* flipped :: If set, flip the direction of curve. */ - /* */ - /* <Return> */ - /* SUCCESS on success, FAILURE if any error was encountered during */ - /* rendering. */ - /* */ + /************************************************************************** + * + * @Function: + * Convert_Glyph + * + * @Description: + * Convert a glyph into a series of segments and arcs and make a + * profiles list with them. + * + * @Input: + * flipped :: + * If set, flip the direction of curve. + * + * @Return: + * SUCCESS on success, FAILURE if any error was encountered during + * rendering. + */ static Bool Convert_Glyph( RAS_ARGS Int flipped ) { @@ -2028,12 +2065,12 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* Init_Linked */ - /* */ - /* Initializes an empty linked list. */ - /* */ + /************************************************************************** + * + * Init_Linked + * + * Initializes an empty linked list. + */ static void Init_Linked( TProfileList* l ) { @@ -2041,12 +2078,12 @@ } - /*************************************************************************/ - /* */ - /* InsNew */ - /* */ - /* Inserts a new profile in a linked list. */ - /* */ + /************************************************************************** + * + * InsNew + * + * Inserts a new profile in a linked list. + */ static void InsNew( PProfileList list, PProfile profile ) @@ -2072,12 +2109,12 @@ } - /*************************************************************************/ - /* */ - /* DelOld */ - /* */ - /* Removes an old profile from a linked list. */ - /* */ + /************************************************************************** + * + * DelOld + * + * Removes an old profile from a linked list. + */ static void DelOld( PProfileList list, PProfile profile ) @@ -2105,14 +2142,14 @@ } - /*************************************************************************/ - /* */ - /* Sort */ - /* */ - /* Sorts a trace list. In 95%, the list is already sorted. We need */ - /* an algorithm which is fast in this case. Bubble sort is enough */ - /* and simple. */ - /* */ + /************************************************************************** + * + * Sort + * + * Sorts a trace list. In 95%, the list is already sorted. We need + * an algorithm which is fast in this case. Bubble sort is enough + * and simple. + */ static void Sort( PProfileList list ) { @@ -2163,14 +2200,14 @@ } - /*************************************************************************/ - /* */ - /* Vertical Sweep Procedure Set */ - /* */ - /* These four routines are used during the vertical black/white sweep */ - /* phase by the generic Draw_Sweep() function. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Vertical Sweep Procedure Set + * + * These four routines are used during the vertical black/white sweep + * phase by the generic Draw_Sweep() function. + * + */ static void Vertical_Sweep_Init( RAS_ARGS Short* min, @@ -2183,8 +2220,6 @@ ras.traceIncr = (Short)-pitch; ras.traceOfs = -*min * pitch; - if ( pitch > 0 ) - ras.traceOfs += (Long)( ras.target.rows - 1 ) * pitch; } @@ -2215,13 +2250,18 @@ /* Drop-out control */ - e1 = TRUNC( CEILING( x1 ) ); + e1 = CEILING( x1 ); + e2 = FLOOR( x2 ); + /* take care of the special case where both the left */ + /* and right contour lie exactly on pixel centers */ if ( dropOutControl != 2 && - x2 - x1 - ras.precision <= ras.precision_jitter ) + x2 - x1 - ras.precision <= ras.precision_jitter && + e1 != x1 && e2 != x2 ) e2 = e1; - else - e2 = TRUNC( FLOOR( x2 ) ); + + e1 = TRUNC( e1 ); + e2 = TRUNC( e2 ); if ( e2 >= 0 && e1 < ras.bWidth ) { @@ -2242,7 +2282,7 @@ f1 = (Byte) ( 0xFF >> ( e1 & 7 ) ); f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) ); - target = ras.bTarget + ras.traceOfs + c1; + target = ras.bOrigin + ras.traceOfs + c1; c2 -= c1; if ( c2 > 0 ) @@ -2252,12 +2292,9 @@ /* memset() is slower than the following code on many platforms. */ /* This is due to the fact that, in the vast majority of cases, */ /* the span length in bytes is relatively small. */ - c2--; - while ( c2 > 0 ) - { + while ( --c2 > 0 ) *(++target) = 0xFF; - c2--; - } + target[1] |= f2; } else @@ -2400,7 +2437,7 @@ f1 = (Short)( e1 & 7 ); if ( e1 >= 0 && e1 < ras.bWidth && - ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) ) + ras.bOrigin[ras.traceOfs + c1] & ( 0x80 >> f1 ) ) goto Exit; } else @@ -2416,7 +2453,7 @@ c1 = (Short)( e1 >> 3 ); f1 = (Short)( e1 & 7 ); - ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 ); + ras.bOrigin[ras.traceOfs + c1] |= (char)( 0x80 >> f1 ); } Exit: @@ -2431,14 +2468,14 @@ } - /***********************************************************************/ - /* */ - /* Horizontal Sweep Procedure Set */ - /* */ - /* These four routines are used during the horizontal black/white */ - /* sweep phase by the generic Draw_Sweep() function. */ - /* */ - /***********************************************************************/ + /************************************************************************ + * + * Horizontal Sweep Procedure Set + * + * These four routines are used during the horizontal black/white + * sweep phase by the generic Draw_Sweep() function. + * + */ static void Horizontal_Sweep_Init( RAS_ARGS Short* min, @@ -2483,19 +2520,14 @@ { Byte f1; PByte bits; - PByte p; FT_TRACE7(( " -> y=%d (drop-out)", e1 )); - bits = ras.bTarget + ( y >> 3 ); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); - p = bits - e1 * ras.target.pitch; - if ( ras.target.pitch > 0 ) - p += (Long)( ras.target.rows - 1 ) * ras.target.pitch; - - p[0] |= f1; + bits[0] |= f1; } } @@ -2597,13 +2629,9 @@ e1 = TRUNC( e1 ); - bits = ras.bTarget + ( y >> 3 ); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); - bits -= e1 * ras.target.pitch; - if ( ras.target.pitch > 0 ) - bits += (Long)( ras.target.rows - 1 ) * ras.target.pitch; - if ( e1 >= 0 && (ULong)e1 < ras.target.rows && *bits & f1 ) @@ -2619,12 +2647,8 @@ { FT_TRACE7(( " -> y=%d (drop-out)", e1 )); - bits = ras.bTarget + ( y >> 3 ); + bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch; f1 = (Byte)( 0x80 >> ( y & 7 ) ); - bits -= e1 * ras.target.pitch; - - if ( ras.target.pitch > 0 ) - bits += (Long)( ras.target.rows - 1 ) * ras.target.pitch; bits[0] |= f1; } @@ -2642,11 +2666,11 @@ } - /*************************************************************************/ - /* */ - /* Generic Sweep Drawing routine */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Generic Sweep Drawing routine + * + */ static Bool Draw_Sweep( RAS_ARG ) @@ -2764,7 +2788,7 @@ P_Left = draw_left; P_Right = draw_right; - while ( P_Left ) + while ( P_Left && P_Right ) { x1 = P_Left ->X; x2 = P_Right->X; @@ -2865,7 +2889,7 @@ P_Left = draw_left; P_Right = draw_right; - while ( P_Left ) + while ( P_Left && P_Right ) { if ( P_Left->countL ) { @@ -2888,20 +2912,109 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Render_Single_Pass */ - /* */ - /* <Description> */ - /* Perform one sweep with sub-banding. */ - /* */ - /* <Input> */ - /* flipped :: If set, flip the direction of the outline. */ - /* */ - /* <Return> */ - /* Renderer error code. */ - /* */ +#ifdef STANDALONE_ + + /************************************************************************** + * + * The following functions should only compile in stand-alone mode, + * i.e., when building this component without the rest of FreeType. + * + */ + + /************************************************************************** + * + * @Function: + * FT_Outline_Get_CBox + * + * @Description: + * Return an outline's `control box'. The control box encloses all + * the outline's points, including Bézier control points. Though it + * coincides with the exact bounding box for most glyphs, it can be + * slightly larger in some situations (like when rotating an outline + * that contains Bézier outside arcs). + * + * Computing the control box is very fast, while getting the bounding + * box can take much more time as it needs to walk over all segments + * and arcs in the outline. To get the latter, you can use the + * `ftbbox' component, which is dedicated to this single task. + * + * @Input: + * outline :: + * A pointer to the source outline descriptor. + * + * @Output: + * acbox :: + * The outline's control box. + * + * @Note: + * See @FT_Glyph_Get_CBox for a discussion of tricky fonts. + */ + + static void + FT_Outline_Get_CBox( const FT_Outline* outline, + FT_BBox *acbox ) + { + Long xMin, yMin, xMax, yMax; + + + if ( outline && acbox ) + { + if ( outline->n_points == 0 ) + { + xMin = 0; + yMin = 0; + xMax = 0; + yMax = 0; + } + else + { + FT_Vector* vec = outline->points; + FT_Vector* limit = vec + outline->n_points; + + + xMin = xMax = vec->x; + yMin = yMax = vec->y; + vec++; + + for ( ; vec < limit; vec++ ) + { + Long x, y; + + + x = vec->x; + if ( x < xMin ) xMin = x; + if ( x > xMax ) xMax = x; + + y = vec->y; + if ( y < yMin ) yMin = y; + if ( y > yMax ) yMax = y; + } + } + acbox->xMin = xMin; + acbox->xMax = xMax; + acbox->yMin = yMin; + acbox->yMax = yMax; + } + } + +#endif /* STANDALONE_ */ + + + /************************************************************************** + * + * @Function: + * Render_Single_Pass + * + * @Description: + * Perform one sweep with sub-banding. + * + * @Input: + * flipped :: + * If set, flip the direction of the outline. + * + * @Return: + * Renderer error code. + */ static int Render_Single_Pass( RAS_ARGS Bool flipped ) { @@ -2963,17 +3076,17 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Render_Glyph */ - /* */ - /* <Description> */ - /* Render a glyph in a bitmap. Sub-banding if needed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * Render_Glyph + * + * @Description: + * Render a glyph in a bitmap. Sub-banding if needed. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error Render_Glyph( RAS_ARG ) { @@ -2982,7 +3095,6 @@ Set_High_Precision( RAS_VARS ras.outline.flags & FT_OUTLINE_HIGH_PRECISION ); - ras.scale_shift = ras.precision_shift; if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS ) ras.dropOutControl = 2; @@ -3013,7 +3125,10 @@ ras.band_stack[0].y_max = (Short)( ras.target.rows - 1 ); ras.bWidth = (UShort)ras.target.width; - ras.bTarget = (Byte*)ras.target.buffer; + ras.bOrigin = (Byte*)ras.target.buffer; + + if ( ras.target.pitch > 0 ) + ras.bOrigin += (Long)( ras.target.rows - 1 ) * ras.target.pitch; if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 ) return error; @@ -3146,7 +3261,9 @@ const FT_Outline* outline = (const FT_Outline*)params->source; const FT_Bitmap* target_map = params->target; +#ifndef FT_STATIC_RASTER black_TWorker worker[1]; +#endif Long buffer[FT_MAX_BLACK_POOL]; @@ -3185,25 +3302,11 @@ if ( !target_map->buffer ) return FT_THROW( Invalid ); - /* reject too large outline coordinates */ - { - FT_Vector* vec = outline->points; - FT_Vector* limit = vec + outline->n_points; - - - for ( ; vec < limit; vec++ ) - { - if ( vec->x < -0x1000000L || vec->x > 0x1000000L || - vec->y < -0x1000000L || vec->y > 0x1000000L ) - return FT_THROW( Invalid ); - } - } - ras.outline = *outline; ras.target = *target_map; - worker->buff = buffer; - worker->sizeBuff = (&buffer)[1]; /* Points to right after buffer. */ + ras.buff = buffer; + ras.sizeBuff = (&buffer)[1]; /* Points to right after buffer. */ return Render_Glyph( RAS_VAR ); } diff --git a/src/3rdparty/freetype/src/raster/ftraster.h b/src/3rdparty/freetype/src/raster/ftraster.h index 40b5d6d321..50d34201a1 100644 --- a/src/3rdparty/freetype/src/raster/ftraster.h +++ b/src/3rdparty/freetype/src/raster/ftraster.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftraster.h */ -/* */ -/* The FreeType glyph rasterizer (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftraster.h + * + * The FreeType glyph rasterizer (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTRASTER_H_ @@ -28,11 +28,11 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* Uncomment the following line if you are using ftraster.c as a */ - /* standalone module, fully independent of FreeType. */ - /* */ + /************************************************************************** + * + * Uncomment the following line if you are using ftraster.c as a + * standalone module, fully independent of FreeType. + */ /* #define STANDALONE_ */ FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_standard_raster; diff --git a/src/3rdparty/freetype/src/raster/ftrend1.c b/src/3rdparty/freetype/src/raster/ftrend1.c index a7ce9731d7..62c727182a 100644 --- a/src/3rdparty/freetype/src/raster/ftrend1.c +++ b/src/3rdparty/freetype/src/raster/ftrend1.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftrend1.c */ -/* */ -/* The FreeType glyph rasterizer interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrend1.c + * + * The FreeType glyph rasterizer interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -22,7 +22,6 @@ #include FT_OUTLINE_H #include "ftrend1.h" #include "ftraster.h" -#include "rastpic.h" #include "rasterrs.h" @@ -128,7 +127,11 @@ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } - ft_glyphslot_preset_bitmap( slot, mode, origin ); + if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) ) + { + error = FT_THROW( Raster_Overflow ); + goto Exit; + } /* allocate new one */ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) @@ -197,7 +200,7 @@ (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_raster1_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_STANDARD_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_standard_raster /* raster_class */ ) diff --git a/src/3rdparty/freetype/src/raster/ftrend1.h b/src/3rdparty/freetype/src/raster/ftrend1.h index 2abdf2d703..82ecac686c 100644 --- a/src/3rdparty/freetype/src/raster/ftrend1.h +++ b/src/3rdparty/freetype/src/raster/ftrend1.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftrend1.h */ -/* */ -/* The FreeType glyph rasterizer interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftrend1.h + * + * The FreeType glyph rasterizer interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTREND1_H_ diff --git a/src/3rdparty/freetype/src/raster/module.mk b/src/3rdparty/freetype/src/raster/module.mk index b115f416b2..0a6d4b09d9 100644 --- a/src/3rdparty/freetype/src/raster/module.mk +++ b/src/3rdparty/freetype/src/raster/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/raster/raster.c b/src/3rdparty/freetype/src/raster/raster.c index 76edd21e1e..e3ac9e566a 100644 --- a/src/3rdparty/freetype/src/raster/raster.c +++ b/src/3rdparty/freetype/src/raster/raster.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* raster.c */ -/* */ -/* FreeType monochrome rasterer module component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * raster.c + * + * FreeType monochrome rasterer module component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -21,7 +21,6 @@ #include "ftraster.c" #include "ftrend1.c" -#include "rastpic.c" /* END */ diff --git a/src/3rdparty/freetype/src/raster/rasterrs.h b/src/3rdparty/freetype/src/raster/rasterrs.h index 22a3e15340..7266407365 100644 --- a/src/3rdparty/freetype/src/raster/rasterrs.h +++ b/src/3rdparty/freetype/src/raster/rasterrs.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* rasterrs.h */ -/* */ -/* monochrome renderer error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the monochrome renderer error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * rasterrs.h + * + * monochrome renderer error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the monochrome renderer error enumeration + * constants. + * + */ #ifndef RASTERRS_H_ #define RASTERRS_H_ diff --git a/src/3rdparty/freetype/src/raster/rules.mk b/src/3rdparty/freetype/src/raster/rules.mk index 9aef1f0bab..7664671e80 100644 --- a/src/3rdparty/freetype/src/raster/rules.mk +++ b/src/3rdparty/freetype/src/raster/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -28,8 +28,7 @@ RASTER_COMPILE := $(CC) $(ANSIFLAGS) \ # raster driver sources (i.e., C files) # RASTER_DRV_SRC := $(RASTER_DIR)/ftraster.c \ - $(RASTER_DIR)/ftrend1.c \ - $(RASTER_DIR)/rastpic.c + $(RASTER_DIR)/ftrend1.c # raster driver headers diff --git a/src/3rdparty/freetype/src/sfnt/Jamfile b/src/3rdparty/freetype/src/sfnt/Jamfile index 57977fc966..f646b3526e 100644 --- a/src/3rdparty/freetype/src/sfnt/Jamfile +++ b/src/3rdparty/freetype/src/sfnt/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/sfnt Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -22,6 +22,8 @@ SubDir FT2_TOP $(FT2_SRC_DIR) sfnt ; sfobjs ttbdf ttcmap + ttcolr + ttcpal ttkern ttload ttmtx diff --git a/src/3rdparty/freetype/src/sfnt/module.mk b/src/3rdparty/freetype/src/sfnt/module.mk index 51ca67e784..8c3b44fec7 100644 --- a/src/3rdparty/freetype/src/sfnt/module.mk +++ b/src/3rdparty/freetype/src/sfnt/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/sfnt/pngshim.c b/src/3rdparty/freetype/src/sfnt/pngshim.c index cd110776c8..ca85d9751f 100644 --- a/src/3rdparty/freetype/src/sfnt/pngshim.c +++ b/src/3rdparty/freetype/src/sfnt/pngshim.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* pngshim.c */ -/* */ -/* PNG Bitmap glyph support. */ -/* */ -/* Copyright 2013-2018 by */ -/* Google, Inc. */ -/* Written by Stuart Gill and Behdad Esfahbod. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pngshim.c + * + * PNG Bitmap glyph support. + * + * Copyright (C) 2013-2019 by + * Google, Inc. + * Written by Stuart Gill and Behdad Esfahbod. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -68,7 +68,6 @@ ( ( __clang_major__ >= 4 ) || \ ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \ defined( __OPTIMIZE__ ) && \ - !defined( __EMSCRIPTEN__ ) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __clang__ diff --git a/src/3rdparty/freetype/src/sfnt/pngshim.h b/src/3rdparty/freetype/src/sfnt/pngshim.h index 194238c3a2..06c6f6b20e 100644 --- a/src/3rdparty/freetype/src/sfnt/pngshim.h +++ b/src/3rdparty/freetype/src/sfnt/pngshim.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* pngshim.h */ -/* */ -/* PNG Bitmap glyph support. */ -/* */ -/* Copyright 2013-2018 by */ -/* Google, Inc. */ -/* Written by Stuart Gill and Behdad Esfahbod. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * pngshim.h + * + * PNG Bitmap glyph support. + * + * Copyright (C) 2013-2019 by + * Google, Inc. + * Written by Stuart Gill and Behdad Esfahbod. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef PNGSHIM_H_ diff --git a/src/3rdparty/freetype/src/sfnt/rules.mk b/src/3rdparty/freetype/src/sfnt/rules.mk index 83acc66a8f..ee3314eac3 100644 --- a/src/3rdparty/freetype/src/sfnt/rules.mk +++ b/src/3rdparty/freetype/src/sfnt/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -28,17 +28,19 @@ SFNT_COMPILE := $(CC) $(ANSIFLAGS) \ # SFNT driver sources (i.e., C files) # -SFNT_DRV_SRC := $(SFNT_DIR)/ttload.c \ - $(SFNT_DIR)/ttmtx.c \ +SFNT_DRV_SRC := $(SFNT_DIR)/pngshim.c \ + $(SFNT_DIR)/sfdriver.c \ + $(SFNT_DIR)/sfobjs.c \ + $(SFNT_DIR)/sfwoff.c \ + $(SFNT_DIR)/ttbdf.c \ $(SFNT_DIR)/ttcmap.c \ - $(SFNT_DIR)/ttsbit.c \ - $(SFNT_DIR)/ttpost.c \ + $(SFNT_DIR)/ttcolr.c \ + $(SFNT_DIR)/ttcpal.c \ $(SFNT_DIR)/ttkern.c \ - $(SFNT_DIR)/ttbdf.c \ - $(SFNT_DIR)/sfobjs.c \ - $(SFNT_DIR)/sfdriver.c \ - $(SFNT_DIR)/sfntpic.c \ - $(SFNT_DIR)/pngshim.c + $(SFNT_DIR)/ttload.c \ + $(SFNT_DIR)/ttmtx.c \ + $(SFNT_DIR)/ttpost.c \ + $(SFNT_DIR)/ttsbit.c # SFNT driver headers # diff --git a/src/3rdparty/freetype/src/sfnt/sfdriver.c b/src/3rdparty/freetype/src/sfnt/sfdriver.c index 303e1ca9f1..2611685284 100644 --- a/src/3rdparty/freetype/src/sfnt/sfdriver.c +++ b/src/3rdparty/freetype/src/sfnt/sfdriver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfdriver.c */ -/* */ -/* High-level SFNT driver interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfdriver.c + * + * High-level SFNT driver interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -25,7 +25,6 @@ #include "sfdriver.h" #include "ttload.h" #include "sfobjs.h" -#include "sfntpic.h" #include "sferrors.h" @@ -33,6 +32,11 @@ #include "ttsbit.h" #endif +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS +#include "ttcolr.h" +#include "ttcpal.h" +#endif + #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES #include "ttpost.h" #endif @@ -57,18 +61,18 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_sfdriver +#define FT_COMPONENT sfdriver /* - * SFNT TABLE SERVICE + * SFNT TABLE SERVICE * */ @@ -155,7 +159,7 @@ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES /* - * GLYPH DICT SERVICE + * GLYPH DICT SERVICE * */ @@ -178,8 +182,8 @@ static FT_UInt - sfnt_get_name_index( FT_Face face, - FT_String* glyph_name ) + sfnt_get_name_index( FT_Face face, + const FT_String* glyph_name ) { TT_Face ttface = (TT_Face)face; @@ -222,7 +226,7 @@ /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -371,47 +375,61 @@ { case 15: k4 ^= (FT_UInt32)tail[14] << 16; + /* fall through */ case 14: k4 ^= (FT_UInt32)tail[13] << 8; + /* fall through */ case 13: k4 ^= (FT_UInt32)tail[12]; k4 *= c4; k4 = ROTL32( k4, 18 ); k4 *= c1; h4 ^= k4; + /* fall through */ case 12: k3 ^= (FT_UInt32)tail[11] << 24; + /* fall through */ case 11: k3 ^= (FT_UInt32)tail[10] << 16; + /* fall through */ case 10: k3 ^= (FT_UInt32)tail[9] << 8; + /* fall through */ case 9: k3 ^= (FT_UInt32)tail[8]; k3 *= c3; k3 = ROTL32( k3, 17 ); k3 *= c4; h3 ^= k3; + /* fall through */ case 8: k2 ^= (FT_UInt32)tail[7] << 24; + /* fall through */ case 7: k2 ^= (FT_UInt32)tail[6] << 16; + /* fall through */ case 6: k2 ^= (FT_UInt32)tail[5] << 8; + /* fall through */ case 5: k2 ^= (FT_UInt32)tail[4]; k2 *= c2; k2 = ROTL32( k2, 16 ); k2 *= c3; h2 ^= k2; + /* fall through */ case 4: k1 ^= (FT_UInt32)tail[3] << 24; + /* fall through */ case 3: k1 ^= (FT_UInt32)tail[2] << 16; + /* fall through */ case 2: k1 ^= (FT_UInt32)tail[1] << 8; + /* fall through */ case 1: k1 ^= (FT_UInt32)tail[0]; k1 *= c1; @@ -460,14 +478,12 @@ typedef int (*char_type_func)( int c ); - /* handling of PID/EID 3/0 and 3/1 is the same */ + /* Handling of PID/EID 3/0 and 3/1 is the same. */ #define IS_WIN( n ) ( (n)->platformID == 3 && \ - ( (n)->encodingID == 1 || (n)->encodingID == 0 ) && \ - (n)->languageID == 0x409 ) + ( (n)->encodingID == 1 || (n)->encodingID == 0 ) ) #define IS_APPLE( n ) ( (n)->platformID == 1 && \ - (n)->encodingID == 0 && \ - (n)->languageID == 0 ) + (n)->encodingID == 0 ) static char* get_win_string( FT_Memory memory, @@ -491,42 +507,40 @@ if ( FT_STREAM_SEEK( entry->stringOffset ) || FT_FRAME_ENTER( entry->stringLength ) ) - { - FT_FREE( result ); - entry->stringLength = 0; - entry->stringOffset = 0; - FT_FREE( entry->string ); - - return NULL; - } + goto get_win_string_error; r = (FT_String*)result; p = (FT_Char*)stream->cursor; for ( len = entry->stringLength / 2; len > 0; len--, p += 2 ) { - if ( p[0] == 0 ) + if ( p[0] == 0 && char_type( p[1] ) ) + *r++ = p[1]; + else { - if ( char_type( p[1] ) ) - *r++ = p[1]; - else - { - if ( report_invalid_characters ) - { - FT_TRACE0(( "get_win_string:" - " Character `%c' (0x%X) invalid in PS name string\n", - p[1], p[1] )); - /* it's not the job of FreeType to correct PS names... */ - *r++ = p[1]; - } - } + if ( report_invalid_characters ) + FT_TRACE0(( "get_win_string:" + " Character 0x%X invalid in PS name string\n", + ((unsigned)p[0])*256 + (unsigned)p[1] )); + break; } } - *r = '\0'; + if ( !len ) + *r = '\0'; FT_FRAME_EXIT(); - return result; + if ( !len ) + return result; + + get_win_string_error: + FT_FREE( result ); + + entry->stringLength = 0; + entry->stringOffset = 0; + FT_FREE( entry->string ); + + return NULL; } @@ -552,14 +566,7 @@ if ( FT_STREAM_SEEK( entry->stringOffset ) || FT_FRAME_ENTER( entry->stringLength ) ) - { - FT_FREE( result ); - entry->stringOffset = 0; - entry->stringLength = 0; - FT_FREE( entry->string ); - - return NULL; - } + goto get_apple_string_error; r = (FT_String*)result; p = (FT_Char*)stream->cursor; @@ -571,20 +578,28 @@ else { if ( report_invalid_characters ) - { FT_TRACE0(( "get_apple_string:" " Character `%c' (0x%X) invalid in PS name string\n", *p, *p )); - /* it's not the job of FreeType to correct PS names... */ - *r++ = *p; - } + break; } } - *r = '\0'; + if ( !len ) + *r = '\0'; FT_FRAME_EXIT(); - return result; + if ( !len ) + return result; + + get_apple_string_error: + FT_FREE( result ); + + entry->stringOffset = 0; + entry->stringLength = 0; + FT_FREE( entry->string ); + + return NULL; } @@ -607,10 +622,10 @@ if ( name->nameID == id && name->stringLength > 0 ) { - if ( IS_WIN( name ) ) + if ( IS_WIN( name ) && ( name->languageID == 0x409 || *win == -1 ) ) *win = n; - if ( IS_APPLE( name ) ) + if ( IS_APPLE( name ) && ( name->languageID == 0 || *apple == -1 ) ) *apple = n; } } @@ -643,9 +658,9 @@ /* - * Find the shortest decimal representation of a 16.16 fixed point - * number. The function fills `buf' with the result, returning a pointer - * to the position after the representation's last byte. + * Find the shortest decimal representation of a 16.16 fixed point + * number. The function fills `buf' with the result, returning a pointer + * to the position after the representation's last byte. */ static char* @@ -673,7 +688,7 @@ if ( fixed < 0 ) { *p++ = '-'; - fixed = -fixed; + fixed = NEG_INT( fixed ); } int_part = ( fixed >> 16 ) & 0xFFFF; @@ -828,13 +843,20 @@ face->name_table.names + win, sfnt_is_alphanumeric, 0 ); - else + if ( !result && apple != -1 ) result = get_apple_string( face->root.memory, face->name_table.stream, face->name_table.names + apple, sfnt_is_alphanumeric, 0 ); + if ( !result ) + { + FT_TRACE0(( "sfnt_get_var_ps_name:" + " No valid PS name prefix for font instances found\n" )); + return NULL; + } + len = ft_strlen( result ); /* sanitize if necessary; we reserve space for 36 bytes (a 128bit */ @@ -1052,7 +1074,7 @@ face->name_table.names + win, sfnt_is_postscript, 1 ); - else + if ( !result && apple != -1 ) result = get_apple_string( face->root.memory, face->name_table.stream, face->name_table.names + apple, @@ -1073,7 +1095,7 @@ /* - * TT CMAP INFO + * TT CMAP INFO */ FT_DEFINE_SERVICE_TTCMAPSREC( tt_service_get_cmap_info, @@ -1132,41 +1154,41 @@ /* - * SERVICE LIST + * SERVICE LIST */ #if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF FT_DEFINE_SERVICEDESCREC5( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict, + FT_SERVICE_ID_BDF, &sfnt_service_bdf, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_DEFINE_SERVICEDESCREC4( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #elif defined TT_CONFIG_OPTION_BDF FT_DEFINE_SERVICEDESCREC4( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_BDF, &sfnt_service_bdf, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #else FT_DEFINE_SERVICEDESCREC3( sfnt_services, - FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET, - FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, - FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET ) + FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, + FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, + FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info ) #endif @@ -1174,21 +1196,9 @@ sfnt_get_interface( FT_Module module, const char* module_interface ) { - /* SFNT_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - FT_Library library; - - - if ( !module ) - return NULL; - library = module->library; - if ( !library ) - return NULL; -#else FT_UNUSED( module ); -#endif - return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface ); + return ft_service_list_lookup( sfnt_services, module_interface ); } @@ -1198,6 +1208,12 @@ #define PUT_EMBEDDED_BITMAPS( a ) NULL #endif +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS +#define PUT_COLOR_LAYERS( a ) a +#else +#define PUT_COLOR_LAYERS( a ) NULL +#endif + #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES #define PUT_PS_NAMES( a ) a #else @@ -1256,9 +1272,24 @@ /* TT_Free_Table_Func free_eblc */ PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ), - /* TT_Set_SBit_Strike_Func set_sbit_strike */ + /* TT_Set_SBit_Strike_Func set_sbit_strike */ PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ), - /* TT_Load_Strike_Metrics_Func load_strike_metrics */ + /* TT_Load_Strike_Metrics_Func load_strike_metrics */ + + PUT_COLOR_LAYERS( tt_face_load_cpal ), + /* TT_Load_Table_Func load_cpal */ + PUT_COLOR_LAYERS( tt_face_load_colr ), + /* TT_Load_Table_Func load_colr */ + PUT_COLOR_LAYERS( tt_face_free_cpal ), + /* TT_Free_Table_Func free_cpal */ + PUT_COLOR_LAYERS( tt_face_free_colr ), + /* TT_Free_Table_Func free_colr */ + PUT_COLOR_LAYERS( tt_face_palette_set ), + /* TT_Set_Palette_Func set_palette */ + PUT_COLOR_LAYERS( tt_face_get_colr_layer ), + /* TT_Get_Colr_Layer_Func get_colr_layer */ + PUT_COLOR_LAYERS( tt_face_colr_blend_layer ), + /* TT_Blend_Colr_Func colr_blend */ tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */ @@ -1277,7 +1308,7 @@ 0x10000L, /* driver version 1.0 */ 0x20000L, /* driver requires FreeType 2.0 or higher */ - (const void*)&SFNT_INTERFACE_GET, /* module specific interface */ + (const void*)&sfnt_interface, /* module specific interface */ (FT_Module_Constructor)NULL, /* module_init */ (FT_Module_Destructor) NULL, /* module_done */ diff --git a/src/3rdparty/freetype/src/sfnt/sfdriver.h b/src/3rdparty/freetype/src/sfnt/sfdriver.h index 81c22d2887..8c174634b3 100644 --- a/src/3rdparty/freetype/src/sfnt/sfdriver.h +++ b/src/3rdparty/freetype/src/sfnt/sfdriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfdriver.h */ -/* */ -/* High-level SFNT driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfdriver.h + * + * High-level SFNT driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SFDRIVER_H_ @@ -26,10 +26,8 @@ FT_BEGIN_HEADER - FT_DECLARE_MODULE( sfnt_module_class ) - FT_END_HEADER #endif /* SFDRIVER_H_ */ diff --git a/src/3rdparty/freetype/src/sfnt/sferrors.h b/src/3rdparty/freetype/src/sfnt/sferrors.h index 74003d4b38..43e148d295 100644 --- a/src/3rdparty/freetype/src/sfnt/sferrors.h +++ b/src/3rdparty/freetype/src/sfnt/sferrors.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* sferrors.h */ -/* */ -/* SFNT error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the SFNT error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * sferrors.h + * + * SFNT error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the SFNT error enumeration constants. + * + */ #ifndef SFERRORS_H_ #define SFERRORS_H_ diff --git a/src/3rdparty/freetype/src/sfnt/sfnt.c b/src/3rdparty/freetype/src/sfnt/sfnt.c index 8b9a6b345d..b4faf34a3a 100644 --- a/src/3rdparty/freetype/src/sfnt/sfnt.c +++ b/src/3rdparty/freetype/src/sfnt/sfnt.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfnt.c */ -/* */ -/* Single object library component. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfnt.c + * + * Single object library component. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -21,10 +21,13 @@ #include "pngshim.c" #include "sfdriver.c" -#include "sfntpic.c" #include "sfobjs.c" +#include "sfwoff.c" #include "ttbdf.c" #include "ttcmap.c" +#include "ttcolr.c" +#include "ttcpal.c" + #include "ttkern.c" #include "ttload.c" #include "ttmtx.c" diff --git a/src/3rdparty/freetype/src/sfnt/sfobjs.c b/src/3rdparty/freetype/src/sfnt/sfobjs.c index 6ba8509f56..6edf3ae1de 100644 --- a/src/3rdparty/freetype/src/sfnt/sfobjs.c +++ b/src/3rdparty/freetype/src/sfnt/sfobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfobjs.c */ -/* */ -/* SFNT object management (base). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfobjs.c + * + * SFNT object management (base). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -21,13 +21,13 @@ #include "ttload.h" #include "ttcmap.h" #include "ttkern.h" +#include "sfwoff.h" #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_DEBUG_H #include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SFNT_NAMES_H -#include FT_GZIP_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_SERVICE_MULTIPLE_MASTERS_H @@ -41,14 +41,14 @@ #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_sfobjs +#define FT_COMPONENT sfobjs @@ -337,403 +337,6 @@ } -#define WRITE_USHORT( p, v ) \ - do \ - { \ - *(p)++ = (FT_Byte)( (v) >> 8 ); \ - *(p)++ = (FT_Byte)( (v) >> 0 ); \ - \ - } while ( 0 ) - -#define WRITE_ULONG( p, v ) \ - do \ - { \ - *(p)++ = (FT_Byte)( (v) >> 24 ); \ - *(p)++ = (FT_Byte)( (v) >> 16 ); \ - *(p)++ = (FT_Byte)( (v) >> 8 ); \ - *(p)++ = (FT_Byte)( (v) >> 0 ); \ - \ - } while ( 0 ) - - - static void - sfnt_stream_close( FT_Stream stream ) - { - FT_Memory memory = stream->memory; - - - FT_FREE( stream->base ); - - stream->size = 0; - stream->base = NULL; - stream->close = NULL; - } - - - FT_CALLBACK_DEF( int ) - compare_offsets( const void* a, - const void* b ) - { - WOFF_Table table1 = *(WOFF_Table*)a; - WOFF_Table table2 = *(WOFF_Table*)b; - - FT_ULong offset1 = table1->Offset; - FT_ULong offset2 = table2->Offset; - - - if ( offset1 > offset2 ) - return 1; - else if ( offset1 < offset2 ) - return -1; - else - return 0; - } - - - /* Replace `face->root.stream' with a stream containing the extracted */ - /* SFNT of a WOFF font. */ - - static FT_Error - woff_open_font( FT_Stream stream, - TT_Face face ) - { - FT_Memory memory = stream->memory; - FT_Error error = FT_Err_Ok; - - WOFF_HeaderRec woff; - WOFF_Table tables = NULL; - WOFF_Table* indices = NULL; - - FT_ULong woff_offset; - - FT_Byte* sfnt = NULL; - FT_Stream sfnt_stream = NULL; - - FT_Byte* sfnt_header; - FT_ULong sfnt_offset; - - FT_Int nn; - FT_ULong old_tag = 0; - - static const FT_Frame_Field woff_header_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE WOFF_HeaderRec - - FT_FRAME_START( 44 ), - FT_FRAME_ULONG ( signature ), - FT_FRAME_ULONG ( flavor ), - FT_FRAME_ULONG ( length ), - FT_FRAME_USHORT( num_tables ), - FT_FRAME_USHORT( reserved ), - FT_FRAME_ULONG ( totalSfntSize ), - FT_FRAME_USHORT( majorVersion ), - FT_FRAME_USHORT( minorVersion ), - FT_FRAME_ULONG ( metaOffset ), - FT_FRAME_ULONG ( metaLength ), - FT_FRAME_ULONG ( metaOrigLength ), - FT_FRAME_ULONG ( privOffset ), - FT_FRAME_ULONG ( privLength ), - FT_FRAME_END - }; - - - FT_ASSERT( stream == face->root.stream ); - FT_ASSERT( FT_STREAM_POS() == 0 ); - - if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) ) - return error; - - /* Make sure we don't recurse back here or hit TTC code. */ - if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf ) - return FT_THROW( Invalid_Table ); - - /* Miscellaneous checks. */ - if ( woff.length != stream->size || - woff.num_tables == 0 || - 44 + woff.num_tables * 20UL >= woff.length || - 12 + woff.num_tables * 16UL >= woff.totalSfntSize || - ( woff.totalSfntSize & 3 ) != 0 || - ( woff.metaOffset == 0 && ( woff.metaLength != 0 || - woff.metaOrigLength != 0 ) ) || - ( woff.metaLength != 0 && woff.metaOrigLength == 0 ) || - ( woff.privOffset == 0 && woff.privLength != 0 ) ) - { - FT_ERROR(( "woff_font_open: invalid WOFF header\n" )); - return FT_THROW( Invalid_Table ); - } - - /* Don't trust `totalSfntSize' before thorough checks. */ - if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) || - FT_NEW( sfnt_stream ) ) - goto Exit; - - sfnt_header = sfnt; - - /* Write sfnt header. */ - { - FT_UInt searchRange, entrySelector, rangeShift, x; - - - x = woff.num_tables; - entrySelector = 0; - while ( x ) - { - x >>= 1; - entrySelector += 1; - } - entrySelector--; - - searchRange = ( 1 << entrySelector ) * 16; - rangeShift = woff.num_tables * 16 - searchRange; - - WRITE_ULONG ( sfnt_header, woff.flavor ); - WRITE_USHORT( sfnt_header, woff.num_tables ); - WRITE_USHORT( sfnt_header, searchRange ); - WRITE_USHORT( sfnt_header, entrySelector ); - WRITE_USHORT( sfnt_header, rangeShift ); - } - - /* While the entries in the sfnt header must be sorted by the */ - /* tag value, the tables themselves are not. We thus have to */ - /* sort them by offset and check that they don't overlap. */ - - if ( FT_NEW_ARRAY( tables, woff.num_tables ) || - FT_NEW_ARRAY( indices, woff.num_tables ) ) - goto Exit; - - FT_TRACE2(( "\n" - " tag offset compLen origLen checksum\n" - " -------------------------------------------\n" )); - - if ( FT_FRAME_ENTER( 20L * woff.num_tables ) ) - goto Exit; - - for ( nn = 0; nn < woff.num_tables; nn++ ) - { - WOFF_Table table = tables + nn; - - table->Tag = FT_GET_TAG4(); - table->Offset = FT_GET_ULONG(); - table->CompLength = FT_GET_ULONG(); - table->OrigLength = FT_GET_ULONG(); - table->CheckSum = FT_GET_ULONG(); - - FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n", - (FT_Char)( table->Tag >> 24 ), - (FT_Char)( table->Tag >> 16 ), - (FT_Char)( table->Tag >> 8 ), - (FT_Char)( table->Tag ), - table->Offset, - table->CompLength, - table->OrigLength, - table->CheckSum )); - - if ( table->Tag <= old_tag ) - { - FT_FRAME_EXIT(); - - FT_ERROR(( "woff_font_open: table tags are not sorted\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } - - old_tag = table->Tag; - indices[nn] = table; - } - - FT_FRAME_EXIT(); - - /* Sort by offset. */ - - ft_qsort( indices, - woff.num_tables, - sizeof ( WOFF_Table ), - compare_offsets ); - - /* Check offsets and lengths. */ - - woff_offset = 44 + woff.num_tables * 20L; - sfnt_offset = 12 + woff.num_tables * 16L; - - for ( nn = 0; nn < woff.num_tables; nn++ ) - { - WOFF_Table table = indices[nn]; - - - if ( table->Offset != woff_offset || - table->CompLength > woff.length || - table->Offset > woff.length - table->CompLength || - table->OrigLength > woff.totalSfntSize || - sfnt_offset > woff.totalSfntSize - table->OrigLength || - table->CompLength > table->OrigLength ) - { - FT_ERROR(( "woff_font_open: invalid table offsets\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } - - table->OrigOffset = sfnt_offset; - - /* The offsets must be multiples of 4. */ - woff_offset += ( table->CompLength + 3 ) & ~3U; - sfnt_offset += ( table->OrigLength + 3 ) & ~3U; - } - - /* - * Final checks! - * - * We don't decode and check the metadata block. - * We don't check table checksums either. - * But other than those, I think we implement all - * `MUST' checks from the spec. - */ - - if ( woff.metaOffset ) - { - if ( woff.metaOffset != woff_offset || - woff.metaOffset + woff.metaLength > woff.length ) - { - FT_ERROR(( "woff_font_open:" - " invalid `metadata' offset or length\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } - - /* We have padding only ... */ - woff_offset += woff.metaLength; - } - - if ( woff.privOffset ) - { - /* ... if it isn't the last block. */ - woff_offset = ( woff_offset + 3 ) & ~3U; - - if ( woff.privOffset != woff_offset || - woff.privOffset + woff.privLength > woff.length ) - { - FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } - - /* No padding for the last block. */ - woff_offset += woff.privLength; - } - - if ( sfnt_offset != woff.totalSfntSize || - woff_offset != woff.length ) - { - FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } - - /* Now use `totalSfntSize'. */ - if ( FT_REALLOC( sfnt, - 12 + woff.num_tables * 16UL, - woff.totalSfntSize ) ) - goto Exit; - - sfnt_header = sfnt + 12; - - /* Write the tables. */ - - for ( nn = 0; nn < woff.num_tables; nn++ ) - { - WOFF_Table table = tables + nn; - - - /* Write SFNT table entry. */ - WRITE_ULONG( sfnt_header, table->Tag ); - WRITE_ULONG( sfnt_header, table->CheckSum ); - WRITE_ULONG( sfnt_header, table->OrigOffset ); - WRITE_ULONG( sfnt_header, table->OrigLength ); - - /* Write table data. */ - if ( FT_STREAM_SEEK( table->Offset ) || - FT_FRAME_ENTER( table->CompLength ) ) - goto Exit; - - if ( table->CompLength == table->OrigLength ) - { - /* Uncompressed data; just copy. */ - ft_memcpy( sfnt + table->OrigOffset, - stream->cursor, - table->OrigLength ); - } - else - { -#ifdef FT_CONFIG_OPTION_USE_ZLIB - - /* Uncompress with zlib. */ - FT_ULong output_len = table->OrigLength; - - - error = FT_Gzip_Uncompress( memory, - sfnt + table->OrigOffset, &output_len, - stream->cursor, table->CompLength ); - if ( error ) - goto Exit; - if ( output_len != table->OrigLength ) - { - FT_ERROR(( "woff_font_open: compressed table length mismatch\n" )); - error = FT_THROW( Invalid_Table ); - goto Exit; - } - -#else /* !FT_CONFIG_OPTION_USE_ZLIB */ - - error = FT_THROW( Unimplemented_Feature ); - goto Exit; - -#endif /* !FT_CONFIG_OPTION_USE_ZLIB */ - } - - FT_FRAME_EXIT(); - - /* We don't check whether the padding bytes in the WOFF file are */ - /* actually '\0'. For the output, however, we do set them properly. */ - sfnt_offset = table->OrigOffset + table->OrigLength; - while ( sfnt_offset & 3 ) - { - sfnt[sfnt_offset] = '\0'; - sfnt_offset++; - } - } - - /* Ok! Finally ready. Swap out stream and return. */ - FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize ); - sfnt_stream->memory = stream->memory; - sfnt_stream->close = sfnt_stream_close; - - FT_Stream_Free( - face->root.stream, - ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); - - face->root.stream = sfnt_stream; - - face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; - - Exit: - FT_FREE( tables ); - FT_FREE( indices ); - - if ( error ) - { - FT_FREE( sfnt ); - FT_Stream_Close( sfnt_stream ); - FT_FREE( sfnt_stream ); - } - - return error; - } - - -#undef WRITE_USHORT -#undef WRITE_ULONG - - /* Fill in face->ttc_header. If the font is not a TTC, it is */ /* synthesized into a TTC with one offset table. */ static FT_Error @@ -918,7 +521,9 @@ /* Stream may have changed in sfnt_open_font. */ stream = face->root.stream; - FT_TRACE2(( "sfnt_init_face: %08p, %d\n", face, face_instance_index )); + FT_TRACE2(( "sfnt_init_face: %08p (index %d)\n", + face, + face_instance_index )); face_index = FT_ABS( face_instance_index ) & 0xFFFF; @@ -1001,15 +606,15 @@ face->variation_support |= TT_FACE_FLAG_VAR_FVAR; /* - * As documented in the OpenType specification, an entry for the - * default instance may be omitted in the named instance table. In - * particular this means that even if there is no named instance - * table in the font we actually do have a named instance, namely the - * default instance. + * As documented in the OpenType specification, an entry for the + * default instance may be omitted in the named instance table. In + * particular this means that even if there is no named instance + * table in the font we actually do have a named instance, namely the + * default instance. * - * For consistency, we always want the default instance in our list - * of named instances. If it is missing, we try to synthesize it - * later on. Here, we have to adjust `num_instances' accordingly. + * For consistency, we always want the default instance in our list + * of named instances. If it is missing, we try to synthesize it + * later on. Here, we have to adjust `num_instances' accordingly. */ if ( ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) && @@ -1341,6 +946,13 @@ if ( sfnt->load_eblc ) LOAD_( eblc ); + /* colored glyph support */ + if ( sfnt->load_cpal ) + { + LOAD_( cpal ); + LOAD_( colr ); + } + /* consider the pclt, kerning, and gasp tables as optional */ LOAD_( pclt ); LOAD_( gasp ); @@ -1389,12 +1001,13 @@ FT_Long flags = root->face_flags; - /*********************************************************************/ - /* */ - /* Compute face flags. */ - /* */ + /********************************************************************** + * + * Compute face flags. + */ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC || - face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ) + face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX || + face->colr ) flags |= FT_FACE_FLAG_COLOR; /* color glyphs */ if ( has_outline == TRUE ) @@ -1438,10 +1051,10 @@ root->face_flags = flags; - /*********************************************************************/ - /* */ - /* Compute style flags. */ - /* */ + /********************************************************************** + * + * Compute style flags. + */ flags = 0; if ( has_outline == TRUE && face->os2.version != 0xFFFFU ) @@ -1471,14 +1084,14 @@ root->style_flags |= flags; - /*********************************************************************/ - /* */ - /* Polish the charmaps. */ - /* */ - /* Try to set the charmap encoding according to the platform & */ - /* encoding ID of each charmap. Emulate Unicode charmap if one */ - /* is missing. */ - /* */ + /********************************************************************** + * + * Polish the charmaps. + * + * Try to set the charmap encoding according to the platform & + * encoding ID of each charmap. Emulate Unicode charmap if one + * is missing. + */ tt_face_build_cmaps( face ); /* ignore errors */ @@ -1521,7 +1134,8 @@ error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec, NULL, &cmaprec, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -1533,9 +1147,9 @@ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* - * Now allocate the root array of FT_Bitmap_Size records and - * populate them. Unfortunately, it isn't possible to indicate bit - * depths in the FT_Bitmap_Size record. This is a design error. + * Now allocate the root array of FT_Bitmap_Size records and + * populate them. Unfortunately, it isn't possible to indicate bit + * depths in the FT_Bitmap_Size record. This is a design error. */ { FT_UInt count; @@ -1615,10 +1229,10 @@ root->face_flags |= FT_FACE_FLAG_SCALABLE; - /*********************************************************************/ - /* */ - /* Set up metrics. */ - /* */ + /********************************************************************** + * + * Set up metrics. + */ if ( FT_IS_SCALABLE( root ) ) { /* XXX What about if outline header is missing */ @@ -1630,59 +1244,73 @@ root->units_per_EM = face->header.Units_Per_EM; - /* XXX: Computing the ascender/descender/height is very different */ - /* from what the specification tells you. Apparently, we */ - /* must be careful because */ - /* */ - /* - not all fonts have an OS/2 table; in this case, we take */ - /* the values in the horizontal header. However, these */ - /* values very often are not reliable. */ - /* */ - /* - otherwise, the correct typographic values are in the */ - /* sTypoAscender, sTypoDescender & sTypoLineGap fields. */ - /* */ - /* However, certain fonts have these fields set to 0. */ - /* Rather, they have usWinAscent & usWinDescent correctly */ - /* set (but with different values). */ - /* */ - /* As an example, Arial Narrow is implemented through four */ - /* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */ - /* */ - /* Strangely, all fonts have the same values in their */ - /* sTypoXXX fields, except ARIALNB which sets them to 0. */ - /* */ - /* On the other hand, they all have different */ - /* usWinAscent/Descent values -- as a conclusion, the OS/2 */ - /* table cannot be used to compute the text height reliably! */ - /* */ - - /* The ascender and descender are taken from the `hhea' table. */ - /* If zero, they are taken from the `OS/2' table. */ - - root->ascender = face->horizontal.Ascender; - root->descender = face->horizontal.Descender; - - root->height = root->ascender - root->descender + - face->horizontal.Line_Gap; - - if ( !( root->ascender || root->descender ) ) + /* + * Computing the ascender/descender/height is tricky. + * + * The OpenType specification v1.8.3 says: + * + * [OS/2's] sTypoAscender, sTypoDescender and sTypoLineGap fields + * are intended to allow applications to lay out documents in a + * typographically-correct and portable fashion. + * + * This is somewhat at odds with the decades of backwards + * compatibility, operating systems and applications doing whatever + * they want, not to mention broken fonts. + * + * Not all fonts have an OS/2 table; in this case, we take the values + * in the horizontal header, although there is nothing stopping the + * values from being unreliable. Even with a OS/2 table, certain fonts + * set the sTypoAscender, sTypoDescender and sTypoLineGap fields to 0 + * and instead correctly set usWinAscent and usWinDescent. + * + * As an example, Arial Narrow is shipped as four files ARIALN.TTF, + * ARIALNI.TTF, ARIALNB.TTF and ARIALNBI.TTF. Strangely, all fonts have + * the same values in their sTypo* fields, except ARIALNB.ttf which + * sets them to 0. All of them have different usWinAscent/Descent + * values. The OS/2 table therefore cannot be trusted for computing the + * text height reliably. + * + * As a compromise, do the following: + * + * 1. If the OS/2 table exists and the fsSelection bit 7 is set + * (USE_TYPO_METRICS), trust the font and use the sTypo* metrics. + * 2. Otherwise, use the `hhea' table's metrics. + * 3. If they are zero and the OS/2 table exists, + * 1. use the OS/2 table's sTypo* metrics if they are non-zero. + * 2. Otherwise, use the OS/2 table's usWin* metrics. + */ + + if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 128 ) { - if ( face->os2.version != 0xFFFFU ) - { - if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) - { - root->ascender = face->os2.sTypoAscender; - root->descender = face->os2.sTypoDescender; + root->ascender = face->os2.sTypoAscender; + root->descender = face->os2.sTypoDescender; + root->height = root->ascender - root->descender + + face->os2.sTypoLineGap; + } + else + { + root->ascender = face->horizontal.Ascender; + root->descender = face->horizontal.Descender; + root->height = root->ascender - root->descender + + face->horizontal.Line_Gap; - root->height = root->ascender - root->descender + - face->os2.sTypoLineGap; - } - else + if ( !( root->ascender || root->descender ) ) + { + if ( face->os2.version != 0xFFFFU ) { - root->ascender = (FT_Short)face->os2.usWinAscent; - root->descender = -(FT_Short)face->os2.usWinDescent; - - root->height = root->ascender - root->descender; + if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) + { + root->ascender = face->os2.sTypoAscender; + root->descender = face->os2.sTypoDescender; + root->height = root->ascender - root->descender + + face->os2.sTypoLineGap; + } + else + { + root->ascender = (FT_Short)face->os2.usWinAscent; + root->descender = -(FT_Short)face->os2.usWinDescent; + root->height = root->ascender - root->descender; + } } } } @@ -1737,6 +1365,13 @@ /* destroy the embedded bitmaps table if it is loaded */ if ( sfnt->free_eblc ) sfnt->free_eblc( face ); + + /* destroy color table data if it is loaded */ + if ( sfnt->free_cpal ) + { + sfnt->free_cpal( face ); + sfnt->free_colr( face ); + } } #ifdef TT_CONFIG_OPTION_BDF @@ -1792,11 +1427,18 @@ FT_FREE( face->sbit_strike_map ); face->root.num_fixed_sizes = 0; -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_FREE( face->postscript_name ); + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT FT_FREE( face->var_postscript_prefix ); #endif + /* freeing glyph color palette data */ + FT_FREE( face->palette_data.palette_name_ids ); + FT_FREE( face->palette_data.palette_flags ); + FT_FREE( face->palette_data.palette_entry_name_ids ); + FT_FREE( face->palette ); + face->sfnt = NULL; } diff --git a/src/3rdparty/freetype/src/sfnt/sfobjs.h b/src/3rdparty/freetype/src/sfnt/sfobjs.h index 1b8d1be5b1..3fbf2dd6bd 100644 --- a/src/3rdparty/freetype/src/sfnt/sfobjs.h +++ b/src/3rdparty/freetype/src/sfnt/sfobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* sfobjs.h */ -/* */ -/* SFNT object management (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * sfobjs.h + * + * SFNT object management (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef SFOBJS_H_ @@ -53,7 +53,7 @@ FT_BEGIN_HEADER FT_END_HEADER -#endif /* SFDRIVER_H_ */ +#endif /* SFOBJS_H_ */ /* END */ diff --git a/src/3rdparty/freetype/src/sfnt/sfwoff.c b/src/3rdparty/freetype/src/sfnt/sfwoff.c new file mode 100644 index 0000000000..ca4821a20a --- /dev/null +++ b/src/3rdparty/freetype/src/sfnt/sfwoff.c @@ -0,0 +1,434 @@ +/**************************************************************************** + * + * sfwoff.c + * + * WOFF format management (base). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#include <ft2build.h> +#include "sfwoff.h" +#include FT_TRUETYPE_TAGS_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_GZIP_H + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT sfwoff + + +#define WRITE_USHORT( p, v ) \ + do \ + { \ + *(p)++ = (FT_Byte)( (v) >> 8 ); \ + *(p)++ = (FT_Byte)( (v) >> 0 ); \ + \ + } while ( 0 ) + +#define WRITE_ULONG( p, v ) \ + do \ + { \ + *(p)++ = (FT_Byte)( (v) >> 24 ); \ + *(p)++ = (FT_Byte)( (v) >> 16 ); \ + *(p)++ = (FT_Byte)( (v) >> 8 ); \ + *(p)++ = (FT_Byte)( (v) >> 0 ); \ + \ + } while ( 0 ) + + + static void + sfnt_stream_close( FT_Stream stream ) + { + FT_Memory memory = stream->memory; + + + FT_FREE( stream->base ); + + stream->size = 0; + stream->base = NULL; + stream->close = NULL; + } + + + FT_CALLBACK_DEF( int ) + compare_offsets( const void* a, + const void* b ) + { + WOFF_Table table1 = *(WOFF_Table*)a; + WOFF_Table table2 = *(WOFF_Table*)b; + + FT_ULong offset1 = table1->Offset; + FT_ULong offset2 = table2->Offset; + + + if ( offset1 > offset2 ) + return 1; + else if ( offset1 < offset2 ) + return -1; + else + return 0; + } + + + /* Replace `face->root.stream' with a stream containing the extracted */ + /* SFNT of a WOFF font. */ + + FT_LOCAL_DEF( FT_Error ) + woff_open_font( FT_Stream stream, + TT_Face face ) + { + FT_Memory memory = stream->memory; + FT_Error error = FT_Err_Ok; + + WOFF_HeaderRec woff; + WOFF_Table tables = NULL; + WOFF_Table* indices = NULL; + + FT_ULong woff_offset; + + FT_Byte* sfnt = NULL; + FT_Stream sfnt_stream = NULL; + + FT_Byte* sfnt_header; + FT_ULong sfnt_offset; + + FT_Int nn; + FT_ULong old_tag = 0; + + static const FT_Frame_Field woff_header_fields[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE WOFF_HeaderRec + + FT_FRAME_START( 44 ), + FT_FRAME_ULONG ( signature ), + FT_FRAME_ULONG ( flavor ), + FT_FRAME_ULONG ( length ), + FT_FRAME_USHORT( num_tables ), + FT_FRAME_USHORT( reserved ), + FT_FRAME_ULONG ( totalSfntSize ), + FT_FRAME_USHORT( majorVersion ), + FT_FRAME_USHORT( minorVersion ), + FT_FRAME_ULONG ( metaOffset ), + FT_FRAME_ULONG ( metaLength ), + FT_FRAME_ULONG ( metaOrigLength ), + FT_FRAME_ULONG ( privOffset ), + FT_FRAME_ULONG ( privLength ), + FT_FRAME_END + }; + + + FT_ASSERT( stream == face->root.stream ); + FT_ASSERT( FT_STREAM_POS() == 0 ); + + if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) ) + return error; + + /* Make sure we don't recurse back here or hit TTC code. */ + if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf ) + return FT_THROW( Invalid_Table ); + + /* Miscellaneous checks. */ + if ( woff.length != stream->size || + woff.num_tables == 0 || + 44 + woff.num_tables * 20UL >= woff.length || + 12 + woff.num_tables * 16UL >= woff.totalSfntSize || + ( woff.totalSfntSize & 3 ) != 0 || + ( woff.metaOffset == 0 && ( woff.metaLength != 0 || + woff.metaOrigLength != 0 ) ) || + ( woff.metaLength != 0 && woff.metaOrigLength == 0 ) || + ( woff.privOffset == 0 && woff.privLength != 0 ) ) + { + FT_ERROR(( "woff_font_open: invalid WOFF header\n" )); + return FT_THROW( Invalid_Table ); + } + + /* Don't trust `totalSfntSize' before thorough checks. */ + if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) || + FT_NEW( sfnt_stream ) ) + goto Exit; + + sfnt_header = sfnt; + + /* Write sfnt header. */ + { + FT_UInt searchRange, entrySelector, rangeShift, x; + + + x = woff.num_tables; + entrySelector = 0; + while ( x ) + { + x >>= 1; + entrySelector += 1; + } + entrySelector--; + + searchRange = ( 1 << entrySelector ) * 16; + rangeShift = woff.num_tables * 16 - searchRange; + + WRITE_ULONG ( sfnt_header, woff.flavor ); + WRITE_USHORT( sfnt_header, woff.num_tables ); + WRITE_USHORT( sfnt_header, searchRange ); + WRITE_USHORT( sfnt_header, entrySelector ); + WRITE_USHORT( sfnt_header, rangeShift ); + } + + /* While the entries in the sfnt header must be sorted by the */ + /* tag value, the tables themselves are not. We thus have to */ + /* sort them by offset and check that they don't overlap. */ + + if ( FT_NEW_ARRAY( tables, woff.num_tables ) || + FT_NEW_ARRAY( indices, woff.num_tables ) ) + goto Exit; + + FT_TRACE2(( "\n" + " tag offset compLen origLen checksum\n" + " -------------------------------------------\n" )); + + if ( FT_FRAME_ENTER( 20L * woff.num_tables ) ) + goto Exit; + + for ( nn = 0; nn < woff.num_tables; nn++ ) + { + WOFF_Table table = tables + nn; + + table->Tag = FT_GET_TAG4(); + table->Offset = FT_GET_ULONG(); + table->CompLength = FT_GET_ULONG(); + table->OrigLength = FT_GET_ULONG(); + table->CheckSum = FT_GET_ULONG(); + + FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n", + (FT_Char)( table->Tag >> 24 ), + (FT_Char)( table->Tag >> 16 ), + (FT_Char)( table->Tag >> 8 ), + (FT_Char)( table->Tag ), + table->Offset, + table->CompLength, + table->OrigLength, + table->CheckSum )); + + if ( table->Tag <= old_tag ) + { + FT_FRAME_EXIT(); + + FT_ERROR(( "woff_font_open: table tags are not sorted\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + old_tag = table->Tag; + indices[nn] = table; + } + + FT_FRAME_EXIT(); + + /* Sort by offset. */ + + ft_qsort( indices, + woff.num_tables, + sizeof ( WOFF_Table ), + compare_offsets ); + + /* Check offsets and lengths. */ + + woff_offset = 44 + woff.num_tables * 20L; + sfnt_offset = 12 + woff.num_tables * 16L; + + for ( nn = 0; nn < woff.num_tables; nn++ ) + { + WOFF_Table table = indices[nn]; + + + if ( table->Offset != woff_offset || + table->CompLength > woff.length || + table->Offset > woff.length - table->CompLength || + table->OrigLength > woff.totalSfntSize || + sfnt_offset > woff.totalSfntSize - table->OrigLength || + table->CompLength > table->OrigLength ) + { + FT_ERROR(( "woff_font_open: invalid table offsets\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + table->OrigOffset = sfnt_offset; + + /* The offsets must be multiples of 4. */ + woff_offset += ( table->CompLength + 3 ) & ~3U; + sfnt_offset += ( table->OrigLength + 3 ) & ~3U; + } + + /* + * Final checks! + * + * We don't decode and check the metadata block. + * We don't check table checksums either. + * But other than those, I think we implement all + * `MUST' checks from the spec. + */ + + if ( woff.metaOffset ) + { + if ( woff.metaOffset != woff_offset || + woff.metaOffset + woff.metaLength > woff.length ) + { + FT_ERROR(( "woff_font_open:" + " invalid `metadata' offset or length\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + /* We have padding only ... */ + woff_offset += woff.metaLength; + } + + if ( woff.privOffset ) + { + /* ... if it isn't the last block. */ + woff_offset = ( woff_offset + 3 ) & ~3U; + + if ( woff.privOffset != woff_offset || + woff.privOffset + woff.privLength > woff.length ) + { + FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + /* No padding for the last block. */ + woff_offset += woff.privLength; + } + + if ( sfnt_offset != woff.totalSfntSize || + woff_offset != woff.length ) + { + FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + + /* Now use `totalSfntSize'. */ + if ( FT_REALLOC( sfnt, + 12 + woff.num_tables * 16UL, + woff.totalSfntSize ) ) + goto Exit; + + sfnt_header = sfnt + 12; + + /* Write the tables. */ + + for ( nn = 0; nn < woff.num_tables; nn++ ) + { + WOFF_Table table = tables + nn; + + + /* Write SFNT table entry. */ + WRITE_ULONG( sfnt_header, table->Tag ); + WRITE_ULONG( sfnt_header, table->CheckSum ); + WRITE_ULONG( sfnt_header, table->OrigOffset ); + WRITE_ULONG( sfnt_header, table->OrigLength ); + + /* Write table data. */ + if ( FT_STREAM_SEEK( table->Offset ) || + FT_FRAME_ENTER( table->CompLength ) ) + goto Exit; + + if ( table->CompLength == table->OrigLength ) + { + /* Uncompressed data; just copy. */ + ft_memcpy( sfnt + table->OrigOffset, + stream->cursor, + table->OrigLength ); + } + else + { +#ifdef FT_CONFIG_OPTION_USE_ZLIB + + /* Uncompress with zlib. */ + FT_ULong output_len = table->OrigLength; + + + error = FT_Gzip_Uncompress( memory, + sfnt + table->OrigOffset, &output_len, + stream->cursor, table->CompLength ); + if ( error ) + goto Exit; + if ( output_len != table->OrigLength ) + { + FT_ERROR(( "woff_font_open: compressed table length mismatch\n" )); + error = FT_THROW( Invalid_Table ); + goto Exit; + } + +#else /* !FT_CONFIG_OPTION_USE_ZLIB */ + + error = FT_THROW( Unimplemented_Feature ); + goto Exit; + +#endif /* !FT_CONFIG_OPTION_USE_ZLIB */ + } + + FT_FRAME_EXIT(); + + /* We don't check whether the padding bytes in the WOFF file are */ + /* actually '\0'. For the output, however, we do set them properly. */ + sfnt_offset = table->OrigOffset + table->OrigLength; + while ( sfnt_offset & 3 ) + { + sfnt[sfnt_offset] = '\0'; + sfnt_offset++; + } + } + + /* Ok! Finally ready. Swap out stream and return. */ + FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize ); + sfnt_stream->memory = stream->memory; + sfnt_stream->close = sfnt_stream_close; + + FT_Stream_Free( + face->root.stream, + ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); + + face->root.stream = sfnt_stream; + + face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; + + Exit: + FT_FREE( tables ); + FT_FREE( indices ); + + if ( error ) + { + FT_FREE( sfnt ); + FT_Stream_Close( sfnt_stream ); + FT_FREE( sfnt_stream ); + } + + return error; + } + + +#undef WRITE_USHORT +#undef WRITE_ULONG + + +/* END */ diff --git a/src/3rdparty/freetype/src/sfnt/sfwoff.h b/src/3rdparty/freetype/src/sfnt/sfwoff.h new file mode 100644 index 0000000000..15495c32a2 --- /dev/null +++ b/src/3rdparty/freetype/src/sfnt/sfwoff.h @@ -0,0 +1,41 @@ +/**************************************************************************** + * + * sfwoff.h + * + * WOFFF format management (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef SFWOFF_H_ +#define SFWOFF_H_ + + +#include <ft2build.h> +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_OBJECTS_H + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + woff_open_font( FT_Stream stream, + TT_Face face ); + + +FT_END_HEADER + +#endif /* SFWOFF_H_ */ + + +/* END */ diff --git a/src/3rdparty/freetype/src/sfnt/ttbdf.c b/src/3rdparty/freetype/src/sfnt/ttbdf.c index 534201f229..853599fc43 100644 --- a/src/3rdparty/freetype/src/sfnt/ttbdf.c +++ b/src/3rdparty/freetype/src/sfnt/ttbdf.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttbdf.c */ -/* */ -/* TrueType and OpenType embedded BDF properties (body). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttbdf.c + * + * TrueType and OpenType embedded BDF properties (body). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -27,14 +27,14 @@ #ifdef TT_CONFIG_OPTION_BDF - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttbdf +#define FT_COMPONENT ttbdf FT_LOCAL_DEF( void ) @@ -45,7 +45,7 @@ if ( bdf->loaded ) { - FT_Stream stream = FT_FACE(face)->stream; + FT_Stream stream = FT_FACE( face )->stream; if ( bdf->table ) @@ -111,8 +111,8 @@ FT_UInt num_items = FT_PEEK_USHORT( p + 2 ); /* - * We don't need to check the value sets themselves, since this - * is done later. + * We don't need to check the value sets themselves, since this + * is done later. */ strike += 10 * num_items; @@ -142,7 +142,7 @@ BDF_PropertyRec *aprop ) { TT_BDF bdf = &face->bdf; - FT_Size size = FT_FACE(face)->size; + FT_Size size = FT_FACE( face )->size; FT_Error error = FT_Err_Ok; FT_Byte* p; FT_UInt count; diff --git a/src/3rdparty/freetype/src/sfnt/ttbdf.h b/src/3rdparty/freetype/src/sfnt/ttbdf.h index 809a663001..e4164e61fc 100644 --- a/src/3rdparty/freetype/src/sfnt/ttbdf.h +++ b/src/3rdparty/freetype/src/sfnt/ttbdf.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttbdf.h */ -/* */ -/* TrueType and OpenType embedded BDF properties (specification). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttbdf.h + * + * TrueType and OpenType embedded BDF properties (specification). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTBDF_H_ diff --git a/src/3rdparty/freetype/src/sfnt/ttcmap.c b/src/3rdparty/freetype/src/sfnt/ttcmap.c index 996e66485f..683f3b1818 100644 --- a/src/3rdparty/freetype/src/sfnt/ttcmap.c +++ b/src/3rdparty/freetype/src/sfnt/ttcmap.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttcmap.c */ -/* */ -/* TrueType character mapping table (cmap) support (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttcmap.c + * + * TrueType character mapping table (cmap) support (body). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -27,17 +27,16 @@ #include "ttload.h" #include "ttcmap.h" #include "ttpost.h" -#include "sfntpic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttcmap +#define FT_COMPONENT ttcmap #define TT_PEEK_SHORT FT_PEEK_SHORT @@ -77,19 +76,19 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 0 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* glyph_ids 6 BYTE[256] array of glyph indices */ - /* 262 */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 0 + * length 2 USHORT table length in bytes + * language 4 USHORT Mac language code + * glyph_ids 6 BYTE[256] array of glyph indices + * 262 + */ #ifdef TT_CONFIG_CMAP_FORMAT_0 @@ -238,57 +237,57 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 2 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* keys 6 USHORT[256] sub-header keys */ - /* subs 518 SUBHEAD[NSUBS] sub-headers array */ - /* glyph_ids 518+NSUB*8 USHORT[] glyph ID array */ - /* */ - /* The `keys' table is used to map charcode high bytes to sub-headers. */ - /* The value of `NSUBS' is the number of sub-headers defined in the */ - /* table and is computed by finding the maximum of the `keys' table. */ - /* */ - /* Note that for any `n', `keys[n]' is a byte offset within the `subs' */ - /* table, i.e., it is the corresponding sub-header index multiplied */ - /* by 8. */ - /* */ - /* Each sub-header has the following format. */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* first 0 USHORT first valid low-byte */ - /* count 2 USHORT number of valid low-bytes */ - /* delta 4 SHORT see below */ - /* offset 6 USHORT see below */ - /* */ - /* A sub-header defines, for each high byte, the range of valid */ - /* low bytes within the charmap. Note that the range defined by `first' */ - /* and `count' must be completely included in the interval [0..255] */ - /* according to the specification. */ - /* */ - /* If a character code is contained within a given sub-header, then */ - /* mapping it to a glyph index is done as follows. */ - /* */ - /* * The value of `offset' is read. This is a _byte_ distance from the */ - /* location of the `offset' field itself into a slice of the */ - /* `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too). */ - /* */ - /* * The value `slice[char.lo - first]' is read. If it is 0, there is */ - /* no glyph for the charcode. Otherwise, the value of `delta' is */ - /* added to it (modulo 65536) to form a new glyph index. */ - /* */ - /* It is up to the validation routine to check that all offsets fall */ - /* within the glyph IDs table (and not within the `subs' table itself or */ - /* outside of the CMap). */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 2 + * length 2 USHORT table length in bytes + * language 4 USHORT Mac language code + * keys 6 USHORT[256] sub-header keys + * subs 518 SUBHEAD[NSUBS] sub-headers array + * glyph_ids 518+NSUB*8 USHORT[] glyph ID array + * + * The `keys' table is used to map charcode high bytes to sub-headers. + * The value of `NSUBS' is the number of sub-headers defined in the + * table and is computed by finding the maximum of the `keys' table. + * + * Note that for any `n', `keys[n]' is a byte offset within the `subs' + * table, i.e., it is the corresponding sub-header index multiplied + * by 8. + * + * Each sub-header has the following format. + * + * NAME OFFSET TYPE DESCRIPTION + * + * first 0 USHORT first valid low-byte + * count 2 USHORT number of valid low-bytes + * delta 4 SHORT see below + * offset 6 USHORT see below + * + * A sub-header defines, for each high byte, the range of valid + * low bytes within the charmap. Note that the range defined by `first' + * and `count' must be completely included in the interval [0..255] + * according to the specification. + * + * If a character code is contained within a given sub-header, then + * mapping it to a glyph index is done as follows. + * + * - The value of `offset' is read. This is a _byte_ distance from the + * location of the `offset' field itself into a slice of the + * `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too). + * + * - The value `slice[char.lo - first]' is read. If it is 0, there is + * no glyph for the charcode. Otherwise, the value of `delta' is + * added to it (modulo 65536) to form a new glyph index. + * + * It is up to the validation routine to check that all offsets fall + * within the glyph IDs table (and not within the `subs' table itself or + * outside of the CMap). + */ #ifdef TT_CONFIG_CMAP_FORMAT_2 @@ -626,68 +625,68 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 4 */ - /* length 2 USHORT table length */ - /* in bytes */ - /* language 4 USHORT Mac language code */ - /* */ - /* segCountX2 6 USHORT 2*NUM_SEGS */ - /* searchRange 8 USHORT 2*(1 << LOG_SEGS) */ - /* entrySelector 10 USHORT LOG_SEGS */ - /* rangeShift 12 USHORT segCountX2 - */ - /* searchRange */ - /* */ - /* endCount 14 USHORT[NUM_SEGS] end charcode for */ - /* each segment; last */ - /* is 0xFFFF */ - /* */ - /* pad 14+NUM_SEGS*2 USHORT padding */ - /* */ - /* startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for */ - /* each segment */ - /* */ - /* idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each */ - /* segment */ - /* idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for */ - /* each segment; can be */ - /* zero */ - /* */ - /* glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID */ - /* ranges */ - /* */ - /* Character codes are modelled by a series of ordered (increasing) */ - /* intervals called segments. Each segment has start and end codes, */ - /* provided by the `startCount' and `endCount' arrays. Segments must */ - /* not overlap, and the last segment should always contain the value */ - /* 0xFFFF for `endCount'. */ - /* */ - /* The fields `searchRange', `entrySelector' and `rangeShift' are better */ - /* ignored (they are traces of over-engineering in the TrueType */ - /* specification). */ - /* */ - /* Each segment also has a signed `delta', as well as an optional offset */ - /* within the `glyphIds' table. */ - /* */ - /* If a segment's idOffset is 0, the glyph index corresponding to any */ - /* charcode within the segment is obtained by adding the value of */ - /* `idDelta' directly to the charcode, modulo 65536. */ - /* */ - /* Otherwise, a glyph index is taken from the glyph IDs sub-array for */ - /* the segment, and the value of `idDelta' is added to it. */ - /* */ - /* */ - /* Finally, note that a lot of fonts contain an invalid last segment, */ - /* where `start' and `end' are correctly set to 0xFFFF but both `delta' */ - /* and `offset' are incorrect (e.g., `opens___.ttf' which comes with */ - /* OpenOffice.org). We need special code to deal with them correctly. */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 4 + * length 2 USHORT table length + * in bytes + * language 4 USHORT Mac language code + * + * segCountX2 6 USHORT 2*NUM_SEGS + * searchRange 8 USHORT 2*(1 << LOG_SEGS) + * entrySelector 10 USHORT LOG_SEGS + * rangeShift 12 USHORT segCountX2 - + * searchRange + * + * endCount 14 USHORT[NUM_SEGS] end charcode for + * each segment; last + * is 0xFFFF + * + * pad 14+NUM_SEGS*2 USHORT padding + * + * startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for + * each segment + * + * idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each + * segment + * idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for + * each segment; can be + * zero + * + * glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID + * ranges + * + * Character codes are modelled by a series of ordered (increasing) + * intervals called segments. Each segment has start and end codes, + * provided by the `startCount' and `endCount' arrays. Segments must + * not overlap, and the last segment should always contain the value + * 0xFFFF for `endCount'. + * + * The fields `searchRange', `entrySelector' and `rangeShift' are better + * ignored (they are traces of over-engineering in the TrueType + * specification). + * + * Each segment also has a signed `delta', as well as an optional offset + * within the `glyphIds' table. + * + * If a segment's idOffset is 0, the glyph index corresponding to any + * charcode within the segment is obtained by adding the value of + * `idDelta' directly to the charcode, modulo 65536. + * + * Otherwise, a glyph index is taken from the glyph IDs sub-array for + * the segment, and the value of `idDelta' is added to it. + * + * + * Finally, note that a lot of fonts contain an invalid last segment, + * where `start' and `end' are correctly set to 0xFFFF but both `delta' + * and `offset' are incorrect (e.g., `opens___.ttf' which comes with + * OpenOffice.org). We need special code to deal with them correctly. + */ #ifdef TT_CONFIG_CMAP_FORMAT_4 @@ -1573,23 +1572,23 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 6 */ - /* length 2 USHORT table length in bytes */ - /* language 4 USHORT Mac language code */ - /* */ - /* first 6 USHORT first segment code */ - /* count 8 USHORT segment size in chars */ - /* glyphIds 10 USHORT[count] glyph IDs */ - /* */ - /* A very simplified segment mapping. */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 6 + * length 2 USHORT table length in bytes + * language 4 USHORT Mac language code + * + * first 6 USHORT first segment code + * count 8 USHORT segment size in chars + * glyphIds 10 USHORT[count] glyph IDs + * + * A very simplified segment mapping. + */ #ifdef TT_CONFIG_CMAP_FORMAT_6 @@ -1768,26 +1767,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 8 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* is32 12 BYTE[8192] 32-bitness bitmap */ - /* count 8204 ULONG number of groups */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* startId 8 ULONG start glyph ID for the group */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 8 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * is32 12 BYTE[8192] 32-bitness bitmap + * count 8204 ULONG number of groups + * + * This header is followed by `count' groups of the following format: + * + * start 0 ULONG first charcode + * end 4 ULONG last charcode + * startId 8 ULONG start glyph ID for the group + */ #ifdef TT_CONFIG_CMAP_FORMAT_8 @@ -2037,22 +2036,22 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 10 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* */ - /* start 12 ULONG first char in range */ - /* count 16 ULONG number of chars in range */ - /* glyphIds 20 USHORT[count] glyph indices covered */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 10 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * + * start 12 ULONG first char in range + * count 16 ULONG number of chars in range + * glyphIds 20 USHORT[count] glyph indices covered + */ #ifdef TT_CONFIG_CMAP_FORMAT_10 @@ -2209,26 +2208,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 12 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* count 12 ULONG number of groups */ - /* 16 */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* startId 8 ULONG start glyph ID for the group */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 12 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * count 12 ULONG number of groups + * 16 + * + * This header is followed by `count' groups of the following format: + * + * start 0 ULONG first charcode + * end 4 ULONG last charcode + * startId 8 ULONG start glyph ID for the group + */ #ifdef TT_CONFIG_CMAP_FORMAT_12 @@ -2369,10 +2368,7 @@ /* if `gindex' is invalid, the remaining values */ /* in this group are invalid, too */ if ( gindex >= (FT_UInt)face->num_glyphs ) - { - gindex = 0; continue; - } cmap->cur_charcode = char_code; cmap->cur_gindex = gindex; @@ -2565,26 +2561,26 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 13 */ - /* reserved 2 USHORT reserved */ - /* length 4 ULONG length in bytes */ - /* language 8 ULONG Mac language code */ - /* count 12 ULONG number of groups */ - /* 16 */ - /* */ - /* This header is followed by `count' groups of the following format: */ - /* */ - /* start 0 ULONG first charcode */ - /* end 4 ULONG last charcode */ - /* glyphId 8 ULONG glyph ID for the whole group */ - /* */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 13 + * reserved 2 USHORT reserved + * length 4 ULONG length in bytes + * language 8 ULONG Mac language code + * count 12 ULONG number of groups + * 16 + * + * This header is followed by `count' groups of the following format: + * + * start 0 ULONG first charcode + * end 4 ULONG last charcode + * glyphId 8 ULONG glyph ID for the whole group + */ #ifdef TT_CONFIG_CMAP_FORMAT_13 @@ -2891,58 +2887,59 @@ /*************************************************************************/ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* TABLE OVERVIEW */ - /* -------------- */ - /* */ - /* NAME OFFSET TYPE DESCRIPTION */ - /* */ - /* format 0 USHORT must be 14 */ - /* length 2 ULONG table length in bytes */ - /* numSelector 6 ULONG number of variation sel. records */ - /* */ - /* Followed by numSelector records, each of which looks like */ - /* */ - /* varSelector 0 UINT24 Unicode codepoint of sel. */ - /* defaultOff 3 ULONG offset to a default UVS table */ - /* describing any variants to be found in */ - /* the normal Unicode subtable. */ - /* nonDefOff 7 ULONG offset to a non-default UVS table */ - /* describing any variants not in the */ - /* standard cmap, with GIDs here */ - /* (either offset may be 0 NULL) */ - /* */ - /* Selectors are sorted by code point. */ - /* */ - /* A default Unicode Variation Selector (UVS) subtable is just a list of */ - /* ranges of code points which are to be found in the standard cmap. No */ - /* glyph IDs (GIDs) here. */ - /* */ - /* numRanges 0 ULONG number of ranges following */ - /* */ - /* A range looks like */ - /* */ - /* uniStart 0 UINT24 code point of the first character in */ - /* this range */ - /* additionalCnt 3 UBYTE count of additional characters in this */ - /* range (zero means a range of a single */ - /* character) */ - /* */ - /* Ranges are sorted by `uniStart'. */ - /* */ - /* A non-default Unicode Variation Selector (UVS) subtable is a list of */ - /* mappings from codepoint to GID. */ - /* */ - /* numMappings 0 ULONG number of mappings */ - /* */ - /* A range looks like */ - /* */ - /* uniStart 0 UINT24 code point of the first character in */ - /* this range */ - /* GID 3 USHORT and its GID */ - /* */ - /* Ranges are sorted by `uniStart'. */ + /************************************************************************** + * + * TABLE OVERVIEW + * -------------- + * + * NAME OFFSET TYPE DESCRIPTION + * + * format 0 USHORT must be 14 + * length 2 ULONG table length in bytes + * numSelector 6 ULONG number of variation sel. records + * + * Followed by numSelector records, each of which looks like + * + * varSelector 0 UINT24 Unicode codepoint of sel. + * defaultOff 3 ULONG offset to a default UVS table + * describing any variants to be found in + * the normal Unicode subtable. + * nonDefOff 7 ULONG offset to a non-default UVS table + * describing any variants not in the + * standard cmap, with GIDs here + * (either offset may be 0 NULL) + * + * Selectors are sorted by code point. + * + * A default Unicode Variation Selector (UVS) subtable is just a list of + * ranges of code points which are to be found in the standard cmap. No + * glyph IDs (GIDs) here. + * + * numRanges 0 ULONG number of ranges following + * + * A range looks like + * + * uniStart 0 UINT24 code point of the first character in + * this range + * additionalCnt 3 UBYTE count of additional characters in this + * range (zero means a range of a single + * character) + * + * Ranges are sorted by `uniStart'. + * + * A non-default Unicode Variation Selector (UVS) subtable is a list of + * mappings from codepoint to GID. + * + * numMappings 0 ULONG number of mappings + * + * A range looks like + * + * uniStart 0 UINT24 code point of the first character in + * this range + * GID 3 USHORT and its GID + * + * Ranges are sorted by `uniStart'. + */ #ifdef TT_CONFIG_CMAP_FORMAT_14 @@ -3661,7 +3658,7 @@ tt_get_glyph_name( TT_Face face, FT_UInt idx ) { - FT_String* PSname; + FT_String* PSname = NULL; tt_face_get_ps_name( face, idx, &PSname ); @@ -3681,6 +3678,9 @@ FT_UNUSED( pointer ); + if ( !psnames->unicodes_init ) + return FT_THROW( Unimplemented_Feature ); + return psnames->unicodes_init( memory, unicodes, face->root.num_glyphs, @@ -3749,7 +3749,6 @@ #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ -#ifndef FT_CONFIG_OPTION_PIC static const TT_CMap_Class tt_cmap_classes[] = { @@ -3758,61 +3757,6 @@ NULL, }; -#else /*FT_CONFIG_OPTION_PIC*/ - - void - FT_Destroy_Class_tt_cmap_classes( FT_Library library, - TT_CMap_Class* clazz ) - { - FT_Memory memory = library->memory; - - - if ( clazz ) - FT_FREE( clazz ); - } - - - FT_Error - FT_Create_Class_tt_cmap_classes( FT_Library library, - TT_CMap_Class** output_class ) - { - TT_CMap_Class* clazz = NULL; - TT_CMap_ClassRec* recs; - FT_Error error; - FT_Memory memory = library->memory; - - int i = 0; - - -#define TTCMAPCITEM( a ) i++; -#include "ttcmapc.h" - - /* allocate enough space for both the pointers */ - /* plus terminator and the class instances */ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * ( i + 1 ) + - sizeof ( TT_CMap_ClassRec ) * i ) ) - return error; - - /* the location of the class instances follows the array of pointers */ - recs = (TT_CMap_ClassRec*)( (char*)clazz + - sizeof ( *clazz ) * ( i + 1 ) ); - i = 0; - -#undef TTCMAPCITEM -#define TTCMAPCITEM( a ) \ - FT_Init_Class_ ## a( &recs[i] ); \ - clazz[i] = &recs[i]; \ - i++; -#include "ttcmapc.h" - - clazz[i] = NULL; - - *output_class = clazz; - return FT_Err_Ok; - } - -#endif /*FT_CONFIG_OPTION_PIC*/ - /* parse the `cmap' table and build the corresponding TT_CMap objects */ /* in the current face */ @@ -3859,7 +3803,7 @@ { FT_Byte* volatile cmap = table + offset; volatile FT_UInt format = TT_PEEK_USHORT( cmap ); - const TT_CMap_Class* volatile pclazz = TT_CMAP_CLASSES_GET; + const TT_CMap_Class* volatile pclazz = tt_cmap_classes; TT_CMap_Class volatile clazz; diff --git a/src/3rdparty/freetype/src/sfnt/ttcmap.h b/src/3rdparty/freetype/src/sfnt/ttcmap.h index d264d99d2c..36801c939e 100644 --- a/src/3rdparty/freetype/src/sfnt/ttcmap.h +++ b/src/3rdparty/freetype/src/sfnt/ttcmap.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttcmap.h */ -/* */ -/* TrueType character mapping table (cmap) support (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttcmap.h + * + * TrueType character mapping table (cmap) support (specification). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTCMAP_H_ @@ -56,8 +56,6 @@ FT_BEGIN_HEADER } TT_CMap_ClassRec; -#ifndef FT_CONFIG_OPTION_PIC - #define FT_DEFINE_TT_CMAP( class_, \ size_, \ init_, \ @@ -92,42 +90,6 @@ FT_BEGIN_HEADER get_cmap_info_ \ }; -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_TT_CMAP( class_, \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_, \ - format_, \ - validate_, \ - get_cmap_info_ ) \ - void \ - FT_Init_Class_ ## class_( TT_CMap_ClassRec* clazz ) \ - { \ - clazz->clazz.size = size_; \ - clazz->clazz.init = init_; \ - clazz->clazz.done = done_; \ - clazz->clazz.char_index = char_index_; \ - clazz->clazz.char_next = char_next_; \ - clazz->clazz.char_var_index = char_var_index_; \ - clazz->clazz.char_var_default = char_var_default_; \ - clazz->clazz.variant_list = variant_list_; \ - clazz->clazz.charvariant_list = charvariant_list_; \ - clazz->clazz.variantchar_list = variantchar_list_; \ - clazz->format = format_; \ - clazz->validate = validate_; \ - clazz->get_cmap_info = get_cmap_info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - typedef struct TT_ValidatorRec_ { diff --git a/src/3rdparty/freetype/src/sfnt/ttcmapc.h b/src/3rdparty/freetype/src/sfnt/ttcmapc.h index 4980e9dd3d..ace9e69ca8 100644 --- a/src/3rdparty/freetype/src/sfnt/ttcmapc.h +++ b/src/3rdparty/freetype/src/sfnt/ttcmapc.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttcmapc.h */ -/* */ -/* TT CMAP classes definitions (specification only). */ -/* */ -/* Copyright 2009-2018 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttcmapc.h + * + * TT CMAP classes definitions (specification only). + * + * Copyright (C) 2009-2019 by + * Oran Agra and Mickey Gabel. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifdef TT_CONFIG_CMAP_FORMAT_0 diff --git a/src/3rdparty/freetype/src/sfnt/ttcolr.c b/src/3rdparty/freetype/src/sfnt/ttcolr.c new file mode 100644 index 0000000000..6b537d95b8 --- /dev/null +++ b/src/3rdparty/freetype/src/sfnt/ttcolr.c @@ -0,0 +1,451 @@ +/**************************************************************************** + * + * ttcolr.c + * + * TrueType and OpenType colored glyph layer support (body). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * `COLR' table specification: + * + * https://www.microsoft.com/typography/otspec/colr.htm + * + */ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_COLOR_H + + +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS + +#include "ttcolr.h" + + + /* NOTE: These are the table sizes calculated through the specs. */ +#define BASE_GLYPH_SIZE 6 +#define LAYER_SIZE 4 +#define COLR_HEADER_SIZE 14 + + + typedef struct BaseGlyphRecord_ + { + FT_UShort gid; + FT_UShort first_layer_index; + FT_UShort num_layers; + + } BaseGlyphRecord; + + + typedef struct Colr_ + { + FT_UShort version; + FT_UShort num_base_glyphs; + FT_UShort num_layers; + + FT_Byte* base_glyphs; + FT_Byte* layers; + + /* The memory which backs up the `COLR' table. */ + void* table; + FT_ULong table_size; + + } Colr; + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT ttcolr + + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_colr( TT_Face face, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = face->root.memory; + + FT_Byte* table = NULL; + FT_Byte* p = NULL; + + Colr* colr = NULL; + + FT_ULong base_glyph_offset, layer_offset; + FT_ULong table_size; + + + /* `COLR' always needs `CPAL' */ + if ( !face->cpal ) + return FT_THROW( Invalid_File_Format ); + + error = face->goto_table( face, TTAG_COLR, stream, &table_size ); + if ( error ) + goto NoColr; + + if ( table_size < COLR_HEADER_SIZE ) + goto InvalidTable; + + if ( FT_FRAME_EXTRACT( table_size, table ) ) + goto NoColr; + + p = table; + + if ( FT_NEW( colr ) ) + goto NoColr; + + colr->version = FT_NEXT_USHORT( p ); + if ( colr->version != 0 ) + goto InvalidTable; + + colr->num_base_glyphs = FT_NEXT_USHORT( p ); + base_glyph_offset = FT_NEXT_ULONG( p ); + + if ( base_glyph_offset >= table_size ) + goto InvalidTable; + if ( colr->num_base_glyphs * BASE_GLYPH_SIZE > + table_size - base_glyph_offset ) + goto InvalidTable; + + layer_offset = FT_NEXT_ULONG( p ); + colr->num_layers = FT_NEXT_USHORT( p ); + + if ( layer_offset >= table_size ) + goto InvalidTable; + if ( colr->num_layers * LAYER_SIZE > table_size - layer_offset ) + goto InvalidTable; + + colr->base_glyphs = (FT_Byte*)( table + base_glyph_offset ); + colr->layers = (FT_Byte*)( table + layer_offset ); + colr->table = table; + colr->table_size = table_size; + + face->colr = colr; + + return FT_Err_Ok; + + InvalidTable: + error = FT_THROW( Invalid_Table ); + + NoColr: + FT_FRAME_RELEASE( table ); + FT_FREE( colr ); + + return error; + } + + + FT_LOCAL_DEF( void ) + tt_face_free_colr( TT_Face face ) + { + FT_Stream stream = face->root.stream; + FT_Memory memory = face->root.memory; + + Colr* colr = (Colr*)face->colr; + + + if ( colr ) + { + FT_FRAME_RELEASE( colr->table ); + FT_FREE( colr ); + } + } + + + static FT_Bool + find_base_glyph_record( FT_Byte* base_glyph_begin, + FT_Int num_base_glyph, + FT_UInt glyph_id, + BaseGlyphRecord* record ) + { + FT_Int min = 0; + FT_Int max = num_base_glyph - 1; + + + while ( min <= max ) + { + FT_Int mid = min + ( max - min ) / 2; + FT_Byte* p = base_glyph_begin + mid * BASE_GLYPH_SIZE; + + FT_UShort gid = FT_NEXT_USHORT( p ); + + + if ( gid < glyph_id ) + min = mid + 1; + else if (gid > glyph_id ) + max = mid - 1; + else + { + record->gid = gid; + record->first_layer_index = FT_NEXT_USHORT( p ); + record->num_layers = FT_NEXT_USHORT( p ); + + return 1; + } + } + + return 0; + } + + + FT_LOCAL_DEF( FT_Bool ) + tt_face_get_colr_layer( TT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ) + { + Colr* colr = (Colr*)face->colr; + BaseGlyphRecord glyph_record; + + + if ( !colr ) + return 0; + + if ( !iterator->p ) + { + FT_ULong offset; + + + /* first call to function */ + iterator->layer = 0; + + if ( !find_base_glyph_record( colr->base_glyphs, + colr->num_base_glyphs, + base_glyph, + &glyph_record ) ) + return 0; + + if ( glyph_record.num_layers ) + iterator->num_layers = glyph_record.num_layers; + else + return 0; + + offset = LAYER_SIZE * glyph_record.first_layer_index; + if ( offset + LAYER_SIZE * glyph_record.num_layers > colr->table_size ) + return 0; + + iterator->p = colr->layers + offset; + } + + if ( iterator->layer >= iterator->num_layers ) + return 0; + + *aglyph_index = FT_NEXT_USHORT( iterator->p ); + *acolor_index = FT_NEXT_USHORT( iterator->p ); + + if ( *aglyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) || + ( *acolor_index != 0xFFFF && + *acolor_index >= face->palette_data.num_palette_entries ) ) + return 0; + + iterator->layer++; + + return 1; + } + + + FT_LOCAL_DEF( FT_Error ) + tt_face_colr_blend_layer( TT_Face face, + FT_UInt color_index, + FT_GlyphSlot dstSlot, + FT_GlyphSlot srcSlot ) + { + FT_Error error; + + FT_UInt x, y; + FT_Byte b, g, r, alpha; + + FT_ULong size; + FT_Byte* src; + FT_Byte* dst; + + + if ( !dstSlot->bitmap.buffer ) + { + /* Initialize destination of color bitmap */ + /* with the size of first component. */ + dstSlot->bitmap_left = srcSlot->bitmap_left; + dstSlot->bitmap_top = srcSlot->bitmap_top; + + dstSlot->bitmap.width = srcSlot->bitmap.width; + dstSlot->bitmap.rows = srcSlot->bitmap.rows; + dstSlot->bitmap.pixel_mode = FT_PIXEL_MODE_BGRA; + dstSlot->bitmap.pitch = (int)dstSlot->bitmap.width * 4; + dstSlot->bitmap.num_grays = 256; + + size = dstSlot->bitmap.rows * (unsigned int)dstSlot->bitmap.pitch; + + error = ft_glyphslot_alloc_bitmap( dstSlot, size ); + if ( error ) + return error; + + FT_MEM_ZERO( dstSlot->bitmap.buffer, size ); + } + else + { + /* Resize destination if needed such that new component fits. */ + FT_Int x_min, x_max, y_min, y_max; + + + x_min = FT_MIN( dstSlot->bitmap_left, srcSlot->bitmap_left ); + x_max = FT_MAX( dstSlot->bitmap_left + (FT_Int)dstSlot->bitmap.width, + srcSlot->bitmap_left + (FT_Int)srcSlot->bitmap.width ); + + y_min = FT_MIN( dstSlot->bitmap_top - (FT_Int)dstSlot->bitmap.rows, + srcSlot->bitmap_top - (FT_Int)srcSlot->bitmap.rows ); + y_max = FT_MAX( dstSlot->bitmap_top, srcSlot->bitmap_top ); + + if ( x_min != dstSlot->bitmap_left || + x_max != dstSlot->bitmap_left + (FT_Int)dstSlot->bitmap.width || + y_min != dstSlot->bitmap_top - (FT_Int)dstSlot->bitmap.rows || + y_max != dstSlot->bitmap_top ) + { + FT_Memory memory = face->root.memory; + + FT_UInt width = (FT_UInt)( x_max - x_min ); + FT_UInt rows = (FT_UInt)( y_max - y_min ); + FT_UInt pitch = width * 4; + + FT_Byte* buf = NULL; + FT_Byte* p; + FT_Byte* q; + + + size = rows * pitch; + if ( FT_ALLOC( buf, size ) ) + return error; + + p = dstSlot->bitmap.buffer; + q = buf + + (int)pitch * ( y_max - dstSlot->bitmap_top ) + + 4 * ( dstSlot->bitmap_left - x_min ); + + for ( y = 0; y < dstSlot->bitmap.rows; y++ ) + { + FT_MEM_COPY( q, p, dstSlot->bitmap.width * 4 ); + + p += dstSlot->bitmap.pitch; + q += pitch; + } + + ft_glyphslot_set_bitmap( dstSlot, buf ); + + dstSlot->bitmap_top = y_max; + dstSlot->bitmap_left = x_min; + + dstSlot->bitmap.width = width; + dstSlot->bitmap.rows = rows; + dstSlot->bitmap.pitch = (int)pitch; + + dstSlot->internal->flags |= FT_GLYPH_OWN_BITMAP; + dstSlot->format = FT_GLYPH_FORMAT_BITMAP; + } + } + + if ( color_index == 0xFFFF ) + { + if ( face->have_foreground_color ) + { + b = face->foreground_color.blue; + g = face->foreground_color.green; + r = face->foreground_color.red; + alpha = face->foreground_color.alpha; + } + else + { + if ( face->palette_data.palette_flags && + ( face->palette_data.palette_flags[face->palette_index] & + FT_PALETTE_FOR_DARK_BACKGROUND ) ) + { + /* white opaque */ + b = 0xFF; + g = 0xFF; + r = 0xFF; + alpha = 0xFF; + } + else + { + /* black opaque */ + b = 0x00; + g = 0x00; + r = 0x00; + alpha = 0xFF; + } + } + } + else + { + b = face->palette[color_index].blue; + g = face->palette[color_index].green; + r = face->palette[color_index].red; + alpha = face->palette[color_index].alpha; + } + + /* XXX Convert if srcSlot.bitmap is not grey? */ + src = srcSlot->bitmap.buffer; + dst = dstSlot->bitmap.buffer + + dstSlot->bitmap.pitch * ( dstSlot->bitmap_top - srcSlot->bitmap_top ) + + 4 * ( srcSlot->bitmap_left - dstSlot->bitmap_left ); + + for ( y = 0; y < srcSlot->bitmap.rows; y++ ) + { + for ( x = 0; x < srcSlot->bitmap.width; x++ ) + { + int aa = src[x]; + int fa = alpha * aa / 255; + + int fb = b * fa / 255; + int fg = g * fa / 255; + int fr = r * fa / 255; + + int ba2 = 255 - fa; + + int bb = dst[4 * x + 0]; + int bg = dst[4 * x + 1]; + int br = dst[4 * x + 2]; + int ba = dst[4 * x + 3]; + + + dst[4 * x + 0] = (FT_Byte)( bb * ba2 / 255 + fb ); + dst[4 * x + 1] = (FT_Byte)( bg * ba2 / 255 + fg ); + dst[4 * x + 2] = (FT_Byte)( br * ba2 / 255 + fr ); + dst[4 * x + 3] = (FT_Byte)( ba * ba2 / 255 + fa ); + } + + src += srcSlot->bitmap.pitch; + dst += dstSlot->bitmap.pitch; + } + + return FT_Err_Ok; + } + +#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_colr_dummy; + +#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + +/* EOF */ diff --git a/src/3rdparty/freetype/src/sfnt/ttcolr.h b/src/3rdparty/freetype/src/sfnt/ttcolr.h new file mode 100644 index 0000000000..817489a855 --- /dev/null +++ b/src/3rdparty/freetype/src/sfnt/ttcolr.h @@ -0,0 +1,58 @@ +/**************************************************************************** + * + * ttcolr.h + * + * TrueType and OpenType colored glyph layer support (specification). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef __TTCOLR_H__ +#define __TTCOLR_H__ + + +#include <ft2build.h> +#include "ttload.h" + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + tt_face_load_colr( TT_Face face, + FT_Stream stream ); + + FT_LOCAL( void ) + tt_face_free_colr( TT_Face face ); + + FT_LOCAL( FT_Bool ) + tt_face_get_colr_layer( TT_Face face, + FT_UInt base_glyph, + FT_UInt *aglyph_index, + FT_UInt *acolor_index, + FT_LayerIterator* iterator ); + + FT_LOCAL( FT_Error ) + tt_face_colr_blend_layer( TT_Face face, + FT_UInt color_index, + FT_GlyphSlot dstSlot, + FT_GlyphSlot srcSlot ); + + +FT_END_HEADER + + +#endif /* __TTCOLR_H__ */ + +/* END */ diff --git a/src/3rdparty/freetype/src/sfnt/ttcpal.c b/src/3rdparty/freetype/src/sfnt/ttcpal.c new file mode 100644 index 0000000000..3482169a89 --- /dev/null +++ b/src/3rdparty/freetype/src/sfnt/ttcpal.c @@ -0,0 +1,311 @@ +/**************************************************************************** + * + * ttcpal.c + * + * TrueType and OpenType color palette support (body). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * `CPAL' table specification: + * + * https://www.microsoft.com/typography/otspec/cpal.htm + * + */ + + +#include <ft2build.h> +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_COLOR_H + + +#ifdef TT_CONFIG_OPTION_COLOR_LAYERS + +#include "ttcpal.h" + + + /* NOTE: These are the table sizes calculated through the specs. */ +#define CPAL_V0_HEADER_BASE_SIZE 12 +#define COLOR_SIZE 4 + + + /* all data from `CPAL' not covered in FT_Palette_Data */ + typedef struct Cpal_ + { + FT_UShort version; /* Table version number (0 or 1 supported). */ + FT_UShort num_colors; /* Total number of color records, */ + /* combined for all palettes. */ + FT_Byte* colors; /* RGBA array of colors */ + FT_Byte* color_indices; /* Index of each palette's first color record */ + /* in the combined color record array. */ + + /* The memory which backs up the `CPAL' table. */ + void* table; + FT_ULong table_size; + + } Cpal; + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ +#undef FT_COMPONENT +#define FT_COMPONENT ttcpal + + + FT_LOCAL_DEF( FT_Error ) + tt_face_load_cpal( TT_Face face, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = face->root.memory; + + FT_Byte* table = NULL; + FT_Byte* p = NULL; + + Cpal* cpal = NULL; + + FT_ULong colors_offset; + FT_ULong table_size; + + + error = face->goto_table( face, TTAG_CPAL, stream, &table_size ); + if ( error ) + goto NoCpal; + + if ( table_size < CPAL_V0_HEADER_BASE_SIZE ) + goto InvalidTable; + + if ( FT_FRAME_EXTRACT( table_size, table ) ) + goto NoCpal; + + p = table; + + if ( FT_NEW( cpal ) ) + goto NoCpal; + + cpal->version = FT_NEXT_USHORT( p ); + if ( cpal->version > 1 ) + goto InvalidTable; + + face->palette_data.num_palette_entries = FT_NEXT_USHORT( p ); + face->palette_data.num_palettes = FT_NEXT_USHORT( p ); + + cpal->num_colors = FT_NEXT_USHORT( p ); + colors_offset = FT_NEXT_ULONG( p ); + + if ( CPAL_V0_HEADER_BASE_SIZE + + face->palette_data.num_palettes * 2U > table_size ) + goto InvalidTable; + + if ( colors_offset >= table_size ) + goto InvalidTable; + if ( cpal->num_colors * COLOR_SIZE > table_size - colors_offset ) + goto InvalidTable; + + if ( face->palette_data.num_palette_entries > cpal->num_colors ) + goto InvalidTable; + + cpal->color_indices = p; + cpal->colors = (FT_Byte*)( table + colors_offset ); + + if ( cpal->version == 1 ) + { + FT_ULong type_offset, label_offset, entry_label_offset; + FT_UShort* array = NULL; + FT_UShort* limit; + FT_UShort* q; + + + if ( CPAL_V0_HEADER_BASE_SIZE + + face->palette_data.num_palettes * 2U + + 3U * 4 > table_size ) + goto InvalidTable; + + p += face->palette_data.num_palettes * 2; + + type_offset = FT_NEXT_ULONG( p ); + label_offset = FT_NEXT_ULONG( p ); + entry_label_offset = FT_NEXT_ULONG( p ); + + if ( type_offset ) + { + if ( type_offset >= table_size ) + goto InvalidTable; + if ( face->palette_data.num_palettes * 2 > + table_size - type_offset ) + goto InvalidTable; + + if ( FT_QNEW_ARRAY( array, face->palette_data.num_palettes ) ) + goto NoCpal; + + p = table + type_offset; + q = array; + limit = q + face->palette_data.num_palettes; + + while ( q < limit ) + *q++ = FT_NEXT_USHORT( p ); + + face->palette_data.palette_flags = array; + } + + if ( label_offset ) + { + if ( label_offset >= table_size ) + goto InvalidTable; + if ( face->palette_data.num_palettes * 2 > + table_size - label_offset ) + goto InvalidTable; + + if ( FT_QNEW_ARRAY( array, face->palette_data.num_palettes ) ) + goto NoCpal; + + p = table + label_offset; + q = array; + limit = q + face->palette_data.num_palettes; + + while ( q < limit ) + *q++ = FT_NEXT_USHORT( p ); + + face->palette_data.palette_name_ids = array; + } + + if ( entry_label_offset ) + { + if ( entry_label_offset >= table_size ) + goto InvalidTable; + if ( face->palette_data.num_palette_entries * 2 > + table_size - entry_label_offset ) + goto InvalidTable; + + if ( FT_QNEW_ARRAY( array, face->palette_data.num_palette_entries ) ) + goto NoCpal; + + p = table + entry_label_offset; + q = array; + limit = q + face->palette_data.num_palette_entries; + + while ( q < limit ) + *q++ = FT_NEXT_USHORT( p ); + + face->palette_data.palette_entry_name_ids = array; + } + } + + cpal->table = table; + cpal->table_size = table_size; + + face->cpal = cpal; + + /* set up default palette */ + if ( FT_NEW_ARRAY( face->palette, + face->palette_data.num_palette_entries ) ) + goto NoCpal; + + if ( tt_face_palette_set( face, 0 ) ) + goto InvalidTable; + + return FT_Err_Ok; + + InvalidTable: + error = FT_THROW( Invalid_Table ); + + NoCpal: + FT_FRAME_RELEASE( table ); + FT_FREE( cpal ); + + face->cpal = NULL; + + /* arrays in `face->palette_data' and `face->palette' */ + /* are freed in `sfnt_done_face' */ + + return error; + } + + + FT_LOCAL_DEF( void ) + tt_face_free_cpal( TT_Face face ) + { + FT_Stream stream = face->root.stream; + FT_Memory memory = face->root.memory; + + Cpal* cpal = (Cpal*)face->cpal; + + + if ( cpal ) + { + FT_FRAME_RELEASE( cpal->table ); + FT_FREE( cpal ); + } + } + + + FT_LOCAL_DEF( FT_Error ) + tt_face_palette_set( TT_Face face, + FT_UInt palette_index ) + { + Cpal* cpal = (Cpal*)face->cpal; + + FT_Byte* offset; + FT_Byte* p; + + FT_Color* q; + FT_Color* limit; + + FT_UShort color_index; + + + if ( !cpal || palette_index >= face->palette_data.num_palettes ) + return FT_THROW( Invalid_Argument ); + + offset = cpal->color_indices + 2 * palette_index; + color_index = FT_PEEK_USHORT( offset ); + + if ( color_index + face->palette_data.num_palette_entries > + cpal->num_colors ) + return FT_THROW( Invalid_Table ); + + p = cpal->colors + COLOR_SIZE * color_index; + q = face->palette; + limit = q + face->palette_data.num_palette_entries; + + while ( q < limit ) + { + q->blue = FT_NEXT_BYTE( p ); + q->green = FT_NEXT_BYTE( p ); + q->red = FT_NEXT_BYTE( p ); + q->alpha = FT_NEXT_BYTE( p ); + + q++; + } + + return FT_Err_Ok; + } + + +#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + + /* ANSI C doesn't like empty source files */ + typedef int _tt_cpal_dummy; + +#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ + +/* EOF */ diff --git a/src/3rdparty/freetype/src/sfnt/ttcpal.h b/src/3rdparty/freetype/src/sfnt/ttcpal.h new file mode 100644 index 0000000000..d1b244f3e3 --- /dev/null +++ b/src/3rdparty/freetype/src/sfnt/ttcpal.h @@ -0,0 +1,49 @@ +/**************************************************************************** + * + * ttcpal.h + * + * TrueType and OpenType color palette support (specification). + * + * Copyright (C) 2018-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Originally written by Shao Yu Zhang <shaozhang@fb.com>. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + +#ifndef __TTCPAL_H__ +#define __TTCPAL_H__ + + +#include <ft2build.h> +#include "ttload.h" + + +FT_BEGIN_HEADER + + + FT_LOCAL( FT_Error ) + tt_face_load_cpal( TT_Face face, + FT_Stream stream ); + + FT_LOCAL( void ) + tt_face_free_cpal( TT_Face face ); + + FT_LOCAL( FT_Error ) + tt_face_palette_set( TT_Face face, + FT_UInt palette_index ); + + +FT_END_HEADER + + +#endif /* __TTCPAL_H__ */ + +/* END */ diff --git a/src/3rdparty/freetype/src/sfnt/ttkern.c b/src/3rdparty/freetype/src/sfnt/ttkern.c index 68f15a2010..8d1b781090 100644 --- a/src/3rdparty/freetype/src/sfnt/ttkern.c +++ b/src/3rdparty/freetype/src/sfnt/ttkern.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttkern.c */ -/* */ -/* Load the basic TrueType kerning table. This doesn't handle */ -/* kerning data within the GPOS table at the moment. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttkern.c + * + * Load the basic TrueType kerning table. This doesn't handle + * kerning data within the GPOS table at the moment. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #include "sferrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttkern +#define FT_COMPONENT ttkern #undef TT_KERN_INDEX @@ -127,8 +127,8 @@ avail |= mask; /* - * Now check whether the pairs in this table are ordered. - * We then can use binary search. + * Now check whether the pairs in this table are ordered. + * We then can use binary search. */ if ( num_pairs > 0 ) { @@ -283,8 +283,8 @@ break; /* - * We don't support format 2 because we haven't seen a single font - * using it in real life... + * We don't support format 2 because we haven't seen a single font + * using it in real life... */ default: diff --git a/src/3rdparty/freetype/src/sfnt/ttkern.h b/src/3rdparty/freetype/src/sfnt/ttkern.h index 4e45d0964b..5f283e5e62 100644 --- a/src/3rdparty/freetype/src/sfnt/ttkern.h +++ b/src/3rdparty/freetype/src/sfnt/ttkern.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttkern.h */ -/* */ -/* Load the basic TrueType kerning table. This doesn't handle */ -/* kerning data within the GPOS table at the moment. */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttkern.h + * + * Load the basic TrueType kerning table. This doesn't handle + * kerning data within the GPOS table at the moment. + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTKERN_H_ diff --git a/src/3rdparty/freetype/src/sfnt/ttload.c b/src/3rdparty/freetype/src/sfnt/ttload.c index a86a546c3d..5443bf4b69 100644 --- a/src/3rdparty/freetype/src/sfnt/ttload.c +++ b/src/3rdparty/freetype/src/sfnt/ttload.c @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttload.c */ -/* */ -/* Load the basic TrueType tables, i.e., tables that can be either in */ -/* TTF or OTF fonts (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttload.c + * + * Load the basic TrueType tables, i.e., tables that can be either in + * TTF or OTF fonts (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,32 +26,34 @@ #include "sferrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttload - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_lookup_table */ - /* */ - /* <Description> */ - /* Looks for a TrueType table by name. */ - /* */ - /* <Input> */ - /* face :: A face object handle. */ - /* */ - /* tag :: The searched tag. */ - /* */ - /* <Return> */ - /* A pointer to the table directory entry. 0 if not found. */ - /* */ +#define FT_COMPONENT ttload + + + /************************************************************************** + * + * @Function: + * tt_face_lookup_table + * + * @Description: + * Looks for a TrueType table by name. + * + * @Input: + * face :: + * A face object handle. + * + * tag :: + * The searched tag. + * + * @Return: + * A pointer to the table directory entry. 0 if not found. + */ FT_LOCAL_DEF( TT_Table ) tt_face_lookup_table( TT_Face face, FT_ULong tag ) @@ -101,27 +103,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_goto_table */ - /* */ - /* <Description> */ - /* Looks for a TrueType table by name, then seek a stream to it. */ - /* */ - /* <Input> */ - /* face :: A face object handle. */ - /* */ - /* tag :: The searched tag. */ - /* */ - /* stream :: The stream to seek when the table is found. */ - /* */ - /* <Output> */ - /* length :: The length of the table if found, undefined otherwise. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_goto_table + * + * @Description: + * Looks for a TrueType table by name, then seek a stream to it. + * + * @Input: + * face :: + * A face object handle. + * + * tag :: + * The searched tag. + * + * stream :: + * The stream to seek when the table is found. + * + * @Output: + * length :: + * The length of the table if found, undefined otherwise. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_goto_table( TT_Face face, FT_ULong tag, @@ -309,28 +315,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_font_dir */ - /* */ - /* <Description> */ - /* Loads the header of a SFNT font file. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Output> */ - /* sfnt :: The SFNT header. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the beginning of the font directory. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_font_dir + * + * @Description: + * Loads the header of a SFNT font file. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Output: + * sfnt :: + * The SFNT header. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * The stream cursor must be at the beginning of the font directory. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_font_dir( TT_Face face, FT_Stream stream ) @@ -496,46 +505,51 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_any */ - /* */ - /* <Description> */ - /* Loads any font table into client memory. */ - /* */ - /* <Input> */ - /* face :: The face object to look for. */ - /* */ - /* tag :: The tag of table to load. Use the value 0 if you want */ - /* to access the whole font file, else set this parameter */ - /* to a valid TrueType table tag that you can forge with */ - /* the MAKE_TT_TAG macro. */ - /* */ - /* offset :: The starting offset in the table (or the file if */ - /* tag == 0). */ - /* */ - /* length :: The address of the decision variable: */ - /* */ - /* If length == NULL: */ - /* Loads the whole table. Returns an error if */ - /* `offset' == 0! */ - /* */ - /* If *length == 0: */ - /* Exits immediately; returning the length of the given */ - /* table or of the font file, depending on the value of */ - /* `tag'. */ - /* */ - /* If *length != 0: */ - /* Loads the next `length' bytes of table or font, */ - /* starting at offset `offset' (in table or font too). */ - /* */ - /* <Output> */ - /* buffer :: The address of target buffer. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_any + * + * @Description: + * Loads any font table into client memory. + * + * @Input: + * face :: + * The face object to look for. + * + * tag :: + * The tag of table to load. Use the value 0 if you want + * to access the whole font file, else set this parameter + * to a valid TrueType table tag that you can forge with + * the MAKE_TT_TAG macro. + * + * offset :: + * The starting offset in the table (or the file if + * tag == 0). + * + * length :: + * The address of the decision variable: + * + * If length == NULL: + * Loads the whole table. Returns an error if + * `offset' == 0! + * + * If *length == 0: + * Exits immediately; returning the length of the given + * table or of the font file, depending on the value of + * `tag'. + * + * If *length != 0: + * Loads the next `length' bytes of table or font, + * starting at offset `offset' (in table or font too). + * + * @Output: + * buffer :: + * The address of target buffer. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_any( TT_Face face, FT_ULong tag, @@ -586,22 +600,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_generic_header */ - /* */ - /* <Description> */ - /* Loads the TrueType table `head' or `bhed'. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_generic_header + * + * @Description: + * Loads the TrueType table `head' or `bhed'. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error tt_face_load_generic_header( TT_Face face, FT_Stream stream, @@ -622,10 +638,10 @@ FT_FRAME_LONG ( Magic_Number ), FT_FRAME_USHORT( Flags ), FT_FRAME_USHORT( Units_Per_EM ), - FT_FRAME_LONG ( Created[0] ), - FT_FRAME_LONG ( Created[1] ), - FT_FRAME_LONG ( Modified[0] ), - FT_FRAME_LONG ( Modified[1] ), + FT_FRAME_ULONG ( Created[0] ), + FT_FRAME_ULONG ( Created[1] ), + FT_FRAME_ULONG ( Modified[0] ), + FT_FRAME_ULONG ( Modified[1] ), FT_FRAME_SHORT ( xMin ), FT_FRAME_SHORT ( yMin ), FT_FRAME_SHORT ( xMax ), @@ -676,22 +692,24 @@ #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_maxp */ - /* */ - /* <Description> */ - /* Loads the maximum profile into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_maxp + * + * @Description: + * Loads the maximum profile into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_maxp( TT_Face face, FT_Stream stream ) @@ -784,22 +802,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_name */ - /* */ - /* <Description> */ - /* Loads the name records. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_name + * + * @Description: + * Loads the name records. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_name( TT_Face face, FT_Stream stream ) @@ -981,17 +1001,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_free_name */ - /* */ - /* <Description> */ - /* Frees the name records. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_free_name + * + * @Description: + * Frees the name records. + * + * @Input: + * face :: + * A handle to the target face object. + */ FT_LOCAL_DEF( void ) tt_face_free_name( TT_Face face ) { @@ -1030,23 +1051,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_cmap */ - /* */ - /* <Description> */ - /* Loads the cmap directory in a face object. The cmaps themselves */ - /* are loaded on demand in the `ttcmap.c' module. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_cmap + * + * @Description: + * Loads the cmap directory in a face object. The cmaps themselves + * are loaded on demand in the `ttcmap.c' module. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_cmap( TT_Face face, @@ -1068,22 +1091,24 @@ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_os2 */ - /* */ - /* <Description> */ - /* Loads the OS2 table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_os2 + * + * @Description: + * Loads the OS2 table. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_os2( TT_Face face, FT_Stream stream ) @@ -1228,22 +1253,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_postscript */ - /* */ - /* <Description> */ - /* Loads the Postscript table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_postscript + * + * @Description: + * Loads the Postscript table. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_post( TT_Face face, FT_Stream stream ) @@ -1288,22 +1315,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_pclt */ - /* */ - /* <Description> */ - /* Loads the PCL 5 Table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_pclt + * + * @Description: + * Loads the PCL 5 Table. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_pclt( TT_Face face, FT_Stream stream ) @@ -1349,22 +1378,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_gasp */ - /* */ - /* <Description> */ - /* Loads the `gasp' table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_gasp + * + * @Description: + * Loads the `gasp' table into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_gasp( TT_Face face, FT_Stream stream ) diff --git a/src/3rdparty/freetype/src/sfnt/ttload.h b/src/3rdparty/freetype/src/sfnt/ttload.h index f94be8b7bd..cc18c18694 100644 --- a/src/3rdparty/freetype/src/sfnt/ttload.h +++ b/src/3rdparty/freetype/src/sfnt/ttload.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttload.h */ -/* */ -/* Load the basic TrueType tables, i.e., tables that can be either in */ -/* TTF or OTF fonts (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttload.h + * + * Load the basic TrueType tables, i.e., tables that can be either in + * TTF or OTF fonts (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTLOAD_H_ diff --git a/src/3rdparty/freetype/src/sfnt/ttmtx.c b/src/3rdparty/freetype/src/sfnt/ttmtx.c index 6ddda95b56..b6725c962f 100644 --- a/src/3rdparty/freetype/src/sfnt/ttmtx.c +++ b/src/3rdparty/freetype/src/sfnt/ttmtx.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttmtx.c */ -/* */ -/* Load the metrics tables common to TTF and OTF fonts (body). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttmtx.c + * + * Load the metrics tables common to TTF and OTF fonts (body). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -38,34 +38,37 @@ /* both the horizontal and vertical headers. */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttmtx - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hmtx */ - /* */ - /* <Description> */ - /* Load the `hmtx' or `vmtx' table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load `vmtx'. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ +#define FT_COMPONENT ttmtx + + + /************************************************************************** + * + * @Function: + * tt_face_load_hmtx + * + * @Description: + * Load the `hmtx' or `vmtx' table into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * vertical :: + * A boolean flag. If set, load `vmtx'. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_hmtx( TT_Face face, FT_Stream stream, @@ -102,24 +105,27 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hhea */ - /* */ - /* <Description> */ - /* Load the `hhea' or 'vhea' table into a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load `vhea'. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_hhea + * + * @Description: + * Load the `hhea' or 'vhea' table into a face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * The input stream. + * + * vertical :: + * A boolean flag. If set, load `vhea'. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_hhea( TT_Face face, FT_Stream stream, @@ -190,30 +196,35 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_get_metrics */ - /* */ - /* <Description> */ - /* Return the horizontal or vertical metrics in font units for a */ - /* given glyph. The values are the left side bearing (top side */ - /* bearing for vertical metrics) and advance width (advance height */ - /* for vertical metrics). */ - /* */ - /* <Input> */ - /* face :: A pointer to the TrueType face structure. */ - /* */ - /* vertical :: If set to TRUE, get vertical metrics. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* abearing :: The bearing, either left side or top side. */ - /* */ - /* aadvance :: The advance width or advance height, depending on */ - /* the `vertical' flag. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_get_metrics + * + * @Description: + * Return the horizontal or vertical metrics in font units for a + * given glyph. The values are the left side bearing (top side + * bearing for vertical metrics) and advance width (advance height + * for vertical metrics). + * + * @Input: + * face :: + * A pointer to the TrueType face structure. + * + * vertical :: + * If set to TRUE, get vertical metrics. + * + * gindex :: + * The glyph index. + * + * @Output: + * abearing :: + * The bearing, either left side or top side. + * + * aadvance :: + * The advance width or advance height, depending on + * the `vertical' flag. + */ FT_LOCAL_DEF( void ) tt_face_get_metrics( TT_Face face, FT_Bool vertical, @@ -269,7 +280,7 @@ else { table_pos += 4 * ( k - 1 ); - if ( table_pos + 4 > table_end ) + if ( table_pos + 2 > table_end ) goto NoData; if ( FT_STREAM_SEEK( table_pos ) || @@ -281,7 +292,9 @@ *abearing = 0; else { - if ( !FT_STREAM_SEEK( table_pos ) ) + if ( FT_STREAM_SEEK( table_pos ) ) + *abearing = 0; + else (void)FT_READ_SHORT( *abearing ); } } diff --git a/src/3rdparty/freetype/src/sfnt/ttmtx.h b/src/3rdparty/freetype/src/sfnt/ttmtx.h index ab00acd795..5b0b60b641 100644 --- a/src/3rdparty/freetype/src/sfnt/ttmtx.h +++ b/src/3rdparty/freetype/src/sfnt/ttmtx.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttmtx.h */ -/* */ -/* Load the metrics tables common to TTF and OTF fonts (specification). */ -/* */ -/* Copyright 2006-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttmtx.h + * + * Load the metrics tables common to TTF and OTF fonts (specification). + * + * Copyright (C) 2006-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTMTX_H_ diff --git a/src/3rdparty/freetype/src/sfnt/ttpost.c b/src/3rdparty/freetype/src/sfnt/ttpost.c index 6de99ef977..636a0a004a 100644 --- a/src/3rdparty/freetype/src/sfnt/ttpost.c +++ b/src/3rdparty/freetype/src/sfnt/ttpost.c @@ -1,28 +1,28 @@ -/***************************************************************************/ -/* */ -/* ttpost.c */ -/* */ -/* PostScript name table processing for TrueType and OpenType fonts */ -/* (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* The post table is not completely loaded by the core engine. This */ - /* file loads the missing PS glyph names and implements an API to access */ - /* them. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ttpost.c + * + * PostScript name table processing for TrueType and OpenType fonts + * (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * The post table is not completely loaded by the core engine. This + * file loads the missing PS glyph names and implements an API to access + * them. + * + */ #include <ft2build.h> @@ -38,17 +38,17 @@ #include "sferrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttpost +#define FT_COMPONENT ttpost - /* If this configuration macro is defined, we rely on the `PSNames' */ + /* If this configuration macro is defined, we rely on the `psnames' */ /* module to grab the glyph names. */ #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES @@ -62,9 +62,9 @@ #else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ - /* Otherwise, we ignore the `PSNames' module, and provide our own */ + /* Otherwise, we ignore the `psnames' module, and provide our own */ /* table of Mac names. Thus, it is possible to build a version of */ - /* FreeType without the Type 1 driver & PSNames module. */ + /* FreeType without the Type 1 driver & psnames module. */ #define MAC_NAME( x ) (FT_String*)tt_post_default_names[x] @@ -459,28 +459,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_get_ps_name */ - /* */ - /* <Description> */ - /* Get the PostScript glyph name of a glyph. */ - /* */ - /* <Input> */ - /* face :: A handle to the parent face. */ - /* */ - /* idx :: The glyph index. */ - /* */ - /* <InOut> */ - /* PSname :: The address of a string pointer. Undefined in case of */ - /* error, otherwise it is a pointer to the glyph name. */ - /* */ - /* You must not modify the returned string! */ - /* */ - /* <Output> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_get_ps_name + * + * @Description: + * Get the PostScript glyph name of a glyph. + * + * @Input: + * face :: + * A handle to the parent face. + * + * idx :: + * The glyph index. + * + * @InOut: + * PSname :: + * The address of a string pointer. Undefined in case of + * error, otherwise it is a pointer to the glyph name. + * + * You must not modify the returned string! + * + * @Output: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_get_ps_name( TT_Face face, FT_UInt idx, diff --git a/src/3rdparty/freetype/src/sfnt/ttpost.h b/src/3rdparty/freetype/src/sfnt/ttpost.h index 3bec07e445..812a0fc92d 100644 --- a/src/3rdparty/freetype/src/sfnt/ttpost.h +++ b/src/3rdparty/freetype/src/sfnt/ttpost.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* ttpost.h */ -/* */ -/* PostScript name table processing for TrueType and OpenType fonts */ -/* (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttpost.h + * + * PostScript name table processing for TrueType and OpenType fonts + * (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTPOST_H_ diff --git a/src/3rdparty/freetype/src/sfnt/ttsbit.c b/src/3rdparty/freetype/src/sfnt/ttsbit.c index 33b8640bc3..23bd9d7eb0 100644 --- a/src/3rdparty/freetype/src/sfnt/ttsbit.c +++ b/src/3rdparty/freetype/src/sfnt/ttsbit.c @@ -1,22 +1,22 @@ -/***************************************************************************/ -/* */ -/* ttsbit.c */ -/* */ -/* TrueType and OpenType embedded bitmap support (body). */ -/* */ -/* Copyright 2005-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* Copyright 2013 by Google, Inc. */ -/* Google Author(s): Behdad Esfahbod. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsbit.c + * + * TrueType and OpenType embedded bitmap support (body). + * + * Copyright (C) 2005-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * Copyright 2013 by Google, Inc. + * Google Author(s): Behdad Esfahbod. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -36,14 +36,14 @@ #include "pngshim.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttsbit +#define FT_COMPONENT ttsbit FT_LOCAL_DEF( FT_Error ) @@ -129,8 +129,8 @@ } /* - * Count the number of strikes available in the table. We are a bit - * paranoid there and don't trust the data. + * Count the number of strikes available in the table. We are a bit + * paranoid there and don't trust the data. */ count = (FT_UInt)num_strikes; if ( 8 + 48UL * count > table_size ) @@ -182,8 +182,8 @@ " expect bad rendering results\n" )); /* - * Count the number of strikes available in the table. We are a bit - * paranoid there and don't trust the data. + * Count the number of strikes available in the table. We are a bit + * paranoid there and don't trust the data. */ count = (FT_UInt)num_strikes; if ( 8 + 4UL * count > table_size ) @@ -1014,8 +1014,8 @@ for ( nn = 0; nn < num_components; nn++ ) { FT_UInt gindex = FT_NEXT_USHORT( p ); - FT_Byte dx = FT_NEXT_BYTE( p ); - FT_Byte dy = FT_NEXT_BYTE( p ); + FT_Char dx = FT_NEXT_CHAR( p ); + FT_Char dy = FT_NEXT_CHAR( p ); /* NB: a recursive call */ diff --git a/src/3rdparty/freetype/src/sfnt/ttsbit.h b/src/3rdparty/freetype/src/sfnt/ttsbit.h index ce2af3c162..5ab8ff5568 100644 --- a/src/3rdparty/freetype/src/sfnt/ttsbit.h +++ b/src/3rdparty/freetype/src/sfnt/ttsbit.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttsbit.h */ -/* */ -/* TrueType and OpenType embedded bitmap support (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsbit.h + * + * TrueType and OpenType embedded bitmap support (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTSBIT_H_ diff --git a/src/3rdparty/freetype/src/smooth/Jamfile b/src/3rdparty/freetype/src/smooth/Jamfile index 9957d5e915..6ca1cede9e 100644 --- a/src/3rdparty/freetype/src/smooth/Jamfile +++ b/src/3rdparty/freetype/src/smooth/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/smooth Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/smooth/ftgrays.c b/src/3rdparty/freetype/src/smooth/ftgrays.c index 803a19e415..fd357a50fc 100644 --- a/src/3rdparty/freetype/src/smooth/ftgrays.c +++ b/src/3rdparty/freetype/src/smooth/ftgrays.c @@ -1,94 +1,102 @@ -/***************************************************************************/ -/* */ -/* ftgrays.c */ -/* */ -/* A new `perfect' anti-aliasing renderer (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* This file can be compiled without the rest of the FreeType engine, by */ - /* defining the STANDALONE_ macro when compiling it. You also need to */ - /* put the files `ftgrays.h' and `ftimage.h' into the current */ - /* compilation directory. Typically, you could do something like */ - /* */ - /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */ - /* */ - /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */ - /* same directory */ - /* */ - /* - compile `ftgrays' with the STANDALONE_ macro defined, as in */ - /* */ - /* cc -c -DSTANDALONE_ ftgrays.c */ - /* */ - /* The renderer can be initialized with a call to */ - /* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */ - /* with a call to `ft_gray_raster.raster_render'. */ - /* */ - /* See the comments and documentation in the file `ftimage.h' for more */ - /* details on how the raster works. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* This is a new anti-aliasing scan-converter for FreeType 2. The */ - /* algorithm used here is _very_ different from the one in the standard */ - /* `ftraster' module. Actually, `ftgrays' computes the _exact_ */ - /* coverage of the outline on each pixel cell. */ - /* */ - /* It is based on ideas that I initially found in Raph Levien's */ - /* excellent LibArt graphics library (see http://www.levien.com/libart */ - /* for more information, though the web pages do not tell anything */ - /* about the renderer; you'll have to dive into the source code to */ - /* understand how it works). */ - /* */ - /* Note, however, that this is a _very_ different implementation */ - /* compared to Raph's. Coverage information is stored in a very */ - /* different way, and I don't use sorted vector paths. Also, it doesn't */ - /* use floating point values. */ - /* */ - /* This renderer has the following advantages: */ - /* */ - /* - It doesn't need an intermediate bitmap. Instead, one can supply a */ - /* callback function that will be called by the renderer to draw gray */ - /* spans on any target surface. You can thus do direct composition on */ - /* any kind of bitmap, provided that you give the renderer the right */ - /* callback. */ - /* */ - /* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */ - /* each pixel cell. */ - /* */ - /* - It performs a single pass on the outline (the `standard' FT2 */ - /* renderer makes two passes). */ - /* */ - /* - It can easily be modified to render to _any_ number of gray levels */ - /* cheaply. */ - /* */ - /* - For small (< 20) pixel sizes, it is faster than the standard */ - /* renderer. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ +/**************************************************************************** + * + * ftgrays.c + * + * A new `perfect' anti-aliasing renderer (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + /************************************************************************** + * + * This file can be compiled without the rest of the FreeType engine, by + * defining the STANDALONE_ macro when compiling it. You also need to + * put the files `ftgrays.h' and `ftimage.h' into the current + * compilation directory. Typically, you could do something like + * + * - copy `src/smooth/ftgrays.c' (this file) to your current directory + * + * - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the + * same directory + * + * - compile `ftgrays' with the STANDALONE_ macro defined, as in + * + * cc -c -DSTANDALONE_ ftgrays.c + * + * The renderer can be initialized with a call to + * `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated + * with a call to `ft_gray_raster.raster_render'. + * + * See the comments and documentation in the file `ftimage.h' for more + * details on how the raster works. + * + */ + + /************************************************************************** + * + * This is a new anti-aliasing scan-converter for FreeType 2. The + * algorithm used here is _very_ different from the one in the standard + * `ftraster' module. Actually, `ftgrays' computes the _exact_ + * coverage of the outline on each pixel cell by straight segments. + * + * It is based on ideas that I initially found in Raph Levien's + * excellent LibArt graphics library (see https://www.levien.com/libart + * for more information, though the web pages do not tell anything + * about the renderer; you'll have to dive into the source code to + * understand how it works). + * + * Note, however, that this is a _very_ different implementation + * compared to Raph's. Coverage information is stored in a very + * different way, and I don't use sorted vector paths. Also, it doesn't + * use floating point values. + * + * Bézier segments are flattened by splitting them until their deviation + * from straight line becomes much smaller than a pixel. Therefore, the + * pixel coverage by a Bézier curve is calculated approximately. To + * estimate the deviation, we use the distance from the control point + * to the conic chord centre or the cubic chord trisection. These + * distances vanish fast after each split. In the conic case, they vanish + * predictably and the number of necessary splits can be calculated. + * + * This renderer has the following advantages: + * + * - It doesn't need an intermediate bitmap. Instead, one can supply a + * callback function that will be called by the renderer to draw gray + * spans on any target surface. You can thus do direct composition on + * any kind of bitmap, provided that you give the renderer the right + * callback. + * + * - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on + * each pixel cell by straight segments. + * + * - It performs a single pass on the outline (the `standard' FT2 + * renderer makes two passes). + * + * - It can easily be modified to render to _any_ number of gray levels + * cheaply. + * + * - For small (< 80) pixel sizes, it is faster than the standard + * renderer. + * + */ + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_smooth +#define FT_COMPONENT smooth #ifdef STANDALONE_ @@ -112,9 +120,9 @@ /* - * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' - * algorithm. We use alpha = 1, beta = 3/8, giving us results with a - * largest error less than 7% compared to the exact value. + * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' + * algorithm. We use alpha = 1, beta = 3/8, giving us results with a + * largest error less than 7% compared to the exact value. */ #define FT_HYPOT( x, y ) \ ( x = FT_ABS( x ), \ @@ -222,10 +230,10 @@ typedef ptrdiff_t FT_PtrDist; #endif #define FT_THROW( e ) \ - ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \ + ( FT_Throw( FT_ERR_CAT( ErrRaster_, e ), \ __LINE__, \ __FILE__ ) | \ - FT_ERR_CAT( ErrRaster, e ) ) + FT_ERR_CAT( ErrRaster_, e ) ) #else /* !FT_DEBUG_LEVEL_TRACE */ @@ -279,8 +287,6 @@ typedef ptrdiff_t FT_PtrDist; #include "ftsmerrs.h" -#include "ftspic.h" - #define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph #define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory @@ -329,17 +335,9 @@ typedef ptrdiff_t FT_PtrDist; /* must be at least 6 bits! */ #define PIXEL_BITS 8 -#undef FLOOR -#undef CEILING -#undef TRUNC -#undef SCALED - #define ONE_PIXEL ( 1 << PIXEL_BITS ) -#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) -#define SUBPIXELS( x ) ( (TPos)(x) * ONE_PIXEL ) -#define FLOOR( x ) ( (x) & -ONE_PIXEL ) -#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) -#define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) +#define TRUNC( x ) (TCoord)( (x) >> PIXEL_BITS ) +#define FRACT( x ) (TCoord)( (x) & ( ONE_PIXEL - 1 ) ) #if PIXEL_BITS >= 6 #define UPSCALE( x ) ( (x) * ( ONE_PIXEL >> 6 ) ) @@ -390,15 +388,15 @@ typedef ptrdiff_t FT_PtrDist; #define FT_UDIVPREP( c, b ) \ long b ## _r = c ? (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) \ : 0 -#define FT_UDIV( a, b ) \ - ( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \ - ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) ) +#define FT_UDIV( a, b ) \ + (TCoord)( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \ + ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) ) - /*************************************************************************/ - /* */ - /* TYPE DEFINITIONS */ - /* */ + /************************************************************************** + * + * TYPE DEFINITIONS + */ /* don't change the following types to FT_Int or FT_Pos, since we might */ /* need to define them to "float" or "double" when experimenting with */ @@ -434,6 +432,9 @@ typedef ptrdiff_t FT_PtrDist; #define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) ) #endif + /* FT_Span buffer size for direct rendering only */ +#define FT_MAX_GRAY_SPANS 10 + #if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ /* We disable the warning `structure was padded due to */ @@ -467,6 +468,8 @@ typedef ptrdiff_t FT_PtrDist; FT_Raster_Span_Func render_span; void* render_span_data; + FT_Span spans[FT_MAX_GRAY_SPANS]; + int num_spans; } gray_TWorker, *gray_PWorker; @@ -516,10 +519,10 @@ typedef ptrdiff_t FT_PtrDist; #endif /* FT_DEBUG_LEVEL_TRACE */ - /*************************************************************************/ - /* */ - /* Record the current cell in the table. */ - /* */ + /************************************************************************** + * + * Record the current cell in the linked list. + */ static void gray_record_cell( RAS_ARG ) { @@ -528,10 +531,9 @@ typedef ptrdiff_t FT_PtrDist; pcell = &ras.ycells[ras.ey - ras.min_ey]; - for (;;) + while ( ( cell = *pcell ) ) { - cell = *pcell; - if ( !cell || cell->x > x ) + if ( cell->x > x ) break; if ( cell->x == x ) @@ -561,10 +563,10 @@ typedef ptrdiff_t FT_PtrDist; } - /*************************************************************************/ - /* */ - /* Set the current cell to a new position. */ - /* */ + /************************************************************************** + * + * Set the current cell to a new position. + */ static void gray_set_cell( RAS_ARG_ TCoord ex, TCoord ey ) @@ -579,16 +581,13 @@ typedef ptrdiff_t FT_PtrDist; /* Note that if a cell is to the left of the clipping region, it is */ /* actually set to the (min_ex-1) horizontal position. */ - if ( ex < ras.min_ex ) - ex = ras.min_ex - 1; - /* record the current one if it is valid and substantial */ if ( !ras.invalid && ( ras.area || ras.cover ) ) gray_record_cell( RAS_VAR ); ras.area = 0; ras.cover = 0; - ras.ex = ex; + ras.ex = FT_MAX( ex, ras.min_ex - 1 ); ras.ey = ey; ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey || @@ -598,10 +597,10 @@ typedef ptrdiff_t FT_PtrDist; #ifndef FT_LONG64 - /*************************************************************************/ - /* */ - /* Render a scanline as one or more cells. */ - /* */ + /************************************************************************** + * + * Render a scanline as one or more cells. + */ static void gray_render_scanline( RAS_ARG_ TCoord ey, TPos x1, @@ -624,8 +623,8 @@ typedef ptrdiff_t FT_PtrDist; return; } - fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); - fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); + fx1 = FRACT( x1 ); + fx2 = FRACT( x2 ); /* everything is located in a single cell. That is easy! */ /* */ @@ -652,6 +651,9 @@ typedef ptrdiff_t FT_PtrDist; dx = -dx; } + /* the fractional part of y-delta is mod/dx. It is essential to */ + /* keep track of its accumulation for accurate rendering. */ + /* XXX: y-delta and x-delta below should be related. */ FT_DIV_MOD( TCoord, p, dx, delta, mod ); ras.area += (TArea)( ( fx1 + first ) * delta ); @@ -696,10 +698,10 @@ typedef ptrdiff_t FT_PtrDist; } - /*************************************************************************/ - /* */ - /* Render a given line as a series of scanlines. */ - /* */ + /************************************************************************** + * + * Render a given line as a series of scanlines. + */ static void gray_render_line( RAS_ARG_ TPos to_x, TPos to_y ) @@ -717,8 +719,8 @@ typedef ptrdiff_t FT_PtrDist; ( ey1 < ras.min_ey && ey2 < ras.min_ey ) ) goto End; - fy1 = (TCoord)( ras.y - SUBPIXELS( ey1 ) ); - fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) ); + fy1 = FRACT( ras.y ); + fy2 = FRACT( to_y ); /* everything is on a single scanline */ if ( ey1 == ey2 ) @@ -734,7 +736,7 @@ typedef ptrdiff_t FT_PtrDist; if ( dx == 0 ) { TCoord ex = TRUNC( ras.x ); - TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 ); + TCoord two_fx = FRACT( ras.x ) << 1; TArea area; @@ -789,6 +791,8 @@ typedef ptrdiff_t FT_PtrDist; dy = -dy; } + /* the fractional part of x-delta is mod/dy. It is essential to */ + /* keep track of its accumulation for accurate rendering. */ FT_DIV_MOD( TCoord, p, dy, delta, mod ); x = ras.x + delta; @@ -837,16 +841,17 @@ typedef ptrdiff_t FT_PtrDist; #else - /*************************************************************************/ - /* */ - /* Render a straight line across multiple cells in any direction. */ - /* */ + /************************************************************************** + * + * Render a straight line across multiple cells in any direction. + */ static void gray_render_line( RAS_ARG_ TPos to_x, TPos to_y ) { - TPos dx, dy, fx1, fy1, fx2, fy2; - TCoord ex1, ex2, ey1, ey2; + TPos dx, dy; + TCoord fx1, fy1, fx2, fy2; + TCoord ex1, ey1, ex2, ey2; ey1 = TRUNC( ras.y ); @@ -860,8 +865,8 @@ typedef ptrdiff_t FT_PtrDist; ex1 = TRUNC( ras.x ); ex2 = TRUNC( to_x ); - fx1 = ras.x - SUBPIXELS( ex1 ); - fy1 = ras.y - SUBPIXELS( ey1 ); + fx1 = FRACT( ras.x ); + fy1 = FRACT( ras.y ); dx = to_x - ras.x; dy = to_y - ras.y; @@ -870,8 +875,8 @@ typedef ptrdiff_t FT_PtrDist; ; else if ( dy == 0 ) /* ex1 != ex2 */ /* any horizontal line */ { - ex1 = ex2; - gray_set_cell( RAS_VAR_ ex1, ey1 ); + gray_set_cell( RAS_VAR_ ex2, ey2 ); + goto End; } else if ( dx == 0 ) { @@ -898,7 +903,7 @@ typedef ptrdiff_t FT_PtrDist; } else /* any other line */ { - TPos prod = dx * fy1 - dy * fx1; + TPos prod = dx * (TPos)fy1 - dy * (TPos)fx1; FT_UDIVPREP( ex1 != ex2, dx ); FT_UDIVPREP( ey1 != ey2, dy ); @@ -912,7 +917,7 @@ typedef ptrdiff_t FT_PtrDist; prod - dx * ONE_PIXEL > 0 ) /* left */ { fx2 = 0; - fy2 = (TPos)FT_UDIV( -prod, -dx ); + fy2 = FT_UDIV( -prod, -dx ); prod -= dy * ONE_PIXEL; ras.cover += ( fy2 - fy1 ); ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 ); @@ -924,7 +929,7 @@ typedef ptrdiff_t FT_PtrDist; prod - dx * ONE_PIXEL + dy * ONE_PIXEL > 0 ) /* up */ { prod -= dx * ONE_PIXEL; - fx2 = (TPos)FT_UDIV( -prod, dy ); + fx2 = FT_UDIV( -prod, dy ); fy2 = ONE_PIXEL; ras.cover += ( fy2 - fy1 ); ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 ); @@ -937,7 +942,7 @@ typedef ptrdiff_t FT_PtrDist; { prod += dy * ONE_PIXEL; fx2 = ONE_PIXEL; - fy2 = (TPos)FT_UDIV( prod, dx ); + fy2 = FT_UDIV( prod, dx ); ras.cover += ( fy2 - fy1 ); ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 ); fx1 = 0; @@ -947,7 +952,7 @@ typedef ptrdiff_t FT_PtrDist; else /* ( prod + dy * ONE_PIXEL < 0 && prod > 0 ) down */ { - fx2 = (TPos)FT_UDIV( prod, -dy ); + fx2 = FT_UDIV( prod, -dy ); fy2 = 0; prod += dx * ONE_PIXEL; ras.cover += ( fy2 - fy1 ); @@ -961,8 +966,8 @@ typedef ptrdiff_t FT_PtrDist; } while ( ex1 != ex2 || ey1 != ey2 ); } - fx2 = to_x - SUBPIXELS( ex2 ); - fy2 = to_y - SUBPIXELS( ey2 ); + fx2 = FRACT( to_x ); + fy2 = FRACT( to_y ); ras.cover += ( fy2 - fy1 ); ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 ); @@ -981,16 +986,18 @@ typedef ptrdiff_t FT_PtrDist; base[4].x = base[2].x; - b = base[1].x; - a = base[3].x = ( base[2].x + b ) / 2; - b = base[1].x = ( base[0].x + b ) / 2; - base[2].x = ( a + b ) / 2; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + base[3].x = b >> 1; + base[2].x = ( a + b ) >> 2; + base[1].x = a >> 1; base[4].y = base[2].y; - b = base[1].y; - a = base[3].y = ( base[2].y + b ) / 2; - b = base[1].y = ( base[0].y + b ) / 2; - base[2].y = ( a + b ) / 2; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + base[3].y = b >> 1; + base[2].y = ( a + b ) >> 2; + base[1].y = a >> 1; } @@ -1044,12 +1051,11 @@ typedef ptrdiff_t FT_PtrDist; /* many times as there are trailing zeros in the counter. */ do { - split = 1; - while ( ( draw & split ) == 0 ) + split = draw & ( -draw ); /* isolate the rightmost 1-bit */ + while ( ( split >>= 1 ) ) { gray_split_conic( arc ); arc += 2; - split <<= 1; } gray_render_line( RAS_VAR_ arc[0].x, arc[0].y ); @@ -1062,28 +1068,32 @@ typedef ptrdiff_t FT_PtrDist; static void gray_split_cubic( FT_Vector* base ) { - TPos a, b, c, d; + TPos a, b, c; base[6].x = base[3].x; - c = base[1].x; - d = base[2].x; - base[1].x = a = ( base[0].x + c ) / 2; - base[5].x = b = ( base[3].x + d ) / 2; - c = ( c + d ) / 2; - base[2].x = a = ( a + c ) / 2; - base[4].x = b = ( b + c ) / 2; - base[3].x = ( a + b ) / 2; + a = base[0].x + base[1].x; + b = base[1].x + base[2].x; + c = base[2].x + base[3].x; + base[5].x = c >> 1; + c += b; + base[4].x = c >> 2; + base[1].x = a >> 1; + a += b; + base[2].x = a >> 2; + base[3].x = ( a + c ) >> 3; base[6].y = base[3].y; - c = base[1].y; - d = base[2].y; - base[1].y = a = ( base[0].y + c ) / 2; - base[5].y = b = ( base[3].y + d ) / 2; - c = ( c + d ) / 2; - base[2].y = a = ( a + c ) / 2; - base[4].y = b = ( b + c ) / 2; - base[3].y = ( a + b ) / 2; + a = base[0].y + base[1].y; + b = base[1].y + base[2].y; + c = base[2].y + base[3].y; + base[5].y = c >> 1; + c += b; + base[4].y = c >> 2; + base[1].y = a >> 1; + a += b; + base[2].y = a >> 2; + base[3].y = ( a + c ) >> 3; } @@ -1094,9 +1104,6 @@ typedef ptrdiff_t FT_PtrDist; { FT_Vector bez_stack[16 * 3 + 1]; /* enough to accommodate bisections */ FT_Vector* arc = bez_stack; - TPos dx, dy, dx_, dy_; - TPos dx1, dy1, dx2, dy2; - TPos L, s, s_limit; arc[0].x = UPSCALE( to->x ); @@ -1125,45 +1132,13 @@ typedef ptrdiff_t FT_PtrDist; for (;;) { - /* Decide whether to split or draw. See `Rapid Termination */ - /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */ - /* F. Hain, at */ - /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camera-ready%20CISST02%202.pdf */ - - /* dx and dy are x and y components of the P0-P3 chord vector. */ - dx = dx_ = arc[3].x - arc[0].x; - dy = dy_ = arc[3].y - arc[0].y; - - L = FT_HYPOT( dx_, dy_ ); - - /* Avoid possible arithmetic overflow below by splitting. */ - if ( L > 32767 ) - goto Split; - - /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */ - s_limit = L * (TPos)( ONE_PIXEL / 6 ); - - /* s is L * the perpendicular distance from P1 to the line P0-P3. */ - dx1 = arc[1].x - arc[0].x; - dy1 = arc[1].y - arc[0].y; - s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx1 ), MUL_LONG( dx, dy1 ) ) ); - - if ( s > s_limit ) - goto Split; - - /* s is L * the perpendicular distance from P2 to the line P0-P3. */ - dx2 = arc[2].x - arc[0].x; - dy2 = arc[2].y - arc[0].y; - s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx2 ), MUL_LONG( dx, dy2 ) ) ); - - if ( s > s_limit ) - goto Split; - - /* Split super curvy segments where the off points are so far - from the chord that the angles P0-P1-P3 or P0-P2-P3 become - acute as detected by appropriate dot products. */ - if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 || - dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 ) + /* with each split, control points quickly converge towards */ + /* chord trisection points and the vanishing distances below */ + /* indicate when the segment is flat enough to draw */ + if ( FT_ABS( 2 * arc[0].x - 3 * arc[1].x + arc[3].x ) > ONE_PIXEL / 2 || + FT_ABS( 2 * arc[0].y - 3 * arc[1].y + arc[3].y ) > ONE_PIXEL / 2 || + FT_ABS( arc[0].x - 3 * arc[2].x + 2 * arc[3].x ) > ONE_PIXEL / 2 || + FT_ABS( arc[0].y - 3 * arc[2].y + 2 * arc[3].y ) > ONE_PIXEL / 2 ) goto Split; gray_render_line( RAS_VAR_ arc[0].x, arc[0].y ); @@ -1238,8 +1213,6 @@ typedef ptrdiff_t FT_PtrDist; { /* scale the coverage from 0..(ONE_PIXEL*ONE_PIXEL*2) to 0..256 */ coverage >>= PIXEL_BITS * 2 + 1 - 8; - if ( coverage < 0 ) - coverage = -coverage - 1; /* compute the line's coverage depending on the outline fill rule */ if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL ) @@ -1249,23 +1222,30 @@ typedef ptrdiff_t FT_PtrDist; if ( coverage >= 256 ) coverage = 511 - coverage; } - else + else /* default non-zero winding rule */ { - /* normal non-zero winding rule */ + if ( coverage < 0 ) + coverage = ~coverage; /* the same as -coverage - 1 */ + if ( coverage >= 256 ) coverage = 255; } - if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */ + if ( ras.num_spans >= 0 ) /* for FT_RASTER_FLAG_DIRECT only */ { - FT_Span span; + FT_Span* span = ras.spans + ras.num_spans++; - span.x = (short)x; - span.len = (unsigned short)acount; - span.coverage = (unsigned char)coverage; + span->x = (short)x; + span->len = (unsigned short)acount; + span->coverage = (unsigned char)coverage; - ras.render_span( y, 1, &span, ras.render_span_data ); + if ( ras.num_spans == FT_MAX_GRAY_SPANS ) + { + /* flush the span buffer and reset the count */ + ras.render_span( y, ras.num_spans, ras.spans, ras.render_span_data ); + ras.num_spans = 0; + } } else { @@ -1279,14 +1259,29 @@ typedef ptrdiff_t FT_PtrDist; */ switch ( acount ) { - case 7: *q++ = c; - case 6: *q++ = c; - case 5: *q++ = c; - case 4: *q++ = c; - case 3: *q++ = c; - case 2: *q++ = c; - case 1: *q = c; - case 0: break; + case 7: + *q++ = c; + /* fall through */ + case 6: + *q++ = c; + /* fall through */ + case 5: + *q++ = c; + /* fall through */ + case 4: + *q++ = c; + /* fall through */ + case 3: + *q++ = c; + /* fall through */ + case 2: + *q++ = c; + /* fall through */ + case 1: + *q = c; + /* fall through */ + case 0: + break; default: FT_MEM_SET( q, c, acount ); } @@ -1324,53 +1319,63 @@ typedef ptrdiff_t FT_PtrDist; if ( cover != 0 ) gray_hline( RAS_VAR_ x, y, cover, ras.max_ex - x ); + + if ( ras.num_spans > 0 ) /* for FT_RASTER_FLAG_DIRECT only */ + { + /* flush the span buffer and reset the count */ + ras.render_span( y, ras.num_spans, ras.spans, ras.render_span_data ); + ras.num_spans = 0; + } } } #ifdef STANDALONE_ - /*************************************************************************/ - /* */ - /* The following functions should only compile in stand-alone mode, */ - /* i.e., when building this component without the rest of FreeType. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Decompose */ - /* */ - /* <Description> */ - /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bézier arcs. This function is also able to emit */ - /* `move to' and `close to' operations to indicate the start and end */ - /* of new contours in the outline. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source target. */ - /* */ - /* func_interface :: A table of `emitters', i.e., function pointers */ - /* called during decomposition to indicate path */ - /* operations. */ - /* */ - /* <InOut> */ - /* user :: A typeless pointer which is passed to each */ - /* emitter during the decomposition. It can be */ - /* used to store the state during the */ - /* decomposition. */ - /* */ - /* <Return> */ - /* Error code. 0 means success. */ - /* */ + /************************************************************************** + * + * The following functions should only compile in stand-alone mode, + * i.e., when building this component without the rest of FreeType. + * + */ + + /************************************************************************** + * + * @Function: + * FT_Outline_Decompose + * + * @Description: + * Walk over an outline's structure to decompose it into individual + * segments and Bézier arcs. This function is also able to emit + * `move to' and `close to' operations to indicate the start and end + * of new contours in the outline. + * + * @Input: + * outline :: + * A pointer to the source target. + * + * func_interface :: + * A table of `emitters', i.e., function pointers + * called during decomposition to indicate path + * operations. + * + * @InOut: + * user :: + * A typeless pointer which is passed to each + * emitter during the decomposition. It can be + * used to store the state during the + * decomposition. + * + * @Return: + * Error code. 0 means success. + */ static int FT_Outline_Decompose( const FT_Outline* outline, const FT_Outline_Funcs* func_interface, void* user ) { #undef SCALED -#define SCALED( x ) ( ( (x) << shift ) - delta ) +#define SCALED( x ) ( (x) * ( 1L << shift ) - delta ) FT_Vector v_last; FT_Vector v_control; @@ -1610,81 +1615,6 @@ typedef ptrdiff_t FT_PtrDist; return FT_THROW( Invalid_Outline ); } - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_CBox */ - /* */ - /* <Description> */ - /* Return an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bézier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bézier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <Output> */ - /* acbox :: The outline's control box. */ - /* */ - /* <Note> */ - /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ - /* */ - - static void - FT_Outline_Get_CBox( const FT_Outline* outline, - FT_BBox *acbox ) - { - TPos xMin, yMin, xMax, yMax; - - - if ( outline && acbox ) - { - if ( outline->n_points == 0 ) - { - xMin = 0; - yMin = 0; - xMax = 0; - yMax = 0; - } - else - { - FT_Vector* vec = outline->points; - FT_Vector* limit = vec + outline->n_points; - - - xMin = xMax = vec->x; - yMin = yMax = vec->y; - vec++; - - for ( ; vec < limit; vec++ ) - { - TPos x, y; - - - x = vec->x; - if ( x < xMin ) xMin = x; - if ( x > xMax ) xMax = x; - - y = vec->y; - if ( y < yMin ) yMin = y; - if ( y > yMax ) yMax = y; - } - } - acbox->xMin = xMin; - acbox->xMax = xMax; - acbox->yMin = yMin; - acbox->yMax = yMax; - } - } - #endif /* STANDALONE_ */ @@ -1702,19 +1632,20 @@ typedef ptrdiff_t FT_PtrDist; static int - gray_convert_glyph_inner( RAS_ARG ) + gray_convert_glyph_inner( RAS_ARG, + int continued ) { + int error; - volatile int error = 0; - -#ifdef FT_CONFIG_OPTION_PIC - FT_Outline_Funcs func_interface; - Init_Class_func_interface(&func_interface); -#endif if ( ft_setjmp( ras.jump_buffer ) == 0 ) { + if ( continued ) + FT_Trace_Disable(); error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); + if ( continued ) + FT_Trace_Enable(); + if ( !ras.invalid ) gray_record_cell( RAS_VAR ); @@ -1741,8 +1672,6 @@ typedef ptrdiff_t FT_PtrDist; { const TCoord yMin = ras.min_ey; const TCoord yMax = ras.max_ey; - const TCoord xMin = ras.min_ex; - const TCoord xMax = ras.max_ex; TCell buffer[FT_MAX_GRAY_POOL]; size_t height = (size_t)( yMax - yMin ); @@ -1751,6 +1680,8 @@ typedef ptrdiff_t FT_PtrDist; TCoord bands[32]; /* enough to accommodate bisections */ TCoord* band; + int continued = 0; + /* set up vertical bands */ if ( height > n ) @@ -1774,8 +1705,8 @@ typedef ptrdiff_t FT_PtrDist; ras.max_ey = FT_MIN( y, yMax ); band = bands; - band[1] = xMin; - band[0] = xMax; + band[1] = ras.min_ey; + band[0] = ras.max_ey; do { @@ -1787,10 +1718,11 @@ typedef ptrdiff_t FT_PtrDist; ras.num_cells = 0; ras.invalid = 1; - ras.min_ex = band[1]; - ras.max_ex = band[0]; + ras.min_ey = band[1]; + ras.max_ey = band[0]; - error = gray_convert_glyph_inner( RAS_VAR ); + error = gray_convert_glyph_inner( RAS_VAR, continued ); + continued = 1; if ( !error ) { @@ -1827,7 +1759,6 @@ typedef ptrdiff_t FT_PtrDist; { const FT_Outline* outline = (const FT_Outline*)params->source; const FT_Bitmap* target_map = params->target; - FT_BBox cbox, clip; #ifndef FT_STATIC_RASTER gray_TWorker worker[1]; @@ -1864,6 +1795,12 @@ typedef ptrdiff_t FT_PtrDist; ras.render_span = (FT_Raster_Span_Func)params->gray_spans; ras.render_span_data = params->user; + ras.num_spans = 0; + + ras.min_ex = params->clip_box.xMin; + ras.min_ey = params->clip_box.yMin; + ras.max_ex = params->clip_box.xMax; + ras.max_ey = params->clip_box.yMax; } else { @@ -1888,46 +1825,15 @@ typedef ptrdiff_t FT_PtrDist; ras.render_span = (FT_Raster_Span_Func)NULL; ras.render_span_data = NULL; - } - - FT_Outline_Get_CBox( outline, &cbox ); - - /* reject too large outline coordinates */ - if ( cbox.xMin < -0x1000000L || cbox.xMax > 0x1000000L || - cbox.yMin < -0x1000000L || cbox.yMax > 0x1000000L ) - return FT_THROW( Invalid_Outline ); - - /* truncate the bounding box to integer pixels */ - cbox.xMin = cbox.xMin >> 6; - cbox.yMin = cbox.yMin >> 6; - cbox.xMax = ( cbox.xMax + 63 ) >> 6; - cbox.yMax = ( cbox.yMax + 63 ) >> 6; + ras.num_spans = -1; /* invalid */ - /* compute clipping box */ - if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) - { - /* compute clip box from target pixmap */ - clip.xMin = 0; - clip.yMin = 0; - clip.xMax = (FT_Pos)target_map->width; - clip.yMax = (FT_Pos)target_map->rows; + ras.min_ex = 0; + ras.min_ey = 0; + ras.max_ex = (FT_Pos)target_map->width; + ras.max_ey = (FT_Pos)target_map->rows; } - else if ( params->flags & FT_RASTER_FLAG_CLIP ) - clip = params->clip_box; - else - { - clip.xMin = -32768L; - clip.yMin = -32768L; - clip.xMax = 32767L; - clip.yMax = 32767L; - } - - /* clip to target bitmap, exit if nothing to do */ - ras.min_ex = FT_MAX( cbox.xMin, clip.xMin ); - ras.min_ey = FT_MAX( cbox.yMin, clip.yMin ); - ras.max_ex = FT_MIN( cbox.xMax, clip.xMax ); - ras.max_ey = FT_MIN( cbox.yMax, clip.yMax ); + /* exit if nothing to do */ if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey ) return 0; diff --git a/src/3rdparty/freetype/src/smooth/ftgrays.h b/src/3rdparty/freetype/src/smooth/ftgrays.h index 9e11ca675e..e9f9c7a4ad 100644 --- a/src/3rdparty/freetype/src/smooth/ftgrays.h +++ b/src/3rdparty/freetype/src/smooth/ftgrays.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftgrays.h */ -/* */ -/* FreeType smooth renderer declaration */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftgrays.h + * + * FreeType smooth renderer declaration + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTGRAYS_H_ @@ -28,19 +28,18 @@ #include "ftimage.h" #else #include <ft2build.h> -#include FT_CONFIG_CONFIG_H /* for FT_CONFIG_OPTION_PIC */ #include FT_IMAGE_H #endif - /*************************************************************************/ - /* */ - /* To make ftgrays.h independent from configuration files we check */ - /* whether FT_EXPORT_VAR has been defined already. */ - /* */ - /* On some systems and compilers (Win32 mostly), an extra keyword is */ - /* necessary to compile the library as a DLL. */ - /* */ + /************************************************************************** + * + * To make ftgrays.h independent from configuration files we check + * whether FT_EXPORT_VAR has been defined already. + * + * On some systems and compilers (Win32 mostly), an extra keyword is + * necessary to compile the library as a DLL. + */ #ifndef FT_EXPORT_VAR #define FT_EXPORT_VAR( x ) extern x #endif diff --git a/src/3rdparty/freetype/src/smooth/ftsmerrs.h b/src/3rdparty/freetype/src/smooth/ftsmerrs.h index 226dc1b001..d52c0dd9e2 100644 --- a/src/3rdparty/freetype/src/smooth/ftsmerrs.h +++ b/src/3rdparty/freetype/src/smooth/ftsmerrs.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* ftsmerrs.h */ -/* */ -/* smooth renderer error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the smooth renderer error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ftsmerrs.h + * + * smooth renderer error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the smooth renderer error enumeration + * constants. + * + */ #ifndef FTSMERRS_H_ #define FTSMERRS_H_ diff --git a/src/3rdparty/freetype/src/smooth/ftsmooth.c b/src/3rdparty/freetype/src/smooth/ftsmooth.c index ef176bdf1e..cd034d2b40 100644 --- a/src/3rdparty/freetype/src/smooth/ftsmooth.c +++ b/src/3rdparty/freetype/src/smooth/ftsmooth.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsmooth.c */ -/* */ -/* Anti-aliasing renderer interface (body). */ -/* */ -/* Copyright 2000-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsmooth.c + * + * Anti-aliasing renderer interface (body). + * + * Copyright (C) 2000-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -22,7 +22,6 @@ #include FT_OUTLINE_H #include "ftsmooth.h" #include "ftgrays.h" -#include "ftspic.h" #include "ftsmerrs.h" @@ -31,6 +30,26 @@ static FT_Error ft_smooth_init( FT_Renderer render ) { + +#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + + FT_Vector* sub = render->root.library->lcd_geometry; + + + /* set up default subpixel geometry for striped RGB panels. */ + sub[0].x = -21; + sub[0].y = 0; + sub[1].x = 0; + sub[1].y = 0; + sub[2].x = 21; + sub[2].y = 0; + +#elif 0 /* or else, once ClearType patents expire */ + + FT_Library_SetLcdFilter( render->root.library, FT_LCD_FILTER_DEFAULT ); + +#endif + render->clazz->raster_class->raster_reset( render->raster, NULL, 0 ); return 0; @@ -130,7 +149,11 @@ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } - ft_glyphslot_preset_bitmap( slot, mode, origin ); + if ( ft_glyphslot_preset_bitmap( slot, mode, origin ) ) + { + error = FT_THROW( Raster_Overflow ); + goto Exit; + } /* allocate new one */ if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, bitmap->pitch ) ) @@ -220,7 +243,7 @@ } if ( lcd_filter_func ) - lcd_filter_func( bitmap, mode, lcd_weights ); + lcd_filter_func( bitmap, lcd_weights ); } #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ @@ -235,33 +258,40 @@ unsigned int width = bitmap->width; int pitch = bitmap->pitch; + FT_Vector* sub = slot->library->lcd_geometry; - /* Render 3 separate monochrome bitmaps, shifting the outline */ - /* by 1/3 pixel. */ - width /= 3; - bitmap->buffer += width; + /* Render 3 separate monochrome bitmaps, shifting the outline. */ + width /= 3; + FT_Outline_Translate( outline, + -sub[0].x, + -sub[0].y ); error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, -21, 0 ); - x_shift -= 21; bitmap->buffer += width; - + FT_Outline_Translate( outline, + sub[0].x - sub[1].x, + sub[0].y - sub[1].y ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= width; if ( error ) goto Exit; - FT_Outline_Translate( outline, 42, 0 ); - x_shift += 42; - bitmap->buffer -= 2 * width; - + bitmap->buffer += 2 * width; + FT_Outline_Translate( outline, + sub[1].x - sub[2].x, + sub[1].y - sub[2].y ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= 2 * width; if ( error ) goto Exit; + x_shift -= sub[2].x; + y_shift -= sub[2].y; + /* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */ /* XXX: It is more efficient to render every third byte above. */ @@ -286,34 +316,43 @@ { int pitch = bitmap->pitch; + FT_Vector* sub = slot->library->lcd_geometry; + - /* Render 3 separate monochrome bitmaps, shifting the outline */ - /* by 1/3 pixel. Triple the pitch to render on each third row. */ + /* Render 3 separate monochrome bitmaps, shifting the outline. */ + /* Notice that the subpixel geometry vectors are rotated. */ + /* Triple the pitch to render on each third row. */ bitmap->pitch *= 3; bitmap->rows /= 3; - bitmap->buffer += pitch; - + FT_Outline_Translate( outline, + -sub[0].y, + sub[0].x ); error = render->raster_render( render->raster, ¶ms ); if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, 21 ); - y_shift += 21; bitmap->buffer += pitch; - + FT_Outline_Translate( outline, + sub[0].y - sub[1].y, + sub[1].x - sub[0].x ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= pitch; if ( error ) goto Exit; - FT_Outline_Translate( outline, 0, -42 ); - y_shift -= 42; - bitmap->buffer -= 2 * pitch; - + bitmap->buffer += 2 * pitch; + FT_Outline_Translate( outline, + sub[1].y - sub[2].y, + sub[2].x - sub[1].x ); error = render->raster_render( render->raster, ¶ms ); + bitmap->buffer -= 2 * pitch; if ( error ) goto Exit; + x_shift -= sub[2].y; + y_shift += sub[2].x; + bitmap->pitch /= 3; bitmap->rows *= 3; } @@ -403,7 +442,7 @@ (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */ ) @@ -430,7 +469,7 @@ (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */ ) @@ -457,7 +496,7 @@ (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, /* get_glyph_cbox */ (FT_Renderer_SetModeFunc) ft_smooth_set_mode, /* set_mode */ - (FT_Raster_Funcs*)&FT_GRAYS_RASTER_GET /* raster_class */ + (FT_Raster_Funcs*)&ft_grays_raster /* raster_class */ ) diff --git a/src/3rdparty/freetype/src/smooth/ftsmooth.h b/src/3rdparty/freetype/src/smooth/ftsmooth.h index c76ffc5034..fbb21a31d0 100644 --- a/src/3rdparty/freetype/src/smooth/ftsmooth.h +++ b/src/3rdparty/freetype/src/smooth/ftsmooth.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ftsmooth.h */ -/* */ -/* Anti-aliasing renderer interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsmooth.h + * + * Anti-aliasing renderer interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef FTSMOOTH_H_ diff --git a/src/3rdparty/freetype/src/smooth/module.mk b/src/3rdparty/freetype/src/smooth/module.mk index 5b8bc3be3b..44b76dfec6 100644 --- a/src/3rdparty/freetype/src/smooth/module.mk +++ b/src/3rdparty/freetype/src/smooth/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/smooth/rules.mk b/src/3rdparty/freetype/src/smooth/rules.mk index f30824a367..0153ac24a4 100644 --- a/src/3rdparty/freetype/src/smooth/rules.mk +++ b/src/3rdparty/freetype/src/smooth/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -29,8 +29,7 @@ SMOOTH_COMPILE := $(CC) $(ANSIFLAGS) \ # smooth driver sources (i.e., C files) # SMOOTH_DRV_SRC := $(SMOOTH_DIR)/ftgrays.c \ - $(SMOOTH_DIR)/ftsmooth.c \ - $(SMOOTH_DIR)/ftspic.c + $(SMOOTH_DIR)/ftsmooth.c # smooth driver headers diff --git a/src/3rdparty/freetype/src/smooth/smooth.c b/src/3rdparty/freetype/src/smooth/smooth.c index 5249a8931e..9c543d3360 100644 --- a/src/3rdparty/freetype/src/smooth/smooth.c +++ b/src/3rdparty/freetype/src/smooth/smooth.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* smooth.c */ -/* */ -/* FreeType anti-aliasing rasterer module component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * smooth.c + * + * FreeType anti-aliasing rasterer module component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -21,7 +21,6 @@ #include "ftgrays.c" #include "ftsmooth.c" -#include "ftspic.c" /* END */ diff --git a/src/3rdparty/freetype/src/tools/afblue.pl b/src/3rdparty/freetype/src/tools/afblue.pl index 7c6f1a7df1..937d4ecf6e 100644 --- a/src/3rdparty/freetype/src/tools/afblue.pl +++ b/src/3rdparty/freetype/src/tools/afblue.pl @@ -5,7 +5,7 @@ # # Process a blue zone character data file. # -# Copyright 2013-2018 by +# Copyright (C) 2013-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, diff --git a/src/3rdparty/freetype/src/tools/apinames.c b/src/3rdparty/freetype/src/tools/apinames.c index 06c3260430..aeecf88d22 100644 --- a/src/3rdparty/freetype/src/tools/apinames.c +++ b/src/3rdparty/freetype/src/tools/apinames.c @@ -10,7 +10,7 @@ * accepted if you are using GCC for compilation (and probably by * other compilers too). * - * Author: David Turner, 2005, 2006, 2008-2013, 2015 + * Author: FreeType team, 2005-2019 * * This code is explicitly placed into the public domain. * @@ -26,6 +26,7 @@ #define LINEBUFF_SIZE 1024 + typedef enum OutputFormat_ { OUTPUT_LIST = 0, /* output the list of names, one per line */ @@ -53,10 +54,12 @@ typedef struct NameRec_ } NameRec, *Name; + static Name the_names; static int num_names; static int max_names; + static void names_add( const char* name, const char* end ) @@ -65,14 +68,16 @@ names_add( const char* name, int nn, len; Name nm; + if ( end <= name ) return; /* compute hash value */ - len = (int)(end - name); + len = (int)( end - name ); h = 0; + for ( nn = 0; nn < len; nn++ ) - h = h*33 + name[nn]; + h = h * 33 + name[nn]; /* check for an pre-existing name */ for ( nn = 0; nn < num_names; nn++ ) @@ -88,7 +93,7 @@ names_add( const char* name, /* add new name */ if ( num_names >= max_names ) { - max_names += (max_names >> 1) + 4; + max_names += ( max_names >> 1 ) + 4; the_names = (NameRec*)realloc( the_names, sizeof ( the_names[0] ) * max_names ); if ( !the_names ) @@ -97,7 +102,7 @@ names_add( const char* name, nm = &the_names[num_names++]; nm->hash = h; - nm->name = (char*)malloc( len+1 ); + nm->name = (char*)malloc( len + 1 ); if ( !nm->name ) panic( "not enough memory" ); @@ -116,6 +121,7 @@ name_compare( const void* name1, return strcmp( n1->name, n2->name ); } + static void names_sort( void ) { @@ -134,87 +140,93 @@ names_dump( FILE* out, switch ( format ) { - case OUTPUT_WINDOWS_DEF: - if ( dll_name ) - fprintf( out, "LIBRARY %s\n", dll_name ); - - fprintf( out, "DESCRIPTION FreeType 2 DLL\n" ); - fprintf( out, "EXPORTS\n" ); - for ( nn = 0; nn < num_names; nn++ ) - fprintf( out, " %s\n", the_names[nn].name ); - break; + case OUTPUT_WINDOWS_DEF: + if ( dll_name ) + fprintf( out, "LIBRARY %s\n", dll_name ); - case OUTPUT_BORLAND_DEF: - if ( dll_name ) - fprintf( out, "LIBRARY %s\n", dll_name ); - - fprintf( out, "DESCRIPTION FreeType 2 DLL\n" ); - fprintf( out, "EXPORTS\n" ); - for ( nn = 0; nn < num_names; nn++ ) - fprintf( out, " _%s\n", the_names[nn].name ); - break; - - case OUTPUT_WATCOM_LBC: - { - const char* dot; - char temp[512]; + fprintf( out, "DESCRIPTION FreeType 2 DLL\n" ); + fprintf( out, "EXPORTS\n" ); + for ( nn = 0; nn < num_names; nn++ ) + fprintf( out, " %s\n", the_names[nn].name ); - if ( !dll_name ) - { - fprintf( stderr, - "you must provide a DLL name with the -d option!\n" ); - exit( 4 ); - } + break; - /* we must omit the .dll suffix from the library name */ - dot = strchr( dll_name, '.' ); - if ( dot ) - { - int len = dot - dll_name; + case OUTPUT_BORLAND_DEF: + if ( dll_name ) + fprintf( out, "LIBRARY %s\n", dll_name ); + fprintf( out, "DESCRIPTION FreeType 2 DLL\n" ); + fprintf( out, "EXPORTS\n" ); - if ( len > (int)( sizeof ( temp ) - 1 ) ) - len = sizeof ( temp ) - 1; + for ( nn = 0; nn < num_names; nn++ ) + fprintf( out, " _%s\n", the_names[nn].name ); - memcpy( temp, dll_name, len ); - temp[len] = 0; + break; - dll_name = (const char*)temp; - } + case OUTPUT_WATCOM_LBC: + { + const char* dot; + char temp[512]; - for ( nn = 0; nn < num_names; nn++ ) - fprintf( out, "++_%s.%s.%s\n", the_names[nn].name, dll_name, - the_names[nn].name ); - } - break; - case OUTPUT_NETWARE_IMP: + if ( !dll_name ) { - if ( dll_name ) - fprintf( out, " (%s)\n", dll_name ); - for ( nn = 0; nn < num_names - 1; nn++ ) - fprintf( out, " %s,\n", the_names[nn].name ); - fprintf( out, " %s\n", the_names[num_names - 1].name ); + fprintf( stderr, + "you must provide a DLL name with the -d option!\n" ); + exit( 4 ); } - break; - case OUTPUT_GNU_VERMAP: + /* we must omit the `.dll' suffix from the library name */ + dot = strchr( dll_name, '.' ); + if ( dot ) { - fprintf( out, "{\n\tglobal:\n" ); - for ( nn = 0; nn < num_names; nn++ ) - fprintf( out, "\t\t%s;\n", the_names[nn].name ); - fprintf( out, "\tlocal:\n\t\t*;\n};\n" ); + int len = dot - dll_name; + + + if ( len > (int)( sizeof ( temp ) - 1 ) ) + len = sizeof ( temp ) - 1; + + memcpy( temp, dll_name, len ); + temp[len] = 0; + + dll_name = (const char*)temp; } - break; - default: /* LIST */ for ( nn = 0; nn < num_names; nn++ ) - fprintf( out, "%s\n", the_names[nn].name ); - } -} + fprintf( out, "++_%s.%s.%s\n", + the_names[nn].name, dll_name, the_names[nn].name ); + } + + break; + + case OUTPUT_NETWARE_IMP: + if ( dll_name ) + fprintf( out, " (%s)\n", dll_name ); + + for ( nn = 0; nn < num_names - 1; nn++ ) + fprintf( out, " %s,\n", the_names[nn].name ); + fprintf( out, " %s\n", the_names[num_names - 1].name ); + + break; + + case OUTPUT_GNU_VERMAP: + fprintf( out, "{\n\tglobal:\n" ); + for ( nn = 0; nn < num_names; nn++ ) + fprintf( out, "\t\t%s;\n", the_names[nn].name ); + fprintf( out, "\tlocal:\n\t\t*;\n};\n" ); + + break; + + default: /* LIST */ + for ( nn = 0; nn < num_names; nn++ ) + fprintf( out, "%s\n", the_names[nn].name ); + + break; + } +} /* states of the line parser */ @@ -226,89 +238,96 @@ typedef enum State_ } State; + static int -read_header_file( FILE* file, int verbose ) +read_header_file( FILE* file, + int verbose ) { static char buff[LINEBUFF_SIZE + 1]; State state = STATE_START; + while ( !feof( file ) ) { char* p; + if ( !fgets( buff, LINEBUFF_SIZE, file ) ) break; p = buff; - while ( *p && (*p == ' ' || *p == '\\') ) /* skip leading whitespace */ + /* skip leading whitespace */ + while ( *p && ( *p == ' ' || *p == '\\' ) ) p++; - if ( *p == '\n' || *p == '\r' ) /* skip empty lines */ + /* skip empty lines */ + if ( *p == '\n' || *p == '\r' ) continue; switch ( state ) { - case STATE_START: + case STATE_START: + if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 ) + break; + + p += 10; + for (;;) + { + if ( *p == 0 || *p == '\n' || *p == '\r' ) + goto NextLine; + + if ( *p == ')' ) { - if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 ) - break; - - p += 10; - for (;;) - { - if ( *p == 0 || *p == '\n' || *p == '\r' ) - goto NextLine; - - if ( *p == ')' ) - { - p++; - break; - } - - p++; - } - - state = STATE_TYPE; - - /* sometimes, the name is just after the FT_EXPORT(...), so - * skip whitespace, and fall-through if we find an alphanumeric - * character - */ - while ( *p == ' ' || *p == '\t' ) - p++; - - if ( !isalpha(*p) ) - break; + p++; + break; } - /* fall-through */ - case STATE_TYPE: - { - char* name = p; + p++; + } - while ( isalnum(*p) || *p == '_' ) - p++; + state = STATE_TYPE; + + /* + * Sometimes, the name is just after `FT_EXPORT(...)', so skip + * whitespace and fall-through if we find an alphanumeric character. + */ + while ( *p == ' ' || *p == '\t' ) + p++; + + if ( !isalpha( *p ) ) + break; + + /* fall-through */ + + case STATE_TYPE: + { + char* name = p; - if ( p > name ) - { - if ( verbose ) - fprintf( stderr, ">>> %.*s\n", (int)(p - name), name ); - names_add( name, p ); - } + while ( isalnum( *p ) || *p == '_' ) + p++; - state = STATE_START; + if ( p > name ) + { + if ( verbose ) + fprintf( stderr, ">>> %.*s\n", (int)( p - name ), name ); + + names_add( name, p ); } - break; - default: - ; + state = STATE_START; + } + + break; + + default: + ; } - NextLine: +NextLine: ; - } + } /* end of while loop */ return 0; } @@ -318,143 +337,154 @@ static void usage( void ) { static const char* const format = - "%s %s: extract FreeType API names from header files\n\n" - "this program is used to extract the list of public FreeType API\n" - "functions. It receives the list of header files as argument and\n" - "generates a sorted list of unique identifiers\n\n" - - "usage: %s header1 [options] [header2 ...]\n\n" - - "options: - : parse the content of stdin, ignore arguments\n" - " -v : verbose mode, output sent to standard error\n" - " -oFILE : write output to FILE instead of standard output\n" - " -dNAME : indicate DLL file name, 'freetype.dll' by default\n" - " -w : output .DEF file for Visual C++ and Mingw\n" - " -wB : output .DEF file for Borland C++\n" - " -wW : output Watcom Linker Response File\n" - " -wN : output NetWare Import File\n" - " -wL : output version map for GNU or Solaris linker\n" - "\n"; + "%s %s: extract FreeType API names from header files\n" + "\n" + "This program extracts the list of public FreeType API functions.\n" + "It receives a list of header files as an argument and\n" + "generates a sorted list of unique identifiers in various formats.\n" + "\n" + "usage: %s header1 [options] [header2 ...]\n" + "\n" + "options: - parse the contents of stdin, ignore arguments\n" + " -v verbose mode, output sent to standard error\n" + " -oFILE write output to FILE instead of standard output\n" + " -dNAME indicate DLL file name, 'freetype.dll' by default\n" + " -w output .DEF file for Visual C++ and Mingw\n" + " -wB output .DEF file for Borland C++\n" + " -wW output Watcom Linker Response File\n" + " -wN output NetWare Import File\n" + " -wL output version map for GNU or Solaris linker\n" + "\n"; fprintf( stderr, format, PROGRAM_NAME, PROGRAM_VERSION, - PROGRAM_NAME - ); - exit(1); + PROGRAM_NAME ); + + exit( 1 ); } -int main( int argc, const char* const* argv ) +int +main( int argc, + const char* const* argv ) { - int from_stdin = 0; - int verbose = 0; - OutputFormat format = OUTPUT_LIST; /* the default */ - FILE* out = stdout; + int from_stdin = 0; + int verbose = 0; + OutputFormat format = OUTPUT_LIST; /* the default */ + FILE* out = stdout; const char* library_name = NULL; + if ( argc < 2 ) usage(); - /* '-' used as a single argument means read source file from stdin */ + /* `-' used as a single argument means read source file from stdin */ while ( argc > 1 && argv[1][0] == '-' ) { const char* arg = argv[1]; + switch ( arg[1] ) { - case 'v': - verbose = 1; - break; + case 'v': + verbose = 1; - case 'o': - if ( arg[2] == 0 ) - { - if ( argc < 2 ) - usage(); + break; - arg = argv[2]; - argv++; - argc--; - } - else - arg += 2; + case 'o': + if ( arg[2] == 0 ) + { + if ( argc < 2 ) + usage(); - out = fopen( arg, "wt" ); - if ( !out ) - { - fprintf( stderr, "could not open '%s' for writing\n", argv[2] ); - exit(3); - } - break; + arg = argv[2]; + argv++; + argc--; + } + else + arg += 2; - case 'd': - if ( arg[2] == 0 ) - { - if ( argc < 2 ) - usage(); + out = fopen( arg, "wt" ); + if ( !out ) + { + fprintf( stderr, "could not open '%s' for writing\n", arg ); + exit( 3 ); + } - arg = argv[2]; - argv++; - argc--; - } - else - arg += 2; + break; - library_name = arg; - break; + case 'd': + if ( arg[2] == 0 ) + { + if ( argc < 2 ) + usage(); - case 'w': - format = OUTPUT_WINDOWS_DEF; - switch ( arg[2] ) - { - case 'B': - format = OUTPUT_BORLAND_DEF; - break; + arg = argv[2]; + argv++; + argc--; + } + else + arg += 2; + + library_name = arg; + + break; - case 'W': - format = OUTPUT_WATCOM_LBC; - break; + case 'w': + format = OUTPUT_WINDOWS_DEF; - case 'N': - format = OUTPUT_NETWARE_IMP; - break; + switch ( arg[2] ) + { + case 'B': + format = OUTPUT_BORLAND_DEF; + break; - case 'L': - format = OUTPUT_GNU_VERMAP; - break; + case 'W': + format = OUTPUT_WATCOM_LBC; + break; - case 0: - break; + case 'N': + format = OUTPUT_NETWARE_IMP; + break; - default: - usage(); - } + case 'L': + format = OUTPUT_GNU_VERMAP; break; case 0: - from_stdin = 1; break; default: usage(); + } + + break; + + case 0: + from_stdin = 1; + + break; + + default: + usage(); } argc--; argv++; - } + + } /* end of while loop */ if ( from_stdin ) - { read_header_file( stdin, verbose ); - } else { for ( --argc, argv++; argc > 0; argc--, argv++ ) { FILE* file = fopen( argv[0], "rb" ); + if ( !file ) fprintf( stderr, "unable to open '%s'\n", argv[0] ); else @@ -469,7 +499,7 @@ int main( int argc, const char* const* argv ) } if ( num_names == 0 ) - panic( "could not find exported functions !!\n" ); + panic( "could not find exported functions\n" ); names_sort(); names_dump( out, format, library_name ); @@ -479,3 +509,6 @@ int main( int argc, const char* const* argv ) return 0; } + + +/* END */ diff --git a/src/3rdparty/freetype/src/tools/glnames.py b/src/3rdparty/freetype/src/tools/glnames.py index b048d29364..e1b613d11b 100644 --- a/src/3rdparty/freetype/src/tools/glnames.py +++ b/src/3rdparty/freetype/src/tools/glnames.py @@ -6,7 +6,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -5310,24 +5310,24 @@ def main(): mac_extras_count = len( mac_extras ) base_list = mac_extras + sid_standard_names - write( "/***************************************************************************/\n" ) - write( "/* */\n" ) - - write( "/* %-71s*/\n" % os.path.basename( sys.argv[1] ) ) - - write( "/* */\n" ) - write( "/* PostScript glyph names. */\n" ) - write( "/* */\n" ) - write( "/* Copyright 2005-2018 by */\n" ) - write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" ) - write( "/* */\n" ) - write( "/* This file is part of the FreeType project, and may only be used, */\n" ) - write( "/* modified, and distributed under the terms of the FreeType project */\n" ) - write( "/* license, LICENSE.TXT. By continuing to use, modify, or distribute */\n" ) - write( "/* this file you indicate that you have read the license and */\n" ) - write( "/* understand and accept it fully. */\n" ) - write( "/* */\n" ) - write( "/***************************************************************************/\n" ) + write( "/****************************************************************************\n" ) + write( " *\n" ) + + write( " * %-71s\n" % os.path.basename( sys.argv[1] ) ) + + write( " *\n" ) + write( " * PostScript glyph names.\n" ) + write( " *\n" ) + write( " * Copyright 2005-2019 by\n" ) + write( " * David Turner, Robert Wilhelm, and Werner Lemberg.\n" ) + write( " *\n" ) + write( " * This file is part of the FreeType project, and may only be used,\n" ) + write( " * modified, and distributed under the terms of the FreeType project\n" ) + write( " * license, LICENSE.TXT. By continuing to use, modify, or distribute\n" ) + write( " * this file you indicate that you have read the license and\n" ) + write( " * understand and accept it fully.\n" ) + write( " *\n" ) + write( " */\n" ) write( "\n" ) write( "\n" ) write( " /* This file has been generated automatically -- do not edit! */\n" ) @@ -5361,12 +5361,12 @@ def main(): write( """\ /* - * This table is a compressed version of the Adobe Glyph List (AGL), - * optimized for efficient searching. It has been generated by the - * `glnames.py' python script located in the `src/tools' directory. + * This table is a compressed version of the Adobe Glyph List (AGL), + * optimized for efficient searching. It has been generated by the + * `glnames.py' python script located in the `src/tools' directory. * - * The lookup function to get the Unicode value for a given string - * is defined below the table. + * The lookup function to get the Unicode value for a given string + * is defined below the table. */ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST @@ -5380,7 +5380,7 @@ def main(): write( """\ #ifdef DEFINE_PS_TABLES /* - * This function searches the compressed table efficiently. + * This function searches the compressed table efficiently. */ static unsigned long ft_get_adobe_glyph_index( const char* name, diff --git a/src/3rdparty/freetype/src/tools/update-copyright-year b/src/3rdparty/freetype/src/tools/update-copyright-year index 934f11cf02..2ae50d6f52 100644 --- a/src/3rdparty/freetype/src/tools/update-copyright-year +++ b/src/3rdparty/freetype/src/tools/update-copyright-year @@ -2,7 +2,7 @@ eval '(exit $?0)' && eval 'exec perl -wS -i "$0" ${1+"$@"}' & eval 'exec perl -wS -i "$0" $argv:q' if 0; -# Copyright 2015-2018 by +# Copyright (C) 2015-2019 by # Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -67,7 +67,8 @@ while (<>) s { (?<begin>.*) Copyright - (?<space1>\ +) + (?<space1>(\ + + | \ +\(C\)\ +)) (?<first>[12][0-9][0-9][0-9]) (?<middle>.+) (?<last>[12][0-9][0-9][0-9]) @@ -78,14 +79,15 @@ while (<>) } { # Fill line to the same length (if appropriate); we skip the middle - # part but insert two spaces and `-'. + # part but insert `(C)', three spaces, and `-'. my $space = length($+{space1}) - 1 + length($+{middle}) - 1 + length($+{space2}) - 1 - + length($+{space3}); + + length($+{space3}) + - (length("(C)") + 1); print "$+{begin}"; - print "Copyright\ $+{first}-$year\ by"; + print "Copyright\ (C)\ $+{first}-$year\ by"; print ' ' x $space if length($+{end}); print "$+{end}\n"; $replaced = 1; @@ -95,7 +97,8 @@ while (<>) s { (?<begin>.*) Copyright - (?<space1>\ +) + (?<space1>(\ + + | \ +\(C\)\ +)) (?<first>[12][0-9][0-9][0-9]) (?<space2>\ +) by @@ -103,7 +106,7 @@ while (<>) (?<end>.*) } { - # Fill line to the same length (if appropriate); we insert two + # Fill line to the same length (if appropriate); we insert three # spaces, a `-', and the current year. my $space = length($+{space1}) - 1 + length($+{space2}) - 1 @@ -111,7 +114,7 @@ while (<>) - (length($year) + 1); print "$+{begin}"; - print "Copyright $+{first}-$year by"; + print "Copyright\ (C)\ $+{first}-$year\ by"; # If $space is negative this inserts nothing. print ' ' x $space if length($+{end}); print "$+{end}\n"; diff --git a/src/3rdparty/freetype/src/truetype/Jamfile b/src/3rdparty/freetype/src/truetype/Jamfile index e321fba14a..2de63a7b4c 100644 --- a/src/3rdparty/freetype/src/truetype/Jamfile +++ b/src/3rdparty/freetype/src/truetype/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/truetype Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/truetype/module.mk b/src/3rdparty/freetype/src/truetype/module.mk index 16bc9c8b20..8a841cc956 100644 --- a/src/3rdparty/freetype/src/truetype/module.mk +++ b/src/3rdparty/freetype/src/truetype/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/truetype/rules.mk b/src/3rdparty/freetype/src/truetype/rules.mk index e16113f128..df8dcd4a4e 100644 --- a/src/3rdparty/freetype/src/truetype/rules.mk +++ b/src/3rdparty/freetype/src/truetype/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -33,7 +33,6 @@ TT_DRV_SRC := $(TT_DIR)/ttdriver.c \ $(TT_DIR)/ttgxvar.c \ $(TT_DIR)/ttinterp.c \ $(TT_DIR)/ttobjs.c \ - $(TT_DIR)/ttpic.c \ $(TT_DIR)/ttpload.c \ $(TT_DIR)/ttsubpix.c diff --git a/src/3rdparty/freetype/src/truetype/truetype.c b/src/3rdparty/freetype/src/truetype/truetype.c index 484370975c..84928e7321 100644 --- a/src/3rdparty/freetype/src/truetype/truetype.c +++ b/src/3rdparty/freetype/src/truetype/truetype.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* truetype.c */ -/* */ -/* FreeType TrueType driver component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * truetype.c + * + * FreeType TrueType driver component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT @@ -24,7 +24,6 @@ #include "ttgxvar.c" /* gx distortable font */ #include "ttinterp.c" #include "ttobjs.c" /* object manager */ -#include "ttpic.c" #include "ttpload.c" /* tables loader */ #include "ttsubpix.c" diff --git a/src/3rdparty/freetype/src/truetype/ttdriver.c b/src/3rdparty/freetype/src/truetype/ttdriver.c index 820cafbb8d..ff626d53ab 100644 --- a/src/3rdparty/freetype/src/truetype/ttdriver.c +++ b/src/3rdparty/freetype/src/truetype/ttdriver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttdriver.c */ -/* */ -/* TrueType font driver implementation (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttdriver.c + * + * TrueType font driver implementation (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -43,20 +43,19 @@ #include "tterrors.h" -#include "ttpic.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttdriver +#define FT_COMPONENT ttdriver /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ static FT_Error @@ -164,38 +163,42 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_get_kerning */ - /* */ - /* <Description> */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* <Output> */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this function. Other layouts, or more sophisticated */ - /* kernings, are out of scope of this method (the basic driver */ - /* interface is meant to be simple). */ - /* */ - /* They can be implemented by format-specific interfaces. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_get_kerning + * + * @Description: + * A driver method used to return the kerning vector between two + * glyphs of the same face. + * + * @Input: + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * @Output: + * kerning :: + * The kerning vector. This is in font units for + * scalable formats, and in pixels for fixed-sizes + * formats. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only horizontal layouts (left-to-right & right-to-left) are + * supported by this function. Other layouts, or more sophisticated + * kernings, are out of scope of this method (the basic driver + * interface is meant to be simple). + * + * They can be implemented by format-specific interfaces. + */ static FT_Error tt_get_kerning( FT_Face ttface, /* TT_Face */ FT_UInt left_glyph, @@ -384,32 +387,36 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_glyph_load */ - /* */ - /* <Description> */ - /* A driver method used to load a glyph within a given glyph slot. */ - /* */ - /* <Input> */ - /* slot :: A handle to the target slot object where the glyph */ - /* will be loaded. */ - /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled, loaded, etc. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_glyph_load + * + * @Description: + * A driver method used to load a glyph within a given glyph slot. + * + * @Input: + * slot :: + * A handle to the target slot object where the glyph + * will be loaded. + * + * size :: + * A handle to the source face size at which the glyph + * must be scaled, loaded, etc. + * + * glyph_index :: + * The index of the glyph in the font file. + * + * load_flags :: + * A flag indicating what to load for this glyph. The + * FT_LOAD_XXX constants can be used to control the + * glyph loading process (e.g., whether the outline + * should be scaled, whether to load bitmaps or not, + * whether to hint the outline, etc). + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */ FT_Size ttsize, /* TT_Size */ @@ -464,7 +471,7 @@ ? &ttsize->metrics : &size->hinted_metrics; - /* now load the glyph outline if necessary */ + /* now fill in the glyph slot with outline/bitmap/layered */ error = TT_Load_Glyph( size, slot, glyph_index, load_flags ); /* force drop-out mode to 2 - irrelevant now */ @@ -491,17 +498,19 @@ FT_DEFINE_SERVICE_MULTIMASTERSREC( tt_service_gx_multi_masters, - (FT_Get_MM_Func) NULL, /* get_mm */ - (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ - (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */ - (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */ - (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */ - (FT_Set_Var_Design_Func)TT_Set_Var_Design, /* set_var_design */ - (FT_Get_Var_Design_Func)TT_Get_Var_Design, /* get_var_design */ - (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */ - - (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */ - (FT_Done_Blend_Func) tt_done_blend /* done_blend */ + (FT_Get_MM_Func) NULL, /* get_mm */ + (FT_Set_MM_Design_Func) NULL, /* set_mm_design */ + (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) TT_Get_MM_Blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) TT_Get_MM_Var, /* get_mm_var */ + (FT_Set_Var_Design_Func) TT_Set_Var_Design, /* set_var_design */ + (FT_Get_Var_Design_Func) TT_Get_Var_Design, /* get_var_design */ + (FT_Set_Instance_Func) TT_Set_Named_Instance, /* set_instance */ + (FT_Set_MM_WeightVector_Func)NULL, /* set_mm_weightvector */ + (FT_Get_MM_WeightVector_Func)NULL, /* get_mm_weightvector */ + + (FT_Get_Var_Blend_Func) tt_get_var_blend, /* get_var_blend */ + (FT_Done_Blend_Func) tt_done_blend /* done_blend */ ) FT_DEFINE_SERVICE_METRICSVARIATIONSREC( @@ -548,19 +557,19 @@ tt_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, - FT_SERVICE_ID_MULTI_MASTERS, &TT_SERVICE_GX_MULTI_MASTERS_GET, - FT_SERVICE_ID_METRICS_VARIATIONS, &TT_SERVICE_METRICS_VARIATIONS_GET, + FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters, + FT_SERVICE_ID_METRICS_VARIATIONS, &tt_service_metrics_variations, FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, - FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, - FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET ) + FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, + FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) #else FT_DEFINE_SERVICEDESCREC4( tt_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, - FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET, - FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET ) + FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, + FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) #endif @@ -574,26 +583,15 @@ SFNT_Service sfnt; - /* TT_SERVICES_GET dereferences `library' in PIC mode */ -#ifdef FT_CONFIG_OPTION_PIC - if ( !driver ) - return NULL; - library = driver->library; - if ( !library ) - return NULL; -#endif - - result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface ); + result = ft_service_list_lookup( tt_services, tt_interface ); if ( result ) return result; -#ifndef FT_CONFIG_OPTION_PIC if ( !driver ) return NULL; library = driver->library; if ( !library ) return NULL; -#endif /* only return the default interface from the SFNT module */ sfntd = FT_Get_Module( library, "sfnt" ); diff --git a/src/3rdparty/freetype/src/truetype/ttdriver.h b/src/3rdparty/freetype/src/truetype/ttdriver.h index 707aa68edf..3936c6a4de 100644 --- a/src/3rdparty/freetype/src/truetype/ttdriver.h +++ b/src/3rdparty/freetype/src/truetype/ttdriver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttdriver.h */ -/* */ -/* High-level TrueType driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttdriver.h + * + * High-level TrueType driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTDRIVER_H_ @@ -26,10 +26,8 @@ FT_BEGIN_HEADER - FT_DECLARE_DRIVER( tt_driver_class ) - FT_END_HEADER #endif /* TTDRIVER_H_ */ diff --git a/src/3rdparty/freetype/src/truetype/tterrors.h b/src/3rdparty/freetype/src/truetype/tterrors.h index 88bca3a04a..5609d28d68 100644 --- a/src/3rdparty/freetype/src/truetype/tterrors.h +++ b/src/3rdparty/freetype/src/truetype/tterrors.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* tterrors.h */ -/* */ -/* TrueType error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the TrueType error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * tterrors.h + * + * TrueType error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the TrueType error enumeration + * constants. + * + */ #ifndef TTERRORS_H_ #define TTERRORS_H_ diff --git a/src/3rdparty/freetype/src/truetype/ttgload.c b/src/3rdparty/freetype/src/truetype/ttgload.c index 39d9c3f736..a04684086b 100644 --- a/src/3rdparty/freetype/src/truetype/ttgload.c +++ b/src/3rdparty/freetype/src/truetype/ttgload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttgload.c */ -/* */ -/* TrueType Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttgload.c + * + * TrueType Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -38,20 +38,35 @@ #include "ttsubpix.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttgload +#define FT_COMPONENT ttgload - /*************************************************************************/ - /* */ - /* Composite glyph flags. */ - /* */ + /************************************************************************** + * + * Simple glyph flags. + */ +#define ON_CURVE_POINT 0x01 /* same value as FT_CURVE_TAG_ON */ +#define X_SHORT_VECTOR 0x02 +#define Y_SHORT_VECTOR 0x04 +#define REPEAT_FLAG 0x08 +#define X_POSITIVE 0x10 /* two meanings depending on X_SHORT_VECTOR */ +#define SAME_X 0x10 +#define Y_POSITIVE 0x20 /* two meanings depending on Y_SHORT_VECTOR */ +#define SAME_Y 0x20 +#define OVERLAP_SIMPLE 0x40 /* we ignore this value */ + + + /************************************************************************** + * + * Composite glyph flags. + */ #define ARGS_ARE_WORDS 0x0001 #define ARGS_ARE_XY_VALUES 0x0002 #define ROUND_XY_TO_GRID 0x0004 @@ -62,15 +77,24 @@ #define WE_HAVE_A_2X2 0x0080 #define WE_HAVE_INSTR 0x0100 #define USE_MY_METRICS 0x0200 -#define OVERLAP_COMPOUND 0x0400 +#define OVERLAP_COMPOUND 0x0400 /* we ignore this value */ #define SCALED_COMPONENT_OFFSET 0x0800 #define UNSCALED_COMPONENT_OFFSET 0x1000 - /*************************************************************************/ - /* */ - /* Return the horizontal metrics in font units for a given glyph. */ - /* */ +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#define IS_DEFAULT_INSTANCE( _face ) \ + ( !( FT_IS_NAMED_INSTANCE( _face ) || \ + FT_IS_VARIATION( _face ) ) ) +#else +#define IS_DEFAULT_INSTANCE( _face ) 1 +#endif + + + /************************************************************************** + * + * Return the horizontal metrics in font units for a given glyph. + */ FT_LOCAL_DEF( void ) TT_Get_HMetrics( TT_Face face, FT_UInt idx, @@ -84,11 +108,11 @@ } - /*************************************************************************/ - /* */ - /* Return the vertical metrics in font units for a given glyph. */ - /* See function `tt_loader_set_pp' below for explanations. */ - /* */ + /************************************************************************** + * + * Return the vertical metrics in font units for a given glyph. + * See function `tt_loader_set_pp' below for explanations. + */ FT_LOCAL_DEF( void ) TT_Get_VMetrics( TT_Face face, FT_UInt idx, @@ -250,13 +274,13 @@ #endif /* FT_CONFIG_OPTION_INCREMENTAL */ - /*************************************************************************/ - /* */ - /* The following functions are used by default with TrueType fonts. */ - /* However, they can be replaced by alternatives if we need to support */ - /* TrueType-compressed formats (like MicroType) in the future. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * The following functions are used by default with TrueType fonts. + * However, they can be replaced by alternatives if we need to support + * TrueType-compressed formats (like MicroType) in the future. + * + */ FT_CALLBACK_DEF( FT_Error ) TT_Access_Glyph_Frame( TT_Loader loader, @@ -267,12 +291,9 @@ FT_Error error; FT_Stream stream = loader->stream; - /* for non-debug mode */ FT_UNUSED( glyph_index ); - FT_TRACE4(( "Glyph %ld\n", glyph_index )); - /* the following line sets the `error' variable through macros! */ if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) ) return error; @@ -337,7 +358,7 @@ FT_Byte *flag, *flag_limit; FT_Byte c, count; FT_Vector *vec, *vec_limit; - FT_Pos x; + FT_Pos x, y; FT_Short *cont, *cont_limit, prev_cont; FT_Int xy_size = 0; @@ -382,6 +403,8 @@ goto Invalid_Outline; } + FT_TRACE5(( " # of points: %d\n", n_points )); + /* note that we will add four phantom points later */ error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 ); if ( error ) @@ -452,7 +475,7 @@ goto Invalid_Outline; *flag++ = c = FT_NEXT_BYTE( p ); - if ( c & 8 ) + if ( c & REPEAT_FLAG ) { if ( p + 1 > limit ) goto Invalid_Outline; @@ -478,31 +501,29 @@ for ( ; vec < vec_limit; vec++, flag++ ) { - FT_Pos y = 0; - FT_Byte f = *flag; + FT_Pos delta = 0; + FT_Byte f = *flag; - if ( f & 2 ) + if ( f & X_SHORT_VECTOR ) { if ( p + 1 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_BYTE( p ); - if ( ( f & 16 ) == 0 ) - y = -y; + delta = (FT_Pos)FT_NEXT_BYTE( p ); + if ( !( f & X_POSITIVE ) ) + delta = -delta; } - else if ( ( f & 16 ) == 0 ) + else if ( !( f & SAME_X ) ) { if ( p + 2 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_SHORT( p ); + delta = (FT_Pos)FT_NEXT_SHORT( p ); } - x += y; + x += delta; vec->x = x; - /* the cast is for stupid compilers */ - *flag = (FT_Byte)( f & ~( 2 | 16 ) ); } /* reading the Y coordinates */ @@ -510,35 +531,36 @@ vec = gloader->current.outline.points; vec_limit = vec + n_points; flag = (FT_Byte*)outline->tags; - x = 0; + y = 0; for ( ; vec < vec_limit; vec++, flag++ ) { - FT_Pos y = 0; - FT_Byte f = *flag; + FT_Pos delta = 0; + FT_Byte f = *flag; - if ( f & 4 ) + if ( f & Y_SHORT_VECTOR ) { if ( p + 1 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_BYTE( p ); - if ( ( f & 32 ) == 0 ) - y = -y; + delta = (FT_Pos)FT_NEXT_BYTE( p ); + if ( !( f & Y_POSITIVE ) ) + delta = -delta; } - else if ( ( f & 32 ) == 0 ) + else if ( !( f & SAME_Y ) ) { if ( p + 2 > limit ) goto Invalid_Outline; - y = (FT_Pos)FT_NEXT_SHORT( p ); + delta = (FT_Pos)FT_NEXT_SHORT( p ); } - x += y; - vec->y = x; + y += delta; + vec->y = y; + /* the cast is for stupid compilers */ - *flag = (FT_Byte)( f & FT_CURVE_TAG_ON ); + *flag = (FT_Byte)( f & ON_CURVE_POINT ); } outline->n_points = (FT_Short)n_points; @@ -559,9 +581,10 @@ TT_Load_Composite_Glyph( TT_Loader loader ) { FT_Error error; - FT_Byte* p = loader->cursor; - FT_Byte* limit = loader->limit; - FT_GlyphLoader gloader = loader->gloader; + FT_Byte* p = loader->cursor; + FT_Byte* limit = loader->limit; + FT_GlyphLoader gloader = loader->gloader; + FT_Long num_glyphs = loader->face->root.num_glyphs; FT_SubGlyph subglyph; FT_UInt num_subglyphs; @@ -590,6 +613,11 @@ subglyph->flags = FT_NEXT_USHORT( p ); subglyph->index = FT_NEXT_USHORT( p ); + /* we reject composites that have components */ + /* with invalid glyph indices */ + if ( subglyph->index >= num_glyphs ) + goto Invalid_Composite; + /* check space */ count = 2; if ( subglyph->flags & ARGS_ARE_WORDS ) @@ -768,15 +796,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Hint_Glyph */ - /* */ - /* <Description> */ - /* Hint the glyph using the zone prepared by the caller. Note that */ - /* the zone is supposed to include four phantom points. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Hint_Glyph + * + * @Description: + * Hint the glyph using the zone prepared by the caller. Note that + * the zone is supposed to include four phantom points. + */ static FT_Error TT_Hint_Glyph( TT_Loader loader, FT_Bool is_composite ) @@ -797,15 +825,9 @@ #ifdef TT_USE_BYTECODE_INTERPRETER - if ( loader->glyph->control_len > 0xFFFFL ) - { - FT_TRACE1(( "TT_Hint_Glyph: too long instructions" )); - FT_TRACE1(( " (0x%lx byte) is truncated\n", - loader->glyph->control_len )); - } n_ins = loader->glyph->control_len; - /* save original point position in org */ + /* save original point positions in `org' array */ if ( n_ins > 0 ) FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points ); @@ -896,16 +918,16 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Process_Simple_Glyph */ - /* */ - /* <Description> */ - /* Once a simple glyph has been loaded, it needs to be processed. */ - /* Usually, this means scaling and hinting through bytecode */ - /* interpretation. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Process_Simple_Glyph + * + * @Description: + * Once a simple glyph has been loaded, it needs to be processed. + * Usually, this means scaling and hinting through bytecode + * interpretation. + */ static FT_Error TT_Process_Simple_Glyph( TT_Loader loader ) { @@ -914,6 +936,11 @@ FT_Outline* outline; FT_Int n_points; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Memory memory = loader->face->root.memory; + FT_Vector* unrounded = NULL; +#endif + outline = &gloader->current.outline; n_points = outline->n_points; @@ -934,26 +961,32 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - if ( FT_IS_NAMED_INSTANCE( FT_FACE( loader->face ) ) || - FT_IS_VARIATION( FT_FACE( loader->face ) ) ) + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) { + if ( FT_NEW_ARRAY( unrounded, n_points ) ) + goto Exit; + /* Deltas apply to the unscaled data. */ error = TT_Vary_Apply_Glyph_Deltas( loader->face, loader->glyph_index, outline, + unrounded, (FT_UInt)n_points ); /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ + + /* XXX: change all FreeType modules to store `linear' and `vadvance' */ + /* in 26.6 format before the `base' module scales them to 16.16 */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - loader->linear = outline->points[n_points - 3].x - - outline->points[n_points - 4].x; + loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x - + unrounded[n_points - 4].x ) / 64; if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - loader->vadvance = outline->points[n_points - 1].x - - outline->points[n_points - 2].x; + loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].x - + unrounded[n_points - 2].x ) / 64; if ( error ) - return error; + goto Exit; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -1008,10 +1041,23 @@ /* compensate for any scaling by de/emboldening; */ /* the amount was determined via experimentation */ if ( x_scale_factor != 1000 && ppem > 11 ) + { +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Vector* orig_points = outline->points; + + + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) + outline->points = unrounded; +#endif FT_Outline_EmboldenXY( outline, FT_MulFix( 1280 * ppem, 1000 - x_scale_factor ), 0 ); +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) + outline->points = orig_points; +#endif + } do_scale = TRUE; } } @@ -1032,10 +1078,26 @@ if ( do_scale ) { - for ( ; vec < limit; vec++ ) +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) { - vec->x = FT_MulFix( vec->x, x_scale ); - vec->y = FT_MulFix( vec->y, y_scale ); + FT_Vector* u = unrounded; + + + for ( ; vec < limit; vec++, u++ ) + { + vec->x = ( FT_MulFix( u->x, x_scale ) + 32 ) >> 6; + vec->y = ( FT_MulFix( u->y, y_scale ) + 32 ) >> 6; + } + } + else +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + { + for ( ; vec < limit; vec++ ) + { + vec->x = FT_MulFix( vec->x, x_scale ); + vec->y = FT_MulFix( vec->y, y_scale ); + } } } @@ -1067,19 +1129,24 @@ error = TT_Hint_Glyph( loader, 0 ); } +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + Exit: + FT_FREE( unrounded ); +#endif + return error; } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Process_Composite_Component */ - /* */ - /* <Description> */ - /* Once a composite component has been loaded, it needs to be */ - /* processed. Usually, this means transforming and translating. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Process_Composite_Component + * + * @Description: + * Once a composite component has been loaded, it needs to be + * processed. Usually, this means transforming and translating. + */ static FT_Error TT_Process_Composite_Component( TT_Loader loader, FT_SubGlyph subglyph, @@ -1153,10 +1220,10 @@ #if 0 - /*******************************************************************/ - /* */ - /* This algorithm is what Apple documents. But it doesn't work. */ - /* */ + /******************************************************************** + * + * This algorithm is what Apple documents. But it doesn't work. + */ int a = subglyph->transform.xx > 0 ? subglyph->transform.xx : -subglyph->transform.xx; int b = subglyph->transform.yx > 0 ? subglyph->transform.yx @@ -1178,10 +1245,10 @@ #else /* 1 */ - /*******************************************************************/ - /* */ - /* This algorithm is a guess and works much better than the above. */ - /* */ + /******************************************************************** + * + * This algorithm is a guess and works much better than the above. + */ FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx, subglyph->transform.xy ); FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy, @@ -1239,16 +1306,16 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Process_Composite_Glyph */ - /* */ - /* <Description> */ - /* This is slightly different from TT_Process_Simple_Glyph, in that */ - /* its sole purpose is to hint the glyph. Thus this function is */ - /* only available when bytecode interpreter is enabled. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Process_Composite_Glyph + * + * @Description: + * This is slightly different from TT_Process_Simple_Glyph, in that + * its sole purpose is to hint the glyph. Thus this function is + * only available when bytecode interpreter is enabled. + */ static FT_Error TT_Process_Composite_Glyph( TT_Loader loader, FT_UInt start_point, @@ -1460,7 +1527,7 @@ } #endif - use_aw_2 = (FT_Bool)( subpixel_hinting && grayscale ); + use_aw_2 = FT_BOOL( subpixel_hinting && grayscale ); loader->pp1.x = loader->bbox.xMin - loader->left_bearing; loader->pp1.y = 0; @@ -1497,27 +1564,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* load_truetype_glyph */ - /* */ - /* <Description> */ - /* Loads a given truetype glyph. Handles composites and uses a */ - /* TT_Loader object. */ - /* */ + /************************************************************************** + * + * @Function: + * load_truetype_glyph + * + * @Description: + * Loads a given truetype glyph. Handles composites and uses a + * TT_Loader object. + */ static FT_Error load_truetype_glyph( TT_Loader loader, FT_UInt glyph_index, FT_UInt recurse_count, FT_Bool header_only ) { - FT_Error error = FT_Err_Ok; + FT_Error error = FT_Err_Ok; FT_Fixed x_scale, y_scale; FT_ULong offset; - TT_Face face = loader->face; - FT_GlyphLoader gloader = loader->gloader; - FT_Bool opened_frame = 0; + TT_Face face = loader->face; + FT_GlyphLoader gloader = loader->gloader; + + FT_Bool opened_frame = 0; #ifdef FT_CONFIG_OPTION_INCREMENTAL FT_StreamRec inc_stream; @@ -1550,15 +1618,15 @@ loader->glyph_index = glyph_index; - if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ) + if ( loader->load_flags & FT_LOAD_NO_SCALE ) { - x_scale = loader->size->metrics->x_scale; - y_scale = loader->size->metrics->y_scale; + x_scale = 0x10000L; + y_scale = 0x10000L; } else { - x_scale = 0x10000L; - y_scale = 0x10000L; + x_scale = loader->size->metrics->x_scale; + y_scale = loader->size->metrics->y_scale; } /* Set `offset' to the start of the glyph relative to the start of */ @@ -1617,38 +1685,36 @@ if ( error ) goto Exit; - opened_frame = 1; - /* read glyph header first */ error = face->read_glyph_header( loader ); - if ( error ) - goto Exit; - /* the metrics must be computed after loading the glyph header */ - /* since we need the glyph's `yMax' value in case the vertical */ - /* metrics must be emulated */ - error = tt_get_metrics( loader, glyph_index ); - if ( error ) - goto Exit; + face->forget_glyph_frame( loader ); - if ( header_only ) + if ( error ) goto Exit; } + /* a space glyph */ if ( loader->byte_len == 0 || loader->n_contours == 0 ) { loader->bbox.xMin = 0; loader->bbox.xMax = 0; loader->bbox.yMin = 0; loader->bbox.yMax = 0; + } - error = tt_get_metrics( loader, glyph_index ); - if ( error ) - goto Exit; + /* the metrics must be computed after loading the glyph header */ + /* since we need the glyph's `yMax' value in case the vertical */ + /* metrics must be emulated */ + error = tt_get_metrics( loader, glyph_index ); + if ( error ) + goto Exit; - if ( header_only ) - goto Exit; + if ( header_only ) + goto Exit; + if ( loader->byte_len == 0 || loader->n_contours == 0 ) + { /* must initialize points before (possibly) overriding */ /* glyph metrics from the incremental interface */ tt_loader_set_pp( loader ); @@ -1669,6 +1735,9 @@ short contours[4] = { 0, 1, 2, 3 }; FT_Outline outline; + /* unrounded values */ + FT_Vector unrounded[4] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} }; + points[0].x = loader->pp1.x; points[0].y = loader->pp1.y; @@ -1690,6 +1759,7 @@ error = TT_Vary_Apply_Glyph_Deltas( loader->face, glyph_index, &outline, + unrounded, (FT_UInt)outline.n_points ); if ( error ) goto Exit; @@ -1704,13 +1774,14 @@ loader->pp4.x = points[3].x; loader->pp4.y = points[3].y; - /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - loader->linear = loader->pp2.x - loader->pp1.x; + loader->linear = FT_PIX_ROUND( unrounded[1].x - + unrounded[0].x ) / 64; if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - loader->vadvance = loader->pp4.x - loader->pp3.x; + loader->vadvance = FT_PIX_ROUND( unrounded[3].x - + unrounded[2].x ) / 64; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -1745,6 +1816,16 @@ /***********************************************************************/ /***********************************************************************/ + /* we now open a frame again, right after the glyph header */ + /* (which consists of 10 bytes) */ + error = face->access_glyph_frame( loader, glyph_index, + face->glyf_offset + offset + 10, + (FT_UInt)loader->byte_len - 10 ); + if ( error ) + goto Exit; + + opened_frame = 1; + /* if it is a simple glyph, load it */ if ( loader->n_contours > 0 ) @@ -1790,7 +1871,6 @@ * pointers with a width of at least 32 bits. */ - /* clear the nodes filled by sibling chains */ node = ft_list_get_node_at( &loader->composites, recurse_count ); for ( node2 = node; node2; node2 = node2->next ) @@ -1841,9 +1921,10 @@ FT_SubGlyph subglyph; FT_Outline outline; - FT_Vector* points = NULL; - char* tags = NULL; - short* contours = NULL; + FT_Vector* points = NULL; + char* tags = NULL; + short* contours = NULL; + FT_Vector* unrounded = NULL; limit = (short)gloader->current.num_subglyphs; @@ -1857,9 +1938,10 @@ outline.tags = NULL; outline.contours = NULL; - if ( FT_NEW_ARRAY( points, outline.n_points ) || - FT_NEW_ARRAY( tags, outline.n_points ) || - FT_NEW_ARRAY( contours, outline.n_points ) ) + if ( FT_NEW_ARRAY( points, outline.n_points ) || + FT_NEW_ARRAY( tags, outline.n_points ) || + FT_NEW_ARRAY( contours, outline.n_points ) || + FT_NEW_ARRAY( unrounded, outline.n_points ) ) goto Exit1; subglyph = gloader->current.subglyphs; @@ -1908,6 +1990,7 @@ face, glyph_index, &outline, + unrounded, (FT_UInt)outline.n_points ) ) ) goto Exit1; @@ -1935,14 +2018,19 @@ /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - loader->linear = loader->pp2.x - loader->pp1.x; + loader->linear = + FT_PIX_ROUND( unrounded[outline.n_points - 3].x - + unrounded[outline.n_points - 4].x ) / 64; if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - loader->vadvance = loader->pp4.x - loader->pp3.x; + loader->vadvance = + FT_PIX_ROUND( unrounded[outline.n_points - 1].x - + unrounded[outline.n_points - 2].x ) / 64; Exit1: FT_FREE( outline.points ); FT_FREE( outline.tags ); FT_FREE( outline.contours ); + FT_FREE( unrounded ); if ( error ) goto Exit; @@ -2002,7 +2090,7 @@ FT_Int linear_vadvance; - /* Each time we call load_truetype_glyph in this loop, the */ + /* Each time we call `load_truetype_glyph' in this loop, the */ /* value of `gloader.base.subglyphs' can change due to table */ /* reallocations. We thus need to recompute the subglyph */ /* pointer on each iteration. */ @@ -2045,12 +2133,14 @@ if ( num_points == num_base_points ) continue; - /* gloader->base.outline consists of three parts: */ - /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */ - /* */ - /* (1): exists from the beginning */ - /* (2): components that have been loaded so far */ - /* (3): the newly loaded component */ + /* gloader->base.outline consists of three parts: */ + /* */ + /* 0 ----> start_point ----> num_base_points ----> n_points */ + /* (1) (2) (3) */ + /* */ + /* (1) points that exist from the beginning */ + /* (2) component points that have been loaded so far */ + /* (3) points of the newly loaded component */ error = TT_Process_Composite_Component( loader, subglyph, start_point, @@ -2066,6 +2156,7 @@ loader->ins_pos = ins_pos; if ( IS_HINTED( loader->load_flags ) && #ifdef TT_USE_BYTECODE_INTERPRETER + subglyph && subglyph->flags & WE_HAVE_INSTR && #endif num_points > start_point ) @@ -2132,7 +2223,7 @@ glyph->metrics.horiBearingX = bbox.xMin; glyph->metrics.horiBearingY = bbox.yMax; - glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; + glyph->metrics.horiAdvance = SUB_LONG(loader->pp2.x, loader->pp1.x); /* Adjust advance width to the value contained in the hdmx table */ /* unless FT_LOAD_COMPUTE_METRICS is set or backward compatibility */ @@ -2276,13 +2367,13 @@ /* XXX: for now, we have no better algorithm for the lsb, but it */ /* should work fine. */ /* */ - glyph->metrics.vertBearingX = glyph->metrics.horiBearingX - - glyph->metrics.horiAdvance / 2; + glyph->metrics.vertBearingX = SUB_LONG( glyph->metrics.horiBearingX, + glyph->metrics.horiAdvance / 2 ); glyph->metrics.vertBearingY = top; glyph->metrics.vertAdvance = advance; } - return 0; + return FT_Err_Ok; } @@ -2589,11 +2680,6 @@ if ( reexecute ) { - FT_UInt i; - - - for ( i = 0; i < size->cvt_size; i++ ) - size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); error = tt_size_run_prep( size, pedantic ); if ( error ) return error; @@ -2656,33 +2742,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Load_Glyph */ - /* */ - /* <Description> */ - /* A function used to load a single glyph within a given glyph slot, */ - /* for a given size. */ - /* */ - /* <Input> */ - /* glyph :: A handle to a target slot object where the glyph */ - /* will be loaded. */ - /* */ - /* size :: A handle to the source face size at which the glyph */ - /* must be scaled/loaded. */ - /* */ - /* glyph_index :: The index of the glyph in the font file. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Load_Glyph + * + * @Description: + * A function used to load a single glyph within a given glyph slot, + * for a given size. + * + * @Input: + * glyph :: + * A handle to a target slot object where the glyph + * will be loaded. + * + * size :: + * A handle to the source face size at which the glyph + * must be scaled/loaded. + * + * glyph_index :: + * The index of the glyph in the font file. + * + * load_flags :: + * A flag indicating what to load for this glyph. The + * FT_LOAD_XXX constants can be used to control the + * glyph loading process (e.g., whether the outline + * should be scaled, whether to load bitmaps or not, + * whether to hint the outline, etc). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Load_Glyph( TT_Size size, TT_GlyphSlot glyph, @@ -2692,13 +2782,6 @@ FT_Error error; TT_LoaderRec loader; -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT -#define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \ - FT_IS_VARIATION( glyph->face ) ) ) -#else -#define IS_DEFAULT_INSTANCE 1 -#endif - FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index )); @@ -2707,7 +2790,7 @@ /* try to load embedded bitmap (if any) */ if ( size->strike_index != 0xFFFFFFFFUL && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 && - IS_DEFAULT_INSTANCE ) + IS_DEFAULT_INSTANCE( glyph->face ) ) { FT_Fixed x_scale = size->root.metrics.x_scale; FT_Fixed y_scale = size->root.metrics.y_scale; diff --git a/src/3rdparty/freetype/src/truetype/ttgload.h b/src/3rdparty/freetype/src/truetype/ttgload.h index d237cfd284..f1324bc862 100644 --- a/src/3rdparty/freetype/src/truetype/ttgload.h +++ b/src/3rdparty/freetype/src/truetype/ttgload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttgload.h */ -/* */ -/* TrueType Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttgload.h + * + * TrueType Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTGLOAD_H_ diff --git a/src/3rdparty/freetype/src/truetype/ttgxvar.c b/src/3rdparty/freetype/src/truetype/ttgxvar.c index 29ab2a4efd..78d87dc097 100644 --- a/src/3rdparty/freetype/src/truetype/ttgxvar.c +++ b/src/3rdparty/freetype/src/truetype/ttgxvar.c @@ -1,42 +1,42 @@ -/***************************************************************************/ -/* */ -/* ttgxvar.c */ -/* */ -/* TrueType GX Font Variation loader */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html */ - /* */ - /* The documentation for `gvar' is not intelligible; `cvar' refers you */ - /* to `gvar' and is thus also incomprehensible. */ - /* */ - /* The documentation for `avar' appears correct, but Apple has no fonts */ - /* with an `avar' table, so it is hard to test. */ - /* */ - /* Many thanks to John Jenkins (at Apple) in figuring this out. */ - /* */ - /* */ - /* Apple's `kern' table has some references to tuple indices, but as */ - /* there is no indication where these indices are defined, nor how to */ - /* interpolate the kerning values (different tuples have different */ - /* classes) this issue is ignored. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * ttgxvar.c + * + * TrueType GX Font Variation loader + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * Apple documents the `fvar', `gvar', `cvar', and `avar' tables at + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6[fgca]var.html + * + * The documentation for `gvar' is not intelligible; `cvar' refers you + * to `gvar' and is thus also incomprehensible. + * + * The documentation for `avar' appears correct, but Apple has no fonts + * with an `avar' table, so it is hard to test. + * + * Many thanks to John Jenkins (at Apple) in figuring this out. + * + * + * Apple's `kern' table has some references to tuple indices, but as + * there is no indication where these indices are defined, nor how to + * interpolate the kerning values (different tuples have different + * classes) this issue is ignored. + * + */ #include <ft2build.h> @@ -67,14 +67,27 @@ : (stream)->limit - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /* some macros we need */ +#define FT_fdot14ToFixed( x ) \ + ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) +#define FT_intToFixed( i ) \ + ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) +#define FT_fdot6ToFixed( i ) \ + ( (FT_Fixed)( (FT_ULong)(i) << 10 ) ) +#define FT_fixedToInt( x ) \ + ( (FT_Short)( ( (x) + 0x8000U ) >> 16 ) ) +#define FT_fixedToFdot6( x ) \ + ( (FT_Pos)( ( (x) + 0x200 ) >> 10 ) ) + + + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttgxvar +#define FT_COMPONENT ttgxvar /*************************************************************************/ @@ -86,12 +99,12 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It */ - /* indicates that there is a delta for every point without needing to */ - /* enumerate all of them. */ - /* */ + /************************************************************************** + * + * The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It + * indicates that there is a delta for every point without needing to + * enumerate all of them. + */ /* ensure that value `0' has the same width as a pointer */ #define ALL_POINTS (FT_UShort*)~(FT_PtrDist)0 @@ -101,29 +114,32 @@ #define GX_PT_POINT_RUN_COUNT_MASK 0x7FU - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_readpackedpoints */ - /* */ - /* <Description> */ - /* Read a set of points to which the following deltas will apply. */ - /* Points are packed with a run length encoding. */ - /* */ - /* <Input> */ - /* stream :: The data stream. */ - /* */ - /* size :: The size of the table holding the data. */ - /* */ - /* <Output> */ - /* point_cnt :: The number of points read. A zero value means that */ - /* all points in the glyph will be affected, without */ - /* enumerating them individually. */ - /* */ - /* <Return> */ - /* An array of FT_UShort containing the affected points or the */ - /* special value ALL_POINTS. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_readpackedpoints + * + * @Description: + * Read a set of points to which the following deltas will apply. + * Points are packed with a run length encoding. + * + * @Input: + * stream :: + * The data stream. + * + * size :: + * The size of the table holding the data. + * + * @Output: + * point_cnt :: + * The number of points read. A zero value means that + * all points in the glyph will be affected, without + * enumerating them individually. + * + * @Return: + * An array of FT_UShort containing the affected points or the + * special value ALL_POINTS. + */ static FT_UShort* ft_var_readpackedpoints( FT_Stream stream, FT_ULong size, @@ -211,34 +227,41 @@ #define GX_DT_DELTA_RUN_COUNT_MASK 0x3FU - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_readpackeddeltas */ - /* */ - /* <Description> */ - /* Read a set of deltas. These are packed slightly differently than */ - /* points. In particular there is no overall count. */ - /* */ - /* <Input> */ - /* stream :: The data stream. */ - /* */ - /* size :: The size of the table holding the data. */ - /* */ - /* delta_cnt :: The number of deltas to be read. */ - /* */ - /* <Return> */ - /* An array of FT_Short containing the deltas for the affected */ - /* points. (This only gets the deltas for one dimension. It will */ - /* generally be called twice, once for x, once for y. When used in */ - /* cvt table, it will only be called once.) */ - /* */ - static FT_Short* + /************************************************************************** + * + * @Function: + * ft_var_readpackeddeltas + * + * @Description: + * Read a set of deltas. These are packed slightly differently than + * points. In particular there is no overall count. + * + * @Input: + * stream :: + * The data stream. + * + * size :: + * The size of the table holding the data. + * + * delta_cnt :: + * The number of deltas to be read. + * + * @Return: + * An array of FT_Fixed containing the deltas for the affected + * points. (This only gets the deltas for one dimension. It will + * generally be called twice, once for x, once for y. When used in + * cvt table, it will only be called once.) + * + * We use FT_Fixed to avoid accumulation errors while summing up all + * deltas (the rounding to integer values happens as the very last + * step). + */ + static FT_Fixed* ft_var_readpackeddeltas( FT_Stream stream, FT_ULong size, FT_UInt delta_cnt ) { - FT_Short *deltas = NULL; + FT_Fixed *deltas = NULL; FT_UInt runcnt, cnt; FT_UInt i, j; FT_Memory memory = stream->memory; @@ -272,13 +295,13 @@ { /* `runcnt' shorts from the stack */ for ( j = 0; j <= cnt && i < delta_cnt; j++ ) - deltas[i++] = FT_GET_SHORT(); + deltas[i++] = FT_intToFixed( FT_GET_SHORT() ); } else { /* `runcnt' signed bytes from the stack */ for ( j = 0; j <= cnt && i < delta_cnt; j++ ) - deltas[i++] = FT_GET_CHAR(); + deltas[i++] = FT_intToFixed( FT_GET_CHAR() ); } if ( j <= cnt ) @@ -293,18 +316,19 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_avar */ - /* */ - /* <Description> */ - /* Parse the `avar' table if present. It need not be, so we return */ - /* nothing. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_avar + * + * @Description: + * Parse the `avar' table if present. It need not be, so we return + * nothing. + * + * @InOut: + * face :: + * The font face. + */ static void ft_var_load_avar( TT_Face face ) { @@ -377,9 +401,10 @@ for ( j = 0; j < segment->pairCount; j++ ) { - /* convert to Fixed */ - segment->correspondence[j].fromCoord = FT_GET_SHORT() * 4; - segment->correspondence[j].toCoord = FT_GET_SHORT() * 4; + segment->correspondence[j].fromCoord = + FT_fdot14ToFixed( FT_GET_SHORT() ); + segment->correspondence[j].toCoord = + FT_fdot14ToFixed( FT_GET_SHORT() ); FT_TRACE5(( " mapping %.5f to %.5f\n", segment->correspondence[j].fromCoord / 65536.0, @@ -394,17 +419,6 @@ } - /* some macros we need */ -#define FT_FIXED_ONE ( (FT_Fixed)0x10000 ) - -#define FT_fdot14ToFixed( x ) \ - ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) -#define FT_intToFixed( i ) \ - ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) -#define FT_fixedToInt( x ) \ - ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) - - static FT_Error ft_var_load_item_variation_store( TT_Face face, FT_ULong offset, @@ -702,29 +716,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_hvvar */ - /* */ - /* <Description> */ - /* If `vertical' is zero, parse the `HVAR' table and set */ - /* `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked' */ - /* is set to TRUE. */ - /* */ - /* If `vertical' is not zero, parse the `VVAR' table and set */ - /* `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked' */ - /* is set to TRUE. */ - /* */ - /* Some memory may remain allocated on error; it is always freed in */ - /* `tt_done_blend', however. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_hvvar + * + * @Description: + * If `vertical' is zero, parse the `HVAR' table and set + * `blend->hvar_loaded' to TRUE. On success, `blend->hvar_checked' + * is set to TRUE. + * + * If `vertical' is not zero, parse the `VVAR' table and set + * `blend->vvar_loaded' to TRUE. On success, `blend->vvar_checked' + * is set to TRUE. + * + * Some memory may remain allocated on error; it is always freed in + * `tt_done_blend', however. + * + * @InOut: + * face :: + * The font face. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error ft_var_load_hvvar( TT_Face face, FT_Bool vertical ) @@ -872,7 +887,7 @@ /* outer loop steps through master designs to be blended */ for ( master = 0; master < varData->regionIdxCount; master++ ) { - FT_Fixed scalar = FT_FIXED_ONE; + FT_Fixed scalar = 0x10000L; FT_UInt regionIndex = varData->regionIndices[master]; GX_AxisCoords axis = itemStore->varRegionList[regionIndex].axisList; @@ -881,47 +896,43 @@ /* inner loop steps through axes in this region */ for ( j = 0; j < itemStore->axisCount; j++, axis++ ) { - FT_Fixed axisScalar; - - /* compute the scalar contribution of this axis; */ /* ignore invalid ranges */ if ( axis->startCoord > axis->peakCoord || axis->peakCoord > axis->endCoord ) - axisScalar = FT_FIXED_ONE; + continue; else if ( axis->startCoord < 0 && axis->endCoord > 0 && axis->peakCoord != 0 ) - axisScalar = FT_FIXED_ONE; + continue; /* peak of 0 means ignore this axis */ else if ( axis->peakCoord == 0 ) - axisScalar = FT_FIXED_ONE; + continue; - /* ignore this region if coords are out of range */ - else if ( face->blend->normalizedcoords[j] < axis->startCoord || - face->blend->normalizedcoords[j] > axis->endCoord ) - axisScalar = 0; + else if ( face->blend->normalizedcoords[j] == axis->peakCoord ) + continue; - /* calculate a proportional factor */ - else + /* ignore this region if coords are out of range */ + else if ( face->blend->normalizedcoords[j] <= axis->startCoord || + face->blend->normalizedcoords[j] >= axis->endCoord ) { - if ( face->blend->normalizedcoords[j] == axis->peakCoord ) - axisScalar = FT_FIXED_ONE; - else if ( face->blend->normalizedcoords[j] < axis->peakCoord ) - axisScalar = - FT_DivFix( face->blend->normalizedcoords[j] - axis->startCoord, - axis->peakCoord - axis->startCoord ); - else - axisScalar = - FT_DivFix( axis->endCoord - face->blend->normalizedcoords[j], - axis->endCoord - axis->peakCoord ); + scalar = 0; + break; } - /* take product of all the axis scalars */ - scalar = FT_MulFix( scalar, axisScalar ); - + /* cumulative product of all the axis scalars */ + else if ( face->blend->normalizedcoords[j] < axis->peakCoord ) + scalar = + FT_MulDiv( scalar, + face->blend->normalizedcoords[j] - axis->startCoord, + axis->peakCoord - axis->startCoord ); + else + scalar = + FT_MulDiv( scalar, + axis->endCoord - face->blend->normalizedcoords[j], + axis->endCoord - axis->peakCoord ); } /* per-axis loop */ /* get the scaled delta for this region */ @@ -937,25 +948,29 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_hvadvance_adjust */ - /* */ - /* <Description> */ - /* Apply `HVAR' advance width or `VVAR' advance height adjustment of */ - /* a given glyph. */ - /* */ - /* <Input> */ - /* gindex :: The glyph index. */ - /* */ - /* vertical :: If set, handle `VVAR' table. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* adelta :: Points to width or height value that gets modified. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_hvadvance_adjust + * + * @Description: + * Apply `HVAR' advance width or `VVAR' advance height adjustment of + * a given glyph. + * + * @Input: + * gindex :: + * The glyph index. + * + * vertical :: + * If set, handle `VVAR' table. + * + * @InOut: + * face :: + * The font face. + * + * adelta :: + * Points to width or height value that gets modified. + */ static FT_Error tt_hvadvance_adjust( TT_Face face, FT_UInt gindex, @@ -1151,20 +1166,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_mvar */ - /* */ - /* <Description> */ - /* Parse the `MVAR' table. */ - /* */ - /* Some memory may remain allocated on error; it is always freed in */ - /* `tt_done_blend', however. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_mvar + * + * @Description: + * Parse the `MVAR' table. + * + * Some memory may remain allocated on error; it is always freed in + * `tt_done_blend', however. + * + * @InOut: + * face :: + * The font face. + */ static void ft_var_load_mvar( TT_Face face ) { @@ -1297,22 +1313,26 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_apply_mvar */ - /* */ - /* <Description> */ - /* Apply `MVAR' table adjustments. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_apply_mvar + * + * @Description: + * Apply `MVAR' table adjustments. + * + * @InOut: + * face :: + * The font face. + */ FT_LOCAL_DEF( void ) tt_apply_mvar( TT_Face face ) { GX_Blend blend = face->blend; GX_Value value, limit; + FT_Short mvar_hasc_delta = 0; + FT_Short mvar_hdsc_delta = 0; + FT_Short mvar_hlgp_delta = 0; if ( !( face->variation_support & TT_FACE_FLAG_VAR_MVAR ) ) @@ -1347,6 +1367,14 @@ /* since we handle both signed and unsigned values as FT_Short, */ /* ensure proper overflow arithmetic */ *p = (FT_Short)( value->unmodified + (FT_Short)delta ); + + /* Treat hasc, hdsc and hlgp specially, see below. */ + if ( value->tag == MVAR_TAG_HASC ) + mvar_hasc_delta = (FT_Short)delta; + else if ( value->tag == MVAR_TAG_HDSC ) + mvar_hdsc_delta = (FT_Short)delta; + else if ( value->tag == MVAR_TAG_HLGP ) + mvar_hlgp_delta = (FT_Short)delta; } } @@ -1354,25 +1382,40 @@ { FT_Face root = &face->root; - - if ( face->os2.version != 0xFFFFU ) - { - if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) - { - root->ascender = face->os2.sTypoAscender; - root->descender = face->os2.sTypoDescender; - - root->height = root->ascender - root->descender + - face->os2.sTypoLineGap; - } - else - { - root->ascender = (FT_Short)face->os2.usWinAscent; - root->descender = -(FT_Short)face->os2.usWinDescent; - - root->height = root->ascender - root->descender; - } - } + /* + * Apply the deltas of hasc, hdsc and hlgp to the FT_Face's ascender, + * descender and height attributes, no matter how they were originally + * computed. + * + * (Code that ignores those and accesses the font's metrics values + * directly is already served by the delta application code above.) + * + * The MVAR table supports variations for both typo and win metrics. + * According to Behdad Esfahbod, the thinking of the working group was + * that no one uses win metrics anymore for setting line metrics (the + * specification even calls these metrics "horizontal clipping + * ascent/descent", probably for their role on the Windows platform in + * computing clipping boxes), and new fonts should use typo metrics, so + * typo deltas should be applied to whatever sfnt_load_face decided the + * line metrics should be. + * + * Before, the following led to different line metrics between default + * outline and instances, visible when e.g. the default outlines were + * used as the regular face and instances for everything else: + * + * 1. sfnt_load_face applied the hhea metrics by default. + * 2. This code later applied the typo metrics by default, regardless of + * whether they were actually changed or the font had the OS/2 table's + * fsSelection's bit 7 (USE_TYPO_METRICS) set. + */ + FT_Short current_line_gap = root->height - root->ascender + + root->descender; + + + root->ascender = root->ascender + mvar_hasc_delta; + root->descender = root->descender + mvar_hdsc_delta; + root->height = root->ascender - root->descender + + current_line_gap + mvar_hlgp_delta; root->underline_position = face->postscript.underlinePosition - face->postscript.underlineThickness / 2; @@ -1400,21 +1443,22 @@ } GX_GVar_Head; - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_load_gvar */ - /* */ - /* <Description> */ - /* Parse the `gvar' table if present. If `fvar' is there, `gvar' had */ - /* better be there too. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_load_gvar + * + * @Description: + * Parse the `gvar' table if present. If `fvar' is there, `gvar' had + * better be there too. + * + * @InOut: + * face :: + * The font face. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error ft_var_load_gvar( TT_Face face ) { @@ -1512,28 +1556,55 @@ if ( gvar_head.flags & 1 ) { + FT_ULong limit = gvar_start + table_len; + + /* long offsets (one more offset than glyphs, to mark size of last) */ if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) ) goto Exit; for ( i = 0; i <= blend->gv_glyphcnt; i++ ) + { blend->glyphoffsets[i] = offsetToData + FT_GET_ULONG(); - - FT_FRAME_EXIT(); + /* use `>', not `>=' */ + if ( blend->glyphoffsets[i] > limit ) + { + FT_TRACE2(( "ft_var_load_gvar:" + " invalid glyph variation data offset for index %d\n", + i )); + error = FT_THROW( Invalid_Table ); + break; + } + } } else { + FT_ULong limit = gvar_start + table_len; + + /* short offsets (one more offset than glyphs, to mark size of last) */ if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) ) goto Exit; for ( i = 0; i <= blend->gv_glyphcnt; i++ ) + { blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2; - /* XXX: Undocumented: `*2'! */ - - FT_FRAME_EXIT(); + /* use `>', not `>=' */ + if ( blend->glyphoffsets[i] > limit ) + { + FT_TRACE2(( "ft_var_load_gvar:" + " invalid glyph variation data offset for index %d\n", + i )); + error = FT_THROW( Invalid_Table ); + break; + } + } } + FT_FRAME_EXIT(); + if ( error ) + goto Exit; + if ( blend->tuplecount != 0 ) { if ( FT_NEW_ARRAY( blend->tuplecoords, @@ -1550,7 +1621,7 @@ for ( j = 0; j < (FT_UInt)gvar_head.axisCount; j++ ) { blend->tuplecoords[i * gvar_head.axisCount + j] = - FT_GET_SHORT() * 4; /* convert to FT_Fixed */ + FT_fdot14ToFixed( FT_GET_SHORT() ); FT_TRACE5(( "%.5f ", blend->tuplecoords[i * gvar_head.axisCount + j] / 65536.0 )); } @@ -1567,33 +1638,38 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_var_apply_tuple */ - /* */ - /* <Description> */ - /* Figure out whether a given tuple (design) applies to the current */ - /* blend, and if so, what is the scaling factor. */ - /* */ - /* <Input> */ - /* blend :: The current blend of the font. */ - /* */ - /* tupleIndex :: A flag saying whether this is an intermediate */ - /* tuple or not. */ - /* */ - /* tuple_coords :: The coordinates of the tuple in normalized axis */ - /* units. */ - /* */ - /* im_start_coords :: The initial coordinates where this tuple starts */ - /* to apply (for intermediate coordinates). */ - /* */ - /* im_end_coords :: The final coordinates after which this tuple no */ - /* longer applies (for intermediate coordinates). */ - /* */ - /* <Return> */ - /* An FT_Fixed value containing the scaling factor. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_var_apply_tuple + * + * @Description: + * Figure out whether a given tuple (design) applies to the current + * blend, and if so, what is the scaling factor. + * + * @Input: + * blend :: + * The current blend of the font. + * + * tupleIndex :: + * A flag saying whether this is an intermediate + * tuple or not. + * + * tuple_coords :: + * The coordinates of the tuple in normalized axis + * units. + * + * im_start_coords :: + * The initial coordinates where this tuple starts + * to apply (for intermediate coordinates). + * + * im_end_coords :: + * The final coordinates after which this tuple no + * longer applies (for intermediate coordinates). + * + * @Return: + * An FT_Fixed value containing the scaling factor. + */ static FT_Fixed ft_var_apply_tuple( GX_Blend blend, FT_UShort tupleIndex, @@ -1607,13 +1683,8 @@ for ( i = 0; i < blend->num_axis; i++ ) { - FT_TRACE6(( " axis coordinate %d (%.5f):\n", + FT_TRACE6(( " axis %d coordinate %.5f:\n", i, blend->normalizedcoords[i] / 65536.0 )); - if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) ) - FT_TRACE6(( " intermediate coordinates %d (%.5f, %.5f):\n", - i, - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); /* It's not clear why (for intermediate tuples) we don't need */ /* to check against start/end -- the documentation says we don't. */ @@ -1622,7 +1693,7 @@ if ( tuple_coords[i] == 0 ) { - FT_TRACE6(( " tuple coordinate is zero, ignored\n", i )); + FT_TRACE6(( " tuple coordinate is zero, ignore\n", i )); continue; } @@ -1635,7 +1706,7 @@ if ( blend->normalizedcoords[i] == tuple_coords[i] ) { - FT_TRACE6(( " tuple coordinate value %.5f fits perfectly\n", + FT_TRACE6(( " tuple coordinate %.5f fits perfectly\n", tuple_coords[i] / 65536.0 )); /* `apply' does not change */ continue; @@ -1648,13 +1719,13 @@ if ( blend->normalizedcoords[i] < FT_MIN( 0, tuple_coords[i] ) || blend->normalizedcoords[i] > FT_MAX( 0, tuple_coords[i] ) ) { - FT_TRACE6(( " tuple coordinate value %.5f is exceeded, stop\n", + FT_TRACE6(( " tuple coordinate %.5f is exceeded, stop\n", tuple_coords[i] / 65536.0 )); apply = 0; break; } - FT_TRACE6(( " tuple coordinate value %.5f fits\n", + FT_TRACE6(( " tuple coordinate %.5f fits\n", tuple_coords[i] / 65536.0 )); apply = FT_MulDiv( apply, blend->normalizedcoords[i], @@ -1664,10 +1735,10 @@ { /* intermediate tuple */ - if ( blend->normalizedcoords[i] < im_start_coords[i] || - blend->normalizedcoords[i] > im_end_coords[i] ) + if ( blend->normalizedcoords[i] <= im_start_coords[i] || + blend->normalizedcoords[i] >= im_end_coords[i] ) { - FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] is exceeded," + FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ is exceeded," " stop\n", im_start_coords[i] / 65536.0, im_end_coords[i] / 65536.0 )); @@ -1675,25 +1746,17 @@ break; } - else if ( blend->normalizedcoords[i] < tuple_coords[i] ) - { - FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); + FT_TRACE6(( " intermediate tuple range ]%.5f;%.5f[ fits\n", + im_start_coords[i] / 65536.0, + im_end_coords[i] / 65536.0 )); + if ( blend->normalizedcoords[i] < tuple_coords[i] ) apply = FT_MulDiv( apply, blend->normalizedcoords[i] - im_start_coords[i], tuple_coords[i] - im_start_coords[i] ); - } - else - { - FT_TRACE6(( " intermediate tuple range [%.5f;%.5f] fits\n", - im_start_coords[i] / 65536.0, - im_end_coords[i] / 65536.0 )); apply = FT_MulDiv( apply, im_end_coords[i] - blend->normalizedcoords[i], im_end_coords[i] - tuple_coords[i] ); - } } } @@ -1756,11 +1819,11 @@ } if ( coord < a->def ) - normalized[i] = -FT_DivFix( coord - a->def, - a->minimum - a->def ); + normalized[i] = -FT_DivFix( SUB_LONG( coord, a->def ), + SUB_LONG( a->minimum, a->def ) ); else if ( coord > a->def ) - normalized[i] = FT_DivFix( coord - a->def, - a->maximum - a->def ); + normalized[i] = FT_DivFix( SUB_LONG( coord, a->def ), + SUB_LONG( a->maximum, a->def ) ); else normalized[i] = 0; } @@ -1910,27 +1973,29 @@ } GX_FVar_Axis; - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Get_MM_Var */ - /* */ - /* <Description> */ - /* Check that the font's `fvar' table is valid, parse it, and return */ - /* those data. It also loads (and parses) the `MVAR' table, if */ - /* possible. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* TT_Get_MM_Var initializes the blend structure. */ - /* */ - /* <Output> */ - /* master :: The `fvar' data (must be freed by caller). Can be NULL, */ - /* which makes this function simply load MM support. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Get_MM_Var + * + * @Description: + * Check that the font's `fvar' table is valid, parse it, and return + * those data. It also loads (and parses) the `MVAR' table, if + * possible. + * + * @InOut: + * face :: + * The font face. + * TT_Get_MM_Var initializes the blend structure. + * + * @Output: + * master :: + * The `fvar' data (must be freed by caller). Can be NULL, + * which makes this function simply load MM support. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Get_MM_Var( TT_Face face, FT_MM_Var* *master ) @@ -2507,11 +2572,14 @@ if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ) { - FT_UInt idx = (FT_UInt)face->root.face_index >> 16; + FT_UInt instance_index = (FT_UInt)face->root.face_index >> 16; c = blend->normalizedcoords + i; - n = blend->normalized_stylecoords + idx * mmvar->num_axis + i; + n = blend->normalized_stylecoords + + ( instance_index - 1 ) * mmvar->num_axis + + i; + for ( j = i; j < mmvar->num_axis; j++, n++, c++ ) if ( *c != *n ) have_diff = 1; @@ -2526,7 +2594,11 @@ /* return value -1 indicates `no change' */ if ( !have_diff ) + { + face->doblend = TRUE; + return -1; + } for ( ; i < mmvar->num_axis; i++ ) { @@ -2590,31 +2662,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_MM_Blend */ - /* */ - /* <Description> */ - /* Set the blend (normalized) coordinates for this instance of the */ - /* font. Check that the `gvar' table is reasonable and does some */ - /* initial preparation. */ - /* */ - /* <InOut> */ - /* face :: The font. */ - /* Initialize the blend structure with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use the default value (0) for the remaining axes. */ - /* */ - /* coords :: An array of `num_coords', each between [-1,1]. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_MM_Blend + * + * @Description: + * Set the blend (normalized) coordinates for this instance of the + * font. Check that the `gvar' table is reasonable and does some + * initial preparation. + * + * @InOut: + * face :: + * The font. + * Initialize the blend structure with `gvar' data. + * + * @Input: + * num_coords :: + * The number of available coordinates. If it is + * larger than the number of axes, ignore the excess + * values. If it is smaller than the number of axes, + * use the default value (0) for the remaining axes. + * + * coords :: + * An array of `num_coords', each between [-1,1]. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Set_MM_Blend( TT_Face face, FT_UInt num_coords, @@ -2636,29 +2711,32 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Get_MM_Blend */ - /* */ - /* <Description> */ - /* Get the blend (normalized) coordinates for this instance of the */ - /* font. */ - /* */ - /* <InOut> */ - /* face :: The font. */ - /* Initialize the blend structure with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, set the excess */ - /* values to 0. */ - /* */ - /* coords :: An array of `num_coords', each between [-1,1]. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Get_MM_Blend + * + * @Description: + * Get the blend (normalized) coordinates for this instance of the + * font. + * + * @InOut: + * face :: + * The font. + * Initialize the blend structure with `gvar' data. + * + * @Input: + * num_coords :: + * The number of available coordinates. If it is + * larger than the number of axes, set the excess + * values to 0. + * + * coords :: + * An array of `num_coords', each between [-1,1]. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Get_MM_Blend( TT_Face face, FT_UInt num_coords, @@ -2712,31 +2790,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_Var_Design */ - /* */ - /* <Description> */ - /* Set the coordinates for the instance, measured in the user */ - /* coordinate system. Parse the `avar' table (if present) to convert */ - /* from user to normalized coordinates. */ - /* */ - /* <InOut> */ - /* face :: The font face. */ - /* Initialize the blend struct with `gvar' data. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available coordinates. If it is */ - /* larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use the default values for the remaining axes. */ - /* */ - /* coords :: A coordinate array with `num_coords' elements. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_Var_Design + * + * @Description: + * Set the coordinates for the instance, measured in the user + * coordinate system. Parse the `avar' table (if present) to convert + * from user to normalized coordinates. + * + * @InOut: + * face :: + * The font face. + * Initialize the blend struct with `gvar' data. + * + * @Input: + * num_coords :: + * The number of available coordinates. If it is + * larger than the number of axes, ignore the excess + * values. If it is smaller than the number of axes, + * use the default values for the remaining axes. + * + * coords :: + * A coordinate array with `num_coords' elements. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Set_Var_Design( TT_Face face, FT_UInt num_coords, @@ -2854,28 +2935,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Get_Var_Design */ - /* */ - /* <Description> */ - /* Get the design coordinates of the currently selected interpolated */ - /* font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* num_coords :: The number of design coordinates to retrieve. If it */ - /* is larger than the number of axes, set the excess */ - /* values to~0. */ - /* */ - /* <Output> */ - /* coords :: The design coordinates array. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Get_Var_Design + * + * @Description: + * Get the design coordinates of the currently selected interpolated + * font. + * + * @Input: + * face :: + * A handle to the source face. + * + * num_coords :: + * The number of design coordinates to retrieve. If it + * is larger than the number of axes, set the excess + * values to~0. + * + * @Output: + * coords :: + * The design coordinates array. + * + * @Return: + * FreeType error code. 0~means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Get_Var_Design( TT_Face face, FT_UInt num_coords, @@ -2929,24 +3013,26 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_Named_Instance */ - /* */ - /* <Description> */ - /* Set the given named instance, also resetting any further */ - /* variation. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* instance_index :: The instance index, starting with value 1. */ - /* Value 0 indicates to not use an instance. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_Named_Instance + * + * @Description: + * Set the given named instance, also resetting any further + * variation. + * + * @Input: + * face :: + * A handle to the source face. + * + * instance_index :: + * The instance index, starting with value 1. + * Value 0 indicates to not use an instance. + * + * @Return: + * FreeType error code. 0~means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Set_Named_Instance( TT_Face face, FT_UInt instance_index ) @@ -2973,7 +3059,7 @@ if ( instance_index > num_instances ) goto Exit; - if ( instance_index > 0 && mmvar->namedstyle ) + if ( instance_index > 0 ) { FT_Memory memory = face->root.memory; SFNT_Service sfnt = (SFNT_Service)face->sfnt; @@ -2999,7 +3085,12 @@ mmvar->num_axis, named_style->coords ); if ( error ) + { + /* internal error code -1 means `no change' */ + if ( error == -1 ) + error = FT_Err_Ok; goto Exit; + } } else error = TT_Set_Var_Design( face, 0, NULL ); @@ -3022,48 +3113,77 @@ /*************************************************************************/ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_vary_cvt */ - /* */ - /* <Description> */ - /* Modify the loaded cvt table according to the `cvar' table and the */ - /* font's blend. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* Most errors are ignored. It is perfectly valid not to have a */ - /* `cvar' table even if there is a `gvar' and `fvar' table. */ - /* */ + static FT_Error + tt_cvt_ready_iterator( FT_ListNode node, + void* user ) + { + TT_Size size = (TT_Size)node->data; + + FT_UNUSED( user ); + + + size->cvt_ready = -1; + + return FT_Err_Ok; + } + + + /************************************************************************** + * + * @Function: + * tt_face_vary_cvt + * + * @Description: + * Modify the loaded cvt table according to the `cvar' table and the + * font's blend. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + * + * Most errors are ignored. It is perfectly valid not to have a + * `cvar' table even if there is a `gvar' and `fvar' table. + */ FT_LOCAL_DEF( FT_Error ) tt_face_vary_cvt( TT_Face face, FT_Stream stream ) { - FT_Error error; - FT_Memory memory = stream->memory; - FT_ULong table_start; - FT_ULong table_len; - FT_UInt tupleCount; - FT_ULong offsetToData; - FT_ULong here; - FT_UInt i, j; - FT_Fixed* tuple_coords = NULL; - FT_Fixed* im_start_coords = NULL; - FT_Fixed* im_end_coords = NULL; - GX_Blend blend = face->blend; - FT_UInt point_count, spoint_count = 0; + FT_Error error; + FT_Memory memory = stream->memory; + + FT_Face root = &face->root; + + FT_ULong table_start; + FT_ULong table_len; + + FT_UInt tupleCount; + FT_ULong offsetToData; + + FT_ULong here; + FT_UInt i, j; + + FT_Fixed* tuple_coords = NULL; + FT_Fixed* im_start_coords = NULL; + FT_Fixed* im_end_coords = NULL; + + GX_Blend blend = face->blend; + + FT_UInt point_count; + FT_UInt spoint_count = 0; + FT_UShort* sharedpoints = NULL; FT_UShort* localpoints = NULL; FT_UShort* points; - FT_Short* deltas; + + FT_Fixed* deltas = NULL; + FT_Fixed* cvt_deltas = NULL; FT_TRACE2(( "CVAR " )); @@ -3146,11 +3266,14 @@ } FT_TRACE5(( "cvar: there %s %d tuple%s:\n", - ( tupleCount & 0xFFF ) == 1 ? "is" : "are", - tupleCount & 0xFFF, - ( tupleCount & 0xFFF ) == 1 ? "" : "s" )); + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are", + tupleCount & GX_TC_TUPLE_COUNT_MASK, + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" )); - for ( i = 0; i < ( tupleCount & 0xFFF ); i++ ) + if ( FT_NEW_ARRAY( cvt_deltas, face->cvt_size ) ) + goto FExit; + + for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ ) { FT_UInt tupleDataSize; FT_UInt tupleIndex; @@ -3165,8 +3288,7 @@ if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD ) { for ( j = 0; j < blend->num_axis; j++ ) - tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */ - /* short frac to fixed */ + tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() ); } else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount ) { @@ -3174,20 +3296,32 @@ " invalid tuple index\n" )); error = FT_THROW( Invalid_Table ); - goto Exit; + goto FExit; } else + { + if ( !blend->tuplecoords ) + { + FT_TRACE2(( "tt_face_vary_cvt:" + " no valid tuple coordinates available\n" )); + + error = FT_THROW( Invalid_Table ); + goto FExit; + } + FT_MEM_COPY( tuple_coords, - &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis], + blend->tuplecoords + + ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis, blend->num_axis * sizeof ( FT_Fixed ) ); + } if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) { for ( j = 0; j < blend->num_axis; j++ ) - im_start_coords[j] = FT_GET_SHORT() * 4; + im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() ); for ( j = 0; j < blend->num_axis; j++ ) - im_end_coords[j] = FT_GET_SHORT() * 4; + im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() ); } apply = ft_var_apply_tuple( blend, @@ -3241,17 +3375,21 @@ /* this means that there are deltas for every entry in cvt */ for ( j = 0; j < face->cvt_size; j++ ) { - FT_Long orig_cvt = face->cvt[j]; + FT_Fixed old_cvt_delta; - face->cvt[j] = (FT_Short)( orig_cvt + - FT_MulFix( deltas[j], apply ) ); + old_cvt_delta = cvt_deltas[j]; + cvt_deltas[j] = old_cvt_delta + FT_MulFix( deltas[j], apply ); #ifdef FT_DEBUG_LEVEL_TRACE - if ( orig_cvt != face->cvt[j] ) + if ( old_cvt_delta != cvt_deltas[j] ) { - FT_TRACE7(( " %d: %d -> %d\n", - j, orig_cvt, face->cvt[j] )); + FT_TRACE7(( " %d: %f -> %f\n", + j, + ( FT_fdot6ToFixed( face->cvt[j] ) + + old_cvt_delta ) / 65536.0, + ( FT_fdot6ToFixed( face->cvt[j] ) + + cvt_deltas[j] ) / 65536.0 )); count++; } #endif @@ -3274,23 +3412,26 @@ for ( j = 0; j < point_count; j++ ) { - int pindex; - FT_Long orig_cvt; + int pindex; + FT_Fixed old_cvt_delta; pindex = points[j]; if ( (FT_ULong)pindex >= face->cvt_size ) continue; - orig_cvt = face->cvt[pindex]; - face->cvt[pindex] = (FT_Short)( orig_cvt + - FT_MulFix( deltas[j], apply ) ); + old_cvt_delta = cvt_deltas[pindex]; + cvt_deltas[pindex] = old_cvt_delta + FT_MulFix( deltas[j], apply ); #ifdef FT_DEBUG_LEVEL_TRACE - if ( orig_cvt != face->cvt[pindex] ) + if ( old_cvt_delta != cvt_deltas[pindex] ) { - FT_TRACE7(( " %d: %d -> %d\n", - pindex, orig_cvt, face->cvt[pindex] )); + FT_TRACE7(( " %d: %f -> %f\n", + pindex, + ( FT_fdot6ToFixed( face->cvt[pindex] ) + + old_cvt_delta ) / 65536.0, + ( FT_fdot6ToFixed( face->cvt[pindex] ) + + cvt_deltas[pindex] ) / 65536.0 )); count++; } #endif @@ -3313,6 +3454,9 @@ FT_TRACE5(( "\n" )); + for ( i = 0; i < face->cvt_size; i++ ) + face->cvt[i] += FT_fixedToFdot6( cvt_deltas[i] ); + FExit: FT_FRAME_EXIT(); @@ -3322,6 +3466,13 @@ FT_FREE( tuple_coords ); FT_FREE( im_start_coords ); FT_FREE( im_end_coords ); + FT_FREE( cvt_deltas ); + + /* iterate over all FT_Size objects and set `cvt_ready' to -1 */ + /* to trigger rescaling of all CVT values */ + FT_List_Iterate( &root->sizes_list, + tt_cvt_ready_iterator, + NULL ); return error; } @@ -3367,9 +3518,8 @@ /* between `p1' and `p2', using `ref1' and `ref2' as the reference */ /* point indices. */ - /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */ - /* `Ins_IUP' */ - + /* modeled after `af_iup_interp', `_iup_worker_interpolate', and */ + /* `Ins_IUP' with spec differences in handling ill-defined cases. */ static void tt_delta_interpolate( int p1, int p2, @@ -3528,61 +3678,89 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Vary_Apply_Glyph_Deltas */ - /* */ - /* <Description> */ - /* Apply the appropriate deltas to the current glyph. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* glyph_index :: The index of the glyph being modified. */ - /* */ - /* n_points :: The number of the points in the glyph, including */ - /* phantom points. */ - /* */ - /* <InOut> */ - /* outline :: The outline to change. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Vary_Apply_Glyph_Deltas + * + * @Description: + * Apply the appropriate deltas to the current glyph. + * + * @Input: + * face :: + * A handle to the target face object. + * + * glyph_index :: + * The index of the glyph being modified. + * + * n_points :: + * The number of the points in the glyph, including + * phantom points. + * + * @InOut: + * outline :: + * The outline to change. + * + * @Output: + * unrounded :: + * An array with `n_points' elements that is filled with unrounded + * point coordinates (in 26.6 format). + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Vary_Apply_Glyph_Deltas( TT_Face face, FT_UInt glyph_index, FT_Outline* outline, + FT_Vector* unrounded, FT_UInt n_points ) { - FT_Stream stream = face->root.stream; - FT_Memory memory = stream->memory; - GX_Blend blend = face->blend; + FT_Error error; + FT_Stream stream = face->root.stream; + FT_Memory memory = stream->memory; - FT_Vector* points_org = NULL; - FT_Vector* points_out = NULL; + FT_Vector* points_org = NULL; /* coordinates in 16.16 format */ + FT_Vector* points_out = NULL; /* coordinates in 16.16 format */ FT_Bool* has_delta = NULL; - FT_Error error; - FT_ULong glyph_start; - FT_UInt tupleCount; - FT_ULong offsetToData; - FT_ULong here; - FT_UInt i, j; - FT_Fixed* tuple_coords = NULL; - FT_Fixed* im_start_coords = NULL; - FT_Fixed* im_end_coords = NULL; - FT_UInt point_count, spoint_count = 0; + FT_ULong glyph_start; + + FT_UInt tupleCount; + FT_ULong offsetToData; + FT_ULong dataSize; + + FT_ULong here; + FT_UInt i, j; + + FT_Fixed* tuple_coords = NULL; + FT_Fixed* im_start_coords = NULL; + FT_Fixed* im_end_coords = NULL; + + GX_Blend blend = face->blend; + + FT_UInt point_count; + FT_UInt spoint_count = 0; + FT_UShort* sharedpoints = NULL; FT_UShort* localpoints = NULL; FT_UShort* points; - FT_Short *deltas_x, *deltas_y; + + FT_Fixed* deltas_x = NULL; + FT_Fixed* deltas_y = NULL; + FT_Fixed* point_deltas_x = NULL; + FT_Fixed* point_deltas_y = NULL; if ( !face->doblend || !blend ) return FT_THROW( Invalid_Argument ); + for ( i = 0; i < n_points; i++ ) + { + unrounded[i].x = INT_TO_F26DOT6( outline->points[i].x ); + unrounded[i].y = INT_TO_F26DOT6( outline->points[i].y ); + } + if ( glyph_index >= blend->gv_glyphcnt || blend->glyphoffsets[glyph_index] == blend->glyphoffsets[glyph_index + 1] ) @@ -3597,9 +3775,11 @@ FT_NEW_ARRAY( has_delta, n_points ) ) goto Fail1; - if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) || - FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] - - blend->glyphoffsets[glyph_index] ) ) + dataSize = blend->glyphoffsets[glyph_index + 1] - + blend->glyphoffsets[glyph_index]; + + if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) || + FT_FRAME_ENTER( dataSize ) ) goto Fail1; glyph_start = FT_Stream_FTell( stream ); @@ -3615,8 +3795,8 @@ offsetToData = FT_GET_USHORT(); /* rough sanity test */ - if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > - blend->gvar_size ) + if ( offsetToData > dataSize || + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > dataSize ) { FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:" " invalid glyph variation array header\n" )); @@ -3646,8 +3826,15 @@ tupleCount & GX_TC_TUPLE_COUNT_MASK, ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" )); + if ( FT_NEW_ARRAY( point_deltas_x, n_points ) || + FT_NEW_ARRAY( point_deltas_y, n_points ) ) + goto Fail3; + for ( j = 0; j < n_points; j++ ) - points_org[j] = outline->points[j]; + { + points_org[j].x = FT_intToFixed( outline->points[j].x ); + points_org[j].y = FT_intToFixed( outline->points[j].y ); + } for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ ) { @@ -3664,8 +3851,7 @@ if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD ) { for ( j = 0; j < blend->num_axis; j++ ) - tuple_coords[j] = FT_GET_SHORT() * 4; /* convert from */ - /* short frac to fixed */ + tuple_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() ); } else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount ) { @@ -3673,20 +3859,21 @@ " invalid tuple index\n" )); error = FT_THROW( Invalid_Table ); - goto Fail2; + goto Fail3; } else FT_MEM_COPY( tuple_coords, - &blend->tuplecoords[( tupleIndex & 0xFFF ) * blend->num_axis], + blend->tuplecoords + + ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) * blend->num_axis, blend->num_axis * sizeof ( FT_Fixed ) ); if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) { for ( j = 0; j < blend->num_axis; j++ ) - im_start_coords[j] = FT_GET_SHORT() * 4; + im_start_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() ); for ( j = 0; j < blend->num_axis; j++ ) - im_end_coords[j] = FT_GET_SHORT() * 4; + im_end_coords[j] = FT_fdot14ToFixed( FT_GET_SHORT() ); } apply = ft_var_apply_tuple( blend, @@ -3742,14 +3929,17 @@ /* this means that there are deltas for every point in the glyph */ for ( j = 0; j < n_points; j++ ) { - FT_Pos delta_x = FT_MulFix( deltas_x[j], apply ); - FT_Pos delta_y = FT_MulFix( deltas_y[j], apply ); + FT_Fixed old_point_delta_x = point_deltas_x[j]; + FT_Fixed old_point_delta_y = point_deltas_y[j]; + + FT_Fixed point_delta_x = FT_MulFix( deltas_x[j], apply ); + FT_Fixed point_delta_y = FT_MulFix( deltas_y[j], apply ); if ( j < n_points - 4 ) { - outline->points[j].x += delta_x; - outline->points[j].y += delta_y; + point_deltas_x[j] = old_point_delta_x + point_delta_x; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } else { @@ -3759,33 +3949,37 @@ if ( j == ( n_points - 4 ) && !( face->variation_support & TT_FACE_FLAG_VAR_LSB ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 3 ) && !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 2 ) && !( face->variation_support & TT_FACE_FLAG_VAR_TSB ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; else if ( j == ( n_points - 1 ) && !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } #ifdef FT_DEBUG_LEVEL_TRACE - if ( delta_x || delta_y ) + if ( point_delta_x || point_delta_y ) { - FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", + FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n", j, - outline->points[j].x - delta_x, - outline->points[j].y - delta_y, - outline->points[j].x, - outline->points[j].y )); + ( FT_intToFixed( outline->points[j].x ) + + old_point_delta_x ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + old_point_delta_y ) / 65536.0, + ( FT_intToFixed( outline->points[j].x ) + + point_deltas_x[j] ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + point_deltas_y[j] ) / 65536.0 )); count++; } #endif @@ -3837,14 +4031,17 @@ for ( j = 0; j < n_points; j++ ) { - FT_Pos delta_x = points_out[j].x - points_org[j].x; - FT_Pos delta_y = points_out[j].y - points_org[j].y; + FT_Fixed old_point_delta_x = point_deltas_x[j]; + FT_Fixed old_point_delta_y = point_deltas_y[j]; + + FT_Pos point_delta_x = points_out[j].x - points_org[j].x; + FT_Pos point_delta_y = points_out[j].y - points_org[j].y; if ( j < n_points - 4 ) { - outline->points[j].x += delta_x; - outline->points[j].y += delta_y; + point_deltas_x[j] = old_point_delta_x + point_delta_x; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } else { @@ -3854,33 +4051,37 @@ if ( j == ( n_points - 4 ) && !( face->variation_support & TT_FACE_FLAG_VAR_LSB ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 3 ) && !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) - outline->points[j].x += delta_x; + point_deltas_x[j] = old_point_delta_x + point_delta_x; else if ( j == ( n_points - 2 ) && !( face->variation_support & TT_FACE_FLAG_VAR_TSB ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; else if ( j == ( n_points - 1 ) && !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) - outline->points[j].y += delta_y; + point_deltas_y[j] = old_point_delta_y + point_delta_y; } #ifdef FT_DEBUG_LEVEL_TRACE - if ( delta_x || delta_y ) + if ( point_delta_x || point_delta_y ) { - FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", + FT_TRACE7(( " %d: (%f, %f) -> (%f, %f)\n", j, - outline->points[j].x - delta_x, - outline->points[j].y - delta_y, - outline->points[j].x, - outline->points[j].y )); + ( FT_intToFixed( outline->points[j].x ) + + old_point_delta_x ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + old_point_delta_y ) / 65536.0, + ( FT_intToFixed( outline->points[j].x ) + + point_deltas_x[j] ) / 65536.0, + ( FT_intToFixed( outline->points[j].y ) + + point_deltas_y[j] ) / 65536.0 )); count++; } #endif @@ -3904,6 +4105,19 @@ FT_TRACE5(( "\n" )); + for ( i = 0; i < n_points; i++ ) + { + unrounded[i].x += FT_fixedToFdot6( point_deltas_x[i] ); + unrounded[i].y += FT_fixedToFdot6( point_deltas_y[i] ); + + outline->points[i].x += FT_fixedToInt( point_deltas_x[i] ); + outline->points[i].y += FT_fixedToInt( point_deltas_y[i] ); + } + + Fail3: + FT_FREE( point_deltas_x ); + FT_FREE( point_deltas_y ); + Fail2: if ( sharedpoints != ALL_POINTS ) FT_FREE( sharedpoints ); @@ -3922,16 +4136,16 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_get_var_blend */ - /* */ - /* <Description> */ - /* An extended internal version of `TT_Get_MM_Blend' that returns */ - /* pointers instead of copying data, without any initialization of */ - /* the MM machinery in case it isn't loaded yet. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_get_var_blend + * + * @Description: + * An extended internal version of `TT_Get_MM_Blend' that returns + * pointers instead of copying data, without any initialization of + * the MM machinery in case it isn't loaded yet. + */ FT_LOCAL_DEF( FT_Error ) tt_get_var_blend( TT_Face face, FT_UInt *num_coords, @@ -3993,14 +4207,14 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_done_blend */ - /* */ - /* <Description> */ - /* Free the blend internal data structure. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_done_blend + * + * @Description: + * Free the blend internal data structure. + */ FT_LOCAL_DEF( void ) tt_done_blend( TT_Face face ) { diff --git a/src/3rdparty/freetype/src/truetype/ttgxvar.h b/src/3rdparty/freetype/src/truetype/ttgxvar.h index a37bb90266..07c99b6403 100644 --- a/src/3rdparty/freetype/src/truetype/ttgxvar.h +++ b/src/3rdparty/freetype/src/truetype/ttgxvar.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttgxvar.h */ -/* */ -/* TrueType GX Font Variation loader (specification) */ -/* */ -/* Copyright 2004-2018 by */ -/* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttgxvar.h + * + * TrueType GX Font Variation loader (specification) + * + * Copyright (C) 2004-2019 by + * David Turner, Robert Wilhelm, Werner Lemberg and George Williams. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTGXVAR_H_ @@ -29,15 +29,15 @@ FT_BEGIN_HEADER #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_AVarCorrespondenceRec */ - /* */ - /* <Description> */ - /* A data structure representing `shortFracCorrespondence' in `avar' */ - /* table according to the specifications from Apple. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_AVarCorrespondenceRec + * + * @Description: + * A data structure representing `shortFracCorrespondence' in `avar' + * table according to the specifications from Apple. + */ typedef struct GX_AVarCorrespondenceRec_ { FT_Fixed fromCoord; @@ -46,15 +46,15 @@ FT_BEGIN_HEADER } GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_AVarRec */ - /* */ - /* <Description> */ - /* Data from the segment field of `avar' table. */ - /* There is one of these for each axis. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_AVarRec + * + * @Description: + * Data from the segment field of `avar' table. + * There is one of these for each axis. + */ typedef struct GX_AVarSegmentRec_ { FT_UShort pairCount; @@ -114,14 +114,14 @@ FT_BEGIN_HEADER } GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_HVVarTableRec */ - /* */ - /* <Description> */ - /* Data from either the `HVAR' or `VVAR' table. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_HVVarTableRec + * + * @Description: + * Data from either the `HVAR' or `VVAR' table. + */ typedef struct GX_HVVarTableRec_ { GX_ItemVarStoreRec itemStore; /* Item Variation Store */ @@ -191,14 +191,14 @@ FT_BEGIN_HEADER } GX_ValueRec, *GX_Value; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_MVarTableRec */ - /* */ - /* <Description> */ - /* Data from the `MVAR' table. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_MVarTableRec + * + * @Description: + * Data from the `MVAR' table. + */ typedef struct GX_MVarTableRec_ { FT_UShort valueCount; @@ -209,95 +209,95 @@ FT_BEGIN_HEADER } GX_MVarTableRec, *GX_MVarTable; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* GX_BlendRec */ - /* */ - /* <Description> */ - /* Data for interpolating a font from a distortable font specified */ - /* by the GX *var tables ([fgcahvm]var). */ - /* */ - /* <Fields> */ - /* num_axis :: */ - /* The number of axes along which interpolation may happen. */ - /* */ - /* coords :: */ - /* An array of design coordinates (in user space) indicating the */ - /* contribution along each axis to the final interpolated font. */ - /* `normalizedcoords' holds the same values. */ - /* */ - /* normalizedcoords :: */ - /* An array of normalized values (between [-1,1]) indicating the */ - /* contribution along each axis to the final interpolated font. */ - /* `coords' holds the same values. */ - /* */ - /* mmvar :: */ - /* Data from the `fvar' table. */ - /* */ - /* mmvar_len :: */ - /* The length of the `mmvar' structure. */ - /* */ - /* normalized_stylecoords :: */ - /* A two-dimensional array that holds the named instance data from */ - /* `mmvar' as normalized values. */ - /* */ - /* avar_loaded :: */ - /* A Boolean; if set, FreeType tried to load (and parse) the `avar' */ - /* table. */ - /* */ - /* avar_segment :: */ - /* Data from the `avar' table. */ - /* */ - /* hvar_loaded :: */ - /* A Boolean; if set, FreeType tried to load (and parse) the `hvar' */ - /* table. */ - /* */ - /* hvar_checked :: */ - /* A Boolean; if set, FreeType successfully loaded and parsed the */ - /* `hvar' table. */ - /* */ - /* hvar_error :: */ - /* If loading and parsing of the `hvar' table failed, this field */ - /* holds the corresponding error code. */ - /* */ - /* hvar_table :: */ - /* Data from the `hvar' table. */ - /* */ - /* vvar_loaded :: */ - /* A Boolean; if set, FreeType tried to load (and parse) the `vvar' */ - /* table. */ - /* */ - /* vvar_checked :: */ - /* A Boolean; if set, FreeType successfully loaded and parsed the */ - /* `vvar' table. */ - /* */ - /* vvar_error :: */ - /* If loading and parsing of the `vvar' table failed, this field */ - /* holds the corresponding error code. */ - /* */ - /* vvar_table :: */ - /* Data from the `vvar' table. */ - /* */ - /* mvar_table :: */ - /* Data from the `mvar' table. */ - /* */ - /* tuplecount :: */ - /* The number of shared tuples in the `gvar' table. */ - /* */ - /* tuplecoords :: */ - /* A two-dimensional array that holds the shared tuple coordinates */ - /* in the `gvar' table. */ - /* */ - /* gv_glyphcnt :: */ - /* The number of glyphs handled in the `gvar' table. */ - /* */ - /* glyphoffsets :: */ - /* Offsets into the glyph variation data array. */ - /* */ - /* gvar_size :: */ - /* The size of the `gvar' table. */ - /* */ + /************************************************************************** + * + * @Struct: + * GX_BlendRec + * + * @Description: + * Data for interpolating a font from a distortable font specified + * by the GX *var tables ([fgcahvm]var). + * + * @Fields: + * num_axis :: + * The number of axes along which interpolation may happen. + * + * coords :: + * An array of design coordinates (in user space) indicating the + * contribution along each axis to the final interpolated font. + * `normalizedcoords' holds the same values. + * + * normalizedcoords :: + * An array of normalized values (between [-1,1]) indicating the + * contribution along each axis to the final interpolated font. + * `coords' holds the same values. + * + * mmvar :: + * Data from the `fvar' table. + * + * mmvar_len :: + * The length of the `mmvar' structure. + * + * normalized_stylecoords :: + * A two-dimensional array that holds the named instance data from + * `mmvar' as normalized values. + * + * avar_loaded :: + * A Boolean; if set, FreeType tried to load (and parse) the `avar' + * table. + * + * avar_segment :: + * Data from the `avar' table. + * + * hvar_loaded :: + * A Boolean; if set, FreeType tried to load (and parse) the `hvar' + * table. + * + * hvar_checked :: + * A Boolean; if set, FreeType successfully loaded and parsed the + * `hvar' table. + * + * hvar_error :: + * If loading and parsing of the `hvar' table failed, this field + * holds the corresponding error code. + * + * hvar_table :: + * Data from the `hvar' table. + * + * vvar_loaded :: + * A Boolean; if set, FreeType tried to load (and parse) the `vvar' + * table. + * + * vvar_checked :: + * A Boolean; if set, FreeType successfully loaded and parsed the + * `vvar' table. + * + * vvar_error :: + * If loading and parsing of the `vvar' table failed, this field + * holds the corresponding error code. + * + * vvar_table :: + * Data from the `vvar' table. + * + * mvar_table :: + * Data from the `mvar' table. + * + * tuplecount :: + * The number of shared tuples in the `gvar' table. + * + * tuplecoords :: + * A two-dimensional array that holds the shared tuple coordinates + * in the `gvar' table. + * + * gv_glyphcnt :: + * The number of glyphs handled in the `gvar' table. + * + * glyphoffsets :: + * Offsets into the glyph variation data array. + * + * gvar_size :: + * The size of the `gvar' table. + */ typedef struct GX_BlendRec_ { FT_UInt num_axis; @@ -336,14 +336,14 @@ FT_BEGIN_HEADER } GX_BlendRec; - /*************************************************************************/ - /* */ - /* <enum> */ - /* GX_TupleCountFlags */ - /* */ - /* <Description> */ - /* Flags used within the `TupleCount' field of the `gvar' table. */ - /* */ + /************************************************************************** + * + * @enum: + * GX_TupleCountFlags + * + * @Description: + * Flags used within the `TupleCount' field of the `gvar' table. + */ typedef enum GX_TupleCountFlags_ { GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000, @@ -353,15 +353,15 @@ FT_BEGIN_HEADER } GX_TupleCountFlags; - /*************************************************************************/ - /* */ - /* <enum> */ - /* GX_TupleIndexFlags */ - /* */ - /* <Description> */ - /* Flags used within the `TupleIndex' field of the `gvar' and `cvar' */ - /* tables. */ - /* */ + /************************************************************************** + * + * @enum: + * GX_TupleIndexFlags + * + * @Description: + * Flags used within the `TupleIndex' field of the `gvar' and `cvar' + * tables. + */ typedef enum GX_TupleIndexFlags_ { GX_TI_EMBEDDED_TUPLE_COORD = 0x8000, @@ -416,6 +416,7 @@ FT_BEGIN_HEADER TT_Vary_Apply_Glyph_Deltas( TT_Face face, FT_UInt glyph_index, FT_Outline* outline, + FT_Vector* unrounded, FT_UInt n_points ); FT_LOCAL( FT_Error ) diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.c b/src/3rdparty/freetype/src/truetype/ttinterp.c index da9b595aba..70434e1729 100644 --- a/src/3rdparty/freetype/src/truetype/ttinterp.c +++ b/src/3rdparty/freetype/src/truetype/ttinterp.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttinterp.c */ -/* */ -/* TrueType bytecode interpreter (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttinterp.c + * + * TrueType bytecode interpreter (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ /* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */ @@ -39,14 +39,14 @@ #ifdef TT_USE_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttinterp +#define FT_COMPONENT ttinterp #define NO_SUBPIXEL_HINTING \ @@ -82,10 +82,10 @@ exc->func_dualproj( exc, (v)->x, (v)->y ) - /*************************************************************************/ - /* */ - /* Two simple bounds-checking macros. */ - /* */ + /************************************************************************** + * + * Two simple bounds-checking macros. + */ #define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) ) #define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) ) @@ -97,30 +97,33 @@ #define FAILURE 1 - /*************************************************************************/ - /* */ - /* CODERANGE FUNCTIONS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Goto_CodeRange */ - /* */ - /* <Description> */ - /* Switches to a new code range (updates the code related elements in */ - /* `exec', and `IP'). */ - /* */ - /* <Input> */ - /* range :: The new execution code range. */ - /* */ - /* IP :: The new IP in the new code range. */ - /* */ - /* <InOut> */ - /* exec :: The target execution context. */ - /* */ + /************************************************************************** + * + * CODERANGE FUNCTIONS + * + */ + + + /************************************************************************** + * + * @Function: + * TT_Goto_CodeRange + * + * @Description: + * Switches to a new code range (updates the code related elements in + * `exec', and `IP'). + * + * @Input: + * range :: + * The new execution code range. + * + * IP :: + * The new IP in the new code range. + * + * @InOut: + * exec :: + * The target execution context. + */ FT_LOCAL_DEF( void ) TT_Goto_CodeRange( TT_ExecContext exec, FT_Int range, @@ -148,24 +151,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Set_CodeRange */ - /* */ - /* <Description> */ - /* Sets a code range. */ - /* */ - /* <Input> */ - /* range :: The code range index. */ - /* */ - /* base :: The new code base. */ - /* */ - /* length :: The range size in bytes. */ - /* */ - /* <InOut> */ - /* exec :: The target execution context. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Set_CodeRange + * + * @Description: + * Sets a code range. + * + * @Input: + * range :: + * The code range index. + * + * base :: + * The new code base. + * + * length :: + * The range size in bytes. + * + * @InOut: + * exec :: + * The target execution context. + */ FT_LOCAL_DEF( void ) TT_Set_CodeRange( TT_ExecContext exec, FT_Int range, @@ -179,20 +186,22 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Clear_CodeRange */ - /* */ - /* <Description> */ - /* Clears a code range. */ - /* */ - /* <Input> */ - /* range :: The code range index. */ - /* */ - /* <InOut> */ - /* exec :: The target execution context. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Clear_CodeRange + * + * @Description: + * Clears a code range. + * + * @Input: + * range :: + * The code range index. + * + * @InOut: + * exec :: + * The target execution context. + */ FT_LOCAL_DEF( void ) TT_Clear_CodeRange( TT_ExecContext exec, FT_Int range ) @@ -204,29 +213,31 @@ } - /*************************************************************************/ - /* */ - /* EXECUTION CONTEXT ROUTINES */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Done_Context */ - /* */ - /* <Description> */ - /* Destroys a given context. */ - /* */ - /* <Input> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* memory :: A handle to the parent memory object. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* */ + /************************************************************************** + * + * EXECUTION CONTEXT ROUTINES + * + */ + + + /************************************************************************** + * + * @Function: + * TT_Done_Context + * + * @Description: + * Destroys a given context. + * + * @Input: + * exec :: + * A handle to the target execution context. + * + * memory :: + * A handle to the parent memory object. + * + * @Note: + * Only the glyph loader and debugger should call this function. + */ FT_LOCAL_DEF( void ) TT_Done_Context( TT_ExecContext exec ) { @@ -257,23 +268,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Init_Context */ - /* */ - /* <Description> */ - /* Initializes a context object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the parent memory object. */ - /* */ - /* <InOut> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * Init_Context + * + * @Description: + * Initializes a context object. + * + * @Input: + * memory :: + * A handle to the parent memory object. + * + * @InOut: + * exec :: + * A handle to the target execution context. + * + * @Return: + * FreeType error code. 0 means success. + */ static FT_Error Init_Context( TT_ExecContext exec, FT_Memory memory ) @@ -313,30 +326,35 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Update_Max */ - /* */ - /* <Description> */ - /* Checks the size of a buffer and reallocates it if necessary. */ - /* */ - /* <Input> */ - /* memory :: A handle to the parent memory object. */ - /* */ - /* multiplier :: The size in bytes of each element in the buffer. */ - /* */ - /* new_max :: The new capacity (size) of the buffer. */ - /* */ - /* <InOut> */ - /* size :: The address of the buffer's current size expressed */ - /* in elements. */ - /* */ - /* buff :: The address of the buffer base pointer. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * Update_Max + * + * @Description: + * Checks the size of a buffer and reallocates it if necessary. + * + * @Input: + * memory :: + * A handle to the parent memory object. + * + * multiplier :: + * The size in bytes of each element in the buffer. + * + * new_max :: + * The new capacity (size) of the buffer. + * + * @InOut: + * size :: + * The address of the buffer's current size expressed + * in elements. + * + * buff :: + * The address of the buffer base pointer. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) Update_Max( FT_Memory memory, FT_ULong* size, @@ -359,28 +377,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Load_Context */ - /* */ - /* <Description> */ - /* Prepare an execution context for glyph hinting. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* size :: A handle to the source size object. */ - /* */ - /* <InOut> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Load_Context + * + * @Description: + * Prepare an execution context for glyph hinting. + * + * @Input: + * face :: + * A handle to the source face object. + * + * size :: + * A handle to the source size object. + * + * @InOut: + * exec :: + * A handle to the target execution context. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only the glyph loader and debugger should call this function. + */ FT_LOCAL_DEF( FT_Error ) TT_Load_Context( TT_ExecContext exec, TT_Face face, @@ -467,23 +488,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Save_Context */ - /* */ - /* <Description> */ - /* Saves the code ranges in a `size' object. */ - /* */ - /* <Input> */ - /* exec :: A handle to the source execution context. */ - /* */ - /* <InOut> */ - /* size :: A handle to the target size object. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Save_Context + * + * @Description: + * Saves the code ranges in a `size' object. + * + * @Input: + * exec :: + * A handle to the source execution context. + * + * @InOut: + * size :: + * A handle to the target size object. + * + * @Note: + * Only the glyph loader and debugger should call this function. + */ FT_LOCAL_DEF( void ) TT_Save_Context( TT_ExecContext exec, TT_Size size ) @@ -505,27 +528,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_Run_Context */ - /* */ - /* <Description> */ - /* Executes one or more instructions in the execution context. */ - /* */ - /* <Input> */ - /* debug :: A Boolean flag. If set, the function sets some internal */ - /* variables and returns immediately, otherwise TT_RunIns() */ - /* is called. */ - /* */ - /* This is commented out currently. */ - /* */ - /* <Input> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* TrueType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_Run_Context + * + * @Description: + * Executes one or more instructions in the execution context. + * + * @Input: + * exec :: + * A handle to the target execution context. + * + * @Return: + * TrueType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) TT_Run_Context( TT_ExecContext exec ) { @@ -609,22 +626,22 @@ } - /*************************************************************************/ - /* */ - /* Before an opcode is executed, the interpreter verifies that there are */ - /* enough arguments on the stack, with the help of the `Pop_Push_Count' */ - /* table. */ - /* */ - /* For each opcode, the first column gives the number of arguments that */ - /* are popped from the stack; the second one gives the number of those */ - /* that are pushed in result. */ - /* */ - /* Opcodes which have a varying number of parameters in the data stream */ - /* (NPUSHB, NPUSHW) are handled specially; they have a negative value in */ - /* the `opcode_length' table, and the value in `Pop_Push_Count' is set */ - /* to zero. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Before an opcode is executed, the interpreter verifies that there are + * enough arguments on the stack, with the help of the `Pop_Push_Count' + * table. + * + * For each opcode, the first column gives the number of arguments that + * are popped from the stack; the second one gives the number of those + * that are pushed in result. + * + * Opcodes which have a varying number of parameters in the data stream + * (NPUSHB, NPUSHW) are handled specially; they have a negative value in + * the `opcode_length' table, and the value in `Pop_Push_Count' is set + * to zero. + * + */ #undef PACK @@ -637,23 +654,25 @@ /* opcodes are gathered in groups of 16 */ /* please keep the spaces as they are */ - /* SVTCA y */ PACK( 0, 0 ), - /* SVTCA x */ PACK( 0, 0 ), - /* SPvTCA y */ PACK( 0, 0 ), - /* SPvTCA x */ PACK( 0, 0 ), - /* SFvTCA y */ PACK( 0, 0 ), - /* SFvTCA x */ PACK( 0, 0 ), - /* SPvTL // */ PACK( 2, 0 ), - /* SPvTL + */ PACK( 2, 0 ), - /* SFvTL // */ PACK( 2, 0 ), - /* SFvTL + */ PACK( 2, 0 ), - /* SPvFS */ PACK( 2, 0 ), - /* SFvFS */ PACK( 2, 0 ), - /* GPv */ PACK( 0, 2 ), - /* GFv */ PACK( 0, 2 ), - /* SFvTPv */ PACK( 0, 0 ), + /* 0x00 */ + /* SVTCA[0] */ PACK( 0, 0 ), + /* SVTCA[1] */ PACK( 0, 0 ), + /* SPVTCA[0] */ PACK( 0, 0 ), + /* SPVTCA[1] */ PACK( 0, 0 ), + /* SFVTCA[0] */ PACK( 0, 0 ), + /* SFVTCA[1] */ PACK( 0, 0 ), + /* SPVTL[0] */ PACK( 2, 0 ), + /* SPVTL[1] */ PACK( 2, 0 ), + /* SFVTL[0] */ PACK( 2, 0 ), + /* SFVTL[1] */ PACK( 2, 0 ), + /* SPVFS */ PACK( 2, 0 ), + /* SFVFS */ PACK( 2, 0 ), + /* GPV */ PACK( 0, 2 ), + /* GFV */ PACK( 0, 2 ), + /* SFVTPV */ PACK( 0, 0 ), /* ISECT */ PACK( 5, 0 ), + /* 0x10 */ /* SRP0 */ PACK( 1, 0 ), /* SRP1 */ PACK( 1, 0 ), /* SRP2 */ PACK( 1, 0 ), @@ -667,10 +686,11 @@ /* SMD */ PACK( 1, 0 ), /* ELSE */ PACK( 0, 0 ), /* JMPR */ PACK( 1, 0 ), - /* SCvTCi */ PACK( 1, 0 ), - /* SSwCi */ PACK( 1, 0 ), + /* SCVTCI */ PACK( 1, 0 ), + /* SSWCI */ PACK( 1, 0 ), /* SSW */ PACK( 1, 0 ), + /* 0x20 */ /* DUP */ PACK( 1, 2 ), /* POP */ PACK( 1, 0 ), /* CLEAR */ PACK( 0, 0 ), @@ -678,7 +698,7 @@ /* DEPTH */ PACK( 0, 1 ), /* CINDEX */ PACK( 1, 1 ), /* MINDEX */ PACK( 1, 0 ), - /* AlignPTS */ PACK( 2, 0 ), + /* ALIGNPTS */ PACK( 2, 0 ), /* INS_$28 */ PACK( 0, 0 ), /* UTP */ PACK( 1, 0 ), /* LOOPCALL */ PACK( 2, 0 ), @@ -688,6 +708,7 @@ /* MDAP[0] */ PACK( 1, 0 ), /* MDAP[1] */ PACK( 1, 0 ), + /* 0x30 */ /* IUP[0] */ PACK( 0, 0 ), /* IUP[1] */ PACK( 0, 0 ), /* SHP[0] */ PACK( 0, 0 ), /* loops */ @@ -700,17 +721,18 @@ /* IP */ PACK( 0, 0 ), /* loops */ /* MSIRP[0] */ PACK( 2, 0 ), /* MSIRP[1] */ PACK( 2, 0 ), - /* AlignRP */ PACK( 0, 0 ), /* loops */ + /* ALIGNRP */ PACK( 0, 0 ), /* loops */ /* RTDG */ PACK( 0, 0 ), /* MIAP[0] */ PACK( 2, 0 ), /* MIAP[1] */ PACK( 2, 0 ), - /* NPushB */ PACK( 0, 0 ), - /* NPushW */ PACK( 0, 0 ), + /* 0x40 */ + /* NPUSHB */ PACK( 0, 0 ), + /* NPUSHW */ PACK( 0, 0 ), /* WS */ PACK( 2, 0 ), /* RS */ PACK( 1, 1 ), - /* WCvtP */ PACK( 2, 0 ), - /* RCvt */ PACK( 1, 1 ), + /* WCVTP */ PACK( 2, 0 ), + /* RCVT */ PACK( 1, 1 ), /* GC[0] */ PACK( 1, 1 ), /* GC[1] */ PACK( 1, 1 ), /* SCFS */ PACK( 2, 0 ), @@ -718,10 +740,11 @@ /* MD[1] */ PACK( 2, 1 ), /* MPPEM */ PACK( 0, 1 ), /* MPS */ PACK( 0, 1 ), - /* FlipON */ PACK( 0, 0 ), - /* FlipOFF */ PACK( 0, 0 ), + /* FLIPON */ PACK( 0, 0 ), + /* FLIPOFF */ PACK( 0, 0 ), /* DEBUG */ PACK( 1, 0 ), + /* 0x50 */ /* LT */ PACK( 2, 1 ), /* LTEQ */ PACK( 2, 1 ), /* GT */ PACK( 2, 1 ), @@ -735,10 +758,11 @@ /* AND */ PACK( 2, 1 ), /* OR */ PACK( 2, 1 ), /* NOT */ PACK( 1, 1 ), - /* DeltaP1 */ PACK( 1, 0 ), + /* DELTAP1 */ PACK( 1, 0 ), /* SDB */ PACK( 1, 0 ), /* SDS */ PACK( 1, 0 ), + /* 0x60 */ /* ADD */ PACK( 2, 1 ), /* SUB */ PACK( 2, 1 ), /* DIV */ PACK( 2, 1 ), @@ -756,14 +780,15 @@ /* NROUND[2] */ PACK( 1, 1 ), /* NROUND[3] */ PACK( 1, 1 ), - /* WCvtF */ PACK( 2, 0 ), - /* DeltaP2 */ PACK( 1, 0 ), - /* DeltaP3 */ PACK( 1, 0 ), - /* DeltaCn[0] */ PACK( 1, 0 ), - /* DeltaCn[1] */ PACK( 1, 0 ), - /* DeltaCn[2] */ PACK( 1, 0 ), + /* 0x70 */ + /* WCVTF */ PACK( 2, 0 ), + /* DELTAP2 */ PACK( 1, 0 ), + /* DELTAP3 */ PACK( 1, 0 ), + /* DELTAC1 */ PACK( 1, 0 ), + /* DELTAC2 */ PACK( 1, 0 ), + /* DELTAC3 */ PACK( 1, 0 ), /* SROUND */ PACK( 1, 0 ), - /* S45Round */ PACK( 1, 0 ), + /* S45ROUND */ PACK( 1, 0 ), /* JROT */ PACK( 2, 0 ), /* JROF */ PACK( 2, 0 ), /* ROFF */ PACK( 0, 0 ), @@ -773,23 +798,25 @@ /* SANGW */ PACK( 1, 0 ), /* AA */ PACK( 1, 0 ), - /* FlipPT */ PACK( 0, 0 ), /* loops */ - /* FlipRgON */ PACK( 2, 0 ), - /* FlipRgOFF */ PACK( 2, 0 ), + /* 0x80 */ + /* FLIPPT */ PACK( 0, 0 ), /* loops */ + /* FLIPRGON */ PACK( 2, 0 ), + /* FLIPRGOFF */ PACK( 2, 0 ), /* INS_$83 */ PACK( 0, 0 ), /* INS_$84 */ PACK( 0, 0 ), - /* ScanCTRL */ PACK( 1, 0 ), - /* SDPvTL[0] */ PACK( 2, 0 ), - /* SDPvTL[1] */ PACK( 2, 0 ), - /* GetINFO */ PACK( 1, 1 ), + /* SCANCTRL */ PACK( 1, 0 ), + /* SDPVTL[0] */ PACK( 2, 0 ), + /* SDPVTL[1] */ PACK( 2, 0 ), + /* GETINFO */ PACK( 1, 1 ), /* IDEF */ PACK( 1, 0 ), /* ROLL */ PACK( 3, 3 ), /* MAX */ PACK( 2, 1 ), /* MIN */ PACK( 2, 1 ), - /* ScanTYPE */ PACK( 1, 0 ), - /* InstCTRL */ PACK( 2, 0 ), + /* SCANTYPE */ PACK( 1, 0 ), + /* INSTCTRL */ PACK( 2, 0 ), /* INS_$8F */ PACK( 0, 0 ), + /* 0x90 */ /* INS_$90 */ PACK( 0, 0 ), /* GETVAR */ PACK( 0, 0 ), /* will be handled specially */ /* GETDATA */ PACK( 0, 1 ), @@ -807,6 +834,7 @@ /* INS_$9E */ PACK( 0, 0 ), /* INS_$9F */ PACK( 0, 0 ), + /* 0xA0 */ /* INS_$A0 */ PACK( 0, 0 ), /* INS_$A1 */ PACK( 0, 0 ), /* INS_$A2 */ PACK( 0, 0 ), @@ -824,23 +852,25 @@ /* INS_$AE */ PACK( 0, 0 ), /* INS_$AF */ PACK( 0, 0 ), - /* PushB[0] */ PACK( 0, 1 ), - /* PushB[1] */ PACK( 0, 2 ), - /* PushB[2] */ PACK( 0, 3 ), - /* PushB[3] */ PACK( 0, 4 ), - /* PushB[4] */ PACK( 0, 5 ), - /* PushB[5] */ PACK( 0, 6 ), - /* PushB[6] */ PACK( 0, 7 ), - /* PushB[7] */ PACK( 0, 8 ), - /* PushW[0] */ PACK( 0, 1 ), - /* PushW[1] */ PACK( 0, 2 ), - /* PushW[2] */ PACK( 0, 3 ), - /* PushW[3] */ PACK( 0, 4 ), - /* PushW[4] */ PACK( 0, 5 ), - /* PushW[5] */ PACK( 0, 6 ), - /* PushW[6] */ PACK( 0, 7 ), - /* PushW[7] */ PACK( 0, 8 ), - + /* 0xB0 */ + /* PUSHB[0] */ PACK( 0, 1 ), + /* PUSHB[1] */ PACK( 0, 2 ), + /* PUSHB[2] */ PACK( 0, 3 ), + /* PUSHB[3] */ PACK( 0, 4 ), + /* PUSHB[4] */ PACK( 0, 5 ), + /* PUSHB[5] */ PACK( 0, 6 ), + /* PUSHB[6] */ PACK( 0, 7 ), + /* PUSHB[7] */ PACK( 0, 8 ), + /* PUSHW[0] */ PACK( 0, 1 ), + /* PUSHW[1] */ PACK( 0, 2 ), + /* PUSHW[2] */ PACK( 0, 3 ), + /* PUSHW[3] */ PACK( 0, 4 ), + /* PUSHW[4] */ PACK( 0, 5 ), + /* PUSHW[5] */ PACK( 0, 6 ), + /* PUSHW[6] */ PACK( 0, 7 ), + /* PUSHW[7] */ PACK( 0, 8 ), + + /* 0xC0 */ /* MDRP[00] */ PACK( 1, 0 ), /* MDRP[01] */ PACK( 1, 0 ), /* MDRP[02] */ PACK( 1, 0 ), @@ -858,6 +888,7 @@ /* MDRP[14] */ PACK( 1, 0 ), /* MDRP[15] */ PACK( 1, 0 ), + /* 0xD0 */ /* MDRP[16] */ PACK( 1, 0 ), /* MDRP[17] */ PACK( 1, 0 ), /* MDRP[18] */ PACK( 1, 0 ), @@ -875,6 +906,7 @@ /* MDRP[30] */ PACK( 1, 0 ), /* MDRP[31] */ PACK( 1, 0 ), + /* 0xE0 */ /* MIRP[00] */ PACK( 2, 0 ), /* MIRP[01] */ PACK( 2, 0 ), /* MIRP[02] */ PACK( 2, 0 ), @@ -892,6 +924,7 @@ /* MIRP[14] */ PACK( 2, 0 ), /* MIRP[15] */ PACK( 2, 0 ), + /* 0xF0 */ /* MIRP[16] */ PACK( 2, 0 ), /* MIRP[17] */ PACK( 2, 0 ), /* MIRP[18] */ PACK( 2, 0 ), @@ -920,23 +953,25 @@ static const char* const opcode_name[256] = { - "7 SVTCA y", - "7 SVTCA x", - "8 SPvTCA y", - "8 SPvTCA x", - "8 SFvTCA y", - "8 SFvTCA x", - "8 SPvTL ||", - "7 SPvTL +", - "8 SFvTL ||", - "7 SFvTL +", - "5 SPvFS", - "5 SFvFS", - "3 GPv", - "3 GFv", - "6 SFvTPv", + /* 0x00 */ + "8 SVTCA[y]", + "8 SVTCA[x]", + "9 SPVTCA[y]", + "9 SPVTCA[x]", + "9 SFVTCA[y]", + "9 SFVTCA[x]", + "9 SPVTL[||]", + "8 SPVTL[+]", + "9 SFVTL[||]", + "8 SFVTL[+]", + "5 SPVFS", + "5 SFVFS", + "3 GPV", + "3 GFV", + "6 SFVTPV", "5 ISECT", + /* 0x10 */ "4 SRP0", "4 SRP1", "4 SRP2", @@ -950,10 +985,11 @@ "3 SMD", "4 ELSE", "4 JMPR", - "6 SCvTCi", - "5 SSwCi", + "6 SCVTCI", + "5 SSWCI", "3 SSW", + /* 0x20 */ "3 DUP", "3 POP", "5 CLEAR", @@ -961,50 +997,53 @@ "5 DEPTH", "6 CINDEX", "6 MINDEX", - "8 AlignPTS", + "8 ALIGNPTS", "7 INS_$28", "3 UTP", "8 LOOPCALL", "4 CALL", "4 FDEF", "4 ENDF", - "7 MDAP[0]", - "7 MDAP[1]", - - "6 IUP[0]", - "6 IUP[1]", - "6 SHP[0]", - "6 SHP[1]", - "6 SHC[0]", - "6 SHC[1]", - "6 SHZ[0]", - "6 SHZ[1]", + "6 MDAP[]", + "9 MDAP[rnd]", + + /* 0x30 */ + "6 IUP[y]", + "6 IUP[x]", + "8 SHP[rp2]", + "8 SHP[rp1]", + "8 SHC[rp2]", + "8 SHC[rp1]", + "8 SHZ[rp2]", + "8 SHZ[rp1]", "5 SHPIX", "2 IP", - "8 MSIRP[0]", - "8 MSIRP[1]", - "7 AlignRP", + "7 MSIRP[]", + "A MSIRP[rp0]", + "7 ALIGNRP", "4 RTDG", - "7 MIAP[0]", - "7 MIAP[1]", + "6 MIAP[]", + "9 MIAP[rnd]", - "6 NPushB", - "6 NPushW", + /* 0x40 */ + "6 NPUSHB", + "6 NPUSHW", "2 WS", "2 RS", - "5 WCvtP", - "4 RCvt", - "5 GC[0]", - "5 GC[1]", + "5 WCVTP", + "4 RCVT", + "8 GC[curr]", + "8 GC[orig]", "4 SCFS", - "5 MD[0]", - "5 MD[1]", + "8 MD[curr]", + "8 MD[orig]", "5 MPPEM", "3 MPS", - "6 FlipON", - "7 FlipOFF", + "6 FLIPON", + "7 FLIPOFF", "5 DEBUG", + /* 0x50 */ "2 LT", "4 LTEQ", "2 GT", @@ -1018,10 +1057,11 @@ "3 AND", "2 OR", "3 NOT", - "7 DeltaP1", + "7 DELTAP1", "3 SDB", "3 SDS", + /* 0x60 */ "3 ADD", "3 SUB", "3 DIV", @@ -1030,23 +1070,24 @@ "3 NEG", "5 FLOOR", "7 CEILING", - "8 ROUND[0]", - "8 ROUND[1]", - "8 ROUND[2]", - "8 ROUND[3]", - "9 NROUND[0]", - "9 NROUND[1]", - "9 NROUND[2]", - "9 NROUND[3]", - - "5 WCvtF", - "7 DeltaP2", - "7 DeltaP3", - "A DeltaCn[0]", - "A DeltaCn[1]", - "A DeltaCn[2]", + "8 ROUND[G]", + "8 ROUND[B]", + "8 ROUND[W]", + "7 ROUND[]", + "9 NROUND[G]", + "9 NROUND[B]", + "9 NROUND[W]", + "8 NROUND[]", + + /* 0x70 */ + "5 WCVTF", + "7 DELTAP2", + "7 DELTAP3", + "7 DELTAC1", + "7 DELTAC2", + "7 DELTAC3", "6 SROUND", - "8 S45Round", + "8 S45ROUND", "4 JROT", "4 JROF", "4 ROFF", @@ -1056,26 +1097,28 @@ "5 SANGW", "2 AA", - "6 FlipPT", - "8 FlipRgON", - "9 FlipRgOFF", + /* 0x80 */ + "6 FLIPPT", + "8 FLIPRGON", + "9 FLIPRGOFF", "7 INS_$83", "7 INS_$84", - "8 ScanCTRL", - "9 SDPvTL[0]", - "9 SDPvTL[1]", - "7 GetINFO", + "8 SCANCTRL", + "A SDPVTL[||]", + "9 SDPVTL[+]", + "7 GETINFO", "4 IDEF", "4 ROLL", "3 MAX", "3 MIN", - "8 ScanTYPE", - "8 InstCTRL", + "8 SCANTYPE", + "8 INSTCTRL", "7 INS_$8F", + /* 0x90 */ "7 INS_$90", #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - "6 GETVAR", + "C GETVARIATION", "7 GETDATA", #else "7 INS_$91", @@ -1095,6 +1138,7 @@ "7 INS_$9E", "7 INS_$9F", + /* 0xA0 */ "7 INS_$A0", "7 INS_$A1", "7 INS_$A2", @@ -1112,90 +1156,95 @@ "7 INS_$AE", "7 INS_$AF", - "8 PushB[0]", - "8 PushB[1]", - "8 PushB[2]", - "8 PushB[3]", - "8 PushB[4]", - "8 PushB[5]", - "8 PushB[6]", - "8 PushB[7]", - "8 PushW[0]", - "8 PushW[1]", - "8 PushW[2]", - "8 PushW[3]", - "8 PushW[4]", - "8 PushW[5]", - "8 PushW[6]", - "8 PushW[7]", - - "8 MDRP[00]", - "8 MDRP[01]", - "8 MDRP[02]", - "8 MDRP[03]", - "8 MDRP[04]", - "8 MDRP[05]", - "8 MDRP[06]", - "8 MDRP[07]", - "8 MDRP[08]", - "8 MDRP[09]", - "8 MDRP[10]", - "8 MDRP[11]", - "8 MDRP[12]", - "8 MDRP[13]", - "8 MDRP[14]", - "8 MDRP[15]", - - "8 MDRP[16]", - "8 MDRP[17]", - "8 MDRP[18]", - "8 MDRP[19]", - "8 MDRP[20]", - "8 MDRP[21]", - "8 MDRP[22]", - "8 MDRP[23]", - "8 MDRP[24]", - "8 MDRP[25]", - "8 MDRP[26]", - "8 MDRP[27]", - "8 MDRP[28]", - "8 MDRP[29]", - "8 MDRP[30]", - "8 MDRP[31]", - - "8 MIRP[00]", - "8 MIRP[01]", - "8 MIRP[02]", - "8 MIRP[03]", - "8 MIRP[04]", - "8 MIRP[05]", - "8 MIRP[06]", - "8 MIRP[07]", - "8 MIRP[08]", - "8 MIRP[09]", - "8 MIRP[10]", - "8 MIRP[11]", - "8 MIRP[12]", - "8 MIRP[13]", - "8 MIRP[14]", - "8 MIRP[15]", - - "8 MIRP[16]", - "8 MIRP[17]", - "8 MIRP[18]", - "8 MIRP[19]", - "8 MIRP[20]", - "8 MIRP[21]", - "8 MIRP[22]", - "8 MIRP[23]", - "8 MIRP[24]", - "8 MIRP[25]", - "8 MIRP[26]", - "8 MIRP[27]", - "8 MIRP[28]", - "8 MIRP[29]", - "8 MIRP[30]", - "8 MIRP[31]" + /* 0xB0 */ + "8 PUSHB[0]", + "8 PUSHB[1]", + "8 PUSHB[2]", + "8 PUSHB[3]", + "8 PUSHB[4]", + "8 PUSHB[5]", + "8 PUSHB[6]", + "8 PUSHB[7]", + "8 PUSHW[0]", + "8 PUSHW[1]", + "8 PUSHW[2]", + "8 PUSHW[3]", + "8 PUSHW[4]", + "8 PUSHW[5]", + "8 PUSHW[6]", + "8 PUSHW[7]", + + /* 0xC0 */ + "7 MDRP[G]", + "7 MDRP[B]", + "7 MDRP[W]", + "6 MDRP[]", + "8 MDRP[rG]", + "8 MDRP[rB]", + "8 MDRP[rW]", + "7 MDRP[r]", + "8 MDRP[mG]", + "8 MDRP[mB]", + "8 MDRP[mW]", + "7 MDRP[m]", + "9 MDRP[mrG]", + "9 MDRP[mrB]", + "9 MDRP[mrW]", + "8 MDRP[mr]", + + /* 0xD0 */ + "8 MDRP[pG]", + "8 MDRP[pB]", + "8 MDRP[pW]", + "7 MDRP[p]", + "9 MDRP[prG]", + "9 MDRP[prB]", + "9 MDRP[prW]", + "8 MDRP[pr]", + "9 MDRP[pmG]", + "9 MDRP[pmB]", + "9 MDRP[pmW]", + "8 MDRP[pm]", + "A MDRP[pmrG]", + "A MDRP[pmrB]", + "A MDRP[pmrW]", + "9 MDRP[pmr]", + + /* 0xE0 */ + "7 MIRP[G]", + "7 MIRP[B]", + "7 MIRP[W]", + "6 MIRP[]", + "8 MIRP[rG]", + "8 MIRP[rB]", + "8 MIRP[rW]", + "7 MIRP[r]", + "8 MIRP[mG]", + "8 MIRP[mB]", + "8 MIRP[mW]", + "7 MIRP[m]", + "9 MIRP[mrG]", + "9 MIRP[mrB]", + "9 MIRP[mrW]", + "8 MIRP[mr]", + + /* 0xF0 */ + "8 MIRP[pG]", + "8 MIRP[pB]", + "8 MIRP[pW]", + "7 MIRP[p]", + "9 MIRP[prG]", + "9 MIRP[prB]", + "9 MIRP[prW]", + "8 MIRP[pr]", + "9 MIRP[pmG]", + "9 MIRP[pmB]", + "9 MIRP[pmW]", + "8 MIRP[pm]", + "A MIRP[pmrG]", + "A MIRP[pmrB]", + "A MIRP[pmrW]", + "9 MIRP[pmr]" }; #endif /* FT_DEBUG_LEVEL_TRACE */ @@ -1448,18 +1497,18 @@ #endif /* TT_DotFix14 */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* Current_Ratio */ - /* */ - /* <Description> */ - /* Returns the current aspect ratio scaling factor depending on the */ - /* projection vector's state and device resolutions. */ - /* */ - /* <Return> */ - /* The aspect ratio in 16.16 format, always <= 1.0 . */ - /* */ + /************************************************************************** + * + * @Function: + * Current_Ratio + * + * @Description: + * Returns the current aspect ratio scaling factor depending on the + * projection vector's state and device resolutions. + * + * @Return: + * The aspect ratio in 16.16 format, always <= 1.0 . + */ static FT_Long Current_Ratio( TT_ExecContext exc ) { @@ -1501,11 +1550,11 @@ } - /*************************************************************************/ - /* */ - /* Functions related to the control value table (CVT). */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Functions related to the control value table (CVT). + * + */ FT_CALLBACK_DEF( FT_F26Dot6 ) @@ -1547,7 +1596,7 @@ FT_ULong idx, FT_F26Dot6 value ) { - exc->cvt[idx] += value; + exc->cvt[idx] = ADD_LONG( exc->cvt[idx], value ); } @@ -1556,25 +1605,26 @@ FT_ULong idx, FT_F26Dot6 value ) { - exc->cvt[idx] += FT_DivFix( value, Current_Ratio( exc ) ); - } - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* GetShortIns */ - /* */ - /* <Description> */ - /* Returns a short integer taken from the instruction stream at */ - /* address IP. */ - /* */ - /* <Return> */ - /* Short read at code[IP]. */ - /* */ - /* <Note> */ - /* This one could become a macro. */ - /* */ + exc->cvt[idx] = ADD_LONG( exc->cvt[idx], + FT_DivFix( value, Current_Ratio( exc ) ) ); + } + + + /************************************************************************** + * + * @Function: + * GetShortIns + * + * @Description: + * Returns a short integer taken from the instruction stream at + * address IP. + * + * @Return: + * Short read at code[IP]. + * + * @Note: + * This one could become a macro. + */ static FT_Short GetShortIns( TT_ExecContext exc ) { @@ -1585,22 +1635,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Ins_Goto_CodeRange */ - /* */ - /* <Description> */ - /* Goes to a certain code range in the instruction stream. */ - /* */ - /* <Input> */ - /* aRange :: The index of the code range. */ - /* */ - /* aIP :: The new IP address in the code range. */ - /* */ - /* <Return> */ - /* SUCCESS or FAILURE. */ - /* */ + /************************************************************************** + * + * @Function: + * Ins_Goto_CodeRange + * + * @Description: + * Goes to a certain code range in the instruction stream. + * + * @Input: + * aRange :: + * The index of the code range. + * + * aIP :: + * The new IP address in the code range. + * + * @Return: + * SUCCESS or FAILURE. + */ static FT_Bool Ins_Goto_CodeRange( TT_ExecContext exc, FT_Int aRange, @@ -1642,27 +1694,56 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Direct_Move */ - /* */ - /* <Description> */ - /* Moves a point by a given distance along the freedom vector. The */ - /* point will be `touched'. */ - /* */ - /* <Input> */ - /* point :: The index of the point to move. */ - /* */ - /* distance :: The distance to apply. */ - /* */ - /* <InOut> */ - /* zone :: The affected glyph zone. */ - /* */ - /* <Note> */ - /* See `ttinterp.h' for details on backward compatibility mode. */ - /* `Touches' the point. */ - /* */ + /* + * + * Apple's TrueType specification at + * + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#order + * + * gives the following order of operations in instructions that move + * points. + * + * - check single width cut-in (MIRP, MDRP) + * + * - check control value cut-in (MIRP, MIAP) + * + * - apply engine compensation (MIRP, MDRP) + * + * - round distance (MIRP, MDRP) or value (MIAP, MDAP) + * + * - check minimum distance (MIRP,MDRP) + * + * - move point (MIRP, MDRP, MIAP, MSIRP, MDAP) + * + * For rounding instructions, engine compensation happens before rounding. + * + */ + + + /************************************************************************** + * + * @Function: + * Direct_Move + * + * @Description: + * Moves a point by a given distance along the freedom vector. The + * point will be `touched'. + * + * @Input: + * point :: + * The index of the point to move. + * + * distance :: + * The distance to apply. + * + * @InOut: + * zone :: + * The affected glyph zone. + * + * @Note: + * See `ttinterp.h' for details on backward compatibility mode. + * `Touches' the point. + */ static void Direct_Move( TT_ExecContext exc, TT_GlyphZone zone, @@ -1728,23 +1809,26 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Direct_Move_Orig */ - /* */ - /* <Description> */ - /* Moves the *original* position of a point by a given distance along */ - /* the freedom vector. Obviously, the point will not be `touched'. */ - /* */ - /* <Input> */ - /* point :: The index of the point to move. */ - /* */ - /* distance :: The distance to apply. */ - /* */ - /* <InOut> */ - /* zone :: The affected glyph zone. */ - /* */ + /************************************************************************** + * + * @Function: + * Direct_Move_Orig + * + * @Description: + * Moves the *original* position of a point by a given distance along + * the freedom vector. Obviously, the point will not be `touched'. + * + * @Input: + * point :: + * The index of the point to move. + * + * distance :: + * The distance to apply. + * + * @InOut: + * zone :: + * The affected glyph zone. + */ static void Direct_Move_Orig( TT_ExecContext exc, TT_GlyphZone zone, @@ -1772,15 +1856,15 @@ } - /*************************************************************************/ - /* */ - /* Special versions of Direct_Move() */ - /* */ - /* The following versions are used whenever both vectors are both */ - /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */ - /* See `ttinterp.h' for details on backward compatibility mode. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Special versions of Direct_Move() + * + * The following versions are used whenever both vectors are both + * along one of the coordinate unit vectors, i.e. in 90% of the cases. + * See `ttinterp.h' for details on backward compatibility mode. + * + */ static void @@ -1827,14 +1911,14 @@ } - /*************************************************************************/ - /* */ - /* Special versions of Direct_Move_Orig() */ - /* */ - /* The following versions are used whenever both vectors are both */ - /* along one of the coordinate unit vectors, i.e. in 90% of the cases. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Special versions of Direct_Move_Orig() + * + * The following versions are used whenever both vectors are both + * along one of the coordinate unit vectors, i.e. in 90% of the cases. + * + */ static void @@ -1860,29 +1944,24 @@ zone->org[point].y = ADD_LONG( zone->org[point].y, distance ); } - - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_None */ - /* */ - /* <Description> */ - /* Does not round, but adds engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance (not) to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* The compensated distance. */ - /* */ - /* <Note> */ - /* The TrueType specification says very few about the relationship */ - /* between rounding and engine compensation. However, it seems from */ - /* the description of super round that we should add the compensation */ - /* before rounding. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_None + * + * @Description: + * Does not round, but adds engine compensation. + * + * @Input: + * distance :: + * The distance (not) to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * The compensated distance. + */ static FT_F26Dot6 Round_None( TT_ExecContext exc, FT_F26Dot6 distance, @@ -1909,22 +1988,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_To_Grid */ - /* */ - /* <Description> */ - /* Rounds value to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_To_Grid + * + * @Description: + * Rounds value to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_To_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -1953,22 +2034,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_To_Half_Grid */ - /* */ - /* <Description> */ - /* Rounds value to half grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_To_Half_Grid + * + * @Description: + * Rounds value to half grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_To_Half_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -1999,22 +2082,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Down_To_Grid */ - /* */ - /* <Description> */ - /* Rounds value down to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Down_To_Grid + * + * @Description: + * Rounds value down to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_Down_To_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2042,22 +2127,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Up_To_Grid */ - /* */ - /* <Description> */ - /* Rounds value up to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Up_To_Grid + * + * @Description: + * Rounds value up to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_Up_To_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2086,22 +2173,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_To_Double_Grid */ - /* */ - /* <Description> */ - /* Rounds value to double grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_To_Double_Grid + * + * @Description: + * Rounds value to double grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + */ static FT_F26Dot6 Round_To_Double_Grid( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2130,28 +2219,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Super */ - /* */ - /* <Description> */ - /* Super-rounds value to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ - /* <Note> */ - /* The TrueType specification says very little about the relationship */ - /* between rounding and engine compensation. However, it seems from */ - /* the description of super round that we should add the compensation */ - /* before rounding. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Super + * + * @Description: + * Super-rounds value to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + * + * @Note: + * The TrueType specification says very little about the relationship + * between rounding and engine compensation. However, it seems from + * the description of super round that we should add the compensation + * before rounding. + */ static FT_F26Dot6 Round_Super( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2183,26 +2274,28 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Round_Super_45 */ - /* */ - /* <Description> */ - /* Super-rounds value to grid after adding engine compensation. */ - /* */ - /* <Input> */ - /* distance :: The distance to round. */ - /* */ - /* compensation :: The engine compensation. */ - /* */ - /* <Return> */ - /* Rounded distance. */ - /* */ - /* <Note> */ - /* There is a separate function for Round_Super_45() as we may need */ - /* greater precision. */ - /* */ + /************************************************************************** + * + * @Function: + * Round_Super_45 + * + * @Description: + * Super-rounds value to grid after adding engine compensation. + * + * @Input: + * distance :: + * The distance to round. + * + * compensation :: + * The engine compensation. + * + * @Return: + * Rounded distance. + * + * @Note: + * There is a separate function for Round_Super_45() as we may need + * greater precision. + */ static FT_F26Dot6 Round_Super_45( TT_ExecContext exc, FT_F26Dot6 distance, @@ -2234,17 +2327,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Compute_Round */ - /* */ - /* <Description> */ - /* Sets the rounding mode. */ - /* */ - /* <Input> */ - /* round_mode :: The rounding mode to be used. */ - /* */ + /************************************************************************** + * + * @Function: + * Compute_Round + * + * @Description: + * Sets the rounding mode. + * + * @Input: + * round_mode :: + * The rounding mode to be used. + */ static void Compute_Round( TT_ExecContext exc, FT_Byte round_mode ) @@ -2286,19 +2380,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* SetSuperRound */ - /* */ - /* <Description> */ - /* Sets Super Round parameters. */ - /* */ - /* <Input> */ - /* GridPeriod :: The grid period. */ - /* */ - /* selector :: The SROUND opcode. */ - /* */ + /************************************************************************** + * + * @Function: + * SetSuperRound + * + * @Description: + * Sets Super Round parameters. + * + * @Input: + * GridPeriod :: + * The grid period. + * + * selector :: + * The SROUND opcode. + */ static void SetSuperRound( TT_ExecContext exc, FT_F2Dot14 GridPeriod, @@ -2355,22 +2451,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Project */ - /* */ - /* <Description> */ - /* Computes the projection of vector given by (v2-v1) along the */ - /* current projection vector. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Project + * + * @Description: + * Computes the projection of vector given by (v2-v1) along the + * current projection vector. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Project( TT_ExecContext exc, FT_Pos dx, @@ -2382,22 +2480,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Dual_Project */ - /* */ - /* <Description> */ - /* Computes the projection of the vector given by (v2-v1) along the */ - /* current dual vector. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Dual_Project + * + * @Description: + * Computes the projection of the vector given by (v2-v1) along the + * current dual vector. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Dual_Project( TT_ExecContext exc, FT_Pos dx, @@ -2409,22 +2509,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Project_x */ - /* */ - /* <Description> */ - /* Computes the projection of the vector given by (v2-v1) along the */ - /* horizontal axis. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Project_x + * + * @Description: + * Computes the projection of the vector given by (v2-v1) along the + * horizontal axis. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Project_x( TT_ExecContext exc, FT_Pos dx, @@ -2437,22 +2539,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Project_y */ - /* */ - /* <Description> */ - /* Computes the projection of the vector given by (v2-v1) along the */ - /* vertical axis. */ - /* */ - /* <Input> */ - /* v1 :: First input vector. */ - /* v2 :: Second input vector. */ - /* */ - /* <Return> */ - /* The distance in F26dot6 format. */ - /* */ + /************************************************************************** + * + * @Function: + * Project_y + * + * @Description: + * Computes the projection of the vector given by (v2-v1) along the + * vertical axis. + * + * @Input: + * v1 :: + * First input vector. + * v2 :: + * Second input vector. + * + * @Return: + * The distance in F26dot6 format. + */ static FT_F26Dot6 Project_y( TT_ExecContext exc, FT_Pos dx, @@ -2465,15 +2569,15 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Compute_Funcs */ - /* */ - /* <Description> */ - /* Computes the projection and movement function pointers according */ - /* to the current graphics state. */ - /* */ + /************************************************************************** + * + * @Function: + * Compute_Funcs + * + * @Description: + * Computes the projection and movement function pointers according + * to the current graphics state. + */ static void Compute_Funcs( TT_ExecContext exc ) { @@ -2528,28 +2632,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* Normalize */ - /* */ - /* <Description> */ - /* Norms a vector. */ - /* */ - /* <Input> */ - /* Vx :: The horizontal input vector coordinate. */ - /* Vy :: The vertical input vector coordinate. */ - /* */ - /* <Output> */ - /* R :: The normed unit vector. */ - /* */ - /* <Return> */ - /* Returns FAILURE if a vector parameter is zero. */ - /* */ - /* <Note> */ - /* In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and */ - /* R is undefined. */ - /* */ + /************************************************************************** + * + * @Function: + * Normalize + * + * @Description: + * Norms a vector. + * + * @Input: + * Vx :: + * The horizontal input vector coordinate. + * Vy :: + * The vertical input vector coordinate. + * + * @Output: + * R :: + * The normed unit vector. + * + * @Return: + * Returns FAILURE if a vector parameter is zero. + * + * @Note: + * In case Vx and Vy are both zero, `Normalize' returns SUCCESS, and + * R is undefined. + */ static FT_Bool Normalize( FT_F26Dot6 Vx, FT_F26Dot6 Vy, @@ -2577,11 +2684,11 @@ } - /*************************************************************************/ - /* */ - /* Here we start with the implementation of the various opcodes. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Here we start with the implementation of the various opcodes. + * + */ #define ARRAY_BOUND_ERROR \ @@ -2592,12 +2699,12 @@ } while (0) - /*************************************************************************/ - /* */ - /* MPPEM[]: Measure Pixel Per EM */ - /* Opcode range: 0x4B */ - /* Stack: --> Euint16 */ - /* */ + /************************************************************************** + * + * MPPEM[]: Measure Pixel Per EM + * Opcode range: 0x4B + * Stack: --> Euint16 + */ static void Ins_MPPEM( TT_ExecContext exc, FT_Long* args ) @@ -2606,12 +2713,12 @@ } - /*************************************************************************/ - /* */ - /* MPS[]: Measure Point Size */ - /* Opcode range: 0x4C */ - /* Stack: --> Euint16 */ - /* */ + /************************************************************************** + * + * MPS[]: Measure Point Size + * Opcode range: 0x4C + * Stack: --> Euint16 + */ static void Ins_MPS( TT_ExecContext exc, FT_Long* args ) @@ -2633,12 +2740,12 @@ } - /*************************************************************************/ - /* */ - /* DUP[]: DUPlicate the stack's top element */ - /* Opcode range: 0x20 */ - /* Stack: StkElt --> StkElt StkElt */ - /* */ + /************************************************************************** + * + * DUP[]: DUPlicate the stack's top element + * Opcode range: 0x20 + * Stack: StkElt --> StkElt StkElt + */ static void Ins_DUP( FT_Long* args ) { @@ -2646,12 +2753,12 @@ } - /*************************************************************************/ - /* */ - /* POP[]: POP the stack's top element */ - /* Opcode range: 0x21 */ - /* Stack: StkElt --> */ - /* */ + /************************************************************************** + * + * POP[]: POP the stack's top element + * Opcode range: 0x21 + * Stack: StkElt --> + */ static void Ins_POP( void ) { @@ -2659,12 +2766,12 @@ } - /*************************************************************************/ - /* */ - /* CLEAR[]: CLEAR the entire stack */ - /* Opcode range: 0x22 */ - /* Stack: StkElt... --> */ - /* */ + /************************************************************************** + * + * CLEAR[]: CLEAR the entire stack + * Opcode range: 0x22 + * Stack: StkElt... --> + */ static void Ins_CLEAR( TT_ExecContext exc ) { @@ -2672,12 +2779,12 @@ } - /*************************************************************************/ - /* */ - /* SWAP[]: SWAP the stack's top two elements */ - /* Opcode range: 0x23 */ - /* Stack: 2 * StkElt --> 2 * StkElt */ - /* */ + /************************************************************************** + * + * SWAP[]: SWAP the stack's top two elements + * Opcode range: 0x23 + * Stack: 2 * StkElt --> 2 * StkElt + */ static void Ins_SWAP( FT_Long* args ) { @@ -2690,12 +2797,12 @@ } - /*************************************************************************/ - /* */ - /* DEPTH[]: return the stack DEPTH */ - /* Opcode range: 0x24 */ - /* Stack: --> uint32 */ - /* */ + /************************************************************************** + * + * DEPTH[]: return the stack DEPTH + * Opcode range: 0x24 + * Stack: --> uint32 + */ static void Ins_DEPTH( TT_ExecContext exc, FT_Long* args ) @@ -2704,12 +2811,12 @@ } - /*************************************************************************/ - /* */ - /* LT[]: Less Than */ - /* Opcode range: 0x50 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * LT[]: Less Than + * Opcode range: 0x50 + * Stack: int32? int32? --> bool + */ static void Ins_LT( FT_Long* args ) { @@ -2717,12 +2824,12 @@ } - /*************************************************************************/ - /* */ - /* LTEQ[]: Less Than or EQual */ - /* Opcode range: 0x51 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * LTEQ[]: Less Than or EQual + * Opcode range: 0x51 + * Stack: int32? int32? --> bool + */ static void Ins_LTEQ( FT_Long* args ) { @@ -2730,12 +2837,12 @@ } - /*************************************************************************/ - /* */ - /* GT[]: Greater Than */ - /* Opcode range: 0x52 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * GT[]: Greater Than + * Opcode range: 0x52 + * Stack: int32? int32? --> bool + */ static void Ins_GT( FT_Long* args ) { @@ -2743,12 +2850,12 @@ } - /*************************************************************************/ - /* */ - /* GTEQ[]: Greater Than or EQual */ - /* Opcode range: 0x53 */ - /* Stack: int32? int32? --> bool */ - /* */ + /************************************************************************** + * + * GTEQ[]: Greater Than or EQual + * Opcode range: 0x53 + * Stack: int32? int32? --> bool + */ static void Ins_GTEQ( FT_Long* args ) { @@ -2756,12 +2863,12 @@ } - /*************************************************************************/ - /* */ - /* EQ[]: EQual */ - /* Opcode range: 0x54 */ - /* Stack: StkElt StkElt --> bool */ - /* */ + /************************************************************************** + * + * EQ[]: EQual + * Opcode range: 0x54 + * Stack: StkElt StkElt --> bool + */ static void Ins_EQ( FT_Long* args ) { @@ -2769,12 +2876,12 @@ } - /*************************************************************************/ - /* */ - /* NEQ[]: Not EQual */ - /* Opcode range: 0x55 */ - /* Stack: StkElt StkElt --> bool */ - /* */ + /************************************************************************** + * + * NEQ[]: Not EQual + * Opcode range: 0x55 + * Stack: StkElt StkElt --> bool + */ static void Ins_NEQ( FT_Long* args ) { @@ -2782,12 +2889,12 @@ } - /*************************************************************************/ - /* */ - /* ODD[]: Is ODD */ - /* Opcode range: 0x56 */ - /* Stack: f26.6 --> bool */ - /* */ + /************************************************************************** + * + * ODD[]: Is ODD + * Opcode range: 0x56 + * Stack: f26.6 --> bool + */ static void Ins_ODD( TT_ExecContext exc, FT_Long* args ) @@ -2796,12 +2903,12 @@ } - /*************************************************************************/ - /* */ - /* EVEN[]: Is EVEN */ - /* Opcode range: 0x57 */ - /* Stack: f26.6 --> bool */ - /* */ + /************************************************************************** + * + * EVEN[]: Is EVEN + * Opcode range: 0x57 + * Stack: f26.6 --> bool + */ static void Ins_EVEN( TT_ExecContext exc, FT_Long* args ) @@ -2810,12 +2917,12 @@ } - /*************************************************************************/ - /* */ - /* AND[]: logical AND */ - /* Opcode range: 0x5A */ - /* Stack: uint32 uint32 --> uint32 */ - /* */ + /************************************************************************** + * + * AND[]: logical AND + * Opcode range: 0x5A + * Stack: uint32 uint32 --> uint32 + */ static void Ins_AND( FT_Long* args ) { @@ -2823,12 +2930,12 @@ } - /*************************************************************************/ - /* */ - /* OR[]: logical OR */ - /* Opcode range: 0x5B */ - /* Stack: uint32 uint32 --> uint32 */ - /* */ + /************************************************************************** + * + * OR[]: logical OR + * Opcode range: 0x5B + * Stack: uint32 uint32 --> uint32 + */ static void Ins_OR( FT_Long* args ) { @@ -2836,12 +2943,12 @@ } - /*************************************************************************/ - /* */ - /* NOT[]: logical NOT */ - /* Opcode range: 0x5C */ - /* Stack: StkElt --> uint32 */ - /* */ + /************************************************************************** + * + * NOT[]: logical NOT + * Opcode range: 0x5C + * Stack: StkElt --> uint32 + */ static void Ins_NOT( FT_Long* args ) { @@ -2849,12 +2956,12 @@ } - /*************************************************************************/ - /* */ - /* ADD[]: ADD */ - /* Opcode range: 0x60 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * ADD[]: ADD + * Opcode range: 0x60 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_ADD( FT_Long* args ) { @@ -2862,12 +2969,12 @@ } - /*************************************************************************/ - /* */ - /* SUB[]: SUBtract */ - /* Opcode range: 0x61 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * SUB[]: SUBtract + * Opcode range: 0x61 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_SUB( FT_Long* args ) { @@ -2875,12 +2982,12 @@ } - /*************************************************************************/ - /* */ - /* DIV[]: DIVide */ - /* Opcode range: 0x62 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * DIV[]: DIVide + * Opcode range: 0x62 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_DIV( TT_ExecContext exc, FT_Long* args ) @@ -2892,12 +2999,12 @@ } - /*************************************************************************/ - /* */ - /* MUL[]: MULtiply */ - /* Opcode range: 0x63 */ - /* Stack: f26.6 f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * MUL[]: MULtiply + * Opcode range: 0x63 + * Stack: f26.6 f26.6 --> f26.6 + */ static void Ins_MUL( FT_Long* args ) { @@ -2905,12 +3012,12 @@ } - /*************************************************************************/ - /* */ - /* ABS[]: ABSolute value */ - /* Opcode range: 0x64 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * ABS[]: ABSolute value + * Opcode range: 0x64 + * Stack: f26.6 --> f26.6 + */ static void Ins_ABS( FT_Long* args ) { @@ -2919,12 +3026,12 @@ } - /*************************************************************************/ - /* */ - /* NEG[]: NEGate */ - /* Opcode range: 0x65 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * NEG[]: NEGate + * Opcode range: 0x65 + * Stack: f26.6 --> f26.6 + */ static void Ins_NEG( FT_Long* args ) { @@ -2932,12 +3039,12 @@ } - /*************************************************************************/ - /* */ - /* FLOOR[]: FLOOR */ - /* Opcode range: 0x66 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * FLOOR[]: FLOOR + * Opcode range: 0x66 + * Stack: f26.6 --> f26.6 + */ static void Ins_FLOOR( FT_Long* args ) { @@ -2945,12 +3052,12 @@ } - /*************************************************************************/ - /* */ - /* CEILING[]: CEILING */ - /* Opcode range: 0x67 */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * CEILING[]: CEILING + * Opcode range: 0x67 + * Stack: f26.6 --> f26.6 + */ static void Ins_CEILING( FT_Long* args ) { @@ -2958,12 +3065,12 @@ } - /*************************************************************************/ - /* */ - /* RS[]: Read Store */ - /* Opcode range: 0x43 */ - /* Stack: uint32 --> uint32 */ - /* */ + /************************************************************************** + * + * RS[]: Read Store + * Opcode range: 0x43 + * Stack: uint32 --> uint32 + */ static void Ins_RS( TT_ExecContext exc, FT_Long* args ) @@ -3004,12 +3111,12 @@ } - /*************************************************************************/ - /* */ - /* WS[]: Write Store */ - /* Opcode range: 0x42 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * WS[]: Write Store + * Opcode range: 0x42 + * Stack: uint32 uint32 --> + */ static void Ins_WS( TT_ExecContext exc, FT_Long* args ) @@ -3027,12 +3134,12 @@ } - /*************************************************************************/ - /* */ - /* WCVTP[]: Write CVT in Pixel units */ - /* Opcode range: 0x44 */ - /* Stack: f26.6 uint32 --> */ - /* */ + /************************************************************************** + * + * WCVTP[]: Write CVT in Pixel units + * Opcode range: 0x44 + * Stack: f26.6 uint32 --> + */ static void Ins_WCVTP( TT_ExecContext exc, FT_Long* args ) @@ -3050,12 +3157,12 @@ } - /*************************************************************************/ - /* */ - /* WCVTF[]: Write CVT in Funits */ - /* Opcode range: 0x70 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * WCVTF[]: Write CVT in Funits + * Opcode range: 0x70 + * Stack: uint32 uint32 --> + */ static void Ins_WCVTF( TT_ExecContext exc, FT_Long* args ) @@ -3073,12 +3180,12 @@ } - /*************************************************************************/ - /* */ - /* RCVT[]: Read CVT */ - /* Opcode range: 0x45 */ - /* Stack: uint32 --> f26.6 */ - /* */ + /************************************************************************** + * + * RCVT[]: Read CVT + * Opcode range: 0x45 + * Stack: uint32 --> f26.6 + */ static void Ins_RCVT( TT_ExecContext exc, FT_Long* args ) @@ -3098,12 +3205,12 @@ } - /*************************************************************************/ - /* */ - /* AA[]: Adjust Angle */ - /* Opcode range: 0x7F */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * AA[]: Adjust Angle + * Opcode range: 0x7F + * Stack: uint32 --> + */ static void Ins_AA( void ) { @@ -3111,14 +3218,14 @@ } - /*************************************************************************/ - /* */ - /* DEBUG[]: DEBUG. Unsupported. */ - /* Opcode range: 0x4F */ - /* Stack: uint32 --> */ - /* */ - /* Note: The original instruction pops a value from the stack. */ - /* */ + /************************************************************************** + * + * DEBUG[]: DEBUG. Unsupported. + * Opcode range: 0x4F + * Stack: uint32 --> + * + * Note: The original instruction pops a value from the stack. + */ static void Ins_DEBUG( TT_ExecContext exc ) { @@ -3126,12 +3233,12 @@ } - /*************************************************************************/ - /* */ - /* ROUND[ab]: ROUND value */ - /* Opcode range: 0x68-0x6B */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * ROUND[ab]: ROUND value + * Opcode range: 0x68-0x6B + * Stack: f26.6 --> f26.6 + */ static void Ins_ROUND( TT_ExecContext exc, FT_Long* args ) @@ -3143,12 +3250,12 @@ } - /*************************************************************************/ - /* */ - /* NROUND[ab]: No ROUNDing of value */ - /* Opcode range: 0x6C-0x6F */ - /* Stack: f26.6 --> f26.6 */ - /* */ + /************************************************************************** + * + * NROUND[ab]: No ROUNDing of value + * Opcode range: 0x6C-0x6F + * Stack: f26.6 --> f26.6 + */ static void Ins_NROUND( TT_ExecContext exc, FT_Long* args ) @@ -3160,12 +3267,12 @@ } - /*************************************************************************/ - /* */ - /* MAX[]: MAXimum */ - /* Opcode range: 0x8B */ - /* Stack: int32? int32? --> int32 */ - /* */ + /************************************************************************** + * + * MAX[]: MAXimum + * Opcode range: 0x8B + * Stack: int32? int32? --> int32 + */ static void Ins_MAX( FT_Long* args ) { @@ -3174,12 +3281,12 @@ } - /*************************************************************************/ - /* */ - /* MIN[]: MINimum */ - /* Opcode range: 0x8C */ - /* Stack: int32? int32? --> int32 */ - /* */ + /************************************************************************** + * + * MIN[]: MINimum + * Opcode range: 0x8C + * Stack: int32? int32? --> int32 + */ static void Ins_MIN( FT_Long* args ) { @@ -3188,12 +3295,12 @@ } - /*************************************************************************/ - /* */ - /* MINDEX[]: Move INDEXed element */ - /* Opcode range: 0x26 */ - /* Stack: int32? --> StkElt */ - /* */ + /************************************************************************** + * + * MINDEX[]: Move INDEXed element + * Opcode range: 0x26 + * Stack: int32? --> StkElt + */ static void Ins_MINDEX( TT_ExecContext exc, FT_Long* args ) @@ -3221,12 +3328,12 @@ } - /*************************************************************************/ - /* */ - /* CINDEX[]: Copy INDEXed element */ - /* Opcode range: 0x25 */ - /* Stack: int32 --> StkElt */ - /* */ + /************************************************************************** + * + * CINDEX[]: Copy INDEXed element + * Opcode range: 0x25 + * Stack: int32 --> StkElt + */ static void Ins_CINDEX( TT_ExecContext exc, FT_Long* args ) @@ -3247,12 +3354,12 @@ } - /*************************************************************************/ - /* */ - /* ROLL[]: ROLL top three elements */ - /* Opcode range: 0x8A */ - /* Stack: 3 * StkElt --> 3 * StkElt */ - /* */ + /************************************************************************** + * + * ROLL[]: ROLL top three elements + * Opcode range: 0x8A + * Stack: 3 * StkElt --> 3 * StkElt + */ static void Ins_ROLL( FT_Long* args ) { @@ -3269,19 +3376,19 @@ } - /*************************************************************************/ - /* */ - /* MANAGING THE FLOW OF CONTROL */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MANAGING THE FLOW OF CONTROL + * + */ - /*************************************************************************/ - /* */ - /* SLOOP[]: Set LOOP variable */ - /* Opcode range: 0x17 */ - /* Stack: int32? --> */ - /* */ + /************************************************************************** + * + * SLOOP[]: Set LOOP variable + * Opcode range: 0x17 + * Stack: int32? --> + */ static void Ins_SLOOP( TT_ExecContext exc, FT_Long* args ) @@ -3323,12 +3430,12 @@ } - /*************************************************************************/ - /* */ - /* IF[]: IF test */ - /* Opcode range: 0x58 */ - /* Stack: StkElt --> */ - /* */ + /************************************************************************** + * + * IF[]: IF test + * Opcode range: 0x58 + * Stack: StkElt --> + */ static void Ins_IF( TT_ExecContext exc, FT_Long* args ) @@ -3367,12 +3474,12 @@ } - /*************************************************************************/ - /* */ - /* ELSE[]: ELSE */ - /* Opcode range: 0x1B */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * ELSE[]: ELSE + * Opcode range: 0x1B + * Stack: --> + */ static void Ins_ELSE( TT_ExecContext exc ) { @@ -3400,12 +3507,12 @@ } - /*************************************************************************/ - /* */ - /* EIF[]: End IF */ - /* Opcode range: 0x59 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * EIF[]: End IF + * Opcode range: 0x59 + * Stack: --> + */ static void Ins_EIF( void ) { @@ -3413,12 +3520,12 @@ } - /*************************************************************************/ - /* */ - /* JMPR[]: JuMP Relative */ - /* Opcode range: 0x1C */ - /* Stack: int32 --> */ - /* */ + /************************************************************************** + * + * JMPR[]: JuMP Relative + * Opcode range: 0x1C + * Stack: int32 --> + */ static void Ins_JMPR( TT_ExecContext exc, FT_Long* args ) @@ -3448,12 +3555,12 @@ } - /*************************************************************************/ - /* */ - /* JROT[]: Jump Relative On True */ - /* Opcode range: 0x78 */ - /* Stack: StkElt int32 --> */ - /* */ + /************************************************************************** + * + * JROT[]: Jump Relative On True + * Opcode range: 0x78 + * Stack: StkElt int32 --> + */ static void Ins_JROT( TT_ExecContext exc, FT_Long* args ) @@ -3463,12 +3570,12 @@ } - /*************************************************************************/ - /* */ - /* JROF[]: Jump Relative On False */ - /* Opcode range: 0x79 */ - /* Stack: StkElt int32 --> */ - /* */ + /************************************************************************** + * + * JROF[]: Jump Relative On False + * Opcode range: 0x79 + * Stack: StkElt int32 --> + */ static void Ins_JROF( TT_ExecContext exc, FT_Long* args ) @@ -3478,19 +3585,19 @@ } - /*************************************************************************/ - /* */ - /* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * DEFINING AND USING FUNCTIONS AND INSTRUCTIONS + * + */ - /*************************************************************************/ - /* */ - /* FDEF[]: Function DEFinition */ - /* Opcode range: 0x2C */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * FDEF[]: Function DEFinition + * Opcode range: 0x2C + * Stack: uint32 --> + */ static void Ins_FDEF( TT_ExecContext exc, FT_Long* args ) @@ -3788,12 +3895,12 @@ } - /*************************************************************************/ - /* */ - /* ENDF[]: END Function definition */ - /* Opcode range: 0x2D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * ENDF[]: END Function definition + * Opcode range: 0x2D + * Stack: --> + */ static void Ins_ENDF( TT_ExecContext exc ) { @@ -3837,12 +3944,12 @@ } - /*************************************************************************/ - /* */ - /* CALL[]: CALL function */ - /* Opcode range: 0x2B */ - /* Stack: uint32? --> */ - /* */ + /************************************************************************** + * + * CALL[]: CALL function + * Opcode range: 0x2B + * Stack: uint32? --> + */ static void Ins_CALL( TT_ExecContext exc, FT_Long* args ) @@ -3926,12 +4033,12 @@ } - /*************************************************************************/ - /* */ - /* LOOPCALL[]: LOOP and CALL function */ - /* Opcode range: 0x2A */ - /* Stack: uint32? Eint16? --> */ - /* */ + /************************************************************************** + * + * LOOPCALL[]: LOOP and CALL function + * Opcode range: 0x2A + * Stack: uint32? Eint16? --> + */ static void Ins_LOOPCALL( TT_ExecContext exc, FT_Long* args ) @@ -4019,12 +4126,12 @@ } - /*************************************************************************/ - /* */ - /* IDEF[]: Instruction DEFinition */ - /* Opcode range: 0x89 */ - /* Stack: Eint8 --> */ - /* */ + /************************************************************************** + * + * IDEF[]: Instruction DEFinition + * Opcode range: 0x89 + * Stack: Eint8 --> + */ static void Ins_IDEF( TT_ExecContext exc, FT_Long* args ) @@ -4094,19 +4201,19 @@ } - /*************************************************************************/ - /* */ - /* PUSHING DATA ONTO THE INTERPRETER STACK */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * PUSHING DATA ONTO THE INTERPRETER STACK + * + */ - /*************************************************************************/ - /* */ - /* NPUSHB[]: PUSH N Bytes */ - /* Opcode range: 0x40 */ - /* Stack: --> uint32... */ - /* */ + /************************************************************************** + * + * NPUSHB[]: PUSH N Bytes + * Opcode range: 0x40 + * Stack: --> uint32... + */ static void Ins_NPUSHB( TT_ExecContext exc, FT_Long* args ) @@ -4129,12 +4236,12 @@ } - /*************************************************************************/ - /* */ - /* NPUSHW[]: PUSH N Words */ - /* Opcode range: 0x41 */ - /* Stack: --> int32... */ - /* */ + /************************************************************************** + * + * NPUSHW[]: PUSH N Words + * Opcode range: 0x41 + * Stack: --> int32... + */ static void Ins_NPUSHW( TT_ExecContext exc, FT_Long* args ) @@ -4160,12 +4267,12 @@ } - /*************************************************************************/ - /* */ - /* PUSHB[abc]: PUSH Bytes */ - /* Opcode range: 0xB0-0xB7 */ - /* Stack: --> uint32... */ - /* */ + /************************************************************************** + * + * PUSHB[abc]: PUSH Bytes + * Opcode range: 0xB0-0xB7 + * Stack: --> uint32... + */ static void Ins_PUSHB( TT_ExecContext exc, FT_Long* args ) @@ -4186,12 +4293,12 @@ } - /*************************************************************************/ - /* */ - /* PUSHW[abc]: PUSH Words */ - /* Opcode range: 0xB8-0xBF */ - /* Stack: --> int32... */ - /* */ + /************************************************************************** + * + * PUSHW[abc]: PUSH Words + * Opcode range: 0xB8-0xBF + * Stack: --> int32... + */ static void Ins_PUSHW( TT_ExecContext exc, FT_Long* args ) @@ -4216,11 +4323,11 @@ } - /*************************************************************************/ - /* */ - /* MANAGING THE GRAPHICS STATE */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MANAGING THE GRAPHICS STATE + * + */ static FT_Bool @@ -4274,20 +4381,20 @@ } - /*************************************************************************/ - /* */ - /* SVTCA[a]: Set (F and P) Vectors to Coordinate Axis */ - /* Opcode range: 0x00-0x01 */ - /* Stack: --> */ - /* */ - /* SPvTCA[a]: Set PVector to Coordinate Axis */ - /* Opcode range: 0x02-0x03 */ - /* Stack: --> */ - /* */ - /* SFvTCA[a]: Set FVector to Coordinate Axis */ - /* Opcode range: 0x04-0x05 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * SVTCA[a]: Set (F and P) Vectors to Coordinate Axis + * Opcode range: 0x00-0x01 + * Stack: --> + * + * SPvTCA[a]: Set PVector to Coordinate Axis + * Opcode range: 0x02-0x03 + * Stack: --> + * + * SFvTCA[a]: Set FVector to Coordinate Axis + * Opcode range: 0x04-0x05 + * Stack: --> + */ static void Ins_SxyTCA( TT_ExecContext exc ) { @@ -4318,12 +4425,12 @@ } - /*************************************************************************/ - /* */ - /* SPvTL[a]: Set PVector To Line */ - /* Opcode range: 0x06-0x07 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * SPvTL[a]: Set PVector To Line + * Opcode range: 0x06-0x07 + * Stack: uint32 uint32 --> + */ static void Ins_SPVTL( TT_ExecContext exc, FT_Long* args ) @@ -4339,12 +4446,12 @@ } - /*************************************************************************/ - /* */ - /* SFvTL[a]: Set FVector To Line */ - /* Opcode range: 0x08-0x09 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * SFvTL[a]: Set FVector To Line + * Opcode range: 0x08-0x09 + * Stack: uint32 uint32 --> + */ static void Ins_SFVTL( TT_ExecContext exc, FT_Long* args ) @@ -4359,12 +4466,12 @@ } - /*************************************************************************/ - /* */ - /* SFvTPv[]: Set FVector To PVector */ - /* Opcode range: 0x0E */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * SFvTPv[]: Set FVector To PVector + * Opcode range: 0x0E + * Stack: --> + */ static void Ins_SFVTPV( TT_ExecContext exc ) { @@ -4373,12 +4480,12 @@ } - /*************************************************************************/ - /* */ - /* SPvFS[]: Set PVector From Stack */ - /* Opcode range: 0x0A */ - /* Stack: f2.14 f2.14 --> */ - /* */ + /************************************************************************** + * + * SPvFS[]: Set PVector From Stack + * Opcode range: 0x0A + * Stack: f2.14 f2.14 --> + */ static void Ins_SPVFS( TT_ExecContext exc, FT_Long* args ) @@ -4400,12 +4507,12 @@ } - /*************************************************************************/ - /* */ - /* SFvFS[]: Set FVector From Stack */ - /* Opcode range: 0x0B */ - /* Stack: f2.14 f2.14 --> */ - /* */ + /************************************************************************** + * + * SFvFS[]: Set FVector From Stack + * Opcode range: 0x0B + * Stack: f2.14 f2.14 --> + */ static void Ins_SFVFS( TT_ExecContext exc, FT_Long* args ) @@ -4425,12 +4532,12 @@ } - /*************************************************************************/ - /* */ - /* GPv[]: Get Projection Vector */ - /* Opcode range: 0x0C */ - /* Stack: ef2.14 --> ef2.14 */ - /* */ + /************************************************************************** + * + * GPv[]: Get Projection Vector + * Opcode range: 0x0C + * Stack: ef2.14 --> ef2.14 + */ static void Ins_GPV( TT_ExecContext exc, FT_Long* args ) @@ -4440,12 +4547,12 @@ } - /*************************************************************************/ - /* */ - /* GFv[]: Get Freedom Vector */ - /* Opcode range: 0x0D */ - /* Stack: ef2.14 --> ef2.14 */ - /* */ + /************************************************************************** + * + * GFv[]: Get Freedom Vector + * Opcode range: 0x0D + * Stack: ef2.14 --> ef2.14 + */ static void Ins_GFV( TT_ExecContext exc, FT_Long* args ) @@ -4455,12 +4562,12 @@ } - /*************************************************************************/ - /* */ - /* SRP0[]: Set Reference Point 0 */ - /* Opcode range: 0x10 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SRP0[]: Set Reference Point 0 + * Opcode range: 0x10 + * Stack: uint32 --> + */ static void Ins_SRP0( TT_ExecContext exc, FT_Long* args ) @@ -4469,12 +4576,12 @@ } - /*************************************************************************/ - /* */ - /* SRP1[]: Set Reference Point 1 */ - /* Opcode range: 0x11 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SRP1[]: Set Reference Point 1 + * Opcode range: 0x11 + * Stack: uint32 --> + */ static void Ins_SRP1( TT_ExecContext exc, FT_Long* args ) @@ -4483,12 +4590,12 @@ } - /*************************************************************************/ - /* */ - /* SRP2[]: Set Reference Point 2 */ - /* Opcode range: 0x12 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SRP2[]: Set Reference Point 2 + * Opcode range: 0x12 + * Stack: uint32 --> + */ static void Ins_SRP2( TT_ExecContext exc, FT_Long* args ) @@ -4497,12 +4604,12 @@ } - /*************************************************************************/ - /* */ - /* SMD[]: Set Minimum Distance */ - /* Opcode range: 0x1A */ - /* Stack: f26.6 --> */ - /* */ + /************************************************************************** + * + * SMD[]: Set Minimum Distance + * Opcode range: 0x1A + * Stack: f26.6 --> + */ static void Ins_SMD( TT_ExecContext exc, FT_Long* args ) @@ -4511,12 +4618,12 @@ } - /*************************************************************************/ - /* */ - /* SCVTCI[]: Set Control Value Table Cut In */ - /* Opcode range: 0x1D */ - /* Stack: f26.6 --> */ - /* */ + /************************************************************************** + * + * SCVTCI[]: Set Control Value Table Cut In + * Opcode range: 0x1D + * Stack: f26.6 --> + */ static void Ins_SCVTCI( TT_ExecContext exc, FT_Long* args ) @@ -4525,12 +4632,12 @@ } - /*************************************************************************/ - /* */ - /* SSWCI[]: Set Single Width Cut In */ - /* Opcode range: 0x1E */ - /* Stack: f26.6 --> */ - /* */ + /************************************************************************** + * + * SSWCI[]: Set Single Width Cut In + * Opcode range: 0x1E + * Stack: f26.6 --> + */ static void Ins_SSWCI( TT_ExecContext exc, FT_Long* args ) @@ -4539,12 +4646,12 @@ } - /*************************************************************************/ - /* */ - /* SSW[]: Set Single Width */ - /* Opcode range: 0x1F */ - /* Stack: int32? --> */ - /* */ + /************************************************************************** + * + * SSW[]: Set Single Width + * Opcode range: 0x1F + * Stack: int32? --> + */ static void Ins_SSW( TT_ExecContext exc, FT_Long* args ) @@ -4554,12 +4661,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPON[]: Set auto-FLIP to ON */ - /* Opcode range: 0x4D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * FLIPON[]: Set auto-FLIP to ON + * Opcode range: 0x4D + * Stack: --> + */ static void Ins_FLIPON( TT_ExecContext exc ) { @@ -4567,12 +4674,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPOFF[]: Set auto-FLIP to OFF */ - /* Opcode range: 0x4E */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * FLIPOFF[]: Set auto-FLIP to OFF + * Opcode range: 0x4E + * Stack: --> + */ static void Ins_FLIPOFF( TT_ExecContext exc ) { @@ -4580,12 +4687,12 @@ } - /*************************************************************************/ - /* */ - /* SANGW[]: Set ANGle Weight */ - /* Opcode range: 0x7E */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SANGW[]: Set ANGle Weight + * Opcode range: 0x7E + * Stack: uint32 --> + */ static void Ins_SANGW( void ) { @@ -4593,12 +4700,12 @@ } - /*************************************************************************/ - /* */ - /* SDB[]: Set Delta Base */ - /* Opcode range: 0x5E */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SDB[]: Set Delta Base + * Opcode range: 0x5E + * Stack: uint32 --> + */ static void Ins_SDB( TT_ExecContext exc, FT_Long* args ) @@ -4607,12 +4714,12 @@ } - /*************************************************************************/ - /* */ - /* SDS[]: Set Delta Shift */ - /* Opcode range: 0x5F */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SDS[]: Set Delta Shift + * Opcode range: 0x5F + * Stack: uint32 --> + */ static void Ins_SDS( TT_ExecContext exc, FT_Long* args ) @@ -4624,12 +4731,12 @@ } - /*************************************************************************/ - /* */ - /* RTHG[]: Round To Half Grid */ - /* Opcode range: 0x19 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * RTHG[]: Round To Half Grid + * Opcode range: 0x19 + * Stack: --> + */ static void Ins_RTHG( TT_ExecContext exc ) { @@ -4638,12 +4745,12 @@ } - /*************************************************************************/ - /* */ - /* RTG[]: Round To Grid */ - /* Opcode range: 0x18 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * RTG[]: Round To Grid + * Opcode range: 0x18 + * Stack: --> + */ static void Ins_RTG( TT_ExecContext exc ) { @@ -4652,11 +4759,11 @@ } - /*************************************************************************/ - /* RTDG[]: Round To Double Grid */ - /* Opcode range: 0x3D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * RTDG[]: Round To Double Grid + * Opcode range: 0x3D + * Stack: --> + */ static void Ins_RTDG( TT_ExecContext exc ) { @@ -4665,11 +4772,11 @@ } - /*************************************************************************/ - /* RUTG[]: Round Up To Grid */ - /* Opcode range: 0x7C */ - /* Stack: --> */ - /* */ + /************************************************************************** + * RUTG[]: Round Up To Grid + * Opcode range: 0x7C + * Stack: --> + */ static void Ins_RUTG( TT_ExecContext exc ) { @@ -4678,12 +4785,12 @@ } - /*************************************************************************/ - /* */ - /* RDTG[]: Round Down To Grid */ - /* Opcode range: 0x7D */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * RDTG[]: Round Down To Grid + * Opcode range: 0x7D + * Stack: --> + */ static void Ins_RDTG( TT_ExecContext exc ) { @@ -4692,12 +4799,12 @@ } - /*************************************************************************/ - /* */ - /* ROFF[]: Round OFF */ - /* Opcode range: 0x7A */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * ROFF[]: Round OFF + * Opcode range: 0x7A + * Stack: --> + */ static void Ins_ROFF( TT_ExecContext exc ) { @@ -4706,12 +4813,12 @@ } - /*************************************************************************/ - /* */ - /* SROUND[]: Super ROUND */ - /* Opcode range: 0x76 */ - /* Stack: Eint8 --> */ - /* */ + /************************************************************************** + * + * SROUND[]: Super ROUND + * Opcode range: 0x76 + * Stack: Eint8 --> + */ static void Ins_SROUND( TT_ExecContext exc, FT_Long* args ) @@ -4723,12 +4830,12 @@ } - /*************************************************************************/ - /* */ - /* S45ROUND[]: Super ROUND 45 degrees */ - /* Opcode range: 0x77 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * S45ROUND[]: Super ROUND 45 degrees + * Opcode range: 0x77 + * Stack: uint32 --> + */ static void Ins_S45ROUND( TT_ExecContext exc, FT_Long* args ) @@ -4740,15 +4847,15 @@ } - /*************************************************************************/ - /* */ - /* GC[a]: Get Coordinate projected onto */ - /* Opcode range: 0x46-0x47 */ - /* Stack: uint32 --> f26.6 */ - /* */ - /* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */ - /* along the dual projection vector! */ - /* */ + /************************************************************************** + * + * GC[a]: Get Coordinate projected onto + * Opcode range: 0x46-0x47 + * Stack: uint32 --> f26.6 + * + * XXX: UNDOCUMENTED: Measures from the original glyph must be taken + * along the dual projection vector! + */ static void Ins_GC( TT_ExecContext exc, FT_Long* args ) @@ -4777,16 +4884,16 @@ } - /*************************************************************************/ - /* */ - /* SCFS[]: Set Coordinate From Stack */ - /* Opcode range: 0x48 */ - /* Stack: f26.6 uint32 --> */ - /* */ - /* Formula: */ - /* */ - /* OA := OA + ( value - OA.p )/( f.p ) * f */ - /* */ + /************************************************************************** + * + * SCFS[]: Set Coordinate From Stack + * Opcode range: 0x48 + * Stack: f26.6 uint32 --> + * + * Formula: + * + * OA := OA + ( value - OA.p )/( f.p ) * f + */ static void Ins_SCFS( TT_ExecContext exc, FT_Long* args ) @@ -4815,21 +4922,21 @@ } - /*************************************************************************/ - /* */ - /* MD[a]: Measure Distance */ - /* Opcode range: 0x49-0x4A */ - /* Stack: uint32 uint32 --> f26.6 */ - /* */ - /* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */ - /* the dual projection vector. */ - /* */ - /* XXX: UNDOCUMENTED: Flag attributes are inverted! */ - /* 0 => measure distance in original outline */ - /* 1 => measure distance in grid-fitted outline */ - /* */ - /* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */ - /* */ + /************************************************************************** + * + * MD[a]: Measure Distance + * Opcode range: 0x49-0x4A + * Stack: uint32 uint32 --> f26.6 + * + * XXX: UNDOCUMENTED: Measure taken in the original glyph must be along + * the dual projection vector. + * + * XXX: UNDOCUMENTED: Flag attributes are inverted! + * 0 => measure distance in original outline + * 1 => measure distance in grid-fitted outline + * + * XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! + */ static void Ins_MD( TT_ExecContext exc, FT_Long* args ) @@ -4902,12 +5009,12 @@ } - /*************************************************************************/ - /* */ - /* SDPvTL[a]: Set Dual PVector to Line */ - /* Opcode range: 0x86-0x87 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * SDPvTL[a]: Set Dual PVector to Line + * Opcode range: 0x86-0x87 + * Stack: uint32 uint32 --> + */ static void Ins_SDPVTL( TT_ExecContext exc, FT_Long* args ) @@ -4985,12 +5092,12 @@ } - /*************************************************************************/ - /* */ - /* SZP0[]: Set Zone Pointer 0 */ - /* Opcode range: 0x13 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZP0[]: Set Zone Pointer 0 + * Opcode range: 0x13 + * Stack: uint32 --> + */ static void Ins_SZP0( TT_ExecContext exc, FT_Long* args ) @@ -5015,12 +5122,12 @@ } - /*************************************************************************/ - /* */ - /* SZP1[]: Set Zone Pointer 1 */ - /* Opcode range: 0x14 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZP1[]: Set Zone Pointer 1 + * Opcode range: 0x14 + * Stack: uint32 --> + */ static void Ins_SZP1( TT_ExecContext exc, FT_Long* args ) @@ -5045,12 +5152,12 @@ } - /*************************************************************************/ - /* */ - /* SZP2[]: Set Zone Pointer 2 */ - /* Opcode range: 0x15 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZP2[]: Set Zone Pointer 2 + * Opcode range: 0x15 + * Stack: uint32 --> + */ static void Ins_SZP2( TT_ExecContext exc, FT_Long* args ) @@ -5075,12 +5182,12 @@ } - /*************************************************************************/ - /* */ - /* SZPS[]: Set Zone PointerS */ - /* Opcode range: 0x16 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SZPS[]: Set Zone PointerS + * Opcode range: 0x16 + * Stack: uint32 --> + */ static void Ins_SZPS( TT_ExecContext exc, FT_Long* args ) @@ -5110,12 +5217,12 @@ } - /*************************************************************************/ - /* */ - /* INSTCTRL[]: INSTruction ConTRoL */ - /* Opcode range: 0x8E */ - /* Stack: int32 int32 --> */ - /* */ + /************************************************************************** + * + * INSTCTRL[]: INSTruction ConTRoL + * Opcode range: 0x8E + * Stack: int32 int32 --> + */ static void Ins_INSTCTRL( TT_ExecContext exc, FT_Long* args ) @@ -5172,12 +5279,12 @@ } - /*************************************************************************/ - /* */ - /* SCANCTRL[]: SCAN ConTRoL */ - /* Opcode range: 0x85 */ - /* Stack: uint32? --> */ - /* */ + /************************************************************************** + * + * SCANCTRL[]: SCAN ConTRoL + * Opcode range: 0x85 + * Stack: uint32? --> + */ static void Ins_SCANCTRL( TT_ExecContext exc, FT_Long* args ) @@ -5219,12 +5326,12 @@ } - /*************************************************************************/ - /* */ - /* SCANTYPE[]: SCAN TYPE */ - /* Opcode range: 0x8D */ - /* Stack: uint16 --> */ - /* */ + /************************************************************************** + * + * SCANTYPE[]: SCAN TYPE + * Opcode range: 0x8D + * Stack: uint16 --> + */ static void Ins_SCANTYPE( TT_ExecContext exc, FT_Long* args ) @@ -5234,19 +5341,19 @@ } - /*************************************************************************/ - /* */ - /* MANAGING OUTLINES */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MANAGING OUTLINES + * + */ - /*************************************************************************/ - /* */ - /* FLIPPT[]: FLIP PoinT */ - /* Opcode range: 0x80 */ - /* Stack: uint32... --> */ - /* */ + /************************************************************************** + * + * FLIPPT[]: FLIP PoinT + * Opcode range: 0x80 + * Stack: uint32... --> + */ static void Ins_FLIPPT( TT_ExecContext exc ) { @@ -5295,12 +5402,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPRGON[]: FLIP RanGe ON */ - /* Opcode range: 0x81 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * FLIPRGON[]: FLIP RanGe ON + * Opcode range: 0x81 + * Stack: uint32 uint32 --> + */ static void Ins_FLIPRGON( TT_ExecContext exc, FT_Long* args ) @@ -5333,12 +5440,12 @@ } - /*************************************************************************/ - /* */ - /* FLIPRGOFF: FLIP RanGe OFF */ - /* Opcode range: 0x82 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * FLIPRGOFF: FLIP RanGe OFF + * Opcode range: 0x82 + * Stack: uint32 uint32 --> + */ static void Ins_FLIPRGOFF( TT_ExecContext exc, FT_Long* args ) @@ -5450,12 +5557,12 @@ } - /*************************************************************************/ - /* */ - /* SHP[a]: SHift Point by the last point */ - /* Opcode range: 0x32-0x33 */ - /* Stack: uint32... --> */ - /* */ + /************************************************************************** + * + * SHP[a]: SHift Point by the last point + * Opcode range: 0x32-0x33 + * Stack: uint32... --> + */ static void Ins_SHP( TT_ExecContext exc ) { @@ -5507,16 +5614,16 @@ } - /*************************************************************************/ - /* */ - /* SHC[a]: SHift Contour */ - /* Opcode range: 0x34-35 */ - /* Stack: uint32 --> */ - /* */ - /* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */ - /* contour in the twilight zone, namely contour number */ - /* zero which includes all points of it. */ - /* */ + /************************************************************************** + * + * SHC[a]: SHift Contour + * Opcode range: 0x34-35 + * Stack: uint32 --> + * + * UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) + * contour in the twilight zone, namely contour number + * zero which includes all points of it. + */ static void Ins_SHC( TT_ExecContext exc, FT_Long* args ) @@ -5563,12 +5670,12 @@ } - /*************************************************************************/ - /* */ - /* SHZ[a]: SHift Zone */ - /* Opcode range: 0x36-37 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * SHZ[a]: SHift Zone + * Opcode range: 0x36-37 + * Stack: uint32 --> + */ static void Ins_SHZ( TT_ExecContext exc, FT_Long* args ) @@ -5611,12 +5718,12 @@ } - /*************************************************************************/ - /* */ - /* SHPIX[]: SHift points by a PIXel amount */ - /* Opcode range: 0x38 */ - /* Stack: f26.6 uint32... --> */ - /* */ + /************************************************************************** + * + * SHPIX[]: SHift points by a PIXel amount + * Opcode range: 0x38 + * Stack: f26.6 uint32... --> + */ static void Ins_SHPIX( TT_ExecContext exc, FT_Long* args ) @@ -5771,12 +5878,12 @@ } - /*************************************************************************/ - /* */ - /* MSIRP[a]: Move Stack Indirect Relative Position */ - /* Opcode range: 0x3A-0x3B */ - /* Stack: f26.6 uint32 --> */ - /* */ + /************************************************************************** + * + * MSIRP[a]: Move Stack Indirect Relative Position + * Opcode range: 0x3A-0x3B + * Stack: f26.6 uint32 --> + */ static void Ins_MSIRP( TT_ExecContext exc, FT_Long* args ) @@ -5846,12 +5953,12 @@ } - /*************************************************************************/ - /* */ - /* MDAP[a]: Move Direct Absolute Point */ - /* Opcode range: 0x2E-0x2F */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * MDAP[a]: Move Direct Absolute Point + * Opcode range: 0x2E-0x2F + * Stack: uint32 --> + */ static void Ins_MDAP( TT_ExecContext exc, FT_Long* args ) @@ -5900,12 +6007,12 @@ } - /*************************************************************************/ - /* */ - /* MIAP[a]: Move Indirect Absolute Point */ - /* Opcode range: 0x3E-0x3F */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * MIAP[a]: Move Indirect Absolute Point + * Opcode range: 0x3E-0x3F + * Stack: uint32 uint32 --> + */ static void Ins_MIAP( TT_ExecContext exc, FT_Long* args ) @@ -6020,12 +6127,12 @@ } - /*************************************************************************/ - /* */ - /* MDRP[abcde]: Move Direct Relative Point */ - /* Opcode range: 0xC0-0xDF */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * MDRP[abcde]: Move Direct Relative Point + * Opcode range: 0xC0-0xDF + * Stack: uint32 --> + */ static void Ins_MDRP( TT_ExecContext exc, FT_Long* args ) @@ -6164,12 +6271,12 @@ } - /*************************************************************************/ - /* */ - /* MIRP[abcde]: Move Indirect Relative Point */ - /* Opcode range: 0xE0-0xFF */ - /* Stack: int32? uint32 --> */ - /* */ + /************************************************************************** + * + * MIRP[abcde]: Move Indirect Relative Point + * Opcode range: 0xE0-0xFF + * Stack: int32? uint32 --> + */ static void Ins_MIRP( TT_ExecContext exc, FT_Long* args ) @@ -6189,6 +6296,8 @@ FT_Bool reverse_move = FALSE; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ + FT_F26Dot6 delta; + minimum_distance = exc->GS.minimum_distance; control_value_cutin = exc->GS.control_value_cutin; @@ -6221,8 +6330,11 @@ /* single width test */ - if ( FT_ABS( cvt_dist - exc->GS.single_width_value ) < - exc->GS.single_width_cutin ) + delta = SUB_LONG( cvt_dist, exc->GS.single_width_value ); + if ( delta < 0 ) + delta = NEG_LONG( delta ); + + if ( delta < exc->GS.single_width_cutin ) { if ( cvt_dist >= 0 ) cvt_dist = exc->GS.single_width_value; @@ -6251,7 +6363,7 @@ if ( exc->GS.auto_flip ) { if ( ( org_dist ^ cvt_dist ) < 0 ) - cvt_dist = -cvt_dist; + cvt_dist = NEG_LONG( cvt_dist ); } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY @@ -6276,9 +6388,6 @@ if ( exc->GS.gep0 == exc->GS.gep1 ) { - FT_F26Dot6 delta; - - /* XXX: According to Greg Hitchcock, the following wording is */ /* the right one: */ /* */ @@ -6313,9 +6422,6 @@ exc->ignore_x_mode && exc->GS.gep0 == exc->GS.gep1 ) { - FT_F26Dot6 delta; - - delta = SUB_LONG( cvt_dist, org_dist ); if ( delta < 0 ) delta = NEG_LONG( delta ); @@ -6412,12 +6518,12 @@ } - /*************************************************************************/ - /* */ - /* ALIGNRP[]: ALIGN Relative Point */ - /* Opcode range: 0x3C */ - /* Stack: uint32 uint32... --> */ - /* */ + /************************************************************************** + * + * ALIGNRP[]: ALIGN Relative Point + * Opcode range: 0x3C + * Stack: uint32 uint32... --> + */ static void Ins_ALIGNRP( TT_ExecContext exc ) { @@ -6475,12 +6581,12 @@ } - /*************************************************************************/ - /* */ - /* ISECT[]: moves point to InterSECTion */ - /* Opcode range: 0x0F */ - /* Stack: 5 * uint32 --> */ - /* */ + /************************************************************************** + * + * ISECT[]: moves point to InterSECTion + * Opcode range: 0x0F + * Stack: 5 * uint32 --> + */ static void Ins_ISECT( TT_ExecContext exc, FT_Long* args ) @@ -6571,12 +6677,12 @@ } - /*************************************************************************/ - /* */ - /* ALIGNPTS[]: ALIGN PoinTS */ - /* Opcode range: 0x27 */ - /* Stack: uint32 uint32 --> */ - /* */ + /************************************************************************** + * + * ALIGNPTS[]: ALIGN PoinTS + * Opcode range: 0x27 + * Stack: uint32 uint32 --> + */ static void Ins_ALIGNPTS( TT_ExecContext exc, FT_Long* args ) @@ -6603,12 +6709,12 @@ } - /*************************************************************************/ - /* */ - /* IP[]: Interpolate Point */ - /* Opcode range: 0x39 */ - /* Stack: uint32... --> */ - /* */ + /************************************************************************** + * + * IP[]: Interpolate Point + * Opcode range: 0x39 + * Stack: uint32... --> + */ /* SOMETIMES, DUMBER CODE IS BETTER CODE */ @@ -6763,12 +6869,12 @@ } - /*************************************************************************/ - /* */ - /* UTP[a]: UnTouch Point */ - /* Opcode range: 0x29 */ - /* Stack: uint32 --> */ - /* */ + /************************************************************************** + * + * UTP[a]: UnTouch Point + * Opcode range: 0x29 + * Stack: uint32 --> + */ static void Ins_UTP( TT_ExecContext exc, FT_Long* args ) @@ -6932,12 +7038,12 @@ } - /*************************************************************************/ - /* */ - /* IUP[a]: Interpolate Untouched Points */ - /* Opcode range: 0x30-0x31 */ - /* Stack: --> */ - /* */ + /************************************************************************** + * + * IUP[a]: Interpolate Untouched Points + * Opcode range: 0x30-0x31 + * Stack: --> + */ static void Ins_IUP( TT_ExecContext exc ) { @@ -7060,12 +7166,12 @@ } - /*************************************************************************/ - /* */ - /* DELTAPn[]: DELTA exceptions P1, P2, P3 */ - /* Opcode range: 0x5D,0x71,0x72 */ - /* Stack: uint32 (2 * uint32)... --> */ - /* */ + /************************************************************************** + * + * DELTAPn[]: DELTA exceptions P1, P2, P3 + * Opcode range: 0x5D,0x71,0x72 + * Stack: uint32 (2 * uint32)... --> + */ static void Ins_DELTAP( TT_ExecContext exc, FT_Long* args ) @@ -7142,12 +7248,12 @@ if ( SUBPIXEL_HINTING_INFINALITY ) { /* - * Allow delta move if + * Allow delta move if * - * - not using ignore_x_mode rendering, - * - glyph is specifically set to allow it, or - * - glyph is composite and freedom vector is not in subpixel - * direction. + * - not using ignore_x_mode rendering, + * - glyph is specifically set to allow it, or + * - glyph is composite and freedom vector is not in subpixel + * direction. */ if ( !exc->ignore_x_mode || ( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) || @@ -7227,12 +7333,12 @@ } - /*************************************************************************/ - /* */ - /* DELTACn[]: DELTA exceptions C1, C2, C3 */ - /* Opcode range: 0x73,0x74,0x75 */ - /* Stack: uint32 (2 * uint32)... --> */ - /* */ + /************************************************************************** + * + * DELTACn[]: DELTA exceptions C1, C2, C3 + * Opcode range: 0x73,0x74,0x75 + * Stack: uint32 (2 * uint32)... --> + */ static void Ins_DELTAC( TT_ExecContext exc, FT_Long* args ) @@ -7305,27 +7411,27 @@ } - /*************************************************************************/ - /* */ - /* MISC. INSTRUCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * MISC. INSTRUCTIONS + * + */ - /*************************************************************************/ - /* */ - /* GETINFO[]: GET INFOrmation */ - /* Opcode range: 0x88 */ - /* Stack: uint32 --> uint32 */ - /* */ - /* XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May */ - /* 2015) not documented in the OpenType specification. */ - /* */ - /* Selector bit 11 is incorrectly described as bit 8, while the */ - /* real meaning of bit 8 (vertical LCD subpixels) stays */ - /* undocumented. The same mistake can be found in Greg Hitchcock's */ - /* whitepaper. */ - /* */ + /************************************************************************** + * + * GETINFO[]: GET INFOrmation + * Opcode range: 0x88 + * Stack: uint32 --> uint32 + * + * XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May + * 2015) not documented in the OpenType specification. + * + * Selector bit 11 is incorrectly described as bit 8, while the + * real meaning of bit 8 (vertical LCD subpixels) stays + * undocumented. The same mistake can be found in Greg Hitchcock's + * whitepaper. + */ static void Ins_GETINFO( TT_ExecContext exc, FT_Long* args ) @@ -7337,11 +7443,11 @@ K = 0; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - /********************************/ - /* RASTERIZER VERSION */ - /* Selector Bit: 0 */ - /* Return Bit(s): 0-7 */ - /* */ + /********************************* + * RASTERIZER VERSION + * Selector Bit: 0 + * Return Bit(s): 0-7 + */ if ( SUBPIXEL_HINTING_INFINALITY && ( args[0] & 1 ) != 0 && exc->subpixel_hinting ) @@ -7362,39 +7468,40 @@ if ( ( args[0] & 1 ) != 0 ) K = driver->interpreter_version; - /********************************/ - /* GLYPH ROTATED */ - /* Selector Bit: 1 */ - /* Return Bit(s): 8 */ - /* */ + /********************************* + * GLYPH ROTATED + * Selector Bit: 1 + * Return Bit(s): 8 + */ if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated ) K |= 1 << 8; - /********************************/ - /* GLYPH STRETCHED */ - /* Selector Bit: 2 */ - /* Return Bit(s): 9 */ - /* */ + /********************************* + * GLYPH STRETCHED + * Selector Bit: 2 + * Return Bit(s): 9 + */ if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched ) K |= 1 << 9; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /********************************/ - /* VARIATION GLYPH */ - /* Selector Bit: 3 */ - /* Return Bit(s): 10 */ - /* */ - /* XXX: UNDOCUMENTED! */ + /********************************* + * VARIATION GLYPH + * Selector Bit: 3 + * Return Bit(s): 10 + * + * XXX: UNDOCUMENTED! + */ if ( (args[0] & 8 ) != 0 && exc->face->blend ) K |= 1 << 10; #endif - /********************************/ - /* BI-LEVEL HINTING AND */ - /* GRAYSCALE RENDERING */ - /* Selector Bit: 5 */ - /* Return Bit(s): 12 */ - /* */ + /********************************* + * BI-LEVEL HINTING AND + * GRAYSCALE RENDERING + * Selector Bit: 5 + * Return Bit(s): 12 + */ if ( ( args[0] & 32 ) != 0 && exc->grayscale ) K |= 1 << 12; @@ -7405,50 +7512,54 @@ /* Bold Italic'. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean ) { - /********************************/ - /* HINTING FOR SUBPIXEL */ - /* Selector Bit: 6 */ - /* Return Bit(s): 13 */ - /* */ - /* v40 does subpixel hinting by default. */ + /********************************* + * HINTING FOR SUBPIXEL + * Selector Bit: 6 + * Return Bit(s): 13 + * + * v40 does subpixel hinting by default. + */ if ( ( args[0] & 64 ) != 0 ) K |= 1 << 13; - /********************************/ - /* VERTICAL LCD SUBPIXELS? */ - /* Selector Bit: 8 */ - /* Return Bit(s): 15 */ - /* */ + /********************************* + * VERTICAL LCD SUBPIXELS? + * Selector Bit: 8 + * Return Bit(s): 15 + */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean ) K |= 1 << 15; - /********************************/ - /* SUBPIXEL POSITIONED? */ - /* Selector Bit: 10 */ - /* Return Bit(s): 17 */ - /* */ - /* XXX: FreeType supports it, dependent on what client does? */ + /********************************* + * SUBPIXEL POSITIONED? + * Selector Bit: 10 + * Return Bit(s): 17 + * + * XXX: FreeType supports it, dependent on what client does? + */ if ( ( args[0] & 1024 ) != 0 ) K |= 1 << 17; - /********************************/ - /* SYMMETRICAL SMOOTHING */ - /* Selector Bit: 11 */ - /* Return Bit(s): 18 */ - /* */ - /* The only smoothing method FreeType supports unless someone sets */ - /* FT_LOAD_TARGET_MONO. */ + /********************************* + * SYMMETRICAL SMOOTHING + * Selector Bit: 11 + * Return Bit(s): 18 + * + * The only smoothing method FreeType supports unless someone sets + * FT_LOAD_TARGET_MONO. + */ if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean ) K |= 1 << 18; - /********************************/ - /* CLEARTYPE HINTING AND */ - /* GRAYSCALE RENDERING */ - /* Selector Bit: 12 */ - /* Return Bit(s): 19 */ - /* */ - /* Grayscale rendering is what FreeType does anyway unless someone */ - /* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */ + /********************************* + * CLEARTYPE HINTING AND + * GRAYSCALE RENDERING + * Selector Bit: 12 + * Return Bit(s): 19 + * + * Grayscale rendering is what FreeType does anyway unless someone + * sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) + */ if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype ) K |= 1 << 19; } @@ -7462,67 +7573,73 @@ if ( exc->rasterizer_version >= 37 ) { - /********************************/ - /* HINTING FOR SUBPIXEL */ - /* Selector Bit: 6 */ - /* Return Bit(s): 13 */ - /* */ + /********************************* + * HINTING FOR SUBPIXEL + * Selector Bit: 6 + * Return Bit(s): 13 + */ if ( ( args[0] & 64 ) != 0 && exc->subpixel_hinting ) K |= 1 << 13; - /********************************/ - /* COMPATIBLE WIDTHS ENABLED */ - /* Selector Bit: 7 */ - /* Return Bit(s): 14 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * COMPATIBLE WIDTHS ENABLED + * Selector Bit: 7 + * Return Bit(s): 14 + * + * Functionality still needs to be added + */ if ( ( args[0] & 128 ) != 0 && exc->compatible_widths ) K |= 1 << 14; - /********************************/ - /* VERTICAL LCD SUBPIXELS? */ - /* Selector Bit: 8 */ - /* Return Bit(s): 15 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * VERTICAL LCD SUBPIXELS? + * Selector Bit: 8 + * Return Bit(s): 15 + * + * Functionality still needs to be added + */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd ) K |= 1 << 15; - /********************************/ - /* HINTING FOR BGR? */ - /* Selector Bit: 9 */ - /* Return Bit(s): 16 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * HINTING FOR BGR? + * Selector Bit: 9 + * Return Bit(s): 16 + * + * Functionality still needs to be added + */ if ( ( args[0] & 512 ) != 0 && exc->bgr ) K |= 1 << 16; if ( exc->rasterizer_version >= 38 ) { - /********************************/ - /* SUBPIXEL POSITIONED? */ - /* Selector Bit: 10 */ - /* Return Bit(s): 17 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * SUBPIXEL POSITIONED? + * Selector Bit: 10 + * Return Bit(s): 17 + * + * Functionality still needs to be added + */ if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned ) K |= 1 << 17; - /********************************/ - /* SYMMETRICAL SMOOTHING */ - /* Selector Bit: 11 */ - /* Return Bit(s): 18 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * SYMMETRICAL SMOOTHING + * Selector Bit: 11 + * Return Bit(s): 18 + * + * Functionality still needs to be added + */ if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing ) K |= 1 << 18; - /********************************/ - /* GRAY CLEARTYPE */ - /* Selector Bit: 12 */ - /* Return Bit(s): 19 */ - /* */ - /* Functionality still needs to be added */ + /********************************* + * GRAY CLEARTYPE + * Selector Bit: 12 + * Return Bit(s): 19 + * + * Functionality still needs to be added + */ if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype ) K |= 1 << 19; } @@ -7537,16 +7654,16 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /*************************************************************************/ - /* */ - /* GETVARIATION[]: get normalized variation (blend) coordinates */ - /* Opcode range: 0x91 */ - /* Stack: --> f2.14... */ - /* */ - /* XXX: UNDOCUMENTED! There is no official documentation from Apple for */ - /* this bytecode instruction. Active only if a font has GX */ - /* variation axes. */ - /* */ + /************************************************************************** + * + * GETVARIATION[]: get normalized variation (blend) coordinates + * Opcode range: 0x91 + * Stack: --> f2.14... + * + * XXX: UNDOCUMENTED! There is no official documentation from Apple for + * this bytecode instruction. Active only if a font has GX + * variation axes. + */ static void Ins_GETVARIATION( TT_ExecContext exc, FT_Long* args ) @@ -7576,15 +7693,15 @@ } - /*************************************************************************/ - /* */ - /* GETDATA[]: no idea what this is good for */ - /* Opcode range: 0x92 */ - /* Stack: --> 17 */ - /* */ - /* XXX: UNDOCUMENTED! There is no documentation from Apple for this */ - /* very weird bytecode instruction. */ - /* */ + /************************************************************************** + * + * GETDATA[]: no idea what this is good for + * Opcode range: 0x92 + * Stack: --> 17 + * + * XXX: UNDOCUMENTED! There is no documentation from Apple for this + * very weird bytecode instruction. + */ static void Ins_GETDATA( FT_Long* args ) { @@ -7632,34 +7749,34 @@ } - /*************************************************************************/ - /* */ - /* RUN */ - /* */ - /* This function executes a run of opcodes. It will exit in the */ - /* following cases: */ - /* */ - /* - Errors (in which case it returns FALSE). */ - /* */ - /* - Reaching the end of the main code range (returns TRUE). */ - /* Reaching the end of a code range within a function call is an */ - /* error. */ - /* */ - /* - After executing one single opcode, if the flag `Instruction_Trap' */ - /* is set to TRUE (returns TRUE). */ - /* */ - /* On exit with TRUE, test IP < CodeSize to know whether it comes from */ - /* an instruction trap or a normal termination. */ - /* */ - /* */ - /* Note: The documented DEBUG opcode pops a value from the stack. This */ - /* behaviour is unsupported; here a DEBUG opcode is always an */ - /* error. */ - /* */ - /* */ - /* THIS IS THE INTERPRETER'S MAIN LOOP. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * RUN + * + * This function executes a run of opcodes. It will exit in the + * following cases: + * + * - Errors (in which case it returns FALSE). + * + * - Reaching the end of the main code range (returns TRUE). + * Reaching the end of a code range within a function call is an + * error. + * + * - After executing one single opcode, if the flag `Instruction_Trap' + * is set to TRUE (returns TRUE). + * + * On exit with TRUE, test IP < CodeSize to know whether it comes from + * an instruction trap or a normal termination. + * + * + * Note: The documented DEBUG opcode pops a value from the stack. This + * behaviour is unsupported; here a DEBUG opcode is always an + * error. + * + * + * THIS IS THE INTERPRETER'S MAIN LOOP. + * + */ /* documentation is in ttinterp.h */ @@ -7691,16 +7808,16 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* - * Toggle backward compatibility according to what font wants, except - * when + * Toggle backward compatibility according to what font wants, except + * when * - * 1) we have a `tricky' font that heavily relies on the interpreter to - * render glyphs correctly, for example DFKai-SB, or - * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. + * 1) we have a `tricky' font that heavily relies on the interpreter to + * render glyphs correctly, for example DFKai-SB, or + * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. * - * In those cases, backward compatibility needs to be turned off to get - * correct rendering. The rendering is then completely up to the - * font's programming. + * In those cases, backward compatibility needs to be turned off to get + * correct rendering. The rendering is then completely up to the + * font's programming. * */ if ( SUBPIXEL_HINTING_MINIMAL && @@ -7801,7 +7918,7 @@ /* and the first few stack elements also */ FT_TRACE6(( " " )); FT_TRACE7(( "%06d ", exc->IP )); - FT_TRACE6(( opcode_name[exc->opcode] + 2 )); + FT_TRACE6(( "%s", opcode_name[exc->opcode] + 2 )); FT_TRACE7(( "%*s", *opcode_name[exc->opcode] == 'A' ? 2 : 12 - ( *opcode_name[exc->opcode] - '0' ), diff --git a/src/3rdparty/freetype/src/truetype/ttinterp.h b/src/3rdparty/freetype/src/truetype/ttinterp.h index 2966439ea2..0cb1e892fb 100644 --- a/src/3rdparty/freetype/src/truetype/ttinterp.h +++ b/src/3rdparty/freetype/src/truetype/ttinterp.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttinterp.h */ -/* */ -/* TrueType bytecode interpreter (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttinterp.h + * + * TrueType bytecode interpreter (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTINTERP_H_ @@ -26,10 +26,10 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* Rounding mode constants. */ - /* */ + /************************************************************************** + * + * Rounding mode constants. + */ #define TT_Round_Off 5 #define TT_Round_To_Half_Grid 0 #define TT_Round_To_Grid 1 @@ -40,13 +40,13 @@ FT_BEGIN_HEADER #define TT_Round_Super_45 7 - /*************************************************************************/ - /* */ - /* Function types used by the interpreter, depending on various modes */ - /* (e.g. the rounding mode, whether to render a vertical or horizontal */ - /* line etc). */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Function types used by the interpreter, depending on various modes + * (e.g. the rounding mode, whether to render a vertical or horizontal + * line etc). + * + */ /* Rounding function */ typedef FT_F26Dot6 @@ -84,10 +84,10 @@ FT_BEGIN_HEADER FT_F26Dot6 value ); - /*************************************************************************/ - /* */ - /* This structure defines a call record, used to manage function calls. */ - /* */ + /************************************************************************** + * + * This structure defines a call record, used to manage function calls. + */ typedef struct TT_CallRec_ { FT_Int Caller_Range; @@ -101,11 +101,11 @@ FT_BEGIN_HEADER #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - /*************************************************************************/ - /* */ - /* These structures define rules used to tweak subpixel hinting for */ - /* various fonts. "", 0, "", NULL value indicates to match any value. */ - /* */ + /************************************************************************** + * + * These structures define rules used to tweak subpixel hinting for + * various fonts. "", 0, "", NULL value indicates to match any value. + */ #define SPH_MAX_NAME_SIZE 32 #define SPH_MAX_CLASS_MEMBERS 100 @@ -141,11 +141,11 @@ FT_BEGIN_HEADER #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ - /*************************************************************************/ - /* */ - /* The main structure for the interpreter which collects all necessary */ - /* variables and states. */ - /* */ + /************************************************************************** + * + * The main structure for the interpreter which collects all necessary + * variables and states. + */ typedef struct TT_ExecContextRec_ { TT_Face face; @@ -352,7 +352,7 @@ FT_BEGIN_HEADER * https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx * * [3] Beat Stamm describes it in more detail: - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec12 + * http://rastertragedy.com/RTRCh4.htm#Sec12. * * [4] The list of `native ClearType' fonts is small at the time of this * writing; I found the following on a Windows 10 Update 1511 @@ -464,26 +464,27 @@ FT_BEGIN_HEADER #endif /* TT_USE_BYTECODE_INTERPRETER */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_New_Context */ - /* */ - /* <Description> */ - /* Queries the face context for a given font. Note that there is */ - /* now a _single_ execution context in the TrueType driver which is */ - /* shared among faces. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* A handle to the execution context. Initialized for `face'. */ - /* */ - /* <Note> */ - /* Only the glyph loader and debugger should call this function. */ - /* (And right now only the glyph loader uses it.) */ - /* */ + /************************************************************************** + * + * @Function: + * TT_New_Context + * + * @Description: + * Queries the face context for a given font. Note that there is + * now a _single_ execution context in the TrueType driver which is + * shared among faces. + * + * @Input: + * face :: + * A handle to the source face object. + * + * @Return: + * A handle to the execution context. Initialized for `face'. + * + * @Note: + * Only the glyph loader and debugger should call this function. + * (And right now only the glyph loader uses it.) + */ FT_EXPORT( TT_ExecContext ) TT_New_Context( TT_Driver driver ); @@ -506,27 +507,28 @@ FT_BEGIN_HEADER #endif /* TT_USE_BYTECODE_INTERPRETER */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* TT_RunIns */ - /* */ - /* <Description> */ - /* Executes one or more instruction in the execution context. This */ - /* is the main function of the TrueType opcode interpreter. */ - /* */ - /* <Input> */ - /* exec :: A handle to the target execution context. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only the object manager and debugger should call this function. */ - /* */ - /* This function is publicly exported because it is directly */ - /* invoked by the TrueType debugger. */ - /* */ + /************************************************************************** + * + * @Function: + * TT_RunIns + * + * @Description: + * Executes one or more instruction in the execution context. This + * is the main function of the TrueType opcode interpreter. + * + * @Input: + * exec :: + * A handle to the target execution context. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only the object manager and debugger should call this function. + * + * This function is publicly exported because it is directly + * invoked by the TrueType debugger. + */ FT_EXPORT( FT_Error ) TT_RunIns( TT_ExecContext exec ); diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.c b/src/3rdparty/freetype/src/truetype/ttobjs.c index 6685dc8196..e4775a51ed 100644 --- a/src/3rdparty/freetype/src/truetype/ttobjs.c +++ b/src/3rdparty/freetype/src/truetype/ttobjs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttobjs.c */ -/* */ -/* Objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttobjs.c + * + * Objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -36,36 +36,37 @@ #include "ttgxvar.h" #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttobjs +#define FT_COMPONENT ttobjs #ifdef TT_USE_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* GLYPH ZONE FUNCTIONS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_glyphzone_done */ - /* */ - /* <Description> */ - /* Deallocate a glyph zone. */ - /* */ - /* <Input> */ - /* zone :: A pointer to the target glyph zone. */ - /* */ + /************************************************************************** + * + * GLYPH ZONE FUNCTIONS + * + */ + + + /************************************************************************** + * + * @Function: + * tt_glyphzone_done + * + * @Description: + * Deallocate a glyph zone. + * + * @Input: + * zone :: + * A pointer to the target glyph zone. + */ FT_LOCAL_DEF( void ) tt_glyphzone_done( TT_GlyphZone zone ) { @@ -87,27 +88,31 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_glyphzone_new */ - /* */ - /* <Description> */ - /* Allocate a new glyph zone. */ - /* */ - /* <Input> */ - /* memory :: A handle to the current memory object. */ - /* */ - /* maxPoints :: The capacity of glyph zone in points. */ - /* */ - /* maxContours :: The capacity of glyph zone in contours. */ - /* */ - /* <Output> */ - /* zone :: A pointer to the target glyph zone record. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_glyphzone_new + * + * @Description: + * Allocate a new glyph zone. + * + * @Input: + * memory :: + * A handle to the current memory object. + * + * maxPoints :: + * The capacity of glyph zone in points. + * + * maxContours :: + * The capacity of glyph zone in contours. + * + * @Output: + * zone :: + * A pointer to the target glyph zone record. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_glyphzone_new( FT_Memory memory, FT_UShort maxPoints, @@ -143,7 +148,7 @@ /* This list shall be expanded as we find more of them. */ static FT_Bool - tt_check_trickyness_family( FT_String* name ) + tt_check_trickyness_family( const FT_String* name ) { #define TRICK_NAMES_MAX_CHARACTERS 19 @@ -566,32 +571,37 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_init */ - /* */ - /* <Description> */ - /* Initialize a given TrueType face object. */ - /* */ - /* <Input> */ - /* stream :: The source font stream. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection, in bits 0-15. The numbered instance */ - /* index~+~1 of a GX (sub)font, if applicable, in bits */ - /* 16-30. */ - /* */ - /* num_params :: Number of additional generic parameters. Ignored. */ - /* */ - /* params :: Additional generic parameters. Ignored. */ - /* */ - /* <InOut> */ - /* face :: The newly built face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_init + * + * @Description: + * Initialize a given TrueType face object. + * + * @Input: + * stream :: + * The source font stream. + * + * face_index :: + * The index of the TrueType font, if we are opening a + * collection, in bits 0-15. The numbered instance + * index~+~1 of a GX (sub)font, if applicable, in bits + * 16-30. + * + * num_params :: + * Number of additional generic parameters. Ignored. + * + * params :: + * Additional generic parameters. Ignored. + * + * @InOut: + * face :: + * The newly built face object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ @@ -743,17 +753,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_done */ - /* */ - /* <Description> */ - /* Finalize a given face object. */ - /* */ - /* <Input> */ - /* face :: A pointer to the face object to destroy. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_done + * + * @Description: + * Finalize a given face object. + * + * @Input: + * face :: + * A pointer to the face object to destroy. + */ FT_LOCAL_DEF( void ) tt_face_done( FT_Face ttface ) /* TT_Face */ { @@ -799,30 +810,32 @@ } - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ #ifdef TT_USE_BYTECODE_INTERPRETER - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_run_fpgm */ - /* */ - /* <Description> */ - /* Run the font program. */ - /* */ - /* <Input> */ - /* size :: A handle to the size object. */ - /* */ - /* pedantic :: Set if bytecode execution should be pedantic. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_run_fpgm + * + * @Description: + * Run the font program. + * + * @Input: + * size :: + * A handle to the size object. + * + * pedantic :: + * Set if bytecode execution should be pedantic. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_size_run_fpgm( TT_Size size, FT_Bool pedantic ) @@ -899,22 +912,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_run_prep */ - /* */ - /* <Description> */ - /* Run the control value program. */ - /* */ - /* <Input> */ - /* size :: A handle to the size object. */ - /* */ - /* pedantic :: Set if bytecode execution should be pedantic. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_run_prep + * + * @Description: + * Run the control value program. + * + * @Input: + * size :: + * A handle to the size object. + * + * pedantic :: + * Set if bytecode execution should be pedantic. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_size_run_prep( TT_Size size, FT_Bool pedantic ) @@ -922,7 +937,22 @@ TT_Face face = (TT_Face)size->root.face; TT_ExecContext exec; FT_Error error; + FT_UInt i; + /* unscaled CVT values are already stored in 26.6 format */ + FT_Fixed scale = size->ttmetrics.scale >> 6; + + + /* Scale the cvt values to the new ppem. */ + /* By default, we use the y ppem value for scaling. */ + FT_TRACE6(( "CVT values:\n" )); + for ( i = 0; i < size->cvt_size; i++ ) + { + size->cvt[i] = FT_MulFix( face->cvt[i], scale ); + FT_TRACE6(( " %3d: %f (%f)\n", + i, face->cvt[i] / 64.0, size->cvt[i] / 64.0 )); + } + FT_TRACE6(( "\n" )); exec = size->context; @@ -1079,11 +1109,17 @@ tt_metrics->rotated = FALSE; tt_metrics->stretched = FALSE; - /* set default engine compensation */ - tt_metrics->compensations[0] = 0; /* gray */ - tt_metrics->compensations[1] = 0; /* black */ - tt_metrics->compensations[2] = 0; /* white */ - tt_metrics->compensations[3] = 0; /* reserved */ + /* Set default engine compensation. Value 3 is not described */ + /* in the OpenType specification (as of Mai 2019), but Greg */ + /* says that MS handles it the same as `gray'. */ + /* */ + /* The Apple specification says that the compensation for */ + /* `gray' is always zero. FreeType doesn't do any */ + /* compensation at all. */ + tt_metrics->compensations[0] = 0; /* gray */ + tt_metrics->compensations[1] = 0; /* black */ + tt_metrics->compensations[2] = 0; /* white */ + tt_metrics->compensations[3] = 0; /* the same as gray */ } /* allocate function defs, instruction defs, cvt, and storage area */ @@ -1156,13 +1192,7 @@ if ( size->cvt_ready < 0 ) { FT_UInt i; - TT_Face face = (TT_Face)size->root.face; - - /* Scale the cvt values to the new ppem. */ - /* We use by default the y ppem to scale the CVT. */ - for ( i = 0; i < size->cvt_size; i++ ) - size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); /* all twilight points are originally zero */ for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) @@ -1191,20 +1221,21 @@ #endif /* TT_USE_BYTECODE_INTERPRETER */ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_init */ - /* */ - /* <Description> */ - /* Initialize a new TrueType size object. */ - /* */ - /* <InOut> */ - /* size :: A handle to the size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_init + * + * @Description: + * Initialize a new TrueType size object. + * + * @InOut: + * size :: + * A handle to the size object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_size_init( FT_Size ttsize ) /* TT_Size */ { @@ -1224,17 +1255,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_done */ - /* */ - /* <Description> */ - /* The TrueType size object finalizer. */ - /* */ - /* <Input> */ - /* size :: A handle to the target size object. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_done + * + * @Description: + * The TrueType size object finalizer. + * + * @Input: + * size :: + * A handle to the target size object. + */ FT_LOCAL_DEF( void ) tt_size_done( FT_Size ttsize ) /* TT_Size */ { @@ -1249,22 +1281,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_size_reset */ - /* */ - /* <Description> */ - /* Reset a TrueType size when resolutions and character dimensions */ - /* have been changed. */ - /* */ - /* <Input> */ - /* size :: A handle to the target size object. */ - /* */ - /* only_height :: Only recompute ascender, descender, and height; */ - /* this flag is used for variation fonts where */ - /* `tt_size_reset' is used as an iterator function. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_size_reset + * + * @Description: + * Reset a TrueType size when resolutions and character dimensions + * have been changed. + * + * @Input: + * size :: + * A handle to the target size object. + * + * only_height :: + * Only recompute ascender, descender, and height; + * this flag is used for variation fonts where + * `tt_size_reset' is used as an iterator function. + */ FT_LOCAL_DEF( FT_Error ) tt_size_reset( TT_Size size, FT_Bool only_height ) @@ -1358,20 +1392,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_driver_init */ - /* */ - /* <Description> */ - /* Initialize a given TrueType driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_driver_init + * + * @Description: + * Initialize a given TrueType driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ { @@ -1398,17 +1433,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_driver_done */ - /* */ - /* <Description> */ - /* Finalize a given TrueType driver. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target TrueType driver. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_driver_done + * + * @Description: + * Finalize a given TrueType driver. + * + * @Input: + * driver :: + * A handle to the target TrueType driver. + */ FT_LOCAL_DEF( void ) tt_driver_done( FT_Module ttdriver ) /* TT_Driver */ { @@ -1416,20 +1452,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_slot_init */ - /* */ - /* <Description> */ - /* Initialize a new slot object. */ - /* */ - /* <InOut> */ - /* slot :: A handle to the slot object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_slot_init + * + * @Description: + * Initialize a new slot object. + * + * @InOut: + * slot :: + * A handle to the slot object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_slot_init( FT_GlyphSlot slot ) { diff --git a/src/3rdparty/freetype/src/truetype/ttobjs.h b/src/3rdparty/freetype/src/truetype/ttobjs.h index 38fa30e4e9..9fc654d5d1 100644 --- a/src/3rdparty/freetype/src/truetype/ttobjs.h +++ b/src/3rdparty/freetype/src/truetype/ttobjs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttobjs.h */ -/* */ -/* Objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttobjs.h + * + * Objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTOBJS_H_ @@ -28,40 +28,40 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Driver */ - /* */ - /* <Description> */ - /* A handle to a TrueType driver object. */ - /* */ + /************************************************************************** + * + * @Type: + * TT_Driver + * + * @Description: + * A handle to a TrueType driver object. + */ typedef struct TT_DriverRec_* TT_Driver; - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a TrueType glyph slot object. */ - /* */ - /* <Note> */ - /* This is a direct typedef of FT_GlyphSlot, as there is nothing */ - /* specific about the TrueType glyph slot. */ - /* */ + /************************************************************************** + * + * @Type: + * TT_GlyphSlot + * + * @Description: + * A handle to a TrueType glyph slot object. + * + * @Note: + * This is a direct typedef of FT_GlyphSlot, as there is nothing + * specific about the TrueType glyph slot. + */ typedef FT_GlyphSlot TT_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GraphicsState */ - /* */ - /* <Description> */ - /* The TrueType graphics state used during bytecode interpretation. */ - /* */ + /************************************************************************** + * + * @Struct: + * TT_GraphicsState + * + * @Description: + * The TrueType graphics state used during bytecode interpretation. + */ typedef struct TT_GraphicsState_ { FT_UShort rp0; @@ -113,25 +113,25 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* EXECUTION SUBTABLES */ - /* */ - /* These sub-tables relate to instruction execution. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * EXECUTION SUBTABLES + * + * These sub-tables relate to instruction execution. + * + */ #define TT_MAX_CODE_RANGES 3 - /*************************************************************************/ - /* */ - /* There can only be 3 active code ranges at once: */ - /* - the Font Program */ - /* - the CVT Program */ - /* - a glyph's instructions set */ - /* */ + /************************************************************************** + * + * There can only be 3 active code ranges at once: + * - the Font Program + * - the CVT Program + * - a glyph's instructions set + */ typedef enum TT_CodeRange_Tag_ { tt_coderange_none = 0, @@ -152,10 +152,10 @@ FT_BEGIN_HEADER typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES]; - /*************************************************************************/ - /* */ - /* Defines a function/instruction definition record. */ - /* */ + /************************************************************************** + * + * Defines a function/instruction definition record. + */ typedef struct TT_DefRecord_ { FT_Int range; /* in which code range is it located? */ @@ -169,10 +169,10 @@ FT_BEGIN_HEADER } TT_DefRecord, *TT_DefArray; - /*************************************************************************/ - /* */ - /* Subglyph transformation record. */ - /* */ + /************************************************************************** + * + * Subglyph transformation record. + */ typedef struct TT_Transform_ { FT_Fixed xx, xy; /* transformation matrix coefficients */ @@ -182,72 +182,72 @@ FT_BEGIN_HEADER } TT_Transform; - /*************************************************************************/ - /* */ - /* A note regarding non-squared pixels: */ - /* */ - /* (This text will probably go into some docs at some time; for now, it */ - /* is kept here to explain some definitions in the TT_Size_Metrics */ - /* record). */ - /* */ - /* The CVT is a one-dimensional array containing values that control */ - /* certain important characteristics in a font, like the height of all */ - /* capitals, all lowercase letter, default spacing or stem width/height. */ - /* */ - /* These values are found in FUnits in the font file, and must be scaled */ - /* to pixel coordinates before being used by the CVT and glyph programs. */ - /* Unfortunately, when using distinct x and y resolutions (or distinct x */ - /* and y pointsizes), there are two possible scalings. */ - /* */ - /* A first try was to implement a `lazy' scheme where all values were */ - /* scaled when first used. However, while some values are always used */ - /* in the same direction, some others are used under many different */ - /* circumstances and orientations. */ - /* */ - /* I have found a simpler way to do the same, and it even seems to work */ - /* in most of the cases: */ - /* */ - /* - All CVT values are scaled to the maximum ppem size. */ - /* */ - /* - When performing a read or write in the CVT, a ratio factor is used */ - /* to perform adequate scaling. Example: */ - /* */ - /* x_ppem = 14 */ - /* y_ppem = 10 */ - /* */ - /* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */ - /* entries are scaled to it. */ - /* */ - /* x_ratio = 1.0 */ - /* y_ratio = y_ppem/ppem (< 1.0) */ - /* */ - /* We compute the current ratio like: */ - /* */ - /* - If projVector is horizontal, */ - /* ratio = x_ratio = 1.0 */ - /* */ - /* - if projVector is vertical, */ - /* ratio = y_ratio */ - /* */ - /* - else, */ - /* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */ - /* */ - /* Reading a cvt value returns */ - /* ratio * cvt[index] */ - /* */ - /* Writing a cvt value in pixels: */ - /* cvt[index] / ratio */ - /* */ - /* The current ppem is simply */ - /* ratio * ppem */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Metrics used by the TrueType size and context objects. */ - /* */ + /************************************************************************** + * + * A note regarding non-squared pixels: + * + * (This text will probably go into some docs at some time; for now, it + * is kept here to explain some definitions in the TT_Size_Metrics + * record). + * + * The CVT is a one-dimensional array containing values that control + * certain important characteristics in a font, like the height of all + * capitals, all lowercase letter, default spacing or stem width/height. + * + * These values are found in FUnits in the font file, and must be scaled + * to pixel coordinates before being used by the CVT and glyph programs. + * Unfortunately, when using distinct x and y resolutions (or distinct x + * and y pointsizes), there are two possible scalings. + * + * A first try was to implement a `lazy' scheme where all values were + * scaled when first used. However, while some values are always used + * in the same direction, some others are used under many different + * circumstances and orientations. + * + * I have found a simpler way to do the same, and it even seems to work + * in most of the cases: + * + * - All CVT values are scaled to the maximum ppem size. + * + * - When performing a read or write in the CVT, a ratio factor is used + * to perform adequate scaling. Example: + * + * x_ppem = 14 + * y_ppem = 10 + * + * We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt + * entries are scaled to it. + * + * x_ratio = 1.0 + * y_ratio = y_ppem/ppem (< 1.0) + * + * We compute the current ratio like: + * + * - If projVector is horizontal, + * ratio = x_ratio = 1.0 + * + * - if projVector is vertical, + * ratio = y_ratio + * + * - else, + * ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) + * + * Reading a cvt value returns + * ratio * cvt[index] + * + * Writing a cvt value in pixels: + * cvt[index] / ratio + * + * The current ppem is simply + * ratio * ppem + * + */ + + + /************************************************************************** + * + * Metrics used by the TrueType size and context objects. + */ typedef struct TT_Size_Metrics_ { /* for non-square pixels */ @@ -268,10 +268,10 @@ FT_BEGIN_HEADER } TT_Size_Metrics; - /*************************************************************************/ - /* */ - /* TrueType size class. */ - /* */ + /************************************************************************** + * + * TrueType size class. + */ typedef struct TT_SizeRec_ { FT_SizeRec root; @@ -324,10 +324,10 @@ FT_BEGIN_HEADER } TT_SizeRec; - /*************************************************************************/ - /* */ - /* TrueType driver class. */ - /* */ + /************************************************************************** + * + * TrueType driver class. + */ typedef struct TT_DriverRec_ { FT_DriverRec root; @@ -348,10 +348,10 @@ FT_BEGIN_HEADER /* will always use the TT driver to create them. */ - /*************************************************************************/ - /* */ - /* Face functions */ - /* */ + /************************************************************************** + * + * Face functions + */ FT_LOCAL( FT_Error ) tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ @@ -363,10 +363,10 @@ FT_BEGIN_HEADER tt_face_done( FT_Face ttface ); /* TT_Face */ - /*************************************************************************/ - /* */ - /* Size functions */ - /* */ + /************************************************************************** + * + * Size functions + */ FT_LOCAL( FT_Error ) tt_size_init( FT_Size ttsize ); /* TT_Size */ @@ -394,10 +394,10 @@ FT_BEGIN_HEADER FT_Bool only_height ); - /*************************************************************************/ - /* */ - /* Driver functions */ - /* */ + /************************************************************************** + * + * Driver functions + */ FT_LOCAL( FT_Error ) tt_driver_init( FT_Module ttdriver ); /* TT_Driver */ @@ -405,10 +405,10 @@ FT_BEGIN_HEADER tt_driver_done( FT_Module ttdriver ); /* TT_Driver */ - /*************************************************************************/ - /* */ - /* Slot functions */ - /* */ + /************************************************************************** + * + * Slot functions + */ FT_LOCAL( FT_Error ) tt_slot_init( FT_GlyphSlot slot ); diff --git a/src/3rdparty/freetype/src/truetype/ttpload.c b/src/3rdparty/freetype/src/truetype/ttpload.c index d9526ad082..bc954c2dba 100644 --- a/src/3rdparty/freetype/src/truetype/ttpload.c +++ b/src/3rdparty/freetype/src/truetype/ttpload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttpload.c */ -/* */ -/* TrueType-specific tables loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttpload.c + * + * TrueType-specific tables loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -31,33 +31,35 @@ #include "tterrors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_ttpload - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_loca */ - /* */ - /* <Description> */ - /* Load the locations table. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ +#define FT_COMPONENT ttpload + + + /************************************************************************** + * + * @Function: + * tt_face_load_loca + * + * @Description: + * Load the locations table. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * The input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_loca( TT_Face face, FT_Stream stream ) @@ -297,23 +299,25 @@ - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_cvt */ - /* */ - /* <Description> */ - /* Load the control value table into a face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_cvt + * + * @Description: + * Load the control value table into a face object. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_cvt( TT_Face face, FT_Stream stream ) @@ -348,12 +352,12 @@ goto Exit; { - FT_Short* cur = face->cvt; - FT_Short* limit = cur + face->cvt_size; + FT_Int32* cur = face->cvt; + FT_Int32* limit = cur + face->cvt_size; for ( ; cur < limit; cur++ ) - *cur = FT_GET_SHORT(); + *cur = FT_GET_SHORT() * 64; } FT_FRAME_EXIT(); @@ -378,23 +382,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_fpgm */ - /* */ - /* <Description> */ - /* Load the font program. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_fpgm + * + * @Description: + * Load the font program. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_fpgm( TT_Face face, FT_Stream stream ) @@ -440,23 +446,25 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_prep */ - /* */ - /* <Description> */ - /* Load the cvt program. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_prep + * + * @Description: + * Load the cvt program. + * + * @InOut: + * face :: + * A handle to the target face object. + * + * @Input: + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_prep( TT_Face face, FT_Stream stream ) @@ -501,22 +509,24 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* tt_face_load_hdmx */ - /* */ - /* <Description> */ - /* Load the `hdmx' table into the face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: A handle to the input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * tt_face_load_hdmx + * + * @Description: + * Load the `hdmx' table into the face object. + * + * @Input: + * face :: + * A handle to the target face object. + * + * stream :: + * A handle to the input stream. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) tt_face_load_hdmx( TT_Face face, @@ -610,11 +620,11 @@ } - /*************************************************************************/ - /* */ - /* Return the advance width table for a given pixel size if it is found */ - /* in the font's `hdmx' table (if any). */ - /* */ + /************************************************************************** + * + * Return the advance width table for a given pixel size if it is found + * in the font's `hdmx' table (if any). + */ FT_LOCAL_DEF( FT_Byte* ) tt_face_get_device_metrics( TT_Face face, FT_UInt ppem, diff --git a/src/3rdparty/freetype/src/truetype/ttpload.h b/src/3rdparty/freetype/src/truetype/ttpload.h index fa12527247..022750e324 100644 --- a/src/3rdparty/freetype/src/truetype/ttpload.h +++ b/src/3rdparty/freetype/src/truetype/ttpload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttpload.h */ -/* */ -/* TrueType-specific tables loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttpload.h + * + * TrueType-specific tables loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTPLOAD_H_ diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.c b/src/3rdparty/freetype/src/truetype/ttsubpix.c index d94bcc8b50..23a2e5b440 100644 --- a/src/3rdparty/freetype/src/truetype/ttsubpix.c +++ b/src/3rdparty/freetype/src/truetype/ttsubpix.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttsubpix.c */ -/* */ -/* TrueType Subpixel Hinting. */ -/* */ -/* Copyright 2010-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsubpix.c + * + * TrueType Subpixel Hinting. + * + * Copyright (C) 2010-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H @@ -30,35 +30,35 @@ #if defined( TT_USE_BYTECODE_INTERPRETER ) && \ defined( TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY ) - /*************************************************************************/ - /* */ - /* These rules affect how the TT Interpreter does hinting, with the */ - /* goal of doing subpixel hinting by (in general) ignoring x moves. */ - /* Some of these rules are fixes that go above and beyond the */ - /* stated techniques in the MS whitepaper on Cleartype, due to */ - /* artifacts in many glyphs. So, these rules make some glyphs render */ - /* better than they do in the MS rasterizer. */ - /* */ - /* "" string or 0 int/char indicates to apply to all glyphs. */ - /* "-" used as dummy placeholders, but any non-matching string works. */ - /* */ - /* Some of this could arguably be implemented in fontconfig, however: */ - /* */ - /* - Fontconfig can't set things on a glyph-by-glyph basis. */ - /* - The tweaks that happen here are very low-level, from an average */ - /* user's point of view and are best implemented in the hinter. */ - /* */ - /* The goal is to make the subpixel hinting techniques as generalized */ - /* as possible across all fonts to prevent the need for extra rules such */ - /* as these. */ - /* */ - /* The rule structure is designed so that entirely new rules can easily */ - /* be added when a new compatibility feature is discovered. */ - /* */ - /* The rule structures could also use some enhancement to handle ranges. */ - /* */ - /* ****************** WORK IN PROGRESS ******************* */ - /* */ + /************************************************************************** + * + * These rules affect how the TT Interpreter does hinting, with the + * goal of doing subpixel hinting by (in general) ignoring x moves. + * Some of these rules are fixes that go above and beyond the + * stated techniques in the MS whitepaper on Cleartype, due to + * artifacts in many glyphs. So, these rules make some glyphs render + * better than they do in the MS rasterizer. + * + * "" string or 0 int/char indicates to apply to all glyphs. + * "-" used as dummy placeholders, but any non-matching string works. + * + * Some of this could arguably be implemented in fontconfig, however: + * + * - Fontconfig can't set things on a glyph-by-glyph basis. + * - The tweaks that happen here are very low-level, from an average + * user's point of view and are best implemented in the hinter. + * + * The goal is to make the subpixel hinting techniques as generalized + * as possible across all fonts to prevent the need for extra rules such + * as these. + * + * The rule structure is designed so that entirely new rules can easily + * be added when a new compatibility feature is discovered. + * + * The rule structures could also use some enhancement to handle ranges. + * + * ****************** WORK IN PROGRESS ******************* + */ /* These are `classes' of fonts that can be grouped together and used in */ /* rules below. A blank entry "" is required at the end of these! */ diff --git a/src/3rdparty/freetype/src/truetype/ttsubpix.h b/src/3rdparty/freetype/src/truetype/ttsubpix.h index 1070bb016f..4966800c2d 100644 --- a/src/3rdparty/freetype/src/truetype/ttsubpix.h +++ b/src/3rdparty/freetype/src/truetype/ttsubpix.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* ttsubpix.h */ -/* */ -/* TrueType Subpixel Hinting. */ -/* */ -/* Copyright 2010-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ttsubpix.h + * + * TrueType Subpixel Hinting. + * + * Copyright (C) 2010-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef TTSUBPIX_H_ @@ -29,11 +29,11 @@ FT_BEGIN_HEADER #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - /*************************************************************************/ - /* */ - /* ID flags to identify special functions at FDEF and runtime. */ - /* */ - /* */ + /************************************************************************** + * + * ID flags to identify special functions at FDEF and runtime. + * + */ #define SPH_FDEF_INLINE_DELTA_1 0x0000001 #define SPH_FDEF_INLINE_DELTA_2 0x0000002 #define SPH_FDEF_DIAGONAL_STROKE 0x0000004 @@ -45,11 +45,11 @@ FT_BEGIN_HEADER #define SPH_FDEF_TYPEMAN_DIAGENDCTRL 0x0000100 - /*************************************************************************/ - /* */ - /* Tweak flags that are set for each glyph by the below rules. */ - /* */ - /* */ + /************************************************************************** + * + * Tweak flags that are set for each glyph by the below rules. + * + */ #define SPH_TWEAK_ALLOW_X_DMOVE 0x0000001UL #define SPH_TWEAK_ALWAYS_DO_DELTAP 0x0000002UL #define SPH_TWEAK_ALWAYS_SKIP_DELTAP 0x0000004UL diff --git a/src/3rdparty/freetype/src/type1/Jamfile b/src/3rdparty/freetype/src/type1/Jamfile index b94b7d0aae..0bcfb2e406 100644 --- a/src/3rdparty/freetype/src/type1/Jamfile +++ b/src/3rdparty/freetype/src/type1/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/type1 Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/type1/module.mk b/src/3rdparty/freetype/src/type1/module.mk index 3fea5cc16f..2f48c65821 100644 --- a/src/3rdparty/freetype/src/type1/module.mk +++ b/src/3rdparty/freetype/src/type1/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/type1/rules.mk b/src/3rdparty/freetype/src/type1/rules.mk index cb1a142860..901169c7a5 100644 --- a/src/3rdparty/freetype/src/type1/rules.mk +++ b/src/3rdparty/freetype/src/type1/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/type1/t1afm.c b/src/3rdparty/freetype/src/type1/t1afm.c index 61053d9a64..6841184539 100644 --- a/src/3rdparty/freetype/src/type1/t1afm.c +++ b/src/3rdparty/freetype/src/type1/t1afm.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1afm.c */ -/* */ -/* AFM support for Type 1 fonts (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1afm.c + * + * AFM support for Type 1 fonts (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -26,14 +26,14 @@ #ifndef T1_CONFIG_OPTION_NO_AFM - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1afm +#define FT_COMPONENT t1afm FT_LOCAL_DEF( void ) diff --git a/src/3rdparty/freetype/src/type1/t1afm.h b/src/3rdparty/freetype/src/type1/t1afm.h index cb8d302b4d..a8e6a5495a 100644 --- a/src/3rdparty/freetype/src/type1/t1afm.h +++ b/src/3rdparty/freetype/src/type1/t1afm.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1afm.h */ -/* */ -/* AFM support for Type 1 fonts (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1afm.h + * + * AFM support for Type 1 fonts (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1AFM_H_ diff --git a/src/3rdparty/freetype/src/type1/t1driver.c b/src/3rdparty/freetype/src/type1/t1driver.c index 029b410b47..557733da3b 100644 --- a/src/3rdparty/freetype/src/type1/t1driver.c +++ b/src/3rdparty/freetype/src/type1/t1driver.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1driver.c */ -/* */ -/* Type 1 driver interface (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1driver.c + * + * Type 1 driver interface (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -43,19 +43,19 @@ #include FT_SERVICE_KERNING_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1driver +#define FT_COMPONENT t1driver - /* - * GLYPH DICT SERVICE - * - */ + /* + * GLYPH DICT SERVICE + * + */ static FT_Error t1_get_glyph_name( T1_Face face, @@ -70,8 +70,8 @@ static FT_UInt - t1_get_name_index( T1_Face face, - FT_String* glyph_name ) + t1_get_name_index( T1_Face face, + const FT_String* glyph_name ) { FT_Int i; @@ -97,7 +97,7 @@ /* - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -115,30 +115,32 @@ /* - * MULTIPLE MASTERS SERVICE + * MULTIPLE MASTERS SERVICE * */ #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT static const FT_Service_MultiMastersRec t1_service_multi_masters = { - (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */ - (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */ - (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */ - (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */ - (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */ - (FT_Set_Var_Design_Func)T1_Set_Var_Design, /* set_var_design */ - (FT_Get_Var_Design_Func)T1_Get_Var_Design, /* get_var_design */ - (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */ - - (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */ - (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */ + (FT_Get_MM_Func) T1_Get_Multi_Master, /* get_mm */ + (FT_Set_MM_Design_Func) T1_Set_MM_Design, /* set_mm_design */ + (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, /* set_mm_blend */ + (FT_Get_MM_Blend_Func) T1_Get_MM_Blend, /* get_mm_blend */ + (FT_Get_MM_Var_Func) T1_Get_MM_Var, /* get_mm_var */ + (FT_Set_Var_Design_Func) T1_Set_Var_Design, /* set_var_design */ + (FT_Get_Var_Design_Func) T1_Get_Var_Design, /* get_var_design */ + (FT_Set_Instance_Func) T1_Reset_MM_Blend, /* set_instance */ + (FT_Set_MM_WeightVector_Func)T1_Set_MM_WeightVector, /* set_mm_weightvector */ + (FT_Get_MM_WeightVector_Func)T1_Get_MM_WeightVector, /* get_mm_weightvector */ + + (FT_Get_Var_Blend_Func) NULL, /* get_var_blend */ + (FT_Done_Blend_Func) T1_Done_Blend /* done_blend */ }; #endif /* - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -270,9 +272,12 @@ break; case PS_DICT_FONT_NAME: - retval = ft_strlen( type1->font_name ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_name ), retval ); + if ( type1->font_name ) + { + retval = ft_strlen( type1->font_name ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_name ), retval ); + } break; case PS_DICT_UNIQUE_ID: @@ -362,7 +367,7 @@ ok = 1; } - if ( ok ) + if ( ok && type1->subrs ) { retval = type1->subrs_len[idx] + 1; if ( value && value_len >= retval ) @@ -559,33 +564,49 @@ break; case PS_DICT_VERSION: - retval = ft_strlen( type1->font_info.version ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.version ), retval ); + if ( type1->font_info.version ) + { + retval = ft_strlen( type1->font_info.version ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.version ), retval ); + } break; case PS_DICT_NOTICE: - retval = ft_strlen( type1->font_info.notice ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.notice ), retval ); + if ( type1->font_info.notice ) + { + retval = ft_strlen( type1->font_info.notice ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.notice ), retval ); + } break; case PS_DICT_FULL_NAME: - retval = ft_strlen( type1->font_info.full_name ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.full_name ), retval ); + if ( type1->font_info.full_name ) + { + retval = ft_strlen( type1->font_info.full_name ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.full_name ), retval ); + } break; case PS_DICT_FAMILY_NAME: - retval = ft_strlen( type1->font_info.family_name ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.family_name ), retval ); + if ( type1->font_info.family_name ) + { + retval = ft_strlen( type1->font_info.family_name ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.family_name ), + retval ); + } break; case PS_DICT_WEIGHT: - retval = ft_strlen( type1->font_info.weight ) + 1; - if ( value && value_len >= retval ) - ft_memcpy( value, (void *)( type1->font_info.weight ), retval ); + if ( type1->font_info.weight ) + { + retval = ft_strlen( type1->font_info.weight ) + 1; + if ( value && value_len >= retval ) + ft_memcpy( value, (void *)( type1->font_info.weight ), retval ); + } break; case PS_DICT_ITALIC_ANGLE: @@ -618,7 +639,7 @@ /* - * PROPERTY SERVICE + * PROPERTY SERVICE * */ @@ -630,7 +651,7 @@ /* - * SERVICE LIST + * SERVICE LIST * */ @@ -665,38 +686,42 @@ #ifndef T1_CONFIG_OPTION_NO_AFM - /*************************************************************************/ - /* */ - /* <Function> */ - /* Get_Kerning */ - /* */ - /* <Description> */ - /* A driver method used to return the kerning vector between two */ - /* glyphs of the same face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* <Output> */ - /* kerning :: The kerning vector. This is in font units for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this function. Other layouts, or more sophisticated */ - /* kernings are out of scope of this method (the basic driver */ - /* interface is meant to be simple). */ - /* */ - /* They can be implemented by format-specific interfaces. */ - /* */ + /************************************************************************** + * + * @Function: + * Get_Kerning + * + * @Description: + * A driver method used to return the kerning vector between two + * glyphs of the same face. + * + * @Input: + * face :: + * A handle to the source face object. + * + * left_glyph :: + * The index of the left glyph in the kern pair. + * + * right_glyph :: + * The index of the right glyph in the kern pair. + * + * @Output: + * kerning :: + * The kerning vector. This is in font units for + * scalable formats, and in pixels for fixed-sizes + * formats. + * + * @Return: + * FreeType error code. 0 means success. + * + * @Note: + * Only horizontal layouts (left-to-right & right-to-left) are + * supported by this function. Other layouts, or more sophisticated + * kernings are out of scope of this method (the basic driver + * interface is meant to be simple). + * + * They can be implemented by format-specific interfaces. + */ static FT_Error Get_Kerning( FT_Face t1face, /* T1_Face */ FT_UInt left_glyph, diff --git a/src/3rdparty/freetype/src/type1/t1driver.h b/src/3rdparty/freetype/src/type1/t1driver.h index 2b1507233d..206f64a0bc 100644 --- a/src/3rdparty/freetype/src/type1/t1driver.h +++ b/src/3rdparty/freetype/src/type1/t1driver.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1driver.h */ -/* */ -/* High-level Type 1 driver interface (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1driver.h + * + * High-level Type 1 driver interface (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1DRIVER_H_ @@ -26,14 +26,8 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - - FT_EXPORT_VAR( const FT_Driver_ClassRec ) t1_driver_class; - FT_END_HEADER #endif /* T1DRIVER_H_ */ diff --git a/src/3rdparty/freetype/src/type1/t1errors.h b/src/3rdparty/freetype/src/type1/t1errors.h index 9e0151b957..b35f67a24c 100644 --- a/src/3rdparty/freetype/src/type1/t1errors.h +++ b/src/3rdparty/freetype/src/type1/t1errors.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* t1errors.h */ -/* */ -/* Type 1 error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the Type 1 error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t1errors.h + * + * Type 1 error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the Type 1 error enumeration constants. + * + */ #ifndef T1ERRORS_H_ #define T1ERRORS_H_ diff --git a/src/3rdparty/freetype/src/type1/t1gload.c b/src/3rdparty/freetype/src/type1/t1gload.c index 87d40e7566..f9b115b186 100644 --- a/src/3rdparty/freetype/src/type1/t1gload.c +++ b/src/3rdparty/freetype/src/type1/t1gload.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1gload.c */ -/* */ -/* Type 1 Glyph Loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1gload.c + * + * Type 1 Glyph Loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -29,14 +29,14 @@ #include "t1errors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1gload +#define FT_COMPONENT t1gload static FT_Error @@ -62,6 +62,7 @@ PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); #endif + decoder->font_matrix = type1->font_matrix; decoder->font_offset = type1->font_offset; @@ -249,6 +250,8 @@ *max_advance = 0; + FT_TRACE6(( "T1_Compute_Max_Advance:\n" )); + /* for each glyph, parse the glyph charstring and extract */ /* the advance width */ for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ ) @@ -261,6 +264,9 @@ /* ignore the error if one occurred - skip to next glyph */ } + FT_TRACE6(( "T1_Compute_Max_Advance: max advance: %f\n", + *max_advance / 65536.0 )); + psaux->t1_decoder_funcs->done( &decoder ); return FT_Err_Ok; @@ -282,11 +288,18 @@ FT_Error error; + FT_TRACE5(( "T1_Get_Advances:\n" )); + if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { for ( nn = 0; nn < count; nn++ ) + { advances[nn] = 0; + FT_TRACE5(( " idx %d: advance height 0 font units\n", + first + nn )); + } + return FT_Err_Ok; } @@ -320,6 +333,11 @@ advances[nn] = FIXED_TO_INT( decoder.builder.advance.x ); else advances[nn] = 0; + + FT_TRACE5(( " idx %d: advance width %d font unit%s\n", + first + nn, + advances[nn], + advances[nn] == 1 ? "" : "s" )); } return FT_Err_Ok; @@ -384,9 +402,9 @@ t1glyph->outline.n_points = 0; t1glyph->outline.n_contours = 0; - hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && - ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); - scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ); + hinting = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) && + !( load_flags & FT_LOAD_NO_HINTING ) ); + scaled = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) ); glyph->hint = hinting; glyph->scaled = scaled; @@ -398,7 +416,7 @@ t1glyph, (FT_Byte**)type1->glyph_names, face->blend, - FT_BOOL( hinting ), + hinting, FT_LOAD_TARGET_MODE( load_flags ), T1_Parse_Glyph ); if ( error ) @@ -406,8 +424,7 @@ must_finish_decoder = TRUE; - decoder.builder.no_recurse = FT_BOOL( - ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); + decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE ); decoder.num_subrs = type1->num_subrs; decoder.subrs = type1->subrs; @@ -528,7 +545,7 @@ /* First of all, scale the points, if we are not hinting */ - if ( !hinting || ! decoder.builder.hints_funcs ) + if ( !hinting || !decoder.builder.hints_funcs ) for ( n = cur->n_points; n > 0; n--, vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); diff --git a/src/3rdparty/freetype/src/type1/t1gload.h b/src/3rdparty/freetype/src/type1/t1gload.h index 72ef76f6ae..80440369dc 100644 --- a/src/3rdparty/freetype/src/type1/t1gload.h +++ b/src/3rdparty/freetype/src/type1/t1gload.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1gload.h */ -/* */ -/* Type 1 Glyph Loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1gload.h + * + * Type 1 Glyph Loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1GLOAD_H_ diff --git a/src/3rdparty/freetype/src/type1/t1load.c b/src/3rdparty/freetype/src/type1/t1load.c index 9dfa637a69..5cffdfaac4 100644 --- a/src/3rdparty/freetype/src/type1/t1load.c +++ b/src/3rdparty/freetype/src/type1/t1load.c @@ -1,63 +1,63 @@ -/***************************************************************************/ -/* */ -/* t1load.c */ -/* */ -/* Type 1 font loader (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is the new and improved Type 1 data loader for FreeType 2. The */ - /* old loader has several problems: it is slow, complex, difficult to */ - /* maintain, and contains incredible hacks to make it accept some */ - /* ill-formed Type 1 fonts without hiccup-ing. Moreover, about 5% of */ - /* the Type 1 fonts on my machine still aren't loaded correctly by it. */ - /* */ - /* This version is much simpler, much faster and also easier to read and */ - /* maintain by a great order of magnitude. The idea behind it is to */ - /* _not_ try to read the Type 1 token stream with a state machine (i.e. */ - /* a Postscript-like interpreter) but rather to perform simple pattern */ - /* matching. */ - /* */ - /* Indeed, nearly all data definitions follow a simple pattern like */ - /* */ - /* ... /Field <data> ... */ - /* */ - /* where <data> can be a number, a boolean, a string, or an array of */ - /* numbers. There are a few exceptions, namely the encoding, font name, */ - /* charstrings, and subrs; they are handled with a special pattern */ - /* matching routine. */ - /* */ - /* All other common cases are handled very simply. The matching rules */ - /* are defined in the file `t1tokens.h' through the use of several */ - /* macros calls PARSE_XXX. This file is included twice here; the first */ - /* time to generate parsing callback functions, the second time to */ - /* generate a table of keywords (with pointers to the associated */ - /* callback functions). */ - /* */ - /* The function `parse_dict' simply scans *linearly* a given dictionary */ - /* (either the top-level or private one) and calls the appropriate */ - /* callback when it encounters an immediate keyword. */ - /* */ - /* This is by far the fastest way one can find to parse and read all */ - /* data. */ - /* */ - /* This led to tremendous code size reduction. Note that later, the */ - /* glyph loader will also be _greatly_ simplified, and the automatic */ - /* hinter will replace the clumsy `t1hinter'. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t1load.c + * + * Type 1 font loader (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This is the new and improved Type 1 data loader for FreeType 2. The + * old loader has several problems: it is slow, complex, difficult to + * maintain, and contains incredible hacks to make it accept some + * ill-formed Type 1 fonts without hiccup-ing. Moreover, about 5% of + * the Type 1 fonts on my machine still aren't loaded correctly by it. + * + * This version is much simpler, much faster and also easier to read and + * maintain by a great order of magnitude. The idea behind it is to + * _not_ try to read the Type 1 token stream with a state machine (i.e. + * a Postscript-like interpreter) but rather to perform simple pattern + * matching. + * + * Indeed, nearly all data definitions follow a simple pattern like + * + * ... /Field <data> ... + * + * where <data> can be a number, a boolean, a string, or an array of + * numbers. There are a few exceptions, namely the encoding, font name, + * charstrings, and subrs; they are handled with a special pattern + * matching routine. + * + * All other common cases are handled very simply. The matching rules + * are defined in the file `t1tokens.h' through the use of several + * macros calls PARSE_XXX. This file is included twice here; the first + * time to generate parsing callback functions, the second time to + * generate a table of keywords (with pointers to the associated + * callback functions). + * + * The function `parse_dict' simply scans *linearly* a given dictionary + * (either the top-level or private one) and calls the appropriate + * callback when it encounters an immediate keyword. + * + * This is by far the fastest way one can find to parse and read all + * data. + * + * This led to tremendous code size reduction. Note that later, the + * glyph loader will also be _greatly_ simplified, and the automatic + * hinter will replace the clumsy `t1hinter'. + * + */ #include <ft2build.h> @@ -73,20 +73,20 @@ #ifdef FT_CONFIG_OPTION_INCREMENTAL -#define IS_INCREMENTAL (FT_Bool)( face->root.internal->incremental_interface != 0 ) +#define IS_INCREMENTAL FT_BOOL( face->root.internal->incremental_interface ) #else #define IS_INCREMENTAL 0 #endif - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1load +#define FT_COMPONENT t1load #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT @@ -222,11 +222,11 @@ } - /*************************************************************************/ - /* */ - /* Given a normalized (blend) coordinate, figure out the design */ - /* coordinate appropriate for that value. */ - /* */ + /************************************************************************** + * + * Given a normalized (blend) coordinate, figure out the design + * coordinate appropriate for that value. + */ static FT_Fixed mm_axis_unmap( PS_DesignMap axismap, FT_Fixed ncv ) @@ -251,11 +251,11 @@ } - /*************************************************************************/ - /* */ - /* Given a vector of weights, one for each design, figure out the */ - /* normalized axis coordinates which gave rise to those weights. */ - /* */ + /************************************************************************** + * + * Given a vector of weights, one for each design, figure out the + * normalized axis coordinates which gave rise to those weights. + */ static void mm_weights_unmap( FT_Fixed* weights, FT_Fixed* axiscoords, @@ -293,11 +293,11 @@ } - /*************************************************************************/ - /* */ - /* Just a wrapper around T1_Get_Multi_Master to support the different */ - /* arguments needed by the GX var distortable fonts. */ - /* */ + /************************************************************************** + * + * Just a wrapper around T1_Get_Multi_Master to support the different + * arguments needed by the GX var distortable fonts. + */ FT_LOCAL_DEF( FT_Error ) T1_Get_MM_Var( T1_Face face, FT_MM_Var* *master ) @@ -348,16 +348,13 @@ mmvar->axis[i].tag = FT_MAKE_TAG( 'o', 'p', 's', 'z' ); } - if ( blend->num_designs == ( 1U << blend->num_axis ) ) - { - mm_weights_unmap( blend->default_weight_vector, - axiscoords, - blend->num_axis ); + mm_weights_unmap( blend->default_weight_vector, + axiscoords, + blend->num_axis ); - for ( i = 0; i < mmaster.num_axis; i++ ) - mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i], - axiscoords[i] ); - } + for ( i = 0; i < mmaster.num_axis; i++ ) + mmvar->axis[i].def = mm_axis_unmap( &blend->design_map[i], + axiscoords[i] ); *master = mmvar; @@ -387,24 +384,31 @@ for ( n = 0; n < blend->num_designs; n++ ) { FT_Fixed result = 0x10000L; /* 1.0 fixed */ + FT_Fixed factor; for ( m = 0; m < blend->num_axis; m++ ) { - FT_Fixed factor; - - - /* get current blend axis position; */ /* use a default value if we don't have a coordinate */ - factor = m < num_coords ? coords[m] : 0x8000; - if ( factor < 0 ) - factor = 0; - if ( factor > 0x10000L ) - factor = 0x10000L; + if ( m >= num_coords ) + { + result >>= 1; + continue; + } + /* get current blend axis position */ + factor = coords[m]; if ( ( n & ( 1 << m ) ) == 0 ) factor = 0x10000L - factor; + if ( factor <= 0 ) + { + result = 0; + break; + } + else if ( factor >= 0x10000L ) + continue; + result = FT_MulFix( result, factor ); } @@ -476,6 +480,75 @@ } + FT_LOCAL_DEF( FT_Error ) + T1_Set_MM_WeightVector( T1_Face face, + FT_UInt len, + FT_Fixed* weightvector ) + { + PS_Blend blend = face->blend; + FT_UInt i, n; + + + if ( !blend ) + return FT_THROW( Invalid_Argument ); + + if ( !len && !weightvector ) + { + for ( i = 0; i < blend->num_designs; i++ ) + blend->weight_vector[i] = blend->default_weight_vector[i]; + } + else + { + if ( !weightvector ) + return FT_THROW( Invalid_Argument ); + + n = len < blend->num_designs ? len : blend->num_designs; + + for ( i = 0; i < n; i++ ) + blend->weight_vector[i] = weightvector[i]; + + for ( ; i < blend->num_designs; i++ ) + blend->weight_vector[i] = (FT_Fixed)0; + + if ( len ) + face->root.face_flags |= FT_FACE_FLAG_VARIATION; + else + face->root.face_flags &= ~FT_FACE_FLAG_VARIATION; + } + + return FT_Err_Ok; + } + + + FT_LOCAL_DEF( FT_Error ) + T1_Get_MM_WeightVector( T1_Face face, + FT_UInt* len, + FT_Fixed* weightvector ) + { + PS_Blend blend = face->blend; + FT_UInt i; + + + if ( !blend ) + return FT_THROW( Invalid_Argument ); + + if ( *len < blend->num_designs ) + { + *len = blend->num_designs; + return FT_THROW( Invalid_Argument ); + } + + for ( i = 0; i < blend->num_designs; i++ ) + weightvector[i] = blend->weight_vector[i]; + for ( ; i < *len; i++ ) + weightvector[i] = (FT_Fixed)0; + + *len = blend->num_designs; + + return FT_Err_Ok; + } + + FT_LOCAL_DEF( FT_Error ) T1_Set_MM_Design( T1_Face face, FT_UInt num_coords, @@ -573,11 +646,11 @@ } - /*************************************************************************/ - /* */ - /* Just a wrapper around T1_Set_MM_Design to support the different */ - /* arguments needed by the GX var distortable fonts. */ - /* */ + /************************************************************************** + * + * Just a wrapper around T1_Set_MM_Design to support the different + * arguments needed by the GX var distortable fonts. + */ FT_LOCAL_DEF( FT_Error ) T1_Set_Var_Design( T1_Face face, FT_UInt num_coords, @@ -719,6 +792,8 @@ if ( error ) goto Exit; + FT_TRACE4(( " [" )); + blend = face->blend; memory = face->root.memory; @@ -741,11 +816,13 @@ goto Exit; } + FT_TRACE4(( " /%.*s", len, token->start )); + name = (FT_Byte*)blend->axis_names[n]; if ( name ) { FT_TRACE0(( "parse_blend_axis_types:" - " overwriting axis name `%s' with `%*.s'\n", + " overwriting axis name `%s' with `%.*s'\n", name, len, token->start )); FT_FREE( name ); } @@ -758,6 +835,8 @@ name[len] = '\0'; } + FT_TRACE4(( "]\n" )); + Exit: loader->parser.root.error = error; } @@ -802,6 +881,8 @@ blend = face->blend; num_axis = 0; /* make compiler happy */ + FT_TRACE4(( " [" )); + for ( n = 0; n < num_designs; n++ ) { T1_TokenRec axis_tokens[T1_MAX_MM_AXIS]; @@ -842,6 +923,7 @@ } /* now read each axis token into the design position */ + FT_TRACE4(( " [" )) ; for ( axis = 0; axis < n_axis; axis++ ) { T1_Token token2 = axis_tokens + axis; @@ -850,9 +932,13 @@ parser->root.cursor = token2->start; parser->root.limit = token2->limit; blend->design_pos[n][axis] = T1_ToFixed( parser, 0 ); + FT_TRACE4(( " %f", (double)blend->design_pos[n][axis] / 65536 )); } + FT_TRACE4(( "]" )) ; } + FT_TRACE4(( "]\n" )); + loader->parser.root.cursor = old_cursor; loader->parser.root.limit = old_limit; } @@ -899,6 +985,8 @@ goto Exit; blend = face->blend; + FT_TRACE4(( " [" )); + /* now read each axis design map */ for ( n = 0; n < num_axis; n++ ) { @@ -915,6 +1003,8 @@ T1_ToTokenArray( parser, point_tokens, T1_MAX_MM_MAP_POINTS, &num_points ); + FT_TRACE4(( " [" )); + if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS ) { FT_ERROR(( "parse_blend_design_map: incorrect table\n" )); @@ -948,9 +1038,17 @@ map->design_points[p] = T1_ToInt( parser ); map->blend_points [p] = T1_ToFixed( parser, 0 ); + + FT_TRACE4(( " [%d %f]", + map->design_points[p], + (double)map->blend_points[p] / 65536 )); } + + FT_TRACE4(( "]" )); } + FT_TRACE4(( "]\n" )); + parser->root.cursor = old_cursor; parser->root.limit = old_limit; @@ -1010,6 +1108,8 @@ old_cursor = parser->root.cursor; old_limit = parser->root.limit; + FT_TRACE4(( "[" )); + for ( n = 0; n < num_designs; n++ ) { token = design_tokens + n; @@ -1018,8 +1118,12 @@ blend->default_weight_vector[n] = blend->weight_vector[n] = T1_ToFixed( parser, 0 ); + + FT_TRACE4(( " %f", (double)blend->weight_vector[n] / 65536 )); } + FT_TRACE4(( "]\n" )); + parser->root.cursor = old_cursor; parser->root.limit = old_limit; @@ -1036,6 +1140,20 @@ { face->len_buildchar = (FT_UInt)T1_ToFixedArray( &loader->parser, 0, NULL, 0 ); + +#ifdef FT_DEBUG_LEVEL_TRACE + { + FT_UInt i; + + + FT_TRACE4(( " [" )); + for ( i = 0; i < face->len_buildchar; i++ ) + FT_TRACE4(( " 0" )); + + FT_TRACE4(( "]\n" )); + } +#endif + return; } @@ -1071,6 +1189,8 @@ /* if the keyword has a dedicated callback, call it */ if ( field->type == T1_FIELD_TYPE_CALLBACK ) { + FT_TRACE4(( " %s", field->ident )); + field->reader( (FT_Face)face, loader ); error = loader->parser.root.error; goto Exit; @@ -1148,6 +1268,8 @@ max_objects = 0; } + FT_TRACE4(( " %s", field->ident )); + if ( *objects ) { if ( field->type == T1_FIELD_TYPE_INTEGER_ARRAY || @@ -1167,6 +1289,8 @@ error = FT_Err_Ok; } + FT_TRACE4(( "\n" )); + Exit: return error; } @@ -1179,6 +1303,8 @@ FT_UNUSED( face ); loader->keywords_encountered |= T1_PRIVATE; + + FT_TRACE4(( "\n" )); } @@ -1258,6 +1384,14 @@ return; } + FT_TRACE4(( " [%f %f %f %f %f %f]\n", + (double)temp[0] / 65536 / 1000, + (double)temp[1] / 65536 / 1000, + (double)temp[2] / 65536 / 1000, + (double)temp[3] / 65536 / 1000, + (double)temp[4] / 65536 / 1000, + (double)temp[5] / 65536 / 1000 )); + temp_scale = FT_ABS( temp[3] ); if ( temp_scale == 0 ) @@ -1280,12 +1414,18 @@ temp[5] = FT_DivFix( temp[5], temp_scale ); temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L; } - matrix->xx = temp[0]; matrix->yx = temp[1]; matrix->xy = temp[2]; matrix->yy = temp[3]; + if ( !FT_Matrix_Check( matrix ) ) + { + FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" )); + parser->root.error = FT_THROW( Invalid_File_Format ); + return; + } + /* note that the offsets must be expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; @@ -1367,12 +1507,7 @@ /* We need to `zero' out encoding_table.elements */ for ( n = 0; n < array_size; n++ ) - { - char* notdef = (char *)".notdef"; - - - (void)T1_Add_Table( char_table, n, notdef, 8 ); - } + (void)T1_Add_Table( char_table, n, ".notdef", 8 ); /* Now we need to read records of the form */ /* */ @@ -1494,6 +1629,15 @@ T1_Skip_Spaces( parser ); } +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " [" )); + + /* XXX show encoding vector */ + FT_TRACE4(( "..." )); + + FT_TRACE4(( "]\n" )); +#endif + face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY; parser->root.cursor = cur; } @@ -1504,18 +1648,30 @@ { if ( cur + 17 < limit && ft_strncmp( (const char*)cur, "StandardEncoding", 16 ) == 0 ) + { face->type1.encoding_type = T1_ENCODING_TYPE_STANDARD; + FT_TRACE4(( " StandardEncoding\n" )); + } else if ( cur + 15 < limit && ft_strncmp( (const char*)cur, "ExpertEncoding", 14 ) == 0 ) + { face->type1.encoding_type = T1_ENCODING_TYPE_EXPERT; + FT_TRACE4(( " ExpertEncoding\n" )); + } else if ( cur + 18 < limit && ft_strncmp( (const char*)cur, "ISOLatin1Encoding", 17 ) == 0 ) + { face->type1.encoding_type = T1_ENCODING_TYPE_ISOLATIN1; + FT_TRACE4(( " ISOLatin1Encoding\n" )); + } else + { parser->root.error = FT_ERR( Ignore ); + FT_TRACE4(( "<unknown>\n" )); + } } } @@ -1696,6 +1852,15 @@ if ( !loader->num_subrs ) loader->num_subrs = num_subrs; +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " <" )); + + /* XXX show subrs? */ + FT_TRACE4(( "%d elements", num_subrs )); + + FT_TRACE4(( ">\n" )); +#endif + return; Fail: @@ -1977,7 +2142,6 @@ /* 0 333 hsbw endchar */ FT_Byte notdef_glyph[] = { 0x8B, 0xF7, 0xE1, 0x0D, 0x0E }; - char* notdef_name = (char *)".notdef"; error = T1_Add_Table( swap_table, 0, @@ -1992,7 +2156,7 @@ if ( error ) goto Fail; - error = T1_Add_Table( name_table, 0, notdef_name, 8 ); + error = T1_Add_Table( name_table, 0, ".notdef", 8 ); if ( error ) goto Fail; @@ -2017,6 +2181,15 @@ loader->num_glyphs += 1; } +#ifdef FT_DEBUG_LEVEL_TRACE + FT_TRACE4(( " <" )); + + /* XXX show charstrings? */ + FT_TRACE4(( "%d elements", loader->num_glyphs )); + + FT_TRACE4(( ">\n" )); +#endif + return; Fail: @@ -2024,12 +2197,12 @@ } - /*************************************************************************/ - /* */ - /* Define the token field static variables. This is a set of */ - /* T1_FieldRec variables. */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * Define the token field static variables. This is a set of + * T1_FieldRec variables. + * + */ static @@ -2216,6 +2389,7 @@ ? T1_FIELD_DICT_PRIVATE : T1_FIELD_DICT_FONTDICT; + if ( !( dict & keyword->dict ) ) { FT_TRACE1(( "parse_dict: found `%s' but ignoring it" @@ -2330,6 +2504,7 @@ if ( error ) goto Exit; + FT_TRACE4(( " top dictionary:\n" )); error = parse_dict( face, &loader, parser->base_dict, parser->base_len ); if ( error ) @@ -2339,6 +2514,7 @@ if ( error ) goto Exit; + FT_TRACE4(( " private dictionary:\n" )); error = parse_dict( face, &loader, parser->private_dict, parser->private_len ); if ( error ) @@ -2349,6 +2525,16 @@ #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT + /* we don't support Multiple Master fonts with intermediate designs; */ + /* this implies that `num_designs' must be equal to `2^^num_axis' */ + if ( face->blend && + face->blend->num_designs != ( 1U << face->blend->num_axis ) ) + { + FT_ERROR(( "T1_Open_Face:" + " number-of-designs != 2 ^^ number-of-axes\n" )); + T1_Done_Blend( face ); + } + if ( face->blend && face->blend->num_default_design_vector != 0 && face->blend->num_default_design_vector != face->blend->num_axis ) @@ -2441,8 +2627,7 @@ /* we must now build type1.encoding when we have a custom array */ if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY ) { - FT_Int charcode, idx, min_char, max_char; - FT_Byte* glyph_name; + FT_Int charcode, idx, min_char, max_char; /* OK, we do the following: for each element in the encoding */ @@ -2456,27 +2641,27 @@ charcode = 0; for ( ; charcode < loader.encoding_table.max_elems; charcode++ ) { - FT_Byte* char_name; + const FT_String* char_name = + (const FT_String*)loader.encoding_table.elements[charcode]; type1->encoding.char_index[charcode] = 0; - type1->encoding.char_name [charcode] = (char *)".notdef"; + type1->encoding.char_name [charcode] = ".notdef"; - char_name = loader.encoding_table.elements[charcode]; if ( char_name ) for ( idx = 0; idx < type1->num_glyphs; idx++ ) { - glyph_name = (FT_Byte*)type1->glyph_names[idx]; - if ( ft_strcmp( (const char*)char_name, - (const char*)glyph_name ) == 0 ) + const FT_String* glyph_name = type1->glyph_names[idx]; + + + if ( ft_strcmp( char_name, glyph_name ) == 0 ) { type1->encoding.char_index[charcode] = (FT_UShort)idx; - type1->encoding.char_name [charcode] = (char*)glyph_name; + type1->encoding.char_name [charcode] = glyph_name; /* Change min/max encoded char only if glyph name is */ /* not /.notdef */ - if ( ft_strcmp( (const char*)".notdef", - (const char*)glyph_name ) != 0 ) + if ( ft_strcmp( ".notdef", glyph_name ) != 0 ) { if ( charcode < min_char ) min_char = charcode; diff --git a/src/3rdparty/freetype/src/type1/t1load.h b/src/3rdparty/freetype/src/type1/t1load.h index 03be3f7f93..44f835bde2 100644 --- a/src/3rdparty/freetype/src/type1/t1load.h +++ b/src/3rdparty/freetype/src/type1/t1load.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1load.h */ -/* */ -/* Type 1 font loader (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1load.h + * + * Type 1 font loader (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1LOAD_H_ @@ -106,6 +106,16 @@ FT_BEGIN_HEADER FT_LOCAL( void ) T1_Done_Blend( T1_Face face ); + FT_LOCAL( FT_Error ) + T1_Set_MM_WeightVector( T1_Face face, + FT_UInt len, + FT_Fixed* weightvector ); + + FT_LOCAL( FT_Error ) + T1_Get_MM_WeightVector( T1_Face face, + FT_UInt* len, + FT_Fixed* weightvector ); + #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */ diff --git a/src/3rdparty/freetype/src/type1/t1objs.c b/src/3rdparty/freetype/src/type1/t1objs.c index 7333c4c958..741388a645 100644 --- a/src/3rdparty/freetype/src/type1/t1objs.c +++ b/src/3rdparty/freetype/src/type1/t1objs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1objs.c */ -/* */ -/* Type 1 objects manager (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1objs.c + * + * Type 1 objects manager (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -36,21 +36,21 @@ #include FT_INTERNAL_POSTSCRIPT_AUX_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1objs +#define FT_COMPONENT t1objs - /*************************************************************************/ - /* */ - /* SIZE FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SIZE FUNCTIONS + * + */ static PSH_Globals_Funcs @@ -133,11 +133,11 @@ } - /*************************************************************************/ - /* */ - /* SLOT FUNCTIONS */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * SLOT FUNCTIONS + * + */ FT_LOCAL_DEF( void ) T1_GlyphSlot_Done( FT_GlyphSlot slot ) @@ -177,24 +177,25 @@ } - /*************************************************************************/ - /* */ - /* FACE FUNCTIONS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Face_Done */ - /* */ - /* <Description> */ - /* The face object destructor. */ - /* */ - /* <Input> */ - /* face :: A typeless pointer to the face object to destroy. */ - /* */ + /************************************************************************** + * + * FACE FUNCTIONS + * + */ + + + /************************************************************************** + * + * @Function: + * T1_Face_Done + * + * @Description: + * The face object destructor. + * + * @Input: + * face :: + * A typeless pointer to the face object to destroy. + */ FT_LOCAL_DEF( void ) T1_Face_Done( FT_Face t1face ) /* T1_Face */ { @@ -274,29 +275,34 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Face_Init */ - /* */ - /* <Description> */ - /* The face object constructor. */ - /* */ - /* <Input> */ - /* stream :: input stream where to load font data. */ - /* */ - /* face_index :: The index of the font face in the resource. */ - /* */ - /* num_params :: Number of additional generic parameters. Ignored. */ - /* */ - /* params :: Additional generic parameters. Ignored. */ - /* */ - /* <InOut> */ - /* face :: The face record to build. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * T1_Face_Init + * + * @Description: + * The face object constructor. + * + * @Input: + * stream :: + * input stream where to load font data. + * + * face_index :: + * The index of the font face in the resource. + * + * num_params :: + * Number of additional generic parameters. Ignored. + * + * params :: + * Additional generic parameters. Ignored. + * + * @InOut: + * face :: + * The face record to build. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) T1_Face_Init( FT_Stream stream, FT_Face t1face, /* T1_Face */ @@ -341,6 +347,10 @@ if ( error ) goto Exit; + FT_TRACE2(( "T1_Face_Init: %08p (index %d)\n", + face, + face_index )); + /* if we just wanted to check the format, leave successfully now */ if ( face_index < 0 ) goto Exit; @@ -516,7 +526,8 @@ error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -564,20 +575,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Driver_Init */ - /* */ - /* <Description> */ - /* Initializes a given Type 1 driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * T1_Driver_Init + * + * @Description: + * Initializes a given Type 1 driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) T1_Driver_Init( FT_Module module ) { @@ -620,17 +632,18 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T1_Driver_Done */ - /* */ - /* <Description> */ - /* Finalizes a given Type 1 driver. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target Type 1 driver. */ - /* */ + /************************************************************************** + * + * @Function: + * T1_Driver_Done + * + * @Description: + * Finalizes a given Type 1 driver. + * + * @Input: + * driver :: + * A handle to the target Type 1 driver. + */ FT_LOCAL_DEF( void ) T1_Driver_Done( FT_Module driver ) { diff --git a/src/3rdparty/freetype/src/type1/t1objs.h b/src/3rdparty/freetype/src/type1/t1objs.h index 8298e036f4..2161091f77 100644 --- a/src/3rdparty/freetype/src/type1/t1objs.h +++ b/src/3rdparty/freetype/src/type1/t1objs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1objs.h */ -/* */ -/* Type 1 objects manager (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1objs.h + * + * Type 1 objects manager (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1OBJS_H_ @@ -34,59 +34,59 @@ FT_BEGIN_HEADER typedef struct T1_Glyph_Hints_ T1_Glyph_Hints; - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_Size */ - /* */ - /* <Description> */ - /* A handle to a Type 1 size object. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_Size + * + * @Description: + * A handle to a Type 1 size object. + */ typedef struct T1_SizeRec_* T1_Size; - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a Type 1 glyph slot object. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_GlyphSlot + * + * @Description: + * A handle to a Type 1 glyph slot object. + */ typedef struct T1_GlyphSlotRec_* T1_GlyphSlot; - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_CharMap */ - /* */ - /* <Description> */ - /* A handle to a Type 1 character mapping object. */ - /* */ - /* <Note> */ - /* The Type 1 format doesn't use a charmap but an encoding table. */ - /* The driver is responsible for making up charmap objects */ - /* corresponding to these tables. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_CharMap + * + * @Description: + * A handle to a Type 1 character mapping object. + * + * @Note: + * The Type 1 format doesn't use a charmap but an encoding table. + * The driver is responsible for making up charmap objects + * corresponding to these tables. + */ typedef struct T1_CharMapRec_* T1_CharMap; - /*************************************************************************/ - /* */ - /* HERE BEGINS THE TYPE1 SPECIFIC STUFF */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * HERE BEGINS THE TYPE1 SPECIFIC STUFF + * + */ - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_SizeRec */ - /* */ - /* <Description> */ - /* Type 1 size record. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_SizeRec + * + * @Description: + * Type 1 size record. + */ typedef struct T1_SizeRec_ { FT_SizeRec root; @@ -105,14 +105,14 @@ FT_BEGIN_HEADER T1_Size_Init( FT_Size size ); - /*************************************************************************/ - /* */ - /* <Type> */ - /* T1_GlyphSlotRec */ - /* */ - /* <Description> */ - /* Type 1 glyph slot record. */ - /* */ + /************************************************************************** + * + * @Type: + * T1_GlyphSlotRec + * + * @Description: + * Type 1 glyph slot record. + */ typedef struct T1_GlyphSlotRec_ { FT_GlyphSlotRec root; diff --git a/src/3rdparty/freetype/src/type1/t1parse.c b/src/3rdparty/freetype/src/type1/t1parse.c index 8e201e5ef5..56caeb9e40 100644 --- a/src/3rdparty/freetype/src/type1/t1parse.c +++ b/src/3rdparty/freetype/src/type1/t1parse.c @@ -1,36 +1,36 @@ -/***************************************************************************/ -/* */ -/* t1parse.c */ -/* */ -/* Type 1 parser (body). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The Type 1 parser is in charge of the following: */ - /* */ - /* - provide an implementation of a growing sequence of objects called */ - /* a `T1_Table' (used to build various tables needed by the loader). */ - /* */ - /* - opening .pfb and .pfa files to extract their top-level and private */ - /* dictionaries. */ - /* */ - /* - read numbers, arrays & strings from any dictionary. */ - /* */ - /* See `t1load.c' to see how data is loaded from the font file. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t1parse.c + * + * Type 1 parser (body). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * The Type 1 parser is in charge of the following: + * + * - provide an implementation of a growing sequence of objects called + * a `T1_Table' (used to build various tables needed by the loader). + * + * - opening .pfb and .pfa files to extract their top-level and private + * dictionaries. + * + * - read numbers, arrays & strings from any dictionary. + * + * See `t1load.c' to see how data is loaded from the font file. + * + */ #include <ft2build.h> @@ -43,14 +43,14 @@ #include "t1errors.h" - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1parse +#define FT_COMPONENT t1parse /*************************************************************************/ @@ -169,21 +169,21 @@ } } - /******************************************************************/ - /* */ - /* Here a short summary of what is going on: */ - /* */ - /* When creating a new Type 1 parser, we try to locate and load */ - /* the base dictionary if this is possible (i.e., for PFB */ - /* files). Otherwise, we load the whole font into memory. */ - /* */ - /* When `loading' the base dictionary, we only setup pointers */ - /* in the case of a memory-based stream. Otherwise, we */ - /* allocate and load the base dictionary in it. */ - /* */ - /* parser->in_pfb is set if we are in a binary (`.pfb') font. */ - /* parser->in_memory is set if we have a memory stream. */ - /* */ + /******************************************************************* + * + * Here a short summary of what is going on: + * + * When creating a new Type 1 parser, we try to locate and load + * the base dictionary if this is possible (i.e., for PFB + * files). Otherwise, we load the whole font into memory. + * + * When `loading' the base dictionary, we only setup pointers + * in the case of a memory-based stream. Otherwise, we + * allocate and load the base dictionary in it. + * + * parser->in_pfb is set if we are in a binary (`.pfb') font. + * parser->in_memory is set if we have a memory stream. + */ /* try to compute the size of the base dictionary; */ /* look for a Postscript binary file tag, i.e., 0x8001 */ diff --git a/src/3rdparty/freetype/src/type1/t1parse.h b/src/3rdparty/freetype/src/type1/t1parse.h index 4ac82ae913..dab8fddc8b 100644 --- a/src/3rdparty/freetype/src/type1/t1parse.h +++ b/src/3rdparty/freetype/src/type1/t1parse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1parse.h */ -/* */ -/* Type 1 parser (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1parse.h + * + * Type 1 parser (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T1PARSE_H_ @@ -28,36 +28,45 @@ FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_ParserRec */ - /* */ - /* <Description> */ - /* A PS_ParserRec is an object used to parse a Type 1 fonts very */ - /* quickly. */ - /* */ - /* <Fields> */ - /* root :: The root parser. */ - /* */ - /* stream :: The current input stream. */ - /* */ - /* base_dict :: A pointer to the top-level dictionary. */ - /* */ - /* base_len :: The length in bytes of the top dictionary. */ - /* */ - /* private_dict :: A pointer to the private dictionary. */ - /* */ - /* private_len :: The length in bytes of the private dictionary. */ - /* */ - /* in_pfb :: A boolean. Indicates that we are handling a PFB */ - /* file. */ - /* */ - /* in_memory :: A boolean. Indicates a memory-based stream. */ - /* */ - /* single_block :: A boolean. Indicates that the private dictionary */ - /* is stored in lieu of the base dictionary. */ - /* */ + /************************************************************************** + * + * @Struct: + * T1_ParserRec + * + * @Description: + * A PS_ParserRec is an object used to parse a Type 1 fonts very + * quickly. + * + * @Fields: + * root :: + * The root parser. + * + * stream :: + * The current input stream. + * + * base_dict :: + * A pointer to the top-level dictionary. + * + * base_len :: + * The length in bytes of the top dictionary. + * + * private_dict :: + * A pointer to the private dictionary. + * + * private_len :: + * The length in bytes of the private dictionary. + * + * in_pfb :: + * A boolean. Indicates that we are handling a PFB + * file. + * + * in_memory :: + * A boolean. Indicates a memory-based stream. + * + * single_block :: + * A boolean. Indicates that the private dictionary + * is stored in lieu of the base dictionary. + */ typedef struct T1_ParserRec_ { PS_ParserRec root; diff --git a/src/3rdparty/freetype/src/type1/t1tokens.h b/src/3rdparty/freetype/src/type1/t1tokens.h index 43a65d88ea..97f2dbe0cf 100644 --- a/src/3rdparty/freetype/src/type1/t1tokens.h +++ b/src/3rdparty/freetype/src/type1/t1tokens.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t1tokens.h */ -/* */ -/* Type 1 tokenizer (specification). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t1tokens.h + * + * Type 1 tokenizer (specification). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #undef FT_STRUCTURE diff --git a/src/3rdparty/freetype/src/type1/type1.c b/src/3rdparty/freetype/src/type1/type1.c index 72eff59bfe..ce8557a5fb 100644 --- a/src/3rdparty/freetype/src/type1/type1.c +++ b/src/3rdparty/freetype/src/type1/type1.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* type1.c */ -/* */ -/* FreeType Type 1 driver component (body only). */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * type1.c + * + * FreeType Type 1 driver component (body only). + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/type42/Jamfile b/src/3rdparty/freetype/src/type42/Jamfile index b98de05a74..6123b35598 100644 --- a/src/3rdparty/freetype/src/type42/Jamfile +++ b/src/3rdparty/freetype/src/type42/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/type42 Jamfile # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/type42/module.mk b/src/3rdparty/freetype/src/type42/module.mk index 3d4732bb6f..9e9d15455b 100644 --- a/src/3rdparty/freetype/src/type42/module.mk +++ b/src/3rdparty/freetype/src/type42/module.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/type42/rules.mk b/src/3rdparty/freetype/src/type42/rules.mk index 9325d3898f..9d71f5300e 100644 --- a/src/3rdparty/freetype/src/type42/rules.mk +++ b/src/3rdparty/freetype/src/type42/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 2002-2018 by +# Copyright (C) 2002-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/type42/t42drivr.c b/src/3rdparty/freetype/src/type42/t42drivr.c index f579b2708c..09ad632e97 100644 --- a/src/3rdparty/freetype/src/type42/t42drivr.c +++ b/src/3rdparty/freetype/src/type42/t42drivr.c @@ -1,39 +1,39 @@ -/***************************************************************************/ -/* */ -/* t42drivr.c */ -/* */ -/* High-level Type 42 driver interface (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This driver implements Type42 fonts as described in the */ - /* Technical Note #5012 from Adobe, with these limitations: */ - /* */ - /* 1) CID Fonts are not currently supported. */ - /* 2) Incremental fonts making use of the GlyphDirectory keyword */ - /* will be loaded, but the rendering will be using the TrueType */ - /* tables. */ - /* 3) As for Type1 fonts, CDevProc is not supported. */ - /* 4) The Metrics dictionary is not supported. */ - /* 5) AFM metrics are not supported. */ - /* */ - /* In other words, this driver supports Type42 fonts derived from */ - /* TrueType fonts in a non-CID manner, as done by usual conversion */ - /* programs. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t42drivr.c + * + * High-level Type 42 driver interface (body). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This driver implements Type42 fonts as described in the + * Technical Note #5012 from Adobe, with these limitations: + * + * 1) CID Fonts are not currently supported. + * 2) Incremental fonts making use of the GlyphDirectory keyword + * will be loaded, but the rendering will be using the TrueType + * tables. + * 3) As for Type1 fonts, CDevProc is not supported. + * 4) The Metrics dictionary is not supported. + * 5) AFM metrics are not supported. + * + * In other words, this driver supports Type42 fonts derived from + * TrueType fonts in a non-CID manner, as done by usual conversion + * programs. + * + */ #include "t42drivr.h" @@ -47,12 +47,12 @@ #include FT_SERVICE_POSTSCRIPT_INFO_H #undef FT_COMPONENT -#define FT_COMPONENT trace_t42 +#define FT_COMPONENT t42 /* * - * GLYPH DICT SERVICE + * GLYPH DICT SERVICE * */ @@ -69,8 +69,8 @@ static FT_UInt - t42_get_name_index( T42_Face face, - FT_String* glyph_name ) + t42_get_name_index( T42_Face face, + const FT_String* glyph_name ) { FT_Int i; @@ -98,7 +98,7 @@ /* * - * POSTSCRIPT NAME SERVICE + * POSTSCRIPT NAME SERVICE * */ @@ -117,7 +117,7 @@ /* * - * POSTSCRIPT INFO SERVICE + * POSTSCRIPT INFO SERVICE * */ @@ -173,7 +173,7 @@ /* * - * SERVICE LIST + * SERVICE LIST * */ diff --git a/src/3rdparty/freetype/src/type42/t42drivr.h b/src/3rdparty/freetype/src/type42/t42drivr.h index 3667f3e066..a35ca28f84 100644 --- a/src/3rdparty/freetype/src/type42/t42drivr.h +++ b/src/3rdparty/freetype/src/type42/t42drivr.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t42drivr.h */ -/* */ -/* High-level Type 42 driver interface (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t42drivr.h + * + * High-level Type 42 driver interface (specification). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T42DRIVR_H_ @@ -26,14 +26,8 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif - - FT_EXPORT_VAR( const FT_Driver_ClassRec ) t42_driver_class; - FT_END_HEADER diff --git a/src/3rdparty/freetype/src/type42/t42error.h b/src/3rdparty/freetype/src/type42/t42error.h index e3978a7607..5fb2143949 100644 --- a/src/3rdparty/freetype/src/type42/t42error.h +++ b/src/3rdparty/freetype/src/type42/t42error.h @@ -1,26 +1,26 @@ -/***************************************************************************/ -/* */ -/* t42error.h */ -/* */ -/* Type 42 error codes (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the Type 42 error enumeration constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * t42error.h + * + * Type 42 error codes (specification only). + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the Type 42 error enumeration constants. + * + */ #ifndef T42ERROR_H_ #define T42ERROR_H_ diff --git a/src/3rdparty/freetype/src/type42/t42objs.c b/src/3rdparty/freetype/src/type42/t42objs.c index 66e5c40382..d31bace451 100644 --- a/src/3rdparty/freetype/src/type42/t42objs.c +++ b/src/3rdparty/freetype/src/type42/t42objs.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t42objs.c */ -/* */ -/* Type 42 objects manager (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t42objs.c + * + * Type 42 objects manager (body). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "t42objs.h" @@ -25,7 +25,7 @@ #undef FT_COMPONENT -#define FT_COMPONENT trace_t42 +#define FT_COMPONENT t42 static FT_Error @@ -98,8 +98,7 @@ /* we must now build type1.encoding when we have a custom array */ if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY ) { - FT_Int charcode, idx, min_char, max_char; - FT_Byte* glyph_name; + FT_Int charcode, idx, min_char, max_char; /* OK, we do the following: for each element in the encoding */ @@ -114,27 +113,27 @@ charcode = 0; for ( ; charcode < loader.encoding_table.max_elems; charcode++ ) { - FT_Byte* char_name; + const FT_String* char_name = + (const FT_String*)loader.encoding_table.elements[charcode]; type1->encoding.char_index[charcode] = 0; - type1->encoding.char_name [charcode] = (char *)".notdef"; + type1->encoding.char_name [charcode] = ".notdef"; - char_name = loader.encoding_table.elements[charcode]; if ( char_name ) for ( idx = 0; idx < type1->num_glyphs; idx++ ) { - glyph_name = (FT_Byte*)type1->glyph_names[idx]; - if ( ft_strcmp( (const char*)char_name, - (const char*)glyph_name ) == 0 ) + const FT_String* glyph_name = type1->glyph_names[idx]; + + + if ( ft_strcmp( char_name, glyph_name ) == 0 ) { type1->encoding.char_index[charcode] = (FT_UShort)idx; - type1->encoding.char_name [charcode] = (char*)glyph_name; + type1->encoding.char_name [charcode] = glyph_name; /* Change min/max encoded char only if glyph name is */ /* not /.notdef */ - if ( ft_strcmp( (const char*)".notdef", - (const char*)glyph_name ) != 0 ) + if ( ft_strcmp( ".notdef", glyph_name ) != 0 ) { if ( charcode < min_char ) min_char = charcode; @@ -354,7 +353,8 @@ error = FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); if ( error && - FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) && + FT_ERR_NEQ( error, Unimplemented_Feature ) ) goto Exit; error = FT_Err_Ok; @@ -457,20 +457,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* T42_Driver_Init */ - /* */ - /* <Description> */ - /* Initializes a given Type 42 driver object. */ - /* */ - /* <Input> */ - /* driver :: A handle to the target driver object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ + /************************************************************************** + * + * @Function: + * T42_Driver_Init + * + * @Description: + * Initializes a given Type 42 driver object. + * + * @Input: + * driver :: + * A handle to the target driver object. + * + * @Return: + * FreeType error code. 0 means success. + */ FT_LOCAL_DEF( FT_Error ) T42_Driver_Init( FT_Module module ) /* T42_Driver */ { diff --git a/src/3rdparty/freetype/src/type42/t42objs.h b/src/3rdparty/freetype/src/type42/t42objs.h index 3bad5135e0..98300cf348 100644 --- a/src/3rdparty/freetype/src/type42/t42objs.h +++ b/src/3rdparty/freetype/src/type42/t42objs.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t42objs.h */ -/* */ -/* Type 42 objects manager (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t42objs.h + * + * Type 42 objects manager (specification). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T42OBJS_H_ diff --git a/src/3rdparty/freetype/src/type42/t42parse.c b/src/3rdparty/freetype/src/type42/t42parse.c index 4813d1f3f9..c47a77786d 100644 --- a/src/3rdparty/freetype/src/type42/t42parse.c +++ b/src/3rdparty/freetype/src/type42/t42parse.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t42parse.c */ -/* */ -/* Type 42 font parser (body). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t42parse.c + * + * Type 42 font parser (body). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include "t42parse.h" @@ -23,14 +23,14 @@ #include FT_INTERNAL_POSTSCRIPT_AUX_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t42 +#define FT_COMPONENT t42 static void @@ -149,19 +149,19 @@ parser->base_dict = NULL; parser->in_memory = 0; - /*******************************************************************/ - /* */ - /* Here a short summary of what is going on: */ - /* */ - /* When creating a new Type 42 parser, we try to locate and load */ - /* the base dictionary, loading the whole font into memory. */ - /* */ - /* When `loading' the base dictionary, we only set up pointers */ - /* in the case of a memory-based stream. Otherwise, we allocate */ - /* and load the base dictionary in it. */ - /* */ - /* parser->in_memory is set if we have a memory stream. */ - /* */ + /******************************************************************** + * + * Here a short summary of what is going on: + * + * When creating a new Type 42 parser, we try to locate and load + * the base dictionary, loading the whole font into memory. + * + * When `loading' the base dictionary, we only set up pointers + * in the case of a memory-based stream. Otherwise, we allocate + * and load the base dictionary in it. + * + * parser->in_memory is set if we have a memory stream. + */ if ( FT_STREAM_SEEK( 0L ) || FT_FRAME_ENTER( 17 ) ) @@ -226,7 +226,8 @@ if ( !parser->in_memory ) FT_FREE( parser->base_dict ); - parser->root.funcs.done( &parser->root ); + if ( parser->root.funcs.done ) + parser->root.funcs.done( &parser->root ); } @@ -284,6 +285,13 @@ matrix->xy = temp[2]; matrix->yy = temp[3]; + if ( !FT_Matrix_Check( matrix ) ) + { + FT_ERROR(( "t42_parse_font_matrix: invalid font matrix\n" )); + parser->root.error = FT_THROW( Invalid_File_Format ); + return; + } + /* note that the offsets must be expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; @@ -366,12 +374,7 @@ /* We need to `zero' out encoding_table.elements */ for ( n = 0; n < count; n++ ) - { - char* notdef = (char *)".notdef"; - - - (void)T1_Add_Table( char_table, n, notdef, 8 ); - } + (void)T1_Add_Table( char_table, n, ".notdef", 8 ); /* Now we need to read records of the form */ /* */ @@ -588,6 +591,14 @@ else if ( *cur == '<' ) { + if ( string_buf && !allocated ) + { + FT_ERROR(( "t42_parse_sfnts: " + "can't handle mixed binary and hex strings\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + T1_Skip_PS_Token( parser ); if ( parser->root.error ) goto Exit; @@ -1006,8 +1017,7 @@ } /* if /.notdef does not occupy index 0, do our magic. */ - if ( ft_strcmp( (const char*)".notdef", - (const char*)name_table->elements[0] ) ) + if ( ft_strcmp( ".notdef", (const char*)name_table->elements[0] ) ) { /* Swap glyph in index 0 with /.notdef glyph. First, add index 0 */ /* name and code entries to swap_table. Then place notdef_index */ diff --git a/src/3rdparty/freetype/src/type42/t42parse.h b/src/3rdparty/freetype/src/type42/t42parse.h index f35d23de63..0c7bb48496 100644 --- a/src/3rdparty/freetype/src/type42/t42parse.h +++ b/src/3rdparty/freetype/src/type42/t42parse.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t42parse.h */ -/* */ -/* Type 42 font parser (specification). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t42parse.h + * + * Type 42 font parser (specification). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T42PARSE_H_ diff --git a/src/3rdparty/freetype/src/type42/t42types.h b/src/3rdparty/freetype/src/type42/t42types.h index d0aa2de570..a258144ec3 100644 --- a/src/3rdparty/freetype/src/type42/t42types.h +++ b/src/3rdparty/freetype/src/type42/t42types.h @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* t42types.h */ -/* */ -/* Type 42 font data types (specification only). */ -/* */ -/* Copyright 2002-2018 by */ -/* Roberto Alameda. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * t42types.h + * + * Type 42 font data types (specification only). + * + * Copyright (C) 2002-2019 by + * Roberto Alameda. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef T42TYPES_H_ diff --git a/src/3rdparty/freetype/src/type42/type42.c b/src/3rdparty/freetype/src/type42/type42.c index 6a89cfbed1..0cb7b77eec 100644 --- a/src/3rdparty/freetype/src/type42/type42.c +++ b/src/3rdparty/freetype/src/type42/type42.c @@ -1,19 +1,19 @@ -/***************************************************************************/ -/* */ -/* type42.c */ -/* */ -/* FreeType Type 42 driver component. */ -/* */ -/* Copyright 2002-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * type42.c + * + * FreeType Type 42 driver component. + * + * Copyright (C) 2002-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #define FT_MAKE_OPTION_SINGLE_OBJECT diff --git a/src/3rdparty/freetype/src/winfonts/Jamfile b/src/3rdparty/freetype/src/winfonts/Jamfile index 4385e3b39f..4b92226159 100644 --- a/src/3rdparty/freetype/src/winfonts/Jamfile +++ b/src/3rdparty/freetype/src/winfonts/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/winfonts Jamfile # -# Copyright 2001-2018 by +# Copyright (C) 2001-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/winfonts/fnterrs.h b/src/3rdparty/freetype/src/winfonts/fnterrs.h index 3a86af5aac..af29307c75 100644 --- a/src/3rdparty/freetype/src/winfonts/fnterrs.h +++ b/src/3rdparty/freetype/src/winfonts/fnterrs.h @@ -1,27 +1,27 @@ -/***************************************************************************/ -/* */ -/* fnterrs.h */ -/* */ -/* Win FNT/FON error codes (specification only). */ -/* */ -/* Copyright 2001-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the Windows FNT/FON error enumeration */ - /* constants. */ - /* */ - /*************************************************************************/ +/**************************************************************************** + * + * fnterrs.h + * + * Win FNT/FON error codes (specification only). + * + * Copyright (C) 2001-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ + + + /************************************************************************** + * + * This file is used to define the Windows FNT/FON error enumeration + * constants. + * + */ #ifndef FNTERRS_H_ #define FNTERRS_H_ diff --git a/src/3rdparty/freetype/src/winfonts/module.mk b/src/3rdparty/freetype/src/winfonts/module.mk index 13f9077cfc..82fb0151f8 100644 --- a/src/3rdparty/freetype/src/winfonts/module.mk +++ b/src/3rdparty/freetype/src/winfonts/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/winfonts/rules.mk b/src/3rdparty/freetype/src/winfonts/rules.mk index d694d1a771..998d49bc9f 100644 --- a/src/3rdparty/freetype/src/winfonts/rules.mk +++ b/src/3rdparty/freetype/src/winfonts/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2018 by +# Copyright (C) 1996-2019 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/src/3rdparty/freetype/src/winfonts/winfnt.c b/src/3rdparty/freetype/src/winfonts/winfnt.c index 36bd3148d5..2d771be2cc 100644 --- a/src/3rdparty/freetype/src/winfonts/winfnt.c +++ b/src/3rdparty/freetype/src/winfonts/winfnt.c @@ -1,21 +1,21 @@ -/***************************************************************************/ -/* */ -/* winfnt.c */ -/* */ -/* FreeType font driver for Windows FNT/FON files */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* Copyright 2003 Huw D M Davies for Codeweavers */ -/* Copyright 2007 Dmitry Timoshkov for Codeweavers */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * winfnt.c + * + * FreeType font driver for Windows FNT/FON files + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * Copyright 2003 Huw D M Davies for Codeweavers + * Copyright 2007 Dmitry Timoshkov for Codeweavers + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> @@ -30,14 +30,14 @@ #include FT_SERVICE_WINFNT_H #include FT_SERVICE_FONT_FORMAT_H - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT -#define FT_COMPONENT trace_winfnt +#define FT_COMPONENT winfnt static const FT_Frame_Field winmz_header_fields[] = @@ -1131,10 +1131,10 @@ winfnt_get_header /* get_header */ }; - /* - * SERVICE LIST - * - */ + /* + * SERVICE LIST + * + */ static const FT_ServiceDescRec winfnt_services[] = { diff --git a/src/3rdparty/freetype/src/winfonts/winfnt.h b/src/3rdparty/freetype/src/winfonts/winfnt.h index 4885c9d745..b628ad4c42 100644 --- a/src/3rdparty/freetype/src/winfonts/winfnt.h +++ b/src/3rdparty/freetype/src/winfonts/winfnt.h @@ -1,20 +1,20 @@ -/***************************************************************************/ -/* */ -/* winfnt.h */ -/* */ -/* FreeType font driver for Windows FNT/FON files */ -/* */ -/* Copyright 1996-2018 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* Copyright 2007 Dmitry Timoshkov for Codeweavers */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * winfnt.h + * + * FreeType font driver for Windows FNT/FON files + * + * Copyright (C) 1996-2019 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * Copyright 2007 Dmitry Timoshkov for Codeweavers + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #ifndef WINFNT_H_ @@ -28,9 +28,6 @@ FT_BEGIN_HEADER -#ifdef FT_CONFIG_OPTION_PIC -#error "this module does not support PIC yet" -#endif typedef struct WinMZ_HeaderRec_ { @@ -153,9 +150,6 @@ FT_BEGIN_HEADER FT_FaceRec root; FNT_Font font; - FT_CharMap charmap_handle; - FT_CharMapRec charmap; /* a single charmap per face */ - } FNT_FaceRec, *FNT_Face; -- cgit v1.2.3 From 949fc2860e6472e105faff5dea9780cc467c9950 Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Tue, 15 Oct 2019 15:58:39 +0200 Subject: Doc: Add best-practices-info about initialization and clean-up From https://wiki.qt.io/Writing_Unit_Tests Change-Id: I20027066640ca797a2330f6daa81468f03921a69 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/testlib/doc/src/qttestlib-manual.qdoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index ee7767b5a5..a72ba1db91 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -102,6 +102,20 @@ \li \c{cleanup()} will be called after every test function. \endlist + Use \c initTestCase() for preparing the test. Every test should leave the + system in a usable state, so it can be run repeatedly. Cleanup operations + should be handled in \c cleanupTestCase(), so they get run even if the test + fails. + + Use \c init() for preparing a test function. Every test function should + leave the system in a usable state, so it can be run repeatedly. Cleanup + operations should be handled in \c cleanup(), so they get run even if the + test function fails and exits early. + + Alternatively, you can use RAII (resource acquisition is initialization), + with cleanup operations called in destructors, to ensure they happen when + the test function returns and the object moves out of scope. + If \c{initTestCase()} fails, no test function will be executed. If \c{init()} fails, the following test function will not be executed, the test will proceed to the next test function. -- cgit v1.2.3 From faff69968bea8ffefe843ef9b8016cf70766d10d Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Tue, 15 Oct 2019 16:16:46 +0200 Subject: Doc: Add best-practices-info about creating benchmarks From https://wiki.qt.io/Writing_Unit_Tests Change-Id: Idc0bafb32690f443e1f49cd4f8efb653d3aa46a4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/testlib/doc/src/qttestlib-manual.qdoc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index a72ba1db91..a55671522b 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -317,10 +317,35 @@ \section1 Creating a Benchmark To create a benchmark, follow the instructions for creating a test and then add a - QBENCHMARK macro to the test function that you want to benchmark. + \l QBENCHMARK macro or \l QTest::setBenchmarkResult() to the test function that + you want to benchmark. In the following code snippet, the macro is used: \snippet code/doc_src_qtestlib.cpp 12 + A test function that measures performance should contain either a single + \c QBENCHMARK macro or a single call to \c setBenchmarkResult(). Multiple + occurrences make no sense, because only one performance result can be + reported per test function, or per data tag in a data-driven setup. + + Avoid changing the test code that forms (or influences) the body of a + \c QBENCHMARK macro, or the test code that computes the value passed to + \c setBenchmarkResult(). Differences in successive performance results + should ideally be caused only by changes to the product you are testing. + Changes to the test code can potentially result in misleading report of + a change in performance. If you do need to change the test code, make + that clear in the commit message. + + In a performance test function, the \c QBENCHMARK or \c setBenchmarkResult() + should be followed by a verification step using \l QCOMPARE(), \l QVERIFY(), + and so on. You can then flag a performance result as \e invalid if another + code path than the intended one was measured. A performance analysis tool + can use this information to filter out invalid results. + For example, an unexpected error condition will typically cause the program + to bail out prematurely from the normal program execution, and thus falsely + show a dramatic performance increase. + + \section2 Selecting the Measurement Back-end + The code inside the QBENCHMARK macro will be measured, and possibly also repeated several times in order to get an accurate measurement. This depends on the selected measurement back-end. Several back-ends are available. They can be selected on the -- cgit v1.2.3 From f54e97726f36c56d9f51f2243493c55ab8cf7bef Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Wed, 30 Oct 2019 10:50:41 +0100 Subject: Doc: Add notes about Qt Style Sheets taking precedence ...over setting properties on individual widgets. Task-number: QTBUG-28675 Change-Id: Ic7bfd723ed8970112a9892727170d3bacaa1903f Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> --- src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 7 ++++++- src/widgets/itemviews/qtreewidget.cpp | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 00323eace6..12e27a71ad 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -59,6 +59,11 @@ \li \l{Qt Style Sheets Examples} \endlist + \note If Qt Style Sheets are used on the same widget as functions that + set the appearance of widgets, such as \l QWidget::setFont() or + \l QTreeWidgetItem::setBackground(), style sheets will take precedence + if the settings conflict. + \target overview \section1 Overview diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index be7ddd8b30..6da5ca0f4c 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1284,6 +1284,9 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const Sets the background brush of the label in the given \a column to the specified \a brush. + \note If \l{Qt Style Sheets} are used on the same widget as setBackground(), + style sheets will take precedence if the settings conflict. + \sa setForeground() */ -- cgit v1.2.3 From a62a6b9b173dadb24bbf6b98e493910c8ddc410e Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Fri, 18 Oct 2019 16:18:07 +0200 Subject: Doc: Update info about QSKIP() Add a section about using QEXPECT_FAIL() to skip known bugs. Change-Id: Icf258b6e20add3b68d62e404fd9ac0db70420bf2 From: https://wiki.qt.io/Writing_Unit_Tests Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/testlib/qtestcase.qdoc | 59 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc index 9006d7b401..824f3574b3 100644 --- a/src/testlib/qtestcase.qdoc +++ b/src/testlib/qtestcase.qdoc @@ -317,26 +317,55 @@ If called from a test function, the QSKIP() macro stops execution of the test without adding a failure to the test log. You can use it to skip tests that - wouldn't make sense in the current configuration. The text \a description is - appended to the test log and should contain an explanation of why the test - couldn't be executed. + wouldn't make sense in the current configuration. For example, a test of font + rendering may call QSKIP() if the needed fonts are not installed on the test + system. + + The text \a description is appended to the test log and should contain an + explanation of why the test couldn't be executed. + + If the test is data-driven, each call to QSKIP() in the test function will + skip only the current row of test data, so an unconditional call to QSKIP() + will produce one skip message in the test log for each row of test data. + + If called from an \c _data function, the QSKIP() macro will stop execution of + the \c _data function and will prevent execution of the associated test + function. This entirely omits a data-driven test. To omit individual rows, + make them conditional by using a simple \c{if (condition) newRow(...) << ...} + in the \c _data function, instead of using QSKIP() in the test function. + + If called from \c initTestCase_data(), the QSKIP() macro will skip all test + and \c _data functions. If called from \c initTestCase() when there is no + \c initTestCase_data(), or when it only sets up one row, QSKIP() will + likewise skip the whole test. However, if \c initTestCase_data() contains + more than one row, then \c initTestCase() is called (followed by each test + and finally the wrap-up) once per row of it. Therefore, a call to QSKIP() in + \c initTestCase() will merely skip all test functions for the current row of + global data, set up by \c initTestCase_data(). + + \note This macro can only be used in a test function or \c _data + function that is invoked by the test framework. - If the test is data-driven, each call to QSKIP() will skip only the current - row of test data, so an unconditional call to QSKIP will produce one skip - message in the test log for each row of test data. + Example: + \snippet code/src_qtestlib_qtestcase.cpp 8 - If called from an _data function, the QSKIP() macro will stop execution of - the _data function and will prevent execution of the associated test - function. + \section2 Skipping Known Bugs - If called from initTestCase() or initTestCase_data(), the QSKIP() macro will - skip all test and _data functions. + If a test exposes a known bug that will not be fixed immediately, use the + QEXPECT_FAIL() macro to document the failure and reference the bug tracking + identifier for the known issue. When the test is run, expected failures will + be marked as XFAIL in the test output and will not be counted as failures + when setting the test program's return code. If an expected failure does + not occur, the XPASS (unexpected pass) will be reported in the test output + and will be counted as a test failure. - \b {Note:} This macro can only be used in a test function or _data - function that is invoked by the test framework. + For known bugs, QEXPECT_FAIL() is better than QSKIP() because a developer + cannot fix the bug without an XPASS result reminding them that the test + needs to be updated too. If QSKIP() is used, there is no reminder to revise + or re-enable the test, without which subsequent regressions will not be + reported. - Example: - \snippet code/src_qtestlib_qtestcase.cpp 8 + \sa QEXPECT_FAIL(), {Select Appropriate Mechanisms to Exclude Tests} */ /*! \macro QEXPECT_FAIL(dataIndex, comment, mode) -- cgit v1.2.3 From 26f9cb7ce5a81eac9743d0dd183f59ceb7e73569 Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Thu, 17 Oct 2019 08:43:49 +1000 Subject: wasm: take canvas offset into account MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes issue with dialogs when the canvas is not at 0,0 in the browser window Change-Id: I14f6754746e064921635d6b3af3353bf3620ac44 Fixes: QTBUG-79160 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/wasm/qwasmscreen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index e536bc0ee3..37f1ea832a 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -186,8 +186,12 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize() canvas.set("width", canvasSize.width()); canvas.set("height", canvasSize.height()); + QPoint offset; + offset.setX(emscripten::val::global(canvasId.constData())["offsetTop"].as<int>()); + offset.setY(emscripten::val::global(canvasId.constData())["offsetLeft"].as<int>()); + emscripten::val rect = canvas.call<emscripten::val>("getBoundingClientRect"); - QPoint position(rect["left"].as<int>(), rect["top"].as<int>()); + QPoint position(rect["left"].as<int>() - offset.x(), rect["top"].as<int>() - offset.y()); setGeometry(QRect(position, cssSize.toSize())); m_compositor->redrawWindowContent(); -- cgit v1.2.3 From 2d680b27f3c56aacbec3191f38b7b1898c8747b1 Mon Sep 17 00:00:00 2001 From: Kari Oikarinen <kari.oikarinen@qt.io> Date: Mon, 7 Oct 2019 12:15:09 +0300 Subject: Clarify Q{Abstract,Local}Socket::waitForDisconnected() documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it clear that the functions will return false if the socket was already disconnected. Fix the QLocalSocket example snippet to handle that case correctly by checking state() before attempting to wait. Fixes: QTBUG-50711 Change-Id: I4ab4062446a0041a35a3a1d65a19202ffa103298 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- .../doc/snippets/code/src_network_socket_qabstractsocket.cpp | 5 +++-- .../snippets/code/src_network_socket_qlocalsocket_unix.cpp | 4 +++- src/network/socket/qabstractsocket.cpp | 11 ++++++----- src/network/socket/qlocalsocket.cpp | 11 ++++++----- 4 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/network/doc/snippets/code/src_network_socket_qabstractsocket.cpp b/src/network/doc/snippets/code/src_network_socket_qabstractsocket.cpp index 3db16b50e6..e19cb40666 100644 --- a/src/network/doc/snippets/code/src_network_socket_qabstractsocket.cpp +++ b/src/network/doc/snippets/code/src_network_socket_qabstractsocket.cpp @@ -57,9 +57,10 @@ if (socket->waitForConnected(1000)) //! [1] socket->disconnectFromHost(); - if (socket->state() == QAbstractSocket::UnconnectedState || - socket->waitForDisconnected(1000)) +if (socket->state() == QAbstractSocket::UnconnectedState + || socket->waitForDisconnected(1000)) { qDebug("Disconnected!"); +} //! [1] diff --git a/src/network/doc/snippets/code/src_network_socket_qlocalsocket_unix.cpp b/src/network/doc/snippets/code/src_network_socket_qlocalsocket_unix.cpp index 181f9c1686..deafca831d 100644 --- a/src/network/doc/snippets/code/src_network_socket_qlocalsocket_unix.cpp +++ b/src/network/doc/snippets/code/src_network_socket_qlocalsocket_unix.cpp @@ -57,6 +57,8 @@ if (socket->waitForConnected(1000)) //! [1] socket->disconnectFromServer(); -if (socket->waitForDisconnected(1000)) +if (socket->state() == QLocalSocket::UnconnectedState + || socket->waitForDisconnected(1000)) { qDebug("Disconnected!"); +} //! [1] diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 9c8f29e18a..b1ea9a4133 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -2359,11 +2359,12 @@ bool QAbstractSocket::waitForBytesWritten(int msecs) } /*! - Waits until the socket has disconnected, up to \a msecs - milliseconds. If the connection has been disconnected, this - function returns \c true; otherwise it returns \c false. In the case - where it returns \c false, you can call error() to determine - the cause of the error. + Waits until the socket has disconnected, up to \a msecs milliseconds. If the + connection was successfully disconnected, this function returns \c true; + otherwise it returns \c false (if the operation timed out, if an error + occurred, or if this QAbstractSocket is already disconnected). In the case + where it returns \c false, you can call error() to determine the cause of + the error. The following example waits up to one second for a connection to be closed: diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index 1c34cd13ee..af7cdb76d2 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -287,11 +287,12 @@ QT_BEGIN_NAMESPACE /*! \fn bool QLocalSocket::waitForDisconnected(int msecs) - Waits until the socket has disconnected, up to \a msecs - milliseconds. If the connection has been disconnected, this - function returns \c true; otherwise it returns \c false. In the case - where it returns \c false, you can call error() to determine - the cause of the error. + Waits until the socket has disconnected, up to \a msecs milliseconds. If the + connection was successfully disconnected, this function returns \c true; + otherwise it returns \c false (if the operation timed out, if an error + occurred, or if this QLocalSocket is already disconnected). In the case + where it returns \c false, you can call error() to determine the cause of + the error. The following example waits up to one second for a connection to be closed: -- cgit v1.2.3 From efaa4aa2a1452cf73bc3117c49d1345a4106fd57 Mon Sep 17 00:00:00 2001 From: Adam Sowa <adam.sowa@strixcode.com> Date: Thu, 31 Oct 2019 08:52:26 +0100 Subject: QFile::decodeName(const char *): don't construct QByteArray but use the argument directly Use QString::fromLocal8Bit(const QByteArray &str) instead of constructing QByteArray to avoid memory allocation and strcpy. Change-Id: I32bbb47fbc45681c621adaebe8f8574d8f8ad6bf Fixes: QTBUG-79644 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/io/qfile.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h index cf1465ec70..2099b2852f 100644 --- a/src/corelib/io/qfile.h +++ b/src/corelib/io/qfile.h @@ -84,6 +84,10 @@ public: // note: duplicated in qglobal.cpp (qEnvironmentVariable) return QString::fromUtf8(localFileName).normalized(QString::NormalizationForm_C); } + static inline QString decodeName(const char *localFileName) + { + return QString::fromUtf8(localFileName).normalized(QString::NormalizationForm_C); + } #else static inline QByteArray encodeName(const QString &fileName) { @@ -93,9 +97,11 @@ public: { return QString::fromLocal8Bit(localFileName); } + static inline QString decodeName(const char *localFileName) + { + return QString::fromLocal8Bit(localFileName); + } #endif - inline static QString decodeName(const char *localFileName) - { return decodeName(QByteArray(localFileName)); } #if QT_DEPRECATED_SINCE(5,0) typedef QByteArray (*EncoderFn)(const QString &fileName); -- cgit v1.2.3 From 4f45dc762d73b5f8ac112d109fa3fa48dd99ee47 Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Tue, 15 Oct 2019 17:06:52 +0200 Subject: Doc: Add best-practice-info for using QVERIFY() and QCOMPARE() From https://wiki.qt.io/Writing_Unit_Tests Task-number: QTBUG-63987 Change-Id: I7229ac0712d1207c0c9ebdac868c33bb35dcb0f0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- .../doc/snippets/code/src_qtestlib_qtestcase.cpp | 29 +++++- src/testlib/qtestcase.qdoc | 108 ++++++++++++++++----- 2 files changed, 109 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp index 5f71828595..2dc4fe49ef 100644 --- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp +++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp @@ -53,12 +53,12 @@ void wrapInFunction() { //! [0] -QVERIFY(1 + 1 == 2); + QVERIFY(spy.isValid()) //! [0] //! [1] -QVERIFY2(1 + 1 == 2, "A breach in basic arithmetic occurred."); +QVERIFY2(qIsNaN(0.0 / 0.0), "Ill-defined division produced unambiguous result."); //! [1] @@ -324,3 +324,28 @@ void TestQLocale::roundTripInt() QVERIFY(ok); } //! [31] + + +//! [32] +bool opened = file.open(QIODevice::WriteOnly); +QVERIFY(opened); +//! [32] + + +//! [33] +QVERIFY2(file.open(QIODevice::WriteOnly), + qPrintable(QString("open %1: %2").arg(file.fileName()).arg(file.errorString())); +//! [33] + +//! [34] +QT_BEGIN_NAMESPACE +namespace QTest { + template <> char *toString<MyType>(const MyType &t) + { + char *repr = new char[t.reprSize()]; + t.writeRepr(repr); + return repr; + } +} +QT_END_NAMESPACE +//! [34] diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc index 824f3574b3..5088a812f3 100644 --- a/src/testlib/qtestcase.qdoc +++ b/src/testlib/qtestcase.qdoc @@ -43,55 +43,106 @@ true, execution continues. If not, a failure is recorded in the test log and the test won't be executed further. - \b {Note:} This macro can only be used in a test function that is invoked + You can use \l QVERIFY2() when it is practical and valuable to put additional + information into the test failure report. + + \note This macro can only be used in a test function that is invoked by the test framework. - Example: + For example, the following code shows this macro being used to verify that a + \l QSignalSpy object is valid: + \snippet code/src_qtestlib_qtestcase.cpp 0 - \sa QCOMPARE(), QTRY_VERIFY() + For more information about the failure, use \c QCOMPARE(x, y) instead of + \c QVERIFY(x == y), because it reports both the expected and actual value + when the comparison fails. + + \sa QCOMPARE(), QTRY_VERIFY(), QSignalSpy, QEXPECT_FAIL() */ /*! \macro QVERIFY2(condition, message) \relates QTest - The QVERIFY2() macro behaves exactly like QVERIFY(), except that it outputs - a verbose \a message when \a condition is false. The \a message is a plain - C string. + The QVERIFY2() macro behaves exactly like QVERIFY(), except that it reports + a \a message when \a condition is false. The \a message is a plain C string. + + The message can also be obtained from a function call that produces a plain + C string, such as qPrintable() applied to a QString, which may be built in + any of its usual ways, including applying \c {.args()} to format some data. Example: \snippet code/src_qtestlib_qtestcase.cpp 1 - \sa QVERIFY(), QCOMPARE() + For example, if you have a file object and you are testing its \c open() + function, you might write a test with a statement like: + + \snippet code/src_qtestlib_qtestcase.cpp 32 + + If this test fails, it will give no clue as to why the file failed to open: + + \c {FAIL! : tst_QFile::open_write() 'opened' returned FALSE. ()} + + If there is a more informative error message you could construct from the + values being tested, you can use \c QVERIFY2() to pass that message along + with your test condition, to provide a more informative message on failure: + + \snippet code/src_qtestlib_qtestcase.cpp 33 + + If this branch is being tested in the Qt CI system, the above detailed + failure message will be inserted into the summary posted to the code-review + system: + + \c {FAIL! : tst_QFile::open_write() 'opened' returned FALSE. + (open /tmp/qt.a3B42Cd: No space left on device)} + + \sa QVERIFY(), QCOMPARE(), QEXPECT_FAIL() */ /*! \macro QCOMPARE(actual, expected) \relates QTest - The QCOMPARE macro compares an \a actual value to an \a expected value using - the equals operator. If \a actual and \a expected are identical, execution + The QCOMPARE() macro compares an \a actual value to an \a expected value + using the equality operator. If \a actual and \a expected match, execution continues. If not, a failure is recorded in the test log and the test - won't be executed further. - - In the case of comparing floats and doubles, qFuzzyCompare() is used for - comparing. This means that comparing to 0 will likely fail. One solution - to this is to compare to 1, and add 1 to the produced output. - - QCOMPARE tries to output the contents of the values if the comparison fails, + function returns without attempting any later checks. + + Always respect QCOMPARE() parameter semantics. The first parameter passed to it + should always be the actual value produced by the code-under-test, while the + second parameter should always be the expected value. When the values don't + match, QCOMPARE() prints them with the labels \e Actual and \e Expected. + If the parameter order is swapped, debugging a failing test can be confusing. + + When comparing floating-point types (\c float, \c double, and \c qfloat16), + \l qFuzzyCompare() is used for finite values. Infinities match if they have + the same sign, and any NaN as actual value matches with any NaN as expected + value (even though NaN != NaN, even when they're identical). This means that + expecting 0 can fail when the actual value may be affected by rounding errors. + One solution to this is to offset both actual and expected values by adding + some suitable constant (such as 1). + + QCOMPARE() tries to output the contents of the values if the comparison fails, so it is visible from the test log why the comparison failed. - For your own classes, you can use \l QTest::toString() to format values for - outputting into the test log. + Example: + \snippet code/src_qtestlib_qtestcase.cpp 2 \note This macro can only be used in a test function that is invoked by the test framework. + For your own classes, you can use \l QTest::toString() to format values for + outputting into the test log. + Example: - \snippet code/src_qtestlib_qtestcase.cpp 2 + \snippet code/src_qtestlib_qtestcase.cpp 34 + + The return from \c toString() must be a \c {new char []}. That is, it shall + be released with \c delete[] (rather than \c free() or plain \c delete) once + the calling code is done with it. - \sa QVERIFY(), QTRY_COMPARE(), QTest::toString() + \sa QVERIFY(), QTRY_COMPARE(), QTest::toString(), QEXPECT_FAIL() */ /*! \macro QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) @@ -127,7 +178,8 @@ \note This macro can only be used in a test function that is invoked by the test framework. - \sa QTRY_VERIFY(), QTRY_VERIFY2_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE() + \sa QTRY_VERIFY(), QTRY_VERIFY2_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), + QEXPECT_FAIL() */ @@ -141,7 +193,8 @@ \note This macro can only be used in a test function that is invoked by the test framework. - \sa QTRY_VERIFY_WITH_TIMEOUT(), QTRY_VERIFY2(), QVERIFY(), QCOMPARE(), QTRY_COMPARE() + \sa QTRY_VERIFY_WITH_TIMEOUT(), QTRY_VERIFY2(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), + QEXPECT_FAIL() */ /*! \macro QTRY_VERIFY2_WITH_TIMEOUT(condition, message, timeout) @@ -161,7 +214,8 @@ \note This macro can only be used in a test function that is invoked by the test framework. - \sa QTRY_VERIFY(), QTRY_VERIFY_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE() + \sa QTRY_VERIFY(), QTRY_VERIFY_WITH_TIMEOUT(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), + QEXPECT_FAIL() */ /*! \macro QTRY_VERIFY2(condition, message) @@ -181,7 +235,8 @@ \note This macro can only be used in a test function that is invoked by the test framework. - \sa QTRY_VERIFY2_WITH_TIMEOUT(), QTRY_VERIFY2(), QVERIFY(), QCOMPARE(), QTRY_COMPARE() + \sa QTRY_VERIFY2_WITH_TIMEOUT(), QTRY_VERIFY2(), QVERIFY(), QCOMPARE(), QTRY_COMPARE(), + QEXPECT_FAIL() */ /*! \macro QTRY_COMPARE_WITH_TIMEOUT(actual, expected, timeout) @@ -198,7 +253,7 @@ \note This macro can only be used in a test function that is invoked by the test framework. - \sa QTRY_COMPARE(), QCOMPARE(), QVERIFY(), QTRY_VERIFY() + \sa QTRY_COMPARE(), QCOMPARE(), QVERIFY(), QTRY_VERIFY(), QEXPECT_FAIL() */ /*! \macro QTRY_COMPARE(actual, expected) @@ -212,7 +267,8 @@ \note This macro can only be used in a test function that is invoked by the test framework. - \sa QTRY_COMPARE_WITH_TIMEOUT(), QCOMPARE(), QVERIFY(), QTRY_VERIFY() + \sa QTRY_COMPARE_WITH_TIMEOUT(), QCOMPARE(), QVERIFY(), QTRY_VERIFY(), + QEXPECT_FAIL() */ /*! \macro QFETCH(type, name) -- cgit v1.2.3 From a54a48e5b8f56326eaee0868e0d2426218f31162 Mon Sep 17 00:00:00 2001 From: Peter Varga <pvarga@inf.u-szeged.hu> Date: Wed, 30 Oct 2019 10:11:20 +0100 Subject: AtSpiAdaptor: Fix QAccessible::TextUpdated notification Change-Id: I47e445d085b130121fe44eb2d4afc830de3b884b Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> --- src/platformsupport/linuxaccessibility/atspiadaptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 580cf0e31d..6e8cab93a2 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -958,7 +958,7 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) textRemoved = textEvent->textRemoved(); changePosition = textEvent->changePosition(); cursorPosition = textEvent->cursorPosition(); - } else if (event->type() == QAccessible::TextInserted) { + } else if (event->type() == QAccessible::TextUpdated) { QAccessibleTextUpdateEvent *textEvent = static_cast<QAccessibleTextUpdateEvent*>(event); textInserted = textEvent->textInserted(); textRemoved = textEvent->textRemoved(); -- cgit v1.2.3 From fa0a79a2bbafc8685a2ad13af5e9e3eb9bff8163 Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Fri, 11 Oct 2019 16:25:08 +0200 Subject: Doc: Add guidelines for writing Qt tests Based on https://wiki.qt.io/Writing_Unit_Tests. Some of the guidelines will be added to the documentation of a particular class, function, or macro. Task-number: QTBUG-18368 Task-number: QTBUG-63987 Change-Id: Ied267edc71e370a07f5124ba05432799f595dda6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/testlib/doc/src/qt-webpages.qdoc | 26 +- src/testlib/doc/src/qttest-best-practices.qdoc | 533 +++++++++++++++++++++++++ src/testlib/doc/src/qttest-index.qdoc | 3 +- 3 files changed, 556 insertions(+), 6 deletions(-) create mode 100644 src/testlib/doc/src/qttest-best-practices.qdoc (limited to 'src') diff --git a/src/testlib/doc/src/qt-webpages.qdoc b/src/testlib/doc/src/qt-webpages.qdoc index 29a2589a4c..976435e668 100644 --- a/src/testlib/doc/src/qt-webpages.qdoc +++ b/src/testlib/doc/src/qt-webpages.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -25,10 +25,26 @@ ** ****************************************************************************/ /*! - \externalpage http://blog.qt.io - \title Qt Labs + \externalpage https://blog.qt.io/blog/2008/12/05/qtestlib-now-with-nice-graphs-pointing-upwards/ + \title qtestlib-tools Announcement */ + /*! - \externalpage http://blog.qt.io/blog/2008/12/05/qtestlib-now-with-nice-graphs-pointing-upwards/ - \title qtestlib-tools Announcement + \externalpage https://www.froglogic.com/coco/ + \title Froglogic Coco Code Coverage +*/ + +/*! + \externalpage https://gcc.gnu.org/onlinedocs/gcc/Gcov.html + \title gcov +*/ + +/*! + \externalpage https://github.com/google/googletest/tree/master/googlemock + \title Googletest Mocking (gMock) Framework +*/ + +/*! + \externalpage https://www.itk.org/Wiki/CMake_Testing_With_CTest + \title CMake/Testing With CTest */ diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc new file mode 100644 index 0000000000..c7fee93c80 --- /dev/null +++ b/src/testlib/doc/src/qttest-best-practices.qdoc @@ -0,0 +1,533 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qttest-best-practices.qdoc + + \title Qt Test Best Practices + + \brief Guidelines for creating Qt tests. + + We recommend that you add Qt tests for bug fixes and new features. Before + you try to fix a bug, add a \e {regression test} (ideally automatic) that + fails before the fix, exhibiting the bug, and passes after the fix. While + you're developing new features, add tests to verify that they work as + intended. + + Conforming to a set of coding standards will make it more likely for + Qt autotests to work reliably in all environments. For example, some + tests need to read data from disk. If no standards are set for how this + is done, some tests won't be portable. For example, a test that assumes + its test-data files are in the current working directory only works for + an in-source build. In a shadow build (outside the source directory), the + test will fail to find its data. + + The following sections contain guidelines for writing Qt tests: + + \list + \li \l {General Principles} + \li \l {Writing Reliable Tests} + \li \l {Improving Test Output} + \li \l {Writing Testable Code} + \li \l {Setting up Test Machines} + \endlist + + \section1 General Principles + + The following sections provide general guidelines for writing unit tests: + + \list + \li \l {Verify Tests} + \li \l {Give Test Functions Descriptive Names} + \li \l {Write Self-contained Test Functions} + \li \l {Test the Full Stack} + \li \l {Make Tests Complete Quickly} + \li \l {Use Data-driven Testing} + \li \l {Use Coverage Tools} + \li \l {Select Appropriate Mechanisms to Exclude Tests} + \li \l {Avoid Q_ASSERT} + \endlist + + \section2 Verify Tests + + Write and commit your tests along with your fix or new feature on a new + branch. Once you're done, you can check out the branch on which your work + is based, and then check out into this branch the test-files for your new + tests. This enables you to verify that the tests do fail on the prior + branch, and therefore actually do catch a bug or test a new feature. + + For example, the workflow to fix a bug in the \c QDateTime class could be + like this if you use the Git version control system: + + \list 1 + \li Create a branch for your fix and test: + \c {git checkout -b fix-branch 5.14} + \li Write a test and fix the bug. + \li Build and test with both the fix and the new test, to verify that + the new test passes with the fix. + \li Add the fix and test to your branch: + \c {git add tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp src/corelib/time/qdatetime.cpp} + \li Commit the fix and test to your branch: + \c {git commit -m 'Fix bug in QDateTime'} + \li To verify that the test actually catches something for which you + needed the fix, checkout the branch you based your own branch on: + \c {git checkout 5.14} + \li Checkout only the test file to the 5.14 branch: + \c {git checkout fix-branch -- tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp} + + Only the test is now on the fix-branch. The rest of the source tree + is still on 5.14. + \li Build and run the test to verify that it fails on 5.14, and + therefore does indeed catch a bug. + \li You can now return to the fix branch: + \c {git checkout fix-branch} + \li Alternatively, you can restore your work tree to a clean state on + 5.14: + \c{git checkout HEAD -- tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp} + \endlist + + When you're reviewing a change, you can adapt this workflow to check that + the change does indeed come with a test for a problem it does fix. + + \section2 Give Test Functions Descriptive Names + + Naming test cases is important. The test name appears in the failure report + for a test run. For data-driven tests, the name of the data row also appears + in the failure report. The names give those reading the report a first + indication of what has gone wrong. + + Test function names should make it obvious what the function is trying to + test. Do not simply use the bug-tracking identifier, because the identifiers + become obsolete if the bug-tracker is replaced. Also, some bug-trackers may + not be accessible to all users. When the bug report may be of interest to + later readers of the test code, you can mention it in a comment alongside a + relevant part of the test. + + Likewise, when writing data-driven tests, give descriptive names to the + test-cases, that indicate what aspect of the functionality each focuses on. + Do not simply number the test-case, or use bug-tracking identifiers. Someone + reading the test output will have no idea what the numbers or identifiers + mean. You can add a comment on the test-row that mentions the bug-tracking + identifier, when relevant. + + \section2 Write Self-contained Test Functions + + Within a test program, test functions should be independent of each other + and they should not rely upon previous test functions having been run. You + can check this by running the test function on its own with + \c {tst_foo testname}. + + Do not re-use instances of the class under test in several tests. Test + instances (for example widgets) should not be member variables of the + tests, but preferably be instantiated on the stack to ensure proper + cleanup even if a test fails, so that tests do not interfere with + each other. + + \section2 Test the Full Stack + + If an API is implemented in terms of pluggable or platform-specific backends + that do the heavy-lifting, make sure to write tests that cover the + code-paths all the way down into the backends. Testing the upper layer API + parts using a mock backend is a nice way to isolate errors in the API layer + from the backends, but it is complementary to tests that run the actual + implementation with real-world data. + + \section2 Make Tests Complete Quickly + + Tests should not waste time by being unnecessarily repetitious, by using + inappropriately large volumes of test data, or by introducing needless + idle time. + + This is particularly true for unit testing, where every second of extra + unit test execution time makes CI testing of a branch across multiple + targets take longer. Remember that unit testing is separate from load and + reliability testing, where larger volumes of test data and longer test + runs are expected. + + Benchmark tests, which typically execute the same test multiple times, + should be located in a separate \c tests/benchmarks directory and they + should not be mixed with functional unit tests. + + \section2 Use Data-driven Testing + + Data-driven tests make it easier to add new tests for boundary conditions + found in later bug reports. + + Using a data-driven test rather than testing several items in sequence in + a test saves repetition of very similar code and ensures later cases are + tested even when earlier ones fail. It also encourages systematic and + uniform testing, because the same tests are applied to each data sample. + + \section2 Use Coverage Tools + + Use a coverage tool such as \l {Froglogic Coco Code Coverage} or \l {gcov} + to help write tests that cover as many statements, branches, and conditions + as possible in the function or class being tested. The earlier this is done + in the development cycle for a new feature, the easier it will be to catch + regressions later when the code is refactored. + + \section2 Select Appropriate Mechanisms to Exclude Tests + + It is important to select the appropriate mechanism to exclude inapplicable + tests: \l QSKIP(), using conditional statements to exclude parts of a test + function, or not building the test for a particular platform. + + Use QSKIP() to handle cases where a whole test function is found at run-time + to be inapplicable in the current test environment. When just a part of a + test function is to be skipped, a conditional statement can be used, + optionally with a \c qDebug() call to report the reason for skipping the + inapplicable part. + + Test functions or data rows of a data-driven test can be limited to + particular platforms, or to particular features being enabled using + \c{#if}. However, beware of \l moc limitations when using \c{#if} to + skip test functions. The \c moc preprocessor does not have access to + all the \c builtin macros of the compiler that are often used for + feature detection of the compiler. Therefore, \c moc might get a different + result for a preprocessor condition from that seen by the rest of your + code. This may result in \c moc generating meta-data for a test slot that + the actual compiler skips, or omitting the meta-data for a test slot that + is actually compiled into the class. In the first case, the test will + attempt to run a slot that is not implemented. In the second case, the + test will not attempt to run a test slot even though it should. + + If an entire test program is inapplicable for a specific platform or + unless a particular feature is enabled, the best approach is to use the + parent directory's \c .pro file to avoid building the test. For example, + if the \c tests/auto/gui/someclass test is not valid for \macOS, add the + following line to \c tests/auto/gui.pro: + + \badcode + mac*: SUBDIRS -= someclass + \endcode + + \section2 Avoid Q_ASSERT + + The \l Q_ASSERT macro causes a program to abort whenever the asserted + condition is \c false, but only if the software was built in debug mode. + In both release and debug-and-release builds, \c Q_ASSERT does nothing. + + \c Q_ASSERT should be avoided because it makes tests behave differently + depending on whether a debug build is being tested, and because it causes + a test to abort immediately, skipping all remaining test functions and + returning incomplete or malformed test results. + + It also skips any tear-down or tidy-up that was supposed to happen at the + end of the test, and might therefore leave the workspace in an untidy state, + which might cause complications for further tests. + + Instead of \c Q_ASSERT, the \l QCOMPARE() or \l QVERIFY() macro variants + should be used. They cause the current test to report a failure and + terminate, but allow the remaining test functions to be executed and the + entire test program to terminate normally. \l Q_VERIFY2() even allows a + descriptive error message to be recorded in the test log. + + \section1 Writing Reliable Tests + + The following sections provide guidelines for writing reliable tests: + + \list + \li \l {Avoid Side-effects in Verification Steps} + \li \l {Avoid Fixed Timeouts} + \li \l {Beware of Timing-dependent Behavior} + \li \l {Avoid Bitmap Capture and Comparison} + \endlist + + \section2 Avoid Side-effects in Verification Steps + + When performing verification steps in an autotest using \l QCOMPARE(), + \l QVERIFY(), and so on, side-effects should be avoided. Side-effects + in verification steps can make a test difficult to understand. Also, + they can easily break a test in ways that are difficult to diagnose + when the test is changed to use \l QTRY_VERIFY(), \l QTRY_COMPARE() or + \l QBENCHMARK(). These can execute the passed expression multiple times, + thus repeating any side-effects. + + When side-effects are unavoidable, ensure that the prior state is restored + at the end of the test function, even if the test fails. This commonly + requires use of an RAII (resource acquisition is initialization) class + that restores state when the function returns, or a \l cleanup() method. + Do not simply put the restoration code at the end of the test. If part of + the test fails, such code will be skipped and the prior state will not be + restored. + + \section2 Avoid Fixed Timeouts + + Avoid using hard-coded timeouts, such as QTest::qWait() to wait for some + conditions to become true. Consider using the \l QtSignalSpy class, + the \l QTRY_VERIFY() or \l QTRY_COMPARE() macros, or the \c QtSignalSpy + class in conjunction with the \c QTRY_ macro variants. + + The \c qWait() function can be used to set a delay for a fixed period + between performing some action and waiting for some asynchronous behavior + triggered by that action to be completed. For example, changing the state + of a widget and then waiting for the widget to be repainted. However, + such timeouts often cause failures when a test written on a workstation is + executed on a device, where the expected behavior might take longer to + complete. Increasing the fixed timeout to a value several times larger + than needed on the slowest test platform is not a good solution, because + it slows down the test run on all platforms, particularly for table-driven + tests. + + If the code under test issues Qt signals on completion of the asynchronous + behavior, a better approach is to use the \l QSignalSpy class to notify + the test function that the verification step can now be performed. + + If there are no Qt signals, use the \c QTRY_COMPARE() and \c QTRY_VERIFY() + macros, which periodically test a specified condition until it becomes true + or some maximum timeout is reached. These macros prevent the test from + taking longer than necessary, while avoiding breakages when tests are + written on workstations and later executed on embedded platforms. + + If there are no Qt signals, and you are writing the test as part of + developing a new API, consider whether the API could benefit from the + addition of a signal that reports the completion of the asynchronous + behavior. + + \section2 Beware of Timing-dependent Behavior + + Some test strategies are vulnerable to timing-dependent behavior of certain + classes, which can lead to tests that fail only on certain platforms or that + do not return consistent results. + + One example of this is text-entry widgets, which often have a blinking + cursor that can make comparisons of captured bitmaps succeed or fail + depending on the state of the cursor when the bitmap is captured. This, + in turn, may depend on the speed of the machine executing the test. + + When testing classes that change their state based on timer events, the + timer-based behavior needs to be taken into account when performing + verification steps. Due to the variety of timing-dependent behavior, there + is no single generic solution to this testing problem. + + For text-entry widgets, potential solutions include disabling the cursor + blinking behavior (if the API provides that feature), waiting for the + cursor to be in a known state before capturing a bitmap (for example, by + subscribing to an appropriate signal if the API provides one), or + excluding the area containing the cursor from the bitmap comparison. + + \section2 Avoid Bitmap Capture and Comparison + + While verifying test results by capturing and comparing bitmaps is sometimes + necessary, it can be quite fragile and labor-intensive. + + For example, a particular widget may have different appearance on different + platforms or with different widget styles, so reference bitmaps may need to + be created multiple times and then maintained in the future as Qt's set of + supported platforms evolves. Making changes that affect the bitmap thus + means having to recreate the expected bitmaps on each supported platform, + which would require access to each platform. + + Bitmap comparisons can also be influenced by factors such as the test + machine's screen resolution, bit depth, active theme, color scheme, + widget style, active locale (currency symbols, text direction, and so + on), font size, transparency effects, and choice of window manager. + + Where possible, use programmatic means, such as verifying properties of + objects and variables, instead of capturing and comparing bitmaps. + + \section1 Improving Test Output + + The following sections provide guidelines for producing readable and + helpful test output: + + \list + \li \l {Explicitly Ignore Expected Warnings} + \li \l {Avoid Printing Debug Messages from Autotests} + \li \l {Write Well-structured Diagnostic Code} + \endlist + + \section2 Explicitly Ignore Expected Warnings + + If a test is expected to cause Qt to output a warning or debug message + on the console, it should call \l QTest::ignoreMessage() to filter that + message out of the test output and to fail the test if the message is + not output. + + If such a message is only output when Qt is built in debug mode, use + \l QLibraryInfo::isDebugBuild() to determine whether the Qt libraries + were built in debug mode. Using \c{#ifdef QT_DEBUG} is not enough, as + it will only tell you whether the test was built in debug mode, and + that does not guarantee that the Qt libraries were also built in debug + mode. + + \section2 Avoid Printing Debug Messages from Autotests + + Autotests should not produce any unhandled warning or debug messages. + This will allow the CI Gate to treat new warning or debug messages as + test failures. + + Adding debug messages during development is fine, but these should be + either disabled or removed before a test is checked in. + + \section2 Write Well-structured Diagnostic Code + + Any diagnostic output that would be useful if a test fails should be part + of the regular test output rather than being commented-out, disabled by + preprocessor directives, or enabled only in debug builds. If a test fails + during continuous integration, having all of the relevant diagnostic output + in the CI logs could save you a lot of time compared to enabling the + diagnostic code and testing again. Epecially, if the failure was on a + platform that you don't have on your desktop. + + Diagnostic messages in tests should use Qt's output mechanisms, such as + \c qDebug() and \c qWarning(), rather than \c stdio.h or \c iostream.h output + mechanisms. The latter bypass Qt's message handling and prevent the + \c -silent command-line option from suppressing the diagnostic messages. + This could result in important failure messages being hidden in a large + volume of debugging output. + + \section1 Writing Testable Code + + The following sections provide guidelines for writing code that is easy to + test: + + \list + \li \l {Break Dependencies} + \li \l {Compile All Classes into Libraries} + \endlist + + \section2 Break Dependencies + + The idea of unit testing is to use every class in isolation. Since many + classes instantiate other classes, it is not possible to instantiate one + class separately. Therefore, you should use a technique called + \e {dependency injection} that separates object creation from object use. + A factory is responsible for building object trees. Other objects manipulate + these objects through abstract interfaces. + + This technique works well for data-driven applications. For GUI + applications, this approach can be difficult as objects are frequently + created and destructed. To verify the correct behavior of classes that + depend on abstract interfaces, \e mocking can be used. For example, see + \l {Googletest Mocking (gMock) Framework}. + + \section2 Compile All Classes into Libraries + + In small to medium sized projects, a build script typically lists all + source files and then compiles the executable in one go. This means that + the build scripts for the tests must list the needed source files again. + + It is easier to list the source files and the headers only once in a + script to build a static library. Then the \c main() function will be + linked against the static library to build the executable and the tests + will be linked against the static libraries. + + For projects where the same source files are used in building several + programs, it may be more appropriate to build the shared classes into + a dynamically-linked (or shared object) library that each program, + including the test programs, can load at run-time. Again, having the + compiled code in a library helps to avoid duplication in the description + of which components to combine to make the various programs. + + \section1 Setting up Test Machines + + The following sections discuss common problems caused by test machine setup: + + \list + \li \l {Screen Savers} + \li \l {System Dialogs} + \li \l {Display Usage} + \li \l {Window Managers} + \endlist + + All of these problems can typically be solved by the judicious use of + virtualisation. + + \section2 Screen Savers + + Screen savers can interfere with some of the tests for GUI classes, causing + unreliable test results. Screen savers should be disabled to ensure that + test results are consistent and reliable. + + \section2 System Dialogs + + Dialogs displayed unexpectedly by the operating system or other running + applications can steal input focus from widgets involved in an autotest, + causing unreproducible failures. + + Examples of typical problems include online update notification dialogs + on macOS, false alarms from virus scanners, scheduled tasks such as virus + signature updates, software updates pushed out to workstations, and chat + programs popping up windows on top of the stack. + + \section2 Display Usage + + Some tests use the test machine's display, mouse, and keyboard, and can + thus fail if the machine is being used for something else at the same + time or if multiple tests are run in parallel. + + The CI system uses dedicated test machines to avoid this problem, but if + you don't have a dedicated test machine, you may be able to solve this + problem by running the tests on a second display. + + On Unix, one can also run the tests on a nested or virtual X-server, such as + Xephyr. For example, to run the entire set of tests on Xephyr, execute the + following commands: + + \code + Xephyr :1 -ac -screen 1920x1200 >/dev/null 2>&1 & + sleep 5 + DISPLAY=:1 icewm >/dev/null 2>&1 & + cd tests/auto + make + DISPLAY=:1 make -k -j1 check + \endcode + + Users of NVIDIA binary drivers should note that Xephyr might not be able to + provide GLX extensions. Forcing Mesa libGL might help: + + \code + export LD_PRELOAD=/usr/lib/mesa-diverted/x86_64-linux-gnu/libGL.so.1 + \endcode + + However, when tests are run on Xephyr and the real X-server with different + libGL versions, the QML disk cache can make the tests crash. To avoid this, + use \c QML_DISABLE_DISK_CACHE=1. + + Alternatively, use the offscreen plugin: + + \code + TESTARGS="-platform offscreen" make check -k -j1 + \endcode + + \section2 Window Managers + + On Unix, at least two autotests (\c tst_examples and \c tst_gestures) + require a window manager to be running. Therefore, if running these + tests under a nested X-server, you must also run a window manager + in that X-server. + + Your window manager must be configured to position all windows on the + display automatically. Some windows managers, such as Tab Window Manager + (twm), have a mode for manually positioning new windows, and this prevents + the test suite from running without user interaction. + + \note Tab Window Manager is not suitable for running the full suite of + Qt autotests, as the \c tst_gestures autotest causes it to forget its + configuration and revert to manual window placement. +*/ diff --git a/src/testlib/doc/src/qttest-index.qdoc b/src/testlib/doc/src/qttest-index.qdoc index 23be46b431..e31f232069 100644 --- a/src/testlib/doc/src/qttest-index.qdoc +++ b/src/testlib/doc/src/qttest-index.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -56,6 +56,7 @@ \list \li \l{Qt Test Overview} + \li \l{Qt Test Best Practices} \li \l{Qt Test Tutorial} \endlist -- cgit v1.2.3 From 0fb995492d377fde96b453680f3604f5991171c0 Mon Sep 17 00:00:00 2001 From: David Faure <david.faure@kdab.com> Date: Sun, 27 Oct 2019 09:33:54 +0100 Subject: QImageIOHandler: remove #if around virtual method name() It makes -DQT_DISABLE_DEPRECATED_BEFORE=0x050d00 (in an application) trigger a binary incompatible change and crash. Change-Id: I9b9783d134821697180dc3fd8f2f69a51ddb7ac6 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/gui/image/qimageiohandler.cpp | 4 +--- src/gui/image/qimageiohandler.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp index 0e7b541cf2..a4f927a462 100644 --- a/src/gui/image/qimageiohandler.cpp +++ b/src/gui/image/qimageiohandler.cpp @@ -416,18 +416,16 @@ QByteArray QImageIOHandler::format() const \sa read(), QIODevice::peek() */ -#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete Use format() instead. */ -QByteArray QImageIOHandler::name() const +QByteArray QImageIOHandler::name() const // ### Qt6: remove { return format(); } -#endif /*! Writes the image \a image to the assigned device. Returns \c true on diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h index c20b84afbb..a4acf9dfe0 100644 --- a/src/gui/image/qimageiohandler.h +++ b/src/gui/image/qimageiohandler.h @@ -69,10 +69,8 @@ public: void setFormat(const QByteArray &format) const; QByteArray format() const; -#if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X("Use QImageIOHandler::format() instead") virtual QByteArray name() const; -#endif virtual bool canRead() const = 0; virtual bool read(QImage *image) = 0; -- cgit v1.2.3 From 5436a6f3e0a9e7ef7ed51fc5b304e1f81eaed960 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 1 Nov 2019 10:58:24 +0100 Subject: QNetworkReply: Fix SSL configuration handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QT_CONFIG consistently and enclose sslConfigurationImplementation(), setSslConfigurationImplementation() and ignoreSslErrorsImplementation() within QT_CONFIG as well. This enables a build of Qt for Python with -no-feature-ssl. Change-Id: Ia699293ab73a5dc86d8dcf95aa5f6369334d36a2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/access/qnetworkreply.cpp | 5 +++-- src/network/access/qnetworkreply.h | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index aca9cb1c08..fb30bfd4f1 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -687,7 +687,7 @@ QVariant QNetworkReply::attribute(QNetworkRequest::Attribute code) const return d_func()->attributes.value(code); } -#ifndef QT_NO_SSL +#if QT_CONFIG(ssl) /*! Returns the SSL configuration and state associated with this reply, if SSL was used. It will contain the remote server's @@ -742,7 +742,6 @@ void QNetworkReply::ignoreSslErrors(const QList<QSslError> &errors) { ignoreSslErrorsImplementation(errors); } -#endif /*! \fn void QNetworkReply::sslConfigurationImplementation(QSslConfiguration &configuration) const @@ -786,6 +785,8 @@ void QNetworkReply::ignoreSslErrorsImplementation(const QList<QSslError> &) { } +#endif // QT_CONFIG(ssl) + /*! If this function is called, SSL errors related to network connection will be ignored, including certificate validation diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h index 63c2752caf..4a402daa91 100644 --- a/src/network/access/qnetworkreply.h +++ b/src/network/access/qnetworkreply.h @@ -143,7 +143,7 @@ public: // attributes QVariant attribute(QNetworkRequest::Attribute code) const; -#ifndef QT_NO_SSL +#if QT_CONFIG(ssl) QSslConfiguration sslConfiguration() const; void setSslConfiguration(const QSslConfiguration &configuration); void ignoreSslErrors(const QList<QSslError> &errors); @@ -157,7 +157,7 @@ Q_SIGNALS: void metaDataChanged(); void finished(); void error(QNetworkReply::NetworkError); -#ifndef QT_NO_SSL +#if QT_CONFIG(ssl) void encrypted(); void sslErrors(const QList<QSslError> &errors); void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator); @@ -182,9 +182,11 @@ protected: void setRawHeader(const QByteArray &headerName, const QByteArray &value); void setAttribute(QNetworkRequest::Attribute code, const QVariant &value); +#if QT_CONFIG(ssl) virtual void sslConfigurationImplementation(QSslConfiguration &) const; virtual void setSslConfigurationImplementation(const QSslConfiguration &); virtual void ignoreSslErrorsImplementation(const QList<QSslError> &); +#endif private: Q_DECLARE_PRIVATE(QNetworkReply) -- cgit v1.2.3 From 39ed657b6393c850735857e367303800f1a04413 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Mon, 21 Oct 2019 10:23:27 +0200 Subject: Query the mouse buttons initially in case the middle button was used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I99a3ef598bdaaba1afb6bf6521d1ceafcc9b603c Reviewed-by: André de la Rocha <andre.rocha@qt.io> --- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 71a09304c5..fae01c9147 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -579,7 +579,9 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin const QTabletEvent::TabletDevice device = QTabletEvent::Stylus; QTabletEvent::PointerType type; - Qt::MouseButtons mouseButtons; + // Since it may be the middle button, so if the checks fail then it should + // be set to Middle if it was used. + Qt::MouseButtons mouseButtons = queryMouseButtons(); const bool pointerInContact = IS_POINTER_INCONTACT_WPARAM(msg.wParam); if (pointerInContact) -- cgit v1.2.3 From 1d959c0de32f146904086737fc2c18f4ce85ebce Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@qt.io> Date: Fri, 1 Nov 2019 16:30:47 +0100 Subject: Qt XML: Fix module in comment Change-Id: Ibb1c0b54c4add118328f9281e2dbbcf9c1c62312 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> --- src/xml/qtxmlglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xml/qtxmlglobal.h b/src/xml/qtxmlglobal.h index ed5de8db87..1ce3008f4a 100644 --- a/src/xml/qtxmlglobal.h +++ b/src/xml/qtxmlglobal.h @@ -3,7 +3,7 @@ ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the QtCore module of the Qt Toolkit. +** This file is part of the QtXml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage -- cgit v1.2.3 From accc40f323b2eb284a9c2767a29659ebbb135b14 Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@qt.io> Date: Wed, 30 Oct 2019 14:45:47 +0100 Subject: Fix check for EGL on INTEGRITY This fixes a regression introduced in c00487d588f. Fixes: QTBUG-79285 Change-Id: I95f073d019d6e909f8de132ea9f27002043d5d52 Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Timo Aarnipuro <timo.aarnipuro@qt.io> Reviewed-by: Tasuku Suzuki <tasuku.suzuki@tqcs.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- src/gui/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index c2793bf236..19312d245d 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1375,7 +1375,7 @@ }, "egl": { "label": "EGL", - "condition": "(features.opengl || features.openvg) && (features.angle || libs.egl) && (features.dlopen || !config.unix)", + "condition": "(features.opengl || features.openvg) && (features.angle || libs.egl) && (features.dlopen || !config.unix || config.integrity)", "output": [ "privateFeature", "feature" ] }, "egl_x11": { -- cgit v1.2.3 From 77455a9a8c678daf4a3035ce0c835f7bfeb617ee Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 4 Nov 2019 09:26:36 +0100 Subject: QProcess: explicitly mark QProcess::error() as deprecated The signal QProcess::error() was deprecated in Qt5.6 but not annotated with QT_DEPRECATED_X. Change-Id: I9dd11c9b8019a0554cb82d6acb6b7e0a01c78123 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/corelib/io/qprocess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 9fda5fba11..585508adf1 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -278,7 +278,8 @@ Q_SIGNALS: void finished(int exitCode); // ### Qt 6: merge the two signals with a default value #endif void finished(int exitCode, QProcess::ExitStatus exitStatus); -#if QT_DEPRECATED_SINCE(5,6) +#if QT_DEPRECATED_SINCE(5, 6) + QT_DEPRECATED_X("Use QProcess::errorOccurred(QProcess::ProcessError) instead") void error(QProcess::ProcessError error); #endif void errorOccurred(QProcess::ProcessError error); -- cgit v1.2.3 From a3361ac66d5f8929530c1507b14bae7e398247a6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Mon, 4 Nov 2019 16:09:49 +0100 Subject: Remove old resizing inplace QImage converters They are highly unlikely to avoid reallocating and moving data, and working inplace is likely just slower. Change-Id: I16eb1d54a660e52b145be1ed0b64a3fb636a0002 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/gui/image/qimage_conversions.cpp | 220 +---------------------------------- 1 file changed, 5 insertions(+), 215 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 9e1df7058c..760f831889 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -819,216 +819,6 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver return true; } -static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - const int depth = 32; - auto params = QImageData::calculateImageParameters(data->width, data->height, depth); - if (params.bytesPerLine < 0) - return false; - uchar *const newData = (uchar *)realloc(data->data, params.totalSize); - if (!newData) - return false; - - data->data = newData; - - // start converting from the end because the end image is bigger than the source - uchar *src_data = newData + data->nbytes; // end of src - quint32 *dest_data = (quint32 *) (newData + params.totalSize); // end of dest > end of src - const int width = data->width; - const int src_pad = data->bytes_per_line - width; - const int dest_pad = (params.bytesPerLine >> 2) - width; - if (data->colortable.size() == 0) { - data->colortable.resize(256); - for (int i = 0; i < 256; ++i) - data->colortable[i] = qRgb(i, i, i); - } else { - for (int i = 0; i < data->colortable.size(); ++i) - data->colortable[i] = qPremultiply(data->colortable.at(i)); - - // Fill the rest of the table in case src_data > colortable.size() - const int oldSize = data->colortable.size(); - const QRgb lastColor = data->colortable.at(oldSize - 1); - data->colortable.insert(oldSize, 256 - oldSize, lastColor); - } - - for (int i = 0; i < data->height; ++i) { - src_data -= src_pad; - dest_data -= dest_pad; - for (int pixI = 0; pixI < width; ++pixI) { - --src_data; - --dest_data; - *dest_data = data->colortable.at(*src_data); - } - } - - data->colortable = QVector<QRgb>(); - data->format = QImage::Format_ARGB32_Premultiplied; - data->bytes_per_line = params.bytesPerLine; - data->depth = depth; - data->nbytes = params.totalSize; - - return true; -} - -static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - const int depth = 32; - auto params = QImageData::calculateImageParameters(data->width, data->height, depth); - if (params.bytesPerLine < 0) - return false; - uchar *const newData = (uchar *)realloc(data->data, params.totalSize); - if (!newData) - return false; - - data->data = newData; - - // start converting from the end because the end image is bigger than the source - uchar *src_data = newData + data->nbytes; - quint32 *dest_data = (quint32 *) (newData + params.totalSize); - const int width = data->width; - const int src_pad = data->bytes_per_line - width; - const int dest_pad = (params.bytesPerLine >> 2) - width; - if (data->colortable.size() == 0) { - data->colortable.resize(256); - for (int i = 0; i < 256; ++i) - data->colortable[i] = qRgb(i, i, i); - } else { - // Fill the rest of the table in case src_data > colortable.size() - const int oldSize = data->colortable.size(); - const QRgb lastColor = data->colortable.at(oldSize - 1); - data->colortable.insert(oldSize, 256 - oldSize, lastColor); - } - - for (int i = 0; i < data->height; ++i) { - src_data -= src_pad; - dest_data -= dest_pad; - for (int pixI = 0; pixI < width; ++pixI) { - --src_data; - --dest_data; - *dest_data = (quint32) data->colortable.at(*src_data); - } - } - - data->colortable = QVector<QRgb>(); - data->format = QImage::Format_ARGB32; - data->bytes_per_line = params.bytesPerLine; - data->depth = depth; - data->nbytes = params.totalSize; - - return true; -} - -static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - if (data->has_alpha_clut) { - for (int i = 0; i < data->colortable.size(); ++i) - data->colortable[i] |= 0xff000000; - } - - if (!convert_indexed8_to_ARGB_inplace(data, flags)) - return false; - - data->format = QImage::Format_RGB32; - return true; -} - -static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_Indexed8); - Q_ASSERT(data->own_data); - - const int depth = 16; - auto params = QImageData::calculateImageParameters(data->width, data->height, depth); - if (params.bytesPerLine < 0) - return false; - uchar *const newData = (uchar *)realloc(data->data, params.totalSize); - if (!newData) - return false; - - data->data = newData; - - // start converting from the end because the end image is bigger than the source - uchar *src_data = newData + data->nbytes; - quint16 *dest_data = (quint16 *) (newData + params.totalSize); - const int width = data->width; - const int src_pad = data->bytes_per_line - width; - const int dest_pad = (params.bytesPerLine >> 1) - width; - - quint16 colorTableRGB16[256]; - const int tableSize = data->colortable.size(); - if (tableSize == 0) { - for (int i = 0; i < 256; ++i) - colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); - } else { - // 1) convert the existing colors to RGB16 - for (int i = 0; i < tableSize; ++i) - colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); - data->colortable = QVector<QRgb>(); - - // 2) fill the rest of the table in case src_data > colortable.size() - const quint16 lastColor = colorTableRGB16[tableSize - 1]; - for (int i = tableSize; i < 256; ++i) - colorTableRGB16[i] = lastColor; - } - - for (int i = 0; i < data->height; ++i) { - src_data -= src_pad; - dest_data -= dest_pad; - for (int pixI = 0; pixI < width; ++pixI) { - --src_data; - --dest_data; - *dest_data = colorTableRGB16[*src_data]; - } - } - - data->format = QImage::Format_RGB16; - data->bytes_per_line = params.bytesPerLine; - data->depth = depth; - data->nbytes = params.totalSize; - - return true; -} - -static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) -{ - Q_ASSERT(data->format == QImage::Format_RGB32); - Q_ASSERT(data->own_data); - - const int depth = 16; - - // cannot overflow, since we're shrinking the buffer - const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qsizetype src_bytes_per_line = data->bytes_per_line; - quint32 *src_data = (quint32 *) data->data; - quint16 *dst_data = (quint16 *) data->data; - - for (int i = 0; i < data->height; ++i) { - for (int j = 0; j < data->width; ++j) - dst_data[j] = qConvertRgb32To16(src_data[j]); - src_data = (quint32 *) (((char*)src_data) + src_bytes_per_line); - dst_data = (quint16 *) (((char*)dst_data) + dst_bytes_per_line); - } - data->format = QImage::Format_RGB16; - data->bytes_per_line = dst_bytes_per_line; - data->depth = depth; - data->nbytes = dst_bytes_per_line * data->height; - uchar *const newData = (uchar *)realloc(data->data, data->nbytes); - if (newData) - data->data = newData; - - // can't fail, since we're shrinking - return true; -} - static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src) { Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied); @@ -2978,10 +2768,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - convert_indexed8_to_RGB_inplace, - convert_indexed8_to_ARGB_inplace, - convert_indexed8_to_ARGB_PM_inplace, - convert_indexed8_to_RGB16_inplace, + 0, + 0, + 0, + 0, 0, 0, 0, @@ -3005,7 +2795,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, mask_alpha_converter_inplace<QImage::Format_ARGB32>, mask_alpha_converter_inplace<QImage::Format_ARGB32_Premultiplied>, - convert_RGB_to_RGB16_inplace, + 0, 0, 0, 0, -- cgit v1.2.3 From b1004c7d0a5d7abbacd687fd41a5b2683e62b27d Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Tue, 29 Oct 2019 09:44:50 +0100 Subject: If only family is set, prefer that in the families list after resolving If a font with only a family set is resolved with one that has been setup with setFamilies() then the family needs to be prepended to the families list after resolving. This is so that the font still prefers the one set as just a family with no famillies set. This also amends the QFontDialog test to account for this too. [ChangeLog][QtGui][Text] Resolving a font that just has a family set with families set will prepend the family to the families so that it is still the first preference for the font. Task-number: QTBUG-46322 Change-Id: Icc4005732f95b2b4c684e592b06b31e133270e44 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> --- src/gui/text/qfont.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 84c5be60b1..f5dbec3a3e 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -271,8 +271,13 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other) if (! (mask & QFont::FamilyResolved)) request.family = other->request.family; - if (!(mask & QFont::FamiliesResolved)) + if (!(mask & QFont::FamiliesResolved)) { request.families = other->request.families; + // Prepend the family explicitly set so it will be given + // preference in this case + if (mask & QFont::FamilyResolved) + request.families.prepend(request.family); + } if (! (mask & QFont::StyleNameResolved)) request.styleName = other->request.styleName; -- cgit v1.2.3 From 524ab7b5357e66b935a42956ec365a511e62e5ed Mon Sep 17 00:00:00 2001 From: Shawn Rutledge <shawn.rutledge@qt.io> Date: Fri, 4 Oct 2019 22:06:41 +0200 Subject: Avoid crashing when the end of an empty markdown list is detected The markdown parser generates empty lists in some cases when a character that can be used as a bullet is found on a line by itself. cbEnterBlock() and cbLeaveBlock() are called symmetrically in such cases. QStack::pop() on an empty stack triggers an assert, so push and pop need to be done symmetrically too. But it's difficult to actually create the list as soon as the MD_BLOCK_UL or MD_BLOCK_OL callback occurs, without breaking the case fixed in 7224d0e427d71e559b928c44634839b4791c1416 (and probably other cases). That's because QTextCursor::insertList() creates a list item at the same time as it creates the list itself, and also inherits block formatting from the previous block. We now insert empty lists with empty items whenever the need for that is detected though, and there's a failsafe to prevent popping in case something still goes wrong with that logic. We aren't strict about reproducing the original markdown when regenerating it via toMarkdown(), but it's getting closer. Fixes: QTBUG-78870 Change-Id: Ided194ce7aec2710c60dbac42761ee4169ed9b78 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Robert Loehning <robert.loehning@qt.io> --- src/gui/text/qtextmarkdownimporter.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 87ade1f973..c2ad1e5612 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -216,6 +216,10 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) qCDebug(lcMD) << "LI"; } break; case MD_BLOCK_UL: { + if (m_needsInsertList) // list nested in an empty list + m_listStack.push(m_cursor->insertList(m_listFormat)); + else + m_needsInsertList = true; MD_BLOCK_UL_DETAIL *detail = static_cast<MD_BLOCK_UL_DETAIL *>(det); m_listFormat = QTextListFormat(); m_listFormat.setIndent(m_listStack.count() + 1); @@ -230,17 +234,19 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) m_listFormat.setStyle(QTextListFormat::ListDisc); break; } - qCDebug(lcMD, "UL %c level %d", detail->mark, m_listStack.count()); - m_needsInsertList = true; + qCDebug(lcMD, "UL %c level %d", detail->mark, m_listStack.count() + 1); } break; case MD_BLOCK_OL: { + if (m_needsInsertList) // list nested in an empty list + m_listStack.push(m_cursor->insertList(m_listFormat)); + else + m_needsInsertList = true; MD_BLOCK_OL_DETAIL *detail = static_cast<MD_BLOCK_OL_DETAIL *>(det); m_listFormat = QTextListFormat(); m_listFormat.setIndent(m_listStack.count() + 1); m_listFormat.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter)); m_listFormat.setStyle(QTextListFormat::ListDecimal); - qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, m_listStack.count()); - m_needsInsertList = true; + qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, m_listStack.count() + 1); } break; case MD_BLOCK_TD: { MD_BLOCK_TD_DETAIL *detail = static_cast<MD_BLOCK_TD_DETAIL *>(det); @@ -306,8 +312,14 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail) break; case MD_BLOCK_UL: case MD_BLOCK_OL: - qCDebug(lcMD, "list at level %d ended", m_listStack.count()); - m_listStack.pop(); + if (Q_UNLIKELY(m_needsInsertList)) + m_listStack.push(m_cursor->createList(m_listFormat)); + if (Q_UNLIKELY(m_listStack.isEmpty())) { + qCWarning(lcMD, "list ended unexpectedly"); + } else { + qCDebug(lcMD, "list at level %d ended", m_listStack.count()); + m_listStack.pop(); + } break; case MD_BLOCK_TR: { // https://github.com/mity/md4c/issues/29 -- cgit v1.2.3 From d1c6f7e5a2e0ee6c50bbf0668e44200bd8469a09 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge <shawn.rutledge@qt.io> Date: Mon, 14 Oct 2019 17:59:16 +0200 Subject: QTextMarkdownWriter: preserve empty lists You can save a "skeletal" document with list items to fill in later, the same as you can do in HTML or ODF format. Reading them back via QTextDocument::fromMarkdown() isn't always perfect though. Fixes: QTBUG-79217 Change-Id: Iacdb3e6792250ebdead05f314c9e3d00546eeb9f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/text/qtextmarkdownwriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index 764c64aead..c9a63920c3 100644 --- a/src/gui/text/qtextmarkdownwriter.cpp +++ b/src/gui/text/qtextmarkdownwriter.cpp @@ -173,7 +173,8 @@ void QTextMarkdownWriter::writeFrame(const QTextFrame *frame) if (lastWasList) m_stream << Newline; } - int endingCol = writeBlock(block, !table, table && tableRow == 0, nextIsDifferent); + int endingCol = writeBlock(block, !table, table && tableRow == 0, + nextIsDifferent && !block.textList()); m_doubleNewlineWritten = false; if (table) { QTextTableCell cell = table->cellAt(block.position()); -- cgit v1.2.3 From dbb54805f63f9ed68d84fe090d608872f16170d2 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Thu, 22 Nov 2018 12:00:53 +0100 Subject: Deprecate reverse iteration on QHash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit std::unordered_map only supports forward iteration for good reasons. Align our API with this by deprecating reverse iteration and the operator+/-() for iterators. [ChangeLog][QtCore][QHash] Reverse iteration over QHash is now deprecated. [ChangeLog][Potentially Binary-Incompatible Changes] QHash's iterator category was changed from bidirectional iterator to forward iterator. This may cause trouble if a library uses the iterator category to alter functionality through tag dispatching. This only applies when compiling the library or application with QT_DISABLE_DEPRECATED_BEFORE=0x050F00 and the other with a lower value. Change-Id: I0fb6d017cabdef1bc508e62f76dc2fa73cd3652d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/serialization/qdatastream.h | 17 +++ src/corelib/tools/qhash.h | 252 +++++++++++++++++++++++++++++--- src/xml/dom/qdom.cpp | 2 +- 3 files changed, 252 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index cfcd89333b..332828b21e 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -321,14 +321,31 @@ template <typename Container> QDataStream &writeAssociativeContainer(QDataStream &s, const Container &c) { s << quint32(c.size()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // Deserialization should occur in the reverse order. // Otherwise, value() will return the least recently inserted // value instead of the most recently inserted one. auto it = c.constEnd(); auto begin = c.constBegin(); while (it != begin) { + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED --it; + QT_WARNING_POP s << it.key() << it.value(); +#else + auto it = c.constBegin(); + auto end = c.constEnd(); + while (it != end) { + const auto rangeStart = it++; + while (it != end && rangeStart.key() == it.key()) + ++it; + const qint64 last = std::distance(rangeStart, it) - 1; + for (qint64 i = last; i >= 0; --i) { + auto next = std::next(rangeStart, i); + s << next.key() << next.value(); + } +#endif } return s; diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 236e433101..9108be4dc6 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -325,7 +325,11 @@ public: QHashData::Node *i; public: +#if QT_DEPRECATED_SINCE(5, 15) typedef std::bidirectional_iterator_tag iterator_category; +#else + typedef std::forward_iterator_tag iterator_category; +#endif typedef qptrdiff difference_type; typedef T value_type; typedef T *pointer; @@ -350,21 +354,25 @@ public: i = QHashData::nextNode(i); return r; } - inline iterator &operator--() { +#if QT_DEPRECATED_SINCE(5, 15) + inline QT_DEPRECATED iterator &operator--() + { i = QHashData::previousNode(i); return *this; } - inline iterator operator--(int) { + inline QT_DEPRECATED iterator operator--(int) + { iterator r = *this; i = QHashData::previousNode(i); return r; } - inline iterator operator+(int j) const + inline QT_DEPRECATED iterator operator+(int j) const { iterator r = *this; if (j > 0) while (j--) ++r; else while (j++) --r; return r; } - inline iterator operator-(int j) const { return operator+(-j); } - inline iterator &operator+=(int j) { return *this = *this + j; } - inline iterator &operator-=(int j) { return *this = *this - j; } - friend inline iterator operator+(int j, iterator k) { return k + j; } + inline QT_DEPRECATED iterator operator-(int j) const { return operator+(-j); } + inline QT_DEPRECATED iterator &operator+=(int j) { return *this = *this + j; } + inline QT_DEPRECATED iterator &operator-=(int j) { return *this = *this - j; } + friend inline QT_DEPRECATED iterator operator+(int j, iterator k) { return k + j; } +#endif #ifndef QT_STRICT_ITERATORS public: @@ -384,7 +392,11 @@ public: QHashData::Node *i; public: +#if QT_DEPRECATED_SINCE(5, 15) typedef std::bidirectional_iterator_tag iterator_category; +#else + typedef std::forward_iterator_tag iterator_category; +#endif typedef qptrdiff difference_type; typedef T value_type; typedef const T *pointer; @@ -416,21 +428,28 @@ public: i = QHashData::nextNode(i); return r; } - inline const_iterator &operator--() { +#if QT_DEPRECATED_SINCE(5, 15) + inline QT_DEPRECATED const_iterator &operator--() + { i = QHashData::previousNode(i); return *this; } - inline const_iterator operator--(int) { + inline QT_DEPRECATED const_iterator operator--(int) + { const_iterator r = *this; i = QHashData::previousNode(i); return r; } - inline const_iterator operator+(int j) const + inline QT_DEPRECATED const_iterator operator+(int j) const { const_iterator r = *this; if (j > 0) while (j--) ++r; else while (j++) --r; return r; } - inline const_iterator operator-(int j) const { return operator+(-j); } - inline const_iterator &operator+=(int j) { return *this = *this + j; } - inline const_iterator &operator-=(int j) { return *this = *this - j; } - friend inline const_iterator operator+(int j, const_iterator k) { return k + j; } + inline QT_DEPRECATED const_iterator operator-(int j) const { return operator+(-j); } + inline QT_DEPRECATED const_iterator &operator+=(int j) { return *this = *this + j; } + inline QT_DEPRECATED const_iterator &operator-=(int j) { return *this = *this - j; } + friend inline QT_DEPRECATED const_iterator operator+(int j, const_iterator k) + { + return k + j; + } +#endif // ### Qt 5: not sure this is necessary anymore #ifdef QT_STRICT_ITERATORS @@ -462,8 +481,14 @@ public: inline key_iterator &operator++() { ++i; return *this; } inline key_iterator operator++(int) { return key_iterator(i++);} - inline key_iterator &operator--() { --i; return *this; } - inline key_iterator operator--(int) { return key_iterator(i--); } +#if QT_DEPRECATED_SINCE(5, 15) + inline QT_DEPRECATED key_iterator &operator--() + { + --i; + return *this; + } + inline QT_DEPRECATED key_iterator operator--(int) { return key_iterator(i--); } +#endif const_iterator base() const { return i; } }; @@ -587,12 +612,31 @@ Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::unite(const QHash &other) if (d == &QHashData::shared_null) { *this = other; } else { +#if QT_DEPRECATED_SINCE(5, 15) QHash copy(other); const_iterator it = copy.constEnd(); while (it != copy.constBegin()) { + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED --it; + QT_WARNING_POP insertMulti(it.key(), it.value()); } +#else + QHash copy(other); + const_iterator it = copy.cbegin(); + const const_iterator end = copy.cend(); + while (it != end) { + const auto rangeStart = it++; + while (it != end && rangeStart.key() == it.key()) + ++it; + const qint64 last = std::distance(rangeStart, it) - 1; + for (qint64 i = last; i >= 0; --i) { + auto next = std::next(rangeStart, i); + insertMulti(next.key(), next.value()); + } + } +#endif } return *this; } @@ -1145,8 +1189,180 @@ Q_INLINE_TEMPLATE int QMultiHash<Key, T>::count(const Key &key, const T &value) return n; } -Q_DECLARE_ASSOCIATIVE_ITERATOR(Hash) -Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash) +template<class Key, class T> +class QHashIterator +{ + typedef typename QHash<Key, T>::const_iterator const_iterator; + typedef const_iterator Item; + QHash<Key, T> c; + const_iterator i, n; + inline bool item_exists() const { return n != c.constEnd(); } + +public: + inline QHashIterator(const QHash<Key, T> &container) + : c(container), i(c.constBegin()), n(c.constEnd()) + { + } + inline QHashIterator &operator=(const QHash<Key, T> &container) + { + c = container; + i = c.constBegin(); + n = c.constEnd(); + return *this; + } + inline void toFront() + { + i = c.constBegin(); + n = c.constEnd(); + } + inline void toBack() + { + i = c.constEnd(); + n = c.constEnd(); + } + inline bool hasNext() const { return i != c.constEnd(); } + inline Item next() + { + n = i++; + return n; + } + inline Item peekNext() const { return i; } + inline const T &value() const + { + Q_ASSERT(item_exists()); + return *n; + } + inline const Key &key() const + { + Q_ASSERT(item_exists()); + return n.key(); + } + inline bool findNext(const T &t) + { + while ((n = i) != c.constEnd()) + if (*i++ == t) + return true; + return false; + } +#if QT_DEPRECATED_SINCE(5, 15) + inline QT_DEPRECATED bool hasPrevious() const { return i != c.constBegin(); } + inline QT_DEPRECATED Item previous() + { + n = --i; + return n; + } + inline QT_DEPRECATED Item peekPrevious() const + { + const_iterator p = i; + return --p; + } + inline bool QT_DEPRECATED findPrevious(const T &t) + { + while (i != c.constBegin()) + if (*(n = --i) == t) + return true; + n = c.constEnd(); + return false; + } +#endif +}; + +template<class Key, class T> +class QMutableHashIterator +{ + typedef typename QHash<Key, T>::iterator iterator; + typedef typename QHash<Key, T>::const_iterator const_iterator; + typedef iterator Item; + QHash<Key, T> *c; + iterator i, n; + inline bool item_exists() const { return const_iterator(n) != c->constEnd(); } + +public: + inline QMutableHashIterator(QHash<Key, T> &container) : c(&container) + { + i = c->begin(); + n = c->end(); + } + inline QMutableHashIterator &operator=(QHash<Key, T> &container) + { + c = &container; + i = c->begin(); + n = c->end(); + return *this; + } + inline void toFront() + { + i = c->begin(); + n = c->end(); + } + inline void toBack() + { + i = c->end(); + n = c->end(); + } + inline bool hasNext() const { return const_iterator(i) != c->constEnd(); } + inline Item next() + { + n = i++; + return n; + } + inline Item peekNext() const { return i; } + inline void remove() + { + if (const_iterator(n) != c->constEnd()) { + i = c->erase(n); + n = c->end(); + } + } + inline void setValue(const T &t) + { + if (const_iterator(n) != c->constEnd()) + *n = t; + } + inline T &value() + { + Q_ASSERT(item_exists()); + return *n; + } + inline const T &value() const + { + Q_ASSERT(item_exists()); + return *n; + } + inline const Key &key() const + { + Q_ASSERT(item_exists()); + return n.key(); + } + inline bool findNext(const T &t) + { + while (const_iterator(n = i) != c->constEnd()) + if (*i++ == t) + return true; + return false; + } +#if QT_DEPRECATED_SINCE(5, 15) + inline QT_DEPRECATED bool hasPrevious() const { return const_iterator(i) != c->constBegin(); } + inline QT_DEPRECATED Item previous() + { + n = --i; + return n; + } + inline QT_DEPRECATED Item peekPrevious() const + { + iterator p = i; + return --p; + } + inline QT_DEPRECATED bool findPrevious(const T &t) + { + while (const_iterator(i) != c->constBegin()) + if (*(n = --i) == t) + return true; + n = c->end(); + return false; + } +#endif +}; template <class Key, class T> uint qHash(const QHash<Key, T> &key, uint seed = 0) diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index e3bf97d1a6..c71256457a 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -2648,7 +2648,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const { if (index >= length() || index < 0) return nullptr; - return *(map.constBegin() + index); + return *std::next(map.cbegin(), index); } int QDomNamedNodeMapPrivate::length() const -- cgit v1.2.3 From 2faccdf9a6586cb9b6f7bc276c39c814ab354003 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 3 Dec 2018 13:36:49 +0100 Subject: Don't insert multiple names for the same role It doesn't make a lot of sense to have two names for the same role. Use 'fileIcon' exclusively for the Qt::Decoration/ FileIconRole. Change-Id: Icaa46ba4aa61efc56ba007a14bab5e59ea26cd35 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/widgets/dialogs/qfilesystemmodel.cpp | 3 ++- src/widgets/itemviews/qdirmodel.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a04189513a..79a7c23e0d 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -2077,7 +2077,8 @@ void QFileSystemModelPrivate::init() #endif // filesystemwatcher q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); - roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QFileSystemModel::FileIconRole, + QByteArrayLiteral("fileIcon")); // == Qt::decoration roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath")); roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName")); roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions")); diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index ba7ee15314..c9e7c7b7a6 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1162,7 +1162,7 @@ void QDirModelPrivate::init() root.parent = 0; root.info = QFileInfo(); clear(&root); - roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath")); roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName")); } -- cgit v1.2.3 From 66b6e28c0158b8c4e96ddf08908a538d865ce63a Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 3 Dec 2018 13:43:03 +0100 Subject: Use QMultiHash::insert() instead of insertMulti() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5daeba708a9efcf60e92cfc9a04e80546e9ae6a2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/dbus/qdbusintegrator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 4c27a93382..28779a41d0 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -222,7 +222,7 @@ static dbus_bool_t qDBusAddWatch(DBusWatch *watch, void *data) watcher.write->setEnabled(q_dbus_watch_get_enabled(watch)); d->connect(watcher.write, &QSocketNotifier::activated, d, &QDBusConnectionPrivate::socketWrite); } - d->watchers.insertMulti(fd, watcher); + d->watchers.insert(fd, watcher); return true; } @@ -2245,7 +2245,7 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook } } - signalHooks.insertMulti(key, hook); + signalHooks.insert(key, hook); connect(hook.obj, &QObject::destroyed, this, &QDBusConnectionPrivate::objectDestroyed, Qt::ConnectionType(Qt::BlockingQueuedConnection | Qt::UniqueConnection)); -- cgit v1.2.3 From 7f0aaa88ef1db3840bd504d63a38d53032b8f802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Sun, 27 Oct 2019 18:57:56 +0100 Subject: macOS: Only skip screen reconfigure if primary screen changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia5d208ace5086e8e92f95f859383773894a18768 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit dcbe25bbbb603bc335d7cf0982a80293289b0d8f) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/platforms/cocoa/qcocoascreen.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 392099d083..16b11b3835 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -93,11 +93,10 @@ void QCocoaScreen::initializeScreens() mainDisplay->updateProperties(); qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay; QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay); + if (cocoaScreen == mainDisplay) + return; // Already reconfigured } - if (cocoaScreen == mainDisplay) - return; // Already reconfigured - cocoaScreen->updateProperties(); qCInfo(lcQpaScreen) << "Reconfigured" << cocoaScreen; } -- cgit v1.2.3 From bc4c2382aacbb33fad4a2d06fc631e4859f12a33 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Tue, 5 Nov 2019 10:15:59 +0100 Subject: QMdiArea: On macOS, render inactive subwindow controls grayed out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The controls were correctly grayed out when the entire window was not active, but inactive subwindows showed their controls in color, and only the titlebar had a slightly paler gradient to indicate that they are not active. MDI is not a concept on macOS and there is no clear style guide for how such windows are supposed to behave, but the look of the inactive titlebar before this change is too similar to the active state for it to be useful. This change restores the pre-5.11 state, prior to the removal of HITheme based styling in 8633e1a7b48f71e91f81ef5c667d6eb7a8db3adb. Change-Id: If009bf085a87fe2610d888636348dc8b13a93ec1 Fixes: QTBUG-79648 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 63dc49fd18..610329a350 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -5539,7 +5539,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex const auto ct = d->windowButtonCocoaControl(sc); const auto cw = QMacStylePrivate::CocoaControl(ct, QStyleHelper::SizeLarge); auto *wb = static_cast<NSButton *>(d->cocoaControl(cw)); - wb.enabled = (sc & titlebar->subControls); + wb.enabled = (sc & titlebar->subControls) && isActive; [wb highlight:(titlebar->state & State_Sunken) && (sc & titlebar->activeSubControls)]; Q_UNUSED(isHovered); // FIXME No public API for this -- cgit v1.2.3 From e5078714febaa72bf2f43b3a8ac9caec1c324129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20=C3=96lmann?= <u.oelmann@pengutronix.de> Date: Mon, 14 Oct 2019 12:12:24 +0200 Subject: qlibinputtouch: bugfix: do not skip touch events Having a platform with Texas Instruments's ADS7846 touch screen controller (NXP i.MX6 DualLite SoC) and a LOGIC Technologies Inc. LTTD800x480 L2RT 7" (800x480 pixels) TFT LCD panel attached to it (resistive touch) using Linux v5.2.17 and libinput-1.12.6 a single one finger touch starts with a LIBINPUT_EVENT_TOUCH_ DOWN directly followed by a LIBINPUT_EVENT_TOUCH_MOTION both having the same touch position. Now Qt's code for touch input processing compressed both into one touch point with state Qt::TouchPointStationary which resulted in QGuiApplicationPrivate:: processTouchEvent() seeing no touch points with state Qt::TouchPointPressed anymore. As a consequence processTouchEvent()'s local container windowsNeeding- Events stayed empty and the whole touch frame was skipped. Fix this by still compressing into one touch point, but keeping its state as Qt::TouchPointPressed. Fixes: QTBUG-79212 Change-Id: Ia571d79ec5c1d6143e923ed69b378503b53e5992 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/platformsupport/input/libinput/qlibinputtouch.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index a65bc91c39..ad85360b0e 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -113,16 +113,16 @@ void QLibInputTouch::processTouchMotion(libinput_event_touch *e) DeviceState *state = deviceState(e); QWindowSystemInterface::TouchPoint *tp = state->point(slot); if (tp) { + Qt::TouchPointState tmpState = Qt::TouchPointMoved; const QPointF p = getPos(e); - if (tp->area.center() != p) { + if (tp->area.center() == p) + tmpState = Qt::TouchPointStationary; + else tp->area.moveCenter(p); - // 'down' may be followed by 'motion' within the same "frame". - // Handle this by compressing and keeping the Pressed state until the 'frame'. - if (tp->state != Qt::TouchPointPressed) - tp->state = Qt::TouchPointMoved; - } else { - tp->state = Qt::TouchPointStationary; - } + // 'down' may be followed by 'motion' within the same "frame". + // Handle this by compressing and keeping the Pressed state until the 'frame'. + if (tp->state != Qt::TouchPointPressed && tp->state != Qt::TouchPointReleased) + tp->state = tmpState; } else { qWarning("Inconsistent touch state (got 'motion' without 'down')"); } -- cgit v1.2.3 From 88047be4ecb99799f4876ff3e7001abe34ac29bc Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 5 Nov 2019 07:49:48 +0100 Subject: QAbstractItemView: don't toggle selection on mouse move on some index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In single selection mode, the current selection toggled when the user pressed the left mouse + Ctrl key and then moved the mouse over the item. This was introduced with 28a21d98ef8d880a6dd86ee19dd803424bb5eae1 which added the possibility to deselect an item in single selection mode. Fix it by adding a check if the event was a mouse move event and use the old codepath for it. Fixes: QTBUG-77353 Change-Id: Id845ada302c92646885dfd966721b00d940f1260 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> --- src/widgets/itemviews/qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index c2afed775c..b1557e9af4 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3967,7 +3967,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM case SingleSelection: // ClearAndSelect on valid index otherwise NoUpdate if (event && event->type() == QEvent::MouseButtonRelease) return QItemSelectionModel::NoUpdate; - if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index)) + if ((keyModifiers & Qt::ControlModifier) && d->selectionModel->isSelected(index) && event->type() != QEvent::MouseMove) return QItemSelectionModel::Deselect | d->selectionBehaviorFlags(); else return QItemSelectionModel::ClearAndSelect | d->selectionBehaviorFlags(); -- cgit v1.2.3 From 4ada4f283efe4b2adcde29c2139dfc502c120399 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Tue, 5 Nov 2019 10:34:28 +0100 Subject: Make QDir::cleanPath documentation less misleading The code doesn't convert anything that might be a separator on other platforms (most notably, '\') to '/', it only replaces platform-native separators (i.e. '\' if running on Windows) with '/'. Change-Id: I2e241b88b8bd271dfa5d7db61402fe8ef9a6bb6f Fixes: QTBUG-79736 Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/io/qdir.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index fae935fc24..526702d151 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2372,8 +2372,9 @@ static QString qt_cleanPath(const QString &path, bool *ok) } /*! - Returns \a path with directory separators normalized (converted to "/") and - redundant ones removed, and "."s and ".."s resolved (as far as possible). + Returns \a path with directory separators normalized (that is, platform-native + separators converted to "/") and redundant ones removed, and "."s and ".."s + resolved (as far as possible). Symbolic links are kept. This function does not return the canonical path, but rather the simplest version of the input. -- cgit v1.2.3 From 5771b5325b85f71a8f8ff78ed13eaee3df2e3ba8 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Tue, 5 Nov 2019 22:10:24 +0100 Subject: syncqt: Add a means to suspend/resume the processing of a file Rather than tweaking the parser to cover every eventuality with corner case lines that could cause incorrect header files to be created then the means to suspend/resume the processing of a file is added. This enables us to have it skip over the template line that is causing a QList header to be created as part of the QtGui headers. This patch includes the fix to solve this in addition. Fixes: QTBUG-68129 Change-Id: I751646c4b20a4434347c149ae5e6dcb6e7618853 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- src/gui/kernel/qevent.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 2b1c6a6e31..0a8a1925e7 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -827,7 +827,14 @@ private: qint64 m_numericId; }; Q_DECLARE_TYPEINFO(QPointingDeviceUniqueId, Q_MOVABLE_TYPE); + +#if 0 +#pragma qt_sync_suspend_processing +#endif template <> class QList<QPointingDeviceUniqueId> {}; // to prevent instantiation: use QVector instead +#if 0 +#pragma qt_sync_resume_processing +#endif Q_GUI_EXPORT bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW; inline bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) Q_DECL_NOTHROW -- cgit v1.2.3 From b7858e9b4bdb2866f0c76ecaa8dd25bd9b618afc Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Wed, 9 Oct 2019 15:24:08 +0200 Subject: Add QPlatformPlaceholderScreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...and QPlatformScreen::isPlaceholder() This class can be used to reduce the amount of boiler-plate required to create a fake screen when there are no real screens (Qt doesn't currently support running with no QScreens). Change-Id: I7290406a3d010bcbaf15a1a8a84216e3abf75c78 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/kernel/qplatformscreen.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index d7378aed51..e27355a940 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -105,6 +105,8 @@ public: QPlatformScreen(); virtual ~QPlatformScreen(); + virtual bool isPlaceholder() const { return false; }; + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; virtual QRect geometry() const = 0; @@ -172,6 +174,16 @@ private: friend class QScreenPrivate; }; +// Qt doesn't currently support running with no platform screen +// QPA plugins can use this class to create a fake screen +class QPlatformPlaceholderScreen : public QPlatformScreen { + bool isPlaceholder() const override { return true; }; + QRect geometry() const override { return QRect(); } + QRect availableGeometry() const override { return QRect(); } + int depth() const override { return 32; } + QImage::Format format() const override { return QImage::Format::Format_RGB32; } +}; + QT_END_NAMESPACE #endif // QPLATFORMSCREEN_H -- cgit v1.2.3 From 7bf4f81de81b6e800509867d5acad545c566dbac Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 17 Sep 2019 19:53:55 +0200 Subject: Add qfloat16::copySign() since we can't overload std::copysign() Change-Id: Idfaf841b3eb3538f076ae4f0de2d7d029e1588fe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qfloat16.cpp | 8 ++++++++ src/corelib/global/qfloat16.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 6c21b7de5a..97709d7685 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -145,6 +145,14 @@ QT_BEGIN_NAMESPACE \sa qIsFinite() */ +/*! + \since 5.15 + \fn qfloat16::copySign(qfloat16 sign) const noexcept + + Returns a qfloat16 with the sign of \a sign but the rest of its value taken + from this qfloat16. Serves as qfloat16's equivalent of std::copysign(). +*/ + /*! \internal \since 5.14 diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 9a4f1800a4..c50fa36402 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -84,6 +84,9 @@ public: bool isNaN() const noexcept { return ((b16 >> 8) & 0x7e) == 0x7e; } bool isFinite() const noexcept { return ((b16 >> 8) & 0x7c) != 0x7c; } Q_CORE_EXPORT int fpClassify() const noexcept; + // Can't specialize std::copysign() for qfloat16 + qfloat16 copySign(qfloat16 sign) const noexcept + { return qfloat16(Wrap((sign.b16 & 0x8000) | (b16 & 0x7fff))); } // Support for std::numeric_limits<qfloat16> static constexpr qfloat16 _limit_epsilon() noexcept { return qfloat16(Wrap(0x1400)); } static constexpr qfloat16 _limit_min() noexcept { return qfloat16(Wrap(0x400)); } -- cgit v1.2.3 From 3c7df4a0ff91a833cf77e38ab8ccd65e289242e9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 17 Sep 2019 19:55:44 +0200 Subject: Add support for a signaling NaN in qfloat16 There was a comment saying what value does the job, so might as well put it to work. Change-Id: I47f1a8ce7ce889580f71aa784ccbcc227ebe0b23 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qfloat16.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index c50fa36402..154b200475 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -95,7 +95,9 @@ public: static constexpr qfloat16 _limit_lowest() noexcept { return qfloat16(Wrap(0xfbff)); } static constexpr qfloat16 _limit_infinity() noexcept { return qfloat16(Wrap(0x7c00)); } static constexpr qfloat16 _limit_quiet_NaN() noexcept { return qfloat16(Wrap(0x7e00)); } - // Signalling NaN is 0x7f00 +#if QT_CONFIG(signaling_nan) + static constexpr qfloat16 _limit_signaling_NaN() noexcept { return qfloat16(Wrap(0x7f00)); } +#endif inline constexpr bool isNormal() const noexcept { return (b16 & 0x7fff) == 0 || ((b16 & 0x7c00) && (b16 & 0x7c00) != 0x7c00); } private: @@ -330,6 +332,12 @@ public: { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_infinity(); } static constexpr QT_PREPEND_NAMESPACE(qfloat16) quiet_NaN() { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_quiet_NaN(); } +#if QT_CONFIG(signaling_nan) + static constexpr QT_PREPEND_NAMESPACE(qfloat16) signaling_NaN() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_signaling_NaN(); } +#else + static constexpr bool has_signaling_NaN = false; +#endif }; template<> class numeric_limits<const QT_PREPEND_NAMESPACE(qfloat16)> -- cgit v1.2.3 From 78ed3a12dbae70232711fd704e549ea0595ddd95 Mon Sep 17 00:00:00 2001 From: Mitch Curtis <mitch.curtis@qt.io> Date: Wed, 6 Nov 2019 14:31:23 +0100 Subject: Fix typo in QLoggingCategory documentation Change-Id: Id147e6f4c25a75eed5456390819f340d8d20172c Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> --- src/corelib/io/qloggingcategory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 89607d5a98..4a83780234 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -179,7 +179,7 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift) The \c QtProject/qtlogging.ini file is looked up in all directories returned by QStandardPaths::GenericConfigLocation. - Set the \c QT_LOGGING_DEBUG environment variable to find out where you logging + Set the \c QT_LOGGING_DEBUG environment variable to find out where your logging rules are loaded from. \section2 Installing a Custom Filter -- cgit v1.2.3 From ed20f3209804d865804f9eb14c3fcfb4b7941140 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Date: Fri, 25 Oct 2019 14:47:15 +0200 Subject: QHighDpiScaling: fix potential null pointer dereference It's not guaranteed that QPlatformScreen::screen should always return a valid pointer. Furthermore, you can run into this situation with, for example, two screens setup. Task-number: QTBUG-53022 Change-Id: Ic23bb2c30b1245f98a793a44cc5e0b39f9afac4b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/gui/kernel/qhighdpiscaling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 76548d5d86..704dcee633 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -657,7 +657,8 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen) // Check if there is a factor set on the screen object or associated // with the screen name. These are mutually exclusive, so checking // order is not significant. - QVariant byIndex = screen->screen()->property(scaleFactorProperty); + auto qScreen = screen->screen(); + auto byIndex = qScreen ? qScreen->property(scaleFactorProperty) : QVariant(); auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name()); if (byIndex.isValid()) { screenPropertyUsed = true; -- cgit v1.2.3 From fa2c9a27e2a4b6ce59823f2f3c6c53a57e7c037f Mon Sep 17 00:00:00 2001 From: Sona Kurazyan <sona.kurazyan@qt.io> Date: Thu, 24 Oct 2019 11:10:56 +0200 Subject: Move out the reusable part of QDomHandler to a new class QDomHandler implements methods for building the DOM tree. These methods can be reused also in the new QXmlStreamReader-based implementation. They are moved to a new QDomBuilder class and QDomHandler become a wrapper around it. Task-number: QTBUG-76178 Change-Id: I01956c209ae253b69c23f20d90a5befe7b5329a0 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/xml/dom/qdom.cpp | 6 +- src/xml/dom/qdomhelpers.cpp | 238 +++++++++++++++++++++++++++++++++----------- src/xml/dom/qdomhelpers_p.h | 90 +++++++++++++++-- 3 files changed, 265 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index c71256457a..75b7f8988c 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5728,11 +5728,11 @@ bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader if (!reader->parse(source)) { if (errorMsg) - *errorMsg = hnd.errorMsg; + *errorMsg = std::get<0>(hnd.errorInfo()); if (errorLine) - *errorLine = hnd.errorLine; + *errorLine = std::get<1>(hnd.errorInfo()); if (errorColumn) - *errorColumn = hnd.errorColumn; + *errorColumn = std::get<2>(hnd.errorInfo()); return false; } diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp index 74d2c8c124..bda6f8ef87 100644 --- a/src/xml/dom/qdomhelpers.cpp +++ b/src/xml/dom/qdomhelpers.cpp @@ -51,20 +51,161 @@ QT_BEGIN_NAMESPACE QDomHandler::QDomHandler(QDomDocumentPrivate *adoc, QXmlSimpleReader *areader, bool namespaceProcessing) - : errorLine(0), - errorColumn(0), - doc(adoc), - node(adoc), - cdata(false), - nsProcessing(namespaceProcessing), - locator(nullptr), - reader(areader) + : cdata(false), reader(areader), domBuilder(adoc, &locator, namespaceProcessing) { } QDomHandler::~QDomHandler() {} bool QDomHandler::endDocument() +{ + return domBuilder.endDocument(); +} + +bool QDomHandler::startDTD(const QString &name, const QString &publicId, const QString &systemId) +{ + return domBuilder.startDTD(name, publicId, systemId); +} + +bool QDomHandler::startElement(const QString &nsURI, const QString &, const QString &qName, + const QXmlAttributes &atts) +{ + return domBuilder.startElement(nsURI, qName, atts); +} + +bool QDomHandler::endElement(const QString &, const QString &, const QString &) +{ + return domBuilder.endElement(); +} + +bool QDomHandler::characters(const QString &ch) +{ + return domBuilder.characters(ch, cdata); +} + +bool QDomHandler::processingInstruction(const QString &target, const QString &data) +{ + return domBuilder.processingInstruction(target, data); +} + +bool QDomHandler::skippedEntity(const QString &name) +{ + // we can only handle inserting entity references into content + if (reader && !reader->d_ptr->skipped_entity_in_content) + return true; + + return domBuilder.skippedEntity(name); +} + +bool QDomHandler::fatalError(const QXmlParseException &exception) +{ + domBuilder.errorMsg = exception.message(); + domBuilder.errorLine = exception.lineNumber(); + domBuilder.errorColumn = exception.columnNumber(); + return QXmlDefaultHandler::fatalError(exception); +} + +bool QDomHandler::startCDATA() +{ + cdata = true; + return true; +} + +bool QDomHandler::endCDATA() +{ + cdata = false; + return true; +} + +bool QDomHandler::startEntity(const QString &name) +{ + return domBuilder.startEntity(name); +} + +bool QDomHandler::endEntity(const QString &) +{ + return domBuilder.endEntity(); +} + +bool QDomHandler::comment(const QString &ch) +{ + return domBuilder.comment(ch); +} + +bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, + const QString &systemId, const QString ¬ationName) +{ + return domBuilder.unparsedEntityDecl(name, publicId, systemId, notationName); +} + +bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicId, + const QString &systemId) +{ + return unparsedEntityDecl(name, publicId, systemId, QString()); +} + +bool QDomHandler::notationDecl(const QString &name, const QString &publicId, + const QString &systemId) +{ + return domBuilder.notationDecl(name, publicId, systemId); +} + +void QDomHandler::setDocumentLocator(QXmlLocator *locator) +{ + this->locator.setLocator(locator); +} + +QDomBuilder::ErrorInfo QDomHandler::errorInfo() const +{ + return domBuilder.error(); +} + +/************************************************************** + * + * QXmlDocumentLocators + * + **************************************************************/ + +void QSAXDocumentLocator::setLocator(QXmlLocator *l) +{ + locator = l; +} + +int QSAXDocumentLocator::column() const +{ + if (!locator) + return 0; + + return static_cast<int>(locator->columnNumber()); +} + +int QSAXDocumentLocator::line() const +{ + if (!locator) + return 0; + + return static_cast<int>(locator->lineNumber()); +} + +/************************************************************** + * + * QDomBuilder + * + **************************************************************/ + +QDomBuilder::QDomBuilder(QDomDocumentPrivate *d, QXmlDocumentLocator *l, bool namespaceProcessing) + : errorLine(0), + errorColumn(0), + doc(d), + node(d), + locator(l), + nsProcessing(namespaceProcessing) +{ +} + +QDomBuilder::~QDomBuilder() {} + +bool QDomBuilder::endDocument() { // ### is this really necessary? (rms) if (node != doc) @@ -72,7 +213,7 @@ bool QDomHandler::endDocument() return true; } -bool QDomHandler::startDTD(const QString &name, const QString &publicId, const QString &systemId) +bool QDomBuilder::startDTD(const QString &name, const QString &publicId, const QString &systemId) { doc->doctype()->name = name; doc->doctype()->publicId = publicId; @@ -80,7 +221,7 @@ bool QDomHandler::startDTD(const QString &name, const QString &publicId, const Q return true; } -bool QDomHandler::startElement(const QString &nsURI, const QString &, const QString &qName, +bool QDomBuilder::startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts) { // tag name @@ -94,24 +235,24 @@ bool QDomHandler::startElement(const QString &nsURI, const QString &, const QStr if (!n) return false; - n->setLocation(locator->lineNumber(), locator->columnNumber()); + n->setLocation(locator->line(), locator->column()); node->appendChild(n); node = n; // attributes for (int i = 0; i < atts.length(); i++) { - if (nsProcessing) { - ((QDomElementPrivate *)node)->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i)); - } else { - ((QDomElementPrivate *)node)->setAttribute(atts.qName(i), atts.value(i)); - } + auto domElement = static_cast<QDomElementPrivate *>(node); + if (nsProcessing) + domElement->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i)); + else + domElement->setAttribute(atts.qName(i), atts.value(i)); } return true; } -bool QDomHandler::endElement(const QString &, const QString &, const QString &) +bool QDomBuilder::endElement() { if (!node || node == doc) return false; @@ -120,7 +261,7 @@ bool QDomHandler::endElement(const QString &, const QString &, const QString &) return true; } -bool QDomHandler::characters(const QString &ch) +bool QDomBuilder::characters(const QString &characters, bool cdata) { // No text as child of some document if (node == doc) @@ -128,91 +269,79 @@ bool QDomHandler::characters(const QString &ch) QScopedPointer<QDomNodePrivate> n; if (cdata) { - n.reset(doc->createCDATASection(ch)); + n.reset(doc->createCDATASection(characters)); } else if (!entityName.isEmpty()) { QScopedPointer<QDomEntityPrivate> e( new QDomEntityPrivate(doc, nullptr, entityName, QString(), QString(), QString())); - e->value = ch; + e->value = characters; e->ref.deref(); doc->doctype()->appendChild(e.data()); e.take(); n.reset(doc->createEntityReference(entityName)); } else { - n.reset(doc->createTextNode(ch)); + n.reset(doc->createTextNode(characters)); } - n->setLocation(locator->lineNumber(), locator->columnNumber()); + n->setLocation(locator->line(), locator->column()); node->appendChild(n.data()); n.take(); return true; } -bool QDomHandler::processingInstruction(const QString &target, const QString &data) +bool QDomBuilder::processingInstruction(const QString &target, const QString &data) { QDomNodePrivate *n; n = doc->createProcessingInstruction(target, data); if (n) { - n->setLocation(locator->lineNumber(), locator->columnNumber()); + n->setLocation(locator->line(), locator->column()); node->appendChild(n); return true; } else return false; } -bool QDomHandler::skippedEntity(const QString &name) +bool QDomBuilder::skippedEntity(const QString &name) { - // we can only handle inserting entity references into content - if (reader && !reader->d_ptr->skipped_entity_in_content) - return true; - QDomNodePrivate *n = doc->createEntityReference(name); - n->setLocation(locator->lineNumber(), locator->columnNumber()); + n->setLocation(locator->line(), locator->column()); node->appendChild(n); return true; } -bool QDomHandler::fatalError(const QXmlParseException &exception) -{ - errorMsg = exception.message(); - errorLine = exception.lineNumber(); - errorColumn = exception.columnNumber(); - return QXmlDefaultHandler::fatalError(exception); -} - -bool QDomHandler::startCDATA() +void QDomBuilder::fatalError(const QString &message) { - cdata = true; - return true; + errorMsg = message; + errorLine = static_cast<int>(locator->line()); + errorColumn = static_cast<int>(locator->column()); } -bool QDomHandler::endCDATA() +QDomBuilder::ErrorInfo QDomBuilder::error() const { - cdata = false; - return true; + return ErrorInfo(errorMsg, errorLine, errorColumn); } -bool QDomHandler::startEntity(const QString &name) +bool QDomBuilder::startEntity(const QString &name) { entityName = name; return true; } -bool QDomHandler::endEntity(const QString &) +bool QDomBuilder::endEntity() { entityName.clear(); return true; } -bool QDomHandler::comment(const QString &ch) +bool QDomBuilder::comment(const QString &characters) { QDomNodePrivate *n; - n = doc->createComment(ch); - n->setLocation(locator->lineNumber(), locator->columnNumber()); + n = doc->createComment(characters); + n->setLocation(locator->line(), locator->column()); node->appendChild(n); return true; } -bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, +bool QDomBuilder::unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString ¬ationName) { QDomEntityPrivate *e = @@ -223,13 +352,13 @@ bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicI return true; } -bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicId, +bool QDomBuilder::externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) { return unparsedEntityDecl(name, publicId, systemId, QString()); } -bool QDomHandler::notationDecl(const QString &name, const QString &publicId, +bool QDomBuilder::notationDecl(const QString &name, const QString &publicId, const QString &systemId) { QDomNotationPrivate *n = new QDomNotationPrivate(doc, nullptr, name, publicId, systemId); @@ -239,9 +368,4 @@ bool QDomHandler::notationDecl(const QString &name, const QString &publicId, return true; } -void QDomHandler::setDocumentLocator(QXmlLocator *locator) -{ - this->locator = locator; -} - QT_END_NAMESPACE diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h index ee81f1f9ce..7647de65d2 100644 --- a/src/xml/dom/qdomhelpers_p.h +++ b/src/xml/dom/qdomhelpers_p.h @@ -58,6 +58,83 @@ QT_BEGIN_NAMESPACE class QDomDocumentPrivate; class QDomNodePrivate; +/************************************************************** + * + * QXmlDocumentLocators + * + **************************************************************/ + +/* TODO: QXmlDocumentLocator can be removed when the SAX-based + * implementation is removed. Right now it is needed for QDomBuilder + * to work with both QXmlStreamReader and QXmlInputSource (SAX) + * based implementations. + */ +class QXmlDocumentLocator +{ +public: + virtual ~QXmlDocumentLocator() = default; + virtual int column() const = 0; + virtual int line() const = 0; +}; + +class QSAXDocumentLocator : public QXmlDocumentLocator +{ +public: + ~QSAXDocumentLocator() override = default; + + int column() const override; + int line() const override; + + void setLocator(QXmlLocator *l); + +private: + QXmlLocator *locator = nullptr; +}; + +/************************************************************** + * + * QDomBuilder + * + **************************************************************/ + +class QDomBuilder +{ +public: + QDomBuilder(QDomDocumentPrivate *d, QXmlDocumentLocator *l, bool namespaceProcessing); + ~QDomBuilder(); + + bool endDocument(); + bool startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts); + bool endElement(); + bool characters(const QString &characters, bool cdata = false); + bool processingInstruction(const QString &target, const QString &data); + bool skippedEntity(const QString &name); + bool startEntity(const QString &name); + bool endEntity(); + bool startDTD(const QString &name, const QString &publicId, const QString &systemId); + bool comment(const QString &characters); + bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId); + bool notationDecl(const QString &name, const QString &publicId, const QString &systemId); + bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, + const QString ¬ationName); + + void fatalError(const QString &message); + + using ErrorInfo = std::tuple<QString, int, int>; + ErrorInfo error() const; + + QString errorMsg; + int errorLine; + int errorColumn; + +private: + QDomDocumentPrivate *doc; + QDomNodePrivate *node; + QXmlDocumentLocator *locator; + QString entityName; + bool nsProcessing; +}; + /************************************************************** * * QDomHandler @@ -68,7 +145,7 @@ class QDomHandler : public QXmlDefaultHandler { public: QDomHandler(QDomDocumentPrivate *d, QXmlSimpleReader *reader, bool namespaceProcessing); - ~QDomHandler(); + ~QDomHandler() override; // content handler bool endDocument() override; @@ -102,18 +179,13 @@ public: void setDocumentLocator(QXmlLocator *locator) override; - QString errorMsg; - int errorLine; - int errorColumn; + QDomBuilder::ErrorInfo errorInfo() const; private: - QDomDocumentPrivate *doc; - QDomNodePrivate *node; - QString entityName; bool cdata; - bool nsProcessing; - QXmlLocator *locator; QXmlSimpleReader *reader; + QSAXDocumentLocator locator; + QDomBuilder domBuilder; }; QT_END_NAMESPACE -- cgit v1.2.3 From 3916b8a28bc9c55e10f4de611ed76e17017494aa Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Thu, 24 Oct 2019 08:34:46 +0200 Subject: iOS: Account for UITextInteraction when building against 12.x or lower MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In iOS 13.0 we can handle UITextInteraction as normal, but in lower versions it is not available to utilize at compile time. So we have to check for the other types instead and return if it is not one of those. Change-Id: Icbc5558e677ed40c03f30a174e2d79b87f489f68 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/platforms/ios/quiview.mm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 4e3657ec37..91a186bace 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,17 +628,13 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) - (void)addInteraction:(id<UIInteraction>)interaction { - if (__builtin_available(iOS 13.0, *)) { - if ([interaction isKindOfClass:UITextInteraction.class]) - return; // Prevent iOS from adding UITextInteraction - } + if ([NSStringFromClass(interaction.class) isEqualToString:@"UITextInteraction"]) + return; [super addInteraction:interaction]; } -#endif @end -- cgit v1.2.3 From 1c4626f8309376b8ee661f172958a8698c269112 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 5 Nov 2019 16:15:04 +0100 Subject: Rationalize descriptions of date-time formats Document QDateTime's methods by reference to QDate and QTime, to avoid repetition. Use consistent descriptions between toString() and fromString(), in each case. Document the truth: various things were simply wrong, in at least some copies. Change-Id: Ie80017250cd470f65733f96d182ed7d043694f0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/time/qdatetime.cpp | 215 ++++++++++++----------------------------- 1 file changed, 61 insertions(+), 154 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 95a7255a04..878a2c1e46 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1213,25 +1213,25 @@ QString QDate::toString(Qt::DateFormat format) const \table \header \li Expression \li Output - \row \li d \li the day as number without a leading zero (1 to 31) - \row \li dd \li the day as number with a leading zero (01 to 31) + \row \li d \li The day as a number without a leading zero (1 to 31) + \row \li dd \li The day as a number with a leading zero (01 to 31) \row \li ddd - \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). + \li The abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses the system locale to localize the name, i.e. QLocale::system(). \row \li dddd - \li the long localized day name (e.g. 'Monday' to 'Sunday'). + \li The long localized day name (e.g. 'Monday' to 'Sunday'). Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li M \li the month as number without a leading zero (1 to 12) - \row \li MM \li the month as number with a leading zero (01 to 12) + \row \li M \li The month as a number without a leading zero (1 to 12) + \row \li MM \li The month as a number with a leading zero (01 to 12) \row \li MMM - \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). + \li The abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses the system locale to localize the name, i.e. QLocale::system(). \row \li MMMM - \li the long localized month name (e.g. 'January' to 'December'). + \li The long localized month name (e.g. 'January' to 'December'). Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li yy \li the year as two digit number (00 to 99) - \row \li yyyy \li the year as four digit number. If the year is negative, - a minus sign is prepended in addition. + \row \li yy \li The year as a two digit number (00 to 99) + \row \li yyyy \li The year as a four digit number. If the year is negative, + a minus sign is prepended, making five characters. \endtable Any sequence of characters enclosed in single quotes will be included @@ -1719,11 +1719,15 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format) \row \li MMMM \li The long localized month name (e.g. 'January' to 'December'). Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li yy \li The year as two digit number (00 to 99) - \row \li yyyy \li The year as four digit number. If the year is negative, - a minus sign is prepended in addition. + \row \li yy \li The year as a two digit number (00 to 99) + \row \li yyyy \li The year as a four digit number, possibly plus a leading + minus sign for negative years. \endtable + \note Unlike the other version of this function, day and month names must + be given in the user's local language. It is only possible to use the English + names if the user's language is English. + All other input characters will be treated as text. Any sequence of characters that are enclosed in single quotes will also be treated as text and will not be used as an expression. For example: @@ -2063,30 +2067,30 @@ QString QTime::toString(Qt::DateFormat format) const \table \header \li Expression \li Output \row \li h - \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \li The hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) \row \li hh - \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \li The hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) \row \li H - \li the hour without a leading zero (0 to 23, even with AM/PM display) + \li The hour without a leading zero (0 to 23, even with AM/PM display) \row \li HH - \li the hour with a leading zero (00 to 23, even with AM/PM display) - \row \li m \li the minute without a leading zero (0 to 59) - \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the whole second, without any leading zero (0 to 59) - \row \li ss \li the whole second, with a leading zero where applicable (00 to 59) - \row \li z \li the fractional part of the second, to go after a decimal + \li The hour with a leading zero (00 to 23, even with AM/PM display) + \row \li m \li The minute without a leading zero (0 to 59) + \row \li mm \li The minute with a leading zero (00 to 59) + \row \li s \li The whole second, without any leading zero (0 to 59) + \row \li ss \li The whole second, with a leading zero where applicable (00 to 59) + \row \li z \li The fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus "\c{s.z}" reports the seconds to full available (millisecond) precision without trailing zeroes. - \row \li zzz \li the fractional part of the second, to millisecond + \row \li zzz \li The fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999). \row \li AP or A - \li use AM/PM display. \e A/AP will be replaced by either - QLocale::amText() or QLocale::pmText(). + \li Use AM/PM display. \e A/AP will be replaced by an upper-case + version of either QLocale::amText() or QLocale::pmText(). \row \li ap or a - \li use am/pm display. \e a/ap will be replaced by a lower-case version of - QLocale::amText() or QLocale::pmText(). - \row \li t \li the timezone (for example "CEST") + \li Use am/pm display. \e a/ap will be replaced by a lower-case version + of either QLocale::amText() or QLocale::pmText(). + \row \li t \li The timezone (for example "CEST") \endtable Any sequence of characters enclosed in single quotes will be included @@ -2437,23 +2441,30 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format) \table \header \li Expression \li Output \row \li h - \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \li The hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) \row \li hh - \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \li m \li the minute without a leading zero (0 to 59) - \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the whole second, without any leading zero (0 to 59) - \row \li ss \li the whole second, with a leading zero where applicable (00 to 59) - \row \li z \li the fractional part of the second, to go after a decimal + \li The hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \row \li H + \li The hour without a leading zero (0 to 23, even with AM/PM display) + \row \li HH + \li The hour with a leading zero (00 to 23, even with AM/PM display) + \row \li m \li The minute without a leading zero (0 to 59) + \row \li mm \li The minute with a leading zero (00 to 59) + \row \li s \li The whole second, without any leading zero (0 to 59) + \row \li ss \li The whole second, with a leading zero where applicable (00 to 59) + \row \li z \li The fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus "\c{s.z}" reports the seconds to full available (millisecond) precision without trailing zeroes. - \row \li zzz \li the fractional part of the second, to millisecond + \row \li zzz \li The fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999). - \row \li AP - \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". - \row \li ap - \li Interpret as an AM/PM time. \e ap must be either "am" or "pm". + \row \li AP or A + \li Interpret as an AM/PM time. \e A/AP will match an upper-case + version of either QLocale::amText() or QLocale::pmText(). + \row \li ap or a + \li Interpret as an am/pm time. \e a/ap will match a lower-case version + of either QLocale::amText() or QLocale::pmText(). + \row \li t \li the timezone (for example "CEST") \endtable All other input characters will be treated as text. Any sequence @@ -4358,61 +4369,9 @@ QString QDateTime::toString(Qt::DateFormat format) const \fn QString QDateTime::toString(const QString &format) const \fn QString QDateTime::toString(QStringView format) const - Returns the datetime as a string. The \a format parameter - determines the format of the result string. - - These expressions may be used for the date: - - \table - \header \li Expression \li Output - \row \li d \li the day as number without a leading zero (1 to 31) - \row \li dd \li the day as number with a leading zero (01 to 31) - \row \li ddd - \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). - Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li dddd - \li the long localized day name (e.g. 'Monday' to 'Sunday'). - Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li M \li the month as number without a leading zero (1-12) - \row \li MM \li the month as number with a leading zero (01-12) - \row \li MMM - \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). - Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li MMMM - \li the long localized month name (e.g. 'January' to 'December'). - Uses the system locale to localize the name, i.e. QLocale::system(). - \row \li yy \li the year as two digit number (00-99) - \row \li yyyy \li the year as four digit number - \endtable - - These expressions may be used for the time: - - \table - \header \li Expression \li Output - \row \li h - \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) - \row \li hh - \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \li H - \li the hour without a leading zero (0 to 23, even with AM/PM display) - \row \li HH - \li the hour with a leading zero (00 to 23, even with AM/PM display) - \row \li m \li the minute without a leading zero (0 to 59) - \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the whole second without a leading zero (0 to 59) - \row \li ss \li the whole second with a leading zero where applicable (00 to 59) - \row \li z \li the fractional part of the second, to go after a decimal - point, without trailing zeroes (0 to 999). Thus "\c{s.z}" - reports the seconds to full available (millisecond) precision - without trailing zeroes. - \row \li zzz \li the fractional part of the second, to millisecond - precision, including trailing zeroes where applicable (000 to 999). - \row \li AP or A - \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM". - \row \li ap or a - \li use am/pm display. \e a/ap will be replaced by either "am" or "pm". - \row \li t \li the timezone (for example "CEST") - \endtable + Returns the datetime as a string. The \a format parameter determines the + format of the result string. See QTime::toString() and QDate::toString() for + the supported specifiers for time and date, respectively. Any sequence of characters enclosed in single quotes will be included verbatim in the output string (stripped of the quotes), even if it contains @@ -5409,65 +5368,13 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) Returns the QDateTime represented by the \a string, using the \a format given, or an invalid datetime if the string cannot be parsed. - Uses the calendar \a cal if supplied, else Gregorian. The illustrative - values and ranges below are given for the latter; other calendars may have - different ranges or values. - - These expressions may be used for the date part of the format string: - - \table - \header \li Expression \li Output - \row \li d \li the day as number without a leading zero (1 to 31) - \row \li dd \li the day as number with a leading zero (01 to 31) - \row \li ddd - \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). - \row \li dddd - \li the long localized day name (e.g. 'Monday' to 'Sunday'). - \row \li M \li the month as number without a leading zero (1-12) - \row \li MM \li the month as number with a leading zero (01-12) - \row \li MMM - \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). - \row \li MMMM - \li the long localized month name (e.g. 'January' to 'December'). - \row \li yy \li the year as two digit number (00-99) - \row \li yyyy \li the year as four digit number - \endtable - - \note Unlike the other version of this function, day and month names must - be given in the user's local language. It is only possible to use the English - names if the user's language is English. + Uses the calendar \a cal if supplied, else Gregorian. - These expressions may be used for the time part of the format string: - - \table - \header \li Expression \li Output - \row \li h - \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) - \row \li hh - \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \li H - \li the hour without a leading zero (0 to 23, even with AM/PM display) - \row \li HH - \li the hour with a leading zero (00 to 23, even with AM/PM display) - \row \li m \li the minute without a leading zero (0 to 59) - \row \li mm \li the minute with a leading zero (00 to 59) - \row \li s \li the whole second without a leading zero (0 to 59) - \row \li ss \li the whole second with a leading zero where applicable (00 to 59) - \row \li z \li the fractional part of the second, to go after a decimal - point, without trailing zeroes (0 to 999). Thus "\c{s.z}" - reports the seconds to full available (millisecond) precision - without trailing zeroes. - \row \li zzz \li the fractional part of the second, to millisecond - precision, including trailing zeroes where applicable (000 to 999). - \row \li AP or A - \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". - \row \li ap or a - \li Interpret as an AM/PM time. \e ap must be either "am" or "pm". - \endtable - - All other input characters will be treated as text. Any sequence - of characters that are enclosed in single quotes will also be - treated as text and not be used as an expression. + See QDate::fromString() and QTime::fromString() for the expressions + recognized in the format string to represent parts of the date and time. + All other input characters will be treated as text. Any sequence of + characters that are enclosed in single quotes will also be treated as text + and not be used as an expression. \snippet code/src_corelib_tools_qdatetime.cpp 12 -- cgit v1.2.3 From 52a3f1b00cca13767eefabf61742d2d802c56511 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Wed, 6 Nov 2019 10:04:54 +0100 Subject: Fix accuracy of ARGB32->A2RGB30 conversions It was converted over ARGB32PM, when it should have been directly converted to not lose accuracy, instead there was an unnecessary direct ARGB32->RGB30 conversion, which was converted to the necessary type. This also improves the selection of conversion over ARGB32PM or RGBA64PM for ARGB32 and RGBA8888 by using 32-bit conversion when alpha is not relevant. Change-Id: I5990d8a23b2909d3910d8c1213fa46477742b052 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/image/qimage.cpp | 25 ++----------- src/gui/image/qimage_conversions.cpp | 69 +++++++++++++++++++++--------------- src/gui/image/qimage_p.h | 23 ++++++++++++ 3 files changed, 67 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 2779b97fbd..d8ed0829af 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2060,27 +2060,6 @@ QImage::Format QImage::format() const \sa {Image Formats} */ -static bool highColorPrecision(QImage::Format format) -{ - // Formats with higher color precision than ARGB32_Premultiplied. - switch (format) { - case QImage::Format_ARGB32: - case QImage::Format_RGBA8888: - case QImage::Format_BGR30: - case QImage::Format_RGB30: - case QImage::Format_A2BGR30_Premultiplied: - case QImage::Format_A2RGB30_Premultiplied: - case QImage::Format_RGBX64: - case QImage::Format_RGBA64: - case QImage::Format_RGBA64_Premultiplied: - case QImage::Format_Grayscale16: - return true; - default: - break; - } - return false; -} - /*! \internal */ @@ -2092,9 +2071,11 @@ QImage QImage::convertToFormat_helper(Format format, Qt::ImageConversionFlags fl if (format == Format_Invalid || d->format == Format_Invalid) return QImage(); + const QPixelLayout *destLayout = &qPixelLayouts[format]; Image_Converter converter = qimage_converter_map[d->format][format]; if (!converter && format > QImage::Format_Indexed8 && d->format > QImage::Format_Indexed8) { - if (highColorPrecision(format) && highColorPrecision(d->format)) { + if (qt_highColorPrecision(d->format, !destLayout->hasAlphaChannel) + && qt_highColorPrecision(format, !hasAlphaChannel())) { converter = convert_generic_to_rgb64; } else converter = convert_generic; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 9e1df7058c..97a5f89e68 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -260,10 +260,17 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im if (data->depth != qt_depthForFormat(dst_format)) return false; - uint buf[BufferSize]; - uint *buffer = buf; const QPixelLayout *srcLayout = &qPixelLayouts[data->format]; const QPixelLayout *destLayout = &qPixelLayouts[dst_format]; + + // The precision here is only ARGB32PM so don't convert between higher accuracy + // formats (assert instead when we have a convert_generic_over_rgb64_inplace). + if (qt_highColorPrecision(data->format, !destLayout->hasAlphaChannel) + && qt_highColorPrecision(dst_format, !srcLayout->hasAlphaChannel)) + return false; + + uint buf[BufferSize]; + uint *buffer = buf; uchar *srcData = data->data; Q_ASSERT(srcLayout->bpp == destLayout->bpp); @@ -626,12 +633,13 @@ static bool convert_rgbswap_generic_inplace(QImageData *data, Qt::ImageConversio } template<QtPixelOrder PixelOrder, bool RGBA> -static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +static void convert_ARGB_to_A2RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) { - Q_ASSERT(RGBA || src->format == QImage::Format_RGB32 || src->format == QImage::Format_ARGB32); - Q_ASSERT(!RGBA || src->format == QImage::Format_RGBX8888 || src->format == QImage::Format_RGBA8888); - Q_ASSERT(dest->format == QImage::Format_BGR30 || dest->format == QImage::Format_RGB30); + Q_ASSERT(RGBA || src->format == QImage::Format_ARGB32); + Q_ASSERT(!RGBA || src->format == QImage::Format_RGBA8888); + Q_ASSERT(dest->format == QImage::Format_A2BGR30_Premultiplied + || dest->format == QImage::Format_A2RGB30_Premultiplied); Q_ASSERT(src->width == dest->width); Q_ASSERT(src->height == dest->height); @@ -646,7 +654,9 @@ static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::Im QRgb c = *src_data; if (RGBA) c = RGBA2ARGB(c); - *dest_data = qConvertRgb32ToRgb30<PixelOrder>(c); + const uint alpha = (qAlpha(c) >> 6) * 85; + c = BYTE_MUL(c, alpha); + *dest_data = (qConvertRgb32ToRgb30<PixelOrder>(c) & 0x3fffffff) | (alpha << 30); ++src_data; ++dest_data; } @@ -656,10 +666,10 @@ static void convert_RGB_to_RGB30(QImageData *dest, const QImageData *src, Qt::Im } template<QtPixelOrder PixelOrder, bool RGBA> -static bool convert_RGB_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFlags) +static bool convert_ARGB_to_A2RGB30_inplace(QImageData *data, Qt::ImageConversionFlags) { - Q_ASSERT(RGBA || (data->format == QImage::Format_RGB32 || data->format == QImage::Format_ARGB32)); - Q_ASSERT(!RGBA || (data->format == QImage::Format_RGBX8888 || data->format == QImage::Format_RGBA8888)); + Q_ASSERT(RGBA || data->format == QImage::Format_ARGB32); + Q_ASSERT(!RGBA || data->format == QImage::Format_RGBA8888); const int pad = (data->bytes_per_line >> 2) - data->width; QRgb *rgb_data = (QRgb *) data->data; @@ -670,13 +680,16 @@ static bool convert_RGB_to_RGB30_inplace(QImageData *data, Qt::ImageConversionFl QRgb c = *rgb_data; if (RGBA) c = RGBA2ARGB(c); - *rgb_data = qConvertRgb32ToRgb30<PixelOrder>(c); + const uint alpha = (qAlpha(c) >> 6) * 85; + c = BYTE_MUL(c, alpha); + *rgb_data = (qConvertRgb32ToRgb30<PixelOrder>(c) & 0x3fffffff) | (alpha << 30); ++rgb_data; } rgb_data += pad; } - data->format = (PixelOrder == PixelOrderRGB) ? QImage::Format_RGB30 : QImage::Format_BGR30; + data->format = (PixelOrder == PixelOrderRGB) ? QImage::Format_A2RGB30_Premultiplied + : QImage::Format_A2BGR30_Premultiplied; return true; } @@ -2353,9 +2366,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - convert_RGB_to_RGB30<PixelOrderBGR, false>, 0, - convert_RGB_to_RGB30<PixelOrderRGB, false>, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -2381,10 +2394,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_ARGB_to_RGBx, convert_ARGB_to_RGBA, 0, - convert_RGB_to_RGB30<PixelOrderBGR, false>, 0, - convert_RGB_to_RGB30<PixelOrderRGB, false>, + convert_ARGB_to_A2RGB30<PixelOrderBGR, false>, 0, + convert_ARGB_to_A2RGB30<PixelOrderRGB, false>, 0, 0, 0, convert_ARGB32_to_RGBA64<false>, @@ -2634,9 +2647,9 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, convert_passthrough, convert_passthrough, - convert_RGB_to_RGB30<PixelOrderBGR, true>, 0, - convert_RGB_to_RGB30<PixelOrderRGB, true>, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -2661,10 +2674,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat mask_alpha_converter_RGBx, 0, 0, - convert_RGB_to_RGB30<PixelOrderBGR, true>, 0, - convert_RGB_to_RGB30<PixelOrderRGB, true>, + convert_ARGB_to_A2RGB30<PixelOrderBGR, true>, 0, + convert_ARGB_to_A2RGB30<PixelOrderRGB, true>, 0, 0, 0, convert_ARGB32_to_RGBA64<true>, @@ -3017,9 +3030,9 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - convert_RGB_to_RGB30_inplace<PixelOrderBGR, false>, 0, - convert_RGB_to_RGB30_inplace<PixelOrderRGB, false>, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -3044,10 +3057,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_ARGB_to_RGBA_inplace<QImage::Format_RGBX8888>, convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888>, 0, - convert_RGB_to_RGB30_inplace<PixelOrderBGR, false>, 0, - convert_RGB_to_RGB30_inplace<PixelOrderRGB, false>, + convert_ARGB_to_A2RGB30_inplace<PixelOrderBGR, false>, 0, + convert_ARGB_to_A2RGB30_inplace<PixelOrderRGB, false>, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB32 @@ -3123,9 +3136,9 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, convert_passthrough_inplace<QImage::Format_RGBA8888>, convert_passthrough_inplace<QImage::Format_RGBA8888_Premultiplied>, - convert_RGB_to_RGB30_inplace<PixelOrderBGR, true>, 0, - convert_RGB_to_RGB30_inplace<PixelOrderRGB, true>, + 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -3150,10 +3163,10 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma mask_alpha_converter_rgbx_inplace, 0, 0, - convert_RGB_to_RGB30_inplace<PixelOrderBGR, true>, 0, - convert_RGB_to_RGB30_inplace<PixelOrderRGB, true>, + convert_ARGB_to_A2RGB30_inplace<PixelOrderBGR, true>, 0, + convert_ARGB_to_A2RGB30_inplace<PixelOrderRGB, true>, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGBA8888 diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 9e2d9c86bb..0930955f5a 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -276,6 +276,29 @@ inline QImage::Format qt_alphaVersion(QImage::Format format) return QImage::Format_ARGB32_Premultiplied; } +inline bool qt_highColorPrecision(QImage::Format format, bool opaque = false) +{ + // Formats with higher color precision than ARGB32_Premultiplied. + switch (format) { + case QImage::Format_ARGB32: + case QImage::Format_RGBA8888: + return !opaque; + case QImage::Format_BGR30: + case QImage::Format_RGB30: + case QImage::Format_A2BGR30_Premultiplied: + case QImage::Format_A2RGB30_Premultiplied: + case QImage::Format_RGBX64: + case QImage::Format_RGBA64: + case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_Grayscale16: + return true; + default: + break; + } + return false; +} + + inline QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format) { const QImage::Format toFormat = qt_alphaVersion(format); -- cgit v1.2.3 From 72f57cc84244633ca69ede9a1fd510b9b1881c1d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 6 Nov 2019 17:59:49 +0100 Subject: QWaitCondition: mark obsolete functions as deprecated Mark QWaitCondition:wait(..., ulong) as deprecated so they can be removed in Qt6. Also replace the usages of this deprecated functions inside QtCore. Change-Id: I77313255fa05f5c112b0b40d4c55339cc4f85346 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/thread/qreadwritelock.cpp | 4 ++-- src/corelib/thread/qthread_unix.cpp | 2 +- src/corelib/thread/qthreadpool.cpp | 2 +- src/corelib/thread/qwaitcondition.h | 20 ++++++++++-------- src/corelib/thread/qwaitcondition.qdoc | 34 ++++++++++++++++++++---------- src/corelib/thread/qwaitcondition_unix.cpp | 4 ++++ 6 files changed, 42 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 14654986a0..c8463de402 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -477,7 +477,7 @@ bool QReadWriteLockPrivate::lockForRead(int timeout) if (elapsed > timeout) return false; waitingReaders++; - readerCond.wait(&mutex, timeout - elapsed); + readerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed)); } else { waitingReaders++; readerCond.wait(&mutex); @@ -511,7 +511,7 @@ bool QReadWriteLockPrivate::lockForWrite(int timeout) return false; } waitingWriters++; - writerCond.wait(&mutex, timeout - elapsed); + writerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed)); } else { waitingWriters++; writerCond.wait(&mutex); diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index cb3c0d6bb1..b19922753a 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -765,7 +765,7 @@ bool QThread::wait(unsigned long time) return true; while (d->running) { - if (!d->thread_done.wait(locker.mutex(), time)) + if (!d->thread_done.wait(locker.mutex(), QDeadlineTimer(time))) return false; } return true; diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 4d2389f699..5f23a78c8a 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -136,7 +136,7 @@ void QThreadPoolThread::run() manager->waitingThreads.enqueue(this); registerThreadInactive(); // wait for work, exiting after the expiry timeout is reached - runnableReady.wait(locker.mutex(), manager->expiryTimeout); + runnableReady.wait(locker.mutex(), QDeadlineTimer(manager->expiryTimeout)); ++manager->activeThreads; if (manager->waitingThreads.removeOne(this)) expired = true; diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h index 11520e4cfe..86e2141f84 100644 --- a/src/corelib/thread/qwaitcondition.h +++ b/src/corelib/thread/qwaitcondition.h @@ -40,15 +40,12 @@ #ifndef QWAITCONDITION_H #define QWAITCONDITION_H -#include <QtCore/qglobal.h> - -#include <limits.h> +#include <QDeadlineTimer> QT_BEGIN_NAMESPACE #if QT_CONFIG(thread) -class QDeadlineTimer; class QWaitConditionPrivate; class QMutex; class QReadWriteLock; @@ -59,11 +56,16 @@ public: QWaitCondition(); ~QWaitCondition(); - // ### Qt 6: remove unsigned long overloads - bool wait(QMutex *lockedMutex, unsigned long time = ULONG_MAX); - bool wait(QMutex *lockedMutex, QDeadlineTimer deadline); - bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time = ULONG_MAX); - bool wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline); + bool wait(QMutex *lockedMutex, + QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever)); + bool wait(QReadWriteLock *lockedReadWriteLock, + QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever)); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead") + bool wait(QMutex *lockedMutex, unsigned long time); + QT_DEPRECATED_VERSION_X_5_15("Use wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) instead") + bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time); +#endif void wakeOne(); void wakeAll(); diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc index eebc28f059..9da6f6f25c 100644 --- a/src/corelib/thread/qwaitcondition.qdoc +++ b/src/corelib/thread/qwaitcondition.qdoc @@ -119,10 +119,22 @@ \sa wakeOne() */ +#if QT_DEPRECATED_SINCE(5, 15) /*! \fn bool QWaitCondition::wait(QMutex *lockedMutex, unsigned long time) + \obsolete use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead +*/ +/*! + \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, unsigned long time) + \obsolete use wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) instead +*/ +#endif - Releases the \a lockedMutex and waits on the wait condition. The +/*! + \fn bool QWaitCondition::wait(QMutex *lockedMutex, QDeadlineTimer deadline) + \since 5.12 + + Releases the \a lockedMutex and waits on the wait condition. The \a lockedMutex must be initially locked by the calling thread. If \a lockedMutex is not in a locked state, the behavior is undefined. If \a lockedMutex is a recursive mutex, this function @@ -132,10 +144,10 @@ \list \li Another thread signals it using wakeOne() or wakeAll(). This function will return true in this case. - \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX - (the default), then the wait will never timeout (the event - must be signalled). This function will return false if the - wait timed out. + \li the deadline given by \a deadline is reached. If \a deadline is + \c QDeadlineTimer::Forever (the default), then the wait will never + timeout (the event must be signalled). This function will return + false if the wait timed out. \endlist The \a lockedMutex will be returned to the same locked state. This @@ -146,8 +158,8 @@ */ /*! - \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, unsigned long time) - \since 4.4 + \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) + \since 5.12 Releases the \a lockedReadWriteLock and waits on the wait condition. The \a lockedReadWriteLock must be initially locked by the @@ -160,10 +172,10 @@ \list \li Another thread signals it using wakeOne() or wakeAll(). This function will return true in this case. - \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX - (the default), then the wait will never timeout (the event - must be signalled). This function will return false if the - wait timed out. + \li the deadline given by \a deadline is reached. If \a deadline is + \c QDeadlineTimer::Forever (the default), then the wait will never + timeout (the event must be signalled). This function will return + false if the wait timed out. \endlist The \a lockedReadWriteLock will be returned to the same locked diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index dd7475cec5..a8dfb9999c 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -202,12 +202,14 @@ void QWaitCondition::wakeAll() report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock"); } +#if QT_DEPRECATED_SINCE(5, 15) bool QWaitCondition::wait(QMutex *mutex, unsigned long time) { if (time == std::numeric_limits<unsigned long>::max()) return wait(mutex, QDeadlineTimer(QDeadlineTimer::Forever)); return wait(mutex, QDeadlineTimer(time)); } +#endif bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline) { @@ -229,12 +231,14 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline) return returnValue; } +#if QT_DEPRECATED_SINCE(5, 15) bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time) { if (time == std::numeric_limits<unsigned long>::max()) return wait(readWriteLock, QDeadlineTimer(QDeadlineTimer::Forever)); return wait(readWriteLock, QDeadlineTimer(time)); } +#endif bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline) { -- cgit v1.2.3 From ef54abae43db79792b40dfdca30ac0fa1b582354 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha <andre.rocha@qt.io> Date: Tue, 29 Oct 2019 20:42:00 +0100 Subject: Windows QPA: Fix missing update when the display is sleeping If an item was updated while the display was in sleep mode then when the display came back from sleep it would not be updated. This change detects when the display returns from sleep and repaints the windows to ensure the updated items are presented. Fixes: QTBUG-76307 Change-Id: I5fff5209e8a5c359d06ba1df61944690e9475ea6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/plugins/platforms/windows/qwindowscontext.cpp | 58 ++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscontext.h | 2 + .../platforms/windows/qwindowsintegration.cpp | 2 + 3 files changed, 62 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 38b9823d6b..5c1b00a1c9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -273,6 +273,8 @@ struct QWindowsContextPrivate { const HRESULT m_oleInitializeResult; QWindow *m_lastActiveWindow = nullptr; bool m_asyncExpose = false; + HPOWERNOTIFY m_powerNotification = nullptr; + HWND m_powerDummyWindow = nullptr; }; QWindowsContextPrivate::QWindowsContextPrivate() @@ -313,6 +315,13 @@ QWindowsContext::~QWindowsContext() #if QT_CONFIG(tabletevent) d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes. #endif + + if (d->m_powerNotification) + UnregisterPowerSettingNotification(d->m_powerNotification); + + if (d->m_powerDummyWindow) + DestroyWindow(d->m_powerDummyWindow); + unregisterWindowClasses(); if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE) OleUninitialize(); @@ -380,6 +389,55 @@ bool QWindowsContext::initPointer(unsigned integrationOptions) return true; } +extern "C" LRESULT QT_WIN_CALLBACK qWindowsPowerWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message != WM_POWERBROADCAST || wParam != PBT_POWERSETTINGCHANGE) + return DefWindowProc(hwnd, message, wParam, lParam); + + static bool initialized = false; // ignore the initial change + if (!initialized) { + initialized = true; + return DefWindowProc(hwnd, message, wParam, lParam); + } + + auto setting = reinterpret_cast<const POWERBROADCAST_SETTING *>(lParam); + if (setting) { + auto data = reinterpret_cast<const DWORD *>(&setting->Data); + if (*data == 1) { + // Repaint the windows when returning from sleeping display mode. + const auto tlw = QGuiApplication::topLevelWindows(); + for (auto w : tlw) { + if (w->isVisible() && w->windowState() != Qt::WindowMinimized) { + if (auto tw = QWindowsWindow::windowsWindowOf(w)) { + if (HWND hwnd = tw->handle()) { + InvalidateRect(hwnd, nullptr, false); + } + } + } + } + } + } + return DefWindowProc(hwnd, message, wParam, lParam); +} + +bool QWindowsContext::initPowerNotificationHandler() +{ + if (d->m_powerNotification) + return false; + + d->m_powerDummyWindow = createDummyWindow(QStringLiteral("QtPowerDummyWindow"), L"QtPowerDummyWindow", qWindowsPowerWindowProc); + if (!d->m_powerDummyWindow) + return false; + + d->m_powerNotification = RegisterPowerSettingNotification(d->m_powerDummyWindow, &GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE); + if (!d->m_powerNotification) { + DestroyWindow(d->m_powerDummyWindow); + d->m_powerDummyWindow = nullptr; + return false; + } + return true; +} + void QWindowsContext::setTabletAbsoluteRange(int a) { #if QT_CONFIG(tabletevent) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 4908f14629..04290379db 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -176,6 +176,8 @@ public: bool initTablet(unsigned integrationOptions); bool initPointer(unsigned integrationOptions); + bool initPowerNotificationHandler(); + int defaultDPI() const; QString registerWindowClass(const QWindow *w); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 5c1fa00088..849e6cf2d0 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -256,6 +256,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL m_context.initTouch(m_options); QPlatformCursor::setCapability(QPlatformCursor::OverrideCursor); + + m_context.initPowerNotificationHandler(); } QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() -- cgit v1.2.3 From a866055d18b2c2efc0f3cf5307d8eac78cce26eb Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Date: Wed, 6 Nov 2019 21:37:48 +0100 Subject: QHighDpiScaling: impove readability of screenSubfactor method Task-number: QTBUG-53022 Change-Id: Idae4379dd78d3125c375fad37a5a3af5bbcdc51e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/gui/kernel/qhighdpiscaling.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 704dcee633..0782a49481 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -644,7 +644,7 @@ QPoint QHighDpiScaling::mapPositionFromGlobal(const QPoint &pos, const QPoint &w qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen) { - qreal factor = qreal(1.0); + auto factor = qreal(1.0); if (!screen) return factor; @@ -657,15 +657,16 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen) // Check if there is a factor set on the screen object or associated // with the screen name. These are mutually exclusive, so checking // order is not significant. - auto qScreen = screen->screen(); - auto byIndex = qScreen ? qScreen->property(scaleFactorProperty) : QVariant(); - auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name()); - if (byIndex.isValid()) { - screenPropertyUsed = true; - factor = byIndex.toReal(); - } else if (byNameIt != qNamedScreenScaleFactors()->cend()) { - screenPropertyUsed = true; - factor = *byNameIt; + if (auto qScreen = screen->screen()) { + auto screenFactor = qScreen->property(scaleFactorProperty).toReal(&screenPropertyUsed); + if (screenPropertyUsed) + factor = screenFactor; + } + + if (!screenPropertyUsed) { + auto byNameIt = qNamedScreenScaleFactors()->constFind(screen->name()); + if ((screenPropertyUsed = byNameIt != qNamedScreenScaleFactors()->cend())) + factor = *byNameIt; } } -- cgit v1.2.3 From 3e529369eb16704aa0d601a7f4b8e490dc8b772c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Thu, 7 Nov 2019 08:45:27 +0100 Subject: Support MaximizeUsingFullscreenGeometryHint in resizeMaximizedWindows() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In QPlatformScreen there is a convenience function which resizes windows when the screen changes. This did not have support for MaximizeUsingFullscreenGeometryHint and would mistakenly resize these windows to the available geometry. Since not all QPA plugins support this hint, we have to add a capability flag to avoid changing behavior on platforms where it works as intended. Task-number: QTBUG-74202 Change-Id: Ife88f597fbb3affa722f63ac18fb5719ffa8ed33 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/kernel/qplatformintegration.h | 3 ++- src/gui/kernel/qplatformscreen.cpp | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d9f349555a..01406958e2 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -106,7 +106,8 @@ public: ApplicationIcon, SwitchableWidgetComposition, TopStackedNativeChildWindows, - OpenGLOnRasterSurface + OpenGLOnRasterSurface, + MaximizeUsingFullscreenGeometry }; virtual ~QPlatformIntegration() { } diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index f3213bf5ea..7daf48b191 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -410,15 +410,22 @@ void QPlatformScreen::resizeMaximizedWindows() const QRect newGeometry = deviceIndependentGeometry(); const QRect newAvailableGeometry = QHighDpi::fromNative(availableGeometry(), QHighDpiScaling::factor(this), newGeometry.topLeft()); + const bool supportsMaximizeUsingFullscreen = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MaximizeUsingFullscreenGeometry); + for (QWindow *w : windows()) { // Skip non-platform windows, e.g., offscreen windows. if (!w->handle()) continue; - if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) + if (supportsMaximizeUsingFullscreen + && w->windowState() & Qt::WindowMaximized + && w->flags() & Qt::MaximizeUsingFullscreenGeometryHint) { + w->setGeometry(newGeometry); + } else if (w->windowState() & Qt::WindowMaximized || w->geometry() == oldAvailableGeometry) { w->setGeometry(newAvailableGeometry); - else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) + } else if (w->windowState() & Qt::WindowFullScreen || w->geometry() == oldGeometry) { w->setGeometry(newGeometry); + } } } -- cgit v1.2.3 From 26f8adb1eefd1a8822413e036f2878b8cc1e7029 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha <andre.rocha@qt.io> Date: Thu, 7 Nov 2019 16:52:10 +0100 Subject: Windows QPA: Avoid returning UI Automation ValueProvider for static text Static text controls should not return a ValueProvider. Otherwise, Narrator reads out static texts and announces whether they are editable or not, which is confusing to users. It should only read out the text itself. Fixes: QTBUG-79613 Change-Id: I080cd6a5db10f6f673b50c40ac7d87c3737d9b55 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 5a05adbf81..96d64acc32 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -277,8 +277,9 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow } break; case UIA_ValuePatternId: - // All accessible controls return text(QAccessible::Value) (which may be empty). - *pRetVal = new QWindowsUiaValueProvider(id()); + // All non-static controls support the Value pattern. + if (accessible->role() != QAccessible::StaticText) + *pRetVal = new QWindowsUiaValueProvider(id()); break; case UIA_RangeValuePatternId: // Controls providing a numeric value within a range (e.g., sliders, scroll bars, dials). -- cgit v1.2.3 From c17a5cec1901dd23f4c39ec2ae47a060fbb06895 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Thu, 7 Nov 2019 08:57:59 +0100 Subject: Android: Implement MaximizeUsingFullscreenGeometryHint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This flag tells the app to use as much of the screen as possible while still keeping system UI visible, and can be supported on Android by using translucent system UI, similar to iOS. What this does: 1. It changes the current fullscreen/not-fullscreen logic to allow three states: fullscreen, fullscreen with translucent decorations and not-fullscreen. 2. In order for it to work, we have to send the actual screen geometry and available geometry, at least in the case where the user needs to know the available geometry to know the safe area of the window. So we get the real screen metrics and pass these to the QPA plugin (API level 17, so we can do that now that the minimum version is 21.) 3. Note that getting the insets and calculating the useable area does not work for non-fullscreen windows, since Android is quite inconsistent in this respect. So in this case we just use the window size and origin of 0,0 for the available geometry. 4. Since we are touching this code anyway, this patch also tries to use more consistent wording (calling it "available geometry" everywhere instead of desktop geometry in some places and just geometry in others, etc.) [ChangeLog][Android] Qt::MaximizeUsingFullscreenGeometryHint window flag is now supported, and will make the window fullscreen, but keep the system UI on-screen, with a translucent background color. Fixes: QTBUG-74202 Change-Id: I7a59a6c6fb51ebbdb86e7149e794726e67001279 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com> --- .../qtproject/qt5/android/QtActivityDelegate.java | 63 ++++++++++++-------- .../src/org/qtproject/qt5/android/QtLayout.java | 31 ++++++++-- .../src/org/qtproject/qt5/android/QtNative.java | 40 ++++++++----- .../qtproject/qt5/android/QtServiceDelegate.java | 2 +- src/plugins/platforms/android/androidjniinput.cpp | 4 +- src/plugins/platforms/android/androidjnimain.cpp | 69 +++++++++------------- src/plugins/platforms/android/androidjnimain.h | 13 ++-- .../android/qandroidplatformintegration.cpp | 54 ++++++++--------- .../android/qandroidplatformintegration.h | 28 ++++----- .../platforms/android/qandroidplatformscreen.cpp | 11 ++-- .../platforms/android/qandroidplatformwindow.cpp | 32 +++++++--- .../platforms/android/qandroidplatformwindow.h | 4 +- 12 files changed, 202 insertions(+), 149 deletions(-) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index 2df2ed9a1d..0db9441749 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -121,6 +121,10 @@ public class QtActivityDelegate private static final String EXTRACT_STYLE_KEY = "extract.android.style"; private static final String EXTRACT_STYLE_MINIMAL_KEY = "extract.android.style.option"; + public static final int SYSTEM_UI_VISIBILITY_NORMAL = 0; + public static final int SYSTEM_UI_VISIBILITY_FULLSCREEN = 1; + public static final int SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2; + private static String m_environmentVariables = null; private static String m_applicationParameters = null; @@ -131,7 +135,7 @@ public class QtActivityDelegate private long m_metaState; private int m_lastChar = 0; private int m_softInputMode = 0; - private boolean m_fullScreen = false; + private int m_systemUiVisibility = SYSTEM_UI_VISIBILITY_NORMAL; private boolean m_started = false; private HashMap<Integer, QtSurface> m_surfaces = null; private HashMap<Integer, View> m_nativeViews = null; @@ -153,38 +157,51 @@ public class QtActivityDelegate private CursorHandle m_rightSelectionHandle; private EditPopupMenu m_editPopupMenu; - public void setFullScreen(boolean enterFullScreen) + + public void setSystemUiVisibility(int systemUiVisibility) { - if (m_fullScreen == enterFullScreen) + if (m_systemUiVisibility == systemUiVisibility) return; - if (m_fullScreen = enterFullScreen) { + m_systemUiVisibility = systemUiVisibility; + + int systemUiVisibilityFlags = 0; + switch (m_systemUiVisibility) { + case SYSTEM_UI_VISIBILITY_NORMAL: + m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE; + break; + case SYSTEM_UI_VISIBILITY_FULLSCREEN: m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - try { - int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; - flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; - flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; - flags |= View.SYSTEM_UI_FLAG_FULLSCREEN; - flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").getInt(null); - m_activity.getWindow().getDecorView().setSystemUiVisibility(flags | View.INVISIBLE); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | View.INVISIBLE; + break; + case SYSTEM_UI_VISIBILITY_TRANSLUCENT: + m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN + | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION + | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - m_activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); - } + systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE; + break; + }; + + m_activity.getWindow().getDecorView().setSystemUiVisibility(systemUiVisibilityFlags); + m_layout.requestLayout(); } public void updateFullScreen() { - if (m_fullScreen) { - m_fullScreen = false; - setFullScreen(true); + if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) { + m_systemUiVisibility = SYSTEM_UI_VISIBILITY_NORMAL; + setSystemUiVisibility(SYSTEM_UI_VISIBILITY_FULLSCREEN); } } @@ -943,7 +960,7 @@ public class QtActivityDelegate } catch (Exception e) { e.printStackTrace(); } - outState.putBoolean("FullScreen", m_fullScreen); + outState.putInt("SystemUiVisibility", m_systemUiVisibility); outState.putBoolean("Started", m_started); // It should never } diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java index f22b8176c8..63993f81b5 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java @@ -46,6 +46,7 @@ import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; +import android.view.WindowInsets; public class QtLayout extends ViewGroup { @@ -69,10 +70,32 @@ public class QtLayout extends ViewGroup @Override protected void onSizeChanged (int w, int h, int oldw, int oldh) { - DisplayMetrics metrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, w, h, - metrics.xdpi, metrics.ydpi, metrics.scaledDensity, metrics.density); + WindowInsets insets = getRootWindowInsets(); + + DisplayMetrics realMetrics = new DisplayMetrics(); + ((Activity) getContext()).getWindowManager().getDefaultDisplay().getRealMetrics(realMetrics); + + boolean isFullScreenView = h == realMetrics.heightPixels; + + int insetLeft = isFullScreenView ? insets.getSystemWindowInsetLeft() : 0; + int insetTop = isFullScreenView ? insets.getSystemWindowInsetTop() : 0; + int insetRight = isFullScreenView ? insets.getSystemWindowInsetRight() : 0; + int insetBottom = isFullScreenView ? insets.getSystemWindowInsetBottom() : 0; + + int usableAreaWidth = w - insetLeft - insetRight; + int usableAreaHeight = h - insetTop - insetBottom; + + QtNative.setApplicationDisplayMetrics(realMetrics.widthPixels, + realMetrics.heightPixels, + insetLeft, + insetTop, + usableAreaWidth, + usableAreaHeight, + realMetrics.xdpi, + realMetrics.ydpi, + realMetrics.scaledDensity, + realMetrics.density); + if (m_startApplicationRunnable != null) { m_startApplicationRunnable.run(); m_startApplicationRunnable = null; diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 7db16002ff..dee5628144 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -91,8 +91,10 @@ public class QtNative private static boolean m_started = false; private static int m_displayMetricsScreenWidthPixels = 0; private static int m_displayMetricsScreenHeightPixels = 0; - private static int m_displayMetricsDesktopWidthPixels = 0; - private static int m_displayMetricsDesktopHeightPixels = 0; + private static int m_displayMetricsAvailableLeftPixels = 0; + private static int m_displayMetricsAvailableTopPixels = 0; + private static int m_displayMetricsAvailableWidthPixels = 0; + private static int m_displayMetricsAvailableHeightPixels = 0; private static double m_displayMetricsXDpi = .0; private static double m_displayMetricsYDpi = .0; private static double m_displayMetricsScaledDensity = 1.0; @@ -376,8 +378,10 @@ public class QtNative res[0] = startQtAndroidPlugin(qtParams, environment); setDisplayMetrics(m_displayMetricsScreenWidthPixels, m_displayMetricsScreenHeightPixels, - m_displayMetricsDesktopWidthPixels, - m_displayMetricsDesktopHeightPixels, + m_displayMetricsAvailableLeftPixels, + m_displayMetricsAvailableTopPixels, + m_displayMetricsAvailableWidthPixels, + m_displayMetricsAvailableHeightPixels, m_displayMetricsXDpi, m_displayMetricsYDpi, m_displayMetricsScaledDensity, @@ -398,8 +402,10 @@ public class QtNative public static void setApplicationDisplayMetrics(int screenWidthPixels, int screenHeightPixels, - int desktopWidthPixels, - int desktopHeightPixels, + int availableLeftPixels, + int availableTopPixels, + int availableWidthPixels, + int availableHeightPixels, double XDpi, double YDpi, double scaledDensity, @@ -415,8 +421,10 @@ public class QtNative if (m_started) { setDisplayMetrics(screenWidthPixels, screenHeightPixels, - desktopWidthPixels, - desktopHeightPixels, + availableLeftPixels, + availableTopPixels, + availableWidthPixels, + availableHeightPixels, XDpi, YDpi, scaledDensity, @@ -424,8 +432,10 @@ public class QtNative } else { m_displayMetricsScreenWidthPixels = screenWidthPixels; m_displayMetricsScreenHeightPixels = screenHeightPixels; - m_displayMetricsDesktopWidthPixels = desktopWidthPixels; - m_displayMetricsDesktopHeightPixels = desktopHeightPixels; + m_displayMetricsAvailableLeftPixels = availableLeftPixels; + m_displayMetricsAvailableTopPixels = availableTopPixels; + m_displayMetricsAvailableWidthPixels = availableWidthPixels; + m_displayMetricsAvailableHeightPixels = availableHeightPixels; m_displayMetricsXDpi = XDpi; m_displayMetricsYDpi = YDpi; m_displayMetricsScaledDensity = scaledDensity; @@ -686,13 +696,13 @@ public class QtNative }); } - private static void setFullScreen(final boolean fullScreen) + private static void setSystemUiVisibility(final int systemUiVisibility) { runAction(new Runnable() { @Override public void run() { if (m_activityDelegate != null) { - m_activityDelegate.setFullScreen(fullScreen); + m_activityDelegate.setSystemUiVisibility(systemUiVisibility); } updateWindow(); } @@ -1035,8 +1045,10 @@ public class QtNative // screen methods public static native void setDisplayMetrics(int screenWidthPixels, int screenHeightPixels, - int desktopWidthPixels, - int desktopHeightPixels, + int availableLeftPixels, + int availableTopPixels, + int availableWidthPixels, + int availableHeightPixels, double XDpi, double YDpi, double scaledDensity, diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java index 33bcb364de..4cceab50c7 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java @@ -115,7 +115,7 @@ public class QtServiceDelegate QtNative.setService(m_service, this); QtNative.setClassLoader(classLoader); - QtNative.setApplicationDisplayMetrics(10, 10, 10, 10, 120, 120, 1.0, 1.0); + QtNative.setApplicationDisplayMetrics(10, 10, 0, 0, 10, 10, 120, 120, 1.0, 1.0); if (loaderParams.containsKey(STATIC_INIT_CLASSES_KEY)) { for (String className: loaderParams.getStringArray(STATIC_INIT_CLASSES_KEY)) { diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 56885f2e23..049f9b0b13 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -247,8 +247,8 @@ namespace QtAndroidInput break; } - const int dw = desktopWidthPixels(); - const int dh = desktopHeightPixels(); + const int dw = availableWidthPixels(); + const int dh = availableHeightPixels(); QWindowSystemInterface::TouchPoint touchPoint; touchPoint.id = id; touchPoint.pressure = pressure; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index fd2644717e..bdbd3517bd 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -111,8 +111,8 @@ static int m_surfaceId = 1; static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr; -static int m_desktopWidthPixels = 0; -static int m_desktopHeightPixels = 0; +static int m_availableWidthPixels = 0; +static int m_availableHeightPixels = 0; static double m_scaledDensity = 0; static double m_density = 1.0; @@ -155,14 +155,14 @@ namespace QtAndroid : 0; } - int desktopWidthPixels() + int availableWidthPixels() { - return m_desktopWidthPixels; + return m_availableWidthPixels; } - int desktopHeightPixels() + int availableHeightPixels() { - return m_desktopHeightPixels; + return m_availableHeightPixels; } double scaledDensity() @@ -200,22 +200,9 @@ namespace QtAndroid return m_serviceObject; } - void showStatusBar() + void setSystemUiVisibility(SystemUiVisibility uiVisibility) { - if (m_statusBarShowing) - return; - - QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", false); - m_statusBarShowing = true; - } - - void hideStatusBar() - { - if (!m_statusBarShowing) - return; - - QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", true); - m_statusBarShowing = false; + QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setSystemUiVisibility", "(I)V", jint(uiVisibility)); } jobject createBitmap(QImage img, JNIEnv *env) @@ -620,35 +607,33 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, } static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, - jint widthPixels, jint heightPixels, - jint desktopWidthPixels, jint desktopHeightPixels, + jint screenWidthPixels, jint screenHeightPixels, + jint availableLeftPixels, jint availableTopPixels, + jint availableWidthPixels, jint availableHeightPixels, jdouble xdpi, jdouble ydpi, jdouble scaledDensity, jdouble density) { - // Android does not give us the correct screen size for immersive mode, but - // the surface does have the right size - - widthPixels = qMax(widthPixels, desktopWidthPixels); - heightPixels = qMax(heightPixels, desktopHeightPixels); - - m_desktopWidthPixels = desktopWidthPixels; - m_desktopHeightPixels = desktopHeightPixels; + m_availableWidthPixels = availableWidthPixels; + m_availableHeightPixels = availableHeightPixels; m_scaledDensity = scaledDensity; m_density = density; QMutexLocker lock(&m_platformMutex); if (!m_androidPlatformIntegration) { - QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels, - desktopHeightPixels, - qRound(double(widthPixels) / xdpi * 25.4), - qRound(double(heightPixels) / ydpi * 25.4), - widthPixels, - heightPixels); + QAndroidPlatformIntegration::setDefaultDisplayMetrics(availableLeftPixels, + availableTopPixels, + availableWidthPixels, + availableHeightPixels, + qRound(double(screenWidthPixels) / xdpi * 25.4), + qRound(double(screenHeightPixels) / ydpi * 25.4), + screenWidthPixels, + screenHeightPixels); } else { - m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4), - qRound(double(heightPixels) / ydpi * 25.4)); - m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels); - m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); + m_androidPlatformIntegration->setPhysicalSize(qRound(double(screenWidthPixels) / xdpi * 25.4), + qRound(double(screenHeightPixels) / ydpi * 25.4)); + m_androidPlatformIntegration->setScreenSize(screenWidthPixels, screenHeightPixels); + m_androidPlatformIntegration->setAvailableGeometry(QRect(availableLeftPixels, availableTopPixels, + availableWidthPixels, availableHeightPixels)); } } @@ -774,7 +759,7 @@ static JNINativeMethod methods[] = { {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"waitForServiceSetup", "()V", (void *)waitForServiceSetup}, - {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, + {"setDisplayMetrics", "(IIIIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"updateWindow", "()V", (void *)updateWindow}, {"updateApplicationState", "(I)V", (void *)updateApplicationState}, diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 17ae30a1be..63be5910f9 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -77,8 +77,8 @@ namespace QtAndroid void bringChildToBack(int surfaceId); QWindow *topLevelWindowAt(const QPoint &globalPos); - int desktopWidthPixels(); - int desktopHeightPixels(); + int availableWidthPixels(); + int availableHeightPixels(); double scaledDensity(); double pixelDensity(); JavaVM *javaVM(); @@ -88,8 +88,13 @@ namespace QtAndroid jobject activity(); jobject service(); - void showStatusBar(); - void hideStatusBar(); + // Keep synchronized with flags in ActivityDelegate.java + enum SystemUiVisibility { + SYSTEM_UI_VISIBILITY_NORMAL = 0, + SYSTEM_UI_VISIBILITY_FULLSCREEN = 1, + SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2 + }; + void setSystemUiVisibility(SystemUiVisibility uiVisibility); jobject createBitmap(QImage img, JNIEnv *env = 0); jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index e0c437be27..48f330680b 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -76,12 +76,9 @@ QT_BEGIN_NAMESPACE -int QAndroidPlatformIntegration::m_defaultGeometryWidth = 320; -int QAndroidPlatformIntegration::m_defaultGeometryHeight = 455; -int QAndroidPlatformIntegration::m_defaultScreenWidth = 320; -int QAndroidPlatformIntegration::m_defaultScreenHeight = 455; -int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth = 50; -int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; +QSize QAndroidPlatformIntegration::m_defaultScreenSize = QSize(320, 455); +QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry = QRect(0, 0, 320, 455); +QSize QAndroidPlatformIntegration::m_defaultPhysicalSize = QSize(50, 71); Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; @@ -174,9 +171,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen = new QAndroidPlatformScreen(); QWindowSystemInterface::handleScreenAdded(m_primaryScreen); - m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); - m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); + m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); + m_primaryScreen->setSize(m_defaultScreenSize); + m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); m_mainThread = QThread::currentThread(); @@ -266,6 +263,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity(); case RasterGLSurface: return QtAndroid::activity(); case TopStackedNativeChildWindows: return false; + case MaximizeUsingFullscreenGeometry: return true; default: return QPlatformIntegration::hasCapability(cap); } @@ -415,20 +413,19 @@ QPlatformTheme *QAndroidPlatformIntegration::createPlatformTheme(const QString & return 0; } -void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int screenWidth, int screenHeight) +void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int availableLeft, + int availableTop, + int availableWidth, + int availableHeight, + int physicalWidth, + int physicalHeight, + int screenWidth, + int screenHeight) { - m_defaultGeometryWidth = gw; - m_defaultGeometryHeight = gh; - m_defaultPhysicalSizeWidth = sw; - m_defaultPhysicalSizeHeight = sh; - m_defaultScreenWidth = screenWidth; - m_defaultScreenHeight = screenHeight; -} - -void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh) -{ - m_defaultGeometryWidth = gw; - m_defaultGeometryHeight = gh; + m_defaultAvailableGeometry = QRect(availableLeft, availableTop, + availableWidth, availableHeight); + m_defaultPhysicalSize = QSize(physicalWidth, physicalHeight); + m_defaultScreenSize = QSize(screenWidth, screenHeight); } void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation, @@ -440,10 +437,9 @@ void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation cur void QAndroidPlatformIntegration::flushPendingUpdates() { - m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, - m_defaultPhysicalSizeHeight)); - m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); + m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); + m_primaryScreen->setSize(m_defaultScreenSize); + m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); } #ifndef QT_NO_ACCESSIBILITY @@ -453,13 +449,13 @@ QPlatformAccessibility *QAndroidPlatformIntegration::accessibility() const } #endif -void QAndroidPlatformIntegration::setDesktopSize(int width, int height) +void QAndroidPlatformIntegration::setAvailableGeometry(const QRect &availableGeometry) { if (m_primaryScreen) - QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height))); + QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, availableGeometry)); } -void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height) +void QAndroidPlatformIntegration::setPhysicalSize(int width, int height) { if (m_primaryScreen) QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height))); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index c795c499bc..d607ec0064 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -91,8 +91,8 @@ public: QAndroidPlatformScreen *screen() { return m_primaryScreen; } QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; - virtual void setDesktopSize(int width, int height); - virtual void setDisplayMetrics(int width, int height); + void setAvailableGeometry(const QRect &availableGeometry); + void setPhysicalSize(int width, int height); void setScreenSize(int width, int height); bool isVirtualDesktop() { return true; } @@ -116,16 +116,17 @@ public: QStringList themeNames() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; - static void setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int width, int height); - static void setDefaultDesktopSize(int gw, int gh); + static void setDefaultDisplayMetrics(int availableLeft, + int availableTop, + int availableWidth, + int availableHeight, + int physicalWidth, + int physicalHeight, + int screenWidth, + int screenHeight); static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, Qt::ScreenOrientation nativeOrientation); - static QSize defaultDesktopSize() - { - return QSize(m_defaultGeometryWidth, m_defaultGeometryHeight); - } - QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } @@ -143,12 +144,9 @@ private: QThread *m_mainThread; - static int m_defaultGeometryWidth; - static int m_defaultGeometryHeight; - static int m_defaultPhysicalSizeWidth; - static int m_defaultPhysicalSizeHeight; - static int m_defaultScreenWidth; - static int m_defaultScreenHeight; + static QRect m_defaultAvailableGeometry; + static QSize m_defaultPhysicalSize; + static QSize m_defaultScreenSize; static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_nativeOrientation; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 80757c2135..5f8486a7a2 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -90,8 +90,8 @@ private: QAndroidPlatformScreen::QAndroidPlatformScreen() : QObject(), QPlatformScreen() { - m_availableGeometry = QRect(0, 0, QAndroidPlatformIntegration::m_defaultGeometryWidth, QAndroidPlatformIntegration::m_defaultGeometryHeight); - m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight); + m_availableGeometry = QAndroidPlatformIntegration::m_defaultAvailableGeometry; + m_size = QAndroidPlatformIntegration::m_defaultScreenSize; // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // is way much faster than 32 if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { @@ -101,8 +101,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen() m_format = QImage::Format_ARGB32_Premultiplied; m_depth = 32; } - m_physicalSize.setHeight(QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight); - m_physicalSize.setWidth(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth); + m_physicalSize = QAndroidPlatformIntegration::m_defaultPhysicalSize; connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QAndroidPlatformScreen::applicationStateChanged); } @@ -294,7 +293,7 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w) if (w != 0) { QAndroidPlatformWindow *platformWindow = static_cast<QAndroidPlatformWindow *>(w->handle()); if (platformWindow != 0) - platformWindow->updateStatusBarVisibility(); + platformWindow->updateSystemUiVisibility(); } } @@ -334,7 +333,7 @@ void QAndroidPlatformScreen::doRedraw() } QMutexLocker lock(&m_surfaceMutex); if (m_id == -1 && m_rasterSurfaces) { - m_id = QtAndroid::createSurface(this, m_availableGeometry, true, m_depth); + m_id = QtAndroid::createSurface(this, geometry(), true, m_depth); AndroidDeadlockProtector protector; if (!protector.acquire()) return; diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index 4f691ce112..a88cb9b823 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -67,25 +67,39 @@ void QAndroidPlatformWindow::lower() void QAndroidPlatformWindow::raise() { - updateStatusBarVisibility(); + updateSystemUiVisibility(); platformScreen()->raise(this); } +QMargins QAndroidPlatformWindow::safeAreaMargins() const +{ + if ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint)) { + QRect availableGeometry = platformScreen()->availableGeometry(); + return QMargins(availableGeometry.left(), availableGeometry.top(), + availableGeometry.right(), availableGeometry.bottom()); + } else { + return QPlatformWindow::safeAreaMargins(); + } +} + void QAndroidPlatformWindow::setGeometry(const QRect &rect) { + QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); } void QAndroidPlatformWindow::setVisible(bool visible) { if (visible) - updateStatusBarVisibility(); + updateSystemUiVisibility(); if (visible) { - if (m_windowState & Qt::WindowFullScreen) + if ((m_windowState & Qt::WindowFullScreen) + || ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint))) { setGeometry(platformScreen()->geometry()); - else if (m_windowState & Qt::WindowMaximized) + } else if (m_windowState & Qt::WindowMaximized) { setGeometry(platformScreen()->availableGeometry()); + } } if (visible) @@ -107,7 +121,7 @@ void QAndroidPlatformWindow::setWindowState(Qt::WindowStates state) m_windowState = state; if (window()->isVisible()) - updateStatusBarVisibility(); + updateSystemUiVisibility(); } void QAndroidPlatformWindow::setWindowFlags(Qt::WindowFlags flags) @@ -143,15 +157,17 @@ void QAndroidPlatformWindow::requestActivateWindow() platformScreen()->topWindowChanged(window()); } -void QAndroidPlatformWindow::updateStatusBarVisibility() +void QAndroidPlatformWindow::updateSystemUiVisibility() { Qt::WindowFlags flags = window()->flags(); bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window; if (!isNonRegularWindow) { if (m_windowState & Qt::WindowFullScreen) - QtAndroid::hideStatusBar(); + QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_FULLSCREEN); + else if (flags & Qt::MaximizeUsingFullscreenGeometryHint) + QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_TRANSLUCENT); else - QtAndroid::showStatusBar(); + QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_NORMAL); } } diff --git a/src/plugins/platforms/android/qandroidplatformwindow.h b/src/plugins/platforms/android/qandroidplatformwindow.h index d8eb6b7b7f..f83ad7bea3 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.h +++ b/src/plugins/platforms/android/qandroidplatformwindow.h @@ -70,9 +70,11 @@ public: QAndroidPlatformScreen *platformScreen() const; + QMargins safeAreaMargins() const override; + void propagateSizeHints() override; void requestActivateWindow() override; - void updateStatusBarVisibility(); + void updateSystemUiVisibility(); inline bool isRaster() const { if (isForeignWindow()) return false; -- cgit v1.2.3 From f0a43a9def456784fd9408e3026d6689c8b715c1 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Thu, 7 Nov 2019 12:18:22 +0100 Subject: Make QPlatformPlaceholderScreen a sibling of other screens This is how the fake screen currently behaves in the xcb plugin. So if we are to deduplicate, it's probably best to match current behavior first. I still left an option for not being a virtual sibling in case other platforms don't support showing a window on a placeholder screen. Task-number: QTBUG-79711 Change-Id: I4e8b44d892efb85fdb003f1d473d0867442d7e4e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/kernel/qplatformscreen.cpp | 14 ++++++++++++++ src/gui/kernel/qplatformscreen.h | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 7daf48b191..e511a6f5c4 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -616,4 +616,18 @@ int QPlatformScreen::preferredMode() const return 0; } +QList<QPlatformScreen *> QPlatformPlaceholderScreen::virtualSiblings() const +{ + QList<QPlatformScreen *> siblings; + + if (!m_virtualSibling) + return siblings; + + for (QScreen *screen : QGuiApplication::screens()) { + if (screen->handle() && screen->handle() != this) + siblings << screen->handle(); + } + return siblings; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index e27355a940..0be7646032 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -105,7 +105,7 @@ public: QPlatformScreen(); virtual ~QPlatformScreen(); - virtual bool isPlaceholder() const { return false; }; + virtual bool isPlaceholder() const { return false; } virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; @@ -176,12 +176,23 @@ private: // Qt doesn't currently support running with no platform screen // QPA plugins can use this class to create a fake screen -class QPlatformPlaceholderScreen : public QPlatformScreen { - bool isPlaceholder() const override { return true; }; +class Q_GUI_EXPORT QPlatformPlaceholderScreen : public QPlatformScreen { +public: + // virtualSibling can be passed in to make the placeholder a sibling with other screens during + // the transitioning phase when the real screen is about to be removed, or the first real screen + // is about to be added. This is useful because Qt will currently recreate (but now show!) + // windows when they are moved from one virtual desktop to another, so if the last monitor is + // unplugged, then plugged in again, windows will be hidden unless the placeholder belongs to + // the same virtual desktop as the other screens. + QPlatformPlaceholderScreen(bool virtualSibling = true) : m_virtualSibling(virtualSibling) {} + bool isPlaceholder() const override { return true; } QRect geometry() const override { return QRect(); } QRect availableGeometry() const override { return QRect(); } int depth() const override { return 32; } QImage::Format format() const override { return QImage::Format::Format_RGB32; } + QList<QPlatformScreen *> virtualSiblings() const override; +private: + bool m_virtualSibling = true; }; QT_END_NAMESPACE -- cgit v1.2.3 From 576c8126ab569020b6396134570190525567e36f Mon Sep 17 00:00:00 2001 From: Simon Hausmann <simon.hausmann@qt.io> Date: Wed, 23 Oct 2019 16:58:26 +0200 Subject: Avoid erroneous creation of QScopedValueRollback objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark the class as [[nodiscard]] to ensure that instances are given names and do not destruct (roll back) immediately. This avoids accidental code like this: QScopedValueRollback<Foo>(bar, baz); which rolls back instantly, when it should be QScopedValueRollback<Foo> blah(bar, baz); which rolls back at the end of the scope. Change-Id: I00269fe325b804078bd0a9d5058c941af7ba5597 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/tools/qscopedvaluerollback.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index f904b8dfcb..b8ceff6665 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -45,7 +45,11 @@ QT_BEGIN_NAMESPACE template <typename T> -class QScopedValueRollback +class +#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && __cplusplus >= 201703L +[[nodiscard]] +#endif +QScopedValueRollback { public: explicit QScopedValueRollback(T &var) -- cgit v1.2.3 From 8f2db974ab594125301aac62594510e146125cb4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 1 Nov 2019 11:15:32 +0100 Subject: Windows QPA: Fix wrong scaling of fixed size in window creation phase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a fixed size the window is moved to another screen by QPlatformWindow::initialGeometry(), the size constraints would be incorrectly scaled using the initial screen in the handling of WM_GETMINMAXINFO. To fix this, pass the resulting screen out of QPlatformWindow::initialGeometry() and use it during the window creation phase. Fixes: QTBUG-77307 Change-Id: I149a2a65e816da841a32abc14a495925bf9cc6f6 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/gui/kernel/qplatformwindow.cpp | 9 ++++-- src/gui/kernel/qplatformwindow.h | 6 ++-- src/plugins/platforms/windows/qwindowswindow.cpp | 35 +++++++++++++++++------- src/plugins/platforms/windows/qwindowswindow.h | 10 +++++-- 4 files changed, 44 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 2a0cb1094c..65accc9f68 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -694,9 +694,12 @@ static QSize fixInitialSize(QSize size, const QWindow *w, However if the given window already has geometry which the application has initialized, it takes priority. */ -QRect QPlatformWindow::initialGeometry(const QWindow *w, - const QRect &initialGeometry, int defaultWidth, int defaultHeight) +QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeometry, + int defaultWidth, int defaultHeight, + const QScreen **resultingScreenReturn) { + if (resultingScreenReturn) + *resultingScreenReturn = w->screen(); if (!w->isTopLevel()) { const qreal factor = QHighDpiScaling::factor(w); const QSize size = fixInitialSize(QHighDpi::fromNative(initialGeometry.size(), factor), @@ -712,6 +715,8 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, : QGuiApplication::screenAt(initialGeometry.center()); if (!screen) return initialGeometry; + if (resultingScreenReturn) + *resultingScreenReturn = screen; // initialGeometry refers to window's screen QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); if (wp->resizeAutomatic) diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 4d48cc2f13..b6aeb3a86a 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE class QPlatformScreen; class QPlatformWindowPrivate; +class QScreen; class QWindow; class QIcon; class QRegion; @@ -142,8 +143,9 @@ public: virtual void invalidateSurface(); - static QRect initialGeometry(const QWindow *w, - const QRect &initialGeometry, int defaultWidth, int defaultHeight); + static QRect initialGeometry(const QWindow *w, const QRect &initialGeometry, + int defaultWidth, int defaultHeight, + const QScreen **resultingScreenReturn = nullptr); virtual void requestUpdate(); bool hasPendingUpdateRequest() const; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a4f4099aa6..ea91e3bb2d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -759,7 +759,10 @@ QWindowsWindowData const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w); - const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, defaultWindowWidth, defaultWindowHeight); + const QScreen *screen{}; + const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, + defaultWindowWidth, defaultWindowHeight, + &screen); if (title.isEmpty() && (result.flags & Qt::WindowTitleHint)) title = topLevel ? qAppName() : w->objectName(); @@ -769,7 +772,9 @@ QWindowsWindowData // Capture events before CreateWindowEx() returns. The context is cleared in // the QWindowsWindow constructor. - const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle)); + const QWindowCreationContextPtr context(new QWindowCreationContext(w, screen, data.geometry, + rect, data.customMargins, + style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME)); @@ -879,10 +884,10 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang // Scaling helpers for size constraints. -static QSize toNativeSizeConstrained(QSize dip, const QWindow *w) +static QSize toNativeSizeConstrained(QSize dip, const QScreen *s) { if (QHighDpiScaling::isActive()) { - const qreal factor = QHighDpiScaling::factor(w); + const qreal factor = QHighDpiScaling::factor(s); if (!qFuzzyCompare(factor, qreal(1))) { if (dip.width() > 0 && dip.width() < QWINDOWSIZE_MAX) dip.setWidth(qRound(qreal(dip.width()) * factor)); @@ -995,11 +1000,12 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co return true; } -void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins &margins, +void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QScreen *screen, + const QMargins &margins, QSize *minimumSize, QSize *maximumSize) { - *minimumSize = toNativeSizeConstrained(w->minimumSize(), w); - *maximumSize = toNativeSizeConstrained(w->maximumSize(), w); + *minimumSize = toNativeSizeConstrained(w->minimumSize(), screen); + *maximumSize = toNativeSizeConstrained(w->maximumSize(), screen); const int maximumWidth = qMax(maximumSize->width(), minimumSize->width()); const int maximumHeight = qMax(maximumSize->height(), minimumSize->height()); @@ -1017,12 +1023,13 @@ void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins } void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, + const QScreen *screen, const QMargins &margins, MINMAXINFO *mmi) { QSize minimumSize; QSize maximumSize; - frameSizeConstraints(w, margins, &minimumSize, &maximumSize); + frameSizeConstraints(w, screen, margins, &minimumSize, &maximumSize); qCDebug(lcQpaWindows).nospace() << '>' << __FUNCTION__ << '<' << " min=" << minimumSize.width() << ',' << minimumSize.height() << " max=" << maximumSize.width() << ',' << maximumSize.height() @@ -1041,6 +1048,13 @@ void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, qCDebug(lcQpaWindows).nospace() << '<' << __FUNCTION__ << " out " << *mmi; } +void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, + const QMargins &margins, + MINMAXINFO *mmi) +{ + applyToMinMaxInfo(w, w->screen(), margins, mmi); +} + bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w) { return qt_window_private(const_cast<QWindow *>(w))->positionPolicy @@ -1226,11 +1240,12 @@ void QWindowsForeignWindow::setVisible(bool visible) \ingroup qt-lighthouse-win */ -QWindowCreationContext::QWindowCreationContext(const QWindow *w, +QWindowCreationContext::QWindowCreationContext(const QWindow *w, const QScreen *s, const QRect &geometryIn, const QRect &geometry, const QMargins &cm, DWORD style, DWORD exStyle) : window(w), + screen(s), requestedGeometryIn(geometryIn), requestedGeometry(geometry), obtainedPos(geometryIn.topLeft()), @@ -1270,7 +1285,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, void QWindowCreationContext::applyToMinMaxInfo(MINMAXINFO *mmi) const { - QWindowsGeometryHint::applyToMinMaxInfo(window, margins + customMargins, mmi); + QWindowsGeometryHint::applyToMinMaxInfo(window, screen, margins + customMargins, mmi); } /*! diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 7efbcf900c..1f8800272b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -66,9 +66,12 @@ struct QWindowsGeometryHint static QMargins frame(const QWindow *w, const QRect &geometry, DWORD style, DWORD exStyle); static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result); + static void applyToMinMaxInfo(const QWindow *w, const QScreen *screen, + const QMargins &margins, MINMAXINFO *mmi); static void applyToMinMaxInfo(const QWindow *w, const QMargins &margins, MINMAXINFO *mmi); - static void frameSizeConstraints(const QWindow *w, const QMargins &margins, + static void frameSizeConstraints(const QWindow *w, const QScreen *screen, + const QMargins &margins, QSize *minimumSize, QSize *maximumSize); static inline QPoint mapToGlobal(HWND hwnd, const QPoint &); static inline QPoint mapToGlobal(const QWindow *w, const QPoint &); @@ -80,13 +83,16 @@ struct QWindowsGeometryHint struct QWindowCreationContext { - explicit QWindowCreationContext(const QWindow *w, + explicit QWindowCreationContext(const QWindow *w, const QScreen *s, const QRect &geometryIn, const QRect &geometry, const QMargins &customMargins, DWORD style, DWORD exStyle); void applyToMinMaxInfo(MINMAXINFO *mmi) const; const QWindow *window; + // The screen to use to scale size constraints, etc. Might differ from the + // screen of the window after QPlatformWindow::initialGeometry() (QTBUG-77307). + const QScreen *screen; QRect requestedGeometryIn; // QWindow scaled QRect requestedGeometry; // after QPlatformWindow::initialGeometry() QPoint obtainedPos; -- cgit v1.2.3 From b81863cfad1ca1e5825eaffb50a9b2fe2da51c7f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Thu, 7 Nov 2019 20:35:32 +0100 Subject: QWaitCondition: fix dummy QWaitCondition implementation The dummy implementation of QWaitCondition which is used when the thread feature is not available lacks some functions which were recently added. So we have to add them now. Change-Id: I32720e0857a1bd3fcf0e70078404a38dd8a8ca88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/thread/qwaitcondition.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h index 86e2141f84..079049af25 100644 --- a/src/corelib/thread/qwaitcondition.h +++ b/src/corelib/thread/qwaitcondition.h @@ -40,7 +40,7 @@ #ifndef QWAITCONDITION_H #define QWAITCONDITION_H -#include <QDeadlineTimer> +#include <QtCore/QDeadlineTimer> QT_BEGIN_NAMESPACE @@ -82,21 +82,28 @@ private: #else class QMutex; +class QReadWriteLock; + class Q_CORE_EXPORT QWaitCondition { public: QWaitCondition() {} ~QWaitCondition() {} - bool wait(QMutex *mutex, unsigned long time = ULONG_MAX) - { - Q_UNUSED(mutex); - Q_UNUSED(time); - return true; - } + bool wait(QMutex *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever)) + { return true; } + bool wait(QReadWriteLock *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever)) + { return true; } +#if QT_DEPRECATED_SINCE(5, 15) + bool wait(QMutex *, unsigned long) { return true; } + bool wait(QReadWriteLock *, unsigned long) { return true; } +#endif void wakeOne() {} void wakeAll() {} + + void notify_one() { wakeOne(); } + void notify_all() { wakeAll(); } }; #endif // QT_CONFIG(thread) -- cgit v1.2.3 From 004e3e0dc2cab4a4534d2ed3ace41aad6bfbe45d Mon Sep 17 00:00:00 2001 From: Ryan Chu <ryan.chu@qt.io> Date: Wed, 21 Aug 2019 16:18:07 +0200 Subject: Make Qt aware of NTFS Junctions on Windows On NTFS, a junction point can be created and deleted by the mklink and rmdir commands, respectively. If a directory is not identified correctly as a junction, then applications will likely try to remove it using recursive methods, leading to fatal data loss. With this change, Qt can identify file system entries as junctions, allowing applications to use the correct file system operation to remove it. The test needs to delay the cleaning up of junctions and files it creates until the checks are complete; since they might fail and make the test function return prematurely, use a scope guard. [ChangeLog][QtCore][QFileInfo] Add QFileInfo::isJunction so that applications can recognize NTFS file system entries as junctions Task-number: QTBUG-75869 Change-Id: I3c208245afbd9fb7555515fb776ff63b133ca858 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/corelib/io/qfileinfo.cpp | 19 +++++++++++++++++++ src/corelib/io/qfileinfo.h | 1 + src/corelib/io/qfilesystemmetadata_p.h | 16 +++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 89834de29f..93696c1320 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1145,6 +1145,25 @@ bool QFileInfo::isShortcut() const [d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); }); } + +/*! + Returns \c true if the object points to a junction; + otherwise returns \c false. + + Junctions only exist on Windows' NTFS file system, and are typically + created by the \c{mklink} command. They can be thought of as symlinks for + directories, and can only be created for absolute paths on the local + volume. +*/ +bool QFileInfo::isJunction() const +{ + Q_D(const QFileInfo); + return d->checkAttribute<bool>( + QFileSystemMetaData::LegacyLinkType, + [d]() { return d->metaData.isJunction(); }, + [d]() { return d->getFileFlags(QAbstractFileEngine::LinkType); }); +} + /*! Returns \c true if the object points to a directory or to a symbolic link to a directory, and that directory is the root directory; otherwise diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index 3ac028085a..7c7ff56ae4 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -113,6 +113,7 @@ public: bool isSymLink() const; bool isSymbolicLink() const; bool isShortcut() const; + bool isJunction() const; bool isRoot() const; bool isBundle() const; diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 81f4b3ba13..275a4bf8d0 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -111,8 +111,10 @@ public: AliasType = 0x0, #endif #if defined(Q_OS_WIN) + JunctionType = 0x04000000, WinLnkType = 0x08000000, // Note: Uses the same position for AliasType on Mac #else + JunctionType = 0x0, WinLnkType = 0x0, #endif SequentialType = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag @@ -205,8 +207,10 @@ public: bool wasDeleted() const { return (entryFlags & WasDeletedAttribute); } #if defined(Q_OS_WIN) bool isLnkFile() const { return (entryFlags & WinLnkType); } + bool isJunction() const { return (entryFlags & JunctionType); } #else bool isLnkFile() const { return false; } + bool isJunction() const { return false; } #endif qint64 size() const { return size_; } @@ -356,9 +360,15 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo if (setLinkType) { knownFlagsMask |= LinkType; entryFlags &= ~LinkType; - if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) - && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { - entryFlags |= LinkType; + if (fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) { + if (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK) { + entryFlags |= LinkType; +#if defined(IO_REPARSE_TAG_MOUNT_POINT) + } else if ((fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) + && (findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { + entryFlags |= JunctionType; +#endif + } } } } -- cgit v1.2.3 From bf131e8d2181b3404f5293546ed390999f760404 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Fri, 8 Nov 2019 11:30:40 +0100 Subject: Do not load plugin from the $PWD I see no reason why this would make sense to look for plugins in the current directory. And when there are plugins there, it may actually be wrong Change-Id: I5f5aa168021fedddafce90effde0d5762cd0c4c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/plugin/qpluginloader.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index cadff4f32b..c2443dbdda 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -305,7 +305,6 @@ static QString locatePlugin(const QString& fileName) paths.append(fileName.left(slash)); // don't include the '/' } else { paths = QCoreApplication::libraryPaths(); - paths.prepend(QStringLiteral(".")); // search in current dir first } for (const QString &path : qAsConst(paths)) { -- cgit v1.2.3 From 32d8f5310bffdeae30a500e2c0d6bbb59d795f0c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Thu, 7 Nov 2019 17:03:34 +0100 Subject: eglfs: kms: Allow overriding plane ids per crtc With atomic enabled (QT_QPA_EGLFS_KMS_ATOMIC=1) the plane chosen for a crtc becomes important. The current logic is pretty broken when there are multiple planes available with many of them marked as being supported by multiple CRTCs. Choosing the same plane for multiple crtcs results in failing the atomic commit. This happens with a RPi4 with two screens connected, for example. (because there are 2*3 planes: one primary, one overlay, one cursor for each screen, but Qt is trying to use the same primary plane with both CRTCs) The issue does not surface in special environments where there is one (dedicated) plane per crtc exposed by drm, but becomes apparent on a PC or on the RPi where the setup described above is the common case. As a temporary solution allow doing the following: export QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS="49,28:78,57" This would then force using plane id 28 for crtc id 49, and plane id 57 for crtc id 78. (the ids can be discovered either from the eglfs debug logs, or by checking /sys/kernel/debug/dri/<N>/state) This is to be complemented with a fix for picking a unique primary plane for all CRTCs but that's going to be a separate patch. Allowing a manual override is important regardless since it helps troubleshooting. Task-number: QTBUG-74953 Change-Id: Ie03f80dac31813f2c4489235d435769dd3d3883e Reviewed-by: Johan Helsing <johan.helsing@qt.io> --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 6121faf362..263c02682d 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -490,8 +490,30 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, } } - if (output.eglfs_plane) - qCDebug(qLcKmsDebug, "Output eglfs plane is: %d", output.eglfs_plane->id); + // A more useful version: allows specifying "crtc_id,plane_id:crtc_id,plane_id:..." + // in order to allow overriding the plane used for a given crtc. + if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS")) { + const QString val = qEnvironmentVariable("QT_QPA_EGLFS_KMS_PLANES_FOR_CRTCS"); + qCDebug(qLcKmsDebug, "crtc_id:plane_id override list: %s", qPrintable(val)); + const QStringList crtcPlanePairs = val.split(QLatin1Char(':')); + for (const QString &crtcPlanePair : crtcPlanePairs) { + const QStringList values = crtcPlanePair.split(QLatin1Char(',')); + if (values.count() == 2 && uint(values[0].toInt()) == output.crtc_id) { + uint planeId = values[1].toInt(); + for (const QKmsPlane &kmsplane : qAsConst(m_planes)) { + if (kmsplane.id == planeId) { + output.eglfs_plane = (QKmsPlane*)&kmsplane; + break; + } + } + } + } + } + + if (output.eglfs_plane) { + qCDebug(qLcKmsDebug, "Chose plane %u for output %s (crtc id %u) (may not be applicable)", + output.eglfs_plane->id, connectorName.constData(), output.crtc_id); + } m_crtc_allocator |= (1 << output.crtc_index); -- cgit v1.2.3 From 2f81ad9d746a4949d7fd76e2aa26c2281fac5d53 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Fri, 8 Nov 2019 10:18:10 +0100 Subject: eglfs: kms: Choose unique primary planes for each crtc Otherwise we end up with using the same plane for multiple crtcs, which fails (with atomic - planes have no importance when atomic is not enabled). This fixes systems where we run with atomic enabled and there are multiple primary planes with their possible_crtcs matching multiple crtcs. Task-number: QTBUG-74953 Change-Id: I8bcbdd389265d09f8851187881102fb5b9a83b5c Reviewed-by: Johan Helsing <johan.helsing@qt.io> --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 37 ++++++++++++++++++----- src/platformsupport/kmsconvenience/qkmsdevice_p.h | 2 ++ 2 files changed, 31 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 263c02682d..90437117aa 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -176,6 +176,15 @@ static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode) return true; } +static inline void assignPlane(QKmsOutput *output, QKmsPlane *plane) +{ + if (output->eglfs_plane) + output->eglfs_plane->activeCrtcId = 0; + + plane->activeCrtcId = output->crtc_id; + output->eglfs_plane = plane; +} + QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, ScreenInfo *vinfo) @@ -449,13 +458,16 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, #endif QString planeListStr; - for (const QKmsPlane &plane : qAsConst(m_planes)) { + for (QKmsPlane &plane : m_planes) { if (plane.possibleCrtcs & (1 << output.crtc_index)) { output.available_planes.append(plane); planeListStr.append(QString::number(plane.id)); planeListStr.append(QLatin1Char(' ')); - if (plane.type == QKmsPlane::PrimaryPlane) - output.eglfs_plane = (QKmsPlane*)&plane; + + // Choose the first primary plane that is not already assigned to + // another screen's associated crtc. + if (!output.eglfs_plane && plane.type == QKmsPlane::PrimaryPlane && !plane.activeCrtcId) + assignPlane(&output, &plane); } } qCDebug(qLcKmsDebug, "Output %s can use %d planes: %s", @@ -477,9 +489,11 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, qCDebug(qLcKmsDebug, "Forcing plane index %d, plane id %u (belongs to crtc id %u)", idx, plane->plane_id, plane->crtc_id); - for (const QKmsPlane &kmsplane : qAsConst(m_planes)) { - if (kmsplane.id == output.forced_plane_id) - output.eglfs_plane = (QKmsPlane*)&kmsplane; + for (QKmsPlane &kmsplane : m_planes) { + if (kmsplane.id == output.forced_plane_id) { + assignPlane(&output, &kmsplane); + break; + } } drmModeFreePlane(plane); @@ -500,9 +514,9 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, const QStringList values = crtcPlanePair.split(QLatin1Char(',')); if (values.count() == 2 && uint(values[0].toInt()) == output.crtc_id) { uint planeId = values[1].toInt(); - for (const QKmsPlane &kmsplane : qAsConst(m_planes)) { + for (QKmsPlane &kmsplane : m_planes) { if (kmsplane.id == planeId) { - output.eglfs_plane = (QKmsPlane*)&kmsplane; + assignPlane(&output, &kmsplane); break; } } @@ -515,6 +529,13 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, output.eglfs_plane->id, connectorName.constData(), output.crtc_id); } +#if QT_CONFIG(drm_atomic) + if (hasAtomicSupport() && !output.eglfs_plane) { + qCDebug(qLcKmsDebug, "No plane associated with output %s (crtc id %u) and atomic modesetting is enabled. This is bad.", + connectorName.constData(), output.crtc_id); + } +#endif + m_crtc_allocator |= (1 << output.crtc_index); vinfo->output = output; diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index b1150e2875..0873154459 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -179,6 +179,8 @@ struct QKmsPlane uint32_t crtcheightPropertyId = 0; uint32_t zposPropertyId = 0; uint32_t blendOpPropertyId = 0; + + uint32_t activeCrtcId = 0; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QKmsPlane::Rotations) -- cgit v1.2.3 From aef07a433f16f5ed3800ee60e11116f78f13d3c4 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <albert.astals.cid@kdab.com> Date: Fri, 27 Sep 2019 16:27:58 +0200 Subject: QTableWidget: Fix -Wdeprecated-copy warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from ../../include/QtCore/qlist.h:1, from ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/kernel/qobject.h:49, from ../../include/QtCore/qobject.h:1, from ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/kernel/qcoreapplication.h:46, from ../../include/QtCore/qcoreapplication.h:1, from /src/widgets/kernel/../../gui/kernel/../../corelib/global/qt_pch.h:66, from /src/widgets/kernel/../../gui/kernel/qt_gui_pch.h:48, from /src/widgets/kernel/qt_widgets_pch.h:48: ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/tools/qlist.h: In instantiation of ‘void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = QTableWidgetSelectionRange]’: ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/tools/qlist.h:614:13: required from ‘void QList<T>::append(const T&) [with T = QTableWidgetSelectionRange]’ /src/widgets/itemviews/qtablewidget.cpp:2416:71: required from here ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/tools/qlist.h:471:35: warning: implicitly-declared ‘constexpr QTableWidgetSelectionRange& QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange&)’ is deprecated [-Wdeprecated-copy] 471 | else *reinterpret_cast<T*>(n) = t; | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /src/widgets/itemviews/qtablewidget.cpp:40: /src/widgets/itemviews/qtablewidget.h:52:24: note: because ‘QTableWidgetSelectionRange’ has user-provided ‘QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange&)’ 52 | class Q_WIDGETS_EXPORT QTableWidgetSelectionRange | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: Iad959315ad374ef288f5fffd15d6876cb63bce8e Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 127ed7e6e0f8939861cce7349e28a1dec9a7d6ed) --- src/widgets/itemviews/qtablewidget.cpp | 6 ++---- src/widgets/itemviews/qtablewidget.h | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index a25a582881..b1dbafa997 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -923,10 +923,8 @@ QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bo Constructs a the table selection range by copying the given \a other table selection range. */ -QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) - : top(other.top), left(other.left), bottom(other.bottom), right(other.right) -{ -} +QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) = default; +QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &other) = default; /*! Destroys the table selection range. diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index d93032f3f0..0d93a0a075 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -49,14 +49,17 @@ QT_REQUIRE_CONFIG(tablewidget); QT_BEGIN_NAMESPACE +// ### Qt6 unexport the class, remove the user-defined special 3 and make it a literal type. class Q_WIDGETS_EXPORT QTableWidgetSelectionRange { public: QTableWidgetSelectionRange(); QTableWidgetSelectionRange(int top, int left, int bottom, int right); - QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other); ~QTableWidgetSelectionRange(); + QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other); + QTableWidgetSelectionRange &operator=(const QTableWidgetSelectionRange &other); + inline int topRow() const { return top; } inline int bottomRow() const { return bottom; } inline int leftColumn() const { return left; } -- cgit v1.2.3 From 30f4ca4e4fbc1d8cf86808dbeb00ec3c046f6c1c Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Thu, 14 Feb 2019 04:06:27 +1000 Subject: wasm: fix building examples and applications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bug where app build would fail with AssertionError: SIMD is used, but not supported in WASM mode yet This patch was wiped out by the recent freetype update and is exactly the same as 44b91a619d14932635e9a3fe155de4df9f98a25c Fixes: QTBUG-79938 Change-Id: Iaa8f23c83d0488ddd351454a674a6cad76e7cc8b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/3rdparty/freetype/src/sfnt/pngshim.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/3rdparty/freetype/src/sfnt/pngshim.c b/src/3rdparty/freetype/src/sfnt/pngshim.c index ca85d9751f..fc78b6d5df 100644 --- a/src/3rdparty/freetype/src/sfnt/pngshim.c +++ b/src/3rdparty/freetype/src/sfnt/pngshim.c @@ -68,6 +68,7 @@ ( ( __clang_major__ >= 4 ) || \ ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \ defined( __OPTIMIZE__ ) && \ + !defined( __EMSCRIPTEN__ ) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __clang__ -- cgit v1.2.3 From 364160600889d6055a556a189e6f3d4a8dc3f96d Mon Sep 17 00:00:00 2001 From: Eike Ziller <eike.ziller@qt.io> Date: Fri, 8 Nov 2019 14:02:01 +0100 Subject: Use default QTD font size for mono font when importing markdown QFontDatabase::systemFont(FixedFont) determines the font for inline code and code blocks in a markdown document. Now we change the size of that font to the same size as QTextDocument::defaultFont() so that the user has the ability to customize the font size in each document instead of only system-wide. Change-Id: Ief7367336f7613e88695dbb08bcb7e9f50db8961 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/text/qtextmarkdownimporter.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index c2ad1e5612..78d18a714b 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -160,6 +160,10 @@ void QTextMarkdownImporter::import(QTextDocument *doc, const QString &markdown) m_paragraphMargin = m_doc->defaultFont().pointSize() * 2 / 3; m_cursor = new QTextCursor(doc); doc->clear(); + if (doc->defaultFont().pointSize() != -1) + m_monoFont.setPointSize(doc->defaultFont().pointSize()); + else + m_monoFont.setPixelSize(doc->defaultFont().pixelSize()); qCDebug(lcMD) << "default font" << doc->defaultFont() << "mono font" << m_monoFont; QByteArray md = markdown.toUtf8(); md_parse(md.constData(), MD_SIZE(md.size()), &callbacks, this); -- cgit v1.2.3 From 38f38c718895ba01a79c823a2ace6d9f27e12e85 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Mon, 11 Nov 2019 16:02:16 +0100 Subject: Deprecate enumerators fro SSL v.2 and v.3 protocols And we'll get rid of them in Qt 6. Task-number: QTBUG-75638 Change-Id: I34764f93bf579da0640a930d9160783ea9c8317d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/network/ssl/qssl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h index 42c7b5c56d..4ca90cc8c5 100644 --- a/src/network/ssl/qssl.h +++ b/src/network/ssl/qssl.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. @@ -77,9 +77,11 @@ namespace QSsl { #endif enum SslProtocol { +#if QT_DEPRECATED_SINCE(5, 15) SslV3, SslV2, - TlsV1_0, +#endif + TlsV1_0 = 2, #if QT_DEPRECATED_SINCE(5,0) TlsV1 = TlsV1_0, #endif -- cgit v1.2.3 From 79a1fc0e0106d125b467b603087137fdff5401f4 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko <alex1973tr@gmail.com> Date: Fri, 8 Nov 2019 19:37:51 +0200 Subject: QBasicTimer: release timer id on exit In some cases of inheritance, timer deletion can be triggered from the event dispatcher destructor where QThreadData::eventDispatcher is already nullptr. Despite the fact that the application is in shutdown phase, we should free the resource. Change-Id: I61ed1d817fd7638953f7d629823f19d4f6f1ee00 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/kernel/qbasictimer.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp index ea8f8e2c77..623ecb9b8b 100644 --- a/src/corelib/kernel/qbasictimer.cpp +++ b/src/corelib/kernel/qbasictimer.cpp @@ -216,13 +216,11 @@ void QBasicTimer::stop() { if (id) { QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); - if (eventDispatcher) { - if (Q_UNLIKELY(!eventDispatcher->unregisterTimer(id))) { - qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread"); - return; - } - QAbstractEventDispatcherPrivate::releaseTimerId(id); + if (eventDispatcher && !eventDispatcher->unregisterTimer(id)) { + qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread"); + return; } + QAbstractEventDispatcherPrivate::releaseTimerId(id); } id = 0; } -- cgit v1.2.3 From 2735c5bf069bcadefc2d6b626161e1166c2a683b Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Wed, 23 Oct 2019 07:48:04 +0200 Subject: Add support for passing qrc files to qmlimportscanner With the qrcFiles entry in the deployment JSON for Android, it can now pass this on to qmlimportscanner for scanning the qrc files for the available imports. This enables qmake to populate the qrc files it has referenced in the project, be it generated by qmake or added by the user. Task-number: QTBUG-55259 Change-Id: Ic512ce6f24508b3ea09ebdd07ac4446debfd9155 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- src/tools/androiddeployqt/main.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index feecfba8fb..550ed0832f 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -164,6 +164,7 @@ struct Options QString applicationBinary; QString rootPath; QStringList qmlImportPaths; + QStringList qrcFiles; // Versioning QString versionName; @@ -976,7 +977,10 @@ bool readInputFile(Options *options) } } } - + { + const QJsonValue qrcFiles = jsonObject.value(QLatin1String("qrcFiles")); + options->qrcFiles = qrcFiles.toString().split(QLatin1Char(','), QString::SkipEmptyParts); + } options->packageName = packageNameFromAndroidManifest(options->androidSourceDirectory + QLatin1String("/AndroidManifest.xml")); if (options->packageName.isEmpty()) options->packageName = cleanPackageName(QLatin1String("org.qtproject.example.%1").arg(options->applicationBinary)); @@ -1709,22 +1713,28 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies) } QString rootPath = options->rootPath; - if (rootPath.isEmpty()) - rootPath = QFileInfo(options->inputFileName).absolutePath(); - else - rootPath = QFileInfo(rootPath).absoluteFilePath(); + if (!options->qrcFiles.isEmpty()) { + qmlImportScanner += QLatin1String(" -qrcFiles"); + for (const QString &qrcFile : options->qrcFiles) + qmlImportScanner += QLatin1Char(' ') + shellQuote(qrcFile); + } else { + if (rootPath.isEmpty()) + rootPath = QFileInfo(options->inputFileName).absolutePath(); + else + rootPath = QFileInfo(rootPath).absoluteFilePath(); - if (!rootPath.endsWith(QLatin1Char('/'))) - rootPath += QLatin1Char('/'); + if (!rootPath.endsWith(QLatin1Char('/'))) + rootPath += QLatin1Char('/'); + qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath)); + } QStringList importPaths; importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml")); - importPaths += shellQuote(rootPath); + if (!rootPath.isEmpty()) + importPaths += shellQuote(rootPath); for (const QString &qmlImportPath : qAsConst(options->qmlImportPaths)) importPaths += shellQuote(qmlImportPath); - - qmlImportScanner += QLatin1String(" -rootPath %1 -importPath %2") - .arg(shellQuote(rootPath), importPaths.join(QLatin1Char(' '))); + qmlImportScanner += QLatin1String(" -importPath %1").arg(importPaths.join(QLatin1Char(' '))); if (options->verbose) { fprintf(stdout, "Running qmlimportscanner with the following command: %s\n", @@ -1946,7 +1956,8 @@ bool readDependencies(Options *options) } } - if (!options->rootPath.isEmpty() && !scanImports(options, &usedDependencies)) + if ((!options->rootPath.isEmpty() || options->qrcFiles.isEmpty()) && + !scanImports(options, &usedDependencies)) return false; return true; -- cgit v1.2.3 From 51cbd5288c85cb4de382cb23d6f5559c2b626126 Mon Sep 17 00:00:00 2001 From: Eike Ziller <eike.ziller@qt.io> Date: Fri, 8 Nov 2019 14:48:23 +0100 Subject: Fix rendering of markdown in QLabel Since 65314b6ce88cdbb28a22be0cab9856ec9bc9604b there is a TextFormat for MarkdownText, and QWidgetTextControl supports that, but QLabel does it in its own way and sets plain text or rich text on the text document itself. Add a code path for MarkdownText there. [ChangeLog][QtWidgets][QLabel] Markdown is now a supported textFormat for QLabel. Fixes: QTBUG-79766 Change-Id: Ib9370ef300089af2c4d6070e545c5470f32833a8 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/widgets/widgets/qlabel.cpp | 33 ++++++++++++++++++++++----------- src/widgets/widgets/qlabel_p.h | 6 +++--- 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index a840bf4ee6..77d117775a 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -85,6 +85,7 @@ QLabelPrivate::QLabelPrivate() shortcutId(0), #endif textformat(Qt::AutoText), + effectiveTextFormat(Qt::PlainText), textInteractionFlags(Qt::LinksAccessibleByMouse), sizePolicy(), margin(0), @@ -94,7 +95,6 @@ QLabelPrivate::QLabelPrivate() scaledcontents(false), textLayoutDirty(false), textDirty(false), - isRichText(false), isTextLabel(false), hasShortcut(/*???*/), #ifndef QT_NO_CURSOR @@ -294,8 +294,14 @@ void QLabel::setText(const QString &text) d->text = text; d->isTextLabel = true; d->textDirty = true; - d->isRichText = d->textformat == Qt::RichText - || (d->textformat == Qt::AutoText && Qt::mightBeRichText(d->text)); + if (d->textformat == Qt::AutoText) { + if (Qt::mightBeRichText(d->text)) + d->effectiveTextFormat = Qt::RichText; + else + d->effectiveTextFormat = Qt::PlainText; + } else { + d->effectiveTextFormat = d->textformat; + } d->control = oldControl; @@ -306,7 +312,7 @@ void QLabel::setText(const QString &text) d->control = nullptr; } - if (d->isRichText) { + if (d->effectiveTextFormat != Qt::PlainText) { setMouseTracking(true); } else { // Note: mouse tracking not disabled intentionally @@ -1478,14 +1484,19 @@ void QLabelPrivate::ensureTextPopulated() const if (control) { QTextDocument *doc = control->document(); if (textDirty) { -#ifndef QT_NO_TEXTHTMLPARSER - if (isRichText) - doc->setHtml(text); - else + if (effectiveTextFormat == Qt::PlainText) { doc->setPlainText(text); -#else - doc->setPlainText(text); +#if QT_CONFIG(texthtmlparser) + } else if (effectiveTextFormat == Qt::RichText) { + doc->setHtml(text); +#endif +#if QT_CONFIG(textmarkdownreader) + } else if (effectiveTextFormat == Qt::MarkdownText) { + doc->setMarkdown(text); #endif + } else { + doc->setPlainText(text); + } doc->setUndoRedoEnabled(false); #ifndef QT_NO_SHORTCUT @@ -1623,7 +1634,7 @@ QMenu *QLabelPrivate::createStandardContextMenu(const QPoint &pos) { QString linkToCopy; QPoint p; - if (control && isRichText) { + if (control && effectiveTextFormat != Qt::PlainText) { p = layoutPoint(pos); linkToCopy = control->document()->documentLayout()->anchorAt(p); } diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h index 59188563a9..6b3fbc5f0c 100644 --- a/src/widgets/widgets/qlabel_p.h +++ b/src/widgets/widgets/qlabel_p.h @@ -93,8 +93,8 @@ public: #endif inline bool needTextControl() const { return isTextLabel - && (isRichText - || (!isRichText && (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard)))); + && (effectiveTextFormat != Qt::PlainText + || (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard))); } void ensureTextPopulated() const; @@ -134,6 +134,7 @@ public: int shortcutId; #endif Qt::TextFormat textformat; + Qt::TextFormat effectiveTextFormat; Qt::TextInteractionFlags textInteractionFlags; mutable QSizePolicy sizePolicy; int margin; @@ -143,7 +144,6 @@ public: uint scaledcontents : 1; mutable uint textLayoutDirty : 1; mutable uint textDirty : 1; - mutable uint isRichText : 1; mutable uint isTextLabel : 1; mutable uint hasShortcut : 1; #ifndef QT_NO_CURSOR -- cgit v1.2.3 From 4e0d5498eb7ba401e6697182ce74b34d439ecf76 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko <alex1973tr@gmail.com> Date: Sat, 9 Nov 2019 17:48:01 +0200 Subject: QEventDispatcherWin32: unify input checks in {un}register...() The event manager has a family of the functions for registering sockets notifiers, event notifiers, and timers. To ensure efficient debugging, it would be useful to have one approach regarding input parameters validation for the entire set of that functions. Based on registerSocketNotifier() implementation, this patch offers the same debugging principles for QWinEventNotifier and QTimer. Some debug messages have also been refined. Change-Id: I1418ef43c51f7b794462b5e9c8a849633e0c60f9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/kernel/qeventdispatcher_win.cpp | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 87623f304a..517ba17fb2 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -636,11 +636,11 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) int type = notifier->type(); #ifndef QT_NO_DEBUG if (sockfd < 0) { - qWarning("QSocketNotifier: Internal error"); + qWarning("QEventDispatcherWin32::registerSocketNotifier: invalid socket identifier"); return; } if (notifier->thread() != thread() || thread() != QThread::currentThread()) { - qWarning("QSocketNotifier: socket notifiers cannot be enabled from another thread"); + qWarning("QEventDispatcherWin32: socket notifiers cannot be enabled from another thread"); return; } #endif @@ -697,11 +697,11 @@ void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier) #ifndef QT_NO_DEBUG int sockfd = notifier->socket(); if (sockfd < 0) { - qWarning("QSocketNotifier: Internal error"); + qWarning("QEventDispatcherWin32::unregisterSocketNotifier: invalid socket identifier"); return; } if (notifier->thread() != thread() || thread() != QThread::currentThread()) { - qWarning("QSocketNotifier: socket notifiers cannot be disabled from another thread"); + qWarning("QEventDispatcherWin32: socket notifiers cannot be disabled from another thread"); return; } #endif @@ -783,8 +783,7 @@ bool QEventDispatcherWin32::unregisterTimer(int timerId) qWarning("QEventDispatcherWin32::unregisterTimer: invalid argument"); return false; } - QThread *currentThread = QThread::currentThread(); - if (thread() != currentThread) { + if (thread() != QThread::currentThread()) { qWarning("QEventDispatcherWin32::unregisterTimer: timers cannot be stopped from another thread"); return false; } @@ -811,8 +810,7 @@ bool QEventDispatcherWin32::unregisterTimers(QObject *object) qWarning("QEventDispatcherWin32::unregisterTimers: invalid argument"); return false; } - QThread *currentThread = QThread::currentThread(); - if (object->thread() != thread() || thread() != currentThread) { + if (object->thread() != thread() || thread() != QThread::currentThread()) { qWarning("QEventDispatcherWin32::unregisterTimers: timers cannot be stopped from another thread"); return false; } @@ -837,10 +835,12 @@ bool QEventDispatcherWin32::unregisterTimers(QObject *object) QList<QEventDispatcherWin32::TimerInfo> QEventDispatcherWin32::registeredTimers(QObject *object) const { +#ifndef QT_NO_DEBUG if (!object) { qWarning("QEventDispatcherWin32:registeredTimers: invalid argument"); return QList<TimerInfo>(); } +#endif Q_D(const QEventDispatcherWin32); QList<TimerInfo> list; @@ -853,13 +853,13 @@ QEventDispatcherWin32::registeredTimers(QObject *object) const bool QEventDispatcherWin32::registerEventNotifier(QWinEventNotifier *notifier) { - if (!notifier) { - qWarning("QWinEventNotifier: Internal error"); - return false; - } else if (notifier->thread() != thread() || thread() != QThread::currentThread()) { - qWarning("QWinEventNotifier: event notifiers cannot be enabled from another thread"); + Q_ASSERT(notifier); +#ifndef QT_NO_DEBUG + if (notifier->thread() != thread() || thread() != QThread::currentThread()) { + qWarning("QEventDispatcherWin32: event notifiers cannot be enabled from another thread"); return false; } +#endif Q_D(QEventDispatcherWin32); @@ -877,13 +877,13 @@ bool QEventDispatcherWin32::registerEventNotifier(QWinEventNotifier *notifier) void QEventDispatcherWin32::unregisterEventNotifier(QWinEventNotifier *notifier) { - if (!notifier) { - qWarning("QWinEventNotifier: Internal error"); - return; - } else if (notifier->thread() != thread() || thread() != QThread::currentThread()) { - qWarning("QWinEventNotifier: event notifiers cannot be disabled from another thread"); + Q_ASSERT(notifier); +#ifndef QT_NO_DEBUG + if (notifier->thread() != thread() || thread() != QThread::currentThread()) { + qWarning("QEventDispatcherWin32: event notifiers cannot be disabled from another thread"); return; } +#endif Q_D(QEventDispatcherWin32); -- cgit v1.2.3 From 782df5b41dd3ab098fd1d3233339079487e1812f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Fri, 11 Oct 2019 00:42:08 +0200 Subject: Make QObjectPrivate::threadData a proper atomic QObjectPrivate::threadData used to be a QThreadData *, and was read and written from multiple threads without proper synchronization. As an example, it was read from QCoreApplication::postEvent and written from QObject::moveToThread, therefore causing UB. Port threadData to a proper atomic, removing the races. Fix all usage points. In general, QObject is documented to be simply reentrant, not thread-safe, and certain bits (e.g. timers, moveToThread) are not even reentrant. The reasoning therefore is that a given QObject's threadData is not supposed to be touched by multiple threads without some synchronization happening elsewhere, and therefore relaxed loads should be sufficient. As drive-by change: refactor QCoreApplication::postEvent. It was particularly subtle, because it had a loop using a volatile to cope with the possibility of the receiver object switching thread while we tried to lock its thread's event queue. However, volatile does not achieve any synchronization, so drop it, and refactor the algorithm using better locking primitives. Put this algorithm in a common place, and also reuse it from removePostedEvents, which was lacking any synchronization. Change-Id: Icc755f7eb418ff54b33db4bdd87fd8eaf4e82c7a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/io/qprocess_unix.cpp | 6 +- src/corelib/io/qprocess_win.cpp | 2 +- src/corelib/kernel/qcoreapplication.cpp | 112 ++++++++++----------- src/corelib/kernel/qcoreapplication_p.h | 10 ++ src/corelib/kernel/qcoreapplication_win.cpp | 2 +- src/corelib/kernel/qeventdispatcher_unix.cpp | 6 +- src/corelib/kernel/qeventdispatcher_win.cpp | 2 +- src/corelib/kernel/qeventloop.cpp | 43 ++++---- src/corelib/kernel/qobject.cpp | 52 ++++++---- src/corelib/kernel/qobject_p.h | 9 +- src/corelib/kernel/qsocketnotifier.cpp | 15 ++- src/corelib/kernel/qwineventnotifier.cpp | 6 +- src/gui/kernel/qguiapplication_p.h | 2 +- src/network/socket/qabstractsocket.cpp | 8 +- src/network/socket/qnativesocketengine.cpp | 6 +- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 4 +- .../platforms/cocoa/qcocoaeventdispatcher.mm | 4 +- src/widgets/kernel/qapplication.cpp | 2 +- 18 files changed, 165 insertions(+), 126 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 0c80daa024..9edb4a6d11 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -246,7 +246,7 @@ bool QProcessPrivate::openChannel(Channel &channel) return false; // create the socket notifiers - if (threadData->hasEventDispatcher()) { + if (threadData.loadRelaxed()->hasEventDispatcher()) { if (&channel == &stdinChannel) { channel.notifier = new QSocketNotifier(channel.pipe[1], QSocketNotifier::Write, q); @@ -377,7 +377,7 @@ void QProcessPrivate::startProcess() return; } - if (threadData->hasEventDispatcher()) { + if (threadData.loadRelaxed()->hasEventDispatcher()) { startupSocketNotifier = new QSocketNotifier(childStartedPipe[0], QSocketNotifier::Read, q); QObject::connect(startupSocketNotifier, SIGNAL(activated(int)), @@ -517,7 +517,7 @@ void QProcessPrivate::startProcess() if (stderrChannel.pipe[0] != -1) ::fcntl(stderrChannel.pipe[0], F_SETFL, ::fcntl(stderrChannel.pipe[0], F_GETFL) | O_NONBLOCK); - if (threadData->eventDispatcher.loadAcquire()) { + if (threadData.loadRelaxed()->eventDispatcher.loadAcquire()) { deathNotifier = new QSocketNotifier(forkfd, QSocketNotifier::Read, q); QObject::connect(deathNotifier, SIGNAL(activated(int)), q, SLOT(_q_processDied())); diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 3ba86063e3..05af5a5aee 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -590,7 +590,7 @@ void QProcessPrivate::startProcess() if (!pid) return; - if (threadData->hasEventDispatcher()) { + if (threadData.loadRelaxed()->hasEventDispatcher()) { processFinishedNotifier = new QWinEventNotifier(pid->hProcess, q); QObject::connect(processFinishedNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_processDied())); processFinishedNotifier->setEnabled(true); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index e25049f821..6d95979f76 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -135,23 +135,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_QOBJECT -class QMutexUnlocker -{ -public: - inline explicit QMutexUnlocker(QMutex *m) - : mtx(m) - { } - inline ~QMutexUnlocker() { unlock(); } - inline void unlock() { if (mtx) mtx->unlock(); mtx = 0; } - -private: - Q_DISABLE_COPY(QMutexUnlocker) - - QMutex *mtx; -}; -#endif - #if defined(Q_OS_WIN) || defined(Q_OS_MAC) extern QString qAppFileName(); #endif @@ -517,25 +500,27 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() void QCoreApplicationPrivate::cleanupThreadData() { - if (threadData && !threadData_clean) { + auto thisThreadData = threadData.loadRelaxed(); + + if (thisThreadData && !threadData_clean) { #if QT_CONFIG(thread) - void *data = &threadData->tls; + void *data = &thisThreadData->tls; QThreadStorageData::finish((void **)data); #endif // need to clear the state of the mainData, just in case a new QCoreApplication comes along. - const auto locker = qt_scoped_lock(threadData->postEventList.mutex); - for (int i = 0; i < threadData->postEventList.size(); ++i) { - const QPostEvent &pe = threadData->postEventList.at(i); + const auto locker = qt_scoped_lock(thisThreadData->postEventList.mutex); + for (int i = 0; i < thisThreadData->postEventList.size(); ++i) { + const QPostEvent &pe = thisThreadData->postEventList.at(i); if (pe.event) { --pe.receiver->d_func()->postedEvents; pe.event->posted = false; delete pe.event; } } - threadData->postEventList.clear(); - threadData->postEventList.recursion = 0; - threadData->quitNow = false; + thisThreadData->postEventList.clear(); + thisThreadData->postEventList.recursion = 0; + thisThreadData->quitNow = false; threadData_clean = true; } } @@ -858,7 +843,8 @@ void QCoreApplicationPrivate::init() #ifndef QT_NO_QOBJECT // use the event dispatcher created by the app programmer (if any) Q_ASSERT(!eventDispatcher); - eventDispatcher = threadData->eventDispatcher.loadRelaxed(); + auto thisThreadData = threadData.loadRelaxed(); + eventDispatcher = thisThreadData->eventDispatcher.loadRelaxed(); // otherwise we create one if (!eventDispatcher) @@ -866,11 +852,11 @@ void QCoreApplicationPrivate::init() Q_ASSERT(eventDispatcher); if (!eventDispatcher->parent()) { - eventDispatcher->moveToThread(threadData->thread.loadAcquire()); + eventDispatcher->moveToThread(thisThreadData->thread.loadAcquire()); eventDispatcher->setParent(q); } - threadData->eventDispatcher = eventDispatcher; + thisThreadData->eventDispatcher = eventDispatcher; eventDispatcherReady(); #endif @@ -914,7 +900,7 @@ QCoreApplication::~QCoreApplication() #endif #ifndef QT_NO_QOBJECT - d_func()->threadData->eventDispatcher = nullptr; + d_func()->threadData.loadRelaxed()->eventDispatcher = nullptr; if (QCoreApplicationPrivate::eventDispatcher) QCoreApplicationPrivate::eventDispatcher->closingDown(); QCoreApplicationPrivate::eventDispatcher = nullptr; @@ -1185,7 +1171,7 @@ static bool doNotify(QObject *receiver, QEvent *event) bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event) { // We can't access the application event filters outside of the main thread (race conditions) - Q_ASSERT(receiver->d_func()->threadData->thread.loadAcquire() == mainThread()); + Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread()); if (extraData) { // application event filters are only called for objects in the GUI thread @@ -1238,7 +1224,7 @@ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event) // send to all application event filters (only does anything in the main thread) if (QCoreApplication::self - && receiver->d_func()->threadData->thread.loadAcquire() == mainThread() + && receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread() && QCoreApplication::self->d_func()->sendThroughApplicationEventFilters(receiver, event)) { filtered = true; return filtered; @@ -1414,7 +1400,7 @@ int QCoreApplication::exec() void QCoreApplicationPrivate::execCleanup() { - threadData->quitNow = false; + threadData.loadRelaxed()->quitNow = false; in_exec = false; if (!aboutToQuitEmitted) emit q_func()->aboutToQuit(QCoreApplication::QPrivateSignal()); @@ -1451,7 +1437,7 @@ void QCoreApplication::exit(int returnCode) { if (!self) return; - QThreadData *data = self->d_func()->threadData; + QThreadData *data = self->d_func()->threadData.loadRelaxed(); data->quitNow = true; for (int i = 0; i < data->eventLoops.size(); ++i) { QEventLoop *eventLoop = data->eventLoops.at(i); @@ -1501,6 +1487,38 @@ bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event) #endif // QT_NO_QOBJECT +QCoreApplicationPrivate::QPostEventListLocker QCoreApplicationPrivate::lockThreadPostEventList(QObject *object) +{ + QPostEventListLocker locker; + + if (!object) { + locker.threadData = QThreadData::current(); + locker.locker = qt_unique_lock(locker.threadData->postEventList.mutex); + return locker; + } + + auto &threadData = QObjectPrivate::get(object)->threadData; + + // if object has moved to another thread, follow it + for (;;) { + // synchronizes with the storeRelease in QObject::moveToThread + locker.threadData = threadData.loadAcquire(); + if (!locker.threadData) { + // destruction in progress + return locker; + } + + auto temporaryLocker = qt_unique_lock(locker.threadData->postEventList.mutex); + if (locker.threadData == threadData.loadAcquire()) { + locker.locker = std::move(temporaryLocker); + break; + } + } + + Q_ASSERT(locker.threadData); + return locker; +} + /*! \since 4.3 @@ -1536,32 +1554,14 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority) return; } - QThreadData * volatile * pdata = &receiver->d_func()->threadData; - QThreadData *data = *pdata; - if (!data) { + auto locker = QCoreApplicationPrivate::lockThreadPostEventList(receiver); + if (!locker.threadData) { // posting during destruction? just delete the event to prevent a leak delete event; return; } - // lock the post event mutex - data->postEventList.mutex.lock(); - - // if object has moved to another thread, follow it - while (data != *pdata) { - data->postEventList.mutex.unlock(); - - data = *pdata; - if (!data) { - // posting during destruction? just delete the event to prevent a leak - delete event; - return; - } - - data->postEventList.mutex.lock(); - } - - QMutexUnlocker locker(&data->postEventList.mutex); + QThreadData *data = locker.threadData; // if this is one of the compressible events, do compression if (receiver->d_func()->postedEvents @@ -1860,8 +1860,8 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) { - QThreadData *data = receiver ? receiver->d_func()->threadData : QThreadData::current(); - auto locker = qt_unique_lock(data->postEventList.mutex); + auto locker = QCoreApplicationPrivate::lockThreadPostEventList(receiver); + QThreadData *data = locker.threadData; // the QObject destructor calls this function directly. this can // happen while the event loop is in the middle of posting events, diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 3bad42d076..9d2fde619c 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -61,6 +61,7 @@ #endif #ifndef QT_NO_QOBJECT #include "private/qobject_p.h" +#include "private/qlocking_p.h" #endif #ifdef Q_OS_MACOS @@ -140,6 +141,15 @@ public: static void checkReceiverThread(QObject *receiver); void cleanupThreadData(); + + struct QPostEventListLocker + { + QThreadData *threadData; + std::unique_lock<QMutex> locker; + + void unlock() { locker.unlock(); } + }; + static QPostEventListLocker lockThreadPostEventList(QObject *object); #endif // QT_NO_QOBJECT int &argc; diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 961b96710e..765f129758 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -918,7 +918,7 @@ QDebug operator<<(QDebug dbg, const MSG &msg) #ifndef QT_NO_QOBJECT void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId) { - QThreadData *data = object->d_func()->threadData; + QThreadData *data = object->d_func()->threadData.loadRelaxed(); const auto locker = qt_scoped_lock(data->postEventList.mutex); if (data->postEventList.size() == 0) diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 5bc65b7110..2492d70005 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -463,13 +463,15 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags) // we are awake, broadcast it emit awake(); - QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); + + auto threadData = d->threadData.loadRelaxed(); + QCoreApplicationPrivate::sendPostedEvents(0, 0, threadData); const bool include_timers = (flags & QEventLoop::X11ExcludeTimers) == 0; const bool include_notifiers = (flags & QEventLoop::ExcludeSocketNotifiers) == 0; const bool wait_for_events = flags & QEventLoop::WaitForMoreEvents; - const bool canWait = (d->threadData->canWaitLocked() + const bool canWait = (threadData->canWaitLocked() && !d->interrupt.loadRelaxed() && wait_for_events); diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 517ba17fb2..8616631603 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -1048,7 +1048,7 @@ bool QEventDispatcherWin32::event(QEvent *e) void QEventDispatcherWin32::sendPostedEvents() { Q_D(QEventDispatcherWin32); - QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); + QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData.loadRelaxed()); } HWND QEventDispatcherWin32::internalHwnd() diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index eacd0c4e73..5a5dfb06aa 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -106,7 +106,7 @@ QEventLoop::QEventLoop(QObject *parent) if (!QCoreApplication::instance() && QCoreApplicationPrivate::threadRequiresCoreApplication()) { qWarning("QEventLoop: Cannot be used without QApplication"); } else { - d->threadData->ensureEventDispatcher(); + d->threadData.loadRelaxed()->ensureEventDispatcher(); } } @@ -133,9 +133,10 @@ QEventLoop::~QEventLoop() bool QEventLoop::processEvents(ProcessEventsFlags flags) { Q_D(QEventLoop); - if (!d->threadData->hasEventDispatcher()) + auto threadData = d->threadData.loadRelaxed(); + if (!threadData->hasEventDispatcher()) return false; - return d->threadData->eventDispatcher.loadRelaxed()->processEvents(flags); + return threadData->eventDispatcher.loadRelaxed()->processEvents(flags); } /*! @@ -164,9 +165,11 @@ bool QEventLoop::processEvents(ProcessEventsFlags flags) int QEventLoop::exec(ProcessEventsFlags flags) { Q_D(QEventLoop); + auto threadData = d->threadData.loadRelaxed(); + //we need to protect from race condition with QThread::exit - QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread.loadAcquire()))->mutex); - if (d->threadData->quitNow) + QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(threadData->thread.loadAcquire()))->mutex); + if (threadData->quitNow) return -1; if (d->inExec) { @@ -183,8 +186,11 @@ int QEventLoop::exec(ProcessEventsFlags flags) { d->inExec = true; d->exit.storeRelease(false); - ++d->threadData->loopLevel; - d->threadData->eventLoops.push(d->q_func()); + + auto threadData = d->threadData.loadRelaxed(); + ++threadData->loopLevel; + threadData->eventLoops.push(d->q_func()); + locker.unlock(); } @@ -198,11 +204,12 @@ int QEventLoop::exec(ProcessEventsFlags flags) "QCoreApplication::notify() and catch all exceptions there.\n"); } locker.relock(); - QEventLoop *eventLoop = d->threadData->eventLoops.pop(); + auto threadData = d->threadData.loadRelaxed(); + QEventLoop *eventLoop = threadData->eventLoops.pop(); Q_ASSERT_X(eventLoop == d->q_func(), "QEventLoop::exec()", "internal error"); Q_UNUSED(eventLoop); // --release warning d->inExec = false; - --d->threadData->loopLevel; + --threadData->loopLevel; } }; LoopReference ref(d, locker); @@ -217,7 +224,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) // exception, which returns control to the browser while preserving the C++ stack. // Event processing then continues as normal. The sleep call below never returns. // QTBUG-70185 - if (d->threadData->loopLevel > 1) + if (threadData->loopLevel > 1) emscripten_sleep(1); #endif @@ -247,7 +254,7 @@ int QEventLoop::exec(ProcessEventsFlags flags) void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime) { Q_D(QEventLoop); - if (!d->threadData->hasEventDispatcher()) + if (!d->threadData.loadRelaxed()->hasEventDispatcher()) return; QElapsedTimer start; @@ -276,21 +283,22 @@ void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime) void QEventLoop::exit(int returnCode) { Q_D(QEventLoop); - if (!d->threadData->hasEventDispatcher()) + auto threadData = d->threadData.loadAcquire(); + if (!threadData->hasEventDispatcher()) return; d->returnCode.storeRelaxed(returnCode); d->exit.storeRelease(true); - d->threadData->eventDispatcher.loadRelaxed()->interrupt(); + threadData->eventDispatcher.loadRelaxed()->interrupt(); #ifdef Q_OS_WASM // QEventLoop::exec() never returns in emscripten. We implement approximate behavior here. // QTBUG-70185 - if (d->threadData->loopLevel == 1) { + if (threadData->loopLevel == 1) { emscripten_force_exit(returnCode); } else { d->inExec = false; - --d->threadData->loopLevel; + --threadData->loopLevel; } #endif } @@ -316,9 +324,10 @@ bool QEventLoop::isRunning() const void QEventLoop::wakeUp() { Q_D(QEventLoop); - if (!d->threadData->hasEventDispatcher()) + auto threadData = d->threadData.loadAcquire(); + if (!threadData->hasEventDispatcher()) return; - d->threadData->eventDispatcher.loadRelaxed()->wakeUp(); + threadData->eventDispatcher.loadRelaxed()->wakeUp(); } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index bb1b48b0a6..cee885c0fe 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -212,11 +212,12 @@ QObjectPrivate::QObjectPrivate(int version) QObjectPrivate::~QObjectPrivate() { + auto thisThreadData = threadData.loadRelaxed(); if (extraData && !extraData->runningTimers.isEmpty()) { - if (Q_LIKELY(threadData->thread.loadAcquire() == QThread::currentThread())) { + if (Q_LIKELY(thisThreadData->thread.loadAcquire() == QThread::currentThread())) { // unregister pending timers - if (threadData->hasEventDispatcher()) - threadData->eventDispatcher.loadRelaxed()->unregisterTimers(q_ptr); + if (thisThreadData->hasEventDispatcher()) + thisThreadData->eventDispatcher.loadRelaxed()->unregisterTimers(q_ptr); // release the timer ids back to the pool for (int i = 0; i < extraData->runningTimers.size(); ++i) @@ -229,7 +230,7 @@ QObjectPrivate::~QObjectPrivate() if (postedEvents) QCoreApplication::removePostedEvents(q_ptr, 0); - threadData->deref(); + thisThreadData->deref(); if (metaObject) metaObject->objectDestroyed(q_ptr); @@ -920,11 +921,12 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) Q_D(QObject); d_ptr->q_ptr = this; - d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); - d->threadData->ref(); + auto threadData = (parent && !parent->thread()) ? parent->d_func()->threadData.loadRelaxed() : QThreadData::current(); + threadData->ref(); + d->threadData.storeRelaxed(threadData); if (parent) { QT_TRY { - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) + if (!check_parent_thread(parent, parent ? parent->d_func()->threadData.loadRelaxed() : 0, threadData)) parent = 0; if (d->isWidget) { if (parent) { @@ -936,7 +938,7 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) setParent(parent); } } QT_CATCH(...) { - d->threadData->deref(); + threadData->deref(); QT_RETHROW; } } @@ -1320,7 +1322,7 @@ bool QObject::event(QEvent *e) case QEvent::ThreadChange: { Q_D(QObject); - QThreadData *threadData = d->threadData; + QThreadData *threadData = d->threadData.loadRelaxed(); QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher.loadRelaxed(); if (eventDispatcher) { QList<QAbstractEventDispatcher::TimerInfo> timers = eventDispatcher->registeredTimers(this); @@ -1487,7 +1489,7 @@ bool QObject::blockSignals(bool block) noexcept */ QThread *QObject::thread() const { - return d_func()->threadData->thread.loadAcquire(); + return d_func()->threadData.loadRelaxed()->thread.loadAcquire(); } /*! @@ -1534,7 +1536,7 @@ void QObject::moveToThread(QThread *targetThread) { Q_D(QObject); - if (d->threadData->thread.loadAcquire() == targetThread) { + if (d->threadData.loadRelaxed()->thread.loadAcquire() == targetThread) { // object is already in this thread return; } @@ -1550,13 +1552,14 @@ void QObject::moveToThread(QThread *targetThread) QThreadData *currentData = QThreadData::current(); QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr; - if (d->threadData->thread.loadAcquire() == 0 && currentData == targetData) { + QThreadData *thisThreadData = d->threadData.loadRelaxed(); + if (!thisThreadData->thread.loadAcquire() && currentData == targetData) { // one exception to the rule: we allow moving objects with no thread affinity to the current thread currentData = d->threadData; - } else if (d->threadData != currentData) { + } else if (thisThreadData != currentData) { qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n" "Cannot move to target thread (%p)\n", - currentData->thread.loadRelaxed(), d->threadData->thread.loadRelaxed(), targetData ? targetData->thread.loadRelaxed() : nullptr); + currentData->thread.loadRelaxed(), thisThreadData->thread.loadRelaxed(), targetData ? targetData->thread.loadRelaxed() : nullptr); #ifdef Q_OS_MAC qWarning("You might be loading two sets of Qt binaries into the same process. " @@ -1653,8 +1656,10 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData // set new thread data targetData->ref(); - threadData->deref(); - threadData = targetData; + threadData.loadRelaxed()->deref(); + + // synchronizes with loadAcquire e.g. in QCoreApplication::postEvent + threadData.storeRelease(targetData); for (int i = 0; i < children.size(); ++i) { QObject *child = children.at(i); @@ -1666,7 +1671,7 @@ void QObjectPrivate::_q_reregisterTimers(void *pointer) { Q_Q(QObject); QList<QAbstractEventDispatcher::TimerInfo> *timerList = reinterpret_cast<QList<QAbstractEventDispatcher::TimerInfo> *>(pointer); - QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher.loadRelaxed(); + QAbstractEventDispatcher *eventDispatcher = threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); for (int i = 0; i < timerList->size(); ++i) { const QAbstractEventDispatcher::TimerInfo &ti = timerList->at(i); eventDispatcher->registerTimer(ti.timerId, ti.interval, ti.timerType, q); @@ -1724,7 +1729,9 @@ int QObject::startTimer(int interval, Qt::TimerType timerType) qWarning("QObject::startTimer: Timers cannot have negative intervals"); return 0; } - if (Q_UNLIKELY(!d->threadData->hasEventDispatcher())) { + + auto thisThreadData = d->threadData.loadRelaxed(); + if (Q_UNLIKELY(!thisThreadData->hasEventDispatcher())) { qWarning("QObject::startTimer: Timers can only be used with threads started with QThread"); return 0; } @@ -1732,7 +1739,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType) qWarning("QObject::startTimer: Timers cannot be started from another thread"); return 0; } - int timerId = d->threadData->eventDispatcher.loadRelaxed()->registerTimer(interval, timerType, this); + int timerId = thisThreadData->eventDispatcher.loadRelaxed()->registerTimer(interval, timerType, this); if (!d->extraData) d->extraData = new QObjectPrivate::ExtraData; d->extraData->runningTimers.append(timerId); @@ -1806,8 +1813,9 @@ void QObject::killTimer(int id) return; } - if (d->threadData->hasEventDispatcher()) - d->threadData->eventDispatcher.loadRelaxed()->unregisterTimer(id); + auto thisThreadData = d->threadData.loadRelaxed(); + if (thisThreadData->hasEventDispatcher()) + thisThreadData->eventDispatcher.loadRelaxed()->unregisterTimer(id); d->extraData->runningTimers.remove(at); QAbstractEventDispatcherPrivate::releaseTimerId(id); @@ -3774,7 +3782,7 @@ void doActivate(QObject *sender, int signal_index, void **argv) list = &signalVector->at(-1); Qt::HANDLE currentThreadId = QThread::currentThreadId(); - bool inSenderThread = currentThreadId == QObjectPrivate::get(sender)->threadData->threadId.loadRelaxed(); + bool inSenderThread = currentThreadId == QObjectPrivate::get(sender)->threadData.loadRelaxed()->threadId.loadRelaxed(); // We need to check against the highest connection id to ensure that signals added // during the signal emission are not emitted in this emission. diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 45fc27917d..1ebf8e7a07 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -374,8 +374,13 @@ public: } public: ExtraData *extraData; // extra data set by the user - QThreadData *getThreadData() const { return threadData; } - QThreadData *threadData; // id of the thread that owns the object + QThreadData *getThreadData() const { return threadData.loadAcquire(); } + // This atomic requires acquire/release semantics in a few places, + // e.g. QObject::moveToThread must synchronize with QCoreApplication::postEvent, + // because postEvent is thread-safe. + // However, most of the code paths involving QObject are only reentrant and + // not thread-safe, so synchronization should not be necessary there. + QAtomicPointer<QThreadData> threadData; // id of the thread that owns the object using ConnectionDataPointer = QExplicitlySharedDataPointer<ConnectionData>; QAtomicPointer<ConnectionData> connections; diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index 2a246b1204..78269ee605 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -147,12 +147,14 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent) d->sntype = type; d->snenabled = true; + auto thisThreadData = d->threadData.loadRelaxed(); + if (socket < 0) qWarning("QSocketNotifier: Invalid socket specified"); - else if (!d->threadData->hasEventDispatcher()) + else if (!thisThreadData->hasEventDispatcher()) qWarning("QSocketNotifier: Can only be used with threads started with QThread"); else - d->threadData->eventDispatcher.loadRelaxed()->registerSocketNotifier(this); + thisThreadData->eventDispatcher.loadRelaxed()->registerSocketNotifier(this); } /*! @@ -234,16 +236,19 @@ void QSocketNotifier::setEnabled(bool enable) return; d->snenabled = enable; - if (!d->threadData->hasEventDispatcher()) // perhaps application/thread is shutting down + + auto thisThreadData = d->threadData.loadRelaxed(); + + if (!thisThreadData->hasEventDispatcher()) // perhaps application/thread is shutting down return; if (Q_UNLIKELY(thread() != QThread::currentThread())) { qWarning("QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread"); return; } if (d->snenabled) - d->threadData->eventDispatcher.loadRelaxed()->registerSocketNotifier(this); + thisThreadData->eventDispatcher.loadRelaxed()->registerSocketNotifier(this); else - d->threadData->eventDispatcher.loadRelaxed()->unregisterSocketNotifier(this); + thisThreadData->eventDispatcher.loadRelaxed()->unregisterSocketNotifier(this); } diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp index d2ae9668fe..db5d44b276 100644 --- a/src/corelib/kernel/qwineventnotifier.cpp +++ b/src/corelib/kernel/qwineventnotifier.cpp @@ -124,7 +124,7 @@ QWinEventNotifier::QWinEventNotifier(HANDLE hEvent, QObject *parent) : QObject(*new QWinEventNotifierPrivate(hEvent, false), parent) { Q_D(QWinEventNotifier); - QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher.loadRelaxed(); + QAbstractEventDispatcher *eventDispatcher = d->threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); if (Q_UNLIKELY(!eventDispatcher)) { qWarning("QWinEventNotifier: Can only be used with threads started with QThread"); return; @@ -197,7 +197,7 @@ void QWinEventNotifier::setEnabled(bool enable) return; d->enabled = enable; - QAbstractEventDispatcher *eventDispatcher = d->threadData->eventDispatcher.loadRelaxed(); + QAbstractEventDispatcher *eventDispatcher = d->threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); if (!eventDispatcher) { // perhaps application is shutting down if (!enable && d->waitHandle != nullptr) d->unregisterWaitObject(); @@ -256,7 +256,7 @@ void QWinEventNotifierPrivate::unregisterWaitObject() static void CALLBACK wfsoCallback(void *context, BOOLEAN /*ignore*/) { QWinEventNotifierPrivate *nd = reinterpret_cast<QWinEventNotifierPrivate *>(context); - QAbstractEventDispatcher *eventDispatcher = nd->threadData->eventDispatcher.loadRelaxed(); + QAbstractEventDispatcher *eventDispatcher = nd->threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); // Happens when Q(Core)Application is destroyed before QWinEventNotifier. // https://bugreports.qt.io/browse/QTBUG-70214 diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 26f65b2f16..ee493faa5d 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -116,7 +116,7 @@ public: static QAbstractEventDispatcher *qt_qpa_core_dispatcher() { if (QCoreApplication::instance()) - return QCoreApplication::instance()->d_func()->threadData->eventDispatcher.loadRelaxed(); + return QCoreApplication::instance()->d_func()->threadData.loadRelaxed()->eventDispatcher.loadRelaxed(); else return nullptr; } diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index b1ea9a4133..e48fbea3b6 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -659,7 +659,7 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc configureCreatedSocket(); - if (threadData->hasEventDispatcher()) + if (threadData.loadRelaxed()->hasEventDispatcher()) socketEngine->setReceiver(this); #if defined (QABSTRACTSOCKET_DEBUG) @@ -1138,7 +1138,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() } // Start the connect timer. - if (threadData->hasEventDispatcher()) { + if (threadData.loadRelaxed()->hasEventDispatcher()) { if (!connectTimer) { connectTimer = new QTimer(q); QObject::connect(connectTimer, SIGNAL(timeout()), @@ -1740,7 +1740,7 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port, return; #endif } else { - if (d->threadData->hasEventDispatcher()) { + if (d->threadData.loadRelaxed()->hasEventDispatcher()) { // this internal API for QHostInfo either immediately gives us the desired // QHostInfo from cache or later calls the _q_startConnecting slot. bool immediateResultValid = false; @@ -1953,7 +1953,7 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState // Sync up with error string, which open() shall clear. d->socketError = UnknownSocketError; - if (d->threadData->hasEventDispatcher()) + if (d->threadData.loadRelaxed()->hasEventDispatcher()) d->socketEngine->setReceiver(d); QIODevice::open(openMode); diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 5126a5330f..f3ca2afdc8 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -1341,7 +1341,7 @@ void QNativeSocketEngine::setReadNotificationEnabled(bool enable) Q_D(QNativeSocketEngine); if (d->readNotifier) { d->readNotifier->setEnabled(enable); - } else if (enable && d->threadData->hasEventDispatcher()) { + } else if (enable && d->threadData.loadRelaxed()->hasEventDispatcher()) { d->readNotifier = new QReadNotifier(d->socketDescriptor, this); d->readNotifier->setEnabled(true); } @@ -1358,7 +1358,7 @@ void QNativeSocketEngine::setWriteNotificationEnabled(bool enable) Q_D(QNativeSocketEngine); if (d->writeNotifier) { d->writeNotifier->setEnabled(enable); - } else if (enable && d->threadData->hasEventDispatcher()) { + } else if (enable && d->threadData.loadRelaxed()->hasEventDispatcher()) { d->writeNotifier = new QWriteNotifier(d->socketDescriptor, this); d->writeNotifier->setEnabled(true); } @@ -1375,7 +1375,7 @@ void QNativeSocketEngine::setExceptionNotificationEnabled(bool enable) Q_D(QNativeSocketEngine); if (d->exceptNotifier) { d->exceptNotifier->setEnabled(enable); - } else if (enable && d->threadData->hasEventDispatcher()) { + } else if (enable && d->threadData.loadRelaxed()->hasEventDispatcher()) { d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this); d->exceptNotifier->setEnabled(true); } diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 9b0a6b1b86..f1fe2aa98b 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -149,7 +149,7 @@ QT_USE_NAMESPACE if ([reflectionDelegate respondsToSelector:_cmd]) return [reflectionDelegate applicationShouldTerminate:sender]; - if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) { + if (QGuiApplicationPrivate::instance()->threadData.loadRelaxed()->eventLoops.isEmpty()) { // No event loop is executing. This probably means that Qt is used as a plugin, // or as a part of a native Cocoa application. In any case it should be fine to // terminate now. @@ -359,7 +359,7 @@ QT_USE_NAMESPACE if (!platformItem || platformItem->menu()) return; - QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData); + QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData.loadRelaxed()); QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers:[NSEvent modifierFlags]]; static QMetaMethod activatedSignal = QMetaMethod::fromSignal(&QCocoaMenuItem::activated); diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index b3ce9e45dc..110c82bf1f 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -511,7 +511,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if (hadModalSession && !d->currentModalSessionCached) interruptLater = true; } - bool canWait = (d->threadData->canWait + bool canWait = (d->threadData.loadRelaxed()->canWait && !retVal && !d->interrupt && (d->processEventsFlags & QEventLoop::WaitForMoreEvents)); @@ -878,7 +878,7 @@ void QCocoaEventDispatcherPrivate::processPostedEvents() } int serial = serialNumber.loadRelaxed(); - if (!threadData->canWait || (serial != lastSerial)) { + if (!threadData.loadRelaxed()->canWait || (serial != lastSerial)) { lastSerial = serial; QCoreApplication::sendPostedEvents(); QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index dfa1bc23b1..6d4baacfef 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3660,7 +3660,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) // send to all application event filters if (threadRequiresCoreApplication() - && receiver->d_func()->threadData->thread.loadAcquire() == mainThread() + && receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread() && sendThroughApplicationEventFilters(receiver, e)) { filtered = true; return filtered; -- cgit v1.2.3 From 5bd48047de4abecc47187d938c5e6ed8b8304aaf Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Fri, 8 Nov 2019 11:41:16 +0100 Subject: eglfs: kms: Make threaded atomic drm work The atomic modesetting support was not prepared for page flips being issued from different (per-screen) threads. This could be seen with the threaded render loop of Qt Quick: having a QQuickWindow per screen means having a dedicated render thread for each screen. QKmsDevice used simply instance variables to keep track of the request. This leads to the commit failing with EBUSY sooner or later. Make the atomic request and related variables thread local. This prevents failing drmModeAtomicCommit() with 2 or more screens and the threaded render loop. It does not fix other potential issues when waiting for page flips to complete, that is to be tackled separately. Task-number: QTBUG-74953 Change-Id: I2dac10d5e9bdc0cb556ac78c9643c96d40d692e4 Reviewed-by: Johan Helsing <johan.helsing@qt.io> --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 58 ++++++++++++---------- src/platformsupport/kmsconvenience/qkmsdevice_p.h | 15 +++--- .../eglfs_kms/qeglfskmsgbmscreen.cpp | 16 +++--- .../eglfs_kms_support/qeglfskmsintegration.cpp | 2 +- 4 files changed, 50 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 90437117aa..92ba9fbcd9 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -581,10 +581,6 @@ QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path) , m_path(path) , m_dri_fd(-1) , m_has_atomic_support(false) -#if QT_CONFIG(drm_atomic) - , m_atomic_request(nullptr) - , m_previous_request(nullptr) -#endif , m_crtc_allocator(0) { if (m_path.isEmpty()) { @@ -600,7 +596,7 @@ QKmsDevice::QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path) QKmsDevice::~QKmsDevice() { #if QT_CONFIG(drm_atomic) - atomicReset(); + threadLocalAtomicReset(); #endif } @@ -940,39 +936,51 @@ bool QKmsDevice::hasAtomicSupport() } #if QT_CONFIG(drm_atomic) -drmModeAtomicReq * QKmsDevice::atomic_request() +drmModeAtomicReq *QKmsDevice::threadLocalAtomicRequest() { - if (!m_atomic_request && m_has_atomic_support) - m_atomic_request = drmModeAtomicAlloc(); + if (!m_has_atomic_support) + return nullptr; - return m_atomic_request; + AtomicReqs &a(m_atomicReqs.localData()); + if (!a.request) + a.request = drmModeAtomicAlloc(); + + return a.request; } -bool QKmsDevice::atomicCommit(void *user_data) +bool QKmsDevice::threadLocalAtomicCommit(void *user_data) { - if (m_atomic_request) { - int ret = drmModeAtomicCommit(m_dri_fd, m_atomic_request, - DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET, user_data); + if (!m_has_atomic_support) + return false; - if (ret) { - qWarning("Failed to commit atomic request (code=%d)", ret); - return false; - } + AtomicReqs &a(m_atomicReqs.localData()); + if (!a.request) + return false; - m_previous_request = m_atomic_request; - m_atomic_request = nullptr; + int ret = drmModeAtomicCommit(m_dri_fd, a.request, + DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_ALLOW_MODESET, + user_data); - return true; + if (ret) { + qWarning("Failed to commit atomic request (code=%d)", ret); + return false; } - return false; + a.previous_request = a.request; + a.request = nullptr; + + return true; } -void QKmsDevice::atomicReset() +void QKmsDevice::threadLocalAtomicReset() { - if (m_previous_request) { - drmModeAtomicFree(m_previous_request); - m_previous_request = nullptr; + if (!m_has_atomic_support) + return; + + AtomicReqs &a(m_atomicReqs.localData()); + if (a.previous_request) { + drmModeAtomicFree(a.previous_request); + a.previous_request = nullptr; } } #endif diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h index 0873154459..55a590cfce 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h +++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h @@ -57,6 +57,7 @@ #include <qpa/qplatformscreen.h> #include <QtCore/QMap> #include <QtCore/QVariant> +#include <QtCore/QThreadStorage> #include <xf86drm.h> #include <xf86drmMode.h> @@ -241,10 +242,9 @@ public: bool hasAtomicSupport(); #if QT_CONFIG(drm_atomic) - bool atomicCommit(void *user_data); - void atomicReset(); - - drmModeAtomicReq *atomic_request(); + drmModeAtomicReq *threadLocalAtomicRequest(); + bool threadLocalAtomicCommit(void *user_data); + void threadLocalAtomicReset(); #endif void createScreens(); @@ -284,8 +284,11 @@ protected: bool m_has_atomic_support; #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *m_atomic_request; - drmModeAtomicReq *m_previous_request; + struct AtomicReqs { + drmModeAtomicReq *request = nullptr; + drmModeAtomicReq *previous_request = nullptr; + }; + QThreadStorage<AtomicReqs> m_atomicReqs; #endif quint32 m_crtc_allocator; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 16dbfe1522..333433f666 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -243,7 +243,7 @@ void QEglFSKmsGbmScreen::ensureModeSet(uint32_t fb) if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *request = device()->atomic_request(); + drmModeAtomicReq *request = device()->threadLocalAtomicRequest(); if (request) { drmModeAtomicAddProperty(request, op.connector_id, op.crtcIdPropertyId, op.crtc_id); drmModeAtomicAddProperty(request, op.crtc_id, op.modeIdPropertyId, op.mode_blob_id); @@ -287,8 +287,7 @@ void QEglFSKmsGbmScreen::waitForFlip() } #if QT_CONFIG(drm_atomic) - if (device()->hasAtomicSupport()) - device()->atomicReset(); + device()->threadLocalAtomicReset(); #endif } @@ -324,16 +323,16 @@ void QEglFSKmsGbmScreen::flip() if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *request = device()->atomic_request(); + drmModeAtomicReq *request = device()->threadLocalAtomicRequest(); if (request) { drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->framebufferPropertyId, fb->fb); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcPropertyId, op.crtc_id); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcwidthPropertyId, - output().size.width() << 16); + op.size.width() << 16); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcXPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcYPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcheightPropertyId, - output().size.height() << 16); + op.size.height() << 16); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcXPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcYPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcwidthPropertyId, @@ -371,7 +370,7 @@ void QEglFSKmsGbmScreen::flip() if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *request = device()->atomic_request(); + drmModeAtomicReq *request = device()->threadLocalAtomicRequest(); if (request) { drmModeAtomicAddProperty(request, d.screen->output().eglfs_plane->id, d.screen->output().eglfs_plane->framebufferPropertyId, fb->fb); @@ -394,8 +393,7 @@ void QEglFSKmsGbmScreen::flip() } #if QT_CONFIG(drm_atomic) - if (device()->hasAtomicSupport()) - device()->atomicCommit(this); + device()->threadLocalAtomicCommit(this); #endif } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp index a6aac61506..28b6b7df63 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp @@ -140,7 +140,7 @@ void *QEglFSKmsIntegration::nativeResourceForIntegration(const QByteArray &name) #if QT_CONFIG(drm_atomic) if (name == QByteArrayLiteral("dri_atomic_request") && m_device) - return (void *) (qintptr) m_device->atomic_request(); + return (void *) (qintptr) m_device->threadLocalAtomicRequest(); #endif return nullptr; } -- cgit v1.2.3 From 1e5d1a43dc14240b24615d4cc9a291d5237ea8bf Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@qt.io> Date: Mon, 11 Nov 2019 13:02:32 +0100 Subject: Make sure the metatypes are installed in prefix builds The JSON collection step has to be target_predeps in order to be executed if the only place its output is referred to is INSTALLS. Furthermore, some CONFIG options clear the INSTALLS variable. Therefore, we need to add the metatypes CONFIG entries after those. Change-Id: I4694ab1d82c13cb4e3886c1722a03255d14b7f29 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/corelib.pro | 3 ++- src/gui/gui.pro | 4 ++-- src/widgets/widgets.pro | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index eca888385b..3430154d13 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -1,6 +1,6 @@ TARGET = QtCore QT = -CONFIG += exceptions metatypes install_metatypes +CONFIG += exceptions MODULE = core # not corelib, as per project file MODULE_CONFIG = moc resources @@ -17,6 +17,7 @@ DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x67000000 CONFIG += simd optimize_full +CONFIG += metatypes install_metatypes QMAKE_DOCS = $$PWD/doc/qtcore.qdocconf diff --git a/src/gui/gui.pro b/src/gui/gui.pro index decfb364cf..350d4c5ee3 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -35,7 +35,7 @@ testcocoon { osx: LIBS_PRIVATE += -framework AppKit darwin: LIBS_PRIVATE += -framework CoreGraphics -CONFIG += simd optimize_full metatypes install_metatypes +CONFIG += simd optimize_full include(accessible/accessible.pri) include(kernel/kernel.pri) @@ -99,4 +99,4 @@ qtConfig(egl): CMAKE_EGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_EGL) QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist TRACEPOINT_PROVIDER = $$PWD/qtgui.tracepoints -CONFIG += qt_tracepoints +CONFIG += qt_tracepoints metatypes install_metatypes diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index 2aa56ded93..2d5ba05d40 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -9,8 +9,6 @@ msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x65000000 TRACEPOINT_PROVIDER = $$PWD/qtwidgets.tracepoints CONFIG += qt_tracepoints -CONFIG += metatypes install_metatypes - QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf #platforms @@ -47,3 +45,5 @@ testcocoon { MODULE_PLUGIN_TYPES += \ styles load(qt_module) + +CONFIG += metatypes install_metatypes -- cgit v1.2.3 From f2cc6fd4a0734e442f1101e3277215ea9d44d0d2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 12 Nov 2019 09:41:04 +0100 Subject: uic: Remove some usages of QList Task-number: QTBUG-79896 Change-Id: I298a434040fa903509685b7cde82bbea722f3246 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> --- src/tools/uic/cpp/cppwriteinitialization.cpp | 8 ++++---- src/tools/uic/cpp/cppwriteinitialization.h | 5 +++-- src/tools/uic/treewalker.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 0349061089..9bb2cfcfea 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2304,7 +2304,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) QString tempName = disableSorting(w, varName); - QList<Item *> items = initializeTreeWidgetItems(w->elementItem()); + const auto items = initializeTreeWidgetItems(w->elementItem()); for (int i = 0; i < items.count(); i++) { Item *itm = items[i]; itm->writeSetupUi(varName); @@ -2326,10 +2326,10 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) conditions an item is needed needs to be done bottom-up, the whole process makes two passes, storing the intermediate result in a recursive StringInitializerListMap. */ -QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItems(const QVector<DomItem *> &domItems) +WriteInitialization::Items WriteInitialization::initializeTreeWidgetItems(const QVector<DomItem *> &domItems) { // items - QList<Item *> items; + Items items; const int numDomItems = domItems.size(); items.reserve(numDomItems); @@ -2357,7 +2357,7 @@ QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItem // AbstractFromBuilder saves flags last, so they always end up in the last column's map. addQtFlagsInitializer(item, map, QLatin1String("flags")); - const QList<Item *> subItems = initializeTreeWidgetItems(domItem->elementItem()); + const auto subItems = initializeTreeWidgetItems(domItem->elementItem()); for (Item *subItem : subItems) item->addChild(subItem); } diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index 6f8e352f6a..ab996a2800 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -187,7 +187,7 @@ private: }; ItemData m_setupUiData; ItemData m_retranslateUiData; - QList<Item *> m_children; + QVector<Item *> m_children; Item *m_parent = nullptr; const QString m_itemClassName; @@ -196,6 +196,7 @@ private: QTextStream &m_retranslateUiStream; Driver *m_driver; }; + using Items = QVector<Item *>; void addInitializer(Item *item, const QString &name, int column, const QString &value, const QString &directive = QString(), bool translatable = false) const; @@ -214,7 +215,7 @@ private: void initializeComboBox(DomWidget *w); void initializeListWidget(DomWidget *w); void initializeTreeWidget(DomWidget *w); - QList<Item *> initializeTreeWidgetItems(const QVector<DomItem *> &domItems); + Items initializeTreeWidgetItems(const QVector<DomItem *> &domItems); void initializeTableWidget(DomWidget *w); QString disableSorting(DomWidget *w, const QString &varName); diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h index 3777229517..6905d74fd9 100644 --- a/src/tools/uic/treewalker.h +++ b/src/tools/uic/treewalker.h @@ -29,7 +29,7 @@ #ifndef TREEWALKER_H #define TREEWALKER_H -#include <qlist.h> +#include <qvector.h> QT_BEGIN_NAMESPACE -- cgit v1.2.3 From f2cf5f5417d4df68eb0677e375cb81e39286c05f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 8 Nov 2019 21:16:55 +0100 Subject: Port QThread::wait() to QDeadlineTimer So we are in sync with QWaitCondition::wait(). Task-number: QTBUG-64266 Change-Id: I1d7487786513241cedd35d202c4ddee4937b08ec Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/thread/qthread.cpp | 30 ++++++++++++++++++++------ src/corelib/thread/qthread.h | 8 +++---- src/corelib/thread/qthread_unix.cpp | 4 ++-- src/corelib/thread/qthread_win.cpp | 6 +++--- src/network/access/qnetworkaccessmanager.cpp | 2 +- src/network/access/qnetworkreplyhttpimpl.cpp | 2 +- src/network/bearer/qnetworkconfigmanager_p.cpp | 2 +- 7 files changed, 35 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 880ae9e046..791b765880 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -49,6 +49,8 @@ #include "qthread_p.h" #include "private/qcoreapplication_p.h" +#include <limits> + QT_BEGIN_NAMESPACE /* @@ -726,7 +728,8 @@ QThread::Priority QThread::priority() const */ /*! - \fn bool QThread::wait(unsigned long time) + \fn bool QThread::wait(QDeadlineTimer deadline) + \since 5.15 Blocks the thread until either of these conditions is met: @@ -735,12 +738,14 @@ QThread::Priority QThread::priority() const execution (i.e. when it returns from \l{run()}). This function will return true if the thread has finished. It also returns true if the thread has not been started yet. - \li \a time milliseconds has elapsed. If \a time is ULONG_MAX (the - default), then the wait will never timeout (the thread must - return from \l{run()}). This function will return false if the - wait timed out. + \li The \a deadline is reached. This function will return false if the + deadline is reached. \endlist + A deadline timer set to \c QDeadlineTimer::Forever (the default) will never + time out: in this case, the function only returns when the thread returns + from \l{run()} or if the thread has not yet started. + This provides similar functionality to the POSIX \c pthread_join() function. @@ -833,9 +838,9 @@ void QThread::exit(int returnCode) } } -bool QThread::wait(unsigned long time) +bool QThread::wait(QDeadlineTimer deadline) { - Q_UNUSED(time); + Q_UNUSED(deadline); return false; } @@ -966,6 +971,17 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) } } +/*! + \fn bool QThread::wait(unsigned long time) + \overload +*/ +bool QThread::wait(unsigned long time) +{ + if (time == std::numeric_limits<unsigned long>::max()) + return wait(QDeadlineTimer(QDeadlineTimer::Forever)); + return wait(QDeadlineTimer(time)); +} + #if QT_CONFIG(thread) /*! diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index c7a6dc8f1a..2072e22340 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -42,6 +42,7 @@ #define QTHREAD_H #include <QtCore/qobject.h> +#include <QtCore/qdeadlinetimer.h> // For QThread::create. The configure-time test just checks for the availability // of std::future and std::async; for the C++17 codepath we perform some extra @@ -57,8 +58,6 @@ # endif #endif -#include <limits.h> - QT_BEGIN_NAMESPACE @@ -135,8 +134,9 @@ public Q_SLOTS: void quit(); public: - // default argument causes thread to block indefinetely - bool wait(unsigned long time = ULONG_MAX); + bool wait(QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever)); + // ### Qt6 inline this function + bool wait(unsigned long time); static void sleep(unsigned long); static void msleep(unsigned long); diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index b19922753a..62f0179802 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -751,7 +751,7 @@ void QThread::terminate() #endif } -bool QThread::wait(unsigned long time) +bool QThread::wait(QDeadlineTimer deadline) { Q_D(QThread); QMutexLocker locker(&d->mutex); @@ -765,7 +765,7 @@ bool QThread::wait(unsigned long time) return true; while (d->running) { - if (!d->thread_done.wait(locker.mutex(), QDeadlineTimer(time))) + if (!d->thread_done.wait(locker.mutex(), deadline)) return false; } return true; diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index a72df2fc40..3df7080caf 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -610,7 +610,7 @@ void QThread::terminate() QThreadPrivate::finish(this, false); } -bool QThread::wait(unsigned long time) +bool QThread::wait(QDeadlineTimer deadline) { Q_D(QThread); QMutexLocker locker(&d->mutex); @@ -627,9 +627,9 @@ bool QThread::wait(unsigned long time) bool ret = false; #ifndef Q_OS_WINRT - switch (WaitForSingleObject(d->handle, time)) { + switch (WaitForSingleObject(d->handle, deadline.remainingTime())) { #else - switch (WaitForSingleObjectEx(d->handle, time, false)) { + switch (WaitForSingleObjectEx(d->handle, deadline.remainingTime(), false)) { #endif case WAIT_OBJECT_0: ret = true; diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 3e1e6d8be8..6c1cb420fe 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1981,7 +1981,7 @@ void QNetworkAccessManagerPrivate::destroyThread() { if (thread) { thread->quit(); - thread->wait(5000); + thread->wait(QDeadlineTimer(5000)); if (thread->isFinished()) delete thread; else diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index a13c2b144c..ba9d0a76d5 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -986,7 +986,7 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq } thread->quit(); - thread->wait(5000); + thread->wait(QDeadlineTimer(5000)); if (thread->isFinished()) delete thread; else diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index b432444669..252b88d36a 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -93,7 +93,7 @@ void QNetworkConfigurationManagerPrivate::cleanup() { QThread* thread = bearerThread; deleteLater(); - if (thread->wait(5000)) + if (thread->wait(QDeadlineTimer(5000))) delete thread; } -- cgit v1.2.3 From a3f62d7ead78fde31bc26dd35d4bf6789a7b9e2f Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Tue, 9 Oct 2018 10:14:43 +1000 Subject: wasm: add platform qsettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the backend is async, the settings will not be ready to read/write instantly as on other platforms, but only be ready after the filesystem has been synced to the sandbox. This takes at least 250 to 500 ms. The QSettings status() or isWritable() can be used to discern when the settings are ready for use. This also fixes a crash in threaded wasm Task-number: QTBUG-70002 Fixes: QTBUG-63923 Fixes: QTBUG-79650 Change-Id: If24c6ada1b91b2a565ed6733da74972c3027f622 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/corelib/io/io.pri | 1 + src/corelib/io/qsettings.cpp | 15 +- src/corelib/io/qsettings_p.h | 13 +- src/corelib/io/qsettings_wasm.cpp | 259 ++++++++++++++++++++++++++++++++ src/corelib/kernel/qcoreapplication.cpp | 19 +-- src/gui/kernel/qguiapplication.cpp | 8 +- 6 files changed, 277 insertions(+), 38 deletions(-) create mode 100644 src/corelib/io/qsettings_wasm.cpp (limited to 'src') diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index fe81689932..c4c6f41387 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -136,6 +136,7 @@ qtConfig(settings) { } else: darwin:!nacl { SOURCES += io/qsettings_mac.cpp } + wasm : SOURCES += io/qsettings_wasm.cpp } win32 { diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index fc7122d904..dcc9340473 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -76,10 +76,6 @@ # include <ioLib.h> #endif -#ifdef Q_OS_WASM -#include <emscripten.h> -#endif - #include <algorithm> #include <stdlib.h> @@ -295,7 +291,7 @@ after_loop: // see also qsettings_win.cpp, qsettings_winrt.cpp and qsettings_mac.cpp -#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) +#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && !defined(Q_OS_WASM) QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application) { @@ -1185,7 +1181,9 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format, confFiles.append(QConfFile::fromName(systemPath.path + orgFile, false)); } +#ifndef Q_OS_WASM // wasm needs to delay access until after file sync initAccess(); +#endif } QConfFileSettingsPrivate::QConfFileSettingsPrivate(const QString &fileName, @@ -1548,13 +1546,6 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile) perms |= QFile::ReadGroup | QFile::ReadOther; QFile(confFile->name).setPermissions(perms); } -#ifdef Q_OS_WASM - EM_ASM( - // Sync sandbox filesystem to persistent database filesystem. See QTBUG-70002 - FS.syncfs(false, function(err) { - }); - ); -#endif } else { setStatus(QSettings::AccessError); } diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h index d18c96a06c..c30f099a72 100644 --- a/src/corelib/io/qsettings_p.h +++ b/src/corelib/io/qsettings_p.h @@ -57,6 +57,10 @@ #include "QtCore/qiodevice.h" #include "QtCore/qstack.h" #include "QtCore/qstringlist.h" + +#include <QtCore/qvariant.h> +#include "qsettings.h" + #ifndef QT_NO_QOBJECT #include "private/qobject_p.h" #endif @@ -253,6 +257,10 @@ protected: mutable QSettings::Status status; }; +#ifdef Q_OS_WASM +class QWasmSettingsPrivate; +#endif + class QConfFileSettingsPrivate : public QSettingsPrivate { public: @@ -281,7 +289,7 @@ public: private: void initFormat(); - void initAccess(); + virtual void initAccess(); void syncConfFile(QConfFile *confFile); bool writeIniFile(QIODevice &device, const ParsedSettingsMap &map); #ifdef Q_OS_MAC @@ -297,6 +305,9 @@ private: QString extension; Qt::CaseSensitivity caseSensitivity; int nextPosition; +#ifdef Q_OS_WASM + friend class QWasmSettingsPrivate; +#endif }; QT_END_NAMESPACE diff --git a/src/corelib/io/qsettings_wasm.cpp b/src/corelib/io/qsettings_wasm.cpp new file mode 100644 index 0000000000..8d8f4b505c --- /dev/null +++ b/src/corelib/io/qsettings_wasm.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsettings.h" +#ifndef QT_NO_SETTINGS + +#include "qsettings_p.h" +#ifndef QT_NO_QOBJECT +#include "qcoreapplication.h" +#include <QFile> +#endif // QT_NO_QOBJECT +#include <QDebug> + +#include <QFileInfo> +#include <QDir> +#include <emscripten.h> + +QT_BEGIN_NAMESPACE + +static bool isReadReady = false; + +class QWasmSettingsPrivate : public QConfFileSettingsPrivate +{ +public: + QWasmSettingsPrivate(QSettings::Scope scope, const QString &organization, + const QString &application); + ~QWasmSettingsPrivate(); + + bool get(const QString &key, QVariant *value) const override; + QStringList children(const QString &prefix, ChildSpec spec) const override; + void clear() override; + void sync() override; + void flush() override; + bool isWritable() const override; + + void syncToLocal(const char *data, int size); + void loadLocal(const QByteArray &filename); + void setReady(); + void initAccess() override; + +private: + QString databaseName; + QString id; +}; + +static void QWasmSettingsPrivate_onLoad(void *userData, void *dataPtr, int size) +{ + QWasmSettingsPrivate *wasm = reinterpret_cast<QWasmSettingsPrivate *>(userData); + + QFile file(wasm->fileName()); + QFileInfo fileInfo(wasm->fileName()); + QDir dir(fileInfo.path()); + if (!dir.exists()) + dir.mkpath(fileInfo.path()); + + if (file.open(QFile::WriteOnly)) { + file.write(reinterpret_cast<char *>(dataPtr), size); + file.close(); + wasm->setReady(); + } +} + +static void QWasmSettingsPrivate_onError(void *userData) +{ + QWasmSettingsPrivate *wasm = reinterpret_cast<QWasmSettingsPrivate *>(userData); + if (wasm) + wasm->setStatus(QSettings::AccessError); +} + +static void QWasmSettingsPrivate_onStore(void *userData) +{ + QWasmSettingsPrivate *wasm = reinterpret_cast<QWasmSettingsPrivate *>(userData); + if (wasm) + wasm->setStatus(QSettings::NoError); +} + +static void QWasmSettingsPrivate_onCheck(void *userData, int exists) +{ + QWasmSettingsPrivate *wasm = reinterpret_cast<QWasmSettingsPrivate *>(userData); + if (wasm) { + if (exists) + wasm->loadLocal(wasm->fileName().toLocal8Bit()); + else + wasm->setReady(); + } +} + +QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, + QSettings::Scope scope, + const QString &organization, + const QString &application) +{ + Q_UNUSED(format) + if (organization == QLatin1String("Qt")) + { + QString organizationDomain = QCoreApplication::organizationDomain(); + QString applicationName = QCoreApplication::applicationName(); + + QSettingsPrivate *newSettings; + newSettings = new QWasmSettingsPrivate(scope, organizationDomain, applicationName); + + newSettings->beginGroupOrArray(QSettingsGroup(normalizedKey(organization))); + if (!application.isEmpty()) + newSettings->beginGroupOrArray(QSettingsGroup(normalizedKey(application))); + + return newSettings; + } + return new QWasmSettingsPrivate(scope, organization, application); +} + +QWasmSettingsPrivate::QWasmSettingsPrivate(QSettings::Scope scope, const QString &organization, + const QString &application) + : QConfFileSettingsPrivate(QSettings::NativeFormat, scope, organization, application) +{ + setStatus(QSettings::AccessError); // access error until sandbox gets loaded + databaseName = organization; + id = application; + + emscripten_idb_async_exists("/home/web_user", + fileName().toLocal8Bit(), + reinterpret_cast<void*>(this), + QWasmSettingsPrivate_onCheck, + QWasmSettingsPrivate_onError); +} + +QWasmSettingsPrivate::~QWasmSettingsPrivate() +{ +} + + void QWasmSettingsPrivate::initAccess() +{ + if (isReadReady) + QConfFileSettingsPrivate::initAccess(); +} + +bool QWasmSettingsPrivate::get(const QString &key, QVariant *value) const +{ + if (isReadReady) + return QConfFileSettingsPrivate::get(key, value); + + return false; +} + +QStringList QWasmSettingsPrivate::children(const QString &prefix, ChildSpec spec) const +{ + return QConfFileSettingsPrivate::children(prefix, spec); +} + +void QWasmSettingsPrivate::clear() +{ + QConfFileSettingsPrivate::clear(); + emscripten_idb_async_delete("/home/web_user", + fileName().toLocal8Bit(), + reinterpret_cast<void*>(this), + QWasmSettingsPrivate_onStore, + QWasmSettingsPrivate_onError); +} + +void QWasmSettingsPrivate::sync() +{ + QConfFileSettingsPrivate::sync(); + + QFile file(fileName()); + if (file.open(QFile::ReadOnly)) { + QByteArray dataPointer = file.readAll(); + + emscripten_idb_async_store("/home/web_user", + fileName().toLocal8Bit(), + reinterpret_cast<void *>(dataPointer.data()), + dataPointer.length(), + reinterpret_cast<void*>(this), + QWasmSettingsPrivate_onStore, + QWasmSettingsPrivate_onError); + } +} + +void QWasmSettingsPrivate::flush() +{ + sync(); +} + +bool QWasmSettingsPrivate::isWritable() const +{ + return isReadReady && QConfFileSettingsPrivate::isWritable(); +} + +void QWasmSettingsPrivate::syncToLocal(const char *data, int size) +{ + QFile file(fileName()); + + if (file.open(QFile::WriteOnly)) { + file.write(data, size + 1); + QByteArray data = file.readAll(); + + emscripten_idb_async_store("/home/web_user", + fileName().toLocal8Bit(), + reinterpret_cast<void *>(data.data()), + data.length(), + reinterpret_cast<void*>(this), + QWasmSettingsPrivate_onStore, + QWasmSettingsPrivate_onError); + setReady(); + } +} + +void QWasmSettingsPrivate::loadLocal(const QByteArray &filename) +{ + emscripten_idb_async_load("/home/web_user", + filename.data(), + reinterpret_cast<void*>(this), + QWasmSettingsPrivate_onLoad, + QWasmSettingsPrivate_onError); +} + +void QWasmSettingsPrivate::setReady() +{ + isReadReady = true; + setStatus(QSettings::NoError); + QConfFileSettingsPrivate::initAccess(); +} + +QT_END_NAMESPACE +#endif // QT_NO_SETTINGS diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 6d95979f76..32efa727b8 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -121,7 +121,6 @@ #endif #ifdef Q_OS_WASM -#include <emscripten.h> #include <emscripten/val.h> #endif @@ -480,13 +479,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint QCoreApplicationPrivate::~QCoreApplicationPrivate() { -#ifdef Q_OS_WASM - EM_ASM( - // unmount persistent directory as IDBFS - // see also QTBUG-70002 - FS.unmount('/home/web_user'); - ); -#endif #ifndef QT_NO_QOBJECT cleanupThreadData(); #endif @@ -780,17 +772,8 @@ void QCoreApplicationPrivate::init() Q_ASSERT_X(!QCoreApplication::self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = q; -#ifdef Q_OS_WASM - EM_ASM( - // mount and sync persistent filesystem to sandbox - FS.mount(IDBFS, {}, '/home/web_user'); - FS.syncfs(true, function(err) { - if (err) - Module.print(err); - }); - ); - #if QT_CONFIG(thread) +#ifdef Q_OS_WASM QThreadPrivate::idealThreadCount = emscripten::val::global("navigator")["hardwareConcurrency"].as<int>(); #endif #endif diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index f09f7e941b..455de52319 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1696,13 +1696,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() qt_gl_set_global_share_context(0); } #endif -#ifdef Q_OS_WASM - EM_ASM( - // unmount persistent directory as IDBFS - // see QTBUG-70002 - FS.unmount('/home/web_user'); - ); -#endif + platform_integration->destroy(); delete platform_theme; -- cgit v1.2.3 From 0ec40c21c13232906bbbf26a16278fb0da263722 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 12 Nov 2019 10:53:24 +0100 Subject: uic: Update ui4.cpp/h sources Apply changes from qttools/4235774262f633da196a192248dbacf4f67f085e. Task-number: QTBUG-79896 Change-Id: I49466980a7c5983f57d4948386b15e8fcec82343 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> --- src/tools/uic/ui4.cpp | 178 +++++++++++++++++++++++++------------------------- src/tools/uic/ui4.h | 116 ++++++++++++++++---------------- 2 files changed, 147 insertions(+), 147 deletions(-) (limited to 'src') diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 334ced276d..f52a8bd7d4 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -59,7 +59,7 @@ void DomUI::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("version")) { setAttributeVersion(attribute.value().toString()); continue; @@ -94,7 +94,7 @@ void DomUI::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("author"), Qt::CaseInsensitive)) { setElementAuthor(reader.readElementText()); continue; @@ -581,7 +581,7 @@ void DomIncludes::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { auto *v = new DomInclude(); v->read(reader); @@ -621,7 +621,7 @@ void DomInclude::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -636,7 +636,7 @@ void DomInclude::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -678,7 +678,7 @@ void DomResources::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -689,7 +689,7 @@ void DomResources::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { auto *v = new DomResource(); v->read(reader); @@ -732,7 +732,7 @@ void DomResource::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -743,7 +743,7 @@ void DomResource::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -781,7 +781,7 @@ void DomActionGroup::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -792,7 +792,7 @@ void DomActionGroup::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { auto *v = new DomAction(); v->read(reader); @@ -886,7 +886,7 @@ void DomAction::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -901,7 +901,7 @@ void DomAction::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -962,7 +962,7 @@ void DomActionRef::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -973,7 +973,7 @@ void DomActionRef::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1007,7 +1007,7 @@ void DomButtonGroup::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -1018,7 +1018,7 @@ void DomButtonGroup::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -1081,7 +1081,7 @@ void DomButtonGroups::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("buttongroup"), Qt::CaseInsensitive)) { auto *v = new DomButtonGroup(); v->read(reader); @@ -1126,7 +1126,7 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("customwidget"), Qt::CaseInsensitive)) { auto *v = new DomCustomWidget(); v->read(reader); @@ -1166,7 +1166,7 @@ void DomHeader::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -1177,7 +1177,7 @@ void DomHeader::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1219,7 +1219,7 @@ void DomCustomWidget::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { setElementClass(reader.readElementText()); continue; @@ -1473,7 +1473,7 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toInt()); continue; @@ -1488,7 +1488,7 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1519,7 +1519,7 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toString()); continue; @@ -1534,7 +1534,7 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -1569,7 +1569,7 @@ void DomTabStops::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("tabstop"), Qt::CaseInsensitive)) { m_tabStop.append(reader.readElementText()); continue; @@ -1615,7 +1615,7 @@ void DomLayout::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; @@ -1650,7 +1650,7 @@ void DomLayout::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -1759,7 +1759,7 @@ void DomLayoutItem::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toInt()); continue; @@ -1786,7 +1786,7 @@ void DomLayoutItem::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { auto *v = new DomWidget(); v->read(reader); @@ -1910,7 +1910,7 @@ void DomRow::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -1955,7 +1955,7 @@ void DomColumn::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -2001,7 +2001,7 @@ void DomItem::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toInt()); continue; @@ -2016,7 +2016,7 @@ void DomItem::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -2101,7 +2101,7 @@ void DomWidget::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; @@ -2120,7 +2120,7 @@ void DomWidget::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { m_class.append(reader.readElementText()); continue; @@ -2344,7 +2344,7 @@ void DomSpacer::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -2355,7 +2355,7 @@ void DomSpacer::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -2398,7 +2398,7 @@ void DomColor::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("alpha")) { setAttributeAlpha(attribute.value().toInt()); continue; @@ -2409,7 +2409,7 @@ void DomColor::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("red"), Qt::CaseInsensitive)) { setElementRed(reader.readElementText().toInt()); continue; @@ -2494,7 +2494,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("position")) { setAttributePosition(attribute.value().toDouble()); continue; @@ -2505,7 +2505,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); @@ -2568,7 +2568,7 @@ void DomGradient::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("startx")) { setAttributeStartX(attribute.value().toDouble()); continue; @@ -2627,7 +2627,7 @@ void DomGradient::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("gradientstop"), Qt::CaseInsensitive)) { auto *v = new DomGradientStop(); v->read(reader); @@ -2724,7 +2724,7 @@ void DomBrush::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("brushstyle")) { setAttributeBrushStyle(attribute.value().toString()); continue; @@ -2735,7 +2735,7 @@ void DomBrush::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { auto *v = new DomColor(); v->read(reader); @@ -2845,7 +2845,7 @@ void DomColorRole::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("role")) { setAttributeRole(attribute.value().toString()); continue; @@ -2856,7 +2856,7 @@ void DomColorRole::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { auto *v = new DomBrush(); v->read(reader); @@ -2922,7 +2922,7 @@ void DomColorGroup::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("colorrole"), Qt::CaseInsensitive)) { auto *v = new DomColorRole(); v->read(reader); @@ -2983,7 +2983,7 @@ void DomPalette::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("active"), Qt::CaseInsensitive)) { auto *v = new DomColorGroup(); v->read(reader); @@ -3102,7 +3102,7 @@ void DomFont::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("family"), Qt::CaseInsensitive)) { setElementFamily(reader.readElementText()); continue; @@ -3308,7 +3308,7 @@ void DomPoint::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; @@ -3370,7 +3370,7 @@ void DomRect::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; @@ -3467,7 +3467,7 @@ void DomLocale::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("language")) { setAttributeLanguage(attribute.value().toString()); continue; @@ -3482,7 +3482,7 @@ void DomLocale::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -3513,7 +3513,7 @@ void DomSizePolicy::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("hsizetype")) { setAttributeHSizeType(attribute.value().toString()); continue; @@ -3528,7 +3528,7 @@ void DomSizePolicy::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hsizetype"), Qt::CaseInsensitive)) { setElementHSizeType(reader.readElementText().toInt()); continue; @@ -3632,7 +3632,7 @@ void DomSize::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toInt()); continue; @@ -3694,7 +3694,7 @@ void DomDate::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) { setElementYear(reader.readElementText().toInt()); continue; @@ -3774,7 +3774,7 @@ void DomTime::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; @@ -3854,7 +3854,7 @@ void DomDateTime::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; @@ -3990,7 +3990,7 @@ void DomStringList::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; @@ -4013,7 +4013,7 @@ void DomStringList::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { m_string.append(reader.readElementText()); continue; @@ -4063,7 +4063,7 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("resource")) { setAttributeResource(attribute.value().toString()); continue; @@ -4078,7 +4078,7 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -4126,7 +4126,7 @@ void DomResourceIcon::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("theme")) { setAttributeTheme(attribute.value().toString()); continue; @@ -4141,7 +4141,7 @@ void DomResourceIcon::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("normaloff"), Qt::CaseInsensitive)) { auto *v = new DomResourcePixmap(); v->read(reader); @@ -4427,7 +4427,7 @@ void DomString::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; @@ -4450,7 +4450,7 @@ void DomString::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -4495,7 +4495,7 @@ void DomPointF::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; @@ -4557,7 +4557,7 @@ void DomRectF::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; @@ -4655,7 +4655,7 @@ void DomSizeF::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toDouble()); continue; @@ -4717,7 +4717,7 @@ void DomChar::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("unicode"), Qt::CaseInsensitive)) { setElementUnicode(reader.readElementText().toInt()); continue; @@ -4764,7 +4764,7 @@ void DomUrl::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { auto *v = new DomString(); v->read(reader); @@ -4899,7 +4899,7 @@ void DomProperty::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -4914,7 +4914,7 @@ void DomProperty::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("bool"), Qt::CaseInsensitive)) { setElementBool(reader.readElementText()); continue; @@ -5659,7 +5659,7 @@ void DomConnections::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("connection"), Qt::CaseInsensitive)) { auto *v = new DomConnection(); v->read(reader); @@ -5703,7 +5703,7 @@ void DomConnection::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("sender"), Qt::CaseInsensitive)) { setElementSender(reader.readElementText()); continue; @@ -5836,7 +5836,7 @@ void DomConnectionHints::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("hint"), Qt::CaseInsensitive)) { auto *v = new DomConnectionHint(); v->read(reader); @@ -5876,7 +5876,7 @@ void DomConnectionHint::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; @@ -5887,7 +5887,7 @@ void DomConnectionHint::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; @@ -5956,7 +5956,7 @@ void DomDesignerData::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { auto *v = new DomProperty(); v->read(reader); @@ -6001,7 +6001,7 @@ void DomSlots::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) { m_signal.append(reader.readElementText()); continue; @@ -6059,7 +6059,7 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); if (!tag.compare(QLatin1String("tooltip"), Qt::CaseInsensitive)) { auto *v = new DomPropertyToolTip(); v->read(reader); @@ -6114,7 +6114,7 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -6125,7 +6125,7 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; @@ -6153,7 +6153,7 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) { const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - const QStringRef name = attribute.name(); + const auto name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -6172,7 +6172,7 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QStringRef tag = reader.name(); + const auto tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 08a3abf490..94cdb40b6f 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -140,7 +140,7 @@ class DomStringPropertySpecification; */ class QDESIGNER_UILIB_EXPORT DomUI { - Q_DISABLE_COPY(DomUI) + Q_DISABLE_COPY_MOVE(DomUI) public: DomUI() = default; ~DomUI(); @@ -339,7 +339,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomIncludes { - Q_DISABLE_COPY(DomIncludes) + Q_DISABLE_COPY_MOVE(DomIncludes) public: DomIncludes() = default; ~DomIncludes(); @@ -363,7 +363,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomInclude { - Q_DISABLE_COPY(DomInclude) + Q_DISABLE_COPY_MOVE(DomInclude) public: DomInclude() = default; ~DomInclude(); @@ -397,7 +397,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomResources { - Q_DISABLE_COPY(DomResources) + Q_DISABLE_COPY_MOVE(DomResources) public: DomResources() = default; ~DomResources(); @@ -430,7 +430,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomResource { - Q_DISABLE_COPY(DomResource) + Q_DISABLE_COPY_MOVE(DomResource) public: DomResource() = default; ~DomResource(); @@ -451,7 +451,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomActionGroup { - Q_DISABLE_COPY(DomActionGroup) + Q_DISABLE_COPY_MOVE(DomActionGroup) public: DomActionGroup() = default; ~DomActionGroup(); @@ -499,7 +499,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomAction { - Q_DISABLE_COPY(DomAction) + Q_DISABLE_COPY_MOVE(DomAction) public: DomAction() = default; ~DomAction(); @@ -545,7 +545,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomActionRef { - Q_DISABLE_COPY(DomActionRef) + Q_DISABLE_COPY_MOVE(DomActionRef) public: DomActionRef() = default; ~DomActionRef(); @@ -566,7 +566,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomButtonGroup { - Q_DISABLE_COPY(DomButtonGroup) + Q_DISABLE_COPY_MOVE(DomButtonGroup) public: DomButtonGroup() = default; ~DomButtonGroup(); @@ -604,7 +604,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomButtonGroups { - Q_DISABLE_COPY(DomButtonGroups) + Q_DISABLE_COPY_MOVE(DomButtonGroups) public: DomButtonGroups() = default; ~DomButtonGroups(); @@ -628,7 +628,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomCustomWidgets { - Q_DISABLE_COPY(DomCustomWidgets) + Q_DISABLE_COPY_MOVE(DomCustomWidgets) public: DomCustomWidgets() = default; ~DomCustomWidgets(); @@ -652,7 +652,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomHeader { - Q_DISABLE_COPY(DomHeader) + Q_DISABLE_COPY_MOVE(DomHeader) public: DomHeader() = default; ~DomHeader(); @@ -678,7 +678,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomCustomWidget { - Q_DISABLE_COPY(DomCustomWidget) + Q_DISABLE_COPY_MOVE(DomCustomWidget) public: DomCustomWidget() = default; ~DomCustomWidget(); @@ -764,7 +764,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomLayoutDefault { - Q_DISABLE_COPY(DomLayoutDefault) + Q_DISABLE_COPY_MOVE(DomLayoutDefault) public: DomLayoutDefault() = default; ~DomLayoutDefault(); @@ -793,7 +793,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomLayoutFunction { - Q_DISABLE_COPY(DomLayoutFunction) + Q_DISABLE_COPY_MOVE(DomLayoutFunction) public: DomLayoutFunction() = default; ~DomLayoutFunction(); @@ -822,7 +822,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomTabStops { - Q_DISABLE_COPY(DomTabStops) + Q_DISABLE_COPY_MOVE(DomTabStops) public: DomTabStops() = default; ~DomTabStops(); @@ -846,7 +846,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomLayout { - Q_DISABLE_COPY(DomLayout) + Q_DISABLE_COPY_MOVE(DomLayout) public: DomLayout() = default; ~DomLayout(); @@ -937,7 +937,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomLayoutItem { - Q_DISABLE_COPY(DomLayoutItem) + Q_DISABLE_COPY_MOVE(DomLayoutItem) public: DomLayoutItem() = default; ~DomLayoutItem(); @@ -1014,7 +1014,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomRow { - Q_DISABLE_COPY(DomRow) + Q_DISABLE_COPY_MOVE(DomRow) public: DomRow() = default; ~DomRow(); @@ -1038,7 +1038,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomColumn { - Q_DISABLE_COPY(DomColumn) + Q_DISABLE_COPY_MOVE(DomColumn) public: DomColumn() = default; ~DomColumn(); @@ -1062,7 +1062,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomItem { - Q_DISABLE_COPY(DomItem) + Q_DISABLE_COPY_MOVE(DomItem) public: DomItem() = default; ~DomItem(); @@ -1108,7 +1108,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomWidget { - Q_DISABLE_COPY(DomWidget) + Q_DISABLE_COPY_MOVE(DomWidget) public: DomWidget() = default; ~DomWidget(); @@ -1212,7 +1212,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomSpacer { - Q_DISABLE_COPY(DomSpacer) + Q_DISABLE_COPY_MOVE(DomSpacer) public: DomSpacer() = default; ~DomSpacer(); @@ -1245,7 +1245,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomColor { - Q_DISABLE_COPY(DomColor) + Q_DISABLE_COPY_MOVE(DomColor) public: DomColor() = default; ~DomColor(); @@ -1294,7 +1294,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomGradientStop { - Q_DISABLE_COPY(DomGradientStop) + Q_DISABLE_COPY_MOVE(DomGradientStop) public: DomGradientStop() = default; ~DomGradientStop(); @@ -1330,7 +1330,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomGradient { - Q_DISABLE_COPY(DomGradient) + Q_DISABLE_COPY_MOVE(DomGradient) public: DomGradient() = default; ~DomGradient(); @@ -1459,7 +1459,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomBrush { - Q_DISABLE_COPY(DomBrush) + Q_DISABLE_COPY_MOVE(DomBrush) public: DomBrush() = default; ~DomBrush(); @@ -1504,7 +1504,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomColorRole { - Q_DISABLE_COPY(DomColorRole) + Q_DISABLE_COPY_MOVE(DomColorRole) public: DomColorRole() = default; ~DomColorRole(); @@ -1540,7 +1540,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomColorGroup { - Q_DISABLE_COPY(DomColorGroup) + Q_DISABLE_COPY_MOVE(DomColorGroup) public: DomColorGroup() = default; ~DomColorGroup(); @@ -1569,7 +1569,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomPalette { - Q_DISABLE_COPY(DomPalette) + Q_DISABLE_COPY_MOVE(DomPalette) public: DomPalette() = default; ~DomPalette(); @@ -1612,7 +1612,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomFont { - Q_DISABLE_COPY(DomFont) + Q_DISABLE_COPY_MOVE(DomFont) public: DomFont() = default; ~DomFont(); @@ -1701,7 +1701,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomPoint { - Q_DISABLE_COPY(DomPoint) + Q_DISABLE_COPY_MOVE(DomPoint) public: DomPoint() = default; ~DomPoint(); @@ -1734,7 +1734,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomRect { - Q_DISABLE_COPY(DomRect) + Q_DISABLE_COPY_MOVE(DomRect) public: DomRect() = default; ~DomRect(); @@ -1781,7 +1781,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomLocale { - Q_DISABLE_COPY(DomLocale) + Q_DISABLE_COPY_MOVE(DomLocale) public: DomLocale() = default; ~DomLocale(); @@ -1810,7 +1810,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomSizePolicy { - Q_DISABLE_COPY(DomSizePolicy) + Q_DISABLE_COPY_MOVE(DomSizePolicy) public: DomSizePolicy() = default; ~DomSizePolicy(); @@ -1874,7 +1874,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomSize { - Q_DISABLE_COPY(DomSize) + Q_DISABLE_COPY_MOVE(DomSize) public: DomSize() = default; ~DomSize(); @@ -1907,7 +1907,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomDate { - Q_DISABLE_COPY(DomDate) + Q_DISABLE_COPY_MOVE(DomDate) public: DomDate() = default; ~DomDate(); @@ -1947,7 +1947,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomTime { - Q_DISABLE_COPY(DomTime) + Q_DISABLE_COPY_MOVE(DomTime) public: DomTime() = default; ~DomTime(); @@ -1987,7 +1987,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomDateTime { - Q_DISABLE_COPY(DomDateTime) + Q_DISABLE_COPY_MOVE(DomDateTime) public: DomDateTime() = default; ~DomDateTime(); @@ -2048,7 +2048,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomStringList { - Q_DISABLE_COPY(DomStringList) + Q_DISABLE_COPY_MOVE(DomStringList) public: DomStringList() = default; ~DomStringList(); @@ -2105,7 +2105,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomResourcePixmap { - Q_DISABLE_COPY(DomResourcePixmap) + Q_DISABLE_COPY_MOVE(DomResourcePixmap) public: DomResourcePixmap() = default; ~DomResourcePixmap(); @@ -2139,7 +2139,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomResourceIcon { - Q_DISABLE_COPY(DomResourceIcon) + Q_DISABLE_COPY_MOVE(DomResourceIcon) public: DomResourceIcon() = default; ~DomResourceIcon(); @@ -2244,7 +2244,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomString { - Q_DISABLE_COPY(DomString) + Q_DISABLE_COPY_MOVE(DomString) public: DomString() = default; ~DomString(); @@ -2294,7 +2294,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomPointF { - Q_DISABLE_COPY(DomPointF) + Q_DISABLE_COPY_MOVE(DomPointF) public: DomPointF() = default; ~DomPointF(); @@ -2327,7 +2327,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomRectF { - Q_DISABLE_COPY(DomRectF) + Q_DISABLE_COPY_MOVE(DomRectF) public: DomRectF() = default; ~DomRectF(); @@ -2374,7 +2374,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomSizeF { - Q_DISABLE_COPY(DomSizeF) + Q_DISABLE_COPY_MOVE(DomSizeF) public: DomSizeF() = default; ~DomSizeF(); @@ -2407,7 +2407,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomChar { - Q_DISABLE_COPY(DomChar) + Q_DISABLE_COPY_MOVE(DomChar) public: DomChar() = default; ~DomChar(); @@ -2433,7 +2433,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomUrl { - Q_DISABLE_COPY(DomUrl) + Q_DISABLE_COPY_MOVE(DomUrl) public: DomUrl() = default; ~DomUrl(); @@ -2460,7 +2460,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomProperty { - Q_DISABLE_COPY(DomProperty) + Q_DISABLE_COPY_MOVE(DomProperty) public: DomProperty() = default; ~DomProperty(); @@ -2651,7 +2651,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomConnections { - Q_DISABLE_COPY(DomConnections) + Q_DISABLE_COPY_MOVE(DomConnections) public: DomConnections() = default; ~DomConnections(); @@ -2675,7 +2675,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomConnection { - Q_DISABLE_COPY(DomConnection) + Q_DISABLE_COPY_MOVE(DomConnection) public: DomConnection() = default; ~DomConnection(); @@ -2730,7 +2730,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomConnectionHints { - Q_DISABLE_COPY(DomConnectionHints) + Q_DISABLE_COPY_MOVE(DomConnectionHints) public: DomConnectionHints() = default; ~DomConnectionHints(); @@ -2754,7 +2754,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomConnectionHint { - Q_DISABLE_COPY(DomConnectionHint) + Q_DISABLE_COPY_MOVE(DomConnectionHint) public: DomConnectionHint() = default; ~DomConnectionHint(); @@ -2796,7 +2796,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomDesignerData { - Q_DISABLE_COPY(DomDesignerData) + Q_DISABLE_COPY_MOVE(DomDesignerData) public: DomDesignerData() = default; ~DomDesignerData(); @@ -2820,7 +2820,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomSlots { - Q_DISABLE_COPY(DomSlots) + Q_DISABLE_COPY_MOVE(DomSlots) public: DomSlots() = default; ~DomSlots(); @@ -2849,7 +2849,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomPropertySpecifications { - Q_DISABLE_COPY(DomPropertySpecifications) + Q_DISABLE_COPY_MOVE(DomPropertySpecifications) public: DomPropertySpecifications() = default; ~DomPropertySpecifications(); @@ -2878,7 +2878,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomPropertyToolTip { - Q_DISABLE_COPY(DomPropertyToolTip) + Q_DISABLE_COPY_MOVE(DomPropertyToolTip) public: DomPropertyToolTip() = default; ~DomPropertyToolTip(); @@ -2899,7 +2899,7 @@ private: }; class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification { - Q_DISABLE_COPY(DomStringPropertySpecification) + Q_DISABLE_COPY_MOVE(DomStringPropertySpecification) public: DomStringPropertySpecification() = default; ~DomStringPropertySpecification(); -- cgit v1.2.3 From 103d307f2e596e5e7d2eb706117223bf65264e5f Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 30 Sep 2019 12:00:43 -0700 Subject: Be explicit about QDataStream serialization: explicit casts to int The reader uses int variables, so use the same in the writer. Change-Id: I1496b069cc534f1a838dfffd15c94c7cacd3dd93 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/rhi/qshader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index c22b029dc8..9d35d83336 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -348,10 +348,10 @@ void QShader::removeShader(const QShaderKey &key) static void writeShaderKey(QDataStream *ds, const QShaderKey &k) { - *ds << k.source(); + *ds << int(k.source()); *ds << k.sourceVersion().version(); *ds << k.sourceVersion().flags(); - *ds << k.sourceVariant(); + *ds << int(k.sourceVariant()); } /*! @@ -369,7 +369,7 @@ QByteArray QShader::serialized() const return QByteArray(); ds << QSB_VERSION; - ds << d->stage; + ds << int(d->stage); ds << d->desc.toBinaryJson(); ds << d->shaders.count(); for (auto it = d->shaders.cbegin(), itEnd = d->shaders.cend(); it != itEnd; ++it) { -- cgit v1.2.3 From ad11cab4842a4d35fe80641ae3eec7f2d8817652 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Fri, 10 Aug 2018 12:17:49 +0200 Subject: Allow longer time-zone components on Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Android uses its own time-zone naming, which includes a zone called "Canada/East-Saskatchewan", whose second component is 17 characters long. This violates a rule in the IANA naming scheme for zones, that limits components to 14 characters each. So tweak the isValidId() check to allow Android its long names. Android has added Outer Mongolian time-zones, which are as borked as many others in 1970, so blacklist those transitionEachZone() tests. Fixes: QTBUG-69128 Change-Id: I46f674f095431335b16900860d83b624257ae3bb Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> --- src/corelib/time/qtimezoneprivate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp index 569b343187..00dc8b4ced 100644 --- a/src/corelib/time/qtimezoneprivate.cpp +++ b/src/corelib/time/qtimezoneprivate.cpp @@ -632,7 +632,13 @@ bool QTimeZonePrivate::isValidId(const QByteArray &ianaId) // Somewhat slack hand-rolled version: const int MinSectionLength = 1; +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + // Android has its own naming of zones. + // "Canada/East-Saskatchewan" has a 17-character second component. + const int MaxSectionLength = 17; +#else const int MaxSectionLength = 14; +#endif int sectionLength = 0; for (const char *it = ianaId.begin(), * const end = ianaId.end(); it != end; ++it, ++sectionLength) { const char ch = *it; -- cgit v1.2.3 From 813e4460de0316f176d03f19f497e52ddc3c859e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Mon, 11 Nov 2019 12:24:31 +0100 Subject: eglfs: kms: Fix hw cursor with multiple screens We used to have the assumption that moving the cursor to an out of range position is valid and will result in a hidden cursor. This is apparently not the case. For example, on an RPi4 with Mesa V3D we get lots of funny artifacts after doing drmModeMoveCursor() to invalid positions. To remedy this, start hiding the cursor correctly when the position is clearly out of the screen's bounds. Task-number: QTBUG-79924 Change-Id: I3ef7ad0ce928546399443f21452f0b6deadf8036 Reviewed-by: Andy Nichols <andy.nichols@qt.io> --- .../eglfs_kms/qeglfskmsgbmcursor.cpp | 44 ++++++++++++++++------ .../eglfs_kms/qeglfskmsgbmcursor.h | 2 + .../eglfs_kms/qeglfskmsgbmdevice.cpp | 10 +++++ .../eglfs_kms/qeglfskmsgbmdevice.h | 4 ++ .../eglfs_kms_support/qeglfskmsscreen.cpp | 1 + .../eglfs_kms_support/qeglfskmsscreen.h | 4 ++ 6 files changed, 53 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp index 4d0cf0c47e..1125bcb390 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp @@ -214,7 +214,8 @@ void QEglFSKmsGbmCursor::changeCursor(QCursor *windowCursor, QWindow *window) Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen); - + if (kmsScreen->isCursorOutOfRange()) + continue; int status = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, handle, m_cursorSize.width(), m_cursorSize.height()); if (status != 0) @@ -232,17 +233,36 @@ void QEglFSKmsGbmCursor::setPos(const QPoint &pos) { Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen); - QPoint origin = kmsScreen->geometry().topLeft(); - QPoint localPos = pos - origin; - QPoint adjustedPos = localPos - m_cursorImage.hotspot(); - - int ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, adjustedPos.x(), adjustedPos.y()); - if (ret == 0) - m_pos = pos; - else - qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret); - - kmsScreen->handleCursorMove(pos); + const QRect screenGeom = kmsScreen->geometry(); + const QPoint origin = screenGeom.topLeft(); + const QPoint localPos = pos - origin; + const QPoint adjustedLocalPos = localPos - m_cursorImage.hotspot(); + + if (localPos.x() < 0 || localPos.y() < 0 + || localPos.x() >= screenGeom.width() || localPos.y() >= screenGeom.height()) + { + if (!kmsScreen->isCursorOutOfRange()) { + kmsScreen->setCursorOutOfRange(true); + drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0); + } + } else { + int ret; + if (kmsScreen->isCursorOutOfRange()) { + kmsScreen->setCursorOutOfRange(false); + uint32_t handle = gbm_bo_get_handle(m_bo).u32; + ret = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, + handle, m_cursorSize.width(), m_cursorSize.height()); + } else { + ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, + adjustedLocalPos.x(), adjustedLocalPos.y()); + } + if (ret == 0) + m_pos = pos; + else + qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret); + + kmsScreen->handleCursorMove(pos); + } } } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h index d47b579238..5d2dfedba2 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h @@ -85,6 +85,8 @@ public: void updateMouseStatus(); + void reevaluateVisibilityForScreens() { setPos(pos()); } + private: void initCursorAtlas(); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp index 20127ae7f7..f4a69483bd 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp @@ -155,4 +155,14 @@ void QEglFSKmsGbmDevice::registerScreenCloning(QPlatformScreen *screen, gbmScreen->initCloning(screenThisScreenClones, screensCloningThisScreen); } +void QEglFSKmsGbmDevice::registerScreen(QPlatformScreen *screen, + bool isPrimary, + const QPoint &virtualPos, + const QList<QPlatformScreen *> &virtualSiblings) +{ + QEglFSKmsDevice::registerScreen(screen, isPrimary, virtualPos, virtualSiblings); + if (screenConfig()->hwCursor() && m_globalCursor) + m_globalCursor->reevaluateVisibilityForScreens(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h index 518e2ce58b..f1476f8ffa 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h @@ -70,6 +70,10 @@ public: void registerScreenCloning(QPlatformScreen *screen, QPlatformScreen *screenThisScreenClones, const QVector<QPlatformScreen *> &screensCloningThisScreen) override; + void registerScreen(QPlatformScreen *screen, + bool isPrimary, + const QPoint &virtualPos, + const QList<QPlatformScreen *> &virtualSiblings) override; private: Q_DISABLE_COPY(QEglFSKmsGbmDevice) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index e5354d97bd..b097f67e93 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -72,6 +72,7 @@ QEglFSKmsScreen::QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, b : QEglFSScreen(static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration())->display()) , m_device(device) , m_output(output) + , m_cursorOutOfRange(false) , m_powerState(PowerStateOn) , m_interruptHandler(new QEglFSKmsInterruptHandler(this)) , m_headless(headless) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h index 7f395aacb7..93d7e4c1eb 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h @@ -99,12 +99,16 @@ public: QPlatformScreen::PowerState powerState() const override; void setPowerState(QPlatformScreen::PowerState state) override; + bool isCursorOutOfRange() const { return m_cursorOutOfRange; } + void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; } + protected: QKmsDevice *m_device; QKmsOutput m_output; QEdidParser m_edid; QPoint m_pos; + bool m_cursorOutOfRange; QList<QPlatformScreen *> m_siblings; -- cgit v1.2.3 From 14bb413309092adc53e8451daff5690c4698c07d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Fri, 8 Nov 2019 13:15:53 +0100 Subject: eglfs: kms: Read page flip events on a dedicated thread Task-number: QTBUG-74953 Change-Id: I9a630c9245d8b0afe40ade9199cf4f1d358275da Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- .../eglfs_kms/qeglfskmsgbmdevice.cpp | 4 + .../eglfs_kms/qeglfskmsgbmintegration.cpp | 2 - .../eglfs_kms/qeglfskmsgbmscreen.cpp | 28 +-- .../eglfs_kms/qeglfskmsgbmscreen.h | 16 +- .../qeglfskmsegldevicescreen.cpp | 2 +- .../eglfs_kms_egldevice/qeglfskmsegldevicescreen.h | 2 +- .../eglfs_kms_support/eglfs_kms_support.pro | 6 +- .../eglfs_kms_support/qeglfskmsdevice.h | 6 + .../eglfs_kms_support/qeglfskmseventreader.cpp | 218 +++++++++++++++++++++ .../eglfs_kms_support/qeglfskmseventreader.h | 99 ++++++++++ .../eglfs_kms_support/qeglfskmsscreen.cpp | 3 +- .../eglfs_kms_support/qeglfskmsscreen.h | 7 +- .../eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp | 2 +- .../eglfs_kms_vsp2/qeglfskmsvsp2screen.h | 2 +- 14 files changed, 354 insertions(+), 43 deletions(-) create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp index f4a69483bd..503419cf91 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp @@ -83,6 +83,8 @@ bool QEglFSKmsGbmDevice::open() setFd(fd); + m_eventReader.create(this); + return true; } @@ -90,6 +92,8 @@ void QEglFSKmsGbmDevice::close() { // Note: screens are gone at this stage. + m_eventReader.destroy(); + if (m_gbm_device) { gbm_device_destroy(m_gbm_device); m_gbm_device = nullptr; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp index f154520669..caa1187b40 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp @@ -54,8 +54,6 @@ QT_BEGIN_NAMESPACE -QMutex QEglFSKmsGbmScreen::m_waitForFlipMutex; - QEglFSKmsGbmIntegration::QEglFSKmsGbmIntegration() { qCDebug(qLcEglfsKmsDebug, "New DRM/KMS via GBM integration created"); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 333433f666..6f5c3b6953 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -110,7 +110,7 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject( return fb.take(); } -QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless) +QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless) : QEglFSKmsScreen(device, output, headless) , m_gbm_surface(nullptr) , m_gbm_bo_current(nullptr) @@ -276,15 +276,12 @@ void QEglFSKmsGbmScreen::waitForFlip() if (!m_gbm_bo_next) return; - QMutexLocker lock(&m_waitForFlipMutex); - while (m_gbm_bo_next) { - drmEventContext drmEvent; - memset(&drmEvent, 0, sizeof(drmEvent)); - drmEvent.version = 2; - drmEvent.vblank_handler = nullptr; - drmEvent.page_flip_handler = pageFlipHandler; - drmHandleEvent(device()->fd(), &drmEvent); - } + m_flipMutex.lock(); + device()->eventReader()->startWaitFlip(this, &m_flipMutex, &m_flipCond); + m_flipCond.wait(&m_flipMutex); + m_flipMutex.unlock(); + + flipFinished(); #if QT_CONFIG(drm_atomic) device()->threadLocalAtomicReset(); @@ -397,17 +394,6 @@ void QEglFSKmsGbmScreen::flip() #endif } -void QEglFSKmsGbmScreen::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) -{ - Q_UNUSED(fd); - Q_UNUSED(sequence); - Q_UNUSED(tv_sec); - Q_UNUSED(tv_usec); - - QEglFSKmsGbmScreen *screen = static_cast<QEglFSKmsGbmScreen *>(user_data); - screen->flipFinished(); -} - void QEglFSKmsGbmScreen::flipFinished() { if (m_cloneSource) { diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h index b94f44b7b1..69feeee703 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h @@ -43,7 +43,8 @@ #define QEGLFSKMSGBMSCREEN_H #include "qeglfskmsscreen.h" -#include <QtCore/QMutex> +#include <QMutex> +#include <QWaitCondition> #include <gbm.h> @@ -54,7 +55,7 @@ class QEglFSKmsGbmCursor; class QEglFSKmsGbmScreen : public QEglFSKmsScreen { public: - QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless); + QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless); ~QEglFSKmsGbmScreen(); QPlatformCursor *cursor() const override; @@ -75,18 +76,15 @@ private: void cloneDestFlipFinished(QEglFSKmsGbmScreen *cloneDestScreen); void updateFlipStatus(); - static void pageFlipHandler(int fd, - unsigned int sequence, - unsigned int tv_sec, - unsigned int tv_usec, - void *user_data); - gbm_surface *m_gbm_surface; gbm_bo *m_gbm_bo_current; gbm_bo *m_gbm_bo_next; bool m_flipPending; + QMutex m_flipMutex; + QWaitCondition m_flipCond; + QScopedPointer<QEglFSKmsGbmCursor> m_cursor; struct FrameBuffer { @@ -101,8 +99,6 @@ private: bool cloneFlipPending = false; }; QVector<CloneDestination> m_cloneDests; - - static QMutex m_waitForFlipMutex; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp index 1626c86239..5a62e437c4 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) -QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output) +QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output) : QEglFSKmsScreen(device, output) { } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h index 5efe35f8b3..961398ba3e 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen { public: - QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output); + QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output); ~QEglFSKmsEglDeviceScreen(); QPlatformCursor *cursor() const override; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro index 40806b6a9b..e51903ed96 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro @@ -14,9 +14,11 @@ CONFIG += egl SOURCES += $$PWD/qeglfskmsintegration.cpp \ $$PWD/qeglfskmsdevice.cpp \ - $$PWD/qeglfskmsscreen.cpp + $$PWD/qeglfskmsscreen.cpp \ + $$PWD/qeglfskmseventreader.cpp HEADERS += $$PWD/qeglfskmsintegration.h \ $$PWD/qeglfskmsdevice.h \ $$PWD/qeglfskmsscreen.h \ - $$PWD/qeglfskmshelpers.h + $$PWD/qeglfskmshelpers.h \ + $$PWD/qeglfskmseventreader.h diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h index fc83a620d9..34908aa60f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h @@ -42,6 +42,7 @@ #define QEGLFSKMSDEVICE_H #include "private/qeglfsglobal_p.h" +#include "qeglfskmseventreader.h" #include <QtKmsSupport/private/qkmsdevice_p.h> QT_BEGIN_NAMESPACE @@ -55,6 +56,11 @@ public: bool isPrimary, const QPoint &virtualPos, const QList<QPlatformScreen *> &virtualSiblings) override; + + QEglFSKmsEventReader *eventReader() { return &m_eventReader; } + +protected: + QEglFSKmsEventReader m_eventReader; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp new file mode 100644 index 0000000000..645a0ae2e9 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qeglfskmseventreader.h" +#include "qeglfskmsdevice.h" +#include <QSocketNotifier> +#include <QCoreApplication> +#include <QLoggingCategory> + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) + +static void pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) +{ + Q_UNUSED(fd); + Q_UNUSED(sequence); + Q_UNUSED(tv_sec); + Q_UNUSED(tv_usec); + + QEglFSKmsEventReaderThread *t = static_cast<QEglFSKmsEventReaderThread *>(QThread::currentThread()); + t->eventHost()->handlePageFlipCompleted(user_data); +} + +class RegisterWaitFlipEvent : public QEvent +{ +public: + static const QEvent::Type TYPE = QEvent::Type(QEvent::User + 1); + RegisterWaitFlipEvent(void *key, QMutex *mutex, QWaitCondition *cond) + : QEvent(TYPE), key(key), mutex(mutex), cond(cond) + { } + void *key; + QMutex *mutex; + QWaitCondition *cond; +}; + +bool QEglFSKmsEventHost::event(QEvent *event) +{ + if (event->type() == RegisterWaitFlipEvent::TYPE) { + RegisterWaitFlipEvent *e = static_cast<RegisterWaitFlipEvent *>(event); + PendingFlipWait *p = &pendingFlipWaits[0]; + PendingFlipWait *end = p + MAX_FLIPS; + while (p < end) { + if (!p->key) { + p->key = e->key; + p->mutex = e->mutex; + p->cond = e->cond; + updateStatus(); + return true; + } + ++p; + } + qWarning("Cannot queue page flip wait (more than %d screens?)", MAX_FLIPS); + e->mutex->lock(); + e->cond->wakeOne(); + e->mutex->unlock(); + return true; + } + return QObject::event(event); +} + +void QEglFSKmsEventHost::updateStatus() +{ + void **begin = &completedFlips[0]; + void **end = begin + MAX_FLIPS; + + for (int i = 0; i < MAX_FLIPS; ++i) { + PendingFlipWait *w = pendingFlipWaits + i; + if (!w->key) + continue; + + void **p = begin; + while (p < end) { + if (*p == w->key) { + *p = nullptr; + w->key = nullptr; + w->mutex->lock(); + w->cond->wakeOne(); + w->mutex->unlock(); + return; + } + ++p; + } + } +} + +void QEglFSKmsEventHost::handlePageFlipCompleted(void *key) +{ + void **begin = &completedFlips[0]; + void **end = begin + MAX_FLIPS; + void **p = begin; + while (p < end) { + if (*p == key) { + updateStatus(); + return; + } + ++p; + } + p = begin; + while (p < end) { + if (!*p) { + *p = key; + updateStatus(); + return; + } + ++p; + } + qWarning("Cannot store page flip status (more than %d screens?)", MAX_FLIPS); +} + +void QEglFSKmsEventReaderThread::run() +{ + qCDebug(qLcEglfsKmsDebug, "Event reader thread: entering event loop"); + + QSocketNotifier notifier(m_fd, QSocketNotifier::Read); + QObject::connect(¬ifier, &QSocketNotifier::activated, ¬ifier, [this] { + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = 2; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; + drmHandleEvent(m_fd, &drmEvent); + }); + + exec(); + + m_ev.moveToThread(thread()); // move back to the thread where m_ev was created + + qCDebug(qLcEglfsKmsDebug, "Event reader thread: event loop stopped"); +} + +QEglFSKmsEventReader::~QEglFSKmsEventReader() +{ + destroy(); +} + +void QEglFSKmsEventReader::create(QEglFSKmsDevice *device) +{ + destroy(); + + if (!device) + return; + + m_device = device; + + qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d", + m_device, m_device->fd()); + + m_thread = new QEglFSKmsEventReaderThread(m_device->fd()); + m_thread->start(); + + // Change thread affinity for the event host, so that postEvent() + // goes through the event reader thread's event loop for that object. + m_thread->eventHost()->moveToThread(m_thread); +} + +void QEglFSKmsEventReader::destroy() +{ + if (!m_device) + return; + + qCDebug(qLcEglfsKmsDebug, "Stopping event reader for device %p", m_device); + + if (m_thread) { + m_thread->quit(); + m_thread->wait(); + delete m_thread; + m_thread = nullptr; + } + + m_device = nullptr; +} + +void QEglFSKmsEventReader::startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond) +{ + if (m_thread) { + QCoreApplication::postEvent(m_thread->eventHost(), + new RegisterWaitFlipEvent(key, mutex, cond)); + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h new file mode 100644 index 0000000000..4aa285b0fe --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLFSKKMSEVENTREADER_H +#define QEGLFSKKMSEVENTREADER_H + +#include "private/qeglfsglobal_p.h" +#include <QObject> +#include <QThread> +#include <QMutex> +#include <QWaitCondition> + +QT_BEGIN_NAMESPACE + +class QEglFSKmsDevice; + +struct QEglFSKmsEventHost : public QObject +{ + struct PendingFlipWait { + void *key; + QMutex *mutex; + QWaitCondition *cond; + }; + + static const int MAX_FLIPS = 32; + void *completedFlips[MAX_FLIPS] = {}; + QEglFSKmsEventHost::PendingFlipWait pendingFlipWaits[MAX_FLIPS] = {}; + + bool event(QEvent *event) override; + void updateStatus(); + void handlePageFlipCompleted(void *key); +}; + +class QEglFSKmsEventReaderThread : public QThread +{ +public: + QEglFSKmsEventReaderThread(int fd) : m_fd(fd) { } + void run() override; + QEglFSKmsEventHost *eventHost() { return &m_ev; } + +private: + int m_fd; + QEglFSKmsEventHost m_ev; +}; + +class Q_EGLFS_EXPORT QEglFSKmsEventReader +{ +public: + ~QEglFSKmsEventReader(); + + void create(QEglFSKmsDevice *device); + void destroy(); + + void startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond); + +private: + QEglFSKmsDevice *m_device = nullptr; + QEglFSKmsEventReaderThread *m_thread = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QEGLFSKKMSEVENTREADER_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index b097f67e93..959f17eba3 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qeglfskmsscreen.h" +#include "qeglfskmsdevice.h" #include "qeglfsintegration_p.h" #include <QtCore/QLoggingCategory> @@ -68,7 +69,7 @@ private: QEglFSKmsScreen *m_screen; }; -QEglFSKmsScreen::QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, bool headless) +QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless) : QEglFSScreen(static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration())->display()) , m_device(device) , m_output(output) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h index 93d7e4c1eb..a5c8f5b4e8 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h @@ -51,12 +51,13 @@ QT_BEGIN_NAMESPACE +class QEglFSKmsDevice; class QEglFSKmsInterruptHandler; class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen { public: - QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, bool headless = false); + QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless = false); ~QEglFSKmsScreen(); void setVirtualPosition(const QPoint &pos); @@ -87,7 +88,7 @@ public: int currentMode() const override; int preferredMode() const override; - QKmsDevice *device() const { return m_device; } + QEglFSKmsDevice *device() const { return m_device; } virtual void waitForFlip(); @@ -103,7 +104,7 @@ public: void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; } protected: - QKmsDevice *m_device; + QEglFSKmsDevice *m_device; QKmsOutput m_output; QEdidParser m_edid; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp index 475d9d55dd..c255bc84b7 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp @@ -99,7 +99,7 @@ QEglFSKmsVsp2Screen::DmaBuffer *QEglFSKmsVsp2Screen::dmaBufferForGbmBuffer(gbm_b return fb.take(); } -QEglFSKmsVsp2Screen::QEglFSKmsVsp2Screen(QKmsDevice *device, const QKmsOutput &output) +QEglFSKmsVsp2Screen::QEglFSKmsVsp2Screen(QEglFSKmsDevice *device, const QKmsOutput &output) : QEglFSKmsScreen(device, output) , m_blender(new Blender(this)) { diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h index 7618510333..378786643d 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE class QEglFSKmsVsp2Screen : public QEglFSKmsScreen { public: - QEglFSKmsVsp2Screen(QKmsDevice *device, const QKmsOutput &output); + QEglFSKmsVsp2Screen(QEglFSKmsDevice *device, const QKmsOutput &output); gbm_surface *createSurface(); void resetSurface(); -- cgit v1.2.3 From 80ac9e8b7ce8e3f79af0b00610a0a4b0ff17abe4 Mon Sep 17 00:00:00 2001 From: Cristian Adam <cristian.adam@gmail.com> Date: Tue, 12 Nov 2019 17:59:51 +0100 Subject: Compile fix for MinGW 8.1.0 Workaround for libpng bug in GCC 8.1.0. Task-number: QTQAINFRA-3303 Change-Id: Id7668e795cb4ab16de3199fc3727d844aa31bfad Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> --- src/gui/image/image.pri | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 3b2ced3f58..1f42f28d1e 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -79,6 +79,14 @@ qtConfig(png) { HEADERS += image/qpnghandler_p.h SOURCES += image/qpnghandler.cpp QMAKE_USE_PRIVATE += libpng + + win32:mingw { + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86048 + GCC_VERSION = "$${QMAKE_GCC_MAJOR_VERSION}.$${QMAKE_GCC_MINOR_VERSION}.$${QMAKE_GCC_PATCH_VERSION}" + equals(GCC_VERSION, "8.1.0") { + QMAKE_CXXFLAGS += -fno-reorder-blocks-and-partition + } + } } # SIMD -- cgit v1.2.3 From c15a069830baf87f57c84e86326cf86ba9a39713 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 12 Jun 2019 20:49:06 +0200 Subject: QTreeView: make sure to not ask the old model during setModel Within QTreeView::setModel() the header might emit columnCountChanged which then tries to update the geometries based on the old model which is wrong. Fix it by setting geometryRecursionBlock to true so QTreeView::updateGeometries() will not ask the old model for it's data. Fixes: QTBUG-75982 Change-Id: Ia0dd36cd7c6c5347fbc285deac43da6941accbe7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/itemviews/qtreeview.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 413cc2a9cd..034c1f4b4f 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -233,7 +233,9 @@ void QTreeView::setModel(QAbstractItemModel *model) d->viewItems.clear(); d->expandedIndexes.clear(); d->hiddenIndexes.clear(); + d->geometryRecursionBlock = true; // do not update geometries due to signals from the headers d->header->setModel(model); + d->geometryRecursionBlock = false; QAbstractItemView::setModel(model); // QAbstractItemView connects to a private slot -- cgit v1.2.3 From 41702d8455a9e88ac70108e500a10e7bd4df2771 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 21 Oct 2019 21:23:08 +0200 Subject: Honor alpha for SH_Table_GridLineColor Make sure to honor the alpha channel for the color returned by SH_Table_GridLineColor. Fixes: QTBUG-74909 Change-Id: If9688329e5e2ab41833dfeb7e6292fdfcbf63aa1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 2 +- src/widgets/doc/snippets/javastyle.cpp | 2 +- src/widgets/itemviews/qtableview.cpp | 2 +- src/widgets/styles/qcommonstyle.cpp | 2 +- src/widgets/styles/qfusionstyle.cpp | 2 +- src/widgets/styles/qstyle.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 610329a350..603c6e93f3 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2873,7 +2873,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = false; break; case SH_Table_GridLineColor: - ret = int(qt_mac_toQColor(NSColor.gridColor).rgb()); + ret = int(qt_mac_toQColor(NSColor.gridColor).rgba()); break; default: ret = QCommonStyle::styleHint(sh, opt, w, hret); diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index e213d65946..345267c8fc 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -2110,7 +2110,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co break; case SH_Table_GridLineColor: if (option) - ret = int(option->palette.color(QPalette::Base).darker(118).rgb()); + ret = int(option->palette.color(QPalette::Base).darker(118).rgba()); else ret = -1; break; diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp index 8657d5ed29..3d1b1e0030 100644 --- a/src/widgets/doc/snippets/javastyle.cpp +++ b/src/widgets/doc/snippets/javastyle.cpp @@ -2589,7 +2589,7 @@ int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option, switch (hint) { case SH_Table_GridLineColor: { - ret = static_cast<int>(option->palette.color(QPalette::Mid).rgb()); + ret = static_cast<int>(option->palette.color(QPalette::Mid).rgba()); break; } case QStyle::SH_Menu_Scrollable: diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 11c5be10fd..81fceba8dc 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1431,7 +1431,7 @@ void QTableView::paintEvent(QPaintEvent *event) const bool showGrid = d->showGrid; const int gridSize = showGrid ? 1 : 0; const int gridHint = style()->styleHint(QStyle::SH_Table_GridLineColor, &option, this); - const QColor gridColor = static_cast<QRgb>(gridHint); + const QColor gridColor = QColor::fromRgba(static_cast<QRgb>(gridHint)); const QPen gridPen = QPen(gridColor, 0, d->gridStyle); const QHeaderView *verticalHeader = d->verticalHeader; const QHeaderView *horizontalHeader = d->horizontalHeader; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 271b43fe89..861dd7a54c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5143,7 +5143,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_Table_GridLineColor: if (opt) - ret = opt->palette.color(QPalette::Mid).rgb(); + ret = opt->palette.color(QPalette::Mid).rgba(); else ret = -1; break; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index b58dc1660a..0f01a70faa 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3733,7 +3733,7 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW return 0; case SH_Table_GridLineColor: - return option ? option->palette.window().color().darker(120).rgb() : 0; + return option ? option->palette.window().color().darker(120).rgba() : 0; case SH_MessageBox_TextInteractionFlags: return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 6cbed34c3a..d2f5ac76f9 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1835,7 +1835,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_LineEdit_PasswordMaskDelay Determines the delay before visible character is masked with password character, in milliseconds. This enum value was added in Qt 5.4. - \value SH_Table_GridLineColor The RGB value of the grid for a table. + \value SH_Table_GridLineColor The RGBA value of the grid for a table. \value SH_UnderlineShortcut Whether shortcuts are underlined. -- cgit v1.2.3 From a4751f8824723acaee4b9d8aa78a59c2aa36cb3e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 25 Sep 2019 19:54:49 +0200 Subject: QShortcut: add pmf ctor overloads Provide pointer to member function overloads for the QShortcut ctor. The ctor with two functors but no contexts is not provided since it creates ambiguousness. [ChangeLog][QtWidgets][QShortcut] QShortcut ctor has now pmf overloads Fixes: QTBUG-77816 Change-Id: Ic9a759cde5150dbb94c2fd351b88ee8e447e0852 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/kernel/qshortcut.cpp | 74 ++++++++++++++++++++++++++++++++++++++-- src/widgets/kernel/qshortcut.h | 60 ++++++++++++++++++++++++++++++-- 2 files changed, 130 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index eec65c8625..d469279ea5 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -419,6 +419,76 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge \sa activated() */ +/*! + \fn template<typename Functor> + QShortcut(const QKeySequence &key, QWidget *parent, + Functor functor, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + \since 5.15 + \overload + + This is a QShortcut convenience constructor which connects the shortcut's + \l{QShortcut::activated()}{activated()} signal to the \a functor. +*/ +/*! + \fn template<typename Functor> + QShortcut(const QKeySequence &key, QWidget *parent, + const QObject *context, Functor functor, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + \since 5.15 + \overload + + This is a QShortcut convenience constructor which connects the shortcut's + \l{QShortcut::activated()}{activated()} signal to the \a functor. + + The \a functor can be a pointer to a member function of the \a context object. + + If the \a context object is destroyed, the \a functor will not be called. +*/ +/*! + \fn template<typename Functor, typename FunctorAmbiguous> + QShortcut(const QKeySequence &key, QWidget *parent, + const QObject *context1, Functor functor, + FunctorAmbiguous functorAmbiguous, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + \since 5.15 + \overload + + This is a QShortcut convenience constructor which connects the shortcut's + \l{QShortcut::activated()}{activated()} signal to the \a functor and + \l{QShortcut::activatedAmbiguously()}{activatedAmbiguously()} + signal to the \a FunctorAmbiguous. + + The \a functor and \a FunctorAmbiguous can be a pointer to a member + function of the \a context object. + + If the \a context object is destroyed, the \a functor and + \a FunctorAmbiguous will not be called. +*/ +/*! + \fn template<typename Functor, typename FunctorAmbiguous> + QShortcut(const QKeySequence &key, QWidget *parent, + const QObject *context1, Functor functor, + const QObject *context2, FunctorAmbiguous functorAmbiguous, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + \since 5.15 + \overload + + This is a QShortcut convenience constructor which connects the shortcut's + \l{QShortcut::activated()}{activated()} signal to the \a functor and + \l{QShortcut::activatedAmbiguously()}{activatedAmbiguously()} + signal to the \a FunctorAmbiguous. + + The \a functor can be a pointer to a member function of the + \a context1 object. + The \a FunctorAmbiguous can be a pointer to a member function of the + \a context2 object. + + If the \a context1 object is destroyed, the \a functor will not be called. + If the \a context2 object is destroyed, the \a FunctorAmbiguous + will not be called. +*/ + /* \internal Private data accessed through d-pointer. @@ -479,13 +549,13 @@ QShortcut::QShortcut(QWidget *parent) */ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, const char *member, const char *ambiguousMember, - Qt::ShortcutContext context) + Qt::ShortcutContext shortcutContext) : QShortcut(parent) { QAPP_CHECK("QShortcut"); Q_D(QShortcut); - d->sc_context = context; + d->sc_context = shortcutContext; d->sc_sequence = key; d->redoGrab(QGuiApplicationPrivate::instance()->shortcutMap); if (member) diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index 6dcf4971b2..4f9c5ba0f7 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -61,9 +61,65 @@ class Q_WIDGETS_EXPORT QShortcut : public QObject Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext) public: explicit QShortcut(QWidget *parent); - QShortcut(const QKeySequence& key, QWidget *parent, + QShortcut(const QKeySequence &key, QWidget *parent, const char *member = nullptr, const char *ambiguousMember = nullptr, - Qt::ShortcutContext context = Qt::WindowShortcut); + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); +#ifdef Q_CLANG_QDOC + template<typename Functor> + QShortcut(const QKeySequence &key, QWidget *parent, + Functor functor, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + template<typename Functor> + QShortcut(const QKeySequence &key, QWidget *parent, + const QObject *context, Functor functor, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + template<typename Functor, typename FunctorAmbiguous> + QShortcut(const QKeySequence &key, QWidget *parent, + const QObject *context1, Functor functor, + FunctorAmbiguous functorAmbiguous, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); + template<typename Functor, typename FunctorAmbiguous> + QShortcut(const QKeySequence &key, QWidget *parent, + const QObject *context1, Functor functor, + const QObject *context2, FunctorAmbiguous functorAmbiguous, + Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); +#else + template<typename Func1> + QShortcut(const QKeySequence &key, QWidget *parent, + Func1 slot1, + Qt::ShortcutContext context = Qt::WindowShortcut) + : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) + { + connect(this, &QShortcut::activated, std::move(slot1)); + } + template<class Obj1, typename Func1> + QShortcut(const QKeySequence &key, QWidget *parent, + const Obj1 *object1, Func1 slot1, + Qt::ShortcutContext context = Qt::WindowShortcut) + : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) + { + connect(this, &QShortcut::activated, object1, std::move(slot1)); + } + template<class Obj1, typename Func1, typename Func2> + QShortcut(const QKeySequence &key, QWidget *parent, + const Obj1 *object1, Func1 slot1, Func2 slot2, + Qt::ShortcutContext context = Qt::WindowShortcut) + : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) + { + connect(this, &QShortcut::activated, object1, std::move(slot1)); + connect(this, &QShortcut::activatedAmbiguously, object1, std::move(slot2)); + } + template<class Obj1, typename Func1, class Obj2, typename Func2> + QShortcut(const QKeySequence &key, QWidget *parent, + const Obj1 *object1, Func1 slot1, + const Obj2 *object2, Func2 slot2, + Qt::ShortcutContext context = Qt::WindowShortcut) + : QShortcut(key, parent, static_cast<const char*>(nullptr), static_cast<const char*>(nullptr), context) + { + connect(this, &QShortcut::activated, object1, std::move(slot1)); + connect(this, &QShortcut::activatedAmbiguously, object2, std::move(slot2)); + } +#endif ~QShortcut(); void setKey(const QKeySequence& key); -- cgit v1.2.3 From 01ec11507d7ef3de09bad9d1ef8e6d4a3d6c4428 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen <richard.gustavsen@qt.io> Date: Thu, 10 Oct 2019 14:33:53 +0200 Subject: QStyleSheetStyle: add new property to QPushButton: icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is currently no proper way to change the icon of a pushbutton from css. But there is a need for doing so (QTBUG-2982), and the typical work-around is to instead use the css property 'qproperty-icon'. But setting qproperties from the style is not a good idea in the first place, since it modifies the state of the widget it draws. Moreover, such properties are only set once (in QStyle::polish()), and will not have any effect on pseudo states, like hover. To close this gap, this patch will add a css property 'icon' that can be set on a QPushButton. This property will follow normal css cascading, and respect pseudo states, equal to any other css property. [ChangeLog][QtWidgets][QStyle] You can now set the CSS property 'icon' on a QPushButton to override which icon to draw. Fixes: QTBUG-79137 Change-Id: Ie7e0b0fa4f19471f51108cd4ca931356219d562e Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> --- src/gui/text/qcssparser.cpp | 32 ++++++++++++++ src/gui/text/qcssparser_p.h | 2 + .../doc/src/widgets-and-layouts/stylesheet.qdoc | 17 ++++++++ src/widgets/styles/qstylesheetstyle.cpp | 51 +++++++++++++++------- 4 files changed, 86 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index ce7c7610c1..793ef5774b 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -123,6 +123,7 @@ static const QCssKnownValue properties[NumProperties - 1] = { { "font-variant", FontVariant }, { "font-weight", FontWeight }, { "height", Height }, + { "icon", QtIcon }, { "image", QtImage }, { "image-position", QtImageAlignment }, { "left", Left }, @@ -1379,6 +1380,37 @@ bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size) return hit; } +bool ValueExtractor::extractIcon(QIcon *icon, QSize *size) +{ + // Find last declaration that specifies an icon + const auto declaration = std::find_if( + declarations.rbegin(), declarations.rend(), + [](const Declaration &decl) { return decl.d->propertyId == QtIcon; }); + if (declaration == declarations.rend()) + return false; + + *icon = declaration->iconValue(); + + // If the value contains a URI, try to get the size of the icon + if (declaration->d->values.isEmpty()) + return true; + + const auto &propertyValue = declaration->d->values.constFirst(); + if (propertyValue.type != Value::Uri) + return true; + + // First try to read just the size from the image without loading it + const QString url(propertyValue.variant.toString()); + QImageReader imageReader(url); + *size = imageReader.size(); + if (!size->isNull()) + return true; + + // Get the size by loading the image instead + *size = imageReader.read().size(); + return true; +} + /////////////////////////////////////////////////////////////////////////////// // Declaration QColor Declaration::colorValue(const QPalette &pal) const diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index ab85e76cf3..b8bf259dda 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -198,6 +198,7 @@ enum Property { QtLineHeightType, FontKerning, QtForegroundTextureCacheKey, + QtIcon, NumProperties }; @@ -855,6 +856,7 @@ struct Q_GUI_EXPORT ValueExtractor bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg); int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); + bool extractIcon(QIcon *icon, QSize *size); int lengthValue(const Declaration &decl); diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index c8f374a1b1..35bad6786a 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -993,6 +993,9 @@ \li Supports the \l{box model}. Supports the \l{#default-ps}{:default}, \l{#flat-ps}{:flat}, \l{#checked-ps}{:checked} pseudo states. + Since 5.15, the \l{#icon-prop}{icon} property can be set to + override the button icon. + For QPushButton with a menu, the menu indicator is styled using the \l{#menu-indicator-sub}{::menu-indicator} subcontrol. Appearance of checkable push buttons can be @@ -1945,6 +1948,20 @@ See also \l{#width-prop}{width}. + \row + \li \b{\c icon} \target icon-prop + \li \l{#Url}{Url}+ + \li The icon that is used, for widgets that have an icon. + + The only widget currently supporting this property is QPushButton. + + \note It's the application's responsibilty to assign an icon to a + button (using the QAbstractButton API), and not the style's. So be + careful setting it unless your stylesheet is targeting a specific + application. + + Available since 5.15. + \row \li \b{\c icon-size} \target icon-size-prop \li \l{#Length}{Length} diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 3f57992311..0568d749c8 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -534,6 +534,7 @@ public: const QStyleSheetOutlineData *outline() const { return ou; } const QStyleSheetGeometryData *geometry() const { return geo; } const QStyleSheetPositionData *position() const { return p; } + const QStyleSheetImageData *icon() const { return iconPtr; } bool hasModification() const; @@ -569,6 +570,7 @@ public: bool hasGeometry() const { return geo != 0; } bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); } bool hasImage() const { return img != 0; } + bool hasIcon() const { return iconPtr != 0; } QSize minimumContentsSize() const { return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); } @@ -628,6 +630,7 @@ public: QSharedDataPointer<QStyleSheetGeometryData> geo; QSharedDataPointer<QStyleSheetPositionData> p; QSharedDataPointer<QStyleSheetImageData> img; + QSharedDataPointer<QStyleSheetImageData> iconPtr; int clipset; QPainterPath clipPath; @@ -969,11 +972,16 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject if (v.extractPalette(&fg, &sfg, &sbg, &abg)) pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg); - QIcon icon; + QIcon imgIcon; alignment = Qt::AlignCenter; + QSize imgSize; + if (v.extractImage(&imgIcon, &alignment, &imgSize)) + img = new QStyleSheetImageData(imgIcon, alignment, imgSize); + + QIcon icon; QSize size; - if (v.extractImage(&icon, &alignment, &size)) - img = new QStyleSheetImageData(icon, alignment, size); + if (v.extractIcon(&icon, &size)) + iconPtr = new QStyleSheetImageData(icon, Qt::AlignCenter, size); int adj = -255; hasFont = v.extractFont(&font, &adj); @@ -3521,15 +3529,25 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (rule.hasFont) p->setFont(rule.font.resolve(p->font())); - if (rule.hasPosition() && rule.position()->textAlignment != 0) { - Qt::Alignment textAlignment = rule.position()->textAlignment; - QRect textRect = button->rect; + if (rule.hasPosition() || rule.hasIcon()) { uint tf = Qt::TextShowMnemonic; + QRect textRect = button->rect; + + const uint horizontalAlignMask = Qt::AlignHCenter | Qt::AlignLeft | Qt::AlignRight; const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft; - tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter; - if (!styleHint(SH_UnderlineShortcut, button, w)) - tf |= Qt::TextHideMnemonic; - if (!button->icon.isNull()) { + + if (rule.hasPosition() && rule.position()->textAlignment != 0) { + Qt::Alignment textAlignment = rule.position()->textAlignment; + tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter; + tf |= (textAlignment & horizontalAlignMask) ? (textAlignment & horizontalAlignMask) : Qt::AlignHCenter; + if (!styleHint(SH_UnderlineShortcut, button, w)) + tf |= Qt::TextHideMnemonic; + } else { + tf |= Qt::AlignVCenter | Qt::AlignHCenter; + } + + QIcon icon = rule.hasIcon() ? rule.icon()->icon : button->icon; + if (!icon.isNull()) { //Group both icon and text QRect iconRect; QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; @@ -3539,7 +3557,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (button->state & State_On) state = QIcon::On; - QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); + QPixmap pixmap = icon.pixmap(button->iconSize, mode, state); int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio(); int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio(); int labelWidth = pixmapWidth; @@ -3550,10 +3568,10 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q labelWidth += (textWidth + iconSpacing); //Determine label alignment: - if (textAlignment & Qt::AlignLeft) { /*left*/ + if (tf & Qt::AlignLeft) { /*left*/ iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2, pixmapWidth, pixmapHeight); - } else if (textAlignment & Qt::AlignHCenter) { /* center */ + } else if (tf & Qt::AlignHCenter) { /* center */ iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, textRect.y() + (textRect.height() - labelHeight) / 2, pixmapWidth, pixmapHeight); @@ -3565,7 +3583,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q iconRect = visualRect(button->direction, textRect, iconRect); - tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead + // Left align, adjust the text-rect according to the icon instead + tf &= ~horizontalAlignMask; + tf |= Qt::AlignLeft; if (button->direction == Qt::RightToLeft) textRect.setRight(iconRect.left() - iconSpacing); @@ -3576,9 +3596,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); p->drawPixmap(iconRect, pixmap); - } else { - tf |= textAlignment; } + if (button->state & (State_On | State_Sunken)) textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); -- cgit v1.2.3 From 9f48f1ebc21f783cd8bb7daab942d70aebf085bc Mon Sep 17 00:00:00 2001 From: Daniel Teske <qt@squorn.de> Date: Thu, 15 Jun 2017 15:07:35 +0200 Subject: QLineEdit: Fix End key for input masks Consider this simple example: QLineEdit edit; edit.setInputMask( "9-9-9-9-9-9" ); edit.show(); Without any input, m_text will contain: " - - - - - ". text() removes the input mask's mask characters from that and returns " ". A string with 6 spaces. Thus currently the End key jumps to position 6, which is in the middle of the string. Using m_text the End key jumps to the actual end. [ChangeLog][QtWidgets][QLineEdit] Fixed End key in combination with certain input masks. Task-number: QTBUG-16187 Task-number: QTBUG-20414 Change-Id: Ibb30a1dfa2f78103611b5afc9971dc43e8bdcc4a Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/widgets/qwidgetlinecontrol_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 8ebed25084..a8fffd23dc 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -217,7 +217,7 @@ public: void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); } void home(bool mark) { moveCursor(0, mark); } - void end(bool mark) { moveCursor(text().length(), mark); } + void end(bool mark) { moveCursor(m_text.length(), mark); } int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const; QRect rectForPos(int pos) const; -- cgit v1.2.3 From 54f5b8975055f1d48c74efab085acd6338aa1e3c Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland <eirik.aavitsland@qt.io> Date: Tue, 12 Nov 2019 10:46:00 +0100 Subject: Fix: QIcon high dpi scaling when aspect ratio differs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an icon engine is asked to produce a pixmap scaled to a certain size, it may return one with a different aspect ratio than requested. In particular, an SVG will use its own aspect ratio, as it should. QIcon's DPR calculation would break down in this case, resulting in ugly scaling. Fixes: QTBUG-79371 Change-Id: Id97049259dcee1a2980474250ef1163be5639085 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/gui/image/qicon.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index df8220a0c6..0fe4cd45cb 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -165,6 +165,11 @@ QIconPrivate::QIconPrivate(QIconEngine *e) qreal QIconPrivate::pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize) { QSize targetSize = requestedSize * displayDevicePixelRatio; + if ((actualSize.width() == targetSize.width() && actualSize.height() <= targetSize.height()) || + (actualSize.width() <= targetSize.width() && actualSize.height() == targetSize.height())) { + // Correctly scaled for dpr, just having different aspect ratio + return displayDevicePixelRatio; + } qreal scale = 0.5 * (qreal(actualSize.width()) / qreal(targetSize.width()) + qreal(actualSize.height() / qreal(targetSize.height()))); return qMax(qreal(1.0), displayDevicePixelRatio *scale); -- cgit v1.2.3 From 76a0f94a6d7d85f352e3d4a00c192bfc377cc776 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Tue, 8 Oct 2019 08:05:26 +0200 Subject: Take widget content margin into account for menu bar size calculation The menu bar size calculation didn't take into account the margin of the layout content which makes said menu bar sticking out of the widget. This patch includes the margin to ensure the menu bar has the correct size. Fixes: QTBUG-76585 Change-Id: Ia2c163137fa2889f4028ee3b31766b2747d97b72 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/kernel/qlayout.cpp | 16 +++++++--------- src/widgets/kernel/qlayout_p.h | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 3ce81a390b..bd06ead6f7 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -583,18 +583,18 @@ static bool removeWidgetRecursively(QLayoutItem *li, QObject *w) } -void QLayoutPrivate::doResize(const QSize &r) +void QLayoutPrivate::doResize() { Q_Q(QLayout); - int mbh = menuBarHeightForWidth(menubar, r.width()); QWidget *mw = q->parentWidget(); QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect(); + const int mbh = menuBarHeightForWidth(menubar, rect.width()); const int mbTop = rect.top(); rect.setTop(mbTop + mbh); q->setGeometry(rect); #if QT_CONFIG(menubar) if (menubar) - menubar->setGeometry(rect.left(), mbTop, r.width(), mbh); + menubar->setGeometry(rect.left(), mbTop, rect.width(), mbh); #endif } @@ -613,12 +613,10 @@ void QLayout::widgetEvent(QEvent *e) switch (e->type()) { case QEvent::Resize: - if (d->activated) { - QResizeEvent *r = (QResizeEvent *)e; - d->doResize(r->size()); - } else { + if (d->activated) + d->doResize(); + else activate(); - } break; case QEvent::ChildRemoved: { @@ -1116,7 +1114,7 @@ bool QLayout::activate() break; } - d->doResize(mw->size()); + d->doResize(); if (md->extra) { md->extra->explicitMinSize = explMin; diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h index 8e1d773355..2b19af48be 100644 --- a/src/widgets/kernel/qlayout_p.h +++ b/src/widgets/kernel/qlayout_p.h @@ -73,7 +73,7 @@ public: QLayoutPrivate(); void getMargin(int *result, int userMargin, QStyle::PixelMetric pm) const; - void doResize(const QSize &); + void doResize(); void reparentChildWidgets(QWidget *mw); bool checkWidget(QWidget *widget) const; bool checkLayout(QLayout *otherLayout) const; -- cgit v1.2.3 From 360df2cf74410b05d1cab0192f2d0ff5a39db59e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 24 Sep 2019 13:58:08 +0200 Subject: QComboBox: add property placeholderText QComboBox had no option to tell the user that he must select an item - there was no placeholder text like e.g. in QLineEdit. This feature is widely used in html forms so we should support it also. Therefore add a new property 'placeholderText' to specify a text which should be shown when the current selected index is invalid. [ChangeLog][QtWidgets][QComboBox] QComboBox got a new property 'placeholderText' Change-Id: If6dac45c9f43455474e267907b0b0d893301c611 Fixes: QTBUG-1556 Fixes: QTBUG-2776 Fixes: QTBUG-77141 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/widgets/qcombobox.cpp | 56 ++++++++++++++++++++++++++++++++++----- src/widgets/widgets/qcombobox.h | 4 +++ src/widgets/widgets/qcombobox_p.h | 1 + 3 files changed, 55 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 9a0e969e1c..2d21187317 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -368,6 +368,8 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const } if (minimumContentsLength > 0) sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0))); + if (!placeholderText.isEmpty()) + sh.setWidth(qMax(sh.width(), fm.boundingRect(placeholderText).width())); // height @@ -1110,8 +1112,9 @@ void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int q->updateGeometry(); } - // set current index if combo was previously empty - if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid()) { + // set current index if combo was previously empty and there is no placeholderText + if (start == 0 && (end - start + 1) == q->count() && !currentIndex.isValid() && + placeholderText.isEmpty()) { q->setCurrentIndex(0); // need to emit changed if model updated index "silently" } else if (currentIndex.row() != indexBeforeChange) { @@ -1214,10 +1217,9 @@ void QComboBox::initStyleOption(QStyleOptionComboBox *option) const } else { option->activeSubControls = d->hoverControl; } - if (d->currentIndex.isValid()) { - option->currentText = currentText(); + option->currentText = currentText(); + if (d->currentIndex.isValid()) option->currentIcon = d->itemIcon(d->currentIndex); - } option->iconSize = iconSize(); if (d->container && d->container->isVisible()) option->state |= QStyle::State_On; @@ -1771,6 +1773,45 @@ void QComboBox::setIconSize(const QSize &size) updateGeometry(); } +/*! + \property QComboBox::placeholderText + \brief Sets a \a placeholderText text shown when no valid index is set + + The \a placeholderText will be shown when an invalid index is set. The + text is not accessible in the dropdown list. When this function is called + before items are added the placeholder text will be shown, otherwise you + have to call setCurrentIndex(-1) programmatically if you want to show the + placeholder text. + Set an empty placeholder text to reset the setting. + + When the QComboBox is editable, use QLineEdit::setPlaceholderText() + instead. + + \since 5.15 +*/ +void QComboBox::setPlaceholderText(const QString &placeholderText) +{ + Q_D(QComboBox); + if (placeholderText == d->placeholderText) + return; + + d->placeholderText = placeholderText; + if (currentIndex() == -1) { + if (d->placeholderText.isEmpty() && currentIndex() == -1) + setCurrentIndex(0); + else + update(); + } else { + updateGeometry(); + } +} + +QString QComboBox::placeholderText() const +{ + Q_D(const QComboBox); + return d->placeholderText; +} + /*! \property QComboBox::editable \brief whether the combo box can be edited by the user @@ -2249,7 +2290,7 @@ QString QComboBox::currentText() const else if (d->currentIndex.isValid()) return d->itemText(d->currentIndex); else - return QString(); + return d->placeholderText; } /*! @@ -3079,6 +3120,9 @@ void QComboBox::paintEvent(QPaintEvent *) initStyleOption(&opt); painter.drawComplexControl(QStyle::CC_ComboBox, opt); + if (currentIndex() < 0) + opt.palette.setBrush(QPalette::ButtonText, opt.palette.brush(QPalette::ButtonText).color().lighter()); + // draw the icon and text painter.drawControl(QStyle::CE_ComboBoxLabel, opt); } diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 286772c091..4f89d7f542 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -71,6 +71,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy) Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) + Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText) #if QT_CONFIG(completer) #if QT_DEPRECATED_SINCE(5, 13) @@ -148,6 +149,9 @@ public: QSize iconSize() const; void setIconSize(const QSize &size); + void setPlaceholderText(const QString &placeholderText); + QString placeholderText() const; + bool isEditable() const; void setEditable(bool editable); void setLineEdit(QLineEdit *edit); diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 5967776a61..00211d70aa 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -417,6 +417,7 @@ public: int maxVisibleItems; int maxCount; int modelColumn; + QString placeholderText; bool inserting; mutable QSize minimumSizeHint; mutable QSize sizeHint; -- cgit v1.2.3 From 61def1f6cdf2eff521f77c9186fc3bb929359ab9 Mon Sep 17 00:00:00 2001 From: Florian Korsakissok <florian.korsakissok@gmail.com> Date: Wed, 13 Nov 2019 13:46:24 +0100 Subject: HiDPI: Select most fitting pixel ratio when painting QIcon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a way to select a better pixel ratio when the QPainter has a valid pointer to a QPaintDevice than simply getting the global app pixel ratio. Change-Id: I8f89fd01094bbac7a01a83be89991730b0fa6597 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> --- src/gui/image/qicon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 0fe4cd45cb..84e387e317 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -190,7 +190,12 @@ QPixmapIconEngine::~QPixmapIconEngine() void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { - QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0); + qreal dpr = 1.0; + if (QCoreApplication::testAttribute(Qt::AA_UseHighDpiPixmaps)) { + auto paintDevice = painter->device(); + dpr = paintDevice ? paintDevice->devicePixelRatioF() : qApp->devicePixelRatio(); + } + const QSize pixmapSize = rect.size() * dpr; QPixmap px = pixmap(pixmapSize, mode, state); painter->drawPixmap(rect, px); } -- cgit v1.2.3 From 737fd5550bbbc727af18cc2ce43a71753ab95b95 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Wed, 2 Oct 2019 21:16:49 -0700 Subject: Change the QtCore library output to show the plugin path It's a lot more useful than the include dir. It actually helps debug problems. Change-Id: I1496b069cc534f1a838dfffd15ca07fe8ad1c8c6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/corelib/global/qlibraryinfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 8bcf67e73d..276741c9fb 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -887,10 +887,10 @@ void qt_core_boilerplate() "\n" "Installation prefix: %s\n" "Library path: %s\n" - "Include path: %s\n", + "Plugin path: %s\n", qt_configure_prefix_path_str + 12, qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath - 1], - qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath - 1]); + qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::PluginsPath - 1]); QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); -- cgit v1.2.3 From 8e8b50b06165903a6d0e3d08737e67be47d5ec3b Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Sun, 13 Oct 2019 21:15:14 -0700 Subject: RDRAND test: also disable if RDRAND produced only three samples It's unlikely, since we do 64-bit RDRAND on 64-bit machines. Change-Id: I8d95fbaf90e842b9b44dfffd15cd684a98a7ff50 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/corelib/tools/qsimd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index d7c1d8c4a9..75c380ee8a 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -685,7 +685,7 @@ static QT_FUNCTION_TARGET(RDRND) Q_DECL_COLD_FUNCTION bool checkRdrndWorks() noe // Check the results for equality if (testBuffer[0] == testBuffer[1] && testBuffer[0] == testBuffer[2] - && end == testBuffer + TestBufferSize && testBuffer[0] == testBuffer[3]) { + && (end < testBuffer + TestBufferSize || testBuffer[0] == testBuffer[3])) { fprintf(stderr, "WARNING: CPU random generator seem to be failing, " "disabling hardware random number generation\n" "WARNING: RDRND generated:"); -- cgit v1.2.3 From c30ffe1d33e6f48fa94e2003d7c9b17f4c83a6e9 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Date: Fri, 15 Nov 2019 09:08:22 +0100 Subject: Doc: Move the common documentation to a qdocinc The member functions of QStandardPath and Qt.labs.platform.StandardPath behave the same, so it's ideal to maintain their documentation in one place. Task-number: QTBUG-79827 Change-Id: I349dbb85cd9b6a3bedac329c0707fc07057cd64b Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/io/qstandardpaths.cpp | 66 +++++---------------------------------- 1 file changed, 7 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 3b5f2f97da..6ebef3ee20 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -357,22 +357,14 @@ QT_BEGIN_NAMESPACE /*! \fn QString QStandardPaths::writableLocation(StandardLocation type) - Returns the directory where files of \a type should be written to, or an empty string - if the location cannot be determined. - - \note The storage location returned can be a directory that does not exist; i.e., it - may need to be created by the system or the user. + \include standardpath/functiondoc.qdocinc writableLocation */ /*! \fn QStringList QStandardPaths::standardLocations(StandardLocation type) - Returns all the directories where files of \a type belong. - - The list of directories is sorted from high to low priority, starting with - writableLocation() if it can be determined. This list is empty if no locations - for \a type are defined. + \include standardpath/functiondoc.qdocinc standardLocations \sa writableLocation() */ @@ -396,11 +388,7 @@ static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions } /*! - Tries to find a file or directory called \a fileName in the standard locations - for \a type. - - The full path to the first file or directory (depending on \a options) found is returned. - If no such file or directory can be found, an empty string is returned. + \include standardpath/functiondoc.qdocinc locate */ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options) { @@ -414,12 +402,7 @@ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, L } /*! - Tries to find all files or directories called \a fileName in the standard locations - for \a type. - - The \a options flag allows to specify whether to look for files or directories. - - Returns the list of all the files that were found. + \include standardpath/functiondoc.qdocinc locateAll */ QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options) { @@ -492,23 +475,7 @@ static inline QString #endif // Q_OS_WIN /*! - Finds the executable named \a executableName in the paths specified by \a paths, - or the system paths if \a paths is empty. - - On most operating systems the system path is determined by the PATH environment variable. - - The directories where to search for the executable can be set in the \a paths argument. - To search in both your own paths and the system paths, call findExecutable twice, once with - \a paths set and once with \a paths empty. - - Symlinks are not resolved, in order to preserve behavior for the case of executables - whose behavior depends on the name they are invoked with. - - \note On Windows, the usual executable extensions (from the PATHEXT environment variable) - are automatically appended, so that for instance findExecutable("foo") will find foo.exe - or foo.bat if present. - - Returns the absolute file path to the executable, or an empty string if not found. + \include standardpath/functiondoc.qdocinc findExecutable */ QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) { @@ -566,10 +533,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr } /*! - \fn QString QStandardPaths::displayName(StandardLocation type) - - Returns a localized display name for the given location \a type or - an empty QString if no relevant location can be found. + \include standardpath/functiondoc.qdocinc displayName */ #if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED) @@ -626,23 +590,7 @@ QString QStandardPaths::displayName(StandardLocation type) /*! \fn void QStandardPaths::setTestModeEnabled(bool testMode) - If \a testMode is true, this enables a special "test mode" in - QStandardPaths, which changes writable locations - to point to test directories, in order to prevent auto tests from reading from - or writing to the current user's configuration. - - This affects the locations into which test programs might write files: - GenericDataLocation, DataLocation, ConfigLocation, GenericConfigLocation, - AppConfigLocation, GenericCacheLocation, CacheLocation. - Other locations are not affected. - - On Unix, \c XDG_DATA_HOME is set to \e ~/.qttest/share, \c XDG_CONFIG_HOME is - set to \e ~/.qttest/config, and \c XDG_CACHE_HOME is set to \e ~/.qttest/cache. - - On \macos, data goes to \e ~/.qttest/Application Support, cache goes to - \e ~/.qttest/Cache, and config goes to \e ~/.qttest/Preferences. - - On Windows, everything goes to a "qttest" directory under Application Data. + \include standardpath/functiondoc.qdocinc setTestModeEnabled */ static bool qsp_testMode = false; -- cgit v1.2.3 From e19345987714f4f76c8d7075355980b154adbc44 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Mon, 18 Nov 2019 12:15:48 +0100 Subject: Fix kerning with fractional pixel size Since most of our APIs for pixel size are integer-based, we would assume it was when passing it to Harfbuzz. But QRawFont (and the internal APIs in Qt and Harfbuzz) support floating point pixel sizes. The result would be that setting e.g. pixel size 20.25 would give the same glyph positions as 20.75, but the glyphs would be some fraction of a pixel larger. Using floats instead should have no impact on the common case where the pixel size is an integer, but it should also enable the other case, where QRawFont is used (or potentially future APIs that do not have the integer limitation.) [ChangeLog][QtGui][Text] Fixed a problem where pixel sizes would be truncated before calculating glyph positions. Fixes: QTBUG-67091 Change-Id: Ib066b1330ddcf52d4b344412e350aa9a60c847ff Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> --- src/gui/text/qharfbuzzng.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 9c8582b43d..397e6cc49f 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -695,12 +695,12 @@ _hb_qt_font_create(QFontEngine *fe) return NULL; } - const int y_ppem = fe->fontDef.pixelSize; - const int x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100; + const qreal y_ppem = fe->fontDef.pixelSize; + const qreal x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100.0; hb_font_set_funcs(font, hb_qt_get_font_funcs(), (void *)fe, NULL); - hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value()); - hb_font_set_ppem(font, x_ppem, y_ppem); + hb_font_set_scale(font, QFixed::fromReal(x_ppem).value(), -QFixed::fromReal(y_ppem).value()); + hb_font_set_ppem(font, int(x_ppem), int(y_ppem)); hb_font_set_ptem(font, fe->fontDef.pointSize); -- cgit v1.2.3 From 6a7a4aac0a94650247d8578475a8725009d7d569 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Sun, 17 Nov 2019 00:11:21 +0100 Subject: Doc: add warning for binding values in QSqlQuery Not all SQL operations support binding values like the PRAGMA instruction of SQLite. This patch adds a warning for the developer to make it clearer that binding values cannot be used for everything. Task-number: QTBUG-80082 Change-Id: Ie1d33815d74a0759a3593df9410b8bad448f6fe9 Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> --- src/sql/kernel/qsqlquery.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index e7c444f5b9..34a3ba3755 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -182,6 +182,9 @@ QSqlQueryPrivate::~QSqlQueryPrivate() You can retrieve the values of all the fields in a single variable (a map) using boundValues(). + \note Not all SQL operations support binding values. Refer to your database + system's documentation to check their availability. + \section1 Approaches to Binding Values Below we present the same example using each of the four -- cgit v1.2.3 From 54d5ca0c2766e915c960fa437cee6c20a324c1a7 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Sat, 16 Nov 2019 16:53:08 +0100 Subject: Doc: improve Using Model Indexes in Model View Programming guide The current example using QFileSystemModel doesn't take into account the asynchronous nature of that model. This puts people on the wrong path on how to use it. This patch improves the snippet as well as the explanation steps. Change-Id: I5c7a3c19aad48847f0b965b5eb69b492d6263f51 Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/widgets/doc/snippets/simplemodel-use/main.cpp | 7 +++++-- src/widgets/doc/src/model-view-programming.qdoc | 13 +++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/doc/snippets/simplemodel-use/main.cpp b/src/widgets/doc/snippets/simplemodel-use/main.cpp index 3e106c8eea..940669e101 100644 --- a/src/widgets/doc/snippets/simplemodel-use/main.cpp +++ b/src/widgets/doc/snippets/simplemodel-use/main.cpp @@ -79,8 +79,11 @@ int main(int argc, char *argv[]) //! [0] QFileSystemModel *model = new QFileSystemModel; - QModelIndex parentIndex = model->index(QDir::currentPath()); - int numRows = model->rowCount(parentIndex); + connect(model, &QFileSystemModel::directoryLoaded, [model](const QString &directory) { + QModelIndex parentIndex = model->index(directory); + int numRows = model->rowCount(parentIndex); + }); + model->setRootPath(QDir::currentPath); //! [0] //! [1] diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 236582ef3f..ede1ebf932 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -465,14 +465,19 @@ Although this does not show a normal way of using a model, it demonstrates the conventions used by models when dealing with model indexes. + QFileSystemModel loading is asynchronous to minimize system resource use. + We have to take that into account when dealing with this model. + We construct a file system model in the following way: \snippet simplemodel-use/main.cpp 0 - In this case, we set up a default QFileSystemModel, obtain a parent index - using a specific implementation of \l{QFileSystemModel::}{index()} - provided by that model, and we count the number of rows in the model using - the \l{QFileSystemModel::}{rowCount()} function. + In this case, we start by setting up a default QFileSystemModel. We connect + it to a lambda, in which we will obtain a parent index using a specific + implementation of \l{QFileSystemModel::}{index()} provided by that model. + In the lambda, we count the number of rows in the model using the + \l{QFileSystemModel::}{rowCount()} function. Finally, we set the root path + of the QFileSystemModel so it starts loading data and triggers the lambda. For simplicity, we are only interested in the items in the first column of the model. We examine each row in turn, obtaining a model index for -- cgit v1.2.3 From 329eef34f4401e2303a60b70904c7f58ccf64af8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Wed, 19 Jun 2019 17:30:28 -0700 Subject: Add functions for facilitating adding UTF-8 and US-ASCII strings Change-Id: Ief874765cd7b43798de3fffd15a9c0b4dc82a64e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/serialization/qcborvalue_p.h | 9 +++++++++ src/corelib/serialization/qjsonparser.cpp | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index d18d108969..b5d3de74fe 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -236,6 +236,15 @@ public: elements.append(QtCbor::Element(addByteData(data, len), type, QtCbor::Element::HasByteData | extraFlags)); } + void appendAsciiString(const QString &s); + void appendAsciiString(const char *str, qsizetype len) + { + appendByteData(str, len, QCborValue::String, QtCbor::Element::StringIsAscii); + } + void appendUtf8String(const char *str, qsizetype len) + { + appendByteData(str, len, QCborValue::String); + } void append(QLatin1String s) { if (!QtPrivate::isAscii(s)) diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp index aab8112d7f..d7ce702ff7 100644 --- a/src/corelib/serialization/qjsonparser.cpp +++ b/src/corelib/serialization/qjsonparser.cpp @@ -894,9 +894,10 @@ bool Parser::parseString() // no escape sequences, we are done if (isUtf8) { - container->appendByteData(start, json - start - 1, QCborValue::String, - isAscii ? QtCbor::Element::StringIsAscii - : QtCbor::Element::ValueFlags {}); + if (isAscii) + container->appendAsciiString(start, json - start - 1); + else + container->appendUtf8String(start, json - start - 1); END; return true; } -- cgit v1.2.3 From ede867f581c0894e13d669f5364610df7ade0eb5 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 17 Nov 2019 13:10:41 +0100 Subject: QWheelEvent: add \since flag for ctor c08bf215cceda784cd02f8fa20e5b2431e0d9ef9 added a new QWheelEvent ctor but missed the \since flag. Fixes: QTBUG-80088 Change-Id: I6c81179999dd100162dc0cd5dc28e7b5b843b437 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/kernel/qevent.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 2b28052dd5..f555f4dc05 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -846,6 +846,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, /*! Constructs a wheel event object. + \since 5.12 The \a pos provides the location of the mouse cursor within the window. The position in global coordinates is specified by \a globalPos. -- cgit v1.2.3 From d7cb21ac085117f879a8aa1d7727b2ca52d3353d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 15 Nov 2019 21:46:32 +0100 Subject: QDom: use QLocale::C when converting a double to a xml attribute QDomElement::setAttribute(QString, double) did not use QString::setNum() but qsnprintf(). This is wrong because qsnprintf() is using the current locale instead QLocale::C. It was also inconsistent to QDomElement::setAttributeNS() which was already using QString::setNum(). Also fix the documentation which stated that all QDomElement::setAttribute() format the values according the current locale. Fixes: QTBUG-80068 Change-Id: Iabb0b39c0d0723060527542c283a5435f26f31ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/xml/dom/qdom.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 8d232237bf..04151c3f31 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -4818,20 +4818,20 @@ void QDomElement::setAttribute(const QString& name, const QString& value) \fn void QDomElement::setAttribute(const QString& name, int value) \overload - The number is formatted according to the current locale. + The formatting always uses QLocale::C. */ /*! \fn void QDomElement::setAttribute(const QString& name, uint value) \overload - The number is formatted according to the current locale. + The formatting always uses QLocale::C. */ /*! \overload - The number is formatted according to the current locale. + The formatting always uses QLocale::C. */ void QDomElement::setAttribute(const QString& name, qlonglong value) { @@ -4845,7 +4845,7 @@ void QDomElement::setAttribute(const QString& name, qlonglong value) /*! \overload - The number is formatted according to the current locale. + The formatting always uses QLocale::C. */ void QDomElement::setAttribute(const QString& name, qulonglong value) { @@ -4859,7 +4859,7 @@ void QDomElement::setAttribute(const QString& name, qulonglong value) /*! \overload - The number is formatted according to the current locale. + The formatting always uses QLocale::C. */ void QDomElement::setAttribute(const QString& name, float value) { @@ -4873,19 +4873,14 @@ void QDomElement::setAttribute(const QString& name, float value) /*! \overload - The number is formatted according to the current locale. + The formatting always uses QLocale::C. */ void QDomElement::setAttribute(const QString& name, double value) { if (!impl) return; QString x; - char buf[256]; - int count = qsnprintf(buf, sizeof(buf), "%.16g", value); - if (count > 0) - x = QString::fromLatin1(buf, count); - else - x.setNum(value); // Fallback + x.setNum(value); IMPL->setAttribute(name, x); } -- cgit v1.2.3 From b10e1209e1c3655ee6e57185bb5375408ce02e56 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Mon, 4 Nov 2019 17:34:28 +0100 Subject: Implement inplace image conversion for generic down conversions If the destination image format is smaller than the source one, allow an inplace conversion followed by a shrinking realloc. Change-Id: I99b3e285e06fb37fd5fe7412749fa87f4cf2ee9a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/image/qimage_conversions.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 4f3821a7cc..7cd71644a3 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -257,7 +257,8 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im // Cannot be used with indexed formats or between formats with different pixel depths. Q_ASSERT(dst_format > QImage::Format_Indexed8); Q_ASSERT(data->format > QImage::Format_Indexed8); - if (data->depth != qt_depthForFormat(dst_format)) + const int destDepth = qt_depthForFormat(dst_format); + if (data->depth < destDepth) return false; const QPixelLayout *srcLayout = &qPixelLayouts[data->format]; @@ -272,9 +273,16 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im uint buf[BufferSize]; uint *buffer = buf; uchar *srcData = data->data; + uchar *destData = data->data; - Q_ASSERT(srcLayout->bpp == destLayout->bpp); - Q_ASSERT(srcLayout->bpp != QPixelLayout::BPP64); + QImageData::ImageSizeParameters params = { data->bytes_per_line, data->nbytes }; + if (data->depth != destDepth) { + params = QImageData::calculateImageParameters(data->width, data->height, destDepth); + if (!params.isValid()) + return false; + } + + Q_ASSERT(destLayout->bpp != QPixelLayout::BPP64); FetchAndConvertPixelsFunc fetch = srcLayout->fetchToARGB32PM; ConvertAndStorePixelsFunc store = destLayout->storeFromARGB32PM; if (!srcLayout->hasAlphaChannel && destLayout->storeFromRGB32) { @@ -316,15 +324,26 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im while (x < data->width) { dither.x = x; int l = data->width - x; - if (destLayout->bpp == QPixelLayout::BPP32) + if (srcLayout->bpp == QPixelLayout::BPP32) buffer = reinterpret_cast<uint *>(srcData) + x; else l = qMin(l, BufferSize); const uint *ptr = fetch(buffer, srcData, x, l, nullptr, ditherPtr); - store(srcData, ptr, x, l, nullptr, ditherPtr); + store(destData, ptr, x, l, nullptr, ditherPtr); x += l; } srcData += data->bytes_per_line; + destData += params.bytesPerLine; + } + if (params.totalSize != data->nbytes) { + Q_ASSERT(params.totalSize < data->nbytes); + void *newData = realloc(data->data, params.totalSize); + if (newData) { + data->data = (uchar *)newData; + data->nbytes = params.totalSize; + } + data->bytes_per_line = params.bytesPerLine; + data->depth = destDepth; } data->format = dst_format; return true; -- cgit v1.2.3 From c3556025951ec9b16c20d215985761a27fad52d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 12 Nov 2019 12:45:36 +0100 Subject: Windows QPA: Port from QList to QVector Use a QVector where possible. Otherwise, try to introduce auto to make migration easier. Change-Id: I9deadb363fabd1755deca180ed5cb771390fcb30 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 4 ++-- src/plugins/platforms/windows/qwindowsdropdataobject.cpp | 2 +- src/plugins/platforms/windows/qwindowskeymapper.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowsmime.h | 3 +-- src/plugins/platforms/windows/qwindowsscreen.cpp | 6 +++--- src/plugins/platforms/windows/qwindowsscreen.h | 2 +- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- .../windows/uiautomation/qwindowsuiaselectionprovider.cpp | 3 ++- .../windows/uiautomation/qwindowsuiatableitemprovider.cpp | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index b7ab952a1d..cdb4e407d1 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -466,14 +466,14 @@ inline void QWindowsFileDialogSharedData::setSelectedNameFilter(const QString &f inline QList<QUrl> QWindowsFileDialogSharedData::selectedFiles() const { m_data->mutex.lock(); - const QList<QUrl> result = m_data->selectedFiles; + const auto result = m_data->selectedFiles; m_data->mutex.unlock(); return result; } inline QString QWindowsFileDialogSharedData::selectedFile() const { - const QList<QUrl> files = selectedFiles(); + const auto files = selectedFiles(); return files.isEmpty() ? QString() : files.front().toLocalFile(); } diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp index e1a41c0ede..c9dd1c7c17 100644 --- a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp @@ -95,7 +95,7 @@ bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const || pformatetc->cfFormat == CF_TEXT || formatName == QStringLiteral("UniformResourceLocator") || formatName == QStringLiteral("UniformResourceLocatorW")) { - QList<QUrl> urls = dropData->urls(); + const auto urls = dropData->urls(); return std::all_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); }); } } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 4f0f846749..0509403267 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1388,7 +1388,7 @@ QList<int> QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) { const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods; const int matchedKey = int(key) + missingMods; - const QList<int>::iterator it = + const auto it = std::find_if(result.begin(), result.end(), [key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; }); // QTBUG-67200: Use the match with the least modifiers (prefer diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index b9d8b191f5..1c6c999f05 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -107,7 +107,7 @@ static inline QByteArray msgConversionError(const char *func, const char *format msg += ": Unable to convert DIB image. The image converter plugin for '"; msg += format; msg += "' is not available. Available formats: "; - const QList<QByteArray> &formats = QImageReader::supportedImageFormats(); + const auto &formats = QImageReader::supportedImageFormats(); for (const QByteArray &af : formats) { msg += af; msg += ' '; @@ -747,7 +747,7 @@ QWindowsMimeURI::QWindowsMimeURI() bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const { if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) { - const QList<QUrl> urls = mimeData->urls(); + const auto urls = mimeData->urls(); for (const QUrl &url : urls) { if (url.isLocalFile()) return true; @@ -760,7 +760,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat { if (canConvertFromMime(formatetc, mimeData)) { if (getCf(formatetc) == CF_HDROP) { - const QList<QUrl> &urls = mimeData->urls(); + const auto &urls = mimeData->urls(); QStringList fileNames; int size = sizeof(DROPFILES)+2; for (const QUrl &url : urls) { @@ -791,7 +791,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat return setData(result, pmedium); } if (getCf(formatetc) == CF_INETURL_W) { - QList<QUrl> urls = mimeData->urls(); + const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) { QString url = urls.at(0).toString(); @@ -803,7 +803,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat return setData(result, pmedium); } if (getCf(formatetc) == CF_INETURL) { - QList<QUrl> urls = mimeData->urls(); + const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) result = urls.at(0).toString().toLocal8Bit(); diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h index 1c389e8800..f8708f1259 100644 --- a/src/plugins/platforms/windows/qwindowsmime.h +++ b/src/plugins/platforms/windows/qwindowsmime.h @@ -43,7 +43,6 @@ #include <QtCore/qt_windows.h> #include <QtCore/qvector.h> -#include <QtCore/qlist.h> #include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE @@ -95,7 +94,7 @@ public: private: void ensureInitialized() const; - mutable QList<QWindowsMime *> m_mimes; + mutable QVector<QWindowsMime *> m_mimes; mutable int m_internalMimeCount = 0; }; diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index df63adf558..4f76a82544 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -73,7 +73,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor) return {0, 0}; } -using WindowsScreenDataList = QList<QWindowsScreenData>; +using WindowsScreenDataList = QVector<QWindowsScreenData>; static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) { @@ -467,7 +467,7 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam) return false; } -static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens, +static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens, const QString &monitorName) { for (int i= 0; i < screens.size(); ++i) @@ -476,7 +476,7 @@ static inline int indexOfMonitor(const QList<QWindowsScreen *> &screens, return -1; } -static inline int indexOfMonitor(const QList<QWindowsScreenData> &screenData, +static inline int indexOfMonitor(const WindowsScreenDataList &screenData, const QString &monitorName) { for (int i = 0; i < screenData.size(); ++i) diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 2fd56f53cf..5c095808f2 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -127,7 +127,7 @@ private: class QWindowsScreenManager { public: - using WindowsScreenList = QList<QWindowsScreen *>; + using WindowsScreenList = QVector<QWindowsScreen *>; QWindowsScreenManager(); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ea91e3bb2d..5a4f879d0f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -592,7 +592,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co return posFrame; // Find the original screen containing the coordinates. - const QList<QScreen *> screens = screenForGL->virtualSiblings(); + const auto screens = screenForGL->virtualSiblings(); const QScreen *orgScreen = nullptr; for (QScreen *screen : screens) { if (screen->handle()->availableGeometry().contains(posFrame)) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp index 3305e9c5c4..fb41012cf4 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp @@ -49,6 +49,7 @@ #include <QtCore/qloggingcategory.h> #include <QtCore/qstring.h> #include <QtCore/qlist.h> +#include <QtCore/qvector.h> QT_BEGIN_NAMESPACE @@ -78,7 +79,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::GetSelection(SAFEARRAY * return UIA_E_ELEMENTNOTAVAILABLE; // First put selected items in a list, then build a safe array with the right size. - QList<QAccessibleInterface *> selectedList; + QVector<QAccessibleInterface *> selectedList; for (int i = 0; i < accessible->childCount(); ++i) { if (QAccessibleInterface *child = accessible->child(i)) { if (child->state().selected) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp index 2a94012590..1348ec7cc0 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp @@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEAR if (!tableCellInterface) return UIA_E_ELEMENTNOTAVAILABLE; - QList<QAccessibleInterface *> headers = tableCellInterface->rowHeaderCells(); + const auto headers = tableCellInterface->rowHeaderCells(); if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) { for (LONG i = 0; i < headers.size(); ++i) { @@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF if (!tableCellInterface) return UIA_E_ELEMENTNOTAVAILABLE; - QList<QAccessibleInterface *> headers = tableCellInterface->columnHeaderCells(); + const auto headers = tableCellInterface->columnHeaderCells(); if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) { for (LONG i = 0; i < headers.size(); ++i) { -- cgit v1.2.3 From c8df1a2c6dcf47bb784d31905b3cb918ac02dac2 Mon Sep 17 00:00:00 2001 From: Andre Hartmann <aha_1980@gmx.de> Date: Wed, 20 Nov 2019 08:30:50 +0100 Subject: QTemporaryFile: Add a note about behavior on Linux Mostly copied from the 5.10 changelog file. Task-number: QTBUG-80157 Change-Id: I58654fe998ada603241b9a7cb967f55e66ebc954 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Tomasz Siekierda <sierdzio@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/io/qtemporaryfile.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index acd31f4d84..55d13dad70 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -631,6 +631,12 @@ QString QTemporaryFilePrivate::defaultTemplateName() case sensitive. If the template is not present in the filename, QTemporaryFile appends the generated part to the filename given. + \note On Linux, QTemporaryFile will attempt to create unnamed temporary + files. If that succeeds, open() will return true but exists() will be + false. If you call fileName() or any function that calls it, + QTemporaryFile will give the file a name, so most applications will + not see a difference. + \sa QDir::tempPath(), QFile */ -- cgit v1.2.3 From 3b98fe7f773668ed8b35478fa3a8ca0590acc450 Mon Sep 17 00:00:00 2001 From: Alexander Volkov <a.volkov@rusbitech.ru> Date: Mon, 18 Nov 2019 18:53:59 +0300 Subject: xcb: Simplify code by using helper QXcbIntegration::defaultConnection() Change-Id: Ieb0e21d85fcd0c168b1bb090e967d02a8a6a6083 Reviewed-by: Mikhail Svetkin <mikhail.svetkin@gmail.com> --- src/plugins/platforms/xcb/qxcbintegration.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 95ca40fc95..efda6b67ce 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -317,8 +317,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const case OpenGL: case ThreadedOpenGL: { - const auto *connection = qAsConst(m_connections).first(); - if (const auto *integration = connection->glIntegration()) + if (const auto *integration = defaultConnection()->glIntegration()) return cap != ThreadedOpenGL || integration->supportsThreadedOpenGL(); return false; } -- cgit v1.2.3 From 5d1af4f0be0815778aa4f9c3e32a432d9989613b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann <joerg.bornemann@qt.io> Date: Fri, 8 Nov 2019 16:55:06 +0100 Subject: Compile fontconfig-related code on non-Unix platforms ...if the feature is enabled. This fixes the build for MSYS2 with fontconfig. Fixes: QTBUG-79748 Change-Id: I2c834b6d968766f98c5df2f3df5c8c9bdbd80f11 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/platformsupport/fontdatabases/fontdatabases.pro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/fontdatabases.pro b/src/platformsupport/fontdatabases/fontdatabases.pro index f2bac9ab94..c3985ed398 100644 --- a/src/platformsupport/fontdatabases/fontdatabases.pro +++ b/src/platformsupport/fontdatabases/fontdatabases.pro @@ -17,9 +17,10 @@ qtConfig(freetype) { unix { include($$PWD/genericunix/genericunix.pri) - qtConfig(fontconfig) { - include($$PWD/fontconfig/fontconfig.pri) - } +} + +qtConfig(fontconfig) { + include($$PWD/fontconfig/fontconfig.pri) } win32:!winrt { -- cgit v1.2.3 From 8bc4ea1e97c138034d08c705a75f75763361400b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Wed, 13 Nov 2019 10:27:25 +0100 Subject: Windows QPA: Fix deprecation warnings Fix warnings introduced by qtbase/72f57cc84244633ca69ede9a1fd510b9b1881c1d: qwindowstheme.cpp:167:62: warning: 'bool QWaitCondition::wait(QMutex*, long unsigned int)' is deprecated: Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead [-Wdeprecated-declarations]qwindowstheme.cpp: In member function 'bool QShGetFileInfoThread::runWithParams(QShGetFileInfoParams*, long unsigned int)': qwindowstheme.cpp:201:63: warning: 'bool QWaitCondition::wait(QMutex*, long unsigned int)' is deprecated: Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead [-Wdeprecated-declarations] Change-Id: Ie33f8b0e1e742f972d2a8065eba9e16a13ec43ee Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> --- src/plugins/platforms/windows/qwindowstheme.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 40f9652cbd..32a65109af 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -164,7 +164,7 @@ public: QMutexLocker readyLocker(&m_readyMutex); while (!m_cancelled.loadRelaxed()) { if (!m_params && !m_cancelled.loadRelaxed() - && !m_readyCondition.wait(&m_readyMutex, 1000)) + && !m_readyCondition.wait(&m_readyMutex, QDeadlineTimer(1000ll))) continue; if (m_params) { @@ -189,7 +189,7 @@ public: CoUninitialize(); } - bool runWithParams(QShGetFileInfoParams *params, unsigned long timeOutMSecs) + bool runWithParams(QShGetFileInfoParams *params, qint64 timeOutMSecs) { QMutexLocker doneLocker(&m_doneMutex); @@ -198,7 +198,7 @@ public: m_readyCondition.wakeAll(); m_readyMutex.unlock(); - return m_doneCondition.wait(&m_doneMutex, timeOutMSecs); + return m_doneCondition.wait(&m_doneMutex, QDeadlineTimer(timeOutMSecs)); } void cancel() @@ -220,7 +220,7 @@ private: static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes, SHFILEINFO *info, UINT flags, - unsigned long timeOutMSecs = 5000) + qint64 timeOutMSecs = 5000) { static QShGetFileInfoThread *getFileInfoThread = nullptr; if (!getFileInfoThread) { -- cgit v1.2.3 From 73a764c24700089228b4092e983061f788c6d232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> Date: Tue, 19 Nov 2019 17:15:50 +0100 Subject: =?UTF-8?q?Don=E2=80=99t=20warn=20on=20QT=5FAUTO=5FSCREEN=5FSCALE?= =?UTF-8?q?=5FFACTOR=20usage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This warning turned out to be spammy, since the env. variable may be set by KDE, in which case there is nothing the user or app developer can do to fix the situation. QT_AUTO_SCREEN_SCALE_FACTOR is now Done on X11, and remains Deprecated on all other platforms. Change-Id: I9d372655624b0e0b822f0a70e9aec4b18ab98630 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> --- src/gui/kernel/qhighdpiscaling.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 0782a49481..fde6bb0180 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -56,6 +56,9 @@ Q_LOGGING_CATEGORY(lcScaling, "qt.scaling"); #ifndef QT_NO_HIGHDPISCALING static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO"; + +// Note: QT_AUTO_SCREEN_SCALE_FACTOR is Done on X11, and should be kept +// working as-is. It's Deprecated on all other platforms. static const char legacyAutoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; static const char enableHighDpiScalingEnvVar[] = "QT_ENABLE_HIGHDPI_SCALING"; @@ -104,12 +107,6 @@ static inline qreal initialGlobalScaleFactor() if (dpr > 0) result = dpr; } - - if (qEnvironmentVariableIsSet(legacyAutoScreenEnvVar)) { - qWarning("Warning: %s is deprecated. Instead use:\n" - " %s to enable platform plugin controlled per-screen factors.", - legacyAutoScreenEnvVar, enableHighDpiScalingEnvVar); - } } return result; } -- cgit v1.2.3 From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: Deprecate constructing QFlags from a pointer This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- .../doc/snippets/code/src_corelib_global_qglobal.cpp | 1 + src/corelib/global/qflags.h | 7 ++++++- src/corelib/global/qglobal.cpp | 12 +++++++++++- src/corelib/io/qabstractfileengine.cpp | 2 +- src/corelib/io/qfileinfo.cpp | 2 +- src/corelib/io/qfilesystemmetadata_p.h | 5 ++--- src/corelib/io/qfsfileengine_win.cpp | 4 ++-- src/corelib/io/qresource.cpp | 2 +- src/corelib/io/qurl.cpp | 2 +- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 ++-- src/corelib/plugin/qlibrary_p.h | 2 +- src/corelib/text/qregularexpression.cpp | 2 +- src/corelib/text/qtextboundaryfinder.cpp | 2 +- src/corelib/time/qdatetime.cpp | 2 +- src/corelib/time/qdatetimeparser.cpp | 4 ++-- src/corelib/time/qdatetimeparser_p.h | 2 +- src/dbus/qdbusconnection.cpp | 2 +- src/dbus/qdbusintegrator.cpp | 4 ++-- src/gui/image/qimage.cpp | 6 +++--- src/gui/kernel/qplatformcursor.cpp | 2 +- src/gui/kernel/qplatformtheme.h | 2 +- src/gui/kernel/qsimpledrag.cpp | 2 +- src/gui/kernel/qsurfaceformat.cpp | 2 +- src/gui/opengl/qopenglbuffer.cpp | 4 ++-- src/gui/opengl/qopenglfunctions.cpp | 4 ++-- src/gui/opengl/qopenglpaintengine.cpp | 2 +- src/gui/painting/qpaintengineex.cpp | 2 +- src/gui/painting/qpainter.cpp | 16 ++++++++-------- src/gui/painting/qplatformbackingstore.cpp | 4 ++-- src/gui/painting/qplatformbackingstore.h | 2 +- src/gui/text/qcssparser.cpp | 2 +- src/gui/text/qdistancefield.cpp | 2 +- src/gui/text/qfontengine.cpp | 4 ++-- src/gui/text/qfontmetrics.cpp | 8 ++++---- src/gui/text/qglyphrun.cpp | 2 +- src/gui/text/qglyphrun_p.h | 3 +-- src/gui/text/qrawfont.cpp | 2 +- src/gui/text/qtextengine.cpp | 10 +++++----- src/gui/util/qgridlayoutengine.cpp | 2 +- src/gui/util/qgridlayoutengine_p.h | 4 ++-- src/gui/vulkan/qvulkanwindow_p.h | 2 +- src/network/access/qspdyprotocolhandler.cpp | 10 +++++----- src/network/kernel/qnetworkinterface_p.h | 2 +- src/network/kernel/qnetworkinterface_unix_p.h | 2 +- src/network/socket/qlocalsocket_unix.cpp | 4 ++-- src/opengl/qglfunctions.cpp | 2 +- src/platformsupport/eglconvenience/qeglpbuffer_p.h | 2 +- .../eglconvenience/qeglplatformcontext_p.h | 2 +- src/platformsupport/fbconvenience/qfbscreen.cpp | 2 +- src/platformsupport/input/libinput/qlibinputtouch.cpp | 2 +- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 2 +- .../themes/genericunix/qgenericunixthemes_p.h | 4 ++-- src/plugins/imageformats/gif/main.cpp | 2 +- src/plugins/imageformats/ico/main.cpp | 4 ++-- src/plugins/imageformats/jpeg/main.cpp | 4 ++-- .../ibus/qibusplatforminputcontext.h | 2 +- src/plugins/platforms/eglfs/api/qeglfsintegration.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 2 +- .../nsphotolibrarysupport/qiosfileengineassetslibrary.mm | 2 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- src/plugins/platforms/xcb/qxcbconnection.h | 8 ++++---- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- src/plugins/platforms/xcb/qxcbdrag.cpp | 2 +- src/plugins/platforms/xcb/qxcbdrag.h | 4 ++-- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- .../xdgdesktopportal/qxdgdesktopportaltheme.h | 2 +- src/printsupport/kernel/qpaintengine_alpha_p.h | 2 +- src/sql/models/qsqltablemodel.cpp | 2 +- src/widgets/dialogs/qfiledialog.cpp | 4 ++-- src/widgets/dialogs/qfilesystemmodel_p.h | 2 +- src/widgets/dialogs/qfontdialog.cpp | 2 +- src/widgets/dialogs/qprogressdialog.cpp | 2 +- src/widgets/dialogs/qwizard.cpp | 2 +- src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp | 2 +- src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h | 2 +- src/widgets/graphicsview/qgraphicslinearlayout.cpp | 2 +- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 2 +- src/widgets/graphicsview/qgraphicsview.cpp | 6 +++--- src/widgets/itemviews/qcolumnviewgrip.cpp | 2 +- src/widgets/itemviews/qcolumnviewgrip_p.h | 2 +- src/widgets/kernel/qformlayout.cpp | 6 +++--- src/widgets/kernel/qgesture_p.h | 3 +-- src/widgets/kernel/qlayout.cpp | 2 +- src/widgets/kernel/qlayoutengine_p.h | 6 +++--- src/widgets/kernel/qstandardgestures.cpp | 4 ++-- src/widgets/kernel/qwidget.cpp | 4 ++-- src/widgets/kernel/qwidget_p.h | 2 +- src/widgets/kernel/qwindowcontainer_p.h | 2 +- src/widgets/styles/qstylesheetstyle.cpp | 12 ++++++------ src/widgets/widgets/qabstractbutton.cpp | 4 ++-- src/widgets/widgets/qabstractslider.cpp | 4 ++-- src/widgets/widgets/qabstractspinbox.cpp | 4 ++-- src/widgets/widgets/qcalendarwidget.cpp | 6 +++--- src/widgets/widgets/qcombobox.cpp | 4 ++-- src/widgets/widgets/qdatetimeedit.cpp | 9 ++++----- src/widgets/widgets/qdialogbuttonbox.cpp | 2 +- src/widgets/widgets/qdockwidget.cpp | 4 ++-- src/widgets/widgets/qeffects.cpp | 2 +- src/widgets/widgets/qfocusframe.cpp | 2 +- src/widgets/widgets/qgroupbox.cpp | 2 +- src/widgets/widgets/qkeysequenceedit.cpp | 2 +- src/widgets/widgets/qlineedit.cpp | 2 +- src/widgets/widgets/qmainwindowlayout_p.h | 2 +- src/widgets/widgets/qmdisubwindow.cpp | 2 +- src/widgets/widgets/qmenubar.cpp | 2 +- src/widgets/widgets/qprogressbar.cpp | 2 +- src/widgets/widgets/qscrollarea_p.h | 2 +- src/widgets/widgets/qsizegrip.cpp | 2 +- src/widgets/widgets/qsplitter.cpp | 2 +- src/widgets/widgets/qstatusbar.cpp | 2 +- src/widgets/widgets/qtabbar.cpp | 2 +- src/widgets/widgets/qtabwidget.cpp | 2 +- src/widgets/widgets/qtoolbar.cpp | 2 +- src/widgets/widgets/qwidgettextcontrol_p.h | 6 +++--- 114 files changed, 193 insertions(+), 181 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index eb75a29ca2..a540b88247 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -50,6 +50,7 @@ //! [0] label->setAlignment(Qt::AlignLeft | Qt::AlignTop); +label->setAlignment({ }); //! [0] diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index bd3c219968..4f46de5eaa 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -93,8 +93,10 @@ class QFlags "long long will overflow."); Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types."); +#if QT_DEPRECATED_SINCE(5,15) struct Private; typedef int (Private::*Zero); +#endif template <typename E> friend QDataStream &operator>>(QDataStream &, QFlags<E> &); template <typename E> friend QDataStream &operator<<(QDataStream &, QFlags<E>); public: @@ -115,8 +117,11 @@ public: Q_DECL_CONSTEXPR inline QFlags(const QFlags &other); Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other); #endif + Q_DECL_CONSTEXPR inline QFlags() noexcept : i(0) {} Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {} - Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) noexcept : i(0) {} +#if QT_DEPRECATED_SINCE(5,15) + QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {} +#endif Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {} Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) noexcept diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4ab5bd2edb..d95cc786ab 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -250,7 +250,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); Qt::Alignment type is simply a typedef for QFlags<Qt::AlignmentFlag>. QLabel::setAlignment() takes a Qt::Alignment parameter, which means that any combination of - Qt::AlignmentFlag values, or 0, is legal: + Qt::AlignmentFlag values, or \c{{ }}, is legal: \snippet code/src_corelib_global_qglobal.cpp 0 @@ -317,11 +317,21 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); Constructs a QFlags object storing the \a flags. */ +/*! + \fn template <typename Enum> QFlags<Enum>::QFlags() + \since 5.15 + + Constructs a QFlags object with no flags set. +*/ + /*! \fn template <typename Enum> QFlags<Enum>::QFlags(Zero) + \deprecated Constructs a QFlags object with no flags set. The parameter must be a literal 0 value. + + Deprecated, use default constructor instead. */ /*! diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index 8a1679c5af..070139b608 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -658,7 +658,7 @@ QStringList QAbstractFileEngine::entryList(QDir::Filters filters, const QStringL QAbstractFileEngine::FileFlags QAbstractFileEngine::fileFlags(FileFlags type) const { Q_UNUSED(type); - return nullptr; + return {}; } /*! diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 93696c1320..3fe1aec41f 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -134,7 +134,7 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons // extra syscall. Bundle detecton on Mac can be slow, expecially on network // paths, so we separate out that as well. - QAbstractFileEngine::FileFlags req = nullptr; + QAbstractFileEngine::FileFlags req; uint cachedFlags = 0; if (request & (QAbstractFileEngine::FlagsMask | QAbstractFileEngine::TypesMask)) { diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 275a4bf8d0..3154658e5c 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -76,8 +76,7 @@ class Q_AUTOTEST_EXPORT QFileSystemMetaData { public: QFileSystemMetaData() - : knownFlagsMask(nullptr), - size_(-1) + : size_(-1) { } @@ -186,7 +185,7 @@ public: void clear() { - knownFlagsMask = nullptr; + knownFlagsMask = {}; } void clearFlags(MetaDataFlags flags = AllMetaDataFlags) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 5b868cc447..dd4882a2bc 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -591,14 +591,14 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil if (type & Refresh) d->metaData.clear(); - QAbstractFileEngine::FileFlags ret = 0; + QAbstractFileEngine::FileFlags ret; if (type & FlagsMask) ret |= LocalDiskFlag; bool exists; { - QFileSystemMetaData::MetaDataFlags queryFlags = 0; + QFileSystemMetaData::MetaDataFlags queryFlags; queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) & QFileSystemMetaData::Permissions; diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 22c22ce711..0a145b2be4 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1492,7 +1492,7 @@ bool QResourceFileEngine::isSequential() const QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngine::FileFlags type) const { Q_D(const QResourceFileEngine); - QAbstractFileEngine::FileFlags ret = 0; + QAbstractFileEngine::FileFlags ret; if(!d->resource.isValid()) return ret; diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 878e007fb0..659552b72f 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -823,7 +823,7 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to) QString output; const QChar *begin = input.constData() + from; const QChar *end = input.constData() + to; - if (qt_urlRecode(output, begin, end, nullptr, actions)) + if (qt_urlRecode(output, begin, end, {}, actions)) return output; return input.mid(from, to - from); diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 88555f9572..fa975ce117 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -432,7 +432,7 @@ Qt::ItemFlags QPersistentModelIndex::flags() const { if (d) return d->index.flags(); - return 0; + return { }; } /*! @@ -2296,7 +2296,7 @@ Qt::ItemFlags QAbstractItemModel::flags(const QModelIndex &index) const { Q_D(const QAbstractItemModel); if (!d->indexValid(index)) - return 0; + return { }; return Qt::ItemIsSelectable|Qt::ItemIsEnabled; } diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index db5afac98e..a58547a2c3 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -96,7 +96,7 @@ public: void setLoadHints(QLibrary::LoadHints lh); static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString(), - QLibrary::LoadHints loadHints = nullptr); + QLibrary::LoadHints loadHints = { }); static QStringList suffixes_sys(const QString &fullVersion); static QStringList prefixes_sys(); diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 8d2187eb28..d0bdc0d45c 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -912,7 +912,7 @@ QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd) */ QRegularExpressionPrivate::QRegularExpressionPrivate() : QSharedData(), - patternOptions(0), + patternOptions(), pattern(), mutex(), compiledPattern(nullptr), diff --git a/src/corelib/text/qtextboundaryfinder.cpp b/src/corelib/text/qtextboundaryfinder.cpp index 67dd15377b..070b041220 100644 --- a/src/corelib/text/qtextboundaryfinder.cpp +++ b/src/corelib/text/qtextboundaryfinder.cpp @@ -71,7 +71,7 @@ static void init(QTextBoundaryFinder::BoundaryType type, const QChar *chars, int } } - QUnicodeTools::CharAttributeOptions options = 0; + QUnicodeTools::CharAttributeOptions options; switch (type) { case QTextBoundaryFinder::Grapheme: options |= QUnicodeTools::GraphemeBreaks; break; case QTextBoundaryFinder::Word: options |= QUnicodeTools::WordBreaks; break; diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 878a2c1e46..accaea988e 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -3266,7 +3266,7 @@ inline QDateTime::Data::Data(Qt::TimeSpec spec) // the structure is too small, we need to detach d = new QDateTimePrivate; d->ref.ref(); - d->m_status = mergeSpec(nullptr, spec); + d->m_status = mergeSpec({}, spec); } } diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 2c566e3584..70d6f280bf 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -407,7 +407,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) QDTPDEBUGN("parseFormat: %s", newFormat.toLatin1().constData()); QVector<SectionNode> newSectionNodes; - Sections newDisplay = 0; + Sections newDisplay; QStringList newSeparators; int i, index = 0; int add = 0; @@ -1799,7 +1799,7 @@ int QDateTimeParser::SectionNode::maxChange() const QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const { - FieldInfo ret = 0; + FieldInfo ret; const SectionNode &sn = sectionNode(index); switch (sn.type) { case MSecSection: diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index e9f1455380..ec4e4e4df2 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -84,7 +84,7 @@ public: DateTimeEdit }; QDateTimeParser(QVariant::Type t, Context ctx, const QCalendar &cal = QCalendar()) - : currentSectionIndex(-1), display(nullptr), cachedDay(-1), parserType(t), + : currentSectionIndex(-1), cachedDay(-1), parserType(t), fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal) { defaultLocale = QLocale::system(); diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index d6f3230fd2..b93dabb3a7 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -1139,7 +1139,7 @@ QString QDBusConnection::name() const */ QDBusConnection::ConnectionCapabilities QDBusConnection::connectionCapabilities() const { - return d ? d->capabilities : ConnectionCapabilities(0); + return d ? d->capabilities : ConnectionCapabilities(); } /*! diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 28779a41d0..fb4f927a87 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1026,7 +1026,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q extern bool qDBusInitThreads(); QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) - : QObject(p), ref(1), capabilities(0), mode(InvalidMode), busService(0), + : QObject(p), ref(1), mode(InvalidMode), busService(0), connection(0), rootNode(QString(QLatin1Char('/'))), anonymousAuthenticationAllowed(false), @@ -1770,7 +1770,7 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnection *connection) { - QDBusConnection::ConnectionCapabilities result = 0; + QDBusConnection::ConnectionCapabilities result; typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int); static can_send_type_t can_send_type = 0; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d8ed0829af..869e206524 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1912,10 +1912,10 @@ void QImage::invertPixels(InvertMode mode) // Inverting premultiplied pixels would produce invalid image data. if (hasAlphaChannel() && qPixelLayouts[d->format].premultiplied) { if (depth() > 32) { - if (!d->convertInPlace(QImage::Format_RGBA64, 0)) + if (!d->convertInPlace(QImage::Format_RGBA64, { })) *this = convertToFormat(QImage::Format_RGBA64); } else { - if (!d->convertInPlace(QImage::Format_ARGB32, 0)) + if (!d->convertInPlace(QImage::Format_ARGB32, { })) *this = convertToFormat(QImage::Format_ARGB32); } } @@ -1982,7 +1982,7 @@ void QImage::invertPixels(InvertMode mode) } if (originalFormat != d->format) { - if (!d->convertInPlace(originalFormat, 0)) + if (!d->convertInPlace(originalFormat, { })) *this = convertToFormat(originalFormat); } } diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 49eff2ad23..34c4549443 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE QPlatformCursor::clearOverrideCursor(). */ -QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = 0; +QPlatformCursor::Capabilities QPlatformCursor::m_capabilities = { }; /*! \fn QPlatformCursor::QPlatformCursor() diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 356c4ea3ea..3185fc4541 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -309,7 +309,7 @@ public: virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; virtual QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = nullptr) const; + QPlatformTheme::IconOptions iconOptions = { }) const; virtual QIconEngine *createIconEngine(const QString &iconName) const; #ifndef QT_NO_SHORTCUT diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index d3070a3d1a..803206477c 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -393,7 +393,7 @@ void QSimpleDrag::startDrag() static void sendDragLeave(QWindow *window) { - QWindowSystemInterface::handleDrag(window, nullptr, QPoint(), Qt::IgnoreAction, 0, 0); + QWindowSystemInterface::handleDrag(window, nullptr, QPoint(), Qt::IgnoreAction, { }, { }); } void QSimpleDrag::cancel() diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 238886220b..571b820409 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class QSurfaceFormatPrivate { public: - explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = 0) + explicit QSurfaceFormatPrivate(QSurfaceFormat::FormatOptions _opts = { }) : ref(1) , opts(_opts) , redBufferSize(-1) diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 537097c09f..5ad16a8438 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -545,9 +545,9 @@ void *QOpenGLBuffer::map(QOpenGLBuffer::Access access) qWarning("QOpenGLBuffer::map(): buffer not created"); #endif if (!d->guard || !d->guard->id()) - return 0; + return nullptr; if (d->funcs->hasOpenGLExtension(QOpenGLExtensions::MapBufferRange)) { - QOpenGLBuffer::RangeAccessFlags rangeAccess = 0; + QOpenGLBuffer::RangeAccessFlags rangeAccess; switch (access) { case QOpenGLBuffer::ReadOnly: rangeAccess = QOpenGLBuffer::RangeRead; diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 8ec814296a..42186ace23 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -489,7 +489,7 @@ QOpenGLFunctions::OpenGLFeatures QOpenGLFunctions::openGLFeatures() const { QOpenGLFunctionsPrivateEx *d = static_cast<QOpenGLFunctionsPrivateEx *>(d_ptr); if (!d) - return 0; + return { }; if (d->m_features == -1) d->m_features = qt_gl_resolve_features(); return QOpenGLFunctions::OpenGLFeatures(d->m_features); @@ -527,7 +527,7 @@ QOpenGLExtensions::OpenGLExtensions QOpenGLExtensions::openGLExtensions() { QOpenGLFunctionsPrivateEx *d = static_cast<QOpenGLFunctionsPrivateEx *>(d_ptr); if (!d) - return 0; + return { }; if (d->m_extensions == -1) d->m_extensions = qt_gl_resolve_extensions(); return QOpenGLExtensions::OpenGLExtensions(d->m_extensions); diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 47394999c6..20cc2b5ae5 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1575,7 +1575,7 @@ void QOpenGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, c case QImage::Format_ARGB32: case QImage::Format_RGBA64: d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::NonPremultipliedImageSrc); - bindOption = 0; + bindOption = { }; break; case QImage::Format_Alpha8: if (ctx->functions()->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats)) { diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 8314e8bc8a..722afaf119 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1061,7 +1061,7 @@ void QPaintEngineEx::drawStaticTextItem(QStaticTextItem *staticTextItem) QFontEngine *fontEngine = staticTextItem->fontEngine(); fontEngine->addGlyphsToPath(staticTextItem->glyphs, staticTextItem->glyphPositions, - staticTextItem->numGlyphs, &path, 0); + staticTextItem->numGlyphs, &path, { }); if (!path.isEmpty()) { QPainterState *s = state(); QPainter::RenderHints oldHints = s->renderHints; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3ce54c20be..4336ff66be 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5902,7 +5902,7 @@ void QPainter::drawText(const QPointF &p, const QString &str, int tf, int justif int numGlyphs = len; QVarLengthGlyphLayoutArray glyphs(len); QFontEngine *fontEngine = d->state->font.d->engineForScript(QChar::Script_Common); - if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, 0)) + if (!fontEngine->stringToCMap(str.data(), len, &glyphs, &numGlyphs, { })) Q_UNREACHABLE(); QTextItemInt gf(glyphs, &d->state->font, str.data(), len, fontEngine); @@ -6404,7 +6404,7 @@ Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t } QFixed width = rightMost - leftMost; - QTextItem::RenderFlags flags = 0; + QTextItem::RenderFlags flags; if (font.underline()) flags |= QTextItem::Underline; @@ -7213,7 +7213,7 @@ QPainter::RenderHints QPainter::renderHints() const Q_D(const QPainter); if (!d->engine) - return 0; + return { }; return d->state->renderHints; } @@ -7795,7 +7795,7 @@ QPainterState::QPainterState() composition_mode(QPainter::CompositionMode_SourceOver), emulationSpecifier(0), changeFlags(0) { - dirtyFlags = 0; + dirtyFlags = { }; } QPainterState::~QPainterState() @@ -7824,9 +7824,9 @@ void QPainterState::init(QPainter *p) { layoutDirection = QGuiApplication::layoutDirection(); composition_mode = QPainter::CompositionMode_SourceOver; emulationSpecifier = 0; - dirtyFlags = 0; + dirtyFlags = { }; changeFlags = 0; - renderHints = 0; + renderHints = { }; opacity = 1; } @@ -7883,7 +7883,7 @@ void QPainterState::init(QPainter *p) { /*! \fn void QPainter::drawImage(const QPointF &point, const QImage &image, const QRectF &source, - Qt::ImageConversionFlags flags = 0) + Qt::ImageConversionFlags flags = Qt::AutoColor) \overload @@ -7893,7 +7893,7 @@ void QPainterState::init(QPainter *p) { /*! \fn void QPainter::drawImage(const QPoint &point, const QImage &image, const QRect &source, - Qt::ImageConversionFlags flags = 0) + Qt::ImageConversionFlags flags = Qt::AutoColor) \overload Draws the rectangular portion \a source of the given \a image with diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 45e90bd99b..0ecb4390e9 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -427,7 +427,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i origin = QOpenGLTextureBlitter::OriginBottomLeft; textureId = d_ptr->textureId; } else { - TextureFlags flags = 0; + TextureFlags flags; textureId = toTexture(deviceRegion(region, window, offset), &d_ptr->textureSize, &flags); d_ptr->needsSwizzle = (flags & TextureSwizzle) != 0; d_ptr->premultiplied = (flags & TexturePremultiplied) != 0; @@ -534,7 +534,7 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu GLuint pixelType = GL_UNSIGNED_BYTE; bool needsConversion = false; - *flags = 0; + *flags = { }; switch (image.format()) { case QImage::Format_ARGB32_Premultiplied: *flags |= TexturePremultiplied; diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index 4f08b0092f..7aa054f1e2 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -100,7 +100,7 @@ public: bool isLocked() const; void appendTexture(void *source, GLuint textureId, const QRect &geometry, - const QRect &clipRect = QRect(), Flags flags = nullptr); + const QRect &clipRect = QRect(), Flags flags = { }); void clear(); Q_SIGNALS: diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 793ef5774b..cf3d8e5ea2 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -682,7 +682,7 @@ bool ValueExtractor::extractOutline(int *borders, QBrush *colors, BorderStyle *s static Qt::Alignment parseAlignment(const QCss::Value *values, int count) { - Qt::Alignment a[2] = { 0, 0 }; + Qt::Alignment a[2] = { { }, { } }; for (int i = 0; i < qMin(2, count); i++) { if (values[i].type != Value::KnownIdentifier) break; diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index d8a971c7b7..89f943ca51 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -952,7 +952,7 @@ void QDistanceField::setGlyph(QFontEngine *fontEngine, glyph_t glyph, bool doubl { QFixedPoint position; QPainterPath path; - fontEngine->addGlyphsToPath(&glyph, &position, 1, &path, 0); + fontEngine->addGlyphsToPath(&glyph, &position, 1, &path, { }); path.translate(-path.boundingRect().topLeft()); path.setFillRule(Qt::WindingFill); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 403a0510fa..3a1f5ed4f4 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -506,7 +506,7 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform g.numGlyphs = 1; g.glyphs = &kashidaGlyph; g.advances = &kashidaWidth; - recalcAdvances(&g, 0); + recalcAdvances(&g, { }); for (uint k = 0; k < glyphs.justifications[i].nKashidas; ++k) { xpos -= kashidaWidth; @@ -948,7 +948,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph) im.fill(Qt::transparent); QPainter p(&im); p.setRenderHint(QPainter::Antialiasing); - addGlyphsToPath(&glyph, &pt, 1, &path, 0); + addGlyphsToPath(&glyph, &pt, 1, &path, { }); p.setPen(Qt::NoPen); p.setBrush(Qt::black); p.drawPath(path); diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index d3e4f11e8c..906047cdb4 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -562,7 +562,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const int numGlyphs = len; QVarLengthGlyphLayoutArray glyphs(numGlyphs); QFontEngine *engine = d->engineForScript(QChar::Script_Common); - if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, 0)) + if (!engine->stringToCMap(text.data(), len, &glyphs, &numGlyphs, { })) Q_UNREACHABLE(); QFixed width; @@ -684,7 +684,7 @@ int QFontMetrics::horizontalAdvance(QChar ch) const glyphs.numGlyphs = 1; glyphs.glyphs = &glyph; glyphs.advances = &advance; - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); return qRound(advance); } @@ -736,7 +736,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const glyphs.numGlyphs = 1; glyphs.glyphs = &glyph; glyphs.advances = &advance; - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); width = qRound(advance); } @@ -1619,7 +1619,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const glyphs.numGlyphs = 1; glyphs.glyphs = &glyph; glyphs.advances = &advance; - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); return advance.toReal(); } diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp index 3c16c3bf62..f4cd839f15 100644 --- a/src/gui/text/qglyphrun.cpp +++ b/src/gui/text/qglyphrun.cpp @@ -279,7 +279,7 @@ void QGlyphRun::clear() { detach(); d->rawFont = QRawFont(); - d->flags = 0; + d->flags = { }; setPositions(QVector<QPointF>()); setGlyphIndexes(QVector<quint32>()); diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h index 465c3c7000..46e2a8bbfb 100644 --- a/src/gui/text/qglyphrun_p.h +++ b/src/gui/text/qglyphrun_p.h @@ -65,8 +65,7 @@ class QGlyphRunPrivate: public QSharedData { public: QGlyphRunPrivate() - : flags(nullptr) - , glyphIndexData(glyphIndexes.constData()) + : glyphIndexData(glyphIndexes.constData()) , glyphIndexDataSize(0) , glyphPositionData(glyphPositions.constData()) , glyphPositionDataSize(0) diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index a060448924..e04c8909f3 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -303,7 +303,7 @@ QPainterPath QRawFont::pathForGlyph(quint32 glyphIndex) const QFixedPoint position; QPainterPath path; - d->fontEngine->addGlyphsToPath(&glyphIndex, &position, 1, &path, 0); + d->fontEngine->addGlyphsToPath(&glyphIndex, &position, 1, &path, { }); return path; } diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 209433dac5..40adc4a3cf 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1720,7 +1720,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, g.glyphs[i] = actualFontEngine->glyphIndex('-'); if (Q_LIKELY(g.glyphs[i] != 0)) { QGlyphLayout tmp = g.mid(i, 1); - actualFontEngine->recalcAdvances(&tmp, 0); + actualFontEngine->recalcAdvances(&tmp, { }); } g.attributes[i].dontPrint = true; } @@ -2581,7 +2581,7 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, g.numGlyphs = 1; g.glyphs = &kashidaGlyph; g.advances = &point->kashidaWidth; - fe->recalcAdvances(&g, 0); + fe->recalcAdvances(&g, { }); if (point->kashidaWidth == 0) point->type = Justification_Prohibited; @@ -3214,13 +3214,13 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int glyphs.advances = &ellipsisWidth; if (glyph != 0) { - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); ellipsisText = ellipsisChar; } else { glyph = engine->glyphIndex('.'); if (glyph != 0) { - engine->recalcAdvances(&glyphs, 0); + engine->recalcAdvances(&glyphs, { }); ellipsisWidth *= 3; ellipsisText = QStringLiteral("..."); @@ -3928,7 +3928,7 @@ void QTextItemInt::initWithScriptItem(const QScriptItem &si) { // explicitly initialize flags so that initFontAttributes can be called // multiple times on the same TextItem - flags = 0; + flags = { }; if (si.analysis.bidiLevel %2) flags |= QTextItem::RightToLeft; ascent = si.ascent; diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 33adac40b2..024f0f084e 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -1147,7 +1147,7 @@ QLayoutPolicy::ControlTypes QGridLayoutEngine::controlTypes(LayoutSide side) con Qt::Orientation orientation = (side == Top || side == Bottom) ? Qt::Vertical : Qt::Horizontal; int row = (side == Top || side == Left) ? effectiveFirstRow(orientation) : effectiveLastRow(orientation); - QLayoutPolicy::ControlTypes result = 0; + QLayoutPolicy::ControlTypes result; for (int column = columnCount(orientation) - 1; column >= 0; --column) { if (QGridLayoutItem *item = itemAt(row, column, orientation)) diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 5f0e84edb1..181326103b 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -276,7 +276,7 @@ class Q_GUI_EXPORT QGridLayoutItem { public: QGridLayoutItem(int row, int column, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = nullptr); + Qt::Alignment alignment = { }); virtual ~QGridLayoutItem() {} inline int firstRow() const { return q_firstRows[Ver]; } @@ -339,7 +339,7 @@ private: class Q_GUI_EXPORT QGridLayoutEngine { public: - QGridLayoutEngine(Qt::Alignment defaultAlignment = Qt::Alignment(nullptr), bool snapToPixelGrid = false); + QGridLayoutEngine(Qt::Alignment defaultAlignment = { }, bool snapToPixelGrid = false); inline ~QGridLayoutEngine() { qDeleteAll(q_items); } int rowCount(Qt::Orientation orientation) const; diff --git a/src/gui/vulkan/qvulkanwindow_p.h b/src/gui/vulkan/qvulkanwindow_p.h index 777be237a8..915e359673 100644 --- a/src/gui/vulkan/qvulkanwindow_p.h +++ b/src/gui/vulkan/qvulkanwindow_p.h @@ -97,7 +97,7 @@ public: int physDevIndex = 0; QVector<VkPhysicalDevice> physDevs; QVector<VkPhysicalDeviceProperties> physDevProps; - QVulkanWindow::Flags flags = nullptr; + QVulkanWindow::Flags flags; QByteArrayList requestedDevExtensions; QHash<VkPhysicalDevice, QVulkanInfoVector<QVulkanExtension> > supportedDevExtensions; QVector<VkFormat> requestedColorFormats; diff --git a/src/network/access/qspdyprotocolhandler.cpp b/src/network/access/qspdyprotocolhandler.cpp index f845235bf7..cc913ce760 100644 --- a/src/network/access/qspdyprotocolhandler.cpp +++ b/src/network/access/qspdyprotocolhandler.cpp @@ -613,7 +613,7 @@ void QSpdyProtocolHandler::sendSYN_STREAM(const HttpMessagePair &messagePair, QHttpNetworkRequest request = messagePair.first; QHttpNetworkReply *reply = messagePair.second; - ControlFrameFlags flags = 0; + ControlFrameFlags flags; if (!request.uploadByteDevice()) { // no upload -> this is the last frame, send the FIN flag @@ -675,14 +675,14 @@ void QSpdyProtocolHandler::sendRST_STREAM(qint32 streamID, RST_STREAM_STATUS_COD char wireData[8]; appendIntToFourBytes(wireData, streamID); appendIntToFourBytes(wireData + 4, statusCode); - sendControlFrame(FrameType_RST_STREAM, /* flags = */ 0, wireData, /* length = */ 8); + sendControlFrame(FrameType_RST_STREAM, /* flags = */ { }, wireData, /* length = */ 8); } void QSpdyProtocolHandler::sendPING(quint32 pingID) { char rawData[4]; appendIntToFourBytes(rawData, pingID); - sendControlFrame(FrameType_PING, /* flags = */ 0, rawData, /* length = */ 4); + sendControlFrame(FrameType_PING, /* flags = */ { }, rawData, /* length = */ 4); } bool QSpdyProtocolHandler::uploadData(qint32 streamID) @@ -724,7 +724,7 @@ bool QSpdyProtocolHandler::uploadData(qint32 streamID) // nothing to read currently, break the loop break; } else { - DataFrameFlags flags = 0; + DataFrameFlags flags; // we will send the FIN flag later if appropriate qint64 currentWriteSize = sendDataFrame(streamID, flags, currentReadSize, readPointer); if (currentWriteSize == -1 || currentWriteSize != currentReadSize) { @@ -774,7 +774,7 @@ void QSpdyProtocolHandler::sendWINDOW_UPDATE(qint32 streamID, quint32 deltaWindo appendIntToFourBytes(windowUpdateData, streamID); appendIntToFourBytes(windowUpdateData + 4, deltaWindowSize); - sendControlFrame(FrameType_WINDOW_UPDATE, /* flags = */ 0, windowUpdateData, /* length = */ 8); + sendControlFrame(FrameType_WINDOW_UPDATE, /* flags = */ { }, windowUpdateData, /* length = */ 8); } qint64 QSpdyProtocolHandler::sendDataFrame(qint32 streamID, DataFrameFlags flags, diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h index 44e27a7e34..b879a397f2 100644 --- a/src/network/kernel/qnetworkinterface_p.h +++ b/src/network/kernel/qnetworkinterface_p.h @@ -82,7 +82,7 @@ public: class QNetworkInterfacePrivate: public QSharedData { public: - QNetworkInterfacePrivate() : index(0), flags(nullptr) + QNetworkInterfacePrivate() : index(0) { } ~QNetworkInterfacePrivate() { } diff --git a/src/network/kernel/qnetworkinterface_unix_p.h b/src/network/kernel/qnetworkinterface_unix_p.h index 553af5a303..e5c8909eca 100644 --- a/src/network/kernel/qnetworkinterface_unix_p.h +++ b/src/network/kernel/qnetworkinterface_unix_p.h @@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags) { - QNetworkInterface::InterfaceFlags flags = nullptr; + QNetworkInterface::InterfaceFlags flags; flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0); flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0); flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index d1df26d9f1..e7d15f4824 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -341,7 +341,7 @@ void QLocalSocketPrivate::_q_connectToSocket() } connectingSocket = -1; connectingName.clear(); - connectingOpenMode = 0; + connectingOpenMode = { }; } bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor, @@ -438,7 +438,7 @@ void QLocalSocket::close() ::close(d->connectingSocket); d->connectingSocket = -1; d->connectingName.clear(); - d->connectingOpenMode = 0; + d->connectingOpenMode = { }; d->serverName.clear(); d->fullServerName.clear(); QIODevice::close(); diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp index f22f9f470b..b20311bec4 100644 --- a/src/opengl/qglfunctions.cpp +++ b/src/opengl/qglfunctions.cpp @@ -279,7 +279,7 @@ QGLFunctions::OpenGLFeatures QGLFunctions::openGLFeatures() const { QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr); if (!d) - return 0; + return { }; if (d->m_features == -1) d->m_features = qt_gl_resolve_features(); return QGLFunctions::OpenGLFeatures(d->m_features); diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h index 8ad2eb7248..a137d0d328 100644 --- a/src/platformsupport/eglconvenience/qeglpbuffer_p.h +++ b/src/platformsupport/eglconvenience/qeglpbuffer_p.h @@ -60,7 +60,7 @@ class QEGLPbuffer : public QPlatformOffscreenSurface { public: QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface, - QEGLPlatformContext::Flags flags = nullptr); + QEGLPlatformContext::Flags flags = { }); ~QEGLPbuffer(); QSurfaceFormat format() const override { return m_format; } diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index ed77c57df5..f0388cd29c 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -69,7 +69,7 @@ public: QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config = nullptr, const QVariant &nativeHandle = QVariant(), - Flags flags = nullptr); + Flags flags = { }); ~QEGLPlatformContext(); void initialize() override; diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index c42fd879f8..76984dfe5c 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -255,7 +255,7 @@ QFbWindow *QFbScreen::windowForId(WId wid) const QFbScreen::Flags QFbScreen::flags() const { - return 0; + return { }; } QT_END_NAMESPACE diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index ad85360b0e..e3a79be12e 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -136,7 +136,7 @@ void QLibInputTouch::processTouchUp(libinput_event_touch *e) if (tp) { tp->state = Qt::TouchPointReleased; // There may not be a Frame event after the last Up. Work this around. - Qt::TouchPointStates s = 0; + Qt::TouchPointStates s; for (int i = 0; i < state->m_points.count(); ++i) s |= state->m_points.at(i).state; if (s == Qt::TouchPointReleased) diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index 92ba9fbcd9..b820fafd50 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -873,7 +873,7 @@ void QKmsDevice::discoverPlanes() plane.type = QKmsPlane::Type(value); } else if (!strcmp(prop->name, "rotation")) { plane.initialRotation = QKmsPlane::Rotations(int(value)); - plane.availableRotations = 0; + plane.availableRotations = { }; if (propTypeIs(prop, DRM_MODE_PROP_BITMASK)) { for (int i = 0; i < prop->count_enums; ++i) plane.availableRotations |= QKmsPlane::Rotation(1 << prop->enums[i].value); diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index c0da9d8370..f6acf00f39 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -109,7 +109,7 @@ public: QVariant themeHint(ThemeHint hint) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QPlatformTheme::IconOptions iconOptions = { }) const override; const QPalette *palette(Palette type = SystemPalette) const override; @@ -134,7 +134,7 @@ public: QGnomeTheme(); QVariant themeHint(ThemeHint hint) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions = nullptr) const override; + QPlatformTheme::IconOptions = { }) const override; const QFont *font(Font type) const override; QString standardButtonText(int button) const override; diff --git a/src/plugins/imageformats/gif/main.cpp b/src/plugins/imageformats/gif/main.cpp index c171111fac..993871420c 100644 --- a/src/plugins/imageformats/gif/main.cpp +++ b/src/plugins/imageformats/gif/main.cpp @@ -62,7 +62,7 @@ QImageIOPlugin::Capabilities QGifPlugin::capabilities(QIODevice *device, const Q { if (format == "gif" || (device && device->isReadable() && QGifHandler::canRead(device))) return Capabilities(CanRead); - return 0; + return { }; } QImageIOHandler *QGifPlugin::create(QIODevice *device, const QByteArray &format) const diff --git a/src/plugins/imageformats/ico/main.cpp b/src/plugins/imageformats/ico/main.cpp index baaf33e1fc..b00d8c7fd3 100644 --- a/src/plugins/imageformats/ico/main.cpp +++ b/src/plugins/imageformats/ico/main.cpp @@ -46,9 +46,9 @@ QImageIOPlugin::Capabilities QICOPlugin::capabilities(QIODevice *device, const Q if (format == "ico" || format == "cur") return Capabilities(CanRead | CanWrite); if (!format.isEmpty()) - return 0; + return { }; if (!device->isOpen()) - return 0; + return { }; Capabilities cap; if (device->isReadable() && QtIcoHandler::canRead(device)) diff --git a/src/plugins/imageformats/jpeg/main.cpp b/src/plugins/imageformats/jpeg/main.cpp index 58442053a1..83f13c4a9d 100644 --- a/src/plugins/imageformats/jpeg/main.cpp +++ b/src/plugins/imageformats/jpeg/main.cpp @@ -51,9 +51,9 @@ QImageIOPlugin::Capabilities QJpegPlugin::capabilities(QIODevice *device, const if (format == "jpeg" || format == "jpg") return Capabilities(CanRead | CanWrite); if (!format.isEmpty()) - return 0; + return { }; if (!device->isOpen()) - return 0; + return { }; Capabilities cap; if (device->isReadable() && QJpegHandler::canRead(device)) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index 8e7b8df120..e9c9c55f6a 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -61,7 +61,7 @@ public: explicit QIBusFilterEventWatcher(const QDBusPendingCall &call, QObject *parent = nullptr, QWindow *window = nullptr, - const Qt::KeyboardModifiers modifiers = nullptr, + const Qt::KeyboardModifiers modifiers = { }, const QVariantList arguments = QVariantList()) : QDBusPendingCallWatcher(call, parent) , m_window(window) diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index 674f579b4f..d3f51c0d0e 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -236,7 +236,7 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf EGLDisplay dpy = surface->screen() ? static_cast<QEglFSScreen *>(surface->screen()->handle())->display() : display(); QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat()); if (qt_egl_device_integration()->supportsPBuffers()) { - QEGLPlatformContext::Flags flags = 0; + QEGLPlatformContext::Flags flags; if (!qt_egl_device_integration()->supportsSurfacelessContexts()) flags |= QEGLPlatformContext::NoSurfaceless; return new QEGLPbuffer(dpy, fmt, surface, flags); diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index 1fed182882..e6b25c02fd 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -186,7 +186,7 @@ void QEglFSWindow::destroy() #endif } - m_flags = 0; + m_flags = { }; } void QEglFSWindow::invalidateSurface() diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm index 54152aebf7..c5244a51ad 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm @@ -373,7 +373,7 @@ bool QIOSFileEngineAssetsLibrary::close() QAbstractFileEngine::FileFlags QIOSFileEngineAssetsLibrary::fileFlags(QAbstractFileEngine::FileFlags type) const { - QAbstractFileEngine::FileFlags flags = 0; + QAbstractFileEngine::FileFlags flags; const bool isDir = (m_assetUrl == QLatin1String("assets-library://")); const bool exists = isDir || m_assetUrl == g_iteratorCurrentUrl.localData() || loadAsset(); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index e51c3d0502..cbc930387f 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -455,7 +455,7 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err static Qt::MouseButtons translateMouseButtons(int s) { - Qt::MouseButtons ret = 0; + Qt::MouseButtons ret; if (s & XCB_BUTTON_MASK_1) ret |= Qt::LeftButton; if (s & XCB_BUTTON_MASK_2) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index a894944096..62c5e5d79e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -294,7 +294,7 @@ private: int deviceId = 0; QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer; QTabletEvent::TabletDevice tool = QTabletEvent::Stylus; - Qt::MouseButtons buttons = 0; + Qt::MouseButtons buttons; qint64 serialId = 0; bool inProximity = false; struct ValuatorClassInfo { @@ -318,8 +318,8 @@ private: int horizontalIndex = 0; double verticalIncrement = 0; double horizontalIncrement = 0; - Qt::Orientations orientations = 0; - Qt::Orientations legacyOrientations = 0; + Qt::Orientations orientations; + Qt::Orientations legacyOrientations; QPointF lastScrollPosition; }; QHash<int, ScrollingDevice> m_scrollingDevices; @@ -360,7 +360,7 @@ private: WindowMapper m_mapper; - Qt::MouseButtons m_buttonState = nullptr; + Qt::MouseButtons m_buttonState; Qt::MouseButton m_button = Qt::NoButton; QXcbWindow *m_focusWindow = nullptr; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 4639185416..fdf59c5ef4 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -424,7 +424,7 @@ QXcbConnection::TouchDeviceData *QXcbConnection::touchDeviceForId(int id) QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info) { auto *deviceinfo = reinterpret_cast<xcb_input_xi_device_info_t *>(info); - QTouchDevice::Capabilities caps = 0; + QTouchDevice::Capabilities caps; int type = -1; int maxTouchPoints = 1; bool isTouchDevice = false; diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 3d525598ca..eb5b8f808e 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -883,7 +883,7 @@ void QXcbDrag::handleLeave(QPlatformWindow *w, const xcb_client_message_event_t event->data.data32[0], xdnd_dragsource); } - QWindowSystemInterface::handleDrag(w->window(), nullptr, QPoint(), Qt::IgnoreAction, 0, 0); + QWindowSystemInterface::handleDrag(w->window(), nullptr, QPoint(), Qt::IgnoreAction, { }, { }); } void QXcbDrag::send_leave() diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index 1388e68acc..7bef7a818a 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -86,7 +86,7 @@ public: void handlePosition(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleLeave(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleDrop(QPlatformWindow *, const xcb_client_message_event_t *event, - Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr); + Qt::MouseButtons b = { }, Qt::KeyboardModifiers mods = { }); void handleStatus(const xcb_client_message_event_t *event); void handleSelectionRequest(const xcb_selection_request_event_t *event); @@ -109,7 +109,7 @@ private: void init(); void handle_xdnd_position(QPlatformWindow *w, const xcb_client_message_event_t *event, - Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr); + Qt::MouseButtons b = { }, Qt::KeyboardModifiers mods = { }); void handle_xdnd_status(const xcb_client_message_event_t *event); void send_leave(); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 76d3545d35..840bcfd3bb 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -927,7 +927,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values); - QXcbWindowFunctions::WmWindowTypes wmWindowTypes = 0; + QXcbWindowFunctions::WmWindowTypes wmWindowTypes; if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) { wmWindowTypes = static_cast<QXcbWindowFunctions::WmWindowTypes>( window()->property(wm_window_type_property_id).value<int>()); diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h index 5cfc4df0d0..d38b3ddda3 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h @@ -72,7 +72,7 @@ public: QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QPlatformTheme::IconOptions iconOptions = { }) const override; QIconEngine *createIconEngine(const QString &iconName) const override; diff --git a/src/printsupport/kernel/qpaintengine_alpha_p.h b/src/printsupport/kernel/qpaintengine_alpha_p.h index efae442690..bc6ca91017 100644 --- a/src/printsupport/kernel/qpaintengine_alpha_p.h +++ b/src/printsupport/kernel/qpaintengine_alpha_p.h @@ -81,7 +81,7 @@ public: void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override; protected: - QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps = 0); + QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps = { }); QRegion alphaClipping() const; bool continueCall() const; void flushAndInit(bool init = true); diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index ba8a6dea36..4b29492134 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -1305,7 +1305,7 @@ Qt::ItemFlags QSqlTableModel::flags(const QModelIndex &index) const Q_D(const QSqlTableModel); if (index.internalPointer() || index.column() < 0 || index.column() >= d->rec.count() || index.row() < 0) - return 0; + return { }; bool editable = true; diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index a1b9003c1c..fbcc02accd 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -370,7 +370,7 @@ QFileDialog::QFileDialog(QWidget *parent, const QString &caption, const QString &directory, const QString &filter) - : QDialog(*new QFileDialogPrivate, parent, 0) + : QDialog(*new QFileDialogPrivate, parent, { }) { Q_D(QFileDialog); d->init(QUrl::fromLocalFile(directory), filter, caption); @@ -380,7 +380,7 @@ QFileDialog::QFileDialog(QWidget *parent, \internal */ QFileDialog::QFileDialog(const QFileDialogArgs &args) - : QDialog(*new QFileDialogPrivate, args.parent, 0) + : QDialog(*new QFileDialogPrivate, args.parent, { }) { Q_D(QFileDialog); d->init(args.directory, args.filter, args.caption); diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 844e417e2d..ad98b9ef44 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -116,7 +116,7 @@ public: inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; } inline QString type() const { if (info) return info->displayType; return QLatin1String(""); } inline QDateTime lastModified() const { if (info) return info->lastModified(); return QDateTime(); } - inline QFile::Permissions permissions() const { if (info) return info->permissions(); return nullptr; } + inline QFile::Permissions permissions() const { if (info) return info->permissions(); return { }; } inline bool isReadable() const { return ((permissions() & QFile::ReadUser) != 0); } inline bool isWritable() const { return ((permissions() & QFile::WriteUser) != 0); } inline bool isExecutable() const { return ((permissions() & QFile::ExeUser) != 0); } diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 7e3592e034..3da829d328 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -391,7 +391,7 @@ QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, cons QFont QFontDialog::getFont(bool *ok, QWidget *parent) { QFont initial; - return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0); + return QFontDialogPrivate::getFont(ok, initial, parent, QString(), { }); } QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent, diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index e1a6bce5b1..189dcd2989 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -492,7 +492,7 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c) if (c->parentWidget() == q) c->hide(); // until after ensureSizeIsAtLeastSizeHint() else - c->setParent(q, 0); + c->setParent(q, { }); } ensureSizeIsAtLeastSizeHint(); if (c) diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 0295241a74..7c4a473976 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3444,7 +3444,7 @@ int QWizard::nextId() const \sa wizard() */ QWizardPage::QWizardPage(QWidget *parent) - : QWidget(*new QWizardPagePrivate, parent, 0) + : QWidget(*new QWizardPagePrivate, parent, { }) { connect(this, SIGNAL(completeChanged()), this, SLOT(_q_updateCachedCompleteState())); } diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp index 6a8d5c907b..5797d9e539 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp @@ -96,7 +96,7 @@ Qt::Alignment QGraphicsGridLayoutEngine::alignment(QGraphicsLayoutItem *graphics { if (QGraphicsGridLayoutEngineItem *gridEngineItem = findLayoutItem(graphicsLayoutItem)) return gridEngineItem->alignment(); - return 0; + return { }; } diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h index e98160e40f..2f2c547977 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h @@ -68,7 +68,7 @@ class QGraphicsLayoutPrivate; class QGraphicsGridLayoutEngineItem : public QGridLayoutItem { public: QGraphicsGridLayoutEngineItem(QGraphicsLayoutItem *item, int row, int columns, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = nullptr) + Qt::Alignment alignment = { }) : QGridLayoutItem(row, columns, rowSpan, columnSpan, alignment), q_layoutItem(item) {} virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index 8964b3b77a..22633df4e3 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -280,7 +280,7 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item) Q_ASSERT(item); d->fixIndex(&index); d->engine.insertRow(index, d->orientation); - QGraphicsGridLayoutEngineItem *gridEngineItem = new QGraphicsGridLayoutEngineItem(item, d->gridRow(index), d->gridColumn(index), 1, 1, 0); + QGraphicsGridLayoutEngineItem *gridEngineItem = new QGraphicsGridLayoutEngineItem(item, d->gridRow(index), d->gridColumn(index), 1, 1, { }); d->engine.insertItem(gridEngineItem, index); invalidate(); } diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 7413a26261..c60dca7a90 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -235,7 +235,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneHoverEvent mouseEvent.setPos(event->pos()); mouseEvent.setScreenPos(event->screenPos()); mouseEvent.setButton(Qt::NoButton); - mouseEvent.setButtons(0); + mouseEvent.setButtons({ }); mouseEvent.setModifiers(event->modifiers()); sendWidgetMouseEvent(&mouseEvent); event->setAccepted(mouseEvent.isAccepted()); diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 57be850829..f1ed0f3b4e 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -348,7 +348,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() hasUpdateClip(false), mousePressButton(Qt::NoButton), leftIndent(0), topIndent(0), - lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, 0, 0), + lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, { }, { }), alignment(Qt::AlignCenter), transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor), viewportUpdateMode(QGraphicsView::MinimalViewportUpdate), @@ -1170,7 +1170,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity() q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled); if (!enabled) { - q->setInputMethodHints(0); + q->setInputMethodHints({ }); return; } @@ -1183,7 +1183,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity() widget = fw; q->setInputMethodHints(widget->inputMethodHints()); } else { - q->setInputMethodHints(0); + q->setInputMethodHints({ }); } } diff --git a/src/widgets/itemviews/qcolumnviewgrip.cpp b/src/widgets/itemviews/qcolumnviewgrip.cpp index 4a4237805f..00cd7df20a 100644 --- a/src/widgets/itemviews/qcolumnviewgrip.cpp +++ b/src/widgets/itemviews/qcolumnviewgrip.cpp @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE Use setModel() to set the model. */ QColumnViewGrip::QColumnViewGrip(QWidget *parent) -: QWidget(*new QColumnViewGripPrivate, parent, 0) + : QWidget(*new QColumnViewGripPrivate, parent, { }) { #ifndef QT_NO_CURSOR setCursor(Qt::SplitHCursor); diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h index 4311edbeb4..13e4c764e8 100644 --- a/src/widgets/itemviews/qcolumnviewgrip_p.h +++ b/src/widgets/itemviews/qcolumnviewgrip_p.h @@ -73,7 +73,7 @@ public: int moveGrip(int offset); protected: - QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); + QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = { }); void paintEvent(QPaintEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 6f7527c013..1c8b997dcb 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1696,7 +1696,7 @@ Qt::Orientations QFormLayout::expandingDirections() const QFormLayoutPrivate *e = const_cast<QFormLayoutPrivate *>(d); e->updateSizes(); - Qt::Orientations o = 0; + Qt::Orientations o; if (e->expandHorizontal) o = Qt::Horizontal; if (e->expandVertical) @@ -2326,7 +2326,7 @@ void QFormLayout::resetRowWrapPolicy() void QFormLayout::resetFormAlignment() { Q_D(QFormLayout); - d->formAlignment = 0; + d->formAlignment = { }; } /*! @@ -2336,7 +2336,7 @@ void QFormLayout::resetFormAlignment() void QFormLayout::resetLabelAlignment() { Q_D(QFormLayout); - d->labelAlignment = 0; + d->labelAlignment = { }; } #if 0 diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index cbf8d60892..057302bda1 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -111,8 +111,7 @@ class QPinchGesturePrivate : public QGesturePrivate public: QPinchGesturePrivate() - : totalChangeFlags(nullptr), changeFlags(nullptr), - totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), + : totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), isNewSequence(true) { diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index bd06ead6f7..f0f4fc5505 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1337,7 +1337,7 @@ QRect QLayout::alignmentRect(const QRect &r) const returned by QLayoutItems that have an alignment. */ QLayout *that = const_cast<QLayout *>(this); - that->setAlignment(0); + that->setAlignment({ }); QSize ms = that->maximumSize(); that->setAlignment(a); diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 948c2424e6..2999bae646 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -105,9 +105,9 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i); Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w); Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, - const QSizePolicy &sizePolicy, Qt::Alignment align = nullptr); -Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = nullptr); -Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = nullptr); + const QSizePolicy &sizePolicy, Qt::Alignment align = { }); +Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = { }); +Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = { }); Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm); diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index 8a95b12d89..a5c204d59d 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -183,7 +183,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, } case QEvent::TouchUpdate: { const QTouchEvent *ev = static_cast<const QTouchEvent *>(event); - d->changeFlags = 0; + d->changeFlags = { }; if (ev->touchPoints().size() == 2) { QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0); QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); @@ -256,7 +256,7 @@ void QPinchGestureRecognizer::reset(QGesture *state) QPinchGesture *pinch = static_cast<QPinchGesture *>(state); QPinchGesturePrivate *d = pinch->d_func(); - d->totalChangeFlags = d->changeFlags = 0; + d->totalChangeFlags = d->changeFlags = { }; d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF(); d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index e9968e41b4..e96e06d874 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -396,7 +396,7 @@ void QWidget::setAutoFillBackground(bool enabled) If it is \nullptr (the default), the new widget will be a window. If not, it will be a child of \e parent, and be constrained by \e parent's geometry (unless you specify Qt::Window as window flag). - \li \c{Qt::WindowFlags f = 0} (where available) sets the window flags; + \li \c{Qt::WindowFlags f = { }} (where available) sets the window flags; the default is suitable for almost all widgets, but to get, for example, a window without a window system frame, you must use special flags. @@ -1595,7 +1595,7 @@ void QWidgetPrivate::createTLExtra() x->basew = x->baseh = 0; x->frameStrut.setCoords(0, 0, 0, 0); x->normalGeometry = QRect(0,0,-1,-1); - x->savedFlags = 0; + x->savedFlags = { }; x->opacity = 255; x->posIncludesFrame = 0; x->sizeAdjusted = false; diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 698928b0b0..62da3fabf4 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -592,7 +592,7 @@ public: Q_Q(QWidget); return q->testAttribute(Qt::WA_AlwaysStackOnTop) ? QPlatformTextureList::StacksOnTop - : QPlatformTextureList::Flags(nullptr); + : QPlatformTextureList::Flags(); } virtual QImage grabFramebuffer() { return QImage(); } virtual void beginBackingStorePainting() { } diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index c6de168c10..72474077aa 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QWindowContainer : public QWidget Q_DECLARE_PRIVATE(QWindowContainer) public: - explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); + explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = { }); ~QWindowContainer(); QWindow *containedWindow() const; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 0568d749c8..24a397a274 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -479,7 +479,7 @@ struct QStyleSheetGeometryData : public QSharedData struct QStyleSheetPositionData : public QSharedData { - QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = 0) + QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = { }) : left(l), top(t), bottom(b), right(r), origin(o), position(p), mode(m), textAlignment(a) { } int left, top, bottom, right; @@ -922,9 +922,9 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject int left = 0, top = 0, right = 0, bottom = 0; Origin origin = Origin_Unknown; - Qt::Alignment position = 0; + Qt::Alignment position; QCss::PositionMode mode = PositionMode_Unknown; - Qt::Alignment textAlignment = 0; + Qt::Alignment textAlignment; if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment)) p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment); @@ -2231,7 +2231,7 @@ static Qt::Alignment defaultPosition(int pe) return Qt::AlignRight | Qt::AlignVCenter; default: - return 0; + return { }; } } @@ -3341,7 +3341,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC layout = subControlLayout(QLatin1String("mNX")); QStyleOptionComplex optCopy(*opt); - optCopy.subControls = 0; + optCopy.subControls = { }; for (int i = 0; i < layout.count(); i++) { int layoutButton = layout[i].toInt(); if (layoutButton < PseudoElement_MdiCloseButton @@ -4242,7 +4242,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q } r = subRule.contentsRect(r); - Qt::Alignment alignment = 0; + Qt::Alignment alignment; if (subRule.hasPosition()) alignment = subRule.position()->textAlignment; if (alignment == 0) diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index d956d2ba23..19528d61d2 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -468,7 +468,7 @@ void QAbstractButtonPrivate::emitToggled(bool checked) Constructs an abstract button with a \a parent. */ QAbstractButton::QAbstractButton(QWidget *parent) - : QWidget(*new QAbstractButtonPrivate, parent, 0) + : QWidget(*new QAbstractButtonPrivate, parent, { }) { Q_D(QAbstractButton); d->init(); @@ -490,7 +490,7 @@ QAbstractButton::QAbstractButton(QWidget *parent) /*! \internal */ QAbstractButton::QAbstractButton(QAbstractButtonPrivate &dd, QWidget *parent) - : QWidget(dd, parent, 0) + : QWidget(dd, parent, { }) { Q_D(QAbstractButton); d->init(); diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index dc325ab871..a0611565b8 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -273,13 +273,13 @@ void QAbstractSliderPrivate::setSteps(int single, int page) \l value of 0. */ QAbstractSlider::QAbstractSlider(QWidget *parent) - :QWidget(*new QAbstractSliderPrivate, parent, 0) + :QWidget(*new QAbstractSliderPrivate, parent, { }) { } /*! \internal */ QAbstractSlider::QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent) - :QWidget(dd, parent, 0) + :QWidget(dd, parent, { }) { } diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index fc19e0793e..b1e1c9bc1b 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -147,7 +147,7 @@ QT_BEGIN_NAMESPACE */ QAbstractSpinBox::QAbstractSpinBox(QWidget *parent) - : QWidget(*new QAbstractSpinBoxPrivate, parent, 0) + : QWidget(*new QAbstractSpinBoxPrivate, parent, { }) { Q_D(QAbstractSpinBox); d->init(); @@ -157,7 +157,7 @@ QAbstractSpinBox::QAbstractSpinBox(QWidget *parent) \internal */ QAbstractSpinBox::QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent) - : QWidget(dd, parent, 0) + : QWidget(dd, parent, { }) { Q_D(QAbstractSpinBox); d->init(); diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 8593001f8b..749ae96df2 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -1207,9 +1207,9 @@ Qt::ItemFlags QCalendarModel::flags(const QModelIndex &index) const if (!date.isValid()) return QAbstractTableModel::flags(index); if (date < m_minimumDate) - return 0; + return { }; if (date > m_maximumDate) - return 0; + return { }; return QAbstractTableModel::flags(index); } @@ -2135,7 +2135,7 @@ void QCalendarWidgetPrivate::_q_editingFinished() \sa setCurrentPage() */ QCalendarWidget::QCalendarWidget(QWidget *parent) - : QWidget(*new QCalendarWidgetPrivate, parent, 0) + : QWidget(*new QCalendarWidgetPrivate, parent, { }) { Q_D(QCalendarWidget); diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 2d21187317..03dcde0a58 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -931,7 +931,7 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const model QStandardItemModel. */ QComboBox::QComboBox(QWidget *parent) - : QWidget(*new QComboBoxPrivate(), parent, 0) + : QWidget(*new QComboBoxPrivate(), parent, { }) { Q_D(QComboBox); d->init(); @@ -941,7 +941,7 @@ QComboBox::QComboBox(QWidget *parent) \internal */ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent) - : QWidget(dd, parent, 0) + : QWidget(dd, parent, { }) { Q_D(QComboBox); d->init(); diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index e26993fb23..f7763ce27b 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1421,7 +1421,7 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled)); } - QAbstractSpinBox::StepEnabled ret = 0; + QAbstractSpinBox::StepEnabled ret = { }; #ifdef QT_KEYPAD_NAVIGATION if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) { @@ -1456,7 +1456,7 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const switch (d->sectionType(d->currentSectionIndex)) { case QDateTimeParser::NoSection: case QDateTimeParser::FirstSection: - case QDateTimeParser::LastSection: return 0; + case QDateTimeParser::LastSection: return { }; default: break; } if (d->wrapping) @@ -1659,12 +1659,11 @@ QDateTimeEditPrivate::QDateTimeEditPrivate() cacheGuard = false; fixday = true; type = QVariant::DateTime; - sections = 0; + sections = { }; cachedDay = -1; currentSectionIndex = FirstSectionIndex; first.pos = 0; - sections = 0; calendarPopup = false; minimum = QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay(); maximum = QDATETIMEEDIT_DATE_MAX.endOfDay(); @@ -2256,7 +2255,7 @@ QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Se QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::Sections s) { - QDateTimeEdit::Sections ret = 0; + QDateTimeEdit::Sections ret; if (s & QDateTimeParser::MSecSection) ret |= QDateTimeEdit::MSecSection; if (s & QDateTimeParser::SecondSection) diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 28f6cdc7bd..9096ee82f6 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -482,7 +482,7 @@ QDialogButtonBox::QDialogButtonBox(QWidget *parent) \sa orientation, addButton() */ QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent) - : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0) + : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, { }) { d_func()->initLayout(); } diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 05ec3aface..687ef8ba29 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -238,8 +238,8 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *) } opt.icon = icon(); - opt.subControls = 0; - opt.activeSubControls = 0; + opt.subControls = { }; + opt.activeSubControls = { }; opt.features = QStyleOptionToolButton::None; opt.arrowType = Qt::NoArrow; opt.iconSize = dockButtonIconSize(); diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index 7069ef0368..e69366d7c8 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -65,7 +65,7 @@ class QAlphaWidget: public QWidget, private QEffects { Q_OBJECT public: - QAlphaWidget(QWidget* w, Qt::WindowFlags f = 0); + QAlphaWidget(QWidget* w, Qt::WindowFlags f = { }); ~QAlphaWidget(); void run(int time); diff --git a/src/widgets/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp index 0992becdf0..ee24e92c7e 100644 --- a/src/widgets/widgets/qfocusframe.cpp +++ b/src/widgets/widgets/qfocusframe.cpp @@ -154,7 +154,7 @@ void QFocusFrame::initStyleOption(QStyleOption *option) const */ QFocusFrame::QFocusFrame(QWidget *parent) - : QWidget(*new QFocusFramePrivate, parent, 0) + : QWidget(*new QFocusFramePrivate, parent, { }) { setAttribute(Qt::WA_TransparentForMouseEvents); setFocusPolicy(Qt::NoFocus); diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index eec794562a..f7fe072302 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -178,7 +178,7 @@ void QGroupBoxPrivate::click() */ QGroupBox::QGroupBox(QWidget *parent) - : QWidget(*new QGroupBoxPrivate, parent, 0) + : QWidget(*new QGroupBoxPrivate, parent, { }) { Q_D(QGroupBox); d->init(); diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 6f2a6b2d5a..b63b0b4d72 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -131,7 +131,7 @@ void QKeySequenceEditPrivate::finishEditing() Constructs a QKeySequenceEdit widget with the given \a parent. */ QKeySequenceEdit::QKeySequenceEdit(QWidget *parent) - : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, 0) + : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, { }) { } diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index fb67936768..92f43a309d 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -274,7 +274,7 @@ QLineEdit::QLineEdit(QWidget* parent) \sa text(), setMaxLength() */ QLineEdit::QLineEdit(const QString& contents, QWidget* parent) - : QWidget(*new QLineEditPrivate, parent, 0) + : QWidget(*new QLineEditPrivate, parent, { }) { Q_D(QLineEdit); d->init(contents); diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 967b713096..ebed47da30 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -334,7 +334,7 @@ class QDockWidgetGroupWindow : public QWidget { Q_OBJECT public: - explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr) + explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = { }) : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; #if QT_CONFIG(tabbar) diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index d58a1d06db..a0286dfcb1 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -2212,7 +2212,7 @@ void QMdiSubWindowPrivate::updateInternalWindowTitle() \sa QMdiArea::addSubWindow() */ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags) - : QWidget(*new QMdiSubWindowPrivate, parent, 0) + : QWidget(*new QMdiSubWindowPrivate, parent, { }) { Q_D(QMdiSubWindow); #if QT_CONFIG(menu) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 69b1c5896f..afa5ca7142 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -735,7 +735,7 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c /*! Constructs a menu bar with parent \a parent. */ -QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, 0) +QMenuBar::QMenuBar(QWidget *parent) : QWidget(*new QMenuBarPrivate, parent, { }) { Q_D(QMenuBar); d->init(); diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp index 56253b8e44..04241fda09 100644 --- a/src/widgets/widgets/qprogressbar.cpp +++ b/src/widgets/widgets/qprogressbar.cpp @@ -234,7 +234,7 @@ bool QProgressBarPrivate::repaintRequired() const */ QProgressBar::QProgressBar(QWidget *parent) - : QWidget(*(new QProgressBarPrivate), parent, 0) + : QWidget(*(new QProgressBarPrivate), parent, { }) { d_func()->init(); } diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h index 2bdf9ed596..26335285a4 100644 --- a/src/widgets/widgets/qscrollarea_p.h +++ b/src/widgets/widgets/qscrollarea_p.h @@ -65,7 +65,7 @@ class QScrollAreaPrivate: public QAbstractScrollAreaPrivate Q_DECLARE_PUBLIC(QScrollArea) public: - QScrollAreaPrivate(): resizable(false), alignment(nullptr){} + QScrollAreaPrivate(): resizable(false) {} void updateScrollBars(); void updateWidgetPosition(); QPointer<QWidget> widget; diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 835af9c7b8..662d4c9e92 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -195,7 +195,7 @@ Qt::Corner QSizeGripPrivate::corner() const parent. */ QSizeGrip::QSizeGrip(QWidget * parent) - : QWidget(*new QSizeGripPrivate, parent, 0) + : QWidget(*new QSizeGripPrivate, parent, { }) { Q_D(QSizeGrip); d->init(); diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index e7a4889996..1a5fb7f251 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -119,7 +119,7 @@ QSplitterPrivate::~QSplitterPrivate() \a parent. */ QSplitterHandle::QSplitterHandle(Qt::Orientation orientation, QSplitter *parent) - : QWidget(*new QSplitterHandlePrivate, parent, 0) + : QWidget(*new QSplitterHandlePrivate, parent, { }) { Q_D(QSplitterHandle); d->s = parent; diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index 39f0f11daf..943b576ee3 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -226,7 +226,7 @@ QRect QStatusBarPrivate::messageRect() const \sa setSizeGripEnabled() */ QStatusBar::QStatusBar(QWidget * parent) - : QWidget(*new QStatusBarPrivate, parent, 0) + : QWidget(*new QStatusBarPrivate, parent, { }) { Q_D(QStatusBar); d->box = 0; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 7e1794efef..dfe362bdca 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -859,7 +859,7 @@ void QTabBarPrivate::refresh() Creates a new tab bar with the given \a parent. */ QTabBar::QTabBar(QWidget* parent) - :QWidget(*new QTabBarPrivate, parent, 0) + :QWidget(*new QTabBarPrivate, parent, { }) { Q_D(QTabBar); d->init(); diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index 4d7b39ae01..2b3b8280bb 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -359,7 +359,7 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const Constructs a tabbed widget with parent \a parent. */ QTabWidget::QTabWidget(QWidget *parent) - : QWidget(*new QTabWidgetPrivate, parent, 0) + : QWidget(*new QTabWidgetPrivate, parent, { }) { Q_D(QTabWidget); d->init(); diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 58e9c4fd87..79182dfa33 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -503,7 +503,7 @@ void QToolBarPrivate::plug(const QRect &r) Constructs a QToolBar with the given \a parent. */ QToolBar::QToolBar(QWidget *parent) - : QWidget(*new QToolBarPrivate, parent, 0) + : QWidget(*new QToolBarPrivate, parent, { }) { Q_D(QToolBar); d->init(); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 59bf5466e6..1f06aa0b97 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -116,12 +116,12 @@ public: void setCurrentCharFormat(const QTextCharFormat &format); QTextCharFormat currentCharFormat() const; - bool find(const QString &exp, QTextDocument::FindFlags options = nullptr); + bool find(const QString &exp, QTextDocument::FindFlags options = { }); #ifndef QT_NO_REGEXP - bool find(const QRegExp &exp, QTextDocument::FindFlags options = nullptr); + bool find(const QRegExp &exp, QTextDocument::FindFlags options = { }); #endif #if QT_CONFIG(regularexpression) - bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = nullptr); + bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = { }); #endif QString toPlainText() const; -- cgit v1.2.3 From b455e45ab2f33ed24d7d6c484dc6c58ed62db45d Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Thu, 21 Nov 2019 07:50:59 +0100 Subject: Deprecate TlsV1SslV3 Since we anyway deprecated SslV3. Change-Id: I437114a76062b7a18a9978e359b3ccf16869c17d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/network/ssl/qssl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h index 4ca90cc8c5..b28c2a87b9 100644 --- a/src/network/ssl/qssl.h +++ b/src/network/ssl/qssl.h @@ -88,8 +88,10 @@ namespace QSsl { TlsV1_1, TlsV1_2, AnyProtocol, +#if QT_DEPRECATED_SINCE(5, 15) TlsV1SslV3, - SecureProtocols, +#endif + SecureProtocols = AnyProtocol + 2, TlsV1_0OrLater, TlsV1_1OrLater, -- cgit v1.2.3 From 7bb0d5379d74100593da4b14441a886f82c263b6 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen <ville.voutilainen@qt.io> Date: Fri, 22 Nov 2019 13:48:15 +0200 Subject: Make transferTimeout getters const Change-Id: I84c7e830ed9cf58c05ff06052c3df3beb74bb723 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/network/access/qnetworkaccessmanager.cpp | 2 +- src/network/access/qnetworkaccessmanager.h | 2 +- src/network/access/qnetworkrequest.cpp | 2 +- src/network/access/qnetworkrequest.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 6c1cb420fe..ff916ff283 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1726,7 +1726,7 @@ void QNetworkAccessManager::setAutoDeleteReplies(bool shouldAutoDelete) This timeout is zero if setTransferTimeout() hasn't been called, which means that the timeout is not used. */ -int QNetworkAccessManager::transferTimeout() +int QNetworkAccessManager::transferTimeout() const { return d_func()->transferTimeout; } diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index 6db4094a8e..aa4765a043 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -170,7 +170,7 @@ public: bool autoDeleteReplies() const; void setAutoDeleteReplies(bool autoDelete); - int transferTimeout(); + int transferTimeout() const; void setTransferTimeout(int timeout = QNetworkRequest::TransferTimeoutPreset); Q_SIGNALS: diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index e03d844af9..92e5aed38c 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -936,7 +936,7 @@ void QNetworkRequest::setHttp2Configuration(const QHttp2Configuration &configura \sa setTransferTimeout */ -int QNetworkRequest::transferTimeout() +int QNetworkRequest::transferTimeout() const { return d->transferTimeout; } diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index 5d9969bd9b..dcd2c6b61f 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -189,7 +189,7 @@ public: QHttp2Configuration http2Configuration() const; void setHttp2Configuration(const QHttp2Configuration &configuration); - int transferTimeout(); + int transferTimeout() const; void setTransferTimeout(int timeout = TransferTimeoutPreset); #endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC) private: -- cgit v1.2.3 From 5142fe2c54970040fb6967848156a5f28b5a2dc9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Sat, 16 Nov 2019 19:25:11 +0100 Subject: rhi: d3d11: Do not rely on Win10-only enum value When building against a 8.1 or older SDK the Windows 10-only value DXGI_SWAP_EFFECT_FLIP_DISCARD may not be present. Just use the value directly. At runtime that code path cannot be hit anyway when running on 8.1 or older. Task-number: QTBUG-80084 Change-Id: I0974b82db770e5487315798432ee601937b96c5e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/gui/rhi/qrhid3d11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 717f3e6d6c..5e576e9c6a 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -3922,7 +3922,7 @@ bool QD3D11SwapChain::buildOrResize() desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; desc.BufferCount = BUFFER_COUNT; desc.Scaling = DXGI_SCALING_STRETCH; - desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + desc.SwapEffect = DXGI_SWAP_EFFECT(4); // DXGI_SWAP_EFFECT_FLIP_DISCARD // Do not bother with AlphaMode, if won't work unless we go through // DirectComposition. Instead, we just take the other (DISCARD) // path for now when alpha is requested. -- cgit v1.2.3 From a131d6100ca13b00721ea30e6ef0d5225002867e Mon Sep 17 00:00:00 2001 From: Joerg Bornemann <joerg.bornemann@qt.io> Date: Fri, 22 Nov 2019 09:24:55 +0100 Subject: Fix prefix determination for windeployqt'ed applications Qt5Core.dll of windeployqt'ed applications is right next to the executable, and the prefix is considered the directory where the application is located. QLibraryInfo of a relocatable Qt5Core.dll would return a wrong prefix (by default <app dir>/..), because it determines the prefix with QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH (by default ".."). We now detect whether the executable was windeployqt'ed by checking whether Qt5Core.dll is next to the executable. However, we must not do that for applications in QT_HOST_BINS, because they are not windeployqt'ed and must still use the standard prefix. We detect this case by checking whether for Qt5Core.dll exists a corresponding Qt5Core.lib in the libdir below the detected prefix. Fixes: QTBUG-79318 Change-Id: I1c9b971b282c6b9b19a93f1819ba8aee74be5be4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/corelib/global/qlibraryinfo.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 276741c9fb..8c3ed184ae 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -562,9 +562,31 @@ static QString getRelocatablePrefix() HMODULE hModule = getWindowsModuleHandle(); const int kBufferSize = 4096; wchar_t buffer[kBufferSize]; - const int pathSize = GetModuleFileName(hModule, buffer, kBufferSize); - if (pathSize > 0) - prefixPath = prefixFromQtCoreLibraryHelper(QString::fromWCharArray(buffer, pathSize)); + DWORD pathSize = GetModuleFileName(hModule, buffer, kBufferSize); + const QString qtCoreFilePath = QString::fromWCharArray(buffer, int(pathSize)); + const QString qtCoreDirPath = QFileInfo(qtCoreFilePath).absolutePath(); + pathSize = GetModuleFileName(NULL, buffer, kBufferSize); + const QString exeDirPath = QFileInfo(QString::fromWCharArray(buffer, int(pathSize))).absolutePath(); + if (QFileInfo(exeDirPath) == QFileInfo(qtCoreDirPath)) { + // QtCore DLL is next to the executable. This is either a windeployqt'ed executable or an + // executable within the QT_HOST_BIN directory. We're detecting the latter case by checking + // whether there's an import library corresponding to our QtCore DLL in PREFIX/lib. + const QString libdir = QString::fromLatin1( + qt_configure_strs + qt_configure_str_offsets[QLibraryInfo::LibrariesPath - 1]); + const QLatin1Char slash('/'); + const QString qtCoreImpLibPath + = qtCoreDirPath + + slash + QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH) + + slash + libdir + + slash + QFileInfo(qtCoreFilePath).completeBaseName() + QLatin1String(".lib"); + if (!QFileInfo::exists(qtCoreImpLibPath)) { + // We did not find a corresponding import library and conclude that this is a + // windeployqt'ed executable. + return exeDirPath; + } + } + if (!qtCoreFilePath.isEmpty()) + prefixPath = prefixFromQtCoreLibraryHelper(qtCoreFilePath); #else #error "The chosen platform / config does not support querying for a dynamic prefix." #endif -- cgit v1.2.3 From 935681eaca1229f100e54f7447be0e23ceba684b Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik <kde@privat.broulik.de> Date: Fri, 22 Nov 2019 11:01:23 +0100 Subject: QSortFilterProxyModel: Add change signals for properties Makes it more easily consumable from QML. This patch only adds them for properties where no behavior change (i.e. no "if (m_foo == foo) return" changes) is necessary. The other ones will be done in a follow-up patch. Change-Id: If9f35cf9ac382e6f626db138a88eb14cebda1d52 Reviewed-by: David Faure <david.faure@kdab.com> --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 6 ++++++ src/corelib/itemmodels/qsortfilterproxymodel.h | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 978102035e..21303549ab 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2682,6 +2682,7 @@ void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs) d->filter_about_to_be_changed(); d->filter_data.setCaseSensitivity(cs); d->filter_changed(); + emit filterCaseSensitivityChanged(cs); } /*! @@ -2707,6 +2708,7 @@ void QSortFilterProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs) d->sort_casesensitivity = cs; d->sort(); + emit sortCaseSensitivityChanged(cs); } /*! @@ -2732,6 +2734,7 @@ void QSortFilterProxyModel::setSortLocaleAware(bool on) d->sort_localeaware = on; d->sort(); + emit sortLocaleAwareChanged(on); } /*! @@ -2856,6 +2859,7 @@ void QSortFilterProxyModel::setSortRole(int role) return; d->sort_role = role; d->sort(); + emit sortRoleChanged(role); } /*! @@ -2881,6 +2885,7 @@ void QSortFilterProxyModel::setFilterRole(int role) d->filter_about_to_be_changed(); d->filter_role = role; d->filter_changed(); + emit filterRoleChanged(role); } /*! @@ -2907,6 +2912,7 @@ void QSortFilterProxyModel::setRecursiveFilteringEnabled(bool recursive) d->filter_about_to_be_changed(); d->filter_recursive = recursive; d->filter_changed(); + emit recursiveFilteringEnabledChanged(recursive); } #if QT_DEPRECATED_SINCE(5, 11) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 303226668f..91253dd601 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -68,12 +68,12 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel #endif Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn) Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter) - Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity) - Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity) - Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware) - Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole) - Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole) - Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled) + Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity NOTIFY filterCaseSensitivityChanged) + Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity NOTIFY sortCaseSensitivityChanged) + Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware NOTIFY sortLocaleAwareChanged) + Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged) + Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole NOTIFY filterRoleChanged) + Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled NOTIFY recursiveFilteringEnabledChanged) public: explicit QSortFilterProxyModel(QObject *parent = nullptr); @@ -185,6 +185,16 @@ public: QStringList mimeTypes() const override; Qt::DropActions supportedDropActions() const override; + +Q_SIGNALS: + void dynamicSortFilterChanged(bool dynamicSortFilter); + void filterCaseSensitivityChanged(Qt::CaseSensitivity filterCaseSensitivity); + void sortCaseSensitivityChanged(Qt::CaseSensitivity sortCaseSensitivity); + void sortLocaleAwareChanged(bool sortLocaleAware); + void sortRoleChanged(int sortRole); + void filterRoleChanged(int filterRole); + void recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled); + private: Q_DECLARE_PRIVATE(QSortFilterProxyModel) Q_DISABLE_COPY(QSortFilterProxyModel) -- cgit v1.2.3 From 2c871dfd38d89d6415c2c25d47b4a0e9c8b2ef11 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 22 Nov 2019 15:34:38 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in further cases Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Where applicable, port over to member initialization, thus also fixing nullptr warnings. Change-Id: Iaaf2dbbbcf2952253390b8839fd15a1b17be32c0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/gui/kernel/qguiapplication.cpp | 2 +- src/gui/kernel/qplatformdialoghelper.cpp | 22 ++++++------------ src/gui/painting/qpainter.cpp | 11 ++------- src/gui/painting/qpainter_p.h | 20 ++++++++--------- src/gui/painting/qpainterpath.cpp | 2 +- src/gui/text/qfontengine.cpp | 2 +- src/gui/text/qtextengine.cpp | 15 +++---------- src/gui/text/qtextengine_p.h | 19 +++++++--------- src/gui/vulkan/qvulkaninstance.cpp | 1 - src/network/bearer/qnetworkconfigmanager.cpp | 2 +- src/network/kernel/qnetworkinterface.cpp | 2 +- src/network/socket/qlocalsocket_unix.cpp | 1 - src/opengl/qgl.cpp | 3 ++- .../qwindowsguieventdispatcher.cpp | 2 +- .../windows/qwindowsfontenginedirectwrite.cpp | 2 +- .../input/evdevmouse/qevdevmousehandler.cpp | 3 +-- .../input/evdevmouse/qevdevmousehandler_p.h | 8 +++---- .../input/evdevtouch/qevdevtouchhandler.cpp | 15 +++++-------- src/plugins/platforms/windows/qwindowsglcontext.h | 2 +- .../platforms/windows/qwindowskeymapper.cpp | 4 ++-- .../platforms/windows/qwindowsmousehandler.cpp | 4 ++-- .../platforms/windows/qwindowspointerhandler.cpp | 2 +- src/plugins/platforms/windows/qwindowstheme.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 ++--- src/widgets/graphicsview/qgraphicssceneevent.cpp | 17 +++++--------- src/widgets/graphicsview/qgraphicsview.cpp | 3 +-- src/widgets/kernel/qboxlayout.cpp | 2 +- src/widgets/kernel/qformlayout.cpp | 26 +++++++++------------- src/widgets/kernel/qlayoutitem.cpp | 2 +- src/widgets/styles/qstyleoption.cpp | 4 ++-- src/widgets/util/qflickgesture.cpp | 2 +- src/widgets/widgets/qdatetimeedit.cpp | 4 ++-- src/widgets/widgets/qtoolbarlayout.cpp | 4 ++-- 33 files changed, 87 insertions(+), 129 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 455de52319..ef31e475ea 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1763,7 +1763,7 @@ Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() */ Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() { - CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers(0)) + CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers{}) QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); return pi->queryKeyboardModifiers(); } diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index 4bee153489..15ac4acf91 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -186,7 +186,7 @@ QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHi class QFontDialogOptionsPrivate : public QSharedData { public: - QFontDialogOptionsPrivate() : options(0) {} + QFontDialogOptionsPrivate() = default; QFontDialogOptions::FontDialogOptions options; QString windowTitle; @@ -328,7 +328,7 @@ Q_GLOBAL_STATIC(QColorDialogStaticData, qColorDialogStaticData) class QColorDialogOptionsPrivate : public QSharedData { public: - QColorDialogOptionsPrivate() : options(0) {} + QColorDialogOptionsPrivate() = default; // Write out settings around destruction of dialogs ~QColorDialogOptionsPrivate() { qColorDialogStaticData()->writeSettings(); } @@ -465,24 +465,16 @@ void QPlatformColorDialogHelper::setOptions(const QSharedPointer<QColorDialogOpt class QFileDialogOptionsPrivate : public QSharedData { public: - QFileDialogOptionsPrivate() : options(0), - viewMode(QFileDialogOptions::Detail), - fileMode(QFileDialogOptions::AnyFile), - acceptMode(QFileDialogOptions::AcceptOpen), - filters(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs), - useDefaultNameFilters(true) - {} - QFileDialogOptions::FileDialogOptions options; QString windowTitle; - QFileDialogOptions::ViewMode viewMode; - QFileDialogOptions::FileMode fileMode; - QFileDialogOptions::AcceptMode acceptMode; + QFileDialogOptions::ViewMode viewMode = QFileDialogOptions::Detail; + QFileDialogOptions::FileMode fileMode = QFileDialogOptions::AnyFile; + QFileDialogOptions::AcceptMode acceptMode = QFileDialogOptions::AcceptOpen; QString labels[QFileDialogOptions::DialogLabelCount]; - QDir::Filters filters; + QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs; QList<QUrl> sidebarUrls; - bool useDefaultNameFilters; + bool useDefaultNameFilters = true; QStringList nameFilters; QStringList mimeTypeFilters; QString defaultSuffix; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 4336ff66be..d5cec1b45a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7786,16 +7786,9 @@ QPainterState::QPainterState(const QPainterState *s) } QPainterState::QPainterState() - : brushOrigin(0, 0), bgBrush(Qt::white), clipOperation(Qt::NoClip), - renderHints(0), - wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0), - opacity(1), WxF(false), VxF(false), clipEnabled(true), - bgMode(Qt::TransparentMode), painter(0), - layoutDirection(QGuiApplication::layoutDirection()), - composition_mode(QPainter::CompositionMode_SourceOver), - emulationSpecifier(0), changeFlags(0) + : brushOrigin(0, 0), WxF(false), VxF(false), clipEnabled(true), + layoutDirection(QGuiApplication::layoutDirection()) { - dirtyFlags = { }; } QPainterState::~QPainterState() diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 29d4880eb9..285bd90502 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -154,29 +154,29 @@ public: QFont deviceFont; QPen pen; QBrush brush; - QBrush bgBrush; // background brush + QBrush bgBrush = Qt::white; // background brush QRegion clipRegion; QPainterPath clipPath; - Qt::ClipOperation clipOperation; + Qt::ClipOperation clipOperation = Qt::NoClip; QPainter::RenderHints renderHints; QVector<QPainterClipInfo> clipInfo; // ### Make me smaller and faster to copy around... QTransform worldMatrix; // World transformation matrix, not window and viewport QTransform matrix; // Complete transformation matrix, QTransform redirectionMatrix; - int wx, wy, ww, wh; // window rectangle - int vx, vy, vw, vh; // viewport rectangle - qreal opacity; + int wx = 0, wy = 0, ww = 0, wh = 0; // window rectangle + int vx = 0, vy = 0, vw = 0, vh = 0; // viewport rectangle + qreal opacity = 1; uint WxF:1; // World transformation uint VxF:1; // View transformation uint clipEnabled:1; - Qt::BGMode bgMode; - QPainter *painter; + Qt::BGMode bgMode = Qt::TransparentMode; + QPainter *painter = nullptr; Qt::LayoutDirection layoutDirection; - QPainter::CompositionMode composition_mode; - uint emulationSpecifier; - uint changeFlags; + QPainter::CompositionMode composition_mode = QPainter::CompositionMode_SourceOver; + uint emulationSpecifier = 0; + uint changeFlags = 0; }; struct QPainterDummyState diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 1fb37ece56..859122c3b9 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString & fe->addOutlineToPath(x, y, glyphs, this, si.analysis.bidiLevel % 2 ? QTextItem::RenderFlags(QTextItem::RightToLeft) - : QTextItem::RenderFlags(0)); + : QTextItem::RenderFlags{}); const qreal lw = fe->lineThickness().toReal(); if (f.d->underline) { diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 3a1f5ed4f4..1668fac5a3 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -141,7 +141,7 @@ static void hb_getAdvances(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGl qglyphs.glyphs = const_cast<glyph_t *>(glyphs); qglyphs.advances = reinterpret_cast<QFixed *>(advances); - fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0)); + fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags{}); } static HB_Bool hb_canRender(HB_Font font, const HB_UChar16 *string, hb_uint32 length) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 40adc4a3cf..8a91b34b7a 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1896,7 +1896,7 @@ int QTextEngine::shapeTextWithHarfbuzz(const QScriptItem &si, const ushort *stri } if (kerningEnabled && !shaper_item.kerning_applied) - actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0)); + actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags{}); if (engineIdx != 0) { for (quint32 i = 0; i < shaper_item.num_glyphs; ++i) @@ -3895,12 +3895,7 @@ QStackTextEngine::QStackTextEngine(const QString &string, const QFont &f) } QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format) - : justified(false), - underlineStyle(QTextCharFormat::NoUnderline), - charFormat(format), - num_chars(0), - chars(nullptr), - logClusters(nullptr), + : charFormat(format), f(font), fontEngine(font->d->engineForScript(si.analysis.script)) { @@ -3910,13 +3905,9 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo } QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) - : flags(0), - justified(false), - underlineStyle(QTextCharFormat::NoUnderline), - charFormat(format), + : charFormat(format), num_chars(numChars), chars(chars_), - logClusters(nullptr), f(font), glyphs(g), fontEngine(fe) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 76b9757eba..f069951ce5 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -303,10 +303,7 @@ struct QScriptItem; class QTextItemInt : public QTextItem { public: - inline QTextItemInt() - : justified(false), underlineStyle(QTextCharFormat::NoUnderline), num_chars(0), chars(nullptr), - logClusters(nullptr), f(nullptr), fontEngine(nullptr) - {} + inline QTextItemInt() = default; QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat()); QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe, const QTextCharFormat &format = QTextCharFormat()); @@ -321,16 +318,16 @@ public: QFixed width; RenderFlags flags; - bool justified; - QTextCharFormat::UnderlineStyle underlineStyle; + bool justified = false; + QTextCharFormat::UnderlineStyle underlineStyle = QTextCharFormat::NoUnderline; const QTextCharFormat charFormat; - int num_chars; - const QChar *chars; - const unsigned short *logClusters; - const QFont *f; + int num_chars = 0; + const QChar *chars = nullptr; + const unsigned short *logClusters = nullptr; + const QFont *f = nullptr; QGlyphLayout glyphs; - QFontEngine *fontEngine; + QFontEngine *fontEngine = nullptr; }; struct QScriptItem diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp index daf37e3dc8..764cb917ad 100644 --- a/src/gui/vulkan/qvulkaninstance.cpp +++ b/src/gui/vulkan/qvulkaninstance.cpp @@ -251,7 +251,6 @@ public: QVulkanInstancePrivate(QVulkanInstance *q) : q_ptr(q), vkInst(VK_NULL_HANDLE), - flags(0), errorCode(VK_SUCCESS) { } ~QVulkanInstancePrivate() { reset(); } diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index cd87c3669c..c2d30d52e2 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -355,7 +355,7 @@ QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabil if (priv) return priv->capabilities(); - return QNetworkConfigurationManager::Capabilities(0); + return {}; } /*! diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index d43dba3e0c..b7a6d9adf9 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -746,7 +746,7 @@ QString QNetworkInterface::humanReadableName() const */ QNetworkInterface::InterfaceFlags QNetworkInterface::flags() const { - return d ? d->flags : InterfaceFlags(0); + return d ? d->flags : InterfaceFlags{}; } /*! diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index e7d15f4824..3a571edc3a 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -64,7 +64,6 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), delayConnect(0), connectTimer(0), connectingSocket(-1), - connectingOpenMode(0), state(QLocalSocket::UnconnectedState) { } diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2c5a40a992..618f6801de 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -83,7 +83,8 @@ QT_BEGIN_NAMESPACE class QGLDefaultExtensions { public: - QGLDefaultExtensions() : extensions(0) { + QGLDefaultExtensions() + { QGLTemporaryContext tempContext; Q_ASSERT(QOpenGLContext::currentContext()); QOpenGLExtensions *ext = qgl_extensions(); diff --git a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp index a37547f513..20cfb5155e 100644 --- a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp +++ b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE */ QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : - QEventDispatcherWin32(parent), m_flags(0) + QEventDispatcherWin32(parent) { setObjectName(QStringLiteral("QWindowsGuiEventDispatcher")); createInternalHwnd(); // QTBUG-40881: Do not delay registering timers, etc. for QtMfc. diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index e796c18e79..3415002ffc 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -458,7 +458,7 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly glyphs->numGlyphs = actualLength; if (!(flags & GlyphIndicesOnly)) - recalcAdvances(glyphs, 0); + recalcAdvances(glyphs, {}); return true; } diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 6a53ad2088..a729eeb851 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -99,8 +99,7 @@ std::unique_ptr<QEvdevMouseHandler> QEvdevMouseHandler::create(const QString &de } QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit) - : m_device(device), m_fd(fd), m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), - m_abs(abs), m_compression(compression), m_buttons(0), m_prevInvalid(true) + : m_device(device), m_fd(fd), m_abs(abs), m_compression(compression) { setObjectName(QLatin1String("Evdev Mouse Handler")); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 727f1a02f9..93314e885f 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -84,16 +84,16 @@ private: QString m_device; int m_fd; - QSocketNotifier *m_notify; - int m_x, m_y; - int m_prevx, m_prevy; + QSocketNotifier *m_notify = nullptr; + int m_x = 0, m_y = 0; + int m_prevx = 0, m_prevy = 0; bool m_abs; bool m_compression; Qt::MouseButtons m_buttons; Qt::MouseButton m_button; QEvent::Type m_eventType; int m_jitterLimitSquared; - bool m_prevInvalid; + bool m_prevInvalid = true; int m_hardwareWidth; int m_hardwareHeight; qreal m_hardwareScalerY; diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index c51db59e1f..78728ef4ce 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -113,16 +113,13 @@ public: QList<QWindowSystemInterface::TouchPoint> m_lastTouchPoints; struct Contact { - int trackingId; - int x; - int y; - int maj; - int pressure; - Qt::TouchPointState state; + int trackingId = -1; + int x = 0; + int y = 0; + int maj = -1; + int pressure = 0; + Qt::TouchPointState state = Qt::TouchPointPressed; QTouchEvent::TouchPoint::InfoFlags flags; - Contact() : trackingId(-1), - x(0), y(0), maj(-1), pressure(0), - state(Qt::TouchPointPressed), flags(0) { } }; QHash<int, Contact> m_contacts; // The key is a tracking id for type A, slot number for type B. QHash<int, Contact> m_lastContacts; diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index e5f6fefd5a..8794368fe4 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -89,7 +89,7 @@ struct QWindowsOpenGLContextFormat QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile; int version = 0; //! majorVersion<<8 + minorVersion - QSurfaceFormat::FormatOptions options = nullptr; + QSurfaceFormat::FormatOptions options; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 0509403267..e3edf7e81e 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1019,14 +1019,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, nullptr, + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, {}, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, nullptr, + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, {}, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 6df5e6aa27..b776efc942 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -165,7 +165,7 @@ void QWindowsMouseHandler::clearEvents() Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() { - Qt::MouseButtons result = nullptr; + Qt::MouseButtons result; const bool mouseSwapped = GetSystemMetrics(SM_SWAPBUTTON); if (GetAsyncKeyState(VK_LBUTTON) < 0) result |= mouseSwapped ? Qt::RightButton: Qt::LeftButton; @@ -630,7 +630,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QTouchPointList touchPoints; touchPoints.reserve(winTouchPointCount); - Qt::TouchPointStates allStates = nullptr; + Qt::TouchPointStates allStates; GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(msg.lParam), UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT)); diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index b477147da7..fba24d8696 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -482,7 +482,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd, << " message=" << Qt::hex << msg.message << " count=" << Qt::dec << count; - Qt::TouchPointStates allStates = nullptr; + Qt::TouchPointStates allStates; for (quint32 i = 0; i < count; ++i) { if (QWindowsContext::verbose > 1) diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 07120230ce..7a8c321da4 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -71,7 +71,7 @@ public: QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; - QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = {}) const override; void windowsThemeChanged(QWindow *window); void displayChanged() { refreshIconPixmapSizes(); } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 840bcfd3bb..f505ddbd1e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -876,7 +876,7 @@ enum { QXcbWindow::NetWmStates QXcbWindow::netWmStates() { - NetWmStates result(0); + NetWmStates result; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), @@ -1063,7 +1063,7 @@ void QXcbWindow::setNetWmStateOnUnmappedWindow() if (Q_UNLIKELY(m_mapped)) qCWarning(lcQpaXcb()) << "internal error: " << Q_FUNC_INFO << "called on mapped window"; - NetWmStates states(0); + NetWmStates states; const Qt::WindowFlags flags = window()->flags(); if (flags & Qt::WindowStaysOnTopHint) { states |= NetWmStateAbove; @@ -1477,7 +1477,7 @@ uint QXcbWindow::visualIdStatic(QWindow *window) QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const { - QXcbWindowFunctions::WmWindowTypes result(0); + QXcbWindowFunctions::WmWindowTypes result; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index 5077a39d67..768dd07d4e 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -344,8 +344,7 @@ class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent) public: inline QGraphicsSceneMouseEventPrivate() - : button(Qt::NoButton), - buttons(0), modifiers(0), source(Qt::MouseEventNotSynthesized), flags(0) + : button(Qt::NoButton), source(Qt::MouseEventNotSynthesized) { } QPointF pos; @@ -691,17 +690,15 @@ class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate { Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent) public: - inline QGraphicsSceneWheelEventPrivate() - : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal) - { } + inline QGraphicsSceneWheelEventPrivate() = default; QPointF pos; QPointF scenePos; QPoint screenPos; Qt::MouseButtons buttons; Qt::KeyboardModifiers modifiers; - int delta; - Qt::Orientation orientation; + int delta = 0; + Qt::Orientation orientation = Qt::Horizontal; }; /*! @@ -872,15 +869,13 @@ class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate { Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent) public: - inline QGraphicsSceneContextMenuEventPrivate() - : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other) - { } + inline QGraphicsSceneContextMenuEventPrivate() = default; QPointF pos; QPointF scenePos; QPoint screenPos; Qt::KeyboardModifiers modifiers; - QGraphicsSceneContextMenuEvent::Reason reason; + QGraphicsSceneContextMenuEvent::Reason reason = QGraphicsSceneContextMenuEvent::Other; }; /*! diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index f1ed0f3b4e..4c270b1af2 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -352,14 +352,13 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() alignment(Qt::AlignCenter), transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor), viewportUpdateMode(QGraphicsView::MinimalViewportUpdate), - optimizationFlags(0), scene(0), #if QT_CONFIG(rubberband) rubberBanding(false), rubberBandSelectionMode(Qt::IntersectsItemShape), rubberBandSelectionOperation(Qt::ReplaceSelection), #endif - handScrollMotions(0), cacheMode(0), + handScrollMotions(0), #ifndef QT_NO_CURSOR hasStoredOriginalCursor(false), #endif diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index 76d8533271..78d37f381e 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -1173,7 +1173,7 @@ void QBoxLayout::setDirection(Direction direction) if (box->magic) { QSpacerItem *sp = box->item->spacerItem(); if (sp) { - if (sp->expandingDirections() == Qt::Orientations(0) /*No Direction*/) { + if (sp->expandingDirections() == Qt::Orientations{} /*No Direction*/) { //spacing or strut QSize s = sp->sizeHint(); sp->changeSize(s.height(), s.width(), diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 1c8b997dcb..c2838083f3 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -199,18 +199,17 @@ public: ItemMatrix m_matrix; QList<QFormLayoutItem *> m_things; - int layoutWidth; // the last width that we called setupVerticalLayoutData on (for vLayouts) + int layoutWidth = -1; // the last width that we called setupVerticalLayoutData on (for vLayouts) - int hfw_width; // the last width we calculated HFW for - int hfw_height; // what that height was - int hfw_minheight; // what that minheight was + int hfw_width = -1; // the last width we calculated HFW for + int hfw_height = -1; // what that height was - int hfw_sh_height; // the hfw for sh_width - int hfw_sh_minheight; // the minhfw for sh_width + int hfw_sh_height = -1; // the hfw for sh_width + int hfw_sh_minheight = -1; // the minhfw for sh_width - int min_width; // the width that gets turned into minSize (from updateSizes) - int sh_width; // the width that gets turned into prefSize (from updateSizes) - int thresh_width; // the width that we start splitting label/field pairs at (from updateSizes) + int min_width = -1; // the width that gets turned into minSize (from updateSizes) + int sh_width = -1; // the width that gets turned into prefSize (from updateSizes) + int thresh_width = QLAYOUTSIZE_MAX; // the width that we start splitting label/field pairs at (from updateSizes) QSize minSize; QSize prefSize; int formMaxWidth; @@ -222,17 +221,15 @@ public: QVector<QLayoutStruct> hfwLayouts; - int hSpacing; - int vSpacing; + int hSpacing = -1; + int vSpacing = -1; QLayoutItem* replaceAt(int index, QLayoutItem*) override; }; QFormLayoutPrivate::QFormLayoutPrivate() : fieldGrowthPolicy(DefaultFieldGrowthPolicy), rowWrapPolicy(DefaultRowWrapPolicy), has_hfw(false), dirty(true), sizesDirty(true), - expandVertical(0), expandHorizontal(0), labelAlignment(0), formAlignment(0), - layoutWidth(-1), hfw_width(-1), hfw_sh_height(-1), min_width(-1), - sh_width(-1), thresh_width(QLAYOUTSIZE_MAX), hSpacing(-1), vSpacing(-1) + expandVertical(0), expandHorizontal(0) { } @@ -481,7 +478,6 @@ void QFormLayoutPrivate::recalcHFW(int w) } else { hfw_width = w; hfw_height = qMin(QLAYOUTSIZE_MAX, h); - hfw_minheight = qMin(QLAYOUTSIZE_MAX, mh); } } diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 0aab0bb06d..ca5a89e4dc 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -591,7 +591,7 @@ Qt::Orientations QSpacerItem::expandingDirections() const Qt::Orientations QWidgetItem::expandingDirections() const { if (isEmpty()) - return Qt::Orientations(0); + return {}; Qt::Orientations e = wid->sizePolicy().expandingDirections(); /* diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 01cadd9a86..e5e93ecc66 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -2909,7 +2909,7 @@ QStyleOptionRubberBand::QStyleOptionRubberBand(int version) */ QStyleOptionTitleBar::QStyleOptionTitleBar() - : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0), titleBarFlags(0) + : QStyleOptionComplex(Version, SO_TitleBar), titleBarState(0) { } @@ -2954,7 +2954,7 @@ QStyleOptionTitleBar::QStyleOptionTitleBar() \internal */ QStyleOptionTitleBar::QStyleOptionTitleBar(int version) - : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0), titleBarFlags(0) + : QStyleOptionComplex(version, SO_TitleBar), titleBarState(0) { } diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 14a30ce7cf..03df937938 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -610,7 +610,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, } // depending on the scroller state return the gesture state - Result result(0); + Result result; bool scrollerIsActive = (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Scrolling); diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index f7763ce27b..3be163ff75 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1416,9 +1416,9 @@ QDateTimeEdit::StepEnabled QDateTimeEdit::stepEnabled() const { Q_D(const QDateTimeEdit); if (d->readOnly) - return StepEnabled(0); + return {}; if (d->specialValue()) { - return (d->minimum == d->maximum ? StepEnabled(0) : StepEnabled(StepUpEnabled)); + return (d->minimum == d->maximum ? StepEnabled{} : StepEnabled(StepUpEnabled)); } QAbstractSpinBox::StepEnabled ret = { }; diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 961a261e8f..ec60309806 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -240,9 +240,9 @@ Qt::Orientations QToolBarLayout::expandingDirections() const updateGeomArray(); QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); if (!tb) - return Qt::Orientations(0); + return {}; Qt::Orientation o = tb->orientation(); - return expanding ? Qt::Orientations(o) : Qt::Orientations(0); + return expanding ? Qt::Orientations(o) : Qt::Orientations{}; } bool QToolBarLayout::movable() const -- cgit v1.2.3 From 96c27eb710a37780e79e09df2ebce1d5e4922c9d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 25 Jun 2019 20:47:13 +0200 Subject: QList/Table/TreeWidgetItem: Allow reseting values by passing the default value The convenience functions setBackground(), setForeground() and setSizeHint() a default constructed value as 'reset'. This means a default constructed QBrush or QSize is returned in the data() function which leads to an unexpected background or forground color or size hint. Therefore check if the passed value is a default constructed value and set an empty QVariant instead which. [ChangeLog][QtWidgets][ItemViews] The convenience views QList/Table/TreeWidgetItem now treat a default constructed QBrush or QSize as an empty QVariant which allows to reset the values set to it's default values. Task-number: QTBUG-76423 Change-Id: I840570bbad3e5fd8c5b4b58903b4fd0066dbdeb7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/itemviews/qlistwidget.cpp | 9 +++++++-- src/widgets/itemviews/qlistwidget.h | 6 +++--- src/widgets/itemviews/qtablewidget.cpp | 8 ++++++-- src/widgets/itemviews/qtablewidget.h | 6 +++--- src/widgets/itemviews/qtreewidget.cpp | 8 ++++++-- src/widgets/itemviews/qtreewidget.h | 6 +++--- 6 files changed, 28 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index e7dcfac403..1931360dbc 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -987,8 +987,9 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item) \fn void QListWidgetItem::setSizeHint(const QSize &size) \since 4.1 - Sets the size hint for the list item to be \a size. If no size hint is set, - the item delegate will compute the size hint based on the item data. + Sets the size hint for the list item to be \a size. + If no size hint is set or \a size is invalid, the item + delegate will compute the size hint based on the item data. */ /*! @@ -1119,6 +1120,8 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) \since 4.2 Sets the background brush of the list item to the given \a brush. + Setting a default-constructed brush will let the view use the + default color from the style. \sa background(), setForeground() */ @@ -1137,6 +1140,8 @@ void QListWidgetItem::setFlags(Qt::ItemFlags aflags) \since 4.2 Sets the foreground brush of the list item to the given \a brush. + Setting a default-constructed brush will let the view use the + default color from the style. \sa foreground(), setBackground() */ diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h index c102b144df..1319d658ab 100644 --- a/src/widgets/itemviews/qlistwidget.h +++ b/src/widgets/itemviews/qlistwidget.h @@ -127,7 +127,7 @@ public: inline QBrush background() const { return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); } inline void setBackground(const QBrush &brush) - { setData(Qt::BackgroundRole, brush); } + { setData(Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X ("Use QListWidgetItem::foreground() instead") @@ -141,7 +141,7 @@ public: inline QBrush foreground() const { return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); } inline void setForeground(const QBrush &brush) - { setData(Qt::ForegroundRole, brush); } + { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } inline Qt::CheckState checkState() const { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); } @@ -151,7 +151,7 @@ public: inline QSize sizeHint() const { return qvariant_cast<QSize>(data(Qt::SizeHintRole)); } inline void setSizeHint(const QSize &size) - { setData(Qt::SizeHintRole, size); } + { setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); } virtual QVariant data(int role) const; virtual void setData(int role, const QVariant &value); diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index b1dbafa997..91860341ee 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1064,8 +1064,8 @@ QTableWidgetSelectionRange::~QTableWidgetSelectionRange() \since 4.1 Sets the size hint for the table item to be \a size. - If no size hint is set, the item delegate will compute the - size hint based on the item data. + If no size hint is set or \a size is invalid, the item + delegate will compute the size hint based on the item data. */ /*! @@ -1279,6 +1279,8 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \since 4.2 Sets the item's background brush to the specified \a brush. + Setting a default-constructed brush will let the view use the + default color from the style. \sa setForeground() */ @@ -1313,6 +1315,8 @@ void QTableWidgetItem::setFlags(Qt::ItemFlags aflags) \since 4.2 Sets the item's foreground brush to the specified \a brush. + Setting a default-constructed brush will let the view use the + default color from the style. \sa setBackground() */ diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index 0d93a0a075..70e2046400 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -146,7 +146,7 @@ public: inline QBrush background() const { return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); } inline void setBackground(const QBrush &brush) - { setData(Qt::BackgroundRole, brush); } + { setData(Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X ("Use QTableWidgetItem::foreground() instead") @@ -160,7 +160,7 @@ public: inline QBrush foreground() const { return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); } inline void setForeground(const QBrush &brush) - { setData(Qt::ForegroundRole, brush); } + { setData(Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } inline Qt::CheckState checkState() const { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); } @@ -170,7 +170,7 @@ public: inline QSize sizeHint() const { return qvariant_cast<QSize>(data(Qt::SizeHintRole)); } inline void setSizeHint(const QSize &size) - { setData(Qt::SizeHintRole, size); } + { setData(Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); } virtual QVariant data(int role) const; virtual void setData(int role, const QVariant &value); diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 6d0909108b..cce0773fec 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1285,6 +1285,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const Sets the background brush of the label in the given \a column to the specified \a brush. + Setting a default-constructed brush will let the view use the + default color from the style. \note If \l{Qt Style Sheets} are used on the same widget as setBackground(), style sheets will take precedence if the settings conflict. @@ -1314,6 +1316,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const Returns the brush used to render the foreground (e.g. text) of the specified \a column. + Setting a default-constructed brush will let the view use the + default color from the style. \sa background() */ @@ -1357,8 +1361,8 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const \since 4.1 Sets the size hint for the tree item in the given \a column to be \a size. - If no size hint is set, the item delegate will compute the size hint based - on the item data. + If no size hint is set or \a size is invalid, the item + delegate will compute the size hint based on the item data. */ /*! diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h index bed77b336d..b9543fb954 100644 --- a/src/widgets/itemviews/qtreewidget.h +++ b/src/widgets/itemviews/qtreewidget.h @@ -146,7 +146,7 @@ public: inline QBrush background(int column) const { return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); } inline void setBackground(int column, const QBrush &brush) - { setData(column, Qt::BackgroundRole, brush); } + { setData(column, Qt::BackgroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X ("Use QTreeWidgetItem::foreground() instead") @@ -160,7 +160,7 @@ public: inline QBrush foreground(int column) const { return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); } inline void setForeground(int column, const QBrush &brush) - { setData(column, Qt::ForegroundRole, brush); } + { setData(column, Qt::ForegroundRole, brush.style() != Qt::NoBrush ? QVariant(brush) : QVariant()); } inline Qt::CheckState checkState(int column) const { return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt()); } @@ -170,7 +170,7 @@ public: inline QSize sizeHint(int column) const { return qvariant_cast<QSize>(data(column, Qt::SizeHintRole)); } inline void setSizeHint(int column, const QSize &size) - { setData(column, Qt::SizeHintRole, size); } + { setData(column, Qt::SizeHintRole, size.isValid() ? QVariant(size) : QVariant()); } virtual QVariant data(int column, int role) const; virtual void setData(int column, int role, const QVariant &value); -- cgit v1.2.3 From 03b1d2c44940322208c12c7bceee376b51d8e852 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sat, 30 Jun 2018 21:23:02 +0200 Subject: QColor: unify behavior when passing invalid values to setFoo() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling QColor::setFoo() is currently inconsistent - some setter do invalidate the colors, some don't. Unify it by calling invalidate in every setter. Task-number: QTBUG-62452 Change-Id: Ia4f0bd16ea30e9659bc989ffc2b319892438b84b Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/gui/painting/qcolor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 8780cce223..23afba6cce 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1086,6 +1086,7 @@ void QColor::setHsvF(qreal h, qreal s, qreal v, qreal a) || (v < qreal(0.0) || v > qreal(1.0)) || (a < qreal(0.0) || a > qreal(1.0))) { qWarning("QColor::setHsvF: HSV parameters out of range"); + invalidate(); return; } @@ -1198,7 +1199,8 @@ void QColor::setHslF(qreal h, qreal s, qreal l, qreal a) || (s < qreal(0.0) || s > qreal(1.0)) || (l < qreal(0.0) || l > qreal(1.0)) || (a < qreal(0.0) || a > qreal(1.0))) { - qWarning("QColor::setHsvF: HSV parameters out of range"); + qWarning("QColor::setHslF: HSL parameters out of range"); + invalidate(); return; } @@ -1224,7 +1226,7 @@ void QColor::setHslF(qreal h, qreal s, qreal l, qreal a) void QColor::setHsl(int h, int s, int l, int a) { if (h < -1 || (uint)s > 255 || (uint)l > 255 || (uint)a > 255) { - qWarning("QColor::setHsv: HSV parameters out of range"); + qWarning("QColor::setHsl: HSL parameters out of range"); invalidate(); return; } @@ -2719,6 +2721,7 @@ void QColor::setCmyk(int c, int m, int y, int k, int a) || k < 0 || k > 255 || a < 0 || a > 255) { qWarning("QColor::setCmyk: CMYK parameters out of range"); + invalidate(); return; } @@ -2748,6 +2751,7 @@ void QColor::setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a) || k < qreal(0.0) || k > qreal(1.0) || a < qreal(0.0) || a > qreal(1.0)) { qWarning("QColor::setCmykF: CMYK parameters out of range"); + invalidate(); return; } -- cgit v1.2.3 From 8027fb60dd1c1e4349eb1ac782d1197e784d6081 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 18 Nov 2019 13:26:13 +0100 Subject: Fix QCborValue::toCbor with non-ASCII URLs Found while fixing QTBUG-79196. Change-Id: Ia2aa807ffa8a4c798425fffd15d841657def99af Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/serialization/qcborvalue.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index 9053618014..0e3d317518 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -1391,10 +1391,10 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader) auto &e = d->elements[1]; const ByteData *b = d->byteData(e); - auto replaceByteData = [&](const char *buf, qsizetype len) { + auto replaceByteData = [&](const char *buf, qsizetype len, Element::ValueFlags f) { d->data.clear(); d->usedData = 0; - e.flags = Element::HasByteData | Element::StringIsAscii; + e.flags = Element::HasByteData | f; e.value = d->addByteData(buf, len); }; @@ -1414,7 +1414,7 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader) } if (dt.isValid()) { QByteArray text = dt.toString(Qt::ISODateWithMs).toLatin1(); - replaceByteData(text, text.size()); + replaceByteData(text, text.size(), Element::StringIsAscii); e.type = QCborValue::String; d->elements[0].value = qint64(QCborKnownTags::DateTimeString); type = QCborValue::DateTime; @@ -1430,7 +1430,7 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader) b->asQStringRaw() : b->toUtf8String()); QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8(); - replaceByteData(encoded, encoded.size()); + replaceByteData(encoded, encoded.size(), {}); } type = QCborValue::Url; } @@ -1449,7 +1449,7 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader) char buf[sizeof(QUuid)] = {}; if (b) memcpy(buf, b->byte(), qMin(sizeof(buf), size_t(b->len))); - replaceByteData(buf, sizeof(buf)); + replaceByteData(buf, sizeof(buf), {}); type = QCborValue::Uuid; } -- cgit v1.2.3 From bcbefcd6457adac9d92a410b1f7250ed5b0e8955 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 15 Oct 2019 16:37:52 -0700 Subject: QCborValue: Extend the constructor to also create extended types We already did that when parsing from CBOR binary data, so the code was already present. [ChangeLog][QtCore][QCborValue] The constructor taking a CBOR tag and a value to be tagged now attempts to convert to a QCborValue extended type. For example, if the tag is 0 (UnixTime_t) and the payload is a number, the resulting object will become tag 1 (DateTime) and the payload will be the the ISO-8601 date/time string. Fixes: QTBUG-79196 Change-Id: I6edce5101800424a8093fffd15cdf650fb2fc45c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/serialization/qcborvalue.cpp | 157 ++++++++++++++++--------------- 1 file changed, 83 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index 0e3d317518..4052bfa22e 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -758,6 +758,81 @@ QT_BEGIN_NAMESPACE using namespace QtCbor; +static QCborValue::Type convertToExtendedType(QCborContainerPrivate *d) +{ + qint64 tag = d->elements.at(0).value; + auto &e = d->elements[1]; + const ByteData *b = d->byteData(e); + + auto replaceByteData = [&](const char *buf, qsizetype len, Element::ValueFlags f) { + d->data.clear(); + d->usedData = 0; + e.flags = Element::HasByteData | f; + e.value = d->addByteData(buf, len); + }; + + switch (tag) { + case qint64(QCborKnownTags::DateTimeString): + case qint64(QCborKnownTags::UnixTime_t): { + QDateTime dt; + if (tag == qint64(QCborKnownTags::DateTimeString) && b && + e.type == QCborValue::String && (e.flags & Element::StringIsUtf16) == 0) { + // The data is supposed to be US-ASCII. If it isn't (contains UTF-8), + // QDateTime::fromString will fail anyway. + dt = QDateTime::fromString(b->asLatin1(), Qt::ISODateWithMs); + } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Integer) { + dt = QDateTime::fromSecsSinceEpoch(e.value, Qt::UTC); + } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Double) { + dt = QDateTime::fromMSecsSinceEpoch(qint64(e.fpvalue() * 1000), Qt::UTC); + } + if (dt.isValid()) { + QByteArray text = dt.toString(Qt::ISODateWithMs).toLatin1(); + replaceByteData(text, text.size(), Element::StringIsAscii); + e.type = QCborValue::String; + d->elements[0].value = qint64(QCborKnownTags::DateTimeString); + return QCborValue::DateTime; + } + break; + } + + case qint64(QCborKnownTags::Url): + if (e.type == QCborValue::String) { + if (b) { + // normalize to a short (decoded) form, so as to save space + QUrl url(e.flags & Element::StringIsUtf16 ? + b->asQStringRaw() : + b->toUtf8String()); + QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8(); + replaceByteData(encoded, encoded.size(), {}); + } + return QCborValue::Url; + } + break; + + case quint64(QCborKnownTags::RegularExpression): + if (e.type == QCborValue::String) { + // no normalization is necessary + return QCborValue::RegularExpression; + } + break; + + case qint64(QCborKnownTags::Uuid): + if (e.type == QCborValue::ByteArray) { + // force the size to 16 + char buf[sizeof(QUuid)] = {}; + if (b) + memcpy(buf, b->byte(), qMin(sizeof(buf), size_t(b->len))); + replaceByteData(buf, sizeof(buf), {}); + + return QCborValue::Uuid; + } + break; + } + + // no enriching happened + return QCborValue::Tag; +} + // in qcborstream.cpp extern void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error); @@ -1384,77 +1459,10 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader) d->decodeValueFromCbor(reader); } - QCborValue::Type type = QCborValue::Tag; + QCborValue::Type type; if (reader.lastError() == QCborError::NoError) { // post-process to create our extended types - qint64 tag = d->elements.at(0).value; - auto &e = d->elements[1]; - const ByteData *b = d->byteData(e); - - auto replaceByteData = [&](const char *buf, qsizetype len, Element::ValueFlags f) { - d->data.clear(); - d->usedData = 0; - e.flags = Element::HasByteData | f; - e.value = d->addByteData(buf, len); - }; - - switch (tag) { - case qint64(QCborKnownTags::DateTimeString): - case qint64(QCborKnownTags::UnixTime_t): { - QDateTime dt; - if (tag == qint64(QCborKnownTags::DateTimeString) && b && - e.type == QCborValue::String && (e.flags & Element::StringIsUtf16) == 0) { - // The data is supposed to be US-ASCII. If it isn't, - // QDateTime::fromString will fail anyway. - dt = QDateTime::fromString(b->asLatin1(), Qt::ISODateWithMs); - } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Integer) { - dt = QDateTime::fromSecsSinceEpoch(e.value, Qt::UTC); - } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Double) { - dt = QDateTime::fromMSecsSinceEpoch(qint64(e.fpvalue() * 1000), Qt::UTC); - } - if (dt.isValid()) { - QByteArray text = dt.toString(Qt::ISODateWithMs).toLatin1(); - replaceByteData(text, text.size(), Element::StringIsAscii); - e.type = QCborValue::String; - d->elements[0].value = qint64(QCborKnownTags::DateTimeString); - type = QCborValue::DateTime; - } - break; - } - - case qint64(QCborKnownTags::Url): - if (e.type == QCborValue::String) { - if (b) { - // normalize to a short (decoded) form, so as to save space - QUrl url(e.flags & Element::StringIsUtf16 ? - b->asQStringRaw() : - b->toUtf8String()); - QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8(); - replaceByteData(encoded, encoded.size(), {}); - } - type = QCborValue::Url; - } - break; - - case quint64(QCborKnownTags::RegularExpression): - if (e.type == QCborValue::String) { - // no normalization is necessary - type = QCborValue::RegularExpression; - } - break; - - case qint64(QCborKnownTags::Uuid): - if (e.type == QCborValue::ByteArray) { - // force the size to 16 - char buf[sizeof(QUuid)] = {}; - if (b) - memcpy(buf, b->byte(), qMin(sizeof(buf), size_t(b->len))); - replaceByteData(buf, sizeof(buf), {}); - - type = QCborValue::Uuid; - } - break; - } + type = convertToExtendedType(d); } else { // decoding error type = QCborValue::Invalid; @@ -1717,21 +1725,22 @@ QCborValue::QCborValue(const QCborMap &m) } /*! - \fn QCborValue::QCborValue(QCborTag t, const QCborValue &tv) - \fn QCborValue::QCborValue(QCborKnownTags t, const QCborValue &tv) + \fn QCborValue::QCborValue(QCborTag tag, const QCborValue &tv) + \fn QCborValue::QCborValue(QCborKnownTags tag, const QCborValue &tv) Creates a QCborValue for the extended type represented by the tag value \a - t, tagging value \a tv. The tag can later be retrieved using tag() and + tag, tagging value \a tv. The tag can later be retrieved using tag() and the tagged value using taggedValue(). \sa isTag(), tag(), taggedValue(), QCborKnownTags */ -QCborValue::QCborValue(QCborTag t, const QCborValue &tv) +QCborValue::QCborValue(QCborTag tag, const QCborValue &tv) : n(-1), container(new QCborContainerPrivate), t(Tag) { container->ref.storeRelaxed(1); - container->append(t); + container->append(tag); container->append(tv); + t = convertToExtendedType(container); } /*! -- cgit v1.2.3 From 2e7c83ea3882edd7bcc84c67c31fdc71be40e223 Mon Sep 17 00:00:00 2001 From: Jimi Huotari <chiitoo@gentoo.org> Date: Wed, 6 Nov 2019 00:54:57 +0200 Subject: Fix build with -xcb and -no-libinput Since a34e81ab [1], 'xkbcommon_support' is under 'src/platformsupport/input', and will not be defined when building with -no-libinput, and as such, 'xkbcommon_support-private' added in 'src/plugins/platforms/xcb/xcb_qpa_lib.pro' will be unknown. 1. https://code.qt.io/cgit/qt/qtbase.git/commit/?h=5.14&id=a34e81ab Change-Id: I79563b329623651b462b8fedcfb59ef5f2c2e52a Gentoo-bug: https://bugs.gentoo.org/699110 Suggested-by: Petr Zima <zima@matfyz.cz> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/platformsupport/platformsupport.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 6d4f1b93bd..877665ff06 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -11,7 +11,7 @@ SUBDIRS = \ qtConfig(freetype)|darwin|win32: \ SUBDIRS += fontdatabases -qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid) { +qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid)|qtConfig(xkbcommon) { SUBDIRS += input input.depends += devicediscovery } -- cgit v1.2.3 From 0e0793ca590439bd437310f1e80507d21be3f14d Mon Sep 17 00:00:00 2001 From: Langonda Agag <namezero@afim.info> Date: Mon, 25 Nov 2019 07:25:46 +0000 Subject: Improve QTextDocumentPrivate cursor performance The cursors in QTextDocumentPrivate are held in a QList. This becomes a serious performance problem with lots of extra selections due to a call to QTextDocumentPrivate::removeCursor() from the QTextCursor destructor. Given the following test program: QPlainTextEdit *editor = ... std::list< QTextCursor> list; for(int i = 0; i < 100000; ++i) { QTextCursor c(editor->document()); c.setPosition(std::rand()%100); list.push_front(c); } list.clear(); // <-- clear calls hangs for 3+ seconds // due to time spent in // QTextDocumentPrivate::removeCursor() // due to QList::removeAll() call Note the push_front because it exacerbates the issue because the entire list will be traversed. The change submitted changes the structure to a set, removing the issue. In theory, this limits that a cursors cannot be in the structure twice, but this neither happens nor would it make sense. Change-Id: I817dc5d1bda1d98c6725a531b32d1c711a029a34 Reviewed-by: Langonda Agag <namezero@afim.info> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> --- src/gui/text/qtextdocument_p.cpp | 2 +- src/gui/text/qtextdocument_p.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index a1b1c2e92b..2f02f62a57 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -243,7 +243,7 @@ void QTextDocumentPrivate::clear() curs->adjusted_anchor = 0; } - QList<QTextCursorPrivate *>oldCursors = cursors; + QSet<QTextCursorPrivate *> oldCursors = cursors; QT_TRY{ cursors.clear(); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index f4e7a25f22..94c67b3264 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -277,8 +277,8 @@ private: public: void documentChange(int from, int length); - inline void addCursor(QTextCursorPrivate *c) { cursors.append(c); } - inline void removeCursor(QTextCursorPrivate *c) { cursors.removeAll(c); } + inline void addCursor(QTextCursorPrivate *c) { cursors.insert(c); } + inline void removeCursor(QTextCursorPrivate *c) { cursors.remove(c); } QTextFrame *frameAt(int pos) const; QTextFrame *rootFrame() const; @@ -330,7 +330,7 @@ private: BlockMap blocks; int initialBlockCharFormatIndex; - QList<QTextCursorPrivate *> cursors; + QSet<QTextCursorPrivate *> cursors; QMap<int, QTextObject *> objects; QMap<QUrl, QVariant> resources; QMap<QUrl, QVariant> cachedResources; -- cgit v1.2.3 From 3c90ac02d1a6dc383c21d3911f0db881f9341802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Sun, 24 Nov 2019 21:40:13 +0100 Subject: macOS: Replace use of deprecated NSDragPboard enum Change-Id: I90128abe310f971a89ecb6551e31950211adda77 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qcocoadrag.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 09433194a6..95808b8a11 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -134,7 +134,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o) NSImage *nsimage = qt_mac_create_nsimage(pm); [nsimage setSize:NSSizeFromCGSize(pmDeviceIndependentSize.toCGSize())]; - QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND); + QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND); m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy")); dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest); @@ -145,7 +145,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o) CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y(); event_location.y -= flippedY; NSSize mouseOffset_unused = NSMakeSize(0.0, 0.0); - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag]; [theWindow dragImage:nsimage at:event_location -- cgit v1.2.3 From 770a1d71560f7195fed0ada523884784bc89f791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Sun, 24 Nov 2019 21:57:35 +0100 Subject: macOS: Replace use of deprecated acceptsTouchEvents API The equivalent of setting acceptsTouchEvents to YES is enabling indirect touches. Direct touches are enabled by default by AppKit, but can be explicitly disabled by clearing the NSTouchTypeMaskDirect bit. Change-Id: I5ba09d36f6ee2ce962e3ce21bab06537dd1fa5ad Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qcocoawindow.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 15329ca708..6e2d446898 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1692,9 +1692,9 @@ void QCocoaWindow::registerTouch(bool enable) { m_registerTouchCount += enable ? 1 : -1; if (enable && m_registerTouchCount == 1) - [m_view setAcceptsTouchEvents:YES]; + m_view.allowedTouchTypes |= NSTouchTypeMaskIndirect; else if (m_registerTouchCount == 0) - [m_view setAcceptsTouchEvents:NO]; + m_view.allowedTouchTypes &= ~NSTouchTypeMaskIndirect; } void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness) -- cgit v1.2.3 From b8cf3c35002affe9f1876dd3940d75171be43f64 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha <andre.rocha@qt.io> Date: Fri, 22 Nov 2019 19:44:48 +0100 Subject: Windows QPA: Disable the native Windows OSK if Qt Virtual Keyboard is in use This change detects that the Qt Virtual Keyboard is in use through the QT_IM_MODULE environment variable and disables the native Windows OSK accordingly, to avoid showing both virtual keyboards at the same time. Task-number: QTBUG-76088 Change-Id: I2715b337e6de729f0514ea1892b94b3c4f9cd984 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 7 +++++-- .../windows/uiautomation/qwindowsuiamainprovider.cpp | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 079c25f9eb..19d632dc10 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -283,8 +283,11 @@ void QWindowsInputContext::showInputPanel() // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions // the caret would actually be visible (QTBUG-74492) and the workaround for // the Surface seems unnecessary there anyway. But leave it hidden for IME. - if (QOperatingSystemVersion::current() >= - QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { + // Only trigger the native OSK if the Qt OSK is not in use. + static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); + if (imModuleEmpty + && QOperatingSystemVersion::current() + >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); } else { HideCaret(platformWindow->handle()); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index f589fd6b10..e5a9f275ae 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -390,7 +390,17 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR setVariantI4(UIA_WindowControlTypeId, pRetVal); } else { // Control type converted from role. - setVariantI4(roleToControlTypeId(accessible->role()), pRetVal); + auto controlType = roleToControlTypeId(accessible->role()); + + // The native OSK should be disbled if the Qt OSK is in use. + static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); + + // If we want to disable the native OSK auto-showing + // we have to report text fields as non-editable. + if (controlType == UIA_EditControlTypeId && !imModuleEmpty) + controlType = UIA_TextControlTypeId; + + setVariantI4(controlType, pRetVal); } break; case UIA_HelpTextPropertyId: -- cgit v1.2.3 From 108e73602d60904b204cc71e9daaee084c66ce7b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Tue, 19 Nov 2019 15:43:38 +0100 Subject: Fix Qt6 TODOs in qcolor Do trivial binary but source compatible changes. Change-Id: Ifd2c3dea1dda80a46594ad413425d7800cc74dd8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/gui/painting/qcolor.cpp | 44 -------------------------------------------- src/gui/painting/qcolor.h | 17 +---------------- 2 files changed, 1 insertion(+), 60 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 23afba6cce..c567b25468 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -854,18 +854,6 @@ QColor::QColor(Spec spec) noexcept Returns \c true if the color is valid; otherwise returns \c false. */ -/*! - Returns the name of the color in the format "#RRGGBB"; i.e. a "#" - character followed by three two-digit hexadecimal numbers. - - \sa setNamedColor() -*/ - -QString QColor::name() const -{ - return name(HexRgb); -} - /*! \since 5.2 @@ -2627,16 +2615,6 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a) return color; } -/*! - \obsolete - - Use the \c const overload instead. -*/ -void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) -{ - const_cast<const QColor *>(this)->getCmyk(c, m, y, k, a); -} - /*! Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components @@ -2666,16 +2644,6 @@ void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) const *a = ct.acmyk.alpha >> 8; } -/*! - \obsolete - - Use the \c const overload instead. -*/ -void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a) -{ - const_cast<const QColor *>(this)->getCmykF(c, m, y, k, a); -} - /*! Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components @@ -2924,18 +2892,6 @@ QColor QColor::dark(int factor) const noexcept } #endif -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -/*! - Assigns a copy of \a color to this color, and returns a reference to it. -*/ -QColor &QColor::operator=(const QColor &color) noexcept -{ - cspec = color.cspec; - ct.argb = color.ct.argb; - return *this; -} -#endif - /*! \overload Assigns a copy of \a color and returns a reference to this color. */ diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index c3111f9e3b..423a0ac50f 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -89,24 +89,11 @@ public: inline QColor(QLatin1String name); QColor(Spec spec) noexcept; -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - // ### Qt 6: remove all of these, the trivial ones are fine. - Q_DECL_CONSTEXPR QColor(const QColor &color) noexcept - : cspec(color.cspec), ct(color.ct) - {} - Q_DECL_CONSTEXPR QColor(QColor &&other) noexcept : cspec(other.cspec), ct(other.ct) {} - QColor &operator=(QColor &&other) noexcept - { cspec = other.cspec; ct = other.ct; return *this; } - QColor &operator=(const QColor &) noexcept; -#endif // Qt < 6 - QColor &operator=(Qt::GlobalColor color) noexcept; bool isValid() const noexcept; - // ### Qt 6: merge overloads - QString name() const; - QString name(NameFormat format) const; + QString name(NameFormat format = HexRgb) const; #if QT_STRINGVIEW_LEVEL < 2 void setNamedColor(const QString& name); @@ -182,11 +169,9 @@ public: qreal yellowF() const noexcept; qreal blackF() const noexcept; - void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr); // ### Qt 6: remove void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr) const; void setCmyk(int c, int m, int y, int k, int a = 255); - void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr); // ### Qt 6: remove void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr) const; void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a = 1.0); -- cgit v1.2.3 From 31e94dc96cf372db27d9a064e770180178f70156 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Sat, 23 Nov 2019 01:54:38 +0100 Subject: QGb18030Codec: fix out-of-bounds access when decoding surrogate pairs This is already the second surrogate of the pair, there's no need to + +i. Fixes: QTBUG-80268 Change-Id: Ia2aa807ffa8a4c798425fffd15d9a48ee0ca8ed7 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/codecs/qgb18030codec.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/corelib/codecs/qgb18030codec.cpp b/src/corelib/codecs/qgb18030codec.cpp index 4206eacb6f..ca15be1cea 100644 --- a/src/corelib/codecs/qgb18030codec.cpp +++ b/src/corelib/codecs/qgb18030codec.cpp @@ -107,7 +107,6 @@ QByteArray QGb18030Codec::convertFromUnicode(const QChar *uc, int len, Converter if (high >= 0) { if (uc[i].isLowSurrogate()) { // valid surrogate pair - ++i; uint u = QChar::surrogateToUcs4(high, uc[i].unicode()); len = qt_UnicodeToGb18030(u, buf); if (len >= 2) { -- cgit v1.2.3 From f0443984b84dea782ccd06dbce59808d55b15dbe Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 24 Sep 2019 16:26:56 +0200 Subject: QComboBox cleanup: use member initialization and nullptr Cleanup QComboBox private classes: - rearrange members to avoid unneeded padding - use nullptr - remove unused functions - don't print warnings about own deprecated functions Change-Id: I350d1c63602e32cf4b45549bc35cf1538dbbe8f0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/widgets/widgets/qcombobox.cpp | 48 +++++++---------------- src/widgets/widgets/qcombobox_p.h | 82 ++++++++++++++++++--------------------- 2 files changed, 52 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 03dcde0a58..19b442f477 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -91,30 +91,11 @@ QT_BEGIN_NAMESPACE QComboBoxPrivate::QComboBoxPrivate() : QWidgetPrivate(), - model(0), - lineEdit(0), - container(0), - insertPolicy(QComboBox::InsertAtBottom), - sizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow), - minimumContentsLength(0), shownOnce(false), autoCompletion(true), duplicatesEnabled(false), frame(true), - maxVisibleItems(10), - maxCount(INT_MAX), - modelColumn(0), - inserting(false), - arrowState(QStyle::State_None), - hoverControl(QStyle::SC_None), - autoCompletionCaseSensitivity(Qt::CaseInsensitive), - indexBeforeChange(-1) -#ifdef Q_OS_MAC - , m_platformMenu(0) -#endif -#if QT_CONFIG(completer) - , completer(0) -#endif + inserting(false) { } @@ -447,12 +428,8 @@ void QComboBoxPrivateContainer::paintEvent(QPaintEvent *e) QFrame::paintEvent(e); } -void QComboBoxPrivateContainer::leaveEvent(QEvent *) -{ -} - QComboBoxPrivateContainer::QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent) - : QFrame(parent, Qt::Popup), combo(parent), view(0), top(0), bottom(0), maybeIgnoreMouseButtonRelease(false) + : QFrame(parent, Qt::Popup), combo(parent) { // we need the combobox and itemview Q_ASSERT(parent); @@ -557,7 +534,7 @@ void QComboBoxPrivateContainer::updateScrollers() */ void QComboBoxPrivateContainer::viewDestroyed() { - view = 0; + view = nullptr; setItemView(new QComboBoxListView()); } @@ -591,7 +568,7 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) if (isAncestorOf(view)) delete view; - view = 0; + view = nullptr; } // setup the item view @@ -1568,7 +1545,7 @@ void QComboBox::setAutoCompletion(bool enable) d->lineEdit->setCompleter(d->completer); d->completer->setWidget(this); } else { - d->lineEdit->setCompleter(0); + d->lineEdit->setCompleter(nullptr); } } @@ -1757,7 +1734,7 @@ QSize QComboBox::iconSize() const if (d->iconSize.isValid()) return d->iconSize; - int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); + int iconWidth = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this); return QSize(iconWidth, iconWidth); } @@ -1827,7 +1804,7 @@ QString QComboBox::placeholderText() const bool QComboBox::isEditable() const { Q_D(const QComboBox); - return d->lineEdit != 0; + return d->lineEdit != nullptr; } /*! \internal @@ -1883,7 +1860,7 @@ void QComboBox::setEditable(bool editable) setAttribute(Qt::WA_InputMethodEnabled, false); d->lineEdit->hide(); d->lineEdit->deleteLater(); - d->lineEdit = 0; + d->lineEdit = nullptr; } d->updateDelegate(); @@ -1932,6 +1909,8 @@ void QComboBox::setLineEdit(QLineEdit *edit) d->lineEdit->setFocusProxy(this); d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED #if QT_CONFIG(completer) setAutoCompletion(d->autoCompletion); @@ -1948,6 +1927,7 @@ void QComboBox::setLineEdit(QLineEdit *edit) } #endif #endif +QT_WARNING_POP #endif setAttribute(Qt::WA_InputMethodEnabled); @@ -1996,7 +1976,7 @@ void QComboBox::setValidator(const QValidator *v) const QValidator *QComboBox::validator() const { Q_D(const QComboBox); - return d->lineEdit ? d->lineEdit->validator() : 0; + return d->lineEdit ? d->lineEdit->validator() : nullptr; } #endif // QT_NO_VALIDATOR @@ -2040,7 +2020,7 @@ void QComboBox::setCompleter(QCompleter *c) QCompleter *QComboBox::completer() const { Q_D(const QComboBox); - return d->lineEdit ? d->lineEdit->completer() : 0; + return d->lineEdit ? d->lineEdit->completer() : nullptr; } #endif // QT_CONFIG(completer) @@ -2927,7 +2907,7 @@ void QComboBox::hidePopup() QSignalBlocker containerBlocker(d->container); // Flash selected/triggered item (if any). if (style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)) { - QItemSelectionModel *selectionModel = view() ? view()->selectionModel() : 0; + QItemSelectionModel *selectionModel = view() ? view()->selectionModel() : nullptr; if (selectionModel && selectionModel->hasSelection()) { QEventLoop eventLoop; const QItemSelection selection = selectionModel->selection(); diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 00211d70aa..c79406eafd 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -79,7 +79,6 @@ QT_REQUIRE_CONFIG(combobox); QT_BEGIN_NAMESPACE -class QAction; class QPlatformMenu; class QComboBoxListView : public QListView @@ -131,9 +130,6 @@ private: QComboBox *combo; }; - -class QStandardItemModel; - class Q_AUTOTEST_EXPORT QComboBoxPrivateScroller : public QWidget { Q_OBJECT @@ -212,7 +208,7 @@ Q_SIGNALS: private: QAbstractSlider::SliderAction sliderAction; QBasicTimer timer; - bool fast; + bool fast = false; }; class Q_WIDGETS_EXPORT QComboBoxPrivateContainer : public QFrame @@ -246,7 +242,6 @@ protected: void showEvent(QShowEvent *e) override; void hideEvent(QHideEvent *e) override; void timerEvent(QTimerEvent *timerEvent) override; - void leaveEvent(QEvent *e) override; void resizeEvent(QResizeEvent *e) override; void paintEvent(QPaintEvent *e) override; QStyleOptionComboBox comboStyleOption() const; @@ -257,18 +252,19 @@ Q_SIGNALS: private: QComboBox *combo; - QAbstractItemView *view; - QComboBoxPrivateScroller *top; - QComboBoxPrivateScroller *bottom; - bool maybeIgnoreMouseButtonRelease; + QAbstractItemView *view = nullptr; + QComboBoxPrivateScroller *top = nullptr; + QComboBoxPrivateScroller *bottom = nullptr; QElapsedTimer popupTimer; + bool maybeIgnoreMouseButtonRelease = false; friend class QComboBox; friend class QComboBoxPrivate; }; class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate -{ Q_OBJECT +{ + Q_OBJECT public: QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {} @@ -355,8 +351,8 @@ public: void _q_complete(); void _q_itemSelected(const QModelIndex &item); bool contains(const QString &text, int role); - void emitActivated(const QModelIndex&); - void _q_emitHighlighted(const QModelIndex&); + void emitActivated(const QModelIndex &index); + void _q_emitHighlighted(const QModelIndex &index); void _q_emitCurrentIndexChanged(const QModelIndex &index); void _q_modelDestroyed(); void _q_modelReset(); @@ -366,8 +362,8 @@ public: void _q_resetButton(); void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void _q_updateIndexBeforeChange(); - void _q_rowsInserted(const QModelIndex & parent, int start, int end); - void _q_rowsRemoved(const QModelIndex & parent, int start, int end); + void _q_rowsInserted(const QModelIndex &parent, int start, int end); + void _q_rowsRemoved(const QModelIndex &parent, int start, int end); void updateArrow(QStyle::StateFlag state); bool updateHoverControl(const QPoint &pos); QRect popupGeometry(int screen = -1) const; @@ -402,40 +398,38 @@ public: }; #endif - QAbstractItemModel *model; - QLineEdit *lineEdit; - QComboBoxPrivateContainer *container; - QComboBox::InsertPolicy insertPolicy; - QComboBox::SizeAdjustPolicy sizeAdjustPolicy; - int minimumContentsLength; - QSize iconSize; - uint shownOnce : 1; - uint autoCompletion : 1; - uint duplicatesEnabled : 1; - uint frame : 1; - uint padding : 26; - int maxVisibleItems; - int maxCount; - int modelColumn; - QString placeholderText; - bool inserting; - mutable QSize minimumSizeHint; - mutable QSize sizeHint; - QStyle::StateFlag arrowState; - QStyle::SubControl hoverControl; - QRect hoverRect; - QPersistentModelIndex currentIndex; - QPersistentModelIndex root; - Qt::CaseSensitivity autoCompletionCaseSensitivity; - int indexBeforeChange; + QAbstractItemModel *model = nullptr; + QLineEdit *lineEdit = nullptr; + QComboBoxPrivateContainer *container = nullptr; #ifdef Q_OS_MAC - QPlatformMenu *m_platformMenu; + QPlatformMenu *m_platformMenu = nullptr; #endif #if QT_CONFIG(completer) QPointer<QCompleter> completer; #endif - static QPalette viewContainerPalette(QComboBox *cmb) - { return cmb->d_func()->viewContainer()->palette(); } + QPersistentModelIndex currentIndex; + QPersistentModelIndex root; + QString placeholderText; + QRect hoverRect; + QSize iconSize; + mutable QSize minimumSizeHint; + mutable QSize sizeHint; + QComboBox::InsertPolicy insertPolicy = QComboBox::InsertAtBottom; + QComboBox::SizeAdjustPolicy sizeAdjustPolicy = QComboBox::AdjustToContentsOnFirstShow; + QStyle::StateFlag arrowState = QStyle::State_None; + QStyle::SubControl hoverControl = QStyle::SC_None; + Qt::CaseSensitivity autoCompletionCaseSensitivity = Qt::CaseInsensitive; + int minimumContentsLength = 0; + int indexBeforeChange = -1; + int maxVisibleItems = 10; + int maxCount = std::numeric_limits<int>::max(); + int modelColumn = 0; + int placeholderIndex = -1; + bool shownOnce : 1; + bool autoCompletion : 1; + bool duplicatesEnabled : 1; + bool frame : 1; + bool inserting : 1; }; QT_END_NAMESPACE -- cgit v1.2.3 From ccc2133c648ca531630095f3f1016e2026d7e34e Mon Sep 17 00:00:00 2001 From: Sona Kurazyan <sona.kurazyan@qt.io> Date: Fri, 25 Oct 2019 12:05:27 +0200 Subject: Port QDomDocument to QXmlStreamReader Reimplement QDomDocument using QXmlStreamReader and switch to the new implementation starting from Qt 6. The changes in the behavior are reflected in tests: some test cases which were marked as "expected to fail" are now passing. Task-number: QTBUG-76178 Change-Id: I5ace2f13c036a9a778de922b47a1ce35957ce5f6 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/xml/dom/qdom.cpp | 77 +++++++++++++ src/xml/dom/qdom.h | 3 + src/xml/dom/qdom_p.h | 2 + src/xml/dom/qdomhelpers.cpp | 272 ++++++++++++++++++++++++++++++++++++++++++++ src/xml/dom/qdomhelpers_p.h | 42 +++++++ 5 files changed, 396 insertions(+) (limited to 'src') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index bbbdf1c6f3..81f33b0693 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -59,6 +59,7 @@ #include <qvariant.h> #include <qshareddata.h> #include <qdebug.h> +#include <qxmlstream.h> #include <stdio.h> QT_BEGIN_NAMESPACE @@ -5734,6 +5735,34 @@ bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader return true; } +bool QDomDocumentPrivate::setContent(QXmlStreamReader *reader, bool namespaceProcessing, + QString *errorMsg, int *errorLine, int *errorColumn) +{ + clear(); + impl = new QDomImplementationPrivate; + type = new QDomDocumentTypePrivate(this, this); + type->ref.deref(); + + if (!reader) { + qWarning("Failed to set content, XML reader is not initialized"); + return false; + } + + QDomParser domParser(this, reader, namespaceProcessing); + + if (!domParser.parse()) { + if (errorMsg) + *errorMsg = std::get<0>(domParser.errorInfo()); + if (errorLine) + *errorLine = std::get<1>(domParser.errorInfo()); + if (errorColumn) + *errorColumn = std::get<2>(domParser.errorInfo()); + return false; + } + + return true; +} + QDomNodePrivate* QDomDocumentPrivate::cloneNode(bool deep) { QDomNodePrivate *p = new QDomDocumentPrivate(this, deep); @@ -6153,9 +6182,16 @@ bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QSt { if (!impl) impl = new QDomDocumentPrivate(); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlInputSource source; source.setData(text); return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn); +#else + QXmlStreamReader streamReader(text); + streamReader.setNamespaceProcessing(namespaceProcessing); + return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn); +#endif } /*! @@ -6215,10 +6251,17 @@ bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing, { if (!impl) impl = new QDomDocumentPrivate(); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QBuffer buf; buf.setData(data); QXmlInputSource source(&buf); return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn); +#else + QXmlStreamReader streamReader(data); + streamReader.setNamespaceProcessing(namespaceProcessing); + return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn); +#endif } /*! @@ -6231,8 +6274,15 @@ bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString { if (!impl) impl = new QDomDocumentPrivate(); + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QXmlInputSource source(dev); return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn); +#else + QXmlStreamReader streamReader(dev); + streamReader.setNamespaceProcessing(namespaceProcessing); + return IMPL->setContent(&streamReader, namespaceProcessing, errorMsg, errorLine, errorColumn); +#endif } /*! @@ -6314,6 +6364,33 @@ bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QStri return IMPL->setContent(source, reader, nullptr, errorMsg, errorLine, errorColumn); } +/*! + \overload + \since 5.15 + + This function reads the XML document from the QXmlStreamReader \a reader + and parses it. Returns \c true if the content was successfully parsed; + otherwise returns \c false. + + If \a namespaceProcessing is \c true, the parser recognizes namespaces in the XML + file and sets the prefix name, local name and namespace URI to appropriate values. + If \a namespaceProcessing is \c false, the parser does no namespace processing when + it reads the XML file. + + If a parse error occurs, the error message is placed in \c{*}\a{errorMsg}, the line + number in \c{*}\a{errorLine} and the column number in \c{*}\a{errorColumn} (unless + the associated pointer is set to 0). + + \sa QXmlStreamReader +*/ +bool QDomDocument::setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg, + int *errorLine, int *errorColumn) +{ + if (!impl) + impl = new QDomDocumentPrivate(); + return IMPL->setContent(reader, namespaceProcessing, errorMsg, errorLine, errorColumn); +} + /*! Converts the parsed document back to its textual representation. diff --git a/src/xml/dom/qdom.h b/src/xml/dom/qdom.h index 0a7db7dcd7..1b00a14179 100644 --- a/src/xml/dom/qdom.h +++ b/src/xml/dom/qdom.h @@ -91,6 +91,7 @@ class QDomNode; class QDomEntity; class QDomNotation; class QDomCharacterData; +class QXmlStreamReader; class Q_XML_EXPORT QDomImplementation { @@ -343,6 +344,8 @@ public: bool setContent(const QString& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); bool setContent(QIODevice* dev, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); + bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg = nullptr, + int *errorLine = nullptr, int *errorColumn = nullptr); // Qt extensions QString toString(int = 1) const; diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h index 06ed0d5f0e..d197e999f1 100644 --- a/src/xml/dom/qdom_p.h +++ b/src/xml/dom/qdom_p.h @@ -465,6 +465,8 @@ public: int *errorLine, int *errorColumn); bool setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader, QString *errorMsg, int *errorLine, int *errorColumn); + bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg, + int *errorLine, int *errorColumn); // Attributes QDomDocumentTypePrivate *doctype() { return type.data(); } diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp index bda6f8ef87..9399ad3b9b 100644 --- a/src/xml/dom/qdomhelpers.cpp +++ b/src/xml/dom/qdomhelpers.cpp @@ -39,6 +39,7 @@ #include "qdomhelpers_p.h" #include "qdom_p.h" +#include "qxmlstream.h" #include "private/qxml_p.h" QT_BEGIN_NAMESPACE @@ -166,6 +167,18 @@ QDomBuilder::ErrorInfo QDomHandler::errorInfo() const * **************************************************************/ +int QDomDocumentLocator::column() const +{ + Q_ASSERT(reader); + return static_cast<int>(reader->columnNumber()); +} + +int QDomDocumentLocator::line() const +{ + Q_ASSERT(reader); + return static_cast<int>(reader->lineNumber()); +} + void QSAXDocumentLocator::setLocator(QXmlLocator *l) { locator = l; @@ -252,6 +265,44 @@ bool QDomBuilder::startElement(const QString &nsURI, const QString &qName, return true; } +inline QString stringRefToString(const QStringRef &stringRef) +{ + // Calling QStringRef::toString() on a NULL QStringRef in some cases returns + // an empty string (i.e. QString("")) instead of a NULL string (i.e. QString()). + // QDom implementation differentiates between NULL and empty strings, so + // we need this as workaround to keep the current behavior unchanged. + return stringRef.isNull() ? QString() : stringRef.toString(); +} + +bool QDomBuilder::startElement(const QString &nsURI, const QString &qName, + const QXmlStreamAttributes &atts) +{ + QDomNodePrivate *n = + nsProcessing ? doc->createElementNS(nsURI, qName) : doc->createElement(qName); + if (!n) + return false; + + n->setLocation(locator->line(), locator->column()); + + node->appendChild(n); + node = n; + + // attributes + for (const auto &attr : atts) { + auto domElement = static_cast<QDomElementPrivate *>(node); + if (nsProcessing) { + domElement->setAttributeNS(stringRefToString(attr.namespaceUri()), + stringRefToString(attr.qualifiedName()), + stringRefToString(attr.value())); + } else { + domElement->setAttribute(stringRefToString(attr.qualifiedName()), + stringRefToString(attr.value())); + } + } + + return true; +} + bool QDomBuilder::endElement() { if (!node || node == doc) @@ -368,4 +419,225 @@ bool QDomBuilder::notationDecl(const QString &name, const QString &publicId, return true; } +/************************************************************** + * + * QDomParser + * + **************************************************************/ + +QDomParser::QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing) + : reader(r), locator(r), domBuilder(d, &locator, namespaceProcessing) +{ +} + +bool QDomParser::parse() +{ + return parseProlog() && parseBody(); +} + +QDomBuilder::ErrorInfo QDomParser::errorInfo() const +{ + return domBuilder.error(); +} + +bool QDomParser::parseProlog() +{ + Q_ASSERT(reader); + + bool foundDtd = false; + + while (!reader->atEnd()) { + reader->readNext(); + + if (reader->hasError()) { + domBuilder.fatalError(reader->errorString()); + return false; + } + + switch (reader->tokenType()) { + case QXmlStreamReader::StartDocument: + if (!reader->documentVersion().isEmpty()) { + QString value(QLatin1String("version='")); + value += reader->documentVersion(); + value += QLatin1Char('\''); + if (!reader->documentEncoding().isEmpty()) { + value += QLatin1String(" encoding='"); + value += reader->documentEncoding(); + value += QLatin1Char('\''); + } + if (reader->isStandaloneDocument()) { + value += QLatin1String(" standalone='yes'"); + } else { + // TODO: Add standalone='no', if 'standalone' is specified. With the current + // QXmlStreamReader there is no way to figure out if it was specified or not. + // QXmlStreamReader needs to be modified for handling that case correctly. + } + + if (!domBuilder.processingInstruction(QLatin1String("xml"), value)) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing XML declaration")); + return false; + } + } + break; + case QXmlStreamReader::DTD: + if (foundDtd) { + domBuilder.fatalError(QDomParser::tr("Multiple DTD sections are not allowed")); + return false; + } + foundDtd = true; + + if (!domBuilder.startDTD(stringRefToString(reader->dtdName()), + stringRefToString(reader->dtdPublicId()), + stringRefToString(reader->dtdSystemId()))) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing document type declaration")); + return false; + } + if (!parseMarkupDecl()) + return false; + break; + case QXmlStreamReader::Comment: + if (!domBuilder.comment(reader->text().toString())) { + domBuilder.fatalError(QDomParser::tr("Error occurred while processing comment")); + return false; + } + break; + case QXmlStreamReader::ProcessingInstruction: + if (!domBuilder.processingInstruction(reader->processingInstructionTarget().toString(), + reader->processingInstructionData().toString())) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing a processing instruction")); + return false; + } + break; + default: + // If the token is none of the above, prolog processing is done. + return true; + } + } + + return true; +} + +bool QDomParser::parseBody() +{ + Q_ASSERT(reader); + + std::stack<QStringRef> tagStack; + while (!reader->atEnd() && !reader->hasError()) { + switch (reader->tokenType()) { + case QXmlStreamReader::StartElement: + tagStack.push(reader->qualifiedName()); + if (!domBuilder.startElement(stringRefToString(reader->namespaceUri()), + stringRefToString(reader->qualifiedName()), + reader->attributes())) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing a start element")); + return false; + } + break; + case QXmlStreamReader::EndElement: + if (tagStack.empty() || reader->qualifiedName() != tagStack.top()) { + domBuilder.fatalError( + QDomParser::tr("Unexpected end element '%1'").arg(reader->name())); + return false; + } + tagStack.pop(); + if (!domBuilder.endElement()) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing an end element")); + return false; + } + break; + case QXmlStreamReader::Characters: + if (!reader->isWhitespace()) { // Skip the content consisting of only whitespaces + if (!reader->text().toString().trimmed().isEmpty()) { + if (!domBuilder.characters(reader->text().toString(), reader->isCDATA())) { + domBuilder.fatalError(QDomParser::tr( + "Error occurred while processing the element content")); + return false; + } + } + } + break; + case QXmlStreamReader::Comment: + if (!domBuilder.comment(reader->text().toString())) { + domBuilder.fatalError(QDomParser::tr("Error occurred while processing comments")); + return false; + } + break; + case QXmlStreamReader::ProcessingInstruction: + if (!domBuilder.processingInstruction(reader->processingInstructionTarget().toString(), + reader->processingInstructionData().toString())) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing a processing instruction")); + return false; + } + break; + case QXmlStreamReader::EntityReference: + if (!domBuilder.skippedEntity(reader->name().toString())) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing an entity reference")); + return false; + } + break; + default: + domBuilder.fatalError(QDomParser::tr("Unexpected token")); + return false; + } + + reader->readNext(); + } + + if (reader->hasError()) { + domBuilder.fatalError(reader->errorString()); + reader->readNext(); + return false; + } + + if (!tagStack.empty()) { + domBuilder.fatalError(QDomParser::tr("Tag mismatch")); + return false; + } + + return true; +} + +bool QDomParser::parseMarkupDecl() +{ + Q_ASSERT(reader); + + const auto entities = reader->entityDeclarations(); + for (const auto &entityDecl : entities) { + // Entity declarations are created only for Extrenal Entities. Internal Entities + // are parsed, and QXmlStreamReader handles the parsing itself and returns the + // parsed result. So we don't need to do anything for the Internal Entities. + if (!entityDecl.publicId().isEmpty() || !entityDecl.systemId().isEmpty()) { + // External Entity + if (!domBuilder.unparsedEntityDecl(stringRefToString(entityDecl.name()), + stringRefToString(entityDecl.publicId()), + stringRefToString(entityDecl.systemId()), + stringRefToString(entityDecl.notationName()))) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing entity declaration")); + return false; + } + } + } + + const auto notations = reader->notationDeclarations(); + for (const auto ¬ationDecl : notations) { + if (!domBuilder.notationDecl(stringRefToString(notationDecl.name()), + stringRefToString(notationDecl.publicId()), + stringRefToString(notationDecl.systemId()))) { + domBuilder.fatalError( + QDomParser::tr("Error occurred while processing notation declaration")); + return false; + } + } + + return true; +} + QT_END_NAMESPACE diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h index 7647de65d2..f5efd8a42d 100644 --- a/src/xml/dom/qdomhelpers_p.h +++ b/src/xml/dom/qdomhelpers_p.h @@ -39,6 +39,7 @@ #ifndef QDOMHELPERS_P_H #define QDOMHELPERS_P_H +#include <qcoreapplication.h> #include <qglobal.h> #include <qxml.h> @@ -57,6 +58,8 @@ QT_BEGIN_NAMESPACE class QDomDocumentPrivate; class QDomNodePrivate; +class QXmlStreamReader; +class QXmlStreamAttributes; /************************************************************** * @@ -77,6 +80,19 @@ public: virtual int line() const = 0; }; +class QDomDocumentLocator : public QXmlDocumentLocator +{ +public: + QDomDocumentLocator(QXmlStreamReader *r) : reader(r) {} + ~QDomDocumentLocator() override = default; + + int column() const override; + int line() const override; + +private: + QXmlStreamReader *reader; +}; + class QSAXDocumentLocator : public QXmlDocumentLocator { public: @@ -105,6 +121,7 @@ public: bool endDocument(); bool startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts); + bool startElement(const QString &nsURI, const QString &qName, const QXmlStreamAttributes &atts); bool endElement(); bool characters(const QString &characters, bool cdata = false); bool processingInstruction(const QString &target, const QString &data); @@ -188,6 +205,31 @@ private: QDomBuilder domBuilder; }; +/************************************************************** + * + * QDomParser + * + **************************************************************/ + +class QDomParser +{ + Q_DECLARE_TR_FUNCTIONS(QDomParser) +public: + QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing); + + bool parse(); + QDomBuilder::ErrorInfo errorInfo() const; + +private: + bool parseProlog(); + bool parseBody(); + bool parseMarkupDecl(); + + QXmlStreamReader *reader; + QDomDocumentLocator locator; + QDomBuilder domBuilder; +}; + QT_END_NAMESPACE #endif // QDOMHELPERS_P_H -- cgit v1.2.3 From c54b1d273f6aee3538c1608e9fefff22e80e11fb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Mon, 25 Nov 2019 16:19:17 +0100 Subject: qtestsupport_widgets.h: Fix syncqt warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix include, removing: QtWidgets WARNING qtbase/src/widgets/kernel/qtestsupport_widgets.h includes qtwidgetsglobal.h when it should include QtWidgets/qtwidgetsglobal.h Change-Id: I3dc608cba48e9ae36b0683a94a4bf411e23f5136 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/widgets/kernel/qtestsupport_widgets.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qtestsupport_widgets.h b/src/widgets/kernel/qtestsupport_widgets.h index ca1406b0b2..2b37a9e858 100644 --- a/src/widgets/kernel/qtestsupport_widgets.h +++ b/src/widgets/kernel/qtestsupport_widgets.h @@ -40,7 +40,7 @@ #ifndef QTESTSUPPORT_WIDGETS_H #define QTESTSUPPORT_WIDGETS_H -#include "qtwidgetsglobal.h" +#include <QtWidgets/qtwidgetsglobal.h> QT_BEGIN_NAMESPACE -- cgit v1.2.3 From da0af1e21de6eda849dacf0283c78fbd36fd4f3f Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland <eirik.aavitsland@qt.io> Date: Thu, 21 Nov 2019 11:14:53 +0100 Subject: Doc: Improve explanation of QLineEdit input mask The explanation of the input mask syntax and behavior was somewhat unclear. Task-number: QTBUG-76320 Change-Id: I45dc4a883c491d3dc08125b0f7efad46f2a9a33f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/widgets/qlineedit.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index fb67936768..658315028a 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1198,12 +1198,18 @@ QMargins QLineEdit::textMargins() const Unset the mask and return to normal QLineEdit operation by passing an empty string (""). - The table below shows the characters that can be used in an input mask. - A space character, the default character for a blank, is needed for cases - where a character is \e{permitted but not required}. + The input mask is an input template string. It can contain the following elements: + \table + \row \li Mask Characters \li Defines the class of input characters that are + considered valid in this position + \row \li Meta Characters \li Various special meanings + \row \li Separators \li All other characters are regarded as immutable separators + \endtable + + The following table shows the mask and meta characters that can be used in an input mask. \table - \header \li Character \li Meaning + \header \li Mask Character \li Meaning \row \li \c A \li ASCII alphabetic character required. A-Z, a-z. \row \li \c a \li ASCII alphabetic character permitted but not required. \row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9. @@ -1219,19 +1225,28 @@ QMargins QLineEdit::textMargins() const \row \li \c h \li Hexadecimal character permitted but not required. \row \li \c B \li Binary character required. 0-1. \row \li \c b \li Binary character permitted but not required. + \header \li Meta Character \li Meaning \row \li \c > \li All following alphabetic characters are uppercased. \row \li \c < \li All following alphabetic characters are lowercased. \row \li \c ! \li Switch off case conversion. + \row \li \c {;c} \li Terminates the input mask and sets the \e{blank} character to \e{c}. \row \li \c {[ ] { }} \li Reserved. \row \li \tt{\\} \li Use \tt{\\} to escape the special characters listed above to use them as separators. \endtable - The mask consists of a string of mask characters and separators, - optionally followed by a semicolon and the character used for - blanks. The blank characters are always removed from the text - after editing. + When created or cleared, the line edit will be filled with a copy of the + input mask string where the meta characters have been removed, and the mask + characters have been replaced with the \e{blank} character (by default, a + \c space). + + When an input mask is set, the text() method returns a modified copy of the + line edit content where all the \e{blank} characters have been removed. The + unmodified content can be read using displayText(). + + The hasAcceptableInput() method returns false if the current content of the + line edit does not fulfil the requirements of the input mask. Examples: \table @@ -1240,7 +1255,7 @@ QMargins QLineEdit::textMargins() const \row \li \c HH:HH:HH:HH:HH:HH;_ \li MAC address \row \li \c 0000-00-00 \li ISO Date; blanks are \c space \row \li \c >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# \li License number; - blanks are \c - and all (alphabetic) characters are converted to + blanks are \c{#} and all (alphabetic) characters are converted to uppercase. \endtable -- cgit v1.2.3 From 719ad1db552319529bb5978fabbae1af9a06c240 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 26 Nov 2019 09:31:55 +0100 Subject: uic: Migrate from QList to QVector Replace QList by QVector in the ui4.cpp/.h files and replace occurrences in remaining code. Change-Id: I15913710b339ef1ef5f7e3c72a7a1be69a87079b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> --- src/tools/uic/cpp/cppwriteinitialization.h | 2 +- src/tools/uic/ui4.cpp | 30 +++++----- src/tools/uic/ui4.h | 90 +++++++++++++++--------------- src/tools/uic/utils.h | 2 +- 4 files changed, 62 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index ab996a2800..0a6ddbb3c8 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -85,7 +85,7 @@ namespace CPP { struct WriteInitialization : public TreeWalker { - using DomPropertyList = QList<DomProperty*>; + using DomPropertyList = QVector<DomProperty*>; using DomPropertyMap = QHash<QString, DomProperty*>; WriteInitialization(Uic *uic); diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index f52a8bd7d4..ed00e2c3fd 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -862,13 +862,13 @@ void DomActionGroup::setElementActionGroup(const QVector<DomActionGroup *> &a) m_actionGroup = a; } -void DomActionGroup::setElementProperty(const QList<DomProperty *> &a) +void DomActionGroup::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomActionGroup::setElementAttribute(const QList<DomProperty *> &a) +void DomActionGroup::setElementAttribute(const QVector<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; @@ -944,13 +944,13 @@ void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomAction::setElementProperty(const QList<DomProperty *> &a) +void DomAction::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomAction::setElementAttribute(const QList<DomProperty *> &a) +void DomAction::setElementAttribute(const QVector<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; @@ -1058,13 +1058,13 @@ void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) con writer.writeEndElement(); } -void DomButtonGroup::setElementProperty(const QList<DomProperty *> &a) +void DomButtonGroup::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomButtonGroup::setElementAttribute(const QList<DomProperty *> &a) +void DomButtonGroup::setElementAttribute(const QVector<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; @@ -1717,13 +1717,13 @@ void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomLayout::setElementProperty(const QList<DomProperty *> &a) +void DomLayout::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomLayout::setElementAttribute(const QList<DomProperty *> &a) +void DomLayout::setElementAttribute(const QVector<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; @@ -1938,7 +1938,7 @@ void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomRow::setElementProperty(const QList<DomProperty *> &a) +void DomRow::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; @@ -1983,7 +1983,7 @@ void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomColumn::setElementProperty(const QList<DomProperty *> &a) +void DomColumn::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; @@ -2059,7 +2059,7 @@ void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomItem::setElementProperty(const QList<DomProperty *> &a) +void DomItem::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; @@ -2268,13 +2268,13 @@ void DomWidget::setElementClass(const QStringList &a) m_class = a; } -void DomWidget::setElementProperty(const QList<DomProperty *> &a) +void DomWidget::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomWidget::setElementAttribute(const QList<DomProperty *> &a) +void DomWidget::setElementAttribute(const QVector<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; @@ -2386,7 +2386,7 @@ void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomSpacer::setElementProperty(const QList<DomProperty *> &a) +void DomSpacer::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; @@ -5984,7 +5984,7 @@ void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeEndElement(); } -void DomDesignerData::setElementProperty(const QList<DomProperty *> &a) +void DomDesignerData::setElementProperty(const QVector<DomProperty *> &a) { m_children |= Property; m_property = a; diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 94cdb40b6f..90b17f7027 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -472,11 +472,11 @@ public: inline QVector<DomActionGroup *> elementActionGroup() const { return m_actionGroup; } void setElementActionGroup(const QVector<DomActionGroup *> &a); - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); - inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementAttribute() const { return m_attribute; } + void setElementAttribute(const QVector<DomProperty *> &a); private: // attribute data @@ -487,8 +487,8 @@ private: uint m_children = 0; QVector<DomAction *> m_action; QVector<DomActionGroup *> m_actionGroup; - QList<DomProperty*> m_property; - QList<DomProperty*> m_attribute; + QVector<DomProperty *> m_property; + QVector<DomProperty *> m_attribute; enum Child { Action = 1, @@ -519,11 +519,11 @@ public: inline void clearAttributeMenu() { m_has_attr_menu = false; } // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); - inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementAttribute() const { return m_attribute; } + void setElementAttribute(const QVector<DomProperty *> &a); private: // attribute data @@ -535,8 +535,8 @@ private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; - QList<DomProperty*> m_attribute; + QVector<DomProperty *> m_property; + QVector<DomProperty *> m_attribute; enum Child { Property = 1, @@ -581,11 +581,11 @@ public: inline void clearAttributeName() { m_has_attr_name = false; } // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); - inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementAttribute() const { return m_attribute; } + void setElementAttribute(const QVector<DomProperty *> &a); private: // attribute data @@ -594,8 +594,8 @@ private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; - QList<DomProperty*> m_attribute; + QVector<DomProperty *> m_property; + QVector<DomProperty *> m_attribute; enum Child { Property = 1, @@ -891,11 +891,11 @@ public: inline void clearAttributeColumnMinimumWidth() { m_has_attr_columnMinimumWidth = false; } // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); - inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementAttribute() const { return m_attribute; } + void setElementAttribute(const QVector<DomProperty *> &a); inline QVector<DomLayoutItem *> elementItem() const { return m_item; } void setElementItem(const QVector<DomLayoutItem *> &a); @@ -925,8 +925,8 @@ private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; - QList<DomProperty*> m_attribute; + QVector<DomProperty *> m_property; + QVector<DomProperty *> m_attribute; QVector<DomLayoutItem *> m_item; enum Child { @@ -1023,14 +1023,14 @@ public: void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; + QVector<DomProperty *> m_property; enum Child { Property = 1 @@ -1047,14 +1047,14 @@ public: void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; + QVector<DomProperty *> m_property; enum Child { Property = 1 @@ -1082,8 +1082,8 @@ public: inline void clearAttributeColumn() { m_has_attr_column = false; } // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); inline QVector<DomItem *> elementItem() const { return m_item; } void setElementItem(const QVector<DomItem *> &a); @@ -1098,7 +1098,7 @@ private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; + QVector<DomProperty *> m_property; QVector<DomItem *> m_item; enum Child { @@ -1136,11 +1136,11 @@ public: inline QStringList elementClass() const { return m_class; } void setElementClass(const QStringList &a); - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); - inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementAttribute() const { return m_attribute; } + void setElementAttribute(const QVector<DomProperty *> &a); inline QVector<DomRow *> elementRow() const { return m_row; } void setElementRow(const QVector<DomRow *> &a); @@ -1183,8 +1183,8 @@ private: // child element data uint m_children = 0; QStringList m_class; - QList<DomProperty*> m_property; - QList<DomProperty*> m_attribute; + QVector<DomProperty *> m_property; + QVector<DomProperty *> m_attribute; QVector<DomRow *> m_row; QVector<DomColumn *> m_column; QVector<DomItem *> m_item; @@ -1227,8 +1227,8 @@ public: inline void clearAttributeName() { m_has_attr_name = false; } // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); private: // attribute data @@ -1237,7 +1237,7 @@ private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; + QVector<DomProperty *> m_property; enum Child { Property = 1 @@ -2805,14 +2805,14 @@ public: void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty *> &a); + inline QVector<DomProperty *> elementProperty() const { return m_property; } + void setElementProperty(const QVector<DomProperty *> &a); private: // child element data uint m_children = 0; - QList<DomProperty*> m_property; + QVector<DomProperty *> m_property; enum Child { Property = 1 diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h index 34c4ab23d4..bd543c7bb7 100644 --- a/src/tools/uic/utils.h +++ b/src/tools/uic/utils.h @@ -42,7 +42,7 @@ inline bool toBool(const QString &str) inline QString toString(const DomString *str) { return str ? str->text() : QString(); } -inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) +inline QHash<QString, DomProperty *> propertyMap(const QVector<DomProperty *> &properties) { QHash<QString, DomProperty *> map; for (DomProperty *p : properties) -- cgit v1.2.3 From 1825426187ba7fa5d53b1ad7c4eea1a1ad5f4b2c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Mon, 25 Nov 2019 16:00:06 +0100 Subject: QtWidgets: Fix warnings about providing function for DESIGNABLE in property declaration Set them to be designable by default, fixing: kernel/qaction.h:66: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. kernel/qwidget.h:178: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. kernel/qwidget.h:179: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. kernel/qwidget.h:180: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. kernel/qwidget.h:181: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. kernel/qwidget.h:182: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. kernel/qwidget.h:204: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. widgets/qabstractbutton.h:67: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. widgets/qgroupbox.h:60: Warning: Providing a function for DESIGNABLE in a property declaration is deprecated and will not be supported in Qt 6 anymore. The toolbar properties were not caught by the warnings, but it appears the checks do not work; the properties are designable when parented on a non-QMainWindow parent. Change-Id: Ib7dfb878ba593f2dfa05b85db2c384bf3d860e46 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/kernel/qaction.h | 2 +- src/widgets/kernel/qwidget.h | 12 ++++++------ src/widgets/widgets/qabstractbutton.h | 2 +- src/widgets/widgets/qgroupbox.h | 2 +- src/widgets/widgets/qtoolbar.h | 12 +++--------- 5 files changed, 12 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index f7693f4dde..258a1ea0a0 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -63,7 +63,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject Q_DECLARE_PRIVATE(QAction) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed) - Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled) + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY changed) Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed) Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed) diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 83a6e6d4b3..415a738eb4 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -175,11 +175,11 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice Q_PROPERTY(QSize sizeHint READ sizeHint) Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint) Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops) - Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow) - Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow) - Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated - Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow) - Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow) + Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged) + Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged) + Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged) // deprecated + Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity) + Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified) #ifndef QT_NO_TOOLTIP Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip) Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration) @@ -201,7 +201,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) #endif Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale) - Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow) + Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath) Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints) public: diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index e8dee142f2..50c94654f3 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QAbstractButton : public QWidget Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) #endif Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable) - Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true) + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled USER true) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat) Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive) Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay) diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h index deaeba4656..bd8394b43b 100644 --- a/src/widgets/widgets/qgroupbox.h +++ b/src/widgets/widgets/qgroupbox.h @@ -57,7 +57,7 @@ class Q_WIDGETS_EXPORT QGroupBox : public QWidget Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) Q_PROPERTY(bool flat READ isFlat WRITE setFlat) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable) - Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true) + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled USER true) public: explicit QGroupBox(QWidget *parent = nullptr); explicit QGroupBox(const QString &title, QWidget *parent = nullptr); diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 0c434e8d1d..6aaf59cafd 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -59,15 +59,9 @@ class Q_WIDGETS_EXPORT QToolBar : public QWidget { Q_OBJECT - Q_PROPERTY(bool movable READ isMovable WRITE setMovable - DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0) - NOTIFY movableChanged) - Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas - DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0) - NOTIFY allowedAreasChanged) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation - DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) == 0) - NOTIFY orientationChanged) + Q_PROPERTY(bool movable READ isMovable WRITE setMovable NOTIFY movableChanged) + Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas NOTIFY allowedAreasChanged) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged) Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle NOTIFY toolButtonStyleChanged) -- cgit v1.2.3 From 2260d680c935eae0e989beb2040a01040f66a5fa Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 24 Nov 2019 20:57:19 +0100 Subject: Deprecate qMove(), Q_DECL_OVERRIDE and Q_DECL_FINAL This function and the two macros are natively supported by all compilers needed since Qt 5.7 as explained in 4c704fad089ddd92e9d274faa5a840dd96349ca1 Change-Id: Iac01d2481ef4a6ee333e3ee5f09082a9fba725e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qglobal.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index d95cc786ab..f46313d9d5 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -4810,9 +4810,11 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) /*! \macro qMove(x) \relates <QtGlobal> + \obsolete - It expands to "std::move" if your compiler supports that C++11 function, or to nothing - otherwise. + Use \c std::move instead. + + It expands to "std::move". qMove takes an rvalue reference to its parameter \a x, and converts it to an xvalue. */ @@ -4913,6 +4915,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) /*! \macro Q_DECL_OVERRIDE \since 5.0 + \obsolete \relates <QtGlobal> This macro can be used to declare an overriding virtual @@ -4920,8 +4923,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) an error if the overriding virtual function does not in fact override anything. - It expands to "override" if your compiler supports that C++11 - contextual keyword, or to nothing otherwise. + It expands to "override". The macro goes at the end of the function, usually after the \c{const}, if any: @@ -4933,6 +4935,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) /*! \macro Q_DECL_FINAL \since 5.0 + \obsolete \relates <QtGlobal> This macro can be used to declare an overriding virtual or a class @@ -4940,10 +4943,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) no longer override this virtual function, or inherit from this class, respectively. - It expands to "final" if your compiler supports that C++11 - contextual keyword, or something non-standard if your compiler - supports something close enough to the C++11 semantics, or to - nothing otherwise. + It expands to "final". The macro goes at the end of the function, usually after the \c{const}, if any: -- cgit v1.2.3 From e1d173d3cac8d100e23ecfe2dd0556d3ff5ed1af Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 26 Nov 2019 14:35:14 +0100 Subject: Fix qdoc include paths for QStandardPaths Amends c30ffe1d33e6f48fa94e2003d7c9b17f4c83a6e9. Fix src/corelib/io/qstandardpaths.cpp:361: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' src/corelib/io/qstandardpaths.cpp:368: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' src/corelib/io/qstandardpaths.cpp:392: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' src/corelib/io/qstandardpaths.cpp:406: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' src/corelib/io/qstandardpaths.cpp:479: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' src/corelib/io/qstandardpaths.cpp:537: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' src/corelib/io/qstandardpaths.cpp:594: (qdoc) warning: Cannot find qdoc include file 'standardpath/functiondoc.qdocinc' Task-number: QTBUG-79827 Change-Id: I8eb0ae7bc167151979c729964d2dc3f171e10568 Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/io/qstandardpaths.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 6ebef3ee20..02adda3d6c 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -357,14 +357,14 @@ QT_BEGIN_NAMESPACE /*! \fn QString QStandardPaths::writableLocation(StandardLocation type) - \include standardpath/functiondoc.qdocinc writableLocation + \include standardpath/functiondocs.qdocinc writableLocation */ /*! \fn QStringList QStandardPaths::standardLocations(StandardLocation type) - \include standardpath/functiondoc.qdocinc standardLocations + \include standardpath/functiondocs.qdocinc standardLocations \sa writableLocation() */ @@ -388,7 +388,7 @@ static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions } /*! - \include standardpath/functiondoc.qdocinc locate + \include standardpath/functiondocs.qdocinc locate */ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options) { @@ -402,7 +402,7 @@ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, L } /*! - \include standardpath/functiondoc.qdocinc locateAll + \include standardpath/functiondocs.qdocinc locateAll */ QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options) { @@ -475,7 +475,7 @@ static inline QString #endif // Q_OS_WIN /*! - \include standardpath/functiondoc.qdocinc findExecutable + \include standardpath/functiondocs.qdocinc findExecutable */ QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths) { @@ -533,7 +533,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr } /*! - \include standardpath/functiondoc.qdocinc displayName + \include standardpath/functiondocs.qdocinc displayName */ #if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED) @@ -590,7 +590,7 @@ QString QStandardPaths::displayName(StandardLocation type) /*! \fn void QStandardPaths::setTestModeEnabled(bool testMode) - \include standardpath/functiondoc.qdocinc setTestModeEnabled + \include standardpath/functiondocs.qdocinc setTestModeEnabled */ static bool qsp_testMode = false; -- cgit v1.2.3 From cd3585ab159c3d0614f418fd148b7cea77ea6d12 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 24 Nov 2019 12:40:17 +0100 Subject: QDial: use correct button color When the pixmap for the QDial was cached, the button color for the knob was not properly set Fixes: QTBUG-19855 Change-Id: Ib09ac12f0b11c47a0d05f01759fc6eeadbeab06c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/styles/qstylehelper.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 4e61b2d1ec..9477ca86da 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -274,6 +274,12 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter) painter->drawLines(QStyleHelper::calcLines(option)); } + // setting color before BEGIN_STYLE_PIXMAPCACHE since + // otherwise it is not set when the image is in the cache + buttonColor.setHsv(buttonColor .hue(), + qMin(140, buttonColor .saturation()), + qMax(180, buttonColor.value())); + // Cache dial background BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial")); p->setRenderHint(QPainter::Antialiasing); @@ -285,9 +291,6 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter) QRectF br = QRectF(dx + 0.5, dy + 0.5, int(r * 2 - 2 * d_ - 2), int(r * 2 - 2 * d_ - 2)); - buttonColor.setHsv(buttonColor .hue(), - qMin(140, buttonColor .saturation()), - qMax(180, buttonColor.value())); if (enabled) { // Drop shadow -- cgit v1.2.3 From d5608ca43756ed62678e60215da71827dd26a900 Mon Sep 17 00:00:00 2001 From: Ben Boeckel <ben.boeckel@kitware.com> Date: Wed, 24 May 2017 09:21:09 -0400 Subject: Qt5CoreMacros: properly check the CMake version The POSITION_INDEPENDENT_CODE property was introduced in 2.8.12, so use it in versions newer than 2.8.12. Fixes: QTBUG-79671 Change-Id: If7f023e80964f2e47edc35eee617b51aeecbf032 Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/corelib/Qt5CoreMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 17cc19fc4e..84c75401b1 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -385,7 +385,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) if (Qt5_POSITION_INDEPENDENT_CODE - AND (CMAKE_VERSION VERSION_LESS 2.8.12 + AND (CMAKE_VERSION VERSION_GREATER_EQUAL 2.8.12 AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))) set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) -- cgit v1.2.3 From 8a60244da8f34aaa4ba0f71ada5b87aee33e0715 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud <fredrik.orderud@ge.com> Date: Sun, 24 Nov 2019 21:45:46 +0100 Subject: Fix renderbufferStorageMultisample: invalid internalformat Chrome 78 is outputting "INVALID_ENUM: renderbufferStorageMultisample: invalid internalformat" when running a Qt application after building it for WebAssembly (WASM) against the Qt 5.13 branch using the Emscripten 1.39.3 (upstream) compiler. The problem appear to be caused by glRenderbufferStorageMultisample not supporting GL_DEPTH_STENCIL directly. Instead, GL_DEPTH24_STENCIL8 or GL_DEPTH32F_STENCIL8 should be passed. Keeping the glRenderbufferStorage call as-is. Change-Id: I777dbc26b1d989950525a434a25ed344389f5059 Reference: https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glRenderbufferStorageMultisample.xhtml Fixes: QTBUG-80286 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/opengl/qopenglframebufferobject.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 5d30891565..bb0dbdc9bd 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -658,13 +658,11 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); - GLenum storageFormat = GL_DEPTH_STENCIL; - if (samples != 0 ) { funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - storageFormat, dsSize.width(), dsSize.height()); + GL_DEPTH24_STENCIL8, dsSize.width(), dsSize.height()); } else { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, storageFormat, + funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, dsSize.width(), dsSize.height()); } -- cgit v1.2.3 From ce7447d88ce5f410ae01b0f5697a86b3ba7c47f2 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sat, 21 Sep 2019 15:25:11 +0200 Subject: QLayoutItem: make QLayoutItem::widget() const in Qt6 QLayoutItem::widget() should be const since it does not modify the class. Since this can not be done within Qt5 in a binary compatible way, change it for Qt6. Fixes: QTBUG-41997 Change-Id: I9211eb1c36a5bc4f06ab417a9df790ebedb7fcda Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/kernel/qlayoutengine.cpp | 11 +++++++++-- src/widgets/kernel/qlayoutitem.cpp | 14 ++++++++++---- src/widgets/kernel/qlayoutitem.h | 8 ++++++++ src/widgets/widgets/qdockwidget_p.h | 4 ++++ 4 files changed, 31 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp index 19a47075a6..92b362e89d 100644 --- a/src/widgets/kernel/qlayoutengine.cpp +++ b/src/widgets/kernel/qlayoutengine.cpp @@ -376,7 +376,11 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSize Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWidget *w = const_cast<QWidgetItem *>(i)->widget(); +#else + QWidget *w = i->widget(); +#endif return qSmartMinSize(w->sizeHint(), w->minimumSizeHint(), w->minimumSize(), w->maximumSize(), w->sizePolicy()); @@ -414,8 +418,11 @@ Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align) { - QWidget *w = const_cast<QWidgetItem*>(i)->widget(); - +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + QWidget *w = const_cast<QWidgetItem *>(i)->widget(); +#else + QWidget *w = i->widget(); +#endif return qSmartMaxSize(w->sizeHint().expandedTo(w->minimumSizeHint()), w->minimumSize(), w->maximumSize(), w->sizePolicy(), align); } diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index ca5a89e4dc..fc02afb014 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -291,14 +291,12 @@ void QSpacerItem::changeSize(int w, int h, QSizePolicy::Policy hPolicy, /*! Destructor. */ -QWidgetItem::~QWidgetItem() {} +QWidgetItem::~QWidgetItem() = default; /*! Destroys the QLayoutItem. */ -QLayoutItem::~QLayoutItem() -{ -} +QLayoutItem::~QLayoutItem() = default; /*! Invalidates any cached information in this layout item. @@ -362,7 +360,11 @@ QSpacerItem * QSpacerItem::spacerItem() \sa layout(), spacerItem() */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWidget *QLayoutItem::widget() +#else +QWidget *QLayoutItem::widget() const +#endif { return nullptr; } @@ -370,7 +372,11 @@ QWidget *QLayoutItem::widget() /*! Returns the widget managed by this item. */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWidget *QWidgetItem::widget() +#else +QWidget *QWidgetItem::widget() const +#endif { return wid; } diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h index 059ff2d470..8553e20adc 100644 --- a/src/widgets/kernel/qlayoutitem.h +++ b/src/widgets/kernel/qlayoutitem.h @@ -74,7 +74,11 @@ public: virtual int minimumHeightForWidth(int) const; virtual void invalidate(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) virtual QWidget *widget(); +#else + virtual QWidget *widget() const; +#endif virtual QLayout *layout(); virtual QSpacerItem *spacerItem(); @@ -133,7 +137,11 @@ public: bool isEmpty() const override; void setGeometry(const QRect&) override; QRect geometry() const override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWidget *widget() override; +#else + QWidget *widget() const override; +#endif bool hasHeightForWidth() const override; int heightForWidth(int) const override; diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index bc6ac86c45..e663ec4c2d 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -201,7 +201,11 @@ inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWidget *w = const_cast<QDockWidgetItem*>(this)->widget(); +#else + QWidget *w = widget(); +#endif if (w != nullptr) return qobject_cast<QDockWidgetLayout*>(w->layout()); return nullptr; -- cgit v1.2.3 From f3c37c839c5350c9d9c14074ea1cccd881281850 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Tue, 12 Nov 2019 17:13:58 +0100 Subject: Enable QRhi Metal backend on iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While we are at it, remove the Border and MirrorOnce wrap modes that have not been supported on OpenGL, because they are unsupported with Metal+iOS as well. Task-number: QTBUG-78580 Change-Id: I0db94b9d3a6125b3bb5d7b1db5d02a42cd94d2c2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/rhi/qrhi.cpp | 8 ++--- src/gui/rhi/qrhi_p.h | 2 -- src/gui/rhi/qrhid3d11.cpp | 4 --- src/gui/rhi/qrhigles2.cpp | 5 --- src/gui/rhi/qrhimetal.mm | 64 +++++++++++++++++++++++++++------ src/gui/rhi/qrhivulkan.cpp | 4 --- src/gui/rhi/rhi.pri | 6 ++-- src/plugins/platforms/ios/qioswindow.mm | 11 +++++- src/plugins/platforms/ios/quiview.h | 4 +++ src/plugins/platforms/ios/quiview.mm | 35 ++++++++++++++---- 10 files changed, 101 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 8ef98d2e42..ac5836fc68 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -48,8 +48,7 @@ #ifdef Q_OS_WIN #include "qrhid3d11_p_p.h" #endif -//#ifdef Q_OS_DARWIN -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) #include "qrhimetal_p_p.h" #endif @@ -2253,9 +2252,7 @@ bool QRhiTexture::buildFrom(const QRhiNativeHandles *src) \value Repeat \value ClampToEdge - \value Border \value Mirror - \value MirrorOnce */ /*! @@ -4049,8 +4046,7 @@ QRhi *QRhi::create(Implementation impl, QRhiInitParams *params, Flags flags, QRh break; #endif case Metal: -//#ifdef Q_OS_DARWIN -#ifdef Q_OS_MACOS +#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) r->d = new QRhiMetal(static_cast<QRhiMetalInitParams *>(params), static_cast<QRhiMetalNativeHandles *>(importDevice)); break; diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 907924c788..8cc4c7a06c 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -812,9 +812,7 @@ public: enum AddressMode { Repeat, ClampToEdge, - Border, Mirror, - MirrorOnce }; enum CompareOp { diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 5e576e9c6a..7e05aefe8d 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2862,12 +2862,8 @@ static inline D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode(QRhiSampler::AddressMo return D3D11_TEXTURE_ADDRESS_WRAP; case QRhiSampler::ClampToEdge: return D3D11_TEXTURE_ADDRESS_CLAMP; - case QRhiSampler::Border: - return D3D11_TEXTURE_ADDRESS_BORDER; case QRhiSampler::Mirror: return D3D11_TEXTURE_ADDRESS_MIRROR; - case QRhiSampler::MirrorOnce: - return D3D11_TEXTURE_ADDRESS_MIRROR_ONCE; default: Q_UNREACHABLE(); return D3D11_TEXTURE_ADDRESS_CLAMP; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index abee843a74..ab61050e3e 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -1785,11 +1785,6 @@ static inline GLenum toGlWrapMode(QRhiSampler::AddressMode m) return GL_CLAMP_TO_EDGE; case QRhiSampler::Mirror: return GL_MIRRORED_REPEAT; - case QRhiSampler::MirrorOnce: - Q_FALLTHROUGH(); - case QRhiSampler::Border: - qWarning("Unsupported wrap mode %d", m); - return GL_CLAMP_TO_EDGE; default: Q_UNREACHABLE(); return GL_CLAMP_TO_EDGE; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 131b2da802..06e81465a2 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -41,6 +41,8 @@ #ifdef Q_OS_MACOS #include <AppKit/AppKit.h> +#else +#include <UIKit/UIKit.h> #endif #include <Metal/Metal.h> @@ -318,7 +320,13 @@ struct QMetalComputePipelineData struct QMetalSwapChainData { + // The iOS simulator's headers mark CAMetalLayer as iOS 13.0+ only. + // (for real device SDKs it is 8.0+) +#ifdef TARGET_IPHONE_SIMULATOR + API_AVAILABLE(ios(13.0)) CAMetalLayer *layer = nullptr; +#else CAMetalLayer *layer = nullptr; +#endif id<CAMetalDrawable> curDrawable; dispatch_semaphore_t sem[QMTL_FRAMES_IN_FLIGHT]; MTLRenderPassDescriptor *rp = nullptr; @@ -1763,8 +1771,10 @@ void QRhiMetal::executeBufferHostWritesForCurrentFrame(QMetalBuffer *bufD) if (changeEnd == -1 || u.offset + u.data.size() > changeEnd) changeEnd = u.offset + u.data.size(); } +#ifdef Q_OS_MACOS if (changeBegin >= 0 && bufD->d->managed) [bufD->d->buf[idx] didModifyRange: NSMakeRange(NSUInteger(changeBegin), NSUInteger(changeEnd - changeBegin))]; +#endif bufD->d->pendingUpdates[idx].clear(); } @@ -1798,8 +1808,12 @@ void QRhiMetal::beginPass(QRhiCommandBuffer *cb, if (color0.needsDrawableForTex || color0.needsDrawableForResolveTex) { Q_ASSERT(currentSwapChain); QMetalSwapChain *swapChainD = QRHI_RES(QMetalSwapChain, currentSwapChain); - if (!swapChainD->d->curDrawable) - swapChainD->d->curDrawable = [swapChainD->d->layer nextDrawable]; + if (!swapChainD->d->curDrawable) { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) +#endif + swapChainD->d->curDrawable = [swapChainD->d->layer nextDrawable]; + } if (!swapChainD->d->curDrawable) { qWarning("No drawable"); return; @@ -2170,12 +2184,13 @@ bool QMetalRenderBuffer::build() case DepthStencil: #ifdef Q_OS_MACOS desc.storageMode = MTLStorageModePrivate; + d->format = rhiD->d->dev.depth24Stencil8PixelFormatSupported + ? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8; #else - desc.storageMode = MTLResourceStorageModeMemoryless; + desc.storageMode = MTLStorageModeMemoryless; transientBacking = true; + d->format = MTLPixelFormatDepth32Float_Stencil8; #endif - d->format = rhiD->d->dev.depth24Stencil8PixelFormatSupported - ? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8; desc.pixelFormat = d->format; break; case Color: @@ -2569,12 +2584,8 @@ static inline MTLSamplerAddressMode toMetalAddressMode(QRhiSampler::AddressMode return MTLSamplerAddressModeRepeat; case QRhiSampler::ClampToEdge: return MTLSamplerAddressModeClampToEdge; - case QRhiSampler::Border: - return MTLSamplerAddressModeClampToBorderColor; case QRhiSampler::Mirror: return MTLSamplerAddressModeMirrorRepeat; - case QRhiSampler::MirrorOnce: - return MTLSamplerAddressModeMirrorClampToEdge; default: Q_UNREACHABLE(); return MTLSamplerAddressModeClampToEdge; @@ -3311,7 +3322,11 @@ bool QMetalGraphicsPipeline::build() // validation blows up otherwise. MTLPixelFormat fmt = MTLPixelFormat(rpD->dsFormat); rpDesc.depthAttachmentPixelFormat = fmt; +#ifdef Q_OS_MACOS if (fmt != MTLPixelFormatDepth16Unorm && fmt != MTLPixelFormatDepth32Float) +#else + if (fmt != MTLPixelFormatDepth32Float) +#endif rpDesc.stencilAttachmentPixelFormat = fmt; } @@ -3528,6 +3543,10 @@ QMetalSwapChain::~QMetalSwapChain() void QMetalSwapChain::release() { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) { +#endif + if (!d->layer) return; @@ -3556,6 +3575,10 @@ void QMetalSwapChain::release() QRHI_PROF_F(releaseSwapChain(this)); rhiD->unregisterResource(this); + +#ifdef TARGET_IPHONE_SIMULATOR + } +#endif } QRhiCommandBuffer *QMetalSwapChain::currentFrameCommandBuffer() @@ -3578,16 +3601,20 @@ QRhiRenderPassDescriptor *QMetalSwapChain::newCompatibleRenderPassDescriptor() { chooseFormats(); // ensure colorFormat and similar are filled out - QRHI_RES_RHI(QRhiMetal); QMetalRenderPassDescriptor *rpD = new QMetalRenderPassDescriptor(m_rhi); rpD->colorAttachmentCount = 1; rpD->hasDepthStencil = m_depthStencil != nullptr; rpD->colorFormat[0] = int(d->colorFormat); +#ifdef Q_OS_MACOS // m_depthStencil may not be built yet so cannot rely on computed fields in it + QRHI_RES_RHI(QRhiMetal); rpD->dsFormat = rhiD->d->dev.depth24Stencil8PixelFormatSupported ? MTLPixelFormatDepth24Unorm_Stencil8 : MTLPixelFormatDepth32Float_Stencil8; +#else + rpD->dsFormat = MTLPixelFormatDepth32Float_Stencil8; +#endif return rpD; } @@ -3603,6 +3630,10 @@ void QMetalSwapChain::chooseFormats() bool QMetalSwapChain::buildOrResize() { +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) { +#endif + Q_ASSERT(m_window); const bool needsRegistration = !window || window != m_window; @@ -3622,7 +3653,11 @@ bool QMetalSwapChain::buildOrResize() return false; } +#ifdef Q_OS_MACOS NSView *view = reinterpret_cast<NSView *>(window->winId()); +#else + UIView *view = reinterpret_cast<UIView *>(window->winId()); +#endif Q_ASSERT(view); d->layer = static_cast<CAMetalLayer *>(view.layer); Q_ASSERT(d->layer); @@ -3726,6 +3761,15 @@ bool QMetalSwapChain::buildOrResize() rhiD->registerResource(this); return true; + +#ifdef TARGET_IPHONE_SIMULATOR + } else { + // Won't ever get here in a normal app because MTLDevice creation would + // fail too. Print a warning, just in case. + qWarning("No CAMetalLayer support in this version of the iOS Simulator"); + return false; + } +#endif } QT_END_NAMESPACE diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 2d69abb36b..f60c2d538e 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -4617,12 +4617,8 @@ static inline VkSamplerAddressMode toVkAddressMode(QRhiSampler::AddressMode m) return VK_SAMPLER_ADDRESS_MODE_REPEAT; case QRhiSampler::ClampToEdge: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - case QRhiSampler::Border: - return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; case QRhiSampler::Mirror: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; - case QRhiSampler::MirrorOnce: - return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; default: Q_UNREACHABLE(); return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; diff --git a/src/gui/rhi/rhi.pri b/src/gui/rhi/rhi.pri index 4297a5602b..ccd9592634 100644 --- a/src/gui/rhi/rhi.pri +++ b/src/gui/rhi/rhi.pri @@ -43,15 +43,15 @@ win32 { LIBS += -ld3d11 -ldxgi -ldxguid } -# darwin { -macos { +macos|ios { HEADERS += \ rhi/qrhimetal_p.h \ rhi/qrhimetal_p_p.h SOURCES += \ rhi/qrhimetal.mm - LIBS += -framework AppKit -framework Metal + macos: LIBS += -framework AppKit + LIBS += -framework Metal } include($$PWD/../../3rdparty/VulkanMemoryAllocator.pri) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index cdec57de71..1b6a802ca2 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -51,6 +51,9 @@ #include <qpa/qplatformintegration.h> #import <QuartzCore/CAEAGLLayer.h> +#ifdef Q_OS_IOS +#import <QuartzCore/CAMetalLayer.h> +#endif #include <QtDebug> @@ -58,9 +61,15 @@ QT_BEGIN_NAMESPACE QIOSWindow::QIOSWindow(QWindow *window) : QPlatformWindow(window) - , m_view([[QUIView alloc] initWithQIOSWindow:this]) , m_windowLevel(0) { +#ifdef Q_OS_IOS + if (window->surfaceType() == QSurface::MetalSurface) + m_view = [[QUIMetalView alloc] initWithQIOSWindow:this]; + else +#endif + m_view = [[QUIView alloc] initWithQIOSWindow:this]; + connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QIOSWindow::applicationStateChanged); setParent(QPlatformWindow::parent()); diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index e1d5d5af0c..1ab9481dd6 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -70,3 +70,7 @@ QT_END_NAMESPACE @property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets; @end +#ifdef Q_OS_IOS +@interface QUIMetalView : QUIView +@end +#endif diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 91a186bace..59eae07388 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -100,13 +100,15 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { - // Set up EAGL layer - CAEAGLLayer *eaglLayer = static_cast<CAEAGLLayer *>(self.layer); - eaglLayer.opaque = TRUE; - eaglLayer.drawableProperties = @{ - kEAGLDrawablePropertyRetainedBacking: @(YES), - kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8 - }; + if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { + // Set up EAGL layer + CAEAGLLayer *eaglLayer = static_cast<CAEAGLLayer *>(self.layer); + eaglLayer.opaque = TRUE; + eaglLayer.drawableProperties = @{ + kEAGLDrawablePropertyRetainedBacking: @(YES), + kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8 + }; + } if (isQtApplication()) self.hidden = YES; @@ -675,6 +677,25 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") @end +#ifdef Q_OS_IOS +@implementation QUIMetalView + ++ (Class)layerClass +{ +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) +#endif + + return [CAMetalLayer class]; + +#ifdef TARGET_IPHONE_SIMULATOR + return nil; +#endif +} + +@end +#endif + #ifndef QT_NO_ACCESSIBILITY // Include category as an alternative to using -ObjC (Apple QA1490) #include "quiview_accessibility.mm" -- cgit v1.2.3 From 43f341a13745473cf181cfe6a6ef4725aa2f88eb Mon Sep 17 00:00:00 2001 From: Leander Beernaert <leander.beernaert@qt.io> Date: Tue, 26 Nov 2019 15:50:11 +0100 Subject: Moc Sort json file list in collectjson This patch ensures that the list of input files are sorted before being collected. This provides consistency when comparing results generated from the CMake port which do not have the same order as qmake. Change-Id: I46e3acf7c26dfd21fd0c1196bdeddf22acbf6ba5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/tools/moc/collectjson.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/moc/collectjson.cpp b/src/tools/moc/collectjson.cpp index 4029bca5e9..fe499151cb 100644 --- a/src/tools/moc/collectjson.cpp +++ b/src/tools/moc/collectjson.cpp @@ -83,7 +83,9 @@ int collectJson(const QStringList &jsonFiles, const QString &outputFile) } } - for (const QString &jsonFile: jsonFiles) { + QStringList jsonFilesSorted = jsonFiles; + jsonFilesSorted.sort(); + for (const QString &jsonFile : qAsConst(jsonFilesSorted)) { QFile f(jsonFile); if (!f.open(QIODevice::ReadOnly)) { fprintf(stderr, "Error opening %s for reading\n", qPrintable(jsonFile)); -- cgit v1.2.3 From 48d2ffd39786b2decad76132158aeba172a3b8a8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 26 Nov 2019 15:44:14 +0100 Subject: Add Since markers to QChar::Script docs and sort in alphabetic order Change-Id: I4aedaf87b8b424fe946eb1618ce77a79cfddc111 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/text/qchar.cpp | 244 ++++++++++++++++++++++----------------------- 1 file changed, 122 insertions(+), 122 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 9b03a93278..120a82f9ae 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -288,145 +288,145 @@ QT_BEGIN_NAMESPACE \value Script_Common For characters that may be used with multiple scripts and that do not inherit their script from the preceding characters. - \value Script_Latin - \value Script_Greek - \value Script_Cyrillic - \value Script_Armenian - \value Script_Hebrew + \value Script_Adlam Since Qt 5.11 + \value Script_Ahom Since Qt 5.6 + \value Script_AnatolianHieroglyphs Since Qt 5.6 \value Script_Arabic - \value Script_Syriac - \value Script_Thaana - \value Script_Devanagari + \value Script_Armenian + \value Script_Avestan + \value Script_Balinese + \value Script_Bamum + \value Script_BassaVah Since Qt 5.5 + \value Script_Batak \value Script_Bengali - \value Script_Gurmukhi - \value Script_Gujarati - \value Script_Oriya - \value Script_Tamil - \value Script_Telugu - \value Script_Kannada - \value Script_Malayalam - \value Script_Sinhala - \value Script_Thai - \value Script_Lao - \value Script_Tibetan - \value Script_Myanmar - \value Script_Georgian - \value Script_Hangul - \value Script_Ethiopic - \value Script_Cherokee - \value Script_CanadianAboriginal - \value Script_Ogham - \value Script_Runic - \value Script_Khmer - \value Script_Mongolian - \value Script_Hiragana - \value Script_Katakana + \value Script_Bhaiksuki Since Qt 5.11 \value Script_Bopomofo - \value Script_Han - \value Script_Yi - \value Script_OldItalic - \value Script_Gothic - \value Script_Deseret - \value Script_Tagalog - \value Script_Hanunoo - \value Script_Buhid - \value Script_Tagbanwa - \value Script_Coptic - \value Script_Limbu - \value Script_TaiLe - \value Script_LinearB - \value Script_Ugaritic - \value Script_Shavian - \value Script_Osmanya - \value Script_Cypriot + \value Script_Brahmi \value Script_Braille \value Script_Buginese - \value Script_NewTaiLue - \value Script_Glagolitic - \value Script_Tifinagh - \value Script_SylotiNagri - \value Script_OldPersian - \value Script_Kharoshthi - \value Script_Balinese - \value Script_Cuneiform - \value Script_Phoenician - \value Script_PhagsPa - \value Script_Nko - \value Script_Sundanese - \value Script_Lepcha - \value Script_OlChiki - \value Script_Vai - \value Script_Saurashtra - \value Script_KayahLi - \value Script_Rejang - \value Script_Lycian + \value Script_Buhid + \value Script_CanadianAboriginal \value Script_Carian - \value Script_Lydian + \value Script_CaucasianAlbanian Since Qt 5.5 + \value Script_Chakma \value Script_Cham - \value Script_TaiTham - \value Script_TaiViet - \value Script_Avestan + \value Script_Cherokee + \value Script_Coptic + \value Script_Cuneiform + \value Script_Cypriot + \value Script_Cyrillic + \value Script_Deseret + \value Script_Devanagari + \value Script_Duployan Since Qt 5.5 \value Script_EgyptianHieroglyphs - \value Script_Samaritan - \value Script_Lisu - \value Script_Bamum - \value Script_Javanese - \value Script_MeeteiMayek + \value Script_Elbasan Since Qt 5.5 + \value Script_Ethiopic + \value Script_Georgian + \value Script_Glagolitic + \value Script_Gothic + \value Script_Grantha Since Qt 5.5 + \value Script_Greek + \value Script_Gujarati + \value Script_Gurmukhi + \value Script_Han + \value Script_Hangul + \value Script_Hanunoo + \value Script_Hatran Since Qt 5.6 + \value Script_Hebrew + \value Script_Hiragana \value Script_ImperialAramaic - \value Script_OldSouthArabian - \value Script_InscriptionalParthian \value Script_InscriptionalPahlavi - \value Script_OldTurkic + \value Script_InscriptionalParthian + \value Script_Javanese \value Script_Kaithi - \value Script_Batak - \value Script_Brahmi + \value Script_Kannada + \value Script_Katakana + \value Script_KayahLi + \value Script_Kharoshthi + \value Script_Khmer + \value Script_Khojki Since Qt 5.5 + \value Script_Khudawadi Since Qt 5.5 + \value Script_Lao + \value Script_Latin + \value Script_Lepcha + \value Script_Limbu + \value Script_LinearA Since Qt 5.5 + \value Script_LinearB + \value Script_Lisu + \value Script_Lycian + \value Script_Lydian + \value Script_Mahajani Since Qt 5.5 + \value Script_Malayalam \value Script_Mandaic - \value Script_Chakma + \value Script_Manichaean Since Qt 5.5 + \value Script_Marchen Since Qt 5.11 + \value Script_MasaramGondi Since Qt 5.11 + \value Script_MeeteiMayek + \value Script_MendeKikakui Since Qt 5.5 \value Script_MeroiticCursive \value Script_MeroiticHieroglyphs \value Script_Miao + \value Script_Modi Since Qt 5.5 + \value Script_Mongolian + \value Script_Mro Since Qt 5.5 + \value Script_Multani Since Qt 5.6 + \value Script_Myanmar + \value Script_Nabataean Since Qt 5.5 + \value Script_Newa Since Qt 5.11 + \value Script_NewTaiLue + \value Script_Nko + \value Script_Nushu Since Qt 5.11 + \value Script_Ogham + \value Script_OlChiki + \value Script_OldHungarian Since Qt 5.6 + \value Script_OldItalic + \value Script_OldNorthArabian Since Qt 5.5 + \value Script_OldPermic Since Qt 5.5 + \value Script_OldPersian + \value Script_OldSouthArabian + \value Script_OldTurkic + \value Script_Oriya + \value Script_Osage Since Qt 5.11 + \value Script_Osmanya + \value Script_PahawhHmong Since Qt 5.5 + \value Script_Palmyrene Since Qt 5.5 + \value Script_PauCinHau Since Qt 5.5 + \value Script_PhagsPa + \value Script_Phoenician + \value Script_PsalterPahlavi Since Qt 5.5 + \value Script_Rejang + \value Script_Runic + \value Script_Samaritan + \value Script_Saurashtra \value Script_Sharada + \value Script_Shavian + \value Script_Siddham Since Qt 5.5 + \value Script_SignWriting Since Qt 5.6 + \value Script_Sinhala \value Script_SoraSompeng + \value Script_Soyombo Since Qt 5.11 + \value Script_Sundaneseo + \value Script_SylotiNagri + \value Script_Syriac + \value Script_Tagalog + \value Script_Tagbanwa + \value Script_TaiLe + \value Script_TaiTham + \value Script_TaiViet \value Script_Takri - \value Script_CaucasianAlbanian - \value Script_BassaVah - \value Script_Duployan - \value Script_Elbasan - \value Script_Grantha - \value Script_PahawhHmong - \value Script_Khojki - \value Script_LinearA - \value Script_Mahajani - \value Script_Manichaean - \value Script_MendeKikakui - \value Script_Modi - \value Script_Mro - \value Script_OldNorthArabian - \value Script_Nabataean - \value Script_Palmyrene - \value Script_PauCinHau - \value Script_OldPermic - \value Script_PsalterPahlavi - \value Script_Siddham - \value Script_Khudawadi - \value Script_Tirhuta - \value Script_WarangCiti - \value Script_Ahom - \value Script_AnatolianHieroglyphs - \value Script_Hatran - \value Script_Multani - \value Script_OldHungarian - \value Script_SignWriting - \value Script_Adlam - \value Script_Bhaiksuki - \value Script_Marchen - \value Script_Newa - \value Script_Osage - \value Script_Tangut - \value Script_MasaramGondi - \value Script_Nushu - \value Script_Soyombo - \value Script_ZanabazarSquare + \value Script_Tamil + \value Script_Tangut Since Qt 5.11 + \value Script_Telugu + \value Script_Thaana + \value Script_Thai + \value Script_Tibetan + \value Script_Tifinagh + \value Script_Tirhuta Since Qt 5.5 + \value Script_Ugaritic + \value Script_Vai + \value Script_WarangCiti Since Qt 5.5 + \value Script_Yi + \value Script_ZanabazarSquare Since Qt 5.11 \omitvalue ScriptCount -- cgit v1.2.3 From 6566157df3c5a1352231be87c7b7d2705a46efe3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Wed, 13 Nov 2019 18:42:00 +0100 Subject: Make Qt::RFC2822Date's doc match up with its implementation The qdatetime implementation's rfcDateImpl() uses regexes which did not match its comments; nor did either the regexes or the comments match what was documented. A review of relevant RFCs suggests we should revise this in future, probably at Qt 6. The documentation also only addressed the formats recognized when parsing a date-time, without indicating how they are serialised or how dates and times are handled separately. Added a note to the tests for the read-only formats, to remind the reader that the RFCs merely recommend recognising these - be permissive in what you expect and strict in what you deliver. Change-Id: I0f0bec752e7a50bde98cceceb7e0d11be15c6a6f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qnamespace.qdoc | 16 ++++++++++++---- src/corelib/time/qdatetime.cpp | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index cce88782e9..bebe67be3f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -724,9 +724,17 @@ \value LocalDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate instead (or Qt::SystemLocaleLongDate if you want long dates). - \value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format: either - \c{[ddd,] dd MMM yyyy hh:mm[:ss] +/-TZ} or \c{ddd MMM dd yyyy hh:mm[:ss] +/-TZ} - for combined dates and times. + \value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format: + either \c{[ddd,] dd MMM yyyy [hh:mm[:ss]][ ±tzoff]} + or \c{ddd MMM dd[ hh:mm:ss] yyyy[ ±tzoff]} are recognized for combined dates + and times, where \c{tzoff} is a timezone offset in \c{hhmm} format. For + dates and times separately, the same formats are matched and the unwanted + parts are ignored. In particular, note that a time is not recognized without + an accompanying date. When converting dates to string form, + format \c{dd MMM yyyy} is used, for times the format is \c{hh:mm:ss}. For + combined date and time, these are combined + as \c{dd MMM yyyy hh:mm:ss ±tzoff} (omitting the optional leading day of the + week from the first format recognized). \note For \c ISODate formats, each \c Y, \c M and \c D represents a single digit of the year, month and day used to specify the date. Each \c H, \c M and \c S diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 878a2c1e46..e6213c44c0 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -164,7 +164,7 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s) { ParsedRfcDateTime result; - // Matches "Wdy, dd Mon yyyy HH:mm:ss ±hhmm" (Wdy, being optional) + // Matches "[ddd,] dd MMM yyyy[ hh:mm[:ss]] [±hhmm]" - correct RFC 822, 2822, 5322 format QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); if (s.indexOf(rex) == 0) { const QStringList cap = rex.capturedTexts(); @@ -176,7 +176,7 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s) const int minOffset = cap[9].toInt(); result.utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60)); } else { - // Matches "Wdy Mon dd HH:mm:ss yyyy" + // Matches "ddd MMM dd[ hh:mm:ss] yyyy [±hhmm]" - permissive RFC 850, 1036 (read only) QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); if (s.indexOf(rex) == 0) { const QStringList cap = rex.capturedTexts(); -- cgit v1.2.3 From 0debb205b23a39b79650861de0e61cf4cf00286c Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Thu, 14 Nov 2019 16:40:21 +0100 Subject: Permit leading space at start of RFC 2822 Date format Relevant RFCs explicitly permit such space. Change-Id: I8eb444e96287368cbbf973c77513b43d1d36f972 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index e6213c44c0..9b0bc688c9 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -165,7 +165,7 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s) ParsedRfcDateTime result; // Matches "[ddd,] dd MMM yyyy[ hh:mm[:ss]] [±hhmm]" - correct RFC 822, 2822, 5322 format - QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); + QRegExp rex(QStringLiteral("^[ \\t]*(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); if (s.indexOf(rex) == 0) { const QStringList cap = rex.capturedTexts(); result.date = QDate(cap[3].toInt(), qt_monthNumberFromShortName(cap[2]), cap[1].toInt()); @@ -177,7 +177,7 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s) result.utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60)); } else { // Matches "ddd MMM dd[ hh:mm:ss] yyyy [±hhmm]" - permissive RFC 850, 1036 (read only) - QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); + QRegExp rex(QStringLiteral("^[ \\t]*[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?")); if (s.indexOf(rex) == 0) { const QStringList cap = rex.capturedTexts(); result.date = QDate(cap[6].toInt(), qt_monthNumberFromShortName(cap[1]), cap[2].toInt()); -- cgit v1.2.3 From c20c7efea96046bebcb8ff7823d3a7e227f92e73 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 26 Nov 2019 12:22:31 +0100 Subject: Sanitize QAndroidTimeZonePrivate::init() It was setting the system zone ID if it somehow managed to find a match for an empty zone name; that makes no sense. A case-insensitive comparison seems reasonable for the "this isn't just a default zone object, used because the name I asked for isn't recognized" check. It set m_id after it had checked everything, where it could just as well have used m_id as the variable in which to record whether its check has succeeded already. It was using the name it was asked for, rather than the one this ended up being mapped to, which is probably a better name to use for it. (This should only differ in case.) Split a long line. Change-Id: I41a3b01ba99522ee68f3d7941c532019b9ebf946 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/corelib/time/qtimezoneprivate_android.cpp | 36 ++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp index be4f374fdd..8de41ed3ce 100644 --- a/src/corelib/time/qtimezoneprivate_android.cpp +++ b/src/corelib/time/qtimezoneprivate_android.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2014 Drew Parsons <dparsons@emerall.com> ** Contact: https://www.qt.io/licensing/ ** @@ -76,32 +77,33 @@ QAndroidTimeZonePrivate::~QAndroidTimeZonePrivate() { } - void QAndroidTimeZonePrivate::init(const QByteArray &ianaId) { - QJNIObjectPrivate jo_ianaId = QJNIObjectPrivate::fromString( QString::fromUtf8(ianaId) ); - androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod( "java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;", static_cast<jstring>(jo_ianaId.object()) ); + const QString iana = QString::fromUtf8(ianaId); + androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod( + "java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;", + static_cast<jstring>(QJNIObjectPrivate::fromString(iana).object())); + + // The ID or display name of the zone we've got, if it looks like what we asked for: + const auto match = [iana](const QJNIObjectPrivate &jname) -> QByteArray { + const QString name = jname.toString(); + if (iana.compare(name, Qt::CaseInsensitive)) + return name.toUtf8(); + + return QByteArray(); + }; // Painfully, JNI gives us back a default zone object if it doesn't // recognize the name; so check for whether ianaId is a recognized name of // the zone object we got and ignore the zone if not. // Try checking ianaId against getID(), getDisplayName(): - QJNIObjectPrivate jname = androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;"); - bool found = (jname.toString().toUtf8() == ianaId); - for (int style = 1; !found && style-- > 0;) { - for (int dst = 1; !found && dst-- > 0;) { - jname = androidTimeZone.callObjectMethod("getDisplayName", "(ZI;)Ljava/lang/String;", - bool(dst), style); - found = (jname.toString().toUtf8() == ianaId); + m_id = match(androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;")); + for (int style = 1; m_id.isEmpty() && style-- > 0;) { + for (int dst = 1; m_id.isEmpty() && dst-- > 0;) { + m_id = match(androidTimeZone.callObjectMethod( + "getDisplayName", "(ZI;)Ljava/lang/String;", bool(dst), style)); } } - - if (!found) - m_id.clear(); - else if (ianaId.isEmpty()) - m_id = systemTimeZoneId(); - else - m_id = ianaId; } QAndroidTimeZonePrivate *QAndroidTimeZonePrivate::clone() const -- cgit v1.2.3 From 78cde1bfd94521bbe4972f31a79c959d0990ea77 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 26 Nov 2019 13:35:10 +0100 Subject: Fix mis-guided init() in default QAndroidTimeZonePrivate constructor It set the time-zone member sensibly to the default zone, but then called init("UTC"), which over-wrote that default with UTC. This had no visible effect (as the default-constructed object is only used to access methods that (though virtual) are effectively static), but was needlessly complicated. Tidied up systemTimeZoneId() at the same time. Change-Id: I897aff16855c28487a1029bef50c75ebc1ff5b55 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qtimezoneprivate_android.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp index 8de41ed3ce..5cb8155dcc 100644 --- a/src/corelib/time/qtimezoneprivate_android.cpp +++ b/src/corelib/time/qtimezoneprivate_android.cpp @@ -54,9 +54,10 @@ QT_BEGIN_NAMESPACE QAndroidTimeZonePrivate::QAndroidTimeZonePrivate() : QTimeZonePrivate() { - // start with system time zone - androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod("java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;"); - init("UTC"); + // Keep in sync with systemTimeZoneId(): + androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod( + "java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;"); + m_id = androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;").toString().toUtf8(); } // Create a named time zone @@ -227,11 +228,10 @@ QTimeZonePrivate::Data QAndroidTimeZonePrivate::previousTransition(qint64 before QByteArray QAndroidTimeZonePrivate::systemTimeZoneId() const { - QJNIObjectPrivate androidSystemTimeZone = QJNIObjectPrivate::callStaticObjectMethod("java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;"); - QJNIObjectPrivate systemTZIdAndroid = androidSystemTimeZone.callObjectMethod<jstring>("getID"); - QByteArray systemTZid = systemTZIdAndroid.toString().toUtf8(); - - return systemTZid; + // Keep in sync with default constructor: + QJNIObjectPrivate androidSystemTimeZone = QJNIObjectPrivate::callStaticObjectMethod( + "java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;"); + return androidSystemTimeZone.callObjectMethod<jstring>("getID").toString().toUtf8(); } QList<QByteArray> QAndroidTimeZonePrivate::availableTimeZoneIds() const -- cgit v1.2.3 From 64760504e79c3069d99b5e852688a2589ec22028 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Tue, 26 Nov 2019 12:43:56 +0100 Subject: rhi: Allow testing QRhiRenderPassDescriptors for compatibility For Metal and Vulkan this needs actual work because that's where the concept of renderpass descriptors is relevant. GL and D3D can just return true always. The big benefit of this is that Qt Quick can now compare renderpass descriptors via isCompatible() for its pipeline cache (similarly to how it is already using isLayoutCompatible() for srbs), and so renderpass descriptors for layers (Item.layer, ShaderEffect) will typically be compatible and so can pick up pipelines created by other layers from the cache. Also add autotests for shader resource binding and renderpass descriptor compatibility. Task-number: QTBUG-80318 Change-Id: I0008bc51c4ee13b0113d2c8caf799e1257f18a18 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhi.cpp | 18 ++++ src/gui/rhi/qrhi_p.h | 1 + src/gui/rhi/qrhid3d11.cpp | 6 ++ src/gui/rhi/qrhid3d11_p_p.h | 1 + src/gui/rhi/qrhigles2.cpp | 6 ++ src/gui/rhi/qrhigles2_p_p.h | 1 + src/gui/rhi/qrhimetal.mm | 26 ++++++ src/gui/rhi/qrhimetal_p_p.h | 1 + src/gui/rhi/qrhinull.cpp | 6 ++ src/gui/rhi/qrhinull_p_p.h | 1 + src/gui/rhi/qrhivulkan.cpp | 193 ++++++++++++++++++++++++++++--------------- src/gui/rhi/qrhivulkan_p_p.h | 10 ++- 12 files changed, 202 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index ac5836fc68..ece5190ff7 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2318,6 +2318,24 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const return RenderPassDescriptor; } +/*! + \fn bool QRhiRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const; + + \return true if the \a other QRhiRenderPassDescriptor is compatible with + this one, meaning \c this and \a other can be used interchangebly in + QRhiGraphicsPipeline::setRenderPassDescriptor(). + + The concept of the compatibility of renderpass descriptors is similar to + the \l{QRhiShaderResourceBindings::isLayoutCompatible}{layout + compatibility} of QRhiShaderResourceBindings instances. They allow better + reuse of QRhiGraphicsPipeline instances: for example, a + QRhiGraphicsPipeline instance cache is expected to use these functions to + look for a matching pipeline, instead of just comparing pointers, thus + allowing a different QRhiRenderPassDescriptor and + QRhiShaderResourceBindings to be used in combination with the pipeline, as + long as they are compatible. + */ + /*! \return a pointer to a backend-specific QRhiNativeHandles subclass, such as QRhiVulkanRenderPassNativeHandles. The returned value is null when exposing diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 8cc4c7a06c..9df2c58962 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -911,6 +911,7 @@ class Q_GUI_EXPORT QRhiRenderPassDescriptor : public QRhiResource public: QRhiResource::Type resourceType() const override; + virtual bool isCompatible(const QRhiRenderPassDescriptor *other) const = 0; virtual const QRhiNativeHandles *nativeHandles(); protected: diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 7e05aefe8d..52109edce0 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2940,6 +2940,12 @@ void QD3D11RenderPassDescriptor::release() // nothing to do here } +bool QD3D11RenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QD3D11ReferenceRenderTarget::QD3D11ReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 26de34ae0a..13c56b1d6d 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -136,6 +136,7 @@ struct QD3D11RenderPassDescriptor : public QRhiRenderPassDescriptor QD3D11RenderPassDescriptor(QRhiImplementation *rhi); ~QD3D11RenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; }; struct QD3D11RenderTargetData diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index ab61050e3e..b0e9a149f1 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3455,6 +3455,12 @@ void QGles2RenderPassDescriptor::release() // nothing to do here } +bool QGles2RenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QGles2ReferenceRenderTarget::QGles2ReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index cc945876e6..b0f5e340fb 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -185,6 +185,7 @@ struct QGles2RenderPassDescriptor : public QRhiRenderPassDescriptor QGles2RenderPassDescriptor(QRhiImplementation *rhi); ~QGles2RenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; }; struct QGles2RenderTargetData diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 06e81465a2..e5af1cfab1 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2658,6 +2658,32 @@ void QMetalRenderPassDescriptor::release() // nothing to do here } +bool QMetalRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + if (!other) + return false; + + const QMetalRenderPassDescriptor *o = QRHI_RES(const QMetalRenderPassDescriptor, other); + + if (colorAttachmentCount != o->colorAttachmentCount) + return false; + + if (hasDepthStencil != o->hasDepthStencil) + return false; + + for (int i = 0; i < colorAttachmentCount; ++i) { + if (colorFormat[i] != o->colorFormat[i]) + return false; + } + + if (hasDepthStencil) { + if (dsFormat != o->dsFormat) + return false; + } + + return true; +} + QMetalReferenceRenderTarget::QMetalReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(new QMetalRenderTargetData) diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 2be86db5c8..7876539fcd 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -138,6 +138,7 @@ struct QMetalRenderPassDescriptor : public QRhiRenderPassDescriptor QMetalRenderPassDescriptor(QRhiImplementation *rhi); ~QMetalRenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; // there is no MTLRenderPassDescriptor here as one will be created for each pass in beginPass() diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index fe606f971f..0baea1b9d6 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -690,6 +690,12 @@ void QNullRenderPassDescriptor::release() { } +bool QNullRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QNullReferenceRenderTarget::QNullReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) diff --git a/src/gui/rhi/qrhinull_p_p.h b/src/gui/rhi/qrhinull_p_p.h index ce517bfa63..c96f279f7d 100644 --- a/src/gui/rhi/qrhinull_p_p.h +++ b/src/gui/rhi/qrhinull_p_p.h @@ -101,6 +101,7 @@ struct QNullRenderPassDescriptor : public QRhiRenderPassDescriptor QNullRenderPassDescriptor(QRhiImplementation *rhi); ~QNullRenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; }; struct QNullRenderTargetData diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index f60c2d538e..25a85a5a17 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1032,54 +1032,62 @@ VkFormat QRhiVulkan::optimalDepthStencilFormat() return optimalDsFormat; } -bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat) +bool QRhiVulkan::createDefaultRenderPass(QVkRenderPassDescriptor *rpD, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat) { - VkAttachmentDescription attDesc[3]; - memset(attDesc, 0, sizeof(attDesc)); - // attachment list layout is color (1), ds (0-1), resolve (0-1) - attDesc[0].format = colorFormat; - attDesc[0].samples = samples; - attDesc[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[0].storeOp = samples > VK_SAMPLE_COUNT_1_BIT ? VK_ATTACHMENT_STORE_OP_DONT_CARE : VK_ATTACHMENT_STORE_OP_STORE; - attDesc[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - attDesc[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attDesc[0].finalLayout = samples > VK_SAMPLE_COUNT_1_BIT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - - // clear on load + no store + lazy alloc + transient image should play - // nicely with tiled GPUs (no physical backing necessary for ds buffer) - attDesc[1].format = optimalDepthStencilFormat(); - attDesc[1].samples = samples; - attDesc[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[1].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attDesc[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + VkAttachmentDescription attDesc; + memset(&attDesc, 0, sizeof(attDesc)); + attDesc.format = colorFormat; + attDesc.samples = samples; + attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.storeOp = samples > VK_SAMPLE_COUNT_1_BIT ? VK_ATTACHMENT_STORE_OP_DONT_CARE : VK_ATTACHMENT_STORE_OP_STORE; + attDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.finalLayout = samples > VK_SAMPLE_COUNT_1_BIT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + rpD->attDescs.append(attDesc); - if (samples > VK_SAMPLE_COUNT_1_BIT) { - attDesc[2].format = colorFormat; - attDesc[2].samples = VK_SAMPLE_COUNT_1_BIT; - attDesc[2].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; - attDesc[2].storeOp = VK_ATTACHMENT_STORE_OP_STORE; - attDesc[2].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - attDesc[2].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attDesc[2].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attDesc[2].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + rpD->colorRefs.append({ 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }); + + if (hasDepthStencil) { + // clear on load + no store + lazy alloc + transient image should play + // nicely with tiled GPUs (no physical backing necessary for ds buffer) + memset(&attDesc, 0, sizeof(attDesc)); + attDesc.format = optimalDepthStencilFormat(); + attDesc.samples = samples; + attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + rpD->attDescs.append(attDesc); + + rpD->dsRef = { 1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; } - VkAttachmentReference colorRef = { 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - VkAttachmentReference dsRef = { 1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; - VkAttachmentReference resolveRef = { 2, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + if (samples > VK_SAMPLE_COUNT_1_BIT) { + memset(&attDesc, 0, sizeof(attDesc)); + attDesc.format = colorFormat; + attDesc.samples = VK_SAMPLE_COUNT_1_BIT; + attDesc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; + attDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; + attDesc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + attDesc.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + rpD->attDescs.append(attDesc); + + rpD->resolveRefs.append({ 2, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }); + } VkSubpassDescription subpassDesc; memset(&subpassDesc, 0, sizeof(subpassDesc)); subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; subpassDesc.colorAttachmentCount = 1; - subpassDesc.pColorAttachments = &colorRef; - subpassDesc.pDepthStencilAttachment = hasDepthStencil ? &dsRef : nullptr; + subpassDesc.pColorAttachments = rpD->colorRefs.constData(); + subpassDesc.pDepthStencilAttachment = hasDepthStencil ? &rpD->dsRef : nullptr; // Replace the first implicit dep (TOP_OF_PIPE / ALL_COMMANDS) with our own. VkSubpassDependency subpassDep; @@ -1095,7 +1103,7 @@ bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil, memset(&rpInfo, 0, sizeof(rpInfo)); rpInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; rpInfo.attachmentCount = 1; - rpInfo.pAttachments = attDesc; + rpInfo.pAttachments = rpD->attDescs.constData(); rpInfo.subpassCount = 1; rpInfo.pSubpasses = &subpassDesc; rpInfo.dependencyCount = 1; @@ -1106,19 +1114,21 @@ bool QRhiVulkan::createDefaultRenderPass(VkRenderPass *rp, bool hasDepthStencil, if (samples > VK_SAMPLE_COUNT_1_BIT) { rpInfo.attachmentCount += 1; - subpassDesc.pResolveAttachments = &resolveRef; + subpassDesc.pResolveAttachments = rpD->resolveRefs.constData(); } - VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, rp); + VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, &rpD->rp); if (err != VK_SUCCESS) { qWarning("Failed to create renderpass: %d", err); return false; } + rpD->hasDepthStencil = hasDepthStencil; + return true; } -bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, +bool QRhiVulkan::createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, const QRhiColorAttachment *firstColorAttachment, const QRhiColorAttachment *lastColorAttachment, bool preserveColor, @@ -1126,10 +1136,6 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, QRhiRenderBuffer *depthStencilBuffer, QRhiTexture *depthTexture) { - QVarLengthArray<VkAttachmentDescription, 8> attDescs; - QVarLengthArray<VkAttachmentReference, 8> colorRefs; - QVarLengthArray<VkAttachmentReference, 8> resolveRefs; - // attachment list layout is color (0-8), ds (0-1), resolve (0-8) for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { @@ -1150,14 +1156,14 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, // this has to interact correctly with activateTextureRenderTarget(), hence leaving in COLOR_ATT attDesc.initialLayout = preserveColor ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - attDescs.append(attDesc); + rpD->attDescs.append(attDesc); - const VkAttachmentReference ref = { uint32_t(attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - colorRefs.append(ref); + const VkAttachmentReference ref = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + rpD->colorRefs.append(ref); } - const bool hasDepthStencil = depthStencilBuffer || depthTexture; - if (hasDepthStencil) { + rpD->hasDepthStencil = depthStencilBuffer || depthTexture; + if (rpD->hasDepthStencil) { const VkFormat dsFormat = depthTexture ? QRHI_RES(QVkTexture, depthTexture)->vkformat : QRHI_RES(QVkRenderBuffer, depthStencilBuffer)->vkformat; const VkSampleCountFlagBits samples = depthTexture ? QRHI_RES(QVkTexture, depthTexture)->samples @@ -1174,9 +1180,9 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, attDesc.stencilStoreOp = storeOp; attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; - attDescs.append(attDesc); + rpD->attDescs.append(attDesc); } - VkAttachmentReference dsRef = { uint32_t(attDescs.count() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; + rpD->dsRef = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL }; for (auto it = firstColorAttachment; it != lastColorAttachment; ++it) { if (it->resolveTexture()) { @@ -1194,37 +1200,37 @@ bool QRhiVulkan::createOffscreenRenderPass(VkRenderPass *rp, attDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; attDesc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; attDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - attDescs.append(attDesc); + rpD->attDescs.append(attDesc); - const VkAttachmentReference ref = { uint32_t(attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - resolveRefs.append(ref); + const VkAttachmentReference ref = { uint32_t(rpD->attDescs.count() - 1), VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; + rpD->resolveRefs.append(ref); } else { const VkAttachmentReference ref = { VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; - resolveRefs.append(ref); + rpD->resolveRefs.append(ref); } } VkSubpassDescription subpassDesc; memset(&subpassDesc, 0, sizeof(subpassDesc)); subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpassDesc.colorAttachmentCount = uint32_t(colorRefs.count()); - Q_ASSERT(colorRefs.count() == resolveRefs.count()); - subpassDesc.pColorAttachments = !colorRefs.isEmpty() ? colorRefs.constData() : nullptr; - subpassDesc.pDepthStencilAttachment = hasDepthStencil ? &dsRef : nullptr; - subpassDesc.pResolveAttachments = !resolveRefs.isEmpty() ? resolveRefs.constData() : nullptr; + subpassDesc.colorAttachmentCount = uint32_t(rpD->colorRefs.count()); + Q_ASSERT(rpD->colorRefs.count() == rpD->resolveRefs.count()); + subpassDesc.pColorAttachments = !rpD->colorRefs.isEmpty() ? rpD->colorRefs.constData() : nullptr; + subpassDesc.pDepthStencilAttachment = rpD->hasDepthStencil ? &rpD->dsRef : nullptr; + subpassDesc.pResolveAttachments = !rpD->resolveRefs.isEmpty() ? rpD->resolveRefs.constData() : nullptr; VkRenderPassCreateInfo rpInfo; memset(&rpInfo, 0, sizeof(rpInfo)); rpInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - rpInfo.attachmentCount = uint32_t(attDescs.count()); - rpInfo.pAttachments = attDescs.constData(); + rpInfo.attachmentCount = uint32_t(rpD->attDescs.count()); + rpInfo.pAttachments = rpD->attDescs.constData(); rpInfo.subpassCount = 1; rpInfo.pSubpasses = &subpassDesc; // don't yet know the correct initial/final access and stage stuff for the // implicit deps at this point, so leave it to the resource tracking to // generate barriers - VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, rp); + VkResult err = df->vkCreateRenderPass(dev, &rpInfo, nullptr, &rpD->rp); if (err != VK_SUCCESS) { qWarning("Failed to create renderpass: %d", err); return false; @@ -5501,6 +5507,61 @@ void QVkRenderPassDescriptor::release() rhiD->unregisterResource(this); } +static inline bool attachmentDescriptionEquals(const VkAttachmentDescription &a, const VkAttachmentDescription &b) +{ + return a.format == b.format + && a.samples == b.samples + && a.loadOp == b.loadOp + && a.storeOp == b.storeOp + && a.stencilLoadOp == b.stencilLoadOp + && a.stencilStoreOp == b.stencilStoreOp + && a.initialLayout == b.initialLayout + && a.finalLayout == b.finalLayout; +} + +bool QVkRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + if (!other) + return false; + + const QVkRenderPassDescriptor *o = QRHI_RES(const QVkRenderPassDescriptor, other); + + if (attDescs.count() != o->attDescs.count()) + return false; + if (colorRefs.count() != o->colorRefs.count()) + return false; + if (resolveRefs.count() != o->resolveRefs.count()) + return false; + if (hasDepthStencil != o->hasDepthStencil) + return false; + + for (int i = 0, ie = colorRefs.count(); i != ie; ++i) { + const uint32_t attIdx = colorRefs[i].attachment; + if (attIdx != o->colorRefs[i].attachment) + return false; + if (attIdx != VK_ATTACHMENT_UNUSED && !attachmentDescriptionEquals(attDescs[attIdx], o->attDescs[attIdx])) + return false; + } + + if (hasDepthStencil) { + const uint32_t attIdx = dsRef.attachment; + if (attIdx != o->dsRef.attachment) + return false; + if (attIdx != VK_ATTACHMENT_UNUSED && !attachmentDescriptionEquals(attDescs[attIdx], o->attDescs[attIdx])) + return false; + } + + for (int i = 0, ie = resolveRefs.count(); i != ie; ++i) { + const uint32_t attIdx = resolveRefs[i].attachment; + if (attIdx != o->resolveRefs[i].attachment) + return false; + if (attIdx != VK_ATTACHMENT_UNUSED && !attachmentDescriptionEquals(attDescs[attIdx], o->attDescs[attIdx])) + return false; + } + + return true; +} + const QRhiNativeHandles *QVkRenderPassDescriptor::nativeHandles() { nativeHandlesStruct.renderPass = rp; @@ -5584,7 +5645,7 @@ QRhiRenderPassDescriptor *QVkTextureRenderTarget::newCompatibleRenderPassDescrip QRHI_RES_RHI(QRhiVulkan); QVkRenderPassDescriptor *rp = new QVkRenderPassDescriptor(m_rhi); - if (!rhiD->createOffscreenRenderPass(&rp->rp, + if (!rhiD->createOffscreenRenderPass(rp, m_desc.cbeginColorAttachments(), m_desc.cendColorAttachments(), m_flags.testFlag(QRhiTextureRenderTarget::PreserveColorContents), @@ -6285,7 +6346,7 @@ QRhiRenderPassDescriptor *QVkSwapChain::newCompatibleRenderPassDescriptor() QRHI_RES_RHI(QRhiVulkan); QVkRenderPassDescriptor *rp = new QVkRenderPassDescriptor(m_rhi); - if (!rhiD->createDefaultRenderPass(&rp->rp, + if (!rhiD->createDefaultRenderPass(rp, m_depthStencil != nullptr, samples, colorFormat)) diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index d0e1e6758b..ffa8c59ed5 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -171,10 +171,16 @@ struct QVkRenderPassDescriptor : public QRhiRenderPassDescriptor QVkRenderPassDescriptor(QRhiImplementation *rhi); ~QVkRenderPassDescriptor(); void release() override; + bool isCompatible(const QRhiRenderPassDescriptor *other) const override; const QRhiNativeHandles *nativeHandles() override; VkRenderPass rp = VK_NULL_HANDLE; bool ownsRp = false; + QVarLengthArray<VkAttachmentDescription, 8> attDescs; + QVarLengthArray<VkAttachmentReference, 8> colorRefs; + QVarLengthArray<VkAttachmentReference, 8> resolveRefs; + bool hasDepthStencil = false; + VkAttachmentReference dsRef; QRhiVulkanRenderPassNativeHandles nativeHandlesStruct; int lastActiveFrameSlot = -1; }; @@ -727,11 +733,11 @@ public: VkFormat optimalDepthStencilFormat(); VkSampleCountFlagBits effectiveSampleCount(int sampleCount); - bool createDefaultRenderPass(VkRenderPass *rp, + bool createDefaultRenderPass(QVkRenderPassDescriptor *rpD, bool hasDepthStencil, VkSampleCountFlagBits samples, VkFormat colorFormat); - bool createOffscreenRenderPass(VkRenderPass *rp, + bool createOffscreenRenderPass(QVkRenderPassDescriptor *rpD, const QRhiColorAttachment *firstColorAttachment, const QRhiColorAttachment *lastColorAttachment, bool preserveColor, -- cgit v1.2.3 From 4422a9bd88602c8dfde8648ad39692d968295cfc Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 11 Jun 2019 08:54:34 +0200 Subject: QWidget: don't set WA_PendingMoveEvent when geometry does not change When the geometry of a hidden widget was set with setGeometry(), WA_PendingMoveEvent and WA_PendingResizeEvent were set unconditionally even if the crect already had the correct value. This lead to unneeded Move/Resize events within sendPendingMoveAndResizeEvents(). Fixes: QTBUG-75475 Fixes: QTBUG-79906 Change-Id: Ibbe03882f039948b6b7c04887420741ed2e9c0f7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/kernel/qwidget.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index e9968e41b4..5a0ea58cf8 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7005,8 +7005,10 @@ void QWidget::resize(const QSize &s) d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false); d->setDirtyOpaqueRegion(); } else { + const auto oldRect = data->crect; data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize())); - setAttribute(Qt::WA_PendingResizeEvent); + if (oldRect != data->crect) + setAttribute(Qt::WA_PendingResizeEvent); } } @@ -7021,10 +7023,13 @@ void QWidget::setGeometry(const QRect &r) d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true); d->setDirtyOpaqueRegion(); } else { + const auto oldRect = data->crect; data->crect.setTopLeft(r.topLeft()); data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize())); - setAttribute(Qt::WA_PendingMoveEvent); - setAttribute(Qt::WA_PendingResizeEvent); + if (oldRect != data->crect) { + setAttribute(Qt::WA_PendingMoveEvent); + setAttribute(Qt::WA_PendingResizeEvent); + } } if (d->extra && d->extra->hasWindowContainer) -- cgit v1.2.3 From 14ae88144521b9e3c22202c7967a19607fd91ff9 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Tue, 26 Nov 2019 13:35:59 +0100 Subject: QSslSocket (OpenSSL) fix a resource leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced by fe6e54fb1f5cda652b9489f740763f8d735621dd. The probability -> 0, meaning malloc must fail to trigger it, but it is still a leak. We now use std::unique_ptr which improves the code in general a bit and fixes a leak. Change-Id: I6c0fa36953196d3235fb60354dc9ad2396d8dfcb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/ssl/qsslsocket_openssl.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index d4bad1b1a5..51510f1c60 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -93,6 +93,7 @@ #endif #include <algorithm> +#include <memory> #include <string.h> @@ -1763,6 +1764,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> & errors << QSslError(QSslError::UnspecifiedError); return errors; } + const std::unique_ptr<X509_STORE, decltype(&q_X509_STORE_free)> storeGuard(certStore, q_X509_STORE_free); if (s_loadRootCertsOnDemand) { setDefaultCaCertificates(defaultCaCertificates() + systemCaCertificates()); @@ -1811,7 +1813,6 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> & intermediates = (STACK_OF(X509) *) q_OPENSSL_sk_new_null(); if (!intermediates) { - q_X509_STORE_free(certStore); errors << QSslError(QSslError::UnspecifiedError); return errors; } @@ -1829,14 +1830,12 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> & X509_STORE_CTX *storeContext = q_X509_STORE_CTX_new(); if (!storeContext) { - q_X509_STORE_free(certStore); errors << QSslError(QSslError::UnspecifiedError); return errors; } + std::unique_ptr<X509_STORE_CTX, decltype(&q_X509_STORE_CTX_free)> ctxGuard(storeContext, q_X509_STORE_CTX_free); if (!q_X509_STORE_CTX_init(storeContext, certStore, reinterpret_cast<X509 *>(certificateChain[0].handle()), intermediates)) { - q_X509_STORE_CTX_free(storeContext); - q_X509_STORE_free(certStore); errors << QSslError(QSslError::UnspecifiedError); return errors; } @@ -1845,8 +1844,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> & // We ignore the result of this function since we process errors via the // callback. (void) q_X509_verify_cert(storeContext); - - q_X509_STORE_CTX_free(storeContext); + ctxGuard.reset(); q_OPENSSL_sk_free((OPENSSL_STACK *)intermediates); // Now process the errors @@ -1868,8 +1866,6 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> & for (const auto &error : qAsConst(lastErrors)) errors << _q_OpenSSL_to_QSslError(error.code, certificateChain.value(error.depth)); - q_X509_STORE_free(certStore); - return errors; } -- cgit v1.2.3 From 20891777bb8b295a26e3fb2b9f5b2c59fcff66dd Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Fri, 6 Apr 2018 15:57:49 +1000 Subject: webassembly: enable opengl es3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our WebGL 2 support is half finished, since we use surface format verion of 3 to map to webgl2, but do not enable Open GL ES3 needed for WebGL2 support. This allows glDrawArrays and glDrawElements to be used Change-Id: Ifbd434f4d25e49f671145a6727999a90920d6810 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/gui/configure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index 134a2e0a15..7f4d7cc6af 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1315,7 +1315,7 @@ }, "opengles3": { "label": "OpenGL ES 3.0", - "condition": "features.opengles2 && !features.angle && tests.opengles3 && !config.wasm", + "condition": "features.opengles2 && !features.angle && tests.opengles3", "output": [ "publicFeature", { "type": "define", "name": "QT_OPENGL_ES_3" } -- cgit v1.2.3 From 2a4dd69499cb85695ede86ac7244fe6e1c274834 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Wed, 27 Nov 2019 12:49:37 +0100 Subject: CoreText: Fix getting system fonts on recent macOS/iOS versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We introduced a work-around for iOS 11 which breaks on more recent OS versions because we try to request meta-fonts by name instead of using the special system font descriptors. This would cause warnings on the console and Times New Roman when requesting e.g. the system fixed width font. When testing on iOS 12 without the work-around, we are no longer able to reproduce the original issue, so the assumption is that this problem has been resolved. Since iOS 11 is not a supported target for Qt 5.14 we can remove the work-around entirely. [ChangeLog][macOS/iOS] Fixed a bug where QFontDatabase::systemFont() would return the wrong fonts on macOS 10.15 and iOS 13. Fixes: QTBUG-79900 Change-Id: Ie375c8c2ab877d6d66e3696662c4939f639a6e9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index daa3dc94ea..894919a1c8 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -374,17 +374,6 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>::fontEngine QCFType<CTFontDescriptorRef> descriptor = QCFType<CTFontDescriptorRef>::constructFromGet( static_cast<CTFontDescriptorRef>(usrPtr)); - // CoreText will sometimes invalidate information in font descriptors that refer - // to system fonts in certain function calls or application states. While the descriptor - // looks the same from the outside, some internal plumbing is different, causing the results - // of creating CTFonts from those descriptors unreliable. The work-around for this - // is to copy the attributes of those descriptors each time we make a new CTFont - // from them instead of referring to the original, as that may trigger the CoreText bug. - if (m_systemFontDescriptors.contains(descriptor)) { - QCFType<CFDictionaryRef> attributes = CTFontDescriptorCopyAttributes(descriptor); - descriptor = CTFontDescriptorCreateWithAttributes(attributes); - } - // Since we do not pass in the destination DPI to CoreText when making // the font, we need to pass in a point size which is scaled to include // the DPI. The default DPI for the screen is 72, thus the scale factor -- cgit v1.2.3 From fc5dc8c16a57608ea824a7205f4dd7acc824d82f Mon Sep 17 00:00:00 2001 From: Mitch Curtis <mitch.curtis@qt.io> Date: Mon, 25 Nov 2019 12:48:58 +0100 Subject: Improve QShortcutMap debug output Replace the macro with a logging category so that it's not necessary to patch Qt to get output about e.g. ambiguous shortcuts. Change-Id: I4d365aac5a5c0da8629447d93d3bc90c9c3076c2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/gui/kernel/qshortcutmap.cpp | 81 ++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 0395c1db38..9ed450b031 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -45,6 +45,7 @@ #include "qvector.h" #include "qcoreapplication.h" #include <private/qkeymapper_p.h> +#include <QtCore/qloggingcategory.h> #include <algorithm> @@ -52,8 +53,7 @@ QT_BEGIN_NAMESPACE -// To enable verbose output uncomment below -//#define DEBUG_QSHORTCUTMAP +Q_LOGGING_CATEGORY(lcShortcutMap, "qt.gui.shortcutmap") /* \internal Entry data for QShortcutMap @@ -165,11 +165,9 @@ int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::Short QShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher); const auto it = std::upper_bound(d->sequences.begin(), d->sequences.end(), newEntry); d->sequences.insert(it, newEntry); // Insert sorted -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::addShortcut(" << owner << ", " << key << ", " << context << ") = " << d->currentId; -#endif return d->currentId; } @@ -212,11 +210,9 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key return itemsRemoved; --i; } -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::removeShortcut(" << id << ", " << owner << ", " << key << ") = " << itemsRemoved; -#endif return itemsRemoved; } @@ -250,11 +246,9 @@ int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const return itemsChanged; --i; } -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::setShortcutEnabled(" << enable << ", " << id << ", " << owner << ", " << key << ") = " << itemsChanged; -#endif return itemsChanged; } @@ -288,11 +282,9 @@ int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const Q return itemsChanged; --i; } -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::setShortcutAutoRepeat(" << on << ", " << id << ", " << owner << ", " << key << ") = " << itemsChanged; -#endif return itemsChanged; } @@ -395,9 +387,7 @@ QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e) clearSequence(d->currentSequences); d->currentState = result; -#if defined(DEBUG_QSHORTCUTMAP) - qDebug().nospace() << "QShortcutMap::nextState(" << e << ") = " << result; -#endif + qCDebug(lcShortcutMap).nospace() << "QShortcutMap::nextState(" << e << ") = " << result; return result; } @@ -436,9 +426,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier return QKeySequence::NoMatch; createNewSequences(e, d->newEntries, ignoredModifiers); -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Possible shortcut key sequences:" << d->newEntries; -#endif + qCDebug(lcShortcutMap) << "Possible shortcut key sequences:" << d->newEntries; // Should never happen if (d->newEntries == d->currentSequences) { @@ -491,15 +479,11 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier // previous list. If this match is equal or better than the last match, append to the list if (oneKSResult > result) { okEntries.clear(); -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Found better match (" << d->newEntries << "), clearing key sequence list"; -#endif + qCDebug(lcShortcutMap) << "Found better match (" << d->newEntries << "), clearing key sequence list"; } if (oneKSResult && oneKSResult >= result) { okEntries << d->newEntries.at(i); -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Added ok key sequence" << d->newEntries; -#endif + qCDebug(lcShortcutMap) << "Added ok key sequence" << d->newEntries; } } @@ -515,9 +499,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier } if (result != QKeySequence::NoMatch) d->currentSequences = okEntries; -#if defined(DEBUG_QSHORTCUTMAP) - qDebug() << "Returning shortcut match == " << result; -#endif + qCDebug(lcShortcutMap) << "Returning shortcut match == " << result; return QKeySequence::SequenceMatch(result); } @@ -540,19 +522,16 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl, { Q_D(QShortcutMap); QList<int> possibleKeys = QKeyMapper::possibleKeys(e); -#if defined(DEBUG_QSHORTCUTMAP) - { - QDebug debug = qDebug().nospace(); - debug << __FUNCTION__ << '(' << e << ", ignoredModifiers=" + if (lcShortcutMap().isDebugEnabled()) { + qCDebug(lcShortcutMap).nospace() << __FUNCTION__ << '(' << e << ", ignoredModifiers=" << Qt::KeyboardModifiers(ignoredModifiers) << "), possibleKeys=("; for (int i = 0, size = possibleKeys.size(); i < size; ++i) { if (i) - debug << ", "; - debug << QKeySequence(possibleKeys.at(i)); + qCDebug(lcShortcutMap).nospace() << ", "; + qCDebug(lcShortcutMap).nospace() << QKeySequence(possibleKeys.at(i)); } - debug << ')'; + qCDebug(lcShortcutMap).nospace() << ')'; } -#endif // DEBUG_QSHORTCUTMAP int pkTotal = possibleKeys.count(); if (!pkTotal) return; @@ -661,16 +640,13 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) // Find next const QShortcutEntry *current = 0, *next = 0; int i = 0, enabledShortcuts = 0; -#if defined(DEBUG_QSHORTCUTMAP) QVector<const QShortcutEntry*> ambiguousShortcuts; -#endif while(i < d->identicals.size()) { current = d->identicals.at(i); if (current->enabled || !next){ ++enabledShortcuts; -#if defined(DEBUG_QSHORTCUTMAP) - ambiguousShortcuts.append(current); -#endif + if (lcShortcutMap().isDebugEnabled()) + ambiguousShortcuts.append(current); if (enabledShortcuts > d->ambigCount + 1) break; next = current; @@ -683,19 +659,18 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) if (!next || (e->isAutoRepeat() && !next->autorepeat)) return; // Dispatch next enabled -#if defined(DEBUG_QSHORTCUTMAP) - if (ambiguousShortcuts.size() > 1) { - qDebug() << "The following shortcuts are about to be activated ambiguously:"; - for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts)) { - qDebug().nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")"; + if (lcShortcutMap().isDebugEnabled()) { + if (ambiguousShortcuts.size() > 1) { + qCDebug(lcShortcutMap) << "The following shortcuts are about to be activated ambiguously:"; + for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts)) + qCDebug(lcShortcutMap).nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")"; } - } - qDebug().nospace() - << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\"" - << next->keyseq.toString() << "\", " << next->id << ", " - << (bool)(enabledShortcuts>1) << ") to object(" << next->owner << ')'; -#endif + qCDebug(lcShortcutMap).nospace() + << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\"" + << next->keyseq.toString() << "\", " << next->id << ", " + << static_cast<bool>(enabledShortcuts>1) << ") to object(" << next->owner << ')'; + } QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1); QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se); } -- cgit v1.2.3 From 1a1718b3422291ffecdc0f882a9a6255b039d357 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 26 Nov 2019 15:52:17 +0100 Subject: Add missing docs for UCD additions at 5.15 Also remove two stray commas pointed out in code-review and some others noticed on checking for similar. This amends commit c3eb521a0f10112df6b61d2592351c4eef2e1f9b. Change-Id: If20c5146b740defe8d25ff61d399031b5c66ded1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/text/qchar.cpp | 14 ++++++++++++++ src/corelib/text/qchar.h | 2 +- src/corelib/text/qunicodetables_p.h | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 120a82f9ae..847b4f0b08 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -189,6 +189,9 @@ QT_BEGIN_NAMESPACE \value Unicode_8_0 Version 8.0 Since Qt 5.6 \value Unicode_9_0 Version 9.0 Since Qt 5.11 \value Unicode_10_0 Version 10.0 Since Qt 5.11 + \value Unicode_11_0 Version 11.0 Since Qt 5.15 + \value Unicode_12_0 Version 12.0 Since Qt 5.15 + \value Unicode_12_1 Version 12.1 Since Qt 5.15 \value Unicode_Unassigned The value is not assigned to any character in version 8.0 of Unicode. @@ -317,9 +320,11 @@ QT_BEGIN_NAMESPACE \value Script_Cyrillic \value Script_Deseret \value Script_Devanagari + \value Script_Dogra Since Qt 5.15 \value Script_Duployan Since Qt 5.5 \value Script_EgyptianHieroglyphs \value Script_Elbasan Since Qt 5.5 + \value Script_Elymaic Since Qt 5.15 \value Script_Ethiopic \value Script_Georgian \value Script_Glagolitic @@ -327,9 +332,11 @@ QT_BEGIN_NAMESPACE \value Script_Grantha Since Qt 5.5 \value Script_Greek \value Script_Gujarati + \value Script_GunjalaGondi Since Qt 5.15 \value Script_Gurmukhi \value Script_Han \value Script_Hangul + \value Script_HanifiRohingya Since Qt 5.15 \value Script_Hanunoo \value Script_Hatran Since Qt 5.6 \value Script_Hebrew @@ -356,11 +363,13 @@ QT_BEGIN_NAMESPACE \value Script_Lycian \value Script_Lydian \value Script_Mahajani Since Qt 5.5 + \value Script_Makasar Since Qt 5.15 \value Script_Malayalam \value Script_Mandaic \value Script_Manichaean Since Qt 5.5 \value Script_Marchen Since Qt 5.11 \value Script_MasaramGondi Since Qt 5.11 + \value Script_Medefaidrin Since Qt 5.15 \value Script_MeeteiMayek \value Script_MendeKikakui Since Qt 5.5 \value Script_MeroiticCursive @@ -372,10 +381,12 @@ QT_BEGIN_NAMESPACE \value Script_Multani Since Qt 5.6 \value Script_Myanmar \value Script_Nabataean Since Qt 5.5 + \value Script_Nandinagari Since Qt 5.15 \value Script_Newa Since Qt 5.11 \value Script_NewTaiLue \value Script_Nko \value Script_Nushu Since Qt 5.11 + \value Script_NyiakengPuachueHmong Since Qt 5.15 \value Script_Ogham \value Script_OlChiki \value Script_OldHungarian Since Qt 5.6 @@ -383,6 +394,7 @@ QT_BEGIN_NAMESPACE \value Script_OldNorthArabian Since Qt 5.5 \value Script_OldPermic Since Qt 5.5 \value Script_OldPersian + \value Script_OldSogdian Since Qt 5.15 \value Script_OldSouthArabian \value Script_OldTurkic \value Script_Oriya @@ -403,6 +415,7 @@ QT_BEGIN_NAMESPACE \value Script_Siddham Since Qt 5.5 \value Script_SignWriting Since Qt 5.6 \value Script_Sinhala + \value Script_Sogdian Since Qt 5.15 \value Script_SoraSompeng \value Script_Soyombo Since Qt 5.11 \value Script_Sundaneseo @@ -424,6 +437,7 @@ QT_BEGIN_NAMESPACE \value Script_Tirhuta Since Qt 5.5 \value Script_Ugaritic \value Script_Vai + \value Script_Wancho Since Qt 5.15 \value Script_WarangCiti Since Qt 5.5 \value Script_Yi \value Script_ZanabazarSquare Since Qt 5.11 diff --git a/src/corelib/text/qchar.h b/src/corelib/text/qchar.h index 85a380e7cf..a3d5d7a65e 100644 --- a/src/corelib/text/qchar.h +++ b/src/corelib/text/qchar.h @@ -437,7 +437,7 @@ public: Unicode_10_0, Unicode_11_0, Unicode_12_0, - Unicode_12_1, + Unicode_12_1 }; // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO diff --git a/src/corelib/text/qunicodetables_p.h b/src/corelib/text/qunicodetables_p.h index 79878a859f..49a28000e0 100644 --- a/src/corelib/text/qunicodetables_p.h +++ b/src/corelib/text/qunicodetables_p.h @@ -122,7 +122,7 @@ enum GraphemeBreakClass { Graphemebreak_E_Modifier, Graphemebreak_Glue_After_Zwj, Graphemebreak_E_Base_GAZ, - NumGraphemeBreakClasses, + NumGraphemeBreakClasses }; enum WordBreakClass { @@ -149,7 +149,7 @@ enum WordBreakClass { WordBreak_Glue_After_Zwj, WordBreak_E_Base_GAZ, WordBreak_WSegSpace, - NumWordBreakClasses, + NumWordBreakClasses }; enum SentenceBreakClass { -- cgit v1.2.3 From 65ea4948dc36af2dd9b8beb1263a0e6ccebd79d2 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Wed, 27 Nov 2019 14:40:33 +0100 Subject: Unicode tables: minor prettification Put blank lines before the final Num*Classes entries in enums, to set them off visibly from the "real" members. Moved some oddly placed commas to the ends of preceding lines, so that later additions can just add lines (with comma on end) without having to modify the preceding line while doing so. Change-Id: I5188dc25af9e4c17a1882fd9dab070e88013060b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qunicodetables_p.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/text/qunicodetables_p.h b/src/corelib/text/qunicodetables_p.h index 49a28000e0..81efc09773 100644 --- a/src/corelib/text/qunicodetables_p.h +++ b/src/corelib/text/qunicodetables_p.h @@ -122,6 +122,7 @@ enum GraphemeBreakClass { Graphemebreak_E_Modifier, Graphemebreak_Glue_After_Zwj, Graphemebreak_E_Base_GAZ, + NumGraphemeBreakClasses }; @@ -149,6 +150,7 @@ enum WordBreakClass { WordBreak_Glue_After_Zwj, WordBreak_E_Base_GAZ, WordBreak_WSegSpace, + NumWordBreakClasses }; @@ -167,6 +169,7 @@ enum SentenceBreakClass { SentenceBreak_SContinue, SentenceBreak_STerm, SentenceBreak_Close, + NumSentenceBreakClasses }; @@ -182,6 +185,7 @@ enum LineBreakClass { LineBreak_EB, LineBreak_EM, LineBreak_ZWJ, LineBreak_SA, LineBreak_SG, LineBreak_SP, LineBreak_CR, LineBreak_LF, LineBreak_BK, + NumLineBreakClasses }; -- cgit v1.2.3 From 0c4e502b56dd59e8504f4636797a7ba62fb51d83 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 28 Nov 2019 11:03:06 +0100 Subject: androidtestrunner: Fix warnings about missing parameter to QStringLiteral Use QString instead, fixing: src\tools\androidtestrunner\main.cpp(474): warning C4003: not enough arguments for function-like macro invocation 'QStringLiteral' Change-Id: I88b8c0f1dfa7828460e8952510e3d4150ab68896 Reviewed-by: BogDan Vatra <bogdan@kdab.com> --- src/tools/androidtestrunner/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp index 1046c7b7ef..5471db3afd 100644 --- a/src/tools/androidtestrunner/main.cpp +++ b/src/tools/androidtestrunner/main.cpp @@ -460,7 +460,7 @@ int main(int argc, char *argv[]) } // Run androiddeployqt - static auto verbose = g_options.verbose ? QStringLiteral("--verbose") : QStringLiteral(); + static auto verbose = g_options.verbose ? QStringLiteral("--verbose") : QString(); if (!execCommand(QStringLiteral("%1 %3 --reinstall --output %2 --apk %4").arg(g_options.androidDeployQtCommand, g_options.buildPath, verbose, -- cgit v1.2.3 From 512c1febbd9d5b8af767b2604d6ee97f1fdee4d9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 28 Nov 2019 12:25:40 +0100 Subject: QtWidgets/Windows: Simplify .pro files Remove the include path for wintab which is no longer needed in Qt 5 (the code is in the QPA plugin). Remove the inclusion of win.pri for the Windows vista styles plugin and specify the theme library directly. This should result in simpler CMakeList.txt files. Change-Id: I736db5c965982cdf79a234a94fc723f0556c1717 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> --- src/plugins/styles/windowsvista/windowsvista.pro | 4 +--- src/widgets/kernel/win.pri | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/windowsvista/windowsvista.pro b/src/plugins/styles/windowsvista/windowsvista.pro index c08db7f533..483914c13d 100644 --- a/src/plugins/styles/windowsvista/windowsvista.pro +++ b/src/plugins/styles/windowsvista/windowsvista.pro @@ -11,9 +11,7 @@ HEADERS += qwindowsxpstyle_p.h qwindowsxpstyle_p_p.h SOURCES += qwindowsxpstyle.cpp QMAKE_USE_PRIVATE += user32 gdi32 - -# DEFINES/LIBS needed for qwizard_win.cpp and the styles -include(../../../widgets/kernel/win.pri) +LIBS_PRIVATE *= -luxtheme DISTFILES += windowsvistastyle.json diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri index 3b3170beb1..eede987b4c 100644 --- a/src/widgets/kernel/win.pri +++ b/src/widgets/kernel/win.pri @@ -1,7 +1,6 @@ # Qt/Windows only configuration file # -------------------------------------------------------------------- -INCLUDEPATH += ../3rdparty/wintab !winrt { LIBS_PRIVATE *= -luxtheme -ldwmapi QMAKE_USE_PRIVATE += shell32 -- cgit v1.2.3 From c33916a279ef5908e1ebd44644c873933f6a7c77 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann <joerg.bornemann@qt.io> Date: Thu, 28 Nov 2019 13:38:28 +0100 Subject: Fix prefix determination for windeployqt'ed MinGW applications We hard-coded the assumption the import lib naming scheme is always basename + ".lib" which is wrong for MinGW. This amends commit a131d610. Fixes: QTBUG-80366 Change-Id: Ibefb8a54483cc62743b8783530644b03e720262c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/global/qlibraryinfo.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 8c3ed184ae..f0f77fe68e 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -574,11 +574,19 @@ static QString getRelocatablePrefix() const QString libdir = QString::fromLatin1( qt_configure_strs + qt_configure_str_offsets[QLibraryInfo::LibrariesPath - 1]); const QLatin1Char slash('/'); - const QString qtCoreImpLibPath - = qtCoreDirPath +#if defined(Q_CC_MINGW) + const QString implibPrefix = QStringLiteral("lib"); + const QString implibSuffix = QStringLiteral(".a"); +#else + const QString implibPrefix; + const QString implibSuffix = QStringLiteral(".lib"); +#endif + const QString qtCoreImpLibFileName = implibPrefix + + QFileInfo(qtCoreFilePath).completeBaseName() + implibSuffix; + const QString qtCoreImpLibPath = qtCoreDirPath + slash + QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH) + slash + libdir - + slash + QFileInfo(qtCoreFilePath).completeBaseName() + QLatin1String(".lib"); + + slash + qtCoreImpLibFileName; if (!QFileInfo::exists(qtCoreImpLibPath)) { // We did not find a corresponding import library and conclude that this is a // windeployqt'ed executable. -- cgit v1.2.3 From cfd2f3c46eaefcaa8795a777d5e01fa85dd850a8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 26 Nov 2019 13:44:30 +0100 Subject: Work around macOS's inconsistency in naming of India's time-zone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS fails to create a zone for the name its own systemTimeZone claims to have (see new comment). So make sure we do consistently recognize the name systemTimeZoneId() returns, using systemTimeZone from which we got its name. Add minimal testing of system time-zone. Fixes: QTBUG-80173 Change-Id: I42f21efbd7c439158fee954d555414bb180e7f8f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/corelib/time/qtimezoneprivate_mac.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate_mac.mm b/src/corelib/time/qtimezoneprivate_mac.mm index d3c4fbe5da..4509e316f9 100644 --- a/src/corelib/time/qtimezoneprivate_mac.mm +++ b/src/corelib/time/qtimezoneprivate_mac.mm @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2013 John Layt <jlayt@kde.org> ** Contact: https://www.qt.io/licensing/ ** @@ -94,6 +95,16 @@ void QMacTimeZonePrivate::init(const QByteArray &ianaId) if (m_nstz) m_id = ianaId; } + if (!m_nstz) { + // macOS has been seen returning a systemTimeZone which reports its name + // as Asia/Kolkata, which doesn't appear in knownTimeZoneNames (which + // calls the zone Asia/Calcutta). So explicitly check for the name + // systemTimeZoneId() returns, and use systemTimeZone if we get it: + m_nstz = [NSTimeZone.systemTimeZone retain]; + Q_ASSERT(m_nstz); + if (QString::fromNSString(m_nstz.name).toUtf8() == ianaId) + m_id = ianaId; + } } QString QMacTimeZonePrivate::comment() const -- cgit v1.2.3 From ee3e0ed751e8acdd5f1cefb430b0981c21f71f8e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Mon, 25 Nov 2019 11:15:22 +0100 Subject: rhi: gl: Fix ms renderbuffer on WASM with WebGL2 Unlike renderbufferStorage, renderbufferStorageMultisample is not guaranteed to accept the unsized GL_DEPTH_STENCIL internalformat. For the former, WebGL 2 guarantees it for compatibility for WebGL 1, but the multisample version does not exist in WebGL 1, so from the specs it is not given at all that the unsized format would be accepted. So use the ES 3.0 sized format instead, like we would on a "real" ES 3.0 implementation. Fixes: QTBUG-80296 Change-Id: I822ae382097085c0a3279c16bb69a173dbf15093 Reviewed-by: Andy Nichols <andy.nichols@qt.io> --- src/gui/rhi/qrhigles2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index abee843a74..b394354787 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3147,8 +3147,7 @@ bool QGles2RenderBuffer::build() switch (m_type) { case QRhiRenderBuffer::DepthStencil: if (rhiD->caps.msaaRenderBuffer && samples > 1) { - const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8; - rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, storage, + rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, size.width(), size.height()); stencilRenderbuffer = 0; } else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) { -- cgit v1.2.3 From cd200ad7aef1884a5c36528d5c3933c46c86510f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Wed, 13 Nov 2019 10:37:36 +0100 Subject: QSsl - delete all mentions of SslV2 and SslV3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, change the notion of 'unsupported protocol' for QSslSocket, previously it was SslV2 and SslV3, now instead it's all versions of DTLS and UnknownProtocol: - makes no sense at all to connect using TCP socket and then suddenly start using DTLS_client/server_method - UnknownProtocol is not to be set in a configuration, unknown means that some ciphersuite's protocol version cannot be established. - 'disabledProtocols' auto-test becomes 'unsupportedProtocols' and tests that QSslSocket fails to start encryption if the protocol version is wrong. Handling these enumerators (SslV2 and SslV2) as errors not needed anymore. Removed from QSslContext and our existing backends (qsslsocket_whatever). TlsV1SslV3 enumerator is not making any sense at all (previously was [SSL v3, TLS 1.0], then became "the same as TLS v. 1.0", but now this name is very confusing. Removed. Task-number: QTBUG-75638 Task-number: QTBUG-76501 Change-Id: I2781ba1c3051a7791b476266d4561d956948974a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/network/ssl/qssl.cpp | 3 -- src/network/ssl/qssl.h | 10 ------ src/network/ssl/qsslcontext_openssl.cpp | 58 ++++++++++++--------------------- src/network/ssl/qsslsocket.cpp | 17 ++++++++-- src/network/ssl/qsslsocket_mac.cpp | 54 ++---------------------------- src/network/ssl/qsslsocket_openssl.cpp | 44 ++++++++++--------------- src/network/ssl/qsslsocket_schannel.cpp | 6 ---- src/network/ssl/qsslsocket_winrt.cpp | 6 ---- 8 files changed, 54 insertions(+), 144 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp index c9fa7f85d9..bfbe8eb90f 100644 --- a/src/network/ssl/qssl.cpp +++ b/src/network/ssl/qssl.cpp @@ -120,8 +120,6 @@ Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl"); Describes the protocol of the cipher. - \value SslV3 SSLv3; not supported by QSslSocket. - \value SslV2 SSLv2; not supported by QSslSocket. \value TlsV1_0 TLSv1.0 \value TlsV1_0OrLater TLSv1.0 and later versions. This option is not available when using the WinRT backend due to platform limitations. \value TlsV1 Obsolete, means the same as TlsV1_0 @@ -137,7 +135,6 @@ Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl"); \value TlsV1_3OrLater TLSv1.3 and later versions. (Since Qt 5.12) \value UnknownProtocol The cipher's protocol cannot be determined. \value AnyProtocol Any supported protocol. This value is used by QSslSocket only. - \value TlsV1SslV3 Same as TlsV1_0. \value SecureProtocols The default option, using protocols known to be secure. */ diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h index b28c2a87b9..1fd2cf9c6d 100644 --- a/src/network/ssl/qssl.h +++ b/src/network/ssl/qssl.h @@ -77,20 +77,10 @@ namespace QSsl { #endif enum SslProtocol { -#if QT_DEPRECATED_SINCE(5, 15) - SslV3, - SslV2, -#endif TlsV1_0 = 2, -#if QT_DEPRECATED_SINCE(5,0) - TlsV1 = TlsV1_0, -#endif TlsV1_1, TlsV1_2, AnyProtocol, -#if QT_DEPRECATED_SINCE(5, 15) - TlsV1SslV3, -#endif SecureProtocols = AnyProtocol + 2, TlsV1_0OrLater, diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index 562aa4f518..ad2edce510 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -286,42 +286,31 @@ void QSslContext::initSslContext(QSslContext *sslContext, QSslSocket::SslMode mo bool unsupportedProtocol = false; bool isDtls = false; init_context: - if (sslContext->sslConfiguration.protocol() == QSsl::SslV2) { - // SSL 2 is no longer supported, but chosen deliberately -> error - sslContext->ctx = nullptr; - unsupportedProtocol = true; - } else if (sslContext->sslConfiguration.protocol() == QSsl::SslV3) { - // SSL 3 is no longer supported, but chosen deliberately -> error - sslContext->ctx = nullptr; - unsupportedProtocol = true; - } else { - switch (sslContext->sslConfiguration.protocol()) { - case QSsl::DtlsV1_0: - case QSsl::DtlsV1_0OrLater: - case QSsl::DtlsV1_2: - case QSsl::DtlsV1_2OrLater: + switch (sslContext->sslConfiguration.protocol()) { + case QSsl::DtlsV1_0: + case QSsl::DtlsV1_0OrLater: + case QSsl::DtlsV1_2: + case QSsl::DtlsV1_2OrLater: #if QT_CONFIG(dtls) - isDtls = true; - sslContext->ctx = q_SSL_CTX_new(client ? q_DTLS_client_method() : q_DTLS_server_method()); + isDtls = true; + sslContext->ctx = q_SSL_CTX_new(client ? q_DTLS_client_method() : q_DTLS_server_method()); #else // dtls - sslContext->ctx = nullptr; - unsupportedProtocol = true; - qCWarning(lcSsl, "DTLS protocol requested, but feature 'dtls' is disabled"); - + sslContext->ctx = nullptr; + unsupportedProtocol = true; + qCWarning(lcSsl, "DTLS protocol requested, but feature 'dtls' is disabled"); #endif // dtls - break; - case QSsl::TlsV1_3: - case QSsl::TlsV1_3OrLater: + break; + case QSsl::TlsV1_3: + case QSsl::TlsV1_3OrLater: #if !defined(TLS1_3_VERSION) - qCWarning(lcSsl, "TLS 1.3 is not supported"); - sslContext->ctx = nullptr; - unsupportedProtocol = true; - break; + qCWarning(lcSsl, "TLS 1.3 is not supported"); + sslContext->ctx = nullptr; + unsupportedProtocol = true; + break; #endif // TLS1_3_VERSION - default: - // The ssl options will actually control the supported methods - sslContext->ctx = q_SSL_CTX_new(client ? q_TLS_client_method() : q_TLS_server_method()); - } + default: + // The ssl options will actually control the supported methods + sslContext->ctx = q_SSL_CTX_new(client ? q_TLS_client_method() : q_TLS_server_method()); } if (!sslContext->ctx) { @@ -373,7 +362,6 @@ init_context: #endif // TLS1_3_VERSION break; // Ranges: - case QSsl::TlsV1SslV3: case QSsl::AnyProtocol: case QSsl::SecureProtocols: case QSsl::TlsV1_0OrLater: @@ -415,12 +403,6 @@ init_context: Q_UNREACHABLE(); break; #endif // TLS1_3_VERSION - case QSsl::SslV2: - case QSsl::SslV3: - // These protocols are not supported, and we handle - // them as an error (see the code above). - Q_UNREACHABLE(); - break; case QSsl::UnknownProtocol: break; } diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 690251727d..86937fc6c1 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2217,13 +2217,24 @@ void QSslSocketPrivate::init() */ bool QSslSocketPrivate::verifyProtocolSupported(const char *where) { - if (configuration.protocol == QSsl::SslV2 || configuration.protocol == QSsl::SslV3) { - qCWarning(lcSsl) << where << "Attempted to use an unsupported protocol."; + QLatin1String protocolName("DTLS"); + switch (configuration.protocol) { + case QSsl::UnknownProtocol: + // UnknownProtocol, according to our docs, is for cipher whose protocol is unknown. + // Should not be used when configuring QSslSocket. + protocolName = QLatin1String("UnknownProtocol"); + Q_FALLTHROUGH(); + case QSsl::DtlsV1_0: + case QSsl::DtlsV1_2: + case QSsl::DtlsV1_0OrLater: + case QSsl::DtlsV1_2OrLater: + qCWarning(lcSsl) << where << "QSslConfiguration with unexpected protocol" << protocolName; setErrorAndEmit(QAbstractSocket::SslInvalidUserDataError, QSslSocket::tr("Attempted to use an unsupported protocol.")); return false; + default: + return true; } - return true; } /*! diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index e0e065679d..fe1c43d992 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -496,10 +496,6 @@ QSsl::SslProtocol QSslSocketBackendPrivate::sessionProtocol() const } switch (protocol) { - case kSSLProtocol2: - return QSsl::SslV2; - case kSSLProtocol3: - return QSsl::SslV3; case kTLSProtocol1: return QSsl::TlsV1_0; case kTLSProtocol11: @@ -657,23 +653,6 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui QSslCipher ciph; switch (cipher) { // Sorted as in CipherSuite.h (and groupped by their RFC) - case SSL_RSA_WITH_NULL_MD5: - ciph.d->name = QLatin1String("NULL-MD5"); - ciph.d->protocol = QSsl::SslV3; - break; - case SSL_RSA_WITH_NULL_SHA: - ciph.d->name = QLatin1String("NULL-SHA"); - ciph.d->protocol = QSsl::SslV3; - break; - case SSL_RSA_WITH_RC4_128_MD5: - ciph.d->name = QLatin1String("RC4-MD5"); - ciph.d->protocol = QSsl::SslV3; - break; - case SSL_RSA_WITH_RC4_128_SHA: - ciph.d->name = QLatin1String("RC4-SHA"); - ciph.d->protocol = QSsl::SslV3; - break; - // TLS addenda using AES, per RFC 3268 case TLS_RSA_WITH_AES_128_CBC_SHA: ciph.d->name = QLatin1String("AES128-SHA"); @@ -822,12 +801,8 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui ciph.d->isNull = false; // protocol - if (ciph.d->protocol == QSsl::SslV3) { - ciph.d->protocolString = QLatin1String("SSLv3"); - } else { - ciph.d->protocol = QSsl::TlsV1_2; - ciph.d->protocolString = QLatin1String("TLSv1.2"); - } + ciph.d->protocol = QSsl::TlsV1_2; + ciph.d->protocolString = QLatin1String("TLSv1.2"); const auto bits = ciph.d->name.splitRef(QLatin1Char('-')); if (bits.size() >= 2) { @@ -1106,22 +1081,6 @@ bool QSslSocketBackendPrivate::setSessionProtocol() { Q_ASSERT_X(context, Q_FUNC_INFO, "invalid SSL context (null)"); - // QSsl::SslV2 == kSSLProtocol2 is disabled in Secure Transport and - // always fails with errSSLIllegalParam: - // if (version < MINIMUM_STREAM_VERSION || version > MAXIMUM_STREAM_VERSION) - // return errSSLIllegalParam; - // where MINIMUM_STREAM_VERSION is SSL_Version_3_0, MAXIMUM_STREAM_VERSION is TLS_Version_1_2. - if (configuration.protocol == QSsl::SslV2) { - qCDebug(lcSsl) << "protocol QSsl::SslV2 is disabled"; - return false; - } - - // SslV3 is unsupported. - if (configuration.protocol == QSsl::SslV3) { - qCDebug(lcSsl) << "protocol QSsl::SslV3 is disabled"; - return false; - } - // SecureTransport has kTLSProtocol13 constant and also, kTLSProtocolMaxSupported. // Calling SSLSetProtocolVersionMax/Min with any of these two constants results // in errInvalidParam and a failure to set the protocol version. This means @@ -1162,13 +1121,6 @@ bool QSslSocketBackendPrivate::setSessionProtocol() qCDebug(lcSsl) << plainSocket << "requesting : any"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol1); - } else if (configuration.protocol == QSsl::TlsV1SslV3) { - #ifdef QSSLSOCKET_DEBUG - qCDebug(lcSsl) << plainSocket << "requesting : SSLv3 - TLSv1.2"; - #endif - err = SSLSetProtocolVersionMin(context, kTLSProtocol1); - if (err == errSecSuccess) - err = SSLSetProtocolVersionMax(context, kTLSProtocol1); } else if (configuration.protocol == QSsl::SecureProtocols) { #ifdef QSSLSOCKET_DEBUG qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; @@ -1213,8 +1165,6 @@ bool QSslSocketBackendPrivate::verifySessionProtocol() const bool protocolOk = false; if (configuration.protocol == QSsl::AnyProtocol) protocolOk = true; - else if (configuration.protocol == QSsl::TlsV1SslV3) - protocolOk = (sessionProtocol() == QSsl::TlsV1_0); else if (configuration.protocol == QSsl::SecureProtocols) protocolOk = (sessionProtocol() >= QSsl::TlsV1_0); else if (configuration.protocol == QSsl::TlsV1_0OrLater) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 8cd0724d83..2a23742bdf 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -249,11 +249,7 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(const SSL_CIPHER QString protoString = descriptionList.at(1).toString(); ciph.d->protocolString = protoString; ciph.d->protocol = QSsl::UnknownProtocol; - if (protoString == QLatin1String("SSLv3")) - ciph.d->protocol = QSsl::SslV3; - else if (protoString == QLatin1String("SSLv2")) - ciph.d->protocol = QSsl::SslV2; - else if (protoString == QLatin1String("TLSv1")) + if (protoString == QLatin1String("TLSv1")) ciph.d->protocol = QSsl::TlsV1_0; else if (protoString == QLatin1String("TLSv1.1")) ciph.d->protocol = QSsl::TlsV1_1; @@ -459,20 +455,23 @@ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers); long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions) { long options; - if (protocol == QSsl::TlsV1SslV3) - options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3; - else if (protocol == QSsl::SecureProtocols) - options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3; - else if (protocol == QSsl::TlsV1_0OrLater) - options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3; - else if (protocol == QSsl::TlsV1_1OrLater) - options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1; - else if (protocol == QSsl::TlsV1_2OrLater) - options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1; - else if (protocol == QSsl::TlsV1_3OrLater) - options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2; - else + switch (protocol) { + case QSsl::SecureProtocols: + case QSsl::TlsV1_0OrLater: + options = SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; + break; + case QSsl::TlsV1_1OrLater: + options = SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1; + break; + case QSsl::TlsV1_2OrLater: + options = SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1; + break; + case QSsl::TlsV1_3OrLater: + options = SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; + break; + default: options = SSL_OP_ALL; + } // This option is disabled by default, so we need to be able to clear it if (sslOptions & QSsl::SslOptionDisableEmptyFragments) @@ -530,10 +529,7 @@ bool QSslSocketBackendPrivate::initSslContext() return false; } - if (configuration.protocol != QSsl::SslV2 && - configuration.protocol != QSsl::SslV3 && - configuration.protocol != QSsl::UnknownProtocol && - mode == QSslSocket::SslClientMode) { + if (configuration.protocol != QSsl::UnknownProtocol && mode == QSslSocket::SslClientMode) { // Set server hostname on TLS extension. RFC4366 section 3.1 requires it in ACE format. QString tlsHostName = verificationPeerName.isEmpty() ? q->peerName() : verificationPeerName; if (tlsHostName.isEmpty()) @@ -1746,10 +1742,6 @@ QSsl::SslProtocol QSslSocketBackendPrivate::sessionProtocol() const int ver = q_SSL_version(ssl); switch (ver) { - case 0x2: - return QSsl::SslV2; - case 0x300: - return QSsl::SslV3; case 0x301: return QSsl::TlsV1_0; case 0x302: diff --git a/src/network/ssl/qsslsocket_schannel.cpp b/src/network/ssl/qsslsocket_schannel.cpp index 31b0db4818..2db5c48ff2 100644 --- a/src/network/ssl/qsslsocket_schannel.cpp +++ b/src/network/ssl/qsslsocket_schannel.cpp @@ -226,12 +226,6 @@ DWORD toSchannelProtocol(QSsl::SslProtocol protocol) protocols = SP_PROT_TLS1_0 | SP_PROT_TLS1_1 | SP_PROT_TLS1_2; // @future Add TLS 1.3 when supported by Windows! break; - case QSsl::SslV2: - case QSsl::SslV3: - return DWORD(-1); // Not supported - case QSsl::TlsV1SslV3: - protocols = SP_PROT_TLS1_0; - break; case QSsl::TlsV1_0: protocols = SP_PROT_TLS1_0; break; diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp index 4286b5ea42..5f5201fc82 100644 --- a/src/network/ssl/qsslsocket_winrt.cpp +++ b/src/network/ssl/qsslsocket_winrt.cpp @@ -230,13 +230,7 @@ void QSslSocketBackendPrivate::startClientEncryption() QSsl::SslProtocol protocol = q->protocol(); switch (q->protocol()) { - case QSsl::SslV2: - case QSsl::SslV3: - setErrorAndEmit(QAbstractSocket::SslInvalidUserDataError, - QStringLiteral("unsupported protocol")); - return; case QSsl::AnyProtocol: - case QSsl::TlsV1SslV3: protectionLevel = SocketProtectionLevel_Tls10; break; case QSsl::TlsV1_0: -- cgit v1.2.3 From 9fd217e7467fa5f82340c30b1b6bb28557057919 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Wed, 27 Nov 2019 12:46:28 +0100 Subject: Silence intel compiler warning about float comparison Add the equivalent intel warning macro in public header where there was already the macro for -Wfloat-equal Change-Id: I8f20400f0b95c8f3857fa7a0a33464c8c34d5c0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qfloat16.h | 1 + src/corelib/tools/qpoint.h | 1 + src/corelib/tools/qrect.h | 1 + src/gui/math3d/qmatrix4x4.h | 1 + src/gui/math3d/qquaternion.h | 1 + src/gui/math3d/qvector2d.h | 1 + src/gui/math3d/qvector3d.h | 1 + src/gui/math3d/qvector4d.h | 1 + src/gui/painting/qtransform.h | 1 + 9 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 9a4f1800a4..02fd2f03cc 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -239,6 +239,7 @@ QF16_MAKE_ARITH_OP_INT(/) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) > static_cast<float>(b); } inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) < static_cast<float>(b); } diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index fe952f95da..f0a91c4ff8 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -352,6 +352,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QPointF &QPointF::operator*=(qreal c) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2) { diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 7aa2312f38..c6bfc1a50d 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -665,6 +665,7 @@ Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) noexcept QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool QRectF::isNull() const noexcept { return w == 0. && h == 0.; } diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 69c3510659..1439bfac59 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -215,6 +215,7 @@ private: QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECLARE_TYPEINFO(QMatrix4x4, Q_MOVABLE_TYPE); inline QMatrix4x4::QMatrix4x4 diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index cd0d746e55..f01fab679e 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -171,6 +171,7 @@ inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpo QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) inline bool QQuaternion::isNull() const { return wp == 0.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f; diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index 88d8bc199e..cbce94c199 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -207,6 +207,7 @@ inline QVector2D &QVector2D::operator/=(const QVector2D &vector) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QVector2D &v1, const QVector2D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1]; diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index 1b49f3e7b9..d7ffb0bcc4 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -232,6 +232,7 @@ inline QVector3D &QVector3D::operator/=(const QVector3D &vector) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QVector3D &v1, const QVector3D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2]; diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 08cb423484..afcc71fa88 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -232,6 +232,7 @@ inline QVector4D &QVector4D::operator/=(const QVector4D &vector) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) Q_DECL_CONSTEXPR inline bool operator==(const QVector4D &v1, const QVector4D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2] && v1.v[3] == v2.v[3]; diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index b220770144..b2a634dd2a 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -303,6 +303,7 @@ inline qreal QTransform::dy() const QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wfloat-equal") QT_WARNING_DISABLE_GCC("-Wfloat-equal") +QT_WARNING_DISABLE_INTEL(1572) inline QTransform &QTransform::operator*=(qreal num) { -- cgit v1.2.3 From 5b1a4578f545d5181265d9120b48bc92753b63b9 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud <fredrik.orderud@ge.com> Date: Wed, 27 Nov 2019 20:27:19 +0100 Subject: wasm: Disable TextureSwizzle The WebGL 2.0 specification explicitly does not support texture swizzles. Therefore, disabling it when targeting WASM. This fixes "WebGL: INVALID_ENUM: texParameter: invalid parameter name" when running in Chrome or Firefox. Change-Id: Ic7e22e0f623095245274924095cb63fd0ff7e8c2 Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19 Fixes: QTBUG-80287 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/opengl/qopenglfunctions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 8ec814296a..bc3a4f7c1d 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -388,8 +388,12 @@ static int qt_gl_resolve_extensions() | QOpenGLExtensions::MapBufferRange | QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferMultisample - | QOpenGLExtensions::Sized8Formats - | QOpenGLExtensions::TextureSwizzle; + | QOpenGLExtensions::Sized8Formats; +#ifndef Q_OS_WASM + // WebGL 2.0 specification explicitly does not support texture swizzles + // https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19 + extensions |= QOpenGLExtensions::TextureSwizzle; +#endif } else { // Recognize features by extension name. if (extensionMatcher.match("GL_OES_packed_depth_stencil")) -- cgit v1.2.3 From 02fb4e8f0da24aee81820adb283bb9a1bb8f0688 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 28 Nov 2019 15:51:09 +0100 Subject: Windows: Remove configure test for theme library uxtheme The library should be present on all supported platforms. Change-Id: Ib1d55a1a296b4f70978e71d5fda9fa6def6c3930 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> --- src/widgets/configure.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src') diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 0a68f082a2..cab120098a 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -26,14 +26,6 @@ } }, - "tests": { - "uxtheme": { - "label": "uxtheme.h", - "type": "files", - "files": [ "uxtheme.h" ] - } - }, - "features": { "gtk3": { "label": "GTK+", @@ -56,7 +48,7 @@ }, "style-windowsvista": { "label": "WindowsVista", - "condition": "features.style-windows && features.animation && config.win32 && !config.winrt && tests.uxtheme", + "condition": "features.style-windows && features.animation && config.win32 && !config.winrt", "output": [ "privateFeature", "styles" ] }, "style-android": { -- cgit v1.2.3 From 9feb20e58128ae7e8d208847ce989b65cdfcf5bc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Mon, 4 Nov 2019 16:37:11 +0100 Subject: Remove convert_ARGB_PM_to_ARGB It was only used by conversions to indexed8 and mono, and is slower than the generic conversion which is optimized. Change-Id: I0480c5a1b5fa2de7e3c87fd621064dace46e5945 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/image/qimage_conversions.cpp | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 7cd71644a3..8f33a13b95 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -851,30 +851,6 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver return true; } -static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src) -{ - Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied); - Q_ASSERT(dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_RGBA8888); - Q_ASSERT(src->width == dest->width); - Q_ASSERT(src->height == dest->height); - - const int src_pad = (src->bytes_per_line >> 2) - src->width; - const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; - const QRgb *src_data = (QRgb *) src->data; - QRgb *dest_data = (QRgb *) dest->data; - - for (int i = 0; i < src->height; ++i) { - const QRgb *end = src_data + src->width; - while (src_data < end) { - *dest_data = qUnpremultiply(*src_data); - ++src_data; - ++dest_data; - } - src_data += src_pad; - dest_data += dest_pad; - } -} - static void convert_RGBA_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) { Q_ASSERT(src->format == QImage::Format_RGBA8888 || src->format == QImage::Format_RGBX8888); @@ -1541,7 +1517,7 @@ static void convert_X_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageC static void convert_ARGB_PM_to_Mono(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) { QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); - convert_ARGB_PM_to_ARGB(tmp.data(), src); + convert_generic(tmp.data(), src, Qt::AutoColor); dither_to_Mono(dst, tmp.data(), flags, false); } @@ -1821,7 +1797,7 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt:: static void convert_ARGB_PM_to_Indexed8(QImageData *dst, const QImageData *src, Qt::ImageConversionFlags flags) { QScopedPointer<QImageData> tmp(QImageData::create(QSize(src->width, src->height), QImage::Format_ARGB32)); - convert_ARGB_PM_to_ARGB(tmp.data(), src); + convert_generic(tmp.data(), src, Qt::AutoColor); convert_RGB_to_Indexed8(dst, tmp.data(), flags); } -- cgit v1.2.3 From 985f4910249a0308b746695e64aa1a6205492421 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Mon, 25 Nov 2019 21:30:25 +0100 Subject: QTreeView: Reset the pressed index if the decoration was pressed on We need to reset the pressed index when the decoration was pressed on otherwise if the mouse ends up over an already selected item that was previously clicked on. This prevents it from thinking that the mouse has been released on this item right after pressing on it. Fixes: QTBUG-59067 Change-Id: Iab372ae20db3682ab0812661f86533079ba4083c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/itemviews/qtreeview.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 034c1f4b4f..442369c2ec 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1892,6 +1892,8 @@ void QTreeView::mousePressEvent(QMouseEvent *event) handled = d->expandOrCollapseItemAtPos(event->pos()); if (!handled && d->itemDecorationAt(event->pos()) == -1) QAbstractItemView::mousePressEvent(event); + else + d->pressedIndex = QModelIndex(); } /*! -- cgit v1.2.3 From cc5c47d85f106356e290a95f2cca2c38b1b3c42d Mon Sep 17 00:00:00 2001 From: Peter Varga <pvarga@inf.u-szeged.hu> Date: Thu, 21 Nov 2019 16:37:06 +0100 Subject: macOS Accessibility: Fix role for comboboxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise combobox with editable text field won't work. Change-Id: I135c3a63cf8fba66d724e140a5a63828853e154e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/cocoa/qcocoaaccessibility.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index db4ec251ae..106c226adc 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -133,7 +133,7 @@ static void populateRoleMap() roleMap[QAccessible::SpinBox] = NSAccessibilityIncrementorRole; roleMap[QAccessible::Slider] = NSAccessibilitySliderRole; roleMap[QAccessible::ProgressBar] = NSAccessibilityProgressIndicatorRole; - roleMap[QAccessible::ComboBox] = NSAccessibilityPopUpButtonRole; + roleMap[QAccessible::ComboBox] = NSAccessibilityComboBoxRole; roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole; roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole; roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole; -- cgit v1.2.3 From f881d00a4f37fcf244be8f93235b9c970aa1a9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Wed, 5 Dec 2018 12:34:52 +0100 Subject: QWindowsFontDatabase: Check preferred family names for all fonts The code was initially introduced in 9204b8c31ea1b5f0c05870c5b5d74c33b1a4f622 but getting the names were conditioned on whether or not Windows identified it as a truetype font. This excluded cases which had preferred names embedded but was not truetype fonts. To fix that we run the code unconditionally. [ChangeLog][Windows] Fixed a bug where some fonts would not be accessible by referencing their typographic name. Fixes: QTBUG-78556 Change-Id: I8823684b09cce3b1b8722b1e609a5bb49b13da13 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- .../fontdatabases/windows/qwindowsfontdatabase.cpp | 22 ++++++++++------------ .../windows/qwindowsfontdatabase_ft.cpp | 20 +++++++++----------- 2 files changed, 19 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index 011476cf13..36a94724c1 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1069,18 +1069,16 @@ static bool addFontToDatabase(QString familyName, QString subFamilyName; QString subFamilyStyle; - if (ttf) { - // Look-up names registered in the font - QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); - if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) - englishName = canonicalNames.name; - if (!canonicalNames.preferredName.isEmpty()) { - subFamilyName = familyName; - subFamilyStyle = styleName; - faceName = familyName; // Remember the original name for later lookups - familyName = canonicalNames.preferredName; - styleName = canonicalNames.preferredStyle; - } + // Look-up names registered in the font + QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); + if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) + englishName = canonicalNames.name; + if (!canonicalNames.preferredName.isEmpty()) { + subFamilyName = familyName; + subFamilyStyle = styleName; + faceName = familyName; // Remember the original name for later lookups + familyName = canonicalNames.preferredName; + styleName = canonicalNames.preferredStyle; } QSupportedWritingSystems writingSystems; diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp index a6b7fcf31e..5c2742d295 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase_ft.cpp @@ -215,17 +215,15 @@ static bool addFontToDatabase(QString familyName, QString subFamilyName; QString subFamilyStyle; - if (ttf) { - // Look-up names registered in the font - QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); - if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) - englishName = canonicalNames.name; - if (!canonicalNames.preferredName.isEmpty()) { - subFamilyName = familyName; - subFamilyStyle = styleName; - familyName = canonicalNames.preferredName; - styleName = canonicalNames.preferredStyle; - } + // Look-up names registered in the font + QFontNames canonicalNames = qt_getCanonicalFontNames(logFont); + if (qt_localizedName(familyName) && !canonicalNames.name.isEmpty()) + englishName = canonicalNames.name; + if (!canonicalNames.preferredName.isEmpty()) { + subFamilyName = familyName; + subFamilyStyle = styleName; + familyName = canonicalNames.preferredName; + styleName = canonicalNames.preferredStyle; } QSupportedWritingSystems writingSystems; -- cgit v1.2.3 From cbb4d500199253f1187ee437a3991b5434c3a0bb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 29 Nov 2019 10:55:03 +0100 Subject: Silence MSVC build of Qt for Python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enclose QAssociativeIterableImpl::advanceImpl within QT_WARNING_DISABLE_DEPRECATED, fixing numerous warnings: MSVC\14.23.28105\include\xutility(727): warning C4996: 'QHash<QString,QVariant>::const_iterator::operator --': was declared deprecated include\QtCore\../../src/corelib/tools/qhash.h(432): note: see declaration of 'QHash<QString,QVariant>::const_iterator::operator --' include\QtCore\../../src/corelib/kernel/qmetatype.h(1217): note: see reference to function template instantiation 'void std::advance<QHash<QString,QVariant>::const_iterator,int>(_InIt &,_Diff)' being compiled with [ _InIt=QHash<QString,QVariant>::const_iterator, _Diff=int ] include\QtCore\../../src/corelib/kernel/qmetatype.h(1253): note: see reference to function template instantiation 'void QtMetaTypePrivate::QAssociativeIterableImpl::advanceImpl<T>(void **,int)' being compiled with [T=QVariantHash] include\QtCore\../../src/corelib/kernel/qvariant.h(793): note: see reference to function template instantiation 'QtMetaTypePrivate::QAssociativeIterableImpl::QAssociativeIterableImpl<QVariantHash>(const T *)' being compiled with[T=QVariantHash] Amends dbb54805f63f9ed68d84fe090d608872f16170d2. Change-Id: Ieb875eaa943100ce1941cb1473b35892330c3889 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/kernel/qmetatype.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index d41f7ee80e..240828bc9a 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1212,9 +1212,12 @@ public: { IteratorOwner<typename T::const_iterator>::assign(iterator, static_cast<const T*>(container)->find(*static_cast<const typename T::key_type*>(p))); } + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED // Hits on the deprecated QHash::iterator::operator--() template<class T> static void advanceImpl(void **p, int step) { std::advance(*static_cast<typename T::const_iterator*>(*p), step); } + QT_WARNING_POP template<class T> static void beginImpl(const void *container, void **iterator) -- cgit v1.2.3 From 0f812db558df072a411ade3305b796d54bccd996 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Fri, 29 Nov 2019 10:43:20 +0100 Subject: rhi: vulkan: Remove unused include QVulkanWindow support has long been removed from the Vulkan backend. The include is a leftover from those times. Change-Id: Ie68ac3611b24310f2b6111a72dd0679adafdc74d Reviewed-by: Johan Helsing <johan.helsing@qt.io> --- src/gui/rhi/qrhivulkan.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 103fea627a..444a395ebc 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -48,7 +48,6 @@ #include <qmath.h> #include <QVulkanFunctions> -#include <QVulkanWindow> QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 6ec5a97ebbf65a9283a57b8e5f4192e7ec84a759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Thu, 28 Nov 2019 17:46:34 +0100 Subject: macOS: Harden screen handling logic when reconfiguring displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When connecting/disconnecting/reconfiguring screens Qt needs to know about the changes before they are propagated by the OS in other ways, so that we can reflect the changes in the list of QScreens as soon as they happen. Unfortunately the canonical notifications for this in AppKit, NSApplicationDidChangeScreenParametersNotification, is delivered after AppKit itself reacts to the change, which results in receiving NSWindowDidChangeScreenNotification, NSWindowWillMoveNotification, and others, while the list of QScreens is stale. To work around this we adopted the lower layer Quartz Display Services API in 3976df2805 to notify us when there are changes to the screen configuration. Unfortunately the window server on macOS is not consistent in how it orders events during screen reconfiguration, and we can't rely on the NSScreen list being up to date when we get our callbacks from Quartz. To work around this we still hook into Quartz, so that we get the callbacks as early as possible, but then track the state of the AppKit NSScreen list and update our own QScreens as soon as we see a change. We now also include sleeping displays in the list of QScreens, which matches the behavior of NSScreen.screens. Similarly we exclude displays that are mirroring another display. Task-number: QTBUG-80193 Change-Id: I6b1958d6ee61373b2861e05a0d971d2300596f3e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/cocoa/qcocoascreen.h | 21 ++- src/plugins/platforms/cocoa/qcocoascreen.mm | 272 +++++++++++++++++++++------- 2 files changed, 225 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h index 7ec9a2b5af..dcf6f1c753 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.h +++ b/src/plugins/platforms/cocoa/qcocoascreen.h @@ -53,9 +53,6 @@ class QCocoaIntegration; class QCocoaScreen : public QPlatformScreen { public: - static void initializeScreens(); - static void cleanupScreens(); - ~QCocoaScreen(); // ---------------------------------------------------- @@ -79,7 +76,6 @@ public: // ---------------------------------------------------- NSScreen *nativeScreen() const; - void updateProperties(); void requestUpdate(); void deliverUpdateRequests(); @@ -88,6 +84,7 @@ public: static QCocoaScreen *primaryScreen(); static QCocoaScreen *get(NSScreen *nsScreen); static QCocoaScreen *get(CGDirectDisplayID displayId); + static QCocoaScreen *get(CFUUIDRef uuid); static CGPoint mapToNative(const QPointF &pos, QCocoaScreen *screen = QCocoaScreen::primaryScreen()); static CGRect mapToNative(const QRectF &rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen()); @@ -95,11 +92,23 @@ public: static QRectF mapFromNative(CGRect rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen()); private: - QCocoaScreen(CGDirectDisplayID displayId); + static void initializeScreens(); + static void updateScreens(); + static void cleanupScreens(); + + static bool updateScreensIfNeeded(); + static NSArray *s_screenConfigurationBeforeUpdate; + static void add(CGDirectDisplayID displayId); + QCocoaScreen(CGDirectDisplayID displayId); + void update(CGDirectDisplayID displayId); void remove(); + bool isOnline() const; + bool isMirroring() const; + CGDirectDisplayID m_displayId = kCGNullDirectDisplay; + CGDirectDisplayID displayId() const { return m_displayId; } QRect m_geometry; QRect m_availableGeometry; @@ -116,6 +125,8 @@ private: dispatch_source_t m_displayLinkSource = nullptr; QAtomicInt m_pendingUpdates; + friend class QCocoaIntegration; + friend class QCocoaWindow; friend QDebug operator<<(QDebug debug, const QCocoaScreen *screen); }; diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index bd5c95b9d0..e4dd4cf6c6 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE namespace CoreGraphics { Q_NAMESPACE enum DisplayChange { + ReconfiguredWithFlagsMissing = 0, Moved = kCGDisplayMovedFlag, SetMain = kCGDisplaySetMainFlag, SetMode = kCGDisplaySetModeFlag, @@ -71,73 +72,165 @@ namespace CoreGraphics { Q_ENUM_NS(DisplayChange) } +NSArray *QCocoaScreen::s_screenConfigurationBeforeUpdate = nil; + void QCocoaScreen::initializeScreens() { - uint32_t displayCount = 0; - if (CGGetActiveDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess) - qFatal("Failed to get number of active displays"); - - CGDirectDisplayID activeDisplays[displayCount]; - if (CGGetActiveDisplayList(displayCount, &activeDisplays[0], &displayCount) != kCGErrorSuccess) - qFatal("Failed to get active displays"); - - for (CGDirectDisplayID displayId : activeDisplays) - QCocoaScreen::add(displayId); + updateScreens(); CGDisplayRegisterReconfigurationCallback([](CGDirectDisplayID displayId, CGDisplayChangeSummaryFlags flags, void *userInfo) { - if (flags & kCGDisplayBeginConfigurationFlag) - return; // Wait for changes to apply - Q_UNUSED(userInfo); - qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display reconfiguration" - << " (" << QFlags<CoreGraphics::DisplayChange>(flags) << ")" - << " for displayId=" << displayId; - - QCocoaScreen *cocoaScreen = QCocoaScreen::get(displayId); + // Displays are reconfigured in batches, and we want to update our screens + // once a batch ends, so that all the states of the displays are up to date. + static int displayReconfigurationsInProgress = 0; + + const bool beforeReconfigure = flags & kCGDisplayBeginConfigurationFlag; + qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display " << displayId + << (beforeReconfigure ? " about to reconfigure" : " was ") + << QFlags<CoreGraphics::DisplayChange>(flags) + << " with " << displayReconfigurationsInProgress + << " display configuration(s) in progress"; + + if (!flags) { + // CGDisplayRegisterReconfigurationCallback has been observed to be called + // with flags unset. This seems like a bug. The callback is not paired with + // a matching "completion" callback either, so we don't know whether to treat + // it as a begin or end of reconfigure. + return; + } - if ((flags & kCGDisplayAddFlag) || !cocoaScreen) { - if (!CGDisplayIsActive(displayId)) { - qCDebug(lcQpaScreen) << "Not adding inactive display" << displayId; - return; // Will be added when activated + if (beforeReconfigure) { + if (!displayReconfigurationsInProgress++) { + // There might have been a screen reconfigure before this that + // we didn't process yet, so do that now if that's the case. + updateScreensIfNeeded(); + + Q_ASSERT(!s_screenConfigurationBeforeUpdate); + s_screenConfigurationBeforeUpdate = NSScreen.screens; + qCDebug(lcQpaScreen, "Display reconfigure transaction started" + " with screen configuration %p", s_screenConfigurationBeforeUpdate); + + static void (^tryScreenUpdate)(); + tryScreenUpdate = ^void () { + qCDebug(lcQpaScreen) << "Attempting screen update from runloop block"; + if (!updateScreensIfNeeded()) + CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, tryScreenUpdate); + }; + CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, tryScreenUpdate); } - QCocoaScreen::add(displayId); - } else if ((flags & kCGDisplayRemoveFlag) || !CGDisplayIsActive(displayId)) { - cocoaScreen->remove(); } else { - // Detect changes to the primary screen immediately, instead of - // waiting for a display reconfigure with kCGDisplaySetMainFlag. - // This ensures that any property updates to the other screens - // will be in reference to the correct primary screen. - QCocoaScreen *mainDisplay = QCocoaScreen::get(CGMainDisplayID()); - if (QGuiApplication::primaryScreen()->handle() != mainDisplay) { - mainDisplay->updateProperties(); - qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay; - QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay); - if (cocoaScreen == mainDisplay) - return; // Already reconfigured - } + Q_ASSERT_X(displayReconfigurationsInProgress, "QCococaScreen", + "Display configuration transactions are expected to be balanced"); - cocoaScreen->updateProperties(); - qCInfo(lcQpaScreen).nospace() << "Reconfigured " << - (primaryScreen() == cocoaScreen ? "primary " : "") - << cocoaScreen; + if (!--displayReconfigurationsInProgress) { + qCDebug(lcQpaScreen) << "Display reconfigure transaction completed"; + // We optimistically update now, in case the NSScreens have changed + updateScreensIfNeeded(); + } } }, nullptr); + + static QMacNotificationObserver screenParameterObserver(NSApplication.sharedApplication, + NSApplicationDidChangeScreenParametersNotification, [&]() { + qCDebug(lcQpaScreen) << "Received screen parameter change notification"; + updateScreensIfNeeded(); // As a last resort we update screens here + }); +} + +bool QCocoaScreen::updateScreensIfNeeded() +{ + if (!s_screenConfigurationBeforeUpdate) { + qCDebug(lcQpaScreen) << "QScreens have already been updated, all good"; + return true; + } + + if (s_screenConfigurationBeforeUpdate == NSScreen.screens) { + qCDebug(lcQpaScreen) << "Still waiting for NSScreen configuration change"; + return false; + } + + qCDebug(lcQpaScreen, "NSScreen configuration changed to %p", NSScreen.screens); + updateScreens(); + + s_screenConfigurationBeforeUpdate = nil; + return true; +} + +/* + Update the list of available QScreens, and the properties of existing screens. + + At this point we rely on the NSScreen.screens to be up to date. +*/ +void QCocoaScreen::updateScreens() +{ + uint32_t displayCount = 0; + if (CGGetOnlineDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess) + qFatal("Failed to get number of online displays"); + + QVector<CGDirectDisplayID> onlineDisplays(displayCount); + if (CGGetOnlineDisplayList(displayCount, onlineDisplays.data(), &displayCount) != kCGErrorSuccess) + qFatal("Failed to get online displays"); + + qCInfo(lcQpaScreen) << "Updating screens with" << displayCount + << "online displays:" << onlineDisplays; + + // TODO: Verify whether we can always assume the main display is first + int mainDisplayIndex = onlineDisplays.indexOf(CGMainDisplayID()); + if (mainDisplayIndex < 0) { + qCWarning(lcQpaScreen) << "Main display not in list of online displays!"; + } else if (mainDisplayIndex > 0) { + qCWarning(lcQpaScreen) << "Main display not first display, making sure it is"; + onlineDisplays.move(mainDisplayIndex, 0); + } + + for (CGDirectDisplayID displayId : onlineDisplays) { + Q_ASSERT(CGDisplayIsOnline(displayId)); + + if (CGDisplayMirrorsDisplay(displayId)) + continue; + + // A single physical screen can map to multiple displays IDs, + // depending on which GPU is in use or which physical port the + // screen is connected to. By mapping the display ID to a UUID, + // which are shared between displays that target the same screen, + // we can pick an existing QScreen to update instead of needlessly + // adding and removing QScreens. + QCFType<CFUUIDRef> uuid = CGDisplayCreateUUIDFromDisplayID(displayId); + Q_ASSERT(uuid); + + if (QCocoaScreen *existingScreen = QCocoaScreen::get(uuid)) { + existingScreen->update(displayId); + qCInfo(lcQpaScreen) << "Updated" << existingScreen; + if (CGDisplayIsMain(displayId) && existingScreen != qGuiApp->primaryScreen()->handle()) { + qCInfo(lcQpaScreen) << "Primary screen changed to" << existingScreen; + QWindowSystemInterface::handlePrimaryScreenChanged(existingScreen); + } + } else { + QCocoaScreen::add(displayId); + } + } + + for (QScreen *screen : QGuiApplication::screens()) { + QCocoaScreen *platformScreen = static_cast<QCocoaScreen*>(screen->handle()); + if (!platformScreen->isOnline() || platformScreen->isMirroring()) + platformScreen->remove(); + } } void QCocoaScreen::add(CGDirectDisplayID displayId) { const bool isPrimary = CGDisplayIsMain(displayId); QCocoaScreen *cocoaScreen = new QCocoaScreen(displayId); - qCInfo(lcQpaScreen).nospace() << "Adding " << (isPrimary ? "new primary " : "") << cocoaScreen; + qCInfo(lcQpaScreen) << "Adding" << cocoaScreen + << (isPrimary ? "as new primary screen" : ""); QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary); } QCocoaScreen::QCocoaScreen(CGDirectDisplayID displayId) : QPlatformScreen(), m_displayId(displayId) { - updateProperties(); + update(m_displayId); m_cursor = new QCocoaCursor; } @@ -150,8 +243,6 @@ void QCocoaScreen::cleanupScreens() void QCocoaScreen::remove() { - m_displayId = kCGNullDirectDisplay; // Prevent stale references during removal - // This may result in the application responding to QGuiApplication::screenRemoved // by moving the window to another screen, either by setGeometry, or by setScreen. // If the window isn't moved by the application, Qt will as a fallback move it to @@ -163,7 +254,7 @@ void QCocoaScreen::remove() // QCocoaWindow::windowDidChangeScreen. At that point the window will appear to have // already changed its screen, but that's only true if comparing the Qt screens, // not when comparing the NSScreens. - qCInfo(lcQpaScreen).nospace() << "Removing " << (primaryScreen() == this ? "current primary " : "") << this; + qCInfo(lcQpaScreen) << "Removing " << this; QWindowSystemInterface::handleScreenRemoved(this); } @@ -210,9 +301,14 @@ static QString displayName(CGDirectDisplayID displayID) return QString(); } -void QCocoaScreen::updateProperties() +void QCocoaScreen::update(CGDirectDisplayID displayId) { - Q_ASSERT(m_displayId); + if (displayId != m_displayId) { + qCDebug(lcQpaScreen) << "Reconnecting" << this << "as display" << displayId; + m_displayId = displayId; + } + + Q_ASSERT(isOnline()); const QRect previousGeometry = m_geometry; const QRect previousAvailableGeometry = m_availableGeometry; @@ -350,8 +446,8 @@ struct DeferredDebugHelper void QCocoaScreen::deliverUpdateRequests() { - if (!m_displayId) - return; // Screen removed + if (!isOnline()) + return; QMacAutoReleasePool pool; @@ -562,6 +658,29 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height) return windowPixmap; } +bool QCocoaScreen::isOnline() const +{ + // When a display is disconnected CGDisplayIsOnline and other CGDisplay + // functions that take a displayId will not return false, but will start + // returning -1 to signal that the displayId is invalid. Some functions + // will also assert or even crash in this case, so it's important that + // we double check if a display is online before calling other functions. + auto isOnline = CGDisplayIsOnline(m_displayId); + static const uint32_t kCGDisplayIsDisconnected = int32_t(-1); + return isOnline != kCGDisplayIsDisconnected && isOnline; +} + +/* + Returns true if a screen is mirroring another screen +*/ +bool QCocoaScreen::isMirroring() const +{ + if (!isOnline()) + return false; + + return CGDisplayMirrorsDisplay(m_displayId); +} + /*! The screen used as a reference for global window geometry */ @@ -586,6 +705,12 @@ QList<QPlatformScreen*> QCocoaScreen::virtualSiblings() const QCocoaScreen *QCocoaScreen::get(NSScreen *nsScreen) { + if (s_screenConfigurationBeforeUpdate) { + qCWarning(lcQpaScreen) << "Trying to resolve screen while waiting for screen reconfigure!"; + if (!updateScreensIfNeeded()) + qCWarning(lcQpaScreen) << "Failed to do last minute screen update. Expect crashes."; + } + return get(nsScreen.qt_displayId); } @@ -600,23 +725,34 @@ QCocoaScreen *QCocoaScreen::get(CGDirectDisplayID displayId) return nullptr; } +QCocoaScreen *QCocoaScreen::get(CFUUIDRef uuid) +{ + for (QScreen *screen : QGuiApplication::screens()) { + auto *platformScreen = static_cast<QCocoaScreen*>(screen->handle()); + if (!platformScreen->isOnline()) + continue; + + auto displayId = platformScreen->displayId(); + QCFType<CFUUIDRef> candidateUuid(CGDisplayCreateUUIDFromDisplayID(displayId)); + Q_ASSERT(candidateUuid); + + if (candidateUuid == uuid) + return platformScreen; + } + + return nullptr; +} + NSScreen *QCocoaScreen::nativeScreen() const { if (!m_displayId) return nil; // The display has been disconnected - // A single display may have different displayIds depending on - // which GPU is in use or which physical port the display is - // connected to. By comparing UUIDs instead of display IDs we - // ensure that we always pick up the appropriate NSScreen. - QCFType<CFUUIDRef> uuid = CGDisplayCreateUUIDFromDisplayID(m_displayId); - - for (NSScreen *screen in [NSScreen screens]) { - if (QCFType<CFUUIDRef>(CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId)) == uuid) + for (NSScreen *screen in NSScreen.screens) { + if (screen.qt_displayId == m_displayId) return screen; } - qCWarning(lcQpaScreen) << "Could not find NSScreen for display ID" << m_displayId; return nil; } @@ -651,11 +787,21 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen) debug.nospace(); debug << "QCocoaScreen(" << (const void *)screen; if (screen) { - debug << ", geometry=" << screen->geometry(); + debug << ", " << screen->name(); + if (screen->isOnline()) { + if (CGDisplayIsAsleep(screen->displayId())) + debug << ", Sleeping"; + if (auto mirroring = CGDisplayMirrorsDisplay(screen->displayId())) + debug << ", mirroring=" << mirroring; + } else { + debug << ", Offline"; + } + debug << ", " << screen->geometry(); debug << ", dpr=" << screen->devicePixelRatio(); - debug << ", name=" << screen->name(); - debug << ", displayId=" << screen->m_displayId; - debug << ", native=" << screen->nativeScreen(); + debug << ", displayId=" << screen->displayId(); + + if (auto nativeScreen = screen->nativeScreen()) + debug << ", " << nativeScreen; } debug << ')'; return debug; -- cgit v1.2.3 From 57f44068394d015b8f6d6428c91385b2a4f81897 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <albert.astals.cid@kdab.com> Date: Fri, 29 Nov 2019 12:27:54 +0100 Subject: Remove QFlags(0), QFlags() does the same and is not deprecated Change-Id: I254d37d37f5583e0f7a76fb42b83d234afa29b77 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/plugins/platforms/eglfs/api/qeglfscontext.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 3 +-- src/plugins/platforms/vnc/qvncclient.cpp | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp index c5cef34d8e..c10b6facbb 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config, const QVariant &nativeHandle) : QEGLPlatformContext(format, share, display, config, nativeHandle, - qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags(0) : QEGLPlatformContext::NoSurfaceless), + qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags() : QEGLPlatformContext::NoSurfaceless), m_tempWindow(0) { } diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index e6b25c02fd..3457be116a 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -66,8 +66,7 @@ QEglFSWindow::QEglFSWindow(QWindow *w) #endif m_winId(0), m_surface(EGL_NO_SURFACE), - m_window(0), - m_flags(0) + m_window(0) { } diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp index 3a373a5e4b..2450f7dad5 100644 --- a/src/plugins/platforms/vnc/qvncclient.cpp +++ b/src/plugins/platforms/vnc/qvncclient.cpp @@ -65,7 +65,6 @@ QVncClient::QVncClient(QTcpSocket *clientSocket, QVncServer *server) , m_cutTextPending(0) , m_supportHextile(false) , m_wantUpdate(false) - , m_keymod(0) , m_dirtyCursor(false) , m_updatePending(false) , m_protocolVersion(V3_3) -- cgit v1.2.3 From 4e9e9c2c17afa472fb8ae04fc36d9605863f8b83 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Fri, 27 Sep 2019 09:18:46 +0200 Subject: INTEGRITY: remove constexpr support It doesn't seem to be working correctly with array of literal types, blocking the patch refactoring the webgradient support: 10171: "painting/webgradients.cpp", line 79: error #28: expression must have a constant value Change-Id: I9ddd768d24ef79dd7a69e23c91988d891e41d4b9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qcompilerdetection.h | 1 - src/corelib/thread/qbasicatomic.h | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e47f284a42..aab5625d00 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -365,7 +365,6 @@ # define Q_COMPILER_ATTRIBUTES # define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_CLASS_ENUM -# define Q_COMPILER_CONSTEXPR # define Q_COMPILER_DECLTYPE # define Q_COMPILER_DEFAULT_MEMBERS # define Q_COMPILER_DELETE_MEMBERS diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 9804e60119..c9c95cf6ce 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -47,9 +47,9 @@ # include <QtCore/qatomic_bootstrap.h> // If C++11 atomics are supported, use them! -// Note that constexpr support is sometimes disabled in QNX builds but its -// library has <atomic>. -#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX)) +// Note that constexpr support is sometimes disabled in QNX or INTEGRITY builds, +// but their libraries have <atomic>. +#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX) || defined(Q_OS_INTEGRITY)) # include <QtCore/qatomic_cxx11.h> // We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support -- cgit v1.2.3 From d027860201c55b686b9f8330c559f84799442d68 Mon Sep 17 00:00:00 2001 From: BogDan Vatra <bogdan@kdab.com> Date: Thu, 28 Nov 2019 18:36:48 +0200 Subject: Fix assets iterator - start from index -1 each time when we iterate. Each time when we add a FolderIterator to the stack we MUST reset the index (-1) otherwise it will continue from it's last position. To fix it we are cloning the FolderIterator to set the index to -1. The index must be -1 in order to set it to 0 when we first call next() method. - introduce "fileType" static method for a more reliable also much faster file type lookup. The old version of checking if a file exists, is a folder or a file was buggy that's why it skipped some file randomly. Fixes: QTBUG-80178 Change-Id: I4b28e4616399b1bff35d792b55ded1bf19b62dd9 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> --- .../android/qandroidassetsfileenginehandler.cpp | 70 +++++++++++++++++----- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 26e72a480f..3d16f96450 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -72,9 +72,10 @@ static inline QString prefixedPath(QString path) struct AssetItem { enum class Type { File, - Folder + Folder, + Invalid }; - + AssetItem() = default; AssetItem (const QString &rawName) : name(rawName) { @@ -92,21 +93,47 @@ using AssetItemList = QVector<AssetItem>; class FolderIterator : public AssetItemList { public: - static QSharedPointer<FolderIterator> fromCache(const QString &path) + static QSharedPointer<FolderIterator> fromCache(const QString &path, bool clone) { QMutexLocker lock(&m_assetsCacheMutex); QSharedPointer<FolderIterator> *folder = m_assetsCache.object(path); if (!folder) { folder = new QSharedPointer<FolderIterator>{new FolderIterator{path}}; - if (!m_assetsCache.insert(path, folder)) { + if ((*folder)->empty() || !m_assetsCache.insert(path, folder)) { QSharedPointer<FolderIterator> res = *folder; delete folder; return res; } } - return *folder; + return clone ? QSharedPointer<FolderIterator>{new FolderIterator{*(*folder)}} : *folder; + } + + static AssetItem::Type fileType(const QString &filePath) + { + const QStringList paths = filePath.split(QLatin1Char('/')); + QString fullPath; + AssetItem::Type res = AssetItem::Type::Invalid; + for (const auto &path: paths) { + auto folder = fromCache(fullPath, false); + auto it = std::lower_bound(folder->begin(), folder->end(), AssetItem{path}, [](const AssetItem &val, const AssetItem &assetItem) { + return val.name < assetItem.name; + }); + if (it == folder->end() || it->name != path) + return AssetItem::Type::Invalid; + if (!fullPath.isEmpty()) + fullPath.append(QLatin1Char('/')); + fullPath += path; + res = it->type; + } + return res; } + FolderIterator(const FolderIterator &other) + : AssetItemList(other) + , m_index(-1) + , m_path(other.m_path) + {} + FolderIterator(const QString &path) : m_path(path) { @@ -118,8 +145,12 @@ public: QJNIEnvironmentPrivate env; jobjectArray jFiles = static_cast<jobjectArray>(files.object()); const jint nFiles = env->GetArrayLength(jFiles); - for (int i = 0; i < nFiles; ++i) - push_back({QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()}); + for (int i = 0; i < nFiles; ++i) { + AssetItem item{QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()}; + insert(std::upper_bound(begin(), end(), item, [](const auto &a, const auto &b){ + return a.name < b.name; + }), item); + } } m_path = assetsPrefix + QLatin1Char('/') + m_path + QLatin1Char('/'); m_path.replace(QLatin1String("//"), QLatin1String("/")); @@ -169,7 +200,7 @@ public: const QString &path) : QAbstractFileEngineIterator(filters, nameFilters) { - m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path))); + m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path), true)); if (m_stack.last()->empty()) m_stack.pop_back(); } @@ -215,7 +246,7 @@ public: if (!res) return {}; if (res->second.type == AssetItem::Type::Folder) { - m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath()))); + m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath()), true)); if (m_stack.last()->empty()) m_stack.pop_back(); } @@ -305,12 +336,12 @@ public: FileFlags fileFlags(FileFlags type = FileInfoAll) const override { - FileFlags flags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag); + FileFlags commonFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag); + FileFlags flags; if (m_assetFile) - flags |= FileType; + flags = FileType | commonFlags; else if (m_isFolder) - flags |= DirectoryType; - + flags = DirectoryType | commonFlags; return type & flags; } @@ -341,9 +372,20 @@ public: void setFileName(const QString &file) override { + if (m_fileName == cleanedAssetPath(file)) + return; close(); m_fileName = cleanedAssetPath(file); - m_isFolder = !open(QIODevice::ReadOnly) && !FolderIterator::fromCache(m_fileName)->empty(); + switch (FolderIterator::fileType(m_fileName)) { + case AssetItem::Type::File: + open(QIODevice::ReadOnly); + break; + case AssetItem::Type::Folder: + m_isFolder = true; + break; + case AssetItem::Type::Invalid: + break; + } } Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override -- cgit v1.2.3 From c0fb2a81737c07f213c3a8c36732149e0c58ed0d Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio <elvis.angelaccio@kde.org> Date: Sun, 24 Nov 2019 21:11:25 +0100 Subject: QDBusInterface: mention QtDBus caching in documentation QtDBus caches well known interface objects when there is a non-emtpy interface name passed to the QDBusInterface constructor. This commit amends the constructor documentation to explain this behavior. Change-Id: Ic51836be6d833411500ea05fcc895cd4f6e96407 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/dbus/qdbusinterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index 4dd02e8c76..b53c639b6d 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -204,7 +204,9 @@ QDBusInterfacePrivate::~QDBusInterfacePrivate() interface \a interface on object at path \a path on service \a service, using the given \a connection. If \a interface is an empty string, the object created will refer to the merging of all - interfaces found in that object. + interfaces found by introspecting that object. Otherwise if + \a interface is not empty, the QDBusInterface object will be cached + to speedup further creations of the same interface. \a parent is passed to the base class constructor. -- cgit v1.2.3 From 7a55a984d8d0da6a6cf6fdc440d4cccf7fb42c3d Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <albert.astals.cid@kdab.com> Date: Fri, 29 Nov 2019 13:08:17 +0100 Subject: Workaround warning in QHash::unite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The warning pragmas don't work in gcc due to the fact this is a template. I've been told that unite() will disappear but meanwhile i think it's better if we simply don't give a warning that people can't protect themselves against Change-Id: I358e629be86e0e675ef3e49a7fbc4f7f65ae97f6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/corelib/tools/qhash.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 9108be4dc6..42f8dbd155 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -616,10 +616,7 @@ Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::unite(const QHash &other) QHash copy(other); const_iterator it = copy.constEnd(); while (it != copy.constBegin()) { - QT_WARNING_PUSH - QT_WARNING_DISABLE_DEPRECATED - --it; - QT_WARNING_POP + it.i = QHashData::previousNode(it.i); insertMulti(it.key(), it.value()); } #else -- cgit v1.2.3 From b63141fb1496e528e0e155513a5d4e954b0a1565 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Mon, 2 Dec 2019 09:14:19 +0100 Subject: RHI/Vulkan: Fix build Add missing include, fixing: rhi\qrhivulkan.cpp(6273): error C2027: use of undefined type 'QWindow' Amends 0f812db558df072a411ade3305b796d54bccd996. Change-Id: Ide61b713e958877f18a45a89b36a4e1330f75821 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/rhi/qrhivulkan.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 444a395ebc..a200a6e271 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -48,6 +48,7 @@ #include <qmath.h> #include <QVulkanFunctions> +#include <QtGui/qwindow.h> QT_BEGIN_NAMESPACE -- cgit v1.2.3 From f81f21151d30a37f955aa4af2398a96507626b15 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@edeltech.ch> Date: Mon, 2 Mar 2015 21:13:35 +0100 Subject: Session management for macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch aims to implement the session management available on macOS. Currently applicationShouldTerminate is just a go through that closes everything and ends the application. The new implementation calls first appCommitData and cancels the termination properly if required. This means that if a user wishes to logout, Qt applications can now cancel that like e.g. answering to Safari asking whether it is ok to close because of a number of opened tab/window. Fixes: QTBUG-33034 Change-Id: Id5d7416cb74c762c5424a77c9c7664f0749da7f6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/platforms/cocoa/cocoa.pro | 5 ++ .../platforms/cocoa/qcocoaapplicationdelegate.mm | 16 +++- src/plugins/platforms/cocoa/qcocoaintegration.h | 4 + src/plugins/platforms/cocoa/qcocoaintegration.mm | 10 +++ .../platforms/cocoa/qcocoasessionmanager.cpp | 88 ++++++++++++++++++++++ src/plugins/platforms/cocoa/qcocoasessionmanager.h | 81 ++++++++++++++++++++ 6 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/cocoa/qcocoasessionmanager.cpp create mode 100644 src/plugins/platforms/cocoa/qcocoasessionmanager.h (limited to 'src') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 4cf9e64447..8f2956e7d4 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -87,6 +87,11 @@ qtConfig(accessibility) { qcocoaaccessibility.h } +qtConfig(sessionmanager) { + SOURCES += qcocoasessionmanager.cpp + HEADERS += qcocoasessionmanager.h +} + RESOURCES += qcocoaresources.qrc LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index f1fe2aa98b..3fb9e83d35 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -79,11 +79,14 @@ #include "qcocoamenuitem.h" #include "qcocoansmenu.h" +#if QT_CONFIG(sessionmanager) +# include "qcocoasessionmanager.h" +#endif + #include <qevent.h> #include <qurl.h> #include <qdebug.h> #include <qguiapplication.h> -#include <private/qguiapplication_p.h> #include "qt_mac_p.h" #include <qpa/qwindowsysteminterface.h> #include <qwindowdefs.h> @@ -157,6 +160,17 @@ QT_USE_NAMESPACE return NSTerminateNow; } +#if QT_CONFIG(sessionmanager) + QCocoaSessionManager *cocoaSessionManager = QCocoaSessionManager::instance(); + cocoaSessionManager->resetCancellation(); + cocoaSessionManager->appCommitData(); + + if (cocoaSessionManager->wasCanceled()) { + qCDebug(lcQpaApplication) << "Session management canceled application termination"; + return NSTerminateCancel; + } +#endif + if (!QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>()) { qCDebug(lcQpaApplication) << "Application termination canceled"; return NSTerminateCancel; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index bfc3bfe9de..0c14e07551 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -92,6 +92,10 @@ public: QCocoaVulkanInstance *getCocoaVulkanInstance() const; #endif +#if QT_CONFIG(sessionmanager) + QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const override; +#endif + QCoreTextFontDatabase *fontDatabase() const override; QCocoaNativeInterface *nativeInterface() const override; QPlatformInputContext *inputContext() const override; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 9a2f19c2f2..75d428c16f 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -52,6 +52,9 @@ #include "qcocoamimetypes.h" #include "qcocoaaccessibility.h" #include "qcocoascreen.h" +#if QT_CONFIG(sessionmanager) +# include "qcocoasessionmanager.h" +#endif #include <qpa/qplatforminputcontextfactory_p.h> #include <qpa/qplatformaccessibility.h> @@ -255,6 +258,13 @@ QCocoaIntegration::Options QCocoaIntegration::options() const return mOptions; } +#if QT_CONFIG(sessionmanager) +QPlatformSessionManager *QCocoaIntegration::createPlatformSessionManager(const QString &id, const QString &key) const +{ + return new QCocoaSessionManager(id, key); +} +#endif + bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp new file mode 100644 index 0000000000..74e318b5be --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch> +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT_NO_SESSIONMANAGER +#include <private/qsessionmanager_p.h> +#include <private/qguiapplication_p.h> + +#include <qcocoasessionmanager.h> +#include <qstring.h> + +QT_BEGIN_NAMESPACE + +QCocoaSessionManager::QCocoaSessionManager(const QString &id, const QString &key) + : QPlatformSessionManager(id, key), + m_canceled(false) +{ +} + +QCocoaSessionManager::~QCocoaSessionManager() +{ +} + +bool QCocoaSessionManager::allowsInteraction() +{ + return false; +} + +void QCocoaSessionManager::resetCancellation() +{ + m_canceled = false; +} + +void QCocoaSessionManager::cancel() +{ + m_canceled = true; +} + +bool QCocoaSessionManager::wasCanceled() const +{ + return m_canceled; +} + +QCocoaSessionManager *QCocoaSessionManager::instance() +{ + auto *qGuiAppPriv = QGuiApplicationPrivate::instance(); + auto *managerPrivate = static_cast<QSessionManagerPrivate*>(QObjectPrivate::get(qGuiAppPriv->session_manager)); + return static_cast<QCocoaSessionManager *>(managerPrivate->platformSessionManager); +} + +QT_END_NAMESPACE + +#endif // QT_NO_SESSIONMANAGER diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.h b/src/plugins/platforms/cocoa/qcocoasessionmanager.h new file mode 100644 index 0000000000..89ab7bd157 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch> +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCOCOASESSIONMANAGER_H +#define QCOCOASESSIONMANAGER_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#ifndef QT_NO_SESSIONMANAGER + +#include <qpa/qplatformsessionmanager.h> + +QT_BEGIN_NAMESPACE + +class QCocoaSessionManager : public QPlatformSessionManager +{ +public: + QCocoaSessionManager(const QString &id, const QString &key); + virtual ~QCocoaSessionManager(); + + bool allowsInteraction() override; + void cancel() override; + void resetCancellation(); + bool wasCanceled() const; + + static QCocoaSessionManager *instance(); + +private: + bool m_canceled; + + Q_DISABLE_COPY(QCocoaSessionManager) +}; + +QT_END_NAMESPACE + +#endif // QT_NO_SESSIONMANAGER + +#endif // QCOCOASESSIONMANAGER_H -- cgit v1.2.3 From 438702ac5f592573dbb9ed5fac84b241eb2d767a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Sun, 24 Nov 2019 22:06:27 +0100 Subject: macOS: Don't tweak NSApp presentationOptions on startup AppKit will initialize NSScreens nowadays, so we don't need to manually trigger it. Task-number: QTBUG-80193 Change-Id: Ic0251a1b978b9d4ff53f20e67902787cf529fa87 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 9a2f19c2f2..b7f15a2bf1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -197,16 +197,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) [cocoaApplication setMenu:[qtMenuLoader menu]]; } - // The presentation options such as whether or not the dock and/or menu bar is - // hidden (automatically by the system) affects the main screen's available - // geometry. Since we're initializing the screens synchronously at application - // startup we need to ensure that the presentation options have been propagated - // to the screen before we read out its properties. Normally OS X does this in - // an asynchronous callback, but that's too late for us. We force the propagation - // by explicitly setting the presentation option to the magic 'default value', - // which will resolve to an actual value and result in screen invalidation. - cocoaApplication.presentationOptions = NSApplicationPresentationDefault; - QCocoaScreen::initializeScreens(); QMacInternalPasteboardMime::initializeMimeTypes(); -- cgit v1.2.3 From 9ac156c90b92a981f70929e081c64083b14e9a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Mon, 2 Dec 2019 13:33:30 +0100 Subject: iOS: Guard against request for textInputView without focus window Change-Id: I7b8df07fffef1cc948f6720685234540a20ccc81 Fixes: QTBUG-79316 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/ios/qiostextresponder.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 396c769be8..1bc9744528 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -781,12 +781,16 @@ - (UIView *)textInputView { + auto *focusWindow = QGuiApplication::focusWindow(); + if (!focusWindow) + return nil; + // iOS expects rects we return from other UITextInput methods // to be relative to the view this method returns. // Since QInputMethod returns rects relative to the top level // QWindow, that is also the view we need to return. - Q_ASSERT(qApp->focusWindow()->handle()); - QPlatformWindow *topLevel = qApp->focusWindow()->handle(); + Q_ASSERT(focusWindow->handle()); + QPlatformWindow *topLevel = focusWindow->handle(); while (QPlatformWindow *p = topLevel->parent()) topLevel = p; return reinterpret_cast<UIView *>(topLevel->winId()); -- cgit v1.2.3 From a966a7b7df18ebf7b92409b1199386df7f872b6c Mon Sep 17 00:00:00 2001 From: BogDan Vatra <bogdan@kde.org> Date: Tue, 3 Dec 2019 09:25:06 +0200 Subject: Initialize all variables Set m_isFolder = false also in "close" method Fixes: QTBUG-80468 Change-Id: I5449692d61d4d340e83bdca337b86e054e8bf561 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> --- src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 3d16f96450..fcc08ea00d 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -288,6 +288,7 @@ public: m_assetFile = 0; return true; } + m_isFolder = false; return false; } @@ -397,9 +398,9 @@ public: private: AAsset *m_assetFile = nullptr; - AAssetManager *m_assetManager; + AAssetManager *m_assetManager = nullptr; QString m_fileName; - bool m_isFolder; + bool m_isFolder = false; }; -- cgit v1.2.3 From fea316cbe762768ccda25f02d68c2efed25f5b23 Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@qt.io> Date: Fri, 8 Nov 2019 17:24:30 +0100 Subject: CMake: Remove conditions for CMake < 3.1 We don't support anything older than CMake 3.1 Change-Id: I5425a2fddfe5416a6a127a81da669fb37ac4d81c Reviewed-by: Liang Qi <liang.qi@qt.io> --- src/corelib/Qt5CoreMacros.cmake | 85 +++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 84c75401b1..f2a0d18403 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -343,56 +343,51 @@ endfunction() set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..") -if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) - macro(qt5_use_modules _target _link_type) - if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11) - if(CMAKE_WARN_DEPRECATED) - set(messageType WARNING) - endif() - if(CMAKE_ERROR_DEPRECATED) - set(messageType FATAL_ERROR) - endif() - if(messageType) - message(${messageType} "The qt5_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.") - endif() - endif() +macro(qt5_use_modules _target _link_type) + if(CMAKE_WARN_DEPRECATED) + set(messageType WARNING) + endif() + if(CMAKE_ERROR_DEPRECATED) + set(messageType FATAL_ERROR) + endif() + if(messageType) + message(${messageType} "The qt5_use_modules macro is obsolete. Use target_link_libraries with IMPORTED targets instead.") + endif() - if (NOT TARGET ${_target}) - message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.") - endif() - if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" ) - set(_qt5_modules ${ARGN}) - set(_qt5_link_type ${_link_type}) - else() - set(_qt5_modules ${_link_type} ${ARGN}) - endif() + if (NOT TARGET ${_target}) + message(FATAL_ERROR "The first argument to qt5_use_modules must be an existing target.") + endif() + if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE" ) + set(_qt5_modules ${ARGN}) + set(_qt5_link_type ${_link_type}) + else() + set(_qt5_modules ${_link_type} ${ARGN}) + endif() - if ("${_qt5_modules}" STREQUAL "") - message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.") - endif() + if ("${_qt5_modules}" STREQUAL "") + message(FATAL_ERROR "qt5_use_modules requires at least one Qt module to use.") + endif() - foreach(_module ${_qt5_modules}) + foreach(_module ${_qt5_modules}) + if (NOT Qt5${_module}_FOUND) + find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH) if (NOT Qt5${_module}_FOUND) - find_package(Qt5${_module} PATHS "${_Qt5_COMPONENT_PATH}" NO_DEFAULT_PATH) - if (NOT Qt5${_module}_FOUND) - message(FATAL_ERROR "Cannot use \"${_module}\" module which has not yet been found.") - endif() - endif() - target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES}) - set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) - if (Qt5_POSITION_INDEPENDENT_CODE - AND (CMAKE_VERSION VERSION_GREATER_EQUAL 2.8.12 - AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" - OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0))) - set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + message(FATAL_ERROR "Cannot use \"${_module}\" module which has not yet been found.") endif() - endforeach() - endmacro() -endif() + endif() + target_link_libraries(${_target} ${_qt5_link_type} ${Qt5${_module}_LIBRARIES}) + set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Qt5${_module}_INCLUDE_DIRS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${Qt5${_module}_COMPILE_DEFINITIONS}) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) + set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) + if (Qt5_POSITION_INDEPENDENT_CODE + AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) + set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE}) + endif() + endforeach() +endmacro() function(QT5_IMPORT_PLUGINS TARGET_NAME) set(_doing "") -- cgit v1.2.3 From 443ef0010ae68ac5a883fb9ab7677d9de719e70e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Fri, 29 Nov 2019 10:50:24 +0100 Subject: rhi: Remove unused compat functions These were kept around to keep Qt Quick compiling, but the migration there has been done a long time ago. Remove these leftovers now. Change-Id: Ibd47381b410b11b5475a85c7ed3cb05c22f7adbb Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhi_p.h | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 907924c788..588347d111 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -246,10 +246,6 @@ public: m_bindings.clear(); std::copy(first, last, std::back_inserter(m_bindings)); } - void setBindings(const QVector<QRhiVertexInputBinding> &bindings) // compat., to be removed - { - setBindings(bindings.cbegin(), bindings.cend()); - } const QRhiVertexInputBinding *cbeginBindings() const { return m_bindings.cbegin(); } const QRhiVertexInputBinding *cendBindings() const { return m_bindings.cend(); } const QRhiVertexInputBinding *bindingAt(int index) const { return &m_bindings.at(index); } @@ -261,10 +257,6 @@ public: m_attributes.clear(); std::copy(first, last, std::back_inserter(m_attributes)); } - void setAttributes(const QVector<QRhiVertexInputAttribute> &attributes) // compat., to be removed - { - setAttributes(attributes.cbegin(), attributes.cend()); - } const QRhiVertexInputAttribute *cbeginAttributes() const { return m_attributes.cbegin(); } const QRhiVertexInputAttribute *cendAttributes() const { return m_attributes.cend(); } @@ -551,9 +543,6 @@ public: QRhiTextureUploadDescription() = default; QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry); QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list); - QRhiTextureUploadDescription(const QVector<QRhiTextureUploadEntry> &entries) // compat., to be removed - : m_entries(entries.cbegin(), entries.cend()) - { } void setEntries(std::initializer_list<QRhiTextureUploadEntry> list) { m_entries = list; } template<typename InputIterator> @@ -979,11 +968,6 @@ public: std::copy(first, last, std::back_inserter(m_bindings)); } - void setBindings(const QVector<QRhiShaderResourceBinding> &bindings) // compat., to be removed - { - setBindings(bindings.cbegin(), bindings.cend()); - } - const QRhiShaderResourceBinding *cbeginBindings() const { return m_bindings.cbegin(); } const QRhiShaderResourceBinding *cendBindings() const { return m_bindings.cend(); } @@ -1172,10 +1156,6 @@ public: m_shaderStages.clear(); std::copy(first, last, std::back_inserter(m_shaderStages)); } - void setShaderStages(const QVector<QRhiShaderStage> &stages) // compat., to be removed - { - setShaderStages(stages.cbegin(), stages.cend()); - } const QRhiShaderStage *cbeginShaderStages() const { return m_shaderStages.cbegin(); } const QRhiShaderStage *cendShaderStages() const { return m_shaderStages.cend(); } -- cgit v1.2.3 From 8310d636be068bb814418e2e6044c6dbd7df253a Mon Sep 17 00:00:00 2001 From: Joni Poikelin <joni.poikelin@qt.io> Date: Mon, 14 Oct 2019 12:31:40 +0300 Subject: Fix serializing QUuid with QDataStream with Qt 4 stream versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-76103 Change-Id: Iac92c33539940f5f67d014db5240c6dc14bfb772 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/kernel/qvariant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 43a3fb1db0..84ad555f34 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2577,8 +2577,8 @@ void QVariant::save(QDataStream &s) const } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { // and as a result these types received lower ids too typeId +=1; - } else if (typeId == QMetaType::QPolygonF) { - // This existed in Qt 4 only as a custom type + } else if (typeId == QMetaType::QPolygonF || typeId == QMetaType::QUuid) { + // These existed in Qt 4 only as a custom type typeId = 127; fakeUserType = true; } -- cgit v1.2.3 From 580fd2dbd361be57105ed621d8367c677673a924 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Fri, 29 Nov 2019 16:15:27 +0100 Subject: Relocate a comment that had become detached from its code Two little tool functions had come between it and the function it actually describes. Change-Id: Ib49d1623833275ea79c7916fece29aed9503aa40 Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/time/qdatetimeparser.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 2c566e3584..74db2bdfd5 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -369,13 +369,6 @@ static QString unquote(const QStringRef &str) } return ret; } -/*! - \internal - - Parses the format \a newFormat. If successful, returns \c true and - sets up the format. Else keeps the old format and returns \c false. - -*/ static inline int countRepeat(const QString &str, int index, int maxCount) { @@ -394,7 +387,12 @@ static inline void appendSeparator(QStringList *list, const QString &string, int list->append(lastQuote >= from ? unquote(separator) : separator.toString()); } +/*! + \internal + Parses the format \a newFormat. If successful, returns \c true and sets up + the format. Else keeps the old format and returns \c false. +*/ bool QDateTimeParser::parseFormat(const QString &newFormat) { const QLatin1Char quote('\''); -- cgit v1.2.3 From b6632443d4d5b657f25a123eb52cec9e8d2eefea Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@qt.io> Date: Tue, 26 Nov 2019 15:48:29 +0100 Subject: CMake: Use lower-case macro/function names CMake is case-insensitive for macro and function names. Still, it is "strongly recommended to stay with the case chosen in the function definition." So let's make the function and macro definition lower-case, like we also recommend in the documentation. Change-Id: I1f64b18716f034cb696d2e19a2b380aaadd6cd07 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> --- src/corelib/Qt5CoreMacros.cmake | 26 +++++++++++++------------- src/dbus/Qt5DBusMacros.cmake | 8 ++++---- src/widgets/Qt5WidgetsMacros.cmake | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index f2a0d18403..e298cf7de7 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -39,7 +39,7 @@ include(CMakeParseArguments) # macro used to create the names of output files preserving relative dirs -macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile ) +macro(qt5_make_output_file infile prefix ext outfile ) string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength) string(LENGTH ${infile} _infileLength) set(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR}) @@ -65,7 +65,7 @@ macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile ) endmacro() -macro(QT5_GET_MOC_FLAGS _moc_flags) +macro(qt5_get_moc_flags _moc_flags) set(${_moc_flags}) get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES) @@ -97,7 +97,7 @@ endmacro() # helper macro to set up a moc rule -function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target moc_depends) +function(qt5_create_moc_command infile outfile moc_flags moc_options moc_target moc_depends) # Pass the parameters in a file. Set the working directory to # be that containing the parameters file and reference it by # just the file name. This is necessary because the moc tool on @@ -143,7 +143,7 @@ function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target endfunction() -function(QT5_GENERATE_MOC infile outfile ) +function(qt5_generate_moc infile outfile ) # get include dirs and flags qt5_get_moc_flags(moc_flags) get_filename_component(abs_infile ${infile} ABSOLUTE) @@ -160,7 +160,7 @@ endfunction() # qt5_wrap_cpp(outfiles inputfile ... ) -function(QT5_WRAP_CPP outfiles ) +function(qt5_wrap_cpp outfiles ) # get include dirs qt5_get_moc_flags(moc_flags) @@ -189,7 +189,7 @@ endfunction() # _qt5_parse_qrc_file(infile _out_depends _rc_depends) # internal -function(_QT5_PARSE_QRC_FILE infile _out_depends _rc_depends) +function(_qt5_parse_qrc_file infile _out_depends _rc_depends) get_filename_component(rc_path ${infile} PATH) if(EXISTS "${infile}") @@ -222,7 +222,7 @@ endfunction() # qt5_add_binary_resources(target inputfiles ... ) -function(QT5_ADD_BINARY_RESOURCES target ) +function(qt5_add_binary_resources target ) set(options) set(oneValueArgs DESTINATION) @@ -241,7 +241,7 @@ function(QT5_ADD_BINARY_RESOURCES target ) foreach(it ${rcc_files}) get_filename_component(infile ${it} ABSOLUTE) - _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + _qt5_parse_qrc_file(${infile} _out_depends _rc_depends) set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) set(infiles ${infiles} ${infile}) set(out_depends ${out_depends} ${_out_depends}) @@ -258,7 +258,7 @@ endfunction() # qt5_add_resources(outfiles inputfile ... ) -function(QT5_ADD_RESOURCES outfiles ) +function(qt5_add_resources outfiles ) set(options) set(oneValueArgs) @@ -278,7 +278,7 @@ function(QT5_ADD_RESOURCES outfiles ) get_filename_component(infile ${it} ABSOLUTE) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp) - _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + _qt5_parse_qrc_file(${infile} _out_depends _rc_depends) set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) add_custom_command(OUTPUT ${outfile} @@ -295,7 +295,7 @@ endfunction() # qt5_add_big_resources(outfiles inputfile ... ) -function(QT5_ADD_BIG_RESOURCES outfiles ) +function(qt5_add_big_resources outfiles ) if (CMAKE_VERSION VERSION_LESS 3.9) message(FATAL_ERROR, "qt5_add_big_resources requires CMake 3.9 or newer") endif() @@ -319,7 +319,7 @@ function(QT5_ADD_BIG_RESOURCES outfiles ) set(tmpoutfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}tmp.cpp) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.o) - _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + _qt5_parse_qrc_file(${infile} _out_depends _rc_depends) set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) add_custom_command(OUTPUT ${tmpoutfile} COMMAND ${Qt5Core_RCC_EXECUTABLE} ${rcc_options} --name ${outfilename} --pass 1 --output ${tmpoutfile} ${infile} @@ -389,7 +389,7 @@ macro(qt5_use_modules _target _link_type) endforeach() endmacro() -function(QT5_IMPORT_PLUGINS TARGET_NAME) +function(qt5_import_plugins TARGET_NAME) set(_doing "") foreach(_arg ${ARGN}) if(_arg STREQUAL "INCLUDE") diff --git a/src/dbus/Qt5DBusMacros.cmake b/src/dbus/Qt5DBusMacros.cmake index b381ab0934..9b69e77dc7 100644 --- a/src/dbus/Qt5DBusMacros.cmake +++ b/src/dbus/Qt5DBusMacros.cmake @@ -34,7 +34,7 @@ include(MacroAddFileDependencies) include(CMakeParseArguments) -function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename) +function(qt5_add_dbus_interface _sources _interface _basename) get_filename_component(_infile ${_interface} ABSOLUTE) set(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h") set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp") @@ -71,7 +71,7 @@ function(QT5_ADD_DBUS_INTERFACE _sources _interface _basename) endfunction() -function(QT5_ADD_DBUS_INTERFACES _sources) +function(qt5_add_dbus_interfaces _sources) foreach(_current_FILE ${ARGN}) get_filename_component(_infile ${_current_FILE} ABSOLUTE) get_filename_component(_basename ${_current_FILE} NAME) @@ -84,7 +84,7 @@ function(QT5_ADD_DBUS_INTERFACES _sources) endfunction() -function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ) +function(qt5_generate_dbus_interface _header) # _customName OPTIONS -some -options ) set(options) set(oneValueArgs) set(multiValueArgs OPTIONS) @@ -117,7 +117,7 @@ function(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -optio endfunction() -function(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName) +function(qt5_add_dbus_adaptor _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName) get_filename_component(_infile ${_xml_file} ABSOLUTE) set(_optionalBasename "${ARGV4}") diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake index 737371a5ad..21e73d4f0c 100644 --- a/src/widgets/Qt5WidgetsMacros.cmake +++ b/src/widgets/Qt5WidgetsMacros.cmake @@ -41,7 +41,7 @@ include(CMakeParseArguments) # qt5_wrap_ui(outfiles inputfile ... ) -function(QT5_WRAP_UI outfiles ) +function(qt5_wrap_ui outfiles ) set(options) set(oneValueArgs) set(multiValueArgs OPTIONS) -- cgit v1.2.3 From 61f92c0bcedfaad1721bd1c985217c5271e9086c Mon Sep 17 00:00:00 2001 From: Kai Koehne <kai.koehne@qt.io> Date: Tue, 3 Dec 2019 09:02:15 +0100 Subject: Make sure documentation for VulkanMemoryAllocator 3rdparty code shows up There's no qt documentation module for 'qtrhi' - instead, it should be added to the qtgui documentation module. Fixes: QTBUG-80489 Change-Id: Iea61b907811cd2135c2f1258599d9868d2218679 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/3rdparty/VulkanMemoryAllocator/qt_attribution.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty/VulkanMemoryAllocator/qt_attribution.json b/src/3rdparty/VulkanMemoryAllocator/qt_attribution.json index 2548856ca7..0a5df738a8 100644 --- a/src/3rdparty/VulkanMemoryAllocator/qt_attribution.json +++ b/src/3rdparty/VulkanMemoryAllocator/qt_attribution.json @@ -2,7 +2,7 @@ { "Id": "VulkanMemoryAllocator", "Name": "Vulkan Memory Allocator", - "QDocModule": "qtrhi", + "QDocModule": "qtgui", "Description": "Vulkan Memory Allocator", "QtUsage": "Memory management for the Vulkan backend of QRhi.", -- cgit v1.2.3 From c625d923853d01ad668dd3e8ebd55b7e5a6bcdb8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Mon, 2 Dec 2019 10:27:02 +0100 Subject: Fix depth in renderText() Fixes: QTBUG-31156 Change-Id: I3cbb3f9c5dfbcb182dbe283b0bf0f05a031970a5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/opengl/qgl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 2c5a40a992..2d7b0280d8 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4962,7 +4962,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con // The only option in Qt 5 is the shader-based OpenGL 2 paint engine. // Setting fixed pipeline transformations is futile. Instead, pass the // extra values directly and let the engine figure the matrices out. - static_cast<QGL2PaintEngineEx *>(p->paintEngine())->setTranslateZ(-win_z); + static_cast<QGL2PaintEngineEx *>(p->paintEngine())->setTranslateZ(-2 * win_z); qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font); -- cgit v1.2.3 From 4d796cbf17da28e72ad25760a2ee8c27af96c202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> Date: Fri, 8 Nov 2019 02:19:02 +0100 Subject: Prevent emscripten_webgl_destroy_context from removing event handlers The JavaScript implementation of that function has the following code: if (typeof JSEvents === 'object') JSEvents.removeAllHandlersOnTarget(GL.contexts[contextHandle].GLctx.canvas); // Release all // JS event handlers on the DOM element that the GL context is associated with since the context // is now deleted. This breaks mouse/keyboard events, etc. Disable this logic by temporarily setting the JSEvents object to undefined, for the duration of the emscripten_webgl_destroy_context call. Fixes: QTBUG-74850 Change-Id: Ied3177b0ca6e63e8ea07143bf7d6a850b0bce35a Reviewed-by: Lorn Potter <lorn.potter@gmail.com> --- src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 62087f54bd..0532b7e726 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -30,6 +30,7 @@ #include "qwasmopenglcontext.h" #include "qwasmintegration.h" #include <EGL/egl.h> +#include <emscripten/val.h> QT_BEGIN_NAMESPACE @@ -50,7 +51,13 @@ QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format) QWasmOpenGLContext::~QWasmOpenGLContext() { if (m_context) { + // Destroy GL context. Work around bug in emscripten_webgl_destroy_context + // which removes all event handlers on the canvas by temporarily removing + // emscripten's JSEvents global object. + emscripten::val jsEvents = emscripten::val::global("window")["JSEvents"]; + emscripten::val::global("window").set("JSEvents", emscripten::val::undefined()); emscripten_webgl_destroy_context(m_context); + emscripten::val::global("window").set("JSEvents", jsEvents); m_context = 0; } } -- cgit v1.2.3 From 2ed59f0d42d2817a5855be167f5e3ccf23563e39 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Tue, 3 Dec 2019 11:25:27 +0100 Subject: QMdiArea: on macOS using tabs, render document icons next to the text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is closer to what titles of documents look like in macOS apps, even though MDI is not a well-defined concept on this platform. To implement this, the QCommonStylePrivate::tabLayout method had to be made virtual, as it is called by the QCommonStyle class. It was already reimplemented in QMacStylePrivate, but didn't get called in all cases. Now that it is called as an override, adjust the icon placement to include the padding so that we get identical results to 5.13 for normal tab widgets. Change-Id: I7a63f6d76891146ca713259096a7737a86584d81 Fixes: QTBUG-63445 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/styles/mac/qmacstyle_mac.mm | 18 +++++++++++++----- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 2 +- src/widgets/styles/qcommonstyle_p.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 603c6e93f3..3c97db44ad 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1388,14 +1388,22 @@ void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widg // High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height())); - *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, - tabIconSize.width(), tabIconSize.height()); + const int stylePadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2 - hpadding; + + if (opt->documentMode) { + // documents show the icon as part of the the text + const int textWidth = + opt->fontMetrics.boundingRect(tr, Qt::AlignCenter | Qt::TextShowMnemonic, opt->text).width(); + *iconRect = QRect(tr.center().x() - textWidth / 2 - stylePadding - tabIconSize.width(), + tr.center().y() - tabIconSize.height() / 2, + tabIconSize.width(), tabIconSize.height()); + } else { + *iconRect = QRect(tr.left() + stylePadding, tr.center().y() - tabIconSize.height() / 2, + tabIconSize.width(), tabIconSize.height()); + } if (!verticalTabs) *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); - int stylePadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; - stylePadding -= hpadding; - tr.setLeft(tr.left() + stylePadding + tabIconSize.width() + 4); tr.setRight(tr.right() - stylePadding - tabIconSize.width() - 4); } diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index d6af18f01f..274936bd79 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -284,7 +284,7 @@ public: CocoaControlType windowButtonCocoaControl(QStyle::SubControl sc) const; #if QT_CONFIG(tabbar) - void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const; + void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const override; static Direction tabDirection(QTabBar::Shape shape); static bool verticalTabs(QMacStylePrivate::Direction tabDirection); #endif diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h index 4860dfe4c9..6223a26a54 100644 --- a/src/widgets/styles/qcommonstyle_p.h +++ b/src/widgets/styles/qcommonstyle_p.h @@ -122,7 +122,7 @@ public: mutable QIcon tabBarcloseButtonIcon; #if QT_CONFIG(tabbar) - void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const; + virtual void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const; #endif int animationFps; -- cgit v1.2.3 From e4d1a03df00b7fb9528f4cd600038515a07196db Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Tue, 3 Dec 2019 15:14:59 +0100 Subject: QMacStyle: correct placement of edit field in combobox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dark edit field is now centered within the frame around it, with a thin border on all sides, including between input field and button. Change-Id: I27e853289e9048c21fdc81e45fadacba9665b49e Fixes: QTBUG-63454 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/styles/mac/qmacstyle_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 610329a350..ecdde06bb8 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1740,16 +1740,16 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc if (cw.type == ComboBox) { switch (cw.size) { case QStyleHelper::SizeLarge: - ret = ret.adjusted(0, 0, -28, 0).translated(3, 4.5); + ret = ret.adjusted(0, 0, -25, 0).translated(2, 4.5); ret.setHeight(16); break; case QStyleHelper::SizeSmall: - ret = ret.adjusted(0, 0, -24, 0).translated(3, 2); + ret = ret.adjusted(0, 0, -22, 0).translated(2, 3); ret.setHeight(14); break; case QStyleHelper::SizeMini: - ret = ret.adjusted(0, 0, -21, 0).translated(2, 3); - ret.setHeight(11); + ret = ret.adjusted(0, 0, -19, 0).translated(2, 2.5); + ret.setHeight(10.5); break; default: break; -- cgit v1.2.3 From 9f79ab360fd8a504601d3c66a7773eeaa09bffde Mon Sep 17 00:00:00 2001 From: David Faure <david.faure@kdab.com> Date: Sun, 3 Mar 2019 14:55:20 +0100 Subject: Fix assert in QTextDocument CSS parser on "border-width: 1pt" The code was assuming that if the parsing of the value worked, then it must be a list of 4 variants. But in this case it's just a single length. This came from <td> using 4 values for border-width while other elements use a single value. But the storage is shared. So the fix is to use 4 values everywhere. When reading 4 and there's only one, it gets duplicated, so the caller can just use the first one in that case. Task-number: QTBUG-80496 Change-Id: I682244b6e3781c4d673a62d5e6511dac263c58e8 Reviewed-by: Nils Jeisecke <nils.jeisecke@saltation.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/text/qcssparser.cpp | 1 + src/gui/text/qcssparser_p.h | 4 ++-- src/gui/text/qtexthtmlparser.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index ce7c7610c1..627b3ec8c0 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -443,6 +443,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m) { if (decl.d->parsed.isValid()) { QList<QVariant> v = decl.d->parsed.toList(); + Q_ASSERT(v.size() == 4); for (int i = 0; i < 4; i++) m[i] = lengthValueFromData(qvariant_cast<LengthData>(v.at(i)), f); return; diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index ab85e76cf3..d91b095a76 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -856,13 +856,13 @@ struct Q_GUI_EXPORT ValueExtractor int extractStyleFeatures(); bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size); - int lengthValue(const Declaration &decl); + void lengthValues(const Declaration &decl, int *m); private: void extractFont(); void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color); LengthData lengthValue(const Value& v); - void lengthValues(const Declaration &decl, int *m); + int lengthValue(const Declaration &decl); QSize sizeValue(const Declaration &decl); void sizeValues(const Declaration &decl, QSize *radii); diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 5d37982a8b..b867f42480 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1209,8 +1209,11 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration> if (decl.styleValue() != QCss::BorderStyle_Unknown && decl.styleValue() != QCss::BorderStyle_Native) borderStyle = static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1); break; - case QCss::BorderWidth: - tableBorder = extractor.lengthValue(decl); + case QCss::BorderWidth: { + int borders[4]; + extractor.lengthValues(decl, borders); + tableBorder = borders[0]; + } break; case QCss::BorderCollapse: borderCollapse = decl.borderCollapseValue(); -- cgit v1.2.3 From e5438e8ded27eb6f7f0e85704d6843069296c698 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Wed, 30 Oct 2019 11:49:07 +0100 Subject: QSslSocket (OpenSSL) improve alert messages handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Add a new verification callback. This gives an option to report errors directly from this callback (by emitting handshakeInterruptedOnError()). This allows an application to explain to its peer why the handshake was interrupted (by sending a corresponding alert message). 2. This also means we want to notice such alerts (in Qt, from the application's point of view, they are mostly informational only, no interaction is required). So we also introduce a new 'info callback', that can notice alert messages read or written. We also introduce two new enums describing the level and type of an alert message. QSslSocket gets three new signals (for incoming/outgoing alerts and verification errors found early). 3. In case we requested a certificate, but the peer provided none, we would previously abruptly close the connection without a proper alert message (and such a situation is not handled by any verification callbacks, since there is no certificate(s) to verify essentially). So we now introduce a new verification option that maps to what OpenSSL calls 'SSL_VERIFY_FAIL_IF_NO_PEER_CERT'. This way, the proper alert will be generated. Fixes: QTBUG-68419 Change-Id: I5d1e9298b4040a2d4f867f5b1a3567a2253927b8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/ssl/qsslconfiguration.cpp | 91 ++++++++- src/network/ssl/qsslconfiguration.h | 6 + src/network/ssl/qsslconfiguration_p.h | 8 + src/network/ssl/qsslcontext_openssl.cpp | 20 +- src/network/ssl/qsslsocket.cpp | 136 +++++++++++++- src/network/ssl/qsslsocket.h | 47 +++++ src/network/ssl/qsslsocket_openssl.cpp | 246 +++++++++++++++++++++++-- src/network/ssl/qsslsocket_openssl_p.h | 13 ++ src/network/ssl/qsslsocket_openssl_symbols.cpp | 8 +- src/network/ssl/qsslsocket_openssl_symbols_p.h | 4 + src/network/ssl/qsslsocket_p.h | 1 + 11 files changed, 558 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 738c8d4ac5..b6199a2b16 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -222,7 +222,9 @@ bool QSslConfiguration::operator==(const QSslConfiguration &other) const d->nextNegotiatedProtocol == other.d->nextNegotiatedProtocol && d->nextProtocolNegotiationStatus == other.d->nextProtocolNegotiationStatus && d->dtlsCookieEnabled == other.d->dtlsCookieEnabled && - d->ocspStaplingEnabled == other.d->ocspStaplingEnabled; + d->ocspStaplingEnabled == other.d->ocspStaplingEnabled && + d->reportFromCallback == other.d->reportFromCallback && + d->missingCertIsFatal == other.d->missingCertIsFatal; } /*! @@ -267,7 +269,9 @@ bool QSslConfiguration::isNull() const d->nextAllowedProtocols.isEmpty() && d->nextNegotiatedProtocol.isNull() && d->nextProtocolNegotiationStatus == QSslConfiguration::NextProtocolNegotiationNone && - d->ocspStaplingEnabled == false); + d->ocspStaplingEnabled == false && + d->reportFromCallback == false && + d->missingCertIsFatal == false); } /*! @@ -1190,6 +1194,89 @@ bool QSslConfiguration::ocspStaplingEnabled() const return d->ocspStaplingEnabled; } +/*! + \since 6.0 + + Returns true if a verification callback will emit QSslSocket::handshakeInterruptedOnError() + early, before concluding the handshake. + + \note This function always returns false for all backends but OpenSSL. + + \sa setHandshakeMustInterruptOnError(), QSslSocket::handshakeInterruptedOnError(), QSslSocket::continueInterruptedHandshake() +*/ +bool QSslConfiguration::handshakeMustInterruptOnError() const +{ + return d->reportFromCallback; +} + +/*! + \since 6.0 + + If \a interrupt is true and the underlying backend supports this option, + errors found during certificate verification are reported immediately + by emitting QSslSocket::handshakeInterruptedOnError(). This allows + to stop the unfinished handshake and send a proper alert message to + a peer. No special action is required from the application in this case. + QSslSocket will close the connection after sending the alert message. + If the application after inspecting the error wants to continue the + handshake, it must call QSslSocket::continueInterruptedHandshake() + from its slot function. The signal-slot connection must be direct. + + \note When interrupting handshake is enabled, errors that would otherwise + be reported by QSslSocket::peerVerifyError() are instead only reported by + QSslSocket::handshakeInterruptedOnError(). + \note Even if the handshake was continued, these errors will be + reported when emitting QSslSocket::sslErrors() signal (and thus must + be ignored in the corresponding function slot). + + \sa handshakeMustInterruptOnError(), QSslSocket::handshakeInterruptedOnError(), QSslSocket::continueInterruptedHandshake() +*/ +void QSslConfiguration::setHandshakeMustInterruptOnError(bool interrupt) +{ +#if QT_CONFIG(openssl) + d->reportFromCallback = interrupt; +#else + qCWarning(lcSsl, "This operation requires OpenSSL as TLS backend"); +#endif +} + +/*! + \since 6.0 + + Returns true if errors with code QSslError::NoPeerCertificate + cannot be ignored. + + \note Always returns false for all TLS backends but OpenSSL. + + \sa QSslSocket::ignoreSslErrors(), setMissingCertificateIsFatal() +*/ +bool QSslConfiguration::missingCertificateIsFatal() const +{ + return d->missingCertIsFatal; +} + +/*! + \since 6.0 + + If \a cannotRecover is true, and verification mode in use is + QSslSocket::VerifyPeer or QSslSocket::AutoVerifyPeer (for a + client-side socket), the missing peer's certificate would be + treated as an unrecoverable error that cannot be ignored. A proper + alert message will be sent to the peer before closing the connection. + + \note Only available if Qt was configured and built with OpenSSL backend. + + \sa QSslSocket::ignoreSslErrors(), QSslSocket::PeerVerifyMode, missingCertificateIsFatal() +*/ +void QSslConfiguration::setMissingCertificateIsFatal(bool cannotRecover) +{ +#if QT_CONFIG(openssl) + d->missingCertIsFatal = cannotRecover; +#else + qCWarning(lcSsl, "Handling a missing certificate as a fatal error requires an OpenSSL backend"); +#endif // openssl +} + /*! \internal */ bool QSslConfigurationPrivate::peerSessionWasShared(const QSslConfiguration &configuration) { diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h index ad6e23638f..dc4587a835 100644 --- a/src/network/ssl/qsslconfiguration.h +++ b/src/network/ssl/qsslconfiguration.h @@ -172,6 +172,12 @@ public: static void setDefaultDtlsConfiguration(const QSslConfiguration &configuration); #endif // dtls + bool handshakeMustInterruptOnError() const; + void setHandshakeMustInterruptOnError(bool interrupt); + + bool missingCertificateIsFatal() const; + void setMissingCertificateIsFatal(bool cannotRecover); + void setOcspStaplingEnabled(bool enable); bool ocspStaplingEnabled() const; diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h index 83126bb9a0..6ee3490df6 100644 --- a/src/network/ssl/qsslconfiguration_p.h +++ b/src/network/ssl/qsslconfiguration_p.h @@ -149,6 +149,14 @@ public: const bool ocspStaplingEnabled = false; #endif +#if QT_CONFIG(openssl) + bool reportFromCallback = false; + bool missingCertIsFatal = false; +#else + const bool reportFromCallback = false; + const bool missingCertIsFatal = false; +#endif // openssl + // in qsslsocket.cpp: static QSslConfiguration defaultConfiguration(); static void setDefaultConfiguration(const QSslConfiguration &configuration); diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index ad2edce510..574f48a2b5 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE // defined in qsslsocket_openssl.cpp: extern int q_X509Callback(int ok, X509_STORE_CTX *ctx); +extern "C" int q_X509CallbackDirect(int ok, X509_STORE_CTX *ctx); extern QString getErrorsFromOpenSsl(); #if QT_CONFIG(dtls) @@ -571,11 +572,20 @@ init_context: if (sslContext->sslConfiguration.peerVerifyMode() == QSslSocket::VerifyNone) { q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_NONE, nullptr); } else { - q_SSL_CTX_set_verify(sslContext->ctx, SSL_VERIFY_PEER, -#if QT_CONFIG(dtls) - isDtls ? dtlscallbacks::q_X509DtlsCallback : -#endif // dtls - q_X509Callback); + auto verificationCallback = + #if QT_CONFIG(dtls) + isDtls ? dtlscallbacks::q_X509DtlsCallback : + #endif // dtls + q_X509Callback; + + if (!isDtls && configuration.handshakeMustInterruptOnError()) + verificationCallback = q_X509CallbackDirect; + + auto verificationMode = SSL_VERIFY_PEER; + if (!isDtls && sslContext->sslConfiguration.missingCertificateIsFatal()) + verificationMode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + + q_SSL_CTX_set_verify(sslContext->ctx, verificationMode, verificationCallback); } #if QT_CONFIG(dtls) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 86937fc6c1..99329d3f4a 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -227,6 +227,74 @@ \sa QSslSocket::peerVerifyMode() */ +/*! + \enum QAlertLevel + \brief Describes the level of an alert message + \relates QSslSocket + \since 6.0 + + \ingroup network + \ingroup ssl + \inmodule QtNetwork + + This enum describes the level of an alert message that was sent + or received. + + \value Warning Non-fatal alert message + \value Fatal Fatal alert message, the underlying backend will + handle such an alert properly and close the connection. + \value Unknown An alert of unknown level of severity. +*/ + +/*! + \enum QAlertType + \brief Enumerates possible codes that an alert message can have + \relates QSslSocket + \since 6.0 + + \ingroup network + \ingroup ssl + \inmodule QtNetwork + + See \l{https://tools.ietf.org/html/rfc8446#page-85}{RFC 8446, section 6} + for the possible values and their meaning. + + \value CloseNotify, + \value UnexpectedMessage + \value BadRecordMac + \value RecordOverflow + \value DecompressionFailure + \value HandshakeFailure + \value NoCertificate + \value BadCertificate + \value UnsupportedCertificate + \value CertificateRevoked + \value CertificateExpired + \value CertificateUnknown + \value IllegalParameter + \value UnknownCa + \value AccessDenied + \value DecodeError + \value DecryptError + \value ExportRestriction + \value ProtocolVersion + \value InsufficientSecurity + \value InternalError + \value InappropriateFallback + \value UserCancelled + \value NoRenegotiation + \value MissingExtension + \value UnsupportedExtension + \value CertificateUnobtainable + \value UnrecognizedName + \value BadCertificateStatusResponse + \value BadCertificateHashValue + \value UnknownPskIdentity + \value CertificateRequired + \value NoApplicationProtocol + \value UnknownAlertMessage +*/ + /*! \fn void QSslSocket::encrypted() @@ -322,6 +390,48 @@ \sa QSslPreSharedKeyAuthenticator */ +/*! + \fn void QSslSocket::alertSent(QAlertLevel level, QAlertType type, const QString &description) + + QSslSocket emits this signal if an alert message was sent to a peer. \a level + describes if it was a warning or a fatal error. \a type gives the code + of the alert message. When a textual description of the alert message is + available, it is supplied in \a description. + + \note This signal is mostly informational and can be used for debugging + purposes, normally it does not require any actions from the application. + \note Not all backends support this functionality. + + \sa alertReceived(), QAlertLevel, QAlertType +*/ + +/*! + \fn void QSslSocket::alertReceived(QAlertLevel level, QAlertType type, const QString &description) + + QSslSocket emits this signal if an alert message was received from a peer. + \a level tells if the alert was fatal or it was a warning. \a type is the + code explaining why the alert was sent. When a textual description of + the alert message is available, it is supplied in \a description. + + \note The signal is mostly for informational and debugging purposes and does not + require any handling in the application. If the alert was fatal, underlying + backend will handle it and close the connection. + \note Not all backends support this functionality. + + \sa alertSent(), QAlertLevel, QAlertType +*/ + +/*! + \fn void QSslSocket::handshakeInterruptedOnError(const QSslError &error) + + QSslSocket emits this signal if a certificate verification error was + found and if early error reporting was enabled in QSslConfiguration. + An application is expected to inspect the \a error and decide if + it wants to continue the handshake, or abort it and send an alert message + to the peer. The signal-slot connection must be direct. + + \sa continueInterruptedHandshake(), sslErrors(), QSslConfiguration::setHandshakeMustInterruptOnError() +*/ #include "qssl_p.h" #include "qsslsocket.h" #include "qsslcipher.h" @@ -977,7 +1087,10 @@ void QSslSocket::setSslConfiguration(const QSslConfiguration &configuration) #if QT_CONFIG(ocsp) d->configuration.ocspStaplingEnabled = configuration.ocspStaplingEnabled(); #endif - +#if QT_CONFIG(openssl) + d->configuration.reportFromCallback = configuration.handshakeMustInterruptOnError(); + d->configuration.missingCertIsFatal = configuration.missingCertificateIsFatal(); +#endif // openssl // if the CA certificates were set explicitly (either via // QSslConfiguration::setCaCertificates() or QSslSocket::setCaCertificates(), // we cannot load the certificates on demand @@ -2043,6 +2156,23 @@ void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) d->ignoreErrorsList = errors; } + +/*! + \since 6.0 + + If an application wants to conclude a handshake even after receiving + handshakeInterruptedOnError() signal, it must call this function. + This call must be done from a slot function attached to the signal. + The signal-slot connection must be direct. + + \sa handshakeInterruptedOnError(), QSslConfiguration::setHandshakeMustInterruptOnError() +*/ +void QSslSocket::continueInterruptedHandshake() +{ + Q_D(QSslSocket); + d->handshakeInterrupted = false; +} + /*! \internal */ @@ -2445,6 +2575,10 @@ void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPri #if QT_CONFIG(ocsp) ptr->ocspStaplingEnabled = global->ocspStaplingEnabled; #endif +#if QT_CONFIG(openssl) + ptr->reportFromCallback = global->reportFromCallback; + ptr->missingCertIsFatal = global->missingCertIsFatal; +#endif } /*! diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index 843e2d15f5..8b0f317da4 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -63,6 +63,49 @@ class QSslEllipticCurve; class QSslPreSharedKeyAuthenticator; class QOcspResponse; +enum class QAlertLevel { + Warning, + Fatal, + Unknown +}; + +enum class QAlertType { + CloseNotify, + UnexpectedMessage = 10, + BadRecordMac = 20, + RecordOverflow = 22, + DecompressionFailure = 30, // reserved + HandshakeFailure = 40, + NoCertificate = 41, // reserved + BadCertificate = 42, + UnsupportedCertificate = 43, + CertificateRevoked = 44, + CertificateExpired = 45, + CertificateUnknown = 46, + IllegalParameter = 47, + UnknownCa = 48, + AccessDenied = 49, + DecodeError = 50, + DecryptError = 51, + ExportRestriction = 60, // reserved + ProtocolVersion = 70, + InsufficientSecurity = 71, + InternalError = 80, + InappropriateFallback = 86, + UserCancelled = 90, + NoRenegotiation = 100, + MissingExtension = 109, + UnsupportedExtension = 110, + CertificateUnobtainable = 111, // reserved + UnrecognizedName = 112, + BadCertificateStatusResponse = 113, + BadCertificateHashValue = 114, // reserved + UnknownPskIdentity = 115, + CertificateRequired = 116, + NoApplicationProtocol = 120, + UnknownAlertMessage = 255 +}; + class QSslSocketPrivate; class Q_NETWORK_EXPORT QSslSocket : public QTcpSocket { @@ -201,6 +244,7 @@ public: static QString sslLibraryBuildVersionString(); void ignoreSslErrors(const QList<QSslError> &errors); + void continueInterruptedHandshake(); public Q_SLOTS: void startClientEncryption(); @@ -214,6 +258,9 @@ Q_SIGNALS: void modeChanged(QSslSocket::SslMode newMode); void encryptedBytesWritten(qint64 totalBytes); void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator); + void alertSent(QAlertLevel level, QAlertType type, const QString &description); + void alertReceived(QAlertLevel level, QAlertType type, const QString &description); + void handshakeInterruptedOnError(const QSslError &error); protected: qint64 readData(char *data, qint64 maxlen) override; diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 2a23742bdf..489d7a8ee6 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -97,6 +97,123 @@ QT_BEGIN_NAMESPACE +namespace { + +QAlertLevel tlsAlertLevel(int value) +{ + if (const char *typeString = q_SSL_alert_type_string(value)) { + // Documented to return 'W' for warning, 'F' for fatal, + // 'U' for unknown. + switch (typeString[0]) { + case 'W': + return QAlertLevel::Warning; + case 'F': + return QAlertLevel::Fatal; + default:; + } + } + + return QAlertLevel::Unknown; +} + +QString tlsAlertDescription(int value) +{ + QString description = QLatin1String(q_SSL_alert_desc_string_long(value)); + if (!description.size()) + description = QLatin1String("no description provided"); + return description; +} + +QAlertType tlsAlertType(int value) +{ + // In case for some reason openssl gives us a value, + // which is not in our enum actually, we leave it to + // an application to handle (supposedly they have + // if or switch-statements). + return QAlertType(value & 0xff); +} + +} // Unnamed namespace + +extern "C" +{ + +void qt_AlertInfoCallback(const SSL *connection, int from, int value) +{ + // Passed to SSL_set_info_callback() + // https://www.openssl.org/docs/man1.1.1/man3/SSL_set_info_callback.html + + if (!connection) { +#ifdef QSSLSOCKET_DEBUG + qCWarning(lcSsl, "Invalid 'connection' parameter (nullptr)"); +#endif // QSSLSOCKET_DEBUG + return; + } + + const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData + + QSslSocketBackendPrivate::socketOffsetInExData; + auto privateSocket = + static_cast<QSslSocketBackendPrivate *>(q_SSL_get_ex_data(connection, offset)); + if (!privateSocket) { + // SSL_set_ex_data can fail: +#ifdef QSSLSOCKET_DEBUG + qCWarning(lcSsl, "No external data (socket backend) found for parameter 'connection'"); +#endif // QSSLSOCKET_DEBUG + return; + } + + if (!(from & SSL_CB_ALERT)) { + // We only want to know about alerts (at least for now). + return; + } + + if (from & SSL_CB_WRITE) + privateSocket->alertMessageSent(value); + else + privateSocket->alertMessageReceived(value); +} + +int q_X509CallbackDirect(int ok, X509_STORE_CTX *ctx) +{ + // Passed to SSL_CTX_set_verify() + // https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set_verify.html + // Returns 0 to abort verification, 1 to continue. + + // This is a new, experimental verification callback, reporting + // errors immediately and returning 0 or 1 depending on an application + // either ignoring or not ignoring verification errors as they come. + if (!ctx) { + qCWarning(lcSsl, "Invalid store context (nullptr)"); + return 0; + } + + if (!ok) { + // "Whenever a X509_STORE_CTX object is created for the verification of the + // peer's certificate during a handshake, a pointer to the SSL object is + // stored into the X509_STORE_CTX object to identify the connection affected. + // To retrieve this pointer the X509_STORE_CTX_get_ex_data() function can be + // used with the correct index." + SSL *ssl = static_cast<SSL *>(q_X509_STORE_CTX_get_ex_data(ctx, q_SSL_get_ex_data_X509_STORE_CTX_idx())); + if (!ssl) { + qCWarning(lcSsl, "No external data (SSL) found in X509 store object"); + return 0; + } + + const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData + + QSslSocketBackendPrivate::socketOffsetInExData; + auto privateSocket = static_cast<QSslSocketBackendPrivate *>(q_SSL_get_ex_data(ssl, offset)); + if (!privateSocket) { + qCWarning(lcSsl, "No external data (QSslSocketBackendPrivate) found in SSL object"); + return 0; + } + + return privateSocket->emitErrorFromCallback(ctx); + } + return 1; +} + +} // extern "C" + Q_GLOBAL_STATIC(QRecursiveMutex, qt_opensslInitMutex) bool QSslSocketPrivate::s_libraryLoaded = false; @@ -404,12 +521,15 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx) // Not found on store? Try SSL and its external data then. According to the OpenSSL's // documentation: // - // "Whenever a X509_STORE_CTX object is created for the verification of the peers certificate - // during a handshake, a pointer to the SSL object is stored into the X509_STORE_CTX object - // to identify the connection affected. To retrieve this pointer the X509_STORE_CTX_get_ex_data() - // function can be used with the correct index." + // "Whenever a X509_STORE_CTX object is created for the verification of the + // peer's certificate during a handshake, a pointer to the SSL object is + // stored into the X509_STORE_CTX object to identify the connection affected. + // To retrieve this pointer the X509_STORE_CTX_get_ex_data() function can be + // used with the correct index." + const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData + + QSslSocketBackendPrivate::errorOffsetInExData; if (SSL *ssl = static_cast<SSL *>(q_X509_STORE_CTX_get_ex_data(ctx, q_SSL_get_ex_data_X509_STORE_CTX_idx()))) - errors = ErrorListPtr(q_SSL_get_ex_data(ssl, QSslSocketBackendPrivate::s_indexForSSLExtraData + 1)); + errors = ErrorListPtr(q_SSL_get_ex_data(ssl, offset)); } if (!errors) { @@ -1195,18 +1315,32 @@ bool QSslSocketBackendPrivate::startHandshake() if (inSetAndEmitError) return false; + pendingFatalAlert = false; + errorsReportedFromCallback = false; QVector<QSslErrorEntry> lastErrors; - q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + 1, &lastErrors); + q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + errorOffsetInExData, &lastErrors); + + // SSL_set_ex_data can fail, but see the callback's code - we handle this there. + q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + socketOffsetInExData, this); + q_SSL_set_info_callback(ssl, qt_AlertInfoCallback); + int result = (mode == QSslSocket::SslClientMode) ? q_SSL_connect(ssl) : q_SSL_accept(ssl); - q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + 1, nullptr); + q_SSL_set_ex_data(ssl, s_indexForSSLExtraData + errorOffsetInExData, nullptr); + // Note, unlike errors as external data on SSL object, we do not unset + // a callback/ex-data if alert notifications are enabled: an alert can + // arrive after the handshake, for example, this happens when the server + // does not find a ClientCert or does not like it. - if (!lastErrors.isEmpty()) + if (!lastErrors.isEmpty() || errorsReportedFromCallback) storePeerCertificates(); - for (const auto ¤tError : qAsConst(lastErrors)) { - emit q->peerVerifyError(_q_OpenSSL_to_QSslError(currentError.code, - configuration.peerCertificateChain.value(currentError.depth))); - if (q->state() != QAbstractSocket::ConnectedState) - break; + + if (!errorsReportedFromCallback) { + for (const auto ¤tError : qAsConst(lastErrors)) { + emit q->peerVerifyError(_q_OpenSSL_to_QSslError(currentError.code, + configuration.peerCertificateChain.value(currentError.depth))); + if (q->state() != QAbstractSocket::ConnectedState) + break; + } } errorList << lastErrors; @@ -1230,6 +1364,10 @@ bool QSslSocketBackendPrivate::startHandshake() { const ScopedBool bg(inSetAndEmitError, true); setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, errorString); + if (pendingFatalAlert) { + trySendFatalAlert(); + pendingFatalAlert = false; + } } q->abort(); } @@ -1699,6 +1837,88 @@ bool QSslSocketBackendPrivate::checkOcspStatus() #endif // ocsp +void QSslSocketBackendPrivate::alertMessageSent(int value) +{ + Q_Q(QSslSocket); + + const auto level = tlsAlertLevel(value); + if (level == QAlertLevel::Fatal && !connectionEncrypted) { + // Note, this logic is handshake-time only: + pendingFatalAlert = true; + } + + emit q->alertSent(level, tlsAlertType(value), tlsAlertDescription(value)); +} + +void QSslSocketBackendPrivate::alertMessageReceived(int value) +{ + Q_Q(QSslSocket); + + emit q->alertReceived(tlsAlertLevel(value), tlsAlertType(value), tlsAlertDescription(value)); +} + +int QSslSocketBackendPrivate::emitErrorFromCallback(X509_STORE_CTX *ctx) +{ + // Returns 0 to abort verification, 1 to continue despite error (as + // OpenSSL expects from the verification callback). + Q_Q(QSslSocket); + + Q_ASSERT(ctx); + + using ScopedBool = QScopedValueRollback<bool>; + // While we are not setting, we are emitting and in general - + // we want to prevent accidental recursive startHandshake() + // calls: + const ScopedBool bg(inSetAndEmitError, true); + + X509 *x509 = q_X509_STORE_CTX_get_current_cert(ctx); + if (!x509) { + qCWarning(lcSsl, "Could not obtain the certificate (that failed to verify)"); + return 0; + } + const QSslCertificate certificate = QSslCertificatePrivate::QSslCertificate_from_X509(x509); + + const auto errorAndDepth = QSslErrorEntry::fromStoreContext(ctx); + const QSslError tlsError = _q_OpenSSL_to_QSslError(errorAndDepth.code, certificate); + + errorsReportedFromCallback = true; + handshakeInterrupted = true; + emit q->handshakeInterruptedOnError(tlsError); + + // Conveniently so, we also can access 'lastErrors' external data set + // in startHandshake, we store it for the case an application later + // wants to check errors (ignored or not): + const auto offset = QSslSocketBackendPrivate::s_indexForSSLExtraData + + QSslSocketBackendPrivate::errorOffsetInExData; + if (auto errorList = static_cast<QVector<QSslErrorEntry>*>(q_SSL_get_ex_data(ssl, offset))) + errorList->append(errorAndDepth); + + // An application is expected to ignore this error (by calling ignoreSslErrors) + // in its directly connected slot: + return !handshakeInterrupted; +} + +void QSslSocketBackendPrivate::trySendFatalAlert() +{ + Q_ASSERT(pendingFatalAlert); + + pendingFatalAlert = false; + QVarLengthArray<char, 4096> data; + int pendingBytes = 0; + while (plainSocket->isValid() && (pendingBytes = q_BIO_pending(writeBio)) > 0 + && plainSocket->openMode() != QIODevice::NotOpen) { + // Read encrypted data from the write BIO into a buffer. + data.resize(pendingBytes); + const int bioReadBytes = q_BIO_read(writeBio, data.data(), pendingBytes); + + // Write encrypted data from the buffer to the socket. + qint64 actualWritten = plainSocket->write(data.constData(), bioReadBytes); + if (actualWritten < 0) + return; + plainSocket->flush(); + } +} + void QSslSocketBackendPrivate::disconnectFromHost() { if (ssl) { diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h index 0370a7d2ac..06af9f5974 100644 --- a/src/network/ssl/qsslsocket_openssl_p.h +++ b/src/network/ssl/qsslsocket_openssl_p.h @@ -131,6 +131,10 @@ public: SSL_SESSION *session; QVector<QSslErrorEntry> errorList; static int s_indexForSSLExtraData; // index used in SSL_get_ex_data to get the matching QSslSocketBackendPrivate + enum ExDataOffset { + errorOffsetInExData = 1, + socketOffsetInExData = 2 + }; bool inSetAndEmitError = false; @@ -157,6 +161,15 @@ public: bool checkOcspStatus(); #endif + void alertMessageSent(int encoded); + void alertMessageReceived(int encoded); + + int emitErrorFromCallback(X509_STORE_CTX *ctx); + void trySendFatalAlert(); + + bool pendingFatalAlert = false; + bool errorsReportedFromCallback = false; + // This decription will go to setErrorAndEmit(SslHandshakeError, ocspErrorDescription) QString ocspErrorDescription; // These will go to sslErrors() diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 3504924888..5b0a70d495 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -156,6 +156,10 @@ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG) DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return) DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return) DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return) +using info_callback = void (*) (const SSL *ssl, int type, int val); +DEFINEFUNC2(void, SSL_set_info_callback, SSL *ssl, ssl, info_callback cb, cb, return, return) +DEFINEFUNC(const char *, SSL_alert_type_string, int value, value, return nullptr, return) +DEFINEFUNC(const char *, SSL_alert_desc_string_long, int value, value, return nullptr, return) #ifdef TLS1_3_VERSION DEFINEFUNC2(int, SSL_CTX_set_ciphersuites, SSL_CTX *ctx, ctx, const char *str, str, return 0, return) DEFINEFUNC2(void, SSL_set_psk_use_session_callback, SSL *ssl, ssl, q_SSL_psk_use_session_cb_func_t callback, callback, return, DUMMYARG) @@ -839,7 +843,9 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(OPENSSL_sk_value) RESOLVEFUNC(DH_get0_pqg) RESOLVEFUNC(SSL_CTX_set_options) - + RESOLVEFUNC(SSL_set_info_callback) + RESOLVEFUNC(SSL_alert_type_string) + RESOLVEFUNC(SSL_alert_desc_string_long) #ifdef TLS1_3_VERSION RESOLVEFUNC(SSL_CTX_set_ciphersuites) RESOLVEFUNC(SSL_set_psk_use_session_callback) diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index baf1a43113..ac6aa1760f 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -719,6 +719,10 @@ int q_OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); void *q_CRYPTO_malloc(size_t num, const char *file, int line); #define q_OPENSSL_malloc(num) q_CRYPTO_malloc(num, "", 0) +void q_SSL_set_info_callback(SSL *ssl, void (*cb) (const SSL *ssl, int type, int val)); +const char *q_SSL_alert_type_string(int value); +const char *q_SSL_alert_desc_string_long(int value); + QT_END_NAMESPACE #endif diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 1abd18bb32..4b020b6a73 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -208,6 +208,7 @@ protected: bool paused; bool flushTriggered; QVector<QOcspResponse> ocspResponses; + bool handshakeInterrupted = false; }; #if QT_CONFIG(securetransport) || QT_CONFIG(schannel) -- cgit v1.2.3 From deb166a5ff0ed3693b7d9a1b6a02b41f3f196b39 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Wed, 27 Nov 2019 15:25:29 +0100 Subject: Make QMacTimeZonePrivate default constructor more efficient Inline systemTimeZoneId() in it to save the need for init(). We thus save the lookup by name for a time-zone object, when that object is what we took the name from anyway. Do some minor tidy-up in the other constructors and add an assert to systemTimeZoneId() to match the new one in the default constructor. Change-Id: Ib70acf31bdb4a4fa1306eebd1fd5f00ad6b89bcc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/corelib/time/qtimezoneprivate_mac.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate_mac.mm b/src/corelib/time/qtimezoneprivate_mac.mm index 4509e316f9..406ee6445f 100644 --- a/src/corelib/time/qtimezoneprivate_mac.mm +++ b/src/corelib/time/qtimezoneprivate_mac.mm @@ -60,22 +60,24 @@ QT_BEGIN_NAMESPACE // Create the system default time zone QMacTimeZonePrivate::QMacTimeZonePrivate() - : m_nstz(0) { - init(systemTimeZoneId()); + // Reset the cached system tz then instantiate it: + [NSTimeZone resetSystemTimeZone]; + m_nstz = [NSTimeZone.systemTimeZone retain]; + Q_ASSERT(m_nstz); + m_id = QString::fromNSString(m_nstz.name).toUtf8(); } // Create a named time zone QMacTimeZonePrivate::QMacTimeZonePrivate(const QByteArray &ianaId) - : m_nstz(0) + : m_nstz(nil) { init(ianaId); } QMacTimeZonePrivate::QMacTimeZonePrivate(const QMacTimeZonePrivate &other) - : QTimeZonePrivate(other), m_nstz(0) + : QTimeZonePrivate(other), m_nstz([other.m_nstz copy]) { - m_nstz = [other.m_nstz copy]; } QMacTimeZonePrivate::~QMacTimeZonePrivate() @@ -316,6 +318,7 @@ QByteArray QMacTimeZonePrivate::systemTimeZoneId() const { // Reset the cached system tz then return the name [NSTimeZone resetSystemTimeZone]; + Q_ASSERT(NSTimeZone.systemTimeZone); return QString::fromNSString([[NSTimeZone systemTimeZone] name]).toUtf8(); } -- cgit v1.2.3 From dc7fa56948a2a7953f645c7f9d7237925b3f9abe Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Wed, 27 Nov 2019 17:08:56 +0100 Subject: QMacTimeZonePrivate: use .member rather than [- member] notation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently this is our preferred style for Objective C member references. Change-Id: I8b2bbaabadbea2cfa74f209372e77cee79e3c895 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> --- src/corelib/time/qtimezoneprivate_mac.mm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate_mac.mm b/src/corelib/time/qtimezoneprivate_mac.mm index 406ee6445f..1fb48a31d3 100644 --- a/src/corelib/time/qtimezoneprivate_mac.mm +++ b/src/corelib/time/qtimezoneprivate_mac.mm @@ -111,7 +111,7 @@ void QMacTimeZonePrivate::init(const QByteArray &ianaId) QString QMacTimeZonePrivate::comment() const { - return QString::fromNSString([m_nstz description]); + return QString::fromNSString(m_nstz.description); } QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType, @@ -214,7 +214,7 @@ bool QMacTimeZonePrivate::hasTransitions() const // TODO Not sure what is returned in event of no transitions, assume will be before requested date NSDate *epoch = [NSDate dateWithTimeIntervalSince1970:0]; const NSDate *date = [m_nstz nextDaylightSavingTimeTransitionAfterDate:epoch]; - const bool result = ([date timeIntervalSince1970] > [epoch timeIntervalSince1970]); + const bool result = (date.timeIntervalSince1970 > epoch.timeIntervalSince1970); return result; } @@ -224,7 +224,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc const NSTimeInterval seconds = afterMSecsSinceEpoch / 1000.0; NSDate *nextDate = [NSDate dateWithTimeIntervalSince1970:seconds]; nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate]; - const NSTimeInterval nextSecs = [nextDate timeIntervalSince1970]; + const NSTimeInterval nextSecs = nextDate.timeIntervalSince1970; if (nextDate == nil || nextSecs <= seconds) { [nextDate release]; return invalidData(); @@ -250,7 +250,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec NSDate *nextDate = [NSDate dateWithTimeIntervalSince1970:nextSecs]; nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate]; if (nextDate != nil - && (tranSecs = [nextDate timeIntervalSince1970]) < endSecs) { + && (tranSecs = nextDate.timeIntervalSince1970) < endSecs) { // There's a transition within the last year before endSecs: nextSecs = tranSecs; } else { @@ -259,7 +259,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate]; if (nextDate != nil) { NSTimeInterval lateSecs = nextSecs; - nextSecs = [nextDate timeIntervalSince1970]; + nextSecs = nextDate.timeIntervalSince1970; Q_ASSERT(nextSecs <= endSecs - year || nextSecs == tranSecs); /* We're looking at the first ever transition for our zone, at @@ -285,8 +285,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec NSTimeInterval middle = nextSecs / 2 + lateSecs / 2; NSDate *split = [NSDate dateWithTimeIntervalSince1970:middle]; split = [m_nstz nextDaylightSavingTimeTransitionAfterDate:split]; - if (split != nil - && (tranSecs = [split timeIntervalSince1970]) < endSecs) { + if (split != nil && (tranSecs = split.timeIntervalSince1970) < endSecs) { nextDate = split; nextSecs = tranSecs; } else { @@ -303,7 +302,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec while (nextDate != nil && nextSecs < endSecs) { prevSecs = nextSecs; nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate]; - nextSecs = [nextDate timeIntervalSince1970]; + nextSecs = nextDate.timeIntervalSince1970; if (nextSecs <= prevSecs) // presumably no later data available break; } @@ -319,18 +318,18 @@ QByteArray QMacTimeZonePrivate::systemTimeZoneId() const // Reset the cached system tz then return the name [NSTimeZone resetSystemTimeZone]; Q_ASSERT(NSTimeZone.systemTimeZone); - return QString::fromNSString([[NSTimeZone systemTimeZone] name]).toUtf8(); + return QString::fromNSString(NSTimeZone.systemTimeZone.name).toUtf8(); } QList<QByteArray> QMacTimeZonePrivate::availableTimeZoneIds() const { - NSEnumerator *enumerator = [[NSTimeZone knownTimeZoneNames] objectEnumerator]; - QByteArray tzid = QString::fromNSString([enumerator nextObject]).toUtf8(); + NSEnumerator *enumerator = NSTimeZone.knownTimeZoneNames.objectEnumerator; + QByteArray tzid = QString::fromNSString(enumerator.nextObject).toUtf8(); QList<QByteArray> list; while (!tzid.isEmpty()) { list << tzid; - tzid = QString::fromNSString([enumerator nextObject]).toUtf8(); + tzid = QString::fromNSString(enumerator.nextObject).toUtf8(); } std::sort(list.begin(), list.end()); -- cgit v1.2.3 From de6520805abafbc6f898b3fec043e5d85827dfd0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Thu, 14 Nov 2019 17:11:11 +0100 Subject: Document that toggleViewAction can't be used to toggle the dock widget ...from code. This is by design; the action is updated when the dock widget changes, not the other way around (which would easily result in infinite loops). Change-Id: I9e71784d239a9cbb6c8efaeaa3e3adc6dc590f65 Fixes: QTBUG-80022 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> --- src/widgets/widgets/qdockwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 687ef8ba29..bcbd3dd2d4 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1609,11 +1609,14 @@ bool QDockWidget::event(QEvent *event) #ifndef QT_NO_ACTION /*! - Returns a checkable action that can be used to show or close this - dock widget. + Returns a checkable action that can be added to menus and toolbars so that + the user can show or close this dock widget. The action's text is set to the dock widget's window title. + \note The action can not be used to programmatically show or hide the dock + widget. Use the \l visible property for that. + \sa QAction::text, QWidget::windowTitle */ QAction * QDockWidget::toggleViewAction() const -- cgit v1.2.3 From 8652c79df0a47264a2d525424484e15744e2462b Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Tue, 3 Dec 2019 08:12:50 +0100 Subject: Remove QVariant::operator< and related operator The operator does not have a total order Change-Id: Ifd263c3495aca08c8ccceb9949596c308a76a6c1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/kernel/qvariant.cpp | 119 ---------------------------------------- src/corelib/kernel/qvariant.h | 9 --- 2 files changed, 128 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 258da1a8d4..1fe6ca7b4e 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3840,58 +3840,6 @@ bool QVariant::convert(const int type, void *ptr) const QMetaType::registerComparators(). */ -/*! - \fn bool QVariant::operator<(const QVariant &v) const - - Compares this QVariant with \a v and returns \c true if this is less than \a v. - - \note Comparability might not be availabe for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). -*/ - -/*! - \fn bool QVariant::operator<=(const QVariant &v) const - - Compares this QVariant with \a v and returns \c true if this is less or equal than \a v. - - \note Comparability might not be available for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). -*/ - -/*! - \fn bool QVariant::operator>(const QVariant &v) const - - Compares this QVariant with \a v and returns \c true if this is larger than \a v. - - \note Comparability might not be available for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). -*/ - -/*! - \fn bool QVariant::operator>=(const QVariant &v) const - - Compares this QVariant with \a v and returns \c true if this is larger or equal than \a v. - - \note Comparability might not be available for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). -*/ - static bool qIsNumericType(uint tp) { static const qulonglong numericTypeBits = @@ -4069,73 +4017,6 @@ bool QVariant::cmp(const QVariant &v) const return cmp_helper(v1.d, v2.d); } -/*! - \internal - */ -int QVariant::compare(const QVariant &v) const -{ - // try numerics first, with C++ type promotion rules (no conversion) - if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) - return numericCompare(&d, &v.d); - - // check for equality next, as more types implement operator== than operator< - if (cmp(v)) - return 0; - - const QVariant *v1 = this; - const QVariant *v2 = &v; - QVariant converted1; - QVariant converted2; - - if (d.type != v.d.type) { - // if both types differ, try to convert - if (v2->canConvert(v1->d.type)) { - converted2 = *v2; - if (converted2.convert(v1->d.type)) - v2 = &converted2; - } - if (v1->d.type != v2->d.type && v1->canConvert(v2->d.type)) { - converted1 = *v1; - if (converted1.convert(v2->d.type)) - v1 = &converted1; - } - if (v1->d.type != v2->d.type) { - // if conversion fails, default to toString - int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive); - if (r == 0) { - // cmp(v) returned false, so we should try to agree with it. - return (v1->d.type < v2->d.type) ? -1 : 1; - } - return r; - } - - // did we end up with two numerics? If so, restart - if (qIsNumericType(v1->d.type) && qIsNumericType(v2->d.type)) - return v1->compare(*v2); - } - if (v1->d.type >= QMetaType::User) { - int result; - if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2->d)), d.type, &result)) - return result; - } - switch (v1->d.type) { - case QVariant::Date: - return v1->toDate() < v2->toDate() ? -1 : 1; - case QVariant::Time: - return v1->toTime() < v2->toTime() ? -1 : 1; - case QVariant::DateTime: - return v1->toDateTime() < v2->toDateTime() ? -1 : 1; - case QVariant::StringList: - return v1->toStringList() < v2->toStringList() ? -1 : 1; - } - int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive); - if (r == 0) { - // cmp(v) returned false, so we should try to agree with it. - return (d.type < v.d.type) ? -1 : 1; - } - return r; -} - /*! \internal */ diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 331adea4e7..21802aee85 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -465,14 +465,6 @@ class Q_CORE_EXPORT QVariant { return cmp(v); } inline bool operator!=(const QVariant &v) const { return !cmp(v); } - inline bool operator<(const QVariant &v) const - { return compare(v) < 0; } - inline bool operator<=(const QVariant &v) const - { return compare(v) <= 0; } - inline bool operator>(const QVariant &v) const - { return compare(v) > 0; } - inline bool operator>=(const QVariant &v) const - { return compare(v) >= 0; } protected: friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); @@ -491,7 +483,6 @@ public: Private d; void create(int type, const void *copy); bool cmp(const QVariant &other) const; - int compare(const QVariant &other) const; bool convert(const int t, void *ptr) const; // ### Qt6: drop const private: -- cgit v1.2.3 From f43cb31ba00a431c6d0a0b17750483a72ae03bb0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Sat, 23 Nov 2019 12:28:07 +0100 Subject: Deprecate QVariant::operator< and related operators Since the operator does not have a total order, it is kind of pointless, and this is going to be removed in Qt6 Change-Id: I754be059726bf30993550a2d753f8b865f2d4a5f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/corelib/kernel/qvariant.cpp | 14 ++++++++++++++ src/corelib/kernel/qvariant.h | 10 ++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 762a761026..d1eb463514 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3829,6 +3829,7 @@ bool QVariant::convert(const int type, void *ptr) const /*! \fn bool QVariant::operator<(const QVariant &v) const + \obsolete Compares this QVariant with \a v and returns \c true if this is less than \a v. @@ -3838,10 +3839,15 @@ bool QVariant::convert(const int type, void *ptr) const \warning To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators(). + + This operator is deprecated as it cannot establish a total order required + for most use of this operator, which is the reason you cannot use QVariant + as the key of a QMap. */ /*! \fn bool QVariant::operator<=(const QVariant &v) const + \obsolete Compares this QVariant with \a v and returns \c true if this is less or equal than \a v. @@ -3851,10 +3857,13 @@ bool QVariant::convert(const int type, void *ptr) const \warning To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators(). + + This operator is deprecated as it cannot establish a total order. */ /*! \fn bool QVariant::operator>(const QVariant &v) const + \obsolete Compares this QVariant with \a v and returns \c true if this is larger than \a v. @@ -3864,10 +3873,13 @@ bool QVariant::convert(const int type, void *ptr) const \warning To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators(). + + This operator is deprecated as it cannot establish a total order. */ /*! \fn bool QVariant::operator>=(const QVariant &v) const + \obsolete Compares this QVariant with \a v and returns \c true if this is larger or equal than \a v. @@ -3877,6 +3889,8 @@ bool QVariant::convert(const int type, void *ptr) const \warning To make this function work with a custom type registered with qRegisterMetaType(), its comparison operator must be registered using QMetaType::registerComparators(). + + This operator is deprecated as it cannot establish a total order. */ static bool qIsNumericType(uint tp) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 86c7414704..6e27c9bf1f 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -463,14 +463,16 @@ class Q_CORE_EXPORT QVariant { return cmp(v); } inline bool operator!=(const QVariant &v) const { return !cmp(v); } - inline bool operator<(const QVariant &v) const +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED inline bool operator<(const QVariant &v) const { return compare(v) < 0; } - inline bool operator<=(const QVariant &v) const + QT_DEPRECATED inline bool operator<=(const QVariant &v) const { return compare(v) <= 0; } - inline bool operator>(const QVariant &v) const + QT_DEPRECATED inline bool operator>(const QVariant &v) const { return compare(v) > 0; } - inline bool operator>=(const QVariant &v) const + QT_DEPRECATED inline bool operator>=(const QVariant &v) const { return compare(v) >= 0; } +#endif protected: friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); -- cgit v1.2.3 From 92cf38018afe8f598f2c337c0d202f3767b04ead Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse <jhasse@bixense.com> Date: Wed, 4 Dec 2019 10:40:20 +0100 Subject: Quit application when QWindowsSystemTrayIcon receives WM_CLOSE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an application only has a trayicon and is killed by `taskkill /IM binary.exe` the trayicon's HWND will receive a WM_CLOSE message. If we don't handle this, the tray icon will close anyway, but the app still runs in the task manager. Fixes: QTBUG-43855 Change-Id: I5f82a068df9c40360bd565a2681e1b37ff114e44 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index f2dba4d06b..22cdefbbbc 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -62,6 +62,7 @@ #include <QtCore/qrect.h> #include <QtCore/qvector.h> #include <QtCore/qsettings.h> +#include <qpa/qwindowsysteminterface.h> #include <qt_windows.h> #include <commctrl.h> @@ -136,7 +137,7 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT messa { if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON || message == WM_INITMENU || message == WM_INITMENUPOPUP - || message == WM_COMMAND) { + || message == WM_CLOSE || message == WM_COMMAND) { const int index = indexOfHwnd(hwnd); if (index >= 0) { MSG msg; @@ -439,6 +440,9 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result) case WM_INITMENUPOPUP: QWindowsPopupMenu::notifyAboutToShow(reinterpret_cast<HMENU>(message.wParam)); break; + case WM_CLOSE: + QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>(); + break; case WM_COMMAND: QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam)); break; -- cgit v1.2.3 From 913146ccd401216f71f037ea304b5e61b7a138cf Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete <paul.tvete@qt.io> Date: Fri, 29 Nov 2019 12:41:38 +0100 Subject: RHI: new native texture API The new version takes/returns a value that can be unpacked and passed to other functions without knowing which backend is in use. The old API will be removed in a later change when dependent modules have been updated Task-number: QTBUG-78570 Change-Id: I18d928ceef3cb617c0c509ecccb345551a7990af Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/rhi/qrhi.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++ src/gui/rhi/qrhi_p.h | 7 +++++ src/gui/rhi/qrhid3d11.cpp | 28 ++++++++++++++++++ src/gui/rhi/qrhid3d11_p_p.h | 2 ++ src/gui/rhi/qrhigles2.cpp | 29 +++++++++++++++++++ src/gui/rhi/qrhigles2_p_p.h | 2 ++ src/gui/rhi/qrhimetal.mm | 29 +++++++++++++++++++ src/gui/rhi/qrhimetal_p_p.h | 2 ++ src/gui/rhi/qrhinull.cpp | 6 ++++ src/gui/rhi/qrhinull_p_p.h | 1 + src/gui/rhi/qrhivulkan.cpp | 30 ++++++++++++++++++++ src/gui/rhi/qrhivulkan_p_p.h | 2 ++ 12 files changed, 205 insertions(+) (limited to 'src') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index ece5190ff7..58f30deb41 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2159,6 +2159,32 @@ QRhiResource::Type QRhiRenderBuffer::resourceType() const \value ASTC_12x12 */ +/*! + \class QRhiTexture::NativeTexture + \brief Contains information about the underlying native resources of a texture. + */ + +/*! + \variable QRhiTexture::NativeTexture::object + \brief a pointer to the native object handle. + + With OpenGL, the native handle is a GLuint value, so \c object is then a + pointer to a GLuint. With Vulkan, the native handle is a VkImage, so \c + object is a pointer to a VkImage. With Direct3D 11 and Metal \c + object is a pointer to a ID3D11Texture2D or MTLTexture pointer, respectively. + + \note Pay attention to the fact that \a object is always a pointer + to the native texture handle type, even if the native type itself is a + pointer. + */ + +/*! + \variable QRhiTexture::NativeTexture::layout + \brief Specifies the current image layout for APIs like Vulkan. + + For Vulkan, \c layout contains a \c VkImageLayout value. + */ + /*! \internal */ @@ -2196,11 +2222,24 @@ QRhiResource::Type QRhiTexture::resourceType() const \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles */ +// TODO: remove this version once QtQuick has stopped using it const QRhiNativeHandles *QRhiTexture::nativeHandles() { return nullptr; } +/*! + \return the underlying native resources for this texture. The returned value + will be empty if exposing the underlying native resources is not supported by + the backend. + + \sa buildFrom() + */ +QRhiTexture::NativeTexture QRhiTexture::nativeTexture() +{ + return {}; +} + /*! Similar to build() except that no new native textures are created. Instead, the texture from \a src is used. @@ -2224,12 +2263,40 @@ const QRhiNativeHandles *QRhiTexture::nativeHandles() \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles */ +// TODO: remove this version once QtQuick has stopped using it bool QRhiTexture::buildFrom(const QRhiNativeHandles *src) { Q_UNUSED(src); return false; } +/*! + Similar to build() except that no new native textures are created. Instead, + the native texture resources specified by \a src is used. + + This allows importing an existing native texture object (which must belong + to the same device or sharing context, depending on the graphics API) from + an external graphics engine. + + \note format(), pixelSize(), sampleCount(), and flags() must still be set + correctly. Passing incorrect sizes and other values to QRhi::newTexture() + and then following it with a buildFrom() expecting that the native texture + object alone is sufficient to deduce such values is \b wrong and will lead + to problems. + + \note QRhiTexture does not take ownership of the texture object. release() + does not free the object or any associated memory. + + The opposite of this operation, exposing a QRhiTexture-created native + texture object to a foreign engine, is possible via nativeTexture(). + +*/ +bool QRhiTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + Q_UNUSED(src); + return false; +} + /*! \class QRhiSampler \internal diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 6fb9c44ae6..44118b2f10 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -760,6 +760,11 @@ public: ASTC_12x12 }; + struct NativeTexture { + const void *object; + int layout; + }; + QRhiResource::Type resourceType() const override; Format format() const { return m_format; } @@ -776,7 +781,9 @@ public: virtual bool build() = 0; virtual const QRhiNativeHandles *nativeHandles(); + virtual NativeTexture nativeTexture(); virtual bool buildFrom(const QRhiNativeHandles *src); + virtual bool buildFrom(NativeTexture src); protected: QRhiTexture(QRhiImplementation *rhi, Format format_, const QSize &pixelSize_, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 52109edce0..ba2488bffb 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -2764,11 +2764,39 @@ bool QD3D11Texture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) +{ + auto *srcTex = static_cast<ID3D11Texture2D * const *>(src.object); + if (!srcTex || !*srcTex) + return false; + + if (!prepareBuild()) + return false; + + tex = *srcTex; + + if (!finishBuild()) + return false; + + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, int(sampleDesc.Count))); + + owns = false; + QRHI_RES_RHI(QRhiD3D11); + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QD3D11Texture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QD3D11Texture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) { if (perLevelViews[level]) diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 13c56b1d6d..8f02c4300b 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -100,7 +100,9 @@ struct QD3D11Texture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); bool finishBuild(); diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index b551980bb3..563d59b318 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3404,11 +3404,40 @@ bool QGles2Texture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QGles2Texture::buildFrom(QRhiTexture::NativeTexture src) +{ + const uint *textureId = static_cast<const uint *>(src.object); + if (!textureId || !*textureId) + return false; + + if (!prepareBuild()) + return false; + + texture = *textureId; + specified = true; + + QRHI_RES_RHI(QRhiGles2); + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); + + owns = false; + nativeHandlesStruct.texture = texture; + + generation += 1; + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QGles2Texture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QGles2Texture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + QGles2Sampler::QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v) : QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v) diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index b0f5e340fb..0283fadb4e 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -133,7 +133,9 @@ struct QGles2Texture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index e5af1cfab1..555ed5e79f 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2499,11 +2499,40 @@ bool QMetalTexture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + void * const * tex = (void * const *) src.object; + if (!tex || !*tex) + return false; + + if (!prepareBuild()) + return false; + + d->tex = (id<MTLTexture>) *tex; + + d->owns = false; + nativeHandlesStruct.texture = d->tex; + + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples)); + + lastActiveFrameSlot = -1; + generation += 1; + QRHI_RES_RHI(QRhiMetal); + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QMetalTexture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QMetalTexture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + id<MTLTexture> QMetalTextureData::viewForLevel(int level) { Q_ASSERT(level >= 0 && level < int(q->mipLevelCount)); diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 7876539fcd..8e655fd98b 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -101,7 +101,9 @@ struct QMetalTexture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index 0baea1b9d6..80f004e049 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -651,6 +651,12 @@ bool QNullTexture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + Q_UNUSED(src) + return buildFrom(nullptr); +} + const QRhiNativeHandles *QNullTexture::nativeHandles() { return &nativeHandlesStruct; diff --git a/src/gui/rhi/qrhinull_p_p.h b/src/gui/rhi/qrhinull_p_p.h index c96f279f7d..57c3de0418 100644 --- a/src/gui/rhi/qrhinull_p_p.h +++ b/src/gui/rhi/qrhinull_p_p.h @@ -81,6 +81,7 @@ struct QNullTexture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; QRhiNullTextureNativeHandles nativeHandlesStruct; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 49ca2326bc..21ae142b1d 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -5370,12 +5370,42 @@ bool QVkTexture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QVkTexture::buildFrom(QRhiTexture::NativeTexture src) +{ + auto *img = static_cast<const VkImage*>(src.object); + if (!img || !*img) + return false; + + if (!prepareBuild()) + return false; + + image = *img; + + if (!finishBuild()) + return false; + + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, samples)); + + usageState.layout = VkImageLayout(src.layout); + + owns = false; + QRHI_RES_RHI(QRhiVulkan); + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QVkTexture::nativeHandles() { nativeHandlesStruct.layout = usageState.layout; return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QVkTexture::nativeTexture() +{ + return {&nativeHandlesStruct.image, usageState.layout}; +} + VkImageView QVkTexture::imageViewForLevel(int level) { Q_ASSERT(level >= 0 && level < int(mipLevelCount)); diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index ffa8c59ed5..d1b77870a1 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -121,7 +121,9 @@ struct QVkTexture : public QRhiTexture void release() override; bool build() override; bool buildFrom(const QRhiNativeHandles *src) override; + bool buildFrom(NativeTexture src) override; const QRhiNativeHandles *nativeHandles() override; + NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); bool finishBuild(); -- cgit v1.2.3 From 5a6fb46488ebc26b79b9d37a7f91969e0d852b4f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete <paul.tvete@qt.io> Date: Mon, 2 Dec 2019 17:30:18 +0100 Subject: QGraphicsItem: Fix mouse tracking with modal panels This fixes the case where a mouse tracking item is added to the scene while a modal panel is blocking. In order to optimize event delivery, mouse tracking is enabled for the view only when an item that needs it is added. This means that we cannot use itemAcceptsHoverEvents_helper(), since that returns whether the item _currently_ needs hover events, and we need to know whether it will need them in the future. [ChangeLog][QtWidgets][QGraphicsView] Fixed a bug where hover events would not be delivered if the item was added while blocked by a modal panel. Fixes: QTBUG-77233 Change-Id: Ifc95869f2cc9c8c048330928ef8a13cd27cfd0f9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name> --- src/widgets/graphicsview/qgraphicsscene.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index a47d0d879d..d641d17232 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -2568,8 +2568,16 @@ void QGraphicsScene::addItem(QGraphicsItem *item) ++d->selectionChanging; int oldSelectedItemSize = d->selectedItems.size(); - // Enable mouse tracking if the item accepts hover events or has a cursor set. - if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) { + // Enable mouse tracking if we haven't already done so, and the item needs it. + // We cannot use itemAcceptsHoverEvents_helper() here, since we need to enable + // mouse tracking also if this item is temporarily blocked by a modal panel. + + auto needsMouseTracking = [](const QGraphicsItemPrivate *item) { + return item->acceptsHover + || (item->isWidget && static_cast<const QGraphicsWidgetPrivate *>(item)->hasDecoration()); + }; + + if (d->allItemsIgnoreHoverEvents && needsMouseTracking(item->d_ptr.data())) { d->allItemsIgnoreHoverEvents = false; d->enableMouseTrackingOnViews(); } -- cgit v1.2.3 From 3359b29c99581f52acf033489ad35884a01ccac8 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale <fabian.kosmale@qt.io> Date: Tue, 3 Dec 2019 11:13:42 +0100 Subject: QDoubleValidator: Fix thousand separator handling QDoubleValidator would accept "1,23" as valid in a locale which has ',' as a thousand separator. However, it should have been Intermediate instead, as there is still one digit missing. Fixes: QTBUG-75110 Change-Id: I6de90f0b6f1eae95dc8dfc8e5f9658e482e46db3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/gui/util/qvalidator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 2237b016e9..54cbb28ffa 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -688,7 +688,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL return QValidator::Invalid; bool ok = false; - double i = buff.toDouble(&ok); // returns 0.0 if !ok + double i = locale.toDouble(input, &ok); // returns 0.0 if !ok if (i == qt_qnan()) return QValidator::Invalid; if (!ok) -- cgit v1.2.3 From 7b34da9ef12554025bb4a8f4750e5807cc37f38c Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 3 Dec 2018 11:16:18 +0100 Subject: Add QHash::insert(const QHash &other) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As opposed to unite(), this inserts one hash into the other without duplicating elements. Change-Id: Ifc786c48f5dc3ab18c29782e73eac3c1a3ef8981 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/tools/qhash.cpp | 12 ++++++++++++ src/corelib/tools/qhash.h | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index a53d6db997..dcac91778f 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1807,6 +1807,18 @@ uint qHash(long double key, uint seed) noexcept \sa insertMulti() */ +/*! \fn template <class Key, class T> void QHash<Key, T>::insert(const QHash &other) + \since 5.15 + + Inserts all the items in the \a other hash into this hash. + + If a key is common to both hashes, its value will be replaced with the + value stored in \a other. + + \note If \a other contains multiple entries with the same key then the + final value of the key is undefined. +*/ + /*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::insertMulti(const Key &key, const T &value) Inserts a new item with the \a key and a value of \a value. diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 42f8dbd155..89697b1fd1 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -526,6 +526,7 @@ public: const_iterator find(const Key &key) const; const_iterator constFind(const Key &key) const; iterator insert(const Key &key, const T &value); + void insert(const QHash &hash); iterator insertMulti(const Key &key, const T &value); QHash &unite(const QHash &other); @@ -840,6 +841,31 @@ Q_INLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::insert(const K return iterator(*node); } +template <class Key, class T> +Q_INLINE_TEMPLATE void QHash<Key, T>::insert(const QHash &hash) +{ + if (d == hash.d) + return; + + detach(); + + QHashData::Node *i = hash.d->firstNode(); + QHashData::Node *end = reinterpret_cast<QHashData::Node *>(hash.e); + while (i != end) { + Node *n = concrete(i); + Node **node = findNode(n->key, n->h); + if (*node == e) { + if (d->willGrow()) + node = findNode(n->key, n->h); + createNode(n->h, n->key, n->value, node); + } else { + if (!std::is_same<T, QHashDummyValue>::value) + (*node)->value = n->value; + } + i = QHashData::nextNode(i); + } +} + template <class Key, class T> Q_INLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::insertMulti(const Key &akey, const T &avalue) -- cgit v1.2.3 From d872719bf543a60108db88632d061e343e12b607 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 26 Nov 2018 10:18:24 +0100 Subject: Don't use QHash::unite to merge hashes QHash::unite can silently turn a regular QHash into a multi hash, something that is not intended here. Use a regular insert() instead. Change-Id: I9244a8553e84eed5367939019347b51491765ea0 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/util/qshadergraphloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/util/qshadergraphloader.cpp b/src/gui/util/qshadergraphloader.cpp index a393e876e0..26848020f2 100644 --- a/src/gui/util/qshadergraphloader.cpp +++ b/src/gui/util/qshadergraphloader.cpp @@ -136,7 +136,7 @@ void QShaderGraphLoader::load() if (prototypesValue.isObject()) { QShaderNodesLoader loader; loader.load(prototypesValue.toObject()); - m_prototypes.unite(loader.nodes()); + m_prototypes.insert(loader.nodes()); } else { qWarning() << "Invalid prototypes property, should be an object"; m_status = Error; -- cgit v1.2.3 From ccef2c33b284f2fd0bc08d518398af58214b020f Mon Sep 17 00:00:00 2001 From: Laurent Montel <laurent.montel@kdab.com> Date: Tue, 3 Dec 2019 13:42:08 +0100 Subject: Fix compile with we use QT_DISABLE_DEPRECATED_BEFORE=0x060000 in apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in qt5.15 you deprecated iterator &operator--() in qhash but QDataStream needs it. (see writeAssociativeContainer) So when we compile without deprecated method we can see: qdatastream.h:333:9: error: no match for ‘operator--’ (operand type is ‘QHash<QString, QImage>::const_iterator’) 333 | --it; | ^~~~ The current code is only QHash<QString, QImage> m_images; QDataStream stream(&file); stream << m_images; Change-Id: I12e61c0c60615455ac1eeff02969f155edb12e56 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/serialization/qdatastream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index 332828b21e..d9d4a4fcd3 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -321,7 +321,7 @@ template <typename Container> QDataStream &writeAssociativeContainer(QDataStream &s, const Container &c) { s << quint32(c.size()); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15) // Deserialization should occur in the reverse order. // Otherwise, value() will return the least recently inserted // value instead of the most recently inserted one. -- cgit v1.2.3 From 925b33bdaabc7d07d6910d5696af1ff49287d8fa Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 26 Nov 2019 19:32:21 +0100 Subject: QPlainTextEdit: update internal palette on QEvent::EnabledChange QEvent::EnabledChange did not update the palette of the internal QPlainTextEditControl which lead to a wrong text color when the QPlainTextEdit was disabled e.g. due to a QGroupBox. Fix it the same way it is done in QTextEdit - set the new palette also to the internal control when QEvent::EnabledChange is received. Fixes: QTBUG-80150 Change-Id: Icbeddf3d6cd4877a3d8d4a06b2da69383dd776d2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/widgets/qplaintextedit.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 0a81931b57..e8da720b58 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -2328,6 +2328,7 @@ void QPlainTextEdit::changeEvent(QEvent *e) d->autoScrollTimer.stop(); } else if (e->type() == QEvent::EnabledChange) { e->setAccepted(isEnabled()); + d->control->setPalette(palette()); d->sendControlEvent(e); } else if (e->type() == QEvent::PaletteChange) { d->control->setPalette(palette()); -- cgit v1.2.3 From 97ac281c1d70dcfbb137e5a83e24a747e9510116 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 4 Dec 2019 17:15:30 +0100 Subject: QStyleSheetStyle: properly honor checkmark size when drawing a QMenu When drawing a QMenu which is checkable but does not have an icon somewhere, the width of the (possible) checkmark was not considered during drawing and the text was drawn over the checkmark. Also the wrong state was checked for drawing the checked icon (if one was given). Fixes: QTBUG-80506 Task-number: QTBUG-78238 Change-Id: Icf8aa37aab424564054d3549defee93eb0d7c1a4 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/widgets/styles/qstylesheetstyle.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 3f57992311..aab4b74c4b 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3711,6 +3711,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q bool dis = !(opt->state & QStyle::State_Enabled), act = opt->state & QStyle::State_Selected; + int textRectOffset = m->maxIconWidth; if (!mi.icon.isNull()) { QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal; if (act && !dis) @@ -3736,19 +3737,21 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q p->drawPixmap(pmr.topLeft(), pixmap); } else if (checkable) { QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark); + const QRect cmRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction); if (subSubRule.hasDrawable() || checked) { QStyleOptionMenuItem newMi = mi; if (!dis) newMi.state |= State_Enabled; - if (act) + if (mi.checked) newMi.state |= State_On; - newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction); + newMi.rect = cmRect; drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w); } + textRectOffset = std::max(textRectOffset, cmRect.width()); } QRect textRect = subRule.contentsRect(opt->rect); - textRect.setLeft(textRect.left() + m->maxIconWidth); + textRect.setLeft(textRect.left() + textRectOffset); textRect.setWidth(textRect.width() - mi.tabWidth); const QRect vTextRect = visualRect(opt->direction, m->rect, textRect); -- cgit v1.2.3 From aa504fc2fa764b44d37d9629b9ddf1f114210759 Mon Sep 17 00:00:00 2001 From: David Faure <david.faure@kdab.com> Date: Mon, 2 Dec 2019 21:16:24 +0100 Subject: Optimize qLastIndexOf<QString> to not detach the QString The call to data() on a non-const QString led to a detach(), which is unexpected and unwanted from QString::lastIndexOf() const. Found by looking at why QFileSystemEntry::fileName() was expensive, in the hotspot profiler. The solution is to instanciate QLastIndexOf with QStringView() rather than QString(). I added a deleted QString overload to make sure nobody ever instanciates it with a QString argument again. Change-Id: I06a1b2f937425e83f0779eb215e099aef78c50a7 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qstring.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 51aa0b7512..4d83f19db7 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -146,6 +146,9 @@ qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype from, QStringVie static inline qsizetype qFindChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) noexcept; template <typename Haystack> static inline qsizetype qLastIndexOf(Haystack haystack, QChar needle, qsizetype from, Qt::CaseSensitivity cs) noexcept; +template <> +inline qsizetype qLastIndexOf(QString haystack, QChar needle, + qsizetype from, Qt::CaseSensitivity cs) noexcept = delete; // unwanted, would detach static inline qsizetype qt_string_count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs); static inline qsizetype qt_string_count(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); @@ -3817,7 +3820,7 @@ int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) co int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const { // ### Qt6: qsizetype - return int(QtPrivate::lastIndexOf(*this, from, str, cs)); + return int(QtPrivate::lastIndexOf(QStringView(*this), from, str, cs)); } #endif // QT_STRINGVIEW_LEVEL < 2 @@ -3856,7 +3859,7 @@ int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) co int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { // ### Qt6: qsizetype - return int(qLastIndexOf(*this, ch, from, cs)); + return int(qLastIndexOf(QStringView(*this), ch, from, cs)); } #if QT_STRINGVIEW_LEVEL < 2 -- cgit v1.2.3 From c7fec68e1936576070d0fbac6cf40b818366d298 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Mon, 2 Dec 2019 14:08:29 +0100 Subject: Do not read Xft.dpi on platforms that shouldn't be using Xft settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only read this for desktop environments that have traditionally used these to set settings for other toolkits. Fixes: QTBUG-80323 Change-Id: Ifa8c2682301e69c2770d3734115080a0e6b4e85c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> --- src/plugins/platforms/xcb/qxcbscreen.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8da299d491..7c60ca06f9 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -41,6 +41,7 @@ #include "qxcbwindow.h" #include "qxcbcursor.h" #include "qxcbimage.h" +#include "qxcbintegration.h" #include "qnamespace.h" #include "qxcbxsettings.h" @@ -49,6 +50,7 @@ #include <QDebug> #include <QtAlgorithms> +#include <qpa/qplatformservices.h> #include <qpa/qwindowsysteminterface.h> #include <private/qmath_p.h> #include <QtGui/private/qhighdpiscaling_p.h> @@ -356,6 +358,15 @@ static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stri void QXcbVirtualDesktop::readXResources() { + const QPlatformServices *services = QXcbIntegration::instance()->services(); + bool useXftConf = false; + if (services) { + const QList<QByteArray> desktopEnv = services->desktopEnvironment().split(':'); + useXftConf = desktopEnv.contains("GNOME") || desktopEnv.contains("UNITY") || desktopEnv.contains("XFCE"); + } + if (!useXftConf) + return; + int offset = 0; QByteArray resources; while (true) { -- cgit v1.2.3 From 35da2b87e3d04e4f7eb0895590be6952eeeb4a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Wed, 4 Dec 2019 19:50:28 +0100 Subject: macOS: Enable fullscreen for windows by default This matches the default collection behavior of NSWindows. Change-Id: I363ed211daf6c6c2e579eb11c7294ff509d53e91 Fixes: QTBUG-63829 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6e2d446898..69d192b4f5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -567,7 +567,10 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) { NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior; - if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) { + const bool enableFullScreen = m_view.window.qt_fullScreen + || !(flags & Qt::CustomizeWindowHint) + || (flags & Qt::WindowFullscreenButtonHint); + if (enableFullScreen) { behavior |= NSWindowCollectionBehaviorFullScreenPrimary; behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; } else { -- cgit v1.2.3 From aabf4fbbe932cbf5554062ed973f9b52388b5352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 3 Dec 2019 15:41:55 +0100 Subject: macOS: Improve QCocoaGLContext logging Change-Id: I27d0abe0eb5b0f0ba64b8787b430484c48b131c0 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 4 ++++ src/plugins/platforms/cocoa/qcocoaglcontext.mm | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 4210a4ed3f..238067568b 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -86,6 +86,10 @@ private: QSurfaceFormat m_format; QVarLengthArray<QMacNotificationObserver, 3> m_updateObservers; QAtomicInt m_needsUpdate = false; + +#ifndef QT_NO_DEBUG_STREAM + friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen); +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index b312e033cd..6db4bdb9fd 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -158,6 +158,8 @@ void QCocoaGLContext::initialize() [m_context setValues:&order forParameter:NSOpenGLCPSurfaceOrder]; updateSurfaceFormat(); + + qCDebug(lcQpaOpenGLContext).verbosity(3) << "Created" << this << "based on requested" << context()->format(); } NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurfaceFormat &format) @@ -355,7 +357,7 @@ QCocoaGLContext::~QCocoaGLContext() bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) { - qCDebug(lcQpaOpenGLContext) << "Making" << m_context << "current" + qCDebug(lcQpaOpenGLContext) << "Making" << this << "current" << "in" << QThread::currentThread() << "for" << surface; Q_ASSERT(surface->surface()->supportsOpenGL()); @@ -555,4 +557,20 @@ QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName) return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName); } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QCocoaGLContext *context) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QCocoaGLContext(" << (const void *)context; + if (context) { + if (debug.verbosity() > QDebug::DefaultVerbosity) + debug << ", " << context->format(); + debug << ", " << context->nativeContext(); + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE -- cgit v1.2.3 From 455e9e5be35b36d79b9541a6e014c5c9026d685b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Mon, 2 Dec 2019 13:53:35 +0100 Subject: Windows QPA: Fix tray geometry not updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The application does not update its screens when there are no windows on which a WM_DPICHANGE could be received. Add a check for it to the tray window procedure and trigger an update from there if no top levels are present. Fixes: QTBUG-79248 Change-Id: I0b1c4db560662ecf2b473304942da373be6fdc73 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 22cdefbbbc..ab830e1461 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -57,6 +57,7 @@ #include "qwindowsmenu.h" #include "qwindowsscreen.h" +#include <QtGui/qguiapplication.h> #include <QtGui/qpixmap.h> #include <QtCore/qdebug.h> #include <QtCore/qrect.h> @@ -135,6 +136,9 @@ static int indexOfHwnd(HWND hwnd) extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { + // QTBUG-79248: Trigger screen update if there are no other windows. + if (message == WM_DPICHANGED && QGuiApplication::topLevelWindows().isEmpty()) + QWindowsContext::instance()->screenManager().handleScreenChanges(); if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON || message == WM_INITMENU || message == WM_INITMENUPOPUP || message == WM_CLOSE || message == WM_COMMAND) { -- cgit v1.2.3 From 1f592da7f175aa75726eece2fab8f5c1edde193f Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 26 Nov 2019 07:21:55 -0800 Subject: QCborValue: fix replacing of elements with byte data with ones without We forgot to reset the flags when replacing the element, so we ended up with an integer with HasByteData after: testMap[0] = QStringLiteral("value"); testMap[0] = 42; Fixes: QTBUG-80342 Change-Id: Ia2aa807ffa8a4c798425fffd15dabfa066ea84b0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/serialization/qcborvalue_p.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index 590c2d6e05..48818e4c63 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -196,8 +196,7 @@ public: if (value.container) return replaceAt_complex(e, value, disp); - e.value = value.value_helper(); - e.type = value.type(); + e = { value.value_helper(), value.type() }; if (value.isContainer()) e.container = nullptr; } -- cgit v1.2.3 From 81459dd9c05f057981ddf2db0c2302030a73cb01 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan <sona.kurazyan@qt.io> Date: Wed, 4 Dec 2019 10:57:08 +0100 Subject: Copy formatting attributes when cloning an empty QTextDocument When cloning a QTextDocument, the text fragment of the original document is copied into the new one, which results into copying also the formatting attributes. However, when the text document is empty, the corresponding text fragment is also empty, so nothing is copied. If we want to transfer the formatting attributes for an empty document, we need to set them explicitly. Fixes: QTBUG-80399 Change-Id: I382cd0821723436120af47c06ec7bfa849636307 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/text/qtextdocument.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e94f635651..4b35509ace 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -347,7 +347,19 @@ QTextDocument *QTextDocument::clone(QObject *parent) const { Q_D(const QTextDocument); QTextDocument *doc = new QTextDocument(parent); - QTextCursor(doc).insertFragment(QTextDocumentFragment(this)); + if (isEmpty()) { + const QTextCursor thisCursor(const_cast<QTextDocument *>(this)); + + const auto blockFormat = thisCursor.blockFormat(); + if (blockFormat.isValid() && !blockFormat.isEmpty()) + QTextCursor(doc).setBlockFormat(blockFormat); + + const auto blockCharFormat = thisCursor.blockCharFormat(); + if (blockCharFormat.isValid() && !blockCharFormat.isEmpty()) + QTextCursor(doc).setBlockCharFormat(blockCharFormat); + } else { + QTextCursor(doc).insertFragment(QTextDocumentFragment(this)); + } doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat()); QTextDocumentPrivate *priv = doc->d_func(); priv->title = d->title; -- cgit v1.2.3 From b19220d17fa66de5ded41690ffff263ee2af5c63 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Sun, 23 Jun 2019 15:12:57 +0200 Subject: QByteArray: add a strict mode to fromBase64 QByteArray::fromBase64 was liberal in its input, simply skipping over invalid characters. As a side-effect of this, it had no error reporting, meaning it could not be used to convert fromBase64 _and_ validate the input in one go. Add more option flags to make fromBase64 strictly validate its input. Since we want to know whether it has succeeded or not, and the existing fromBase64 overloads do not allow for that, introduce a new function that returns an optional-like datatype. While at it: base64 decoding can be done in-place; add an rvalue overload to enable this use case. [ChangeLog][QtCore][QByteArray] Added the new fromBase64Encoding function. [ChangeLog][QtCore][QByteArray] Added new flags to make fromBase64 / fromBase64Encoding strictly validate their input, instead of skipping over invalid characters. Change-Id: I99cd5f2230f3d62970b28b4cb102913301da6ccd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- .../snippets/code/src_corelib_tools_qbytearray.cpp | 13 + src/corelib/text/qbytearray.cpp | 300 +++++++++++++++++---- src/corelib/text/qbytearray.h | 60 ++++- 3 files changed, 323 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp index 11ab50687d..01f620cf08 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp @@ -429,6 +429,19 @@ QByteArray::fromBase64("PHA+SGVsbG8/PC9wPg==", QByteArray::Base64Encoding); // r QByteArray::fromBase64("PHA-SGVsbG8_PC9wPg==", QByteArray::Base64UrlEncoding); // returns "<p>Hello?</p>" //! [44bis] +//! [44ter] +void process(const QByteArray &); + +if (auto result = QByteArray::fromBase64Encoding(encodedData)) + process(*result); +//! [44ter] + +//! [44quater] +auto result = QByteArray::fromBase64Encoding(encodedData); +if (result.decodingStatus == QByteArray::Base64DecodingStatus::Ok) + process(result.decoded); +//! [44quater] + //! [45] QByteArray text = QByteArray::fromHex("517420697320677265617421"); diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 444980e9c0..5a61d7f70d 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2,6 +2,7 @@ ** ** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -41,6 +42,7 @@ #include "qbytearray.h" #include "qbytearraymatcher.h" #include "private/qtools_p.h" +#include "qhashfunctions.h" #include "qstring.h" #include "qlist.h" #include "qlocale.h" @@ -1002,10 +1004,20 @@ QByteArray qUncompress(const uchar* data, int nbytes) four. \value OmitTrailingEquals Omits adding the padding equal signs at the end of the encoded data. - - QByteArray::fromBase64() ignores the KeepTrailingEquals and - OmitTrailingEquals options and will not flag errors in case they are - missing or if there are too many of them. + \value IgnoreBase64DecodingErrors When decoding Base64-encoded data, ignores errors + in the input; invalid characters are simply skipped. + This enum value has been added in Qt 5.15. + \value AbortOnBase64DecodingErrors When decoding Base64-encoded data, stops at the first + decoding error. + This enum value has been added in Qt 5.15. + + QByteArray::fromBase64Encoding() and QByteArray::fromBase64() + ignore the KeepTrailingEquals and OmitTrailingEquals options. If + the IgnoreBase64DecodingErrors option is specified, they will not + flag errors in case trailing equal signs are missing or if there + are too many of them. If instead the AbortOnBase64DecodingErrors is + specified, then the input must either have no padding or have the + correct amount of equal signs. */ /*! \fn QByteArray::iterator QByteArray::begin() @@ -4513,7 +4525,140 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) return *this; } +namespace { +struct fromBase64_helper_result { + qsizetype decodedLength; + QByteArray::Base64DecodingStatus status; +}; + +fromBase64_helper_result fromBase64_helper(const char *input, qsizetype inputSize, + char *output /* may alias input */, + QByteArray::Base64Options options) +{ + fromBase64_helper_result result{ 0, QByteArray::Base64DecodingStatus::Ok }; + + unsigned int buf = 0; + int nbits = 0; + + qsizetype offset = 0; + for (qsizetype i = 0; i < inputSize; ++i) { + int ch = input[i]; + int d; + + if (ch >= 'A' && ch <= 'Z') { + d = ch - 'A'; + } else if (ch >= 'a' && ch <= 'z') { + d = ch - 'a' + 26; + } else if (ch >= '0' && ch <= '9') { + d = ch - '0' + 52; + } else if (ch == '+' && (options & QByteArray::Base64UrlEncoding) == 0) { + d = 62; + } else if (ch == '-' && (options & QByteArray::Base64UrlEncoding) != 0) { + d = 62; + } else if (ch == '/' && (options & QByteArray::Base64UrlEncoding) == 0) { + d = 63; + } else if (ch == '_' && (options & QByteArray::Base64UrlEncoding) != 0) { + d = 63; + } else { + if (options & QByteArray::AbortOnBase64DecodingErrors) { + if (ch == '=') { + // can have 1 or 2 '=' signs, in both cases padding base64Size to + // a multiple of 4. Any other case is illegal. + if ((inputSize % 4) != 0) { + result.status = QByteArray::Base64DecodingStatus::IllegalInputLength; + return result; + } else if ((i == inputSize - 1) || + (i == inputSize - 2 && input[++i] == '=')) { + d = -1; // ... and exit the loop, normally + } else { + result.status = QByteArray::Base64DecodingStatus::IllegalPadding; + return result; + } + } else { + result.status = QByteArray::Base64DecodingStatus::IllegalCharacter; + return result; + } + } else { + d = -1; + } + } + + if (d != -1) { + buf = (buf << 6) | d; + nbits += 6; + if (nbits >= 8) { + nbits -= 8; + Q_ASSERT(offset < i); + output[offset++] = buf >> nbits; + buf &= (1 << nbits) - 1; + } + } + } + + result.decodedLength = offset; + return result; +} +} // anonymous namespace + /*! + \fn QByteArray::FromBase64Result QByteArray::fromBase64Encoding(QByteArray &&base64, Base64Options options) + \fn QByteArray::FromBase64Result QByteArray::fromBase64Encoding(const QByteArray &base64, Base64Options options) + \since 5.15 + \overload + + Decodes the Base64 array \a base64, using the options + defined by \a options. If \a options contains \c{IgnoreBase64DecodingErrors} + (the default), the input is not checked for validity; invalid + characters in the input are skipped, enabling the decoding process to + continue with subsequent characters. If \a options contains + \c{AbortOnBase64DecodingErrors}, then decoding will stop at the first + invalid character. + + For example: + + \snippet code/src_corelib_tools_qbytearray.cpp 44ter + + The algorithm used to decode Base64-encoded data is defined in \l{RFC 4648}. + + Returns a QByteArrayFromBase64Result object, containing the decoded + data and a flag telling whether decoding was successful. If the + \c{AbortOnBase64DecodingErrors} option was passed and the input + data was invalid, it is unspecified what the decoded data contains. + + \sa toBase64() +*/ +QByteArray::FromBase64Result QByteArray::fromBase64Encoding(QByteArray &&base64, Base64Options options) +{ + // try to avoid a detach when calling data(), as it would over-allocate + // (we need less space when decoding than the one required by the full copy) + if (base64.isDetached()) { + const auto base64result = fromBase64_helper(base64.data(), + base64.size(), + base64.data(), // in-place + options); + base64.truncate(int(base64result.decodedLength)); + return { std::move(base64), base64result.status }; + } + + return fromBase64Encoding(base64, options); +} + + +QByteArray::FromBase64Result QByteArray::fromBase64Encoding(const QByteArray &base64, Base64Options options) +{ + const auto base64Size = base64.size(); + QByteArray result((base64Size * 3) / 4, Qt::Uninitialized); + const auto base64result = fromBase64_helper(base64.data(), + base64Size, + const_cast<char *>(result.constData()), + options); + result.truncate(int(base64result.decodedLength)); + return { std::move(result), base64result.status }; +} + +/*! + \overload + Returns a decoded copy of the Base64 array \a base64. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters. @@ -4524,21 +4669,28 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) The algorithm used to decode Base64-encoded data is defined in \l{RFC 4648}. - \sa toBase64() + \note The fromBase64Encoding() function is recommended in new code. + + \sa toBase64(), fromBase64Encoding() */ QByteArray QByteArray::fromBase64(const QByteArray &base64) { - return fromBase64(base64, Base64Encoding); + if (auto result = fromBase64Encoding(base64, Base64Encoding)) + return std::move(result.decoded); + return QByteArray(); } /*! \since 5.2 \overload - Returns a decoded copy of the Base64 array \a base64, using the alphabet - defined by \a options. Input is not checked for validity; invalid + Returns a decoded copy of the Base64 array \a base64, using the options + defined by \a options. If \a options contains \c{IgnoreBase64DecodingErrors} + (the default), the input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to - continue with subsequent characters. + continue with subsequent characters. If \a options contains + \c{AbortOnBase64DecodingErrors}, then decoding will stop at the first + invalid character. For example: @@ -4546,49 +4698,18 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64) The algorithm used to decode Base64-encoded data is defined in \l{RFC 4648}. - \sa toBase64() + Returns the decoded data, or, if the \c{AbortOnBase64DecodingErrors} + option was passed and the input data was invalid, an empty byte array. + + \note The fromBase64Encoding() function is recommended in new code. + + \sa toBase64(), fromBase64Encoding() */ QByteArray QByteArray::fromBase64(const QByteArray &base64, Base64Options options) { - unsigned int buf = 0; - int nbits = 0; - QByteArray tmp((base64.size() * 3) / 4, Qt::Uninitialized); - - int offset = 0; - for (int i = 0; i < base64.size(); ++i) { - int ch = base64.at(i); - int d; - - if (ch >= 'A' && ch <= 'Z') - d = ch - 'A'; - else if (ch >= 'a' && ch <= 'z') - d = ch - 'a' + 26; - else if (ch >= '0' && ch <= '9') - d = ch - '0' + 52; - else if (ch == '+' && (options & Base64UrlEncoding) == 0) - d = 62; - else if (ch == '-' && (options & Base64UrlEncoding) != 0) - d = 62; - else if (ch == '/' && (options & Base64UrlEncoding) == 0) - d = 63; - else if (ch == '_' && (options & Base64UrlEncoding) != 0) - d = 63; - else - d = -1; - - if (d != -1) { - buf = (buf << 6) | d; - nbits += 6; - if (nbits >= 8) { - nbits -= 8; - tmp[offset++] = buf >> nbits; - buf &= (1 << nbits) - 1; - } - } - } - - tmp.truncate(offset); - return tmp; + if (auto result = fromBase64Encoding(base64, options)) + return std::move(result.decoded); + return QByteArray(); } /*! @@ -5008,5 +5129,86 @@ void warn(WarningType w, EmittingClass c) } // namespace DeprecatedRefClassBehavior } // namespace QtPrivate +/*! + \class QByteArray::FromBase64Result + \inmodule QtCore + \ingroup tools + \since 5.15 + + \brief The QByteArray::FromBase64Result class holds the result of + a call to QByteArray::fromBase64Encoding. + + Objects of this class can be used to check whether the conversion + was successful, and if so, retrieve the decoded QByteArray. The + conversion operators defined for QByteArray::FromBase64Result make + its usage straightforward: + + \snippet code/src_corelib_tools_qbytearray.cpp 44ter + + In alternative, it is possible to access the conversion status + and the decoded data directly: + + \snippet code/src_corelib_tools_qbytearray.cpp 44quater + + \sa QByteArray::fromBase64 +*/ + +/*! + \variable QByteArray::FromBase64Result::decoded + + Contains the decoded byte array. +*/ + +/*! + \variable QByteArray::FromBase64Result::decodingStatus + + Contains whether the decoding was successful, expressed as a value + of type QByteArray::Base64DecodingStatus. +*/ + +/*! + \fn QByteArray::FromBase64Result::operator bool() const + + Returns whether the decoding was successful. This is equivalent + to checking whether the \c{decodingStatus} member is equal to + QByteArray::Base64DecodingStatus::Ok. +*/ + +/*! + \fn QByteArray::FromBase64Result::operator QByteArray() const + + Returns the decoded byte array. +*/ + +/*! + \fn bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept + \relates QByteArray::FromBase64Result + + Compares \a lhs and \a rhs for equality. \a lhs and \a rhs are equal + if and only if they contain the same decoding status and, if the + status is QByteArray::Base64DecodingStatus::Ok, if and only if + they contain the same decoded data. +*/ + +/*! + \fn bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept + \relates QByteArray::FromBase64Result + + Compares \a lhs and \a rhs for inequality. +*/ + +/*! + \relates QByteArray::FromBase64Result + + Returns the hash value for \a key, using + \a seed to seed the calculation. +*/ +uint qHash(const QByteArray::FromBase64Result &key, uint seed) noexcept +{ + QtPrivate::QHashCombine hash; + seed = hash(seed, key.decoded); + seed = hash(seed, static_cast<int>(key.decodingStatus)); + return seed; +} QT_END_NAMESPACE diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 7c571706d8..4fa17cf58b 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -164,10 +164,20 @@ public: Base64UrlEncoding = 1, KeepTrailingEquals = 0, - OmitTrailingEquals = 2 + OmitTrailingEquals = 2, + + IgnoreBase64DecodingErrors = 0, + AbortOnBase64DecodingErrors = 4, }; Q_DECLARE_FLAGS(Base64Options, Base64Option) + enum class Base64DecodingStatus { + Ok, + IllegalInputLength, + IllegalCharacter, + IllegalPadding, + }; + inline QByteArray() noexcept; QByteArray(const char *, int size = -1); QByteArray(int size, char c); @@ -379,6 +389,10 @@ public: Q_REQUIRED_RESULT static QByteArray number(qulonglong, int base = 10); Q_REQUIRED_RESULT static QByteArray number(double, char f = 'g', int prec = 6); Q_REQUIRED_RESULT static QByteArray fromRawData(const char *, int size); + + class FromBase64Result; + Q_REQUIRED_RESULT static FromBase64Result fromBase64Encoding(QByteArray &&base64, Base64Options options = Base64Encoding); + Q_REQUIRED_RESULT static FromBase64Result fromBase64Encoding(const QByteArray &base64, Base64Options options = Base64Encoding); Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, Base64Options options); Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64); // ### Qt6 merge with previous Q_REQUIRED_RESULT static QByteArray fromHex(const QByteArray &hexEncoded); @@ -749,6 +763,50 @@ inline QByteArray qUncompress(const QByteArray& data) Q_DECLARE_SHARED(QByteArray) +class QByteArray::FromBase64Result +{ +public: + QByteArray decoded; + QByteArray::Base64DecodingStatus decodingStatus; + + void swap(QByteArray::FromBase64Result &other) noexcept + { + qSwap(decoded, other.decoded); + qSwap(decodingStatus, other.decodingStatus); + } + + explicit operator bool() const noexcept { return decodingStatus == QByteArray::Base64DecodingStatus::Ok; } + +#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(Q_QDOC) + QByteArray &operator*() & noexcept { return decoded; } + const QByteArray &operator*() const & noexcept { return decoded; } + QByteArray &&operator*() && noexcept { return std::move(decoded); } +#else + QByteArray &operator*() noexcept { return decoded; } + const QByteArray &operator*() const noexcept { return decoded; } +#endif +}; + +Q_DECLARE_SHARED(QByteArray::FromBase64Result) + +inline bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept +{ + if (lhs.decodingStatus != rhs.decodingStatus) + return false; + + if (lhs.decodingStatus == QByteArray::Base64DecodingStatus::Ok && lhs.decoded != rhs.decoded) + return false; + + return true; +} + +inline bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept +{ + return !operator==(lhs, rhs); +} + +Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHash(const QByteArray::FromBase64Result &key, uint seed = 0) noexcept; + QT_END_NAMESPACE #endif // QBYTEARRAY_H -- cgit v1.2.3 From 20266820a31d5cd4afc808bc8b3e9eb6e0396358 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland <eirik.aavitsland@qt.io> Date: Thu, 5 Dec 2019 15:59:01 +0100 Subject: Item views: do not clip items horizontally in dragging icon The dragging icon is created from the visible items in the selection. It would be clipped to the parts visible in the viewport. That meant that items on the edge could be rendered illegible, even though they were part of what was being dragged. Fix by dropping the horizontal clipping to the viewport. Items fully outside the viewport are already filtered away, so this should at most make a difference to the bottom and/or top items in the set. Keep the vertical clipping, since items may easily be very wide, so an unclipped icon would be unwieldy. Done-With: Sona Kurazyan <sona.kurazyan@qt.io> Fixes: QTBUG-77336 Change-Id: I2d29cb0ca69c1058635106aa0c67e9f7e140d1cd Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/itemviews/qabstractitemview.cpp | 4 +++- src/widgets/itemviews/qlistview.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index b1557e9af4..7ede46dbec 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -4451,7 +4451,9 @@ QItemViewPaintPairs QAbstractItemViewPrivate::draggablePaintPairs(const QModelIn rect |= current; } } - rect &= viewportRect; + QRect clipped = rect & viewportRect; + rect.setLeft(clipped.left()); + rect.setRight(clipped.right()); return ret; } diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 04cddf2926..62fffc17df 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -664,7 +664,9 @@ QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList rect |= current; } } - rect &= viewportRect; + QRect clipped = rect & viewportRect; + rect.setLeft(clipped.left()); + rect.setRight(clipped.right()); return ret; } -- cgit v1.2.3 From 5da34ac263b6beb6666192acfdead1c028278e17 Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Tue, 15 Oct 2019 16:54:30 +0200 Subject: Doc: Update info about building tests Task-number: QTBUG-63987 Change-Id: I4b6e8f35afc9d3ca10b393a0305bbb51bf81ec26 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- .../doc/snippets/code/doc_src_cmakelists.txt | 14 +++++++ src/testlib/doc/src/qttestlib-manual.qdoc | 43 +++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/testlib/doc/snippets/code/doc_src_cmakelists.txt (limited to 'src') diff --git a/src/testlib/doc/snippets/code/doc_src_cmakelists.txt b/src/testlib/doc/snippets/code/doc_src_cmakelists.txt new file mode 100644 index 0000000000..96dbe1acee --- /dev/null +++ b/src/testlib/doc/snippets/code/doc_src_cmakelists.txt @@ -0,0 +1,14 @@ +project(mytest LANGUAGES CXX) + +find_package(Qt5Test REQUIRED) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +enable_testing(true) + +add_executable(mytest tst_mytest.cpp) +add_test(NAME mytest COMMAND mytest) + +target_link_libraries(mytest PRIVATE Qt5::Test) diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index 19d871d404..688cc2f2f6 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -83,6 +83,10 @@ \li Custom types can easily be added to the test data and test output. \endtable + You can use a Qt Creator wizard to create a project that contains Qt tests + and build and run them directly from Qt Creator. For more information, see + \l {Running Autotests}. + \section1 Creating a Test To create a test, subclass QObject and add one or more private slots to it. Each @@ -133,6 +137,41 @@ \if !defined(qtforpython) \section1 Building a Test + You can build an executable that contains one test class that typically + tests one class of production code. However, usually you would want to + test several classes in a project by running one command. + + See \l {Chapter 1: Writing a Unit Test}{Writing a Unit Test} for a step by + step explanation. + + \section2 Building with CMake and CTest + + You can use \l {CMake and CTest} to create a test. + \l{https://cmake.org/cmake/help/latest/manual/ctest.1.html}{CTest} enables + you to include or exclude tests based on a regular expression that is + matched against the test name. You can further apply the \c LABELS property + to a test and CTest can then include or exclude tests based on those labels. + All labeled targets will be run when \c {test} target is called on the + command line. + + There are several other advantages with CMake. For example, the result of + a test run can be published on a web server using CDash with virtually no + effort. + + CTest scales to very different unit test frameworks, and works out of the + box with QTest. + + The following is an example of a CMakeLists.txt file that specifies the + project name and the language used (here, \e mytest and C++), the Qt + modules required for building the test (Qt5Test), and the files that are + included in the test (\e tst_mytest.cpp). + + \quotefile code/doc_src_cmakelists.txt + + For more information about the options you have, see \l {Build with CMake}. + + \section2 Building with qmake + If you are using \c qmake as your build tool, just add the following to your project file: @@ -146,14 +185,14 @@ See the \l{Building a Testcase}{qmake manual} for more information about \c{make check}. + \section2 Building with Other Tools + If you are using other build tools, make sure that you add the location of the Qt Test header files to your include path (usually \c{include/QtTest} under your Qt installation directory). If you are using a release build of Qt, link your test to the \c QtTest library. For debug builds, use \c{QtTest_debug}. - See \l {Chapter 1: Writing a Unit Test}{Writing a Unit Test} for a step by - step explanation. \endif \section1 Qt Test Command Line Arguments -- cgit v1.2.3 From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/animation/qabstractanimation.cpp | 8 +- src/corelib/animation/qanimationgroup.cpp | 8 +- src/corelib/animation/qpropertyanimation.cpp | 2 +- .../animation/qsequentialanimationgroup.cpp | 6 +- src/corelib/animation/qvariantanimation.cpp | 6 +- src/corelib/codecs/qicucodec.cpp | 16 +- src/corelib/codecs/qisciicodec.cpp | 2 +- src/corelib/codecs/qsimplecodec.cpp | 66 +++--- src/corelib/global/qlibraryinfo.cpp | 12 +- src/corelib/global/qlogging.cpp | 2 +- src/corelib/io/qfile.cpp | 4 +- src/corelib/io/qfiledevice.cpp | 2 +- src/corelib/io/qfilesystemengine_unix.cpp | 4 +- src/corelib/io/qfilesystemwatcher.cpp | 2 +- src/corelib/io/qfilesystemwatcher_inotify.cpp | 2 +- src/corelib/io/qiodevice.cpp | 2 +- src/corelib/io/qnoncontiguousbytedevice.cpp | 20 +- src/corelib/io/qprocess.cpp | 26 +-- src/corelib/io/qprocess_unix.cpp | 24 +-- src/corelib/io/qresource.cpp | 6 +- src/corelib/io/qsavefile.cpp | 2 +- src/corelib/io/qsettings.cpp | 12 +- src/corelib/itemmodels/qabstractitemmodel.cpp | 20 +- src/corelib/itemmodels/qabstractproxymodel.cpp | 2 +- .../itemmodels/qconcatenatetablesproxymodel.cpp | 2 +- src/corelib/itemmodels/qitemselectionmodel.cpp | 2 +- src/corelib/kernel/qcoreapplication.cpp | 26 +-- src/corelib/kernel/qcoreevent.cpp | 2 +- src/corelib/kernel/qeventdispatcher_glib.cpp | 40 ++-- src/corelib/kernel/qeventdispatcher_unix.cpp | 2 +- src/corelib/kernel/qmetaobject.cpp | 80 +++---- src/corelib/kernel/qmetaobjectbuilder.cpp | 32 +-- src/corelib/kernel/qmetatype.cpp | 6 +- src/corelib/kernel/qmimedata.cpp | 2 +- src/corelib/kernel/qobject.cpp | 126 +++++------ src/corelib/kernel/qobjectcleanuphandler.cpp | 2 +- src/corelib/kernel/qsharedmemory.cpp | 2 +- src/corelib/kernel/qsharedmemory_systemv.cpp | 6 +- src/corelib/kernel/qsharedmemory_unix.cpp | 2 +- src/corelib/kernel/qtestsupport_core.cpp | 2 +- src/corelib/kernel/qtimer.cpp | 6 +- src/corelib/kernel/qtimerinfo_unix.cpp | 20 +- src/corelib/kernel/qtranslator.cpp | 38 ++-- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/mimetypes/qmimedatabase.cpp | 2 +- src/corelib/mimetypes/qmimeprovider.cpp | 4 +- src/corelib/plugin/qfactoryloader.cpp | 8 +- src/corelib/plugin/qlibrary.cpp | 34 +-- src/corelib/plugin/qlibrary_unix.cpp | 2 +- src/corelib/plugin/qpluginloader.cpp | 8 +- src/corelib/statemachine/qabstractstate.cpp | 6 +- src/corelib/statemachine/qabstracttransition.cpp | 4 +- src/corelib/statemachine/qeventtransition.cpp | 2 +- src/corelib/statemachine/qhistorystate.cpp | 2 +- src/corelib/statemachine/qsignaltransition.cpp | 2 +- src/corelib/statemachine/qstate.cpp | 20 +- src/corelib/statemachine/qstatemachine.cpp | 106 +++++----- src/corelib/text/qlocale.cpp | 8 +- src/corelib/text/qlocale_tools.cpp | 2 +- src/corelib/text/qregularexpression.cpp | 14 +- src/corelib/text/qtextboundaryfinder.cpp | 14 +- src/corelib/thread/qexception.cpp | 2 +- src/corelib/thread/qfutureinterface.cpp | 2 +- src/corelib/thread/qmutex.cpp | 6 +- src/corelib/thread/qmutex_linux.cpp | 4 +- src/corelib/thread/qorderedmutexlocker_p.h | 2 +- src/corelib/thread/qreadwritelock.cpp | 6 +- src/corelib/thread/qresultstore.cpp | 2 +- src/corelib/thread/qthread.cpp | 6 +- src/corelib/thread/qthread_unix.cpp | 24 +-- src/corelib/thread/qthreadstorage.cpp | 12 +- src/corelib/thread/qwaitcondition_unix.cpp | 2 +- src/corelib/time/qdatetime.cpp | 4 +- src/corelib/time/qdatetimeparser.cpp | 2 +- src/corelib/time/qtimezone.cpp | 2 +- src/corelib/time/qtimezoneprivate_icu.cpp | 12 +- src/corelib/time/qtimezoneprivate_tz.cpp | 2 +- src/corelib/tools/qarraydata.cpp | 2 +- src/corelib/tools/qeasingcurve.cpp | 18 +- src/dbus/qdbusabstractadaptor.cpp | 10 +- src/dbus/qdbusabstractinterface.cpp | 6 +- src/dbus/qdbusargument.cpp | 6 +- src/dbus/qdbusconnection.cpp | 32 +-- src/dbus/qdbuscontext.cpp | 4 +- src/dbus/qdbusdemarshaller.cpp | 2 +- src/dbus/qdbusintegrator.cpp | 84 ++++---- src/dbus/qdbusinterface.cpp | 4 +- src/dbus/qdbusinternalfilters.cpp | 2 +- src/dbus/qdbusmarshaller.cpp | 8 +- src/dbus/qdbusmessage.cpp | 28 +-- src/dbus/qdbusmetaobject.cpp | 20 +- src/dbus/qdbusmetatype.cpp | 12 +- src/dbus/qdbusmisc.cpp | 6 +- src/dbus/qdbuspendingcall.cpp | 6 +- src/dbus/qdbuspendingreply.cpp | 4 +- src/dbus/qdbusreply.cpp | 2 +- src/dbus/qdbusunixfiledescriptor.cpp | 4 +- src/dbus/qdbusutil.cpp | 16 +- src/gui/accessible/qaccessible.cpp | 20 +- src/gui/accessible/qaccessibleobject.cpp | 10 +- src/gui/accessible/qplatformaccessibility.cpp | 2 +- src/gui/animation/qguivariantanimation.cpp | 10 +- src/gui/image/qbmphandler.cpp | 4 +- src/gui/image/qicon.cpp | 16 +- src/gui/image/qiconloader.cpp | 2 +- src/gui/image/qimage.cpp | 46 ++-- src/gui/image/qimage_conversions.cpp | 8 +- src/gui/image/qimageiohandler.cpp | 2 +- src/gui/image/qimagereader.cpp | 12 +- src/gui/image/qimagereaderwriterhelpers.cpp | 6 +- src/gui/image/qimagewriter.cpp | 14 +- src/gui/image/qmovie.cpp | 2 +- src/gui/image/qpaintengine_pic.cpp | 6 +- src/gui/image/qpicture.cpp | 22 +- src/gui/image/qpixmap.cpp | 6 +- src/gui/image/qpixmap_blitter.cpp | 8 +- src/gui/image/qpixmapcache.cpp | 14 +- src/gui/image/qplatformpixmap.cpp | 2 +- src/gui/image/qpnghandler.cpp | 58 ++--- src/gui/image/qxpmhandler.cpp | 4 +- src/gui/itemmodels/qstandarditemmodel.cpp | 92 ++++---- src/gui/kernel/qclipboard.cpp | 6 +- src/gui/kernel/qcursor.cpp | 14 +- src/gui/kernel/qdnd.cpp | 12 +- src/gui/kernel/qdrag.cpp | 6 +- src/gui/kernel/qevent.cpp | 8 +- src/gui/kernel/qguiapplication.cpp | 106 +++++----- src/gui/kernel/qguivariant.cpp | 16 +- src/gui/kernel/qkeymapper.cpp | 2 +- src/gui/kernel/qoffscreensurface.cpp | 14 +- src/gui/kernel/qopenglcontext.cpp | 56 ++--- src/gui/kernel/qopenglwindow.cpp | 6 +- src/gui/kernel/qpaintdevicewindow.cpp | 2 +- src/gui/kernel/qpalette.cpp | 2 +- src/gui/kernel/qplatformclipboard.cpp | 2 +- src/gui/kernel/qplatformcursor.cpp | 10 +- src/gui/kernel/qplatforminputcontextfactory.cpp | 2 +- src/gui/kernel/qplatformintegration.cpp | 22 +- src/gui/kernel/qplatformintegrationplugin.cpp | 2 +- src/gui/kernel/qplatformnativeinterface.cpp | 20 +- src/gui/kernel/qplatformopenglcontext.cpp | 2 +- src/gui/kernel/qplatformscreen.cpp | 8 +- src/gui/kernel/qplatformtheme.cpp | 16 +- src/gui/kernel/qscreen.cpp | 2 +- src/gui/kernel/qsessionmanager.cpp | 2 +- src/gui/kernel/qshortcutmap.cpp | 12 +- src/gui/kernel/qsimpledrag.cpp | 2 +- src/gui/kernel/qstylehints.cpp | 2 +- src/gui/kernel/qsurface.cpp | 2 +- src/gui/kernel/qwindow.cpp | 18 +- src/gui/kernel/qwindowsysteminterface.cpp | 2 +- src/gui/opengl/qopengl.cpp | 2 +- src/gui/opengl/qopenglbuffer.cpp | 10 +- src/gui/opengl/qopenglcustomshaderstage.cpp | 8 +- src/gui/opengl/qopengldebug.cpp | 24 +-- src/gui/opengl/qopenglengineshadermanager.cpp | 20 +- src/gui/opengl/qopenglframebufferobject.cpp | 12 +- src/gui/opengl/qopenglfunctions.cpp | 6 +- src/gui/opengl/qopenglfunctions_1_0.cpp | 6 +- src/gui/opengl/qopenglfunctions_1_1.cpp | 10 +- src/gui/opengl/qopenglfunctions_1_2.cpp | 14 +- src/gui/opengl/qopenglfunctions_1_3.cpp | 18 +- src/gui/opengl/qopenglfunctions_1_4.cpp | 22 +- src/gui/opengl/qopenglfunctions_1_5.cpp | 24 +-- src/gui/opengl/qopenglfunctions_2_0.cpp | 26 +-- src/gui/opengl/qopenglfunctions_2_1.cpp | 28 +-- src/gui/opengl/qopenglfunctions_3_0.cpp | 30 +-- src/gui/opengl/qopenglfunctions_3_1.cpp | 22 +- .../opengl/qopenglfunctions_3_2_compatibility.cpp | 34 +-- src/gui/opengl/qopenglfunctions_3_2_core.cpp | 24 +-- .../opengl/qopenglfunctions_3_3_compatibility.cpp | 38 ++-- src/gui/opengl/qopenglfunctions_3_3_core.cpp | 26 +-- .../opengl/qopenglfunctions_4_0_compatibility.cpp | 40 ++-- src/gui/opengl/qopenglfunctions_4_0_core.cpp | 28 +-- .../opengl/qopenglfunctions_4_1_compatibility.cpp | 42 ++-- src/gui/opengl/qopenglfunctions_4_1_core.cpp | 30 +-- .../opengl/qopenglfunctions_4_2_compatibility.cpp | 44 ++-- src/gui/opengl/qopenglfunctions_4_2_core.cpp | 32 +-- .../opengl/qopenglfunctions_4_3_compatibility.cpp | 46 ++-- src/gui/opengl/qopenglfunctions_4_3_core.cpp | 34 +-- .../opengl/qopenglfunctions_4_4_compatibility.cpp | 48 ++--- src/gui/opengl/qopenglfunctions_4_4_core.cpp | 36 ++-- .../opengl/qopenglfunctions_4_5_compatibility.cpp | 52 ++--- src/gui/opengl/qopenglfunctions_4_5_core.cpp | 38 ++-- src/gui/opengl/qopenglpaintdevice.cpp | 2 +- src/gui/opengl/qopenglpaintengine.cpp | 20 +- src/gui/opengl/qopenglshaderprogram.cpp | 12 +- src/gui/opengl/qopengltexture.cpp | 32 +-- src/gui/opengl/qopengltextureglyphcache.cpp | 34 +-- src/gui/opengl/qopengltimerquery.cpp | 26 +-- src/gui/opengl/qopenglversionfunctions.cpp | 2 +- src/gui/opengl/qopenglversionfunctionsfactory.cpp | 2 +- src/gui/opengl/qopenglvertexarrayobject.cpp | 16 +- src/gui/painting/qblittable.cpp | 2 +- src/gui/painting/qbrush.cpp | 14 +- src/gui/painting/qcosmeticstroker.cpp | 6 +- src/gui/painting/qdrawhelper.cpp | 92 ++++---- src/gui/painting/qemulationpaintengine.cpp | 2 +- src/gui/painting/qimagescale.cpp | 4 +- src/gui/painting/qmemrotate.cpp | 6 +- src/gui/painting/qoutlinemapper.cpp | 2 +- src/gui/painting/qpagesize.cpp | 20 +- src/gui/painting/qpaintdevice.cpp | 6 +- src/gui/painting/qpaintengine.cpp | 12 +- src/gui/painting/qpaintengine_raster.cpp | 96 ++++----- src/gui/painting/qpaintengineex.cpp | 30 +-- src/gui/painting/qpainter.cpp | 54 ++--- src/gui/painting/qpainterpath.cpp | 6 +- src/gui/painting/qpathclipper.cpp | 10 +- src/gui/painting/qpathsimplifier.cpp | 42 ++-- src/gui/painting/qpdf.cpp | 18 +- src/gui/painting/qpdfwriter.cpp | 2 +- src/gui/painting/qpen.cpp | 2 +- src/gui/painting/qplatformbackingstore.cpp | 4 +- src/gui/painting/qrasterizer.cpp | 4 +- src/gui/painting/qregion.cpp | 74 +++---- src/gui/painting/qstroker.cpp | 10 +- src/gui/painting/qtextureglyphcache.cpp | 2 +- src/gui/painting/qtriangulatingstroker.cpp | 4 +- src/gui/painting/qtriangulator.cpp | 28 +-- src/gui/text/qabstracttextdocumentlayout.cpp | 2 +- src/gui/text/qdistancefield.cpp | 8 +- src/gui/text/qfont.cpp | 74 +++---- src/gui/text/qfontdatabase.cpp | 50 ++--- src/gui/text/qfontengine.cpp | 40 ++-- src/gui/text/qfontengine_qpf2.cpp | 8 +- src/gui/text/qfontmetrics.cpp | 82 ++++---- src/gui/text/qplatformfontdatabase.cpp | 2 +- src/gui/text/qrawfont.cpp | 6 +- src/gui/text/qstatictext.cpp | 4 +- src/gui/text/qsyntaxhighlighter.cpp | 4 +- src/gui/text/qtextcursor.cpp | 26 +-- src/gui/text/qtextdocument.cpp | 6 +- src/gui/text/qtextdocument_p.cpp | 18 +- src/gui/text/qtextdocumentfragment.cpp | 16 +- src/gui/text/qtextdocumentlayout.cpp | 24 +-- src/gui/text/qtextdocumentwriter.cpp | 6 +- src/gui/text/qtextengine.cpp | 44 ++-- src/gui/text/qtexthtmlparser.cpp | 6 +- src/gui/text/qtextimagehandler.cpp | 2 +- src/gui/text/qtextlayout.cpp | 8 +- src/gui/text/qtextobject.cpp | 16 +- src/gui/text/qtextodfwriter.cpp | 12 +- src/gui/text/qtextoption.cpp | 8 +- src/gui/text/qzip.cpp | 16 +- src/gui/util/qdesktopservices.cpp | 2 +- src/gui/util/qgridlayoutengine.cpp | 26 +-- src/gui/util/qtexturefiledata.cpp | 2 +- src/gui/vulkan/qvulkaninstance.cpp | 2 +- src/gui/vulkan/qvulkanwindow.cpp | 2 +- src/network/access/qabstractprotocolhandler.cpp | 2 +- src/network/access/qftp.cpp | 20 +- src/network/access/qhttpmultipart.cpp | 2 +- src/network/access/qhttpnetworkconnection.cpp | 16 +- .../access/qhttpnetworkconnectionchannel.cpp | 20 +- src/network/access/qhttpnetworkreply.cpp | 10 +- src/network/access/qhttpnetworkrequest.cpp | 2 +- src/network/access/qhttpprotocolhandler.cpp | 4 +- src/network/access/qhttpthreaddelegate.cpp | 18 +- .../access/qnetworkaccessauthenticationmanager.cpp | 2 +- src/network/access/qnetworkaccessbackend.cpp | 10 +- src/network/access/qnetworkaccesscache.cpp | 22 +- .../access/qnetworkaccessdebugpipebackend.cpp | 6 +- src/network/access/qnetworkaccessfilebackend.cpp | 6 +- src/network/access/qnetworkaccessftpbackend.cpp | 12 +- src/network/access/qnetworkcookie.cpp | 2 +- src/network/access/qnetworkdiskcache.cpp | 22 +- src/network/access/qnetworkreplyfileimpl.cpp | 2 +- src/network/access/qnetworkreplyimpl.cpp | 26 +-- src/network/access/qnetworkrequest.cpp | 6 +- src/network/access/qspdyprotocolhandler.cpp | 14 +- src/network/bearer/qnetworkconfigmanager.cpp | 2 +- src/network/bearer/qnetworkconfigmanager_p.cpp | 4 +- src/network/bearer/qnetworkconfiguration.cpp | 2 +- src/network/bearer/qnetworksession.cpp | 2 +- src/network/kernel/qauthenticator.cpp | 10 +- src/network/kernel/qdnslookup.cpp | 4 +- src/network/kernel/qdnslookup_unix.cpp | 8 +- src/network/kernel/qhostaddress.cpp | 2 +- src/network/kernel/qhostinfo.cpp | 4 +- src/network/kernel/qhostinfo_unix.cpp | 8 +- src/network/kernel/qnetworkinterface.cpp | 2 +- src/network/kernel/qnetworkproxy.cpp | 12 +- src/network/kernel/qurlinfo.cpp | 10 +- src/network/socket/qabstractsocket.cpp | 6 +- src/network/socket/qabstractsocketengine.cpp | 6 +- src/network/socket/qhttpsocketengine.cpp | 16 +- src/network/socket/qlocalserver.cpp | 2 +- src/network/socket/qlocalserver_unix.cpp | 2 +- src/network/socket/qlocalsocket.cpp | 2 +- src/network/socket/qlocalsocket_unix.cpp | 8 +- src/network/socket/qnativesocketengine.cpp | 12 +- src/network/socket/qnativesocketengine_unix.cpp | 6 +- src/network/socket/qsocks5socketengine.cpp | 28 +-- src/network/socket/qtcpserver.cpp | 6 +- .../nativecontexts/qglxnativecontext.h | 6 +- .../eglconvenience/qeglconvenience.cpp | 6 +- .../eglconvenience/qeglplatformcontext.cpp | 10 +- .../fontconfig/qfontconfigdatabase.cpp | 72 +++---- .../fontconfig/qfontenginemultifontconfig.cpp | 4 +- .../fontdatabases/freetype/qfontengine_ft.cpp | 84 ++++---- .../glxconvenience/qglxconvenience.cpp | 4 +- .../input/integrityhid/qintegrityhidmanager.h | 2 +- src/plugins/bearer/qnetworksession_impl.cpp | 6 +- src/plugins/imageformats/gif/qgifhandler.cpp | 12 +- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 8 +- src/plugins/platforms/eglfs/api/qeglfscontext.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfscursor.cpp | 2 +- .../platforms/eglfs/api/qeglfsintegration.cpp | 18 +- .../platforms/eglfs/api/qeglfsoffscreenwindow.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfsscreen.cpp | 4 +- src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 8 +- .../eglfs_kms/qeglfskmsgbmcursor.cpp | 4 +- .../eglfs_x11/qeglfsx11integration.cpp | 16 +- .../eglfs_x11/qeglfsx11integration.h | 2 +- src/plugins/platforms/eglfs/qeglfsmain.cpp | 2 +- src/plugins/platforms/offscreen/main.cpp | 2 +- .../platforms/offscreen/qoffscreencommon.cpp | 10 +- .../platforms/offscreen/qoffscreenintegration.cpp | 2 +- .../offscreen/qoffscreenintegration_x11.cpp | 12 +- .../platforms/offscreen/qoffscreenwindow.cpp | 2 +- src/plugins/platforms/vnc/main.cpp | 2 +- src/plugins/platforms/vnc/qvnc.cpp | 4 +- src/plugins/platforms/vnc/qvncclient.cpp | 2 +- src/plugins/platforms/vnc/qvncscreen.cpp | 2 +- .../xcb/gl_integrations/xcb_egl/qxcbeglcontext.h | 2 +- .../xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp | 2 +- .../gl_integrations/xcb_glx/qglxintegration.cpp | 52 ++--- .../gl_integrations/xcb_glx/qxcbglxintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbatom.cpp | 2 +- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 12 +- src/plugins/platforms/xcb/qxcbclipboard.cpp | 22 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 16 +- src/plugins/platforms/xcb/qxcbconnection.h | 2 +- src/plugins/platforms/xcb/qxcbconnection_basic.cpp | 4 +- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 4 +- src/plugins/platforms/xcb/qxcbcursor.cpp | 36 ++-- src/plugins/platforms/xcb/qxcbdrag.cpp | 20 +- src/plugins/platforms/xcb/qxcbimage.cpp | 8 +- src/plugins/platforms/xcb/qxcbintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 4 +- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 10 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 10 +- src/plugins/platforms/xcb/qxcbsessionmanager.cpp | 24 +-- .../platforms/xcb/qxcbsystemtraytracker.cpp | 4 +- src/plugins/platforms/xcb/qxcbvulkaninstance.cpp | 2 +- src/plugins/platforms/xcb/qxcbvulkanwindow.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 18 +- src/plugins/platforms/xcb/qxcbxsettings.cpp | 2 +- src/plugins/platformthemes/gtk3/main.cpp | 2 +- .../platformthemes/gtk3/qgtk3dialoghelpers.cpp | 8 +- src/plugins/platformthemes/gtk3/qgtk3menu.cpp | 4 +- src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 10 +- src/plugins/sqldrivers/mysql/qsql_mysql_p.h | 4 +- src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h | 4 +- src/plugins/sqldrivers/tds/qsql_tds_p.h | 4 +- src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 2 +- src/printsupport/dialogs/qprintdialog_unix.cpp | 2 +- src/printsupport/kernel/qpaintengine_alpha.cpp | 12 +- src/printsupport/kernel/qplatformprintplugin.h | 2 +- src/printsupport/kernel/qprinter_p.h | 10 +- src/sql/kernel/qsqldatabase.cpp | 6 +- src/sql/kernel/qsqldriver.cpp | 2 +- src/sql/models/qsqlrelationaltablemodel.cpp | 14 +- src/tools/moc/generator.cpp | 2 +- src/tools/moc/parser.cpp | 2 +- src/tools/moc/preprocessor.cpp | 2 +- src/widgets/accessible/complexwidgets.cpp | 18 +- src/widgets/accessible/itemviews.cpp | 50 ++--- src/widgets/accessible/qaccessiblemenu.cpp | 14 +- src/widgets/accessible/qaccessiblewidget.cpp | 8 +- .../accessible/qaccessiblewidgetfactory.cpp | 6 +- src/widgets/accessible/qaccessiblewidgets.cpp | 28 +-- src/widgets/accessible/simplewidgets.cpp | 4 +- src/widgets/dialogs/qcolordialog.cpp | 22 +- src/widgets/dialogs/qdialog.cpp | 14 +- src/widgets/dialogs/qerrormessage.cpp | 10 +- src/widgets/dialogs/qfiledialog.cpp | 44 ++-- src/widgets/dialogs/qfilesystemmodel.cpp | 6 +- src/widgets/dialogs/qfontdialog.cpp | 20 +- src/widgets/dialogs/qinputdialog.cpp | 10 +- src/widgets/dialogs/qmessagebox.cpp | 56 ++--- src/widgets/dialogs/qprogressdialog.cpp | 22 +- src/widgets/dialogs/qsidebar.cpp | 6 +- src/widgets/dialogs/qwizard.cpp | 38 ++-- src/widgets/effects/qgraphicseffect.cpp | 2 +- src/widgets/effects/qpixmapfilter.cpp | 10 +- src/widgets/graphicsview/qgraphicsanchorlayout.cpp | 4 +- .../graphicsview/qgraphicsanchorlayout_p.cpp | 50 ++--- src/widgets/graphicsview/qgraphicsgridlayout.cpp | 8 +- src/widgets/graphicsview/qgraphicsitem.cpp | 84 ++++---- .../graphicsview/qgraphicsitemanimation.cpp | 2 +- src/widgets/graphicsview/qgraphicslayout_p.cpp | 2 +- src/widgets/graphicsview/qgraphicslayoutitem.cpp | 2 +- .../graphicsview/qgraphicslayoutstyleinfo.cpp | 2 +- src/widgets/graphicsview/qgraphicslinearlayout.cpp | 10 +- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 52 ++--- src/widgets/graphicsview/qgraphicsscene.cpp | 144 ++++++------- src/widgets/graphicsview/qgraphicssceneevent.cpp | 6 +- src/widgets/graphicsview/qgraphicstransform.cpp | 4 +- src/widgets/graphicsview/qgraphicsview.cpp | 30 +-- src/widgets/graphicsview/qgraphicswidget.cpp | 24 +-- src/widgets/graphicsview/qgraphicswidget_p.cpp | 8 +- src/widgets/graphicsview/qsimplex_p.cpp | 10 +- src/widgets/itemviews/qabstractitemdelegate.cpp | 2 +- src/widgets/itemviews/qabstractitemview.cpp | 48 ++--- src/widgets/itemviews/qcolumnview.cpp | 12 +- src/widgets/itemviews/qdatawidgetmapper.cpp | 8 +- src/widgets/itemviews/qdirmodel.cpp | 20 +- src/widgets/itemviews/qheaderview.cpp | 18 +- src/widgets/itemviews/qitemdelegate.cpp | 18 +- src/widgets/itemviews/qitemeditorfactory.cpp | 14 +- src/widgets/itemviews/qlistview.cpp | 14 +- src/widgets/itemviews/qlistwidget.cpp | 22 +- src/widgets/itemviews/qstyleditemdelegate.cpp | 10 +- src/widgets/itemviews/qtablewidget.cpp | 60 +++--- src/widgets/itemviews/qtreeview.cpp | 18 +- src/widgets/itemviews/qtreewidget.cpp | 56 ++--- src/widgets/itemviews/qtreewidgetitemiterator.cpp | 16 +- src/widgets/kernel/qaction.cpp | 2 +- src/widgets/kernel/qactiongroup.cpp | 6 +- src/widgets/kernel/qapplication.cpp | 174 +++++++-------- src/widgets/kernel/qboxlayout.cpp | 20 +- src/widgets/kernel/qdesktopwidget.cpp | 2 +- src/widgets/kernel/qformlayout.cpp | 70 +++--- src/widgets/kernel/qgesture.cpp | 4 +- src/widgets/kernel/qgesturemanager.cpp | 18 +- src/widgets/kernel/qgridlayout.cpp | 28 +-- src/widgets/kernel/qlayout.cpp | 26 +-- src/widgets/kernel/qlayoutengine.cpp | 2 +- src/widgets/kernel/qlayoutitem.cpp | 4 +- src/widgets/kernel/qopenglwidget.cpp | 26 +-- src/widgets/kernel/qstackedlayout.cpp | 14 +- src/widgets/kernel/qtooltip.cpp | 16 +- src/widgets/kernel/qwhatsthis.cpp | 16 +- src/widgets/kernel/qwidget.cpp | 190 ++++++++--------- src/widgets/kernel/qwidget_p.h | 2 +- src/widgets/kernel/qwidgetaction.cpp | 8 +- src/widgets/kernel/qwidgetrepaintmanager.cpp | 16 +- src/widgets/kernel/qwidgetsvariant.cpp | 6 +- src/widgets/kernel/qwidgetwindow.cpp | 34 +-- src/widgets/kernel/qwindowcontainer.cpp | 10 +- src/widgets/statemachine/qguistatemachine.cpp | 2 +- src/widgets/styles/qcommonstyle.cpp | 30 +-- src/widgets/styles/qproxystyle.cpp | 2 +- src/widgets/styles/qstylefactory.cpp | 2 +- src/widgets/styles/qstylehelper.cpp | 2 +- src/widgets/styles/qstyleoption.cpp | 6 +- src/widgets/styles/qstylesheetstyle.cpp | 110 +++++----- src/widgets/util/qcolormap.cpp | 4 +- src/widgets/util/qcompleter.cpp | 2 +- src/widgets/util/qflickgesture.cpp | 36 ++-- src/widgets/util/qscroller.cpp | 10 +- src/widgets/util/qscrollerproperties.cpp | 6 +- src/widgets/util/qsystemtrayicon.cpp | 8 +- src/widgets/util/qsystemtrayicon_x11.cpp | 4 +- src/widgets/util/qundogroup.cpp | 26 +-- src/widgets/util/qundostack.cpp | 18 +- src/widgets/util/qundoview.cpp | 32 +-- src/widgets/widgets/qabstractbutton.cpp | 10 +- src/widgets/widgets/qabstractscrollarea.cpp | 22 +- src/widgets/widgets/qabstractspinbox.cpp | 10 +- src/widgets/widgets/qbuttongroup.cpp | 6 +- src/widgets/widgets/qcalendarwidget.cpp | 38 ++-- src/widgets/widgets/qdatetimeedit.cpp | 6 +- src/widgets/widgets/qdialogbuttonbox.cpp | 22 +- src/widgets/widgets/qdockarealayout.cpp | 234 ++++++++++----------- src/widgets/widgets/qdockwidget.cpp | 80 +++---- src/widgets/widgets/qeffects.cpp | 14 +- src/widgets/widgets/qfocusframe.cpp | 18 +- src/widgets/widgets/qgroupbox.cpp | 4 +- src/widgets/widgets/qlcdnumber.cpp | 6 +- src/widgets/widgets/qlineedit.cpp | 14 +- src/widgets/widgets/qlineedit_p.cpp | 6 +- src/widgets/widgets/qlineedit_p.h | 2 +- src/widgets/widgets/qmainwindow.cpp | 16 +- src/widgets/widgets/qmainwindowlayout.cpp | 88 ++++---- src/widgets/widgets/qmdiarea.cpp | 68 +++--- src/widgets/widgets/qmdisubwindow.cpp | 96 ++++----- src/widgets/widgets/qmenu.cpp | 156 +++++++------- src/widgets/widgets/qmenubar.cpp | 112 +++++----- src/widgets/widgets/qplaintextedit.cpp | 10 +- src/widgets/widgets/qpushbutton.cpp | 6 +- src/widgets/widgets/qscrollarea.cpp | 6 +- src/widgets/widgets/qscrollbar.cpp | 18 +- src/widgets/widgets/qsizegrip.cpp | 2 +- src/widgets/widgets/qsplashscreen.cpp | 6 +- src/widgets/widgets/qsplitter.cpp | 4 +- src/widgets/widgets/qstackedwidget.cpp | 2 +- src/widgets/widgets/qstatusbar.cpp | 22 +- src/widgets/widgets/qtabbar.cpp | 42 ++-- src/widgets/widgets/qtabbar_p.h | 4 +- src/widgets/widgets/qtabwidget.cpp | 10 +- src/widgets/widgets/qtextedit.cpp | 2 +- src/widgets/widgets/qtoolbar.cpp | 62 +++--- src/widgets/widgets/qtoolbararealayout.cpp | 40 ++-- src/widgets/widgets/qtoolbarlayout.cpp | 34 +-- src/widgets/widgets/qtoolbox.cpp | 16 +- src/widgets/widgets/qtoolbutton.cpp | 14 +- src/widgets/widgets/qwidgetanimator.cpp | 2 +- src/widgets/widgets/qwidgetlinecontrol.cpp | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 12 +- 502 files changed, 4329 insertions(+), 4329 deletions(-) (limited to 'src') diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 46b01449d4..b7136dc055 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -220,7 +220,7 @@ QUnifiedTimer::QUnifiedTimer() : QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), currentAnimationIdx(0), insideTick(false), insideRestart(false), consistentTiming(false), slowMode(false), startTimersPending(false), stopTimerPending(false), - slowdownFactor(5.0f), profilerCallback(0), + slowdownFactor(5.0f), profilerCallback(nullptr), driverStartTime(0), temporalDrift(0) { time.invalidate(); @@ -922,7 +922,7 @@ qint64 QAnimationDriver::elapsed() const The default animation driver just spins the timer... */ QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer) - : QAnimationDriver(0), m_unified_timer(timer) + : QAnimationDriver(nullptr), m_unified_timer(timer) { connect(this, SIGNAL(started()), this, SLOT(startTimer())); connect(this, SIGNAL(stopped()), this, SLOT(stopTimer())); @@ -1035,7 +1035,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) \sa QVariantAnimation, QAnimationGroup */ QAbstractAnimation::QAbstractAnimation(QObject *parent) - : QObject(*new QAbstractAnimationPrivate, 0) + : QObject(*new QAbstractAnimationPrivate, nullptr) { // Allow auto-add on reparent setParent(parent); @@ -1045,7 +1045,7 @@ QAbstractAnimation::QAbstractAnimation(QObject *parent) \internal */ QAbstractAnimation::QAbstractAnimation(QAbstractAnimationPrivate &dd, QObject *parent) - : QObject(dd, 0) + : QObject(dd, nullptr) { // Allow auto-add on reparent setParent(parent); diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index 69e2cfc9bc..729f55d68f 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -133,7 +133,7 @@ QAbstractAnimation *QAnimationGroup::animationAt(int index) const if (index < 0 || index >= d->animations.size()) { qWarning("QAnimationGroup::animationAt: index is out of bounds"); - return 0; + return nullptr; } return d->animations.at(index); @@ -243,14 +243,14 @@ QAbstractAnimation *QAnimationGroup::takeAnimation(int index) Q_D(QAnimationGroup); if (index < 0 || index >= d->animations.size()) { qWarning("QAnimationGroup::takeAnimation: no animation at index %d", index); - return 0; + return nullptr; } QAbstractAnimation *animation = d->animations.at(index); - QAbstractAnimationPrivate::get(animation)->group = 0; + QAbstractAnimationPrivate::get(animation)->group = nullptr; // ### removing from list before doing setParent to avoid inifinite recursion // in ChildRemoved event d->animations.removeAt(index); - animation->setParent(0); + animation->setParent(nullptr); d->animationRemoved(index, animation); return animation; } diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 2a3572d441..c71a77e073 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -259,7 +259,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, QVariantAnimation::updateState(newState, oldState); - QPropertyAnimation *animToStop = 0; + QPropertyAnimation *animToStop = nullptr; { static QBasicMutex mutex; auto locker = qt_unique_lock(mutex); diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index 66e346a2fe..98ac04a14f 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -282,7 +282,7 @@ QPauseAnimation *QSequentialAnimationGroup::insertPause(int index, int msecs) if (index < 0 || index > d->animations.size()) { qWarning("QSequentialAnimationGroup::insertPause: index is out of bounds"); - return 0; + return nullptr; } QPauseAnimation *pause = new QPauseAnimation(msecs); @@ -430,7 +430,7 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter if (index == -1) { Q_ASSERT(animations.isEmpty()); currentAnimationIndex = -1; - currentAnimation = 0; + currentAnimation = nullptr; return; } @@ -503,7 +503,7 @@ void QSequentialAnimationGroupPrivate::_q_uncontrolledAnimationFinished() */ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index) { - if (currentAnimation == 0) + if (currentAnimation == nullptr) setCurrentAnimation(0); // initialize the current animation if (currentAnimationIndex == index diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 216c015732..98b02f0202 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -209,7 +209,7 @@ void QVariantAnimationPrivate::updateInterpolator() if (type == currentInterval.end.second.userType()) interpolator = getInterpolator(type); else - interpolator = 0; + interpolator = nullptr; //we make sure that the interpolator is always set to something if (!interpolator) @@ -445,7 +445,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in { QInterpolatorVector *interpolators = registeredInterpolators(); const auto locker = qt_scoped_lock(registeredInterpolatorsMutex); - QVariantAnimation::Interpolator ret = 0; + QVariantAnimation::Interpolator ret = nullptr; if (interpolationType < interpolators->count()) { ret = interpolators->at(interpolationType); if (ret) return ret; @@ -479,7 +479,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in case QMetaType::QRectF: return castToInterpolator(_q_interpolateVariant<QRectF>); default: - return 0; //this type is not handled + return nullptr; //this type is not handled } } diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp index 5a778c2638..f9092277b2 100644 --- a/src/corelib/codecs/qicucodec.cpp +++ b/src/corelib/codecs/qicucodec.cpp @@ -381,7 +381,7 @@ static QTextCodec *loadQtCodec(const char *name) return QIsciiCodec::create(name); #endif - return 0; + return nullptr; } /// \threadsafe @@ -438,7 +438,7 @@ QTextCodec *QIcuCodec::defaultCodecUnlocked() { QCoreGlobalData *globalData = QCoreGlobalData::instance(); if (!globalData) - return 0; + return nullptr; QTextCodec *c = globalData->codecForLocale.loadAcquire(); if (c) return c; @@ -523,13 +523,13 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name) return c; if (qt_only) - return 0; + return nullptr; // check whether there is really a converter for the name available. UConverter *conv = ucnv_open(standardName, &error); if (!conv) { qDebug("codecForName: ucnv_open failed %s %s", standardName, u_errorName(error)); - return 0; + return nullptr; } //qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName; ucnv_close(conv); @@ -552,7 +552,7 @@ QTextCodec *QIcuCodec::codecForMibUnlocked(int mib) if (mib == 2107) return codecForNameUnlocked("TSCII"); - return 0; + return nullptr; } @@ -567,7 +567,7 @@ QIcuCodec::~QIcuCodec() UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const { - UConverter *conv = 0; + UConverter *conv = nullptr; if (state) { if (!state->d) { // first time @@ -609,7 +609,7 @@ QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::C ucnv_toUnicode(conv, &uc, ucEnd, &chars, end, - 0, false, &error); + nullptr, false, &error); if (!U_SUCCESS(error) && error != U_BUFFER_OVERFLOW_ERROR) { qDebug("convertToUnicode failed: %s", u_errorName(error)); break; @@ -646,7 +646,7 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QText ucnv_fromUnicode(conv, &ch, chEnd, &uc, end, - 0, false, &error); + nullptr, false, &error); if (!U_SUCCESS(error)) qDebug("convertFromUnicode failed: %s", u_errorName(error)); convertedChars = ch - string.data(); diff --git a/src/corelib/codecs/qisciicodec.cpp b/src/corelib/codecs/qisciicodec.cpp index d9a86d77c7..9689818559 100644 --- a/src/corelib/codecs/qisciicodec.cpp +++ b/src/corelib/codecs/qisciicodec.cpp @@ -74,7 +74,7 @@ QTextCodec *QIsciiCodec::create(const char *name) if (qTextCodecNameMatch(name, codecs[i].name)) return new QIsciiCodec(i); } - return 0; + return nullptr; } QIsciiCodec::~QIsciiCodec() diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp index 16a9b8a7c3..4e82620003 100644 --- a/src/corelib/codecs/qsimplecodec.cpp +++ b/src/corelib/codecs/qsimplecodec.cpp @@ -51,7 +51,7 @@ static const struct { quint16 values[128]; } unicodevalues[QSimpleTextCodec::numSimpleCodecs] = { // from RFC 1489, ftp://ftp.isi.edu/in-notes/rfc1489.txt - { "KOI8-R", { "csKOI8R", 0 }, 2084, + { "KOI8-R", { "csKOI8R", nullptr }, 2084, { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219/**/, 0x221A, 0x2248, @@ -72,7 +72,7 @@ static const struct { // it should be 0x2022 (BULLET). // from RFC 2319, ftp://ftp.isi.edu/in-notes/rfc2319.txt - { "KOI8-U", { "KOI8-RU", 0 }, 2088, + { "KOI8-U", { "KOI8-RU", nullptr }, 2088, { 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590, 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, @@ -97,7 +97,7 @@ static const struct { // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo 0x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; for a in 8859-* ; do (awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a ; cat /tmp/digits) | sort | uniq -w4 | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done // then I inserted the files manually. - { "ISO-8859-2", {"latin2", "iso-ir-101", "csISOLatin2", 0 }, 5, + { "ISO-8859-2", {"latin2", "iso-ir-101", "csISOLatin2", nullptr }, 5, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -114,7 +114,7 @@ static const struct { 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9} }, - { "ISO-8859-3", { "latin3", "iso-ir-109", "csISOLatin3", 0 }, 6, + { "ISO-8859-3", { "latin3", "iso-ir-109", "csISOLatin3", nullptr }, 6, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -131,7 +131,7 @@ static const struct { 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0xFFFD, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9} }, - { "ISO-8859-4", { "latin4", "iso-ir-110", "csISOLatin4", 0 }, 7, + { "ISO-8859-4", { "latin4", "iso-ir-110", "csISOLatin4", nullptr }, 7, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -148,7 +148,7 @@ static const struct { 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B, 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9} }, - { "ISO-8859-5", { "cyrillic", "iso-ir-144", "csISOLatinCyrillic", 0 }, 8, + { "ISO-8859-5", { "cyrillic", "iso-ir-144", "csISOLatinCyrillic", nullptr }, 8, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -165,7 +165,7 @@ static const struct { 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F} }, - { "ISO-8859-6", { "ISO-8859-6-I", "ECMA-114", "ASMO-708", "arabic", "iso-ir-127", "csISOLatinArabic", 0 }, 82, + { "ISO-8859-6", { "ISO-8859-6-I", "ECMA-114", "ASMO-708", "arabic", "iso-ir-127", "csISOLatinArabic", nullptr }, 82, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -182,7 +182,7 @@ static const struct { 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x0651, 0x0652, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, - { "ISO-8859-7", { "ECMA-118", "greek", "iso-ir-126", "csISOLatinGreek", 0 }, 10, + { "ISO-8859-7", { "ECMA-118", "greek", "iso-ir-126", "csISOLatinGreek", nullptr }, 10, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -199,7 +199,7 @@ static const struct { 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD} }, - { "ISO-8859-8", { "ISO 8859-8-I", "iso-ir-138", "hebrew", "csISOLatinHebrew", 0 }, 85, + { "ISO-8859-8", { "ISO 8859-8-I", "iso-ir-138", "hebrew", "csISOLatinHebrew", nullptr }, 85, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -216,7 +216,7 @@ static const struct { 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, - { "ISO-8859-9", { "iso-ir-148", "latin5", "csISOLatin5", 0 }, 12, + { "ISO-8859-9", { "iso-ir-148", "latin5", "csISOLatin5", nullptr }, 12, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -233,7 +233,7 @@ static const struct { 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF} }, - { "ISO-8859-10", { "iso-ir-157", "latin6", "ISO-8859-10:1992", "csISOLatin6", 0 }, 13, + { "ISO-8859-10", { "iso-ir-157", "latin6", "ISO-8859-10:1992", "csISOLatin6", nullptr }, 13, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -250,7 +250,7 @@ static const struct { 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138} }, - { "ISO-8859-13", { 0 }, 109, + { "ISO-8859-13", { nullptr }, 109, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -267,7 +267,7 @@ static const struct { 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019} }, - { "ISO-8859-14", { "iso-ir-199", "latin8", "iso-celtic", 0 }, 110, + { "ISO-8859-14", { "iso-ir-199", "latin8", "iso-celtic", nullptr }, 110, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -284,7 +284,7 @@ static const struct { 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF} }, - { "ISO-8859-16", { "iso-ir-226", "latin10", 0 }, 112, + { "ISO-8859-16", { "iso-ir-226", "latin10", nullptr }, 112, { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, @@ -305,7 +305,7 @@ static const struct { // next bits generated again from tables on the Unicode 3.0 CD. // $ for a in CP* ; do (awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a) | sort | sed -e 's/#UNDEF.*$/0xFFFD/' | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done - { "IBM850", { "CP850", "csPC850Multilingual", 0 }, 2009, + { "IBM850", { "CP850", "csPC850Multilingual", nullptr }, 2009, { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, @@ -322,7 +322,7 @@ static const struct { 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4, 0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0} }, - { "IBM874", { "CP874", 0 }, -874, //### what is the mib? + { "IBM874", { "CP874", nullptr }, -874, //### what is the mib? { 0x20AC, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2026, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -339,7 +339,7 @@ static const struct { 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, - { "IBM866", { "CP866", "csIBM866", 0 }, 2086, + { "IBM866", { "CP866", "csIBM866", nullptr }, 2086, { 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, @@ -357,7 +357,7 @@ static const struct { 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0} }, - { "windows-1250", { "CP1250", 0 }, 2250, + { "windows-1250", { "CP1250", nullptr }, 2250, { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, 0xFFFD, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -374,7 +374,7 @@ static const struct { 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9} }, - { "windows-1251", { "CP1251", 0 }, 2251, + { "windows-1251", { "CP1251", nullptr }, 2251, { 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -391,7 +391,7 @@ static const struct { 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F} }, - { "windows-1252", { "CP1252", 0 }, 2252, + { "windows-1252", { "CP1252", nullptr }, 2252, { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0x017D, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -408,7 +408,7 @@ static const struct { 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} }, - { "windows-1253", {"CP1253", 0 }, 2253, + { "windows-1253", {"CP1253", nullptr }, 2253, { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -425,7 +425,7 @@ static const struct { 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD} }, - { "windows-1254", { "CP1254", 0 }, 2254, + { "windows-1254", { "CP1254", nullptr }, 2254, { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -442,7 +442,7 @@ static const struct { 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF} }, - { "windows-1255", { "CP1255", 0 }, 2255, + { "windows-1255", { "CP1255", nullptr }, 2255, { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -459,7 +459,7 @@ static const struct { 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0x200E, 0x200F, 0xFFFD} }, - { "windows-1256", { "CP1256", 0 }, 2256, + { "windows-1256", { "CP1256", nullptr }, 2256, { 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, 0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -476,7 +476,7 @@ static const struct { 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF, 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7, 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2} }, - { "windows-1257", { "CP1257", 0 }, 2257, + { "windows-1257", { "CP1257", nullptr }, 2257, { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0x00A8, 0x02C7, 0x00B8, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -493,7 +493,7 @@ static const struct { 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9} }, - { "windows-1258", { "CP1258", 0 }, 2258, + { "windows-1258", { "CP1258", nullptr }, 2258, { 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0xFFFD, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -511,7 +511,7 @@ static const struct { 0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} }, - { "macintosh", { "Apple Roman", "MacRoman", 0 }, 2027, + { "macintosh", { "Apple Roman", "MacRoman", nullptr }, 2027, { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, @@ -532,7 +532,7 @@ static const struct { // This one is based on the charmap file // /usr/share/i18n/charmaps/SAMI-WS2.gz, which is manually adapted // to this format by Boerre Gaup <boerre@subdimension.com> - { "WINSAMI2", { "WS2", 0 }, -165, + { "WINSAMI2", { "WS2", nullptr }, -165, { 0x20AC, 0xFFFD, 0x010C, 0x0192, 0x010D, 0x01B7, 0x0292, 0x01EE, 0x01EF, 0x0110, 0x0160, 0x2039, 0x0152, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -555,7 +555,7 @@ static const struct { // to iso8859-11, so we name it 8859-11 here, but recognise the name tis620 too. // $ for A in 8 9 A B C D E F ; do for B in 0 1 2 3 4 5 6 7 8 9 A B C D E F ; do echo x${A}${B} 0xFFFD ; done ; done > /tmp/digits ; (cut -c25- < TIS-620 ; cat /tmp/digits) | awk '/^x[89ABCDEF]/{ print $1, $2 }' | sed -e 's/<U/0x/' -e 's/>//' | sort | uniq -w4 | cut -c5- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/tis-620 - { "TIS-620", { "ISO 8859-11", 0 }, 2259, // Thai character set mib enum taken from tis620 (which is byte by byte equivalent) + { "TIS-620", { "ISO 8859-11", nullptr }, 2259, // Thai character set mib enum taken from tis620 (which is byte by byte equivalent) { 0x20AC, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2026, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, @@ -582,7 +582,7 @@ static const struct { Alias: r8 Alias: csHPRoman8 */ - { "hp-roman8", { "roman8", "csHPRoman8", 0 }, 2004, + { "hp-roman8", { "roman8", "csHPRoman8", nullptr }, 2004, { 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, @@ -603,7 +603,7 @@ static const struct { // if you add more chacater sets at the end, change LAST_MIB above }; -QSimpleTextCodec::QSimpleTextCodec(int i) : forwardIndex(i), reverseMap(0) +QSimpleTextCodec::QSimpleTextCodec(int i) : forwardIndex(i), reverseMap(nullptr) { } @@ -640,7 +640,7 @@ static QByteArray *buildReverseMap(int forwardIndex) QString QSimpleTextCodec::convertToUnicode(const char* chars, int len, ConverterState *) const { - if (len <= 0 || chars == 0) + if (len <= 0 || chars == nullptr) return QString(); const unsigned char * c = (const unsigned char *)chars; @@ -665,7 +665,7 @@ QByteArray QSimpleTextCodec::convertFromUnicode(const QChar *in, int length, Con QByteArray *rmap = reverseMap.loadAcquire(); if (!rmap){ rmap = buildReverseMap(this->forwardIndex); - if (!reverseMap.testAndSetRelease(0, rmap)) { + if (!reverseMap.testAndSetRelease(nullptr, rmap)) { delete rmap; rmap = reverseMap.loadAcquire(); } diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 1ebffd9f49..ecd26233cd 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -124,12 +124,12 @@ public: QLibrarySettings *ls = qt_library_settings(); if (ls) { #ifndef QT_BUILD_QMAKE - if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != 0) + if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != nullptr) ls->load(); #endif return ls->settings.data(); } else { - return 0; + return nullptr; } } }; @@ -146,7 +146,7 @@ void QLibrarySettings::load() // If we get any settings here, those won't change when the application shows up. settings.reset(QLibraryInfoPrivate::findConfiguration()); #ifndef QT_BUILD_QMAKE - reloadOnQAppAvailable = (settings.data() == 0 && QCoreApplication::instance() == 0); + reloadOnQAppAvailable = (settings.data() == nullptr && QCoreApplication::instance() == nullptr); bool haveDevicePaths; bool haveEffectivePaths; bool havePaths; @@ -169,7 +169,7 @@ void QLibrarySettings::load() || children.contains(QLatin1String("Paths")); #ifndef QT_BUILD_QMAKE if (!havePaths) - settings.reset(0); + settings.reset(nullptr); #else } else { haveDevicePaths = false; @@ -212,7 +212,7 @@ QSettings *QLibraryInfoPrivate::findConfiguration() return new QSettings(qtconfig, QSettings::IniFormat); } #endif - return 0; //no luck + return nullptr; //no luck } #endif // settings @@ -750,7 +750,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group) // will binary-patch the Qt installation paths -- in such scenarios, Qt // will be built with a dummy path, thus the compile-time result of // strlen is meaningless. - const char * volatile path = 0; + const char * volatile path = nullptr; if (loc == PrefixPath) { path = getPrefix( #ifdef QT_BUILD_QMAKE diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 17f2246082..c9209bd8e3 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1315,7 +1315,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount) if (function.startsWith(QLatin1String("_Z"))) { QScopedPointer<char, QScopedPointerPodDeleter> demangled( - abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); + abi::__cxa_demangle(function.toUtf8(), nullptr, nullptr, nullptr)); if (demangled) function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); } diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 95f03ef816..5320ae2986 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -251,7 +251,7 @@ QFile::QFile(QFilePrivate &dd) Constructs a QFile object. */ QFile::QFile() - : QFileDevice(*new QFilePrivate, 0) + : QFileDevice(*new QFilePrivate, nullptr) { } /*! @@ -265,7 +265,7 @@ QFile::QFile(QObject *parent) Constructs a new file object to represent the file with the given \a name. */ QFile::QFile(const QString &name) - : QFileDevice(*new QFilePrivate, 0) + : QFileDevice(*new QFilePrivate, nullptr) { Q_D(QFile); d->fileName = name; diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index ee619d99cc..b0aba3193c 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -202,7 +202,7 @@ QFileDevice::QFileDevice(QFileDevicePrivate &dd) \internal */ QFileDevice::QFileDevice() - : QIODevice(*new QFileDevicePrivate, 0) + : QIODevice(*new QFileDevicePrivate, nullptr) { } /*! diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index c3abec8989..2e81f93bcf 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1076,14 +1076,14 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat // sendfile(2) is limited in the kernel to 2G - 4k const size_t SendfileSize = 0x7ffff000; - ssize_t n = ::sendfile(dstfd, srcfd, NULL, SendfileSize); + ssize_t n = ::sendfile(dstfd, srcfd, nullptr, SendfileSize); if (n == -1) { // if we got an error here, give up and try at an upper layer return false; } while (n) { - n = ::sendfile(dstfd, srcfd, NULL, SendfileSize); + n = ::sendfile(dstfd, srcfd, nullptr, SendfileSize); if (n == -1) { // uh oh, this is probably a real error (like ENOSPC), but we have // no way to notify QFile of partial success, so just erase any work diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 54460aff77..86c8963cb6 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -88,7 +88,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject } QFileSystemWatcherPrivate::QFileSystemWatcherPrivate() - : native(0), poller(0) + : native(nullptr), poller(nullptr) { } diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index ca1f6cc359..888af998a5 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -242,7 +242,7 @@ QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create(QObject if (fd == -1) { fd = inotify_init(); if (fd == -1) - return 0; + return nullptr; } return new QInotifyFileSystemWatcherEngine(fd, parent); } diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index e26508e631..b89cab5e3c 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -461,7 +461,7 @@ QIODevice::QIODevice(QIODevicePrivate &dd) */ QIODevice::QIODevice() - : QObject(*new QIODevicePrivate, 0) + : QObject(*new QIODevicePrivate, nullptr) { #if defined QIODEVICE_DEBUG QFile *file = qobject_cast<QFile *>(this); diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index d1806aa12b..df0197e8eb 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE \internal */ -QNonContiguousByteDevice::QNonContiguousByteDevice() : QObject((QObject*)0) +QNonContiguousByteDevice::QNonContiguousByteDevice() : QObject((QObject*)nullptr) { } @@ -188,7 +188,7 @@ const char* QNonContiguousByteDeviceByteArrayImpl::readPointer(qint64 maximumLen { if (atEnd()) { len = -1; - return 0; + return nullptr; } if (maximumLength != -1) @@ -241,7 +241,7 @@ const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLe { if (atEnd()) { len = -1; - return 0; + return nullptr; } const char *returnValue = ringBuffer->readPointerAtPosition(currentPosition, len); @@ -282,7 +282,7 @@ qint64 QNonContiguousByteDeviceRingBufferImpl::size() const QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d) : QNonContiguousByteDevice(), - currentReadBuffer(0), currentReadBufferSize(16*1024), + currentReadBuffer(nullptr), currentReadBufferSize(16*1024), currentReadBufferAmount(0), currentReadBufferPosition(0), totalAdvancements(0), eof(false) { @@ -301,10 +301,10 @@ const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLeng { if (eof == true) { len = -1; - return 0; + return nullptr; } - if (currentReadBuffer == 0) + if (currentReadBuffer == nullptr) currentReadBuffer = new QByteArray(currentReadBufferSize, '\0'); // lazy alloc if (maximumLength == -1) @@ -323,7 +323,7 @@ const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLeng // size was unknown before, emit a readProgress with the final size if (size() == -1) emit readProgress(totalAdvancements, totalAdvancements); - return 0; + return nullptr; } currentReadBufferAmount = haveRead; @@ -349,7 +349,7 @@ bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) if (currentReadBufferPosition > currentReadBufferAmount) { qint64 i = currentReadBufferPosition - currentReadBufferAmount; while (i > 0) { - if (device->getChar(0) == false) { + if (device->getChar(nullptr) == false) { emit readProgress(totalAdvancements - i, size()); return false; // ### FIXME handle eof } @@ -377,7 +377,7 @@ bool QNonContiguousByteDeviceIoDeviceImpl::reset() totalAdvancements = 0; //reset the progress counter if (currentReadBuffer) { delete currentReadBuffer; - currentReadBuffer = 0; + currentReadBuffer = nullptr; } currentReadBufferAmount = 0; currentReadBufferPosition = 0; @@ -405,7 +405,7 @@ qint64 QNonContiguousByteDeviceIoDeviceImpl::pos() const return device->pos(); } -QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0) +QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)nullptr) { byteDevice = bd; connect(bd, SIGNAL(readyRead()), SIGNAL(readyRead())); diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 35ca2542f7..ad2e7fb6b8 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -216,7 +216,7 @@ void QProcessEnvironmentPrivate::insert(const QProcessEnvironmentPrivate &other) environment variables to be removed. */ QProcessEnvironment::QProcessEnvironment() - : d(0) + : d(nullptr) { } @@ -436,18 +436,18 @@ void QProcessPrivate::Channel::clear() case PipeSource: Q_ASSERT(process); process->stdinChannel.type = Normal; - process->stdinChannel.process = 0; + process->stdinChannel.process = nullptr; break; case PipeSink: Q_ASSERT(process); process->stdoutChannel.type = Normal; - process->stdoutChannel.process = 0; + process->stdoutChannel.process = nullptr; break; } type = Normal; file.clear(); - process = 0; + process = nullptr; } /*! @@ -869,8 +869,8 @@ QProcessPrivate::QProcessPrivate() sequenceNumber = 0; exitCode = 0; exitStatus = QProcess::NormalExit; - startupSocketNotifier = 0; - deathNotifier = 0; + startupSocketNotifier = nullptr; + deathNotifier = nullptr; childStartedPipe[0] = INVALID_Q_PIPE; childStartedPipe[1] = INVALID_Q_PIPE; forkfd = -1; @@ -924,23 +924,23 @@ void QProcessPrivate::cleanup() if (stdoutChannel.notifier) { delete stdoutChannel.notifier; - stdoutChannel.notifier = 0; + stdoutChannel.notifier = nullptr; } if (stderrChannel.notifier) { delete stderrChannel.notifier; - stderrChannel.notifier = 0; + stderrChannel.notifier = nullptr; } if (stdinChannel.notifier) { delete stdinChannel.notifier; - stdinChannel.notifier = 0; + stdinChannel.notifier = nullptr; } if (startupSocketNotifier) { delete startupSocketNotifier; - startupSocketNotifier = 0; + startupSocketNotifier = nullptr; } if (deathNotifier) { delete deathNotifier; - deathNotifier = 0; + deathNotifier = nullptr; } closeChannel(&stdoutChannel); closeChannel(&stderrChannel); @@ -1229,7 +1229,7 @@ void QProcessPrivate::closeWriteChannel() #endif if (stdinChannel.notifier) { delete stdinChannel.notifier; - stdinChannel.notifier = 0; + stdinChannel.notifier = nullptr; } #ifdef Q_OS_WIN // ### Find a better fix, feeding the process little by little @@ -2615,7 +2615,7 @@ QT_END_INCLUDE_NAMESPACE QStringList QProcess::systemEnvironment() { QStringList tmp; - char *entry = 0; + char *entry = nullptr; int count = 0; while ((entry = environ[count++])) tmp << QString::fromLocal8Bit(entry); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 9edb4a6d11..9cd3bd531b 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -338,11 +338,11 @@ static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Map &environme { *envc = 0; if (environment.isEmpty()) - return 0; + return nullptr; char **envp = new char *[environment.count() + 2]; - envp[environment.count()] = 0; - envp[environment.count() + 1] = 0; + envp[environment.count()] = nullptr; + envp[environment.count() + 1] = nullptr; auto it = environment.constBegin(); const auto end = environment.constEnd(); @@ -390,7 +390,7 @@ void QProcessPrivate::startProcess() // Create argument list with right number of elements, and set the final // one to 0. char **argv = new char *[arguments.count() + 2]; - argv[arguments.count() + 1] = 0; + argv[arguments.count() + 1] = nullptr; // Encode the program name. QByteArray encodedProgramName = QFile::encodeName(program); @@ -437,13 +437,13 @@ void QProcessPrivate::startProcess() // Duplicate the environment. int envc = 0; - char **envp = 0; + char **envp = nullptr; if (environment.d.constData()) { envp = _q_dupEnvironment(environment.d.constData()->vars, &envc); } // Encode the working directory if it's non-empty, otherwise just pass 0. - const char *workingDirPtr = 0; + const char *workingDirPtr = nullptr; QByteArray encodedWorkingDirectory; if (!workingDirectory.isEmpty()) { encodedWorkingDirectory = QFile::encodeName(workingDirectory); @@ -596,7 +596,7 @@ bool QProcessPrivate::processStarted(QString *errorMessage) if (startupSocketNotifier) { startupSocketNotifier->setEnabled(false); startupSocketNotifier->deleteLater(); - startupSocketNotifier = 0; + startupSocketNotifier = nullptr; } qt_safe_close(childStartedPipe[0]); childStartedPipe[0] = -1; @@ -889,7 +889,7 @@ bool QProcessPrivate::waitForDeadChild() crashed = info.code != CLD_EXITED; delete deathNotifier; - deathNotifier = 0; + deathNotifier = nullptr; EINTR_LOOP(ret, forkfd_close(forkfd)); forkfd = -1; // Child is dead, don't try to kill it anymore @@ -935,7 +935,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - ::sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, nullptr); ::setsid(); @@ -964,7 +964,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) char **argv = new char *[arguments.size() + 2]; for (int i = 0; i < arguments.size(); ++i) argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData()); - argv[arguments.size() + 1] = 0; + argv[arguments.size() + 1] = nullptr; // Duplicate the environment. int envc = 0; @@ -991,7 +991,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - ::sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, nullptr); // '\1' means execv failed char c = '\1'; @@ -1002,7 +1002,7 @@ bool QProcessPrivate::startDetached(qint64 *pid) struct sigaction noaction; memset(&noaction, 0, sizeof(noaction)); noaction.sa_handler = SIG_IGN; - ::sigaction(SIGPIPE, &noaction, 0); + ::sigaction(SIGPIPE, &noaction, nullptr); // '\2' means internal error char c = '\2'; diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 0a145b2be4..3664a63050 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1584,7 +1584,7 @@ QAbstractFileEngine::Iterator *QResourceFileEngine::beginEntryList(QDir::Filters */ QAbstractFileEngine::Iterator *QResourceFileEngine::endEntryList() { - return 0; + return nullptr; } bool QResourceFileEngine::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) @@ -1594,7 +1594,7 @@ bool QResourceFileEngine::extension(Extension extension, const ExtensionOption * const MapExtensionOption *options = (const MapExtensionOption*)(option); MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output); returnValue->address = d->map(options->offset, options->size, options->flags); - return (returnValue->address != 0); + return (returnValue->address != nullptr); } if (extension == UnMapExtension) { const UnMapExtensionOption *options = (const UnMapExtensionOption*)option; @@ -1623,7 +1623,7 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory if (offset < 0 || size <= 0 || !resource.isValid() || add_overflow(offset, size, &end) || end > max) { q->setError(QFile::UnspecifiedError, QString()); - return 0; + return nullptr; } const uchar *address = resource.data(); diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index 0a884a7df9..067ccda3df 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -116,7 +116,7 @@ QSaveFile::QSaveFile(const QString &name) Constructs a new file object to represent the file with the given \a name. */ QSaveFile::QSaveFile(const QString &name) - : QFileDevice(*new QSaveFilePrivate, 0) + : QFileDevice(*new QSaveFilePrivate, nullptr) { Q_D(QSaveFile); d->fileName = name; diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index dcc9340473..9fc45e307d 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -206,7 +206,7 @@ QConfFile *QConfFile::fromName(const QString &fileName, bool _userPerms) ConfFileHash *usedHash = usedHashFunc(); ConfFileCache *unusedCache = unusedCacheFunc(); - QConfFile *confFile = 0; + QConfFile *confFile = nullptr; const auto locker = qt_scoped_lock(settingsGlobalMutex); if (!(confFile = usedHash->value(absPath))) { @@ -230,7 +230,7 @@ void QConfFile::clearCache() // QSettingsPrivate QSettingsPrivate::QSettingsPrivate(QSettings::Format format) - : format(format), scope(QSettings::UserScope /* nothing better to put */), iniCodec(0), fallbacks(true), + : format(format), scope(QSettings::UserScope /* nothing better to put */), iniCodec(nullptr), fallbacks(true), pendingChanges(false), status(QSettings::NoError) { } @@ -238,7 +238,7 @@ QSettingsPrivate::QSettingsPrivate(QSettings::Format format) QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope, const QString &organization, const QString &application) : format(format), scope(scope), organizationName(organization), applicationName(application), - iniCodec(0), fallbacks(true), pendingChanges(false), status(QSettings::NoError) + iniCodec(nullptr), fallbacks(true), pendingChanges(false), status(QSettings::NoError) { } @@ -924,8 +924,8 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx) void QConfFileSettingsPrivate::initFormat() { extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"); - readFunc = 0; - writeFunc = 0; + readFunc = nullptr; + writeFunc = nullptr; #if defined(Q_OS_MAC) caseSensitivity = (format == QSettings::NativeFormat) ? Qt::CaseSensitive : IniCaseSensitivity; #else @@ -3338,7 +3338,7 @@ bool QSettings::contains(const QString &key) const { Q_D(const QSettings); QString k = d->actualKey(key); - return d->get(k, 0); + return d->get(k, nullptr); } /*! diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index fa975ce117..46ac703615 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -61,7 +61,7 @@ Q_LOGGING_CATEGORY(lcCheckIndex, "qt.core.qabstractitemmodel.checkindex") QPersistentModelIndexData *QPersistentModelIndexData::create(const QModelIndex &index) { Q_ASSERT(index.isValid()); // we will _never_ insert an invalid index in the list - QPersistentModelIndexData *d = 0; + QPersistentModelIndexData *d = nullptr; QAbstractItemModel *model = const_cast<QAbstractItemModel *>(index.model()); QHash<QModelIndex, QPersistentModelIndexData *> &indexes = model->d_func()->persistent.indexes; const auto it = indexes.constFind(index); @@ -136,7 +136,7 @@ void QPersistentModelIndexData::destroy(QPersistentModelIndexData *data) */ QPersistentModelIndex::QPersistentModelIndex() - : d(0) + : d(nullptr) { } @@ -158,7 +158,7 @@ QPersistentModelIndex::QPersistentModelIndex(const QPersistentModelIndex &other) */ QPersistentModelIndex::QPersistentModelIndex(const QModelIndex &index) - : d(0) + : d(nullptr) { if (index.isValid()) { d = QPersistentModelIndexData::create(index); @@ -176,7 +176,7 @@ QPersistentModelIndex::~QPersistentModelIndex() { if (d && !d->ref.deref()) { QPersistentModelIndexData::destroy(d); - d = 0; + d = nullptr; } } @@ -257,7 +257,7 @@ QPersistentModelIndex &QPersistentModelIndex::operator=(const QModelIndex &other d = QPersistentModelIndexData::create(other); if (d) d->ref.ref(); } else { - d = 0; + d = nullptr; } return *this; } @@ -344,7 +344,7 @@ void *QPersistentModelIndex::internalPointer() const { if (d) return d->index.internalPointer(); - return 0; + return nullptr; } /*! @@ -442,7 +442,7 @@ const QAbstractItemModel *QPersistentModelIndex::model() const { if (d) return d->index.model(); - return 0; + return nullptr; } /*! @@ -484,7 +484,7 @@ QDebug operator<<(QDebug dbg, const QPersistentModelIndex &idx) class QEmptyItemModel : public QAbstractItemModel { public: - explicit QEmptyItemModel(QObject *parent = 0) : QAbstractItemModel(parent) {} + explicit QEmptyItemModel(QObject *parent = nullptr) : QAbstractItemModel(parent) {} QModelIndex index(int, int, const QModelIndex &) const override { return QModelIndex(); } QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); } int rowCount(const QModelIndex &) const override { return 0; } @@ -1950,10 +1950,10 @@ QStringList QAbstractItemModel::mimeTypes() const QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const { if (indexes.count() <= 0) - return 0; + return nullptr; QStringList types = mimeTypes(); if (types.isEmpty()) - return 0; + return nullptr; QMimeData *data = new QMimeData(); QString format = types.at(0); QByteArray encoded; diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp index c863406afd..87559cd6b2 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.cpp +++ b/src/corelib/itemmodels/qabstractproxymodel.cpp @@ -159,7 +159,7 @@ QAbstractItemModel *QAbstractProxyModel::sourceModel() const { Q_D(const QAbstractProxyModel); if (d->model == QAbstractItemModelPrivate::staticEmptyModel()) - return 0; + return nullptr; return d->model; } diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index 0319d215a1..3afa132483 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -497,7 +497,7 @@ void QConcatenateTablesProxyModel::removeSourceModel(QAbstractItemModel *sourceM { Q_D(QConcatenateTablesProxyModel); Q_ASSERT(d->m_models.contains(sourceModel)); - disconnect(sourceModel, 0, this, 0); + disconnect(sourceModel, nullptr, this, nullptr); const int rowsRemoved = sourceModel->rowCount(); const int rowsPrior = d->computeRowsPrior(sourceModel); // location of removed section diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index c93a4d15b9..f4402c88dc 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -656,7 +656,7 @@ void QItemSelectionModelPrivate::initModel(QAbstractItemModel *m) SLOT(_q_layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)) }, { SIGNAL(modelReset()), SLOT(reset()) }, - { 0, 0 } + { nullptr, nullptr } }; if (model == m) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 32efa727b8..34f54d8f94 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -530,10 +530,10 @@ void QCoreApplicationPrivate::eventDispatcherReady() { } -QBasicAtomicPointer<QThread> QCoreApplicationPrivate::theMainThread = Q_BASIC_ATOMIC_INITIALIZER(0); +QBasicAtomicPointer<QThread> QCoreApplicationPrivate::theMainThread = Q_BASIC_ATOMIC_INITIALIZER(nullptr); QThread *QCoreApplicationPrivate::mainThread() { - Q_ASSERT(theMainThread.loadRelaxed() != 0); + Q_ASSERT(theMainThread.loadRelaxed() != nullptr); return theMainThread.loadRelaxed(); } @@ -690,7 +690,7 @@ QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p) #ifdef QT_NO_QOBJECT : d_ptr(&p) #else - : QObject(p, 0) + : QObject(p, nullptr) #endif { d_func()->q_ptr = this; @@ -1139,7 +1139,7 @@ bool QCoreApplication::notify(QObject *receiver, QEvent *event) static bool doNotify(QObject *receiver, QEvent *event) { - if (receiver == 0) { // serious error + if (receiver == nullptr) { // serious error qWarning("QCoreApplication::notify: Unexpected null receiver"); return true; } @@ -1388,7 +1388,7 @@ void QCoreApplicationPrivate::execCleanup() if (!aboutToQuitEmitted) emit q_func()->aboutToQuit(QCoreApplication::QPrivateSignal()); aboutToQuitEmitted = true; - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); } @@ -1531,7 +1531,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority) { Q_TRACE_SCOPE(QCoreApplication_postEvent, receiver, event, event->type()); - if (receiver == 0) { + if (receiver == nullptr) { qWarning("QCoreApplication::postEvent: Unexpected null receiver"); delete event; return; @@ -1635,7 +1635,7 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven for (int i = 0; i < postedEvents->size(); ++i) { const QPostEvent &cur = postedEvents->at(i); if (cur.receiver != receiver - || cur.event == 0 + || cur.event == nullptr || cur.event->type() != event->type()) continue; // found an event for this receiver @@ -1784,7 +1784,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type // null out the event so if sendPostedEvents recurses, it // will ignore this one, as it's been re-posted. - const_cast<QPostEvent &>(pe).event = 0; + const_cast<QPostEvent &>(pe).event = nullptr; // re-post the copied event so it isn't lost data->postEventList.addEvent(pe_copy); @@ -1804,7 +1804,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type // next, update the data structure so that we're ready // for the next event. - const_cast<QPostEvent &>(pe).event = 0; + const_cast<QPostEvent &>(pe).event = nullptr; locker.unlock(); const auto relocker = qScopeGuard([&locker] { locker.lock(); }); @@ -1867,7 +1867,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) --pe.receiver->d_func()->postedEvents; pe.event->posted = false; events.append(pe.event); - const_cast<QPostEvent &>(pe).event = 0; + const_cast<QPostEvent &>(pe).event = nullptr; } else if (!data->postEventList.recursion) { if (i != j) qSwap(data->postEventList[i], data->postEventList[j]); @@ -1929,7 +1929,7 @@ void QCoreApplicationPrivate::removePostedEvent(QEvent * event) --pe.receiver->d_func()->postedEvents; pe.event->posted = false; delete pe.event; - const_cast<QPostEvent &>(pe).event = 0; + const_cast<QPostEvent &>(pe).event = nullptr; return; } } @@ -2204,7 +2204,7 @@ QString QCoreApplication::translate(const char *context, const char *sourceText, // Declared in qglobal.h QString qtTrId(const char *id, int n) { - return QCoreApplication::translate(0, id, 0, n); + return QCoreApplication::translate(nullptr, id, nullptr, n); } bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator) @@ -2956,7 +2956,7 @@ QAbstractEventDispatcher *QCoreApplication::eventDispatcher() { if (QCoreApplicationPrivate::theMainThread.loadAcquire()) return QCoreApplicationPrivate::theMainThread.loadRelaxed()->eventDispatcher(); - return 0; + return nullptr; } /*! diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 4cfc749386..e3326f00d7 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -295,7 +295,7 @@ QT_BEGIN_NAMESPACE Contructs an event object of type \a type. */ QEvent::QEvent(Type type) - : d(0), t(type), posted(false), spont(false), m_accept(true) + : d(nullptr), t(type), posted(false), spont(false), m_accept(true) { Q_TRACE(QEvent_ctor, this, t); } diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index d9746ef6e2..92f3553247 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -114,9 +114,9 @@ static GSourceFuncs socketNotifierSourceFuncs = { socketNotifierSourcePrepare, socketNotifierSourceCheck, socketNotifierSourceDispatch, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr }; struct GTimerSource @@ -188,9 +188,9 @@ static GSourceFuncs timerSourceFuncs = { timerSourcePrepare, timerSourceCheck, timerSourceDispatch, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr }; struct GIdleTimerSource @@ -227,7 +227,7 @@ static gboolean idleTimerSourceCheck(GSource *source) static gboolean idleTimerSourceDispatch(GSource *source, GSourceFunc, gpointer) { GTimerSource *timerSource = reinterpret_cast<GIdleTimerSource *>(source)->timerSource; - (void) timerSourceDispatch(&timerSource->source, 0, 0); + (void) timerSourceDispatch(&timerSource->source, nullptr, nullptr); return true; } @@ -235,9 +235,9 @@ static GSourceFuncs idleTimerSourceFuncs = { idleTimerSourcePrepare, idleTimerSourceCheck, idleTimerSourceDispatch, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr }; struct GPostEventSource @@ -267,7 +267,7 @@ static gboolean postEventSourcePrepare(GSource *s, gint *timeout) static gboolean postEventSourceCheck(GSource *source) { - return postEventSourcePrepare(source, 0); + return postEventSourcePrepare(source, nullptr); } static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer) @@ -283,9 +283,9 @@ static GSourceFuncs postEventSourceFuncs = { postEventSourcePrepare, postEventSourceCheck, postEventSourceDispatch, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr }; @@ -372,10 +372,10 @@ QEventDispatcherGlib::~QEventDispatcherGlib() d->timerSource->timerList.~QTimerInfoList(); g_source_destroy(&d->timerSource->source); g_source_unref(&d->timerSource->source); - d->timerSource = 0; + d->timerSource = nullptr; g_source_destroy(&d->idleTimerSource->source); g_source_unref(&d->idleTimerSource->source); - d->idleTimerSource = 0; + d->idleTimerSource = nullptr; // destroy socket notifier source for (int i = 0; i < d->socketNotifierSource->pollfds.count(); ++i) { @@ -386,19 +386,19 @@ QEventDispatcherGlib::~QEventDispatcherGlib() d->socketNotifierSource->pollfds.~QList<GPollFDWithQSocketNotifier *>(); g_source_destroy(&d->socketNotifierSource->source); g_source_unref(&d->socketNotifierSource->source); - d->socketNotifierSource = 0; + d->socketNotifierSource = nullptr; // destroy post event source g_source_destroy(&d->postEventSource->source); g_source_unref(&d->postEventSource->source); - d->postEventSource = 0; + d->postEventSource = nullptr; - Q_ASSERT(d->mainContext != 0); + Q_ASSERT(d->mainContext != nullptr); #if GLIB_CHECK_VERSION (2, 22, 0) g_main_context_pop_thread_default (d->mainContext); #endif g_main_context_unref(d->mainContext); - d->mainContext = 0; + d->mainContext = nullptr; } bool QEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags) diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 2492d70005..0165ce9075 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -465,7 +465,7 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags) emit awake(); auto threadData = d->threadData.loadRelaxed(); - QCoreApplicationPrivate::sendPostedEvents(0, 0, threadData); + QCoreApplicationPrivate::sendPostedEvents(nullptr, 0, threadData); const bool include_timers = (flags & QEventLoop::X11ExcludeTimers) == 0; const bool include_notifiers = (flags & QEventLoop::ExcludeSocketNotifiers) == 0; diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 5cb30a74ac..fad47eee13 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -282,14 +282,14 @@ QObject *QMetaObject::newInstance(QGenericArgument val0, idx = indexOfConstructor(norm.constData()); } if (idx < 0) - return 0; + return nullptr; - QObject *returnValue = 0; + QObject *returnValue = nullptr; void *param[] = {&returnValue, val0.data(), val1.data(), val2.data(), val3.data(), val4.data(), val5.data(), val6.data(), val7.data(), val8.data(), val9.data()}; if (static_metacall(CreateInstance, idx, param) >= 0) - return 0; + return nullptr; return returnValue; } @@ -301,7 +301,7 @@ int QMetaObject::static_metacall(Call cl, int idx, void **argv) const Q_ASSERT(priv(d.data)->revision >= 6); if (!d.static_metacall) return 0; - d.static_metacall(0, cl, idx, argv); + d.static_metacall(nullptr, cl, idx, argv); return -1; } @@ -691,7 +691,7 @@ static void argumentTypesFromString(const char *str, const char *end, QByteArray QMetaObjectPrivate::decodeMethodSignature( const char *signature, QArgumentTypeArray &types) { - Q_ASSERT(signature != 0); + Q_ASSERT(signature != nullptr); const char *lparens = strchr(signature, '('); if (!lparens) return QByteArray(); @@ -844,7 +844,7 @@ int QMetaObjectPrivate::indexOfConstructor(const QMetaObject *m, const QByteArra */ int QMetaObjectPrivate::absoluteSignalCount(const QMetaObject *m) { - Q_ASSERT(m != 0); + Q_ASSERT(m != nullptr); int n = priv(m->d.data)->signalCount; for (m = m->d.superdata; m; m = m->d.superdata) n += priv(m->d.data)->signalCount; @@ -881,7 +881,7 @@ QMetaMethod QMetaObjectPrivate::signal(const QMetaObject *m, int signal_index) QMetaMethod result; if (signal_index < 0) return result; - Q_ASSERT(m != 0); + Q_ASSERT(m != nullptr); int i = signal_index; i -= signalOffset(m); if (i < 0 && m->d.superdata) @@ -1031,7 +1031,7 @@ int QMetaObject::indexOfProperty(const char *name) const QAbstractDynamicMetaObject *me = const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this)); - return me->createProperty(name, 0); + return me->createProperty(name, nullptr); } return -1; @@ -1145,7 +1145,7 @@ QMetaProperty QMetaObject::property(int index) const if (!result.menum.isValid()) { const char *enum_name = type; const char *scope_name = objectClassName(this); - char *scope_buffer = 0; + char *scope_buffer = nullptr; const char *colon = strrchr(enum_name, ':'); // ':' will always appear in pairs @@ -1159,7 +1159,7 @@ QMetaProperty QMetaObject::property(int index) const enum_name = colon+1; } - const QMetaObject *scope = 0; + const QMetaObject *scope = nullptr; if (qstrcmp(scope_name, "Qt") == 0) scope = &QObject::staticQtMetaObject; else @@ -1542,14 +1542,14 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase * return false; } - QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 1)); + QCoreApplication::postEvent(object, new QMetaCallEvent(slot, nullptr, -1, 1)); } else if (type == Qt::BlockingQueuedConnection) { #if QT_CONFIG(thread) if (currentThread == objectThread) qWarning("QMetaObject::invokeMethod: Dead lock detected"); QSemaphore semaphore; - QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, argv, &semaphore)); + QCoreApplication::postEvent(object, new QMetaCallEvent(slot, nullptr, -1, argv, &semaphore)); semaphore.acquire(); #endif // QT_CONFIG(thread) } else { @@ -1988,7 +1988,7 @@ QList<QByteArray> QMetaMethod::parameterNames() const const char *QMetaMethod::typeName() const { if (!mobj) - return 0; + return nullptr; return QMetaMethodPrivate::get(this)->rawReturnTypeName(); } @@ -2020,7 +2020,7 @@ const char *QMetaMethod::typeName() const const char *QMetaMethod::tag() const { if (!mobj) - return 0; + return nullptr; return QMetaMethodPrivate::get(this)->tag().constData(); } @@ -2303,7 +2303,7 @@ bool QMetaMethod::invoke(QObject *object, return false; } - QScopedPointer<QMetaCallEvent> event(new QMetaCallEvent(idx_offset, idx_relative, callFunction, 0, -1, paramCount)); + QScopedPointer<QMetaCallEvent> event(new QMetaCallEvent(idx_offset, idx_relative, callFunction, nullptr, -1, paramCount)); int *types = event->types(); void **args = event->args(); @@ -2340,7 +2340,7 @@ bool QMetaMethod::invoke(QObject *object, QSemaphore semaphore; QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction, - 0, -1, param, &semaphore)); + nullptr, -1, param, &semaphore)); semaphore.acquire(); #endif // QT_CONFIG(thread) } @@ -2563,7 +2563,7 @@ bool QMetaMethod::invokeOnGadget(void* gadget, QGenericReturnArgument returnValu const char *QMetaEnum::name() const { if (!mobj) - return 0; + return nullptr; return rawStringData(mobj, mobj->d.data[handle]); } @@ -2582,7 +2582,7 @@ const char *QMetaEnum::name() const const char *QMetaEnum::enumName() const { if (!mobj) - return 0; + return nullptr; const bool rev8p = priv(mobj->d.data)->revision >= 8; if (rev8p) return rawStringData(mobj, mobj->d.data[handle + 1]); @@ -2610,13 +2610,13 @@ int QMetaEnum::keyCount() const const char *QMetaEnum::key(int index) const { if (!mobj) - return 0; + return nullptr; const int offset = priv(mobj->d.data)->revision >= 8 ? 3 : 2; int count = mobj->d.data[handle + offset]; int data = mobj->d.data[handle + offset + 1]; if (index >= 0 && index < count) return rawStringData(mobj, mobj->d.data[data + 2*index]); - return 0; + return nullptr; } /*! @@ -2679,7 +2679,7 @@ bool QMetaEnum::isScoped() const */ const char *QMetaEnum::scope() const { - return mobj ? objectClassName(mobj) : 0; + return mobj ? objectClassName(mobj) : nullptr; } /*! @@ -2695,7 +2695,7 @@ const char *QMetaEnum::scope() const */ int QMetaEnum::keyToValue(const char *key, bool *ok) const { - if (ok != 0) + if (ok != nullptr) *ok = false; if (!mobj || !key) return -1; @@ -2715,7 +2715,7 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const const QByteArray className = stringData(mobj, priv(mobj->d.data)->className); if ((!scope || (className.size() == int(scope) && strncmp(qualified_key, className.constData(), scope) == 0)) && strcmp(key, rawStringData(mobj, mobj->d.data[data + 2*i])) == 0) { - if (ok != 0) + if (ok != nullptr) *ok = true; return mobj->d.data[data + 2*i + 1]; } @@ -2734,14 +2734,14 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const const char* QMetaEnum::valueToKey(int value) const { if (!mobj) - return 0; + return nullptr; const int offset = priv(mobj->d.data)->revision >= 8 ? 3 : 2; int count = mobj->d.data[handle + offset]; int data = mobj->d.data[handle + offset + 1]; for (int i = 0; i < count; ++i) if (value == (int)mobj->d.data[data + 2*i + 1]) return rawStringData(mobj, mobj->d.data[data + 2*i]); - return 0; + return nullptr; } /*! @@ -2756,11 +2756,11 @@ const char* QMetaEnum::valueToKey(int value) const */ int QMetaEnum::keysToValue(const char *keys, bool *ok) const { - if (ok != 0) + if (ok != nullptr) *ok = false; if (!mobj || !keys) return -1; - if (ok != 0) + if (ok != nullptr) *ok = true; const QString keysString = QString::fromLatin1(keys); const QVector<QStringRef> splitKeys = keysString.splitRef(QLatin1Char('|')); @@ -2793,7 +2793,7 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const } } if (i < 0) { - if (ok != 0) + if (ok != nullptr) *ok = false; value |= -1; } @@ -2896,7 +2896,7 @@ static QByteArray qualifiedName(const QMetaEnum &e) \internal */ QMetaProperty::QMetaProperty() - : mobj(0), handle(0), idx(0) + : mobj(nullptr), handle(0), idx(0) { } @@ -2909,7 +2909,7 @@ QMetaProperty::QMetaProperty() const char *QMetaProperty::name() const { if (!mobj) - return 0; + return nullptr; int handle = priv(mobj->d.data)->propertyData + 3*idx; return rawStringData(mobj, mobj->d.data[handle]); } @@ -2922,7 +2922,7 @@ const char *QMetaProperty::name() const const char *QMetaProperty::typeName() const { if (!mobj) - return 0; + return nullptr; int handle = priv(mobj->d.data)->propertyData + 3*idx; return rawTypeNameFromTypeInfo(mobj, mobj->d.data[handle + 1]); } @@ -3112,7 +3112,7 @@ QVariant QMetaProperty::read(const QObject *object) const t = enumMetaTypeId; } else { int handle = priv(mobj->d.data)->propertyData + 3*idx; - const char *typeName = 0; + const char *typeName = nullptr; Q_ASSERT(priv(mobj->d.data)->revision >= 7); uint typeInfo = mobj->d.data[handle + 1]; if (!(typeInfo & IsUnresolvedType)) @@ -3138,11 +3138,11 @@ QVariant QMetaProperty::read(const QObject *object) const // changed: result stored directly in value int status = -1; QVariant value; - void *argv[] = { 0, &value, &status }; + void *argv[] = { nullptr, &value, &status }; if (t == QMetaType::QVariant) { argv[0] = &value; } else { - value = QVariant(t, (void*)0); + value = QVariant(t, (void*)nullptr); argv[0] = value.data(); } if (priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall) { @@ -3196,7 +3196,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const v.convert(QVariant::Int); } else { int handle = priv(mobj->d.data)->propertyData + 3*idx; - const char *typeName = 0; + const char *typeName = nullptr; Q_ASSERT(priv(mobj->d.data)->revision >= 7); uint typeInfo = mobj->d.data[handle + 1]; if (!(typeInfo & IsUnresolvedType)) @@ -3213,7 +3213,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const if (!value.isValid()) { if (isResettable()) return reset(object); - v = QVariant(t, 0); + v = QVariant(t, nullptr); } else if (!v.convert(t)) { return false; } @@ -3229,7 +3229,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const // the flags variable is used by the declarative module to implement // interception of property writes. int flags = 0; - void *argv[] = { 0, &v, &status, &flags }; + void *argv[] = { nullptr, &v, &status, &flags }; if (t == QMetaType::QVariant) argv[0] = &v; else @@ -3254,7 +3254,7 @@ bool QMetaProperty::reset(QObject *object) const { if (!object || !mobj || !isResettable()) return false; - void *argv[] = { 0 }; + void *argv[] = { nullptr }; if (priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall) mobj->d.static_metacall(object, QMetaObject::ResetProperty, idx, argv); else @@ -3638,7 +3638,7 @@ bool QMetaProperty::isEditable(const QObject *object) const const char *QMetaClassInfo::name() const { if (!mobj) - return 0; + return nullptr; return rawStringData(mobj, mobj->d.data[handle]); } @@ -3650,7 +3650,7 @@ const char *QMetaClassInfo::name() const const char* QMetaClassInfo::value() const { if (!mobj) - return 0; + return nullptr; return rawStringData(mobj, mobj->d.data[handle + 1]); } diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index f77c4ce32f..4ecc340787 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -210,7 +210,7 @@ public: : flags(0) { superClass = &QObject::staticMetaObject; - staticMetacallFunction = 0; + staticMetacallFunction = nullptr; } bool hasRevisionedProperties() const; @@ -749,7 +749,7 @@ void QMetaObjectBuilder::addMetaObject Q_ASSERT(priv(prototype->d.data)->revision >= 2); const auto *objects = prototype->d.relatedMetaObjects; if (objects) { - while (*objects != 0) { + while (*objects != nullptr) { addRelatedMetaObject(*objects); ++objects; } @@ -831,7 +831,7 @@ const QMetaObject *QMetaObjectBuilder::relatedMetaObject(int index) const if (index >= 0 && index < d->relatedMetaObjects.size()) return d->relatedMetaObjects[index]; else - return 0; + return nullptr; } /*! @@ -1196,8 +1196,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, ALIGN(size, int); if (buf) { if (!relocatable) meta->d.superdata = d->superClass; - meta->d.relatedMetaObjects = 0; - meta->d.extradata = 0; + meta->d.relatedMetaObjects = nullptr; + meta->d.extradata = nullptr; meta->d.static_metacall = d->staticMetacallFunction; } @@ -1494,7 +1494,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, */ QMetaObject *QMetaObjectBuilder::toMetaObject() const { - int size = buildMetaObject(d, 0, 0, false); + int size = buildMetaObject(d, nullptr, 0, false); char *buf = reinterpret_cast<char *>(malloc(size)); memset(buf, 0, size); buildMetaObject(d, buf, size, false); @@ -1517,7 +1517,7 @@ QMetaObject *QMetaObjectBuilder::toMetaObject() const */ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const { - int size = buildMetaObject(d, 0, 0, true); + int size = buildMetaObject(d, nullptr, 0, true); if (size == -1) { if (ok) *ok = false; return QByteArray(); @@ -1555,9 +1555,9 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output, output->d.superdata = superclass; output->d.stringdata = reinterpret_cast<const QByteArrayData *>(buf + stringdataOffset); output->d.data = reinterpret_cast<const uint *>(buf + dataOffset); - output->d.extradata = 0; - output->d.relatedMetaObjects = 0; - output->d.static_metacall = 0; + output->d.extradata = nullptr; + output->d.relatedMetaObjects = nullptr; + output->d.static_metacall = nullptr; } /*! @@ -1720,14 +1720,14 @@ void QMetaObjectBuilder::deserialize d->enumerators.clear(); d->constructors.clear(); d->relatedMetaObjects.clear(); - d->staticMetacallFunction = 0; + d->staticMetacallFunction = nullptr; // Read the class and super class names. stream >> d->className; stream >> name; if (name.isEmpty()) { - d->superClass = 0; - } else if ((cl = resolveClassName(references, name)) != 0) { + d->superClass = nullptr; + } else if ((cl = resolveClassName(references, name)) != nullptr) { d->superClass = cl; } else { stream.setStatus(QDataStream::ReadCorruptData); @@ -1877,7 +1877,7 @@ QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const else if (_mobj && -_index >= 1 && -_index <= int(_mobj->d->constructors.size())) return &(_mobj->d->constructors[(-_index) - 1]); else - return 0; + return nullptr; } /*! @@ -2116,7 +2116,7 @@ QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const if (_mobj && _index >= 0 && _index < int(_mobj->d->properties.size())) return &(_mobj->d->properties[_index]); else - return 0; + return nullptr; } /*! @@ -2588,7 +2588,7 @@ QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const if (_mobj && _index >= 0 && _index < int(_mobj->d->enumerators.size())) return &(_mobj->d->enumerators[_index]); else - return 0; + return nullptr; } /*! diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 356a675517..3f0b8900e4 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1113,8 +1113,8 @@ static int registerNormalizedType(const NS(QByteArray) &normalizedTypeName, QCustomTypeInfo inf; inf.typeName = normalizedTypeName; #ifndef QT_NO_DATASTREAM - inf.loadOp = 0; - inf.saveOp = 0; + inf.loadOp = nullptr; + inf.saveOp = nullptr; #endif inf.alias = -1; inf.typedConstructor = typedConstructor; @@ -1955,7 +1955,7 @@ public: return Q_LIKELY(qMetaTypeWidgetsHelper) ? qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType].metaObject : nullptr; - return 0; + return nullptr; } }; diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 9a98db21d3..00e5183eb1 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -319,7 +319,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty Constructs a new MIME data object with no data in it. */ QMimeData::QMimeData() - : QObject(*new QMimeDataPrivate, 0) + : QObject(*new QMimeDataPrivate, nullptr) { } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index cee885c0fe..a2c5d7db75 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -109,7 +109,7 @@ static int *queuedConnectionTypes(const QList<QByteArray> &typeNames) "(Make sure '%s' is registered using qRegisterMetaType().)", typeName.constData(), typeName.constData()); delete [] types; - return 0; + return nullptr; } } types[typeNames.count()] = 0; @@ -133,7 +133,7 @@ static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc) qWarning("QObject::connect: Cannot queue arguments of type '%s'\n" "(Make sure '%s' is registered using qRegisterMetaType().)", type.name().constData(), type.name().constData()); - return 0; + return nullptr; } } types[argc] = 0; @@ -160,13 +160,13 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) {} #endif -void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; -void (*QAbstractDeclarativeData::destroyed_qml1)(QAbstractDeclarativeData *, QObject *) = 0; -void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; -void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = 0; -int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = 0; -bool (*QAbstractDeclarativeData::isSignalConnected)(QAbstractDeclarativeData *, const QObject *, int) = 0; -void (*QAbstractDeclarativeData::setWidgetParent)(QObject *, QObject *) = 0; +void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = nullptr; +void (*QAbstractDeclarativeData::destroyed_qml1)(QAbstractDeclarativeData *, QObject *) = nullptr; +void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = nullptr; +void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = nullptr; +int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = nullptr; +bool (*QAbstractDeclarativeData::isSignalConnected)(QAbstractDeclarativeData *, const QObject *, int) = nullptr; +void (*QAbstractDeclarativeData::setWidgetParent)(QObject *, QObject *) = nullptr; /*! \fn QObjectData::QObjectData() @@ -182,7 +182,7 @@ QMetaObject *QObjectData::dynamicMetaObject() const } QObjectPrivate::QObjectPrivate(int version) - : threadData(0), currentChildBeingDeleted(0) + : threadData(nullptr), currentChildBeingDeleted(nullptr) { #ifdef QT_BUILD_INTERNAL // Don't check the version parameter in internal builds. @@ -195,8 +195,8 @@ QObjectPrivate::QObjectPrivate(int version) #endif // QObjectData initialization - q_ptr = 0; - parent = 0; // no parent yet. It is set by setParent() + q_ptr = nullptr; + parent = nullptr; // no parent yet. It is set by setParent() isWidget = false; // assume not a widget object blockSig = false; // not blocking signals wasDeleted = false; // double-delete catcher @@ -204,8 +204,8 @@ QObjectPrivate::QObjectPrivate(int version) sendChildEvents = true; // if we should send ChildAdded and ChildRemoved events to parent receiveChildEvents = true; postedEvents = 0; - extraData = 0; - metaObject = 0; + extraData = nullptr; + metaObject = nullptr; isWindow = false; deleteLaterCalled = false; } @@ -926,8 +926,8 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) d->threadData.storeRelaxed(threadData); if (parent) { QT_TRY { - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData.loadRelaxed() : 0, threadData)) - parent = 0; + if (!check_parent_thread(parent, parent ? parent->d_func()->threadData.loadRelaxed() : nullptr, threadData)) + parent = nullptr; if (d->isWidget) { if (parent) { d->parent = parent; @@ -1095,7 +1095,7 @@ QObject::~QObject() Q_TRACE(QObject_dtor, this); if (d->parent) // remove it from parent object - d->setParent_helper(0); + d->setParent_helper(nullptr); } QObjectPrivate::Connection::~Connection() @@ -1541,7 +1541,7 @@ void QObject::moveToThread(QThread *targetThread) return; } - if (d->parent != 0) { + if (d->parent != nullptr) { qWarning("QObject::moveToThread: Cannot move objects with a parent"); return; } @@ -1618,7 +1618,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData if (pe.receiver == q) { // move this post event to the targetList targetData->postEventList.addEvent(pe); - const_cast<QPostEvent &>(pe).event = 0; + const_cast<QPostEvent &>(pe).event = nullptr; ++eventsMoved; } } @@ -2065,7 +2065,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options) { if (!parent) - return 0; + return nullptr; const QObjectList &children = parent->children(); QObject *obj; int i; @@ -2081,7 +2081,7 @@ QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const return obj; } } - return 0; + return nullptr; } /*! @@ -2109,7 +2109,7 @@ void QObjectPrivate::deleteChildren() delete currentChildBeingDeleted; } children.clear(); - currentChildBeingDeleted = 0; + currentChildBeingDeleted = nullptr; isDeletingChildren = false; } @@ -2161,7 +2161,7 @@ void QObjectPrivate::setParent_helper(QObject *o) // object hierarchies are constrained to a single thread if (threadData != parent->d_func()->threadData) { qWarning("QObject::setParent: Cannot set parent, new parent is in a different thread"); - parent = 0; + parent = nullptr; return; } parent->d_func()->children.append(q); @@ -2232,7 +2232,7 @@ void QObject::installEventFilter(QObject *obj) d->extraData = new QObjectPrivate::ExtraData; // clean up unused items in the list - d->extraData->eventFilters.removeAll((QObject*)0); + d->extraData->eventFilters.removeAll((QObject*)nullptr); d->extraData->eventFilters.removeAll(obj); d->extraData->eventFilters.prepend(obj); } @@ -2256,7 +2256,7 @@ void QObject::removeEventFilter(QObject *obj) if (d->extraData) { for (int i = 0; i < d->extraData->eventFilters.count(); ++i) { if (d->extraData->eventFilters.at(i) == obj) - d->extraData->eventFilters[i] = 0; + d->extraData->eventFilters[i] = nullptr; } } } @@ -2379,7 +2379,7 @@ void QObject::deleteLater() const char *qFlagLocation(const char *method) { QThreadData *currentThreadData = QThreadData::current(false); - if (currentThreadData != 0) + if (currentThreadData != nullptr) currentThreadData->flaggedSignatures.store(method); return method; } @@ -2398,7 +2398,7 @@ static const char * extract_location(const char *member) if (*location != '\0') return location; } - return 0; + return nullptr; } static bool check_signal_macro(const QObject *sender, const char *signal, @@ -2437,7 +2437,7 @@ static void err_method_notfound(const QObject *object, case QSIGNAL_CODE: type = "signal"; break; } const char *loc = extract_location(method); - if (strchr(method,')') == 0) // common typing mistake + if (strchr(method,')') == nullptr) // common typing mistake qWarning("QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : ""); @@ -2497,7 +2497,7 @@ QObject *QObject::sender() const return cd->currentSender->sender; } - return 0; + return nullptr; } /*! @@ -2676,7 +2676,7 @@ void QMetaObjectPrivate::memberIndexes(const QObject *obj, return; const QMetaObject *m = obj->metaObject(); // Check that member is member of obj class - while (m != 0 && m != member.mobj) + while (m != nullptr && m != member.mobj) m = m->d.superdata; if (!m) return; @@ -2787,18 +2787,18 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign const QObject *receiver, const char *method, Qt::ConnectionType type) { - if (sender == 0 || receiver == 0 || signal == 0 || method == 0) { + if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) { qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", sender ? sender->metaObject()->className() : "(null)", (signal && *signal) ? signal+1 : "(null)", receiver ? receiver->metaObject()->className() : "(null)", (method && *method) ? method+1 : "(null)"); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } QByteArray tmp_signal_name; if (!check_signal_macro(sender, signal, "connect", "bind")) - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); const QMetaObject *smeta = sender->metaObject(); const char *signal_arg = signal; ++signal; //skip code @@ -2821,7 +2821,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign if (signal_index < 0) { err_method_notfound(sender, signal_arg, "connect"); err_info_about_objects("connect", sender, receiver); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index); signal_index += QMetaObjectPrivate::signalOffset(smeta); @@ -2830,7 +2830,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign int membcode = extract_code(method); if (!check_method_code(membcode, receiver, method, "connect")) - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); const char *method_arg = method; ++method; // skip code @@ -2873,7 +2873,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign if (method_index_relative < 0) { err_method_notfound(receiver, method_arg, "connect"); err_info_about_objects("connect", sender, receiver); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } if (!QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(), @@ -2882,13 +2882,13 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign "\n %s::%s --> %s::%s", sender->metaObject()->className(), signal, receiver->metaObject()->className(), method); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } - int *types = 0; + int *types = nullptr; if ((type == Qt::QueuedConnection) && !(types = queuedConnectionTypes(signalTypes.constData(), signalTypes.size()))) { - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } #ifndef QT_NO_DEBUG @@ -2925,8 +2925,8 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) { - if (sender == 0 - || receiver == 0 + if (sender == nullptr + || receiver == nullptr || signal.methodType() != QMetaMethod::Signal || method.methodType() == QMetaMethod::Constructor) { qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", @@ -2934,7 +2934,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho signal.methodSignature().constData(), receiver ? receiver->metaObject()->className() : "(null)", method.methodSignature().constData() ); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } int signal_index; @@ -2950,12 +2950,12 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho if (signal_index == -1) { qWarning("QObject::connect: Can't find signal %s on instance of class %s", signal.methodSignature().constData(), smeta->className()); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } if (method_index == -1) { qWarning("QObject::connect: Can't find method %s on instance of class %s", method.methodSignature().constData(), rmeta->className()); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } if (!QMetaObject::checkConnectArgs(signal.methodSignature().constData(), method.methodSignature().constData())) { @@ -2963,19 +2963,19 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho "\n %s::%s --> %s::%s", smeta->className(), signal.methodSignature().constData(), rmeta->className(), method.methodSignature().constData()); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } - int *types = 0; + int *types = nullptr; if ((type == Qt::QueuedConnection) && !(types = queuedConnectionTypes(signal.parameterTypes()))) - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); #ifndef QT_NO_DEBUG check_and_warn_compat(smeta, signal, rmeta, method); #endif QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect( - sender, signal_index, signal.enclosingMetaObject(), receiver, method_index, 0, type, types)); + sender, signal_index, signal.enclosingMetaObject(), receiver, method_index, nullptr, type, types)); return handle; } @@ -3058,7 +3058,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho bool QObject::disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) { - if (sender == 0 || (receiver == 0 && method != 0)) { + if (sender == nullptr || (receiver == nullptr && method != nullptr)) { qWarning("QObject::disconnect: Unexpected null parameter"); return false; } @@ -3130,7 +3130,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal, } if (!method) { - res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, -1, 0); + res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, -1, nullptr); } else { const QMetaObject *rmeta = receiver->metaObject(); do { @@ -3141,7 +3141,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal, rmeta = rmeta->superClass(); if (method_index < 0) break; - res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0); + res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, nullptr); method_found = true; } while ((rmeta = rmeta->superClass())); } @@ -3193,7 +3193,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal, bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) { - if (sender == 0 || (receiver == 0 && method.mobj != 0)) { + if (sender == nullptr || (receiver == nullptr && method.mobj != nullptr)) { qWarning("QObject::disconnect: Unexpected null parameter"); return false; } @@ -3242,7 +3242,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, return false; } - if (!QMetaObjectPrivate::disconnect(sender, signal_index, signal.mobj, receiver, method_index, 0)) + if (!QMetaObjectPrivate::disconnect(sender, signal_index, signal.mobj, receiver, method_index, nullptr)) return false; if (!signal.isValid()) { @@ -3381,7 +3381,7 @@ QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_i signal_index = methodIndexToSignalIndex(&smeta, signal_index); return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, - 0, //FIXME, we could speed this connection up by computing the relative index + nullptr, //FIXME, we could speed this connection up by computing the relative index type, types)); } @@ -3457,7 +3457,7 @@ bool QMetaObject::disconnect(const QObject *sender, int signal_index, const QMetaObject *smeta = sender->metaObject(); signal_index = methodIndexToSignalIndex(&smeta, signal_index); return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, - receiver, method_index, 0); + receiver, method_index, nullptr); } /*! @@ -3473,7 +3473,7 @@ bool QMetaObject::disconnectOne(const QObject *sender, int signal_index, const QMetaObject *smeta = sender->metaObject(); signal_index = methodIndexToSignalIndex(&smeta, signal_index); return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, - receiver, method_index, 0, + receiver, method_index, nullptr, QMetaObjectPrivate::DisconnectOne); } @@ -3682,7 +3682,7 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect argumentTypes = queuedConnectionTypes(m.parameterTypes()); if (!argumentTypes) // cannot queue arguments argumentTypes = &DIRECT_CONNECTION_ONLY; - if (!c->argumentTypes.testAndSetOrdered(0, argumentTypes)) { + if (!c->argumentTypes.testAndSetOrdered(nullptr, argumentTypes)) { if (argumentTypes != &DIRECT_CONNECTION_ONLY) delete [] argumentTypes; argumentTypes = c->argumentTypes.loadRelaxed(); @@ -4293,10 +4293,10 @@ QObjectUserData* QObject::userData(uint id) const { Q_D(const QObject); if (!d->extraData) - return 0; + return nullptr; if ((int)id < d->extraData->userData.size()) return d->extraData->userData.at(id); - return 0; + return nullptr; } #endif // QT_NO_USERDATA @@ -4952,7 +4952,7 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa if (!senderMetaObject) { qWarning("QObject::connect: signal not found in %s", sender->metaObject()->className()); slotObj->destroyIfLastRef(); - return QMetaObject::Connection(0); + return QMetaObject::Connection(nullptr); } signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject); return QObjectPrivate::connectImpl(sender, signal_index, receiver, slot, slotObj, type, types, senderMetaObject); @@ -5138,7 +5138,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject) { - if (sender == 0 || (receiver == 0 && slot != 0)) { + if (sender == nullptr || (receiver == nullptr && slot != nullptr)) { qWarning("QObject::disconnect: Unexpected null parameter"); return false; } @@ -5178,7 +5178,7 @@ QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signa const QMetaObject *senderMetaObject = sender->metaObject(); signal_index = methodIndexToSignalIndex(&senderMetaObject, signal_index); - return QObjectPrivate::connectImpl(sender, signal_index, sender, /*slot*/0, slotObj, type, /*types*/0, senderMetaObject); + return QObjectPrivate::connectImpl(sender, signal_index, sender, /*slot*/nullptr, slotObj, type, /*types*/nullptr, senderMetaObject); } /*! @@ -5235,7 +5235,7 @@ QMetaObject::Connection& QMetaObject::Connection::operator=(const QMetaObject::C Creates a Connection instance. */ -QMetaObject::Connection::Connection() : d_ptr(0) {} +QMetaObject::Connection::Connection() : d_ptr(nullptr) {} /*! Destructor for QMetaObject::Connection. diff --git a/src/corelib/kernel/qobjectcleanuphandler.cpp b/src/corelib/kernel/qobjectcleanuphandler.cpp index b6c62af4b3..8bf0e1fcab 100644 --- a/src/corelib/kernel/qobjectcleanuphandler.cpp +++ b/src/corelib/kernel/qobjectcleanuphandler.cpp @@ -94,7 +94,7 @@ QObjectCleanupHandler::~QObjectCleanupHandler() QObject *QObjectCleanupHandler::add(QObject* object) { if (!object) - return 0; + return nullptr; connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*))); cleanupObjects.insert(0, object); diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index 39f3002394..2d65e0bbe4 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -441,7 +441,7 @@ bool QSharedMemory::attach(AccessMode mode) bool QSharedMemory::isAttached() const { Q_D(const QSharedMemory); - return (0 != d->memory); + return (nullptr != d->memory); } /*! diff --git a/src/corelib/kernel/qsharedmemory_systemv.cpp b/src/corelib/kernel/qsharedmemory_systemv.cpp index fea4a65b5c..0ba5f65641 100644 --- a/src/corelib/kernel/qsharedmemory_systemv.cpp +++ b/src/corelib/kernel/qsharedmemory_systemv.cpp @@ -182,9 +182,9 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode) } // grab the memory - memory = shmat(id, 0, (mode == QSharedMemory::ReadOnly ? SHM_RDONLY : 0)); + memory = shmat(id, nullptr, (mode == QSharedMemory::ReadOnly ? SHM_RDONLY : 0)); if ((void*) - 1 == memory) { - memory = 0; + memory = nullptr; setErrorString(QLatin1String("QSharedMemory::attach (shmat)")); return false; } @@ -216,7 +216,7 @@ bool QSharedMemoryPrivate::detach() } return false; } - memory = 0; + memory = nullptr; size = 0; // Get the number of current attachments diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index f6d7e78441..bc0f3b03ca 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -68,7 +68,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() : #ifndef QT_NO_QOBJECT QObjectPrivate(), #endif - memory(0), size(0), error(QSharedMemory::NoError), + memory(nullptr), size(0), error(QSharedMemory::NoError), #ifndef QT_NO_SYSTEMSEMAPHORE systemSemaphore(QString()), lockedByMe(false), #endif diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index 7bd81ed498..8498f7f025 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -55,7 +55,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) Sleep(uint(ms)); #else struct timespec ts = { time_t(ms / 1000), (ms % 1000) * 1000 * 1000 }; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); #endif } diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 948f697dc5..f843fc4236 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -277,7 +277,7 @@ protected: }; QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObject *r, const char *member) - : QObject(QAbstractEventDispatcher::instance()), hasValidReceiver(true), slotObj(0) + : QObject(QAbstractEventDispatcher::instance()), hasValidReceiver(true), slotObj(nullptr) { timerId = startTimer(msec, timerType); connect(this, SIGNAL(timeout()), r, member); @@ -290,7 +290,7 @@ QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObj if (r && thread() != r->thread()) { // Avoid leaking the QSingleShotTimer instance in case the application exits before the timer fires connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater); - setParent(0); + setParent(nullptr); moveToThread(r->thread()); } } @@ -316,7 +316,7 @@ void QSingleShotTimer::timerEvent(QTimerEvent *) if (Q_LIKELY(!receiver.isNull() || !hasValidReceiver)) { // We allocate only the return type - we previously checked the function had // no arguments. - void *args[1] = { 0 }; + void *args[1] = { nullptr }; slotObj->call(const_cast<QObject*>(receiver.data()), args); } } else { diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 39010c19cb..b425ca3dcb 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -83,7 +83,7 @@ QTimerInfoList::QTimerInfoList() } #endif - firstTimerInfo = 0; + firstTimerInfo = nullptr; } timespec QTimerInfoList::updateCurrentTime() @@ -389,7 +389,7 @@ bool QTimerInfoList::timerWait(timespec &tm) repairTimersIfNeeded(); // Find first waiting timer not already active - QTimerInfo *t = 0; + QTimerInfo *t = nullptr; for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) { if (!(*it)->activateRef) { t = *it; @@ -450,7 +450,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time t->interval = interval; t->timerType = timerType; t->obj = object; - t->activateRef = 0; + t->activateRef = nullptr; timespec expected = updateCurrentTime() + interval; @@ -514,9 +514,9 @@ bool QTimerInfoList::unregisterTimer(int timerId) // found it removeAt(i); if (t == firstTimerInfo) - firstTimerInfo = 0; + firstTimerInfo = nullptr; if (t->activateRef) - *(t->activateRef) = 0; + *(t->activateRef) = nullptr; delete t; return true; } @@ -535,9 +535,9 @@ bool QTimerInfoList::unregisterTimers(QObject *object) // object found removeAt(i); if (t == firstTimerInfo) - firstTimerInfo = 0; + firstTimerInfo = nullptr; if (t->activateRef) - *(t->activateRef) = 0; + *(t->activateRef) = nullptr; delete t; // move back one so that we don't skip the new current item --i; @@ -571,7 +571,7 @@ int QTimerInfoList::activateTimers() return 0; // nothing to do int n_act = 0, maxCount = 0; - firstTimerInfo = 0; + firstTimerInfo = nullptr; timespec currentTime = updateCurrentTime(); // qDebug() << "Thread" << QThread::currentThreadId() << "woken up at" << currentTime; @@ -643,11 +643,11 @@ int QTimerInfoList::activateTimers() QCoreApplication::sendEvent(currentTimerInfo->obj, &e); if (currentTimerInfo) - currentTimerInfo->activateRef = 0; + currentTimerInfo->activateRef = nullptr; } } - firstTimerInfo = 0; + firstTimerInfo = nullptr; // qDebug() << "Thread" << QThread::currentThreadId() << "activated" << n_act << "timers"; return n_act; } diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index ddb96ecad6..93d75feafa 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -289,8 +289,8 @@ public: #if defined(QT_USE_MMAP) used_mmap(0), #endif - unmapPointer(0), unmapLength(0), resource(0), - messageArray(0), offsetArray(0), contextArray(0), numerusRulesArray(0), + unmapPointer(nullptr), unmapLength(0), resource(nullptr), + messageArray(nullptr), offsetArray(nullptr), contextArray(nullptr), numerusRulesArray(nullptr), messageLength(0), offsetLength(0), contextLength(0), numerusRulesLength(0) {} #if defined(QT_USE_MMAP) @@ -539,7 +539,7 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo ok = true; } else { delete resource; - resource = 0; + resource = nullptr; } } @@ -610,8 +610,8 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo delete [] unmapPointer; delete d->resource; - d->resource = 0; - d->unmapPointer = 0; + d->resource = nullptr; + d->unmapPointer = nullptr; d->unmapLength = 0; return false; @@ -874,10 +874,10 @@ bool QTranslatorPrivate::do_load(const uchar *data, qsizetype len, const QString } if (!ok) { - messageArray = 0; - contextArray = 0; - offsetArray = 0; - numerusRulesArray = 0; + messageArray = nullptr; + contextArray = nullptr; + offsetArray = nullptr; + numerusRulesArray = nullptr; messageLength = 0; contextLength = 0; offsetLength = 0; @@ -890,7 +890,7 @@ bool QTranslatorPrivate::do_load(const uchar *data, qsizetype len, const QString static QString getMessage(const uchar *m, const uchar *end, const char *context, const char *sourceText, const char *comment, uint numerus) { - const uchar *tn = 0; + const uchar *tn = nullptr; uint tn_length = 0; const uint sourceTextLen = uint(strlen(sourceText)); const uint contextLen = uint(strlen(context)); @@ -957,11 +957,11 @@ end: QString QTranslatorPrivate::do_translate(const char *context, const char *sourceText, const char *comment, int n) const { - if (context == 0) + if (context == nullptr) context = ""; - if (sourceText == 0) + if (sourceText == nullptr) sourceText = ""; - if (comment == 0) + if (comment == nullptr) comment = ""; uint numerus = 0; @@ -1076,13 +1076,13 @@ void QTranslatorPrivate::clear() } delete resource; - resource = 0; - unmapPointer = 0; + resource = nullptr; + unmapPointer = nullptr; unmapLength = 0; - messageArray = 0; - contextArray = 0; - offsetArray = 0; - numerusRulesArray = 0; + messageArray = nullptr; + contextArray = nullptr; + offsetArray = nullptr; + numerusRulesArray = nullptr; messageLength = 0; contextLength = 0; offsetLength = 0; diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index d1eb463514..455dd5069f 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2523,7 +2523,7 @@ void QVariant::load(QDataStream &s) return; } } - create(typeId, 0); + create(typeId, nullptr); d.is_null = is_null; if (!isValid()) { diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 24a7a35ea5..1fbcc31fae 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -487,7 +487,7 @@ QMimeDatabase::QMimeDatabase() : */ QMimeDatabase::~QMimeDatabase() { - d = 0; + d = nullptr; } /*! diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index a3a6b9615c..c61759025c 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -130,7 +130,7 @@ bool QMimeBinaryProvider::CacheFile::reload() if (file.isOpen()) { file.close(); } - data = 0; + data = nullptr; return load(); } @@ -306,7 +306,7 @@ bool QMimeBinaryProvider::matchMagicRule(QMimeBinaryProvider::CacheFile *cacheFi const int valueLength = cacheFile->getUint32(off + 12); const int valueOffset = cacheFile->getUint32(off + 16); const int maskOffset = cacheFile->getUint32(off + 20); - const char *mask = maskOffset ? cacheFile->getCharStar(maskOffset) : NULL; + const char *mask = maskOffset ? cacheFile->getCharStar(maskOffset) : nullptr; if (!QMimeMagicRule::matchSubstring(dataPtr, dataSize, rangeStart, rangeLength, valueLength, cacheFile->getCharStar(valueOffset), mask)) continue; diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 18f10c9b43..14de8db1c6 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -212,7 +212,7 @@ void QFactoryLoader::update() QStringList(QLatin1String("libplugins_%1_*.so").arg(d->suffix)), #endif QDir::Files); - QLibraryPrivate *library = 0; + QLibraryPrivate *library = nullptr; for (int j = 0; j < plugins.count(); ++j) { QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j)); @@ -383,7 +383,7 @@ QObject *QFactoryLoader::instance(int index) const { Q_D(const QFactoryLoader); if (index < 0) - return 0; + return nullptr; #if QT_CONFIG(library) QMutexLocker lock(&d->mutex); @@ -399,7 +399,7 @@ QObject *QFactoryLoader::instance(int index) const return obj; } } - return 0; + return nullptr; } index -= d->libraryList.size(); lock.unlock(); @@ -416,7 +416,7 @@ QObject *QFactoryLoader::instance(int index) const --index; } - return 0; + return nullptr; } QMultiMap<int, QString> QFactoryLoader::keyMap() const diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index eeaa3c18ec..b3a95d4f26 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -256,7 +256,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib) qsizetype fdlen = qMin(file.size(), MaxMemoryMapSize); const char *filedata = reinterpret_cast<char *>(file.map(0, fdlen)); - if (filedata == 0) { + if (filedata == nullptr) { // Try reading the data into memory instead (up to 64 MB). data = file.read(64 * 1024 * 1024); filedata = data.constData(); @@ -387,12 +387,12 @@ private: }; static QBasicMutex qt_library_mutex; -static QLibraryStore *qt_library_data = 0; +static QLibraryStore *qt_library_data = nullptr; static bool qt_library_data_once; QLibraryStore::~QLibraryStore() { - qt_library_data = 0; + qt_library_data = nullptr; } inline void QLibraryStore::cleanup() @@ -459,7 +459,7 @@ inline QLibraryPrivate *QLibraryStore::findOrCreate(const QString &fileName, con QLibraryStore *data = instance(); // check if this library is already loaded - QLibraryPrivate *lib = 0; + QLibraryPrivate *lib = nullptr; if (Q_LIKELY(data)) { lib = data->libraryMap.value(fileName); if (lib) @@ -498,7 +498,7 @@ inline void QLibraryStore::releaseLibrary(QLibraryPrivate *lib) } QLibraryPrivate::QLibraryPrivate(const QString &canonicalFileName, const QString &version, QLibrary::LoadHints loadHints) - : pHnd(0), fileName(canonicalFileName), fullVersion(version), instance(0), + : pHnd(nullptr), fileName(canonicalFileName), fullVersion(version), instance(nullptr), libraryRefCount(0), libraryUnloadCount(0), pluginState(MightBeAPlugin) { loadHintsInt.storeRelaxed(loadHints); @@ -528,7 +528,7 @@ void QLibraryPrivate::mergeLoadHints(QLibrary::LoadHints lh) QFunctionPointer QLibraryPrivate::resolve(const char *symbol) { if (!pHnd) - return 0; + return nullptr; return resolve_sys(symbol); } @@ -584,12 +584,12 @@ bool QLibraryPrivate::unload(UnloadFlag flag) //when the library is unloaded, we release the reference on it so that 'this' //can get deleted libraryRefCount.deref(); - pHnd = 0; - instance = 0; + pHnd = nullptr; + instance = nullptr; } } - return (pHnd == 0); + return (pHnd == nullptr); } void QLibraryPrivate::release() @@ -847,7 +847,7 @@ bool QLibrary::isLoaded() const Constructs a library with the given \a parent. */ QLibrary::QLibrary(QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { } @@ -862,7 +862,7 @@ QLibrary::QLibrary(QObject *parent) ".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.) */ QLibrary::QLibrary(const QString& fileName, QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { setFileName(fileName); } @@ -879,7 +879,7 @@ QLibrary::QLibrary(const QString& fileName, QObject *parent) ".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.) */ QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { setFileNameAndVersion(fileName, verNum); } @@ -895,7 +895,7 @@ QLibrary::QLibrary(const QString& fileName, int verNum, QObject *parent) ".dylib" on \macos and iOS, and ".dll" on Windows. (See \l{fileName}.) */ QLibrary::QLibrary(const QString& fileName, const QString &version, QObject *parent) - :QObject(parent), d(0), did_load(false) + :QObject(parent), d(nullptr), did_load(false) { setFileNameAndVersion(fileName, version); } @@ -942,7 +942,7 @@ void QLibrary::setFileName(const QString &fileName) if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } d = QLibraryPrivate::findOrCreate(fileName, QString(), lh); @@ -970,7 +970,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, int verNum) if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } d = QLibraryPrivate::findOrCreate(fileName, verNum >= 0 ? QString::number(verNum) : QString(), lh); @@ -991,7 +991,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } d = QLibraryPrivate::findOrCreate(fileName, version, lh); @@ -1020,7 +1020,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver QFunctionPointer QLibrary::resolve(const char *symbol) { if (!isLoaded() && !load()) - return 0; + return nullptr; return d->resolve(symbol); } diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index f0de1010d7..6eb84b327b 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -277,7 +277,7 @@ bool QLibraryPrivate::load_sys() qualifiedFileName = attempt; errorString.clear(); } - return (pHnd != 0); + return (pHnd != nullptr); } bool QLibraryPrivate::unload_sys() diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index c2443dbdda..aed1704d5f 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -136,7 +136,7 @@ QT_BEGIN_NAMESPACE Constructs a plugin loader with the given \a parent. */ QPluginLoader::QPluginLoader(QObject *parent) - : QObject(parent), d(0), did_load(false) + : QObject(parent), d(nullptr), did_load(false) { } @@ -152,7 +152,7 @@ QPluginLoader::QPluginLoader(QObject *parent) \sa setFileName() */ QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent) - : QObject(parent), d(0), did_load(false) + : QObject(parent), d(nullptr), did_load(false) { setFileName(fileName); setLoadHints(QLibrary::PreventUnloadHint); @@ -195,7 +195,7 @@ QPluginLoader::~QPluginLoader() QObject *QPluginLoader::instance() { if (!isLoaded() && !load()) - return 0; + return nullptr; if (!d->inst && d->instance) d->inst = d->instance(); return d->inst.data(); @@ -363,7 +363,7 @@ void QPluginLoader::setFileName(const QString &fileName) if (d) { lh = d->loadHints(); d->release(); - d = 0; + d = nullptr; did_load = false; } diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp index 0db44bc427..10f54c3e18 100644 --- a/src/corelib/statemachine/qabstractstate.cpp +++ b/src/corelib/statemachine/qabstractstate.cpp @@ -84,19 +84,19 @@ QT_BEGIN_NAMESPACE QAbstractStatePrivate::QAbstractStatePrivate(StateType type) - : stateType(type), isMachine(false), active(false), parentState(0) + : stateType(type), isMachine(false), active(false), parentState(nullptr) { } QStateMachine *QAbstractStatePrivate::machine() const { QObject *par = parent; - while (par != 0) { + while (par != nullptr) { if (QStateMachine *mach = qobject_cast<QStateMachine*>(par)) return mach; par = par->parent(); } - return 0; + return nullptr; } void QAbstractStatePrivate::callOnEntry(QEvent *e) diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp index d841fd3c8b..df70b54721 100644 --- a/src/corelib/statemachine/qabstracttransition.cpp +++ b/src/corelib/statemachine/qabstracttransition.cpp @@ -144,7 +144,7 @@ QStateMachine *QAbstractTransitionPrivate::machine() const Q_Q(const QAbstractTransition); if (QHistoryState *parent = qobject_cast<QHistoryState *>(q->parent())) return parent->machine(); - return 0; + return nullptr; } bool QAbstractTransitionPrivate::callEventTest(QEvent *e) @@ -223,7 +223,7 @@ void QAbstractTransition::setTargetState(QAbstractState* target) { Q_D(QAbstractTransition); if ((d->targetStates.size() == 1 && target == d->targetStates.at(0).data()) || - (d->targetStates.isEmpty() && target == 0)) { + (d->targetStates.isEmpty() && target == nullptr)) { return; } if (!target) diff --git a/src/corelib/statemachine/qeventtransition.cpp b/src/corelib/statemachine/qeventtransition.cpp index a90f147773..5dcbcfff47 100644 --- a/src/corelib/statemachine/qeventtransition.cpp +++ b/src/corelib/statemachine/qeventtransition.cpp @@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE */ QEventTransitionPrivate::QEventTransitionPrivate() { - object = 0; + object = nullptr; eventType = QEvent::None; registered = false; } diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp index ccf04d4799..e5b8075b96 100644 --- a/src/corelib/statemachine/qhistorystate.cpp +++ b/src/corelib/statemachine/qhistorystate.cpp @@ -147,7 +147,7 @@ protected: QHistoryStatePrivate::QHistoryStatePrivate() : QAbstractStatePrivate(HistoryState) - , defaultTransition(0) + , defaultTransition(nullptr) , historyType(QHistoryState::ShallowHistory) { } diff --git a/src/corelib/statemachine/qsignaltransition.cpp b/src/corelib/statemachine/qsignaltransition.cpp index 59e0c0d788..8e57695fd7 100644 --- a/src/corelib/statemachine/qsignaltransition.cpp +++ b/src/corelib/statemachine/qsignaltransition.cpp @@ -107,7 +107,7 @@ QT_BEGIN_NAMESPACE QSignalTransitionPrivate::QSignalTransitionPrivate() { - sender = 0; + sender = nullptr; signalIndex = -1; } diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 62dd4f0284..f641d25a96 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -146,7 +146,7 @@ QT_BEGIN_NAMESPACE QStatePrivate::QStatePrivate() : QAbstractStatePrivate(StandardState), - errorState(0), initialState(0), childMode(QState::ExclusiveStates), + errorState(nullptr), initialState(nullptr), childMode(QState::ExclusiveStates), childStatesListNeedsRefresh(true), transitionsListNeedsRefresh(true) { } @@ -293,11 +293,11 @@ QAbstractState *QState::errorState() const void QState::setErrorState(QAbstractState *state) { Q_D(QState); - if (state != 0 && qobject_cast<QStateMachine*>(state)) { + if (state != nullptr && qobject_cast<QStateMachine*>(state)) { qWarning("QStateMachine::setErrorState: root state cannot be error state"); return; } - if (state != 0 && (!state->machine() || ((state->machine() != machine()) && !qobject_cast<QStateMachine*>(this)))) { + if (state != nullptr && (!state->machine() || ((state->machine() != machine()) && !qobject_cast<QStateMachine*>(this)))) { qWarning("QState::setErrorState: error state cannot belong " "to a different state machine"); return; @@ -360,15 +360,15 @@ QSignalTransition *QState::addTransition(const QObject *sender, const char *sign { if (!sender) { qWarning("QState::addTransition: sender cannot be null"); - return 0; + return nullptr; } if (!signal) { qWarning("QState::addTransition: signal cannot be null"); - return 0; + return nullptr; } if (!target) { qWarning("QState::addTransition: cannot add transition to null state"); - return 0; + return nullptr; } int offset = (*signal == '0'+QSIGNAL_CODE) ? 1 : 0; const QMetaObject *meta = sender->metaObject(); @@ -376,7 +376,7 @@ QSignalTransition *QState::addTransition(const QObject *sender, const char *sign if (meta->indexOfSignal(QMetaObject::normalizedSignature(signal+offset)) == -1) { qWarning("QState::addTransition: no such signal %s::%s", meta->className(), signal+offset); - return 0; + return nullptr; } } QSignalTransition *trans = new QSignalTransition(sender, signal); @@ -409,7 +409,7 @@ QAbstractTransition *QState::addTransition(QAbstractState *target) { if (!target) { qWarning("QState::addTransition: cannot add transition to null state"); - return 0; + return nullptr; } UnconditionalTransition *trans = new UnconditionalTransition(target); addTransition(trans); @@ -438,7 +438,7 @@ void QState::removeTransition(QAbstractTransition *transition) QStateMachinePrivate *mach = QStateMachinePrivate::get(d->machine()); if (mach) mach->unregisterTransition(transition); - transition->setParent(0); + transition->setParent(nullptr); } /*! @@ -544,7 +544,7 @@ bool QState::event(QEvent *e) d->childStatesListNeedsRefresh = true; d->transitionsListNeedsRefresh = true; if ((e->type() == QEvent::ChildRemoved) && (static_cast<QChildEvent *>(e)->child() == d->initialState)) - d->initialState = 0; + d->initialState = nullptr; } return QAbstractState::event(e); } diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 44e4e151cb..9d2505ba2e 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -197,7 +197,7 @@ struct CalculationCache { bool transitionDomainIsKnown : 1; TransitionInfo() - : transitionDomain(0) + : transitionDomain(nullptr) , effectiveTargetStatesIsKnown(false) , exitSetIsKnown(false) , transitionDomainIsKnown(false) @@ -289,9 +289,9 @@ child of a child, etc.) Otherwise returns 'false'. */ static inline bool isDescendant(const QAbstractState *state1, const QAbstractState *state2) { - Q_ASSERT(state1 != 0); + Q_ASSERT(state1 != nullptr); - for (QAbstractState *it = state1->parentState(); it != 0; it = it->parentState()) { + for (QAbstractState *it = state1->parentState(); it != nullptr; it = it->parentState()) { if (it == state2) return true; } @@ -311,7 +311,7 @@ static bool containsDecendantOf(const QSet<QAbstractState *> &states, const QAbs static int descendantDepth(const QAbstractState *state, const QAbstractState *ancestor) { int depth = 0; - for (const QAbstractState *it = state; it != 0; it = it->parentState()) { + for (const QAbstractState *it = state; it != nullptr; it = it->parentState()) { if (it == ancestor) break; ++depth; @@ -332,7 +332,7 @@ this returns the empty set. */ static QVector<QState*> getProperAncestors(const QAbstractState *state, const QAbstractState *upperBound) { - Q_ASSERT(state != 0); + Q_ASSERT(state != nullptr); QVector<QState*> result; result.reserve(16); for (QState *it = state->parentState(); it && it != upperBound; it = it->parentState()) { @@ -405,7 +405,7 @@ QStateMachinePrivate::QStateMachinePrivate() stopProcessingReason = EventQueueEmpty; error = QStateMachine::NoError; globalRestorePolicy = QState::DontRestoreProperties; - signalEventGenerator = 0; + signalEventGenerator = nullptr; #if QT_CONFIG(animation) animated = true; #endif @@ -437,7 +437,7 @@ static QEvent *cloneEvent(QEvent *e) Q_ASSERT_X(false, "cloneEvent()", "not implemented"); break; } - return 0; + return nullptr; } const QStateMachinePrivate::Handler qt_kernel_statemachine_handler = { @@ -474,10 +474,10 @@ bool QStateMachinePrivate::transitionStateEntryLessThan(QAbstractTransition *t1, } else if (isDescendant(s2, s1)) { return false; } else { - Q_ASSERT(s1->machine() != 0); + Q_ASSERT(s1->machine() != nullptr); QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); - Q_ASSERT(lca != 0); + Q_ASSERT(lca != nullptr); int s1Depth = descendantDepth(s1, lca); int s2Depth = descendantDepth(s2, lca); if (s1Depth == s2Depth) @@ -497,10 +497,10 @@ bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState } else if (isDescendant(s2, s1)) { return true; } else { - Q_ASSERT(s1->machine() != 0); + Q_ASSERT(s1->machine() != nullptr); QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); - Q_ASSERT(lca != 0); + Q_ASSERT(lca != nullptr); return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2)); } } @@ -515,10 +515,10 @@ bool QStateMachinePrivate::stateExitLessThan(QAbstractState *s1, QAbstractState } else if (isDescendant(s2, s1)) { return false; } else { - Q_ASSERT(s1->machine() != 0); + Q_ASSERT(s1->machine() != nullptr); QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine()); QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2); - Q_ASSERT(lca != 0); + Q_ASSERT(lca != nullptr); return (indexOfDescendant(lca, s2) < indexOfDescendant(lca, s1)); } } @@ -526,7 +526,7 @@ bool QStateMachinePrivate::stateExitLessThan(QAbstractState *s1, QAbstractState QState *QStateMachinePrivate::findLCA(const QList<QAbstractState*> &states, bool onlyCompound) { if (states.isEmpty()) - return 0; + return nullptr; QVector<QState*> ancestors = getProperAncestors(states.at(0), rootState()->parentState()); for (int i = 0; i < ancestors.size(); ++i) { QState *anc = ancestors.at(i); @@ -792,7 +792,7 @@ QSet<QAbstractState*> QStateMachinePrivate::computeExitSet_Unordered(QAbstractTr lst.prepend(t->sourceState()); domain = findLCCA(lst); - Q_ASSERT(domain != 0); + Q_ASSERT(domain != nullptr); } for (QAbstractState* s : qAsConst(configuration)) { @@ -918,7 +918,7 @@ QAbstractState *QStateMachinePrivate::getTransitionDomain(QAbstractTransition *t Q_ASSERT(cache); if (effectiveTargetStates.isEmpty()) - return 0; + return nullptr; QAbstractState *domain = nullptr; if (cache->transitionDomain(t, &domain)) @@ -1234,28 +1234,28 @@ QState *QStateMachinePrivate::toStandardState(QAbstractState *state) { if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) return static_cast<QState*>(state); - return 0; + return nullptr; } const QState *QStateMachinePrivate::toStandardState(const QAbstractState *state) { if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState)) return static_cast<const QState*>(state); - return 0; + return nullptr; } QFinalState *QStateMachinePrivate::toFinalState(QAbstractState *state) { if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::FinalState)) return static_cast<QFinalState*>(state); - return 0; + return nullptr; } QHistoryState *QStateMachinePrivate::toHistoryState(QAbstractState *state) { if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::HistoryState)) return static_cast<QHistoryState*>(state); - return 0; + return nullptr; } bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const @@ -1455,13 +1455,13 @@ QHash<QAbstractState*, QVector<QPropertyAssignment> > QStateMachinePrivate::comp QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context) { // Find error state recursively in parent hierarchy if not set explicitly for context state - QAbstractState *errorState = 0; - if (context != 0) { + QAbstractState *errorState = nullptr; + if (context != nullptr) { QState *s = toStandardState(context); - if (s != 0) + if (s != nullptr) errorState = s->errorState(); - if (errorState == 0) + if (errorState == nullptr) errorState = findErrorState(context->parentState()); } @@ -1475,21 +1475,21 @@ void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractSta error = errorCode; switch (errorCode) { case QStateMachine::NoInitialStateError: - Q_ASSERT(currentContext != 0); + Q_ASSERT(currentContext != nullptr); errorString = QStateMachine::tr("Missing initial state in compound state '%1'") .arg(currentContext->objectName()); break; case QStateMachine::NoDefaultStateInHistoryStateError: - Q_ASSERT(currentContext != 0); + Q_ASSERT(currentContext != nullptr); errorString = QStateMachine::tr("Missing default state in history state '%1'") .arg(currentContext->objectName()); break; case QStateMachine::NoCommonAncestorForTransitionError: - Q_ASSERT(currentContext != 0); + Q_ASSERT(currentContext != nullptr); errorString = QStateMachine::tr("No common ancestor for targets and source of transition from state '%1'") .arg(currentContext->objectName()); @@ -1513,11 +1513,11 @@ void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractSta // Avoid infinite loop if the error state itself has an error if (currentContext == currentErrorState) - currentErrorState = 0; + currentErrorState = nullptr; Q_ASSERT(currentErrorState != rootState()); - if (currentErrorState != 0) { + if (currentErrorState != nullptr) { #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": entering error state" << currentErrorState << "from" << currentContext; #endif @@ -1549,7 +1549,7 @@ QStateMachinePrivate::initializeAnimation(QAbstractAnimation *abstractAnimation, } } else { QPropertyAnimation *animation = qobject_cast<QPropertyAnimation *>(abstractAnimation); - if (animation != 0 + if (animation != nullptr && prop.object == animation->targetObject() && prop.propertyName == animation->propertyName()) { @@ -1568,7 +1568,7 @@ void QStateMachinePrivate::_q_animationFinished() { Q_Q(QStateMachine); QAbstractAnimation *anim = qobject_cast<QAbstractAnimation*>(q->sender()); - Q_ASSERT(anim != 0); + Q_ASSERT(anim != nullptr); QObject::disconnect(anim, SIGNAL(finished()), q, SLOT(_q_animationFinished())); if (resetAnimationEndValues.contains(anim)) { qobject_cast<QVariantAnimation*>(anim)->setEndValue(QVariant()); // ### generalize @@ -1576,7 +1576,7 @@ void QStateMachinePrivate::_q_animationFinished() } QAbstractState *state = stateForAnimation.take(anim); - Q_ASSERT(state != 0); + Q_ASSERT(state != nullptr); #ifndef QT_NO_PROPERTIES // Set the final property value. @@ -1638,7 +1638,7 @@ void QStateMachinePrivate::terminateActiveAnimations(QAbstractState *state, resetAnimationEndValues.remove(anim); } QPropertyAssignment assn = propertyForAnimation.take(anim); - Q_ASSERT(assn.object != 0); + Q_ASSERT(assn.object != nullptr); // If there is no property assignment that sets this property, // set the property to its target value. bool found = false; @@ -1745,7 +1745,7 @@ QAbstractTransition *QStateMachinePrivate::createInitialTransition() const }; QState *root = rootState(); - Q_ASSERT(root != 0); + Q_ASSERT(root != nullptr); QList<QAbstractState *> targets; switch (root->childMode()) { case QState::ExclusiveStates: @@ -1891,26 +1891,26 @@ void QStateMachinePrivate::_q_process() enabledTransitions = selectTransitions(e, &calculationCache); if (enabledTransitions.isEmpty()) { delete e; - e = 0; + e = nullptr; } - while (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) { + while (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != nullptr)) { #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": dequeued internal event" << e << "of type" << e->type(); #endif enabledTransitions = selectTransitions(e, &calculationCache); if (enabledTransitions.isEmpty()) { delete e; - e = 0; + e = nullptr; } } - while (enabledTransitions.isEmpty() && ((e = dequeueExternalEvent()) != 0)) { + while (enabledTransitions.isEmpty() && ((e = dequeueExternalEvent()) != nullptr)) { #ifdef QSTATEMACHINE_DEBUG qDebug() << q << ": dequeued external event" << e << "of type" << e->type(); #endif enabledTransitions = selectTransitions(e, &calculationCache); if (enabledTransitions.isEmpty()) { delete e; - e = 0; + e = nullptr; } } if (enabledTransitions.isEmpty()) { @@ -2009,7 +2009,7 @@ QEvent *QStateMachinePrivate::dequeueInternalEvent() { QMutexLocker locker(&internalEventMutex); if (internalEventQueue.isEmpty()) - return 0; + return nullptr; return internalEventQueue.takeFirst(); } @@ -2017,7 +2017,7 @@ QEvent *QStateMachinePrivate::dequeueExternalEvent() { QMutexLocker locker(&externalEventMutex); if (externalEventQueue.isEmpty()) - return 0; + return nullptr; return externalEventQueue.takeFirst(); } @@ -2175,15 +2175,15 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState) return; Q_ASSERT(state == Running); - QState *sourceState = 0; + QState *sourceState = nullptr; QSet<QAbstractState*>::const_iterator it; for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) { sourceState = toStandardState(*it); - if (sourceState != 0) + if (sourceState != nullptr) break; } - Q_ASSERT(sourceState != 0); + Q_ASSERT(sourceState != nullptr); // Reuse previous GoToStateTransition in case of several calls to // goToState() in a row. GoToStateTransition *trans = sourceState->findChild<GoToStateTransition*>(); @@ -2327,7 +2327,7 @@ void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transit Q_ASSERT(connectedSignalIndexes.size() > signalIndex); Q_ASSERT(connectedSignalIndexes.at(signalIndex) != 0); if (--connectedSignalIndexes[signalIndex] == 0) { - Q_ASSERT(signalEventGenerator != 0); + Q_ASSERT(signalEventGenerator != nullptr); static const int generatorMethodOffset = QSignalEventGenerator::staticMetaObject.methodOffset(); QMetaObject::disconnect(sender, signalIndex, signalEventGenerator, generatorMethodOffset); int sum = 0; @@ -2454,7 +2454,7 @@ void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalInd Constructs a new state machine with the given \a parent. */ QStateMachine::QStateMachine(QObject *parent) - : QState(*new QStateMachinePrivate, /*parentState=*/0) + : QState(*new QStateMachinePrivate, /*parentState=*/nullptr) { // Can't pass the parent to the QState constructor, as it expects a QState // But this works as expected regardless of whether parent is a QState or not @@ -2472,7 +2472,7 @@ QStateMachine::QStateMachine(QObject *parent) state machine is invalid, and might work incorrectly. */ QStateMachine::QStateMachine(QState::ChildMode childMode, QObject *parent) - : QState(*new QStateMachinePrivate, /*parentState=*/0) + : QState(*new QStateMachinePrivate, /*parentState=*/nullptr) { Q_D(QStateMachine); d->childMode = childMode; @@ -2495,7 +2495,7 @@ QStateMachine::QStateMachine(QState::ChildMode childMode, QObject *parent) \internal */ QStateMachine::QStateMachine(QStateMachinePrivate &dd, QObject *parent) - : QState(dd, /*parentState=*/0) + : QState(dd, /*parentState=*/nullptr) { setParent(parent); } @@ -2637,7 +2637,7 @@ void QStateMachine::removeState(QAbstractState *state) state, QAbstractStatePrivate::get(state)->machine(), this); return; } - state->setParent(0); + state->setParent(nullptr); } bool QStateMachine::isRunning() const @@ -2661,7 +2661,7 @@ void QStateMachine::start() { Q_D(QStateMachine); - if ((childMode() == QState::ExclusiveStates) && (initialState() == 0)) { + if ((childMode() == QState::ExclusiveStates) && (initialState() == nullptr)) { qWarning("QStateMachine::start: No initial state set for machine. Refusing to start."); return; } @@ -2897,7 +2897,7 @@ bool QStateMachine::event(QEvent *e) d->delayedEventsMutex.lock(); int id = d->timerIdToDelayedEventId.take(tid); QStateMachinePrivate::DelayedEvent ee = d->delayedEvents.take(id); - if (ee.event != 0) { + if (ee.event != nullptr) { Q_ASSERT(ee.timerId == tid); killTimer(tid); d->delayedEventIdFreeList.release(id); @@ -3103,7 +3103,7 @@ void QSignalEventGenerator::qt_static_metacall(QObject *_o, QMetaObject::Call _c const QMetaObject QSignalEventGenerator::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_QSignalEventGenerator.data, - qt_meta_data_QSignalEventGenerator, qt_static_metacall, 0, 0 } + qt_meta_data_QSignalEventGenerator, qt_static_metacall, nullptr, nullptr } }; const QMetaObject *QSignalEventGenerator::metaObject() const @@ -3113,7 +3113,7 @@ const QMetaObject *QSignalEventGenerator::metaObject() const void *QSignalEventGenerator::qt_metacast(const char *_clname) { - if (!_clname) return 0; + if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_QSignalEventGenerator.stringdata)) return static_cast<void*>(const_cast< QSignalEventGenerator*>(this)); return QObject::qt_metacast(_clname); diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 75a5bc802e..694d491273 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_SYSTEMLOCALE -static QSystemLocale *_systemLocale = 0; +static QSystemLocale *_systemLocale = nullptr; class QSystemLocaleSingleton: public QSystemLocale { public: @@ -695,7 +695,7 @@ QSystemLocale::QSystemLocale(bool) QSystemLocale::~QSystemLocale() { if (_systemLocale == this) { - _systemLocale = 0; + _systemLocale = nullptr; globalLocaleData.m_language_id = 0; } @@ -2429,7 +2429,7 @@ QTime QLocale::toTime(const QString &string, const QString &format, QCalendar ca QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, cal); dt.setDefaultLocale(*this); if (dt.parseFormat(format)) - dt.fromString(string, 0, &time); + dt.fromString(string, nullptr, &time); #else Q_UNUSED(cal); Q_UNUSED(string); @@ -2468,7 +2468,7 @@ QDate QLocale::toDate(const QString &string, const QString &format, QCalendar ca QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal); dt.setDefaultLocale(*this); if (dt.parseFormat(format)) - dt.fromString(string, &date, 0); + dt.fromString(string, &date, nullptr); #else Q_UNUSED(string); Q_UNUSED(format); diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index c246028b4d..0da769d694 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -322,7 +322,7 @@ double qt_asciiToDouble(const char *num, int numLen, bool &ok, int &processed, conv_flags = double_conversion::StringToDoubleConverter::ALLOW_LEADING_SPACES | double_conversion::StringToDoubleConverter::ALLOW_TRAILING_SPACES; } - double_conversion::StringToDoubleConverter conv(conv_flags, 0.0, qt_qnan(), 0, 0); + double_conversion::StringToDoubleConverter conv(conv_flags, 0.0, qt_qnan(), nullptr, nullptr); d = conv.StringToDouble(num, numLen, &processed); if (!qIsFinite(d)) { diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index d0bdc0d45c..e05bef450b 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -831,7 +831,7 @@ struct QRegularExpressionPrivate : QSharedData QRegularExpression::MatchType matchType, QRegularExpression::MatchOptions matchOptions, CheckSubjectStringOption checkSubjectStringOption = CheckSubjectString, - const QRegularExpressionMatchPrivate *previous = 0) const; + const QRegularExpressionMatchPrivate *previous = nullptr) const; int captureIndexForName(QStringView name) const; @@ -990,7 +990,7 @@ void QRegularExpressionPrivate::compilePattern() options, &errorCode, &patternErrorOffset, - NULL); + nullptr); if (!compiledPattern) { errorOffset = static_cast<int>(patternErrorOffset); @@ -1049,7 +1049,7 @@ public: { // The default JIT stack size in PCRE is 32K, // we allocate from 32K up to 512K. - stack = pcre2_jit_stack_create_16(32 * 1024, 512 * 1024, NULL); + stack = pcre2_jit_stack_create_16(32 * 1024, 512 * 1024, nullptr); } /*! \internal @@ -1073,7 +1073,7 @@ static pcre2_jit_stack_16 *qtPcreCallback(void *) if (jitStacks()->hasLocalData()) return jitStacks()->localData()->stack; - return 0; + return nullptr; } /*! @@ -1240,9 +1240,9 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString previousMatchWasEmpty = true; } - pcre2_match_context_16 *matchContext = pcre2_match_context_create_16(NULL); - pcre2_jit_stack_assign_16(matchContext, &qtPcreCallback, NULL); - pcre2_match_data_16 *matchData = pcre2_match_data_create_from_pattern_16(compiledPattern, NULL); + pcre2_match_context_16 *matchContext = pcre2_match_context_create_16(nullptr); + pcre2_jit_stack_assign_16(matchContext, &qtPcreCallback, nullptr); + pcre2_match_data_16 *matchData = pcre2_match_data_create_from_pattern_16(compiledPattern, nullptr); const unsigned short * const subjectUtf16 = subject.utf16() + subjectStart; diff --git a/src/corelib/text/qtextboundaryfinder.cpp b/src/corelib/text/qtextboundaryfinder.cpp index 070b041220..ebdba6b2c5 100644 --- a/src/corelib/text/qtextboundaryfinder.cpp +++ b/src/corelib/text/qtextboundaryfinder.cpp @@ -161,10 +161,10 @@ static void init(QTextBoundaryFinder::BoundaryType type, const QChar *chars, int */ QTextBoundaryFinder::QTextBoundaryFinder() : t(Grapheme) - , chars(0) + , chars(nullptr) , length(0) , freePrivate(true) - , d(0) + , d(nullptr) { } @@ -178,7 +178,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other) , length(other.length) , pos(other.pos) , freePrivate(true) - , d(0) + , d(nullptr) { if (other.d) { Q_ASSERT(length > 0); @@ -199,7 +199,7 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o if (other.d) { Q_ASSERT(other.length > 0); uint newCapacity = (other.length + 1) * sizeof(QCharAttributes); - QTextBoundaryFinderPrivate *newD = (QTextBoundaryFinderPrivate *) realloc(freePrivate ? d : 0, newCapacity); + QTextBoundaryFinderPrivate *newD = (QTextBoundaryFinderPrivate *) realloc(freePrivate ? d : nullptr, newCapacity); Q_CHECK_PTR(newD); freePrivate = true; d = newD; @@ -216,7 +216,7 @@ QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &o } else { if (freePrivate) free(d); - d = 0; + d = nullptr; } return *this; @@ -242,7 +242,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QString &strin , length(string.length()) , pos(0) , freePrivate(true) - , d(0) + , d(nullptr) { if (length > 0) { d = (QTextBoundaryFinderPrivate *) malloc((length + 1) * sizeof(QCharAttributes)); @@ -271,7 +271,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QChar *chars, , length(length) , pos(0) , freePrivate(true) - , d(0) + , d(nullptr) { if (!chars) { length = 0; diff --git a/src/corelib/thread/qexception.cpp b/src/corelib/thread/qexception.cpp index a3e30d5a7a..f9c63085b7 100644 --- a/src/corelib/thread/qexception.cpp +++ b/src/corelib/thread/qexception.cpp @@ -199,7 +199,7 @@ void ExceptionStore::setException(const QException &e) bool ExceptionStore::hasException() const { - return (exceptionHolder.exception() != 0); + return (exceptionHolder.exception() != nullptr); } ExceptionHolder ExceptionStore::exception() diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 6430f38a3b..f1fd40e7b6 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -471,7 +471,7 @@ bool QFutureInterfaceBase::derefT() const QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState) : refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0), state(initialState), - manualProgress(false), m_expectedResultCount(0), runnable(0), m_pool(0) + manualProgress(false), m_expectedResultCount(0), runnable(nullptr), m_pool(nullptr) { progressTime.invalidate(); } diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 9e52f286ee..f3883278e3 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -70,7 +70,7 @@ class QRecursiveMutexPrivate : public QMutexData { public: QRecursiveMutexPrivate() - : QMutexData(QMutex::Recursive), owner(0), count(0) {} + : QMutexData(QMutex::Recursive), owner(nullptr), count(0) {} // written to by the thread that first owns 'mutex'; // read during attempts to acquire ownership of 'mutex' from any other thread: @@ -186,7 +186,7 @@ public: */ QMutex::QMutex(RecursionMode mode) { - d_ptr.storeRelaxed(mode == Recursive ? new QRecursiveMutexPrivate : 0); + d_ptr.storeRelaxed(mode == Recursive ? new QRecursiveMutexPrivate : nullptr); } /*! @@ -799,7 +799,7 @@ inline void QRecursiveMutexPrivate::unlock() noexcept if (count > 0) { count--; } else { - owner.storeRelaxed(0); + owner.storeRelaxed(nullptr); mutex.QBasicMutex::unlock(); } } diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 3270875471..72002838cf 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -106,7 +106,7 @@ static inline QMutexData *dummyFutexValue() } template <bool IsTimed> static inline -bool lockInternal_helper(QBasicAtomicPointer<QMutexData> &d_ptr, int timeout = -1, QElapsedTimer *elapsedTimer = 0) noexcept +bool lockInternal_helper(QBasicAtomicPointer<QMutexData> &d_ptr, int timeout = -1, QElapsedTimer *elapsedTimer = nullptr) noexcept { if (!IsTimed) timeout = -1; @@ -175,7 +175,7 @@ void QBasicMutex::unlockInternal() noexcept Q_UNUSED(d); Q_ASSERT(!isRecursive()); - d_ptr.storeRelease(0); + d_ptr.storeRelease(nullptr); futexWakeOne(d_ptr); } diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index 570c526225..83edfd5879 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -69,7 +69,7 @@ class QOrderedMutexLocker public: QOrderedMutexLocker(QBasicMutex *m1, QBasicMutex *m2) : mtx1((m1 == m2) ? m1 : (std::less<QBasicMutex *>()(m1, m2) ? m1 : m2)), - mtx2((m1 == m2) ? 0 : (std::less<QBasicMutex *>()(m1, m2) ? m2 : m1)), + mtx2((m1 == m2) ? nullptr : (std::less<QBasicMutex *>()(m1, m2) ? m2 : m1)), locked(false) { relock(); diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index c8463de402..8c28507d5a 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -227,7 +227,7 @@ bool QReadWriteLock::tryLockForRead(int timeout) return true; while (true) { - if (d == 0) { + if (d == nullptr) { if (!d_ptr.testAndSetAcquire(nullptr, dummyLockedForRead, d)) continue; return true; @@ -341,7 +341,7 @@ bool QReadWriteLock::tryLockForWrite(int timeout) return true; while (true) { - if (d == 0) { + if (d == nullptr) { if (!d_ptr.testAndSetAcquire(d, dummyLockedForWrite, d)) continue; return true; @@ -581,7 +581,7 @@ void QReadWriteLockPrivate::recursiveUnlock() if (self == currentWriter) { if (--writerCount > 0) return; - currentWriter = 0; + currentWriter = nullptr; } else { auto it = currentReaders.find(self); if (it == currentReaders.end()) { diff --git a/src/corelib/thread/qresultstore.cpp b/src/corelib/thread/qresultstore.cpp index 1b3bc20eca..0b82b938e1 100644 --- a/src/corelib/thread/qresultstore.cpp +++ b/src/corelib/thread/qresultstore.cpp @@ -192,7 +192,7 @@ int ResultStoreBase::addResults(int index, const void *results, int vectorSize, ResultItem filteredIn(results, vectorSize); insertResultItem(index, filteredIn); } - ResultItem filteredAway(0, totalCount - vectorSize); + ResultItem filteredAway(nullptr, totalCount - vectorSize); return insertResultItem(index + vectorSize, filteredAway); } } diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 791b765880..d3bb372b00 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE QThreadData::QThreadData(int initialRefCount) : _ref(initialRefCount), loopLevel(0), scopeLevel(0), - eventDispatcher(0), + eventDispatcher(nullptr), quitNow(false), canWait(true), isAdopted(false), requiresCoreApplication(true) { // fprintf(stderr, "QThreadData %p created\n", this); @@ -399,7 +399,7 @@ QThreadPrivate::~QThreadPrivate() QThread *QThread::currentThread() { QThreadData *data = QThreadData::current(); - Q_ASSERT(data != 0); + Q_ASSERT(data != nullptr); return data->thread.loadAcquire(); } @@ -451,7 +451,7 @@ QThread::~QThread() if (d->running && !d->finished && !d->data->isAdopted) qFatal("QThread: Destroyed while thread is still running"); - d->data->thread = 0; + d->data->thread = nullptr; } } diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 62f0179802..1da68b3130 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -109,7 +109,7 @@ Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE)); enum { ThreadPriorityResetFlag = 0x80000000 }; -static thread_local QThreadData *currentThreadData = 0; +static thread_local QThreadData *currentThreadData = nullptr; static pthread_once_t current_thread_data_once = PTHREAD_ONCE_INIT; static pthread_key_t current_thread_data_key; @@ -144,7 +144,7 @@ static void destroy_current_thread_data(void *p) #if defined(Q_OS_VXWORKS) (void *)1); #else - 0); + nullptr); #endif } @@ -182,8 +182,8 @@ static void set_thread_data(QThreadData *data) static void clear_thread_data() { - currentThreadData = 0; - pthread_setspecific(current_thread_data_key, 0); + currentThreadData = nullptr; + pthread_setspecific(current_thread_data_key, nullptr); } template <typename T> @@ -226,7 +226,7 @@ QThreadData *QThreadData::current(bool createIfNecessary) } QT_CATCH(...) { clear_thread_data(); data->deref(); - data = 0; + data = nullptr; QT_RETHROW; } data->deref(); @@ -294,7 +294,7 @@ static void setCurrentThreadName(const char *name) void *QThreadPrivate::start(void *arg) { #if !defined(Q_OS_ANDROID) - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, nullptr); #endif pthread_cleanup_push(QThreadPrivate::finish, arg); @@ -336,7 +336,7 @@ void *QThreadPrivate::start(void *arg) emit thr->started(QThread::QPrivateSignal()); #if !defined(Q_OS_ANDROID) - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, nullptr); pthread_testcancel(); #endif thr->run(); @@ -360,7 +360,7 @@ void *QThreadPrivate::start(void *arg) // thrown. pthread_cleanup_pop(1); - return 0; + return nullptr; } void QThreadPrivate::finish(void *arg) @@ -379,13 +379,13 @@ void QThreadPrivate::finish(void *arg) void *data = &d->data->tls; locker.unlock(); emit thr->finished(QThread::QPrivateSignal()); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); QThreadStorageData::finish((void **)data); locker.relock(); QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher.loadRelaxed(); if (eventDispatcher) { - d->data->eventDispatcher = 0; + d->data->eventDispatcher = nullptr; locker.unlock(); eventDispatcher->closingDown(); delete eventDispatcher; @@ -774,14 +774,14 @@ bool QThread::wait(QDeadlineTimer deadline) void QThread::setTerminationEnabled(bool enabled) { QThread *thr = currentThread(); - Q_ASSERT_X(thr != 0, "QThread::setTerminationEnabled()", + Q_ASSERT_X(thr != nullptr, "QThread::setTerminationEnabled()", "Current thread was not started with QThread."); Q_UNUSED(thr) #if defined(Q_OS_ANDROID) Q_UNUSED(enabled); #else - pthread_setcancelstate(enabled ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE, NULL); + pthread_setcancelstate(enabled ? PTHREAD_CANCEL_ENABLE : PTHREAD_CANCEL_DISABLE, nullptr); if (enabled) pthread_testcancel(); #endif diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp index fdc484d2d2..464559ffa5 100644 --- a/src/corelib/thread/qthreadstorage.cpp +++ b/src/corelib/thread/qthreadstorage.cpp @@ -116,7 +116,7 @@ void **QThreadStorageData::get() const QThreadData *data = QThreadData::current(); if (!data) { qWarning("QThreadStorage::get: QThreadStorage can only be used with threads started with QThread"); - return 0; + return nullptr; } QVector<void *> &tls = data->tls; if (tls.size() <= id) @@ -128,7 +128,7 @@ void **QThreadStorageData::get() const *v, data->thread.loadRelaxed()); - return *v ? v : 0; + return *v ? v : nullptr; } void **QThreadStorageData::set(void *p) @@ -136,7 +136,7 @@ void **QThreadStorageData::set(void *p) QThreadData *data = QThreadData::current(); if (!data) { qWarning("QThreadStorage::set: QThreadStorage can only be used with threads started with QThread"); - return 0; + return nullptr; } QVector<void *> &tls = data->tls; if (tls.size() <= id) @@ -144,7 +144,7 @@ void **QThreadStorageData::set(void *p) void *&value = tls[id]; // delete any previous data - if (value != 0) { + if (value != nullptr) { DEBUG_MSG("QThreadStorageData: Deleting previous storage %d, data %p, for thread %p", id, value, @@ -156,7 +156,7 @@ void **QThreadStorageData::set(void *p) locker.unlock(); void *q = value; - value = 0; + value = nullptr; if (destructor) destructor(q); @@ -178,7 +178,7 @@ void QThreadStorageData::finish(void **p) while (!tls->isEmpty()) { void *&value = tls->last(); void *q = value; - value = 0; + value = nullptr; int i = tls->size() - 1; tls->resize(i); diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index a8dfb9999c..80f9e780e7 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -173,7 +173,7 @@ public: QWaitCondition::QWaitCondition() { d = new QWaitConditionPrivate; - report_error(pthread_mutex_init(&d->mutex, NULL), "QWaitCondition", "mutex init"); + report_error(pthread_mutex_init(&d->mutex, nullptr), "QWaitCondition", "mutex init"); qt_initialize_pthread_cond(&d->cond, "QWaitCondition"); d->waiters = d->wakeups = 0; } diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index c833c18809..979b8c9aeb 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1769,7 +1769,7 @@ QDate QDate::fromString(const QString &string, const QString &format, QCalendar QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format)) - dt.fromString(string, &date, 0); + dt.fromString(string, &date, nullptr); #else Q_UNUSED(string); Q_UNUSED(format); @@ -2499,7 +2499,7 @@ QTime QTime::fromString(const QString &string, const QString &format) QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, QCalendar()); // dt.setDefaultLocale(QLocale::c()); ### Qt 6 if (dt.parseFormat(format)) - dt.fromString(string, 0, &time); + dt.fromString(string, nullptr, &time); #else Q_UNUSED(string); Q_UNUSED(format); diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 2501bbaab7..a487534528 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1152,7 +1152,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, } pos += separator.size(); sectionNodes[index].pos = pos; - int *current = 0; + int *current = nullptr; const SectionNode sn = sectionNodes.at(index); ParsedSection sect; diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index 410a16e3c5..3d2078087b 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -318,7 +318,7 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz); */ QTimeZone::QTimeZone() noexcept - : d(0) + : d(nullptr) { } diff --git a/src/corelib/time/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp index 5570ce7571..8a92bbb387 100644 --- a/src/corelib/time/qtimezoneprivate_icu.cpp +++ b/src/corelib/time/qtimezoneprivate_icu.cpp @@ -273,7 +273,7 @@ static int ucalDaylightOffset(const QByteArray &id) // Create the system default time zone QIcuTimeZonePrivate::QIcuTimeZonePrivate() - : m_ucal(0) + : m_ucal(nullptr) { // TODO No ICU C API to obtain sysem tz, assume default hasn't been changed init(ucalDefaultTimeZoneId()); @@ -281,7 +281,7 @@ QIcuTimeZonePrivate::QIcuTimeZonePrivate() // Create a named time zone QIcuTimeZonePrivate::QIcuTimeZonePrivate(const QByteArray &ianaId) - : m_ucal(0) + : m_ucal(nullptr) { // Need to check validity here as ICu will create a GMT tz if name is invalid if (availableTimeZoneIds().contains(ianaId)) @@ -289,14 +289,14 @@ QIcuTimeZonePrivate::QIcuTimeZonePrivate(const QByteArray &ianaId) } QIcuTimeZonePrivate::QIcuTimeZonePrivate(const QIcuTimeZonePrivate &other) - : QTimeZonePrivate(other), m_ucal(0) + : QTimeZonePrivate(other), m_ucal(nullptr) { // Clone the ucal so we don't close the shared object UErrorCode status = U_ZERO_ERROR; m_ucal = ucal_clone(other.m_ucal, &status); if (!U_SUCCESS(status)) { m_id.clear(); - m_ucal = 0; + m_ucal = nullptr; } } @@ -322,7 +322,7 @@ void QIcuTimeZonePrivate::init(const QByteArray &ianaId) if (!U_SUCCESS(status)) { m_id.clear(); - m_ucal = 0; + m_ucal = nullptr; } } @@ -493,7 +493,7 @@ QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(int offsetFromUtc) c // TODO Available directly in C++ api but not C api, from 4.8 onwards new filter method works #if U_ICU_VERSION_MAJOR_NUM >= 49 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM == 8) UErrorCode status = U_ZERO_ERROR; - UEnumeration *uenum = ucal_openTimeZoneIDEnumeration(UCAL_ZONE_TYPE_ANY, 0, + UEnumeration *uenum = ucal_openTimeZoneIDEnumeration(UCAL_ZONE_TYPE_ANY, nullptr, &offsetFromUtc, &status); QList<QByteArray> result; if (U_SUCCESS(status)) diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index 3c2695a789..5e55c6897d 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -512,7 +512,7 @@ PosixZone PosixZone::parse(const char *&pos, const char *end) if (zoneEnd < end && (zoneEnd[0] == '+' || zoneEnd[0] == '-')) ++zoneEnd; while (zoneEnd < end) { - if (strchr(offsetChars, char(*zoneEnd)) == NULL) + if (strchr(offsetChars, char(*zoneEnd)) == nullptr) break; ++zoneEnd; } diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 36a221f728..3879b48cbb 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -265,7 +265,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize, return; #endif - Q_ASSERT_X(data == 0 || !data->ref.isStatic(), "QArrayData::deallocate", + Q_ASSERT_X(data == nullptr || !data->ref.isStatic(), "QArrayData::deallocate", "Static data cannot be deleted"); ::free(data); } diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 52c8d13fe3..7f9b6ef39f 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -443,12 +443,12 @@ class QEasingCurvePrivate public: QEasingCurvePrivate() : type(QEasingCurve::Linear), - config(0), + config(nullptr), func(&easeNone) { } QEasingCurvePrivate(const QEasingCurvePrivate &other) : type(other.type), - config(other.config ? other.config->copy() : 0), + config(other.config ? other.config->copy() : nullptr), func(other.func) { } ~QEasingCurvePrivate() { delete config; } @@ -590,7 +590,7 @@ struct BezierEase : public QEasingCurveFunction if (!(x < 1)) return 1; - SingleCubicBezier *singleCubicBezier = 0; + SingleCubicBezier *singleCubicBezier = nullptr; getBezierSegment(singleCubicBezier, x); return evaluateSegmentForY(*singleCubicBezier, findTForX(*singleCubicBezier, x)); @@ -1097,7 +1097,7 @@ static QEasingCurve::EasingFunction curveToFunc(QEasingCurve::Type curve) case QEasingCurve::CosineCurve: return &easeCosineCurve; default: - return 0; + return nullptr; }; } @@ -1127,7 +1127,7 @@ static QEasingCurveFunction *curveToFunctionObject(QEasingCurve::Type type) return new QEasingCurveFunction(type, qreal(0.3), qreal(1.0), qreal(1.70158)); } - return 0; + return nullptr; } /*! @@ -1422,7 +1422,7 @@ void QEasingCurvePrivate::setType_helper(QEasingCurve::Type newType) tcbPoints = std::move(config->_tcbPoints); delete config; - config = 0; + config = nullptr; } if (isConfigFunction(newType) || (amp != -1.0) || (period != -1.0) || (overshoot != -1.0) || @@ -1436,11 +1436,11 @@ void QEasingCurvePrivate::setType_helper(QEasingCurve::Type newType) config->_o = overshoot; config->_bezierCurves = std::move(bezierCurves); config->_tcbPoints = std::move(tcbPoints); - func = 0; + func = nullptr; } else if (newType != QEasingCurve::Custom) { func = curveToFunc(newType); } - Q_ASSERT((func == 0) == (config != 0)); + Q_ASSERT((func == nullptr) == (config != nullptr)); type = newType; } @@ -1487,7 +1487,7 @@ void QEasingCurve::setCustomType(EasingFunction func) */ QEasingCurve::EasingFunction QEasingCurve::customType() const { - return d_ptr->type == Custom ? d_ptr->func : 0; + return d_ptr->type == Custom ? d_ptr->func : nullptr; } /*! diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index 993607a643..bf0e33e26e 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -72,7 +72,7 @@ int QDBusAdaptorConnector::relaySlotMethodIndex() QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *obj) { if (!obj) - return 0; + return nullptr; const QObjectList &children = obj->children(); QObjectList::ConstIterator it = children.constBegin(); QObjectList::ConstIterator end = children.constEnd(); @@ -83,7 +83,7 @@ QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *obj) return connector; } } - return 0; + return nullptr; } QDBusAdaptorConnector *qDBusFindAdaptorConnector(QDBusAbstractAdaptor *adaptor) @@ -411,7 +411,7 @@ void QDBusAdaptorConnector::qt_static_metacall(QObject *_o, QMetaObject::Call _c const QMetaObject QDBusAdaptorConnector::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_QDBusAdaptorConnector.data, - qt_meta_data_QDBusAdaptorConnector, qt_static_metacall, 0, 0 } + qt_meta_data_QDBusAdaptorConnector, qt_static_metacall, nullptr, nullptr } }; const QMetaObject *QDBusAdaptorConnector::metaObject() const @@ -421,7 +421,7 @@ const QMetaObject *QDBusAdaptorConnector::metaObject() const void *QDBusAdaptorConnector::qt_metacast(const char *_clname) { - if (!_clname) return 0; + if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_QDBusAdaptorConnector.stringdata)) return static_cast<void*>(const_cast< QDBusAdaptorConnector*>(this)); return QObject::qt_metacast(_clname); @@ -443,7 +443,7 @@ int QDBusAdaptorConnector::qt_metacall(QMetaObject::Call _c, int _id, void **_a) // SIGNAL 0 void QDBusAdaptorConnector::relaySignal(QObject * _t1, const QMetaObject * _t2, int _t3, const QVariantList & _t4) { - void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)), const_cast<void*>(reinterpret_cast<const void*>(&_t4)) }; + void *_a[] = { nullptr, const_cast<void*>(reinterpret_cast<const void*>(&_t1)), const_cast<void*>(reinterpret_cast<const void*>(&_t2)), const_cast<void*>(reinterpret_cast<const void*>(&_t3)), const_cast<void*>(reinterpret_cast<const void*>(&_t4)) }; QMetaObject::activate(this, &staticMetaObject, 0, _a); } diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 87de784fc0..b628c2b560 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -159,7 +159,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu const char *expectedSignature = ""; if (int(mp.type()) != QMetaType::QVariant) { expectedSignature = QDBusMetaType::typeToSignature(type); - if (expectedSignature == 0) { + if (expectedSignature == nullptr) { qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be " "used to read property %s.%s", mp.typeName(), qPrintable(interface), mp.name()); @@ -190,7 +190,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu } QByteArray foundSignature; - const char *foundType = 0; + const char *foundType = nullptr; QVariant value = qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant(); if (value.userType() == type || type == QMetaType::QVariant @@ -597,7 +597,7 @@ bool QDBusAbstractInterface::callWithCallback(const QString &method, QObject *receiver, const char *slot) { - return callWithCallback(method, args, receiver, slot, 0); + return callWithCallback(method, args, receiver, slot, nullptr); } /*! diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 764bc24165..5a0f0f013b 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -74,11 +74,11 @@ QByteArray QDBusArgumentPrivate::createSignature(int id) marshaller->ba = &signature; // run it - void *null = 0; + void *null = nullptr; QVariant v(id, null); QDBusArgument arg(marshaller); QDBusMetaType::marshall(arg, v.userType(), v.constData()); - arg.d = 0; + arg.d = nullptr; // delete it bool ok = marshaller->ok; @@ -290,7 +290,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d) QDBusArgument::QDBusArgument() { if (!qdbus_loadLibDBus()) { - d = 0; + d = nullptr; return; } diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index b93dabb3a7..412b428bdc 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -101,7 +101,7 @@ QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::B Q_ASSERT(type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus); if (!qdbus_loadLibDBus()) - return 0; + return nullptr; // we'll start in suspended delivery mode if we're in the main thread // (the event loop will resume delivery) @@ -124,7 +124,7 @@ QDBusConnectionPrivate *QDBusConnectionManager::connection(const QString &name) void QDBusConnectionManager::removeConnection(const QString &name) { - QDBusConnectionPrivate *d = 0; + QDBusConnectionPrivate *d = nullptr; d = connectionHash.take(name); if (d && !d->ref.deref()) d->deleteLater(); @@ -251,7 +251,7 @@ void QDBusConnectionManager::executeConnectionRequest(QDBusConnectionManager::Co return; d = new QDBusConnectionPrivate; - DBusConnection *c = 0; + DBusConnection *c = nullptr; QDBusErrorInternal error; switch (data->type) { case ConnectionRequestData::ConnectToStandardBus: @@ -275,7 +275,7 @@ void QDBusConnectionManager::executeConnectionRequest(QDBusConnectionManager::Co // register on the bus if (!q_dbus_bus_register(c, error)) { q_dbus_connection_unref(c); - c = 0; + c = nullptr; } } break; @@ -427,7 +427,7 @@ void QDBusConnectionManager::createServer(const QString &address, void *server) QDBusConnection::QDBusConnection(const QString &name) { if (name.isEmpty() || _q_manager.isDestroyed()) { - d = 0; + d = nullptr; } else { const auto locker = qt_scoped_lock(_q_manager()->mutex); d = _q_manager()->connection(name); @@ -492,7 +492,7 @@ QDBusConnection &QDBusConnection::operator=(const QDBusConnection &other) QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name) { if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) { - QDBusConnectionPrivate *d = 0; + QDBusConnectionPrivate *d = nullptr; return QDBusConnection(d); } return QDBusConnection(_q_manager()->connectToBus(type, name, false)); @@ -506,7 +506,7 @@ QDBusConnection QDBusConnection::connectToBus(const QString &address, const QString &name) { if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) { - QDBusConnectionPrivate *d = 0; + QDBusConnectionPrivate *d = nullptr; return QDBusConnection(d); } return QDBusConnection(_q_manager()->connectToBus(address, name)); @@ -521,7 +521,7 @@ QDBusConnection QDBusConnection::connectToPeer(const QString &address, const QString &name) { if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) { - QDBusConnectionPrivate *d = 0; + QDBusConnectionPrivate *d = nullptr; return QDBusConnection(d); } return QDBusConnection(_q_manager()->connectToPeer(address, name)); @@ -616,7 +616,7 @@ bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *rec d->lastError = err; return false; } - return d->sendWithReplyAsync(message, receiver, returnMethod, errorMethod, timeout) != 0; + return d->sendWithReplyAsync(message, receiver, returnMethod, errorMethod, timeout) != nullptr; } /*! @@ -639,7 +639,7 @@ bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *rec bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *receiver, const char *returnMethod, int timeout) const { - return callWithCallback(message, receiver, returnMethod, 0, timeout); + return callWithCallback(message, receiver, returnMethod, nullptr, timeout); } /*! @@ -705,10 +705,10 @@ QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int timeout) const { if (!d || !d->connection) { - return QDBusPendingCall(0); // null pointer -> disconnected + return QDBusPendingCall(nullptr); // null pointer -> disconnected } - QDBusPendingCallPrivate *priv = d->sendWithReplyAsync(message, 0, 0, 0, timeout); + QDBusPendingCallPrivate *priv = d->sendWithReplyAsync(message, nullptr, nullptr, nullptr, timeout); return QDBusPendingCall(priv); } @@ -1015,7 +1015,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const Q_ASSERT_X(QDBusUtil::isValidObjectPath(path), "QDBusConnection::registeredObject", "Invalid object path given"); if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path)) - return 0; + return nullptr; auto pathComponents = path.splitRef(QLatin1Char('/')); if (pathComponents.constLast().isEmpty()) @@ -1040,7 +1040,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const node = it; ++i; } - return 0; + return nullptr; } @@ -1052,7 +1052,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const QDBusConnectionInterface *QDBusConnection::interface() const { if (!d || d->mode != QDBusConnectionPrivate::ClientMode) - return 0; + return nullptr; return d->busService; } @@ -1068,7 +1068,7 @@ QDBusConnectionInterface *QDBusConnection::interface() const */ void *QDBusConnection::internalPointer() const { - return d ? d->connection : 0; + return d ? d->connection : nullptr; } /*! diff --git a/src/dbus/qdbuscontext.cpp b/src/dbus/qdbuscontext.cpp index 5b21c4fa74..de0482be70 100644 --- a/src/dbus/qdbuscontext.cpp +++ b/src/dbus/qdbuscontext.cpp @@ -64,7 +64,7 @@ QDBusContextPrivate *QDBusContextPrivate::set(QObject *obj, QDBusContextPrivate return old; } - return 0; + return nullptr; } /*! @@ -104,7 +104,7 @@ QDBusContextPrivate *QDBusContextPrivate::set(QObject *obj, QDBusContextPrivate Constructs an empty QDBusContext. */ QDBusContext::QDBusContext() - : d_ptr(0) + : d_ptr(nullptr) { } diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index 6befb33d61..c9da593ad2 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -295,7 +295,7 @@ QVariant QDBusDemarshaller::toVariantInternal() // qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", // q_dbus_message_iter_get_arg_type(&iterator), // q_dbus_message_iter_get_arg_type(&iterator)); - char *ptr = 0; + char *ptr = nullptr; ptr += q_dbus_message_iter_get_arg_type(&iterator); q_dbus_message_iter_next(&iterator); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index fb4f927a87..bca02be59e 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -127,7 +127,7 @@ void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate * "condition unknown") << "in connection" << conn; } -qdbusThreadDebugFunc qdbusThreadDebug = 0; +qdbusThreadDebugFunc qdbusThreadDebug = nullptr; #endif typedef QVarLengthArray<QDBusSpyCallEvent::Hook, 4> QDBusSpyHookList; @@ -400,7 +400,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root, // match node = it; else - node = 0; + node = nullptr; start = end + 1; } @@ -413,7 +413,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root, else // there really is no object here // we're just looking at an unused space in the QVector - node = 0; + node = nullptr; } return node; } @@ -440,7 +440,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro const QObjectList children = obj->children(); // find a child with the proper name - QObject *next = 0; + QObject *next = nullptr; QObjectList::ConstIterator it = children.constBegin(); QObjectList::ConstIterator end = children.constEnd(); for ( ; it != end; ++it) @@ -458,7 +458,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro } // object not found - return 0; + return nullptr; } static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode) @@ -599,7 +599,7 @@ static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNo haystack.children.end()); if (needle == haystack.obj) { - haystack.obj = 0; + haystack.obj = nullptr; haystack.flags = 0; } } @@ -609,7 +609,7 @@ static void huntAndUnregister(const QVector<QStringRef> &pathComponents, int i, { if (pathComponents.count() == i) { // found it - node->obj = 0; + node->obj = nullptr; node->flags = 0; if (mode == QDBusConnection::UnregisterTree) { @@ -660,7 +660,7 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg, qDBusDebug() << QThread::currentThread() << "emitting signal at" << p; DBusMessage *msg2 = q_dbus_message_copy(msg); q_dbus_message_set_path(msg2, p); - q_dbus_connection_send(connection, msg2, 0); + q_dbus_connection_send(connection, msg2, nullptr); q_dbus_message_unref(msg2); } } @@ -727,12 +727,12 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags, ++i; // make sure that the output parameters have signatures too - if (returnType != QMetaType::UnknownType && returnType != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == 0) + if (returnType != QMetaType::UnknownType && returnType != QMetaType::Void && QDBusMetaType::typeToSignature(returnType) == nullptr) continue; bool ok = true; for (int j = i; ok && j < metaTypes.count(); ++j) - if (QDBusMetaType::typeToSignature(metaTypes.at(i)) == 0) + if (QDBusMetaType::typeToSignature(metaTypes.at(i)) == nullptr) ok = false; if (!ok) continue; @@ -790,13 +790,13 @@ QDBusCallDeliveryEvent* QDBusConnectionPrivate::prepareReply(QDBusConnectionPriv --n; if (msg.arguments().count() < n) - return 0; // too few arguments + return nullptr; // too few arguments // check that types match for (int i = 0; i < n; ++i) if (metaTypes.at(i + 1) != msg.arguments().at(i).userType() && msg.arguments().at(i).userType() != qMetaTypeId<QDBusArgument>()) - return 0; // no match + return nullptr; // no match // we can deliver // prepare for the call @@ -944,7 +944,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q params.append(const_cast<void *>(arg.constData())); else if (arg.userType() == qMetaTypeId<QDBusArgument>()) { // convert to what the function expects - void *null = 0; + void *null = nullptr; auxParameters.append(QVariant(id, null)); const QDBusArgument &in = @@ -972,7 +972,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q // output arguments const int numMetaTypes = metaTypes.count(); QVariantList outputArgs; - void *null = 0; + void *null = nullptr; if (metaTypes[0] != QMetaType::Void && metaTypes[0] != QMetaType::UnknownType) { outputArgs.reserve(numMetaTypes - i + 1); QVariant arg(metaTypes[0], null); @@ -1026,8 +1026,8 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q extern bool qDBusInitThreads(); QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) - : QObject(p), ref(1), mode(InvalidMode), busService(0), - connection(0), + : QObject(p), ref(1), mode(InvalidMode), busService(nullptr), + connection(nullptr), rootNode(QString(QLatin1Char('/'))), anonymousAuthenticationAllowed(false), dispatchEnabled(true) @@ -1087,11 +1087,11 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() } if (connection) q_dbus_connection_unref(connection); - connection = 0; + connection = nullptr; } else if (lastMode == ServerMode) { if (server) q_dbus_server_unref(server); - server = 0; + server = nullptr; } } @@ -1531,7 +1531,7 @@ void QDBusConnectionPrivate::handleObjectCall(const QDBusMessage &msg) // user code, if necessary. ObjectTreeNode result; int usedLength; - QThread *objThread = 0; + QThread *objThread = nullptr; QSemaphore sem; bool semWait; @@ -1718,7 +1718,7 @@ void QDBusConnectionPrivate::setServer(QDBusServer *object, DBusServer *s, const qDBusAddWatch, qDBusRemoveWatch, qDBusToggleWatch, - this, 0); + this, nullptr); //qDebug() << "watch_functions_set" << watch_functions_set; Q_UNUSED(watch_functions_set); @@ -1726,13 +1726,13 @@ void QDBusConnectionPrivate::setServer(QDBusServer *object, DBusServer *s, const qDBusAddTimeout, qDBusRemoveTimeout, qDBusToggleTimeout, - this, 0); + this, nullptr); //qDebug() << "time_functions_set" << time_functions_set; Q_UNUSED(time_functions_set); - q_dbus_server_set_new_connection_function(server, qDBusNewConnection, this, 0); + q_dbus_server_set_new_connection_function(server, qDBusNewConnection, this, nullptr); - dbus_bool_t data_set = q_dbus_server_set_data(server, server_slot, this, 0); + dbus_bool_t data_set = q_dbus_server_set_data(server, server_slot, this, nullptr); //qDebug() << "data_set" << data_set; Q_UNUSED(data_set); } @@ -1752,16 +1752,16 @@ void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal qDBusAddWatch, qDBusRemoveWatch, qDBusToggleWatch, - this, 0); + this, nullptr); q_dbus_connection_set_timeout_functions(connection, qDBusAddTimeout, qDBusRemoveTimeout, qDBusToggleTimeout, - this, 0); - q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, 0); + this, nullptr); + q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, nullptr); q_dbus_connection_add_filter(connection, qDBusSignalFilter, - this, 0); + this, nullptr); watchForDBusDisconnection(); @@ -1772,7 +1772,7 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti { QDBusConnection::ConnectionCapabilities result; typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int); - static can_send_type_t can_send_type = 0; + static can_send_type_t can_send_type = nullptr; #if defined(QT_LINKED_LIBDBUS) # if DBUS_VERSION-0 >= 0x010400 @@ -1809,11 +1809,11 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError q_dbus_connection_set_exit_on_disconnect(connection, false); q_dbus_connection_set_watch_functions(connection, qDBusAddWatch, qDBusRemoveWatch, - qDBusToggleWatch, this, 0); + qDBusToggleWatch, this, nullptr); q_dbus_connection_set_timeout_functions(connection, qDBusAddTimeout, qDBusRemoveTimeout, - qDBusToggleTimeout, this, 0); - q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, 0); - q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0); + qDBusToggleTimeout, this, nullptr); + q_dbus_connection_set_dispatch_status_function(connection, qDBusUpdateDispatchStatus, this, nullptr); + q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, nullptr); // Initialize the hooks for the NameAcquired and NameLost signals // we don't use connectSignal here because we don't need the rules to be sent to the bus @@ -1904,7 +1904,7 @@ void QDBusConnectionPrivate::processFinishedCall(QDBusPendingCallPrivate *call) if (call->pending) { q_dbus_pending_call_unref(call->pending); - call->pending = 0; + call->pending = nullptr; } // Are there any watchers? @@ -2046,7 +2046,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message, { QDBusBlockingCallWatcher watcher(message); - QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, 0, 0, 0, timeout); + QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, nullptr, nullptr, nullptr, timeout); Q_ASSERT(pcall); if (pcall->replyMessage.type() == QDBusMessage::InvalidMessage) { @@ -2161,7 +2161,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void *message, int timeout) { QDBusError error; - DBusPendingCall *pending = 0; + DBusPendingCall *pending = nullptr; DBusMessage *msg = static_cast<DBusMessage *>(message); bool isNoReply = !pcall; Q_ASSERT(isNoReply == !!q_dbus_message_get_no_reply(msg)); @@ -2175,7 +2175,7 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void * q_dbus_message_unref(msg); pcall->pending = pending; - q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, 0); + q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, nullptr); // DBus won't notify us when a peer disconnects or server terminates so we need to track these ourselves if (mode == QDBusConnectionPrivate::PeerMode || mode == QDBusConnectionPrivate::ClientMode) @@ -2261,7 +2261,7 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook if (connection) { if (mode != QDBusConnectionPrivate::PeerMode) { qDBusDebug() << this << "Adding rule:" << hook.matchRule; - q_dbus_bus_add_match(connection, hook.matchRule, NULL); + q_dbus_bus_add_match(connection, hook.matchRule, nullptr); // Successfully connected the signal // Do we need to watch for this name? @@ -2274,7 +2274,7 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook q_dbus_bus_add_match(connection, buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), rules, QString()), - NULL); + nullptr); data.owner = getNameOwnerNoCache(hook.service); qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:" << data.owner << ")"; @@ -2362,7 +2362,7 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it) if (connection && erase) { if (mode != QDBusConnectionPrivate::PeerMode) { qDBusDebug() << this << "Removing rule:" << hook.matchRule; - q_dbus_bus_remove_match(connection, hook.matchRule, NULL); + q_dbus_bus_remove_match(connection, hook.matchRule, nullptr); // Successfully disconnected the signal // Were we watching for this name? @@ -2375,7 +2375,7 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it) q_dbus_bus_remove_match(connection, buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), rules, QString()), - NULL); + nullptr); } } } @@ -2575,7 +2575,7 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa // it doesn't exist yet, we have to create it QDBusWriteLocker locker(FindMetaObject2Action, this); - QDBusMetaObject *mo = 0; + QDBusMetaObject *mo = nullptr; if (!interface.isEmpty()) mo = cachedMetaObjects.value(interface, 0); if (mo) @@ -2591,7 +2591,7 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa error = QDBusError(reply); lastError = error; if (reply.type() != QDBusMessage::ErrorMessage || error.type() != QDBusError::UnknownMethod) - return 0; // error + return nullptr; // error } // release the lock and return diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index b53c639b6d..72b9d42247 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -149,7 +149,7 @@ static void copyArgument(void *to, int id, const QVariant &arg) QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString &p, const QString &iface, const QDBusConnection &con) - : QDBusAbstractInterfacePrivate(serv, p, iface, con, true), metaObject(0) + : QDBusAbstractInterfacePrivate(serv, p, iface, con, true), metaObject(nullptr) { // QDBusAbstractInterfacePrivate's constructor checked the parameters for us if (connection.isConnected()) { @@ -245,7 +245,7 @@ const QMetaObject *QDBusInterface::metaObject() const */ void *QDBusInterface::qt_metacast(const char *_clname) { - if (!_clname) return 0; + if (!_clname) return nullptr; if (!strcmp(_clname, "QDBusInterface")) return static_cast<void*>(const_cast<QDBusInterface*>(this)); if (d_func()->interface.toLatin1() == _clname) diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index edee4fc1e5..74cc470596 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -358,7 +358,7 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant if (id != QMetaType::QVariant && value.userType() == QDBusMetaTypeId::argument()) { // we have to demarshall before writing - void *null = 0; + void *null = nullptr; QVariant other(id, null); if (!QDBusMetaType::demarshall(qvariant_cast<QDBusArgument>(value), id, other.data())) { qWarning("QDBusConnection: type `%s' (%d) is not registered with QtDBus. " diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index 8e0b3e4598..46b41d1c07 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -197,7 +197,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg) } QByteArray tmpSignature; - const char *signature = 0; + const char *signature = nullptr; if (id == QDBusMetaTypeId::argument()) { // take the signature from the QDBusArgument object we're marshalling tmpSignature = @@ -243,7 +243,7 @@ inline void QDBusMarshaller::append(const QStringList &arg) inline QDBusMarshaller *QDBusMarshaller::beginStructure() { - return beginCommon(DBUS_TYPE_STRUCT, 0); + return beginCommon(DBUS_TYPE_STRUCT, nullptr); } inline QDBusMarshaller *QDBusMarshaller::beginArray(int id) @@ -301,7 +301,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid) inline QDBusMarshaller *QDBusMarshaller::beginMapEntry() { - return beginCommon(DBUS_TYPE_DICT_ENTRY, 0); + return beginCommon(DBUS_TYPE_DICT_ENTRY, nullptr); } void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature) @@ -572,7 +572,7 @@ bool QDBusMarshaller::appendCrossMarshalling(QDBusDemarshaller *demarshaller) QDBusMarshaller mrecursed(capabilities); // create on the stack makes it autoclose QByteArray subSignature; - const char *sig = 0; + const char *sig = nullptr; if (code == DBUS_TYPE_VARIANT || code == DBUS_TYPE_ARRAY) { subSignature = drecursed->currentSignature().toLatin1(); if (!subSignature.isEmpty()) diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index 3e8f2eaf3f..71cdec93ca 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -64,11 +64,11 @@ Q_STATIC_ASSERT(QDBusMessage::SignalMessage == DBUS_MESSAGE_TYPE_SIGNAL); static inline const char *data(const QByteArray &arr) { - return arr.isEmpty() ? 0 : arr.constData(); + return arr.isEmpty() ? nullptr : arr.constData(); } QDBusMessagePrivate::QDBusMessagePrivate() - : msg(0), reply(0), localReply(0), ref(1), type(QDBusMessage::InvalidMessage), + : msg(nullptr), reply(nullptr), localReply(nullptr), ref(1), type(QDBusMessage::InvalidMessage), delayedReply(false), localMessage(false), parametersValidated(false), autoStartService(true), interactiveAuthorizationAllowed(false) @@ -113,10 +113,10 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB { if (!qdbus_loadLibDBus()) { *error = QDBusError(QDBusError::Failed, QLatin1String("Could not open lidbus-1 library")); - return 0; + return nullptr; } - DBusMessage *msg = 0; + DBusMessage *msg = nullptr; const QDBusMessagePrivate *d_ptr = message.d_ptr; switch (d_ptr->type) { @@ -127,13 +127,13 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB // only service and interface can be empty -> path and name must not be empty if (!d_ptr->parametersValidated) { if (!QDBusUtil::checkBusName(d_ptr->service, QDBusUtil::EmptyAllowed, error)) - return 0; + return nullptr; if (!QDBusUtil::checkObjectPath(d_ptr->path, QDBusUtil::EmptyNotAllowed, error)) - return 0; + return nullptr; if (!QDBusUtil::checkInterfaceName(d_ptr->interface, QDBusUtil::EmptyAllowed, error)) - return 0; + return nullptr; if (!QDBusUtil::checkMemberName(d_ptr->name, QDBusUtil::EmptyNotAllowed, error, "method")) - return 0; + return nullptr; } msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(), @@ -153,7 +153,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB // error name can't be empty if (!d_ptr->parametersValidated && !QDBusUtil::checkErrorName(d_ptr->name, QDBusUtil::EmptyNotAllowed, error)) - return 0; + return nullptr; msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_ERROR); q_dbus_message_set_error_name(msg, d_ptr->name.toUtf8()); @@ -166,13 +166,13 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB // only the service name can be empty here if (!d_ptr->parametersValidated) { if (!QDBusUtil::checkBusName(d_ptr->service, QDBusUtil::EmptyAllowed, error)) - return 0; + return nullptr; if (!QDBusUtil::checkObjectPath(d_ptr->path, QDBusUtil::EmptyNotAllowed, error)) - return 0; + return nullptr; if (!QDBusUtil::checkInterfaceName(d_ptr->interface, QDBusUtil::EmptyAllowed, error)) - return 0; + return nullptr; if (!QDBusUtil::checkMemberName(d_ptr->name, QDBusUtil::EmptyNotAllowed, error, "method")) - return 0; + return nullptr; } msg = q_dbus_message_new_signal(d_ptr->path.toUtf8(), d_ptr->interface.toUtf8(), @@ -203,7 +203,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB // not ok; q_dbus_message_unref(msg); *error = QDBusError(QDBusError::Failed, QLatin1String("Marshalling failed: ") + marshaller.errorString); - return 0; + return nullptr; } /* diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 806cf7b415..74e17ced77 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -138,7 +138,7 @@ static int registerComplexDBusType(const char *typeName) static void *construct(void *, const void *) { qFatal("Cannot construct placeholder type QDBusRawType"); - return 0; + return nullptr; } }; @@ -147,7 +147,7 @@ static int registerComplexDBusType(const char *typeName) QDBusRawTypeHandler::construct, sizeof(void *), QMetaType::MovableType, - 0); + nullptr); } Q_DBUS_EXPORT bool qt_dbus_metaobject_skip_annotations = false; @@ -544,9 +544,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) // put the metaobject together obj->d.data = uint_data; - obj->d.relatedMetaObjects = 0; - obj->d.static_metacall = 0; - obj->d.extradata = 0; + obj->d.relatedMetaObjects = nullptr; + obj->d.static_metacall = nullptr; + obj->d.extradata = nullptr; obj->d.stringdata = reinterpret_cast<const QByteArrayData *>(string_data); obj->d.superdata = &QDBusAbstractInterface::staticMetaObject; } @@ -587,7 +587,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con error = QDBusError(); QDBusIntrospection::Interfaces parsed = QDBusIntrospection::parseInterfaces(xml); - QDBusMetaObject *we = 0; + QDBusMetaObject *we = nullptr; QDBusIntrospection::Interfaces::ConstIterator it = parsed.constBegin(); QDBusIntrospection::Interfaces::ConstIterator end = parsed.constEnd(); for ( ; it != end; ++it) { @@ -621,7 +621,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con if (parsed.isEmpty()) { // object didn't return introspection we = new QDBusMetaObject; - QDBusMetaObjectGenerator generator(interface, 0); + QDBusMetaObjectGenerator generator(interface, nullptr); generator.write(we); we->cached = false; return we; @@ -651,7 +651,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con error = QDBusError(QDBusError::UnknownInterface, QLatin1String("Interface '%1' was not found") .arg(interface)); - return 0; + return nullptr; } QDBusMetaObject::QDBusMetaObject() @@ -670,7 +670,7 @@ const int *QDBusMetaObject::inputTypesForMethod(int id) const int handle = priv(d.data)->methodDBusData + id*intsPerMethod; return reinterpret_cast<const int*>(d.data + d.data[handle]); } - return 0; + return nullptr; } const int *QDBusMetaObject::outputTypesForMethod(int id) const @@ -680,7 +680,7 @@ const int *QDBusMetaObject::outputTypesForMethod(int id) const int handle = priv(d.data)->methodDBusData + id*intsPerMethod; return reinterpret_cast<const int*>(d.data + d.data[handle + 1]); } - return 0; + return nullptr; } int QDBusMetaObject::propertyMetaType(int id) const diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp index 58ce4f8930..e3804f74f8 100644 --- a/src/dbus/qdbusmetatype.cpp +++ b/src/dbus/qdbusmetatype.cpp @@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE class QDBusCustomTypeInfo { public: - QDBusCustomTypeInfo() : signature(), marshall(0), demarshall(0) + QDBusCustomTypeInfo() : signature(), marshall(nullptr), demarshall(nullptr) { } // Suggestion: @@ -78,7 +78,7 @@ public: }; template<typename T> -inline static void registerHelper(T * = 0) +inline static void registerHelper(T * = nullptr) { void (*mf)(QDBusArgument &, const T *) = qDBusMarshallHelper<T>; void (*df)(const QDBusArgument &, T *) = qDBusDemarshallHelper<T>; @@ -259,7 +259,7 @@ bool QDBusMetaType::marshall(QDBusArgument &arg, int id, const void *data) const QDBusCustomTypeInfo &info = (*ct).at(id); if (!info.marshall) { - mf = 0; // make gcc happy + mf = nullptr; // make gcc happy return false; } else mf = info.marshall; @@ -288,7 +288,7 @@ bool QDBusMetaType::demarshall(const QDBusArgument &arg, int id, void *data) const QDBusCustomTypeInfo &info = (*ct).at(id); if (!info.demarshall) { - df = 0; // make gcc happy + df = nullptr; // make gcc happy return false; } else df = info.demarshall; @@ -460,7 +460,7 @@ const char *QDBusMetaType::typeToSignature(int type) { QReadLocker locker(customTypesLock()); if (type >= ct->size()) - return 0; // type not registered with us + return nullptr; // type not registered with us const QDBusCustomTypeInfo &info = (*ct).at(type); @@ -468,7 +468,7 @@ const char *QDBusMetaType::typeToSignature(int type) return info.signature; if (!info.marshall) - return 0; // type not registered with us + return nullptr; // type not registered with us } // call to user code to construct the signature type diff --git a/src/dbus/qdbusmisc.cpp b/src/dbus/qdbusmisc.cpp index eb8f61c783..c321b7524d 100644 --- a/src/dbus/qdbusmisc.cpp +++ b/src/dbus/qdbusmisc.cpp @@ -62,7 +62,7 @@ bool qDBusCheckAsyncTag(const char *tag) return false; const char *p = strstr(tag, noReplyTag); - if (p != NULL && + if (p != nullptr && (p == tag || *(p-1) == ' ') && (p[sizeof noReplyTag - 1] == '\0' || p[sizeof noReplyTag - 1] == ' ')) return true; @@ -167,7 +167,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QVector<in if (id == 0) { errorMsg = QLatin1String("Unregistered output type in parameter list: ") + QLatin1String(type); return -1; - } else if (QDBusMetaType::typeToSignature(id) == 0) + } else if (QDBusMetaType::typeToSignature(id) == nullptr) return -1; metaTypes.append( id ); @@ -195,7 +195,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QVector<in if (id == QDBusMetaTypeId::message()) seenMessage = true; - else if (QDBusMetaType::typeToSignature(id) == 0) { + else if (QDBusMetaType::typeToSignature(id) == nullptr) { errorMsg = QLatin1String("Type not registered with QtDBus in parameter list: ") + QLatin1String(type); return -1; } diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 8e604d5a77..e55321f79c 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -182,7 +182,7 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb if (metaTypes.at(count) == QDBusMetaTypeId::message()) --count; - setMetaTypes(count, count ? metaTypes.constData() + 1 : 0); + setMetaTypes(count, count ? metaTypes.constData() + 1 : nullptr); return true; } @@ -469,10 +469,10 @@ QDBusPendingCall QDBusPendingCall::fromError(const QDBusError &error) */ QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg) { - QDBusPendingCallPrivate *d = 0; + QDBusPendingCallPrivate *d = nullptr; if (msg.type() == QDBusMessage::ErrorMessage || msg.type() == QDBusMessage::ReplyMessage) { - d = new QDBusPendingCallPrivate(QDBusMessage(), 0); + d = new QDBusPendingCallPrivate(QDBusMessage(), nullptr); d->replyMessage = msg; d->ref.storeRelaxed(1); } diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp index ec49bafb60..cf13a134c5 100644 --- a/src/dbus/qdbuspendingreply.cpp +++ b/src/dbus/qdbuspendingreply.cpp @@ -247,7 +247,7 @@ */ QDBusPendingReplyData::QDBusPendingReplyData() - : QDBusPendingCall(0) // initialize base class empty + : QDBusPendingCall(nullptr) // initialize base class empty { } @@ -262,7 +262,7 @@ void QDBusPendingReplyData::assign(const QDBusPendingCall &other) void QDBusPendingReplyData::assign(const QDBusMessage &message) { - d = new QDBusPendingCallPrivate(QDBusMessage(), 0); // drops the reference to the old one + d = new QDBusPendingCallPrivate(QDBusMessage(), nullptr); // drops the reference to the old one d->replyMessage = message; } diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp index cf1a70508c..cd7193e02f 100644 --- a/src/dbus/qdbusreply.cpp +++ b/src/dbus/qdbusreply.cpp @@ -202,7 +202,7 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data } const char *expectedSignature = QDBusMetaType::typeToSignature(data.userType()); - const char *receivedType = 0; + const char *receivedType = nullptr; QByteArray receivedSignature; if (reply.arguments().count() >= 1) { diff --git a/src/dbus/qdbusunixfiledescriptor.cpp b/src/dbus/qdbusunixfiledescriptor.cpp index 73d1db2680..87cabb93f6 100644 --- a/src/dbus/qdbusunixfiledescriptor.cpp +++ b/src/dbus/qdbusunixfiledescriptor.cpp @@ -135,7 +135,7 @@ QExplicitlySharedDataPointer<QDBusUnixFileDescriptorPrivate>::~QExplicitlyShared \sa fileDescriptor(), isValid() */ QDBusUnixFileDescriptor::QDBusUnixFileDescriptor() - : d(0) + : d(nullptr) { } @@ -153,7 +153,7 @@ QDBusUnixFileDescriptor::QDBusUnixFileDescriptor() \sa setFileDescriptor(), fileDescriptor() */ QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(int fileDescriptor) - : d(0) + : d(nullptr) { if (fileDescriptor != -1) setFileDescriptor(fileDescriptor); diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp index dc94897ac4..09311d1ad4 100644 --- a/src/dbus/qdbusutil.cpp +++ b/src/dbus/qdbusutil.cpp @@ -246,12 +246,12 @@ static const char fixedTypes[] = "ybnqiuxtdh"; static bool isBasicType(int c) { - return c != DBUS_TYPE_INVALID && strchr(basicTypes, c) != NULL; + return c != DBUS_TYPE_INVALID && strchr(basicTypes, c) != nullptr; } static bool isFixedType(int c) { - return c != DBUS_TYPE_INVALID && strchr(fixedTypes, c) != NULL; + return c != DBUS_TYPE_INVALID && strchr(fixedTypes, c) != nullptr; } // Returns a pointer to one-past-end of this type if it's valid; @@ -260,10 +260,10 @@ static const char *validateSingleType(const char *signature) { char c = *signature; if (c == DBUS_TYPE_INVALID) - return 0; + return nullptr; // is it one of the one-letter types? - if (strchr(oneLetterTypes, c) != NULL) + if (strchr(oneLetterTypes, c) != nullptr) return signature + 1; // is it an array? @@ -277,9 +277,9 @@ static const char *validateSingleType(const char *signature) // and a free value c = *++signature; if (!isBasicType(c)) - return 0; + return nullptr; signature = validateSingleType(signature + 1); - return signature && *signature == DBUS_DICT_ENTRY_END_CHAR ? signature + 1 : 0; + return signature && *signature == DBUS_DICT_ENTRY_END_CHAR ? signature + 1 : nullptr; } return validateSingleType(signature); @@ -291,14 +291,14 @@ static const char *validateSingleType(const char *signature) while (true) { signature = validateSingleType(signature); if (!signature) - return 0; + return nullptr; if (*signature == DBUS_STRUCT_END_CHAR) return signature + 1; } } // invalid/unknown type - return 0; + return nullptr; } /*! diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index db47a3abc1..7922d6fb06 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -478,15 +478,15 @@ Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins) Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories) Q_GLOBAL_STATIC(QList<QAccessible::ActivationObserver *>, qAccessibleActivationObservers) -QAccessible::UpdateHandler QAccessible::updateHandler = 0; -QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0; +QAccessible::UpdateHandler QAccessible::updateHandler = nullptr; +QAccessible::RootObjectHandler QAccessible::rootObjectHandler = nullptr; static bool cleanupAdded = false; static QPlatformAccessibility *platformAccessibility() { QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration(); - return pfIntegration ? pfIntegration->accessibility() : 0; + return pfIntegration ? pfIntegration->accessibility() : nullptr; } /*! @@ -673,7 +673,7 @@ void QAccessible::removeActivationObserver(ActivationObserver *observer) QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) { if (!object) - return 0; + return nullptr; if (Id id = QAccessibleCache::instance()->objectToId.value(object)) return QAccessibleCache::instance()->interfaceForId(id); @@ -696,7 +696,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) // Find a QAccessiblePlugin (factory) for the class name. If there's // no entry in the cache try to create it using the plugin loader. if (!qAccessiblePlugins()->contains(cn)) { - QAccessiblePlugin *factory = 0; // 0 means "no plugin found". This is cached as well. + QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well. const int index = loader()->indexOf(cn); if (index != -1) factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index)); @@ -724,7 +724,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) return appInterface; } - return 0; + return nullptr; } /*! @@ -1113,7 +1113,7 @@ QAccessibleInterface::relations(QAccessible::Relation /*match = QAccessible::All */ QAccessibleInterface *QAccessibleInterface::focusChild() const { - return 0; + return nullptr; } /*! @@ -1758,12 +1758,12 @@ QAccessibleTextSelectionEvent::~QAccessibleTextSelectionEvent() */ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const { - if (m_object == 0) + if (m_object == nullptr) return QAccessible::accessibleInterface(m_uniqueId); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object); if (!iface || !iface->isValid()) - return 0; + return nullptr; if (m_child >= 0) { QAccessibleInterface *child = iface->child(m_child); @@ -1791,7 +1791,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const */ QWindow *QAccessibleInterface::window() const { - return 0; + return nullptr; } /*! diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 2ef8502ad5..771cfda574 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -128,7 +128,7 @@ QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const if (childIface->isValid() && childIface->rect().contains(x,y)) return childIface; } - return 0; + return nullptr; } /*! @@ -152,7 +152,7 @@ QWindow *QAccessibleApplication::window() const { // an application can have several windows, and AFAIK we don't need // to notify about changes on the application. - return 0; + return nullptr; } // all toplevel windows except popups and the desktop @@ -190,7 +190,7 @@ int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) cons QAccessibleInterface *QAccessibleApplication::parent() const { - return 0; + return nullptr; } QAccessibleInterface *QAccessibleApplication::child(int index) const @@ -198,7 +198,7 @@ QAccessibleInterface *QAccessibleApplication::child(int index) const const QObjectList tlo(topLevelObjects()); if (index >= 0 && index < tlo.count()) return QAccessible::queryAccessibleInterface(tlo.at(index)); - return 0; + return nullptr; } @@ -207,7 +207,7 @@ QAccessibleInterface *QAccessibleApplication::focusChild() const { if (QWindow *window = QGuiApplication::focusWindow()) return window->accessibleRoot(); - return 0; + return nullptr; } /*! \reimp */ diff --git a/src/gui/accessible/qplatformaccessibility.cpp b/src/gui/accessible/qplatformaccessibility.cpp index 8c806d47b8..4813b83963 100644 --- a/src/gui/accessible/qplatformaccessibility.cpp +++ b/src/gui/accessible/qplatformaccessibility.cpp @@ -114,7 +114,7 @@ void QPlatformAccessibility::initialize() typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; const PluginKeyMap keyMap = bridgeloader()->keyMap(); - QAccessibleBridgePlugin *factory = 0; + QAccessibleBridgePlugin *factory = nullptr; int i = -1; const PluginKeyMapConstIterator cend = keyMap.constEnd(); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp index a5b6d8b95c..8afe77ed46 100644 --- a/src/gui/animation/qguivariantanimation.cpp +++ b/src/gui/animation/qguivariantanimation.cpp @@ -75,15 +75,15 @@ static void qUnregisterGuiGetInterpolator() { // casts required by Sun CC 5.5 qRegisterAnimationInterpolator<QColor>( - (QVariant (*)(const QColor &, const QColor &, qreal))0); + (QVariant (*)(const QColor &, const QColor &, qreal))nullptr); qRegisterAnimationInterpolator<QVector2D>( - (QVariant (*)(const QVector2D &, const QVector2D &, qreal))0); + (QVariant (*)(const QVector2D &, const QVector2D &, qreal))nullptr); qRegisterAnimationInterpolator<QVector3D>( - (QVariant (*)(const QVector3D &, const QVector3D &, qreal))0); + (QVariant (*)(const QVector3D &, const QVector3D &, qreal))nullptr); qRegisterAnimationInterpolator<QVector4D>( - (QVariant (*)(const QVector4D &, const QVector4D &, qreal))0); + (QVariant (*)(const QVector4D &, const QVector4D &, qreal))nullptr); qRegisterAnimationInterpolator<QQuaternion>( - (QVariant (*)(const QQuaternion &, const QQuaternion &, qreal))0); + (QVariant (*)(const QQuaternion &, const QQuaternion &, qreal))nullptr); } Q_DESTRUCTOR_FUNCTION(qUnregisterGuiGetInterpolator) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 7f8e072322..32b6131309 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -414,7 +414,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, *p++ = tmp >> 4; } if ((((c & 3) + 1) & 2) == 2) - d->getChar(0); // align on word boundary + d->getChar(nullptr); // align on word boundary x += c; } } else { // encoded mode @@ -494,7 +494,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, if (d->read((char *)p, b) != b) return false; if ((b & 1) == 1) - d->getChar(0); // align on word boundary + d->getChar(nullptr); // align on word boundary x += b; p += b; } diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 84e387e317..19be066d23 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -132,7 +132,7 @@ static void qt_cleanup_icon_cache() if Qt::AA_UseHighDpiPixmaps is not set this function returns 1.0 to keep non-hihdpi aware code working. */ -static qreal qt_effective_device_pixel_ratio(QWindow *window = 0) +static qreal qt_effective_device_pixel_ratio(QWindow *window = nullptr) { if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) return qreal(1.0); @@ -228,7 +228,7 @@ static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngi QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state) { - QPixmapIconEngineEntry *pe = 0; + QPixmapIconEngineEntry *pe = nullptr; for (int i = 0; i < pixmaps.count(); ++i) if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) { if (pe) @@ -674,7 +674,7 @@ QFactoryLoader *qt_iconEngineFactoryLoader() Constructs a null icon. */ QIcon::QIcon() noexcept - : d(0) + : d(nullptr) { } @@ -682,7 +682,7 @@ QIcon::QIcon() noexcept Constructs an icon from a \a pixmap. */ QIcon::QIcon(const QPixmap &pixmap) - :d(0) + :d(nullptr) { addPixmap(pixmap); } @@ -723,7 +723,7 @@ QIcon::QIcon(const QIcon &other) complete list of the supported file formats. */ QIcon::QIcon(const QString &fileName) - : d(0) + : d(nullptr) { addFile(fileName); } @@ -838,7 +838,7 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const { if (!d) return QPixmap(); - return pixmap(0, size, mode, state); + return pixmap(nullptr, size, mode, state); } /*! @@ -878,7 +878,7 @@ QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const { if (!d) return QSize(); - return actualSize(0, size, mode, state); + return actualSize(nullptr, size, mode, state); } /*! @@ -1008,7 +1008,7 @@ void QIcon::detach() if (d->engine->isNull()) { if (!d->ref.deref()) delete d; - d = 0; + d = nullptr; return; } else if (d->ref.loadRelaxed() != 1) { QIconPrivate *x = new QIconPrivate(d->engine->clone()); diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 27c82bc09f..e67b387981 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -714,7 +714,7 @@ QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QThemeIconInfo &in // Find the minimum distance icon int minimalSize = INT_MAX; - QIconLoaderEngineEntry *closestMatch = 0; + QIconLoaderEngineEntry *closestMatch = nullptr; for (int i = 0; i < numEntries; ++i) { QIconLoaderEngineEntry *entry = info.entries.at(i); int distance = directorySizeDistance(entry->dir, iconsize, scale); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 869e206524..99d64737c5 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE static inline bool isLocked(QImageData *data) { - return data != 0 && data->is_locked; + return data != nullptr && data->is_locked; } #if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) @@ -99,15 +99,15 @@ static int next_qimage_serial_number() } QImageData::QImageData() - : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(0), + : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(nullptr), format(QImage::Format_ARGB32), bytes_per_line(0), ser_no(next_qimage_serial_number()), detach_no(0), dpmx(qt_defaultDpiX() * 100 / qreal(2.54)), dpmy(qt_defaultDpiY() * 100 / qreal(2.54)), offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false), - is_cached(false), is_locked(false), cleanupFunction(0), cleanupInfo(0), - paintEngine(0) + is_cached(false), is_locked(false), cleanupFunction(nullptr), cleanupInfo(nullptr), + paintEngine(nullptr) { } @@ -170,7 +170,7 @@ QImageData::~QImageData() delete paintEngine; if (data && own_data) free(data); - data = 0; + data = nullptr; } #if defined(_M_ARM) @@ -746,7 +746,7 @@ bool QImageData::checkForAlphaPixels() const QImage::QImage() noexcept : QPaintDevice() { - d = 0; + d = nullptr; } /*! @@ -955,7 +955,7 @@ QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Forma QImage::QImage(const QString &fileName, const char *format) : QPaintDevice() { - d = 0; + d = nullptr; load(fileName, format); } @@ -981,10 +981,10 @@ extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *so QImage::QImage(const char * const xpm[]) : QPaintDevice() { - d = 0; + d = nullptr; if (!xpm) return; - if (!qt_read_xpm_image_or_array(0, xpm, *this)) + if (!qt_read_xpm_image_or_array(nullptr, xpm, *this)) // Issue: Warning because the constructor may be ambigious qWarning("QImage::QImage(), XPM is not supported"); } @@ -1003,7 +1003,7 @@ QImage::QImage(const QImage &image) : QPaintDevice() { if (image.paintingActive() || isLocked(image.d)) { - d = 0; + d = nullptr; image.copy().swap(*this); } else { d = image.d; @@ -1593,13 +1593,13 @@ void QImage::setColor(int i, QRgb c) uchar *QImage::scanLine(int i) { if (!d) - return 0; + return nullptr; detach(); // In case detach() ran out of memory if (!d) - return 0; + return nullptr; return d->data + i * d->bytes_per_line; } @@ -1610,7 +1610,7 @@ uchar *QImage::scanLine(int i) const uchar *QImage::scanLine(int i) const { if (!d) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < height()); return d->data + i * d->bytes_per_line; @@ -1633,7 +1633,7 @@ const uchar *QImage::scanLine(int i) const const uchar *QImage::constScanLine(int i) const { if (!d) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < height()); return d->data + i * d->bytes_per_line; @@ -1653,12 +1653,12 @@ const uchar *QImage::constScanLine(int i) const uchar *QImage::bits() { if (!d) - return 0; + return nullptr; detach(); // In case detach ran out of memory... if (!d) - return 0; + return nullptr; return d->data; } @@ -1672,7 +1672,7 @@ uchar *QImage::bits() */ const uchar *QImage::bits() const { - return d ? d->data : 0; + return d ? d->data : nullptr; } @@ -1688,7 +1688,7 @@ const uchar *QImage::bits() const */ const uchar *QImage::constBits() const { - return d ? d->data : 0; + return d ? d->data : nullptr; } /*! @@ -3027,11 +3027,11 @@ QImage QImage::createHeuristicMask(bool clipTight) const while(!done) { done = true; ypn = m.scanLine(0); - ypc = 0; + ypc = nullptr; for (y = 0; y < h; y++) { ypp = ypc; ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); + ypn = (y == h-1) ? nullptr : m.scanLine(y+1); const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { // slowness here - it's possible to do six of these tests @@ -3053,11 +3053,11 @@ QImage QImage::createHeuristicMask(bool clipTight) const if (!clipTight) { ypn = m.scanLine(0); - ypc = 0; + ypc = nullptr; for (y = 0; y < h; y++) { ypp = ypc; ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); + ypn = (y == h-1) ? nullptr : m.scanLine(y+1); const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { if ((*p & 0x00ffffff) != background) { @@ -4122,7 +4122,7 @@ void QImage::setText(const QString &key, const QString &value) QPaintEngine *QImage::paintEngine() const { if (!d) - return 0; + return nullptr; if (!d->paintEngine) { QPaintDevice *paintDevice = const_cast<QImage *>(this); diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 8f33a13b95..27088698ec 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -198,7 +198,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio store = destLayout->storeFromRGB32; } QDitherInfo dither; - QDitherInfo *ditherPtr = 0; + QDitherInfo *ditherPtr = nullptr; if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) ditherPtr = &dither; @@ -212,8 +212,8 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio buffer = reinterpret_cast<uint *>(destData) + x; else l = qMin(l, BufferSize); - const uint *ptr = fetch(buffer, srcData, x, l, 0, ditherPtr); - store(destData, ptr, x, l, 0, ditherPtr); + const uint *ptr = fetch(buffer, srcData, x, l, nullptr, ditherPtr); + store(destData, ptr, x, l, nullptr, ditherPtr); x += l; } srcData += src->bytes_per_line; @@ -314,7 +314,7 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im store = destLayout->storeFromRGB32; } QDitherInfo dither; - QDitherInfo *ditherPtr = 0; + QDitherInfo *ditherPtr = nullptr; if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) ditherPtr = &dither; diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp index a4f927a462..0c9083a16e 100644 --- a/src/gui/image/qimageiohandler.cpp +++ b/src/gui/image/qimageiohandler.cpp @@ -288,7 +288,7 @@ public: QImageIOHandlerPrivate::QImageIOHandlerPrivate(QImageIOHandler *q) { - device = 0; + device = nullptr; q_ptr = q; } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index dff24b449a..5e3b608d20 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -179,10 +179,10 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, bool ignoresFormatAndExtension) { if (!autoDetectImageFormat && format.isEmpty()) - return 0; + return nullptr; QByteArray form = format.toLower(); - QImageIOHandler *handler = 0; + QImageIOHandler *handler = nullptr; QByteArray suffix; #ifndef QT_NO_IMAGEFORMATPLUGIN @@ -450,7 +450,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, qDebug("QImageReader::createReadHandler: no handlers found. giving up."); #endif // no handler: give up. - return 0; + return nullptr; } handler->setDevice(device); @@ -500,9 +500,9 @@ public: QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq) : autoDetectImageFormat(true), ignoresFormatAndExtension(false) { - device = 0; + device = nullptr; deleteDevice = false; - handler = 0; + handler = nullptr; quality = -1; imageReaderError = QImageReader::UnknownError; autoTransform = UsePluginDefault; @@ -571,7 +571,7 @@ bool QImageReaderPrivate::initHandler() } // assign a handler - if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == 0) { + if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == nullptr) { imageReaderError = QImageReader::UnsupportedFormatError; errorString = QImageReader::tr("Unsupported image format"); return false; diff --git a/src/gui/image/qimagereaderwriterhelpers.cpp b/src/gui/image/qimagereaderwriterhelpers.cpp index a5b7fb6449..dd56d887a7 100644 --- a/src/gui/image/qimagereaderwriterhelpers.cpp +++ b/src/gui/image/qimagereaderwriterhelpers.cpp @@ -63,7 +63,7 @@ static void appendImagePluginFormats(QFactoryLoader *loader, const PluginKeyMap keyMap = loader->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); int i = -1; - QImageIOPlugin *plugin = 0; + QImageIOPlugin *plugin = nullptr; result->reserve(result->size() + keyMap.size()); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { if (it.key() != i) { @@ -71,7 +71,7 @@ static void appendImagePluginFormats(QFactoryLoader *loader, plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i)); } const QByteArray key = it.value().toLatin1(); - if (plugin && (plugin->capabilities(0, key) & cap) != 0) + if (plugin && (plugin->capabilities(nullptr, key) & cap) != 0) result->append(key); } } @@ -92,7 +92,7 @@ static void appendImagePluginMimeTypes(QFactoryLoader *loader, const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) { const QByteArray key = keys.at(k).toString().toLatin1(); - if (plugin && (plugin->capabilities(0, key) & cap) != 0) { + if (plugin && (plugin->capabilities(nullptr, key) & cap) != 0) { result->append(mimeTypes.at(k).toString().toLatin1()); if (resultKeys) resultKeys->append(key); diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index ec66588ddf..9dcc955fe2 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -139,7 +139,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, { QByteArray form = format.toLower(); QByteArray suffix; - QImageIOHandler *handler = 0; + QImageIOHandler *handler = nullptr; #ifndef QT_NO_IMAGEFORMATPLUGIN typedef QMultiMap<int, QString> PluginKeyMap; @@ -226,7 +226,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, #endif // QT_NO_IMAGEFORMATPLUGIN if (!handler) - return 0; + return nullptr; handler->setDevice(device); if (!testFormat.isEmpty()) @@ -270,9 +270,9 @@ public: */ QImageWriterPrivate::QImageWriterPrivate(QImageWriter *qq) { - device = 0; + device = nullptr; deleteDevice = false; - handler = 0; + handler = nullptr; quality = -1; compression = -1; gamma = 0.0; @@ -304,7 +304,7 @@ bool QImageWriterPrivate::canWriteHelper() errorString = QImageWriter::tr("Device not writable"); return false; } - if (!handler && (handler = createWriteHandlerHelper(device, format)) == 0) { + if (!handler && (handler = createWriteHandlerHelper(device, format)) == nullptr) { imageWriterError = QImageWriter::UnsupportedFormatError; errorString = QImageWriter::tr("Unsupported image format"); return false; @@ -403,7 +403,7 @@ void QImageWriter::setDevice(QIODevice *device) d->device = device; d->deleteDevice = false; delete d->handler; - d->handler = 0; + d->handler = nullptr; } /*! @@ -823,7 +823,7 @@ QString QImageWriter::errorString() const */ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const { - if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == 0) { + if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == nullptr) { d->imageWriterError = QImageWriter::UnsupportedFormatError; d->errorString = QImageWriter::tr("Unsupported image format"); return false; diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 25fce050a1..79019d0fdf 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -272,7 +272,7 @@ public: /*! \internal */ QMoviePrivate::QMoviePrivate(QMovie *qq) - : reader(0), speed(100), movieState(QMovie::NotRunning), + : reader(nullptr), speed(100), movieState(QMovie::NotRunning), currentFrameNumber(-1), nextFrameNumber(0), greatestFrameNumber(-1), nextDelay(0), playCounter(-1), cacheMode(QMovie::CacheNone), haveReadAll(false), isFirstIteration(true) diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp index 6a87a01a87..e89cac452a 100644 --- a/src/gui/image/qpaintengine_pic.cpp +++ b/src/gui/image/qpaintengine_pic.cpp @@ -73,14 +73,14 @@ QPicturePaintEngine::QPicturePaintEngine() : QPaintEngine(*(new QPicturePaintEnginePrivate), AllFeatures) { Q_D(QPicturePaintEngine); - d->pt = 0; + d->pt = nullptr; } QPicturePaintEngine::QPicturePaintEngine(QPaintEnginePrivate &dptr) : QPaintEngine(dptr, AllFeatures) { Q_D(QPicturePaintEngine); - d->pt = 0; + d->pt = nullptr; } QPicturePaintEngine::~QPicturePaintEngine() @@ -484,7 +484,7 @@ void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) #endif const QTextItemInt &si = static_cast<const QTextItemInt &>(ti); - if (si.chars == 0) + if (si.chars == nullptr) QPaintEngine::drawTextItem(p, ti); // Draw as path if (d->pic_d->formatMajor >= 9) { diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 978a07b9f9..3a32cc7f15 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -458,7 +458,7 @@ public: QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); } void setDpiX(int dpi) { dpi_x = dpi; } void setDpiY(int dpi) { dpi_y = dpi; } - QPaintEngine *paintEngine() const override { return 0; } + QPaintEngine *paintEngine() const override { return nullptr; } int metric(PaintDeviceMetric m) const override { switch(m) { @@ -709,11 +709,11 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) QFontMetrics fm(fnt); QPointF pt(p.x(), p.y() - fm.ascent()); - qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0, - str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/nullptr, + str, /*brect=*/nullptr, /*tabstops=*/0, /*...*/nullptr, /*tabarraylen=*/0, painter); } else { - qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0, - str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/nullptr, + str, /*brect=*/nullptr, /*tabstops=*/0, /*...*/nullptr, /*tabarraylen=*/0, painter); } break; @@ -1369,11 +1369,11 @@ QPictureIO::QPictureIO(const QString &fileName, const char* format) void QPictureIO::init() { d = new QPictureIOData(); - d->parameters = 0; + d->parameters = nullptr; d->quality = -1; // default quality of the current format d->gamma=0.0f; d->iostat = 0; - d->iodev = 0; + d->iodev = nullptr; } /*! @@ -1467,7 +1467,7 @@ static QPictureHandler *get_picture_handler(const char *format) return list->at(i); } } - return 0; // no such handler + return nullptr; // no such handler } @@ -1887,7 +1887,7 @@ bool QPictureIO::read() if (picture_format.isEmpty()) { if (file.isOpen()) { // unknown format file.close(); - d->iodev = 0; + d->iodev = nullptr; } return false; } @@ -1913,7 +1913,7 @@ bool QPictureIO::read() if (file.isOpen()) { // picture was read using file file.close(); - d->iodev = 0; + d->iodev = nullptr; } return d->iostat == 0; // picture successfully read? } @@ -1957,7 +1957,7 @@ bool QPictureIO::write() (*h->write_picture)(this); if (file.isOpen()) { // picture was written using file file.close(); - d->iodev = 0; + d->iodev = nullptr; } return d->iostat == 0; // picture successfully written? } diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index b6e41f16a5..3fce64cb20 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -94,7 +94,7 @@ void QPixmap::doInit(int w, int h, int type) if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType) data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type); else - data = 0; + data = nullptr; } /*! @@ -780,7 +780,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) { - if (len == 0 || buf == 0) { + if (len == 0 || buf == nullptr) { data.reset(); return false; } @@ -1455,7 +1455,7 @@ int QPixmap::metric(PaintDeviceMetric metric) const */ QPaintEngine *QPixmap::paintEngine() const { - return data ? data->paintEngine() : 0; + return data ? data->paintEngine() : nullptr; } /*! diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 649a25250c..aeed1e3b34 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -92,8 +92,8 @@ void QBlittablePlatformPixmap::setBlittable(QBlittable *blittable) void QBlittablePlatformPixmap::resize(int width, int height) { - m_blittable.reset(0); - m_engine.reset(0); + m_blittable.reset(nullptr); + m_engine.reset(nullptr); d = QGuiApplication::primaryScreen()->depth(); w = width; h = height; @@ -145,8 +145,8 @@ void QBlittablePlatformPixmap::fill(const QColor &color) // if we could just change the format, e.g. when going from // RGB32 -> ARGB8888. if (color.alpha() != 255 && !hasAlphaChannel()) { - m_blittable.reset(0); - m_engine.reset(0); + m_blittable.reset(nullptr); + m_engine.reset(nullptr); m_alpha = true; } diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 483d6d79a2..9709df9e0c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -126,7 +126,7 @@ static inline bool qt_pixmapcache_thread_test() /*! Constructs an empty Key object. */ -QPixmapCache::Key::Key() : d(0) +QPixmapCache::Key::Key() : d(nullptr) { } @@ -259,9 +259,9 @@ uint qHash(const QPixmapCache::Key &k) } QPMCache::QPMCache() - : QObject(0), + : QObject(nullptr), QCache<QPixmapCache::Key, QPixmapCacheEntry>(cache_limit_default), - keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) + keyArray(nullptr), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) { } QPMCache::~QPMCache() @@ -325,7 +325,7 @@ QPixmap *QPMCache::object(const QString &key) const QPixmapCache::Key cacheKey = cacheKeys.value(key); if (!cacheKey.d || !cacheKey.d->isValid) { const_cast<QPMCache *>(this)->cacheKeys.remove(key); - return 0; + return nullptr; } QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(cacheKey); //We didn't find the pixmap in the cache, the key is not valid anymore @@ -453,7 +453,7 @@ void QPMCache::releaseKey(const QPixmapCache::Key &key) void QPMCache::clear() { free(keyArray); - keyArray = 0; + keyArray = nullptr; freeKey = 0; keyArraySize = 0; //Mark all keys as invalid @@ -539,7 +539,7 @@ bool QPixmapCache::find(const QString &key, QPixmap *pixmap) QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) *pixmap = *ptr; - return ptr != 0; + return ptr != nullptr; } /*! @@ -561,7 +561,7 @@ bool QPixmapCache::find(const Key &key, QPixmap *pixmap) QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) *pixmap = *ptr; - return ptr != 0; + return ptr != nullptr; } /*! diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp index a2e01147c4..493f55514e 100644 --- a/src/gui/image/qplatformpixmap.cpp +++ b/src/gui/image/qplatformpixmap.cpp @@ -266,7 +266,7 @@ QImage QPlatformPixmap::toImage(const QRect &rect) const QImage* QPlatformPixmap::buffer() { - return 0; + return nullptr; } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index d6caf6773a..251f09fe52 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -109,7 +109,7 @@ public: }; QPngHandlerPrivate(QPngHandler *qq) - : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq) + : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(nullptr), info_ptr(nullptr), end_info(nullptr), state(Ready), q(qq) { } float gamma; @@ -134,18 +134,18 @@ public: struct AllocatedMemoryPointers { AllocatedMemoryPointers() - : row_pointers(0), accRow(0), inRow(0), outRow(0) + : row_pointers(nullptr), accRow(nullptr), inRow(nullptr), outRow(nullptr) { } void deallocate() { delete [] row_pointers; - row_pointers = 0; + row_pointers = nullptr; delete [] accRow; - accRow = 0; + accRow = nullptr; delete [] inRow; - inRow = 0; + inRow = nullptr; delete [] outRow; - outRow = 0; + outRow = nullptr; } png_byte **row_pointers; @@ -245,13 +245,13 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal png_uint_32 height = 0; int bit_depth = 0; int color_type = 0; - png_bytep trans_alpha = 0; - png_color_16p trans_color_p = 0; + png_bytep trans_alpha = nullptr; + png_color_16p trans_color_p = nullptr; int num_trans; - png_colorp palette = 0; + png_colorp palette = nullptr; int num_palette; int interlace_method = PNG_INTERLACE_LAST; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, nullptr, nullptr); png_set_interlace_handling(png_ptr); if (color_type == PNG_COLOR_TYPE_GRAY) { @@ -343,7 +343,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal if (bit_depth != 1) png_set_packing(png_ptr); png_read_update_info(png_ptr, info_ptr); - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); QImage::Format format = bit_depth == 1 ? QImage::Format_Mono : QImage::Format_Indexed8; if (image.size() != QSize(width, height) || image.format() != format) { image = QImage(width, height, format); @@ -452,7 +452,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i int bit_depth = 0; int color_type = 0; int unit_type = PNG_OFFSET_PIXEL; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -478,7 +478,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i amp.accRow[i] = rval*amp.inRow[i]; // Accumulate the next input rows for (rval = iysz-rval; rval > 0; rval-=oysz) { - png_read_row(png_ptr, amp.inRow, NULL); + png_read_row(png_ptr, amp.inRow, nullptr); quint32 fact = qMin(oysz, quint32(rval)); for (quint32 i=0; i < ibw; i++) amp.accRow[i] += fact*amp.inRow[i]; @@ -558,11 +558,11 @@ void QPngHandlerPrivate::readPngTexts(png_info *info) bool QPngHandlerPrivate::readPngHeader() { state = Error; - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,nullptr,nullptr,nullptr); if (!png_ptr) return false; - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); + png_set_error_fn(png_ptr, nullptr, nullptr, qt_png_warning); #if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) // Trade off a little bit of memory for better compatibility with existing images @@ -572,21 +572,21 @@ bool QPngHandlerPrivate::readPngHeader() info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_read_struct(&png_ptr, 0, 0); - png_ptr = 0; + png_destroy_read_struct(&png_ptr, nullptr, nullptr); + png_ptr = nullptr; return false; } end_info = png_create_info_struct(png_ptr); if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - png_ptr = 0; + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_ptr = nullptr; return false; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; return false; } @@ -670,7 +670,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Error; return false; @@ -689,7 +689,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (outImage->isNull()) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Error; return false; @@ -706,7 +706,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) int bit_depth = 0; int color_type = 0; int unit_type = PNG_OFFSET_PIXEL; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -747,7 +747,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) outImage->setText(readTexts.at(i), readTexts.at(i+1)); png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Ready; @@ -767,7 +767,7 @@ QImage::Format QPngHandlerPrivate::readImageFormat() int bit_depth = 0, color_type = 0; png_colorp palette; int num_palette; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); if (color_type == PNG_COLOR_TYPE_GRAY) { // Black & White or grayscale if (bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1) { @@ -910,16 +910,16 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const png_structp png_ptr; png_infop info_ptr; - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,nullptr,nullptr,nullptr); if (!png_ptr) { return false; } - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); + png_set_error_fn(png_ptr, nullptr, nullptr, qt_png_warning); info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_write_struct(&png_ptr, 0); + png_destroy_write_struct(&png_ptr, nullptr); return false; } @@ -1022,7 +1022,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const png_set_PLTE(png_ptr, info_ptr, palette, num_palette); if (num_trans) { - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, 0); + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, nullptr); } } diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index cf105b250a..f9424b62bb 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1175,7 +1175,7 @@ QXpmHandler::QXpmHandler() bool QXpmHandler::readHeader() { state = Error; - if (!read_xpm_header(device(), 0, index, buffer, &cpp, &ncols, &width, &height)) + if (!read_xpm_header(device(), nullptr, index, buffer, &cpp, &ncols, &width, &height)) return false; state = ReadHeader; return true; @@ -1191,7 +1191,7 @@ bool QXpmHandler::readImage(QImage *image) return false; } - if (!read_xpm_body(device(), 0, index, buffer, cpp, ncols, width, height, *image)) { + if (!read_xpm_body(device(), nullptr, index, buffer, cpp, ncols, width, height, *image)) { state = Error; return false; } diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 2390c62b9f..2998808b54 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -130,7 +130,7 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, } if (item) { - if (item->d_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { item->d_func()->setParentAndModel(q, model); } else { qWarning("QStandardItem::setChild: Ignoring duplicate insertion of item %p", @@ -139,7 +139,7 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, } } if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; children.replace(index, item); if (item) @@ -412,7 +412,7 @@ void QStandardItemPrivate::setModel(QStandardItemModel *mod) */ QStandardItemModelPrivate::QStandardItemModelPrivate() : root(new QStandardItem), - itemPrototype(0), + itemPrototype(nullptr), sortRole(Qt::DisplayRole) { root->setFlags(Qt::ItemIsDropEnabled); @@ -510,12 +510,12 @@ bool QStandardItemPrivate::insertRows(int row, int count, const QList<QStandardI for (int i = 0; i < limit; ++i) { QStandardItem *item = items.at(i); if (item) { - if (item->d_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { item->d_func()->setParentAndModel(q, model); } else { qWarning("QStandardItem::insertRows: Ignoring duplicate insertion of item %p", item); - item = 0; + item = nullptr; } } children.replace(index, item); @@ -555,12 +555,12 @@ bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QSta for (int i = 0; i < limit; ++i) { QStandardItem *item = items.at(i); if (item) { - if (item->d_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { item->d_func()->setParentAndModel(q, model); } else { qWarning("QStandardItem::insertColumns: Ignoring duplicate insertion of item %p", item); - item = 0; + item = nullptr; } } int r = i / count; @@ -583,7 +583,7 @@ void QStandardItemModelPrivate::itemChanged(QStandardItem *item, const QVector<i { Q_Q(QStandardItemModel); Q_ASSERT(item); - if (item->d_func()->parent == 0) { + if (item->d_func()->parent == nullptr) { // Header item int idx = columnHeaderItems.indexOf(item); if (idx != -1) { @@ -679,7 +679,7 @@ void QStandardItemModelPrivate::rowsRemoved(QStandardItem *parent, for (int i = row; i < row + count; ++i) { QStandardItem *oldItem = rowHeaderItems.at(i); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } rowHeaderItems.remove(row, count); @@ -698,7 +698,7 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent, for (int i = column; i < column + count; ++i) { QStandardItem *oldItem = columnHeaderItems.at(i); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } columnHeaderItems.remove(column, count); @@ -870,7 +870,7 @@ QStandardItem::~QStandardItem() Q_D(QStandardItem); for (QStandardItem *child : qAsConst(d->children)) { if (child) - child->d_func()->setModel(0); + child->d_func()->setModel(nullptr); delete child; } d->children.clear(); @@ -890,7 +890,7 @@ QStandardItem *QStandardItem::parent() const Q_D(const QStandardItem); if (!d->model || (d->model->d_func()->root.data() != d->parent)) return d->parent; - return 0; + return nullptr; } /*! @@ -1794,7 +1794,7 @@ void QStandardItem::removeRows(int row, int count) for (int j = i; j < n+i; ++j) { QStandardItem *oldItem = d->children.at(j); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } d->children.remove(qMax(i, 0), n); @@ -1821,7 +1821,7 @@ void QStandardItem::removeColumns(int column, int count) for (int j=i; j<i+count; ++j) { QStandardItem *oldItem = d->children.at(j); if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; } d->children.remove(i, count); @@ -1874,7 +1874,7 @@ QStandardItem *QStandardItem::child(int row, int column) const Q_D(const QStandardItem); int index = d->childIndex(row, column); if (index == -1) - return 0; + return nullptr; return d->children.at(index); } @@ -1891,12 +1891,12 @@ QStandardItem *QStandardItem::child(int row, int column) const QStandardItem *QStandardItem::takeChild(int row, int column) { Q_D(QStandardItem); - QStandardItem *item = 0; + QStandardItem *item = nullptr; int index = d->childIndex(row, column); if (index != -1) { item = d->children.at(index); if (item) - item->d_func()->setParentAndModel(0, 0); + item->d_func()->setParentAndModel(nullptr, nullptr); d->children.replace(index, 0); } return item; @@ -1925,7 +1925,7 @@ QList<QStandardItem*> QStandardItem::takeRow(int row) for (int column = 0; column < col_count; ++column) { QStandardItem *ch = d->children.at(index + column); if (ch) - ch->d_func()->setParentAndModel(0, 0); + ch->d_func()->setParentAndModel(nullptr, nullptr); items.append(ch); } d->children.remove(index, col_count); @@ -1958,7 +1958,7 @@ QList<QStandardItem*> QStandardItem::takeColumn(int column) int index = d->childIndex(row, column); QStandardItem *ch = d->children.at(index); if (ch) - ch->d_func()->setParentAndModel(0, 0); + ch->d_func()->setParentAndModel(nullptr, nullptr); d->children.remove(index); items.prepend(ch); } @@ -2291,13 +2291,13 @@ QStandardItem *QStandardItemModel::itemFromIndex(const QModelIndex &index) const { Q_D(const QStandardItemModel); if ((index.row() < 0) || (index.column() < 0) || (index.model() != this)) - return 0; + return nullptr; QStandardItem *parent = static_cast<QStandardItem*>(index.internalPointer()); - if (parent == 0) - return 0; + if (parent == nullptr) + return nullptr; QStandardItem *item = parent->child(index.row(), index.column()); // lazy part - if (item == 0) { + if (item == nullptr) { item = d->createItem(); parent->d_func()->setChild(index.row(), index.column(), item); } @@ -2432,7 +2432,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item return; if (item) { - if (item->model() == 0) { + if (item->model() == nullptr) { item->d_func()->setModel(this); } else { qWarning("QStandardItem::setHorizontalHeaderItem: Ignoring duplicate insertion of item %p", @@ -2442,7 +2442,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item } if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; d->columnHeaderItems.replace(column, item); @@ -2461,7 +2461,7 @@ QStandardItem *QStandardItemModel::horizontalHeaderItem(int column) const { Q_D(const QStandardItemModel); if ((column < 0) || (column >= columnCount())) - return 0; + return nullptr; return d->columnHeaderItems.at(column); } @@ -2488,7 +2488,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item) return; if (item) { - if (item->model() == 0) { + if (item->model() == nullptr) { item->d_func()->setModel(this); } else { qWarning("QStandardItem::setVerticalHeaderItem: Ignoring duplicate insertion of item %p", @@ -2498,7 +2498,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item) } if (oldItem) - oldItem->d_func()->setModel(0); + oldItem->d_func()->setModel(nullptr); delete oldItem; d->rowHeaderItems.replace(row, item); @@ -2517,7 +2517,7 @@ QStandardItem *QStandardItemModel::verticalHeaderItem(int row) const { Q_D(const QStandardItemModel); if ((row < 0) || (row >= rowCount())) - return 0; + return nullptr; return d->rowHeaderItems.at(row); } @@ -2757,10 +2757,10 @@ QStandardItem *QStandardItemModel::takeHorizontalHeaderItem(int column) { Q_D(QStandardItemModel); if ((column < 0) || (column >= columnCount())) - return 0; + return nullptr; QStandardItem *headerItem = d->columnHeaderItems.at(column); if (headerItem) { - headerItem->d_func()->setParentAndModel(0, 0); + headerItem->d_func()->setParentAndModel(nullptr, nullptr); d->columnHeaderItems.replace(column, 0); } return headerItem; @@ -2779,10 +2779,10 @@ QStandardItem *QStandardItemModel::takeVerticalHeaderItem(int row) { Q_D(QStandardItemModel); if ((row < 0) || (row >= rowCount())) - return 0; + return nullptr; QStandardItem *headerItem = d->rowHeaderItems.at(row); if (headerItem) { - headerItem->d_func()->setParentAndModel(0, 0); + headerItem->d_func()->setParentAndModel(nullptr, nullptr); d->rowHeaderItems.replace(row, 0); } return headerItem; @@ -2876,7 +2876,7 @@ QVariant QStandardItemModel::headerData(int section, Qt::Orientation orientation || ((orientation == Qt::Vertical) && (section >= rowCount()))) { return QVariant(); } - QStandardItem *headerItem = 0; + QStandardItem *headerItem = nullptr; if (orientation == Qt::Horizontal) headerItem = d->columnHeaderItems.at(section); else if (orientation == Qt::Vertical) @@ -2902,7 +2902,7 @@ QModelIndex QStandardItemModel::index(int row, int column, const QModelIndex &pa { Q_D(const QStandardItemModel); QStandardItem *parentItem = d->itemFromIndex(parent); - if ((parentItem == 0) + if ((parentItem == nullptr) || (row < 0) || (column < 0) || (row >= parentItem->rowCount()) @@ -2919,7 +2919,7 @@ bool QStandardItemModel::insertColumns(int column, int count, const QModelIndex { Q_D(QStandardItemModel); QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); - if (item == 0) + if (item == nullptr) return false; return item->d_func()->insertColumns(column, count, QList<QStandardItem*>()); } @@ -2931,7 +2931,7 @@ bool QStandardItemModel::insertRows(int row, int count, const QModelIndex &paren { Q_D(QStandardItemModel); QStandardItem *item = parent.isValid() ? itemFromIndex(parent) : d->root.data(); - if (item == 0) + if (item == nullptr) return false; return item->d_func()->insertRows(row, count, QList<QStandardItem*>()); } @@ -2967,7 +2967,7 @@ bool QStandardItemModel::removeColumns(int column, int count, const QModelIndex { Q_D(QStandardItemModel); QStandardItem *item = d->itemFromIndex(parent); - if ((item == 0) || (count < 1) || (column < 0) || ((column + count) > item->columnCount())) + if ((item == nullptr) || (count < 1) || (column < 0) || ((column + count) > item->columnCount())) return false; item->removeColumns(column, count); return true; @@ -2980,7 +2980,7 @@ bool QStandardItemModel::removeRows(int row, int count, const QModelIndex &paren { Q_D(QStandardItemModel); QStandardItem *item = d->itemFromIndex(parent); - if ((item == 0) || (count < 1) || (row < 0) || ((row + count) > item->rowCount())) + if ((item == nullptr) || (count < 1) || (row < 0) || ((row + count) > item->rowCount())) return false; item->removeRows(row, count); return true; @@ -3004,7 +3004,7 @@ bool QStandardItemModel::setData(const QModelIndex &index, const QVariant &value if (!index.isValid()) return false; QStandardItem *item = itemFromIndex(index); - if (item == 0) + if (item == nullptr) return false; item->setData(value, role); return true; @@ -3047,17 +3047,17 @@ bool QStandardItemModel::setHeaderData(int section, Qt::Orientation orientation, || ((orientation == Qt::Vertical) && (section >= rowCount()))) { return false; } - QStandardItem *headerItem = 0; + QStandardItem *headerItem = nullptr; if (orientation == Qt::Horizontal) { headerItem = d->columnHeaderItems.at(section); - if (headerItem == 0) { + if (headerItem == nullptr) { headerItem = d->createItem(); headerItem->d_func()->setModel(this); d->columnHeaderItems.replace(section, headerItem); } } else if (orientation == Qt::Vertical) { headerItem = d->rowHeaderItems.at(section); - if (headerItem == 0) { + if (headerItem == nullptr) { headerItem = d->createItem(); headerItem->d_func()->setModel(this); d->rowHeaderItems.replace(section, headerItem); @@ -3076,7 +3076,7 @@ bool QStandardItemModel::setHeaderData(int section, Qt::Orientation orientation, bool QStandardItemModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) { QStandardItem *item = itemFromIndex(index); - if (item == 0) + if (item == nullptr) return false; item->d_func()->setItemData(roles); return true; @@ -3106,7 +3106,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const { QMimeData *data = QAbstractItemModel::mimeData(indexes); if(!data) - return 0; + return nullptr; const QString format = qStandardItemModelDataListMimeType(); if (!mimeTypes().contains(format)) @@ -3124,7 +3124,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const stack.push(item); } else { qWarning("QStandardItemModel::mimeData: No item associated with invalid index"); - return 0; + return nullptr; } } diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 267c079ad9..db22ef2486 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -461,7 +461,7 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode) const QMimeData* QClipboard::mimeData(Mode mode) const { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - if (!clipboard->supportsMode(mode)) return 0; + if (!clipboard->supportsMode(mode)) return nullptr; return clipboard->mimeData(mode); } @@ -488,7 +488,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode) { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); if (!clipboard->supportsMode(mode)) { - if (src != 0) { + if (src != nullptr) { qDebug("Data set on unsupported clipboard mode. QMimeData object will be deleted."); src->deleteLater(); } @@ -512,7 +512,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode) */ void QClipboard::clear(Mode mode) { - setMimeData(0, mode); + setMimeData(nullptr, mode); } /*! diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 1ba8760a9d..4ae5412367 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -384,7 +384,7 @@ QDataStream &operator>>(QDataStream &s, QCursor &c) */ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) - : d(0) + : d(nullptr) { QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither); QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither); @@ -440,7 +440,7 @@ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY) */ QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY) - : d(0) + : d(nullptr) { d = QCursorData::setBitmap(bitmap, mask, hotX, hotY, 1.0); } @@ -452,7 +452,7 @@ QCursor::QCursor() { if (!QCursorData::initialized) { if (QCoreApplication::startingUp()) { - d = 0; + d = nullptr; return; } QCursorData::initialize(); @@ -470,7 +470,7 @@ QCursor::QCursor() \sa setShape() */ QCursor::QCursor(Qt::CursorShape shape) - : d(0) + : d(nullptr) { if (!QCursorData::initialized) QCursorData::initialize(); @@ -550,7 +550,7 @@ void QCursor::setShape(Qt::CursorShape shape) { if (!QCursorData::initialized) QCursorData::initialize(); - QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : 0; + QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : nullptr; if (!c) c = qt_cursorTable[0]; c->ref.ref(); @@ -675,7 +675,7 @@ QCursorData *qt_cursorTable[Qt::LastCursor + 1]; bool QCursorData::initialized = false; QCursorData::QCursorData(Qt::CursorShape s) - : ref(1), cshape(s), bm(0), bmm(0), hx(0), hy(0) + : ref(1), cshape(s), bm(nullptr), bmm(nullptr), hx(0), hy(0) { } @@ -695,7 +695,7 @@ void QCursorData::cleanup() // In case someone has a static QCursor defined with this shape if (!qt_cursorTable[shape]->ref.deref()) delete qt_cursorTable[shape]; - qt_cursorTable[shape] = 0; + qt_cursorTable[shape] = nullptr; } QCursorData::initialized = false; } diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index dd541af3b8..fe766c900e 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -48,19 +48,19 @@ QT_BEGIN_NAMESPACE // the universe's only drag manager -QDragManager *QDragManager::m_instance = 0; +QDragManager *QDragManager::m_instance = nullptr; QDragManager::QDragManager() - : QObject(qApp), m_currentDropTarget(0), + : QObject(qApp), m_currentDropTarget(nullptr), m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()), - m_object(0) + m_object(nullptr) { Q_ASSERT(!m_instance); } QDragManager::~QDragManager() { - m_instance = 0; + m_instance = nullptr; } QDragManager *QDragManager::self() @@ -74,7 +74,7 @@ QObject *QDragManager::source() const { if (m_object) return m_object->source(); - return 0; + return nullptr; } void QDragManager::setCurrentTarget(QObject *target, bool dropped) @@ -111,7 +111,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) m_object = o; - m_object->d_func()->target = 0; + m_object->d_func()->target = nullptr; QGuiApplicationPrivate::instance()->notifyDragStarted(m_object.data()); const Qt::DropAction result = m_platformDrag->drag(m_object); diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 8e2f7be23e..3712eace15 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -112,8 +112,8 @@ QDrag::QDrag(QObject *dragSource) { Q_D(QDrag); d->source = dragSource; - d->target = 0; - d->data = 0; + d->target = nullptr; + d->data = nullptr; d->hotspot = QPoint(-10, -10); d->executed_action = Qt::IgnoreAction; d->supported_actions = Qt::IgnoreAction; @@ -138,7 +138,7 @@ void QDrag::setMimeData(QMimeData *data) Q_D(QDrag); if (d->data == data) return; - if (d->data != 0) + if (d->data != nullptr) delete d->data; d->data = data; } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f555f4dc05..c69cc8ce6f 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2950,7 +2950,7 @@ QObject* QDropEvent::source() const { if (const QDragManager *manager = QDragManager::self()) return manager->source(); - return 0; + return nullptr; } @@ -4315,8 +4315,8 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType, Qt::TouchPointStates touchPointStates, const QList<QTouchEvent::TouchPoint> &touchPoints) : QInputEvent(eventType, modifiers), - _window(0), - _target(0), + _window(nullptr), + _target(nullptr), _device(device), _touchPointStates(touchPointStates), _touchPoints(touchPoints) @@ -5008,7 +5008,7 @@ void QTouchEvent::TouchPoint::setFlags(InfoFlags flags) The \a startPos is the position of a touch or mouse event that started the scrolling. */ QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos) - : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos) + : QEvent(QEvent::ScrollPrepare), m_target(nullptr), m_startPos(startPos) { Q_UNUSED(m_target); } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ef31e475ea..6a0b01b6c3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -141,7 +141,7 @@ Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf()); -QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; +QWindow *QGuiApplicationPrivate::currentMouseWindow = nullptr; QString QGuiApplicationPrivate::styleOverride; @@ -155,8 +155,8 @@ QPointer<QWindow> QGuiApplicationPrivate::currentDragWindow; QVector<QGuiApplicationPrivate::TabletPointData> QGuiApplicationPrivate::tabletDevicePoints; -QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; -QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; +QPlatformIntegration *QGuiApplicationPrivate::platform_integration = nullptr; +QPlatformTheme *QGuiApplicationPrivate::platform_theme = nullptr; QList<QObject *> QGuiApplicationPrivate::generic_plugin_list; @@ -172,13 +172,13 @@ enum ApplicationResourceFlags static unsigned applicationResourceFlags = 0; -QIcon *QGuiApplicationPrivate::app_icon = 0; +QIcon *QGuiApplicationPrivate::app_icon = nullptr; -QString *QGuiApplicationPrivate::platform_name = 0; -QString *QGuiApplicationPrivate::displayName = 0; -QString *QGuiApplicationPrivate::desktopFileName = 0; +QString *QGuiApplicationPrivate::platform_name = nullptr; +QString *QGuiApplicationPrivate::displayName = nullptr; +QString *QGuiApplicationPrivate::desktopFileName = nullptr; -QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette +QPalette *QGuiApplicationPrivate::app_pal = nullptr; // default application palette ulong QGuiApplicationPrivate::mousePressTime = 0; Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; @@ -188,30 +188,30 @@ int QGuiApplicationPrivate::mousePressY = 0; static int mouseDoubleClickDistance = -1; static int touchDoubleTapDistance = -1; -QWindow *QGuiApplicationPrivate::currentMousePressWindow = 0; +QWindow *QGuiApplicationPrivate::currentMousePressWindow = nullptr; static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto; static bool force_reverse = false; -QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; -QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; +QGuiApplicationPrivate *QGuiApplicationPrivate::self = nullptr; +QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = nullptr; int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; #ifndef QT_NO_CLIPBOARD -QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; +QClipboard *QGuiApplicationPrivate::qt_clipboard = nullptr; #endif QList<QScreen *> QGuiApplicationPrivate::screen_list; QWindowList QGuiApplicationPrivate::window_list; -QWindow *QGuiApplicationPrivate::focus_window = 0; +QWindow *QGuiApplicationPrivate::focus_window = nullptr; static QBasicMutex applicationFontMutex; -QFont *QGuiApplicationPrivate::app_font = 0; +QFont *QGuiApplicationPrivate::app_font = nullptr; QStyleHints *QGuiApplicationPrivate::styleHints = nullptr; bool QGuiApplicationPrivate::obey_desktop_settings = true; -QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0; +QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = nullptr; qreal QGuiApplicationPrivate::m_maxDevicePixelRatio = 0.0; @@ -243,7 +243,7 @@ static void initPalette() static inline void clearPalette() { delete QGuiApplicationPrivate::app_pal; - QGuiApplicationPrivate::app_pal = 0; + QGuiApplicationPrivate::app_pal = nullptr; } static void initFontUnlocked() @@ -261,7 +261,7 @@ static void initFontUnlocked() static inline void clearFontUnlocked() { delete QGuiApplicationPrivate::app_font; - QGuiApplicationPrivate::app_font = 0; + QGuiApplicationPrivate::app_font = nullptr; } static void initThemeHints() @@ -656,16 +656,16 @@ QGuiApplication::~QGuiApplication() Q_D(QGuiApplication); d->eventDispatcher->closingDown(); - d->eventDispatcher = 0; + d->eventDispatcher = nullptr; #ifndef QT_NO_CLIPBOARD delete QGuiApplicationPrivate::qt_clipboard; - QGuiApplicationPrivate::qt_clipboard = 0; + QGuiApplicationPrivate::qt_clipboard = nullptr; #endif #ifndef QT_NO_SESSIONMANAGER delete d->session_manager; - d->session_manager = 0; + d->session_manager = nullptr; #endif //QT_NO_SESSIONMANAGER clearPalette(); @@ -676,15 +676,15 @@ QGuiApplication::~QGuiApplication() #endif delete QGuiApplicationPrivate::app_icon; - QGuiApplicationPrivate::app_icon = 0; + QGuiApplicationPrivate::app_icon = nullptr; delete QGuiApplicationPrivate::platform_name; - QGuiApplicationPrivate::platform_name = 0; + QGuiApplicationPrivate::platform_name = nullptr; delete QGuiApplicationPrivate::displayName; - QGuiApplicationPrivate::displayName = 0; + QGuiApplicationPrivate::displayName = nullptr; delete QGuiApplicationPrivate::m_inputDeviceManager; - QGuiApplicationPrivate::m_inputDeviceManager = 0; + QGuiApplicationPrivate::m_inputDeviceManager = nullptr; delete QGuiApplicationPrivate::desktopFileName; - QGuiApplicationPrivate::desktopFileName = 0; + QGuiApplicationPrivate::desktopFileName = nullptr; QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; QGuiApplicationPrivate::lastCursorPosition = {qInf(), qInf()}; @@ -704,7 +704,7 @@ QGuiApplication::~QGuiApplication() QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) : QCoreApplicationPrivate(argc, argv, flags), - inputMethod(0), + inputMethod(nullptr), lastTouchType(QEvent::TouchEnd), ownGlobalShareContext(false) { @@ -797,7 +797,7 @@ QWindow *QGuiApplication::modalWindow() { CHECK_QAPP_INSTANCE(nullptr) if (QGuiApplicationPrivate::self->modalWindowList.isEmpty()) - return 0; + return nullptr; return QGuiApplicationPrivate::self->modalWindowList.first(); } @@ -844,7 +844,7 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal) self->modalWindowList.removeFirst(); QEvent e(QEvent::Leave); QGuiApplication::sendEvent(currentMouseWindow, &e); - currentMouseWindow = 0; + currentMouseWindow = nullptr; self->modalWindowList.prepend(modal); } } @@ -874,12 +874,12 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window) */ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const { - QWindow *unused = 0; + QWindow *unused = nullptr; if (!blockingWindow) blockingWindow = &unused; if (modalWindowList.isEmpty()) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -889,7 +889,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking // A window is not blocked by another modal window if the two are // the same, or if the window is a child of the modal window. if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -930,7 +930,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking break; } } - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -969,7 +969,7 @@ QObject *QGuiApplication::focusObject() { if (focusWindow()) return focusWindow()->focusObject(); - return 0; + return nullptr; } /*! @@ -1022,7 +1022,7 @@ QWindowList QGuiApplication::topLevelWindows() QScreen *QGuiApplication::primaryScreen() { if (QGuiApplicationPrivate::screen_list.isEmpty()) - return 0; + return nullptr; return QGuiApplicationPrivate::screen_list.at(0); } @@ -1450,7 +1450,7 @@ void QGuiApplicationPrivate::createPlatformIntegration() } if (j < argc) { - argv[j] = 0; + argv[j] = nullptr; argc = j; } @@ -1470,7 +1470,7 @@ void QGuiApplicationPrivate::createEventDispatcher() { Q_ASSERT(!eventDispatcher); - if (platform_integration == 0) + if (platform_integration == nullptr) createPlatformIntegration(); // The platform integration should not mess with the event dispatcher @@ -1481,7 +1481,7 @@ void QGuiApplicationPrivate::createEventDispatcher() void QGuiApplicationPrivate::eventDispatcherReady() { - if (platform_integration == 0) + if (platform_integration == nullptr) createPlatformIntegration(); platform_integration->initialize(); @@ -1578,7 +1578,7 @@ void QGuiApplicationPrivate::init() } if (j < argc) { - argv[j] = 0; + argv[j] = nullptr; argc = j; } @@ -1587,7 +1587,7 @@ void QGuiApplicationPrivate::init() if (!envPlugins.isEmpty()) pluginList += envPlugins.split(','); - if (platform_integration == 0) + if (platform_integration == nullptr) createPlatformIntegration(); initPalette(); @@ -1693,16 +1693,16 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() #ifndef QT_NO_OPENGL if (ownGlobalShareContext) { delete qt_gl_global_share_context(); - qt_gl_set_global_share_context(0); + qt_gl_set_global_share_context(nullptr); } #endif platform_integration->destroy(); delete platform_theme; - platform_theme = 0; + platform_theme = nullptr; delete platform_integration; - platform_integration = 0; + platform_integration = nullptr; window_list.clear(); screen_list.clear(); @@ -1793,7 +1793,7 @@ Qt::MouseButtons QGuiApplication::mouseButtons() QPlatformNativeInterface *QGuiApplication::platformNativeInterface() { QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); - return pi ? pi->nativeInterface() : 0; + return pi ? pi->nativeInterface() : nullptr; } /*! @@ -2144,7 +2144,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo window = currentMousePressWindow; } else if (currentMousePressWindow) { window = currentMousePressWindow; - currentMousePressWindow = 0; + currentMousePressWindow = nullptr; } QPointF delta = globalPoint - globalPoint.toPoint(); localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; @@ -2357,7 +2357,7 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le return; } - currentMouseWindow = 0; + currentMouseWindow = nullptr; QEvent event(QEvent::Leave); QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); @@ -2376,7 +2376,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate if (platformWindow->isAlertState()) platformWindow->setAlertState(false); - QObject *previousFocusObject = previous ? previous->focusObject() : 0; + QObject *previousFocusObject = previous ? previous->focusObject() : nullptr; if (previous) { QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); @@ -2445,7 +2445,7 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf if (QScreen *screen = wse->screen.data()) topLevelWindow->d_func()->setTopLevelScreen(screen, false /* recreate */); else // Fall back to default behavior, and try to find some appropriate screen - topLevelWindow->setScreen(0); + topLevelWindow->setScreen(nullptr); } // we may have changed scaling, so trigger resize event if needed if (window->handle()) { @@ -2871,7 +2871,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To break; } - Q_ASSERT(w.data() != 0); + Q_ASSERT(w.data() != nullptr); // make the *scene* functions return the same as the *screen* functions // Note: touchPoint is a reference to the one from activeTouchPoints, @@ -3247,12 +3247,12 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM */ QClipboard * QGuiApplication::clipboard() { - if (QGuiApplicationPrivate::qt_clipboard == 0) { + if (QGuiApplicationPrivate::qt_clipboard == nullptr) { if (!qApp) { qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard"); - return 0; + return nullptr; } - QGuiApplicationPrivate::qt_clipboard = new QClipboard(0); + QGuiApplicationPrivate::qt_clipboard = new QClipboard(nullptr); } return QGuiApplicationPrivate::qt_clipboard; } @@ -3873,7 +3873,7 @@ Qt::LayoutDirection QGuiApplication::layoutDirection() QCursor *QGuiApplication::overrideCursor() { CHECK_QAPP_INSTANCE(nullptr) - return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first(); + return qGuiApp->d_func()->cursor_list.isEmpty() ? nullptr : &qGuiApp->d_func()->cursor_list.first(); } /*! @@ -3907,7 +3907,7 @@ static inline void unsetCursor(QWindow *w) { if (const QScreen *screen = w->screen()) if (QPlatformCursor *cursor = screen->handle()->cursor()) - cursor->changeCursor(0, w); + cursor->changeCursor(nullptr, w); } static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index edca8d9423..4ed9d032f6 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -103,13 +103,13 @@ static void construct(QVariant::Private *x, const void *copy) { const int type = x->type; QVariantConstructor<GuiTypesFilter> constructor(x, copy); - QMetaTypeSwitcher::switcher<void>(constructor, type, 0); + QMetaTypeSwitcher::switcher<void>(constructor, type, nullptr); } static void clear(QVariant::Private *d) { QVariantDestructor<GuiTypesFilter> destructor(d); - QMetaTypeSwitcher::switcher<void>(destructor, d->type, 0); + QMetaTypeSwitcher::switcher<void>(destructor, d->type, nullptr); } // This class is a hack that customizes access to QPolygon and QPolygonF @@ -129,7 +129,7 @@ public: static bool isNull(const QVariant::Private *d) { QGuiVariantIsNull<GuiTypesFilter> isNull(d); - return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0); + return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, nullptr); } // This class is a hack that customizes access to QPixmap, QBitmap, QCursor and QIcon @@ -171,7 +171,7 @@ public: static bool compare(const QVariant::Private *a, const QVariant::Private *b) { QGuiVariantComparator<GuiTypesFilter> comparator(a, b); - return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0); + return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, nullptr); } static bool convert(const QVariant::Private *d, int t, @@ -311,7 +311,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); QVariantDebugStream<GuiTypesFilter> stream(dbg, d); - QMetaTypeSwitcher::switcher<void>(stream, d->type, 0); + QMetaTypeSwitcher::switcher<void>(stream, d->type, nullptr); } #endif @@ -320,12 +320,12 @@ const QVariant::Handler qt_gui_variant_handler = { clear, isNull, #ifndef QT_NO_DATASTREAM - 0, - 0, + nullptr, + nullptr, #endif compare, convert, - 0, + nullptr, #if !defined(QT_NO_DEBUG_STREAM) streamDebug #else diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp index 4893b1d57b..274574f561 100644 --- a/src/gui/kernel/qkeymapper.cpp +++ b/src/gui/kernel/qkeymapper.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE Constructs a new key mapper. */ QKeyMapper::QKeyMapper() - : QObject(*new QKeyMapperPrivate, 0) + : QObject(*new QKeyMapperPrivate, nullptr) { } diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index 0cc11ca3bb..c74fe0b3a1 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -99,10 +99,10 @@ public: QOffscreenSurfacePrivate() : QObjectPrivate() , surfaceType(QSurface::OpenGLSurface) - , platformOffscreenSurface(0) - , offscreenWindow(0) + , platformOffscreenSurface(nullptr) + , offscreenWindow(nullptr) , requestedFormat(QSurfaceFormat::defaultFormat()) - , screen(0) + , screen(nullptr) , size(1, 1) , nativeHandle(nullptr) { @@ -235,11 +235,11 @@ void QOffscreenSurface::destroy() QGuiApplication::sendEvent(this, &e); delete d->platformOffscreenSurface; - d->platformOffscreenSurface = 0; + d->platformOffscreenSurface = nullptr; if (d->offscreenWindow) { d->offscreenWindow->destroy(); delete d->offscreenWindow; - d->offscreenWindow = 0; + d->offscreenWindow = nullptr; } d->nativeHandle = nullptr; @@ -341,7 +341,7 @@ void QOffscreenSurface::setScreen(QScreen *newScreen) if (!newScreen) newScreen = QCoreApplication::instance() ? QGuiApplication::primaryScreen() : nullptr; if (newScreen != d->screen) { - const bool wasCreated = d->platformOffscreenSurface != 0 || d->offscreenWindow != 0; + const bool wasCreated = d->platformOffscreenSurface != nullptr || d->offscreenWindow != nullptr; if (wasCreated) destroy(); if (d->screen) @@ -385,7 +385,7 @@ void QOffscreenSurface::screenDestroyed(QObject *object) { Q_D(QOffscreenSurface); if (object == static_cast<QObject *>(d->screen)) - setScreen(0); + setScreen(nullptr); } /*! diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 638eb1d12f..124b39f2a9 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -223,7 +223,7 @@ class QGuiGLThreadContext { public: QGuiGLThreadContext() - : context(0) + : context(nullptr) { } ~QGuiGLThreadContext() { @@ -234,7 +234,7 @@ public: }; Q_GLOBAL_STATIC(QThreadStorage<QGuiGLThreadContext *>, qwindow_context_storage); -static QOpenGLContext *global_share_context = 0; +static QOpenGLContext *global_share_context = nullptr; #ifndef QT_NO_DEBUG QHash<QOpenGLContext *, bool> QOpenGLContextPrivate::makeCurrentTracker; @@ -347,7 +347,7 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context if (!threadContext) { if (!QThread::currentThread()) { qWarning("No QTLS available. currentContext won't work"); - return 0; + return nullptr; } threadContext = new QGuiGLThreadContext; qwindow_context_storage()->setLocalData(threadContext); @@ -372,10 +372,10 @@ int QOpenGLContextPrivate::maxTextureSize() GLint size; GLint next = 64; - funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); - QOpenGLFunctions_1_0 *gl1funcs = 0; - QOpenGLFunctions_3_2_Core *gl3funcs = 0; + QOpenGLFunctions_1_0 *gl1funcs = nullptr; + QOpenGLFunctions_3_2_Core *gl3funcs = nullptr; if (q->format().profile() == QSurfaceFormat::CoreProfile) gl3funcs = q->versionFunctions<QOpenGLFunctions_3_2_Core>(); @@ -398,7 +398,7 @@ int QOpenGLContextPrivate::maxTextureSize() if (next > max_texture_size) break; - funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); if (gl1funcs) gl1funcs->glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &next); else @@ -455,7 +455,7 @@ QPlatformOpenGLContext *QOpenGLContext::shareHandle() const Q_D(const QOpenGLContext); if (d->shareContext) return d->shareContext->handle(); - return 0; + return nullptr; } /*! @@ -517,8 +517,8 @@ void QOpenGLContextPrivate::_q_screenDestroyed(QObject *object) { Q_Q(QOpenGLContext); if (object == static_cast<QObject *>(screen)) { - screen = 0; - q->setScreen(0); + screen = nullptr; + q->setScreen(nullptr); } } @@ -615,7 +615,7 @@ bool QOpenGLContext::create() d->platformGLContext->setContext(this); d->platformGLContext->initialize(); if (!d->platformGLContext->isSharing()) - d->shareContext = 0; + d->shareContext = nullptr; d->shareGroup = d->shareContext ? d->shareContext->shareGroup() : new QOpenGLContextGroup; d->shareGroup->d_func()->addContext(this); return isValid(); @@ -649,15 +649,15 @@ void QOpenGLContext::destroy() doneCurrent(); if (d->shareGroup) d->shareGroup->d_func()->removeContext(this); - d->shareGroup = 0; + d->shareGroup = nullptr; delete d->platformGLContext; - d->platformGLContext = 0; + d->platformGLContext = nullptr; delete d->functions; - d->functions = 0; + d->functions = nullptr; for (QAbstractOpenGLFunctions *func : qAsConst(d->externalVersionFunctions)) { QAbstractOpenGLFunctionsPrivate *func_d = QAbstractOpenGLFunctionsPrivate::get(func); - func_d->owningContext = 0; + func_d->owningContext = nullptr; func_d->initialized = false; } d->externalVersionFunctions.clear(); @@ -665,7 +665,7 @@ void QOpenGLContext::destroy() d->versionFunctions.clear(); delete d->textureFunctions; - d->textureFunctions = 0; + d->textureFunctions = nullptr; d->nativeHandle = QVariant(); } @@ -823,7 +823,7 @@ QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionP #ifndef QT_OPENGL_ES_2 if (isOpenGLES()) { qWarning("versionFunctions: Not supported on OpenGL ES"); - return 0; + return nullptr; } #endif // QT_OPENGL_ES_2 @@ -838,16 +838,16 @@ QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionP // Check that context is compatible with requested version const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion()); if (v < vp.version()) - return 0; + return nullptr; // If this context only offers core profile functions then we can't create // function objects for legacy or compatibility profile requests if (((vp.hasProfiles() && vp.profile() != QSurfaceFormat::CoreProfile) || vp.isLegacyVersion()) && f.profile() == QSurfaceFormat::CoreProfile) - return 0; + return nullptr; // Create object if suitable one not cached - QAbstractOpenGLFunctions* funcs = 0; + QAbstractOpenGLFunctions* funcs = nullptr; auto it = d->versionFunctions.constFind(vp); if (it == d->versionFunctions.constEnd()) { funcs = QOpenGLVersionFunctionsFactory::create(vp); @@ -1022,7 +1022,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) || qstrncmp(rendererString, "Adreno 6xx", 8) == 0 // Same as above but without the '(TM)' || qstrcmp(rendererString, "GC800 core") == 0 || qstrcmp(rendererString, "GC1000 core") == 0 - || strstr(rendererString, "GC2000") != 0 + || strstr(rendererString, "GC2000") != nullptr || qstrcmp(rendererString, "Immersion.16") == 0; } needsWorkaroundSet = true; @@ -1053,9 +1053,9 @@ void QOpenGLContext::doneCurrent() d->shareGroup->d_func()->deletePendingResources(this); d->platformGLContext->doneCurrent(); - QOpenGLContextPrivate::setCurrentContext(0); + QOpenGLContextPrivate::setCurrentContext(nullptr); - d->surface = 0; + d->surface = nullptr; } /*! @@ -1224,8 +1224,8 @@ void QOpenGLContext::deleteQGLContext() Q_D(QOpenGLContext); if (d->qGLContextDeleteFunction && d->qGLContextHandle) { d->qGLContextDeleteFunction(d->qGLContextHandle); - d->qGLContextDeleteFunction = 0; - d->qGLContextHandle = 0; + d->qGLContextDeleteFunction = nullptr; + d->qGLContextHandle = nullptr; } } @@ -1252,7 +1252,7 @@ void *QOpenGLContext::openGLModuleHandle() Q_ASSERT(ni); return ni->nativeResourceForIntegration(QByteArrayLiteral("glhandle")); #else - return 0; + return nullptr; #endif } @@ -1438,7 +1438,7 @@ QList<QOpenGLContext *> QOpenGLContextGroup::shares() const QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup() { QOpenGLContext *current = QOpenGLContext::currentContext(); - return current ? current->shareGroup() : 0; + return current ? current->shareGroup() : nullptr; } void QOpenGLContextGroupPrivate::addContext(QOpenGLContext *ctx) @@ -1491,7 +1491,7 @@ void QOpenGLContextGroupPrivate::cleanup() while (it != end) { (*it)->invalidateResource(); - (*it)->m_group = 0; + (*it)->m_group = nullptr; ++it; } diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index 022a47c919..2ea8f43711 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -208,8 +208,8 @@ QOpenGLWindowPrivate::~QOpenGLWindowPrivate() Q_Q(QOpenGLWindow); if (q->isValid()) { q->makeCurrent(); // this works even when the platformwindow is destroyed - paintDevice.reset(0); - fbo.reset(0); + paintDevice.reset(nullptr); + fbo.reset(nullptr); blitter.destroy(); q->doneCurrent(); } @@ -692,7 +692,7 @@ QPaintDevice *QOpenGLWindow::redirected(QPoint *) const Q_D(const QOpenGLWindow); if (QOpenGLContext::currentContext() == d->context.data()) return d->paintDevice.data(); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp index 4521c2f62c..4f45fc5fde 100644 --- a/src/gui/kernel/qpaintdevicewindow.cpp +++ b/src/gui/kernel/qpaintdevicewindow.cpp @@ -219,7 +219,7 @@ QPaintDeviceWindow::QPaintDeviceWindow(QPaintDeviceWindowPrivate &dd, QWindow *p */ QPaintEngine *QPaintDeviceWindow::paintEngine() const { - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 61dccd77ac..fc063bc72c 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -536,7 +536,7 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) \sa QApplication::setPalette(), QApplication::palette() */ QPalette::QPalette() - : d(0) + : d(nullptr) { data.current_group = Active; data.resolve_mask = 0; diff --git a/src/gui/kernel/qplatformclipboard.cpp b/src/gui/kernel/qplatformclipboard.cpp index ab2998b901..34c94dca3b 100644 --- a/src/gui/kernel/qplatformclipboard.cpp +++ b/src/gui/kernel/qplatformclipboard.cpp @@ -67,7 +67,7 @@ private: QClipboardData::QClipboardData() { - src = 0; + src = nullptr; } QClipboardData::~QClipboardData() diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 34c4549443..12065078c1 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -128,7 +128,7 @@ void QPlatformCursor::setPos(const QPoint &pos) qWarning("This plugin does not support QCursor::setPos()" "; emulating movement within the application."); } - QWindowSystemInterface::handleMouseEvent(0, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove); + QWindowSystemInterface::handleMouseEvent(nullptr, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove); } // End of display and pointer event handling code @@ -431,7 +431,7 @@ void QPlatformCursorImage::createSystemCursor(int id) { if (!systemCursorTableInit) { for (int i = 0; i <= Qt::LastCursor; i++) - systemCursorTable[i] = 0; + systemCursorTable[i] = nullptr; systemCursorTableInit = true; } switch (id) { @@ -478,7 +478,7 @@ void QPlatformCursorImage::createSystemCursor(int id) case Qt::BlankCursor: systemCursorTable[Qt::BlankCursor] = - new QPlatformCursorImage(0, 0, 0, 0, 0, 0); + new QPlatformCursorImage(nullptr, nullptr, 0, 0, 0, 0); break; // 20x20 cursors @@ -548,14 +548,14 @@ void QPlatformCursorImage::createSystemCursor(int id) void QPlatformCursorImage::set(Qt::CursorShape id) { - QPlatformCursorImage *cursor = 0; + QPlatformCursorImage *cursor = nullptr; if (unsigned(id) <= unsigned(Qt::LastCursor)) { if (!systemCursorTable[id]) createSystemCursor(id); cursor = systemCursorTable[id]; } - if (cursor == 0) { + if (cursor == nullptr) { if (!systemCursorTable[Qt::ArrowCursor]) createSystemCursor(Qt::ArrowCursor); cursor = systemCursorTable[Qt::ArrowCursor]; diff --git a/src/gui/kernel/qplatforminputcontextfactory.cpp b/src/gui/kernel/qplatforminputcontextfactory.cpp index df7b95d8df..749abaf27a 100644 --- a/src/gui/kernel/qplatforminputcontextfactory.cpp +++ b/src/gui/kernel/qplatforminputcontextfactory.cpp @@ -85,7 +85,7 @@ QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key) #else Q_UNUSED(key); #endif - return 0; + return nullptr; } QPlatformInputContext *QPlatformInputContextFactory::create() diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index b3d3db0751..63f66e6bf7 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE */ QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const { - static QPlatformFontDatabase *db = 0; + static QPlatformFontDatabase *db = nullptr; if (!db) { db = new QPlatformFontDatabase; } @@ -86,7 +86,7 @@ QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const QPlatformClipboard *QPlatformIntegration::clipboard() const { - static QPlatformClipboard *clipboard = 0; + static QPlatformClipboard *clipboard = nullptr; if (!clipboard) { clipboard = new QPlatformClipboard; } @@ -104,7 +104,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const */ QPlatformDrag *QPlatformIntegration::drag() const { - static QSimpleDrag *drag = 0; + static QSimpleDrag *drag = nullptr; if (!drag) { drag = new QSimpleDrag; } @@ -114,12 +114,12 @@ QPlatformDrag *QPlatformIntegration::drag() const QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const { - return 0; + return nullptr; } QPlatformServices *QPlatformIntegration::services() const { - return 0; + return nullptr; } /*! @@ -303,7 +303,7 @@ QPlatformOpenGLContext *QPlatformIntegration::createPlatformOpenGLContext(QOpenG { Q_UNUSED(context); qWarning("This plugin does not support createPlatformOpenGLContext!"); - return 0; + return nullptr; } #endif // QT_NO_OPENGL @@ -315,7 +315,7 @@ QPlatformSharedGraphicsCache *QPlatformIntegration::createPlatformSharedGraphics { qWarning("This plugin does not support createPlatformSharedGraphicsBuffer for cacheId: %s!", cacheId); - return 0; + return nullptr; } /*! @@ -325,7 +325,7 @@ QPlatformSharedGraphicsCache *QPlatformIntegration::createPlatformSharedGraphics QPaintEngine *QPlatformIntegration::createImagePaintEngine(QPaintDevice *paintDevice) const { Q_UNUSED(paintDevice) - return 0; + return nullptr; } /*! @@ -357,7 +357,7 @@ void QPlatformIntegration::destroy() */ QPlatformInputContext *QPlatformIntegration::inputContext() const { - return 0; + return nullptr; } #ifndef QT_NO_ACCESSIBILITY @@ -370,7 +370,7 @@ QPlatformInputContext *QPlatformIntegration::inputContext() const */ QPlatformAccessibility *QPlatformIntegration::accessibility() const { - static QPlatformAccessibility *accessibility = 0; + static QPlatformAccessibility *accessibility = nullptr; if (Q_UNLIKELY(!accessibility)) { accessibility = new QPlatformAccessibility; } @@ -484,7 +484,7 @@ class QPlatformTheme *QPlatformIntegration::createPlatformTheme(const QString &n QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const { Q_UNUSED(surface) - return 0; + return nullptr; } #ifndef QT_NO_SESSIONMANAGER diff --git a/src/gui/kernel/qplatformintegrationplugin.cpp b/src/gui/kernel/qplatformintegrationplugin.cpp index 35e4d2797b..b100eacbb5 100644 --- a/src/gui/kernel/qplatformintegrationplugin.cpp +++ b/src/gui/kernel/qplatformintegrationplugin.cpp @@ -54,7 +54,7 @@ QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, con { Q_UNUSED(key) Q_UNUSED(paramList); - return 0; + return nullptr; } QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, const QStringList ¶mList, int &argc, char **argv) diff --git a/src/gui/kernel/qplatformnativeinterface.cpp b/src/gui/kernel/qplatformnativeinterface.cpp index b24541d3ec..8c9e73fbc2 100644 --- a/src/gui/kernel/qplatformnativeinterface.cpp +++ b/src/gui/kernel/qplatformnativeinterface.cpp @@ -56,35 +56,35 @@ QT_BEGIN_NAMESPACE void *QPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } void *QPlatformNativeInterface::nativeResourceForScreen(const QByteArray &resource, QScreen *screen) { Q_UNUSED(resource); Q_UNUSED(screen); - return 0; + return nullptr; } void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { Q_UNUSED(resource); Q_UNUSED(window); - return 0; + return nullptr; } void *QPlatformNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) { Q_UNUSED(resource); Q_UNUSED(context); - return 0; + return nullptr; } void * QPlatformNativeInterface::nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) { Q_UNUSED(resource); Q_UNUSED(backingStore); - return 0; + return nullptr; } #ifndef QT_NO_CURSOR @@ -99,31 +99,31 @@ void *QPlatformNativeInterface::nativeResourceForCursor(const QByteArray &resour QPlatformNativeInterface::NativeResourceForIntegrationFunction QPlatformNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForContextFunction QPlatformNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForScreenFunction QPlatformNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForWindowFunction QPlatformNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForBackingStoreFunction QPlatformNativeInterface::nativeResourceFunctionForBackingStore(const QByteArray &resource) { Q_UNUSED(resource); - return 0; + return nullptr; } QFunctionPointer QPlatformNativeInterface::platformFunction(const QByteArray &function) const diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp index 07b5a0dda6..839ec008aa 100644 --- a/src/gui/kernel/qplatformopenglcontext.cpp +++ b/src/gui/kernel/qplatformopenglcontext.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE class QPlatformOpenGLContextPrivate { public: - QPlatformOpenGLContextPrivate() : context(0) {} + QPlatformOpenGLContextPrivate() : context(nullptr) {} QOpenGLContext *context; }; diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index e511a6f5c4..7c1e2158b1 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -54,7 +54,7 @@ QPlatformScreen::QPlatformScreen() : d_ptr(new QPlatformScreenPrivate) { Q_D(QPlatformScreen); - d->screen = 0; + d->screen = nullptr; } QPlatformScreen::~QPlatformScreen() @@ -99,7 +99,7 @@ QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const return w; } - return 0; + return nullptr; } /*! @@ -310,7 +310,7 @@ QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *window // QTBUG 32681: It can happen during the transition between screens // when one screen is disconnected that the window doesn't have a screen. if (!window->screen()) - return 0; + return nullptr; return window->screen()->handle(); } @@ -395,7 +395,7 @@ QString QPlatformScreen::serialNumber() const */ QPlatformCursor *QPlatformScreen::cursor() const { - return 0; + return nullptr; } /*! diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index f906f808d8..71521c0339 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -354,7 +354,7 @@ const uint QPlatformThemePrivate::numberOfKeyBindings = sizeof(QPlatformThemePri #endif QPlatformThemePrivate::QPlatformThemePrivate() - : systemPalette(0) + : systemPalette(nullptr) { } QPlatformThemePrivate::~QPlatformThemePrivate() @@ -394,7 +394,7 @@ bool QPlatformTheme::usePlatformNativeDialog(DialogType type) const QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType type) const { Q_UNUSED(type); - return 0; + return nullptr; } const QPalette *QPlatformTheme::palette(Palette type) const @@ -405,13 +405,13 @@ const QPalette *QPlatformTheme::palette(Palette type) const const_cast<QPlatformTheme *>(this)->d_ptr->initializeSystemPalette(); return d->systemPalette; } - return 0; + return nullptr; } const QFont *QPlatformTheme::font(Font type) const { Q_UNUSED(type) - return 0; + return nullptr; } QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const @@ -569,17 +569,17 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) QPlatformMenuItem *QPlatformTheme::createPlatformMenuItem() const { - return 0; + return nullptr; } QPlatformMenu *QPlatformTheme::createPlatformMenu() const { - return 0; + return nullptr; } QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar() const { - return 0; + return nullptr; } #ifndef QT_NO_SYSTEMTRAYICON @@ -589,7 +589,7 @@ QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar() const */ QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon() const { - return 0; + return nullptr; } #endif diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 80de561297..9de59f8c7e 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE */ QScreen::QScreen(QPlatformScreen *screen) - : QObject(*new QScreenPrivate(), 0) + : QObject(*new QScreenPrivate(), nullptr) { Q_D(QScreen); d->setPlatformScreen(screen); diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp index e5e9c624b2..8747e02719 100644 --- a/src/gui/kernel/qsessionmanager.cpp +++ b/src/gui/kernel/qsessionmanager.cpp @@ -135,7 +135,7 @@ QSessionManagerPrivate::QSessionManagerPrivate(const QString &id, QSessionManagerPrivate::~QSessionManagerPrivate() { delete platformSessionManager; - platformSessionManager = 0; + platformSessionManager = nullptr; } QSessionManager::QSessionManager(QGuiApplication *app, QString &id, QString &key) diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index 9ed450b031..a7ea20266b 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -65,11 +65,11 @@ Q_LOGGING_CATEGORY(lcShortcutMap, "qt.gui.shortcutmap") struct QShortcutEntry { QShortcutEntry() - : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0) + : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr) {} QShortcutEntry(const QKeySequence &k) - : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0), contextMatcher(0) + : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr) {} QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a, QShortcutMap::ContextMatcher m) @@ -184,7 +184,7 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key { Q_D(QShortcutMap); int itemsRemoved = 0; - bool allOwners = (owner == 0); + bool allOwners = (owner == nullptr); bool allKeys = key.isEmpty(); bool allIds = id == 0; @@ -228,7 +228,7 @@ int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const { Q_D(QShortcutMap); int itemsChanged = 0; - bool allOwners = (owner == 0); + bool allOwners = (owner == nullptr); bool allKeys = key.isEmpty(); bool allIds = id == 0; @@ -264,7 +264,7 @@ int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const Q { Q_D(QShortcutMap); int itemsChanged = 0; - bool allOwners = (owner == 0); + bool allOwners = (owner == nullptr); bool allKeys = key.isEmpty(); bool allIds = id == 0; @@ -638,7 +638,7 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e) d->prevSequence = curKey; } // Find next - const QShortcutEntry *current = 0, *next = 0; + const QShortcutEntry *current = nullptr, *next = nullptr; int i = 0, enabledShortcuts = 0; QVector<const QShortcutEntry*> ambiguousShortcuts; while(i < d->identicals.size()) { diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 803206477c..dec3cc399d 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -76,7 +76,7 @@ static QWindow* topLevelAt(const QPoint &pos) if (w->isVisible() && w->handle() && w->geometry().contains(pos) && !qobject_cast<QShapedPixmapWindow*>(w)) return w; } - return 0; + return nullptr; } /*! diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 732ede90d0..7b3c70c51b 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -116,7 +116,7 @@ public: \sa QGuiApplication::styleHints() */ QStyleHints::QStyleHints() - : QObject(*new QStyleHintsPrivate(), 0) + : QObject(*new QStyleHintsPrivate(), nullptr) { } diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index 709f28d431..85c576b21c 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -134,7 +134,7 @@ bool QSurface::supportsOpenGL() const Creates a surface with the given \a type. */ QSurface::QSurface(SurfaceClass type) - : m_type(type), m_reserved(0) + : m_type(type), m_reserved(nullptr) { } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b71a0c54aa..74e0e6401e 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -156,7 +156,7 @@ QT_BEGIN_NAMESPACE \sa setScreen() */ QWindow::QWindow(QScreen *targetScreen) - : QObject(*new QWindowPrivate(), 0) + : QObject(*new QWindowPrivate(), nullptr) , QSurface(QSurface::Window) { Q_D(QWindow); @@ -223,7 +223,7 @@ QWindow::~QWindow() // some cases end up becoming the focus window again. Clear it again // here as a workaround. See QTBUG-75326. if (QGuiApplicationPrivate::focus_window == this) - QGuiApplicationPrivate::focus_window = 0; + QGuiApplicationPrivate::focus_window = nullptr; } void QWindowPrivate::init(QScreen *targetScreen) @@ -469,7 +469,7 @@ inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const inline void QWindowPrivate::disconnectFromScreen() { if (topLevelScreen) - topLevelScreen = 0; + topLevelScreen = nullptr; } void QWindowPrivate::connectToScreen(QScreen *screen) @@ -732,7 +732,7 @@ void QWindow::setParent(QWindow *parent) if (parent) parent->create(); - d->platformWindow->setParent(parent ? parent->d_func()->platformWindow : 0); + d->platformWindow->setParent(parent ? parent->d_func()->platformWindow : nullptr); } QGuiApplicationPrivate::updateBlockedStatus(this); @@ -744,7 +744,7 @@ void QWindow::setParent(QWindow *parent) bool QWindow::isTopLevel() const { Q_D(const QWindow); - return d->parentWindow == 0; + return d->parentWindow == nullptr; } /*! @@ -2018,7 +2018,7 @@ void QWindow::setScreen(QScreen *newScreen) Q_D(QWindow); if (!newScreen) newScreen = QGuiApplication::primaryScreen(); - d->setTopLevelScreen(newScreen, newScreen != 0); + d->setTopLevelScreen(newScreen, newScreen != nullptr); } /*! @@ -2036,7 +2036,7 @@ void QWindow::setScreen(QScreen *newScreen) */ QAccessibleInterface *QWindow::accessibleRoot() const { - return 0; + return nullptr; } /*! @@ -2696,7 +2696,7 @@ QWindow *QWindow::fromWinId(WId id) { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)) { qWarning("QWindow::fromWinId(): platform plugin does not support foreign windows."); - return 0; + return nullptr; } QWindow *window = new QWindow; @@ -2770,7 +2770,7 @@ void QWindow::setCursor(const QCursor &cursor) void QWindow::unsetCursor() { Q_D(QWindow); - d->setCursor(0); + d->setCursor(nullptr); } /*! diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index ba04f8701d..c9a70897d6 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -179,7 +179,7 @@ void QWindowSystemInterfacePrivate::installWindowSystemEventHandler(QWindowSyste void QWindowSystemInterfacePrivate::removeWindowSystemEventhandler(QWindowSystemEventHandler *handler) { if (eventHandler == handler) - eventHandler = 0; + eventHandler = nullptr; } QWindowSystemEventHandler::~QWindowSystemEventHandler() diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 667d16317f..adca536797 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -72,7 +72,7 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() return; } QOpenGLFunctions *funcs = ctx->functions(); - const char *extensionStr = 0; + const char *extensionStr = nullptr; if (ctx->isOpenGLES() || ctx->format().majorVersion() < 3) extensionStr = reinterpret_cast<const char *>(funcs->glGetString(GL_EXTENSIONS)); diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp index 5ad16a8438..5387cc06e3 100644 --- a/src/gui/opengl/qopenglbuffer.cpp +++ b/src/gui/opengl/qopenglbuffer.cpp @@ -143,10 +143,10 @@ public: QOpenGLBufferPrivate(QOpenGLBuffer::Type t) : ref(1), type(t), - guard(0), + guard(nullptr), usagePattern(QOpenGLBuffer::StaticDraw), actualUsagePattern(QOpenGLBuffer::StaticDraw), - funcs(0) + funcs(nullptr) { } @@ -323,10 +323,10 @@ void QOpenGLBuffer::destroy() Q_D(QOpenGLBuffer); if (d->guard) { d->guard->free(); - d->guard = 0; + d->guard = nullptr; } delete d->funcs; - d->funcs = 0; + d->funcs = nullptr; } /*! @@ -586,7 +586,7 @@ void *QOpenGLBuffer::mapRange(int offset, int count, QOpenGLBuffer::RangeAccessF qWarning("QOpenGLBuffer::mapRange(): buffer not created"); #endif if (!d->guard || !d->guard->id()) - return 0; + return nullptr; return d->funcs->glMapBufferRange(d->type, offset, count, access); } diff --git a/src/gui/opengl/qopenglcustomshaderstage.cpp b/src/gui/opengl/qopenglcustomshaderstage.cpp index baa44f86b0..a95a0a5767 100644 --- a/src/gui/opengl/qopenglcustomshaderstage.cpp +++ b/src/gui/opengl/qopenglcustomshaderstage.cpp @@ -48,7 +48,7 @@ class QOpenGLCustomShaderStagePrivate { public: QOpenGLCustomShaderStagePrivate() : - m_manager(0) {} + m_manager(nullptr) {} QPointer<QOpenGLEngineShaderManager> m_manager; QByteArray m_source; @@ -110,8 +110,8 @@ void QOpenGLCustomShaderStage::removeFromPainter(QPainter* p) // Just set the stage to null, don't call removeCustomStage(). // This should leave the program in a compiled/linked state // if the next custom shader stage is this one again. - d->m_manager->setCustomStage(0); - d->m_manager = 0; + d->m_manager->setCustomStage(nullptr); + d->m_manager = nullptr; } QByteArray QOpenGLCustomShaderStage::source() const @@ -125,7 +125,7 @@ QByteArray QOpenGLCustomShaderStage::source() const void QOpenGLCustomShaderStage::setInactive() { Q_D(QOpenGLCustomShaderStage); - d->m_manager = 0; + d->m_manager = nullptr; } void QOpenGLCustomShaderStage::setSource(const QByteArray& s) diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp index 462a4fdb3b..310006feaf 100644 --- a/src/gui/opengl/qopengldebug.cpp +++ b/src/gui/opengl/qopengldebug.cpp @@ -1108,14 +1108,14 @@ public: \internal */ QOpenGLDebugLoggerPrivate::QOpenGLDebugLoggerPrivate() - : glDebugMessageControl(0), - glDebugMessageInsert(0), - glDebugMessageCallback(0), - glGetDebugMessageLog(0), - glPushDebugGroup(0), - glPopDebugGroup(0), - oldDebugCallbackFunction(0), - context(0), + : glDebugMessageControl(nullptr), + glDebugMessageInsert(nullptr), + glDebugMessageCallback(nullptr), + glGetDebugMessageLog(nullptr), + glPushDebugGroup(nullptr), + glPopDebugGroup(nullptr), + oldDebugCallbackFunction(nullptr), + context(nullptr), maxMessageLength(0), loggingMode(QOpenGLDebugLogger::AsynchronousLogging), initialized(false), @@ -1228,7 +1228,7 @@ void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Source const GLsizei idCount = ids.count(); // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored. // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case. - const GLuint * const idPtr = idCount ? ids.constData() : 0; + const GLuint * const idPtr = idCount ? ids.constData() : nullptr; for (GLenum source : glSources) for (GLenum type : glTypes) @@ -1247,7 +1247,7 @@ void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() // Save the current context and its surface in case we need to set them back QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - QSurface *currentSurface = 0; + QSurface *currentSurface = nullptr; QScopedPointer<QOffscreenSurface> offscreenSurface; @@ -1275,7 +1275,7 @@ void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() } QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = 0; + context = nullptr; initialized = false; } @@ -1356,7 +1356,7 @@ bool QOpenGLDebugLogger::initialize() disconnect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); d->initialized = false; - d->context = 0; + d->context = nullptr; if (!context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) return false; diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp index 1e5a10c99c..a569975486 100644 --- a/src/gui/opengl/qopenglengineshadermanager.cpp +++ b/src/gui/opengl/qopenglengineshadermanager.cpp @@ -72,7 +72,7 @@ public: void invalidateResource() override { delete m_shaders; - m_shaders = 0; + m_shaders = nullptr; } void freeResource(QOpenGLContext *) override @@ -94,7 +94,7 @@ public: shaders = new QOpenGLMultiGroupSharedResource; QOpenGLEngineSharedShadersResource *resource = shaders->value<QOpenGLEngineSharedShadersResource>(context); - return resource ? resource->shaders() : 0; + return resource ? resource->shaders() : nullptr; } private: @@ -116,8 +116,8 @@ const char* QOpenGLEngineSharedShaders::qShaderSnippets[] = { }; QOpenGLEngineSharedShaders::QOpenGLEngineSharedShaders(QOpenGLContext* context) - : blitShaderProg(0) - , simpleShaderProg(0) + : blitShaderProg(nullptr) + , simpleShaderProg(nullptr) { /* @@ -341,12 +341,12 @@ QOpenGLEngineSharedShaders::~QOpenGLEngineSharedShaders() if (blitShaderProg) { delete blitShaderProg; - blitShaderProg = 0; + blitShaderProg = nullptr; } if (simpleShaderProg) { delete simpleShaderProg; - simpleShaderProg = 0; + simpleShaderProg = nullptr; } } @@ -507,8 +507,8 @@ QOpenGLEngineShaderManager::QOpenGLEngineShaderManager(QOpenGLContext* context) opacityMode(NoOpacity), maskType(NoMask), compositionMode(QPainter::CompositionMode_SourceOver), - customSrcStage(0), - currentShaderProg(0) + customSrcStage(nullptr), + currentShaderProg(nullptr) { sharedShaders = QOpenGLEngineSharedShaders::shadersForContext(context); } @@ -627,7 +627,7 @@ void QOpenGLEngineShaderManager::removeCustomStage() { if (customSrcStage) customSrcStage->setInactive(); - customSrcStage = 0; + customSrcStage = nullptr; shaderProgNeedsChanging = true; } @@ -684,7 +684,7 @@ bool QOpenGLEngineShaderManager::useCorrectShaderProg() if (!shaderProgNeedsChanging) return false; - bool useCustomSrc = customSrcStage != 0; + bool useCustomSrc = customSrcStage != nullptr; if (useCustomSrc && srcPixelType != QOpenGLEngineShaderManager::ImageSrc && srcPixelType != Qt::TexturePattern) { useCustomSrc = false; qWarning("QOpenGLEngineShaderManager - Ignoring custom shader stage for non image src"); diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index bb0dbdc9bd..d7a6d32218 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -551,7 +551,7 @@ void QOpenGLFramebufferObjectPrivate::initTexture(int idx) pixelType = GL_UNSIGNED_SHORT; funcs.glTexImage2D(target, 0, color.internalFormat, color.size.width(), color.size.height(), 0, - GL_RGBA, pixelType, NULL); + GL_RGBA, pixelType, nullptr); if (format.mipmap()) { int width = color.size.width(); int height = color.size.height(); @@ -561,7 +561,7 @@ void QOpenGLFramebufferObjectPrivate::initTexture(int idx) height = qMax(1, height >> 1); ++level; funcs.glTexImage2D(target, level, color.internalFormat, width, height, 0, - GL_RGBA, pixelType, NULL); + GL_RGBA, pixelType, nullptr); } } funcs.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + idx, @@ -640,8 +640,8 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext stencil_buffer_guard->free(); } - depth_buffer_guard = 0; - stencil_buffer_guard = 0; + depth_buffer_guard = nullptr; + stencil_buffer_guard = nullptr; GLuint depth_buffer = 0; GLuint stencil_buffer = 0; @@ -1284,7 +1284,7 @@ GLuint QOpenGLFramebufferObject::takeTexture(int colorAttachmentIndex) id = guard ? guard->id() : 0; // Do not call free() on texture_guard, just null it out. // This way the texture will not be deleted when the guard is destroyed. - guard = 0; + guard = nullptr; } return id; } @@ -1564,7 +1564,7 @@ bool QOpenGLFramebufferObject::bindDefault() qWarning("QOpenGLFramebufferObject::bindDefault() called without current context."); #endif - return ctx != 0; + return ctx != nullptr; } /*! diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 3e9eb3dd0a..11ca802ee6 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -182,7 +182,7 @@ struct QOpenGLFunctionsPrivateEx : public QOpenGLExtensionsPrivate, public QOpen Q_GLOBAL_STATIC(QOpenGLMultiGroupSharedResource, qt_gl_functions_resource) -static QOpenGLFunctionsPrivateEx *qt_gl_functions(QOpenGLContext *context = 0) +static QOpenGLFunctionsPrivateEx *qt_gl_functions(QOpenGLContext *context = nullptr) { if (!context) context = QOpenGLContext::currentContext(); @@ -200,7 +200,7 @@ static QOpenGLFunctionsPrivateEx *qt_gl_functions(QOpenGLContext *context = 0) \sa initializeOpenGLFunctions() */ QOpenGLFunctions::QOpenGLFunctions() - : d_ptr(0) + : d_ptr(nullptr) { } @@ -218,7 +218,7 @@ QOpenGLFunctions::QOpenGLFunctions() \sa initializeOpenGLFunctions() */ QOpenGLFunctions::QOpenGLFunctions(QOpenGLContext *context) - : d_ptr(0) + : d_ptr(nullptr) { if (context && QOpenGLContextGroup::currentContextGroup() == context->shareGroup()) d_ptr = qt_gl_functions(context); diff --git a/src/gui/opengl/qopenglfunctions_1_0.cpp b/src/gui/opengl/qopenglfunctions_1_0.cpp index f017c68fd9..f9d93ce210 100644 --- a/src/gui/opengl/qopenglfunctions_1_0.cpp +++ b/src/gui/opengl/qopenglfunctions_1_0.cpp @@ -67,8 +67,8 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_0::QOpenGLFunctions_1_0() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_0_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) { } @@ -98,7 +98,7 @@ bool QOpenGLFunctions_1_0::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_1.cpp b/src/gui/opengl/qopenglfunctions_1_1.cpp index a819d499f8..b0f7538d48 100644 --- a/src/gui/opengl/qopenglfunctions_1_1.cpp +++ b/src/gui/opengl/qopenglfunctions_1_1.cpp @@ -67,10 +67,10 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_1::QOpenGLFunctions_1_1() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) { } @@ -108,7 +108,7 @@ bool QOpenGLFunctions_1_1::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_2.cpp b/src/gui/opengl/qopenglfunctions_1_2.cpp index 61db2b4e0f..5f137b0237 100644 --- a/src/gui/opengl/qopenglfunctions_1_2.cpp +++ b/src/gui/opengl/qopenglfunctions_1_2.cpp @@ -67,12 +67,12 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_2::QOpenGLFunctions_1_2() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) { } @@ -118,7 +118,7 @@ bool QOpenGLFunctions_1_2::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_3.cpp b/src/gui/opengl/qopenglfunctions_1_3.cpp index acc223ea74..0b5ff2fee5 100644 --- a/src/gui/opengl/qopenglfunctions_1_3.cpp +++ b/src/gui/opengl/qopenglfunctions_1_3.cpp @@ -67,14 +67,14 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_3::QOpenGLFunctions_1_3() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) { } @@ -128,7 +128,7 @@ bool QOpenGLFunctions_1_3::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_4.cpp b/src/gui/opengl/qopenglfunctions_1_4.cpp index 8e2349dc08..9419c1aa85 100644 --- a/src/gui/opengl/qopenglfunctions_1_4.cpp +++ b/src/gui/opengl/qopenglfunctions_1_4.cpp @@ -67,16 +67,16 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_4::QOpenGLFunctions_1_4() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) { } @@ -138,7 +138,7 @@ bool QOpenGLFunctions_1_4::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_1_5.cpp b/src/gui/opengl/qopenglfunctions_1_5.cpp index cd81cf8b35..3fa7668a36 100644 --- a/src/gui/opengl/qopenglfunctions_1_5.cpp +++ b/src/gui/opengl/qopenglfunctions_1_5.cpp @@ -67,17 +67,17 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_1_5::QOpenGLFunctions_1_5() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) { } @@ -143,7 +143,7 @@ bool QOpenGLFunctions_1_5::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_2_0.cpp b/src/gui/opengl/qopenglfunctions_2_0.cpp index 97a8c72fa6..29eb055a1d 100644 --- a/src/gui/opengl/qopenglfunctions_2_0.cpp +++ b/src/gui/opengl/qopenglfunctions_2_0.cpp @@ -67,18 +67,18 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_2_0::QOpenGLFunctions_2_0() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) { } @@ -149,7 +149,7 @@ bool QOpenGLFunctions_2_0::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_2_1.cpp b/src/gui/opengl/qopenglfunctions_2_1.cpp index 00bdc1bbba..8a7170dd7d 100644 --- a/src/gui/opengl/qopenglfunctions_2_1.cpp +++ b/src/gui/opengl/qopenglfunctions_2_1.cpp @@ -67,19 +67,19 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_2_1::QOpenGLFunctions_2_1() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) { } @@ -154,7 +154,7 @@ bool QOpenGLFunctions_2_1::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_0.cpp b/src/gui/opengl/qopenglfunctions_3_0.cpp index 2c239dba1f..7d0e900659 100644 --- a/src/gui/opengl/qopenglfunctions_3_0.cpp +++ b/src/gui/opengl/qopenglfunctions_3_0.cpp @@ -67,20 +67,20 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_0::QOpenGLFunctions_3_0() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) , m_reserved_3_0_Deprecated(nullptr) { @@ -160,7 +160,7 @@ bool QOpenGLFunctions_3_0::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_1.cpp b/src/gui/opengl/qopenglfunctions_3_1.cpp index f62f555c8e..c25b124af8 100644 --- a/src/gui/opengl/qopenglfunctions_3_1.cpp +++ b/src/gui/opengl/qopenglfunctions_3_1.cpp @@ -67,16 +67,16 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_1::QOpenGLFunctions_3_1() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) { } @@ -138,7 +138,7 @@ bool QOpenGLFunctions_3_1::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp index ba7be2d893..3e4fd96dc2 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp @@ -67,22 +67,22 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_2_Compatibility::QOpenGLFunctions_3_2_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) , m_reserved_3_0_Deprecated(nullptr) { @@ -170,7 +170,7 @@ bool QOpenGLFunctions_3_2_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.cpp b/src/gui/opengl/qopenglfunctions_3_2_core.cpp index 4c1e3eb3da..ea89fc9e48 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_core.cpp @@ -67,17 +67,17 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_2_Core::QOpenGLFunctions_3_2_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) { } @@ -143,7 +143,7 @@ bool QOpenGLFunctions_3_2_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp index c750c6e0cc..a26d7d99b1 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp @@ -67,25 +67,25 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_3_Compatibility::QOpenGLFunctions_3_3_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -179,7 +179,7 @@ bool QOpenGLFunctions_3_3_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_3_3_core.cpp b/src/gui/opengl/qopenglfunctions_3_3_core.cpp index 5723509e32..277ad1eb14 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_3_core.cpp @@ -67,18 +67,18 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_3_3_Core::QOpenGLFunctions_3_3_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) { } @@ -148,7 +148,7 @@ bool QOpenGLFunctions_3_3_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp index 6ae7643eb5..655f1e6fd4 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp @@ -67,26 +67,26 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_0_Compatibility::QOpenGLFunctions_4_0_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -184,7 +184,7 @@ bool QOpenGLFunctions_4_0_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_0_core.cpp b/src/gui/opengl/qopenglfunctions_4_0_core.cpp index cd4fdb8b2b..60453d147c 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_0_core.cpp @@ -67,19 +67,19 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_0_Core::QOpenGLFunctions_4_0_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) { } @@ -153,7 +153,7 @@ bool QOpenGLFunctions_4_0_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp index d104c74bc2..bdea8b5ba9 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp @@ -67,27 +67,27 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_1_Compatibility::QOpenGLFunctions_4_1_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -189,7 +189,7 @@ bool QOpenGLFunctions_4_1_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_1_core.cpp b/src/gui/opengl/qopenglfunctions_4_1_core.cpp index 7527aba620..b21742d9c1 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_1_core.cpp @@ -67,20 +67,20 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_1_Core::QOpenGLFunctions_4_1_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) { } @@ -158,7 +158,7 @@ bool QOpenGLFunctions_4_1_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp index a5b1b37495..41ab9ae762 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp @@ -67,28 +67,28 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_2_Compatibility::QOpenGLFunctions_4_2_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -194,7 +194,7 @@ bool QOpenGLFunctions_4_2_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.cpp b/src/gui/opengl/qopenglfunctions_4_2_core.cpp index 1381236926..38dbe1b596 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_2_core.cpp @@ -67,21 +67,21 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_2_Core::QOpenGLFunctions_4_2_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) { } @@ -163,7 +163,7 @@ bool QOpenGLFunctions_4_2_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp index 5c0c711d1c..1b23d08ee2 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp @@ -67,29 +67,29 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_3_Compatibility::QOpenGLFunctions_4_3_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) , m_reserved_2_0_Deprecated(nullptr) - , d_3_3_Deprecated(0) + , d_3_3_Deprecated(nullptr) { } @@ -199,7 +199,7 @@ bool QOpenGLFunctions_4_3_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.cpp b/src/gui/opengl/qopenglfunctions_4_3_core.cpp index 34460b841e..8a867471b8 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_3_core.cpp @@ -67,22 +67,22 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_3_Core::QOpenGLFunctions_4_3_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) { } @@ -168,7 +168,7 @@ bool QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp index 907994a3c4..4fc4b50100 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp @@ -67,29 +67,29 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_4_Compatibility::QOpenGLFunctions_4_4_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) - , d_3_3_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) + , d_3_3_Deprecated(nullptr) { } @@ -203,7 +203,7 @@ bool QOpenGLFunctions_4_4_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.cpp b/src/gui/opengl/qopenglfunctions_4_4_core.cpp index 76c0323f6d..6169c7f455 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_4_core.cpp @@ -67,23 +67,23 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_4_Core::QOpenGLFunctions_4_4_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) { } @@ -173,7 +173,7 @@ bool QOpenGLFunctions_4_4_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp index c415bb06ff..02af443498 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp @@ -67,31 +67,31 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_5_Compatibility::QOpenGLFunctions_4_5_Compatibility() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) - , d_4_5_Core(0) - , d_1_0_Deprecated(0) - , d_1_1_Deprecated(0) - , d_1_2_Deprecated(0) - , d_1_3_Deprecated(0) - , d_1_4_Deprecated(0) - , d_3_3_Deprecated(0) - , d_4_5_Deprecated(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) + , d_4_5_Core(nullptr) + , d_1_0_Deprecated(nullptr) + , d_1_1_Deprecated(nullptr) + , d_1_2_Deprecated(nullptr) + , d_1_3_Deprecated(nullptr) + , d_1_4_Deprecated(nullptr) + , d_3_3_Deprecated(nullptr) + , d_4_5_Deprecated(nullptr) { } @@ -213,7 +213,7 @@ bool QOpenGLFunctions_4_5_Compatibility::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.cpp b/src/gui/opengl/qopenglfunctions_4_5_core.cpp index 4dfac3579c..9c0369e5f2 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_5_core.cpp @@ -67,24 +67,24 @@ QT_BEGIN_NAMESPACE QOpenGLFunctions_4_5_Core::QOpenGLFunctions_4_5_Core() : QAbstractOpenGLFunctions() - , d_1_0_Core(0) - , d_1_1_Core(0) - , d_1_2_Core(0) - , d_1_3_Core(0) - , d_1_4_Core(0) - , d_1_5_Core(0) - , d_2_0_Core(0) - , d_2_1_Core(0) - , d_3_0_Core(0) - , d_3_1_Core(0) - , d_3_2_Core(0) - , d_3_3_Core(0) - , d_4_0_Core(0) - , d_4_1_Core(0) - , d_4_2_Core(0) - , d_4_3_Core(0) - , d_4_4_Core(0) - , d_4_5_Core(0) + , d_1_0_Core(nullptr) + , d_1_1_Core(nullptr) + , d_1_2_Core(nullptr) + , d_1_3_Core(nullptr) + , d_1_4_Core(nullptr) + , d_1_5_Core(nullptr) + , d_2_0_Core(nullptr) + , d_2_1_Core(nullptr) + , d_3_0_Core(nullptr) + , d_3_1_Core(nullptr) + , d_3_2_Core(nullptr) + , d_3_3_Core(nullptr) + , d_4_0_Core(nullptr) + , d_4_1_Core(nullptr) + , d_4_2_Core(nullptr) + , d_4_3_Core(nullptr) + , d_4_4_Core(nullptr) + , d_4_5_Core(nullptr) { } @@ -178,7 +178,7 @@ bool QOpenGLFunctions_4_5_Core::initializeOpenGLFunctions() { // Associate with private implementation, creating if necessary // Function pointers in the backends are resolved at creation time - QOpenGLVersionFunctionsBackend* d = 0; + QOpenGLVersionFunctionsBackend* d = nullptr; d = QAbstractOpenGLFunctionsPrivate::functionsBackend(context, QOpenGLFunctions_1_0_CoreBackend::versionStatus()); d_1_0_Core = static_cast<QOpenGLFunctions_1_0_CoreBackend*>(d); d->refs.ref(); diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 3a0c02feb0..3920a10467 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -171,7 +171,7 @@ QOpenGLPaintDevicePrivate::QOpenGLPaintDevicePrivate(const QSize &sz) , dpmy(qt_defaultDpiY() * 100. / 2.54) , devicePixelRatio(1.0) , flipped(false) - , engine(0) + , engine(nullptr) { } diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 20cc2b5ae5..a82edbb073 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -881,7 +881,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) Q_ASSERT(cache->ibo == 0); #else free(cache->vertices); - Q_ASSERT(cache->indices == 0); + Q_ASSERT(cache->indices == nullptr); #endif updateCache = true; } @@ -909,7 +909,7 @@ void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) #else cache->vertices = (float *) malloc(floatSizeInBytes); memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); - cache->indices = 0; + cache->indices = nullptr; #endif } @@ -1359,7 +1359,7 @@ void QOpenGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) return; QOpenGL2PaintEngineState *s = state(); - if (qt_pen_is_cosmetic(pen, state()->renderHints) && !qt_scaleForTransform(s->transform(), 0)) { + if (qt_pen_is_cosmetic(pen, state()->renderHints) && !qt_scaleForTransform(s->transform(), nullptr)) { // QTriangulatingStroker class is not meant to support cosmetically sheared strokes. QPaintEngineEx::stroke(path, pen); return; @@ -1427,7 +1427,7 @@ void QOpenGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &p QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra); fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2, - 0, 0, bounds, QOpenGL2PaintEngineExPrivate::TriStripStrokeFillMode); + nullptr, 0, bounds, QOpenGL2PaintEngineExPrivate::TriStripStrokeFillMode); funcs.glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); @@ -1772,7 +1772,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly QOpenGLTextureGlyphCache *cache = (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform); - if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == 0) { + if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == nullptr) { cache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; @@ -1780,7 +1780,7 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly if (staticTextItem->userDataNeedsUpdate) { recreateVertexArrays = true; - } else if (staticTextItem->userData() == 0) { + } else if (staticTextItem->userData() == nullptr) { recreateVertexArrays = true; } else if (staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) { recreateVertexArrays = true; @@ -1845,9 +1845,9 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat gly QOpenGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray; if (staticTextItem->useBackendOptimizations) { - QOpenGLStaticTextUserData *userData = 0; + QOpenGLStaticTextUserData *userData = nullptr; - if (staticTextItem->userData() == 0 + if (staticTextItem->userData() == nullptr || staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) { userData = new QOpenGLStaticTextUserData(); @@ -2273,12 +2273,12 @@ bool QOpenGL2PaintEngineEx::end() d->funcs.glUseProgram(0); d->transferMode(BrushDrawingMode); - ctx->d_func()->active_engine = 0; + ctx->d_func()->active_engine = nullptr; d->resetGLState(); delete d->shaderManager; - d->shaderManager = 0; + d->shaderManager = nullptr; d->currentBrush = QBrush(); #ifdef QT_OPENGL_CACHE_AS_VBOS diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 4986ca573d..7e89d9c8d4 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -249,7 +249,7 @@ class QOpenGLShaderPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QOpenGLShader) public: QOpenGLShaderPrivate(QOpenGLContext *ctx, QOpenGLShader::ShaderType type) - : shaderGuard(0) + : shaderGuard(nullptr) , shaderType(type) , compiled(false) , glfuncs(new QOpenGLExtraFunctions(ctx)) @@ -374,8 +374,8 @@ bool QOpenGLShaderPrivate::compile(QOpenGLShader *q) // Get info and source code lengths GLint infoLogLength = 0; GLint sourceCodeLength = 0; - char *logBuffer = 0; - char *sourceCodeBuffer = 0; + char *logBuffer = nullptr; + char *sourceCodeBuffer = nullptr; // Get the compilation info log glfuncs->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); @@ -425,7 +425,7 @@ void QOpenGLShaderPrivate::deleteShader() { if (shaderGuard) { shaderGuard->free(); - shaderGuard = 0; + shaderGuard = nullptr; } } @@ -783,13 +783,13 @@ class QOpenGLShaderProgramPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QOpenGLShaderProgram) public: QOpenGLShaderProgramPrivate() - : programGuard(0) + : programGuard(nullptr) , linked(false) , inited(false) , removingShaders(false) , glfuncs(new QOpenGLExtraFunctions) #ifndef QT_OPENGL_ES_2 - , tessellationFuncs(0) + , tessellationFuncs(nullptr) #endif , linkBinaryRecursion(false) { diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 61a6202017..cf4a8dee8d 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarget, QOpenGLTexture *qq) : q_ptr(qq), - context(0), + context(nullptr), target(textureTarget), textureId(0), format(QOpenGLTexture::NoFormat), @@ -82,8 +82,8 @@ QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarge textureView(false), autoGenerateMipMaps(true), storageAllocated(false), - texFuncs(0), - functions(0) + texFuncs(nullptr), + functions(nullptr) { dimensions[0] = dimensions[1] = dimensions[2] = 1; @@ -208,8 +208,8 @@ void QOpenGLTexturePrivate::destroy() functions->glDeleteTextures(1, &textureId); - context = 0; - functions = 0; + context = nullptr; + functions = nullptr; textureId = 0; format = QOpenGLTexture::NoFormat; formatClass = QOpenGLTexture::NoFormatClass; @@ -231,7 +231,7 @@ void QOpenGLTexturePrivate::destroy() textureView = false; autoGenerateMipMaps = true; storageAllocated = false; - texFuncs = 0; + texFuncs = nullptr; swizzleMask[0] = QOpenGLTexture::RedValue; swizzleMask[1] = QOpenGLTexture::GreenValue; @@ -1141,7 +1141,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p texFuncs->glTextureImage1D(textureId, target, bindingTarget, level, format, mipLevelSize(level, dimensions[0]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("1D textures are not supported"); return; @@ -1156,7 +1156,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[0]), layers, 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("1D array textures are not supported"); return; @@ -1170,7 +1170,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[0]), mipLevelSize(level, dimensions[1]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); break; case QOpenGLTexture::TargetCubeMap: { @@ -1190,7 +1190,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[0]), mipLevelSize(level, dimensions[1]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } } break; @@ -1204,7 +1204,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[1]), layers, 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("Array textures are not supported"); return; @@ -1220,7 +1220,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[1]), 6 * layers, 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("Cubemap Array textures are not supported"); return; @@ -1235,7 +1235,7 @@ void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat p mipLevelSize(level, dimensions[1]), mipLevelSize(level, dimensions[2]), 0, - pixelFormat, pixelType, 0); + pixelFormat, pixelType, nullptr); } else { qWarning("3D textures are not supported"); return; @@ -1924,7 +1924,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target if (!viewTargetCompatible) { qWarning("QOpenGLTexture::createTextureView(): Incompatible source and view targets"); - return 0; + return nullptr; } // Check the formats are compatible @@ -2057,7 +2057,7 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target if (!viewFormatCompatible) { qWarning("QOpenGLTexture::createTextureView(): Incompatible source and view formats"); - return 0; + return nullptr; } @@ -3387,7 +3387,7 @@ QOpenGLTexture *QOpenGLTexture::createTextureView(Target target, Q_D(const QOpenGLTexture); if (!isStorageAllocated()) { qWarning("Cannot set create a texture view of a texture that does not have storage allocated."); - return 0; + return nullptr; } Q_ASSERT(maximumMipmapLevel >= minimumMipmapLevel); Q_ASSERT(maximumLayer >= minimumLayer); diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp index 490dc99749..41027d26e0 100644 --- a/src/gui/opengl/qopengltextureglyphcache.cpp +++ b/src/gui/opengl/qopengltextureglyphcache.cpp @@ -55,9 +55,9 @@ static int next_qopengltextureglyphcache_serial_number() QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix, const QColor &color) : QImageTextureGlyphCache(format, matrix, color) - , m_textureResource(0) - , pex(0) - , m_blitProgram(0) + , m_textureResource(nullptr) + , pex(nullptr) + , m_blitProgram(nullptr) , m_filterMode(Nearest) , m_serialNumber(next_qopengltextureglyphcache_serial_number()) , m_buffer(QOpenGLBuffer::VertexBuffer) @@ -102,7 +102,7 @@ static inline bool isCoreProfile() void QOpenGLTextureGlyphCache::createTextureData(int width, int height) { QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); - if (ctx == 0) { + if (ctx == nullptr) { qWarning("QOpenGLTextureGlyphCache::createTextureData: Called with no context"); return; } @@ -121,7 +121,7 @@ void QOpenGLTextureGlyphCache::createTextureData(int width, int height) if (m_textureResource && !m_textureResource->m_texture) { delete m_textureResource; - m_textureResource = 0; + m_textureResource = nullptr; } if (!m_textureResource) @@ -276,7 +276,7 @@ static void load_glyph_image_region_to_texture(QOpenGLContext *ctx, void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) { QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (ctx == 0) { + if (ctx == nullptr) { qWarning("QOpenGLTextureGlyphCache::resizeTextureData: Called with no context"); return; } @@ -313,7 +313,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glGenTextures(1, &tmp_texture); funcs->glBindTexture(GL_TEXTURE_2D, tmp_texture); funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); + GL_RGBA, GL_UNSIGNED_BYTE, nullptr); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -326,7 +326,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); funcs->glBindTexture(GL_TEXTURE_2D, oldTexture); - if (pex != 0) + if (pex != nullptr) pex->transferMode(BrushDrawingMode); funcs->glDisable(GL_STENCIL_TEST); @@ -336,9 +336,9 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glViewport(0, 0, oldWidth, oldHeight); - QOpenGLShaderProgram *blitProgram = 0; - if (pex == 0) { - if (m_blitProgram == 0) { + QOpenGLShaderProgram *blitProgram = nullptr; + if (pex == nullptr) { + if (m_blitProgram == nullptr) { m_blitProgram = new QOpenGLShaderProgram; const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile; @@ -408,7 +408,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) funcs->glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)oldFbo); - if (pex != 0) { + if (pex != nullptr) { funcs->glViewport(0, 0, pex->width, pex->height); pex->updateClipScissorTest(); } else { @@ -424,7 +424,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) { QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (ctx == 0) { + if (ctx == nullptr) { qWarning("QOpenGLTextureGlyphCache::fillTexture: Called with no context"); return; } @@ -447,7 +447,7 @@ int QOpenGLTextureGlyphCache::glyphPadding() const int QOpenGLTextureGlyphCache::maxTextureWidth() const { QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); - if (ctx == 0) + if (ctx == nullptr) return QImageTextureGlyphCache::maxTextureWidth(); else return ctx->d_func()->maxTextureSize(); @@ -456,7 +456,7 @@ int QOpenGLTextureGlyphCache::maxTextureWidth() const int QOpenGLTextureGlyphCache::maxTextureHeight() const { QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); - if (ctx == 0) + if (ctx == nullptr) return QImageTextureGlyphCache::maxTextureHeight(); if (ctx->d_func()->workaround_brokenTexSubImage) @@ -469,10 +469,10 @@ void QOpenGLTextureGlyphCache::clear() { if (m_textureResource) m_textureResource->free(); - m_textureResource = 0; + m_textureResource = nullptr; delete m_blitProgram; - m_blitProgram = 0; + m_blitProgram = nullptr; m_w = 0; m_h = 0; diff --git a/src/gui/opengl/qopengltimerquery.cpp b/src/gui/opengl/qopengltimerquery.cpp index afd2e7887a..a4e10b42f7 100644 --- a/src/gui/opengl/qopengltimerquery.cpp +++ b/src/gui/opengl/qopengltimerquery.cpp @@ -77,8 +77,8 @@ class QOpenGLTimerQueryPrivate : public QObjectPrivate public: QOpenGLTimerQueryPrivate() : QObjectPrivate(), - context(0), - ext(0), + context(nullptr), + ext(nullptr), timeInterval(0), timer(0) { @@ -168,7 +168,7 @@ void QOpenGLTimerQueryPrivate::destroy() core->glDeleteQueries(1, &timer); timer = 0; - context = 0; + context = nullptr; } // GL_TIME_ELAPSED_EXT is not defined on OS X 10.6 @@ -310,14 +310,14 @@ QOpenGLTimerQuery::~QOpenGLTimerQuery() QOpenGLContext* ctx = QOpenGLContext::currentContext(); Q_D(QOpenGLTimerQuery); - QOpenGLContext *oldContext = 0; + QOpenGLContext *oldContext = nullptr; if (d->context != ctx) { oldContext = ctx; if (d->context->makeCurrent(oldContext->surface())) { ctx = d->context; } else { qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current"); - ctx = 0; + ctx = nullptr; } } @@ -468,9 +468,9 @@ public: : QObjectPrivate(), timers(), timeSamples(), - context(0), - core(0), - ext(0), + context(nullptr), + core(nullptr), + ext(nullptr), requestedSampleCount(2), currentSample(-1), timerQueryActive(false) @@ -556,10 +556,10 @@ void QOpenGLTimeMonitorPrivate::destroy() core->glDeleteQueries(timers.size(), timers.data()); timers.clear(); delete core; - core = 0; + core = nullptr; delete ext; - ext = 0; - context = 0; + ext = nullptr; + context = nullptr; } void QOpenGLTimeMonitorPrivate::recordSample() @@ -701,14 +701,14 @@ QOpenGLTimeMonitor::~QOpenGLTimeMonitor() QOpenGLContext* ctx = QOpenGLContext::currentContext(); Q_D(QOpenGLTimeMonitor); - QOpenGLContext *oldContext = 0; + QOpenGLContext *oldContext = nullptr; if (d->context != ctx) { oldContext = ctx; if (d->context->makeCurrent(oldContext->surface())) { ctx = d->context; } else { qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current"); - ctx = 0; + ctx = nullptr; } } diff --git a/src/gui/opengl/qopenglversionfunctions.cpp b/src/gui/opengl/qopenglversionfunctions.cpp index a3d3bb6bd1..5a108335a9 100644 --- a/src/gui/opengl/qopenglversionfunctions.cpp +++ b/src/gui/opengl/qopenglversionfunctions.cpp @@ -68,7 +68,7 @@ void CLASS::init() \ } QOpenGLVersionFunctionsStorage::QOpenGLVersionFunctionsStorage() - : backends(0) + : backends(nullptr) { } diff --git a/src/gui/opengl/qopenglversionfunctionsfactory.cpp b/src/gui/opengl/qopenglversionfunctionsfactory.cpp index fff5eea29c..ca7daedf34 100644 --- a/src/gui/opengl/qopenglversionfunctionsfactory.cpp +++ b/src/gui/opengl/qopenglversionfunctionsfactory.cpp @@ -153,7 +153,7 @@ QAbstractOpenGLFunctions *QOpenGLVersionFunctionsFactory::create(const QOpenGLVe else if (major == 1 && minor == 0) return new QOpenGLFunctions_1_0; } - return 0; + return nullptr; #else Q_UNUSED(versionProfile); return new QOpenGLFunctions_ES2; diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index f0837aff96..f15fe06ee8 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -101,7 +101,7 @@ public: QOpenGLVertexArrayObjectPrivate() : vao(0) , vaoFuncsType(NotSupported) - , context(0) + , context(nullptr) { } @@ -167,7 +167,7 @@ bool QOpenGLVertexArrayObjectPrivate::create() vaoFuncs.helper->glGenVertexArrays(1, &vao); } } else { - vaoFuncs.core_3_0 = 0; + vaoFuncs.core_3_0 = nullptr; vaoFuncsType = NotSupported; QSurfaceFormat format = ctx->format(); #ifndef QT_OPENGL_ES_2 @@ -200,17 +200,17 @@ void QOpenGLVertexArrayObjectPrivate::destroy() Q_Q(QOpenGLVertexArrayObject); QOpenGLContext *ctx = QOpenGLContext::currentContext(); - QOpenGLContext *oldContext = 0; - QSurface *oldContextSurface = 0; + QOpenGLContext *oldContext = nullptr; + QSurface *oldContextSurface = nullptr; QScopedPointer<QOffscreenSurface> offscreenSurface; if (context && context != ctx) { oldContext = ctx; - oldContextSurface = ctx ? ctx->surface() : 0; + oldContextSurface = ctx ? ctx->surface() : nullptr; // Before going through the effort of creating an offscreen surface // check that we are on the GUI thread because otherwise many platforms // will not able to create that offscreen surface. if (QThread::currentThread() != qGuiApp->thread()) { - ctx = 0; + ctx = nullptr; } else { // Cannot just make the current surface current again with another context. // The format may be incompatible and some platforms (iOS) may impose @@ -223,14 +223,14 @@ void QOpenGLVertexArrayObjectPrivate::destroy() ctx = context; } else { qWarning("QOpenGLVertexArrayObject::destroy() failed to make VAO's context current"); - ctx = 0; + ctx = nullptr; } } } if (context) { QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = 0; + context = nullptr; } if (vao && ctx) { diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp index 8e2013c24f..494104251f 100644 --- a/src/gui/painting/qblittable.cpp +++ b/src/gui/painting/qblittable.cpp @@ -46,7 +46,7 @@ class QBlittablePrivate { public: QBlittablePrivate(const QSize &size, QBlittable::Capabilities caps) - : caps(caps), m_size(size), locked(false), cachedImg(0) + : caps(caps), m_size(size), locked(false), cachedImg(nullptr) {} QBlittable::Capabilities caps; QSize m_size; diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index abb3268dfa..b23fb45952 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -179,7 +179,7 @@ struct QTexturedBrushData : public QBrushData { QTexturedBrushData() { m_has_pixmap_texture = false; - m_pixmap = 0; + m_pixmap = nullptr; } ~QTexturedBrushData() { delete m_pixmap; @@ -189,7 +189,7 @@ struct QTexturedBrushData : public QBrushData delete m_pixmap; if (pm.isNull()) { - m_pixmap = 0; + m_pixmap = nullptr; m_has_pixmap_texture = false; } else { m_pixmap = new QPixmap(pm); @@ -202,7 +202,7 @@ struct QTexturedBrushData : public QBrushData void setImage(const QImage &image) { m_image = image; delete m_pixmap; - m_pixmap = 0; + m_pixmap = nullptr; m_has_pixmap_texture = false; } @@ -360,7 +360,7 @@ public: { if (!brush->ref.deref()) delete brush; - brush = 0; + brush = nullptr; } }; @@ -831,7 +831,7 @@ const QGradient *QBrush::gradient() const || d->style == Qt::ConicalGradientPattern) { return &static_cast<const QGradientBrushData *>(d.data())->gradient; } - return 0; + return nullptr; } Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush) @@ -968,7 +968,7 @@ bool QBrush::operator==(const QBrush &b) const // but does not share the same data in memory. Since equality is likely to // be used to avoid iterating over the data for a texture update, this should // still be better than doing an accurate comparison. - const QPixmap *us = 0, *them = 0; + const QPixmap *us = nullptr, *them = nullptr; qint64 cacheKey1, cacheKey2; if (qHasPixmapTexture(*this)) { us = (static_cast<QTexturedBrushData *>(d.data()))->m_pixmap; @@ -1335,7 +1335,7 @@ QDataStream &operator>>(QDataStream &s, QBrush &b) \internal */ QGradient::QGradient() - : m_type(NoGradient), dummy(0) + : m_type(NoGradient), dummy(nullptr) { } diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 0fb89a75b5..bece814a6f 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -225,7 +225,7 @@ static StrokeLine strokeLine(int strokeSelection) break; default: Q_ASSERT(false); - stroke = 0; + stroke = nullptr; } return stroke; } @@ -252,8 +252,8 @@ void QCosmeticStroker::setup() const QVector<qreal> &penPattern = state->lastPen.dashPattern(); if (penPattern.isEmpty()) { Q_ASSERT(!pattern && !reversePattern); - pattern = 0; - reversePattern = 0; + pattern = nullptr; + reversePattern = nullptr; patternLength = 0; patternSize = 0; } else { diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e8d129d047..6819545bda 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -310,7 +310,7 @@ inline void QT_FASTCALL storePixel<QPixelLayout::BPP24>(uchar *dest, int index, typedef uint (QT_FASTCALL *FetchPixelFunc)(const uchar *src, int index); static const FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = { - 0, // BPPNone + nullptr, // BPPNone fetchPixel<QPixelLayout::BPP1MSB>, // BPP1MSB fetchPixel<QPixelLayout::BPP1LSB>, // BPP1LSB fetchPixel<QPixelLayout::BPP8>, // BPP8 @@ -1713,10 +1713,10 @@ static uint *QT_FASTCALL destFetchUndefined(uint *buffer, QRasterBuffer *, int, static DestFetchProc destFetchProc[QImage::NImageFormats] = { - 0, // Format_Invalid + nullptr, // Format_Invalid destFetchMono, // Format_Mono, destFetchMonoLsb, // Format_MonoLSB - 0, // Format_Indexed8 + nullptr, // Format_Indexed8 destFetchARGB32P, // Format_RGB32 destFetch, // Format_ARGB32, destFetchARGB32P, // Format_ARGB32_Premultiplied @@ -1764,10 +1764,10 @@ static QRgba64 * QT_FASTCALL destFetch64Undefined(QRgba64 *buffer, QRasterBuffer static DestFetchProc64 destFetchProc64[QImage::NImageFormats] = { - 0, // Format_Invalid - 0, // Format_Mono, - 0, // Format_MonoLSB - 0, // Format_Indexed8 + nullptr, // Format_Invalid + nullptr, // Format_Mono, + nullptr, // Format_MonoLSB + nullptr, // Format_Indexed8 destFetch64, // Format_RGB32 destFetch64, // Format_ARGB32, destFetch64, // Format_ARGB32_Premultiplied @@ -1905,13 +1905,13 @@ static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, con static DestStoreProc destStoreProc[QImage::NImageFormats] = { - 0, // Format_Invalid + nullptr, // Format_Invalid destStoreMono, // Format_Mono, destStoreMonoLsb, // Format_MonoLSB - 0, // Format_Indexed8 - 0, // Format_RGB32 + nullptr, // Format_Indexed8 + nullptr, // Format_RGB32 destStore, // Format_ARGB32, - 0, // Format_ARGB32_Premultiplied + nullptr, // Format_ARGB32_Premultiplied destStoreRGB16, // Format_RGB16 destStore, // Format_ARGB8565_Premultiplied destStore, // Format_RGB666 @@ -1955,10 +1955,10 @@ static void QT_FASTCALL destStore64RGBA64(QRasterBuffer *rasterBuffer, int x, in static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = { - 0, // Format_Invalid - 0, // Format_Mono, - 0, // Format_MonoLSB - 0, // Format_Indexed8 + nullptr, // Format_Invalid + nullptr, // Format_Mono, + nullptr, // Format_MonoLSB + nullptr, // Format_Indexed8 destStore64, // Format_RGB32 destStore64, // Format_ARGB32, destStore64, // Format_ARGB32_Premultiplied @@ -1980,9 +1980,9 @@ static DestStoreProc64 destStoreProc64[QImage::NImageFormats] = destStore64, // Format_A2RGB30_Premultiplied destStore64, // Format_Alpha8 destStore64, // Format_Grayscale8 - 0, // Format_RGBX64 + nullptr, // Format_RGBX64 destStore64RGBA64, // Format_RGBA64 - 0, // Format_RGBA64_Premultiplied + nullptr, // Format_RGBA64_Premultiplied destStore64, // Format_Grayscale16 destStore64, // Format_BGR888 }; @@ -3627,9 +3627,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf #endif fetcher(sbuf1, sbuf2, len, data->texture, fx, fy, fdx, fdy); - layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, nullptr); if (disty) - layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, nullptr); for (int i = 0; i < len; ++i) { int distx = (fx & 0x0000ffff); @@ -3662,8 +3662,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf fetcher(sbuf1, sbuf2, len, data->texture, fx, fy, fdx, fdy); - layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, nullptr); + layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, nullptr); for (int i = 0; i < len; ++i) { int distx = (fx & 0x0000ffff); @@ -3727,8 +3727,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64_uint32(QRgba64 *buf fw += fdw; } - layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, 0); - layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, 0); + layout->convertToRGBA64PM(buf1, sbuf1, len * 2, clut, nullptr); + layout->convertToRGBA64PM(buf2, sbuf2, len * 2, clut, nullptr); for (int i = 0; i < len; ++i) { int distx = distxs[i]; @@ -3907,7 +3907,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co // FetchUntransformed can have more specialized methods added depending on SIMD features. static SourceFetchProc sourceFetchUntransformed[QImage::NImageFormats] = { - 0, // Invalid + nullptr, // Invalid fetchUntransformed, // Mono fetchUntransformed, // MonoLsb fetchUntransformed, // Indexed8 @@ -4348,9 +4348,9 @@ static inline Operator getOperator(const QSpanData *data, const QSpan *spans, in switch(data->type) { case QSpanData::Solid: solidSource = data->solidColor.isOpaque(); - op.srcFetch = 0; + op.srcFetch = nullptr; #if QT_CONFIG(raster_64bit) - op.srcFetch64 = 0; + op.srcFetch64 = nullptr; #endif break; case QSpanData::LinearGradient: @@ -4721,7 +4721,7 @@ struct QBlendBase QBlendBase(QSpanData *d, const Operator &o) : data(d) , op(o) - , dest(0) + , dest(nullptr) { } @@ -6397,21 +6397,21 @@ static void qt_rectfill_quint64(QRasterBuffer *rasterBuffer, DrawHelper qDrawHelper[QImage::NImageFormats] = { // Format_Invalid, - { 0, 0, 0, 0, 0 }, + { nullptr, nullptr, nullptr, nullptr, nullptr }, // Format_Mono, { blend_color_generic, - 0, 0, 0, 0 + nullptr, nullptr, nullptr, nullptr }, // Format_MonoLSB, { blend_color_generic, - 0, 0, 0, 0 + nullptr, nullptr, nullptr, nullptr }, // Format_Indexed8, { blend_color_generic, - 0, 0, 0, 0 + nullptr, nullptr, nullptr, nullptr }, // Format_RGB32, { @@ -6448,7 +6448,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB8565_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6456,7 +6456,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB666 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6464,7 +6464,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB6666_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6472,7 +6472,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB555 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6480,7 +6480,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB8555_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6488,7 +6488,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB888 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 @@ -6496,7 +6496,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGB444 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6504,7 +6504,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_ARGB4444_Premultiplied { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6568,7 +6568,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_Alpha8 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_alpha @@ -6576,7 +6576,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_Grayscale8 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_gray @@ -6584,7 +6584,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGBX64 { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint64 @@ -6592,7 +6592,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGBA64 { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint64 @@ -6600,7 +6600,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_RGBA64_Premultiplied { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint64 @@ -6608,7 +6608,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_Grayscale16 { blend_color_generic_rgb64, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint16 @@ -6616,7 +6616,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = // Format_BGR888 { blend_color_generic, - 0, + nullptr, qt_alphamapblit_generic, qt_alphargbblit_generic, qt_rectfill_quint24 diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp index 0c0df0fb13..7cd700a84a 100644 --- a/src/gui/painting/qemulationpaintengine.cpp +++ b/src/gui/painting/qemulationpaintengine.cpp @@ -271,7 +271,7 @@ void QEmulationPaintEngine::fillBGRect(const QRectF &r) { qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); real_engine->fill(vp, state()->bgBrush); } diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index 0d7205b483..2e2f65b483 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -223,7 +223,7 @@ static QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi) delete[] isi->yapoints; delete isi; } - return 0; + return nullptr; } static QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, @@ -238,7 +238,7 @@ static QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, isi = new QImageScaleInfo; if (!isi) - return 0; + return nullptr; isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1); diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index 9cb787fb2c..685fbbb37a 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -406,9 +406,9 @@ void qt_memrotate270_64(const uchar *srcPixels, int w, int h, int sbpl, uchar *d MemRotateFunc qMemRotateFunctions[QPixelLayout::BPPCount][3] = // 90, 180, 270 { - { 0, 0, 0 }, // BPPNone, - { 0, 0, 0 }, // BPP1MSB, - { 0, 0, 0 }, // BPP1LSB, + { nullptr, nullptr, nullptr }, // BPPNone, + { nullptr, nullptr, nullptr }, // BPP1MSB, + { nullptr, nullptr, nullptr }, // BPP1LSB, { qt_memrotate90_8, qt_memrotate180_8, qt_memrotate270_8 }, // BPP8, { qt_memrotate90_16, qt_memrotate180_16, qt_memrotate270_16 }, // BPP16, { qt_memrotate90_24, qt_memrotate180_24, qt_memrotate270_24 }, // BPP24 diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index 2074f98069..67e450986d 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -209,7 +209,7 @@ void QOutlineMapper::endOutline() elements[i] = m_transform.map(elements[i]); } else { const QVectorPath vp((qreal *)elements, m_elements.size(), - m_element_types.size() ? m_element_types.data() : 0); + m_element_types.size() ? m_element_types.data() : nullptr); QPainterPath path = vp.convertToPainterPath(); path = m_transform.map(path); if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL)) diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index c98ca8a1fb..d73a66b790 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -394,7 +394,7 @@ static QString qt_keyForPageSizeId(QPageSize::PageSizeId id) } // Return id name for PPD Key -static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match = 0) +static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match = nullptr) { if (ppdKey.isEmpty()) return QPageSize::Custom; @@ -415,7 +415,7 @@ static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match } // Return id name for Windows ID -static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = 0) +static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = nullptr) { // If outside known values then is Custom if (windowsId <= DMPAPER_NONE || windowsId > DMPAPER_LAST) @@ -770,7 +770,7 @@ QPageSizePrivate::QPageSizePrivate(const QSize &pointSize, const QString &name, m_units(QPageSize::Point) { if (pointSize.isValid()) { - QPageSize::PageSizeId id = qt_idForPointSize(pointSize, matchPolicy, 0); + QPageSize::PageSizeId id = qt_idForPointSize(pointSize, matchPolicy, nullptr); id == QPageSize::Custom ? init(pointSize, name) : init(id, name); } } @@ -782,7 +782,7 @@ QPageSizePrivate::QPageSizePrivate(const QSizeF &size, QPageSize::Unit units, m_units(QPageSize::Point) { if (size.isValid()) { - QPageSize::PageSizeId id = qt_idForSize(size, units, matchPolicy, 0); + QPageSize::PageSizeId id = qt_idForSize(size, units, matchPolicy, nullptr); id == QPageSize::Custom ? init(size, units, name) : init(id, name); } } @@ -793,10 +793,10 @@ QPageSizePrivate::QPageSizePrivate(const QString &key, const QSize &pointSize, c m_units(QPageSize::Point) { if (!key.isEmpty() && pointSize.isValid()) { - QPageSize::PageSizeId id = qt_idForPpdKey(key, 0); + QPageSize::PageSizeId id = qt_idForPpdKey(key, nullptr); // If not a known PPD key, check if size is a standard PPD size if (id == QPageSize::Custom) - id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, 0); + id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, nullptr); id == QPageSize::Custom ? init(pointSize, name) : init(id, name); m_key = key; } @@ -808,10 +808,10 @@ QPageSizePrivate::QPageSizePrivate(int windowsId, const QSize &pointSize, const m_units(QPageSize::Point) { if (windowsId > 0 && pointSize.isValid()) { - QPageSize::PageSizeId id = qt_idForWindowsID(windowsId, 0); + QPageSize::PageSizeId id = qt_idForWindowsID(windowsId, nullptr); // If not a known Windows ID, check if size is a standard PPD size if (id == QPageSize::Custom) - id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, 0); + id = qt_idForPointSize(pointSize, QPageSize::FuzzyMatch, nullptr); id == QPageSize::Custom ? init(pointSize, name) : init(id, name); m_windowsId = windowsId; } @@ -1753,7 +1753,7 @@ QString QPageSize::name(PageSizeId pageSizeId) QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, SizeMatchPolicy matchPolicy) { - return qt_idForPointSize(pointSize, matchPolicy, 0); + return qt_idForPointSize(pointSize, matchPolicy, nullptr); } /*! @@ -1769,7 +1769,7 @@ QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, SizeMatchPolicy matc QPageSize::PageSizeId QPageSize::id(const QSizeF &size, Unit units, SizeMatchPolicy matchPolicy) { - return qt_idForSize(size, units, matchPolicy, 0); + return qt_idForSize(size, units, matchPolicy, nullptr); } /*! diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp index 0ddfba6ee9..4afb89b52e 100644 --- a/src/gui/painting/qpaintdevice.cpp +++ b/src/gui/painting/qpaintdevice.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QPaintDevice::QPaintDevice() noexcept { - reserved = 0; + reserved = nullptr; painters = 0; } @@ -67,7 +67,7 @@ void QPaintDevice::initPainter(QPainter *) const */ QPaintDevice *QPaintDevice::redirected(QPoint *) const { - return 0; + return nullptr; } /*! @@ -75,7 +75,7 @@ QPaintDevice *QPaintDevice::redirected(QPoint *) const */ QPainter *QPaintDevice::sharedPainter() const { - return 0; + return nullptr; } Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric) diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index bfe1c9cadf..1785fcd12d 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -305,7 +305,7 @@ void QPaintEngine::syncState() static_cast<QPaintEngineEx *>(this)->sync(); } -static QPaintEngine *qt_polygon_recursion = 0; +static QPaintEngine *qt_polygon_recursion = nullptr; struct QT_Point { int x; int y; @@ -334,7 +334,7 @@ void QPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDra p[i].y = qRound(points[i].y()); } drawPolygon((QPoint *)p.data(), pointCount, mode); - qt_polygon_recursion = 0; + qt_polygon_recursion = nullptr; } struct QT_PointF { @@ -363,7 +363,7 @@ void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDraw p[i].y = points[i].y(); } drawPolygon((QPointF *)p.data(), pointCount, mode); - qt_polygon_recursion = 0; + qt_polygon_recursion = nullptr; } /*! @@ -691,7 +691,7 @@ void QPaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF */ QPaintEngine::QPaintEngine(PaintEngineFeatures caps) - : state(0), + : state(nullptr), gccaps(caps), active(0), selfDestruct(false), @@ -706,7 +706,7 @@ QPaintEngine::QPaintEngine(PaintEngineFeatures caps) */ QPaintEngine::QPaintEngine(QPaintEnginePrivate &dptr, PaintEngineFeatures caps) - : state(0), + : state(nullptr), gccaps(caps), active(0), selfDestruct(false), @@ -728,7 +728,7 @@ QPaintEngine::~QPaintEngine() */ QPainter *QPaintEngine::painter() const { - return state ? state->painter() : 0; + return state ? state->painter() : nullptr; } /*! diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 40c822076b..bc65ed56e3 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -115,17 +115,17 @@ public: pts[7] = bottom; } inline QRectVectorPath(const QRect &r) - : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) + : QVectorPath(pts, 4, nullptr, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) { set(r); } inline QRectVectorPath(const QRectF &r) - : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) + : QVectorPath(pts, 4, nullptr, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) { set(r); } inline QRectVectorPath() - : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) + : QVectorPath(pts, 4, nullptr, QVectorPath::RectangleHint | QVectorPath::ImplicitClose) { } qreal pts[8]; @@ -433,7 +433,7 @@ void QRasterPaintEngine::init() break; default: qWarning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType()); - d->device = 0; + d->device = nullptr; return; } @@ -601,7 +601,7 @@ QRasterPaintEngineState::~QRasterPaintEngineState() QRasterPaintEngineState::QRasterPaintEngineState() { - stroker = 0; + stroker = nullptr; fillFlags = 0; strokeFlags = 0; @@ -621,7 +621,7 @@ QRasterPaintEngineState::QRasterPaintEngineState() flags.tx_noshear = true; flags.fast_images = true; - clip = 0; + clip = nullptr; flags.has_clip_ownership = false; dirty = 0; @@ -643,8 +643,8 @@ QRasterPaintEngineState::QRasterPaintEngineState(QRasterPaintEngineState &s) , dirty(s.dirty) , flag_bits(s.flag_bits) { - brushData.tempImage = 0; - penData.tempImage = 0; + brushData.tempImage = nullptr; + penData.tempImage = nullptr; flags.has_clip_ownership = false; } @@ -759,7 +759,7 @@ void QRasterPaintEngine::updatePen(const QPen &pen) d->dashStroker->setDashOffset(pen.dashOffset()); s->stroker = d->dashStroker.data(); } else { - s->stroker = 0; + s->stroker = nullptr; } ensureRasterState(); // needed because of tx_noshear... @@ -1207,7 +1207,7 @@ static void qrasterpaintengine_state_setNoClip(QRasterPaintEngineState *s) { if (s->flags.has_clip_ownership) delete s->clip; - s->clip = 0; + s->clip = nullptr; s->flags.has_clip_ownership = false; } @@ -1279,14 +1279,14 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) // intersect with, in which case we simplify the operation to // a replace... Qt::ClipOperation isectOp = Qt::IntersectClip; - if (base == 0) + if (base == nullptr) isectOp = Qt::ReplaceClip; QClipData *newClip = new QClipData(d->rasterBuffer->height()); newClip->initialize(); ClipData clipData = { base, newClip, isectOp }; ensureOutlineMapper(); - d->rasterize(d->outlineMapper->convertPath(path), qt_span_clip, &clipData, 0); + d->rasterize(d->outlineMapper->convertPath(path), qt_span_clip, &clipData, nullptr); newClip->fixup(); @@ -1334,7 +1334,7 @@ bool QRasterPaintEngine::setClipRectInDeviceCoords(const QRect &r, Qt::ClipOpera QRect clipRect = qrect_normalized(r) & d->deviceRect; QRasterPaintEngineState *s = state(); - if (op == Qt::ReplaceClip || s->clip == 0) { + if (op == Qt::ReplaceClip || s->clip == nullptr) { // No current clip, hence we intersect with sysclip and be // done with it... @@ -1970,7 +1970,7 @@ void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, Poly } // Compose polygon fill.., - QVectorPath vp((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath vp((const qreal *) points, pointCount, nullptr, QVectorPath::polygonFlags(mode)); ensureOutlineMapper(); QT_FT_Outline *outline = d->outlineMapper->convertPath(vp); @@ -2011,7 +2011,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly // Do the outline... if (s->penData.blend) { - QVectorPath vp((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath vp((const qreal *) points, pointCount, nullptr, QVectorPath::polygonFlags(mode)); if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding); @@ -2075,7 +2075,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg QVarLengthArray<qreal> fpoints(count); for (int i=0; i<count; ++i) fpoints[i] = ((const int *) points)[i]; - QVectorPath vp((qreal *) fpoints.data(), pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath vp((qreal *) fpoints.data(), pointCount, nullptr, QVectorPath::polygonFlags(mode)); if (s->flags.fast_pen) { QCosmeticStroker stroker(s, d->deviceRect, d->deviceRectUnclipped); @@ -2695,14 +2695,14 @@ void QRasterPaintEngine::alphaPenBlt(const void* src, int bpl, int depth, int rx } else if (depth == 8) { if (s->penData.alphamapBlit) { s->penData.alphamapBlit(rb, rx, ry, s->penData.solidColor, - scanline, w, h, bpl, 0, useGammaCorrection); + scanline, w, h, bpl, nullptr, useGammaCorrection); return; } } else if (depth == 32) { // (A)RGB Alpha mask where the alpha component is not used. if (s->penData.alphaRGBBlit) { s->penData.alphaRGBBlit(rb, rx, ry, s->penData.solidColor, - (const uint *) scanline, w, h, bpl / 4, 0, useGammaCorrection); + (const uint *) scanline, w, h, bpl / 4, nullptr, useGammaCorrection); return; } } @@ -2917,10 +2917,10 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None ? fontEngine->glyphFormat : d->glyphCacheFormat; QImageTextureGlyphCache *cache = - static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(0, glyphFormat, s->matrix, QColor(s->penData.solidColor))); + static_cast<QImageTextureGlyphCache *>(fontEngine->glyphCache(nullptr, glyphFormat, s->matrix, QColor(s->penData.solidColor))); if (!cache) { cache = new QImageTextureGlyphCache(glyphFormat, s->matrix, QColor(s->penData.solidColor)); - fontEngine->setGlyphCache(0, cache); + fontEngine->setGlyphCache(nullptr, cache); } cache->populate(fontEngine, numGlyphs, glyphs, positions); @@ -3672,7 +3672,7 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, int rasterPoolSize = MINIMUM_POOL_SIZE; uchar rasterPoolOnStack[MINIMUM_POOL_SIZE + 0xf]; uchar *rasterPoolBase = alignAddress(rasterPoolOnStack, 0xf); - uchar *rasterPoolOnHeap = 0; + uchar *rasterPoolOnHeap = nullptr; qt_ft_grays_raster.raster_reset(*grayRaster.data(), rasterPoolBase, rasterPoolSize); @@ -3684,13 +3684,13 @@ void QRasterPaintEnginePrivate::rasterize(QT_FT_Outline *outline, deviceRect.y() + deviceRect.height() }; QT_FT_Raster_Params rasterParams; - rasterParams.target = 0; + rasterParams.target = nullptr; rasterParams.source = outline; rasterParams.flags = QT_FT_RASTER_FLAG_CLIP; - rasterParams.gray_spans = 0; - rasterParams.black_spans = 0; - rasterParams.bit_test = 0; - rasterParams.bit_set = 0; + rasterParams.gray_spans = nullptr; + rasterParams.black_spans = nullptr; + rasterParams.bit_test = nullptr; + rasterParams.bit_set = nullptr; rasterParams.user = data; rasterParams.clip_box = clip_box; @@ -3843,10 +3843,10 @@ QImage::Format QRasterBuffer::prepare(QImage *image) QClipData::QClipData(int height) { clipSpanHeight = height; - m_clipLines = 0; + m_clipLines = nullptr; allocated = 0; - m_spans = 0; + m_spans = nullptr; xmin = xmax = ymin = ymax = 0; count = 0; @@ -3890,7 +3890,7 @@ void QClipData::initialize() const int currMaxY = currMinY + rects[firstInBand].height(); while (y < currMinY) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } @@ -3922,7 +3922,7 @@ void QClipData::initialize() Q_ASSERT(count <= allocated); while (y < clipSpanHeight) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } @@ -3936,7 +3936,7 @@ void QClipData::initialize() if (hasRectClip) { int y = 0; while (y < ymin) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } @@ -3957,19 +3957,19 @@ void QClipData::initialize() } while (y < clipSpanHeight) { - m_clipLines[y].spans = 0; + m_clipLines[y].spans = nullptr; m_clipLines[y].count = 0; ++y; } } } QT_CATCH(...) { free(m_spans); // have to free m_spans again or someone might think that we were successfully initialized. - m_spans = 0; + m_spans = nullptr; QT_RETHROW; } } QT_CATCH(...) { free(m_clipLines); // same for clipLines - m_clipLines = 0; + m_clipLines = nullptr; QT_RETHROW; } } @@ -4044,7 +4044,7 @@ void QClipData::setClipRect(const QRect &rect) if (m_spans) { free(m_spans); - m_spans = 0; + m_spans = nullptr; } // qDebug() << xmin << xmax << ymin << ymax; @@ -4074,7 +4074,7 @@ void QClipData::setClipRegion(const QRegion ®ion) if (m_spans) { free(m_spans); - m_spans = 0; + m_spans = nullptr; } } @@ -4532,7 +4532,7 @@ void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe) bilinear = false; m11 = m22 = m33 = 1.; m12 = m13 = m21 = m23 = dx = dy = 0.0; - clip = pe ? pe->d_func()->clip() : 0; + clip = pe ? pe->d_func()->clip() : nullptr; } Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); @@ -4668,15 +4668,15 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode void QSpanData::adjustSpanMethods() { - bitmapBlit = 0; - alphamapBlit = 0; - alphaRGBBlit = 0; + bitmapBlit = nullptr; + alphamapBlit = nullptr; + alphaRGBBlit = nullptr; - fillRect = 0; + fillRect = nullptr; switch(type) { case None: - unclipped_blend = 0; + unclipped_blend = nullptr; break; case Solid: { const DrawHelper &drawHelper = qDrawHelper[rasterBuffer->format]; @@ -4695,17 +4695,17 @@ void QSpanData::adjustSpanMethods() case Texture: unclipped_blend = qBlendTexture; if (!texture.imageData) - unclipped_blend = 0; + unclipped_blend = nullptr; break; } // setup clipping if (!unclipped_blend) { - blend = 0; + blend = nullptr; } else if (!clip) { blend = unclipped_blend; } else if (clip->hasRectClip) { - blend = clip->clipRect.isEmpty() ? 0 : qt_span_fill_clipRect; + blend = clip->clipRect.isEmpty() ? nullptr : qt_span_fill_clipRect; } else { blend = qt_span_fill_clipped; } @@ -4748,7 +4748,7 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _ { const QImageData *d = const_cast<QImage *>(image)->data_ptr(); if (!d || d->height == 0) { - texture.imageData = 0; + texture.imageData = nullptr; texture.width = 0; texture.height = 0; texture.x1 = 0; @@ -4757,7 +4757,7 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _ texture.y2 = 0; texture.bytesPerLine = 0; texture.format = QImage::Format_Invalid; - texture.colorTable = 0; + texture.colorTable = nullptr; texture.hasAlpha = alpha != 256; } else { texture.imageData = d->data; @@ -4779,7 +4779,7 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _ texture.bytesPerLine = d->bytes_per_line; texture.format = d->format; - texture.colorTable = (d->format <= QImage::Format_Indexed8 && !d->colortable.isEmpty()) ? &d->colortable : 0; + texture.colorTable = (d->format <= QImage::Format_Indexed8 && !d->colortable.isEmpty()) ? &d->colortable : nullptr; texture.hasAlpha = image->hasAlphaChannel() || alpha != 256; } texture.const_alpha = alpha; diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 722afaf119..5d8f89eadd 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -115,7 +115,7 @@ QVectorPath::CacheEntry *QVectorPath::addCacheData(QPaintEngineEx *engine, void qvectorpath_cache_cleanup cleanup) const{ Q_ASSERT(!lookupCacheData(engine)); if ((m_hints & IsCachedHint) == 0) { - m_cache = 0; + m_cache = nullptr; m_hints |= IsCachedHint; } CacheEntry *e = new CacheEntry; @@ -162,8 +162,8 @@ struct StrokeHandler { QPaintEngineExPrivate::QPaintEngineExPrivate() : dasher(&stroker), - strokeHandler(0), - activeStroker(0), + strokeHandler(nullptr), + activeStroker(nullptr), strokerPen(Qt::NoPen) { } @@ -211,7 +211,7 @@ void QPaintEngineExPrivate::replayClipOperations() right, info.rectf.y(), right, bottom, info.rectf.x(), bottom }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); q->clip(vp, info.operation); break; } @@ -418,7 +418,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) if (style == Qt::SolidLine) { d->activeStroker = &d->stroker; } else if (style == Qt::NoPen) { - d->activeStroker = 0; + d->activeStroker = nullptr; } else { d->dasher.setDashPattern(pen.dashPattern()); d->dasher.setDashOffset(pen.dashOffset()); @@ -616,7 +616,7 @@ void QPaintEngineEx::clip(const QRect &r, Qt::ClipOperation op) right, bottom, qreal(r.x()), bottom, qreal(r.x()), qreal(r.y()) }; - QVectorPath vp(pts, 5, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 5, nullptr, QVectorPath::RectangleHint); clip(vp, op); } @@ -687,7 +687,7 @@ void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) void QPaintEngineEx::clip(const QPainterPath &path, Qt::ClipOperation op) { if (path.isEmpty()) { - QVectorPath vp(0, 0); + QVectorPath vp(nullptr, 0); clip(vp, op); } else { clip(qtVectorPathForPath(path), op); @@ -698,7 +698,7 @@ void QPaintEngineEx::fillRect(const QRectF &r, const QBrush &brush) { qreal pts[] = { r.x(), r.y(), r.x() + r.width(), r.y(), r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); fill(vp, brush); } @@ -719,7 +719,7 @@ void QPaintEngineEx::drawRects(const QRect *rects, int rectCount) right, bottom, qreal(r.x()), bottom, qreal(r.x()), qreal(r.y()) }; - QVectorPath vp(pts, 5, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 5, nullptr, QVectorPath::RectangleHint); draw(vp); } } @@ -735,7 +735,7 @@ void QPaintEngineEx::drawRects(const QRectF *rects, int rectCount) right, bottom, r.x(), bottom, r.x(), r.y() }; - QVectorPath vp(pts, 5, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 5, nullptr, QVectorPath::RectangleHint); draw(vp); } } @@ -871,7 +871,7 @@ void QPaintEngineEx::drawPoints(const QPointF *points, int pointCount) } else { for (int i=0; i<pointCount; ++i) { qreal pts[] = { points[i].x(), points[i].y(), points[i].x() + qreal(1/63.), points[i].y() }; - QVectorPath path(pts, 2, 0); + QVectorPath path(pts, 2, nullptr); stroke(path, pen); } } @@ -903,7 +903,7 @@ void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount) for (int i=0; i<pointCount; ++i) { qreal pts[] = { qreal(points[i].x()), qreal(points[i].y()), qreal(points[i].x() +1/63.), qreal(points[i].y()) }; - QVectorPath path(pts, 2, 0); + QVectorPath path(pts, 2, nullptr); stroke(path, pen); } } @@ -912,7 +912,7 @@ void QPaintEngineEx::drawPoints(const QPoint *points, int pointCount) void QPaintEngineEx::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) { - QVectorPath path((const qreal *) points, pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath path((const qreal *) points, pointCount, nullptr, QVectorPath::polygonFlags(mode)); if (mode == PolylineMode) stroke(path, state()->pen); @@ -928,7 +928,7 @@ void QPaintEngineEx::drawPolygon(const QPoint *points, int pointCount, PolygonDr for (int i=0; i<count; ++i) pts[i] = ((const int *) points)[i]; - QVectorPath path(pts.data(), pointCount, 0, QVectorPath::polygonFlags(mode)); + QVectorPath path(pts.data(), pointCount, nullptr, QVectorPath::polygonFlags(mode)); if (mode == PolylineMode) stroke(path, state()->pen); @@ -960,7 +960,7 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con r.x() + r.width(), r.y() + r.height(), r.x(), r.y() + r.height() }; - QVectorPath path(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath path(pts, 4, nullptr, QVectorPath::RectangleHint); fill(path, brush); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index d5cec1b45a..f70bbbd7d2 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -330,7 +330,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q) original = new QPainterPrivate(q); } - d_ptrs[refcount - 1] = 0; + d_ptrs[refcount - 1] = nullptr; q->restore(); q->d_ptr.take(); q->d_ptr.reset(original); @@ -338,7 +338,7 @@ void QPainterPrivate::detachPainterPrivate(QPainter *q) if (emulationEngine) { extended = emulationEngine->real_engine; delete emulationEngine; - emulationEngine = 0; + emulationEngine = nullptr; } } @@ -1485,9 +1485,9 @@ QPainter::QPainter() */ QPainter::QPainter(QPaintDevice *pd) - : d_ptr(0) + : d_ptr(nullptr) { - Q_ASSERT(pd != 0); + Q_ASSERT(pd != nullptr); if (!QPainterPrivate::attachPainterPrivate(this, pd)) { d_ptr.reset(new QPainterPrivate(this)); begin(pd); @@ -1718,9 +1718,9 @@ static inline void qt_cleanup_painter_state(QPainterPrivate *d) { qDeleteAll(d->states); d->states.clear(); - d->state = 0; - d->engine = 0; - d->device = 0; + d->state = nullptr; + d->engine = nullptr; + d->device = nullptr; } bool QPainter::begin(QPaintDevice *pd) @@ -1769,13 +1769,13 @@ bool QPainter::begin(QPaintDevice *pd) d->device = pd; - d->extended = d->engine->isExtended() ? static_cast<QPaintEngineEx *>(d->engine) : 0; + d->extended = d->engine->isExtended() ? static_cast<QPaintEngineEx *>(d->engine) : nullptr; if (d->emulationEngine) d->emulationEngine->real_engine = d->extended; // Setup new state... Q_ASSERT(!d->state); - d->state = d->extended ? d->extended->createState(0) : new QPainterState; + d->state = d->extended ? d->extended->createState(nullptr) : new QPainterState; d->state->painter = this; d->states.push_back(d->state); @@ -1915,11 +1915,11 @@ bool QPainter::end() if (d->engine->isActive()) { ended = d->engine->end(); - d->updateState(0); + d->updateState(nullptr); --d->device->painters; if (d->device->painters == 0) { - d->engine->setPaintDevice(0); + d->engine->setPaintDevice(nullptr); d->engine->setActive(false); } } @@ -1935,11 +1935,11 @@ bool QPainter::end() if (d->emulationEngine) { delete d->emulationEngine; - d->emulationEngine = 0; + d->emulationEngine = nullptr; } if (d->extended) { - d->extended = 0; + d->extended = nullptr; } qt_cleanup_painter_state(d); @@ -2761,7 +2761,7 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) right, rect.y(), right, bottom, rect.x(), bottom }; - QVectorPath vp(pts, 4, 0, QVectorPath::RectangleHint); + QVectorPath vp(pts, 4, nullptr, QVectorPath::RectangleHint); d->state->clipEnabled = true; d->extended->clip(vp, op); if (op == Qt::ReplaceClip || op == Qt::NoClip) @@ -5642,7 +5642,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positio QFixed width = rightMost - leftMost; - if (extended != 0 && state->matrix.isAffine()) { + if (extended != nullptr && state->matrix.isAffine()) { QStaticTextItem staticTextItem; staticTextItem.color = state->pen.color(); staticTextItem.font = state->font; @@ -5685,7 +5685,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, QFixedPoint *positio drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()), fontEngine, - 0, // textEngine + nullptr, // textEngine (underline ? QTextCharFormat::SingleUnderline : QTextCharFormat::NoUnderline), @@ -5781,7 +5781,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText // If we don't have an extended paint engine, if the painter is projected, // or if the font engine does not support the matrix, we go through standard // code path - if (d->extended == 0 + if (d->extended == nullptr || !d->state->matrix.isAffine() || !fe->supportsTransformation(d->state->matrix)) { staticText_d->paintText(topLeftPosition, this, pen().color()); @@ -5981,7 +5981,7 @@ void QPainter::drawText(const QRect &r, int flags, const QString &str, QRect *br d->updateState(d->state); QRectF bounds; - qt_format_text(d->state->font, r, flags, 0, str, br ? &bounds : 0, 0, 0, 0, this); + qt_format_text(d->state->font, r, flags, nullptr, str, br ? &bounds : nullptr, 0, nullptr, 0, this); if (br) *br = bounds.toAlignedRect(); } @@ -6067,7 +6067,7 @@ void QPainter::drawText(const QRectF &r, int flags, const QString &str, QRectF * if (!d->extended) d->updateState(d->state); - qt_format_text(d->state->font, r, flags, 0, str, br, 0, 0, 0, this); + qt_format_text(d->state->font, r, flags, nullptr, str, br, 0, nullptr, 0, this); } /*! @@ -6185,7 +6185,7 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption if (!d->extended) d->updateState(d->state); - qt_format_text(d->state->font, r, 0, &o, text, 0, 0, 0, 0, this); + qt_format_text(d->state->font, r, 0, &o, text, nullptr, 0, nullptr, 0, this); } /*! @@ -6415,7 +6415,7 @@ Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t drawTextItemDecoration(painter, QPointF(leftMost.toReal(), baseLine.toReal()), fontEngine, - 0, // textEngine + nullptr, // textEngine font.underline() ? QTextCharFormat::SingleUnderline : QTextCharFormat::NoUnderline, flags, width.toReal(), charFormat); @@ -6425,7 +6425,7 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) { Q_D(QPainter); - d->drawTextItem(p, ti, static_cast<QTextEngine *>(0)); + d->drawTextItem(p, ti, static_cast<QTextEngine *>(nullptr)); } void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QTextEngine *textEngine) @@ -6682,7 +6682,7 @@ QRectF QPainter::boundingRect(const QRectF &r, const QString &text, const QTextO return QRectF(r.x(),r.y(), 0,0); QRectF br; - qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, 0, 0, this); + qt_format_text(d->state->font, r, Qt::TextDontPrint, &o, text, &br, 0, nullptr, 0, this); return br; } @@ -7429,7 +7429,7 @@ void QPainter::setRedirected(const QPaintDevice *device, QPaintDevice *replacement, const QPoint &offset) { - Q_ASSERT(device != 0); + Q_ASSERT(device != nullptr); Q_UNUSED(device) Q_UNUSED(replacement) Q_UNUSED(offset) @@ -7480,7 +7480,7 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_UNUSED(device) Q_UNUSED(offset) - return 0; + return nullptr; } #endif @@ -7490,7 +7490,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, QPainter *painter) { qt_format_text(fnt, _r, - tf, 0, str, brect, + tf, nullptr, str, brect, tabstops, ta, tabarraylen, painter); } @@ -7500,7 +7500,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, QPainter *painter) { - Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=0) ); // we either have an option or flags + Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=nullptr) ); // we either have an option or flags if (option) { tf |= option->alignment(); diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 859122c3b9..17d8b863ab 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -546,7 +546,7 @@ void QPainterPath::setElementPositionAt(int i, qreal x, qreal y) Constructs an empty QPainterPath object. */ QPainterPath::QPainterPath() noexcept - : d_ptr(0) + : d_ptr(nullptr) { } @@ -602,7 +602,7 @@ void QPainterPath::ensureData_helper() QPainterPath::Element e = { 0, 0, QPainterPath::MoveToElement }; data->elements << e; d_ptr.reset(data); - Q_ASSERT(d_ptr != 0); + Q_ASSERT(d_ptr != nullptr); } /*! @@ -1036,7 +1036,7 @@ void QPainterPath::arcMoveTo(const QRectF &rect, qreal angle) return; QPointF pt; - qt_find_ellipse_coords(rect, angle, 0, &pt, 0); + qt_find_ellipse_coords(rect, angle, 0, &pt, nullptr); moveTo(pt); } diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 924d332452..1a1b2d76e2 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -690,12 +690,12 @@ int QKdPointTree::build(int begin, int end, int depth) if (last > begin) m_nodes.at(last).left = &m_nodes.at(build(begin, last, depth + 1)); else - m_nodes.at(last).left = 0; + m_nodes.at(last).left = nullptr; if (last + 1 < end) m_nodes.at(last).right = &m_nodes.at(build(last + 1, end, depth + 1)); else - m_nodes.at(last).right = 0; + m_nodes.at(last).right = nullptr; return last; } @@ -811,7 +811,7 @@ void QWingedEdge::intersectAndAdd() if (isect->next) { isect += isect->next; } else { - isect = 0; + isect = nullptr; } } @@ -1535,8 +1535,8 @@ QPainterPath QPathClipper::clip(Operation operation) if (subjectPath == clipPath) return op == BoolSub ? QPainterPath() : subjectPath; - bool subjectIsRect = pathToRect(subjectPath, 0); - bool clipIsRect = pathToRect(clipPath, 0); + bool subjectIsRect = pathToRect(subjectPath, nullptr); + bool clipIsRect = pathToRect(clipPath, nullptr); const QRectF clipBounds = clipPath.boundingRect(); const QRectF subjectBounds = subjectPath.boundingRect(); diff --git a/src/gui/painting/qpathsimplifier.cpp b/src/gui/painting/qpathsimplifier.cpp index 4251840bbc..256a2fefe7 100644 --- a/src/gui/painting/qpathsimplifier.cpp +++ b/src/gui/painting/qpathsimplifier.cpp @@ -378,8 +378,8 @@ private: }; inline PathSimplifier::BoundingVolumeHierarchy::BoundingVolumeHierarchy() - : root(0) - , nodeBlock(0) + : root(nullptr) + , nodeBlock(nullptr) , blockSize(0) , firstFree(0) { @@ -392,7 +392,7 @@ inline PathSimplifier::BoundingVolumeHierarchy::~BoundingVolumeHierarchy() inline void PathSimplifier::BoundingVolumeHierarchy::allocate(int nodeCount) { - Q_ASSERT(nodeBlock == 0); + Q_ASSERT(nodeBlock == nullptr); Q_ASSERT(firstFree == 0); nodeBlock = new Node[blockSize = nodeCount]; } @@ -401,9 +401,9 @@ inline void PathSimplifier::BoundingVolumeHierarchy::free() { freeNode(root); delete[] nodeBlock; - nodeBlock = 0; + nodeBlock = nullptr; firstFree = blockSize = 0; - root = 0; + root = nullptr; } inline PathSimplifier::BVHNode *PathSimplifier::BoundingVolumeHierarchy::newNode() @@ -427,7 +427,7 @@ inline void PathSimplifier::BoundingVolumeHierarchy::freeNode(Node *n) } inline PathSimplifier::ElementAllocator::ElementAllocator() - : blocks(0) + : blocks(nullptr) { } @@ -442,11 +442,11 @@ inline PathSimplifier::ElementAllocator::~ElementAllocator() inline void PathSimplifier::ElementAllocator::allocate(int count) { - Q_ASSERT(blocks == 0); + Q_ASSERT(blocks == nullptr); Q_ASSERT(count > 0); blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (count - 1) * sizeof(Element)); blocks->blockSize = count; - blocks->next = 0; + blocks->next = nullptr; blocks->firstFree = 0; } @@ -479,7 +479,7 @@ inline void PathSimplifier::Element::flip() qSwap(indices[i], indices[degree - i]); } pointingUp = !pointingUp; - Q_ASSERT(next == 0 && previous == 0); + Q_ASSERT(next == nullptr && previous == nullptr); } PathSimplifier::PathSimplifier(const QVectorPath &path, QDataBuffer<QPoint> &vertices, @@ -685,9 +685,9 @@ void PathSimplifier::connectElements() QDataBuffer<Event> events(m_elements.size() * 2); for (int i = 0; i < m_elements.size(); ++i) { Element *element = m_elements.at(i); - element->next = element->previous = 0; + element->next = element->previous = nullptr; element->winding = 0; - element->edgeNode = 0; + element->edgeNode = nullptr; const QPoint &u = m_points->at(element->indices[0]); const QPoint &v = m_points->at(element->indices[element->degree]); if (u != v) { @@ -730,7 +730,7 @@ void PathSimplifier::connectElements() Element *element2 = event2->element; element->edgeNode->data = event2->element; element2->edgeNode = element->edgeNode; - element->edgeNode = 0; + element->edgeNode = nullptr; events.pop_back(); events.pop_back(); @@ -783,8 +783,8 @@ void PathSimplifier::connectElements() Element *upperElement = m_elementAllocator.newElement(); *upperElement = *element; upperElement->lowerIndex() = element->upperIndex() = pointIndex; - upperElement->edgeNode = 0; - element->next = element->previous = 0; + upperElement->edgeNode = nullptr; + element->next = element->previous = nullptr; if (upperElement->next) upperElement->next->previous = upperElement; else if (upperElement->previous) @@ -805,7 +805,7 @@ void PathSimplifier::connectElements() RBNode *left = findElementLeftOf(event->element, bounds); RBNode *node = m_elementList.newNode(); node->data = event->element; - Q_ASSERT(event->element->edgeNode == 0); + Q_ASSERT(event->element->edgeNode == nullptr); event->element->edgeNode = node; m_elementList.attachAfter(left, node); } else { @@ -814,7 +814,7 @@ void PathSimplifier::connectElements() Element *element = event->element; Q_ASSERT(element->edgeNode); m_elementList.deleteNode(element->edgeNode); - Q_ASSERT(element->edgeNode == 0); + Q_ASSERT(element->edgeNode == nullptr); } events.pop_back(); } @@ -870,8 +870,8 @@ void PathSimplifier::connectElements() Q_ASSERT(i + 1 < orderedElements.size()); Element *next = orderedElements.at(i); Element *previous = orderedElements.at(i + 1); - Q_ASSERT(next->previous == 0); - Q_ASSERT(previous->next == 0); + Q_ASSERT(next->previous == nullptr); + Q_ASSERT(previous->next == nullptr); next->previous = previous; previous->next = next; } @@ -893,7 +893,7 @@ void PathSimplifier::fillIndices() m_elements.at(i)->processed = false; for (int i = 0; i < m_elements.size(); ++i) { Element *element = m_elements.at(i); - if (element->processed || element->next == 0) + if (element->processed || element->next == nullptr) continue; do { m_indices->add(element->indices[0]); @@ -1395,13 +1395,13 @@ PathSimplifier::RBNode *PathSimplifier::findElementLeftOf(const Element *element const QPair<RBNode *, RBNode *> &bounds) { if (!m_elementList.root) - return 0; + return nullptr; RBNode *current = bounds.first; Q_ASSERT(!current || !elementIsLeftOf(element, current->data)); if (!current) current = m_elementList.front(m_elementList.root); Q_ASSERT(current); - RBNode *result = 0; + RBNode *result = nullptr; while (current != bounds.second && !elementIsLeftOf(element, current->data)) { result = current; current = m_elementList.next(current); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index f560e1f0f0..932c3e6f5a 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -439,8 +439,8 @@ QByteArray QPdf::generateDashes(const QPen &pen) static const char* const pattern_for_brush[] = { - 0, // NoBrush - 0, // SolidPattern + nullptr, // NoBrush + nullptr, // SolidPattern "0 J\n" "6 w\n" "[] 0 d\n" @@ -637,7 +637,7 @@ static void cubicToHook(qfixed c1x, qfixed c1y, } QPdf::Stroker::Stroker() - : stream(0), + : stream(nullptr), first(true), dashStroker(&basicStroker) { @@ -652,7 +652,7 @@ QPdf::Stroker::Stroker() void QPdf::Stroker::setPen(const QPen &pen, QPainter::RenderHints hints) { if (pen.style() == Qt::NoPen) { - stroker = 0; + stroker = nullptr; return; } qreal w = pen.widthF(); @@ -1469,7 +1469,7 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const QPdfEnginePrivate::QPdfEnginePrivate() : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), pdfVersion(QPdfEngine::Version_1_4), - outDevice(0), ownsDevice(false), + outDevice(nullptr), ownsDevice(false), embedFonts(true), grayscale(false), m_pageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(10, 10, 10, 10)) @@ -1477,8 +1477,8 @@ QPdfEnginePrivate::QPdfEnginePrivate() initResources(); resolution = 1200; currentObject = 1; - currentPage = 0; - stroker.stream = 0; + currentPage = nullptr; + stroker.stream = nullptr; streampos = 0; @@ -1547,12 +1547,12 @@ bool QPdfEngine::end() qDeleteAll(d->fonts); d->fonts.clear(); delete d->currentPage; - d->currentPage = 0; + d->currentPage = nullptr; if (d->outDevice && d->ownsDevice) { d->outDevice->close(); delete d->outDevice; - d->outDevice = 0; + d->outDevice = nullptr; } setActive(false); diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index bf7e2d3dca..35814d146c 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -55,7 +55,7 @@ public: : QObjectPrivate() { engine = new QPdfEngine(); - output = 0; + output = nullptr; pdfVersion = QPdfWriter::PdfVersion_1_4; } ~QPdfWriterPrivate() diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index dc6e3e04d0..1a940443d1 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -254,7 +254,7 @@ public: { if (!pen->ref.deref()) delete pen; - pen = 0; + pen = nullptr; } }; diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 0ecb4390e9..c092a7153f 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -87,10 +87,10 @@ class QPlatformBackingStorePrivate public: QPlatformBackingStorePrivate(QWindow *w) : window(w) - , backingStore(0) + , backingStore(nullptr) #ifndef QT_NO_OPENGL , textureId(0) - , blitter(0) + , blitter(nullptr) #endif { } diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index b4014272f4..cd31d75f83 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -209,7 +209,7 @@ QScanConverter::QScanConverter() : m_lines(0) , m_alloc(0) , m_size(0) - , m_intersections(0) + , m_intersections(nullptr) , m_active(0) { } @@ -442,7 +442,7 @@ void QScanConverter::end() free(m_intersections); m_alloc = 0; m_size = 0; - m_intersections = 0; + m_intersections = nullptr; } if (m_lines.size() > 1024) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 82f5be2b65..783b02fb93 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -1128,7 +1128,7 @@ Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) segments.resize(4 * (end - rect)); int lastRowSegmentCount = 0; - Segment *lastRowSegments = 0; + Segment *lastRowSegments = nullptr; int lastSegment = 0; int lastY = 0; @@ -1380,10 +1380,10 @@ void QRegionPrivate::intersect(const QRect &rect) extents.setRight(qMax(extents.right(), dest->right())); extents.setBottom(qMax(extents.bottom(), dest->bottom())); - const QRect *nextToLast = (numRects > 1 ? dest - 2 : 0); + const QRect *nextToLast = (numRects > 1 ? dest - 2 : nullptr); // mergeFromBelow inlined and optimized - if (canMergeFromBelow(dest - 1, dest, nextToLast, 0)) { + if (canMergeFromBelow(dest - 1, dest, nextToLast, nullptr)) { if (!n || src->y() != dest->y() || src->left() > r.right()) { QRect *prev = dest - 1; prev->setBottom(dest->bottom()); @@ -1408,11 +1408,11 @@ void QRegionPrivate::append(const QRect *r) QRect *myLast = (numRects == 1 ? &extents : rects.data() + (numRects - 1)); if (mergeFromRight(myLast, r)) { if (numRects > 1) { - const QRect *nextToTop = (numRects > 2 ? myLast - 2 : 0); - if (mergeFromBelow(myLast - 1, myLast, nextToTop, 0)) + const QRect *nextToTop = (numRects > 2 ? myLast - 2 : nullptr); + if (mergeFromBelow(myLast - 1, myLast, nextToTop, nullptr)) --numRects; } - } else if (mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : 0), 0)) { + } else if (mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : nullptr), nullptr)) { // nothing } else { vectorize(); @@ -1451,18 +1451,18 @@ void QRegionPrivate::append(const QRegionPrivate *r) { const QRect *rFirst = srcRect; QRect *myLast = destRect - 1; - const QRect *nextToLast = (numRects > 1 ? myLast - 1 : 0); + const QRect *nextToLast = (numRects > 1 ? myLast - 1 : nullptr); if (mergeFromRight(myLast, rFirst)) { ++srcRect; --numAppend; - const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : 0); + const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : nullptr); if (mergeFromBelow(myLast, rFirst + 1, nextToLast, rNextToFirst)) { ++srcRect; --numAppend; } if (numRects > 1) { - nextToLast = (numRects > 2 ? myLast - 2 : 0); - rNextToFirst = (numAppend > 0 ? srcRect : 0); + nextToLast = (numRects > 2 ? myLast - 2 : nullptr); + rNextToFirst = (numAppend > 0 ? srcRect : nullptr); if (mergeFromBelow(myLast - 1, myLast, nextToLast, rNextToFirst)) { --destRect; --numRects; @@ -1522,20 +1522,20 @@ void QRegionPrivate::prepend(const QRegionPrivate *r) // try merging { QRect *myFirst = rects.data(); - const QRect *nextToFirst = (numRects > 1 ? myFirst + 1 : 0); + const QRect *nextToFirst = (numRects > 1 ? myFirst + 1 : nullptr); const QRect *rLast = r->rects.constData() + r->numRects - 1; - const QRect *rNextToLast = (r->numRects > 1 ? rLast - 1 : 0); + const QRect *rNextToLast = (r->numRects > 1 ? rLast - 1 : nullptr); if (mergeFromLeft(myFirst, rLast)) { --numPrepend; --rLast; - rNextToLast = (numPrepend > 1 ? rLast - 1 : 0); + rNextToLast = (numPrepend > 1 ? rLast - 1 : nullptr); if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) { --numPrepend; --rLast; } if (numRects > 1) { - nextToFirst = (numRects > 2? myFirst + 2 : 0); - rNextToLast = (numPrepend > 0 ? rLast : 0); + nextToFirst = (numRects > 2? myFirst + 2 : nullptr); + rNextToLast = (numPrepend > 0 ? rLast : nullptr); if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, rNextToLast)) { --numRects; ++numSkip; @@ -1585,14 +1585,14 @@ void QRegionPrivate::prepend(const QRect *r) QRect *myFirst = (numRects == 1 ? &extents : rects.data()); if (mergeFromLeft(myFirst, r)) { if (numRects > 1) { - const QRect *nextToFirst = (numRects > 2 ? myFirst + 2 : 0); - if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, 0)) { + const QRect *nextToFirst = (numRects > 2 ? myFirst + 2 : nullptr); + if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, nullptr)) { --numRects; memmove(rects.data(), rects.constData() + 1, numRects * sizeof(QRect)); } } - } else if (mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : 0), 0)) { + } else if (mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : nullptr), nullptr)) { // nothing } else { vectorize(); @@ -2324,14 +2324,14 @@ static void miRegionOp(QRegionPrivate &dest, top = qMax(r1->top(), ybot + 1); bot = qMin(r1->bottom(), r2->top() - 1); - if (nonOverlap1Func != 0 && bot >= top) + if (nonOverlap1Func != nullptr && bot >= top) (*nonOverlap1Func)(dest, r1, r1BandEnd, top, bot); ytop = r2->top(); } else if (r2->top() < r1->top()) { top = qMax(r2->top(), ybot + 1); bot = qMin(r2->bottom(), r1->top() - 1); - if (nonOverlap2Func != 0 && bot >= top) + if (nonOverlap2Func != nullptr && bot >= top) (*nonOverlap2Func)(dest, r2, r2BandEnd, top, bot); ytop = r1->top(); } else { @@ -2374,7 +2374,7 @@ static void miRegionOp(QRegionPrivate &dest, */ curBand = dest.numRects; if (r1 != r1End) { - if (nonOverlap1Func != 0) { + if (nonOverlap1Func != nullptr) { do { r1BandEnd = r1; while (r1BandEnd < r1End && r1BandEnd->top() == r1->top()) @@ -2383,7 +2383,7 @@ static void miRegionOp(QRegionPrivate &dest, r1 = r1BandEnd; } while (r1 != r1End); } - } else if ((r2 != r2End) && (nonOverlap2Func != 0)) { + } else if ((r2 != r2End) && (nonOverlap2Func != nullptr)) { do { r2BandEnd = r2; while (r2BandEnd < r2End && r2BandEnd->top() == r2->top()) @@ -2698,7 +2698,7 @@ static void SubtractRegion(QRegionPrivate *regM, QRegionPrivate *regS, Q_ASSERT(!regS->contains(*regM)); Q_ASSERT(!EqualRegion(regM, regS)); - miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, 0); + miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, nullptr); /* * Can't alter dest's extents before we call miRegionOp because @@ -3235,14 +3235,14 @@ static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock)); Q_CHECK_PTR(tmpSLLBlock); (*SLLBlock)->next = tmpSLLBlock; - tmpSLLBlock->next = (ScanLineListBlock *)NULL; + tmpSLLBlock->next = (ScanLineListBlock *)nullptr; *SLLBlock = tmpSLLBlock; *iSLLBlock = 0; } pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]); pSLL->next = pPrevSLL->next; - pSLL->edgelist = (EdgeTableEntry *)NULL; + pSLL->edgelist = (EdgeTableEntry *)nullptr; pPrevSLL->next = pSLL; } pSLL->scanline = scanline; @@ -3250,7 +3250,7 @@ static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, /* * now insert the edge in the right bucket */ - prev = 0; + prev = nullptr; start = pSLL->edgelist; while (start && (start->bres.minor_axis < ETE->bres.minor_axis)) { prev = start; @@ -3306,18 +3306,18 @@ static void CreateETandAET(int count, const QPoint *pts, /* * initialize the Active Edge Table */ - AET->next = 0; - AET->back = 0; - AET->nextWETE = 0; + AET->next = nullptr; + AET->back = nullptr; + AET->nextWETE = nullptr; AET->bres.minor_axis = SMALL_COORDINATE; /* * initialize the Edge Table. */ - ET->scanlines.next = 0; + ET->scanlines.next = nullptr; ET->ymax = SMALL_COORDINATE; ET->ymin = LARGE_COORDINATE; - pSLLBlock->next = 0; + pSLLBlock->next = nullptr; PrevPt = &pts[count - 1]; @@ -3426,7 +3426,7 @@ static void computeWAET(EdgeTableEntry *AET) int inside = 1; int isInside = 0; - AET->nextWETE = 0; + AET->nextWETE = nullptr; pWETE = AET; AET = AET->next; while (AET) { @@ -3442,7 +3442,7 @@ static void computeWAET(EdgeTableEntry *AET) } AET = AET->next; } - pWETE->nextWETE = 0; + pWETE->nextWETE = nullptr; } /* @@ -3672,7 +3672,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) if (!(pETEs = static_cast<EdgeTableEntry *>(malloc(sizeof(EdgeTableEntry) * Count)))) { delete region; - return 0; + return nullptr; } region->vectorize(); @@ -3692,7 +3692,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) #endif delete AET; delete region; - return 0; + return nullptr; } @@ -3808,7 +3808,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) curPtBlock = tmpPtBlock; } free(pETEs); - return 0; // this function returns 0 in case of an error + return nullptr; // this function returns 0 in case of an error } FreeStorage(SLLBlock.next); @@ -4185,7 +4185,7 @@ QRegion QRegion::intersected(const QRegion &r) const QRegion result; result.detach(); - miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, 0, 0); + miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, nullptr, nullptr); /* * Can't alter dest's extents before we call miRegionOp because diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 271d3ba6bf..22302f9790 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -185,10 +185,10 @@ QStrokerOps::QStrokerOps() : m_elements(0) , m_curveThreshold(qt_real_to_fixed(0.25)) , m_dashThreshold(qt_real_to_fixed(0.25)) - , m_customData(0) - , m_moveTo(0) - , m_lineTo(0) - , m_cubicTo(0) + , m_customData(nullptr) + , m_moveTo(nullptr) + , m_lineTo(nullptr) + , m_cubicTo(nullptr) { } @@ -219,7 +219,7 @@ void QStrokerOps::end() { if (m_elements.size() > 1) processCurrentSubpath(); - m_customData = 0; + m_customData = nullptr; } /*! diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 7a3dd04965..f40ca9d8b4 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -127,7 +127,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const QFixed subPixelPosition; if (supportsSubPixelPositions) { - QFixed x = positions != 0 ? positions[i].x : QFixed(); + QFixed x = positions != nullptr ? positions[i].x : QFixed(); subPixelPosition = fontEngine->subPixelPositionForX(x); } diff --git a/src/gui/painting/qtriangulatingstroker.cpp b/src/gui/painting/qtriangulatingstroker.cpp index b1b07f9699..8e0308f268 100644 --- a/src/gui/painting/qtriangulatingstroker.cpp +++ b/src/gui/painting/qtriangulatingstroker.cpp @@ -150,7 +150,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, co m_cos_theta = qFastCos(Q_PI / m_roundness); const qreal *endPts = pts + (count<<1); - const qreal *startPts = 0; + const qreal *startPts = nullptr; Qt::PenCapStyle cap = m_cap_style; @@ -510,7 +510,7 @@ static void qdashprocessor_cubicTo(qreal, qreal, qreal, qreal, qreal, qreal, voi QDashedStrokeProcessor::QDashedStrokeProcessor() : m_points(0), m_types(0), - m_dash_stroker(0), m_inv_scale(1) + m_dash_stroker(nullptr), m_inv_scale(1) { m_dash_stroker.setMoveToHook(qdashprocessor_moveTo); m_dash_stroker.setLineToHook(qdashprocessor_lineTo); diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp index 9be3eeaffd..ec3ab8ff8f 100644 --- a/src/gui/painting/qtriangulator.cpp +++ b/src/gui/painting/qtriangulator.cpp @@ -958,7 +958,7 @@ void QTriangulator<T>::ComplexToSimple::initEdges() } else { Q_ASSERT(i + 1 < m_parent->m_indices.size()); // {node, from, to, next, previous, winding, mayIntersect, pointingUp, originallyPointingUp} - Edge edge = {0, int(m_parent->m_indices.at(i)), int(m_parent->m_indices.at(i + 1)), -1, -1, 0, true, false, false}; + Edge edge = {nullptr, int(m_parent->m_indices.at(i)), int(m_parent->m_indices.at(i + 1)), -1, -1, 0, true, false, false}; m_edges.add(edge); } } @@ -1029,7 +1029,7 @@ template <typename T> QRBTree<int>::Node *QTriangulator<T>::ComplexToSimple::searchEdgeLeftOf(int edgeIndex) const { QRBTree<int>::Node *current = m_edgeList.root; - QRBTree<int>::Node *result = 0; + QRBTree<int>::Node *result = nullptr; while (current) { if (edgeIsLeftOfEdge(edgeIndex, current->data)) { current = current->left; @@ -1072,7 +1072,7 @@ QPair<QRBTree<int>::Node *, QRBTree<int>::Node *> QTriangulator<T>::ComplexToSim } current = (d < 0 ? current->left : current->right); } - if (current == 0) + if (current == nullptr) return result; current = result.first->left; @@ -1273,7 +1273,7 @@ void QTriangulator<T>::ComplexToSimple::fillPriorityQueue() m_events.reserve(m_edges.size() * 2); for (int i = 0; i < m_edges.size(); ++i) { Q_ASSERT(m_edges.at(i).previous == -1 && m_edges.at(i).next == -1); - Q_ASSERT(m_edges.at(i).node == 0); + Q_ASSERT(m_edges.at(i).node == nullptr); Q_ASSERT(m_edges.at(i).pointingUp == m_edges.at(i).originallyPointingUp); Q_ASSERT(m_edges.at(i).pointingUp == (m_parent->m_vertices.at(m_edges.at(i).to) < m_parent->m_vertices.at(m_edges.at(i).from))); // Ignore zero-length edges. @@ -1296,7 +1296,7 @@ void QTriangulator<T>::ComplexToSimple::calculateIntersections() fillPriorityQueue(); Q_ASSERT(m_topIntersection.empty()); - Q_ASSERT(m_edgeList.root == 0); + Q_ASSERT(m_edgeList.root == nullptr); // Find all intersection points. while (!m_events.isEmpty()) { @@ -1305,7 +1305,7 @@ void QTriangulator<T>::ComplexToSimple::calculateIntersections() // Find all edges in the edge list that contain the current vertex and mark them to be split later. QPair<QRBTree<int>::Node *, QRBTree<int>::Node *> range = bounds(event.point); - QRBTree<int>::Node *leftNode = range.first ? m_edgeList.previous(range.first) : 0; + QRBTree<int>::Node *leftNode = range.first ? m_edgeList.previous(range.first) : nullptr; int vertex = (event.type == Event::Upper ? m_edges.at(event.edge).upper() : m_edges.at(event.edge).lower()); QIntersectionPoint eventPoint = QT_PREPEND_NAMESPACE(qIntersectionPoint)(event.point); @@ -1361,7 +1361,7 @@ int QTriangulator<T>::ComplexToSimple::splitEdge(int splitIndex) { const Split &split = m_splits.at(splitIndex); Edge &lowerEdge = m_edges.at(split.edge); - Q_ASSERT(lowerEdge.node == 0); + Q_ASSERT(lowerEdge.node == nullptr); Q_ASSERT(lowerEdge.previous == -1 && lowerEdge.next == -1); if (lowerEdge.from == split.vertex) @@ -1439,7 +1439,7 @@ void QTriangulator<T>::ComplexToSimple::insertEdgeIntoVectorIfWanted(ShortArray template <typename T> void QTriangulator<T>::ComplexToSimple::removeUnwantedEdgesAndConnect() { - Q_ASSERT(m_edgeList.root == 0); + Q_ASSERT(m_edgeList.root == nullptr); // Initialize priority queue. fillPriorityQueue(); @@ -1772,7 +1772,7 @@ void QTriangulator<T>::SimpleToMonotone::setupDataStructures() { int i = 0; Edge e; - e.node = 0; + e.node = nullptr; e.twin = -1; while (i + 3 <= m_parent->m_indices.size()) { @@ -1862,7 +1862,7 @@ template <typename T> QRBTree<int>::Node *QTriangulator<T>::SimpleToMonotone::searchEdgeLeftOfEdge(int edgeIndex) const { QRBTree<int>::Node *current = m_edgeList.root; - QRBTree<int>::Node *result = 0; + QRBTree<int>::Node *result = nullptr; while (current) { if (edgeIsLeftOfEdge(edgeIndex, current->data)) { current = current->left; @@ -1879,7 +1879,7 @@ template <typename T> QRBTree<int>::Node *QTriangulator<T>::SimpleToMonotone::searchEdgeLeftOfPoint(int pointIndex) const { QRBTree<int>::Node *current = m_edgeList.root; - QRBTree<int>::Node *result = 0; + QRBTree<int>::Node *result = nullptr; while (current) { const QPodPoint &p1 = m_parent->m_vertices.at(m_edges.at(current->data).lower()); const QPodPoint &p2 = m_parent->m_vertices.at(m_edges.at(current->data).upper()); @@ -2038,7 +2038,7 @@ void QTriangulator<T>::SimpleToMonotone::monotoneDecomposition() j = m_edges.at(i).previous; Q_ASSERT(j < m_edges.size()); - QRBTree<int>::Node *leftEdgeNode = 0; + QRBTree<int>::Node *leftEdgeNode = nullptr; switch (m_edges.at(i).type) { case RegularVertex: @@ -2049,7 +2049,7 @@ void QTriangulator<T>::SimpleToMonotone::monotoneDecomposition() if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) diagonals.add(QPair<int, int>(i, m_edges.at(i).helper)); m_edges.at(j).node = m_edges.at(i).node; - m_edges.at(i).node = 0; + m_edges.at(i).node = nullptr; m_edges.at(j).node->data = j; m_edges.at(j).helper = i; } else if (m_edges.at(j).node) { @@ -2057,7 +2057,7 @@ void QTriangulator<T>::SimpleToMonotone::monotoneDecomposition() if (m_edges.at(m_edges.at(j).helper).type == MergeVertex) diagonals.add(QPair<int, int>(i, m_edges.at(j).helper)); m_edges.at(i).node = m_edges.at(j).node; - m_edges.at(j).node = 0; + m_edges.at(j).node = nullptr; m_edges.at(i).node->data = i; m_edges.at(i).helper = i; } else { diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index 8b8f3e28ac..8528f59844 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -471,7 +471,7 @@ QTextObjectInterface *QAbstractTextDocumentLayout::handlerForObject(int objectTy QTextObjectHandler handler = d->handlers.value(objectType); if (!handler.component) - return 0; + return nullptr; return handler.iface; } diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 89f943ca51..c843e3b706 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -850,7 +850,7 @@ QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other) if (nbytes && other.data) data = (uchar *)memcpy(malloc(nbytes), other.data, nbytes); else - data = 0; + data = nullptr; } QDistanceFieldData::~QDistanceFieldData() @@ -1046,7 +1046,7 @@ const uchar *QDistanceField::constBits() const uchar *QDistanceField::scanLine(int i) { if (isNull()) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < d->height); return d->data + i * d->width; @@ -1055,7 +1055,7 @@ uchar *QDistanceField::scanLine(int i) const uchar *QDistanceField::scanLine(int i) const { if (isNull()) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < d->height); return d->data + i * d->width; @@ -1064,7 +1064,7 @@ const uchar *QDistanceField::scanLine(int i) const const uchar *QDistanceField::constScanLine(int i) const { if (isNull()) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < d->height); return d->data + i * d->width; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index bf130fa0b7..e162015aba 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -180,14 +180,14 @@ Q_GUI_EXPORT int qt_defaultDpi() } QFontPrivate::QFontPrivate() - : engineData(0), dpi(qt_defaultDpi()), + : engineData(nullptr), dpi(qt_defaultDpi()), underline(false), overline(false), strikeOut(false), kerning(true), - capital(0), letterSpacingIsAbsolute(false), scFont(0) + capital(0), letterSpacingIsAbsolute(false), scFont(nullptr) { } QFontPrivate::QFontPrivate(const QFontPrivate &other) - : request(other.request), engineData(0), dpi(other.dpi), + : request(other.request), engineData(nullptr), dpi(other.dpi), underline(other.underline), overline(other.overline), strikeOut(other.strikeOut), kerning(other.kerning), capital(other.capital), letterSpacingIsAbsolute(other.letterSpacingIsAbsolute), @@ -202,10 +202,10 @@ QFontPrivate::~QFontPrivate() { if (engineData && !engineData->ref.deref()) delete engineData; - engineData = 0; + engineData = nullptr; if (scFont && scFont != this) scFont->ref.deref(); - scFont = 0; + scFont = nullptr; } extern QRecursiveMutex *qt_fontdatabase_mutex(); @@ -221,7 +221,7 @@ QFontEngine *QFontPrivate::engineForScript(int script) const // throw out engineData that came from a different thread if (!engineData->ref.deref()) delete engineData; - engineData = 0; + engineData = nullptr; } if (!engineData || !QT_FONT_ENGINE_FROM_DATA(engineData, script)) QFontDatabase::load(this, script); @@ -261,7 +261,7 @@ QFontPrivate *QFontPrivate::smallCapsFontPrivate() const void QFontPrivate::resolve(uint mask, const QFontPrivate *other) { - Q_ASSERT(other != 0); + Q_ASSERT(other != nullptr); dpi = other->dpi; @@ -346,7 +346,7 @@ QFontEngineData::~QFontEngineData() if (engines[i]) { if (!engines[i]->ref.deref()) delete engines[i]; - engines[i] = 0; + engines[i] = nullptr; } } } @@ -610,10 +610,10 @@ void QFont::detach() if (d->ref.loadRelaxed() == 1) { if (d->engineData && !d->engineData->ref.deref()) delete d->engineData; - d->engineData = 0; + d->engineData = nullptr; if (d->scFont && d->scFont != d.data()) d->scFont->ref.deref(); - d->scFont = 0; + d->scFont = nullptr; return; } @@ -1666,7 +1666,7 @@ void QFont::setRawMode(bool) bool QFont::exactMatch() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return d->request.exactMatch(engine->fontDef); } @@ -1834,7 +1834,7 @@ Q_GLOBAL_STATIC(QFontSubst, globalFontSubst) QString QFont::substitute(const QString &familyName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QFontSubst::ConstIterator it = fontSubst->constFind(familyName.toLower()); if (it != fontSubst->constEnd() && !(*it).isEmpty()) return (*it).first(); @@ -1855,7 +1855,7 @@ QString QFont::substitute(const QString &familyName) QStringList QFont::substitutes(const QString &familyName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); return fontSubst->value(familyName.toLower(), QStringList()); } @@ -1870,7 +1870,7 @@ void QFont::insertSubstitution(const QString &familyName, const QString &substituteName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QStringList &list = (*fontSubst)[familyName.toLower()]; QString s = substituteName.toLower(); if (!list.contains(s)) @@ -1888,7 +1888,7 @@ void QFont::insertSubstitutions(const QString &familyName, const QStringList &substituteNames) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QStringList &list = (*fontSubst)[familyName.toLower()]; for (const QString &substituteName : substituteNames) { const QString lowerSubstituteName = substituteName.toLower(); @@ -1906,7 +1906,7 @@ void QFont::insertSubstitutions(const QString &familyName, void QFont::removeSubstitutions(const QString &familyName) { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); fontSubst->remove(familyName.toLower()); } @@ -1926,7 +1926,7 @@ void QFont::removeSubstitutions(const QString &familyName) QStringList QFont::substitutions() { QFontSubst *fontSubst = globalFontSubst(); - Q_ASSERT(fontSubst != 0); + Q_ASSERT(fontSubst != nullptr); QStringList ret = fontSubst->keys(); ret.sort(); @@ -1940,7 +1940,7 @@ QStringList QFont::substitutions() */ static quint8 get_font_bits(int version, const QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); quint8 bits = 0; if (f->request.style) bits |= 0x01; @@ -1965,7 +1965,7 @@ static quint8 get_font_bits(int version, const QFontPrivate *f) static quint8 get_extended_font_bits(const QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); quint8 bits = 0; if (f->request.ignorePitch) bits |= 0x01; @@ -1980,7 +1980,7 @@ static quint8 get_extended_font_bits(const QFontPrivate *f) */ static void set_font_bits(int version, quint8 bits, QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); f->request.style = (bits & 0x01) != 0 ? QFont::StyleItalic : QFont::StyleNormal; f->underline = (bits & 0x02) != 0; f->overline = (bits & 0x40) != 0; @@ -1995,7 +1995,7 @@ static void set_font_bits(int version, quint8 bits, QFontPrivate *f) static void set_extended_font_bits(quint8 bits, QFontPrivate *f) { - Q_ASSERT(f != 0); + Q_ASSERT(f != nullptr); f->request.ignorePitch = (bits & 0x01) != 0; f->letterSpacingIsAbsolute = (bits & 0x02) != 0; } @@ -2549,7 +2549,7 @@ QFontInfo &QFontInfo::operator=(const QFontInfo &fi) QString QFontInfo::family() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.family; } @@ -2564,7 +2564,7 @@ QString QFontInfo::family() const QString QFontInfo::styleName() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.styleName; } @@ -2576,7 +2576,7 @@ QString QFontInfo::styleName() const int QFontInfo::pointSize() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->fontDef.pointSize); } @@ -2588,7 +2588,7 @@ int QFontInfo::pointSize() const qreal QFontInfo::pointSizeF() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.pointSize; } @@ -2600,7 +2600,7 @@ qreal QFontInfo::pointSizeF() const int QFontInfo::pixelSize() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.pixelSize; } @@ -2612,7 +2612,7 @@ int QFontInfo::pixelSize() const bool QFontInfo::italic() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.style != QFont::StyleNormal; } @@ -2624,7 +2624,7 @@ bool QFontInfo::italic() const QFont::Style QFontInfo::style() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (QFont::Style)engine->fontDef.style; } @@ -2636,7 +2636,7 @@ QFont::Style QFontInfo::style() const int QFontInfo::weight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->fontDef.weight; } @@ -2701,7 +2701,7 @@ bool QFontInfo::strikeOut() const bool QFontInfo::fixedPitch() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); #ifdef Q_OS_MAC if (!engine->fontDef.fixedPitchComputed) { QChar ch[2] = { QLatin1Char('i'), QLatin1Char('m') }; @@ -2727,7 +2727,7 @@ bool QFontInfo::fixedPitch() const QFont::StyleHint QFontInfo::styleHint() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (QFont::StyleHint) engine->fontDef.styleHint; } @@ -2759,7 +2759,7 @@ bool QFontInfo::rawMode() const bool QFontInfo::exactMatch() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return d->request.exactMatch(engine->fontDef); } @@ -2793,7 +2793,7 @@ QFontCache *QFontCache::instance() void QFontCache::cleanup() { - QThreadStorage<QFontCache *> *cache = 0; + QThreadStorage<QFontCache *> *cache = nullptr; QT_TRY { cache = theFontCache(); } QT_CATCH (const std::bad_alloc &) { @@ -2830,7 +2830,7 @@ void QFontCache::clear() Q_ASSERT(engineCacheCount.value(data->engines[i]) == 0); delete data->engines[i]; } - data->engines[i] = 0; + data->engines[i] = nullptr; } } if (!data->ref.deref()) { @@ -2863,7 +2863,7 @@ void QFontCache::clear() FC_DEBUG("QFontCache::clear: engine %p still has refcount %d", engine, engine->ref.loadRelaxed()); } - it.value().data = 0; + it.value().data = nullptr; } } } while (mightHaveEnginesLeftForCleanup); @@ -2881,7 +2881,7 @@ QFontEngineData *QFontCache::findEngineData(const QFontDef &def) const { EngineDataCache::ConstIterator it = engineDataCache.constFind(def); if (it == engineDataCache.constEnd()) - return 0; + return nullptr; // found return it.value(); @@ -2912,7 +2912,7 @@ QFontEngine *QFontCache::findEngine(const Key &key) { EngineCache::Iterator it = engineCache.find(key), end = engineCache.end(); - if (it == end) return 0; + if (it == end) return nullptr; Q_ASSERT(it.value().data != nullptr); Q_ASSERT(key.multi == (it.value().data->type() == QFontEngine::Multi)); diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 67702ab5b5..f2fd585835 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -210,7 +210,7 @@ struct QtFontStyle QtFontStyle(const Key &k) : key(k), bitmapScalable(false), smoothScalable(false), - count(0), pixelSizes(0) + count(0), pixelSizes(nullptr) { } @@ -265,7 +265,7 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) return pixelSizes + i; } if (!add) - return 0; + return nullptr; if (!pixelSizes) { // Most style have only one font size, we avoid waisting memory @@ -280,13 +280,13 @@ QtFontSize *QtFontStyle::pixelSize(unsigned short size, bool add) pixelSizes = newPixelSizes; } pixelSizes[count].pixelSize = size; - pixelSizes[count].handle = 0; + pixelSizes[count].handle = nullptr; return pixelSizes + (count++); } struct QtFontFoundry { - QtFontFoundry(const QString &n) : name(n), count(0), styles(0) {} + QtFontFoundry(const QString &n) : name(n), count(0), styles(nullptr) {} ~QtFontFoundry() { while (count--) delete styles[count]; @@ -314,7 +314,7 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &st } } if (!create) - return 0; + return nullptr; // qDebug("adding key (weight=%d, style=%d, oblique=%d stretch=%d) at %d", key.weight, key.style, key.oblique, key.stretch, pos); if (!(count % 8)) { @@ -345,7 +345,7 @@ struct QtFontFamily : populated(false), fixedPitch(false), - name(n), count(0), foundries(0) + name(n), count(0), foundries(nullptr) { memset(writingSystems, 0, sizeof(writingSystems)); } @@ -381,7 +381,7 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[i]; } if (!create) - return 0; + return nullptr; if (!(count % 8)) { QtFontFoundry **newFoundries = (QtFontFoundry **) @@ -450,7 +450,7 @@ class QFontDatabasePrivate { public: QFontDatabasePrivate() - : count(0), families(0), + : count(0), families(nullptr), fallbacksCache(64) { } @@ -469,7 +469,7 @@ public: while (count--) delete families[count]; ::free(families); - families = 0; + families = nullptr; count = 0; // don't clear the memory fonts! } @@ -505,7 +505,7 @@ void QFontDatabasePrivate::invalidate() QtFontFamily *QFontDatabasePrivate::family(const QString &f, FamilyRequestFlags flags) { - QtFontFamily *fam = 0; + QtFontFamily *fam = nullptr; int low = 0; int high = count; @@ -645,7 +645,7 @@ static void parseFontName(const QString &name, QString &foundry, QString &family struct QtFontDesc { - inline QtFontDesc() : family(0), foundry(0), style(0), size(0) {} + inline QtFontDesc() : family(nullptr), foundry(nullptr), style(nullptr), size(nullptr) {} QtFontFamily *family; QtFontFoundry *foundry; QtFontStyle *style; @@ -949,7 +949,7 @@ QFontEngine *loadSingleEngine(int script, if (Q_UNLIKELY(!engine->supportsScript(QChar::Script(script)))) { qWarning(" OpenType support missing for \"%s\", script %d", qPrintable(def.family), script); - return 0; + return nullptr; } engine->isSmoothlyScalable = style->smoothScalable; @@ -976,7 +976,7 @@ QFontEngine *loadSingleEngine(int script, + qPrintable(def.family), script); if (engine->ref.loadRelaxed() == 0) delete engine; - return 0; + return nullptr; } engine->isSmoothlyScalable = style->smoothScalable; @@ -1081,9 +1081,9 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, Q_UNUSED(script); Q_UNUSED(pitch); - desc->foundry = 0; - desc->style = 0; - desc->size = 0; + desc->foundry = nullptr; + desc->style = nullptr; + desc->size = nullptr; qCDebug(lcFontMatch, " REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count); @@ -1104,7 +1104,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy, } int px = -1; - QtFontSize *size = 0; + QtFontSize *size = nullptr; // 1. see if we have an exact matching size if (!(styleStrategy & QFont::ForceOutline)) { @@ -1244,10 +1244,10 @@ static int match(int script, const QFontDef &request, foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(), script, request.weight, request.style, request.stretch, request.pixelSize, pitch); - desc->family = 0; - desc->foundry = 0; - desc->style = 0; - desc->size = 0; + desc->family = nullptr; + desc->foundry = nullptr; + desc->style = nullptr; + desc->size = nullptr; unsigned int score = ~0u; @@ -1280,7 +1280,7 @@ static int match(int script, const QFontDef &request, bestFoundry(script, score, request.styleStrategy, test.family, foundry_name, styleKey, request.pixelSize, pitch, &test, request.styleName); - if (test.foundry == 0 && !foundry_name.isEmpty()) { + if (test.foundry == nullptr && !foundry_name.isEmpty()) { // the specific foundry was not found, so look for // any foundry matching our requirements newscore = bestFoundry(script, score, request.styleStrategy, test.family, @@ -2068,7 +2068,7 @@ bool QFontDatabase::isPrivateFamily(const QString &family) const */ QString QFontDatabase::writingSystemName(WritingSystem writingSystem) { - const char *name = 0; + const char *name = nullptr; switch (writingSystem) { case Any: name = QT_TRANSLATE_NOOP("QFontDatabase", "Any"); @@ -2548,7 +2548,7 @@ QStringList QFontDatabase::applicationFontFamilies(int id) QFont QFontDatabase::systemFont(QFontDatabase::SystemFont type) { - const QFont *font = 0; + const QFont *font = nullptr; if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { switch (type) { case GeneralFont: @@ -2825,7 +2825,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script) if (fe->type() == QFontEngine::Box && !req.families.at(0).isEmpty()) { if (fe->ref.loadRelaxed() == 0) delete fe; - fe = 0; + fe = nullptr; } else { if (d->dpi > 0) fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / d->dpi)); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 1668fac5a3..3ca9e9bbde 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -221,7 +221,7 @@ static bool qt_get_font_table_default(void *user_data, uint tag, uchar *buffer, #ifdef QT_BUILD_INTERNAL // for testing purpose only, not thread-safe! -static QList<QFontEngine *> *enginesCollector = 0; +static QList<QFontEngine *> *enginesCollector = nullptr; Q_AUTOTEST_EXPORT void QFontEngine_startCollectingEngines() { @@ -234,7 +234,7 @@ Q_AUTOTEST_EXPORT QList<QFontEngine *> QFontEngine_stopCollectingEngines() Q_ASSERT(enginesCollector); QList<QFontEngine *> ret = *enginesCollector; delete enginesCollector; - enginesCollector = 0; + enginesCollector = nullptr; return ret; } #endif // QT_BUILD_INTERNAL @@ -569,9 +569,9 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) { glyph_metrics_t gi = boundingBox(glyph); - if (leftBearing != 0) + if (leftBearing != nullptr) *leftBearing = gi.leftBearing().toReal(); - if (rightBearing != 0) + if (rightBearing != nullptr) *rightBearing = gi.rightBearing().toReal(); } @@ -1022,7 +1022,7 @@ QByteArray QFontEngine::getSfntTable(uint tag) const { QByteArray table; uint len = 0; - if (!getSfntTableData(tag, 0, &len)) + if (!getSfntTableData(tag, nullptr, &len)) return table; table.resize(len); if (!getSfntTableData(tag, reinterpret_cast<uchar *>(table.data()), &len)) @@ -1231,11 +1231,11 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy // version check quint16 version; if (!qSafeFromBigEndian(header, endPtr, &version) || version != 0) - return 0; + return nullptr; quint16 numTables; if (!qSafeFromBigEndian(header + 2, endPtr, &numTables)) - return 0; + return nullptr; const uchar *maps = table + 4; @@ -1255,11 +1255,11 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy for (int n = 0; n < numTables; ++n) { quint16 platformId; if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId)) - return 0; + return nullptr; quint16 platformSpecificId = 0; if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId)) - return 0; + return nullptr; switch (platformId) { case 0: // Unicode @@ -1309,38 +1309,38 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy } } if(tableToUse < 0) - return 0; + return nullptr; resolveTable: *isSymbolFont = (symbolTable > -1); quint32 unicode_table = 0; if (!qSafeFromBigEndian(maps + 8 * tableToUse + 4, endPtr, &unicode_table)) - return 0; + return nullptr; if (!unicode_table) - return 0; + return nullptr; // get the header of the unicode table header = table + unicode_table; quint16 format; if (!qSafeFromBigEndian(header, endPtr, &format)) - return 0; + return nullptr; quint32 length; if (format < 8) { quint16 tmp; if (!qSafeFromBigEndian(header + 2, endPtr, &tmp)) - return 0; + return nullptr; length = tmp; } else { if (!qSafeFromBigEndian(header + 4, endPtr, &length)) - return 0; + return nullptr; } if (table + unicode_table + length > endPtr) - return 0; + return nullptr; *cmapSize = length; // To support symbol fonts that contain a unicode table for the symbol area @@ -1844,7 +1844,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) return engine; } - return 0; + return nullptr; } glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const @@ -1865,7 +1865,7 @@ glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const const_cast<QFontEngineMulti *>(this)->ensureEngineAt(x); engine = m_engines.at(x); } - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == Box) continue; @@ -1934,7 +1934,7 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, if (!engine) continue; } - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == Box) continue; @@ -2308,7 +2308,7 @@ QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosit */ QFontEngine *QFontEngineMulti::createMultiFontEngine(QFontEngine *fe, int script) { - QFontEngine *engine = 0; + QFontEngine *engine = nullptr; QFontCache::Key key(fe->fontDef, script, /*multi = */true); QFontCache *fc = QFontCache::instance(); // We can't rely on the fontDef (and hence the cache Key) diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp index 409176d41b..d22239c040 100644 --- a/src/gui/text/qfontengine_qpf2.cpp +++ b/src/gui/text/qfontengine_qpf2.cpp @@ -151,17 +151,17 @@ static inline const uchar *verifyTag(const uchar *tagPtr, const uchar *endPtr) const QFontEngineQPF2::Glyph *QFontEngineQPF2::findGlyph(glyph_t g) const { if (!g || g >= glyphMapEntries) - return 0; + return nullptr; const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset); quint32 glyphPos = qFromBigEndian<quint32>(gmapPtr[g]); if (glyphPos > glyphDataSize) { if (glyphPos == 0xffffffff) - return 0; + return nullptr; #if defined(DEBUG_FONTENGINE) qDebug() << "glyph" << g << "outside of glyphData, remapping font file"; #endif if (glyphPos > glyphDataSize) - return 0; + return nullptr; } return reinterpret_cast<const Glyph *>(fontData + glyphDataOffset + glyphPos); } @@ -230,7 +230,7 @@ QFontEngineQPF2::QFontEngineQPF2(const QFontDef &def, const QByteArray &data) { fontDef = def; cache_cost = 100; - cmap = 0; + cmap = nullptr; cmapOffset = 0; cmapSize = 0; glyphMapOffset = 0; diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 906047cdb4..a79957797d 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -282,7 +282,7 @@ bool QFontMetrics::operator ==(const QFontMetrics &other) const int QFontMetrics::ascent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->ascent()); } @@ -301,7 +301,7 @@ int QFontMetrics::ascent() const int QFontMetrics::capHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->capHeight()); } @@ -318,7 +318,7 @@ int QFontMetrics::capHeight() const int QFontMetrics::descent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->descent()); } @@ -332,7 +332,7 @@ int QFontMetrics::descent() const int QFontMetrics::height() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->ascent()) + qRound(engine->descent()); } @@ -346,7 +346,7 @@ int QFontMetrics::height() const int QFontMetrics::leading() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->leading()); } @@ -360,7 +360,7 @@ int QFontMetrics::leading() const int QFontMetrics::lineSpacing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()); } @@ -377,7 +377,7 @@ int QFontMetrics::lineSpacing() const int QFontMetrics::minLeftBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->minLeftBearing()); } @@ -394,7 +394,7 @@ int QFontMetrics::minLeftBearing() const int QFontMetrics::minRightBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->minRightBearing()); } @@ -404,7 +404,7 @@ int QFontMetrics::minRightBearing() const int QFontMetrics::maxWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->maxCharWidth()); } @@ -415,7 +415,7 @@ int QFontMetrics::maxWidth() const int QFontMetrics::xHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (d->capital == QFont::SmallCaps) return qRound(d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent()); return qRound(engine->xHeight()); @@ -429,7 +429,7 @@ int QFontMetrics::xHeight() const int QFontMetrics::averageCharWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->averageCharWidth()); } @@ -450,7 +450,7 @@ bool QFontMetrics::inFontUcs4(uint ucs4) const { const int script = QChar::script(ucs4); QFontEngine *engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return false; return engine->canRender(ucs4); @@ -476,7 +476,7 @@ int QFontMetrics::leftBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -509,7 +509,7 @@ int QFontMetrics::rightBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -518,7 +518,7 @@ int QFontMetrics::rightBearing(QChar ch) const glyph_t glyph = engine->glyphIndex(ch.unicode()); qreal rb; - engine->getGlyphBearings(glyph, 0, &rb); + engine->getGlyphBearings(glyph, nullptr, &rb); return qRound(rb); } @@ -673,7 +673,7 @@ int QFontMetrics::horizontalAdvance(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -725,7 +725,7 @@ int QFontMetrics::charWidth(const QString &text, int pos) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -800,7 +800,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -877,7 +877,7 @@ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &te QRectF rb; QRectF rr(rect); qt_format_text(QFont(d.data()), rr, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, - tabArrayLen, 0); + tabArrayLen, nullptr); return rb.toAlignedRect(); } @@ -994,7 +994,7 @@ QString QFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, in int QFontMetrics::underlinePos() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->underlinePosition()); } @@ -1030,7 +1030,7 @@ int QFontMetrics::strikeOutPos() const int QFontMetrics::lineWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return qRound(engine->lineThickness()); } @@ -1248,7 +1248,7 @@ bool QFontMetricsF::operator ==(const QFontMetricsF &other) const qreal QFontMetricsF::ascent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->ascent().toReal(); } @@ -1267,7 +1267,7 @@ qreal QFontMetricsF::ascent() const qreal QFontMetricsF::capHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->capHeight().toReal(); } @@ -1285,7 +1285,7 @@ qreal QFontMetricsF::capHeight() const qreal QFontMetricsF::descent() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->descent().toReal(); } @@ -1299,7 +1299,7 @@ qreal QFontMetricsF::descent() const qreal QFontMetricsF::height() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (engine->ascent() + engine->descent()).toReal(); } @@ -1314,7 +1314,7 @@ qreal QFontMetricsF::height() const qreal QFontMetricsF::leading() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->leading().toReal(); } @@ -1328,7 +1328,7 @@ qreal QFontMetricsF::leading() const qreal QFontMetricsF::lineSpacing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return (engine->leading() + engine->ascent() + engine->descent()).toReal(); } @@ -1345,7 +1345,7 @@ qreal QFontMetricsF::lineSpacing() const qreal QFontMetricsF::minLeftBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->minLeftBearing(); } @@ -1362,7 +1362,7 @@ qreal QFontMetricsF::minLeftBearing() const qreal QFontMetricsF::minRightBearing() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->minRightBearing(); } @@ -1372,7 +1372,7 @@ qreal QFontMetricsF::minRightBearing() const qreal QFontMetricsF::maxWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->maxCharWidth(); } @@ -1383,7 +1383,7 @@ qreal QFontMetricsF::maxWidth() const qreal QFontMetricsF::xHeight() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (d->capital == QFont::SmallCaps) return d->smallCapsFontPrivate()->engineForScript(QChar::Script_Common)->ascent().toReal(); return engine->xHeight().toReal(); @@ -1397,7 +1397,7 @@ qreal QFontMetricsF::xHeight() const qreal QFontMetricsF::averageCharWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->averageCharWidth().toReal(); } @@ -1420,7 +1420,7 @@ bool QFontMetricsF::inFontUcs4(uint ucs4) const { const int script = QChar::script(ucs4); QFontEngine *engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return false; return engine->canRender(ucs4); @@ -1446,7 +1446,7 @@ qreal QFontMetricsF::leftBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -1479,7 +1479,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == QFontEngine::Box) return 0; @@ -1488,7 +1488,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const glyph_t glyph = engine->glyphIndex(ch.unicode()); qreal rb; - engine->getGlyphBearings(glyph, 0, &rb); + engine->getGlyphBearings(glyph, nullptr, &rb); return rb; } @@ -1608,7 +1608,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -1679,7 +1679,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const engine = d->smallCapsFontPrivate()->engineForScript(script); else engine = d->engineForScript(script); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); d->alterCharForCapitalization(ch); @@ -1758,7 +1758,7 @@ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& QRectF rb; qt_format_text(QFont(d.data()), rect, flags | Qt::TextDontPrint, text, &rb, tabStops, tabArray, - tabArrayLen, 0); + tabArrayLen, nullptr); return rb; } @@ -1877,7 +1877,7 @@ QString QFontMetricsF::elidedText(const QString &text, Qt::TextElideMode mode, q qreal QFontMetricsF::underlinePos() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->underlinePosition().toReal(); } @@ -1912,7 +1912,7 @@ qreal QFontMetricsF::strikeOutPos() const qreal QFontMetricsF::lineWidth() const { QFontEngine *engine = d->engineForScript(QChar::Script_Common); - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); return engine->lineThickness().toReal(); } diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 90322b24da..02e25bb6af 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -368,7 +368,7 @@ QFontEngine *QPlatformFontDatabase::fontEngine(const QByteArray &fontData, qreal Q_UNUSED(pixelSize); Q_UNUSED(hintingPreference); qWarning("This plugin does not support font engines created directly from font data"); - return 0; + return nullptr; } /*! diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index e04c8909f3..884525bd76 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -750,7 +750,7 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ int script = qt_script_for_writing_system(writingSystem); QFontEngine *fe = font_d->engineForScript(script); - if (fe != 0 && fe->type() == QFontEngine::Multi) { + if (fe != nullptr && fe->type() == QFontEngine::Multi) { QFontEngineMulti *multiEngine = static_cast<QFontEngineMulti *>(fe); fe = multiEngine->engine(0); @@ -770,7 +770,7 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ Q_ASSERT(fe); } - if (fe != 0) { + if (fe != nullptr) { rawFont.d.data()->setFontEngine(fe); rawFont.d.data()->hintingPreference = font.hintingPreference(); } @@ -795,7 +795,7 @@ void QRawFont::setPixelSize(qreal pixelSize) void QRawFontPrivate::loadFromData(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { - Q_ASSERT(fontEngine == 0); + Q_ASSERT(fontEngine == nullptr); QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase(); setFontEngine(pfdb->fontEngine(fontData, pixelSize, hintingPreference)); diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 490e0b6b8f..e588b44efd 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -403,7 +403,7 @@ QSizeF QStaticText::size() const } QStaticTextPrivate::QStaticTextPrivate() - : textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), + : textWidth(-1.0), items(nullptr), itemCount(0), glyphPool(nullptr), positionPool(nullptr), needsRelayout(true), useBackendOptimizations(false), textFormat(Qt::AutoText), untransformedCoordinates(false) { @@ -411,7 +411,7 @@ QStaticTextPrivate::QStaticTextPrivate() QStaticTextPrivate::QStaticTextPrivate(const QStaticTextPrivate &other) : text(other.text), font(other.font), textWidth(other.textWidth), matrix(other.matrix), - items(0), itemCount(0), glyphPool(0), positionPool(0), textOption(other.textOption), + items(nullptr), itemCount(0), glyphPool(nullptr), positionPool(nullptr), textOption(other.textOption), needsRelayout(true), useBackendOptimizations(other.useBackendOptimizations), textFormat(other.textFormat), untransformedCoordinates(other.untransformedCoordinates) { diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index cf584f6980..c345e89a21 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -321,7 +321,7 @@ QSyntaxHighlighter::QSyntaxHighlighter(QTextDocument *parent) */ QSyntaxHighlighter::~QSyntaxHighlighter() { - setDocument(0); + setDocument(nullptr); } /*! @@ -601,7 +601,7 @@ QTextBlockUserData *QSyntaxHighlighter::currentBlockUserData() const { Q_D(const QSyntaxHighlighter); if (!d->currentBlock.isValid()) - return 0; + return nullptr; return d->currentBlock.userData(); } diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index c88497840f..b69b94d4e7 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -371,7 +371,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor int newPosition = position; - if (mode == QTextCursor::KeepAnchor && complexSelectionTable() != 0) { + if (mode == QTextCursor::KeepAnchor && complexSelectionTable() != nullptr) { if ((op >= QTextCursor::EndOfLine && op <= QTextCursor::NextWord) || (op >= QTextCursor::Right && op <= QTextCursor::WordRight)) { QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); @@ -671,7 +671,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor QTextTable *QTextCursorPrivate::complexSelectionTable() const { if (position == anchor) - return 0; + return nullptr; QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); if (t) { @@ -681,7 +681,7 @@ QTextTable *QTextCursorPrivate::complexSelectionTable() const Q_ASSERT(cell_anchor.isValid()); if (cell_pos == cell_anchor) - t = 0; + t = nullptr; } return t; } @@ -1044,7 +1044,7 @@ QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ Constructs a null cursor. */ QTextCursor::QTextCursor() - : d(0) + : d(nullptr) { } @@ -1623,7 +1623,7 @@ bool QTextCursor::hasComplexSelection() const if (!d) return false; - return d->complexSelectionTable() != 0; + return d->complexSelectionTable() != nullptr; } /*! @@ -2111,7 +2111,7 @@ QTextList *QTextCursor::insertList(QTextListFormat::Style style) QTextList *QTextCursor::createList(const QTextListFormat &format) { if (!d || !d->priv) - return 0; + return nullptr; QTextList *list = static_cast<QTextList *>(d->priv->createObject(format)); QTextBlockFormat modifier; @@ -2146,7 +2146,7 @@ QTextList *QTextCursor::createList(QTextListFormat::Style style) QTextList *QTextCursor::currentList() const { if (!d || !d->priv) - return 0; + return nullptr; QTextBlockFormat b = blockFormat(); QTextObject *o = d->priv->objectForFormat(b); @@ -2186,7 +2186,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols) QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat &format) { if(!d || !d->priv || rows == 0 || cols == 0) - return 0; + return nullptr; int pos = d->position; QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format); @@ -2206,7 +2206,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat QTextTable *QTextCursor::currentTable() const { if(!d || !d->priv) - return 0; + return nullptr; QTextFrame *frame = d->priv->frameAt(d->position); while (frame) { @@ -2215,7 +2215,7 @@ QTextTable *QTextCursor::currentTable() const return table; frame = frame->parentFrame(); } - return 0; + return nullptr; } /*! @@ -2230,7 +2230,7 @@ QTextTable *QTextCursor::currentTable() const QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) { if (!d || !d->priv) - return 0; + return nullptr; return d->priv->insertFrame(selectionStart(), selectionEnd(), format); } @@ -2243,7 +2243,7 @@ QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) QTextFrame *QTextCursor::currentFrame() const { if(!d || !d->priv) - return 0; + return nullptr; return d->priv->frameAt(d->position); } @@ -2603,7 +2603,7 @@ QTextDocument *QTextCursor::document() const { if (d->priv) return d->priv->document(); - return 0; // document went away + return nullptr; // document went away } QT_END_NAMESPACE diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e94f635651..3382ec0b69 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1666,7 +1666,7 @@ QTextCursor QTextDocument::find(const QRegularExpression &expr, const QTextCurso */ QTextObject *QTextDocument::createObject(const QTextFormat &f) { - QTextObject *obj = 0; + QTextObject *obj = nullptr; if (f.isListFormat()) obj = new QTextList(this); else if (f.isTableFormat()) @@ -2408,7 +2408,7 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) sizeof("small") + sizeof("medium") + 1, // "x-large" )> compressed into "xx-large" sizeof("small") + sizeof("medium"), // "xx-large" ) }; - const char *name = 0; + const char *name = nullptr; const int idx = format.intProperty(QTextFormat::FontSizeAdjustment) + 1; if (idx >= 0 && idx <= 4) { name = sizeNameData + sizeNameOffsets[idx]; @@ -3256,7 +3256,7 @@ void QTextHtmlExporter::emitFrame(const QTextFrame::Iterator &frameIt) QTextFrame::Iterator next = frameIt; ++next; if (next.atEnd() - && frameIt.currentFrame() == 0 + && frameIt.currentFrame() == nullptr && frameIt.parentFrame() != doc->rootFrame() && frameIt.currentBlock().begin().atEnd()) return; diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 2f02f62a57..524931ebde 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -185,7 +185,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() docChangeOldLength(0), docChangeLength(0), framesDirty(true), - rtFrame(0), + rtFrame(nullptr), initialBlockCharFormatIndex(-1) // set correctly later in init() { editBlock = 0; @@ -195,7 +195,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() undoState = 0; revision = -1; // init() inserts a block, bringing it to 0 - lout = 0; + lout = nullptr; modified = false; modifiedState = 0; @@ -272,7 +272,7 @@ void QTextDocumentPrivate::clear() blocks.clear(); cachedResources.clear(); delete rtFrame; - rtFrame = 0; + rtFrame = nullptr; init(); cursors = oldCursors; { @@ -290,7 +290,7 @@ void QTextDocumentPrivate::clear() QTextDocumentPrivate::~QTextDocumentPrivate() { for (QTextCursorPrivate *curs : qAsConst(cursors)) - curs->priv = 0; + curs->priv = nullptr; cursors.clear(); undoState = 0; undoEnabled = true; @@ -643,7 +643,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O // qDebug("remove_block at %d", key); Q_ASSERT(X->size_array[0] == 1 && isValidBlockSeparator(text.at(X->stringPosition))); b = blocks.previous(b); - B = 0; + B = nullptr; c.command = blocks.size(b) == 1 ? QTextUndoCommand::BlockDeleted : QTextUndoCommand::BlockRemoved; w = remove_block(key, &c.blockFormat, QTextUndoCommand::BlockAdded, op); @@ -1437,7 +1437,7 @@ static QTextFrame *findChildFrame(QTextFrame *f, int pos) else return c; } - return 0; + return nullptr; } QTextFrame *QTextDocumentPrivate::rootFrame() const @@ -1467,7 +1467,7 @@ void QTextDocumentPrivate::clearFrame(QTextFrame *f) for (int i = 0; i < f->d_func()->childFrames.count(); ++i) clearFrame(f->d_func()->childFrames.at(i)); f->d_func()->childFrames.clear(); - f->d_func()->parentFrame = 0; + f->d_func()->parentFrame = nullptr; } void QTextDocumentPrivate::scan_frames(int pos, int charsRemoved, int charsAdded) @@ -1551,7 +1551,7 @@ QTextFrame *QTextDocumentPrivate::insertFrame(int start, int end, const QTextFra Q_ASSERT(start <= end || end == -1); if (start != end && frameAt(start) != frameAt(end)) - return 0; + return nullptr; beginEditBlock(); @@ -1599,7 +1599,7 @@ void QTextDocumentPrivate::removeFrame(QTextFrame *frame) QTextObject *QTextDocumentPrivate::objectForIndex(int objectIndex) const { if (objectIndex < 0) - return 0; + return nullptr; QTextObject *object = objects.value(objectIndex, 0); if (!object) { diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 742c56382d..d7bc707491 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -277,7 +277,7 @@ void QTextDocumentFragmentPrivate::insert(QTextCursor &_cursor) const \sa isEmpty() */ QTextDocumentFragment::QTextDocumentFragment() - : d(0) + : d(nullptr) { } @@ -287,7 +287,7 @@ QTextDocumentFragment::QTextDocumentFragment() like the document's title. */ QTextDocumentFragment::QTextDocumentFragment(const QTextDocument *document) - : d(0) + : d(nullptr) { if (!document) return; @@ -304,7 +304,7 @@ QTextDocumentFragment::QTextDocumentFragment(const QTextDocument *document) \sa isEmpty(), QTextCursor::selection() */ QTextDocumentFragment::QTextDocumentFragment(const QTextCursor &cursor) - : d(0) + : d(nullptr) { if (!cursor.hasSelection()) return; @@ -678,7 +678,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes() if (n->parent) n = &at(n->parent); else - n = 0; + n = nullptr; } } @@ -793,7 +793,7 @@ bool QTextHtmlImporter::closeTag() bool blockTagClosed = false; while (depth > endDepth) { - Table *t = 0; + Table *t = nullptr; if (!tables.isEmpty()) t = &tables.last(); @@ -816,7 +816,7 @@ bool QTextHtmlImporter::closeTag() indent = t->lastIndent; tables.resize(tables.size() - 1); - t = 0; + t = nullptr; if (tables.isEmpty()) { cursor = doc->rootFrame()->lastCursorPosition(); @@ -1123,7 +1123,7 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() // for list items we may want to collapse with the bottom margin of the // list. - const QTextHtmlParserNode *parentNode = currentNode->parent ? &at(currentNode->parent) : 0; + const QTextHtmlParserNode *parentNode = currentNode->parent ? &at(currentNode->parent) : nullptr; if ((currentNode->id == Html_li || currentNode->id == Html_dt || currentNode->id == Html_dd) && parentNode && (parentNode->isListStart() || parentNode->id == Html_dl) @@ -1270,7 +1270,7 @@ void QTextHtmlImporter::appendBlock(const QTextBlockFormat &format, QTextCharFor QTextDocumentFragment QTextDocumentFragment::fromHtml(const QString &html) { - return fromHtml(html, 0); + return fromHtml(html, nullptr); } /*! diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index ed23a4d8d9..e21a8d8d52 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -111,7 +111,7 @@ public: QTextFrameData::QTextFrameData() : maximumWidth(QFIXED_MAX), - currentLayoutStruct(0), sizeDirty(true), layoutDirty(true) + currentLayoutStruct(nullptr), sizeDirty(true), layoutDirty(true) { } @@ -571,7 +571,7 @@ public: void setCellPosition(QTextTable *t, const QTextTableCell &cell, const QPointF &pos); QRectF layoutTable(QTextTable *t, int layoutFrom, int layoutTo, QFixed parentY); - void positionFloat(QTextFrame *frame, QTextLine *currentLine = 0); + void positionFloat(QTextFrame *frame, QTextLine *currentLine = nullptr); // calls the next one QRectF layoutFrame(QTextFrame *f, int layoutFrom, int layoutTo, QFixed parentY = 0); @@ -1554,7 +1554,7 @@ static inline double prioritizedEdgeAnchorOffset(const QTextDocumentLayoutPrivat competingCell = adjacentCell(table, cell, orthogonalEdge); if (competingCell.isValid()) { checkJoinedEdge(table, td, competingCell, edgeData.edge, edgeData, couldHaveContinuation, - &maxCompetingEdgeData, 0); + &maxCompetingEdgeData, nullptr); } } @@ -1946,7 +1946,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint QTextFrame::Iterator it, const QList<QTextFrame *> &floats, QTextBlock *cursorBlockNeedingRepaint) const { Q_Q(const QTextDocumentLayout); - const bool inRootFrame = (!it.atEnd() && it.parentFrame() && it.parentFrame()->parentFrame() == 0); + const bool inRootFrame = (!it.atEnd() && it.parentFrame() && it.parentFrame()->parentFrame() == nullptr); QVector<QCheckPoint>::ConstIterator lastVisibleCheckPoint = checkPoints.end(); if (inRootFrame && context.clip.isValid()) { @@ -1954,7 +1954,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint } QTextBlock previousBlock; - QTextFrame *previousFrame = 0; + QTextFrame *previousFrame = nullptr; for (; !it.atEnd(); ++it) { QTextFrame *c = it.currentFrame(); @@ -2050,7 +2050,7 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain QVector<QTextLayout::FormatRange> selections; int blpos = bl.position(); int bllen = bl.length(); - const QTextCharFormat *selFormat = 0; + const QTextCharFormat *selFormat = nullptr; for (int i = 0; i < context.selections.size(); ++i) { const QAbstractTextDocumentLayout::Selection &range = context.selections.at(i); const int selStart = range.cursor.selectionStart() - blpos; @@ -2920,7 +2920,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in QTextFrameFormat fformat = f->frameFormat(); QTextFrame *parent = f->parentFrame(); - const QTextFrameData *pd = parent ? data(parent) : 0; + const QTextFrameData *pd = parent ? data(parent) : nullptr; const qreal maximumWidth = qMax(qreal(0), pd ? pd->contentsWidth.toReal() : document->pageSize().width()); QFixed width = QFixed::fromReal(fformat.width().value(maximumWidth)); @@ -2971,7 +2971,7 @@ QRectF QTextDocumentLayoutPrivate::layoutFrame(QTextFrame *f, int layoutFrom, in } QTextFrame *parent = f->parentFrame(); - const QTextFrameData *pd = parent ? data(parent) : 0; + const QTextFrameData *pd = parent ? data(parent) : nullptr; // accumulate top and bottom margins if (parent) { @@ -3296,7 +3296,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout const QFixed origMaximumWidth = layoutStruct->maximumWidth; layoutStruct->maximumWidth = 0; - const QTextBlockFormat *previousBlockFormatPtr = 0; + const QTextBlockFormat *previousBlockFormatPtr = nullptr; if (lastIt.currentBlock().isValid()) previousBlockFormatPtr = &previousBlockFormat; @@ -3405,7 +3405,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout } - fd->currentLayoutStruct = 0; + fd->currentLayoutStruct = nullptr; } static inline void getLineHeightParams(const QTextBlockFormat &blockFormat, const QTextLine &line, qreal scaling, @@ -3865,7 +3865,7 @@ int QTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accur d->ensureLayouted(QFixed::fromReal(point.y())); QTextFrame *f = d->docPrivate->rootFrame(); int position = 0; - QTextLayout *l = 0; + QTextLayout *l = nullptr; QFixedPoint pointf; pointf.x = QFixed::fromReal(point.x()); pointf.y = QFixed::fromReal(point.y()); @@ -3944,7 +3944,7 @@ void QTextDocumentLayout::positionInlineObject(QTextInlineObject item, int posIn line = b.layout()->lineAt(b.layout()->lineCount()-1); // qDebug() << "layoutObject: line.isValid" << line.isValid() << b.position() << b.length() << // frame->firstPosition() << frame->lastPosition(); - d->positionFloat(frame, line.isValid() ? &line : 0); + d->positionFloat(frame, line.isValid() ? &line : nullptr); } void QTextDocumentLayout::drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index 193d2c0dd3..0bafa5d9ff 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -107,7 +107,7 @@ public: \internal */ QTextDocumentWriterPrivate::QTextDocumentWriterPrivate(QTextDocumentWriter *qq) - : device(0), + : device(nullptr), deleteDevice(false), #if QT_CONFIG(textcodec) codec(QTextCodec::codecForName("utf-8")), @@ -320,7 +320,7 @@ bool QTextDocumentWriter::write(const QTextDocument *document) */ bool QTextDocumentWriter::write(const QTextDocumentFragment &fragment) { - if (fragment.d == 0) + if (fragment.d == nullptr) return false; // invalid fragment. QTextDocument *doc = fragment.d->doc; if (doc) @@ -337,7 +337,7 @@ bool QTextDocumentWriter::write(const QTextDocumentFragment &fragment) #if QT_CONFIG(textcodec) void QTextDocumentWriter::setCodec(QTextCodec *codec) { - if (codec == 0) + if (codec == nullptr) codec = QTextCodec::codecForName("UTF-8"); Q_ASSERT(codec); d->codec = codec; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 8a91b34b7a..0024f070ea 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -72,7 +72,7 @@ public: : m_string(string), m_analysis(analysis), m_items(items), - m_splitter(0) + m_splitter(nullptr) { } ~Itemizer() @@ -138,7 +138,7 @@ private: if (!m_splitter) m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, m_string.constData(), m_string.length(), - /*buffer*/0, /*buffer size*/0); + /*buffer*/nullptr, /*buffer size*/0); m_splitter->setPosition(start); QScriptAnalysis itemAnalysis = m_analysis[start]; @@ -1680,8 +1680,8 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, QGlyphLayout g = availableGlyphs(&si).mid(glyphs_shaped, num_glyphs); ushort *log_clusters = logClusters(&si) + item_pos; - hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, 0); - hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, 0); + hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, nullptr); + hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer, nullptr); uint str_pos = 0; uint last_cluster = ~0u; uint last_glyph_pos = glyphs_shaped; @@ -1917,12 +1917,12 @@ void QTextEngine::init(QTextEngine *e) e->visualMovement = false; e->delayDecorations = false; - e->layoutData = 0; + e->layoutData = nullptr; e->minWidth = 0; e->maxWidth = 0; - e->specialData = 0; + e->specialData = nullptr; e->stackEngine = false; #ifndef QT_NO_RAWFONT e->useRawFont = false; @@ -1956,7 +1956,7 @@ const QCharAttributes *QTextEngine::attributes() const itemize(); if (! ensureSpace(layoutData->string.length())) - return NULL; + return nullptr; QVarLengthArray<QUnicodeTools::ScriptItem> scriptItems(layoutData->items.size()); for (int i = 0; i < layoutData->items.size(); ++i) { @@ -2148,7 +2148,7 @@ void QTextEngine::itemize() const if (it == end || format != frag->format) { if (s && position >= s->preeditPosition) { position += s->preeditText.length(); - s = 0; + s = nullptr; } Q_ASSERT(position <= length); QFont::Capitalization capitalization = @@ -2443,8 +2443,8 @@ QTextEngine::FontEngineCache::FontEngineCache() //input is common (and hard to cache at a higher level) QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const { - QFontEngine *engine = 0; - QFontEngine *scaledEngine = 0; + QFontEngine *engine = nullptr; + QFontEngine *scaledEngine = nullptr; int script = si.analysis.script; QFont font = fnt; @@ -2459,7 +2459,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix engine->ref.ref(); if (feCache.prevScaledFontEngine) { releaseCachedFontEngine(feCache.prevScaledFontEngine); - feCache.prevScaledFontEngine = 0; + feCache.prevScaledFontEngine = nullptr; } } if (si.analysis.flags == QScriptAnalysis::SmallCaps) { @@ -2538,7 +2538,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix feCache.prevScript = script; feCache.prevPosition = -1; feCache.prevLength = -1; - feCache.prevScaledFontEngine = 0; + feCache.prevScaledFontEngine = nullptr; } } @@ -2808,14 +2808,14 @@ void QScriptLine::setDefaultHeight(QTextEngine *eng) QTextEngine::LayoutData::LayoutData() { - memory = 0; + memory = nullptr; allocated = 0; memory_on_stack = false; used = 0; hasBidi = false; layoutState = LayoutEmpty; haveCharAttributes = false; - logClustersPtr = 0; + logClustersPtr = nullptr; available_glyphs = 0; } @@ -2833,8 +2833,8 @@ QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int allocated = 0; memory_on_stack = false; - memory = 0; - logClustersPtr = 0; + memory = nullptr; + logClustersPtr = nullptr; } else { memory_on_stack = true; memory = stack_memory; @@ -2855,7 +2855,7 @@ QTextEngine::LayoutData::~LayoutData() { if (!memory_on_stack) free(memory); - memory = 0; + memory = nullptr; } bool QTextEngine::LayoutData::reallocate(int totalGlyphs) @@ -2879,7 +2879,7 @@ bool QTextEngine::LayoutData::reallocate(int totalGlyphs) return false; } - void **newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *)); + void **newMem = (void **)::realloc(memory_on_stack ? nullptr : memory, newAllocated*sizeof(void *)); if (!newMem) { layoutState = LayoutFailed; return false; @@ -2928,7 +2928,7 @@ void QTextEngine::freeMemory() { if (!stackEngine) { delete layoutData; - layoutData = 0; + layoutData = nullptr; } else { layoutData->used = 0; layoutData->hasBidi = false; @@ -3035,7 +3035,7 @@ void QTextEngine::setPreeditArea(int position, const QString &preeditText) return; if (specialData->formats.isEmpty()) { delete specialData; - specialData = 0; + specialData = nullptr; } else { specialData->preeditText = QString(); specialData->preeditPosition = -1; @@ -3057,7 +3057,7 @@ void QTextEngine::setFormats(const QVector<QTextLayout::FormatRange> &formats) return; if (specialData->preeditText.isEmpty()) { delete specialData; - specialData = 0; + specialData = nullptr; } else { specialData->formats.clear(); } @@ -4004,7 +4004,7 @@ QTextLineItemIterator::QTextLineItemIterator(QTextEngine *_eng, int _lineNum, co const QTextLayout::FormatRange *_selection) : eng(_eng), line(eng->lines[_lineNum]), - si(0), + si(nullptr), lineNum(_lineNum), lineEnd(line.from + line.length), firstItem(eng->findItem(line.from)), diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index b867f42480..3b9f2d253e 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -463,7 +463,7 @@ static const QTextHtmlElement *lookupElementHelper(const QString &element) const QTextHtmlElement *end = &elements[Html_NumElements]; const QTextHtmlElement *e = std::lower_bound(start, end, element); if ((e == end) || (element < *e)) - return 0; + return nullptr; return e; } @@ -519,7 +519,7 @@ void QTextHtmlParser::dumpHtml() QTextHtmlParserNode *QTextHtmlParser::newNode(int parent) { QTextHtmlParserNode *lastNode = &nodes.last(); - QTextHtmlParserNode *newNode = 0; + QTextHtmlParserNode *newNode = nullptr; bool reuseLastNode = true; @@ -2123,7 +2123,7 @@ QVector<QCss::Declaration> QTextHtmlParser::declarationsForNode(int node) const QCss::StyleSelector::NodePtr n; n.id = node; - const char *extraPseudo = 0; + const char *extraPseudo = nullptr; if (nodes.at(node).id == Html_a && nodes.at(node).hasHref) extraPseudo = "link"; // Ensure that our own style is taken into consideration diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index f7117bfe0a..14018f34da 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -246,7 +246,7 @@ QSizeF QTextImageHandler::intrinsicSize(QTextDocument *doc, int posInDocument, c QImage QTextImageHandler::image(QTextDocument *doc, const QTextImageFormat &imageFormat) { - Q_ASSERT(doc != 0); + Q_ASSERT(doc != nullptr); return getImage(doc, imageFormat); } diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index a3e194f835..fc256d72f3 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1649,7 +1649,7 @@ namespace { struct LineBreakHelper { LineBreakHelper() - : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(0), logClusters(0), + : glyphCount(0), maxGlyphs(0), currentPosition(0), fontEngine(nullptr), logClusters(nullptr), manualWrap(false), whiteSpaceOrObject(true) { } @@ -1705,7 +1705,7 @@ namespace { inline void calculateRightBearing(QFontEngine *engine, glyph_t glyph) { qreal rb; - engine->getGlyphBearings(glyph, 0, &rb); + engine->getGlyphBearings(glyph, nullptr, &rb); // We only care about negative right bearings, so we limit the range // of the bearing here so that we can assume it's negative in the rest @@ -2212,7 +2212,7 @@ static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine, int textPosition, int textLength) { - Q_ASSERT(logClusters != 0); + Q_ASSERT(logClusters != nullptr); QGlyphRun glyphRun; @@ -2593,7 +2593,7 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR } else { // si.isTab QFont f = eng->font(si); QTextItemInt gf(si, &f, format); - gf.chars = 0; + gf.chars = nullptr; gf.num_chars = 0; gf.width = iterator.itemWidth; QPainterPrivate::get(p)->drawTextItem(QPointF(iterator.x.toReal(), y.toReal()), gf, eng); diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index b845889c3d..77dcae0dc8 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -596,7 +596,7 @@ void QTextFramePrivate::remove_me() parentFrame->d_func()->childFrames.removeAt(index); childFrames.clear(); - parentFrame = 0; + parentFrame = nullptr; } /*! @@ -654,10 +654,10 @@ QTextFrame::iterator QTextFrame::end() const */ QTextFrame::iterator::iterator() { - f = 0; + f = nullptr; b = 0; e = 0; - cf = 0; + cf = nullptr; cb = 0; } @@ -669,7 +669,7 @@ QTextFrame::iterator::iterator(QTextFrame *frame, int block, int begin, int end) f = frame; b = begin; e = end; - cf = 0; + cf = nullptr; cb = block; } @@ -739,7 +739,7 @@ QTextFrame::iterator &QTextFrame::iterator::operator++() if (cf) { int end = cf->lastPosition() + 1; cb = map.findNode(end); - cf = 0; + cf = nullptr; } else if (cb) { cb = map.next(cb); if (cb == e) @@ -777,7 +777,7 @@ QTextFrame::iterator &QTextFrame::iterator::operator--() if (cf) { int start = cf->firstPosition() - 1; cb = map.findNode(start); - cf = 0; + cf = nullptr; } else { if (cb == b) goto end; @@ -907,7 +907,7 @@ QTextBlockUserData::~QTextBlockUserData() bool QTextBlock::isValid() const { - return p != 0 && p->blockMap().isValid(n); + return p != nullptr && p->blockMap().isValid(n); } /*! @@ -1079,7 +1079,7 @@ bool QTextBlock::contains(int position) const QTextLayout *QTextBlock::layout() const { if (!p || !n) - return 0; + return nullptr; const QTextBlockData *b = p->blockMap().fragment(n); if (!b->layout) diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 0e8666565f..408e3ec167 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -70,7 +70,7 @@ static QString pixelToPoint(qreal pixels) // strategies class QOutputStrategy { public: - QOutputStrategy() : contentStream(0), counter(1) { } + QOutputStrategy() : contentStream(nullptr), counter(1) { } virtual ~QOutputStrategy() {} virtual void addFile(const QString &fileName, const QString &mimeType, const QByteArray &bytes) = 0; @@ -240,7 +240,7 @@ void QTextOdfWriter::writeFrame(QXmlStreamWriter &writer, const QTextFrame *fram } QTextFrame::iterator iterator = frame->begin(); - QTextFrame *child = 0; + QTextFrame *child = nullptr; int tableRow = -1; while (! iterator.atEnd()) { @@ -437,7 +437,7 @@ static bool probeImageData(QIODevice *device, QImage *image, QString *mimeType, void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const { writer.writeStartElement(drawNS, QString::fromLatin1("frame")); - if (m_strategy == 0) { + if (m_strategy == nullptr) { // don't do anything. } else if (fragment.charFormat().isImageFormat()) { @@ -997,8 +997,8 @@ QTextOdfWriter::QTextOdfWriter(const QTextDocument &document, QIODevice *device) svgNS (QLatin1String("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")), m_document(&document), m_device(device), - m_strategy(0), - m_codec(0), + m_strategy(nullptr), + m_codec(nullptr), m_createArchive(true) { } @@ -1093,7 +1093,7 @@ bool QTextOdfWriter::writeAll() writer.writeEndElement(); // document-content writer.writeEndDocument(); delete m_strategy; - m_strategy = 0; + m_strategy = nullptr; return true; } diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 2c2c05567f..2f195599f0 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -62,7 +62,7 @@ QTextOption::QTextOption() unused2(0), f(0), tab(-1), - d(0) + d(nullptr) { direction = Qt::LayoutDirectionAuto; } @@ -80,7 +80,7 @@ QTextOption::QTextOption(Qt::Alignment alignment) unused2(0), f(0), tab(-1), - d(0) + d(nullptr) { direction = QGuiApplication::layoutDirection(); } @@ -107,7 +107,7 @@ QTextOption::QTextOption(const QTextOption &o) unused2(o.unused2), f(o.f), tab(o.tab), - d(0) + d(nullptr) { if (o.d) d = new QTextOptionPrivate(*o.d); @@ -124,7 +124,7 @@ QTextOption &QTextOption::operator=(const QTextOption &o) if (this == &o) return *this; - QTextOptionPrivate* dNew = 0; + QTextOptionPrivate* dNew = nullptr; if (o.d) dNew = new QTextOptionPrivate(*o.d); delete d; diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index fc7fbcac12..80c0f122e8 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -141,8 +141,8 @@ static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourc if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; + stream.zalloc = (alloc_func)nullptr; + stream.zfree = (free_func)nullptr; err = inflateInit2(&stream, -MAX_WBITS); if (err != Z_OK) @@ -172,9 +172,9 @@ static int deflate (Bytef *dest, ulong *destLen, const Bytef *source, ulong sour stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; + stream.zalloc = (alloc_func)nullptr; + stream.zfree = (free_func)nullptr; + stream.opaque = (voidpf)nullptr; err = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); if (err != Z_OK) return err; @@ -705,7 +705,7 @@ void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const } // TODO add a check if data.length() > contents.length(). Then try to store the original and revert the compression method to be uncompressed writeUInt(header.h.compressed_size, data.length()); - uint crc_32 = ::crc32(0, 0, 0); + uint crc_32 = ::crc32(0, nullptr, 0); crc_32 = ::crc32(crc_32, (const uchar *)contents.constData(), contents.length()); writeUInt(header.h.crc_32, crc_32); @@ -886,7 +886,7 @@ bool QZipReader::isReadable() const bool QZipReader::exists() const { QFile *f = qobject_cast<QFile*> (d->device); - if (f == 0) + if (f == nullptr) return true; return f->exists(); } @@ -1178,7 +1178,7 @@ bool QZipWriter::isWritable() const bool QZipWriter::exists() const { QFile *f = qobject_cast<QFile*> (d->device); - if (f == 0) + if (f == nullptr) return true; return f->exists(); } diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp index 99214c4960..763f309fc7 100644 --- a/src/gui/util/qdesktopservices.cpp +++ b/src/gui/util/qdesktopservices.cpp @@ -287,7 +287,7 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c */ void QDesktopServices::unsetUrlHandler(const QString &scheme) { - setUrlHandler(scheme, 0, 0); + setUrlHandler(scheme, nullptr, nullptr); } #if QT_DEPRECATED_SINCE(5, 0) diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 024f0f084e..4af5e47f8f 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -177,7 +177,7 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo, qreal extra = compare(box, totalBox, j); if (extra > 0.0) { calculateGeometries(start, end, box.q_sizes(j), dummy.data(), newSizes.data(), - 0, totalBox, rowInfo, snapToPixelGrid); + nullptr, totalBox, rowInfo, snapToPixelGrid); for (int k = 0; k < span; ++k) extras[k].q_sizes(j) = newSizes[k]; @@ -988,7 +988,7 @@ void QGridLayoutEngine::removeItem(QGridLayoutItem *item) for (int i = item->firstRow(); i <= item->lastRow(); ++i) { for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) { if (itemAt(i, j) == item) - setItemAt(i, j, 0); + setItemAt(i, j, nullptr); } } @@ -1001,7 +1001,7 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int row, int column, Qt::Orientation if (orientation == Qt::Horizontal) qSwap(row, column); if (uint(row) >= uint(rowCount()) || uint(column) >= uint(columnCount())) - return 0; + return nullptr; return q_grid.at((row * internalGridColumnCount()) + column); } @@ -1100,7 +1100,7 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, if (constraintOrientation() == Qt::Vertical) { //We have items whose height depends on their width if (constraint.width() >= 0) { - ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); QVector<qreal> sizehint_xx; QVector<qreal> sizehint_widths; @@ -1110,14 +1110,14 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), width, sizehint_xx.data(), sizehint_widths.data(), - 0, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, sizehint_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], sizehint_xx.data(), sizehint_widths.data(), Qt::Vertical, styleInfo); sizeHintCalculated = true; } } else { if (constraint.height() >= 0) { //We have items whose width depends on their height - ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_rowData, &sizehint_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); QVector<qreal> sizehint_yy; QVector<qreal> sizehint_heights; @@ -1127,7 +1127,7 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), height, sizehint_yy.data(), sizehint_heights.data(), - 0, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); + nullptr, sizehint_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); ensureColumnAndRowData(&q_columnData, &sizehint_totalBoxes[Hor], sizehint_yy.data(), sizehint_heights.data(), Qt::Horizontal, styleInfo); sizeHintCalculated = true; } @@ -1137,8 +1137,8 @@ QSizeF QGridLayoutEngine::sizeHint(Qt::SizeHint which, const QSizeF &constraint, } //No items with height for width, so it doesn't matter which order we do these in - ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); - ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); return QSizeF(q_totalBoxes[Hor].q_sizes(which), q_totalBoxes[Ver].q_sizes(which)); } @@ -1650,18 +1650,18 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, if (constraintOrientation() != Qt::Horizontal) { //We might have items whose height depends on their width (HFW) - ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); + ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], nullptr, nullptr, Qt::Horizontal, styleInfo); //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], q_xx.data(), q_widths.data(), Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), q_descents.data(), q_totalBoxes[Ver], q_infos[Ver], m_snapToPixelGrid); } else { //We have items whose width depends on their height (WFH) - ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); + ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], nullptr, nullptr, Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), @@ -1669,7 +1669,7 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], q_yy.data(), q_heights.data(), Qt::Horizontal, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() q_columnData.calculateGeometries(0, columnCount(), size.width(), q_xx.data(), q_widths.data(), - 0, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); + nullptr, q_totalBoxes[Hor], q_infos[Hor], m_snapToPixelGrid); } } diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index ebf46f8e4e..41cbd1b15a 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -247,7 +247,7 @@ void QTextureFileData::setLogName(const QByteArray &name) static QByteArray glFormatName(quint32 fmt) { - const char *id = 0; + const char *id = nullptr; #if QT_CONFIG(opengl) id = QMetaEnum::fromType<QOpenGLTexture::TextureFormat>().valueToKey(fmt); #endif diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp index 764cb917ad..4b961a6f20 100644 --- a/src/gui/vulkan/qvulkaninstance.cpp +++ b/src/gui/vulkan/qvulkaninstance.cpp @@ -758,7 +758,7 @@ VkSurfaceKHR QVulkanInstance::surfaceForWindow(QWindow *window) // VkSurfaceKHR is non-dispatchable and maps to a pointer on x64 and a uint64 on x86. // Therefore a pointer is returned from the platform plugin, not the value itself. void *p = nativeInterface->nativeResourceForWindow(QByteArrayLiteral("vkSurface"), window); - return p ? *static_cast<VkSurfaceKHR *>(p) : 0; + return p ? *static_cast<VkSurfaceKHR *>(p) : VK_NULL_HANDLE; } /*! diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index 790bef9e14..ed73a77683 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -1866,7 +1866,7 @@ void QVulkanWindowPrivate::beginFrame() // build new draw command buffer if (image.cmdBuf) { devFuncs->vkFreeCommandBuffers(dev, cmdPool, 1, &image.cmdBuf); - image.cmdBuf = 0; + image.cmdBuf = nullptr; } VkCommandBufferAllocateInfo cmdBufInfo = { diff --git a/src/network/access/qabstractprotocolhandler.cpp b/src/network/access/qabstractprotocolhandler.cpp index f15dfe6899..6847816ba7 100644 --- a/src/network/access/qabstractprotocolhandler.cpp +++ b/src/network/access/qabstractprotocolhandler.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QAbstractProtocolHandler::QAbstractProtocolHandler(QHttpNetworkConnectionChannel *channel) - : m_channel(channel), m_reply(0), m_socket(m_channel->socket), m_connection(m_channel->connection) + : m_channel(channel), m_reply(nullptr), m_socket(m_channel->socket), m_connection(m_channel->connection) { Q_ASSERT(m_channel); Q_ASSERT(m_socket); diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index cc230a5411..62ae1adbd9 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -74,7 +74,7 @@ public: CsConnectionRefused }; - QFtpDTP(QFtpPI *p, QObject *parent = 0); + QFtpDTP(QFtpPI *p, QObject *parent = nullptr); void setData(QByteArray *); void setDevice(QIODevice *); @@ -149,7 +149,7 @@ class QFtpPI : public QObject Q_OBJECT public: - QFtpPI(QObject *parent = 0); + QFtpPI(QObject *parent = nullptr); void connectToHost(const QString &host, quint16 port); @@ -229,7 +229,7 @@ class QFtpCommand { public: QFtpCommand(QFtp::Command cmd, const QStringList &raw, const QByteArray &ba); - QFtpCommand(QFtp::Command cmd, const QStringList &raw, QIODevice *dev = 0); + QFtpCommand(QFtp::Command cmd, const QStringList &raw, QIODevice *dev = nullptr); ~QFtpCommand(); int id; @@ -279,7 +279,7 @@ QFtpCommand::~QFtpCommand() *********************************************************************/ QFtpDTP::QFtpDTP(QFtpPI *p, QObject *parent) : QObject(parent), - socket(0), + socket(nullptr), listener(this), pi(p), callWriteData(false) @@ -314,7 +314,7 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) if (socket) { delete socket; - socket = 0; + socket = nullptr; } socket = new QTcpSocket(this); #ifndef QT_NO_BEARERMANAGEMENT @@ -427,7 +427,7 @@ void QFtpDTP::writeData() } // do we continue uploading? - callWriteData = data.dev != 0; + callWriteData = data.dev != nullptr; } } @@ -779,7 +779,7 @@ void QFtpDTP::setupSocket() void QFtpDTP::clearData() { is_ba = false; - data.dev = 0; + data.dev = nullptr; } /********************************************************************** @@ -792,7 +792,7 @@ QFtpPI::QFtpPI(QObject *parent) : rawCommand(false), transferConnectionExtended(true), dtp(this), - commandSocket(0), + commandSocket(nullptr), state(Begin), abortState(None), currentCmd(QString()), waitForDtpToConnect(false), @@ -2173,10 +2173,10 @@ QFtp::Command QFtp::currentCommand() const QIODevice* QFtp::currentDevice() const { if (d_func()->pending.isEmpty()) - return 0; + return nullptr; QFtpCommand *c = d_func()->pending.first(); if (c->is_ba) - return 0; + return nullptr; return c->data.dev; } diff --git a/src/network/access/qhttpmultipart.cpp b/src/network/access/qhttpmultipart.cpp index c59df9d8b8..d6fefc4314 100644 --- a/src/network/access/qhttpmultipart.cpp +++ b/src/network/access/qhttpmultipart.cpp @@ -111,7 +111,7 @@ QHttpPart::QHttpPart(const QHttpPart &other) : d(other.d) */ QHttpPart::~QHttpPart() { - d = 0; + d = nullptr; } /*! diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 21c6359807..b9a4c874c0 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -382,9 +382,9 @@ void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket, // Clean the channel channels[i].close(); - channels[i].reply = 0; + channels[i].reply = nullptr; if (channels[i].protocolHandler) - channels[i].protocolHandler->setReply(0); + channels[i].protocolHandler->setReply(nullptr); channels[i].request = QHttpNetworkRequest(); if (socket) channels[i].requeueCurrentlyPipelinedRequests(); @@ -408,7 +408,7 @@ void QHttpNetworkConnectionPrivate::copyCredentials(int fromChannel, QAuthentica } // select another channel - QAuthenticator* otherAuth = 0; + QAuthenticator* otherAuth = nullptr; for (int i = 0; i < activeChannelCount; ++i) { if (i == fromChannel) continue; @@ -441,7 +441,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket if (authMethod != QAuthenticatorPrivate::None) { int i = indexOf(socket); //Use a single authenticator for all domains. ### change later to use domain/realm - QAuthenticator* auth = 0; + QAuthenticator* auth = nullptr; if (isProxy) { auth = &channels[i].proxyAuthenticator; channels[i].proxyAuthMethod = authMethod; @@ -496,7 +496,7 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket // we need to bail out if authentication is required. if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) { // Reset authenticator so the next request on that channel does not get messed up - auth = 0; + auth = nullptr; if (isProxy) channels[i].proxyAuthenticator = QAuthenticator(); else @@ -766,7 +766,7 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) int i = indexOf(socket); // return fast if there was no reply right now processed - if (channels[i].reply == 0) + if (channels[i].reply == nullptr) return; if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) { @@ -937,9 +937,9 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) for (int i = 0; i < activeChannelCount; ++i) { // is the reply associated the currently processing of this channel? if (channels[i].reply == reply) { - channels[i].reply = 0; + channels[i].reply = nullptr; if (channels[i].protocolHandler) - channels[i].protocolHandler->setReply(0); + channels[i].protocolHandler->setReply(nullptr); channels[i].request = QHttpNetworkRequest(); channels[i].resendCurrent = false; diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 39f392a79b..47081b29d2 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -87,11 +87,11 @@ private: static const int reconnectAttemptsDefault = 3; QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel() - : socket(0) + : socket(nullptr) , ssl(false) , isInitialized(false) , state(IdleState) - , reply(0) + , reply(nullptr) , written(0) , bytesTotal(0) , resendCurrent(false) @@ -102,13 +102,13 @@ QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel() , proxyAuthMethod(QAuthenticatorPrivate::None) , authenticationCredentialsSent(false) , proxyCredentialsSent(false) - , protocolHandler(0) + , protocolHandler(nullptr) #ifndef QT_NO_SSL , ignoreAllSslErrors(false) #endif , pipeliningSupported(PipeliningSupportUnknown) , networkLayerPreference(QAbstractSocket::AnyIPProtocol) - , connection(0) + , connection(nullptr) { // Inlining this function in the header leads to compiler error on // release-armv5, on at least timebox 9.2 and 10.1. @@ -295,9 +295,9 @@ void QHttpNetworkConnectionChannel::handleUnexpectedEOF() close(); reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::RemoteHostClosedError, socket); emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString); - reply = 0; + reply = nullptr; if (protocolHandler) - protocolHandler->setReply(0); + protocolHandler->setReply(nullptr); request = QHttpNetworkRequest(); QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } else { @@ -526,8 +526,8 @@ void QHttpNetworkConnectionChannel::allDone() // problem. if (!resendCurrent) { request = QHttpNetworkRequest(); - reply = 0; - protocolHandler->setReply(0); + reply = nullptr; + protocolHandler->setReply(nullptr); } // move next from pipeline to current request @@ -1100,9 +1100,9 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket if (reply) { reply->d_func()->errorString = errorString; emit reply->finishedWithError(errorCode, errorString); - reply = 0; + reply = nullptr; if (protocolHandler) - protocolHandler->setReply(0); + protocolHandler->setReply(nullptr); } } while (!connection->d_func()->highPriorityQueue.isEmpty() || !connection->d_func()->lowPriorityQueue.isEmpty()); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index a8b635c45a..af456c3607 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -330,12 +330,12 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl) currentlyUploadedDataInWindow(0), totallyUploadedData(0), removedContentLength(-1), - connection(0), + connection(nullptr), autoDecompress(false), responseData(), requestIsPrepared(false) ,pipeliningUsed(false), spdyUsed(false), downstreamLimited(false) - ,userProvidedDownloadBuffer(0) + ,userProvidedDownloadBuffer(nullptr) #ifndef QT_NO_COMPRESS - ,inflateStrm(0) + ,inflateStrm(nullptr) #endif { @@ -375,8 +375,8 @@ void QHttpNetworkReplyPrivate::clearHttpLayerInformation() // TODO: Isn't everything HTTP layer related? We don't need to set connection and connectionChannel to 0 at all void QHttpNetworkReplyPrivate::clear() { - connection = 0; - connectionChannel = 0; + connection = nullptr; + connectionChannel = nullptr; autoDecompress = false; clearHttpLayerInformation(); } diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index a3f71b8d2f..5fb8885bdf 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, QHttpNetworkRequest::Priority pri, const QUrl &newUrl) - : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0), + : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(nullptr), autoDecompress(false), pipeliningAllowed(false), spdyAllowed(false), http2Allowed(false), http2Direct(false), withCredentials(true), preConnect(false), redirectCount(0), redirectPolicy(QNetworkRequest::ManualRedirectPolicy) diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index edcbdcbe0e..d39589fb96 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -278,7 +278,7 @@ bool QHttpProtocolHandler::sendRequest() m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState; m_channel->allDone(); m_connection->preConnectFinished(); // will only decrease the counter - m_reply = 0; // so we can reuse this channel + m_reply = nullptr; // so we can reuse this channel return true; // we have a working connection and are done } @@ -373,7 +373,7 @@ bool QHttpProtocolHandler::sendRequest() // premature eof happened m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::UnknownNetworkError); return false; - } else if (readPointer == 0 || currentReadSize == 0) { + } else if (readPointer == nullptr || currentReadSize == 0) { // nothing to read currently, break the loop break; } else { diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 63a3c4f204..f3125a3a95 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -189,7 +189,7 @@ public: QNetworkAccessCachedHttpConnection(const QString &hostName, quint16 port, bool encrypt, QHttpNetworkConnection::ConnectionType connectionType, QSharedPointer<QNetworkSession> networkSession) - : QHttpNetworkConnection(hostName, port, encrypt, connectionType, /*parent=*/0, + : QHttpNetworkConnection(hostName, port, encrypt, connectionType, /*parent=*/nullptr, std::move(networkSession)) #endif { @@ -241,9 +241,9 @@ QHttpThreadDelegate::QHttpThreadDelegate(QObject *parent) : , removedContentLength(-1) , incomingErrorCode(QNetworkReply::NoError) , downloadBuffer() - , httpConnection(0) - , httpReply(0) - , synchronousRequestLoop(0) + , httpConnection(nullptr) + , httpReply(nullptr) + , synchronousRequestLoop(nullptr) { } @@ -439,7 +439,7 @@ void QHttpThreadDelegate::abortRequest() if (httpReply) { httpReply->abort(); delete httpReply; - httpReply = 0; + httpReply = nullptr; } // Got aborted by the timeout timer @@ -545,7 +545,7 @@ void QHttpThreadDelegate::finishedSlot() QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection); - httpReply = 0; + httpReply = nullptr; } void QHttpThreadDelegate::synchronousFinishedSlot() @@ -568,7 +568,7 @@ void QHttpThreadDelegate::synchronousFinishedSlot() QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection); - httpReply = 0; + httpReply = nullptr; } void QHttpThreadDelegate::finishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail) @@ -590,7 +590,7 @@ void QHttpThreadDelegate::finishedWithErrorSlot(QNetworkReply::NetworkError erro QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection); - httpReply = 0; + httpReply = nullptr; } @@ -609,7 +609,7 @@ void QHttpThreadDelegate::synchronousFinishedWithErrorSlot(QNetworkReply::Networ QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection); - httpReply = 0; + httpReply = nullptr; } static void downloadBufferDeleter(char *ptr) diff --git a/src/network/access/qnetworkaccessauthenticationmanager.cpp b/src/network/access/qnetworkaccessauthenticationmanager.cpp index b661cc45b3..0df11684b1 100644 --- a/src/network/access/qnetworkaccessauthenticationmanager.cpp +++ b/src/network/access/qnetworkaccessauthenticationmanager.cpp @@ -71,7 +71,7 @@ public: if (it == end() && !isEmpty()) --it; if (it == end() || !domain.startsWith(it->domain)) - return 0; + return nullptr; return &*it; } diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 566e410051..8f42f3690b 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -105,7 +105,7 @@ QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessM ++it; } } - return 0; + return nullptr; } QStringList QNetworkAccessManagerPrivate::backendSupportedSchemes() const @@ -131,7 +131,7 @@ QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice() else if (reply->outgoingData) { uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingData); } else { - return 0; + return nullptr; } // We want signal emissions only for normal asynchronous uploads @@ -151,8 +151,8 @@ void QNetworkAccessBackend::emitReplyUploadProgress(qint64 bytesSent, qint64 byt } QNetworkAccessBackend::QNetworkAccessBackend() - : manager(0) - , reply(0) + : manager(nullptr) + , reply(nullptr) , synchronous(false) { } @@ -223,7 +223,7 @@ QList<QNetworkProxy> QNetworkAccessBackend::proxyList() const QAbstractNetworkCache *QNetworkAccessBackend::networkCache() const { if (!manager) - return 0; + return nullptr; return manager->networkCache; } diff --git a/src/network/access/qnetworkaccesscache.cpp b/src/network/access/qnetworkaccesscache.cpp index b694a2c999..ba092f2618 100644 --- a/src/network/access/qnetworkaccesscache.cpp +++ b/src/network/access/qnetworkaccesscache.cpp @@ -73,7 +73,7 @@ struct QNetworkAccessCache::Node int useCount; Node() - : older(0), newer(0), object(0), useCount(0) + : older(nullptr), newer(nullptr), object(nullptr), useCount(0) { } }; @@ -103,7 +103,7 @@ void QNetworkAccessCache::CacheableObject::setShareable(bool enable) } QNetworkAccessCache::QNetworkAccessCache() - : oldest(0), newest(0) + : oldest(nullptr), newest(nullptr) { } @@ -130,7 +130,7 @@ void QNetworkAccessCache::clear() timer.stop(); - oldest = newest = 0; + oldest = newest = nullptr; } /*! @@ -145,11 +145,11 @@ void QNetworkAccessCache::linkEntry(const QByteArray &key) Node *const node = &it.value(); Q_ASSERT(node != oldest && node != newest); - Q_ASSERT(node->older == 0 && node->newer == 0); + Q_ASSERT(node->older == nullptr && node->newer == nullptr); Q_ASSERT(node->useCount == 0); if (newest) { - Q_ASSERT(newest->newer == 0); + Q_ASSERT(newest->newer == nullptr); newest->newer = node; node->older = newest; } @@ -186,7 +186,7 @@ bool QNetworkAccessCache::unlinkEntry(const QByteArray &key) if (node->newer) node->newer->older = node->older; - node->newer = node->older = 0; + node->newer = node->older = nullptr; return wasOldest; } @@ -235,9 +235,9 @@ void QNetworkAccessCache::timerEvent(QTimerEvent *) // fixup the list if (oldest) - oldest->older = 0; + oldest->older = nullptr; else - newest = 0; + newest = nullptr; updateTimer(); } @@ -277,7 +277,7 @@ bool QNetworkAccessCache::requestEntry(const QByteArray &key, QObject *target, c if (node->useCount > 0 && !node->object->shareable) { // object is not shareable and is in use // queue for later use - Q_ASSERT(node->older == 0 && node->newer == 0); + Q_ASSERT(node->older == nullptr && node->newer == nullptr); node->receiverQueue.push_back({target, member}); // request queued @@ -296,7 +296,7 @@ QNetworkAccessCache::CacheableObject *QNetworkAccessCache::requestEntryNow(const { NodeHash::Iterator it = hash.find(key); if (it == hash.end()) - return 0; + return nullptr; if (it->useCount > 0) { if (it->object->shareable) { ++it->useCount; @@ -304,7 +304,7 @@ QNetworkAccessCache::CacheableObject *QNetworkAccessCache::requestEntryNow(const } // object in use and not shareable - return 0; + return nullptr; } // entry not in use, let the caller have it diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index 67a856506c..03ffc69628 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -70,13 +70,13 @@ QNetworkAccessDebugPipeBackendFactory::create(QNetworkAccessManager::Operation o default: // no, we can't handle this operation - return 0; + return nullptr; } QUrl url = request.url(); if (url.scheme() == QLatin1String("debugpipe")) return new QNetworkAccessDebugPipeBackend; - return 0; + return nullptr; } QNetworkAccessDebugPipeBackend::QNetworkAccessDebugPipeBackend() @@ -188,7 +188,7 @@ void QNetworkAccessDebugPipeBackend::pushFromUpstreamToSocket() emitReplyUploadProgress(bytesUploaded, bytesUploaded); possiblyFinish(); break; - } else if (haveRead == 0 || readPointer == 0) { + } else if (haveRead == 0 || readPointer == nullptr) { // nothing to read right now, we will be called again later break; } else { diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 60353cb03e..507417f86c 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -73,7 +73,7 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, default: // no, we can't handle this operation - return 0; + return nullptr; } QUrl url = request.url(); @@ -95,7 +95,7 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, return new QNetworkAccessFileBackend; } - return 0; + return nullptr; } QNetworkAccessFileBackend::QNetworkAccessFileBackend() @@ -198,7 +198,7 @@ void QNetworkAccessFileBackend::uploadReadyReadSlot() file.close(); finished(); break; - } else if (haveRead == 0 || readPointer == 0) { + } else if (haveRead == 0 || readPointer == nullptr) { // nothing to read right now, we will be called again later break; } else { diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 51ed2f5a55..fb8cd79c12 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -75,13 +75,13 @@ QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, default: // no, we can't handle this operation - return 0; + return nullptr; } QUrl url = request.url(); if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0) return new QNetworkAccessFtpBackend; - return 0; + return nullptr; } class QNetworkAccessCachedFtpConnection: public QFtp, public QNetworkAccessCache::CacheableObject @@ -104,7 +104,7 @@ public: }; QNetworkAccessFtpBackend::QNetworkAccessFtpBackend() - : ftp(0), uploadDevice(0), totalBytes(0), helpId(-1), sizeId(-1), mdtmId(-1), pwdId(-1), + : ftp(nullptr), uploadDevice(nullptr), totalBytes(0), helpId(-1), sizeId(-1), mdtmId(-1), pwdId(-1), supportsSize(false), supportsMdtm(false), supportsPwd(false), state(Idle) { } @@ -215,7 +215,7 @@ void QNetworkAccessFtpBackend::disconnectFromFtp(CacheCleanupMode mode) state = Disconnecting; if (ftp) { - disconnect(ftp, 0, this, 0); + disconnect(ftp, nullptr, this, nullptr); QByteArray key = makeCacheKey(url()); if (mode == RemoveCachedConnection) { @@ -225,7 +225,7 @@ void QNetworkAccessFtpBackend::disconnectFromFtp(CacheCleanupMode mode) QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key); } - ftp = 0; + ftp = nullptr; } } @@ -362,7 +362,7 @@ void QNetworkAccessFtpBackend::ftpDone() QFtp::TransferType type = QFtp::Binary; if (operation() == QNetworkAccessManager::GetOperation) { setCachingEnabled(true); - ftp->get(url().path(), 0, type); + ftp->get(url().path(), nullptr, type); } else { ftp->put(uploadDevice, url().path(), type); } diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 903de322ff..47f6112b22 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -131,7 +131,7 @@ QNetworkCookie::QNetworkCookie(const QNetworkCookie &other) QNetworkCookie::~QNetworkCookie() { // QSharedDataPointer auto deletes - d = 0; + d = nullptr; } /*! diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index df2e4902a4..b30d1c9664 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -180,11 +180,11 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData) #endif Q_D(QNetworkDiskCache); if (!metaData.isValid() || !metaData.url().isValid() || !metaData.saveToDisk()) - return 0; + return nullptr; if (d->cacheDirectory.isEmpty()) { qWarning("QNetworkDiskCache::prepare() The cache directory is not set"); - return 0; + return nullptr; } const auto headers = metaData.rawHeaders(); @@ -192,14 +192,14 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData) if (header.first.compare("content-length", Qt::CaseInsensitive) == 0) { const qint64 size = header.second.toLongLong(); if (size > (maximumCacheSize() * 3)/4) - return 0; + return nullptr; break; } } QScopedPointer<QCacheItem> cacheItem(new QCacheItem); cacheItem->metaData = metaData; - QIODevice *device = 0; + QIODevice *device = nullptr; if (cacheItem->canCompress()) { cacheItem->data.open(QBuffer::ReadWrite); device = &(cacheItem->data); @@ -208,12 +208,12 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData) QT_TRY { cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data); } QT_CATCH(...) { - cacheItem->file = 0; + cacheItem->file = nullptr; } if (!cacheItem->file || !cacheItem->file->open()) { qWarning("QNetworkDiskCache::prepare() unable to open temporary file"); cacheItem.reset(); - return 0; + return nullptr; } cacheItem->writeHeader(cacheItem->file); device = cacheItem->file; @@ -397,19 +397,19 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url) Q_D(QNetworkDiskCache); QScopedPointer<QBuffer> buffer; if (!url.isValid()) - return 0; + return nullptr; if (d->lastItem.metaData.url() == url && d->lastItem.data.isOpen()) { buffer.reset(new QBuffer); buffer->setData(d->lastItem.data.data()); } else { QScopedPointer<QFile> file(new QFile(d->cacheFileName(url))); if (!file->open(QFile::ReadOnly | QIODevice::Unbuffered)) - return 0; + return nullptr; if (!d->lastItem.read(file.data(), true)) { file->close(); remove(url); - return 0; + return nullptr; } if (d->lastItem.data.isOpen()) { // compressed @@ -419,7 +419,7 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url) buffer.reset(new QBuffer); // ### verify that QFile uses the fd size and not the file name qint64 size = file->size() - file->pos(); - const uchar *p = 0; + const uchar *p = nullptr; #if !defined(Q_OS_INTEGRITY) p = file->map(file->pos(), size); #endif @@ -557,7 +557,7 @@ qint64 QNetworkDiskCache::expire() for (QCacheItem *item : qAsConst(d->inserting)) { if (item && item->file && item->file->fileName() == name) { delete item->file; - item->file = 0; + item->file = nullptr; break; } } diff --git a/src/network/access/qnetworkreplyfileimpl.cpp b/src/network/access/qnetworkreplyfileimpl.cpp index ef319ebf0d..afab8ffd94 100644 --- a/src/network/access/qnetworkreplyfileimpl.cpp +++ b/src/network/access/qnetworkreplyfileimpl.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate() - : QNetworkReplyPrivate(), managerPrivate(0), realFile(0) + : QNetworkReplyPrivate(), managerPrivate(nullptr), realFile(nullptr) { qRegisterMetaType<QNetworkRequest::KnownHeaders>(); qRegisterMetaType<QNetworkReply::NetworkError>(); diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 6eab500e8c..a43a29a239 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -53,9 +53,9 @@ QT_BEGIN_NAMESPACE inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() - : backend(0), outgoingData(0), - copyDevice(0), - cacheEnabled(false), cacheSaveDevice(0), + : backend(nullptr), outgoingData(nullptr), + copyDevice(nullptr), + cacheEnabled(false), cacheSaveDevice(nullptr), notificationHandlingPaused(false), bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), preMigrationDownloaded(-1), httpStatusCode(0), @@ -63,7 +63,7 @@ inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() , downloadBufferReadPosition(0) , downloadBufferCurrentSize(0) , downloadBufferMaximumSize(0) - , downloadBuffer(0) + , downloadBuffer(nullptr) { if (request.attribute(QNetworkRequest::EmitAllUploadProgressSignalsAttribute).toBool() == true) emitAllUploadProgressSignals = true; @@ -489,7 +489,7 @@ void QNetworkReplyImplPrivate::resumeNotificationHandling() QAbstractNetworkCache *QNetworkReplyImplPrivate::networkCache() const { if (!backend) - return 0; + return nullptr; return backend->networkCache(); } @@ -504,7 +504,7 @@ void QNetworkReplyImplPrivate::createCache() bool QNetworkReplyImplPrivate::isCachingEnabled() const { - return (cacheEnabled && networkCache() != 0); + return (cacheEnabled && networkCache() != nullptr); } void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) @@ -529,7 +529,7 @@ void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) "backend %s probably needs to be fixed", backend->metaObject()->className()); networkCache()->remove(url); - cacheSaveDevice = 0; + cacheSaveDevice = nullptr; cacheEnabled = false; } } @@ -541,7 +541,7 @@ void QNetworkReplyImplPrivate::completeCacheSave() } else if (cacheEnabled && cacheSaveDevice) { networkCache()->insert(cacheSaveDevice); } - cacheSaveDevice = 0; + cacheSaveDevice = nullptr; cacheEnabled = false; } @@ -610,7 +610,7 @@ void QNetworkReplyImplPrivate::initCacheSaveDevice() networkCache()->metaObject()->className()); networkCache()->remove(url); - cacheSaveDevice = 0; + cacheSaveDevice = nullptr; cacheEnabled = false; } } @@ -927,9 +927,9 @@ void QNetworkReplyImpl::abort() // stop both upload and download if (d->outgoingData) - disconnect(d->outgoingData, 0, this, 0); + disconnect(d->outgoingData, nullptr, this, nullptr); if (d->copyDevice) - disconnect(d->copyDevice, 0, this, 0); + disconnect(d->copyDevice, nullptr, this, nullptr); QNetworkReply::close(); @@ -943,7 +943,7 @@ void QNetworkReplyImpl::abort() // finished may access the backend if (d->backend) { d->backend->deleteLater(); - d->backend = 0; + d->backend = nullptr; } } @@ -958,7 +958,7 @@ void QNetworkReplyImpl::close() if (d->backend) d->backend->closeDownstreamChannel(); if (d->copyDevice) - disconnect(d->copyDevice, 0, this, 0); + disconnect(d->copyDevice, nullptr, this, nullptr); QNetworkReply::close(); diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 92e5aed38c..70b09dba22 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -444,7 +444,7 @@ public: inline QNetworkRequestPrivate() : priority(QNetworkRequest::NormalPriority) #ifndef QT_NO_SSL - , sslConfiguration(0) + , sslConfiguration(nullptr) #endif , maxRedirectsAllowed(maxRedirectCount) , transferTimeout(0) @@ -464,7 +464,7 @@ public: priority = other.priority; maxRedirectsAllowed = other.maxRedirectsAllowed; #ifndef QT_NO_SSL - sslConfiguration = 0; + sslConfiguration = nullptr; if (other.sslConfiguration) sslConfiguration = new QSslConfiguration(*other.sslConfiguration); #endif @@ -550,7 +550,7 @@ QNetworkRequest::QNetworkRequest(const QNetworkRequest &other) QNetworkRequest::~QNetworkRequest() { // QSharedDataPointer auto deletes - d = 0; + d = nullptr; } /*! diff --git a/src/network/access/qspdyprotocolhandler.cpp b/src/network/access/qspdyprotocolhandler.cpp index cc913ce760..eef8df288d 100644 --- a/src/network/access/qspdyprotocolhandler.cpp +++ b/src/network/access/qspdyprotocolhandler.cpp @@ -254,7 +254,7 @@ static const char spdyDictionary[] = { //} QSpdyProtocolHandler::QSpdyProtocolHandler(QHttpNetworkConnectionChannel *channel) - : QObject(0), QAbstractProtocolHandler(channel), + : QObject(nullptr), QAbstractProtocolHandler(channel), m_nextStreamID(-1), m_maxConcurrentStreams(100), // 100 is recommended in the SPDY RFC m_initialWindowSize(0), @@ -720,7 +720,7 @@ bool QSpdyProtocolHandler::uploadData(qint32 streamID) m_connection->d_func()->emitReplyError(m_socket, reply, QNetworkReply::UnknownNetworkError); return false; - } else if (readPointer == 0 || currentReadSize == 0) { + } else if (readPointer == nullptr || currentReadSize == 0) { // nothing to read currently, break the loop break; } else { @@ -746,7 +746,7 @@ bool QSpdyProtocolHandler::uploadData(qint32 streamID) } if (replyPrivate->totallyUploadedData == request.contentLength()) { DataFrameFlags finFlag = DataFrame_FLAG_FIN; - qint64 writeSize = sendDataFrame(streamID, finFlag, 0, 0); + qint64 writeSize = sendDataFrame(streamID, finFlag, 0, nullptr); Q_ASSERT(writeSize == 0); Q_UNUSED(writeSize); // silence -Wunused-variable replyPrivate->state = QHttpNetworkReplyPrivate::SPDYHalfClosed; @@ -892,7 +892,7 @@ void QSpdyProtocolHandler::parseHttpHeaders(char flags, const QByteArray &frameD HttpMessagePair pair = it.value(); QHttpNetworkReply *httpReply = pair.second; - Q_ASSERT(httpReply != 0); + Q_ASSERT(httpReply != nullptr); if (httpReply->d_func()->state == QHttpNetworkReplyPrivate::SPDYClosed) { sendRST_STREAM(streamID, RST_STREAM_STREAM_ALREADY_CLOSED); @@ -950,7 +950,7 @@ void QSpdyProtocolHandler::parseHttpHeaders(char flags, const QByteArray &frameD if (flag_fin) { if (httpReply->d_func()->state != QHttpNetworkReplyPrivate::SPDYHalfClosed) - sendDataFrame(streamID, DataFrame_FLAG_FIN, 0, 0); + sendDataFrame(streamID, DataFrame_FLAG_FIN, 0, nullptr); replyFinished(httpReply, streamID); } } @@ -1199,7 +1199,7 @@ void QSpdyProtocolHandler::handleDataFrame(const QByteArray &frameHeaders) HttpMessagePair pair = it.value(); QHttpNetworkRequest httpRequest = pair.first; QHttpNetworkReply *httpReply = pair.second; - Q_ASSERT(httpReply != 0); + Q_ASSERT(httpReply != nullptr); QHttpNetworkReplyPrivate *replyPrivate = httpReply->d_func(); @@ -1261,7 +1261,7 @@ void QSpdyProtocolHandler::handleDataFrame(const QByteArray &frameHeaders) if (flag_fin) { if (httpReply->d_func()->state != QHttpNetworkReplyPrivate::SPDYHalfClosed) - sendDataFrame(streamID, DataFrame_FLAG_FIN, 0, 0); + sendDataFrame(streamID, DataFrame_FLAG_FIN, 0, nullptr); replyFinished(httpReply, streamID); } } diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index c2d30d52e2..751735c8bd 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -68,7 +68,7 @@ static void connManager_cleanup() int shutdown = appShutdown.fetchAndStoreAcquire(1); Q_ASSERT(shutdown == 0); Q_UNUSED(shutdown); - QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(0); + QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(nullptr); if (cmp) cmp->cleanup(); } diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 252b88d36a..f0aa452dd3 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(), pollTimer(0), + : QObject(), pollTimer(nullptr), loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")), forcedPolling(0), firstUpdate(true) { @@ -367,7 +367,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() bool envOK = false; const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK); - QBearerEngine *generic = 0; + QBearerEngine *generic = nullptr; QFactoryLoader *l = &loader; const PluginKeyMap keyMap = l->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index 19bc44e02a..25c4ab711e 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -209,7 +209,7 @@ QT_BEGIN_NAMESPACE \sa isValid() */ QNetworkConfiguration::QNetworkConfiguration() - : d(0) + : d(nullptr) { } diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 1636bcee97..324016d72a 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -250,7 +250,7 @@ QT_BEGIN_NAMESPACE \sa QNetworkConfiguration */ QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent) - : QObject(parent), d(0) + : QObject(parent), d(nullptr) { qRegisterMetaType<QNetworkSession::State>(); qRegisterMetaType<QNetworkSession::SessionError>(); diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 33a30eb1cd..e9a8e2a9e5 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -158,7 +158,7 @@ static QByteArray qGssapiContinue(QAuthenticatorPrivate *ctx, Constructs an empty authentication object. */ QAuthenticator::QAuthenticator() - : d(0) + : d(nullptr) { } @@ -175,7 +175,7 @@ QAuthenticator::~QAuthenticator() Constructs a copy of \a other. */ QAuthenticator::QAuthenticator(const QAuthenticator &other) - : d(0) + : d(nullptr) { if (other.d) *this = other; @@ -1227,7 +1227,7 @@ QByteArray qEncodeHmacMd5(QByteArray &key, const QByteArray &message) static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx, QNtlmPhase3Block *phase3) { - Q_ASSERT(phase3 != 0); + Q_ASSERT(phase3 != nullptr); // since v2 Hash is need for both NTLMv2 and LMv2 it is calculated // only once and stored and reused if(phase3->v2Hash.size() == 0) { @@ -1284,7 +1284,7 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch, QNtlmPhase3Block *phase3) { - Q_ASSERT(phase3 != 0); + Q_ASSERT(phase3 != nullptr); // return value stored in phase3 qCreatev2Hash(ctx, phase3); @@ -1351,7 +1351,7 @@ static QByteArray qEncodeLmv2Response(const QAuthenticatorPrivate *ctx, const QNtlmPhase2Block& ch, QNtlmPhase3Block *phase3) { - Q_ASSERT(phase3 != 0); + Q_ASSERT(phase3 != nullptr); // return value stored in phase3 qCreatev2Hash(ctx, phase3); diff --git a/src/network/kernel/qdnslookup.cpp b/src/network/kernel/qdnslookup.cpp index 1b66829070..ab1be02b6b 100644 --- a/src/network/kernel/qdnslookup.cpp +++ b/src/network/kernel/qdnslookup.cpp @@ -481,7 +481,7 @@ void QDnsLookup::abort() { Q_D(QDnsLookup); if (d->runnable) { - d->runnable = 0; + d->runnable = nullptr; d->reply = QDnsLookupReply(); d->reply.error = QDnsLookup::OperationCancelledError; d->reply.errorString = tr("Operation cancelled"); @@ -992,7 +992,7 @@ void QDnsLookupPrivate::_q_lookupFinished(const QDnsLookupReply &_reply) qDebug("DNS reply for %s: %i (%s)", qPrintable(name), _reply.error, qPrintable(_reply.errorString)); #endif reply = _reply; - runnable = 0; + runnable = nullptr; isFinished = true; emit q->finished(); } diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp index ee7484ab35..12b40fc35d 100644 --- a/src/network/kernel/qdnslookup_unix.cpp +++ b/src/network/kernel/qdnslookup_unix.cpp @@ -73,13 +73,13 @@ QT_BEGIN_NAMESPACE typedef struct __res_state* res_state; #endif typedef int (*dn_expand_proto)(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); -static dn_expand_proto local_dn_expand = 0; +static dn_expand_proto local_dn_expand = nullptr; typedef void (*res_nclose_proto)(res_state); -static res_nclose_proto local_res_nclose = 0; +static res_nclose_proto local_res_nclose = nullptr; typedef int (*res_ninit_proto)(res_state); -static res_ninit_proto local_res_ninit = 0; +static res_ninit_proto local_res_ninit = nullptr; typedef int (*res_nquery_proto)(res_state, const char *, int, int, unsigned char *, int); -static res_nquery_proto local_res_nquery = 0; +static res_nquery_proto local_res_nquery = nullptr; // Custom deleter to close resolver state. diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index b54fb349fb..ed1c23ed6e 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -144,7 +144,7 @@ static bool parseIp6(const QString &address, QIPAddressUtils::IPv6Address &addr, } else { scopeId->clear(); } - return QIPAddressUtils::parseIp6(addr, tmp.constBegin(), tmp.constEnd()) == 0; + return QIPAddressUtils::parseIp6(addr, tmp.constBegin(), tmp.constEnd()) == nullptr; } bool QHostAddressPrivate::parse(const QString &ipString) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f9335c3bb9..31671feece 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -410,7 +410,7 @@ QHostInfo QHostInfoAgent::reverseLookup(const QHostAddress &address) // Reverse lookup sockaddr_in sa4; sockaddr_in6 sa6; - sockaddr *sa = 0; + sockaddr *sa = nullptr; QT_SOCKLEN_T saSize; if (address.protocol() == QAbstractSocket::IPv4Protocol) { sa = reinterpret_cast<sockaddr *>(&sa4); @@ -455,7 +455,7 @@ QHostInfo QHostInfoAgent::lookup(const QString &hostName) return results; } - addrinfo *res = 0; + addrinfo *res = nullptr; struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index 78a05f8407..625fbabf31 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -80,12 +80,12 @@ enum LibResolvFeature { typedef struct __res_state *res_state_ptr; typedef int (*res_init_proto)(void); -static res_init_proto local_res_init = 0; +static res_init_proto local_res_init = nullptr; typedef int (*res_ninit_proto)(res_state_ptr); -static res_ninit_proto local_res_ninit = 0; +static res_ninit_proto local_res_ninit = nullptr; typedef void (*res_nclose_proto)(res_state_ptr); -static res_nclose_proto local_res_nclose = 0; -static res_state_ptr local_res = 0; +static res_nclose_proto local_res_nclose = nullptr; +static res_state_ptr local_res = nullptr; #if QT_CONFIG(library) && !defined(Q_OS_QNX) namespace { diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index b7a6d9adf9..eed57f8a32 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -627,7 +627,7 @@ bool QNetworkAddressEntry::isPermanent() const Constructs an empty network interface object. */ QNetworkInterface::QNetworkInterface() - : d(0) + : d(nullptr) { } diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index a2a89ed94b..90c8b75a86 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -254,13 +254,13 @@ class QGlobalNetworkProxy { public: QGlobalNetworkProxy() - : applicationLevelProxy(0) - , applicationLevelProxyFactory(0) + : applicationLevelProxy(nullptr) + , applicationLevelProxyFactory(nullptr) #if QT_CONFIG(socks5) - , socks5SocketEngineHandler(0) + , socks5SocketEngineHandler(nullptr) #endif #if QT_CONFIG(http) - , httpSocketEngineHandler(0) + , httpSocketEngineHandler(nullptr) #endif #ifdef QT_USE_SYSTEM_PROXIES , useSystemProxies(true) @@ -313,7 +313,7 @@ public: applicationLevelProxy = new QNetworkProxy; *applicationLevelProxy = proxy; delete applicationLevelProxyFactory; - applicationLevelProxyFactory = 0; + applicationLevelProxyFactory = nullptr; useSystemProxies = false; } @@ -501,7 +501,7 @@ template<> void QSharedDataPointer<QNetworkProxyPrivate>::detach() \sa setType(), setApplicationProxy() */ QNetworkProxy::QNetworkProxy() - : d(0) + : d(nullptr) { // make sure we have QGlobalNetworkProxy singleton created, otherwise // you don't have any socket engine handler created when directly setting diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp index 7ae6822fb4..e6f2e70ff4 100644 --- a/src/network/kernel/qurlinfo.cpp +++ b/src/network/kernel/qurlinfo.cpp @@ -126,7 +126,7 @@ public: QUrlInfo::QUrlInfo() { - d = 0; + d = nullptr; } /*! @@ -139,7 +139,7 @@ QUrlInfo::QUrlInfo(const QUrlInfo &ui) d = new QUrlInfoPrivate; *d = *ui.d; } else { - d = 0; + d = nullptr; } } @@ -443,7 +443,7 @@ QUrlInfo &QUrlInfo::operator=(const QUrlInfo &ui) *d = *ui.d; } else { delete d; - d = 0; + d = nullptr; } return *this; } @@ -683,7 +683,7 @@ bool QUrlInfo::equal(const QUrlInfo &i1, const QUrlInfo &i2, bool QUrlInfo::operator==(const QUrlInfo &other) const { if (!d) - return other.d == 0; + return other.d == nullptr; if (!other.d) return false; @@ -721,7 +721,7 @@ bool QUrlInfo::operator==(const QUrlInfo &other) const */ bool QUrlInfo::isValid() const { - return d != 0; + return d != nullptr; } QT_END_NAMESPACE diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index e48fbea3b6..cbc4114904 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -564,12 +564,12 @@ QAbstractSocketPrivate::QAbstractSocketPrivate() port(0), localPort(0), peerPort(0), - socketEngine(0), + socketEngine(nullptr), cachedSocketDescriptor(-1), readBufferMaxSize(0), isBuffered(false), hasPendingData(false), - connectTimer(0), + connectTimer(nullptr), hostLookupId(-1), socketType(QAbstractSocket::UnknownSocketType), state(QAbstractSocket::UnconnectedState), @@ -603,7 +603,7 @@ void QAbstractSocketPrivate::resetSocketLayer() socketEngine->close(); socketEngine->disconnect(); delete socketEngine; - socketEngine = 0; + socketEngine = nullptr; cachedSocketDescriptor = -1; } if (connectTimer) diff --git a/src/network/socket/qabstractsocketengine.cpp b/src/network/socket/qabstractsocketengine.cpp index 3fffff6d5a..54c7452c66 100644 --- a/src/network/socket/qabstractsocketengine.cpp +++ b/src/network/socket/qabstractsocketengine.cpp @@ -85,7 +85,7 @@ QAbstractSocketEnginePrivate::QAbstractSocketEnginePrivate() , peerPort(0) , inboundStreamCount(0) , outboundStreamCount(0) - , receiver(0) + , receiver(nullptr) { } @@ -104,7 +104,7 @@ QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket #ifndef QT_NO_NETWORKPROXY // proxy type must have been resolved by now if (proxy.type() == QNetworkProxy::DefaultProxy) - return 0; + return nullptr; #endif QMutexLocker locker(&socketHandlers()->mutex); @@ -116,7 +116,7 @@ QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket #ifndef QT_NO_NETWORKPROXY // only NoProxy can have reached here if (proxy.type() != QNetworkProxy::NoProxy) - return 0; + return nullptr; #endif return new QNativeSocketEngine(parent); diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index c67b273937..76b3053224 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -216,7 +216,7 @@ void QHttpSocketEngine::close() if (d->socket) { d->socket->close(); delete d->socket; - d->socket = 0; + d->socket = nullptr; } } @@ -586,7 +586,7 @@ void QHttpSocketEngine::slotSocketReadNotification() } int statusCode = d->reply->statusCode(); - QAuthenticatorPrivate *priv = 0; + QAuthenticatorPrivate *priv = nullptr; if (statusCode == 200) { d->state = Connected; setLocalAddress(d->socket->localAddress()); @@ -829,8 +829,8 @@ QHttpSocketEnginePrivate::QHttpSocketEnginePrivate() , credentialsSent(false) , pendingResponseData(0) { - socket = 0; - reply = 0; + socket = nullptr; + reply = nullptr; state = QHttpSocketEngine::None; } @@ -843,15 +843,15 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(QAbstractSoc QObject *parent) { if (socketType != QAbstractSocket::TcpSocket) - return 0; + return nullptr; // proxy type must have been resolved by now if (proxy.type() != QNetworkProxy::HttpProxy) - return 0; + return nullptr; // we only accept active sockets if (!qobject_cast<QAbstractSocket *>(parent)) - return 0; + return nullptr; QHttpSocketEngine *engine = new QHttpSocketEngine(parent); engine->setProxy(proxy); @@ -860,7 +860,7 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(QAbstractSoc QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(qintptr, QObject *) { - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index 3e36a7b229..5ca2db70b9 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -417,7 +417,7 @@ QLocalSocket *QLocalServer::nextPendingConnection() { Q_D(QLocalServer); if (d->pendingConnections.isEmpty()) - return 0; + return nullptr; QLocalSocket *nextSocket = d->pendingConnections.dequeue(); #ifndef QT_LOCALSOCKET_TCP if (d->pendingConnections.size() <= d->maxPendingConnections) diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index 9547ec5b88..88367d680d 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -243,7 +243,7 @@ void QLocalServerPrivate::closeServer() if (socketNotifier) { socketNotifier->setEnabled(false); // Otherwise, closed socket is checked before deleter runs socketNotifier->deleteLater(); - socketNotifier = 0; + socketNotifier = nullptr; } if (-1 != listenSocket) diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index af7cdb76d2..d35f838af5 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -372,7 +372,7 @@ QLocalSocket::~QLocalSocket() QLocalSocket::close(); #if !defined(Q_OS_WIN) && !defined(QT_LOCALSOCKET_TCP) Q_D(QLocalSocket); - d->unixSocket.setParent(0); + d->unixSocket.setParent(nullptr); #endif } diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 3a571edc3a..7de9a7d4c7 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -61,8 +61,8 @@ QT_BEGIN_NAMESPACE QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), - delayConnect(0), - connectTimer(0), + delayConnect(nullptr), + connectTimer(nullptr), connectingSocket(-1), state(QLocalSocket::UnconnectedState) { @@ -379,10 +379,10 @@ void QLocalSocketPrivate::cancelDelayedConnect() if (delayConnect) { delayConnect->setEnabled(false); delete delayConnect; - delayConnect = 0; + delayConnect = nullptr; connectTimer->stop(); delete connectTimer; - connectTimer = 0; + connectTimer = nullptr; } } diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index f3ca2afdc8..31628846dc 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -191,9 +191,9 @@ QT_BEGIN_NAMESPACE */ QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() : socketDescriptor(-1), - readNotifier(0), - writeNotifier(0), - exceptNotifier(0) + readNotifier(nullptr), + writeNotifier(nullptr), + exceptNotifier(nullptr) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) QSysInfo::machineHostName(); // this initializes ws2_32.dll @@ -985,15 +985,15 @@ void QNativeSocketEngine::close() d->inboundStreamCount = d->outboundStreamCount = 0; if (d->readNotifier) { qDeleteInEventHandler(d->readNotifier); - d->readNotifier = 0; + d->readNotifier = nullptr; } if (d->writeNotifier) { qDeleteInEventHandler(d->writeNotifier); - d->writeNotifier = 0; + d->writeNotifier = nullptr; } if (d->exceptNotifier) { qDeleteInEventHandler(d->exceptNotifier); - d->exceptNotifier = 0; + d->exceptNotifier = nullptr; } } diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 3ca586e247..e5b9fbbdb2 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -628,7 +628,7 @@ bool QNativeSocketEnginePrivate::nativeListen(int backlog) int QNativeSocketEnginePrivate::nativeAccept() { - int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0); + int acceptedDescriptor = qt_safe_accept(socketDescriptor, nullptr, nullptr); if (acceptedDescriptor == -1) { switch (errno) { case EBADF: @@ -1002,7 +1002,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS struct cmsghdr *cmsgptr; QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wsign-compare") - for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; + for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != nullptr; cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) { QT_WARNING_POP if (cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_PKTINFO @@ -1166,7 +1166,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l #endif if (msg.msg_controllen == 0) - msg.msg_control = 0; + msg.msg_control = nullptr; ssize_t sentBytes = qt_safe_sendmsg(socketDescriptor, &msg, 0); if (sentBytes < 0) { diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 8a030601dc..622d5df131 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -365,13 +365,13 @@ QSocks5BindData *QSocks5BindStore::retrieve(qintptr socketDescriptor) QMutexLocker lock(&mutex); const auto it = store.constFind(socketDescriptor); if (it == store.cend()) - return 0; + return nullptr; QSocks5BindData *bindData = it.value(); store.erase(it); if (bindData) { if (bindData->controlSocket->thread() != QThread::currentThread()) { qWarning("Cannot access socks5 bind data from different thread"); - return 0; + return nullptr; } } else { QSOCKS5_DEBUG << "__ERROR__ binddata == 0"; @@ -503,12 +503,12 @@ QSocks5SocketEnginePrivate::QSocks5SocketEnginePrivate() , writeNotificationEnabled(false) , exceptNotificationEnabled(false) , socketDescriptor(-1) - , data(0) - , connectData(0) + , data(nullptr) + , connectData(nullptr) #ifndef QT_NO_UDPSOCKET - , udpData(0) + , udpData(nullptr) #endif - , bindData(0) + , bindData(nullptr) , readNotificationActivated(false) , writeNotificationActivated(false) , readNotificationPending(false) @@ -1038,11 +1038,11 @@ bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: d->data = d->connectData; d->mode = QSocks5SocketEnginePrivate::ConnectMode; d->data->controlSocket = bindData->controlSocket; - bindData->controlSocket = 0; + bindData->controlSocket = nullptr; d->data->controlSocket->setParent(this); d->socketProtocol = d->data->controlSocket->localAddress().protocol(); d->data->authenticator = bindData->authenticator; - bindData->authenticator = 0; + bindData->authenticator = nullptr; d->localPort = bindData->localPort; d->localAddress = bindData->localAddress; d->peerPort = bindData->peerPort; @@ -1367,7 +1367,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port) QElapsedTimer stopWatch; stopWatch.start(); d->data->controlSocket->connectToHost(d->proxyInfo.hostName(), d->proxyInfo.port()); - if (!d->waitForConnected(msecs, 0) || + if (!d->waitForConnected(msecs, nullptr) || d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) { // waitForConnected sets the error state and closes the socket QSOCKS5_Q_DEBUG << "waitForConnected to proxy server" << d->data->controlSocket->errorString(); @@ -1428,13 +1428,13 @@ int QSocks5SocketEngine::accept() case QSocks5SocketEnginePrivate::BindSuccess: QSOCKS5_Q_DEBUG << "BindSuccess adding" << d->socketDescriptor << "to the bind store"; d->data->controlSocket->disconnect(); - d->data->controlSocket->setParent(0); + d->data->controlSocket->setParent(nullptr); d->bindData->localAddress = d->localAddress; d->bindData->localPort = d->localPort; sd = d->socketDescriptor; socks5BindStore()->add(sd, d->bindData); - d->data = 0; - d->bindData = 0; + d->data = nullptr; + d->bindData = nullptr; d->socketDescriptor = 0; //### do something about this socket layer ... set it closed and an error about why ... // reset state and local port/address @@ -1909,7 +1909,7 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke // proxy type must have been resolved by now if (proxy.type() != QNetworkProxy::Socks5Proxy) { QSOCKS5_DEBUG << "not proxying"; - return 0; + return nullptr; } QScopedPointer<QSocks5SocketEngine> engine(new QSocks5SocketEngine(parent)); engine->setProxy(proxy); @@ -1923,7 +1923,7 @@ QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr so QSOCKS5_DEBUG << "bind store contains" << socketDescriptor; return new QSocks5SocketEngine(parent); } - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 98e58192a2..9916c75e65 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -121,7 +121,7 @@ QTcpServerPrivate::QTcpServerPrivate() : port(0) , socketType(QAbstractSocket::UnknownSocketType) , state(QAbstractSocket::UnconnectedState) - , socketEngine(0) + , socketEngine(nullptr) , serverSocketError(QAbstractSocket::UnknownSocketError) , maxConnections(30) { @@ -389,7 +389,7 @@ void QTcpServer::close() // in out of memory situations, the socketEngine // will be deleted in ~QTcpServer (it's a child-object of this) } - d->socketEngine = 0; + d->socketEngine = nullptr; } d->state = QAbstractSocket::UnconnectedState; @@ -561,7 +561,7 @@ QTcpSocket *QTcpServer::nextPendingConnection() { Q_D(QTcpServer); if (d->pendingConnections.isEmpty()) - return 0; + return nullptr; if (!d->socketEngine) { qWarning("QTcpServer::nextPendingConnection() called while not listening"); diff --git a/src/platformheaders/nativecontexts/qglxnativecontext.h b/src/platformheaders/nativecontexts/qglxnativecontext.h index 2b566d127a..989d68eb9e 100644 --- a/src/platformheaders/nativecontexts/qglxnativecontext.h +++ b/src/platformheaders/nativecontexts/qglxnativecontext.h @@ -56,13 +56,13 @@ typedef int VisualID; struct QGLXNativeContext { QGLXNativeContext() - : m_context(0), - m_display(0), + : m_context(nullptr), + m_display(nullptr), m_window(0), m_visualId(0) { } - QGLXNativeContext(GLXContext ctx, Display *dpy = 0, Window wnd = 0, VisualID vid = 0) + QGLXNativeContext(GLXContext ctx, Display *dpy = nullptr, Window wnd = 0, VisualID vid = 0) : m_context(ctx), m_display(dpy), m_window(wnd), diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index 5ee4773b70..5303d37cee 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -281,11 +281,11 @@ EGLConfig QEglConfigChooser::chooseConfig() } configureAttributes.append(EGL_NONE); - EGLConfig cfg = 0; + EGLConfig cfg = nullptr; 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(), nullptr, 0, &matching) || !matching) continue; // Fetch all of the matching configurations and find the @@ -450,7 +450,7 @@ static struct AttrInfo attrs[] = { {EGL_BIND_TO_TEXTURE_RGBA, "EGL_BIND_TO_TEXTURE_RGBA"}, {EGL_MIN_SWAP_INTERVAL, "EGL_MIN_SWAP_INTERVAL"}, {EGL_MAX_SWAP_INTERVAL, "EGL_MAX_SWAP_INTERVAL"}, - {-1, 0}}; + {-1, nullptr}}; void q_printEglConfig(EGLDisplay display, EGLConfig config) { diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 94def16748..aa87a620d8 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -137,7 +137,7 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig, format); // m_format now has the renderableType() resolved (it cannot be Default anymore) // but does not yet contain version, profile, options. - m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0; + m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : nullptr; QVector<EGLint> contextAttrs; contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); @@ -194,8 +194,8 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont eglBindAPI(m_api); m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, m_shareContext, contextAttrs.constData()); if (m_eglContext == EGL_NO_CONTEXT && m_shareContext != EGL_NO_CONTEXT) { - m_shareContext = 0; - m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, 0, contextAttrs.constData()); + m_shareContext = nullptr; + m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, nullptr, contextAttrs.constData()); } if (m_eglContext == EGL_NO_CONTEXT) { @@ -262,7 +262,7 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon } m_eglContext = context; - m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : 0; + m_shareContext = share ? static_cast<QEGLPlatformContext *>(share)->m_eglContext : nullptr; updateFormatFromGL(); } @@ -326,7 +326,7 @@ void QEGLPlatformContext::updateFormatFromGL() EGLBoolean ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext); if (!ok) { EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT); - tempContext = eglCreateContext(m_eglDisplay, config, 0, m_contextAttrs.constData()); + tempContext = eglCreateContext(m_eglDisplay, config, nullptr, m_contextAttrs.constData()); if (tempContext != EGL_NO_CONTEXT) ok = eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, tempContext); } diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 48b5a74a9e..7af5490963 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -360,7 +360,7 @@ Q_STATIC_ASSERT(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritin static const char *getFcFamilyForStyleHint(const QFont::StyleHint style) { - const char *stylehint = 0; + const char *stylehint = nullptr; switch (style) { case QFont::SansSerif: stylehint = "sans-serif"; @@ -394,7 +394,7 @@ static void populateFromPattern(FcPattern *pattern) { QString familyName; QString familyNameLang; - FcChar8 *value = 0; + FcChar8 *value = nullptr; int weight_value; int slant_value; int spacing_value; @@ -417,7 +417,7 @@ static void populateFromPattern(FcPattern *pattern) slant_value = FC_SLANT_ROMAN; weight_value = FC_WEIGHT_REGULAR; spacing_value = FC_PROPORTIONAL; - file_value = 0; + file_value = nullptr; indexValue = 0; scalable = FcTrue; @@ -431,20 +431,20 @@ static void populateFromPattern(FcPattern *pattern) if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing_value) != FcResultMatch) spacing_value = FC_PROPORTIONAL; if (FcPatternGetString(pattern, FC_FILE, 0, &file_value) != FcResultMatch) - file_value = 0; + file_value = nullptr; if (FcPatternGetInteger(pattern, FC_INDEX, 0, &indexValue) != FcResultMatch) indexValue = 0; if (FcPatternGetBool(pattern, FC_SCALABLE, 0, &scalable) != FcResultMatch) scalable = FcTrue; if (FcPatternGetString(pattern, FC_FOUNDRY, 0, &foundry_value) != FcResultMatch) - foundry_value = 0; + foundry_value = nullptr; if (FcPatternGetString(pattern, FC_STYLE, 0, &style_value) != FcResultMatch) - style_value = 0; + style_value = nullptr; if (FcPatternGetBool(pattern,FC_ANTIALIAS,0,&antialias) != FcResultMatch) antialias = true; QSupportedWritingSystems writingSystems; - FcLangSet *langset = 0; + FcLangSet *langset = nullptr; FcResult res = FcPatternGetLangSet(pattern, FC_LANG, 0, &langset); if (res == FcResultMatch) { bool hasLang = false; @@ -461,7 +461,7 @@ static void populateFromPattern(FcPattern *pattern) if (*capabilityForWritingSystem[j] && requiresOpenType(j)) { if (cap == nullptr) capRes = FcPatternGetString(pattern, FC_CAPABILITY, 0, &cap); - if (capRes == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), capabilityForWritingSystem[j]) == 0) + if (capRes == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), capabilityForWritingSystem[j]) == nullptr) continue; } #endif @@ -546,14 +546,14 @@ void QFontconfigDatabase::populateFontDatabase() #if FC_VERSION >= 20297 FC_CAPABILITY, #endif - (const char *)0 + (const char *)nullptr }; const char **p = properties; while (*p) { FcObjectSetAdd(os, *p); ++p; } - fonts = FcFontList(0, pattern, os); + fonts = FcFontList(nullptr, pattern, os); FcObjectSetDestroy(os); FcPatternDestroy(pattern); } @@ -572,7 +572,7 @@ void QFontconfigDatabase::populateFontDatabase() { "Serif", "serif", false }, { "Sans Serif", "sans-serif", false }, { "Monospace", "monospace", true }, - { 0, 0, false } + { nullptr, nullptr, false } }; const FcDefaultFont *f = defaults; // aliases only make sense for 'common', not for any of the specials @@ -581,9 +581,9 @@ void QFontconfigDatabase::populateFontDatabase() while (f->qtname) { QString familyQtName = QString::fromLatin1(f->qtname); - registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,f->fixed,ws,0); - registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,f->fixed,ws,0); - registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,f->fixed,ws,0); + registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleNormal,QFont::Unstretched,true,true,0,f->fixed,ws,nullptr); + registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleItalic,QFont::Unstretched,true,true,0,f->fixed,ws,nullptr); + registerFont(familyQtName,QString(),QString(),QFont::Normal,QFont::StyleOblique,QFont::Unstretched,true,true,0,f->fixed,ws,nullptr); ++f; } @@ -599,7 +599,7 @@ void QFontconfigDatabase::populateFontDatabase() void QFontconfigDatabase::invalidate() { // Clear app fonts. - FcConfigAppFontClear(0); + FcConfigAppFontClear(nullptr); } QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) @@ -691,7 +691,7 @@ QFontEngine::SubpixelAntialiasingType subpixelTypeFromMatch(FcPattern *match, bo QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) { if (!usrPtr) - return 0; + return nullptr; FontFile *fontfile = static_cast<FontFile *> (usrPtr); QFontEngine::FaceId fid; @@ -706,7 +706,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) if (!engine->init(fid, engine->antialias, engine->defaultFormat) || engine->invalid()) { delete engine; - engine = 0; + engine = nullptr; } return engine; @@ -715,8 +715,8 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, void *usrPtr) QFontEngine *QFontconfigDatabase::fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) { QFontEngineFT *engine = static_cast<QFontEngineFT*>(QFreeTypeFontDatabase::fontEngine(fontData, pixelSize, hintingPreference)); - if (engine == 0) - return 0; + if (engine == nullptr) + return nullptr; setupFontEngine(engine, engine->fontDef); @@ -757,7 +757,7 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont // while a Japanese font should be used for that if LANG=ja) FcPattern *dummy = FcPatternCreate(); FcDefaultSubstitute(dummy); - FcChar8 *lang = 0; + FcChar8 *lang = nullptr; FcResult res = FcPatternGetString(dummy, FC_LANG, 0, &lang); if (res == FcResultMatch) FcPatternAddString(pattern, FC_LANG, lang); @@ -770,11 +770,11 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont FcPatternAddWeak(pattern, FC_FAMILY, value, FcTrue); } - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); FcResult result = FcResultMatch; - FcFontSet *fontSet = FcFontSort(0,pattern,FcFalse,0,&result); + FcFontSet *fontSet = FcFontSort(nullptr,pattern,FcFalse,nullptr,&result); FcPatternDestroy(pattern); if (fontSet) { @@ -782,7 +782,7 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont duplicates.reserve(fontSet->nfont + 1); duplicates.insert(family.toCaseFolded()); for (int i = 0; i < fontSet->nfont; i++) { - FcChar8 *value = 0; + FcChar8 *value = nullptr; if (FcPatternGetString(fontSet->fonts[i], FC_FAMILY, 0, &value) != FcResultMatch) continue; // capitalize(value); @@ -811,7 +811,7 @@ static FcPattern *queryFont(const FcChar8 *file, const QByteArray &data, int id, FT_Library lib = qt_getFreetype(); - FcPattern *pattern = 0; + FcPattern *pattern = nullptr; FT_Face face; if (!FT_New_Memory_Face(lib, (const FT_Byte *)data.constData(), data.size(), id, &face)) { @@ -830,16 +830,16 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData, { QStringList families; - FcFontSet *set = FcConfigGetFonts(0, FcSetApplication); + FcFontSet *set = FcConfigGetFonts(nullptr, FcSetApplication); if (!set) { - FcConfigAppFontAddFile(0, (const FcChar8 *)":/non-existent"); - set = FcConfigGetFonts(0, FcSetApplication); // try again + FcConfigAppFontAddFile(nullptr, (const FcChar8 *)":/non-existent"); + set = FcConfigGetFonts(nullptr, FcSetApplication); // try again if (!set) return families; } int id = 0; - FcBlanks *blanks = FcConfigGetBlanks(0); + FcBlanks *blanks = FcConfigGetBlanks(nullptr); int count = 0; FcPattern *pattern; @@ -849,7 +849,7 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData, if (!pattern) return families; - FcChar8 *fam = 0; + FcChar8 *fam = nullptr; if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) { QString family = QString::fromUtf8(reinterpret_cast<const char *>(fam)); families << family; @@ -877,10 +877,10 @@ QString QFontconfigDatabase::resolveFontFamilyAlias(const QString &family) const const QByteArray cs = family.toUtf8(); FcPatternAddString(pattern, FC_FAMILY, (const FcChar8 *) cs.constData()); } - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); - FcChar8 *familyAfterSubstitution = 0; + FcChar8 *familyAfterSubstitution = nullptr; FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution); resolved = QString::fromUtf8((const char *) familyAfterSubstitution); FcPatternDestroy(pattern); @@ -895,7 +895,7 @@ QFont QFontconfigDatabase::defaultFont() const // or https://bugs.freedesktop.org/show_bug.cgi?id=35482 is fixed FcPattern *dummy = FcPatternCreate(); FcDefaultSubstitute(dummy); - FcChar8 *lang = 0; + FcChar8 *lang = nullptr; FcResult res = FcPatternGetString(dummy, FC_LANG, 0, &lang); FcPattern *pattern = FcPatternCreate(); @@ -904,10 +904,10 @@ QFont QFontconfigDatabase::defaultFont() const // certain FC_LANG based custom rules may happen in FcConfigSubstitute() FcPatternAddString(pattern, FC_LANG, lang); } - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); - FcChar8 *familyAfterSubstitution = 0; + FcChar8 *familyAfterSubstitution = nullptr; FcPatternGetString(pattern, FC_FAMILY, 0, &familyAfterSubstitution); QString resolved = QString::fromUtf8((const char *) familyAfterSubstitution); FcPatternDestroy(pattern); @@ -964,10 +964,10 @@ void QFontconfigDatabase::setupFontEngine(QFontEngineFT *engine, const QFontDef FcResult result; - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); - FcPattern *match = FcFontMatch(0, pattern, &result); + FcPattern *match = FcFontMatch(nullptr, pattern, &result); if (match) { engine->setDefaultHintStyle(defaultHintStyleFromMatch((QFont::HintingPreference)fontDef.hintingPreference, match, useXftConf)); diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp index 2fbcb6216e..cbf0793d75 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp @@ -60,7 +60,7 @@ bool QFontEngineMultiFontConfig::shouldLoadFontEngineForCharacter(int at, uint u { bool charSetHasChar = true; FcPattern *matchPattern = getMatchPatternForFallback(at - 1); - if (matchPattern != 0) { + if (matchPattern != nullptr) { FcCharSet *charSet; FcPatternGetCharSet(matchPattern, FC_CHARSET, 0, &charSet); charSetHasChar = FcCharSetHasChar(charSet, ucs4); @@ -85,7 +85,7 @@ FcPattern * QFontEngineMultiFontConfig::getMatchPatternForFallback(int fallBackI value.u.s = reinterpret_cast<const FcChar8 *>(cs.data()); FcPatternAdd(requestPattern, FC_FAMILY, value, true); FcResult result; - ret = FcFontMatch(0, requestPattern, &result); + ret = FcFontMatch(nullptr, requestPattern, &result); cachedMatchPatterns.insert(fallBackIndex, ret); FcPatternDestroy(requestPattern); return ret; diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 8c6cc8fbc1..3e5939a5e4 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -121,7 +121,7 @@ class QtFreetypeData { public: QtFreetypeData() - : library(0) + : library(nullptr) { } ~QtFreetypeData(); @@ -135,7 +135,7 @@ QtFreetypeData::~QtFreetypeData() iter.value()->cleanup(); faces.clear(); FT_Done_FreeType(library); - library = 0; + library = nullptr; } Q_GLOBAL_STATIC(QThreadStorage<QtFreetypeData *>, theFreetypeData) @@ -215,7 +215,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, const QByteArray &fontData) { if (face_id.filename.isEmpty() && fontData.isEmpty()) - return 0; + return nullptr; QtFreetypeData *freetypeData = qt_getFreetypeData(); @@ -238,7 +238,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, } else if (!QFileInfo(fileName).isNativePath()) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - return 0; + return nullptr; } newFreetype->fontData = file.readAll(); } @@ -247,10 +247,10 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, } if (!newFreetype->fontData.isEmpty()) { if (FT_New_Memory_Face(freetypeData->library, (const FT_Byte *)newFreetype->fontData.constData(), newFreetype->fontData.size(), face_id.index, &face)) { - return 0; + return nullptr; } } else if (FT_New_Face(freetypeData->library, face_id.filename, face_id.index, &face)) { - return 0; + return nullptr; } newFreetype->face = face; @@ -261,8 +261,8 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, newFreetype->matrix.yy = 0x10000; newFreetype->matrix.xy = 0; newFreetype->matrix.yx = 0; - newFreetype->unicode_map = 0; - newFreetype->symbol_map = 0; + newFreetype->unicode_map = nullptr; + newFreetype->symbol_map = nullptr; memset(newFreetype->cmapCache, 0, sizeof(newFreetype->cmapCache)); @@ -307,7 +307,7 @@ void QFreetypeFace::cleanup() { hbFace.reset(); FT_Done_Face(face); - face = 0; + face = nullptr; } void QFreetypeFace::release(const QFontEngine::FaceId &face_id) @@ -324,7 +324,7 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id) if (freetypeData->faces.isEmpty()) { FT_Done_FreeType(freetypeData->library); - freetypeData->library = 0; + freetypeData->library = nullptr; } } @@ -659,7 +659,7 @@ QFontEngineFT *QFontEngineFT::create(const QByteArray &fontData, qreal pixelSize QFontEngineFTRawData *fe = new QFontEngineFTRawData(fontDef); if (!fe->initFromData(fontData)) { delete fe; - return 0; + return nullptr; } fe->updateFamilyNameAndStyle(); @@ -682,7 +682,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd) embolden = false; obliquen = false; antialias = true; - freetype = 0; + freetype = nullptr; default_load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; default_hint_style = ftInitialDefaultHintStyle; subpixelType = Subpixel_None; @@ -729,7 +729,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, face_id = faceId; - symbol = freetype->symbol_map != 0; + symbol = freetype->symbol_map != nullptr; PS_FontInfoRec psrec; // don't assume that type1 fonts are symbol fonts by default if (FT_Get_PS_Font_Info(freetype->face, &psrec) == FT_Err_Ok) { @@ -744,7 +744,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); if (fake_oblique) obliquen = true; - FT_Set_Transform(face, &matrix, 0); + FT_Set_Transform(face, &matrix, nullptr); freetype->matrix = matrix; // fake bold if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) { @@ -953,7 +953,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, format = defaultFormat != Format_None ? defaultFormat : Format_Mono; Q_ASSERT(format != Format_None); - Glyph *g = set ? set->getGlyph(glyph, subPixelPosition) : 0; + Glyph *g = set ? set->getGlyph(glyph, subPixelPosition) : nullptr; if (g && g->format == format && (fetchMetricsOnly || g->data)) return g; @@ -1051,10 +1051,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, // If any of the metrics are too large to fit, don't cache them if (areMetricsTooLarge(info)) - return 0; + return nullptr; g = new Glyph; - g->data = 0; + g->data = nullptr; g->linearAdvance = info.linearAdvance; g->width = info.width; g->height = info.height; @@ -1176,12 +1176,12 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, convertRGBToARGB_V(slot->bitmap.buffer, (uint *)glyph_buffer.data(), info.width, info.height, slot->bitmap.pitch, subpixelType != Subpixel_VRGB); } else { qWarning("QFontEngine: Glyph rendered in unknown pixel_mode=%d", slot->bitmap.pixel_mode); - return 0; + return nullptr; } if (!g) { g = new Glyph; - g->data = 0; + g->data = nullptr; } g->linearAdvance = info.linearAdvance; @@ -1357,7 +1357,7 @@ static inline FT_Matrix QTransformToFTMatrix(const QTransform &matrix) QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix) { if (matrix.type() > QTransform::TxShear || !cacheEnabled) - return 0; + return nullptr; // FT_Set_Transform only supports scalable fonts if (!FT_IS_SCALABLE(freetype->face)) @@ -1365,7 +1365,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix) FT_Matrix m = QTransformToFTMatrix(matrix); - QGlyphSet *gs = 0; + QGlyphSet *gs = nullptr; for (int i = 0; i < transformedGlyphSets.count(); ++i) { const QGlyphSet &g = transformedGlyphSets.at(i); @@ -1393,7 +1393,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix) gs->transformationMatrix = m; gs->outline_drawing = fontDef.pixelSize * fontDef.pixelSize * qAbs(matrix.determinant()) > QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE; } - Q_ASSERT(gs != 0); + Q_ASSERT(gs != nullptr); return gs; } @@ -1401,7 +1401,7 @@ QFontEngineFT::QGlyphSet *QFontEngineFT::loadGlyphSet(const QTransform &matrix) void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) { FT_Face face = lockFace(Unscaled); - FT_Set_Transform(face, 0, 0); + FT_Set_Transform(face, nullptr, nullptr); FT_Load_Glyph(face, glyph, FT_LOAD_NO_BITMAP); int left = face->glyph->metrics.horiBearingX; @@ -1424,7 +1424,7 @@ void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_me else QFreetypeFace::addGlyphToPath(face, face->glyph, p, path, face->units_per_EM << 6, face->units_per_EM << 6); - FT_Set_Transform(face, &freetype->matrix, 0); + FT_Set_Transform(face, &freetype->matrix, nullptr); unlockFace(); } @@ -1622,10 +1622,10 @@ glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m, con void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const { - FT_Face face = 0; + FT_Face face = nullptr; bool design = shouldUseDesignMetrics(flags); for (int i = 0; i < glyphs->numGlyphs; i++) { - Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : 0; + Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : nullptr; // Since we are passing Format_None to loadGlyph, use same default format logic as loadGlyph GlyphFormat acceptableFormat = (defaultFormat != Format_None) ? defaultFormat : Format_Mono; if (g && g->format == acceptableFormat) { @@ -1633,7 +1633,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag } else { if (!face) face = lockFace(); - g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyphs->glyphs[i], 0, Format_None, true); + g = loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyphs->glyphs[i], 0, Format_None, true); if (g) glyphs->advances[i] = design ? QFixed::fromFixed(g->linearAdvance) : QFixed(g->advance); else @@ -1657,7 +1657,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) { - FT_Face face = 0; + FT_Face face = nullptr; glyph_metrics_t overall; // initialize with line height, we get the same behaviour on all platforms @@ -1672,11 +1672,11 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) QFixed ymax = 0; QFixed xmax = 0; for (int i = 0; i < glyphs.numGlyphs; i++) { - Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs.glyphs[i]) : 0; + Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs.glyphs[i]) : nullptr; if (!g) { if (!face) face = lockFace(); - g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyphs.glyphs[i], 0, Format_None, true); + g = loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyphs.glyphs[i], 0, Format_None, true); } if (g) { QFixed x = overall.xoff + glyphs.offsets[i].x + g->x; @@ -1716,12 +1716,12 @@ glyph_metrics_t QFontEngineFT::boundingBox(const QGlyphLayout &glyphs) glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph) { - FT_Face face = 0; + FT_Face face = nullptr; glyph_metrics_t overall; - Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyph) : 0; + Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyph) : nullptr; if (!g) { face = lockFace(); - g = loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyph, 0, Format_None, true); + g = loadGlyph(cacheEnabled ? &defaultGlyphSet : nullptr, glyph, 0, Format_None, true); } if (g) { overall.x = g->x; @@ -1854,10 +1854,10 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, bool disableOutlineDrawing) { QGlyphSet *glyphSet = loadGlyphSet(t); - if (glyphSet != 0 && glyphSet->outline_drawing && !disableOutlineDrawing && !fetchBoundingBox) - return 0; + if (glyphSet != nullptr && glyphSet->outline_drawing && !disableOutlineDrawing && !fetchBoundingBox) + return nullptr; - Glyph *glyph = glyphSet != 0 ? glyphSet->getGlyph(g, subPixelPosition) : 0; + Glyph *glyph = glyphSet != nullptr ? glyphSet->getGlyph(g, subPixelPosition) : nullptr; if (!glyph || glyph->format != format || (!fetchBoundingBox && !glyph->data)) { QScopedValueRollback<HintStyle> saved_default_hint_style(default_hint_style); if (t.type() >= QTransform::TxScale && !is2dRotation(t)) @@ -1865,7 +1865,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, lockFace(); FT_Matrix m = this->matrix; - FT_Matrix ftMatrix = glyphSet != 0 ? glyphSet->transformationMatrix : QTransformToFTMatrix(t); + FT_Matrix ftMatrix = glyphSet != nullptr ? glyphSet->transformationMatrix : QTransformToFTMatrix(t); FT_Matrix_Multiply(&ftMatrix, &m); freetype->matrix = m; glyph = loadGlyph(glyphSet, g, subPixelPosition, format, false, disableOutlineDrawing); @@ -1978,7 +1978,7 @@ FT_Face QFontEngineFT::lockFace(Scaling scale) const freetype->matrix.xy != matrix.xy || freetype->matrix.yx != matrix.yx) { freetype->matrix = matrix; - FT_Set_Transform(face, &freetype->matrix, 0); + FT_Set_Transform(face, &freetype->matrix, nullptr); } return face; @@ -2017,7 +2017,7 @@ void QFontEngineFT::QGlyphSet::clear() for (int i = 0; i < 256; ++i) { if (fast_glyph_data[i]) { delete fast_glyph_data[i]; - fast_glyph_data[i] = 0; + fast_glyph_data[i] = nullptr; } } fast_glyph_count = 0; @@ -2031,7 +2031,7 @@ void QFontEngineFT::QGlyphSet::removeGlyphFromCache(glyph_t index, QFixed subPix if (useFastGlyphData(index, subPixelPosition)) { if (fast_glyph_data[index]) { delete fast_glyph_data[index]; - fast_glyph_data[index] = 0; + fast_glyph_data[index] = nullptr; if (fast_glyph_count > 0) --fast_glyph_count; } @@ -2056,7 +2056,7 @@ int QFontEngineFT::getPointInOutline(glyph_t glyph, int flags, quint32 point, QF lockFace(); bool hsubpixel = true; int vfactor = 1; - int load_flags = loadFlags(0, Format_A8, flags, hsubpixel, vfactor); + int load_flags = loadFlags(nullptr, Format_A8, flags, hsubpixel, vfactor); int result = freetype->getPointInOutline(glyph, load_flags, point, xpos, ypos, nPoints); unlockFace(); return result; @@ -2091,7 +2091,7 @@ QFontEngine *QFontEngineFT::cloneWithSize(qreal pixelSize) const QFontEngineFT *fe = new QFontEngineFT(fontDef); if (!fe->initFromFontEngine(this)) { delete fe; - return 0; + return nullptr; } else { return fe; } diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 81bccb1c25..5387214e8c 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -193,7 +193,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format { QXcbSoftwareOpenGLEnforcer softwareOpenGLEnforcer; - GLXFBConfig config = 0; + GLXFBConfig config = nullptr; do { const QVector<int> spec = qglx_buildSpec(format, drawableBit, flags); @@ -273,7 +273,7 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *f { Q_ASSERT(format); - XVisualInfo *visualInfo = 0; + XVisualInfo *visualInfo = nullptr; GLXFBConfig config = qglx_findConfig(display, screen, *format, false, drawableBit, flags); if (config) diff --git a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h index 36d7587457..fde5fd7dbb 100644 --- a/src/platformsupport/input/integrityhid/qintegrityhidmanager.h +++ b/src/platformsupport/input/integrityhid/qintegrityhidmanager.h @@ -52,7 +52,7 @@ class QIntegrityHIDManager : public QThread { Q_OBJECT public: - QIntegrityHIDManager(const QString &key, const QString &specification, QObject *parent = 0); + QIntegrityHIDManager(const QString &key, const QString &specification, QObject *parent = nullptr); ~QIntegrityHIDManager(); void run(void); diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index c6b678ab20..8eba9ccc42 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -65,7 +65,7 @@ static QBearerEngineImpl *getEngineFromId(const QString &id) } } - return 0; + return nullptr; } class QNetworkSessionManagerPrivate : public QObject @@ -73,7 +73,7 @@ class QNetworkSessionManagerPrivate : public QObject Q_OBJECT public: - QNetworkSessionManagerPrivate(QObject *parent = 0) : QObject(parent) {} + QNetworkSessionManagerPrivate(QObject *parent = nullptr) : QObject(parent) {} ~QNetworkSessionManagerPrivate() {} inline void forceSessionClose(const QNetworkConfiguration &config) @@ -119,7 +119,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() // Defer setting serviceConfig and activeConfig until open(). Q_FALLTHROUGH(); default: - engine = 0; + engine = nullptr; } networkConfigurationsChanged(); diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index a6029b691c..c92cc3ea61 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -147,8 +147,8 @@ private: */ QGIFFormat::QGIFFormat() { - globalcmap = 0; - localcmap = 0; + globalcmap = nullptr; + localcmap = nullptr; lncols = 0; gncols = 0; disposal = NoDisposal; @@ -160,9 +160,9 @@ QGIFFormat::QGIFFormat() lcmap = false; newFrame = false; partialNewFrame = false; - table[0] = 0; - table[1] = 0; - stack = 0; + table[0] = nullptr; + table[1] = nullptr; + stack = nullptr; } /*! @@ -550,7 +550,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, } oldcode=incode; const int h = image->height(); - QRgb *line = 0; + QRgb *line = nullptr; if (!out_of_bounds && h > y) line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y); while (sp>stack) { diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index dd01138722..c31e2db3c5 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -729,7 +729,7 @@ static bool write_jpeg_image(const QImage &image, // do_write_jpeg_image (by making them non-local). struct jpeg_compress_struct cinfo; JSAMPROW row_pointer[1]; - row_pointer[0] = 0; + row_pointer[0] = nullptr; const bool success = do_write_jpeg_image(cinfo, row_pointer, image, device, @@ -751,7 +751,7 @@ public: }; QJpegHandlerPrivate(QJpegHandler *qq) - : quality(75), transformation(QImageIOHandler::TransformationNone), iod_src(0), + : quality(75), transformation(QImageIOHandler::TransformationNone), iod_src(nullptr), rgb888ToRgb32ConverterPtr(qt_convert_rgb888_to_rgb32), state(Ready), optimize(false), progressive(false), q(qq) {} @@ -761,7 +761,7 @@ public: { jpeg_destroy_decompress(&info); delete iod_src; - iod_src = 0; + iod_src = nullptr; } } @@ -954,7 +954,7 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device) QByteArray exifData; - for (jpeg_saved_marker_ptr marker = info.marker_list; marker != NULL; marker = marker->next) { + for (jpeg_saved_marker_ptr marker = info.marker_list; marker != nullptr; marker = marker->next) { if (marker->marker == JPEG_COM) { QString key, value; QString s = QString::fromUtf8((const char *)marker->data, marker->data_length); diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp index c10b6facbb..48fafbda8d 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp @@ -78,7 +78,7 @@ EGLSurface QEglFSContext::createTemporaryOffscreenSurface() } } EGLConfig config = q_configFromGLFormat(eglDisplay(), format()); - return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0); + return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, nullptr); } void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface) diff --git a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp index 22319fcc66..98e05195ee 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp @@ -62,7 +62,7 @@ QEglFSCursor::QEglFSCursor(QPlatformScreen *screen) : m_visible(true), m_screen(static_cast<QEglFSScreen *>(screen)), m_activeScreen(nullptr), - m_deviceListener(0), + m_deviceListener(nullptr), m_updateRequested(false) { QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index d3f51c0d0e..d9a3545a95 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -109,10 +109,10 @@ QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() : m_display(EGL_NO_DISPLAY), - m_inputContext(0), + m_inputContext(nullptr), m_fontDb(new QGenericUnixFontDatabase), m_services(new QGenericUnixServices), - m_kbdMgr(0), + m_kbdMgr(nullptr), m_disableInputHandlers(false) { m_disableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT"); @@ -223,7 +223,7 @@ QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLCo EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat); ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant()); } else { - ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle); + ctx = new QEglFSContext(adjustedFormat, share, dpy, nullptr, nativeHandle); } nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), dpy)); @@ -307,7 +307,7 @@ static int resourceType(const QByteArray &key) void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case EglDisplay: @@ -329,7 +329,7 @@ void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *screen) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case XlibDisplay: @@ -347,7 +347,7 @@ void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QSc void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case EglDisplay: @@ -374,7 +374,7 @@ void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWi #ifndef QT_NO_OPENGL void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case EglContext: @@ -402,7 +402,7 @@ static void *eglContextForContext(QOpenGLContext *context) QEglFSContext *handle = static_cast<QEglFSContext *>(context->handle()); if (!handle) - return 0; + return nullptr; return handle->eglContext(); } @@ -416,7 +416,7 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::na #else Q_UNUSED(resource); #endif - return 0; + return nullptr; } QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function) const diff --git a/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp index 864271cd3a..c96e329816 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp @@ -67,7 +67,7 @@ QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceF return; } EGLConfig config = q_configFromGLFormat(m_display, m_format); - m_surface = eglCreateWindowSurface(m_display, config, m_window, 0); + m_surface = eglCreateWindowSurface(m_display, config, m_window, nullptr); if (m_surface != EGL_NO_SURFACE) m_format = q_glFormatFromConfig(m_display, config); } diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp index 11b68c0589..8a8e8cd563 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE QEglFSScreen::QEglFSScreen(EGLDisplay dpy) : m_dpy(dpy), m_surface(EGL_NO_SURFACE), - m_cursor(0) + m_cursor(nullptr) { m_cursor = qt_egl_device_integration()->createCursor(this); } @@ -164,7 +164,7 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) return; } - QWindow *enter = 0, *leave = 0; + QWindow *enter = nullptr, *leave = nullptr; for (int i = windows.count() - 1; i >= 0; --i) { QWindow *window = windows[i]->sourceWindow(); const QRect geom = window->geometry(); diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index 3457be116a..f7e116eb88 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -61,8 +61,8 @@ QT_BEGIN_NAMESPACE QEglFSWindow::QEglFSWindow(QWindow *w) : QPlatformWindow(w), #ifndef QT_NO_OPENGL - m_backingStore(0), - m_rasterCompositingContext(0), + m_backingStore(nullptr), + m_rasterCompositingContext(nullptr), #endif m_winId(0), m_surface(EGL_NO_SURFACE), @@ -207,7 +207,7 @@ void QEglFSWindow::resetSurface() m_format = q_glFormatFromConfig(display, m_config, platformFormat); const QSize surfaceSize = screen()->rawGeometry().size(); m_window = qt_egl_device_integration()->createNativeWindow(this, surfaceSize, m_format); - m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL); + m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr); } void QEglFSWindow::setVisible(bool visible) @@ -337,7 +337,7 @@ const QPlatformTextureList *QEglFSWindow::textures() const if (m_backingStore) return m_backingStore->textures(); - return 0; + return nullptr; } void QEglFSWindow::endCompositing() diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp index 1125bcb390..dc98cdce4b 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp @@ -69,7 +69,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen) : m_screen(screen) , m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below , m_bo(nullptr) - , m_cursorImage(0, 0, 0, 0, 0, 0) + , m_cursorImage(nullptr, nullptr, 0, 0, 0, 0) , m_state(CursorPendingVisible) , m_deviceListener(nullptr) { @@ -102,7 +102,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen) #ifndef QT_NO_CURSOR QCursor cursor(Qt::ArrowCursor); - changeCursor(&cursor, 0); + changeCursor(&cursor, nullptr); #endif setPos(QPoint(0, 0)); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 07b2de7c58..ce5a721906 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -75,7 +75,7 @@ void EventReader::run() if (client->format == 32 && client->type == atoms[Atoms::WM_PROTOCOLS] && client->data.data32[0] == atoms[Atoms::WM_DELETE_WINDOW]) { - QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : 0; + QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : nullptr; if (window) QWindowSystemInterface::handleCloseEvent(window); } @@ -106,7 +106,7 @@ void QEglFSX11Integration::sendConnectionEvent(xcb_atom_t a) void QEglFSX11Integration::platformInit() { - m_display = XOpenDisplay(0); + m_display = XOpenDisplay(nullptr); if (Q_UNLIKELY(!m_display)) qFatal("Could not open display"); @@ -121,7 +121,7 @@ void QEglFSX11Integration::platformInit() xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_connectionEventListener, it.data->root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY, - it.data->root_visual, 0, 0); + it.data->root_visual, 0, nullptr); m_eventReader = new EventReader(this); m_eventReader->start(); @@ -135,11 +135,11 @@ void QEglFSX11Integration::platformDestroy() m_eventReader->wait(); delete m_eventReader; - m_eventReader = 0; + m_eventReader = nullptr; XCloseDisplay(DISPLAY); - m_display = 0; - m_connection = 0; + m_display = nullptr; + m_connection = nullptr; } EGLNativeDisplayType QEglFSX11Integration::platformDisplay() const @@ -175,7 +175,7 @@ EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *pl xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_window, it.data->root, 0, 0, size.width(), size.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, it.data->root_visual, - 0, 0); + 0, nullptr); xcb_intern_atom_cookie_t cookies[Atoms::N_ATOMS]; static const char *atomNames[Atoms::N_ATOMS] = { @@ -189,7 +189,7 @@ EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *pl for (int i = 0; i < Atoms::N_ATOMS; ++i) { cookies[i] = xcb_intern_atom(m_connection, false, strlen(atomNames[i]), atomNames[i]); - xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(m_connection, cookies[i], 0); + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(m_connection, cookies[i], nullptr); m_atoms[i] = reply->atom; free(reply); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h index bf431caaac..ebcc19b682 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h @@ -67,7 +67,7 @@ class EventReader; class QEglFSX11Integration : public QEglFSDeviceIntegration { public: - QEglFSX11Integration() : m_connection(0), m_window(0), m_eventReader(0) {} + QEglFSX11Integration() : m_connection(nullptr), m_window(0), m_eventReader(nullptr) {} void platformInit() override; void platformDestroy() override; diff --git a/src/plugins/platforms/eglfs/qeglfsmain.cpp b/src/plugins/platforms/eglfs/qeglfsmain.cpp index 4f77b7cd17..b41bbec27d 100644 --- a/src/plugins/platforms/eglfs/qeglfsmain.cpp +++ b/src/plugins/platforms/eglfs/qeglfsmain.cpp @@ -56,7 +56,7 @@ QPlatformIntegration* QEglFSIntegrationPlugin::create(const QString& system, con if (!system.compare(QLatin1String("eglfs"), Qt::CaseInsensitive)) return new QEglFSIntegration; - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/offscreen/main.cpp b/src/plugins/platforms/offscreen/main.cpp index 207db60f3a..f364d9f004 100644 --- a/src/plugins/platforms/offscreen/main.cpp +++ b/src/plugins/platforms/offscreen/main.cpp @@ -57,7 +57,7 @@ QPlatformIntegration *QOffscreenIntegrationPlugin::create(const QString& system, if (!system.compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) return QOffscreenIntegration::createOffscreenIntegration(); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp index eae25012c1..de75a3e012 100644 --- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp +++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -QPlatformWindow *QOffscreenScreen::windowContainingCursor = 0; +QPlatformWindow *QOffscreenScreen::windowContainingCursor = nullptr; class QOffscreenCursor : public QPlatformCursor { @@ -60,7 +60,7 @@ public: { m_pos = pos; const QWindowList wl = QGuiApplication::topLevelWindows(); - QWindow *containing = 0; + QWindow *containing = nullptr; for (QWindow *w : wl) { if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(pos)) { containing = w; @@ -72,7 +72,7 @@ public: if (containing) local -= containing->position(); - QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() : 0; + QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() : nullptr; if (containing != previous) QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos); @@ -80,7 +80,7 @@ public: QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton, QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt); - QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0; + QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : nullptr; } #ifndef QT_NO_CURSOR void changeCursor(QCursor *windowCursor, QWindow *window) override @@ -106,7 +106,7 @@ QPixmap QOffscreenScreen::grabWindow(WId id, int x, int y, int width, int height QOffscreenWindow *window = QOffscreenWindow::windowForWinId(id); if (!window || window->window()->type() == Qt::Desktop) { const QWindowList wl = QGuiApplication::topLevelWindows(); - QWindow *containing = 0; + QWindow *containing = nullptr; for (QWindow *w : wl) { if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(rect)) { containing = w; diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index 869e9228cd..3a4494fc2e 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -79,7 +79,7 @@ template <typename BaseEventDispatcher> class QOffscreenEventDispatcher : public BaseEventDispatcher { public: - explicit QOffscreenEventDispatcher(QObject *parent = 0) + explicit QOffscreenEventDispatcher(QObject *parent = nullptr) : BaseEventDispatcher(parent) { } diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index 92fc8aa57a..84991d751f 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -206,7 +206,7 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL if (d->format.renderableType() != QSurfaceFormat::OpenGL) return; - d->shareContext = 0; + d->shareContext = nullptr; if (context->shareHandle()) d->shareContext = static_cast<QOffscreenX11GLXContext *>(context->shareHandle())->d->context; @@ -216,9 +216,9 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL if (config) { d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, d->shareContext, true); if (!d->context && d->shareContext) { - d->shareContext = 0; + d->shareContext = nullptr; // re-try without a shared glx context - d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, 0, true); + d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, nullptr, true); } // Get the basic surface format details @@ -234,8 +234,8 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL d->context = glXCreateContext(x11->display(), visualInfo, d->shareContext, true); if (!d->context && d->shareContext) { // re-try without a shared glx context - d->shareContext = 0; - d->context = glXCreateContext(x11->display(), visualInfo, 0, true); + d->shareContext = nullptr; + d->context = glXCreateContext(x11->display(), visualInfo, nullptr, true); } d->window = createDummyWindow(x11, visualInfo); @@ -269,7 +269,7 @@ bool QOffscreenX11GLXContext::makeCurrent(QPlatformSurface *surface) void QOffscreenX11GLXContext::doneCurrent() { - glXMakeCurrent(d->x11->display(), 0, 0); + glXMakeCurrent(d->x11->display(), 0, nullptr); } void QOffscreenX11GLXContext::swapBuffers(QPlatformSurface *) diff --git a/src/plugins/platforms/offscreen/qoffscreenwindow.cpp b/src/plugins/platforms/offscreen/qoffscreenwindow.cpp index 832e94034d..53880c877e 100644 --- a/src/plugins/platforms/offscreen/qoffscreenwindow.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenwindow.cpp @@ -69,7 +69,7 @@ QOffscreenWindow::QOffscreenWindow(QWindow *window) QOffscreenWindow::~QOffscreenWindow() { if (QOffscreenScreen::windowContainingCursor == this) - QOffscreenScreen::windowContainingCursor = 0; + QOffscreenScreen::windowContainingCursor = nullptr; m_windowForWinIdHash.remove(m_winId); } diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index 3ec0f0b78d..ac7e18e03f 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -56,7 +56,7 @@ QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive)) return new QVncIntegration(paramList); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index 32114c6443..8390fa19cd 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -537,7 +537,7 @@ QVncClientCursor::QVncClientCursor() { QWindow *w = QGuiApplication::focusWindow(); QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor); - changeCursor(&c, 0); + changeCursor(&c, nullptr); } QVncClientCursor::~QVncClientCursor() @@ -595,7 +595,7 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window) cursor = widgetCursor->pixmap().toImage(); } else { // system cursor - QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0); + QPlatformCursorImage platformImage(nullptr, nullptr, 0, 0, 0, 0); platformImage.set(shape); cursor = *platformImage.image(); hotspot = platformImage.hotspot(); diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp index 2450f7dad5..c5caddc58d 100644 --- a/src/plugins/platforms/vnc/qvncclient.cpp +++ b/src/plugins/platforms/vnc/qvncclient.cpp @@ -617,7 +617,7 @@ void QVncClient::keyEvent() m_keymod = ev.down ? m_keymod | Qt::AltModifier : m_keymod & ~Qt::AltModifier; if (ev.unicode || ev.keycode) - QWindowSystemInterface::handleKeyEvent(0, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode)); + QWindowSystemInterface::handleKeyEvent(nullptr, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode)); m_handleMsg = false; } } diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp index 2eca18fb4d..5dc3919ff5 100644 --- a/src/plugins/platforms/vnc/qvncscreen.cpp +++ b/src/plugins/platforms/vnc/qvncscreen.cpp @@ -101,7 +101,7 @@ bool QVncScreen::initialize() default: qWarning("QVNCScreen::initDevice: No support for screen depth %d", depth()); - dirty = 0; + dirty = nullptr; return false; } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h index c3ce8d8745..fda53f17a1 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h @@ -52,7 +52,7 @@ class QXcbEglContext : public QEGLPlatformContext public: QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share, EGLDisplay display, const QVariant &nativeHandle) - : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle) + : QEGLPlatformContext(glFormat, share, display, nullptr, nativeHandle) { } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp index 65beac227c..30e3381993 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp @@ -93,7 +93,7 @@ void QXcbEglWindow::create() { QXcbWindow::create(); - m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, 0); + m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, nullptr); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 2b77062b16..57805d5571 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -223,13 +223,13 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat const QVariant &nativeHandle) : QPlatformOpenGLContext() , m_display(static_cast<Display *>(screen->connection()->xlib_display())) - , m_config(0) - , m_context(0) - , m_shareContext(0) + , m_config(nullptr) + , m_context(nullptr) + , m_shareContext(nullptr) , m_format(format) , m_isPBufferCurrent(false) , m_ownsContext(nativeHandle.isNull()) - , m_getGraphicsResetStatus(0) + , m_getGraphicsResetStatus(nullptr) , m_lost(false) { if (nativeHandle.isNull()) @@ -254,14 +254,14 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) GLXFBConfig config = qglx_findConfig(m_display, screen->screenNumber(), m_format); m_config = config; - XVisualInfo *visualInfo = 0; + XVisualInfo *visualInfo = nullptr; Window window = 0; // Temporary window used to query OpenGL context if (config) { const QByteArrayList glxExt = QByteArray(glXQueryExtensionsString(m_display, screen->screenNumber())).split(' '); // Resolve entry point for glXCreateContextAttribsARB - glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0; + glXCreateContextAttribsARBProc glXCreateContextAttribsARB = nullptr; if (glxExt.contains("GLX_ARB_create_context")) glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); @@ -271,7 +271,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) // Use glXCreateContextAttribsARB if available // Also, GL ES context creation requires GLX_EXT_create_context_es2_profile - if (glXCreateContextAttribsARB != 0 + if (glXCreateContextAttribsARB != nullptr && (m_format.renderableType() != QSurfaceFormat::OpenGLES || (supportsProfiles && glxExt.contains("GLX_EXT_create_context_es2_profile")))) { // Try to create an OpenGL context for each known OpenGL version in descending // order from the requested version. @@ -358,9 +358,9 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data()); if (!m_context && m_shareContext) { // re-try without a shared glx context - m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data()); + m_context = glXCreateContextAttribsARB(m_display, config, nullptr, true, contextAttributes.data()); if (m_context) - m_shareContext = 0; + m_shareContext = nullptr; } } } @@ -375,9 +375,9 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, m_shareContext, true); if (!m_context && m_shareContext) { // re-try without a shared glx context - m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, 0, true); + m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, nullptr, true); if (m_context) - m_shareContext = 0; + m_shareContext = nullptr; } } @@ -399,7 +399,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_context = glXCreateContext(m_display, visualInfo, m_shareContext, true); if (!m_context && m_shareContext) { // re-try without a shared glx context - m_shareContext = 0; + m_shareContext = nullptr; m_context = glXCreateContext(m_display, visualInfo, nullptr, true); } @@ -444,7 +444,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const // Legacy contexts created using glXCreateContext are created using a visual // and the FBConfig cannot be queried. The only way to adapt these contexts // is to figure out the visual id. - XVisualInfo *vinfo = 0; + XVisualInfo *vinfo = nullptr; // If the VisualID is provided use it. VisualID vid = handle.visualId(); if (!vid) { @@ -464,13 +464,13 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const vinfo = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, &v, &n); if (n < 1) { XFree(vinfo); - vinfo = 0; + vinfo = nullptr; } } // For contexts created with an FBConfig using the modern functions providing the // visual or window is not mandatory. Just query the config from the context. - GLXFBConfig config = 0; + GLXFBConfig config = nullptr; if (!vinfo) { int configId = 0; if (glXQueryContext(dpy, context, GLX_FBCONFIG_ID, &configId) != Success) { @@ -595,8 +595,8 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface) if (interval >= 0 && interval != window->swapInterval() && screen) { typedef void (*qt_glXSwapIntervalEXT)(Display *, GLXDrawable, int); typedef void (*qt_glXSwapIntervalMESA)(unsigned int); - static qt_glXSwapIntervalEXT glXSwapIntervalEXT = 0; - static qt_glXSwapIntervalMESA glXSwapIntervalMESA = 0; + static qt_glXSwapIntervalEXT glXSwapIntervalEXT = nullptr; + static qt_glXSwapIntervalMESA glXSwapIntervalMESA = nullptr; static bool resolved = false; if (!resolved) { resolved = true; @@ -621,9 +621,9 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface) void QGLXContext::doneCurrent() { if (m_isPBufferCurrent) - glXMakeContextCurrent(m_display, 0, 0, 0); + glXMakeContextCurrent(m_display, 0, 0, nullptr); else - glXMakeCurrent(m_display, 0, 0); + glXMakeCurrent(m_display, 0, nullptr); m_isPBufferCurrent = false; } @@ -658,12 +658,12 @@ QSurfaceFormat QGLXContext::format() const bool QGLXContext::isSharing() const { - return m_shareContext != 0; + return m_shareContext != nullptr; } bool QGLXContext::isValid() const { - return m_context != 0 && !m_lost; + return m_context != nullptr && !m_lost; } bool QGLXContext::m_queriedDummyContext = false; @@ -675,7 +675,7 @@ bool QGLXContext::m_supportsThreading = true; // binary search. static const char *qglx_threadedgl_blacklist_renderer[] = { "Chromium", // QTBUG-32225 (initialization fails) - 0 + nullptr }; static const char *qglx_threadedgl_blacklist_vendor[] = { @@ -695,7 +695,7 @@ void QGLXContext::queryDummyContext() return; QOpenGLContext *oldContext = QOpenGLContext::currentContext(); - QSurface *oldSurface = 0; + QSurface *oldSurface = nullptr; if (oldContext) oldSurface = oldContext->surface(); @@ -732,7 +732,7 @@ void QGLXContext::queryDummyContext() if (const char *renderer = (const char *) glGetString(GL_RENDERER)) { for (int i = 0; qglx_threadedgl_blacklist_renderer[i]; ++i) { - if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != 0) { + if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != nullptr) { qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " "blacklisted renderer \"" << qglx_threadedgl_blacklist_renderer[i] @@ -744,7 +744,7 @@ void QGLXContext::queryDummyContext() } if (const char *vendor = (const char *) glGetString(GL_VENDOR)) { for (int i = 0; qglx_threadedgl_blacklist_vendor[i]; ++i) { - if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != 0) { + if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != nullptr) { qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " "blacklisted vendor \"" << qglx_threadedgl_blacklist_vendor[i] @@ -759,7 +759,7 @@ void QGLXContext::queryDummyContext() // Blacklist Mesa drivers due to QTCREATORBUG-10875 (crash in creator), // QTBUG-34492 (flickering in fullscreen) and QTBUG-38221 const char *mesaVersionStr = nullptr; - if (strstr(glxvendor, "Mesa Project") != 0) { + if (strstr(glxvendor, "Mesa Project") != nullptr) { mesaVersionStr = (const char *) glGetString(GL_VERSION); m_supportsThreading = false; } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp index 34895caaa2..6814dbd844 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp @@ -133,7 +133,7 @@ bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint respons Display *xdisplay = static_cast<Display *>(m_connection->xlib_display()); XLockDisplay(xdisplay); bool locked = true; - Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, 0); + Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, nullptr); if (proc) { XESetWireToEvent(xdisplay, responseType, proc); XEvent dummy; @@ -212,7 +212,7 @@ QPlatformOffscreenSurface *QXcbGlxIntegration::createPlatformOffscreenSurface(QO if (glxPbufferUsable) return new QGLXPbuffer(surface); else - return 0; // trigger fallback to hidden QWindow + return nullptr; // trigger fallback to hidden QWindow } diff --git a/src/plugins/platforms/xcb/qxcbatom.cpp b/src/plugins/platforms/xcb/qxcbatom.cpp index ecb73cb90b..79b5ba06e6 100644 --- a/src/plugins/platforms/xcb/qxcbatom.cpp +++ b/src/plugins/platforms/xcb/qxcbatom.cpp @@ -265,7 +265,7 @@ void QXcbAtom::initializeAllAtoms(xcb_connection_t *connection) { cookies[i] = xcb_intern_atom(connection, false, strlen(names[i]), names[i]); for (i = 0; i < QXcbAtom::NAtoms; ++i) { - xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], 0); + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], nullptr); m_allAtoms[i] = reply->atom; free(reply); } diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 741317d766..8f55bc2e96 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -229,7 +229,7 @@ void QXcbBackingStoreImage::resize(const QSize &size) m_xcb_format->bits_per_pixel, 0, byteOrder, XCB_IMAGE_ORDER_MSB_FIRST, - 0, ~0, 0); + nullptr, ~0, nullptr); const size_t segmentSize = imageDataSize(m_xcb_image); @@ -412,13 +412,13 @@ bool QXcbBackingStoreImage::createSystemVShmSegment(xcb_connection_t *c, size_t return false; } - void *addr = shmat(id, 0, 0); + void *addr = shmat(id, nullptr, 0); if (addr == (void *)-1) { qCWarning(lcQpaXcb, "shmat() failed (%d: %s) for id %d", errno, strerror(errno), id); return false; } - if (shmctl(id, IPC_RMID, 0) == -1) + if (shmctl(id, IPC_RMID, nullptr) == -1) qCWarning(lcQpaXcb, "Error while marking the shared memory segment to be destroyed"); const auto seg = xcb_generate_id(c); @@ -780,7 +780,7 @@ QXcbBackingStore::~QXcbBackingStore() QPaintDevice *QXcbBackingStore::paintDevice() { if (!m_image) - return 0; + return nullptr; return m_rgbImage.isNull() ? m_image->image() : &m_rgbImage; } @@ -1036,7 +1036,7 @@ void QXcbSystemTrayBackingStore::recreateImage(QXcbWindow *win, const QSize &siz xcb_create_pixmap(xcb_connection(), 32, m_xrenderPixmap, screen->root(), size.width(), size.height()); m_xrenderPicture = xcb_generate_id(xcb_connection()); - xcb_render_create_picture(xcb_connection(), m_xrenderPicture, m_xrenderPixmap, m_xrenderPictFormat, 0, 0); + xcb_render_create_picture(xcb_connection(), m_xrenderPicture, m_xrenderPixmap, m_xrenderPictFormat, 0, nullptr); // XRender expects premultiplied alpha if (m_image) @@ -1077,7 +1077,7 @@ void QXcbSystemTrayBackingStore::initXRenderMode() m_windowPicture = xcb_generate_id(conn); xcb_void_cookie_t cookie = - xcb_render_create_picture_checked(conn, m_windowPicture, platformWindow->xcb_window(), vfmt->format, 0, 0); + xcb_render_create_picture_checked(conn, m_windowPicture, platformWindow->xcb_window(), vfmt->format, 0, nullptr); xcb_generic_error_t *error = xcb_request_check(conn, cookie); if (error) { qWarning("QXcbSystemTrayBackingStore: Failed to create Picture with format %x for window %x, error code %d", diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 2cb6720d40..c2d9d060fb 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -226,8 +226,8 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c) { Q_ASSERT(QClipboard::Clipboard == 0); Q_ASSERT(QClipboard::Selection == 1); - m_clientClipboard[QClipboard::Clipboard] = 0; - m_clientClipboard[QClipboard::Selection] = 0; + m_clientClipboard[QClipboard::Clipboard] = nullptr; + m_clientClipboard[QClipboard::Selection] = nullptr; m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME; m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME; m_owner = connection()->getQtSelectionOwner(); @@ -316,7 +316,7 @@ QClipboard::Mode QXcbClipboard::modeForAtom(xcb_atom_t a) const QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode) { if (mode > QClipboard::Selection) - return 0; + return nullptr; xcb_window_t clipboardOwner = getSelectionOwner(atomForMode(mode)); if (clipboardOwner == owner()) { @@ -334,7 +334,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) if (mode > QClipboard::Selection) return; - QXcbClipboardMime *xClipboard = 0; + QXcbClipboardMime *xClipboard = nullptr; // verify if there is data to be cleared on global X Clipboard. if (!data) { xClipboard = qobject_cast<QXcbClipboardMime *>(mimeData(mode)); @@ -353,7 +353,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) if (m_clientClipboard[mode]) { if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection]) delete m_clientClipboard[mode]; - m_clientClipboard[mode] = 0; + m_clientClipboard[mode] = nullptr; m_timestamp[mode] = XCB_CURRENT_TIME; } @@ -416,7 +416,7 @@ xcb_window_t QXcbClipboard::requestor() const XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class platformScreen->screen()->root_visual, // visual 0, // value mask - 0); // value list + nullptr); // value list QXcbWindow::setWindowTitle(connection(), window, QStringLiteral("Qt Clipboard Requestor Window")); @@ -529,7 +529,7 @@ void QXcbClipboard::handleSelectionClearRequest(xcb_selection_clear_event_t *eve if (newOwner != XCB_NONE) { if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection]) delete m_clientClipboard[mode]; - m_clientClipboard[mode] = 0; + m_clientClipboard[mode] = nullptr; m_timestamp[mode] = XCB_CURRENT_TIME; } } @@ -576,7 +576,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) xcb_atom_t multipleAtom = atom(QXcbAtom::MULTIPLE); xcb_atom_t timestampAtom = atom(QXcbAtom::TIMESTAMP); - struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = 0; + struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = nullptr; xcb_atom_t multi_type = XCB_NONE; int multi_format = 0; int nmulti = 0; @@ -587,7 +587,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) QByteArray multi_data; if (req->property == XCB_NONE || !clipboardReadProperty(req->requestor, req->property, false, &multi_data, - 0, &multi_type, &multi_format) + nullptr, &multi_type, &multi_format) || multi_format != 32) { // MULTIPLE property not formatted correctly xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); @@ -842,7 +842,7 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb continue; prev_time = event->time; - if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) { + if (clipboardReadProperty(win, property, true, &tmp_buf, &length, nullptr, nullptr)) { if (length == 0) { // no more data, we're done if (nullterm) { buf.resize(offset+1); @@ -900,7 +900,7 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, return buf; xcb_atom_t type; - if (clipboardReadProperty(win, property, true, &buf, 0, &type, 0)) { + if (clipboardReadProperty(win, property, true, &buf, nullptr, &type, nullptr)) { if (type == atom(QXcbAtom::INCR)) { int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; buf = clipboardReadIncrementalProperty(win, property, nbytes, false); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index cbc930387f..435c4aee93 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -184,7 +184,7 @@ QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id) QXcbWindowEventListener *listener = m_mapper.value(id, 0); if (listener) return listener->toWindow(); - return 0; + return nullptr; } #define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \ @@ -803,7 +803,7 @@ xcb_window_t QXcbConnection::getQtSelectionOwner() XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class xcbScreen->root_visual, // visual 0, // value mask - 0); // value list + nullptr); // value list QXcbWindow::setWindowTitle(connection(), m_qtSelectionOwner, QLatin1String("Qt Selection Owner for ") + QCoreApplication::applicationName()); @@ -830,7 +830,7 @@ xcb_window_t QXcbConnection::clientLeader() 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->screen()->root_visual, - 0, 0); + 0, nullptr); QXcbWindow::setWindowTitle(connection(), m_clientLeader, @@ -1031,7 +1031,7 @@ void QXcbConnection::sync() { // from xcb_aux_sync xcb_get_input_focus_cookie_t cookie = xcb_get_input_focus(xcb_connection()); - free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); + free(xcb_get_input_focus_reply(xcb_connection(), cookie, nullptr)); } QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const @@ -1049,14 +1049,14 @@ QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const Qt::MouseButtons QXcbConnection::queryMouseButtons() const { int stateMask = 0; - QXcbCursor::queryPointer(connection(), 0, 0, &stateMask); + QXcbCursor::queryPointer(connection(), nullptr, nullptr, &stateMask); return translateMouseButtons(stateMask); } Qt::KeyboardModifiers QXcbConnection::queryKeyboardModifiers() const { int stateMask = 0; - QXcbCursor::queryPointer(connection(), 0, 0, &stateMask); + QXcbCursor::queryPointer(connection(), nullptr, nullptr, &stateMask); return keyboard()->translateModifiers(stateMask); } @@ -1114,7 +1114,7 @@ void QXcbSyncWindowRequest::invalidate() { if (m_window) { m_window->clearSyncWindowRequest(); - m_window = 0; + m_window = nullptr; } } @@ -1134,7 +1134,7 @@ void QXcbConnectionGrabber::release() { if (m_connection) { m_connection->ungrabServer(); - m_connection = 0; + m_connection = nullptr; } } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 62c5e5d79e..2d89b971dc 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -127,7 +127,7 @@ class Q_XCB_EXPORT QXcbConnection : public QXcbBasicConnection { Q_OBJECT public: - QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = 0); + QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = nullptr); ~QXcbConnection(); QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); } diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp index 1ba4b4a1b9..18dee89adb 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp @@ -93,7 +93,7 @@ static int nullErrorHandler(Display *dpy, XErrorEvent *err) static int ioErrorHandler(Display *dpy) { xcb_connection_t *conn = XGetXCBConnection(dpy); - if (conn != NULL) { + if (conn != nullptr) { /* Print a message with a textual description of the error */ int code = xcb_connection_has_error(conn); const char *str = "Unknown error"; @@ -134,7 +134,7 @@ QXcbBasicConnection::QXcbBasicConnection(const char *displayName) xcb_extension_t *extensions[] = { &xcb_shm_id, &xcb_xfixes_id, &xcb_randr_id, &xcb_shape_id, &xcb_sync_id, - &xcb_render_id, &xcb_xkb_id, &xcb_input_id, 0 + &xcb_render_id, &xcb_xkb_id, &xcb_input_id, nullptr }; for (xcb_extension_t **ext_it = extensions; *ext_it; ++ext_it) diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index fdf59c5ef4..bd62460b96 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -166,7 +166,7 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting) } case XCB_INPUT_DEVICE_CLASS_TYPE_BUTTON: { auto *bci = reinterpret_cast<xcb_input_button_class_t *>(classinfo); - xcb_atom_t *labels = 0; + xcb_atom_t *labels = nullptr; if (bci->num_buttons >= 5) { labels = xcb_input_button_class_labels(bci); xcb_atom_t label4 = labels[3]; @@ -527,7 +527,7 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) int sourceDeviceId = xiEvent->deviceid; // may be the master id qt_xcb_input_device_event_t *xiDeviceEvent = nullptr; xcb_input_enter_event_t *xiEnterEvent = nullptr; - QXcbWindowEventListener *eventListener = 0; + QXcbWindowEventListener *eventListener = nullptr; switch (xiEvent->event_type) { case XCB_INPUT_BUTTON_PRESS: diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index fbadab4d50..639e4f039c 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -67,10 +67,10 @@ enum { }; #undef CursorShape -static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = 0; -static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = 0; -static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = 0; -static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = 0; +static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = nullptr; +static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = nullptr; +static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = nullptr; +static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = nullptr; #endif static xcb_font_t cursorFont = 0; @@ -118,7 +118,7 @@ static const uint8_t mcur_fdiag_bits[] = { static const uint8_t *cursor_bits16[] = { cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, - 0, 0, cur_blank_bits, cur_blank_bits }; + nullptr, nullptr, cur_blank_bits, cur_blank_bits }; static const uint8_t vsplit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -219,7 +219,7 @@ static const uint8_t busym_bits[] = { static const uint8_t * const cursor_bits32[] = { vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, - 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits + nullptr, nullptr, nullptr, nullptr, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits }; static const uint8_t forbidden_bits[] = { @@ -452,19 +452,19 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) if (cshape == Qt::BlankCursor) { xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16, - 1, 0, 0, 0); + 1, 0, 0, nullptr); xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16, - 1, 0, 0, 0); + 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); } else if (cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor) { int i = (cshape - Qt::SizeVerCursor) * 2; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(cursor_bits16[i]), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(cursor_bits16[i + 1]), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor) @@ -472,10 +472,10 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) int i = (cshape - Qt::SplitVCursor) * 2; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(cursor_bits32[i]), - 32, 32, 1, 0, 0, 0); + 32, 32, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(cursor_bits32[i + 1]), - 32, 32, 1, 0, 0, 0); + 32, 32, 1, 0, 0, nullptr); int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) ? 0 : 16; cursor = xcb_generate_id(conn); @@ -484,20 +484,20 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) int i = (cshape - Qt::ForbiddenCursor) * 2; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(cursor_bits20[i]), - 20, 20, 1, 0, 0, 0); + 20, 20, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(cursor_bits20[i + 1]), - 20, 20, 1, 0, 0, 0); + 20, 20, 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 10, 10); } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) { bool open = cshape == Qt::OpenHandCursor; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(open ? openhand_bits : closedhand_bits), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast<uint8_t*>(open ? openhandm_bits : closedhandm_bits), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor @@ -660,14 +660,14 @@ void QXcbCursor::queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDes QPoint QXcbCursor::pos() const { QPoint p; - queryPointer(connection(), 0, &p); + queryPointer(connection(), nullptr, &p); return p; } void QXcbCursor::setPos(const QPoint &pos) { QXcbVirtualDesktop *virtualDesktop = nullptr; - queryPointer(connection(), &virtualDesktop, 0); + queryPointer(connection(), &virtualDesktop, nullptr); xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y()); xcb_flush(xcb_connection()); } diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index eb5b8f808e..47d58fa880 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -148,7 +148,7 @@ void QXcbDrag::init() source_time = XCB_CURRENT_TIME; target_time = XCB_CURRENT_TIME; - QXcbCursor::queryPointer(connection(), ¤t_virtual_desktop, 0); + QXcbCursor::queryPointer(connection(), ¤t_virtual_desktop, nullptr); drag_types.clear(); //current_embedding_widget = 0; @@ -384,13 +384,13 @@ void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod if (!findXdndAwareTarget(globalPos, &target)) return; - QXcbWindow *w = 0; + QXcbWindow *w = nullptr; if (target) { w = connection()->platformWindowFromId(target); if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) - w = 0; + w = nullptr; } else { - w = 0; + w = nullptr; target = current_virtual_desktop->root(); } @@ -522,7 +522,7 @@ void QXcbDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); if (w && w->window()->type() == Qt::Desktop) // && !w->acceptDrops() - w = 0; + w = nullptr; Transaction t = { connection()->time(), @@ -716,7 +716,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message target_time = e->data.data32[3]; } - QMimeData *dropData = 0; + QMimeData *dropData = nullptr; Qt::DropActions supported_actions = Qt::IgnoreAction; if (currentDrag()) { dropData = currentDrag()->mimeData(); @@ -911,7 +911,7 @@ void QXcbDrag::send_leave() QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) - w = 0; + w = nullptr; qCDebug(lcQpaXDnd) << "sending XdndLeave to target:" << current_target; @@ -945,7 +945,7 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e target_time = l[2]; Qt::DropActions supported_drop_actions; - QMimeData *dropData = 0; + QMimeData *dropData = nullptr; if (currentDrag()) { dropData = currentDrag()->mimeData(); supported_drop_actions = Qt::DropActions(l[4]); @@ -1152,7 +1152,7 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event } } - QDrag *transactionDrag = 0; + QDrag *transactionDrag = nullptr; if (at >= 0) { transactionDrag = transactions.at(at).drag; } else if (at == -2) { @@ -1222,7 +1222,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) if (w->window()->type() == Qt::Desktop) { xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy)); delete desktop_proxy; - desktop_proxy = 0; + desktop_proxy = nullptr; } else { qCDebug(lcQpaXDnd) << "not deleting XDndAware"; } diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp index 8f33e6ed31..b0e610dd51 100644 --- a/src/plugins/platforms/xcb/qxcbimage.cpp +++ b/src/plugins/platforms/xcb/qxcbimage.cpp @@ -221,7 +221,7 @@ xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image) for (int i = 0; i < height; i++) memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize); xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, screen->root(), buf, - width, height, 1, 0, 0, 0); + width, height, 1, 0, 0, nullptr); delete[] buf; return pm; } @@ -249,7 +249,7 @@ xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image, 32, 32, 32, 32, QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST, XCB_IMAGE_ORDER_MSB_FIRST, - 0, 0, 0); + nullptr, 0, nullptr); if (!xi) { qWarning("qt_xcb_createCursorXRender: xcb_image_create failed"); return XCB_NONE; @@ -266,10 +266,10 @@ xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image, xcb_create_pixmap(conn, 32, pix, screen->root(), w, h); xcb_render_picture_t pic = xcb_generate_id(conn); - xcb_render_create_picture(conn, pic, pix, fmt->id, 0, 0); + xcb_render_create_picture(conn, pic, pix, fmt->id, 0, nullptr); xcb_gcontext_t gc = xcb_generate_id(conn); - xcb_create_gc(conn, gc, pix, 0, 0); + xcb_create_gc(conn, gc, pix, 0, nullptr); xcb_image_put(conn, pix, gc, xi, 0, 0, 0); xcb_free_gc(conn, gc); diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index efda6b67ce..3fd989e1f9 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -130,7 +130,7 @@ QXcbIntegration *QXcbIntegration::m_instance = nullptr; QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) : m_services(new QGenericUnixServices) - , m_instanceName(0) + , m_instanceName(nullptr) , m_canGrab(true) , m_defaultVisualId(UINT_MAX) { @@ -146,7 +146,7 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char m_nativeInterface.reset(new QXcbNativeInterface); // Parse arguments - const char *displayName = 0; + const char *displayName = nullptr; bool noGrabArg = false; bool doGrabArg = false; if (argc) { diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 3caee3f409..e8286381a2 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -579,7 +579,7 @@ void QXcbKeyboard::selectEvents() required_events, required_map_parts, required_map_parts, - 0); + nullptr); xcb_generic_error_t *error = xcb_request_check(xcb_connection(), select); if (error) { @@ -620,7 +620,7 @@ void QXcbKeyboard::updateVModMapping() vmod_mask = name_reply->virtualMods; // find the virtual modifiers for which names are defined. for (bit = 1; vmod_mask; bit <<= 1) { - vmod_name = 0; + vmod_name = nullptr; if (!(vmod_mask & bit)) continue; diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 81b889a80f..30fa6864ac 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -268,7 +268,7 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterfa if (lowerCaseResource == "peekeventqueue") return NativeResourceForIntegrationFunction(reinterpret_cast<void *>(peekEventQueue)); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) @@ -291,7 +291,7 @@ QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::n return NativeResourceForScreenFunction(reinterpret_cast<void *>(setAppTime)); else if (lowerCaseResource == "setappusertime") return NativeResourceForScreenFunction(reinterpret_cast<void *>(setAppUserTime)); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource) @@ -365,7 +365,7 @@ void *QXcbNativeInterface::startupId() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) return reinterpret_cast<void *>(const_cast<char *>(defaultConnection->startupId().constData())); - return 0; + return nullptr; } void *QXcbNativeInterface::x11Screen() @@ -374,7 +374,7 @@ void *QXcbNativeInterface::x11Screen() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) return reinterpret_cast<void *>(defaultConnection->primaryScreenNumber()); - return 0; + return nullptr; } void *QXcbNativeInterface::rootWindow() @@ -383,7 +383,7 @@ void *QXcbNativeInterface::rootWindow() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) return reinterpret_cast<void *>(defaultConnection->rootWindow()); - return 0; + return nullptr; } void *QXcbNativeInterface::display() diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8da299d491..8bcaa78122 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -318,7 +318,7 @@ bool QXcbVirtualDesktop::xResource(const QByteArray &identifier, static bool parseXftInt(const QByteArray& stringValue, int *value) { - Q_ASSERT(value != 0); + Q_ASSERT(value != nullptr); bool ok; *value = stringValue.toInt(&ok); return ok; @@ -457,7 +457,7 @@ const xcb_visualtype_t *QXcbVirtualDesktop::visualForId(xcb_visualid_t visualid) { QMap<xcb_visualid_t, xcb_visualtype_t>::const_iterator it = m_visuals.find(visualid); if (it == m_visuals.constEnd()) - return 0; + return nullptr; return &*it; } @@ -577,7 +577,7 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const do { auto translate_reply = Q_XCB_REPLY_UNCHECKED(xcb_translate_coordinates, xcb_connection(), parent, child, x, y); if (!translate_reply) { - return 0; + return nullptr; } parent = child; @@ -586,14 +586,14 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const y = translate_reply->dst_y; if (!child || child == root) - return 0; + return nullptr; QPlatformWindow *platformWindow = connection()->platformWindowFromId(child); if (platformWindow) return platformWindow->window(); } while (parent != child); - return 0; + return nullptr; } void QXcbScreen::windowShown(QXcbWindow *window) diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index f880d4d722..2eb32c069e 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -69,7 +69,7 @@ public Q_SLOTS: }; -static SmcConn smcConnection = 0; +static SmcConn smcConnection = nullptr; static bool sm_interactionActive; static bool sm_smActive; static int sm_interactStyle; @@ -81,7 +81,7 @@ static bool sm_phase2; static bool sm_in_phase2; bool qt_sm_blockUserInput = false; -static QSmSocketReceiver* sm_receiver = 0; +static QSmSocketReceiver* sm_receiver = nullptr; static void resetSmState(); static void sm_setProperty(const char *name, const char *type, @@ -191,7 +191,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm) // generate a new session key timeval tv; - gettimeofday(&tv, 0); + gettimeofday(&tv, nullptr); sm->setSessionKey(QString::number(qulonglong(tv.tv_sec)) + QLatin1Char('_') + QString::number(qulonglong(tv.tv_usec))); @@ -203,7 +203,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm) // tell the session manager about our program in best POSIX style sm_setProperty(QString::fromLatin1(SmProgram), argument0); // tell the session manager about our user as well. - struct passwd *entryPtr = 0; + struct passwd *entryPtr = nullptr; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) QVarLengthArray<char, 1024> buf(qMax<long>(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L)); struct passwd entry; @@ -329,7 +329,7 @@ static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) void QSmSocketReceiver::socketActivated(int) { - IceProcessMessages(SmcGetIceConnection(smcConnection), 0, 0); + IceProcessMessages(SmcGetIceConnection(smcConnection), nullptr, nullptr); } @@ -337,11 +337,11 @@ void QSmSocketReceiver::socketActivated(int) QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) : QPlatformSessionManager(id, key) - , m_eventLoop(0) + , m_eventLoop(nullptr) { resetSmState(); char cerror[256]; - char* myId = 0; + char* myId = nullptr; QByteArray b_id = id.toLatin1(); char* prevId = b_id.data(); @@ -359,7 +359,7 @@ QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) if (!qEnvironmentVariableIsSet("SESSION_MANAGER")) return; - smcConnection = SmcOpenConnection(0, 0, 1, 0, + smcConnection = SmcOpenConnection(nullptr, nullptr, 1, 0, SmcSaveYourselfProcMask | SmcDieProcMask | SmcSaveCompleteProcMask | @@ -382,8 +382,8 @@ QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) QXcbSessionManager::~QXcbSessionManager() { if (smcConnection) - SmcCloseConnection(smcConnection, 0, 0); - smcConnection = 0; + SmcCloseConnection(smcConnection, 0, nullptr); + smcConnection = nullptr; delete sm_receiver; } @@ -411,7 +411,7 @@ bool QXcbSessionManager::allowsInteraction() QEventLoop eventLoop; m_eventLoop = &eventLoop; eventLoop.exec(); - m_eventLoop = 0; + m_eventLoop = nullptr; sm_waitingForInteraction = false; if (sm_smActive) { // not cancelled @@ -441,7 +441,7 @@ bool QXcbSessionManager::allowsErrorInteraction() QEventLoop eventLoop; m_eventLoop = &eventLoop; eventLoop.exec(); - m_eventLoop = 0; + m_eventLoop = nullptr; sm_waitingForInteraction = false; if (sm_smActive) { // not cancelled diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp index 684e603fab..ff5ad98cd2 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp @@ -64,11 +64,11 @@ QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection) // Selection, tray atoms for GNOME, NET WM Specification const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE); if (!trayAtom) - return 0; + return nullptr; const QByteArray netSysTray = QByteArrayLiteral("_NET_SYSTEM_TRAY_S") + QByteArray::number(connection->primaryScreenNumber()); const xcb_atom_t selection = connection->internAtom(netSysTray.constData()); if (!selection) - return 0; + return nullptr; return new QXcbSystemTrayTracker(connection, trayAtom, selection); } diff --git a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp index b3f8a5832d..7c15882768 100644 --- a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp @@ -93,7 +93,7 @@ bool QXcbVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window) { - VkSurfaceKHR surface = 0; + VkSurfaceKHR surface = nullptr; if (!m_createSurface) { m_createSurface = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>( diff --git a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp index 25bc340f97..17d7d9791e 100644 --- a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window) : QXcbWindow(window), - m_surface(0) + m_surface(nullptr) { } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f505ddbd1e..66030b9ad4 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -174,13 +174,13 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) { #include <X11/Xatom.h> - static XTextProperty tp = { 0, 0, 0, 0 }; + static XTextProperty tp = { nullptr, 0, 0, 0 }; static bool free_prop = true; // we can't free tp.value in case it references // the data of the static QByteArray below. if (tp.value) { if (free_prop) XFree(tp.value); - tp.value = 0; + tp.value = nullptr; free_prop = true; } @@ -191,7 +191,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) QByteArray mapped = mapper->fromUnicode(s); char* tl[2]; tl[0] = mapped.data(); - tl[1] = 0; + tl[1] = nullptr; errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp); if (errCode < 0) qCDebug(lcQpaXcb, "XmbTextListToTextProperty result code %d", errCode); @@ -280,7 +280,7 @@ void QXcbWindow::create() m_window = platformScreen->root(); m_depth = platformScreen->screen()->root_depth; m_visualId = platformScreen->screen()->root_visual; - const xcb_visualtype_t *visual = 0; + const xcb_visualtype_t *visual = nullptr; if (connection()->hasDefaultVisualId()) { visual = platformScreen->visualForId(connection()->defaultVisualId()); if (visual) @@ -819,7 +819,7 @@ bool QXcbWindow::relayFocusToModalWindow() const while (w && w->parent()) w = w->parent(); - QWindow *modalWindow = 0; + QWindow *modalWindow = nullptr; const bool blocked = QGuiApplicationPrivate::instance()->isWindowBlocked(w, &modalWindow); if (blocked && modalWindow != w) { modalWindow->requestActivate(); @@ -1193,7 +1193,7 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class m_visualId, // visual 0, // value mask - 0); // value list + nullptr); // value list wid = m_netWmUserTimeWindow; xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW), XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow); @@ -1223,7 +1223,7 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent) xcb_rectangle_t rectangle; - xcb_rectangle_t *rect = 0; + xcb_rectangle_t *rect = nullptr; int nrect = 0; if (!transparent) { @@ -1882,7 +1882,7 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in if (m_embedded && !m_trayIconWindow) { if (window() != QGuiApplication::focusWindow()) { const QXcbWindow *container = static_cast<const QXcbWindow *>(parent()); - Q_ASSERT(container != 0); + Q_ASSERT(container != nullptr); sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS); } @@ -2087,7 +2087,7 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail); - const char *sourceName = 0; + const char *sourceName = nullptr; if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) { const QMetaObject *metaObject = qt_getEnumMetaObject(source); const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source))); diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 88f15e344f..902f196ba9 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -256,7 +256,7 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen) QXcbXSettings::~QXcbXSettings() { delete d_ptr; - d_ptr = 0; + d_ptr = nullptr; } bool QXcbXSettings::initialized() const diff --git a/src/plugins/platformthemes/gtk3/main.cpp b/src/plugins/platformthemes/gtk3/main.cpp index fb1c425d8e..860fc3a26e 100644 --- a/src/plugins/platformthemes/gtk3/main.cpp +++ b/src/plugins/platformthemes/gtk3/main.cpp @@ -57,7 +57,7 @@ QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList & if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) return new QGtk3Theme; - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index c64a02fa0c..65564b59a1 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -165,12 +165,12 @@ void QGtk3Dialog::onResponse(QGtk3Dialog *dialog, int response) void QGtk3Dialog::onParentWindowDestroyed() { // The QGtk3*DialogHelper classes own this object. Make sure the parent doesn't delete it. - setParent(0); + setParent(nullptr); } QGtk3ColorDialogHelper::QGtk3ColorDialogHelper() { - d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", 0))); + d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", nullptr))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); @@ -238,7 +238,7 @@ void QGtk3ColorDialogHelper::applyOptions() QGtk3FileDialogHelper::QGtk3FileDialogHelper() { - d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0, + d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN, qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel)), GTK_RESPONSE_CANCEL, qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Ok)), GTK_RESPONSE_OK, @@ -497,7 +497,7 @@ void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters) QGtk3FontDialogHelper::QGtk3FontDialogHelper() { - d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", 0))); + d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", nullptr))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp index 4f0bd9d9a0..d9d117faeb 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp @@ -200,7 +200,7 @@ void QGtk3MenuItem::setMenu(QPlatformMenu *menu) { m_menu = qobject_cast<QGtk3Menu *>(menu); if (GTK_IS_MENU_ITEM(m_item)) - gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu ? m_menu->handle() : NULL); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu ? m_menu->handle() : nullptr); } bool QGtk3MenuItem::isVisible() const @@ -436,7 +436,7 @@ void QGtk3Menu::showPopup(const QWindow *parentWindow, const QRect &targetRect, if (pw) m_targetPos = pw->mapToGlobal(m_targetPos); - gtk_menu_popup(GTK_MENU(m_menu), NULL, NULL, qt_gtk_menu_position_func, this, 0, gtk_get_current_event_time()); + gtk_menu_popup(GTK_MENU(m_menu), nullptr, nullptr, qt_gtk_menu_position_func, this, 0, gtk_get_current_event_time()); } void QGtk3Menu::dismiss() diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index 077955eb4e..93520344f8 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -86,9 +86,9 @@ QGtk3Theme::QGtk3Theme() { // gtk_init will reset the Xlib error handler, and that causes // Qt applications to quit on X errors. Therefore, we need to manually restore it. - int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL); + int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(nullptr); - gtk_init(0, 0); + gtk_init(nullptr, nullptr); XSetErrorHandler(oldErrorHandler); @@ -99,7 +99,7 @@ QGtk3Theme::QGtk3Theme() g_type_ensure(PANGO_TYPE_FONT_FACE); /* Use our custom log handler. */ - g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, NULL); + g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, nullptr); } static inline QVariant gtkGetLongPressTime() @@ -173,7 +173,7 @@ QPlatformDialogHelper *QGtk3Theme::createPlatformDialogHelper(DialogType type) c case FontDialog: return new QGtk3FontDialogHelper; default: - return 0; + return nullptr; } } @@ -197,7 +197,7 @@ bool QGtk3Theme::useNativeFileDialog() * dialogs entirely since we can't avoid creation of a platform * dialog helper. */ - return gtk_check_version(3, 15, 5) == 0; + return gtk_check_version(3, 15, 5) == nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql_p.h b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h index 48b04fb1f5..9ccc8f4e4f 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql_p.h +++ b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h @@ -75,8 +75,8 @@ class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver Q_DECLARE_PRIVATE(QMYSQLDriver) Q_OBJECT public: - explicit QMYSQLDriver(QObject *parent=0); - explicit QMYSQLDriver(MYSQL *con, QObject * parent=0); + explicit QMYSQLDriver(QObject *parent=nullptr); + explicit QMYSQLDriver(MYSQL *con, QObject * parent=nullptr); ~QMYSQLDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString & db, diff --git a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h index 48c64536f1..57db0a4d47 100644 --- a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h +++ b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h @@ -76,8 +76,8 @@ class Q_EXPORT_SQLDRIVER_SQLITE2 QSQLite2Driver : public QSqlDriver Q_DECLARE_PRIVATE(QSQLite2Driver) Q_OBJECT public: - explicit QSQLite2Driver(QObject *parent = 0); - explicit QSQLite2Driver(sqlite *connection, QObject *parent = 0); + explicit QSQLite2Driver(QObject *parent = nullptr); + explicit QSQLite2Driver(sqlite *connection, QObject *parent = nullptr); ~QSQLite2Driver(); bool hasFeature(DriverFeature f) const override; bool open(const QString &db, diff --git a/src/plugins/sqldrivers/tds/qsql_tds_p.h b/src/plugins/sqldrivers/tds/qsql_tds_p.h index 948e3c7024..b72fababbb 100644 --- a/src/plugins/sqldrivers/tds/qsql_tds_p.h +++ b/src/plugins/sqldrivers/tds/qsql_tds_p.h @@ -85,8 +85,8 @@ class Q_EXPORT_SQLDRIVER_TDS QTDSDriver : public QSqlDriver Q_OBJECT friend class QTDSResultPrivate; public: - explicit QTDSDriver(QObject* parent = 0); - QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = 0); + explicit QTDSDriver(QObject* parent = nullptr); + QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = nullptr); ~QTDSDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString &db, diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index 1d8af9dbf0..ab7a2edb67 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -725,7 +725,7 @@ QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) } QPageSetupDialog::QPageSetupDialog(QWidget *parent) - : QDialog(*(new QUnixPageSetupDialogPrivate(0)), parent) + : QDialog(*(new QUnixPageSetupDialogPrivate(nullptr)), parent) { Q_D(QPageSetupDialog); setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index c7328d9732..d929367557 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -1176,7 +1176,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * void QUnixPrintWidgetPrivate::updateWidget() { - const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile); + const bool printToFile = q == nullptr || q->isOptionEnabled(QPrintDialog::PrintToFile); if (printToFile && !filePrintersAdded) { if (widget.printers->count()) widget.printers->insertSeparator(widget.printers->count()); diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index 410051df2a..8106db4edb 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.cpp @@ -377,16 +377,16 @@ void QAlphaPaintEngine::cleanUp() delete d->m_picpainter; delete d->m_pic; - d->m_picpainter = 0; - d->m_pic = 0; - d->m_picengine = 0; + d->m_picpainter = nullptr; + d->m_pic = nullptr; + d->m_picengine = nullptr; } QAlphaPaintEnginePrivate::QAlphaPaintEnginePrivate() : m_pass(0), - m_pic(0), - m_picengine(0), - m_picpainter(0), + m_pic(nullptr), + m_picengine(nullptr), + m_picpainter(nullptr), m_numberOfCachedRects(0), m_hasalpha(false), m_alphaPen(false), diff --git a/src/printsupport/kernel/qplatformprintplugin.h b/src/printsupport/kernel/qplatformprintplugin.h index 30e8f7938a..db28da4dd3 100644 --- a/src/printsupport/kernel/qplatformprintplugin.h +++ b/src/printsupport/kernel/qplatformprintplugin.h @@ -66,7 +66,7 @@ class Q_PRINTSUPPORT_EXPORT QPlatformPrinterSupportPlugin : public QObject { Q_OBJECT public: - explicit QPlatformPrinterSupportPlugin(QObject *parent = 0); + explicit QPlatformPrinterSupportPlugin(QObject *parent = nullptr); ~QPlatformPrinterSupportPlugin(); virtual QPlatformPrinterSupport *create(const QString &key) = 0; diff --git a/src/printsupport/kernel/qprinter_p.h b/src/printsupport/kernel/qprinter_p.h index 37c9702c17..4c42ed5717 100644 --- a/src/printsupport/kernel/qprinter_p.h +++ b/src/printsupport/kernel/qprinter_p.h @@ -76,12 +76,12 @@ class Q_PRINTSUPPORT_EXPORT QPrinterPrivate public: QPrinterPrivate(QPrinter *printer) : pdfVersion(QPrinter::PdfVersion_1_4), - printEngine(0), - paintEngine(0), - realPrintEngine(0), - realPaintEngine(0), + printEngine(nullptr), + paintEngine(nullptr), + realPrintEngine(nullptr), + realPaintEngine(nullptr), #if QT_CONFIG(printpreviewwidget) - previewEngine(0), + previewEngine(nullptr), #endif q_ptr(printer), printRange(QPrinter::AllPages), diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 01726d79ef..32338c1fe2 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -84,7 +84,7 @@ Q_GLOBAL_STATIC(QConnectionDict, dbDict) class QSqlDatabasePrivate { public: - QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0): + QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = nullptr): ref(1), q(d), driver(dr), @@ -178,7 +178,7 @@ DriverDict &QSqlDatabasePrivate::driverDict() QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null() { static QSqlNullDriver dr; - static QSqlDatabasePrivate n(NULL, &dr); + static QSqlDatabasePrivate n(nullptr, &dr); return &n; } @@ -702,7 +702,7 @@ void QSqlDatabasePrivate::init(const QString &type) qWarning("QSqlDatabase: %s driver not loaded", type.toLatin1().data()); qWarning("QSqlDatabase: available drivers: %s", QSqlDatabase::drivers().join(QLatin1Char(' ')).toLatin1().data()); - if (QCoreApplication::instance() == 0) + if (QCoreApplication::instance() == nullptr) qWarning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins"); driver = shared_null()->driver; } diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index e0ddc4ca84..fcd3c70a04 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE static QString prepareIdentifier(const QString &identifier, QSqlDriver::IdentifierType type, const QSqlDriver *driver) { - Q_ASSERT( driver != NULL ); + Q_ASSERT( driver != nullptr ); QString ret = identifier; if (!driver->isIdentifierEscaped(identifier, type)) { ret = driver->escapeIdentifier(identifier, type); diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp index 34be010474..20adec6a3b 100644 --- a/src/sql/models/qsqlrelationaltablemodel.cpp +++ b/src/sql/models/qsqlrelationaltablemodel.cpp @@ -137,7 +137,7 @@ class QRelatedTableModel; struct QRelation { public: - QRelation(): model(0), m_parent(0), m_dictInitialized(false) {} + QRelation(): model(nullptr), m_parent(nullptr), m_dictInitialized(false) {} void init(QSqlRelationalTableModel *parent, const QSqlRelation &relation); void populateModel(); @@ -161,7 +161,7 @@ struct QRelation class QRelatedTableModel : public QSqlTableModel { public: - QRelatedTableModel(QRelation *rel, QObject *parent = 0, QSqlDatabase db = QSqlDatabase()); + QRelatedTableModel(QRelation *rel, QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase()); bool select() override; private: bool firstSelect; @@ -174,7 +174,7 @@ private: */ void QRelation::init(QSqlRelationalTableModel *parent, const QSqlRelation &relation) { - Q_ASSERT(parent != NULL); + Q_ASSERT(parent != nullptr); m_parent = parent; rel = relation; } @@ -183,7 +183,7 @@ void QRelation::populateModel() { if (!isValid()) return; - Q_ASSERT(m_parent != NULL); + Q_ASSERT(m_parent != nullptr); if (!model) { model = new QRelatedTableModel(this, m_parent, m_parent->database()); @@ -202,7 +202,7 @@ void QRelation::populateDictionary() if (!isValid()) return; - if (model == NULL) + if (model == nullptr) populateModel(); QSqlRecord record; @@ -234,13 +234,13 @@ void QRelation::clearDictionary() void QRelation::clear() { delete model; - model = 0; + model = nullptr; clearDictionary(); } bool QRelation::isValid() { - return (rel.isValid() && m_parent != NULL); + return (rel.isValid() && m_parent != nullptr); } diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 6a74e739e6..553e16d472 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -77,7 +77,7 @@ static const char *metaTypeEnumValueString(int type) QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING) } #undef RETURN_METATYPENAME_STRING - return 0; + return nullptr; } Generator::Generator(ClassDef *classDef, const QVector<QByteArray> &metaTypes, const QHash<QByteArray, QByteArray> &knownQObjectClasses, const QHash<QByteArray, QByteArray> &knownGadgets, FILE *outfile) diff --git a/src/tools/moc/parser.cpp b/src/tools/moc/parser.cpp index b7aefae1ec..068f75d4bd 100644 --- a/src/tools/moc/parser.cpp +++ b/src/tools/moc/parser.cpp @@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE Symbol::LexemStore Symbol::lexemStore; #endif -static const char *error_msg = 0; +static const char *error_msg = nullptr; #ifdef Q_CC_MSVC #define ErrorFormatString "%s(%d): " diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index d135bddb4c..a99b8cc80c 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -943,7 +943,7 @@ int PP_Expression::primary_expression() test(PP_RPAREN); } else { next(); - value = lexem().toInt(0, 0); + value = lexem().toInt(nullptr, 0); } return value; } diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 63c6fbb9bb..4d9a629ab6 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -97,10 +97,10 @@ public: if (t == QAccessible::ActionInterface) { return static_cast<QAccessibleActionInterface*>(this); } - return 0; + return nullptr; } - QObject *object() const override { return 0; } + QObject *object() const override { return nullptr; } QAccessible::Role role() const override { return QAccessible::PageTab; } QAccessible::State state() const override { if (!isValid()) { @@ -129,7 +129,7 @@ public: return false; } - QAccessibleInterface *childAt(int, int) const override { return 0; } + QAccessibleInterface *childAt(int, int) const override { return nullptr; } int childCount() const override { return 0; } int indexOfChild(const QAccessibleInterface *) const override { return -1; } @@ -168,7 +168,7 @@ public: QAccessibleInterface *parent() const override { return QAccessible::queryAccessibleInterface(m_parent.data()); } - QAccessibleInterface *child(int) const override { return 0; } + QAccessibleInterface *child(int) const override { return nullptr; } // action interface QStringList actionNames() const override @@ -237,7 +237,7 @@ QAccessibleInterface* QAccessibleTabBar::child(int index) const return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB); } } - return 0; + return nullptr; } int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const @@ -314,7 +314,7 @@ QAccessibleInterface *QAccessibleComboBox::child(int index) const } else if (index == 1 && comboBox()->isEditable()) { return QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); } - return 0; + return nullptr; } int QAccessibleComboBox::childCount() const @@ -327,7 +327,7 @@ QAccessibleInterface *QAccessibleComboBox::childAt(int x, int y) const { if (comboBox()->isEditable() && comboBox()->lineEdit()->rect().contains(x, y)) return child(1); - return 0; + return nullptr; } int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const @@ -432,7 +432,7 @@ bool QAccessibleAbstractScrollArea::isValid() const QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const { if (!abstractScrollArea()->isVisible()) - return 0; + return nullptr; for (int i = 0; i < childCount(); ++i) { QPoint wpos = accessibleChildren().at(i)->mapToGlobal(QPoint(0, 0)); @@ -440,7 +440,7 @@ QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const if (rect.contains(x, y)) return child(i); } - return 0; + return nullptr; } QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 3bfe215c05..5a7fdf9a03 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -121,7 +121,7 @@ QAccessibleTable::~QAccessibleTable() QHeaderView *QAccessibleTable::horizontalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) { @@ -137,7 +137,7 @@ QHeaderView *QAccessibleTable::horizontalHeader() const QHeaderView *QAccessibleTable::verticalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast<const QTableView*>(view())) { @@ -150,19 +150,19 @@ QHeaderView *QAccessibleTable::verticalHeader() const QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const { if (!view()->model()) - return 0; + return nullptr; Q_ASSERT(role() != QAccessible::Tree); QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << view(); - return 0; + return nullptr; } return child(logicalIndex(index)); } QAccessibleInterface *QAccessibleTable::caption() const { - return 0; + return nullptr; } QString QAccessibleTable::columnDescription(int column) const @@ -254,7 +254,7 @@ QList<int> QAccessibleTable::selectedRows() const QAccessibleInterface *QAccessibleTable::summary() const { - return 0; + return nullptr; } bool QAccessibleTable::isColumnSelected(int column) const @@ -422,7 +422,7 @@ QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const if (index.isValid()) { return child(logicalIndex(index)); } - return 0; + return nullptr; } int QAccessibleTable::childCount() const @@ -485,13 +485,13 @@ QAccessibleInterface *QAccessibleTable::parent() const } return QAccessible::queryAccessibleInterface(view()->parent()); } - return 0; + return nullptr; } QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const { if (!view()->model()) - return 0; + return nullptr; auto id = childToId.constFind(logicalIndex); if (id != childToId.constEnd()) @@ -505,7 +505,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const int row = logicalIndex / columns; int column = logicalIndex % columns; - QAccessibleInterface *iface = 0; + QAccessibleInterface *iface = nullptr; if (vHeader) { if (column == 0) { @@ -528,7 +528,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); if (Q_UNLIKELY(!index.isValid())) { qWarning("QAccessibleTable::child: Invalid index at: %d %d", row, column); - return 0; + return nullptr; } iface = new QAccessibleTableCell(view(), index, cellRole()); } @@ -542,7 +542,7 @@ void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::TableInterface) return static_cast<QAccessibleTableInterface*>(this); - return 0; + return nullptr; } void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) @@ -676,13 +676,13 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const { if (!view()->model()) - return 0; + return nullptr; QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); QModelIndex index = view()->indexAt(indexPosition); if (!index.isValid()) - return 0; + return nullptr; const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0); @@ -706,9 +706,9 @@ int QAccessibleTree::childCount() const QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const { if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount()) - return 0; + return nullptr; - QAccessibleInterface *iface = 0; + QAccessibleInterface *iface = nullptr; int index = logicalIndex; if (horizontalHeader()) { @@ -724,7 +724,7 @@ QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const int column = index % view()->model()->columnCount(); QModelIndex modelIndex = indexFromLogical(row, column); if (!modelIndex.isValid()) - return 0; + return nullptr; iface = new QAccessibleTableCell(view(), modelIndex, cellRole()); } QAccessible::registerAccessibleInterface(iface); @@ -772,7 +772,7 @@ QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const QModelIndex index = indexFromLogical(row, column); if (Q_UNLIKELY(!index.isValid())) { qWarning("Requested invalid tree cell: %d %d", row, column); - return 0; + return nullptr; } const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); Q_ASSERT(treeView); @@ -841,7 +841,7 @@ void *QAccessibleTableCell::interface_cast(QAccessible::InterfaceType t) return static_cast<QAccessibleTableCellInterface*>(this); if (t == QAccessible::ActionInterface) return static_cast<QAccessibleActionInterface*>(this); - return 0; + return nullptr; } int QAccessibleTableCell::columnExtent() const { return 1; } @@ -869,7 +869,7 @@ QList<QAccessibleInterface*> QAccessibleTableCell::columnHeaderCells() const QHeaderView *QAccessibleTableCell::horizontalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) @@ -887,7 +887,7 @@ QHeaderView *QAccessibleTableCell::horizontalHeader() const QHeaderView *QAccessibleTableCell::verticalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; #if QT_CONFIG(tableview) if (const QTableView *tv = qobject_cast<const QTableView*>(view)) header = tv->verticalHeader(); @@ -1115,7 +1115,7 @@ QAccessibleInterface *QAccessibleTableCell::parent() const QAccessibleInterface *QAccessibleTableCell::child(int) const { - return 0; + return nullptr; } QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_) @@ -1143,7 +1143,7 @@ QAccessible::State QAccessibleTableHeaderCell::state() const QRect QAccessibleTableHeaderCell::rect() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) { @@ -1206,12 +1206,12 @@ QAccessibleInterface *QAccessibleTableHeaderCell::parent() const QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const { - return 0; + return nullptr; } QHeaderView *QAccessibleTableHeaderCell::headerView() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) { diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 7f87288520..51ba0adaa6 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -88,8 +88,8 @@ QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const { QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y))); if(act && act->isSeparator()) - act = 0; - return act ? getOrCreateMenu(menu(), act) : 0; + act = nullptr; + return act ? getOrCreateMenu(menu(), act) : nullptr; } QString QAccessibleMenu::text(QAccessible::Text t) const @@ -112,7 +112,7 @@ QAccessibleInterface *QAccessibleMenu::child(int index) const { if (index < childCount()) return getOrCreateMenu(menu(), menu()->actions().at(index)); - return 0; + return nullptr; } QAccessibleInterface *QAccessibleMenu::parent() const @@ -165,7 +165,7 @@ QAccessibleInterface *QAccessibleMenuBar::child(int index) const if (index < childCount()) { return getOrCreateMenu(menuBar(), menuBar()->actions().at(index)); } - return 0; + return nullptr; } int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const @@ -195,7 +195,7 @@ QAccessibleInterface *QAccessibleMenuItem::childAt(int x, int y ) const return childInterface; } } - return 0; + return nullptr; } int QAccessibleMenuItem::childCount() const @@ -224,14 +224,14 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const { if (index == 0 && action()->menu()) return QAccessible::queryAccessibleInterface(action()->menu()); - return 0; + return nullptr; } void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::ActionInterface) return static_cast<QAccessibleActionInterface*>(this); - return 0; + return nullptr; } QObject *QAccessibleMenuItem::object() const diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 27e6b09dc7..c782e00f4f 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -363,7 +363,7 @@ QAccessibleInterface *QAccessibleWidget::child(int index) const QWidgetList childList = childWidgets(widget()); if (index >= 0 && index < childList.size()) return QAccessible::queryAccessibleInterface(childList.at(index)); - return 0; + return nullptr; } /*! \reimp */ @@ -374,11 +374,11 @@ QAccessibleInterface *QAccessibleWidget::focusChild() const QWidget *fw = widget()->focusWidget(); if (!fw) - return 0; + return nullptr; if (isAncestor(widget(), fw) || fw == widget()) return QAccessible::queryAccessibleInterface(fw); - return 0; + return nullptr; } /*! \reimp */ @@ -522,7 +522,7 @@ void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::ActionInterface) return static_cast<QAccessibleActionInterface*>(this); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 0bac45de27..d59da86076 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object) { - QAccessibleInterface *iface = 0; + QAccessibleInterface *iface = nullptr; if (!object || !object->isWidgetType()) return iface; @@ -79,7 +79,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje #if QT_CONFIG(lineedit) } else if (classname == QLatin1String("QLineEdit")) { if (widget->objectName() == QLatin1String("qt_spinbox_lineedit")) - iface = 0; + iface = nullptr; else iface = new QAccessibleLineEdit(widget); #endif @@ -223,7 +223,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje #endif } else if (classname == QLatin1String("QDesktopScreenWidget")) { - iface = 0; + iface = nullptr; } else if (classname == QLatin1String("QWidget")) { iface = new QAccessibleWidget(widget); } else if (classname == QLatin1String("QWindowContainer")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 52c953ed3a..574be1f5ea 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -332,14 +332,14 @@ QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget) QAccessibleInterface *QAccessibleStackedWidget::childAt(int x, int y) const { if (!stackedWidget()->isVisible()) - return 0; + return nullptr; QWidget *currentWidget = stackedWidget()->currentWidget(); if (!currentWidget) - return 0; + return nullptr; QPoint position = currentWidget->mapFromGlobal(QPoint(x, y)); if (currentWidget->rect().contains(position)) return child(stackedWidget()->currentIndex()); - return 0; + return nullptr; } int QAccessibleStackedWidget::childCount() const @@ -359,7 +359,7 @@ int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) co QAccessibleInterface *QAccessibleStackedWidget::child(int index) const { if (index < 0 || index >= stackedWidget()->count()) - return 0; + return nullptr; return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index)); } @@ -401,7 +401,7 @@ QAccessibleInterface *QAccessibleMdiArea::child(int index) const QList<QMdiSubWindow *> subWindows = mdiArea()->subWindowList(); QWidget *targetObject = subWindows.value(index); if (!targetObject) - return 0; + return nullptr; return QAccessible::queryAccessibleInterface(targetObject); } @@ -478,7 +478,7 @@ QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const { QMdiSubWindow *source = mdiSubWindow(); if (index != 0 || !source->widget()) - return 0; + return nullptr; return QAccessible::queryAccessibleInterface(source->widget()); } @@ -554,7 +554,7 @@ int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) c QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const { if (index < 0 || index >= childCount()) - return 0; + return nullptr; if (childCount() > 1 && index == 0) return QAccessible::queryAccessibleInterface(navigationBar()); @@ -573,7 +573,7 @@ QAbstractItemView *QAccessibleCalendarWidget::calendarView() const if (child->objectName() == QLatin1String("qt_calendar_calendarview")) return static_cast<QAbstractItemView *>(child); } - return 0; + return nullptr; } QWidget *QAccessibleCalendarWidget::navigationBar() const @@ -582,7 +582,7 @@ QWidget *QAccessibleCalendarWidget::navigationBar() const if (child->objectName() == QLatin1String("qt_calendar_navigationbar")) return static_cast<QWidget *>(child); } - return 0; + return nullptr; } #endif // QT_CONFIG(calendarwidget) @@ -624,7 +624,7 @@ QAccessibleInterface *QAccessibleDockWidget::child(int index) const if (item) return QAccessible::queryAccessibleInterface(item->widget()); } - return 0; + return nullptr; } int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const @@ -1109,7 +1109,7 @@ QAccessibleInterface *QAccessibleMainWindow::child(int index) const if (index >= 0 && index < kids.count()) { return QAccessible::queryAccessibleInterface(kids.at(index)); } - return 0; + return nullptr; } int QAccessibleMainWindow::childCount() const @@ -1128,10 +1128,10 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const { QWidget *w = widget(); if (!w->isVisible()) - return 0; + return nullptr; QPoint gp = w->mapToGlobal(QPoint(0, 0)); if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) - return 0; + return nullptr; const QWidgetList kids = childWidgets(mainWindow()); QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y)); @@ -1140,7 +1140,7 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const return QAccessible::queryAccessibleInterface(child); } } - return 0; + return nullptr; } QMainWindow *QAccessibleMainWindow::mainWindow() const diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index ca74ee4b12..9dbbe9c608 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -364,7 +364,7 @@ QAccessibleInterface *QAccessibleToolButton::child(int index) const #else Q_UNUSED(index) #endif - return 0; + return nullptr; } /* @@ -976,7 +976,7 @@ QAccessibleInterface *QAccessibleWindowContainer::child(int i) const { if (i == 0) return QAccessible::queryAccessibleInterface(container()->containedWindow()); - return 0; + return nullptr; } QWindowContainer *QAccessibleWindowContainer::container() const diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index d00a600424..689002b589 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -192,7 +192,7 @@ class QWellArray : public QWidget Q_PROPERTY(int selectedRow READ selectedRow) public: - QWellArray(int rows, int cols, QWidget* parent=0); + QWellArray(int rows, int cols, QWidget* parent=nullptr); ~QWellArray() {} QString cellContent(int row, int col) const; @@ -744,7 +744,7 @@ class QColorLuminancePicker : public QWidget { Q_OBJECT public: - QColorLuminancePicker(QWidget* parent=0); + QColorLuminancePicker(QWidget* parent=nullptr); ~QColorLuminancePicker(); public slots: @@ -789,7 +789,7 @@ QColorLuminancePicker::QColorLuminancePicker(QWidget* parent) :QWidget(parent) { hue = 100; val = 100; sat = 100; - pix = 0; + pix = nullptr; // setAttribute(WA_NoErase, true); } @@ -812,7 +812,7 @@ void QColorLuminancePicker::setVal(int v) if (val == v) return; val = qMax(0, qMin(v,255)); - delete pix; pix=0; + delete pix; pix=nullptr; repaint(); emit newHsv(hue, sat, val); } @@ -861,7 +861,7 @@ void QColorLuminancePicker::setCol(int h, int s , int v) val = v; hue = h; sat = s; - delete pix; pix=0; + delete pix; pix=nullptr; repaint(); } @@ -1678,8 +1678,8 @@ void QColorDialogPrivate::init(const QColor &initial) q->setWindowTitle(QColorDialog::tr("Select Color")); // default: use the native dialog if possible. Can be overridden in setOptions() - nativeDialogInUse = (platformColorDialogHelper() != 0); - colorPickingEventFilter = 0; + nativeDialogInUse = (platformColorDialogHelper() != nullptr); + colorPickingEventFilter = nullptr; nextCust = 0; if (!nativeDialogInUse) @@ -1703,7 +1703,7 @@ void QColorDialogPrivate::initWidgets() QHBoxLayout *topLay = new QHBoxLayout(); mainLay->addLayout(topLay); - leftLay = 0; + leftLay = nullptr; #if defined(QT_SMALL_COLORDIALOG) smallDisplay = true; @@ -1773,8 +1773,8 @@ void QColorDialogPrivate::initWidgets() pWidth = 150; pHeight = 100; #endif - custom = 0; - standard = 0; + custom = nullptr; + standard = nullptr; } QVBoxLayout *rightLay = new QVBoxLayout; @@ -2302,7 +2302,7 @@ void QColorDialog::done(int result) if (d->receiverToDisconnectOnClose) { disconnect(this, SIGNAL(colorSelected(QColor)), d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); - d->receiverToDisconnectOnClose = 0; + d->receiverToDisconnectOnClose = nullptr; } d->memberToDisconnectOnClose.clear(); } diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 3cdd9a5f04..362200a4fd 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -187,7 +187,7 @@ QWindow *QDialogPrivate::transientParentWindow() const return parent->windowHandle(); else if (q->windowHandle()) return q->windowHandle()->transientParent(); - return 0; + return nullptr; } bool QDialogPrivate::setNativeDialogVisible(bool visible) @@ -214,7 +214,7 @@ QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const void QDialogPrivate::deletePlatformHelper() { delete m_platformHelper; - m_platformHelper = 0; + m_platformHelper = nullptr; m_platformHelperCreated = false; nativeDialogInUse = false; } @@ -460,7 +460,7 @@ void QDialogPrivate::setDefault(QPushButton *pushButton) */ void QDialogPrivate::setMainDefault(QPushButton *pushButton) { - mainDef = 0; + mainDef = nullptr; setDefault(pushButton); } @@ -602,7 +602,7 @@ int QDialog::exec() } if (guard.isNull()) return QDialog::Rejected; - d->eventLoop = 0; + d->eventLoop = nullptr; setAttribute(Qt::WA_ShowModal, wasShowModal); @@ -679,12 +679,12 @@ void QDialog::contextMenuEvent(QContextMenuEvent *e) #else QWidget *w = childAt(e->pos()); if (!w) { - w = rect().contains(e->pos()) ? this : 0; + w = rect().contains(e->pos()) ? this : nullptr; if (!w) return; } while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis)) - w = w->isWindow() ? 0 : w->parentWidget(); + w = w->isWindow() ? nullptr : w->parentWidget(); if (w) { QPointer<QMenu> p = new QMenu(this); QAction *wt = p.data()->addAction(tr("What's This?")); @@ -1191,7 +1191,7 @@ void QDialog::setSizeGripEnabled(bool enabled) d->resizer->show(); } else { delete d->resizer; - d->resizer = 0; + d->resizer = nullptr; } } #endif // QT_CONFIG(sizegrip) diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index f0ec2c0102..790d09414b 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -149,13 +149,13 @@ QSize QErrorMessageTextView::sizeHint() const \sa QMessageBox, QStatusBar::showMessage(), {Standard Dialogs Example} */ -static QErrorMessage * qtMessageHandler = 0; +static QErrorMessage * qtMessageHandler = nullptr; static void deleteStaticcQErrorMessage() // post-routine { if (qtMessageHandler) { delete qtMessageHandler; - qtMessageHandler = 0; + qtMessageHandler = nullptr; } } @@ -252,8 +252,8 @@ QErrorMessage::QErrorMessage(QWidget * parent) QErrorMessage::~QErrorMessage() { if (this == qtMessageHandler) { - qtMessageHandler = 0; - QtMessageHandler tmp = qInstallMessageHandler(0); + qtMessageHandler = nullptr; + QtMessageHandler tmp = qInstallMessageHandler(nullptr); // in case someone else has later stuck in another... if (tmp != jump) qInstallMessageHandler(tmp); @@ -293,7 +293,7 @@ void QErrorMessage::done(int a) QErrorMessage * QErrorMessage::qtHandler() { if (!qtMessageHandler) { - qtMessageHandler = new QErrorMessage(0); + qtMessageHandler = new QErrorMessage(nullptr); qAddPostRoutine(deleteStaticcQErrorMessage); // clean up qtMessageHandler->setWindowTitle(QCoreApplication::applicationName()); qInstallMessageHandler(jump); diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index fbcc02accd..f0bd08a778 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -531,15 +531,15 @@ void QFileDialog::changeEvent(QEvent *e) QFileDialogPrivate::QFileDialogPrivate() : #if QT_CONFIG(proxymodel) - proxyModel(0), + proxyModel(nullptr), #endif - model(0), + model(nullptr), currentHistoryLocation(-1), - renameAction(0), - deleteAction(0), - showHiddenAction(0), + renameAction(nullptr), + deleteAction(nullptr), + showHiddenAction(nullptr), useDefaultCaption(true), - qFileDialogUi(0), + qFileDialogUi(nullptr), options(QFileDialogOptions::create()) { } @@ -882,14 +882,14 @@ void QFileDialog::setVisible(bool visible) #if QT_CONFIG(fscompleter) // So the completer doesn't try to complete and therefore show a popup if (!d->nativeDialogInUse) - d->completer->setModel(0); + d->completer->setModel(nullptr); #endif } else { d->createWidgets(); setAttribute(Qt::WA_DontShowOnScreen, false); #if QT_CONFIG(fscompleter) if (!d->nativeDialogInUse) { - if (d->proxyModel != 0) + if (d->proxyModel != nullptr) d->completer->setModel(d->proxyModel); else d->completer->setModel(d->model); @@ -1824,7 +1824,7 @@ QModelIndex QFileDialogPrivate::rootIndex() const { QAbstractItemView *QFileDialogPrivate::currentView() const { if (!qFileDialogUi->stackedWidget) - return 0; + return nullptr; if (qFileDialogUi->stackedWidget->currentWidget() == qFileDialogUi->listView->parent()) return qFileDialogUi->listView; return qFileDialogUi->treeView; @@ -2038,7 +2038,7 @@ QAbstractItemDelegate *QFileDialog::itemDelegate() const { Q_D(const QFileDialog); if (!d->usingWidgets()) - return 0; + return nullptr; return d->qFileDialogUi->listView->itemDelegate(); } @@ -2776,7 +2776,7 @@ void QFileDialog::done(int result) if (d->receiverToDisconnectOnClose) { disconnect(this, d->signalToDisconnectOnClose, d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); - d->receiverToDisconnectOnClose = 0; + d->receiverToDisconnectOnClose = nullptr; } d->memberToDisconnectOnClose.clear(); d->signalToDisconnectOnClose.clear(); @@ -3015,7 +3015,7 @@ void QFileDialogPrivate::init(const QUrl &directory, const QString &nameFilter, } q->setAcceptMode(QFileDialog::AcceptOpen); - nativeDialogInUse = platformFileDialogHelper() != 0; + nativeDialogInUse = platformFileDialogHelper() != nullptr; if (!nativeDialogInUse) createWidgets(); q->setFileMode(QFileDialog::AnyFile); @@ -3273,7 +3273,7 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) this, SLOT(_q_rowsInserted(QModelIndex))); } - if (proxyModel != 0) { + if (proxyModel != nullptr) { proxyModel->setParent(this); d->proxyModel = proxyModel; proxyModel->setSourceModel(d->model); @@ -3286,13 +3286,13 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel) connect(d->proxyModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_rowsInserted(QModelIndex))); } else { - d->proxyModel = 0; + d->proxyModel = nullptr; d->qFileDialogUi->listView->setModel(d->model); d->qFileDialogUi->treeView->setModel(d->model); #if QT_CONFIG(fscompleter) d->completer->setModel(d->model); d->completer->sourceModel = d->model; - d->completer->proxyModel = 0; + d->completer->proxyModel = nullptr; #endif connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_rowsInserted(QModelIndex))); @@ -3330,27 +3330,27 @@ QAbstractProxyModel *QFileDialog::proxyModel() const void QFileDialogPrivate::createToolButtons() { Q_Q(QFileDialog); - qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, 0, q)); + qFileDialogUi->backButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowBack, nullptr, q)); qFileDialogUi->backButton->setAutoRaise(true); qFileDialogUi->backButton->setEnabled(false); QObject::connect(qFileDialogUi->backButton, SIGNAL(clicked()), q, SLOT(_q_navigateBackward())); - qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, 0, q)); + qFileDialogUi->forwardButton->setIcon(q->style()->standardIcon(QStyle::SP_ArrowForward, nullptr, q)); qFileDialogUi->forwardButton->setAutoRaise(true); qFileDialogUi->forwardButton->setEnabled(false); QObject::connect(qFileDialogUi->forwardButton, SIGNAL(clicked()), q, SLOT(_q_navigateForward())); - qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, 0, q)); + qFileDialogUi->toParentButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogToParent, nullptr, q)); qFileDialogUi->toParentButton->setAutoRaise(true); qFileDialogUi->toParentButton->setEnabled(false); QObject::connect(qFileDialogUi->toParentButton, SIGNAL(clicked()), q, SLOT(_q_navigateToParent())); - qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, 0, q)); + qFileDialogUi->listModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogListView, nullptr, q)); qFileDialogUi->listModeButton->setAutoRaise(true); qFileDialogUi->listModeButton->setDown(true); QObject::connect(qFileDialogUi->listModeButton, SIGNAL(clicked()), q, SLOT(_q_showListView())); - qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, 0, q)); + qFileDialogUi->detailModeButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogDetailedView, nullptr, q)); qFileDialogUi->detailModeButton->setAutoRaise(true); QObject::connect(qFileDialogUi->detailModeButton, SIGNAL(clicked()), q, SLOT(_q_showDetailsView())); @@ -3361,7 +3361,7 @@ void QFileDialogPrivate::createToolButtons() qFileDialogUi->forwardButton->setFixedSize(toolSize); qFileDialogUi->toParentButton->setFixedSize(toolSize); - qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, 0, q)); + qFileDialogUi->newFolderButton->setIcon(q->style()->standardIcon(QStyle::SP_FileDialogNewFolder, nullptr, q)); qFileDialogUi->newFolderButton->setFixedSize(toolSize); qFileDialogUi->newFolderButton->setAutoRaise(true); qFileDialogUi->newFolderButton->setEnabled(false); @@ -3598,7 +3598,7 @@ void QFileDialogPrivate::_q_showContextMenu(const QPoint &position) Q_UNUSED(position); #else Q_Q(QFileDialog); - QAbstractItemView *view = 0; + QAbstractItemView *view = nullptr; if (q->viewMode() == QFileDialog::Detail) view = qFileDialogUi->treeView; else diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 79a7c23e0d..914c845565 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -586,9 +586,9 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const return QModelIndex(); QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index); - Q_ASSERT(indexNode != 0); + Q_ASSERT(indexNode != nullptr); QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent; - if (parentNode == 0 || parentNode == &d->root) + if (parentNode == nullptr || parentNode == &d->root) return QModelIndex(); // get the parent's row @@ -608,7 +608,7 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileSystemNode *node, int column) const { Q_Q(const QFileSystemModel); - QFileSystemModelPrivate::QFileSystemNode *parentNode = (node ? node->parent : 0); + QFileSystemModelPrivate::QFileSystemNode *parentNode = (node ? node->parent : nullptr); if (node == &root || !parentNode) return QModelIndex(); diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 3da829d328..fe8f88d64f 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -276,7 +276,7 @@ void QFontDialogPrivate::init() mainGrid->setColumnMinimumWidth(3, spacing); int margin = 0; - mainGrid->getContentsMargins(0, 0, 0, &margin); + mainGrid->getContentsMargins(nullptr, nullptr, nullptr, &margin); mainGrid->setRowMinimumHeight(3, margin); mainGrid->setRowMinimumHeight(6, 2); @@ -435,7 +435,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) QCoreApplication::sendEvent(d->sizeList, k); if (ci != d->sizeList->currentItem() - && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) + && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this)) d->sizeEdit->selectAll(); return true; } else if ((o == d->familyList || o == d->styleList) && @@ -445,7 +445,7 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e) return true; } } else if (e->type() == QEvent::FocusIn - && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) { + && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, this)) { if (o == d->familyList) d->familyEdit->selectAll(); else if (o == d->styleList) @@ -550,7 +550,7 @@ void QFontDialogPrivate::updateFamilies() else familyList->setCurrentItem(0); familyEdit->setText(familyList->currentText()); - if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) + if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q) && familyList->hasFocus()) familyEdit->selectAll(); @@ -602,7 +602,7 @@ void QFontDialogPrivate::updateStyles() } styleEdit->setText(styleList->currentText()); - if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) + if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q) && styleList->hasFocus()) styleEdit->selectAll(); @@ -641,7 +641,7 @@ void QFontDialogPrivate::updateSizes() const QSignalBlocker blocker(sizeEdit); sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); - if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) + if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q) && sizeList->hasFocus()) sizeEdit->selectAll(); } else { @@ -692,7 +692,7 @@ void QFontDialogPrivate::_q_familyHighlighted(int i) Q_Q(QFontDialog); family = familyList->text(i); familyEdit->setText(family); - if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) + if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q) && familyList->hasFocus()) familyEdit->selectAll(); @@ -709,7 +709,7 @@ void QFontDialogPrivate::_q_styleHighlighted(int index) Q_Q(QFontDialog); QString s = styleList->text(index); styleEdit->setText(s); - if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) + if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q) && styleList->hasFocus()) styleEdit->selectAll(); @@ -728,7 +728,7 @@ void QFontDialogPrivate::_q_sizeHighlighted(int index) Q_Q(QFontDialog); QString s = sizeList->text(index); sizeEdit->setText(s); - if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) + if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, nullptr, q) && sizeEdit->hasFocus()) sizeEdit->selectAll(); @@ -1019,7 +1019,7 @@ void QFontDialog::done(int result) if (d->receiverToDisconnectOnClose) { disconnect(this, SIGNAL(fontSelected(QFont)), d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); - d->receiverToDisconnectOnClose = 0; + d->receiverToDisconnectOnClose = nullptr; } d->memberToDisconnectOnClose.clear(); } diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 3cfe8367e0..1cb4be0682 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -138,7 +138,7 @@ class QInputDialogDoubleSpinBox : public QDoubleSpinBox Q_OBJECT public: - QInputDialogDoubleSpinBox(QWidget *parent = 0) + QInputDialogDoubleSpinBox(QWidget *parent = nullptr) : QDoubleSpinBox(parent) { connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged())); connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged())); @@ -171,7 +171,7 @@ private: class QInputDialogListView : public QListView { public: - QInputDialogListView(QWidget *parent = 0) : QListView(parent) {} + QInputDialogListView(QWidget *parent = nullptr) : QListView(parent) {} QVariant inputMethodQuery(Qt::InputMethodQuery query) const override { if (query == Qt::ImEnabled) @@ -223,8 +223,8 @@ public: }; QInputDialogPrivate::QInputDialogPrivate() - : label(0), buttonBox(0), lineEdit(0), plainTextEdit(0), intSpinBox(0), doubleSpinBox(0), - comboBox(0), listView(0), inputWidget(0), mainLayout(0) + : label(nullptr), buttonBox(nullptr), lineEdit(nullptr), plainTextEdit(nullptr), intSpinBox(nullptr), doubleSpinBox(nullptr), + comboBox(nullptr), listView(nullptr), inputWidget(nullptr), mainLayout(nullptr) { } @@ -1174,7 +1174,7 @@ void QInputDialog::done(int result) if (d->receiverToDisconnectOnClose) { disconnect(this, signalForMember(d->memberToDisconnectOnClose), d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); - d->receiverToDisconnectOnClose = 0; + d->receiverToDisconnectOnClose = nullptr; } d->memberToDisconnectOnClose.clear(); } diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 8dad212692..17d199cb4f 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -97,7 +97,7 @@ public: class TextEdit : public QTextEdit { public: - TextEdit(QWidget *parent=0) : QTextEdit(parent) { } + TextEdit(QWidget *parent=nullptr) : QTextEdit(parent) { } #ifndef QT_NO_CONTEXTMENU void contextMenuEvent(QContextMenuEvent * e) override { @@ -108,7 +108,7 @@ public: #endif // QT_NO_CONTEXTMENU }; - QMessageBoxDetailsText(QWidget *parent=0) + QMessageBoxDetailsText(QWidget *parent=nullptr) : QWidget(parent) , copyAvailable(false) { @@ -197,12 +197,12 @@ class QMessageBoxPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QMessageBox) public: - QMessageBoxPrivate() : escapeButton(0), defaultButton(0), checkbox(0), clickedButton(0), detailsButton(0), + QMessageBoxPrivate() : escapeButton(nullptr), defaultButton(nullptr), checkbox(nullptr), clickedButton(nullptr), detailsButton(nullptr), #if QT_CONFIG(textedit) - detailsText(0), + detailsText(nullptr), #endif compatMode(false), autoAddOkButton(true), - detectedEscapeButton(0), informativeLabel(0), + detectedEscapeButton(nullptr), informativeLabel(nullptr), options(QMessageDialogOptions::create()) { } void init(const QString &title = QString(), const QString &text = QString()); @@ -274,7 +274,7 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) label = new QLabel; label->setObjectName(QLatin1String("qt_msgbox_label")); - label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q))); + label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, q))); label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); label->setOpenExternalLinks(true); iconLabel = new QLabel(q); @@ -283,7 +283,7 @@ void QMessageBoxPrivate::init(const QString &title, const QString &text) buttonBox = new QDialogButtonBox; buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox")); - buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q)); + buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q)); QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), q, SLOT(_q_buttonClicked(QAbstractButton*))); setupLayout(); @@ -927,9 +927,9 @@ void QMessageBox::removeButton(QAbstractButton *button) Q_D(QMessageBox); d->customButtonList.removeAll(button); if (d->escapeButton == button) - d->escapeButton = 0; + d->escapeButton = nullptr; if (d->defaultButton == button) - d->defaultButton = 0; + d->defaultButton = nullptr; d->buttonBox->removeButton(button); d->updateSize(); } @@ -952,9 +952,9 @@ void QMessageBox::setStandardButtons(StandardButtons buttons) QList<QAbstractButton *> buttonList = d->buttonBox->buttons(); if (!buttonList.contains(d->escapeButton)) - d->escapeButton = 0; + d->escapeButton = nullptr; if (!buttonList.contains(d->defaultButton)) - d->defaultButton = 0; + d->defaultButton = nullptr; d->autoAddOkButton = false; d->updateSize(); } @@ -1081,7 +1081,7 @@ void QMessageBoxPrivate::detectEscapeButton() for (auto *button : buttons) { if (buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) { if (detectedEscapeButton) { // already detected! - detectedEscapeButton = 0; + detectedEscapeButton = nullptr; break; } detectedEscapeButton = button; @@ -1094,7 +1094,7 @@ void QMessageBoxPrivate::detectEscapeButton() for (auto *button : buttons) { if (buttonBox->buttonRole(button) == QDialogButtonBox::NoRole) { if (detectedEscapeButton) { // already detected! - detectedEscapeButton = 0; + detectedEscapeButton = nullptr; break; } detectedEscapeButton = button; @@ -1189,7 +1189,7 @@ void QMessageBox::setCheckBox(QCheckBox *cb) d->checkbox->hide(); layout()->removeWidget(d->checkbox); if (d->checkbox->parentWidget() == this) { - d->checkbox->setParent(0); + d->checkbox->setParent(nullptr); d->checkbox->deleteLater(); } } @@ -1433,9 +1433,9 @@ void QMessageBox::changeEvent(QEvent *ev) { if (d->icon != NoIcon) setIcon(d->icon); - Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)); + Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this)); d->label->setTextInteractionFlags(flags); - d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this)); + d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, this)); if (d->informativeLabel) d->informativeLabel->setTextInteractionFlags(flags); Q_FALLTHROUGH(); @@ -1624,7 +1624,7 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent); QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>(); - Q_ASSERT(buttonBox != 0); + Q_ASSERT(buttonBox != nullptr); uint mask = QMessageBox::FirstButton; while (mask <= QMessageBox::LastButton) { @@ -2001,7 +2001,7 @@ QAbstractButton *QMessageBoxPrivate::abstractButtonForId(int id) const if (result) return result; if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly) - return 0; + return nullptr; return q->button(newButton(id)); } @@ -2522,13 +2522,13 @@ void QMessageBox::setDetailedText(const QString &text) d->detailsText->hide(); d->detailsText->deleteLater(); } - d->detailsText = 0; + d->detailsText = nullptr; removeButton(d->detailsButton); if (d->detailsButton) { d->detailsButton->hide(); d->detailsButton->deleteLater(); } - d->detailsButton = 0; + d->detailsButton = nullptr; } else { if (!d->detailsText) { d->detailsText = new QMessageBoxDetailsText(this); @@ -2577,12 +2577,12 @@ void QMessageBox::setInformativeText(const QString &text) d->informativeLabel->hide(); d->informativeLabel->deleteLater(); } - d->informativeLabel = 0; + d->informativeLabel = nullptr; } else { if (!d->informativeLabel) { QLabel *label = new QLabel; label->setObjectName(QLatin1String("qt_msgbox_informativelabel")); - label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this))); + label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this))); label->setAlignment(Qt::AlignTop | Qt::AlignLeft); label->setOpenExternalLinks(true); label->setWordWrap(true); @@ -2644,20 +2644,20 @@ void QMessageBox::setWindowModality(Qt::WindowModality windowModality) QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb) { QStyle *style = mb ? mb->style() : QApplication::style(); - int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb); + int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, mb); QIcon tmpIcon; switch (icon) { case QMessageBox::Information: - tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb); + tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, mb); break; case QMessageBox::Warning: - tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb); + tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, mb); break; case QMessageBox::Critical: - tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb); + tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, mb); break; case QMessageBox::Question: - tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb); + tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb); default: break; } @@ -2739,7 +2739,7 @@ void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHel QPixmap QMessageBox::standardIcon(Icon icon) { - return QMessageBoxPrivate::standardIcon(icon, 0); + return QMessageBoxPrivate::standardIcon(icon, nullptr); } /*! diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 189dcd2989..94d3928c8b 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -65,13 +65,13 @@ class QProgressDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QProgressDialog) public: - QProgressDialogPrivate() : label(0), cancel(0), bar(0), + QProgressDialogPrivate() : label(nullptr), cancel(nullptr), bar(nullptr), shown_once(false), cancellation_flag(false), setValue_called(false), showTime(defaultShowTime), #ifndef QT_NO_SHORTCUT - escapeShortcut(0), + escapeShortcut(nullptr), #endif useDefaultCancelText(false) { @@ -112,7 +112,7 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance label = new QLabel(labelText, q); bar = new QProgressBar(q); bar->setRange(min, max); - int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); + int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, nullptr, q); label->setAlignment(Qt::Alignment(align)); autoClose = true; autoReset = true; @@ -132,12 +132,12 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance void QProgressDialogPrivate::layout() { Q_Q(QProgressDialog); - int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, q); - int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q); - int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q)); - int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q)); + int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, nullptr, q); + int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q); + int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q)); + int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q)); const bool centered = - bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q)); + bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, nullptr, q)); int additionalSpacing = 0; QSize cs = cancel ? cancel->sizeHint() : QSize(0,0); @@ -188,7 +188,7 @@ void QProgressDialogPrivate::_q_disconnectOnClose() if (receiverToDisconnectOnClose) { QObject::disconnect(q, SIGNAL(canceled()), receiverToDisconnectOnClose, memberToDisconnectOnClose); - receiverToDisconnectOnClose = 0; + receiverToDisconnectOnClose = nullptr; } memberToDisconnectOnClose.clear(); } @@ -418,7 +418,7 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton) } else { #ifndef QT_NO_SHORTCUT delete d->escapeShortcut; - d->escapeShortcut = 0; + d->escapeShortcut = nullptr; #endif } d->adoptChildWidget(cancelButton); @@ -450,7 +450,7 @@ void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText q->setCancelButton(new QPushButton(cancelButtonText, q)); } } else { - q->setCancelButton(0); + q->setCancelButton(nullptr); } ensureSizeIsAtLeastSizeHint(); } diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index 2c8c66e1e2..dfb707eda0 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -73,7 +73,7 @@ void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option, Example usage: File dialog sidebar and combo box */ -QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath(false), fileSystemModel(0) +QUrlModel::QUrlModel(QObject *parent) : QStandardItemModel(parent), showFullPath(false), fileSystemModel(nullptr) { } @@ -298,7 +298,7 @@ void QUrlModel::setFileSystemModel(QFileSystemModel *model) { if (model == fileSystemModel) return; - if (fileSystemModel != 0) { + if (fileSystemModel != nullptr) { disconnect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); disconnect(model, SIGNAL(layoutChanged()), @@ -307,7 +307,7 @@ void QUrlModel::setFileSystemModel(QFileSystemModel *model) this, SLOT(layoutChanged())); } fileSystemModel = model; - if (fileSystemModel != 0) { + if (fileSystemModel != nullptr) { connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); connect(model, SIGNAL(layoutChanged()), diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 7c4a473976..a4789f40b1 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -115,7 +115,7 @@ static QWidget *iWantTheFocus(QWidget *ancestor) return candidate; } } - return 0; + return nullptr; } static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, @@ -165,7 +165,7 @@ static const char *changed_signal(int which) }; Q_STATIC_ASSERT(7 == NFallbackDefaultProperties); Q_UNREACHABLE(); - return 0; + return nullptr; } class QWizardDefaultProperty @@ -286,9 +286,9 @@ class QWizardHeader : public QWidget public: enum RulerType { Ruler }; - inline QWizardHeader(RulerType /* ruler */, QWidget *parent = 0) + inline QWizardHeader(RulerType /* ruler */, QWidget *parent = nullptr) : QWidget(parent) { setFixedHeight(2); } - QWizardHeader(QWidget *parent = 0); + QWizardHeader(QWidget *parent = nullptr); void setup(const QWizardLayoutInfo &info, const QString &title, const QString &subTitle, const QPixmap &logo, const QPixmap &banner, @@ -438,7 +438,7 @@ void QWizardHeader::paintEvent(QPaintEvent * /* event */) class QWizardRuler : public QWizardHeader { public: - inline QWizardRuler(QWidget *parent = 0) + inline QWizardRuler(QWidget *parent = nullptr) : QWizardHeader(Ruler, parent) {} }; @@ -684,7 +684,7 @@ void QWizardPrivate::init() std::fill(btns, btns + QWizard::NButtons, nullptr); antiFlickerWidget = new QWizardAntiFlickerWidget(q, this); - wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, 0, q)); + wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, nullptr, q)); if (wizStyle == QWizard::MacStyle) { opts = (QWizard::NoDefaultButton | QWizard::NoCancelButton); } else if (wizStyle == QWizard::ModernStyle) { @@ -836,7 +836,7 @@ void QWizardPrivate::switchToPage(int newId, Direction direction) newPage && newPage->isCommitPage() ? QWizard::CommitButton : QWizard::NextButton; QAbstractButton *nextOrFinishButton = btns[canContinue ? nextOrCommit : QWizard::FinishButton]; - QWidget *candidate = 0; + QWidget *candidate = nullptr; /* If there is no default button and the Next or Finish button @@ -887,7 +887,7 @@ static const char * buttonSlots(QWizard::WizardButton which) case QWizard::NoButton: Q_UNREACHABLE(); }; - return 0; + return nullptr; }; QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() @@ -898,14 +898,14 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() QWizardLayoutInfo info; const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); - info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q); - info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q); - info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, q); - info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q); - info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, titleLabel); - info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, titleLabel); - info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, titleLabel); - info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, titleLabel); + info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q); + info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q); + info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, q); + info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q); + info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, titleLabel); + info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, titleLabel); + info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, titleLabel); + info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, titleLabel); info.hspacing = (layoutHorizontalSpacing == -1) ? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal) : layoutHorizontalSpacing; @@ -959,7 +959,7 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info) for (int i = mainLayout->count() - 1; i >= 0; --i) { QLayoutItem *item = mainLayout->takeAt(i); if (item->layout()) { - item->layout()->setParent(0); + item->layout()->setParent(nullptr); } else { delete item; } @@ -2281,7 +2281,7 @@ void QWizard::removePage(int id) { Q_D(QWizard); - QWizardPage *removedPage = 0; + QWizardPage *removedPage = nullptr; // update startItem accordingly if (d->pageMap.count() > 0) { // only if we have any pages @@ -2792,7 +2792,7 @@ QAbstractButton *QWizard::button(WizardButton which) const return d->vistaHelper->backButton(); #endif if (!d->ensureButton(which)) - return 0; + return nullptr; return d->btns[which]; } diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp index 94188f3485..2eb74ce2a8 100644 --- a/src/widgets/effects/qgraphicseffect.cpp +++ b/src/widgets/effects/qgraphicseffect.cpp @@ -415,7 +415,7 @@ QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent) QGraphicsEffect::~QGraphicsEffect() { Q_D(QGraphicsEffect); - d->setGraphicsEffectSource(0); + d->setGraphicsEffectSource(nullptr); } /*! diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index e1e8175423..637c9c6aba 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -208,7 +208,7 @@ QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate { public: - QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {} + QPixmapConvolutionFilterPrivate(): convolutionKernel(nullptr), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {} ~QPixmapConvolutionFilterPrivate() { delete[] convolutionKernel; } @@ -424,7 +424,7 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q // raster implementation - QImage *target = 0; + QImage *target = nullptr; if (painter->paintEngine()->paintDevice()->devType() == QInternal::Image) { target = static_cast<QImage *>(painter->paintEngine()->paintDevice()); @@ -432,18 +432,18 @@ void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const Q if (mat.type() > QTransform::TxTranslate) { // Disabled because of transformation... - target = 0; + target = nullptr; } else { QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine()); if (pe->clipType() == QRasterPaintEngine::ComplexClip) // disabled because of complex clipping... - target = 0; + target = nullptr; else { QRectF clip = pe->clipBoundingRect(); QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect); QTransform x = painter->deviceTransform(); if (!clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y()))) { - target = 0; + target = nullptr; } } diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp index ea6a8018ca..4f1855a606 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp @@ -353,7 +353,7 @@ void QGraphicsAnchorLayout::addAnchors(QGraphicsLayoutItem *firstItem, bool ok = true; if (orientations & Qt::Horizontal) { // Currently, if the first is ok, then the rest of the calls should be ok - ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != 0; + ok = addAnchor(secondItem, Qt::AnchorLeft, firstItem, Qt::AnchorLeft) != nullptr; if (ok) addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight); } @@ -465,7 +465,7 @@ void QGraphicsAnchorLayout::removeAt(int index) d->removeAnchors(item); d->items.remove(index); - item->setParentLayoutItem(0); + item->setParentLayoutItem(nullptr); invalidate(); } diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 4f44373cad..af0ee3d38c 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32; QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version) - : QObjectPrivate(version), layoutPrivate(0), data(0), + : QObjectPrivate(version), layoutPrivate(nullptr), data(nullptr), sizePolicy(QSizePolicy::Fixed), preferredSize(0), hasSize(true) { @@ -72,7 +72,7 @@ QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate() if (data) { // The QGraphicsAnchor was already deleted at this moment. We must clean // the dangling pointer to avoid double deletion in the AnchorData dtor. - data->graphicsAnchor = 0; + data->graphicsAnchor = nullptr; layoutPrivate->removeAnchor(data->from, data->to); } @@ -631,9 +631,9 @@ QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate() spacings[i] = -1; graphHasConflicts[i] = false; - layoutFirstVertex[i] = 0; - layoutCentralVertex[i] = 0; - layoutLastVertex[i] = 0; + layoutFirstVertex[i] = nullptr; + layoutCentralVertex[i] = nullptr; + layoutLastVertex[i] = nullptr; } } @@ -981,7 +981,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation) feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors); // Update the layout vertex information if one of the vertices is a layout vertex. - AnchorVertex *layoutVertex = 0; + AnchorVertex *layoutVertex = nullptr; if (v->m_item == q) layoutVertex = v; else if (next->m_item == q) @@ -1035,7 +1035,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP QSet<AnchorVertex *> visited; QStack<QPair<AnchorVertex *, AnchorVertex *> > stack; - stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation])); + stack.push(qMakePair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation])); QVector<AnchorVertex*> candidates; // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence) @@ -1384,7 +1384,7 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges() // Save a reference to layout vertices layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft); - layoutCentralVertex[Horizontal] = 0; + layoutCentralVertex[Horizontal] = nullptr; layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight); // Vertical @@ -1395,7 +1395,7 @@ void QGraphicsAnchorLayoutPrivate::createLayoutEdges() // Save a reference to layout vertices layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop); - layoutCentralVertex[Vertical] = 0; + layoutCentralVertex[Vertical] = nullptr; layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom); } @@ -1581,7 +1581,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( } if (item == q) { - layoutCentralVertex[orientation] = 0; + layoutCentralVertex[orientation] = nullptr; } } @@ -1636,29 +1636,29 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *fi qreal *spacing) { Q_Q(QGraphicsAnchorLayout); - if ((firstItem == 0) || (secondItem == 0)) { + if ((firstItem == nullptr) || (secondItem == nullptr)) { qWarning("QGraphicsAnchorLayout::addAnchor(): " "Cannot anchor NULL items"); - return 0; + return nullptr; } if (firstItem == secondItem) { qWarning("QGraphicsAnchorLayout::addAnchor(): " "Cannot anchor the item to itself"); - return 0; + return nullptr; } if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)) { qWarning("QGraphicsAnchorLayout::addAnchor(): " "Cannot anchor edges of different orientations"); - return 0; + return nullptr; } const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem(); if (firstItem == parentWidget || secondItem == parentWidget) { qWarning("QGraphicsAnchorLayout::addAnchor(): " "You cannot add the parent of the layout to the layout."); - return 0; + return nullptr; } // In QGraphicsAnchorLayout, items are represented in its internal @@ -1770,13 +1770,13 @@ QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *fi { // Do not expose internal anchors if (firstItem == secondItem) - return 0; + return nullptr; const Orientation orientation = edgeOrientation(firstEdge); AnchorVertex *v1 = internalVertex(firstItem, firstEdge); AnchorVertex *v2 = internalVertex(secondItem, secondEdge); - QGraphicsAnchor *graphicsAnchor = 0; + QGraphicsAnchor *graphicsAnchor = nullptr; AnchorData *data = graph[orientation].edgeData(v1, v2); if (data) { @@ -1811,7 +1811,7 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex, removeAnchor_helper(firstVertex, secondVertex); // Ensure no dangling pointer is left behind - firstVertex = secondVertex = 0; + firstVertex = secondVertex = nullptr; // Checking if the item stays in the layout or not bool keepFirstItem = false; @@ -2017,13 +2017,13 @@ QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const if (styleInfoDirty) { Q_Q(const QGraphicsAnchorLayout); //### Fix this if QGV ever gets support for Metal style or different Aqua sizes. - QWidget *wid = 0; + QWidget *wid = nullptr; QGraphicsLayoutItem *parent = q->parentLayoutItem(); while (parent && parent->isLayout()) { parent = parent->parentLayoutItem(); } - QGraphicsWidget *w = 0; + QGraphicsWidget *w = nullptr; if (parent) { QGraphicsItem *parentItem = parent->graphicsItem(); if (parentItem && parentItem->isWidget()) @@ -2404,7 +2404,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin // Look for the layout edge. That can be either the first half in case the // layout is split in two, or the whole layout anchor. Orientation orient = Orientation(anchors.first()->orientation); - AnchorData *layoutEdge = 0; + AnchorData *layoutEdge = nullptr; if (layoutCentralVertex[orient]) { layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]); } else { @@ -2423,7 +2423,7 @@ QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHin actualMax = -layoutEdge->minSize; } if (actualMax != expectedMax) { - layoutEdge = 0; + layoutEdge = nullptr; } // For each variable, create constraints based on size hints @@ -2496,8 +2496,8 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation) Q_ASSERT(layoutFirstVertex[orientation] && layoutLastVertex[orientation]); - AnchorData *edgeL1 = 0; - AnchorData *edgeL2 = 0; + AnchorData *edgeL1 = nullptr; + AnchorData *edgeL2 = nullptr; // The layout may have a single anchor between Left and Right or two half anchors // passing through the center @@ -2625,7 +2625,7 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) qreal left; qreal right; - q->getContentsMargins(&left, &top, &right, 0); + q->getContentsMargins(&left, &top, &right, nullptr); const Qt::LayoutDirection visualDir = visualDirection(); if (visualDir == Qt::RightToLeft) qSwap(left, right); diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp index 6b7052a0ab..260e1861c7 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp @@ -137,7 +137,7 @@ QGraphicsGridLayout::~QGraphicsGridLayout() // ~QGraphicsLayoutItem. removeAt(i); if (item) { - item->setParentLayoutItem(0); + item->setParentLayoutItem(nullptr); if (item->ownedByLayout()) delete item; } @@ -535,11 +535,11 @@ QGraphicsLayoutItem *QGraphicsGridLayout::itemAt(int row, int column) const Q_D(const QGraphicsGridLayout); if (row < 0 || row >= rowCount() || column < 0 || column >= columnCount()) { qWarning("QGraphicsGridLayout::itemAt: invalid row, column %d, %d", row, column); - return 0; + return nullptr; } if (QGraphicsGridLayoutEngineItem *engineItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(row, column))) return engineItem->layoutItem(); - return 0; + return nullptr; } /*! @@ -583,7 +583,7 @@ void QGraphicsGridLayout::removeAt(int index) if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index))) { if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) - layoutItem->setParentLayoutItem(0); + layoutItem->setParentLayoutItem(nullptr); d->engine.removeItem(gridItem); // recalculate rowInfo.count if we remove an item that is on the right/bottommost row diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 7c0f836156..6f1eb4b346 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1250,7 +1250,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q if (isWidget) static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && - newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, + newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : nullptr, scene); if (scene) { // Deliver the change to the index @@ -1293,7 +1293,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q // Ensure any last parent focus scope does not point to this item or any of // its descendents. QGraphicsItem *p = parent; - QGraphicsItem *parentFocusScopeItem = 0; + QGraphicsItem *parentFocusScopeItem = nullptr; while (p) { if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { // If this item's focus scope's focus scope item points @@ -1301,7 +1301,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q QGraphicsItem *fsi = p->d_ptr->focusScopeItem; if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { parentFocusScopeItem = fsi; - p->d_ptr->focusScopeItem = 0; + p->d_ptr->focusScopeItem = nullptr; fsi->d_ptr->focusScopeItemChange(false); } break; @@ -1321,7 +1321,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { if (subFocusItem && subFocusItem != q_ptr) { // Find the subFocusItem's topmost focus scope within the new parent's focusscope - QGraphicsItem *ancestorScope = 0; + QGraphicsItem *ancestorScope = nullptr; QGraphicsItem *p2 = subFocusItem->d_ptr->parent; while (p2 && p2 != p) { if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) @@ -1587,7 +1587,7 @@ QGraphicsItem::~QGraphicsItem() if (QAbstractDeclarativeData::destroyed) QAbstractDeclarativeData::destroyed(p->declarativeData, o); } - p->declarativeData = 0; + p->declarativeData = nullptr; p->wasDeleted = false; } } @@ -1607,14 +1607,14 @@ QGraphicsItem::~QGraphicsItem() #endif clearFocus(); - setFocusProxy(0); + setFocusProxy(nullptr); // Update focus scope item ptr. QGraphicsItem *p = d_ptr->parent; while (p) { if (p->flags() & ItemIsFocusScope) { if (p->d_ptr->focusScopeItem == this) - p->d_ptr->focusScopeItem = 0; + p->d_ptr->focusScopeItem = nullptr; break; } p = p->d_ptr->parent; @@ -1630,7 +1630,7 @@ QGraphicsItem::~QGraphicsItem() d_ptr->scene->d_func()->removeItemHelper(this); } else { d_ptr->resetFocusProxy(); - setParentItem(0); + setParentItem(nullptr); } #if QT_CONFIG(graphicseffect) @@ -1639,7 +1639,7 @@ QGraphicsItem::~QGraphicsItem() if (d_ptr->transformData) { for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i); - static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0; + static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = nullptr; delete t; } } @@ -1751,7 +1751,7 @@ QGraphicsWidget *QGraphicsItem::parentWidget() const QGraphicsItem *p = parentItem(); while (p && !p->isWidget()) p = p->parentItem(); - return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0; + return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : nullptr; } /*! @@ -1811,7 +1811,7 @@ QGraphicsItem *QGraphicsItem::panel() const */ QGraphicsObject *QGraphicsItem::toGraphicsObject() { - return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0; + return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : nullptr; } /*! @@ -1822,7 +1822,7 @@ QGraphicsObject *QGraphicsItem::toGraphicsObject() */ const QGraphicsObject *QGraphicsItem::toGraphicsObject() const { - return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0; + return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : nullptr; } /*! @@ -2224,7 +2224,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const return false; - QGraphicsItem *dummy = 0; + QGraphicsItem *dummy = nullptr; if (!blockingPanel) blockingPanel = &dummy; @@ -2420,7 +2420,7 @@ bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const if (p->d_ptr->explicitlyHidden) return false; } while ((p = p->d_ptr->parent)); - return parent == 0; + return parent == nullptr; } /*! @@ -2959,7 +2959,7 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) if (d_ptr->graphicsEffect) { delete d_ptr->graphicsEffect; - d_ptr->graphicsEffect = 0; + d_ptr->graphicsEffect = nullptr; } else if (d_ptr->parent) { d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); } @@ -2984,7 +2984,7 @@ void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() if (itemPrivate->mayHaveChildWithGraphicsEffect) return; itemPrivate->mayHaveChildWithGraphicsEffect = 1; - } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); + } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : nullptr)); #endif } @@ -3396,13 +3396,13 @@ void QGraphicsItem::setActive(bool active) if (!activePanel || activePanel == thisPanel) { // Deactivate this item, and reactivate the parent panel, // or the last active panel (if any). - QGraphicsItem *nextToActivate = 0; + QGraphicsItem *nextToActivate = nullptr; if (d_ptr->parent) nextToActivate = d_ptr->parent->panel(); if (!nextToActivate) nextToActivate = d_ptr->scene->d_func()->lastActivePanel; if (nextToActivate == this || isAncestorOf(nextToActivate)) - nextToActivate = 0; + nextToActivate = nullptr; d_ptr->scene->setActivePanel(nextToActivate); } } @@ -3499,7 +3499,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim } // Update the child focus chain. - QGraphicsItem *commonAncestor = 0; + QGraphicsItem *commonAncestor = nullptr; if (scene && scene->focusItem() && scene->focusItem()->panel() == q_ptr->panel()) { commonAncestor = scene->focusItem()->commonAncestorItem(f); scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor); @@ -3552,7 +3552,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { if (p->d_ptr->focusScopeItem == q_ptr) { - p->d_ptr->focusScopeItem = 0; + p->d_ptr->focusScopeItem = nullptr; if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere focusScopeItemChange(false); } @@ -3572,7 +3572,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenB clearSubFocus(q_ptr); // If this item has the scene's input focus, clear it. - scene->setFocusItem(0); + scene->setFocusItem(nullptr); } } @@ -3621,7 +3621,7 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item) qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene"); return; } - for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) { + for (QGraphicsItem *f = item->focusProxy(); f != nullptr; f = f->focusProxy()) { if (f == this) { qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item); return; @@ -4452,7 +4452,7 @@ QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) c QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const { // Catch simple cases first. - if (other == 0) { + if (other == nullptr) { qWarning("QGraphicsItem::itemTransform: null pointer passed"); return QTransform(); } @@ -4892,7 +4892,7 @@ void QGraphicsItem::stackBefore(const QGraphicsItem *sibling) } QList<QGraphicsItem *> *siblings = d_ptr->parent ? &d_ptr->parent->d_ptr->children - : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0); + : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : nullptr); if (!siblings) { qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling); return; @@ -4949,7 +4949,7 @@ QRectF QGraphicsItem::childrenBoundingRect() const return d_ptr->childrenBoundingRect; d_ptr->childrenBoundingRect = QRectF(); - d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0); + d_ptr->childrenBoundingRectHelper(nullptr, &d_ptr->childrenBoundingRect, nullptr); d_ptr->dirtyChildrenBoundingRect = 0; return d_ptr->childrenBoundingRect; } @@ -5422,7 +5422,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c // Render QStyleOptionGraphicsItem option; - const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0); + const_cast<QGraphicsItem *>(this)->paint(&p, &option, nullptr); p.end(); // Transform QRegion back to device space @@ -5575,7 +5575,7 @@ void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() if (!itemPrivate->updateDueToGraphicsEffect) static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); } - } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); + } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : nullptr)); } void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) @@ -5739,7 +5739,7 @@ void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMost if (*topMostDirtyItem == q_ptr) { if (!dirtySceneTransform) return; // OK, neither my ancestors nor I have dirty scene transforms. - *topMostDirtyItem = 0; + *topMostDirtyItem = nullptr; } else if (*topMostDirtyItem) { return; // Continue backtrack. } @@ -5771,7 +5771,7 @@ void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *s if (parent != q_ptr && parent->d_ptr->subFocusItem) { if (parent->d_ptr->subFocusItem == q_ptr) break; - parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem); + parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(nullptr, stopItem); } parent->d_ptr->subFocusItem = q_ptr; parent->d_ptr->subFocusItemChange(); @@ -5793,7 +5793,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem do { if (parent->d_ptr->subFocusItem != q_ptr) break; - parent->d_ptr->subFocusItem = 0; + parent->d_ptr->subFocusItem = nullptr; if (parent != stopItem && !parent->isAncestorOf(stopItem)) parent->d_ptr->subFocusItemChange(); } while (!parent->isPanel() && (parent = parent->d_ptr->parent)); @@ -5808,7 +5808,7 @@ void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem void QGraphicsItemPrivate::resetFocusProxy() { for (int i = 0; i < focusProxyRefs.size(); ++i) - *focusProxyRefs.at(i) = 0; + *focusProxyRefs.at(i) = nullptr; focusProxyRefs.clear(); } @@ -7322,7 +7322,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } // Find the active view. - QGraphicsView *view = 0; + QGraphicsView *view = nullptr; if (event->widget()) view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget()); @@ -7330,7 +7330,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) int i = 0; bool movedMe = false; while (i <= selectedItems.size()) { - QGraphicsItem *item = 0; + QGraphicsItem *item = nullptr; if (i < selectedItems.size()) item = selectedItems.at(i); else @@ -7891,7 +7891,7 @@ void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObj if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { item->setParentItem(graphicsObject); } else { - QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0); + QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, nullptr, nullptr); } } } @@ -7908,7 +7908,7 @@ QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGra if (index >= 0 && index < d->children.count()) return d->children.at(index)->toGraphicsObject(); else - return 0; + return nullptr; } void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) @@ -7917,10 +7917,10 @@ void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObje int childCount = d->children.count(); if (d->sendParentChangeNotification) { for (int index = 0; index < childCount; index++) - d->children.at(0)->setParentItem(0); + d->children.at(0)->setParentItem(nullptr); } else { for (int index = 0; index < childCount; index++) - QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0); + QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(nullptr, nullptr, nullptr); } } @@ -9949,7 +9949,7 @@ class QGraphicsTextItemPrivate { public: QGraphicsTextItemPrivate() - : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0) + : control(nullptr), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0) { } mutable QWidgetTextControl *control; @@ -11232,7 +11232,7 @@ void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item) // ### Expensive, we could maybe use dirtySceneTransform bit for optimization item->setTransform(itemTransform); - item->d_func()->setIsMemberOfGroup(item->group() != 0); + item->d_func()->setIsMemberOfGroup(item->group() != nullptr); // ### Quite expensive. But removeFromGroup() isn't called very often. prepareGeometryChange(); @@ -11412,18 +11412,18 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP QTransform sceneTransform = item->sceneTransform(); QTransform newEffectTransform = sceneTransform.inverted(); newEffectTransform *= effectTransform; - scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0), + scened->draw(item, &pixmapPainter, nullptr, &sceneTransform, nullptr, nullptr, qreal(1.0), &newEffectTransform, false, true); } else if (deviceCoordinates) { // Device coordinates with info. - scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, + scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, nullptr, info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, info->drawItem); } else { // Item coordinates with info. QTransform newEffectTransform = info->transformPtr->inverted(); newEffectTransform *= effectTransform; - scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, + scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, nullptr, info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform, info->drawItem); } diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index ad77e2f260..1c5dbf265c 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -106,7 +106,7 @@ class QGraphicsItemAnimationPrivate { public: inline QGraphicsItemAnimationPrivate() - : q(0), timeLine(0), item(0), step(0) + : q(nullptr), timeLine(nullptr), item(nullptr), step(0) { } QGraphicsItemAnimation *q; diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp index 59ed7acd72..c10763d065 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp @@ -97,7 +97,7 @@ void QGraphicsLayoutPrivate::getMargin(qreal *result, qreal userMargin, QStyle:: *result = 0.0; if (QGraphicsItem *layoutParentItem = parentItem()) { if (layoutParentItem->isWidget()) - *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, 0); + *result = (qreal)static_cast<QGraphicsWidget*>(layoutParentItem)->style()->pixelMetric(pm, nullptr); } } } diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp index 1192bad51e..8694dcb36b 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp @@ -105,7 +105,7 @@ static void normalizeHints(qreal &minimum, qreal &preferred, qreal &maximum, qre \internal */ QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par, bool layout) - : parent(par), userSizeHints(0), isLayout(layout), ownedByLayout(false), graphicsItem(0) + : parent(par), userSizeHints(nullptr), isLayout(layout), ownedByLayout(false), graphicsItem(nullptr) { } diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp index da2510a8cb..2f1526cc78 100644 --- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE QGraphicsLayoutStyleInfo::QGraphicsLayoutStyleInfo(const QGraphicsLayoutPrivate *layout) - : m_layout(layout), m_style(0) + : m_layout(layout), m_style(nullptr) { m_widget.reset(new QWidget); // pixelMetric might need a widget ptr m_styleOption.initFrom(m_widget.get()); diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index 22633df4e3..f76cc61586 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -211,7 +211,7 @@ QGraphicsLinearLayout::~QGraphicsLinearLayout() // ~QGraphicsLayoutItem. removeAt(i); if (item) { - item->setParentLayoutItem(0); + item->setParentLayoutItem(nullptr); if (item->ownedByLayout()) delete item; } @@ -310,7 +310,7 @@ void QGraphicsLinearLayout::removeItem(QGraphicsLayoutItem *item) { Q_D(QGraphicsLinearLayout); if (QGraphicsGridLayoutEngineItem *gridItem = d->engine.findLayoutItem(item)) { - item->setParentLayoutItem(0); + item->setParentLayoutItem(nullptr); d->removeGridItem(gridItem); delete gridItem; invalidate(); @@ -333,7 +333,7 @@ void QGraphicsLinearLayout::removeAt(int index) if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem*>(d->engine.itemAt(index))) { if (QGraphicsLayoutItem *layoutItem = gridItem->layoutItem()) - layoutItem->setParentLayoutItem(0); + layoutItem->setParentLayoutItem(nullptr); d->removeGridItem(gridItem); delete gridItem; invalidate(); @@ -483,9 +483,9 @@ QGraphicsLayoutItem *QGraphicsLinearLayout::itemAt(int index) const Q_D(const QGraphicsLinearLayout); if (index < 0 || index >= d->engine.itemCount()) { qWarning("QGraphicsLinearLayout::itemAt: invalid index %d", index); - return 0; + return nullptr; } - QGraphicsLayoutItem *item = 0; + QGraphicsLayoutItem *item = nullptr; if (QGraphicsGridLayoutEngineItem *gridItem = static_cast<QGraphicsGridLayoutEngineItem *>(d->engine.itemAt(index))) item = gridItem->layoutItem(); return item; diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index c60dca7a90..4d4958c674 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -291,7 +291,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent } if (!lastWidgetUnderMouse) { - QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0, event->screenPos()); + QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, nullptr, event->screenPos()); lastWidgetUnderMouse = receiver; } @@ -315,10 +315,10 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent if (q->rect().contains(event->pos()) && q->acceptHoverEvents()) lastWidgetUnderMouse = alienWidget ? alienWidget : widget; else // released on the frame our outside the item, or doesn't accept hover events. - lastWidgetUnderMouse = 0; + lastWidgetUnderMouse = nullptr; QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber, event->screenPos()); - embeddedMouseGrabber = 0; + embeddedMouseGrabber = nullptr; #ifndef QT_NO_CURSOR // ### Restore the cursor, don't override it. @@ -368,7 +368,7 @@ void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::Focu QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const { if (!widget) - return 0; + return nullptr; // Run around the focus chain until we find a widget that can take tab focus. if (!child) { @@ -376,12 +376,12 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) } else { child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) { - return 0; + return nullptr; } } if (!child) - return 0; + return nullptr; QWidget *oldChild = child; uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus; @@ -394,7 +394,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) } child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev)); - return 0; + return nullptr; } /*! @@ -405,9 +405,9 @@ void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot() Q_Q(QGraphicsProxyWidget); if (!widget.isNull()) { if (const auto &extra = widget->d_func()->extra) - extra->proxyWidget = 0; + extra->proxyWidget = nullptr; } - widget = 0; + widget = nullptr; delete q; } @@ -430,7 +430,7 @@ void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget() QRectF widgetGeometry = widget->geometry(); QWidget *parentWidget = widget->parentWidget(); if (widget->isWindow()) { - QGraphicsProxyWidget *proxyParent = 0; + QGraphicsProxyWidget *proxyParent = nullptr; if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) { // Nested window proxy (e.g., combobox popup), map widget to the // parent widget's global coordinates, and map that to the parent @@ -497,7 +497,7 @@ void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin) if (child->isWidget()) { if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) { if (proxy->widget() == subWin) { - proxy->setWidget(0); + proxy->setWidget(nullptr); scene->removeItem(proxy); delete proxy; return; @@ -598,7 +598,7 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot())); widget->removeEventFilter(q); widget->setAttribute(Qt::WA_DontShowOnScreen, false); - widget->d_func()->extra->proxyWidget = 0; + widget->d_func()->extra->proxyWidget = nullptr; resolveFont(inheritedFontResolveMask); resolvePalette(inheritedPaletteResolveMask); widget->update(); @@ -1081,7 +1081,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) return; QDragLeaveEvent proxyDragLeave; QCoreApplication::sendEvent(d->dragDropWidget, &proxyDragLeave); - d->dragDropWidget = 0; + d->dragDropWidget = nullptr; #endif } @@ -1143,7 +1143,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) // Leave the last drag drop item QDragLeaveEvent dragLeave; QCoreApplication::sendEvent(d->dragDropWidget, &dragLeave); - d->dragDropWidget = 0; + d->dragDropWidget = nullptr; } // Propagate event->setDropAction(Qt::IgnoreAction); @@ -1165,7 +1165,7 @@ void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event) QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); QCoreApplication::sendEvent(d->dragDropWidget, &dropEvent); event->setAccepted(dropEvent.isAccepted()); - d->dragDropWidget = 0; + d->dragDropWidget = nullptr; } #endif } @@ -1188,8 +1188,8 @@ void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_D(QGraphicsProxyWidget); // If hoverMove was compressed away, make sure we update properly here. if (d->lastWidgetUnderMouse) { - QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos()); - d->lastWidgetUnderMouse = 0; + QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos()); + d->lastWidgetUnderMouse = nullptr; } } @@ -1205,13 +1205,13 @@ void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event) // Ignore events on the window frame. if (!d->widget || !rect().contains(event->pos())) { if (d->lastWidgetUnderMouse) { - QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse, event->screenPos()); - d->lastWidgetUnderMouse = 0; + QApplicationPrivate::dispatchEnterLeave(nullptr, d->lastWidgetUnderMouse, event->screenPos()); + d->lastWidgetUnderMouse = nullptr; } return; } - d->embeddedMouseGrabber = 0; + d->embeddedMouseGrabber = nullptr; d->sendWidgetMouseEvent(event); } @@ -1230,7 +1230,7 @@ void QGraphicsProxyWidget::ungrabMouseEvent(QEvent *event) { Q_D(QGraphicsProxyWidget); Q_UNUSED(event); - d->embeddedMouseGrabber = 0; + d->embeddedMouseGrabber = nullptr; } /*! @@ -1372,12 +1372,12 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event) switch (event->reason()) { case Qt::TabFocusReason: { - if (QWidget *focusChild = d->findFocusChild(0, true)) + if (QWidget *focusChild = d->findFocusChild(nullptr, true)) focusChild->setFocus(event->reason()); break; } case Qt::BacktabFocusReason: - if (QWidget *focusChild = d->findFocusChild(0, false)) + if (QWidget *focusChild = d->findFocusChild(nullptr, false)) focusChild->setFocus(event->reason()); break; default: @@ -1578,16 +1578,16 @@ QGraphicsProxyWidget *QGraphicsProxyWidget::createProxyForChildWidget(QWidget *c return proxy; if (!child->parentWidget()) { qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene"); - return 0; + return nullptr; } QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget()); if (!parentProxy) - return 0; + return nullptr; if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection, Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child))) - return 0; + return nullptr; proxy->setParent(parentProxy); proxy->setWidget(child); return proxy; diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index d641d17232..1c6e68def1 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -278,7 +278,7 @@ static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraph */ QGraphicsScenePrivate::QGraphicsScenePrivate() : indexMethod(QGraphicsScene::BspTreeIndex), - index(0), + index(nullptr), lastItemCount(0), hasSceneRect(false), dirtyGrowingItemsBoundingRect(true), @@ -301,19 +301,19 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() minimumRenderSize(0.0), selectionChanging(0), rectAdjust(2), - focusItem(0), - lastFocusItem(0), - passiveFocusItem(0), - tabFocusFirst(0), - activePanel(0), - lastActivePanel(0), + focusItem(nullptr), + lastFocusItem(nullptr), + passiveFocusItem(nullptr), + tabFocusFirst(nullptr), + activePanel(nullptr), + lastActivePanel(nullptr), activationRefCount(0), childExplicitActivation(0), - lastMouseGrabberItem(0), - dragDropItem(0), - enterWidget(0), + lastMouseGrabberItem(nullptr), + dragDropItem(nullptr), + enterWidget(nullptr), lastDropAction(Qt::IgnoreAction), - style(0) + style(nullptr) { } @@ -443,8 +443,8 @@ void QGraphicsScenePrivate::_q_polishItems() return; const QVariant booleanTrueVariant(true); - QGraphicsItem *item = 0; - QGraphicsItemPrivate *itemd = 0; + QGraphicsItem *item = nullptr; + QGraphicsItemPrivate *itemd = nullptr; const int oldUnpolishedCount = unpolishedItems.count(); for (int i = 0; i < oldUnpolishedCount; ++i) { @@ -602,7 +602,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) unregisterScenePosItem(item); QGraphicsScene *oldScene = item->d_func()->scene; - item->d_func()->scene = 0; + item->d_func()->scene = nullptr; //We need to remove all children first because they might use their parent //attributes (e.g. sceneTransform). @@ -614,7 +614,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (!item->d_ptr->inDestructor && !item->parentItem() && item->isWidget()) { QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); - widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0); + widget->d_func()->fixFocusChainBeforeReparenting(nullptr, oldScene, nullptr); } // Unregister focus proxy. @@ -625,7 +625,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (parentItem->scene()) { Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem", "Parent item's scene is different from this item's scene"); - item->setParentItem(0); + item->setParentItem(nullptr); } } else { unregisterTopLevelItem(item); @@ -633,17 +633,17 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) // Reset the mouse grabber and focus item data. if (item == focusItem) - focusItem = 0; + focusItem = nullptr; if (item == lastFocusItem) - lastFocusItem = 0; + lastFocusItem = nullptr; if (item == passiveFocusItem) - passiveFocusItem = 0; + passiveFocusItem = nullptr; if (item == activePanel) { // ### deactivate... - activePanel = 0; + activePanel = nullptr; } if (item == lastActivePanel) - lastActivePanel = 0; + lastActivePanel = nullptr; // Change tabFocusFirst to the next widget in focus chain if removing the current one. if (item == tabFocusFirst) { @@ -651,7 +651,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (wd->focusNext && wd->focusNext != tabFocusFirst && wd->focusNext->scene() == q) tabFocusFirst = wd->focusNext; else - tabFocusFirst = 0; + tabFocusFirst = nullptr; } // Cancel active touches @@ -705,11 +705,11 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) // Reset the last mouse grabber item if (item == lastMouseGrabberItem) - lastMouseGrabberItem = 0; + lastMouseGrabberItem = nullptr; // Reset the current drop item if (item == dragDropItem) - dragDropItem = 0; + dragDropItem = nullptr; // Reenable selectionChanged() for individual items --selectionChanging; @@ -752,8 +752,8 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin q->setFocus(Qt::ActiveWindowFocusReason); // Find the item's panel. - QGraphicsItem *panel = item ? item->panel() : 0; - lastActivePanel = panel ? activePanel : 0; + QGraphicsItem *panel = item ? item->panel() : nullptr; + lastActivePanel = panel ? activePanel : nullptr; if (panel == activePanel || (!q->isActive() && !duringActivationEvent)) return; @@ -764,7 +764,7 @@ void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool durin if (QGraphicsItem *fi = activePanel->focusItem()) { // Remove focus from the current focus item. if (fi == q->focusItem()) - setFocusItemHelper(0, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false); + setFocusItemHelper(nullptr, Qt::ActiveWindowFocusReason, /* emitFocusChanged = */ false); } QEvent event(QEvent::WindowDeactivate); @@ -841,7 +841,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, // accept input focus. if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable) || !item->isVisible() || !item->isEnabled())) { - item = 0; + item = nullptr; } // Set focus on the scene if an item requests focus. @@ -849,7 +849,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, q->setFocus(focusReason); if (item == focusItem) { if (emitFocusChanged) - emit q->focusItemChanged(focusItem, (QGraphicsItem *)0, focusReason); + emit q->focusItemChanged(focusItem, (QGraphicsItem *)nullptr, focusReason); return; } } @@ -869,7 +869,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, } #endif //QT_NO_IM - focusItem = 0; + focusItem = nullptr; QFocusEvent event(QEvent::FocusOut, focusReason); sendEvent(lastFocusItem, &event); } @@ -877,7 +877,7 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, // This handles the case that the item has been removed from the // scene in response to the FocusOut event. if (item && item->scene() != q) - item = 0; + item = nullptr; if (item) focusItem = item; @@ -1039,7 +1039,7 @@ void QGraphicsScenePrivate::clearMouseGrabber() { if (!mouseGrabberItems.isEmpty()) mouseGrabberItems.first()->ungrabMouse(); - lastMouseGrabberItem = 0; + lastMouseGrabberItem = nullptr; } /*! @@ -1365,10 +1365,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // Update window activation. QGraphicsItem *topItem = cachedItemsUnderMouse.value(0); - QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0; + QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : nullptr; if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) { // pass activation to the blocking modal window - newActiveWindow = topItem ? topItem->window() : 0; + newActiveWindow = topItem ? topItem->window() : nullptr; } if (newActiveWindow != q->activeWindow()) @@ -1409,7 +1409,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // If nobody could take focus, clear it. if (!stickyFocus && !setFocus && !sceneModality) - q->setFocusItem(0, Qt::MouseFocusReason); + q->setFocusItem(nullptr, Qt::MouseFocusReason); // Any item will do. if (sceneModality && cachedItemsUnderMouse.isEmpty()) @@ -1694,7 +1694,7 @@ QGraphicsScene::~QGraphicsScene() // Remove this scene from all associated views. for (int j = 0; j < d->views.size(); ++j) - d->views.at(j)->setScene(0); + d->views.at(j)->setScene(nullptr); } /*! @@ -2432,7 +2432,7 @@ QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> } // Find the common ancestor for all items - QGraphicsItem *commonAncestor = 0; + QGraphicsItem *commonAncestor = nullptr; if (!ancestors.isEmpty()) { while (n < items.size()) { int commonIndex = -1; @@ -2446,7 +2446,7 @@ QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> } while ((parent = parent->parentItem())); if (commonIndex == -1) { - commonAncestor = 0; + commonAncestor = nullptr; break; } @@ -2545,7 +2545,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // from this scene. if (QGraphicsItem *itemParent = item->d_ptr->parent) { if (itemParent->d_ptr->scene != this) - item->setParentItem(0); + item->setParentItem(nullptr); } // Add the item to this scene @@ -2911,7 +2911,7 @@ QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, cons */ QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags) { - QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags); + QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(nullptr, wFlags); proxy->setWidget(widget); addItem(proxy); return proxy; @@ -2944,7 +2944,7 @@ void QGraphicsScene::removeItem(QGraphicsItem *item) const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange, QVariant::fromValue<QGraphicsScene *>(0))); QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant); - if (targetScene != 0 && targetScene != this) { + if (targetScene != nullptr && targetScene != this) { targetScene->addItem(item); return; } @@ -3046,7 +3046,7 @@ void QGraphicsScene::clearFocus() if (d->hasFocus) { d->hasFocus = false; d->passiveFocusItem = d->focusItem; - setFocusItem(0, Qt::OtherFocusReason); + setFocusItem(nullptr, Qt::OtherFocusReason); } } @@ -3492,7 +3492,7 @@ bool QGraphicsScene::event(QEvent *event) // Deactivate the active panel (but keep it so we can // reactivate it later). QGraphicsItem *lastActivePanel = d->activePanel; - d->setActivePanelHelper(0, true); + d->setActivePanelHelper(nullptr, true); d->lastActivePanel = lastActivePanel; } else { // Activate all toplevel items. @@ -3621,7 +3621,7 @@ void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMen void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { Q_D(QGraphicsScene); - d->dragDropItem = 0; + d->dragDropItem = nullptr; d->lastDropAction = Qt::IgnoreAction; event->accept(); } @@ -3705,7 +3705,7 @@ void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event) QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave); d->cloneDragDropEvent(&dragLeave, event); d->sendDragDropEvent(d->dragDropItem, &dragLeave); - d->dragDropItem = 0; + d->dragDropItem = nullptr; } // Propagate event->setDropAction(Qt::IgnoreAction); @@ -3725,7 +3725,7 @@ void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) if (d->dragDropItem) { // Leave the last drag drop item d->sendDragDropEvent(d->dragDropItem, event); - d->dragDropItem = 0; + d->dragDropItem = nullptr; } } @@ -3743,7 +3743,7 @@ void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event) if (d->dragDropItem) { // Drop on the last drag drop item d->sendDragDropEvent(d->dragDropItem, event); - d->dragDropItem = 0; + d->dragDropItem = nullptr; } } @@ -3793,7 +3793,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent) Q_D(QGraphicsScene); d->hasFocus = false; d->passiveFocusItem = d->focusItem; - setFocusItem(0, focusEvent->reason()); + setFocusItem(nullptr, focusEvent->reason()); // Remove all popups when the scene loses focus. if (!d->popupWidgets.isEmpty()) @@ -3825,7 +3825,7 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(), helpEvent->scenePos(), helpEvent->widget()); - QGraphicsItem *toolTipItem = 0; + QGraphicsItem *toolTipItem = nullptr; for (int i = 0; i < itemsAtPos.size(); ++i) { QGraphicsItem *tmp = itemsAtPos.at(i); if (tmp->d_func()->isProxyWidget()) { @@ -3883,7 +3883,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv hoverEvent->widget()); } - QGraphicsItem *item = 0; + QGraphicsItem *item = nullptr; for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) { QGraphicsItem *tmp = cachedItemsUnderMouse.at(i); if (itemAcceptsHoverEvents_helper(tmp)) { @@ -3894,13 +3894,13 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv // Find the common ancestor item for the new topmost hoverItem and the // last item in the hoverItem list. - QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : 0; + QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : nullptr; while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem)) commonAncestorItem = commonAncestorItem->parentItem(); if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) { // The common ancestor isn't in the same panel as the two hovered // items. - commonAncestorItem = 0; + commonAncestorItem = nullptr; } // Check if the common ancestor item is known. @@ -4130,7 +4130,7 @@ void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) if (d->lastMouseGrabberItemHasImplicitMouseGrab) d->mouseGrabberItems.constLast()->ungrabMouse(); } else { - d->lastMouseGrabberItem = 0; + d->lastMouseGrabberItem = nullptr; } // Generate a hoverevent @@ -4362,7 +4362,7 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & pixmapPainter.setWorldTransform(itemToPixmap, true); // Render. - _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection); + _q_paintItem(item, &pixmapPainter, option, nullptr, false, painterStateProtection); pixmapPainter.end(); if (!subPix.isNull()) { @@ -4756,7 +4756,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * return; QTransform transform(Qt::Uninitialized); - QTransform *transformPtr = 0; + QTransform *transformPtr = nullptr; bool translateOnlyTransform = false; #define ENSURE_TRANSFORM_PTR \ if (!transformPtr) { \ @@ -4866,7 +4866,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * item->d_ptr->graphicsEffect->draw(painter); painter->setWorldTransform(restoreTransform); - sourced->info = 0; + sourced->info = nullptr; } else #endif // QT_CONFIG(graphicseffect) { @@ -4944,7 +4944,7 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents)); Q_ASSERT(transformPtr); item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion - ? *exposedRegion : QRegion(), exposedRegion == 0); + ? *exposedRegion : QRegion(), exposedRegion == nullptr); const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape; bool restorePainterClip = false; @@ -5330,7 +5330,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool if (itemClipsChildrenToShape) { // Reset updateClip. for (int i = 0; i < views.size(); ++i) - views.at(i)->d_func()->setUpdateClip(0); + views.at(i)->d_func()->setUpdateClip(nullptr); } } else if (wasDirtyParentSceneTransform) { item->d_ptr->invalidateChildrenSceneTransform(); @@ -5386,7 +5386,7 @@ void QGraphicsScene::drawItems(QPainter *painter, // Determine view, expose and flags. QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0; - QRegion *expose = 0; + QRegion *expose = nullptr; const quint32 oldRectAdjust = d->rectAdjust; if (view) { d->updateAll = false; @@ -5470,7 +5470,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next) } // The item must be a widget. - QGraphicsWidget *widget = 0; + QGraphicsWidget *widget = nullptr; if (!item) { widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev; } else { @@ -5486,7 +5486,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next) // Run around the focus chain until we find a widget that can take tab focus. do { if (widget->flags() & QGraphicsItem::ItemIsFocusable - && widget->isEnabled() && widget->isVisibleTo(0) + && widget->isEnabled() && widget->isVisibleTo(nullptr) && (widget->focusPolicy() & Qt::TabFocus) && (!item || !item->isPanel() || item->isAncestorOf(widget)) ) { @@ -5771,7 +5771,7 @@ void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget) } // Activate the widget's panel (all windows are panels). - QGraphicsItem *panel = widget ? widget->panel() : 0; + QGraphicsItem *panel = widget ? widget->panel() : nullptr; setActivePanel(panel); // Raise @@ -5953,7 +5953,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i); // update state - QGraphicsItem *item = 0; + QGraphicsItem *item = nullptr; if (touchPoint.state() == Qt::TouchPointPressed) { if (sceneTouchEvent->device()->type() == QTouchDevice::TouchPad) { // on touch-pad devices, send all touch points to the same item @@ -6111,7 +6111,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve // If nobody could take focus, clear it. if (!stickyFocus && !setFocus) - q->setFocusItem(0, Qt::MouseFocusReason); + q->setFocusItem(nullptr, Qt::MouseFocusReason); } bool res = false; @@ -6125,7 +6125,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve eventAccepted = touchEvent->isAccepted(); if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) { // item was deleted - item = 0; + item = nullptr; } else { item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted); } @@ -6259,7 +6259,7 @@ void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &ges if (!gesture->hasHotSpot()) continue; const Qt::GestureType gestureType = gesture->gestureType(); - QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0); + QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, nullptr); for (int j = 0; j < items.size(); ++j) { QGraphicsItem *item = items.at(j); @@ -6331,7 +6331,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) if (!startedGestures.isEmpty()) { QSet<QGesture *> normalGestures; // that have just one target QSet<QGesture *> conflictedGestures; // that have multiple possible targets - gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0, + gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, nullptr, &normalGestures, &conflictedGestures); cachedTargetItems = cachedItemGestures.keys(); std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); @@ -6505,7 +6505,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) } gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures, - &cachedItemGestures, &targetsSet, 0, 0); + &cachedItemGestures, &targetsSet, nullptr, nullptr); cachedTargetItems = targetsSet.values(); std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); @@ -6545,7 +6545,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) { Q_ASSERT(original); QGraphicsItem *originalItem = gestureTargets.value(original); - if (originalItem == 0) // we only act on accepted gestures, which implies it has a target. + if (originalItem == nullptr) // we only act on accepted gestures, which implies it has a target. return; // iterate over all active gestures and for each find the owner @@ -6568,13 +6568,13 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) QSet<QGesture *> almostCanceledGestures = canceledGestures; QSet<QGesture *>::Iterator setIter; while (!almostCanceledGestures.isEmpty()) { - QGraphicsObject *target = 0; + QGraphicsObject *target = nullptr; QSet<QGesture*> gestures; setIter = almostCanceledGestures.begin(); // sort per target item while (setIter != almostCanceledGestures.end()) { QGraphicsObject *item = gestureTargets.value(*setIter); - if (target == 0) + if (target == nullptr) target = item; if (target == item) { gestures << *setIter; @@ -6598,7 +6598,7 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) if (!g->hasHotSpot()) continue; - QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0); + QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, nullptr); for (int j = 0; j < items.size(); ++j) { QGraphicsObject *item = items.at(j)->toGraphicsObject(); if (!item) diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index 768dd07d4e..048ea6dc7d 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -278,8 +278,8 @@ class QGraphicsSceneEventPrivate { public: inline QGraphicsSceneEventPrivate() - : widget(0), - q_ptr(0) + : widget(nullptr), + q_ptr(nullptr) { } inline virtual ~QGraphicsSceneEventPrivate() @@ -1290,7 +1290,7 @@ class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent) public: inline QGraphicsSceneDragDropEventPrivate() - : source(0), mimeData(0) + : source(nullptr), mimeData(nullptr) { } QPointF pos; diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp index 0f0d9aaddc..fa763de05d 100644 --- a/src/widgets/graphicsview/qgraphicstransform.cpp +++ b/src/widgets/graphicsview/qgraphicstransform.cpp @@ -112,7 +112,7 @@ void QGraphicsTransformPrivate::setItem(QGraphicsItem *i) Q_ASSERT(d_ptr->transformData); d_ptr->transformData->graphicsTransforms.removeAll(q); d_ptr->dirtySceneTransform = 1; - item = 0; + item = nullptr; } item = i; @@ -138,7 +138,7 @@ QGraphicsTransform::QGraphicsTransform(QObject *parent) QGraphicsTransform::~QGraphicsTransform() { Q_D(QGraphicsTransform); - d->setItem(0); + d->setItem(nullptr); } /*! diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 4c270b1af2..7589a1ebbd 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -352,7 +352,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() alignment(Qt::AlignCenter), transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor), viewportUpdateMode(QGraphicsView::MinimalViewportUpdate), - scene(0), + scene(nullptr), #if QT_CONFIG(rubberband) rubberBanding(false), rubberBandSelectionMode(Qt::IntersectsItemShape), @@ -362,7 +362,7 @@ QGraphicsViewPrivate::QGraphicsViewPrivate() #ifndef QT_NO_CURSOR hasStoredOriginalCursor(false), #endif - lastDragDropEvent(0), + lastDragDropEvent(nullptr), updateSceneSlotReimplementedChecked(false) { styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS); @@ -384,7 +384,7 @@ void QGraphicsViewPrivate::recalculateContentSize() int height = maxSize.height(); QRectF viewRect = matrix.mapRect(q->sceneRect()); - bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)); + bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)); if (frameOnlyAround) { if (hbarpolicy == Qt::ScrollBarAlwaysOn) height -= frameWidth * 2; @@ -394,7 +394,7 @@ void QGraphicsViewPrivate::recalculateContentSize() // Adjust the maximum width and height of the viewport based on the width // of visible scroll bars. - int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q); + int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, q); if (frameOnlyAround) scrollBarExtent += frameWidth * 2; @@ -1162,7 +1162,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg void QGraphicsViewPrivate::updateInputMethodSensitivity() { Q_Q(QGraphicsView); - QGraphicsItem *focusItem = 0; + QGraphicsItem *focusItem = nullptr; bool enabled = scene && (focusItem = scene->focusItem()) && (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod); q->setAttribute(Qt::WA_InputMethodEnabled, enabled); @@ -1174,7 +1174,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity() } QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget() - ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0; + ? static_cast<QGraphicsProxyWidget *>(focusItem) : nullptr; if (!proxy) { q->setInputMethodHints(focusItem->inputMethodHints()); } else if (QWidget *widget = proxy->widget()) { @@ -1192,7 +1192,7 @@ void QGraphicsViewPrivate::updateInputMethodSensitivity() QGraphicsView::QGraphicsView(QWidget *parent) : QAbstractScrollArea(*new QGraphicsViewPrivate, parent) { - setViewport(0); + setViewport(nullptr); setAcceptDrops(true); setBackgroundRole(QPalette::Base); // Investigate leaving these disabled by default. @@ -1208,7 +1208,7 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent) : QAbstractScrollArea(*new QGraphicsViewPrivate, parent) { setScene(scene); - setViewport(0); + setViewport(nullptr); setAcceptDrops(true); setBackgroundRole(QPalette::Base); // Investigate leaving these disabled by default. @@ -1222,7 +1222,7 @@ QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent) QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent) : QAbstractScrollArea(dd, parent) { - setViewport(0); + setViewport(nullptr); setAcceptDrops(true); setBackgroundRole(QPalette::Base); // Investigate leaving these disabled by default. @@ -2374,7 +2374,7 @@ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const { Q_D(const QGraphicsView); if (!d->scene) - return 0; + return nullptr; const QList<QGraphicsItem *> itemsAtPos = items(pos); return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first(); } @@ -2888,7 +2888,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) } d->useLastMouseEvent = false; // a hack to pass a viewport pointer to the scene inside the leave event - Q_ASSERT(event->d == 0); + Q_ASSERT(event->d == nullptr); QScopedValueRollback<QEventPrivate *> rb(event->d); event->d = reinterpret_cast<QEventPrivate *>(viewport()); QCoreApplication::sendEvent(d->scene, event); @@ -3019,7 +3019,7 @@ void QGraphicsView::dropEvent(QDropEvent *event) event->setDropAction(sceneEvent.dropAction()); delete d->lastDragDropEvent; - d->lastDragDropEvent = 0; + d->lastDragDropEvent = nullptr; } /*! @@ -3077,7 +3077,7 @@ void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) sceneEvent.setWidget(d->lastDragDropEvent->widget()); sceneEvent.setSource(d->lastDragDropEvent->source()); delete d->lastDragDropEvent; - d->lastDragDropEvent = 0; + d->lastDragDropEvent = nullptr; // Send it to the scene. QCoreApplication::sendEvent(d->scene, &sceneEvent); @@ -3525,7 +3525,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event) d->scene->d_func()->rectAdjust = 1; else d->scene->d_func()->rectAdjust = 2; - d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0, + d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : nullptr, &d->exposedRegion, viewport()); d->scene->d_func()->rectAdjust = oldRectAdjust; // Make sure the painter's world transform is restored correctly when @@ -3794,7 +3794,7 @@ void QGraphicsView::drawItems(QPainter *painter, int numItems, { Q_D(QGraphicsView); if (d->scene) { - QWidget *widget = painter->device() == viewport() ? viewport() : 0; + QWidget *widget = painter->device() == viewport() ? viewport() : nullptr; d->scene->drawItems(painter, numItems, items, options, widget); } } diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index cf041b9817..1035ed3575 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -172,7 +172,7 @@ QT_BEGIN_NAMESPACE window, a tool, a popup, etc). */ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsObject(*new QGraphicsWidgetPrivate, 0), QGraphicsLayoutItem(0, false) + : QGraphicsObject(*new QGraphicsWidgetPrivate, nullptr), QGraphicsLayoutItem(nullptr, false) { Q_D(QGraphicsWidget); d->init(parent, wFlags); @@ -184,7 +184,7 @@ QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags) Constructs a new QGraphicsWidget, using \a dd as parent. */ QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, Qt::WindowFlags wFlags) - : QGraphicsObject(dd, 0), QGraphicsLayoutItem(0, false) + : QGraphicsObject(dd, nullptr), QGraphicsLayoutItem(nullptr, false) { Q_D(QGraphicsWidget); d->init(parent, wFlags); @@ -241,7 +241,7 @@ QGraphicsWidget::~QGraphicsWidget() if (QGraphicsScene *scn = scene()) { QGraphicsScenePrivate *sceneD = scn->d_func(); if (sceneD->tabFocusFirst == this) - sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext); + sceneD->tabFocusFirst = (d->focusNext == this ? nullptr : d->focusNext); } d->focusPrev->d_func()->focusNext = d->focusNext; d->focusNext->d_func()->focusPrev = d->focusPrev; @@ -263,15 +263,15 @@ QGraphicsWidget::~QGraphicsWidget() if (item->isWidget()) { QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); if (widget->parentLayoutItem() == d->layout) - widget->setParentLayoutItem(0); + widget->setParentLayoutItem(nullptr); } } - d->layout = 0; + d->layout = nullptr; delete temp; } // Remove this graphics widget from widgetStyles - widgetStyles()->setStyleForWidget(this, 0); + widgetStyles()->setStyleForWidget(this, nullptr); // Unset the parent here, when we're still a QGraphicsWidget. // It is otherwise done in ~QGraphicsItem() where we'd be @@ -942,7 +942,7 @@ QStyle *QGraphicsWidget::style() const */ void QGraphicsWidget::setStyle(QStyle *style) { - setAttribute(Qt::WA_SetStyle, style != 0); + setAttribute(Qt::WA_SetStyle, style != nullptr); widgetStyles()->setStyleForWidget(this, style); // Deliver StyleChange to the widget itself (doesn't propagate). @@ -1557,7 +1557,7 @@ bool QGraphicsWidget::focusNextPrevChild(bool next) { Q_D(QGraphicsWidget); // Let the parent's focusNextPrevChild implementation decide what to do. - QGraphicsWidget *parent = 0; + QGraphicsWidget *parent = nullptr; if (!isWindow() && (parent = parentWidget())) return parent->focusNextPrevChild(next); if (!d->scene) @@ -1995,7 +1995,7 @@ void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled) */ void QGraphicsWidget::addAction(QAction *action) { - insertAction(0, action); + insertAction(nullptr, action); } /*! @@ -2012,7 +2012,7 @@ void QGraphicsWidget::addActions(QList<QAction *> actions) #endif { for (int i = 0; i < actions.count(); ++i) - insertAction(0, actions.at(i)); + insertAction(nullptr, actions.at(i)); } /*! @@ -2041,7 +2041,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action) int pos = d->actions.indexOf(before); if (pos < 0) { - before = 0; + before = nullptr; pos = d->actions.size(); } d->actions.insert(pos, action); @@ -2346,7 +2346,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal); frameOptions.rect = windowFrameRect; - frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget); + frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, widget); frameOptions.midLineWidth = 1; style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget); diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index 0156faf8e4..e6f39d6803 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -322,7 +322,7 @@ void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *optio option->titleBarState = Qt::WindowNoState; } QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar"); - QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0); + QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, nullptr); option->text = QFontMetrics(windowTitleFont).elidedText( windowData->windowTitle, Qt::ElideRight, textRect.width()); } @@ -690,7 +690,7 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent break; case Qt::TitleBarArea: windowData->buttonRect = q->style()->subControlRect( - QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0); + QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, nullptr); if (windowData->buttonRect.contains(pos.toPoint())) windowData->buttonMouseOver = true; event->ignore(); @@ -707,7 +707,7 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent Q_UNUSED(cursorShape); #endif // update buttons if we hover over them - windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0); + windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), nullptr); if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton) windowData->hoveredSubControl = QStyle::SC_TitleBarLabel; @@ -781,7 +781,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new if (!parent && oldScene && oldScene != newScene && oldScene->d_func()->tabFocusFirst == q) { // detach from old scene's top level focus chain. - oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : 0; + oldScene->d_func()->tabFocusFirst = (focusAfter != q) ? focusAfter : nullptr; } // detach from current focus chain; skip this widget subtree. diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index e18f1fa4c4..38c2df5fc6 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ -QSimplex::QSimplex() : objective(0), rows(0), columns(0), firstArtificial(0), matrix(0) +QSimplex::QSimplex() : objective(nullptr), rows(0), columns(0), firstArtificial(0), matrix(nullptr) { } @@ -93,7 +93,7 @@ QSimplex::~QSimplex() */ void QSimplex::clearDataStructures() { - if (matrix == 0) + if (matrix == nullptr) return; // Matrix @@ -101,7 +101,7 @@ void QSimplex::clearDataStructures() columns = 0; firstArtificial = 0; free(matrix); - matrix = 0; + matrix = nullptr; // Constraints for (int i = 0; i < constraints.size(); ++i) { @@ -113,7 +113,7 @@ void QSimplex::clearDataStructures() // Other variables.clear(); - objective = 0; + objective = nullptr; } /*! @@ -195,7 +195,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints) QSimplexVariable *artificial; Q_ASSERT(constraints[i]->helper.first == 0); - Q_ASSERT(constraints[i]->artificial == 0); + Q_ASSERT(constraints[i]->artificial == nullptr); switch(constraints[i]->ratio) { case QSimplexConstraint::LessOrEqual: diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index eecc18e5c7..bb47881c03 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -255,7 +255,7 @@ QWidget *QAbstractItemDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const { - return 0; + return nullptr; } diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index b1557e9af4..67c01adea7 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -77,13 +77,13 @@ QT_BEGIN_NAMESPACE QAbstractItemViewPrivate::QAbstractItemViewPrivate() : model(QAbstractItemModelPrivate::staticEmptyModel()), - itemDelegate(0), - selectionModel(0), + itemDelegate(nullptr), + selectionModel(nullptr), ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate), noSelectionOnMousePress(false), selectionMode(QAbstractItemView::ExtendedSelection), selectionBehavior(QAbstractItemView::SelectItems), - currentlyCommittingEditor(0), + currentlyCommittingEditor(nullptr), pressedModifiers(Qt::NoModifier), pressedPosition(QPoint(-1, -1)), pressedAlreadySelected(false), @@ -145,8 +145,8 @@ void QAbstractItemViewPrivate::init() q->setAttribute(Qt::WA_InputMethodEnabled); - verticalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0)); - horizontalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, q, 0)); + verticalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, q, nullptr)); + horizontalScrollMode = static_cast<QAbstractItemView::ScrollMode>(q->style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, q, nullptr)); } void QAbstractItemViewPrivate::setHoverIndex(const QPersistentModelIndex &index) @@ -757,7 +757,7 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) QAbstractItemModel *QAbstractItemView::model() const { Q_D(const QAbstractItemView); - return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model); + return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? nullptr : d->model); } /*! @@ -915,7 +915,7 @@ QVariant QAbstractItemView::inputMethodQuery(Qt::InputMethodQuery query) const void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *delegate) { Q_D(QAbstractItemView); - if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, 0)) { + if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, nullptr)) { if (d->delegateRefCount(rowDelegate) == 1) { disconnect(rowDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); @@ -949,7 +949,7 @@ void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *de QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const { Q_D(const QAbstractItemView); - return d->rowDelegates.value(row, 0); + return d->rowDelegates.value(row, nullptr); } /*! @@ -975,7 +975,7 @@ QAbstractItemDelegate *QAbstractItemView::itemDelegateForRow(int row) const void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate) { Q_D(QAbstractItemView); - if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, 0)) { + if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, nullptr)) { if (d->delegateRefCount(columnDelegate) == 1) { disconnect(columnDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); @@ -1009,7 +1009,7 @@ void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelega QAbstractItemDelegate *QAbstractItemView::itemDelegateForColumn(int column) const { Q_D(const QAbstractItemView); - return d->columnDelegates.value(column, 0); + return d->columnDelegates.value(column, nullptr); } /*! @@ -1084,7 +1084,7 @@ void QAbstractItemView::setCurrentIndex(const QModelIndex &index) { Q_D(QAbstractItemView); if (d->selectionModel && (!index.isValid() || d->isIndexEnabled(index))) { - QItemSelectionModel::SelectionFlags command = selectionCommand(index, 0); + QItemSelectionModel::SelectionFlags command = selectionCommand(index, nullptr); d->selectionModel->setCurrentIndex(index, command); d->currentIndexSet = true; if ((command & QItemSelectionModel::Current) == 0) @@ -1201,7 +1201,7 @@ void QAbstractItemView::edit(const QModelIndex &index) Q_D(QAbstractItemView); if (Q_UNLIKELY(!d->isIndexValid(index))) qWarning("edit: index was invalid"); - if (Q_UNLIKELY(!edit(index, AllEditTriggers, 0))) + if (Q_UNLIKELY(!edit(index, AllEditTriggers, nullptr))) qWarning("edit: editing failed"); } @@ -1286,7 +1286,7 @@ QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode() const void QAbstractItemView::resetVerticalScrollMode() { - auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0)); + auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, this, nullptr)); setVerticalScrollMode(sm); d_func()->verticalScrollModeSet = false; } @@ -1323,7 +1323,7 @@ QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode() const void QAbstractItemView::resetHorizontalScrollMode() { - auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, this, 0)); + auto sm = static_cast<ScrollMode>(style()->styleHint(QStyle::SH_ItemView_ScrollMode, nullptr, this, nullptr)); setHorizontalScrollMode(sm); d_func()->horizontalScrollModeSet = false; } @@ -1964,7 +1964,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event) QPersistentModelIndex persistent = index; emit doubleClicked(persistent); if ((event->button() == Qt::LeftButton) && !edit(persistent, DoubleClicked, event) - && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)) + && !style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this)) emit activated(persistent); d->pressedIndex = QModelIndex(); } @@ -2388,7 +2388,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) setFocus(); QItemSelectionModel::SelectionFlags command = selectionCommand(newCurrent, event); if (command != QItemSelectionModel::NoUpdate - || style()->styleHint(QStyle::SH_ItemView_MovementWithoutUpdatingSelection, 0, this)) { + || style()->styleHint(QStyle::SH_ItemView_MovementWithoutUpdatingSelection, nullptr, this)) { // note that we don't check if the new current index is enabled because moveCursor() makes sure it is if (command & QItemSelectionModel::Current) { d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate); @@ -2654,7 +2654,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve if (!d->isIndexValid(index)) return false; - if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).widget.data())) { + if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(nullptr) : d->editorForIndex(index).widget.data())) { if (w->focusPolicy() == Qt::NoFocus) return false; w->setFocus(); @@ -2692,7 +2692,7 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve if (trigger == SelectedClicked) d->delayedEditing.start(QApplication::doubleClickInterval(), this); else - d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : 0); + d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : nullptr); return true; } @@ -2909,7 +2909,7 @@ void QAbstractItemView::commitData(QWidget *editor) editor->removeEventFilter(delegate); delegate->setModelData(editor, d->model, index); editor->installEventFilter(delegate); - d->currentlyCommittingEditor = 0; + d->currentlyCommittingEditor = nullptr; } /*! @@ -3260,7 +3260,7 @@ QWidget* QAbstractItemView::indexWidget(const QModelIndex &index) const if (QWidget *editor = d->editorForIndex(index).widget.data()) return editor; - return 0; + return nullptr; } /*! @@ -3673,7 +3673,7 @@ void QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelI if (d->autoScroll) scrollTo(current); update(current); - edit(current, CurrentChanged, 0); + edit(current, CurrentChanged, nullptr); if (current.row() == (d->model->rowCount(d->root) - 1)) d->fetchMore(); } else { @@ -3737,7 +3737,7 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const if (d->iconSize.isValid()) { option.decorationSize = d->iconSize; } else { - int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); + int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this); option.decorationSize = QSize(pm, pm); } option.decorationPosition = QStyleOptionViewItem::Left; @@ -3745,7 +3745,7 @@ QStyleOptionViewItem QAbstractItemView::viewOptions() const option.displayAlignment = Qt::AlignLeft|Qt::AlignVCenter; option.textElideMode = d->textElideMode; option.rect = QRect(); - option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, this); + option.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, this); if (d->wrapItemText) option.features = QStyleOptionViewItem::WrapText; option.locale = locale(); @@ -4231,7 +4231,7 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, if (!w) { QAbstractItemDelegate *delegate = delegateForIndex(index); if (!delegate) - return 0; + return nullptr; w = delegate->createEditor(viewport, options, index); if (w) { w->installEventFilter(delegate); diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index a4eed2d885..4d0161025c 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -142,7 +142,7 @@ void QColumnView::setResizeGripsVisible(bool visible) connect(grip, SIGNAL(gripMoved(int)), this, SLOT(_q_gripMoved(int))); } else { QWidget *widget = view->cornerWidget(); - view->setCornerWidget(0); + view->setCornerWidget(nullptr); widget->deleteLater(); } } @@ -327,7 +327,7 @@ void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint) } #if QT_CONFIG(animation) - if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, this)) { + if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this)) { d->currentAnimation.setDuration(animationDuration); d->currentAnimation.setEndValue(newScrollbarValue); d->currentAnimation.start(); @@ -638,7 +638,7 @@ void QColumnViewPrivate::_q_clicked(const QModelIndex &index) { Q_Q(QColumnView); QModelIndex parent = index.parent(); - QAbstractItemView *columnClicked = 0; + QAbstractItemView *columnClicked = nullptr; for (int column = 0; column < columns.count(); ++column) { if (columns.at(column)->rootIndex() == parent) { columnClicked = columns[column]; @@ -666,7 +666,7 @@ void QColumnViewPrivate::_q_clicked(const QModelIndex &index) QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bool show) { Q_Q(QColumnView); - QAbstractItemView *view = 0; + QAbstractItemView *view = nullptr; if (model->hasChildren(index)) { view = q->createColumn(index); q->connect(view, SIGNAL(clicked(QModelIndex)), @@ -1045,8 +1045,8 @@ QColumnViewPrivate::QColumnViewPrivate() : QAbstractItemViewPrivate() ,showResizeGrips(true) ,offset(0) -,previewWidget(0) -,previewColumn(0) +,previewWidget(nullptr) +,previewColumn(nullptr) { } diff --git a/src/widgets/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp index 125ee73194..24039c42f6 100644 --- a/src/widgets/itemviews/qdatawidgetmapper.cpp +++ b/src/widgets/itemviews/qdatawidgetmapper.cpp @@ -56,7 +56,7 @@ public: Q_DECLARE_PUBLIC(QDataWidgetMapper) QDataWidgetMapperPrivate() - : model(QAbstractItemModelPrivate::staticEmptyModel()), delegate(0), + : model(QAbstractItemModelPrivate::staticEmptyModel()), delegate(nullptr), orientation(Qt::Horizontal), submitPolicy(QDataWidgetMapper::AutoSubmit) { } @@ -226,7 +226,7 @@ void QDataWidgetMapperPrivate::_q_modelDestroyed() { Q_Q(QDataWidgetMapper); - model = 0; + model = nullptr; q->setModel(QAbstractItemModelPrivate::staticEmptyModel()); } @@ -374,7 +374,7 @@ QAbstractItemModel *QDataWidgetMapper::model() const { Q_D(const QDataWidgetMapper); return d->model == QAbstractItemModelPrivate::staticEmptyModel() - ? static_cast<QAbstractItemModel *>(0) + ? static_cast<QAbstractItemModel *>(nullptr) : d->model; } @@ -567,7 +567,7 @@ QWidget *QDataWidgetMapper::mappedWidgetAt(int section) const return e.widget; } - return 0; + return nullptr; } /*! diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index c9e7c7b7a6..0d387d7def 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -75,7 +75,7 @@ class QDirModelPrivate : public QAbstractItemModelPrivate public: struct QDirNode { - QDirNode() : parent(0), populated(false), stat(false) {} + QDirNode() : parent(nullptr), populated(false), stat(false) {} QDirNode *parent; QFileInfo info; QIcon icon; // cache the icon @@ -238,7 +238,7 @@ QDirModel::QDirModel(const QStringList &nameFilters, d->nameFilters = nameFilters.isEmpty() ? QStringList(QLatin1String("*")) : nameFilters; d->filters = filters; d->sort = sort; - d->root.parent = 0; + d->root.parent = nullptr; d->root.info = QFileInfo(); d->clear(&d->root); } @@ -293,7 +293,7 @@ QModelIndex QDirModel::index(int row, int column, const QModelIndex &parent) con if (row >= p->children.count()) return QModelIndex(); // now get the internal pointer for the index - QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : 0); + QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : nullptr); Q_ASSERT(n); return createIndex(row, column, n); @@ -310,8 +310,8 @@ QModelIndex QDirModel::parent(const QModelIndex &child) const if (!d->indexValid(child)) return QModelIndex(); QDirModelPrivate::QDirNode *node = d->node(child); - QDirModelPrivate::QDirNode *par = (node ? node->parent : 0); - if (par == 0) // parent is the root node + QDirModelPrivate::QDirNode *par = (node ? node->parent : nullptr); + if (par == nullptr) // parent is the root node return QModelIndex(); // get the parent's row @@ -1159,7 +1159,7 @@ void QDirModelPrivate::init() filters = QDir::AllEntries | QDir::NoDotAndDotDot; sort = QDir::Name; nameFilters << QLatin1String("*"); - root.parent = 0; + root.parent = nullptr; root.info = QFileInfo(); clear(&root); roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration @@ -1170,7 +1170,7 @@ void QDirModelPrivate::init() QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const { if (row < 0) - return 0; + return nullptr; bool isDir = !parent || parent->info.isDir(); QDirNode *p = (parent ? parent : &root); @@ -1179,7 +1179,7 @@ QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) co if (Q_UNLIKELY(row >= p->children.count())) { qWarning("node: the row does not exist"); - return 0; + return nullptr; } return const_cast<QDirNode*>(&p->children.at(row)); @@ -1190,7 +1190,7 @@ QVector<QDirModelPrivate::QDirNode> QDirModelPrivate::children(QDirNode *parent, Q_ASSERT(parent); QFileInfoList infoList; if (parent == &root) { - parent = 0; + parent = nullptr; infoList = QDir::drives(); } else if (parent->info.isDir()) { //resolve directory links only if requested. @@ -1333,7 +1333,7 @@ void QDirModelPrivate::appendChild(QDirModelPrivate::QDirNode *parent, const QSt QDirModelPrivate::QDirNode node; node.populated = false; node.stat = shouldStat; - node.parent = (parent == &root ? 0 : parent); + node.parent = (parent == &root ? nullptr : parent); node.info = QFileInfo(path); node.info.setCaching(true); diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index d7bdf6aa4c..790f305463 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1583,7 +1583,7 @@ int QHeaderView::minimumSectionSize() const Q_D(const QHeaderView); if (d->minimumSectionSize == -1) { QSize strut = QApplication::globalStrut(); - int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); + int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, nullptr, this); if (d->orientation == Qt::Horizontal) return qMax(strut.width(), (fontMetrics().maxWidth() + margin)); return qMax(strut.height(), (fontMetrics().height() + margin)); @@ -2883,12 +2883,12 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical opt.text = d->model->headerData(logicalIndex, d->orientation, Qt::DisplayRole).toString(); - int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); + int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, nullptr, this); - const Qt::Alignment headerArrowAlignment = static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_Header_ArrowAlignment, 0, this)); + const Qt::Alignment headerArrowAlignment = static_cast<Qt::Alignment>(style()->styleHint(QStyle::SH_Header_ArrowAlignment, nullptr, this)); const bool isHeaderArrowOnTheSide = headerArrowAlignment & Qt::AlignVCenter; if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide) - margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this); + margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, nullptr, this); const QVariant variant = d->model->headerData(logicalIndex, d->orientation, Qt::DecorationRole); @@ -2896,8 +2896,8 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical if (opt.icon.isNull()) opt.icon = qvariant_cast<QPixmap>(variant); if (!opt.icon.isNull()) // see CT_HeaderSection - margin += style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this) + - style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); + margin += style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this) + + style()->pixelMetric(QStyle::PM_HeaderMargin, nullptr, this); if (d->textElideMode != Qt::ElideNone) { const QRect textRect = style()->subElementRect(QStyle::SE_HeaderLabel, &opt, this); @@ -3275,7 +3275,7 @@ int QHeaderViewPrivate::sectionHandleAt(int position) return -1; int log = logicalIndex(visual); int pos = q->sectionViewportPosition(log); - int grip = q->style()->pixelMetric(QStyle::PM_HeaderGripMargin, 0, q); + int grip = q->style()->pixelMetric(QStyle::PM_HeaderGripMargin, nullptr, q); bool atLeft = position < pos + grip; bool atRight = (position > pos + q->sectionSize(log) - grip); @@ -3814,10 +3814,10 @@ void QHeaderViewPrivate::updateDefaultSectionSizeFromStyle() { Q_Q(QHeaderView); if (orientation == Qt::Horizontal) { - defaultSectionSize = q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, 0, q); + defaultSectionSize = q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeHorizontal, nullptr, q); } else { defaultSectionSize = qMax(q->minimumSectionSize(), - q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, 0, q)); + q->style()->pixelMetric(QStyle::PM_HeaderDefaultSectionSizeVertical, nullptr, q)); } } diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp index 460764f1b8..daea907963 100644 --- a/src/widgets/itemviews/qitemdelegate.cpp +++ b/src/widgets/itemviews/qitemdelegate.cpp @@ -77,7 +77,7 @@ class QItemDelegatePrivate : public QAbstractItemDelegatePrivate Q_DECLARE_PUBLIC(QItemDelegate) public: - QItemDelegatePrivate() : f(0), clipPainting(true) {} + QItemDelegatePrivate() : f(nullptr), clipPainting(true) {} inline const QItemEditorFactory *editorFactory() const { return f ? f : QItemEditorFactory::defaultFactory(); } @@ -149,7 +149,7 @@ QRect QItemDelegatePrivate::textLayoutBounds(const QStyleOptionViewItem &option, QStyle *style = w ? w->style() : QApplication::style(); const bool wrapText = option.features & QStyleOptionViewItem::WrapText; // see QItemDelegate::drawDisplay - const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, w) + 1; + const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, w) + 1; switch (option.decorationPosition) { case QStyleOptionViewItem::Left: case QStyleOptionViewItem::Right: @@ -502,9 +502,9 @@ QWidget *QItemDelegate::createEditor(QWidget *parent, { Q_D(const QItemDelegate); if (!index.isValid()) - return 0; + return nullptr; const QItemEditorFactory *factory = d->f; - if (factory == 0) + if (factory == nullptr) factory = QItemEditorFactory::defaultFactory(); QWidget *w = factory->createEditor(index.data(Qt::EditRole).userType(), parent); if (w) @@ -533,7 +533,7 @@ void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) con if (!n.isEmpty()) { if (!v.isValid()) - v = QVariant(editor->property(n).userType(), (const void *)0); + v = QVariant(editor->property(n).userType(), (const void *)nullptr); editor->setProperty(n, v); } #endif @@ -586,7 +586,7 @@ void QItemDelegate::updateEditorGeometry(QWidget *editor, QPixmap pixmap = decoration(option, index.data(Qt::DecorationRole)); QString text = QItemDelegatePrivate::replaceNewLine(index.data(Qt::DisplayRole).toString()); QRect pixmapRect = QRect(QPoint(0, 0), option.decorationSize).intersected(pixmap.rect()); - QRect textRect = textRectangle(0, option.rect, option.font, text); + QRect textRect = textRectangle(nullptr, option.rect, option.font, text); QRect checkRect = doCheck(option, textRect, index.data(Qt::CheckStateRole)); QStyleOptionViewItem opt = option; opt.showDecorationSelected = true; // let the editor take up all available space @@ -654,7 +654,7 @@ void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &o const QWidget *widget = d->widget(option); QStyle *style = widget ? widget->style() : QApplication::style(); - const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1; + const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1; QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding const bool wrapText = opt.features & QStyleOptionViewItem::WrapText; d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap); @@ -841,7 +841,7 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option, const bool hasText = textRect->isValid(); const bool hasMargin = (hasText | hasPixmap | hasCheck); const int frameHMargin = hasMargin ? - style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0; + style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1 : 0; const int textMargin = hasText ? frameHMargin : 0; const int pixmapMargin = hasPixmap ? frameHMargin : 0; const int checkMargin = hasCheck ? frameHMargin : 0; @@ -1242,7 +1242,7 @@ QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index, opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); // disable style animations for checkboxes etc. within itemviews (QTBUG-30146) - opt.styleObject = 0; + opt.styleObject = nullptr; return opt; } diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 8ed2ee5f28..f874597d59 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -91,7 +91,7 @@ class QUIntSpinBox : public QSpinBox Q_OBJECT Q_PROPERTY(uint value READ uintValue WRITE setUIntValue NOTIFY uintValueChanged USER true) public: - explicit QUIntSpinBox(QWidget *parent = 0) + explicit QUIntSpinBox(QWidget *parent = nullptr) : QSpinBox(parent) { connect(this, SIGNAL(valueChanged(int)), SIGNAL(uintValueChanged())); @@ -176,7 +176,7 @@ QWidget *QItemEditorFactory::createEditor(int userType, QWidget *parent) const QItemEditorCreatorBase *creator = creatorMap.value(userType, 0); if (!creator) { const QItemEditorFactory *dfactory = defaultFactory(); - return dfactory == this ? 0 : dfactory->createEditor(userType, parent); + return dfactory == this ? nullptr : dfactory->createEditor(userType, parent); } return creator->createWidget(parent); } @@ -295,8 +295,8 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) default: { // the default editor is a lineedit QExpandingLineEdit *le = new QExpandingLineEdit(parent); - le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le)); - if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le)) + le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, nullptr, le)); + if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, le)) le->setWidgetOwnsGeometry(true); return le; } #else @@ -304,7 +304,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) break; #endif } - return 0; + return nullptr; } QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const @@ -335,11 +335,11 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const } } -static QItemEditorFactory *q_default_factory = 0; +static QItemEditorFactory *q_default_factory = nullptr; struct QDefaultFactoryCleaner { inline QDefaultFactoryCleaner() {} - ~QDefaultFactoryCleaner() { delete q_default_factory; q_default_factory = 0; } + ~QDefaultFactoryCleaner() { delete q_default_factory; q_default_factory = nullptr; } }; /*! diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 04cddf2926..de32082b5a 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -933,8 +933,8 @@ QStyleOptionViewItem QListView::viewOptions() const QStyleOptionViewItem option = QAbstractItemView::viewOptions(); if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview int pm = (d->viewMode == QListView::ListMode - ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this) - : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this)); + ? style()->pixelMetric(QStyle::PM_ListViewIconSize, nullptr, this) + : style()->pixelMetric(QStyle::PM_IconViewIconSize, nullptr, this)); option.decorationSize = QSize(pm, pm); } if (d->viewMode == QListView::IconMode) { @@ -1688,7 +1688,7 @@ bool QListView::event(QEvent *e) QListViewPrivate::QListViewPrivate() : QAbstractItemViewPrivate(), - commonListView(0), + commonListView(nullptr), wrap(false), space(0), flow(QListView::TopToBottom), @@ -1733,10 +1733,10 @@ void QListViewPrivate::prepareItemsLayout() // Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy // is Qt::ScrollBarAsNeeded int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded - ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents + ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, vbar) + frameAroundContents : 0; int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded - ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents + ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, hbar) + frameAroundContents : 0; layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin); @@ -3072,7 +3072,7 @@ void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info) moved.resize(items.count()); QRect rect(QPoint(), topLeft); - QListViewItem *item = 0; + QListViewItem *item = nullptr; for (int row = info.first; row <= info.last; ++row) { item = &items[row]; if (isHidden(row)) { @@ -3178,7 +3178,7 @@ QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const QVector<QModelIndex> res; that->interSectingVector = &res; that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data); - that->interSectingVector = 0; + that->interSectingVector = nullptr; return res; } diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 1931360dbc..f71e0f2822 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -75,7 +75,7 @@ void QListModel::clear() for (int i = 0; i < items.count(); ++i) { if (items.at(i)) { items.at(i)->d->theid = -1; - items.at(i)->view = 0; + items.at(i)->view = nullptr; delete items.at(i); } } @@ -96,7 +96,7 @@ void QListModel::remove(QListWidgetItem *item) Q_ASSERT(row != -1); beginRemoveRows(QModelIndex(), row, row); items.at(row)->d->theid = -1; - items.at(row)->view = 0; + items.at(row)->view = nullptr; items.removeAt(row); endRemoveRows(); } @@ -156,11 +156,11 @@ void QListModel::insert(int row, const QStringList &labels) QListWidgetItem *QListModel::take(int row) { if (row < 0 || row >= items.count()) - return 0; + return nullptr; beginRemoveRows(QModelIndex(), row, row); items.at(row)->d->theid = -1; - items.at(row)->view = 0; + items.at(row)->view = nullptr; QListWidgetItem *item = items.takeAt(row); endRemoveRows(); return item; @@ -263,7 +263,7 @@ bool QListModel::insertRows(int row, int count, const QModelIndex &parent) beginInsertRows(QModelIndex(), row, row + count - 1); QListWidget *view = qobject_cast<QListWidget*>(QObject::parent()); - QListWidgetItem *itm = 0; + QListWidgetItem *itm = nullptr; for (int r = row; r < row + count; ++r) { itm = new QListWidgetItem; @@ -282,10 +282,10 @@ bool QListModel::removeRows(int row, int count, const QModelIndex &parent) return false; beginRemoveRows(QModelIndex(), row, row + count - 1); - QListWidgetItem *itm = 0; + QListWidgetItem *itm = nullptr; for (int r = row; r < row + count; ++r) { itm = items.takeAt(row); - itm->view = 0; + itm->view = nullptr; itm->d->theid = -1; delete itm; } @@ -1220,7 +1220,7 @@ void QListWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex ¤t, //persistentCurrent is invalid if something changed the model in response //to the currentItemChanged signal emission and the item was removed if (!persistentCurrent.isValid()) { - currentItem = 0; + currentItem = nullptr; } emit q->currentTextChanged(currentItem ? currentItem->text() : QString()); @@ -1478,7 +1478,7 @@ QListWidgetItem *QListWidget::item(int row) const { Q_D(const QListWidget); if (row < 0 || row >= d->model->rowCount()) - return 0; + return nullptr; return d->listModel()->at(row); } @@ -1548,7 +1548,7 @@ QListWidgetItem *QListWidget::takeItem(int row) { Q_D(QListWidget); if (row < 0 || row >= d->model->rowCount()) - return 0; + return nullptr; return d->listModel()->take(row); } @@ -2064,7 +2064,7 @@ QListWidgetItem *QListWidget::itemFromIndex(const QModelIndex &index) const Q_D(const QListWidget); if (d->isIndexValid(index)) return d->listModel()->at(index.row()); - return 0; + return nullptr; } /*! diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 702e290da3..f42af2ea00 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -83,7 +83,7 @@ class QStyledItemDelegatePrivate : public QAbstractItemDelegatePrivate Q_DECLARE_PUBLIC(QStyledItemDelegate) public: - QStyledItemDelegatePrivate() : factory(0) { } + QStyledItemDelegatePrivate() : factory(nullptr) { } static const QWidget *widget(const QStyleOptionViewItem &option) { @@ -351,7 +351,7 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option, option->backgroundBrush = qvariant_cast<QBrush>(index.data(Qt::BackgroundRole)); // disable style animations for checkboxes etc. within itemviews (QTBUG-30146) - option->styleObject = 0; + option->styleObject = nullptr; } /*! @@ -426,7 +426,7 @@ QWidget *QStyledItemDelegate::createEditor(QWidget *parent, { Q_D(const QStyledItemDelegate); if (!index.isValid()) - return 0; + return nullptr; return d->editorFactory()->createEditor(index.data(Qt::EditRole).userType(), parent); } @@ -450,7 +450,7 @@ void QStyledItemDelegate::setEditorData(QWidget *editor, const QModelIndex &inde if (!n.isEmpty()) { if (!v.isValid()) - v = QVariant(editor->property(n).userType(), (const void *)0); + v = QVariant(editor->property(n).userType(), (const void *)nullptr); editor->setProperty(n, v); } #endif @@ -507,7 +507,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, //or it is in a QTableView #if QT_CONFIG(tableview) && QT_CONFIG(lineedit) if (qobject_cast<QExpandingLineEdit*>(editor) && !qobject_cast<const QTableView*>(widget)) - opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor); + opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, editor); else #endif opt.showDecorationSelected = true; diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 91860341ee..8f37ef4c3d 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE QTableModel::QTableModel(int rows, int columns, QTableWidget *parent) : QAbstractTableModel(parent), - prototype(0), + prototype(nullptr), tableItems(rows * columns, 0), verticalHeaderItems(rows, 0), horizontalHeaderItems(columns, 0) @@ -104,18 +104,18 @@ bool QTableModel::removeRows(int row, int count, const QModelIndex &) beginRemoveRows(QModelIndex(), row, row + count - 1); int i = tableIndex(row, 0); int n = count * columnCount(); - QTableWidgetItem *oldItem = 0; + QTableWidgetItem *oldItem = nullptr; for (int j = i; j < n + i; ++j) { oldItem = tableItems.at(j); if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete oldItem; } tableItems.remove(qMax(i, 0), n); for (int v = row; v < row + count; ++v) { oldItem = verticalHeaderItems.at(v); if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete oldItem; } verticalHeaderItems.remove(row, count); @@ -129,13 +129,13 @@ bool QTableModel::removeColumns(int column, int count, const QModelIndex &) return false; beginRemoveColumns(QModelIndex(), column, column + count - 1); - QTableWidgetItem *oldItem = 0; + QTableWidgetItem *oldItem = nullptr; for (int row = rowCount() - 1; row >= 0; --row) { int i = tableIndex(row, column); for (int j = i; j < i + count; ++j) { oldItem = tableItems.at(j); if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete oldItem; } tableItems.remove(i, count); @@ -143,7 +143,7 @@ bool QTableModel::removeColumns(int column, int count, const QModelIndex &) for (int h=column; h<column+count; ++h) { oldItem = horizontalHeaderItems.at(h); if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete oldItem; } horizontalHeaderItems.remove(column, count); @@ -162,7 +162,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item) // remove old if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete tableItems.at(i); QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); @@ -180,7 +180,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item) if (row < colItems.count()) colItems.remove(row); int sortedRow; - if (item == 0) { + if (item == nullptr) { // move to after all non-0 (sortable) items sortedRow = colItems.count(); } else { @@ -222,7 +222,7 @@ QTableWidgetItem *QTableModel::takeItem(int row, int column) long i = tableIndex(row, column); QTableWidgetItem *itm = tableItems.value(i); if (itm) { - itm->view = 0; + itm->view = nullptr; itm->d->id = -1; tableItems[i] = 0; const QModelIndex ind = index(row, column); @@ -239,7 +239,7 @@ QTableWidgetItem *QTableModel::item(int row, int column) const QTableWidgetItem *QTableModel::item(const QModelIndex &index) const { if (!isValid(index)) - return 0; + return nullptr; return tableItems.at(tableIndex(index.row(), index.column())); } @@ -277,7 +277,7 @@ void QTableModel::setHorizontalHeaderItem(int section, QTableWidgetItem *item) return; if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete oldItem; QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); @@ -299,7 +299,7 @@ void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item) return; if (oldItem) - oldItem->view = 0; + oldItem->view = nullptr; delete oldItem; QTableWidget *view = qobject_cast<QTableWidget*>(QObject::parent()); @@ -315,10 +315,10 @@ void QTableModel::setVerticalHeaderItem(int section, QTableWidgetItem *item) QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section) { if (section < 0 || section >= horizontalHeaderItems.count()) - return 0; + return nullptr; QTableWidgetItem *itm = horizontalHeaderItems.at(section); if (itm) { - itm->view = 0; + itm->view = nullptr; itm->itemFlags &= ~ItemIsHeaderItem; horizontalHeaderItems[section] = 0; } @@ -328,10 +328,10 @@ QTableWidgetItem *QTableModel::takeHorizontalHeaderItem(int section) QTableWidgetItem *QTableModel::takeVerticalHeaderItem(int section) { if (section < 0 || section >= verticalHeaderItems.count()) - return 0; + return nullptr; QTableWidgetItem *itm = verticalHeaderItems.at(section); if (itm) { - itm->view = 0; + itm->view = nullptr; itm->itemFlags &= ~ItemIsHeaderItem; verticalHeaderItems[section] = 0; } @@ -571,7 +571,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order, sorting.reserve(count); for (int row = start; row <= end; ++row) { QTableWidgetItem *itm = item(row, column); - if (itm == 0) { + if (itm == nullptr) { // no more sortable items (all 0-items are // at the end of the table when it is sorted) break; @@ -649,7 +649,7 @@ QVector<QTableWidgetItem*> QTableModel::columnItems(int column) const items.reserve(rc); for (int row = 0; row < rc; ++row) { QTableWidgetItem *itm = item(row, column); - if (itm == 0) { + if (itm == nullptr) { // no more sortable items (all 0-items are // at the end of the table when it is sorted) break; @@ -718,7 +718,7 @@ QVariant QTableModel::headerData(int section, Qt::Orientation orientation, int r if (section < 0) return QVariant(); - QTableWidgetItem *itm = 0; + QTableWidgetItem *itm = nullptr; if (orientation == Qt::Horizontal && section < horizontalHeaderItems.count()) itm = horizontalHeaderItems.at(section); else if (orientation == Qt::Vertical && section < verticalHeaderItems.count()) @@ -741,7 +741,7 @@ bool QTableModel::setHeaderData(int section, Qt::Orientation orientation, (orientation == Qt::Vertical && verticalHeaderItems.size() <= section)) return false; - QTableWidgetItem *itm = 0; + QTableWidgetItem *itm = nullptr; if (orientation == Qt::Horizontal) itm = horizontalHeaderItems.at(section); else @@ -764,14 +764,14 @@ void QTableModel::clear() { for (int j = 0; j < verticalHeaderItems.count(); ++j) { if (verticalHeaderItems.at(j)) { - verticalHeaderItems.at(j)->view = 0; + verticalHeaderItems.at(j)->view = nullptr; delete verticalHeaderItems.at(j); verticalHeaderItems[j] = 0; } } for (int k = 0; k < horizontalHeaderItems.count(); ++k) { if (horizontalHeaderItems.at(k)) { - horizontalHeaderItems.at(k)->view = 0; + horizontalHeaderItems.at(k)->view = nullptr; delete horizontalHeaderItems.at(k); horizontalHeaderItems[k] = 0; } @@ -784,7 +784,7 @@ void QTableModel::clearContents() beginResetModel(); for (int i = 0; i < tableItems.count(); ++i) { if (tableItems.at(i)) { - tableItems.at(i)->view = 0; + tableItems.at(i)->view = nullptr; delete tableItems.at(i); tableItems[i] = 0; } @@ -853,7 +853,7 @@ QMimeData *QTableModel::mimeData(const QModelIndexList &indexes) const // cachedIndexes is a little hack to avoid copying from QModelIndexList to // QList<QTreeWidgetItem*> and back again in the view cachedIndexes = indexes; - QMimeData *mimeData = (view ? view->mimeData(items) : 0); + QMimeData *mimeData = (view ? view->mimeData(items) : nullptr); cachedIndexes.clear(); return mimeData; } @@ -2040,7 +2040,7 @@ QTableWidgetItem *QTableWidget::takeItem(int row, int column) Q_D(QTableWidget); QTableWidgetItem *item = d->tableModel()->takeItem(row, column); if (item) - item->view = 0; + item->view = nullptr; return item; } @@ -2076,7 +2076,7 @@ QTableWidgetItem *QTableWidget::takeVerticalHeaderItem(int row) Q_D(QTableWidget); QTableWidgetItem *itm = d->tableModel()->takeVerticalHeaderItem(row); if (itm) - itm->view = 0; + itm->view = nullptr; return itm; } @@ -2115,7 +2115,7 @@ QTableWidgetItem *QTableWidget::takeHorizontalHeaderItem(int column) Q_D(QTableWidget); QTableWidgetItem *itm = d->tableModel()->takeHorizontalHeaderItem(column); if (itm) - itm->view = 0; + itm->view = nullptr; return itm; } @@ -2126,7 +2126,7 @@ void QTableWidget::setVerticalHeaderLabels(const QStringList &labels) { Q_D(QTableWidget); QTableModel *model = d->tableModel(); - QTableWidgetItem *item = 0; + QTableWidgetItem *item = nullptr; for (int i = 0; i < model->rowCount() && i < labels.count(); ++i) { item = model->verticalHeaderItem(i); if (!item) { @@ -2144,7 +2144,7 @@ void QTableWidget::setHorizontalHeaderLabels(const QStringList &labels) { Q_D(QTableWidget); QTableModel *model = d->tableModel(); - QTableWidgetItem *item = 0; + QTableWidgetItem *item = nullptr; for (int i = 0; i < model->columnCount() && i < labels.count(); ++i) { item = model->horizontalHeaderItem(i); if (!item) { diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 442369c2ec..9aba17be70 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1517,7 +1517,7 @@ void QTreeView::drawTree(QPainter *painter, const QRegion ®ion) const /// ### move to QObject :) static inline bool ancestorOf(QObject *widget, QObject *other) { - for (QObject *parent = other; parent != 0; parent = parent->parent()) { + for (QObject *parent = other; parent != nullptr; parent = parent->parent()) { if (parent == widget) return true; } @@ -1888,7 +1888,7 @@ void QTreeView::mousePressEvent(QMouseEvent *event) { Q_D(QTreeView); bool handled = false; - if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress) + if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonPress) handled = d->expandOrCollapseItemAtPos(event->pos()); if (!handled && d->itemDecorationAt(event->pos()) == -1) QAbstractItemView::mousePressEvent(event); @@ -1907,7 +1907,7 @@ void QTreeView::mouseReleaseEvent(QMouseEvent *event) } else { if (state() == QAbstractItemView::DragSelectingState || state() == QAbstractItemView::DraggingState) setState(QAbstractItemView::NoState); - if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonRelease) + if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, nullptr, this) == QEvent::MouseButtonRelease) d->expandOrCollapseItemAtPos(event->pos()); } } @@ -1944,7 +1944,7 @@ void QTreeView::mouseDoubleClickEvent(QMouseEvent *event) if (edit(persistent, DoubleClicked, event) || state() != NoState) return; // the double click triggered editing - if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, this)) + if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, this)) emit activated(persistent); d->pressedIndex = QModelIndex(); @@ -2208,7 +2208,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie d->collapse(vi, true); d->moveCursorUpdatedView = true; } else { - bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); + bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, nullptr, this); if (descend) { QModelIndex par = current.parent(); if (par.isValid() && par != rootIndex()) @@ -2244,7 +2244,7 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie d->expand(vi, true); d->moveCursorUpdatedView = true; } else { - bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, 0, this); + bool descend = style()->styleHint(QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren, nullptr, this); if (descend) { QModelIndex idx = d->modelIndex(d->below(vi)); if (idx.parent() == current) @@ -3051,7 +3051,7 @@ void QTreeViewPrivate::initialize() header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter); q->setHeader(header); #if QT_CONFIG(animation) - animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0; + animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, q) > 0; QObject::connect(&animatedOperation, SIGNAL(finished()), q, SLOT(_q_endAnimatedOperation())); #endif // animation } @@ -3344,7 +3344,7 @@ void QTreeViewPrivate::layout(int i, bool recursiveExpanding, bool afterIsUninit int hidden = 0; int last = 0; int children = 0; - QTreeViewItem *item = 0; + QTreeViewItem *item = nullptr; for (int j = first; j < first + count; ++j) { current = model->index(j - first, 0, parent); if (isRowHidden(current)) { @@ -3955,7 +3955,7 @@ int QTreeViewPrivate::accessibleTree2Index(const QModelIndex &index) const void QTreeViewPrivate::updateIndentationFromStyle() { Q_Q(const QTreeView); - indent = q->style()->pixelMetric(QStyle::PM_TreeViewIndentation, 0, q); + indent = q->style()->pixelMetric(QStyle::PM_TreeViewIndentation, nullptr, q); } /*! diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index cce0773fec..ddb31523fd 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -144,7 +144,7 @@ QTreeModel::~QTreeModel() clear(); headerItem->view = nullptr; delete headerItem; - rootItem->view = 0; + rootItem->view = nullptr; delete rootItem; } @@ -160,8 +160,8 @@ void QTreeModel::clear() beginResetModel(); for (int i = 0; i < rootItem->childCount(); ++i) { QTreeWidgetItem *item = rootItem->children.at(i); - item->par = 0; - item->view = 0; + item->par = nullptr; + item->view = nullptr; delete item; } rootItem->children.clear(); @@ -214,7 +214,7 @@ void QTreeModel::setColumnCount(int columns) QTreeWidgetItem *QTreeModel::item(const QModelIndex &index) const { if (!index.isValid()) - return 0; + return nullptr; return static_cast<QTreeWidgetItem*>(index.internalPointer()); } @@ -515,9 +515,9 @@ bool QTreeModel::removeRows(int row, int count, const QModelIndex &parent) { for (int i = row + count - 1; i >= row; --i) { QTreeWidgetItem *child = itm ? itm->takeChild(i) : rootItem->children.takeAt(i); Q_ASSERT(child); - child->view = 0; + child->view = nullptr; delete child; - child = 0; + child = nullptr; } blocker.unblock(); @@ -1612,11 +1612,11 @@ QTreeWidgetItem::~QTreeWidgetItem() } } else if (model) { if (this == model->headerItem) { - model->headerItem = 0; + model->headerItem = nullptr; } else { int i = model->rootItem->children.indexOf(this); if (i >= 0) { - model->beginRemoveItems(0, i, 1); + model->beginRemoveItems(nullptr, i, 1); // users _could_ do changes when connected to rowsAboutToBeRemoved, // so we check again to make sure 'i' is valid if (!model->rootItem->children.isEmpty() && model->rootItem->children.at(i) == this) @@ -1630,9 +1630,9 @@ QTreeWidgetItem::~QTreeWidgetItem() for (int i = 0; i < children.count(); ++i) { QTreeWidgetItem *child = children.at(i); // make sure the child does not try to remove itself from our children list - child->par = 0; + child->par = nullptr; // make sure the child does not try to remove itself from the top level list - child->view = 0; + child->view = nullptr; delete child; } @@ -1648,16 +1648,16 @@ QTreeWidgetItem::~QTreeWidgetItem() */ QTreeWidgetItem *QTreeWidgetItem::clone() const { - QTreeWidgetItem *copy = 0; + QTreeWidgetItem *copy = nullptr; QStack<const QTreeWidgetItem*> stack; QStack<QTreeWidgetItem*> parentStack; stack.push(this); parentStack.push(0); - QTreeWidgetItem *root = 0; - const QTreeWidgetItem *item = 0; - QTreeWidgetItem *parent = 0; + QTreeWidgetItem *root = nullptr; + const QTreeWidgetItem *item = nullptr; + QTreeWidgetItem *parent = nullptr; while (!stack.isEmpty()) { // get current item, and copied parent item = stack.pop(); @@ -1992,8 +1992,8 @@ void QTreeWidgetItem::write(QDataStream &out) const \sa data(), flags() */ QTreeWidgetItem::QTreeWidgetItem(const QTreeWidgetItem &other) - : rtti(Type), values(other.values), view(0), - d(new QTreeWidgetItemPrivate(this)), par(0), + : rtti(Type), values(other.values), view(nullptr), + d(new QTreeWidgetItemPrivate(this)), par(nullptr), itemFlags(other.itemFlags) { d->display = other.d->display; @@ -2036,14 +2036,14 @@ void QTreeWidgetItem::addChild(QTreeWidgetItem *child) */ void QTreeWidgetItem::insertChild(int index, QTreeWidgetItem *child) { - if (index < 0 || index > children.count() || child == 0 || child->view != 0 || child->par != 0) + if (index < 0 || index > children.count() || child == nullptr || child->view != nullptr || child->par != nullptr) return; if (QTreeModel *model = treeModel()) { const bool wasSkipSort = model->skipPendingSort; model->skipPendingSort = true; if (model->rootItem == this) - child->par = 0; + child->par = nullptr; else child->par = this; if (view->isSortingEnabled()) { @@ -2103,12 +2103,12 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) if (model) model->beginRemoveItems(this, index, 1); d->updateHiddenStatus(children.at(index), false); QTreeWidgetItem *item = children.takeAt(index); - item->par = 0; + item->par = nullptr; QStack<QTreeWidgetItem*> stack; stack.push(item); while (!stack.isEmpty()) { QTreeWidgetItem *i = stack.pop(); - i->view = 0; + i->view = nullptr; for (int c = 0; c < i->children.count(); ++c) stack.push(i->children.at(c)); } @@ -2116,7 +2116,7 @@ QTreeWidgetItem *QTreeWidgetItem::takeChild(int index) if (model) model->endRemoveRows(); return item; } - return 0; + return nullptr; } /*! @@ -2163,7 +2163,7 @@ void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &c stack.push(child); } if (model && (model->rootItem == this)) - child->par = 0; + child->par = nullptr; else child->par = this; } @@ -2206,12 +2206,12 @@ QList<QTreeWidgetItem*> QTreeWidgetItem::takeChildren() if (model) model->beginRemoveItems(this, 0, children.count()); for (int n = 0; n < children.count(); ++n) { QTreeWidgetItem *item = children.at(n); - item->par = 0; + item->par = nullptr; QStack<QTreeWidgetItem*> stack; stack.push(item); while (!stack.isEmpty()) { QTreeWidgetItem *i = stack.pop(); - i->view = 0; + i->view = nullptr; for (int c = 0; c < i->children.count(); ++c) stack.push(i->children.at(c)); } @@ -3306,7 +3306,7 @@ QTreeWidgetItem *QTreeWidget::itemAbove(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); if (item == d->treeModel()->headerItem) - return 0; + return nullptr; const QModelIndex index = d->index(item); const QModelIndex above = indexAbove(index); return d->item(above); @@ -3321,7 +3321,7 @@ QTreeWidgetItem *QTreeWidget::itemBelow(const QTreeWidgetItem *item) const { Q_D(const QTreeWidget); if (item == d->treeModel()->headerItem) - return 0; + return nullptr; const QModelIndex index = d->index(item); const QModelIndex below = indexBelow(index); return d->item(below); @@ -3424,14 +3424,14 @@ QMimeData *QTreeWidget::mimeData(const QList<QTreeWidgetItem*> items) const for (const auto *item : items) { if (Q_UNLIKELY(!item)) { qWarning("QTreeWidget::mimeData: Null-item passed"); - return 0; + return nullptr; } for (int c = 0; c < item->values.count(); ++c) { const QModelIndex index = indexFromItem(item, c); if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QTreeWidget::mimeData: No index associated with item :" << item; - return 0; + return nullptr; } indexes << index; } diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp index 14c19fcb9c..a24106d90e 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator.cpp +++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp @@ -90,7 +90,7 @@ QTreeWidgetItemIterator::QTreeWidgetItemIterator(const QTreeWidgetItemIterator & */ QTreeWidgetItemIterator::QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags) -: current(0), flags(flags) +: current(nullptr), flags(flags) { Q_ASSERT(widget); QTreeModel *model = qobject_cast<QTreeModel*>(widget->model()); @@ -266,7 +266,7 @@ bool QTreeWidgetItemIterator::matchesFlags(const QTreeWidgetItem *item) const QTreeWidgetItem* QTreeWidgetItemIteratorPrivate::nextSibling(const QTreeWidgetItem* item) const { Q_ASSERT(item); - QTreeWidgetItem *next = 0; + QTreeWidgetItem *next = nullptr; if (QTreeWidgetItem *par = item->parent()) { int i = par->indexOfChild(const_cast<QTreeWidgetItem*>(item)); next = par->child(i + 1); @@ -280,9 +280,9 @@ QTreeWidgetItem* QTreeWidgetItemIteratorPrivate::nextSibling(const QTreeWidgetIt QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *current) { - if (!current) return 0; + if (!current) return nullptr; - QTreeWidgetItem *next = 0; + QTreeWidgetItem *next = nullptr; if (current->childCount()) { // walk the child m_parentIndex.push(m_currentIndex); @@ -307,9 +307,9 @@ QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *cur QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::previous(const QTreeWidgetItem *current) { - if (!current) return 0; + if (!current) return nullptr; - QTreeWidgetItem *prev = 0; + QTreeWidgetItem *prev = nullptr; // walk the previous sibling QTreeWidgetItem *parent = current->parent(); prev = parent ? parent->child(m_currentIndex - 1) @@ -347,7 +347,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem * // we need to adjust the iterator. if (nextItem == itemToBeRemoved) { QTreeWidgetItem *parent = nextItem; - nextItem = 0; + nextItem = nullptr; while (parent && !nextItem) { nextItem = nextSibling(parent); parent = parent->parent(); @@ -358,7 +358,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem * if (!(q->matchesFlags(nextItem))) ++(*q); } else { // set it to null. - q->current = 0; + q->current = nullptr; m_parentIndex.clear(); return; } diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 19ad65692b..64b0d69f6d 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -658,7 +658,7 @@ void QAction::setMenu(QMenu *menu) { Q_D(QAction); if (d->menu) - d->menu->d_func()->setOverrideMenuAction(0); //we reset the default action of any previous menu + d->menu->d_func()->setOverrideMenuAction(nullptr); //we reset the default action of any previous menu d->menu = menu; if (menu) menu->d_func()->setOverrideMenuAction(this); diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index 1d9213de0c..5dc12c48a4 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -81,7 +81,7 @@ void QActionGroupPrivate::_q_actionChanged() current = action; } } else if (action == current) { - current = 0; + current = nullptr; } } } @@ -271,11 +271,11 @@ void QActionGroup::removeAction(QAction *action) Q_D(QActionGroup); if (d->actions.removeAll(action)) { if (action == d->current) - d->current = 0; + d->current = nullptr; QObject::disconnect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); QObject::disconnect(action, SIGNAL(changed()), this, SLOT(_q_actionChanged())); QObject::disconnect(action, SIGNAL(hovered()), this, SLOT(_q_actionHovered())); - action->d_func()->group = 0; + action->d_func()->group = nullptr; } } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6d4baacfef..57771b3e12 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -138,7 +138,7 @@ QT_BEGIN_NAMESPACE Q_CORE_EXPORT void qt_call_post_routines(); Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1); -QApplicationPrivate *QApplicationPrivate::self = 0; +QApplicationPrivate *QApplicationPrivate::self = nullptr; static void initSystemPalette() { @@ -158,7 +158,7 @@ static void initSystemPalette() static void clearSystemPalette() { delete QApplicationPrivate::sys_pal; - QApplicationPrivate::sys_pal = 0; + QApplicationPrivate::sys_pal = nullptr; } bool QApplicationPrivate::autoSipEnabled = true; @@ -169,8 +169,8 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) application_type = QApplicationPrivate::Gui; #ifndef QT_NO_GESTURES - gestureManager = 0; - gestureWidget = 0; + gestureManager = nullptr; + gestureWidget = nullptr; #endif // QT_NO_GESTURES if (!self) @@ -180,7 +180,7 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) QApplicationPrivate::~QApplicationPrivate() { if (self == this) - self = 0; + self = nullptr; } void QApplicationPrivate::createEventDispatcher() @@ -357,7 +357,7 @@ QWidget *QApplication::topLevelAt(const QPoint &pos) if (const QWidgetWindow *widgetWindow = qobject_cast<const QWidgetWindow *>(window)) return widgetWindow->widget(); } - return 0; + return nullptr; } /*! @@ -372,22 +372,22 @@ QWidget *QApplication::topLevelAt(const QPoint &pos) void qt_init_tooltip_palette(); void qt_cleanup(); -QStyle *QApplicationPrivate::app_style = 0; // default application style +QStyle *QApplicationPrivate::app_style = nullptr; // default application style #ifndef QT_NO_STYLE_STYLESHEET QString QApplicationPrivate::styleSheet; // default application stylesheet #endif -QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0; +QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr; -QPalette *QApplicationPrivate::sys_pal = 0; // default system palette -QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer +QPalette *QApplicationPrivate::sys_pal = nullptr; // default system palette +QPalette *QApplicationPrivate::set_pal = nullptr; // default palette set by programmer -QFont *QApplicationPrivate::sys_font = 0; // default system font -QFont *QApplicationPrivate::set_font = 0; // default font set by programmer +QFont *QApplicationPrivate::sys_font = nullptr; // default system font +QFont *QApplicationPrivate::set_font = nullptr; // default font set by programmer -QWidget *QApplicationPrivate::main_widget = 0; // main application widget -QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus -QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show() -QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus +QWidget *QApplicationPrivate::main_widget = nullptr; // main application widget +QWidget *QApplicationPrivate::focus_widget = nullptr; // has keyboard input focus +QWidget *QApplicationPrivate::hidden_focus_widget = nullptr; // will get keyboard input focus after show() +QWidget *QApplicationPrivate::active_window = nullptr; // toplevel with keyboard focus #if QT_CONFIG(wheelevent) QPointer<QWidget> QApplicationPrivate::wheel_widget; #endif @@ -419,9 +419,9 @@ Q_GLOBAL_STATIC(FontHash, app_fonts) PaletteHash *qt_app_palettes_hash() { return app_palettes(); } FontHash *qt_app_fonts_hash() { return app_fonts(); } -QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus +QWidgetList *QApplicationPrivate::popupWidgets = nullptr; // has keyboard input focus -QDesktopWidget *qt_desktopWidget = 0; // root window widgets +QDesktopWidget *qt_desktopWidget = nullptr; // root window widgets /*! \internal @@ -434,7 +434,7 @@ void QApplicationPrivate::process_cmdline() if (!styleOverride.isEmpty()) { if (app_style) { delete app_style; - app_style = 0; + app_style = nullptr; } } @@ -473,7 +473,7 @@ void QApplicationPrivate::process_cmdline() } if(j < argc) { - argv[j] = 0; + argv[j] = nullptr; argc = j; } } @@ -620,7 +620,7 @@ void QApplicationPrivate::initialize() static void setPossiblePalette(const QPalette *palette, const char *className) { - if (palette == 0) + if (palette == nullptr) return; QApplicationPrivate::setPalette_helper(*palette, className, false); } @@ -746,7 +746,7 @@ QWidget *QApplication::activePopupWidget() QWidget *QApplication::activeModalWidget() { QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow()); - return widgetWindow ? widgetWindow->widget() : 0; + return widgetWindow ? widgetWindow->widget() : nullptr; } /*! @@ -769,12 +769,12 @@ QApplication::~QApplication() QApplicationPrivate::is_app_running = false; delete QWidgetPrivate::mapper; - QWidgetPrivate::mapper = 0; + QWidgetPrivate::mapper = nullptr; // delete all widgets if (QWidgetPrivate::allWidgets) { QWidgetSet *mySet = QWidgetPrivate::allWidgets; - QWidgetPrivate::allWidgets = 0; + QWidgetPrivate::allWidgets = nullptr; for (QWidgetSet::ConstIterator it = mySet->constBegin(), cend = mySet->constEnd(); it != cend; ++it) { QWidget *w = *it; if (!w->parent()) // window @@ -784,23 +784,23 @@ QApplication::~QApplication() } delete qt_desktopWidget; - qt_desktopWidget = 0; + qt_desktopWidget = nullptr; delete QApplicationPrivate::app_pal; - QApplicationPrivate::app_pal = 0; + QApplicationPrivate::app_pal = nullptr; clearSystemPalette(); delete QApplicationPrivate::set_pal; - QApplicationPrivate::set_pal = 0; + QApplicationPrivate::set_pal = nullptr; app_palettes()->clear(); delete QApplicationPrivate::sys_font; - QApplicationPrivate::sys_font = 0; + QApplicationPrivate::sys_font = nullptr; delete QApplicationPrivate::set_font; - QApplicationPrivate::set_font = 0; + QApplicationPrivate::set_font = nullptr; app_fonts()->clear(); delete QApplicationPrivate::app_style; - QApplicationPrivate::app_style = 0; + QApplicationPrivate::app_style = nullptr; #if QT_CONFIG(draganddrop) if (qt_is_gui_used) @@ -846,7 +846,7 @@ void qt_cleanup() QPixmapCache::clear(); QColormap::cleanup(); - QApplicationPrivate::active_window = 0; //### this should not be necessary + QApplicationPrivate::active_window = nullptr; //### this should not be necessary #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) if (displayDC) { @@ -892,7 +892,7 @@ QWidget *QApplication::widgetAt(const QPoint &p) QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask) - QRegion(wpoint.x(), wpoint.y(), 1, 1); window->setMask(newmask); - QWidget *recurse = 0; + QWidget *recurse = nullptr; if (QApplication::topLevelAt(p) != window) // verify recursion will terminate recurse = widgetAt(x, y); if (oldmask.isEmpty()) @@ -925,7 +925,7 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis || event->type() == QEvent::LanguageChange)) { for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) { const QPostEvent &cur = *it; - if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type()) + if (cur.receiver != receiver || cur.event == nullptr || cur.event->type() != event->type()) continue; if (cur.event->type() == QEvent::LayoutRequest || cur.event->type() == QEvent::UpdateRequest) { @@ -1020,7 +1020,7 @@ QStyle *QApplication::style() return QApplicationPrivate::app_style; if (!qobject_cast<QApplication *>(QCoreApplication::instance())) { Q_ASSERT(!"No style available without QApplication!"); - return 0; + return nullptr; } if (!QApplicationPrivate::app_style) { @@ -1048,7 +1048,7 @@ QStyle *QApplication::style() } if (!app_style) { Q_ASSERT(!"No styles available!"); - return 0; + return nullptr; } } // take ownership of the style @@ -1202,7 +1202,7 @@ QStyle* QApplication::setStyle(const QString& style) { QStyle *s = QStyleFactory::create(style); if (!s) - return 0; + return nullptr; setStyle(s); return s; @@ -1695,7 +1695,7 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) return; #endif - hidden_focus_widget = 0; + hidden_focus_widget = nullptr; if (focus != focus_widget) { if (focus && focus->isHidden()) { @@ -1893,7 +1893,7 @@ bool QApplication::event(QEvent *e) #endif } else if (e->type() == QEvent::Timer) { QTimerEvent *te = static_cast<QTimerEvent*>(e); - Q_ASSERT(te != 0); + Q_ASSERT(te != nullptr); if (te->timerId() == d->toolTipWakeUp.timerId()) { d->toolTipWakeUp.stop(); if (d->toolTipWidget) { @@ -1905,14 +1905,14 @@ bool QApplication::event(QEvent *e) while (w && !showToolTip) { showToolTip = w->isActiveWindow(); w = w->parentWidget(); - w = w ? w->window() : 0; + w = w ? w->window() : nullptr; } if (showToolTip) { QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos); QCoreApplication::sendEvent(d->toolTipWidget, &e); if (e.isAccepted()) { QStyle *s = d->toolTipWidget->style(); - int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, 0, d->toolTipWidget, 0); + int sleepDelay = s->styleHint(QStyle::SH_ToolTip_FallAsleepDelay, nullptr, d->toolTipWidget, nullptr); d->toolTipFallAsleep.start(sleepDelay, this); } } @@ -1982,7 +1982,7 @@ void QApplicationPrivate::notifyLayoutDirectionChange() */ void QApplication::setActiveWindow(QWidget* act) { - QWidget* window = act?act->window():0; + QWidget* window = act?act->window():nullptr; if (QApplicationPrivate::active_window == window) return; @@ -1998,7 +1998,7 @@ void QApplication::setActiveWindow(QWidget* act) QWidgetList toBeDeactivated; if (QApplicationPrivate::active_window) { - if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) { + if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) { const QWidgetList list = topLevelWidgets(); for (auto *w : list) { if (w->isVisible() && w->isActiveWindow()) @@ -2020,7 +2020,7 @@ void QApplication::setActiveWindow(QWidget* act) QApplicationPrivate::active_window = window; if (QApplicationPrivate::active_window) { - if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) { + if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) { const QWidgetList list = topLevelWidgets(); for (auto *w : list) { if (w->isVisible() && w->isActiveWindow()) @@ -2049,10 +2049,10 @@ void QApplication::setActiveWindow(QWidget* act) sendSpontaneousEvent(w, &activationChange); } - if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode() + if (QApplicationPrivate::popupWidgets == nullptr) { // !inPopupMode() // then focus events if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) { - QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason); + QApplicationPrivate::setFocusWidget(nullptr, Qt::ActiveWindowFocusReason); } else if (QApplicationPrivate::active_window) { QWidget *w = QApplicationPrivate::active_window->focusWidget(); if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/) @@ -2067,7 +2067,7 @@ void QApplication::setActiveWindow(QWidget* act) if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus) QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason); else if (!QApplicationPrivate::active_window->isAncestorOf(w)) - QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason); + QApplicationPrivate::setFocusWidget(nullptr, Qt::ActiveWindowFocusReason); } } } @@ -2095,7 +2095,7 @@ QWidget *qt_tlw_for_window(QWindow *wnd) return tlw; } } - return 0; + return nullptr; } void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) @@ -2158,7 +2158,7 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool test = test->d_func()->focus_next; } - if (wrappingOccurred != 0) + if (wrappingOccurred != nullptr) *wrappingOccurred = next ? focusWidgetAfterWindow : !focusWidgetAfterWindow; if (w == f) { @@ -2166,7 +2166,7 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool w->window()->setAttribute(Qt::WA_KeyboardFocusChange); w->update(); } - return 0; + return nullptr; } return w; } @@ -2248,7 +2248,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con QEvent leaveEvent(QEvent::Leave); for (int i = 0; i < leaveList.size(); ++i) { auto *w = leaveList.at(i); - if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { + if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) { QCoreApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { @@ -2267,7 +2267,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con const QPoint windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos); for (auto it = enterList.crbegin(), end = enterList.crend(); it != end; ++it) { auto *w = *it; - if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { + if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) { const QPointF localPos = w->mapFromGlobal(globalPos); QEnterEvent enterEvent(localPos, windowPos, globalPosF); QCoreApplication::sendEvent(w, &enterEvent); @@ -2287,7 +2287,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen))); // Whenever we leave an alien widget on X11/QPA, we need to reset its nativeParentWidget()'s cursor. // This is not required on Windows as the cursor is reset on every single mouse move. - QWidget *parentOfLeavingCursor = 0; + QWidget *parentOfLeavingCursor = nullptr; for (int i = 0; i < leaveList.size(); ++i) { auto *w = leaveList.at(i); if (!isAlien(w)) @@ -2353,7 +2353,7 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const { - QWindow *unused = 0; + QWindow *unused = nullptr; if (Q_UNLIKELY(!window)) { qWarning().nospace() << "window == 0 passed."; return false; @@ -2362,13 +2362,13 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin blockingWindow = &unused; if (modalWindowList.isEmpty()) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } QWidget *popupWidget = QApplication::activePopupWidget(); - QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : 0; + QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : nullptr; if (popupWindow == window || (!popupWindow && QWindowPrivate::get(window)->isPopup())) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -2378,7 +2378,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin // A window is not blocked by another modal window if the two are // the same, or if the window is a child of the modal window. if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) { - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -2389,7 +2389,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin // modalWindow's widget, this normally happens when waiting for a // native dialog. use WindowModal if we are the child of a group // leader; otherwise use ApplicationModal. - QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; + QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : nullptr; while (m && !m->testAttribute(Qt::WA_GroupLeader)) { m = m->parentWidget(); if (m) @@ -2404,13 +2404,13 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin case Qt::ApplicationModal: { QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(window); - QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : 0; + QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : nullptr; while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) groupLeaderForWidget = groupLeaderForWidget->parentWidget(); if (groupLeaderForWidget) { // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children - QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; + QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : nullptr; while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) m = m->parentWidget(); if (m == groupLeaderForWidget) { @@ -2450,7 +2450,7 @@ bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWin break; } } - *blockingWindow = 0; + *blockingWindow = nullptr; return false; } @@ -2474,7 +2474,7 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) bool qt_try_modal(QWidget *widget, QEvent::Type type) { - QWidget * top = 0; + QWidget * top = nullptr; if (QApplicationPrivate::tryModalHelper(widget, &top)) return true; @@ -2499,7 +2499,7 @@ bool qt_try_modal(QWidget *widget, QEvent::Type type) break; } - if (block_event && top && top->parentWidget() == 0) + if (block_event && top && top->parentWidget() == nullptr) top->raise(); return !block_event; @@ -2523,11 +2523,11 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint QWidget *mouseGrabber = QWidget::mouseGrabber(); if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease)) && !buttonDown && !mouseGrabber) { - return 0; + return nullptr; } if (alienWidget && alienWidget->internalWinId()) - alienWidget = 0; + alienWidget = nullptr; QWidget *receiver = candidate; @@ -2560,7 +2560,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, Q_ASSERT(buttonDown); if (alienWidget && !isAlien(alienWidget)) - alienWidget = 0; + alienWidget = nullptr; QPointer<QWidget> receiverGuard = receiver; QPointer<QWidget> nativeGuard = nativeWidget; @@ -2575,7 +2575,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, // leaveAfterRelease has not been updated. // This happens e.g. when modal dialog or popup is shown as a response to button click. if (leaveAfterRelease && !*buttonDown && !event->buttons()) - leaveAfterRelease = 0; + leaveAfterRelease = nullptr; if (*buttonDown) { if (!graphicsWidget) { @@ -2584,7 +2584,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber()) leaveAfterRelease = *buttonDown; if (event->type() == QEvent::MouseButtonRelease && !event->buttons()) - *buttonDown = 0; + *buttonDown = nullptr; } } else if (lastMouseReceiver && widgetUnderMouse) { // Dispatch enter/leave if we move: @@ -2612,7 +2612,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, // We need this quard in case someone opens a modal dialog / popup. If that's the case // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver. - const bool wasLeaveAfterRelease = leaveAfterRelease != 0; + const bool wasLeaveAfterRelease = leaveAfterRelease != nullptr; bool result = true; // This code is used for sending the synthetic enter/leave events for cases where it is needed // due to other events causing the widget under the mouse to change. However in those cases @@ -2630,18 +2630,18 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, // Dispatch enter/leave if: // 1) the mouse grabber is an alien widget // 2) the button is released on an alien widget - QWidget *enter = 0; + QWidget *enter = nullptr; if (nativeGuard) enter = alienGuard ? alienWidget : nativeWidget; else // The receiver is typically deleted on mouse release with drag'n'drop. enter = QApplication::widgetAt(event->globalPos()); dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos()); - leaveAfterRelease = 0; + leaveAfterRelease = nullptr; lastMouseReceiver = enter; } else if (!wasLeaveAfterRelease) { if (activePopupWidget) { if (!QWidget::mouseGrabber()) - lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0); + lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : nullptr); } else { lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos()); } @@ -2696,7 +2696,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) return; // Mouse cursor not inside the widget or any of its children. if (widget->data->in_destructor && qt_button_down == widget) - qt_button_down = 0; + qt_button_down = nullptr; // A mouse move is not actually sent, but we utilize the sendMouseEvent() call to send the // enter/leave events as appropriate @@ -3048,9 +3048,9 @@ bool QApplication::notify(QObject *receiver, QEvent *e) key->accept(); else key->ignore(); - QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0; + QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : nullptr; #if QT_CONFIG(graphicsview) - QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0; + QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : nullptr; #endif res = d->notify_helper(receiver, e); @@ -3112,7 +3112,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) d->toolTipPos = relpos; d->toolTipGlobalPos = mouse->globalPos(); QStyle *s = d->toolTipWidget->style(); - int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, 0, d->toolTipWidget, 0); + int wakeDelay = s->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, d->toolTipWidget, nullptr); d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive() ? 20 : wakeDelay, this); } } @@ -3442,7 +3442,7 @@ QT_WARNING_POP && !isProxyWidget #endif ) - QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop); + QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop); } break; #endif @@ -3473,7 +3473,7 @@ QT_WARNING_POP eventAccepted = touchEvent->isAccepted(); if (p.isNull()) { // widget was deleted - widget = 0; + widget = nullptr; } else { widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); } @@ -3698,7 +3698,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) bool QApplicationPrivate::inPopupMode() { - return QApplicationPrivate::popupWidgets != 0; + return QApplicationPrivate::popupWidgets != nullptr; } static void ungrabKeyboardForPopup(QWidget *popup) @@ -3742,13 +3742,13 @@ void QApplicationPrivate::closePopup(QWidget *popup) popupWidgets->removeAll(popup); if (popup == qt_popup_down) { - qt_button_down = 0; - qt_popup_down = 0; + qt_button_down = nullptr; + qt_popup_down = nullptr; } if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup delete QApplicationPrivate::popupWidgets; - QApplicationPrivate::popupWidgets = 0; + QApplicationPrivate::popupWidgets = nullptr; if (popupGrabOk) { popupGrabOk = false; @@ -4116,7 +4116,7 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven { const bool setFocusOnRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease(); Qt::FocusPolicy focusPolicy = Qt::ClickFocus; - static QPointer<QWidget> focusedWidgetOnTouchBegin = 0; + static QPointer<QWidget> focusedWidgetOnTouchBegin = nullptr; switch (event->type()) { case QEvent::MouseButtonPress: @@ -4223,7 +4223,7 @@ QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, { const QPointF screenPos = touchPoint.screenPos(); int closestTouchPointId = -1; - QObject *closestTarget = 0; + QObject *closestTarget = nullptr; qreal closestDistance = qreal(0.); QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(), ite = activeTouchPoints.constEnd(); @@ -4309,7 +4309,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, if (!target) continue; } - Q_ASSERT(target.data() != 0); + Q_ASSERT(target.data() != nullptr); QWidget *targetWidget = static_cast<QWidget *>(target.data()); @@ -4335,7 +4335,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd(); for (; it != end; ++it) { const QPointer<QWidget> widget = it.key(); - if (!QApplicationPrivate::tryModalHelper(widget, 0)) + if (!QApplicationPrivate::tryModalHelper(widget, nullptr)) continue; QEvent::Type eventType; @@ -4462,7 +4462,7 @@ QGestureManager* QGestureManager::instance(InstanceCreation ic) { QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); if (!qAppPriv) - return 0; + return nullptr; if (!qAppPriv->gestureManager && ic == ForceCreation) qAppPriv->gestureManager = new QGestureManager(qApp); return qAppPriv->gestureManager; diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index 78d37f381e..7b09adfbf0 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -278,7 +278,7 @@ void QBoxLayoutPrivate::setupGeom() int fixedSpacing = q->spacing(); int previousNonEmptyIndex = -1; - QStyle *style = 0; + QStyle *style = nullptr; if (fixedSpacing < 0) { if (QWidget *parentWidget = q->parentWidget()) style = parentWidget->style(); @@ -318,7 +318,7 @@ void QBoxLayoutPrivate::setupGeom() if (style) { spacing = style->combinedLayoutSpacing(actual1, actual2, horz(dir) ? Qt::Horizontal : Qt::Vertical, - 0, q->parentWidget()); + nullptr, q->parentWidget()); if (spacing < 0) spacing = 0; } @@ -433,10 +433,10 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item) { Q_Q(QBoxLayout); if (!item) - return 0; + return nullptr; QBoxLayoutItem *b = list.value(index); if (!b) - return 0; + return nullptr; QLayoutItem *r = b->item; b->item = item; @@ -551,7 +551,7 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item) \sa direction() */ QBoxLayout::QBoxLayout(Direction dir, QWidget *parent) - : QLayout(*new QBoxLayoutPrivate, 0, parent) + : QLayout(*new QBoxLayoutPrivate, nullptr, parent) { Q_D(QBoxLayout); d->dir = dir; @@ -684,7 +684,7 @@ int QBoxLayout::minimumHeightForWidth(int w) const Q_D(const QBoxLayout); (void) heightForWidth(w); int top, bottom; - d->effectiveMargins(0, &top, 0, &bottom); + d->effectiveMargins(nullptr, &top, nullptr, &bottom); return d->hasHfw ? (d->hfwMinHeight + top + bottom) : -1; } @@ -713,7 +713,7 @@ int QBoxLayout::count() const QLayoutItem *QBoxLayout::itemAt(int index) const { Q_D(const QBoxLayout); - return index >= 0 && index < d->list.count() ? d->list.at(index)->item : 0; + return index >= 0 && index < d->list.count() ? d->list.at(index)->item : nullptr; } /*! @@ -723,16 +723,16 @@ QLayoutItem *QBoxLayout::takeAt(int index) { Q_D(QBoxLayout); if (index < 0 || index >= d->list.count()) - return 0; + return nullptr; QBoxLayoutItem *b = d->list.takeAt(index); QLayoutItem *item = b->item; - b->item = 0; + b->item = nullptr; delete b; if (QLayout *l = item->layout()) { // sanity check in case the user passed something weird to QObject::setParent() if (l->parent() == this) - l->setParent(0); + l->setParent(nullptr); } invalidate(); diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index 9e90adec46..9f98af86e3 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -205,7 +205,7 @@ QT_WARNING_POP } QDesktopWidget::QDesktopWidget() - : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) + : QWidget(*new QDesktopWidgetPrivate, nullptr, Qt::Desktop) { Q_D(QDesktopWidget); setObjectName(QLatin1String("desktop")); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index c2838083f3..4ffa226d7f 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -295,11 +295,11 @@ void QFormLayoutPrivate::updateSizes() bool expandH = false; bool expandV = false; - QFormLayoutItem *prevLbl = 0; - QFormLayoutItem *prevFld = 0; + QFormLayoutItem *prevLbl = nullptr; + QFormLayoutItem *prevFld = nullptr; QWidget *parent = q->parentWidget(); - QStyle *style = parent ? parent->style() : 0; + QStyle *style = parent ? parent->style() : nullptr; int userVSpacing = q->verticalSpacing(); int userHSpacing = wrapAllRows ? 0 : q->horizontalSpacing(); @@ -364,9 +364,9 @@ void QFormLayoutPrivate::updateSizes() QSizePolicy::ControlTypes fldtoptypes = QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType); if (label && lbltop) - label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); + label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); if (field && fldtop) - field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); + field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); } else { // Side by side.. we have to also consider the spacings to empty cells, which can strangely be more than // non empty cells.. @@ -380,21 +380,21 @@ void QFormLayoutPrivate::updateSizes() // To be compatible to QGridLayout, we have to compare solitary labels & fields with both predecessors if (label) { if (!field) { - int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); - int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, 0, parent); + int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); + int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, nullptr, parent); label->vSpace = qMax(lblspacing, fldspacing); } else - label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, 0, parent); + label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); } if (field) { // check spacing against both the previous label and field if (!label) { - int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, 0, parent); - int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); + int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, nullptr, parent); + int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); field->vSpace = qMax(lblspacing, fldspacing); } else - field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, 0, parent); + field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); } } } @@ -403,7 +403,7 @@ void QFormLayoutPrivate::updateSizes() // hard-coded the left and right control types so that all the rows have the same // inter-column spacing (otherwise the right column isn't always left aligned) if (userHSpacing < 0 && !wrapAllRows && (label || !field->fullRow) && field) - field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, 0, parent); + field->sbsHSpace = style->combinedLayoutSpacing(QSizePolicy::Label, QSizePolicy::LineEdit, Qt::Horizontal, nullptr, parent); } // Now update our min/sizehint widths @@ -594,13 +594,13 @@ static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing QSizePolicy::ControlTypes(item1 ? item1->controlTypes() : QSizePolicy::DefaultType); int spacing2 = 0; - spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, 0, parent); + spacing = style->combinedLayoutSpacing(itemtypes, prevItem1->controlTypes(), Qt::Vertical, nullptr, parent); // At most of one of item2 and prevItem2 will be nonnull if (item2) - spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, 0, parent); + spacing2 = style->combinedLayoutSpacing(item2->controlTypes(), prevItem1->controlTypes(), Qt::Vertical, nullptr, parent); else if (prevItem2) - spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, 0, parent); + spacing2 = style->combinedLayoutSpacing(itemtypes, prevItem2->controlTypes(), Qt::Vertical, nullptr, parent); spacing = qMax(spacing, spacing2); } @@ -648,7 +648,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) vLayouts.clear(); vLayouts.resize((2 * rr) + 2); // a max, some may be unused - QStyle *style = 0; + QStyle *style = nullptr; int userVSpacing = q->verticalSpacing(); @@ -676,8 +676,8 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) maxLabelWidth = width; } - QFormLayoutItem *prevItem1 = 0; - QFormLayoutItem *prevItem2 = 0; + QFormLayoutItem *prevItem1 = nullptr; + QFormLayoutItem *prevItem2 = nullptr; bool prevRowSplit = false; for (int i = 0; i < rr; ++i) { @@ -711,13 +711,13 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) initLayoutStruct(vLayouts[vidx], label); if (vidx > 1) - vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, 0, prevItem1, prevItem2); + vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, label, nullptr, prevItem1, prevItem2); label->vLayoutIndex = vidx; label->sideBySide = false; prevItem1 = label; - prevItem2 = 0; + prevItem2 = nullptr; if (vLayouts[vidx].stretch > 0) addTopBottomStretch = false; @@ -729,13 +729,13 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) initLayoutStruct(vLayouts[vidx], field); if (vidx > 1) - vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, 0, prevItem1, prevItem2); + vLayouts[vidx - 1].spacing = spacingHelper(q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field, nullptr, prevItem1, prevItem2); field->vLayoutIndex = vidx; field->sideBySide = false; prevItem1 = field; - prevItem2 = 0; + prevItem2 = nullptr; if (vLayouts[vidx].stretch > 0) addTopBottomStretch = false; @@ -758,7 +758,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) if (label->expandingDirections() & Qt::Vertical) expanding = true; - label->sideBySide = (field != 0); + label->sideBySide = (field != nullptr); label->vLayoutIndex = vidx; stretch1 = label->vStretch(); } @@ -790,7 +790,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) prevItem2 = field; } else { prevItem1 = field; - prevItem2 = 0; + prevItem2 = nullptr; } prevRowSplit = false; @@ -991,12 +991,12 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) { Q_Q(QFormLayout); if (!newitem) - return 0; + return nullptr; const int storageIndex = storageIndexFromLayoutItem(m_matrix, m_things.value(index)); if (Q_UNLIKELY(storageIndex == -1)) { // ### Qt6 - fix warning too when this class becomes public qWarning("QFormLayoutPrivate::replaceAt: Invalid index %d", index); - return 0; + return nullptr; } int row, col; @@ -1192,7 +1192,7 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem) \sa QWidget::setLayout() */ QFormLayout::QFormLayout(QWidget *parent) - : QLayout(*new QFormLayoutPrivate, 0, parent) + : QLayout(*new QFormLayoutPrivate, nullptr, parent) { } @@ -1328,7 +1328,7 @@ void QFormLayout::insertRow(int row, const QString &labelText, QWidget *field) if (field && !d->checkWidget(field)) return; - QLabel *label = 0; + QLabel *label = nullptr; if (!labelText.isEmpty()) { label = new QLabel(labelText); #ifndef QT_NO_SHORTCUT @@ -1350,7 +1350,7 @@ void QFormLayout::insertRow(int row, const QString &labelText, QLayout *field) if (field && !d->checkLayout(field)) return; - insertRow(row, labelText.isEmpty() ? 0 : new QLabel(labelText), field); + insertRow(row, labelText.isEmpty() ? nullptr : new QLabel(labelText), field); } /*! @@ -1653,7 +1653,7 @@ QLayoutItem *QFormLayout::itemAt(int index) const Q_D(const QFormLayout); if (QFormLayoutItem *formItem = d->m_things.value(index)) return formItem->item; - return 0; + return nullptr; } /*! @@ -1666,7 +1666,7 @@ QLayoutItem *QFormLayout::takeAt(int index) const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(index)); if (Q_UNLIKELY(storageIndex == -1)) { qWarning("QFormLayout::takeAt: Invalid index %d", index); - return 0; + return nullptr; } int row, col; @@ -1831,7 +1831,7 @@ QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const { Q_D(const QFormLayout); if (uint(row) >= uint(d->m_matrix.rowCount())) - return 0; + return nullptr; switch (role) { case SpanningRole: if (QFormLayoutItem *item = d->m_matrix(row, 1)) @@ -1844,7 +1844,7 @@ QLayoutItem *QFormLayout::itemAt(int row, ItemRole role) const return item->item; break; } - return 0; + return nullptr; } /*! @@ -1928,7 +1928,7 @@ QWidget *QFormLayout::labelForField(QWidget *field) const if (QFormLayoutItem *label = d->m_matrix(row, LabelRole)) return label->widget(); } - return 0; + return nullptr; } /*! @@ -1947,7 +1947,7 @@ QWidget *QFormLayout::labelForField(QLayout *field) const if (QFormLayoutItem *label = d->m_matrix(row, LabelRole)) return label->widget(); } - return 0; + return nullptr; } /*! diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index fc715687c6..84dbed7043 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -879,7 +879,7 @@ int QTapAndHoldGesturePrivate::Timeout = 700; // in ms Creates new QGestureEvent containing a list of \a gestures. */ QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures) - : QEvent(QEvent::Gesture), m_gestures(gestures), m_widget(0) + : QEvent(QEvent::Gesture), m_gestures(gestures), m_widget(nullptr) { } @@ -907,7 +907,7 @@ QGesture *QGestureEvent::gesture(Qt::GestureType type) const for (int i = 0; i < m_gestures.size(); ++i) if (m_gestures.at(i)->gestureType() == type) return m_gestures.at(i); - return 0; + return nullptr; } /*! diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index d0c6b882b5..5604391059 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -188,7 +188,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni // from the destructor. if (object->isWidgetType()) { if (static_cast<QWidget *>(object)->d_func()->data.in_destructor) - return 0; + return nullptr; } else if (QGesture *g = qobject_cast<QGesture *>(object)) { return g; #if QT_CONFIG(graphicsview) @@ -196,7 +196,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni Q_ASSERT(qobject_cast<QGraphicsObject *>(object)); QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(object); if (graphicsObject->QGraphicsItem::d_func()->inDestructor) - return 0; + return nullptr; #endif } @@ -210,7 +210,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni Q_ASSERT(recognizer); QGesture *state = recognizer->create(object); if (!state) - return 0; + return nullptr; state->setParent(this); if (state->gestureType() == Qt::CustomGesture) { // if the recognizer didn't fill in the gesture type, then this @@ -454,13 +454,13 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original) // sort them per target widget by cherry picking from almostCanceledGestures and delivering QSet<QGesture *> almostCanceledGestures = cancelledGestures; while (!almostCanceledGestures.isEmpty()) { - QWidget *target = 0; + QWidget *target = nullptr; QSet<QGesture*> gestures; iter = almostCanceledGestures.begin(); // sort per target widget while (iter != almostCanceledGestures.end()) { QWidget *widget = m_gestureTargets.value(*iter); - if (target == 0) + if (target == nullptr) target = widget; if (target == widget) { gestures << *iter; @@ -508,7 +508,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) } } // find all gesture contexts for the widget tree - w = w->isWindow() ? 0 : w->parentWidget(); + w = w->isWindow() ? nullptr : w->parentWidget(); while (w) { for (ContextIterator it = w->d_func()->gestureContext.constBegin(), @@ -587,7 +587,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures, // sort gestures by types foreach (QGesture *gesture, gestures) { - QWidget *receiver = m_gestureTargets.value(gesture, 0); + QWidget *receiver = m_gestureTargets.value(gesture, nullptr); Q_ASSERT(receiver); if (receiver) gestureByTypes[gesture->gestureType()].insert(receiver, gesture); @@ -611,7 +611,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures, } } if (w->isWindow()) { - w = 0; + w = nullptr; break; } w = w->parentWidget(); @@ -637,7 +637,7 @@ void QGestureManager::deliverEvents(const QSet<QGesture *> &gestures, for (QSet<QGesture *>::const_iterator it = gestures.begin(), e = gestures.end(); it != e; ++it) { QGesture *gesture = *it; - QWidget *target = m_gestureTargets.value(gesture, 0); + QWidget *target = m_gestureTargets.value(gesture, nullptr); if (!target) { // the gesture has just started and doesn't have a target yet. Q_ASSERT(gesture->state() == Qt::GestureStarted); diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index 4f2b505e32..b4ac263c2b 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -84,7 +84,7 @@ public: Qt::Alignment alignment() const { return item_->alignment(); } QLayoutItem *item() { return item_; } void setItem(QLayoutItem *newitem) { item_ = newitem; } - QLayoutItem *takeItem() { QLayoutItem *i = item_; item_ = 0; return i; } + QLayoutItem *takeItem() { QLayoutItem *i = item_; item_ = nullptr; return i; } int hStretch() { return item_->widget() ? item_->widget()->sizePolicy().horizontalStretch() : 0; } @@ -152,7 +152,7 @@ public: if (index < things.count()) return things.at(index)->item(); else - return 0; + return nullptr; } inline QLayoutItem *takeAt(int index) { Q_Q(QGridLayout); @@ -162,19 +162,19 @@ public: if (QLayout *l = item->layout()) { // sanity check in case the user passed something weird to QObject::setParent() if (l->parent() == q) - l->setParent(0); + l->setParent(nullptr); } delete b; return item; } } - return 0; + return nullptr; } QLayoutItem* replaceAt(int index, QLayoutItem *newitem) override { if (!newitem) - return 0; - QLayoutItem *item = 0; + return nullptr; + QLayoutItem *item = nullptr; QGridBox *b = things.value(index); if (b) { item = b->takeItem(); @@ -342,7 +342,7 @@ QGridLayoutPrivate::QGridLayoutPrivate() setDirty(); rr = cc = 0; nextR = nextC = 0; - hfwData = 0; + hfwData = nullptr; hReversed = false; vReversed = false; horizontalSpacing = -1; @@ -429,7 +429,7 @@ int QGridLayoutPrivate::minimumHeightForWidth(int w, int hSpacing, int vSpacing) if (!has_hfw) return -1; int top, bottom; - effectiveMargins(0, &top, 0, &bottom); + effectiveMargins(nullptr, &top, nullptr, &bottom); return hfw_minheight + top + bottom; } @@ -521,7 +521,7 @@ void QGridLayoutPrivate::setSize(int r, int c) if (hfwData && (int)hfwData->size() < r) { delete hfwData; - hfwData = 0; + hfwData = nullptr; hfw_width = -1; } rr = r; @@ -710,14 +710,14 @@ void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain, qSwap(numRows, numColumns); } - QStyle *style = 0; + QStyle *style = nullptr; if (fixedSpacing < 0) { if (QWidget *parentWidget = q->parentWidget()) style = parentWidget->style(); } for (int c = 0; c < numColumns; ++c) { - QGridBox *previousBox = 0; + QGridBox *previousBox = nullptr; int previousRow = -1; // previous *non-empty* row for (int r = 0; r < numRows; ++r) { @@ -741,7 +741,7 @@ void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain, if (style) spacing = style->combinedLayoutSpacing(controlTypes1, controlTypes2, - orientation, 0, q->parentWidget()); + orientation, nullptr, q->parentWidget()); } else { if (orientation == Qt::Vertical) { QGridBox *sibling = vReversed ? previousBox : box; @@ -1075,7 +1075,7 @@ QRect QGridLayoutPrivate::cellRect(int row, int col) const new items are inserted. */ QGridLayout::QGridLayout(QWidget *parent) - : QLayout(*new QGridLayoutPrivate, 0, parent) + : QLayout(*new QGridLayoutPrivate, nullptr, parent) { Q_D(QGridLayout); d->expand(1, 1); @@ -1089,7 +1089,7 @@ QGridLayout::QGridLayout(QWidget *parent) will not be performed before this is inserted into another layout. */ QGridLayout::QGridLayout() - : QLayout(*new QGridLayoutPrivate, 0, 0) + : QLayout(*new QGridLayoutPrivate, nullptr, nullptr) { Q_D(QGridLayout); d->expand(1, 1); diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index f0f4fc5505..d4ff9083f1 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -130,7 +130,7 @@ QLayout::QLayout(QWidget *parent) management will work. */ QLayout::QLayout() - : QObject(*new QLayoutPrivate, 0) + : QObject(*new QLayoutPrivate, nullptr) { } @@ -149,14 +149,14 @@ QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w) " already has a layout", qUtf16Printable(QObject::objectName()), w->metaObject()->className(), qUtf16Printable(w->objectName())); - setParent(0); + setParent(nullptr); } else { d->topLevel = true; w->d_func()->layout = this; QT_TRY { invalidate(); } QT_CATCH(...) { - w->d_func()->layout = 0; + w->d_func()->layout = nullptr; QT_RETHROW; } } @@ -166,7 +166,7 @@ QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w) QLayoutPrivate::QLayoutPrivate() : QObjectPrivate(), insideSpacing(-1), userLeftMargin(-1), userTopMargin(-1), userRightMargin(-1), userBottomMargin(-1), topLevel(false), enabled(true), activated(true), autoNewChild(false), - constraint(QLayout::SetDefaultConstraint), menubar(0) + constraint(QLayout::SetDefaultConstraint), menubar(nullptr) { } @@ -181,7 +181,7 @@ void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric } else if (!topLevel) { *result = 0; } else if (QWidget *pw = q->parentWidget()) { - *result = pw->style()->pixelMetric(pm, 0, pw); + *result = pw->style()->pixelMetric(pm, nullptr, pw); } else { *result = 0; } @@ -189,8 +189,8 @@ void QLayoutPrivate::getMargin(int *result, int userMargin, QStyle::PixelMetric // Static item factory functions that allow for hooking things in Designer -QLayoutPrivate::QWidgetItemFactoryMethod QLayoutPrivate::widgetItemFactoryMethod = 0; -QLayoutPrivate::QSpacerItemFactoryMethod QLayoutPrivate::spacerItemFactoryMethod = 0; +QLayoutPrivate::QWidgetItemFactoryMethod QLayoutPrivate::widgetItemFactoryMethod = nullptr; +QLayoutPrivate::QSpacerItemFactoryMethod QLayoutPrivate::spacerItemFactoryMethod = nullptr; QWidgetItem *QLayoutPrivate::createWidgetItem(const QLayout *layout, QWidget *widget) { @@ -624,7 +624,7 @@ void QLayout::widgetEvent(QEvent *e) if (c->child()->isWidgetType()) { #if QT_CONFIG(menubar) if (c->child() == d->menubar) - d->menubar = 0; + d->menubar = nullptr; #endif removeWidgetRecursively(this, c->child()); } @@ -764,7 +764,7 @@ QLayout::~QLayout() { Q_D(QLayout); if (d->topLevel && parent() && parent()->isWidgetType() && parentWidget()->layout() == this) - parentWidget()->d_func()->layout = 0; + parentWidget()->d_func()->layout = nullptr; else if (QLayout *parentLayout = qobject_cast<QLayout *>(parent())) parentLayout->removeItem(this); } @@ -919,7 +919,7 @@ void QLayout::addChildWidget(QWidget *w) qWarning("QLayout::addChildWidget: %s \"%ls\" in wrong parent; moved to correct parent", w->metaObject()->className(), qUtf16Printable(w->objectName())); #endif - pw = 0; + pw = nullptr; } bool needShow = mw && mw->isVisible() && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide)); if (!pw && mw) @@ -1153,12 +1153,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt { Q_D(QLayout); if (!from || !to) - return 0; + return nullptr; if (from == to) // Do not return a QLayoutItem for \a from, since ownership still return nullptr; // belongs to the layout (since nothing was changed) int index = -1; - QLayoutItem *item = 0; + QLayoutItem *item = nullptr; for (int u = 0; u < count(); ++u) { item = itemAt(u); if (!item) @@ -1176,7 +1176,7 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt } } if (index == -1) - return 0; + return nullptr; addChildWidget(to); QLayoutItem *newitem = new QWidgetItem(to); diff --git a/src/widgets/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp index 92b362e89d..83bbd69b55 100644 --- a/src/widgets/kernel/qlayoutengine.cpp +++ b/src/widgets/kernel/qlayoutengine.cpp @@ -440,7 +440,7 @@ Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm return -1; } else if (parent->isWidgetType()) { QWidget *pw = static_cast<QWidget *>(parent); - return pw->style()->pixelMetric(pm, 0, pw); + return pw->style()->pixelMetric(pm, nullptr, pw); } else { return static_cast<QLayout *>(parent)->spacing(); } diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index fc02afb014..af5750771d 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -778,7 +778,7 @@ QWidgetItemV2::QWidgetItemV2(QWidget *widget) q_cachedMaximumSize(Dirty, Dirty), q_firstCachedHfw(0), q_hfwCacheSize(0), - d(0) + d(nullptr) { QWidgetPrivate *wd = wid->d_func(); if (!wd->widgetItem) @@ -790,7 +790,7 @@ QWidgetItemV2::~QWidgetItemV2() if (wid) { auto *wd = static_cast<QWidgetPrivate *>(QObjectPrivate::get(wid)); if (wd->widgetItem == this) - wd->widgetItem = 0; + wd->widgetItem = nullptr; } } diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index bc5ca21b97..90622fd21e 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -555,16 +555,16 @@ class QOpenGLWidgetPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QOpenGLWidget) public: QOpenGLWidgetPrivate() - : context(0), - fbo(0), - resolvedFbo(0), - surface(0), + : context(nullptr), + fbo(nullptr), + resolvedFbo(nullptr), + surface(nullptr), initialized(false), fakeHidden(false), inBackingStorePaint(false), hasBeenComposed(false), flushPending(false), - paintDevice(0), + paintDevice(nullptr), updateBehavior(QOpenGLWidget::NoPartialUpdate), requestedSamples(0), inPaintGL(false), @@ -704,11 +704,11 @@ void QOpenGLWidgetPrivate::reset() q->makeCurrent(); delete paintDevice; - paintDevice = 0; + paintDevice = nullptr; delete fbo; - fbo = 0; + fbo = nullptr; delete resolvedFbo; - resolvedFbo = 0; + resolvedFbo = nullptr; if (initialized) q->doneCurrent(); @@ -717,9 +717,9 @@ void QOpenGLWidgetPrivate::reset() // the context's aboutToBeDestroyed() may still call makeCurrent() // to perform some cleanup. delete context; - context = 0; + context = nullptr; delete surface; - surface = 0; + surface = nullptr; initialized = fakeHidden = inBackingStorePaint = false; } @@ -732,9 +732,9 @@ void QOpenGLWidgetPrivate::recreateFbo() context->makeCurrent(surface); delete fbo; - fbo = 0; + fbo = nullptr; delete resolvedFbo; - resolvedFbo = 0; + resolvedFbo = nullptr; int samples = requestedSamples; QOpenGLExtensions *extfuncs = static_cast<QOpenGLExtensions *>(context->functions()); @@ -1421,7 +1421,7 @@ QPaintEngine *QOpenGLWidget::paintEngine() const return QWidget::paintEngine(); if (!d->initialized) - return 0; + return nullptr; return d->paintDevice->paintEngine(); } diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 0412dc188d..f87fe96cc0 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -61,11 +61,11 @@ QLayoutItem* QStackedLayoutPrivate::replaceAt(int idx, QLayoutItem *newitem) { Q_Q(QStackedLayout); if (idx < 0 || idx >= list.size() || !newitem) - return 0; + return nullptr; QWidget *wdg = newitem->widget(); if (Q_UNLIKELY(!wdg)) { qWarning("QStackedLayout::replaceAt: Only widgets can be added"); - return 0; + return nullptr; } QLayoutItem *orgitem = list.at(idx); list.replace(idx, newitem); @@ -154,7 +154,7 @@ QLayoutItem* QStackedLayoutPrivate::replaceAt(int idx, QLayoutItem *newitem) \sa addWidget(), insertWidget() */ QStackedLayout::QStackedLayout() - : QLayout(*new QStackedLayoutPrivate, 0, 0) + : QLayout(*new QStackedLayoutPrivate, nullptr, nullptr) { } @@ -165,7 +165,7 @@ QStackedLayout::QStackedLayout() manage the geometry of its children. */ QStackedLayout::QStackedLayout(QWidget *parent) - : QLayout(*new QStackedLayoutPrivate, 0, parent) + : QLayout(*new QStackedLayoutPrivate, nullptr, parent) { } @@ -174,7 +174,7 @@ QStackedLayout::QStackedLayout(QWidget *parent) the given \a parentLayout. */ QStackedLayout::QStackedLayout(QLayout *parentLayout) - : QLayout(*new QStackedLayoutPrivate, parentLayout, 0) + : QLayout(*new QStackedLayoutPrivate, parentLayout, nullptr) { } @@ -264,7 +264,7 @@ QLayoutItem *QStackedLayout::takeAt(int index) { Q_D(QStackedLayout); if (index <0 || index >= d->list.size()) - return 0; + return nullptr; QLayoutItem *item = d->list.takeAt(index); if (index == d->index) { d->index = -1; @@ -307,7 +307,7 @@ void QStackedLayout::setCurrentIndex(int index) parent->setUpdatesEnabled(false); } - QPointer<QWidget> fw = parent ? parent->window()->focusWidget() : 0; + QPointer<QWidget> fw = parent ? parent->window()->focusWidget() : nullptr; const bool focusWasOnOldPage = fw && (prev && prev->isAncestorOf(fw)); if (prev) { diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 97a279d65d..b290713440 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -151,7 +151,7 @@ public slots: */ void styleSheetParentDestroyed() { setProperty("_q_stylesheet_parent", QVariant()); - styleSheetParent = 0; + styleSheetParent = nullptr; } private: @@ -163,11 +163,11 @@ private: QRect rect; }; -QTipLabel *QTipLabel::instance = 0; +QTipLabel *QTipLabel::instance = nullptr; QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime) #ifndef QT_NO_STYLE_STYLESHEET - : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(0), widget(0) + : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(nullptr), widget(nullptr) #else : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), widget(0) #endif @@ -178,12 +178,12 @@ QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int mse setBackgroundRole(QPalette::ToolTipBase); setPalette(QToolTip::palette()); ensurePolished(); - setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this)); + setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, this)); setFrameStyle(QFrame::NoFrame); setAlignment(Qt::AlignLeft); setIndent(1); qApp->installEventFilter(this); - setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); + setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, nullptr, this) / 255.0); setMouseTracking(true); fadingOut = false; reuseTip(text, msecDisplayTime, pos); @@ -204,7 +204,7 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint if (styleSheetParent){ disconnect(styleSheetParent, SIGNAL(destroyed()), QTipLabel::instance, SLOT(styleSheetParentDestroyed())); - styleSheetParent = 0; + styleSheetParent = nullptr; } #endif @@ -278,7 +278,7 @@ void QTipLabel::mouseMoveEvent(QMouseEvent *e) QTipLabel::~QTipLabel() { - instance = 0; + instance = nullptr; } void QTipLabel::hideTip() @@ -547,7 +547,7 @@ void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w) */ bool QToolTip::isVisible() { - return (QTipLabel::instance != 0 && QTipLabel::instance->isVisible()); + return (QTipLabel::instance != nullptr && QTipLabel::instance->isVisible()); } /*! diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 228ca4d38a..8a632a395a 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -163,7 +163,7 @@ private: QPixmap background; }; -QWhatsThat *QWhatsThat::instance = 0; +QWhatsThat *QWhatsThat::instance = nullptr; // shadowWidth not const, for XP drop-shadow-fu turns it to 0 static int shadowWidth = 6; // also used as '5' and '6' and even '8' below @@ -193,7 +193,7 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor setCursor(Qt::ArrowCursor); #endif QRect r; - doc = 0; + doc = nullptr; ensurePolished(); // Ensures style sheet font before size calc if (Qt::mightBeRichText(text)) { doc = new QTextDocument(); @@ -229,7 +229,7 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor QWhatsThat::~QWhatsThat() { - instance = 0; + instance = nullptr; if (doc) delete doc; } @@ -383,7 +383,7 @@ void QWhatsThisPrivate::notifyToplevels(QEvent *e) QCoreApplication::sendEvent(w, e); } -QWhatsThisPrivate *QWhatsThisPrivate::instance = 0; +QWhatsThisPrivate *QWhatsThisPrivate::instance = nullptr; QWhatsThisPrivate::QWhatsThisPrivate() : leaveOnMouseRelease(false) @@ -423,7 +423,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate() QAccessibleEvent event(this, QAccessible::ContextHelpEnd); QAccessible::updateAccessibility(&event); #endif - instance = 0; + instance = nullptr; } bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) @@ -497,7 +497,7 @@ class QWhatsThisAction: public QAction Q_OBJECT public: - explicit QWhatsThisAction(QObject* parent = 0); + explicit QWhatsThisAction(QObject* parent = nullptr); private slots: void actionTriggered(); @@ -553,7 +553,7 @@ void QWhatsThis::enterWhatsThisMode() */ bool QWhatsThis::inWhatsThisMode() { - return (QWhatsThisPrivate::instance != 0); + return (QWhatsThisPrivate::instance != nullptr); } /*! @@ -577,7 +577,7 @@ void QWhatsThisPrivate::say(QWidget * widget, const QString &text, int x, int y) if (text.size() == 0) return; // make a fresh widget, and set it up - QWhatsThat *whatsThat = new QWhatsThat(text, 0, widget); + QWhatsThat *whatsThat = new QWhatsThat(text, nullptr, widget); // okay, now to find a suitable location int scr = (widget ? diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 9099805cf8..9080c530c7 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -132,16 +132,16 @@ extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp QWidgetPrivate::QWidgetPrivate(int version) : QObjectPrivate(version) - , focus_next(0) - , focus_prev(0) - , focus_child(0) - , layout(0) - , needsFlush(0) - , redirectDev(0) - , widgetItem(0) - , extraPaintEngine(0) - , polished(0) - , graphicsEffect(0) + , focus_next(nullptr) + , focus_prev(nullptr) + , focus_child(nullptr) + , layout(nullptr) + , needsFlush(nullptr) + , redirectDev(nullptr) + , widgetItem(nullptr) + , extraPaintEngine(nullptr) + , polished(nullptr) + , graphicsEffect(nullptr) #if !defined(QT_NO_IM) , imHints(Qt::ImhNone) #endif @@ -159,7 +159,7 @@ QWidgetPrivate::QWidgetPrivate(int version) , topLayoutItemMargin(0) , rightLayoutItemMargin(0) , bottomLayoutItemMargin(0) - , hd(0) + , hd(nullptr) , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred) , fg_role(QPalette::NoRole) , bg_role(QPalette::NoRole) @@ -214,7 +214,7 @@ QWidgetPrivate::QWidgetPrivate(int version) QWidgetPrivate::~QWidgetPrivate() { if (widgetItem) - widgetItem->wid = 0; + widgetItem->wid = nullptr; if (extra) deleteExtra(); @@ -819,8 +819,8 @@ void QWidget::setAutoFillBackground(bool enabled) */ -QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid -QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid +QWidgetMapper *QWidgetPrivate::mapper = nullptr; // widget with wid +QWidgetSet *QWidgetPrivate::allWidgets = nullptr; // widgets with no wid /***************************************************************************** @@ -890,7 +890,7 @@ struct QWidgetExceptionCleaner \sa windowFlags */ QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) - : QObject(*new QWidgetPrivate, 0), QPaintDevice() + : QObject(*new QWidgetPrivate, nullptr), QPaintDevice() { QT_TRY { d_func()->init(parent, f); @@ -904,7 +904,7 @@ QWidget::QWidget(QWidget *parent, Qt::WindowFlags f) /*! \internal */ QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f) - : QObject(dd, 0), QPaintDevice() + : QObject(dd, nullptr), QPaintDevice() { Q_D(QWidget); QT_TRY { @@ -996,7 +996,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) if (parentWidget && parentWidget->windowType() == Qt::Desktop) { const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(parentWidget); targetScreen = sw ? sw->screenNumber() : 0; - parentWidget = 0; + parentWidget = nullptr; } q->data = &data; @@ -1072,7 +1072,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) QCoreApplication::sendEvent(q, &e); QCoreApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); - extraPaintEngine = 0; + extraPaintEngine = nullptr; } void QWidgetPrivate::createRecursively() @@ -1307,9 +1307,9 @@ void QWidgetPrivate::create() if (nativeParent->windowHandle()) { if (flags & Qt::Window) { win->setTransientParent(nativeParent->window()->windowHandle()); - win->setParent(0); + win->setParent(nullptr); } else { - win->setTransientParent(0); + win->setTransientParent(nullptr); win->setParent(nativeParent->windowHandle()); } } @@ -1442,7 +1442,7 @@ QWidget::~QWidget() // delete layout while we still are a valid widget delete d->layout; - d->layout = 0; + d->layout = nullptr; // Remove myself from focus list Q_ASSERT(d->focus_next->d_func()->focus_prev == this); @@ -1451,7 +1451,7 @@ QWidget::~QWidget() if (d->focus_next != this) { d->focus_next->d_func()->focus_prev = d->focus_prev; d->focus_prev->d_func()->focus_next = d->focus_next; - d->focus_next = d->focus_prev = 0; + d->focus_next = d->focus_prev = nullptr; } @@ -1493,7 +1493,7 @@ QWidget::~QWidget() } delete d->needsFlush; - d->needsFlush = 0; + d->needsFlush = nullptr; // The next 20 lines are duplicated from QObject, but required here // since QWidget deletes is children itself @@ -1520,7 +1520,7 @@ QWidget::~QWidget() if (QAbstractDeclarativeData::destroyed) QAbstractDeclarativeData::destroyed(d->declarativeData, this); } - d->declarativeData = 0; // don't activate again in ~QObject + d->declarativeData = nullptr; // don't activate again in ~QObject d->wasDeleted = false; } @@ -1564,7 +1564,7 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier // will have the same windowid (the root window id) as the // qt_desktopWidget. We should not add the second desktop widget // to the mapper. - bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop; + bool userDesktopWidget = qt_desktopWidget != nullptr && qt_desktopWidget != q && q->windowType() == Qt::Desktop; if (mapper && data.winid && !userDesktopWidget) { mapper->remove(data.winid); } @@ -1589,8 +1589,8 @@ void QWidgetPrivate::createTLExtra() if (!extra->topextra) { extra->topextra = qt_make_unique<QTLWExtra>(); QTLWExtra* x = extra->topextra.get(); - x->backingStore = 0; - x->sharedPainter = 0; + x->backingStore = nullptr; + x->sharedPainter = nullptr; x->incw = x->inch = 0; x->basew = x->baseh = 0; x->frameStrut.setCoords(0, 0, 0, 0); @@ -1601,7 +1601,7 @@ void QWidgetPrivate::createTLExtra() x->sizeAdjusted = false; x->inTopLevelResize = false; x->embedded = 0; - x->window = 0; + x->window = nullptr; x->initialScreenIndex = -1; #ifdef QWIDGET_EXTRA_DEBUG @@ -1620,9 +1620,9 @@ void QWidgetPrivate::createExtra() { if (!extra) { // if not exists extra = qt_make_unique<QWExtra>(); - extra->glContext = 0; + extra->glContext = nullptr; #if QT_CONFIG(graphicsview) - extra->proxyWidget = 0; + extra->proxyWidget = nullptr; #endif extra->minw = 0; extra->minh = 0; @@ -1681,7 +1681,7 @@ static void deleteBackingStore(QWidgetPrivate *d) QTLWExtra *topData = d->topData(); delete topData->backingStore; - topData->backingStore = 0; + topData->backingStore = nullptr; } void QWidgetPrivate::deleteTLSysExtra() @@ -1705,7 +1705,7 @@ void QWidgetPrivate::deleteTLSysExtra() extra->topextra->window->destroy(); } delete extra->topextra->window; - extra->topextra->window = 0; + extra->topextra->window = nullptr; } } @@ -1805,7 +1805,7 @@ void QWidgetPrivate::paintOnScreen(const QRegion &rgn) if (toBePainted.isEmpty()) return; // Nothing to repaint. - drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, 0); + drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, nullptr); if (Q_UNLIKELY(q->paintingActive())) qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent"); @@ -2302,10 +2302,10 @@ void QWidgetPrivate::deactivateWidgetCleanup() Q_Q(QWidget); // If this was the active application window, reset it if (QApplication::activeWindow() == q) - QApplication::setActiveWindow(0); + QApplication::setActiveWindow(nullptr); // If the is the active mouse press widget, reset it if (q == qt_button_down) - qt_button_down = 0; + qt_button_down = nullptr; } @@ -2563,7 +2563,7 @@ void QWidget::setStyleSheet(const QString& styleSheet) if (testAttribute(Qt::WA_SetStyle)) { d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true); } else { - d->setStyle_helper(new QStyleSheetStyle(0), true); + d->setStyle_helper(new QStyleSheetStyle(nullptr), true); } } @@ -2606,7 +2606,7 @@ QStyle *QWidget::style() const void QWidget::setStyle(QStyle *style) { Q_D(QWidget); - setAttribute(Qt::WA_SetStyle, style != 0); + setAttribute(Qt::WA_SetStyle, style != nullptr); d->createExtra(); #ifndef QT_NO_STYLE_STYLESHEET if (QStyleSheetStyle *styleSheetStyle = qt_styleSheet(style)) { @@ -2686,7 +2686,7 @@ void QWidgetPrivate::inheritStyle() QStyle *origStyle = proxy ? proxy->base : extraStyle; QWidget *parent = q->parentWidget(); - QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0; + QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : nullptr; // If we have stylesheet on app or parent has stylesheet style, we need // to be running a proxy if (!qApp->styleSheet().isEmpty() || qt_styleSheet(parentStyle)) { @@ -2709,7 +2709,7 @@ void QWidgetPrivate::inheritStyle() // In such a case we need to start following the application style (i.e revert // the propagation behavior of QStyleSheetStyle) if (!q->testAttribute(Qt::WA_SetStyle)) - origStyle = 0; + origStyle = nullptr; setStyle_helper(origStyle, true); #endif // QT_NO_STYLE_STYLESHEET @@ -3085,7 +3085,7 @@ bool QWidget::isEnabledTo(const QWidget *ancestor) const */ void QWidget::addAction(QAction *action) { - insertAction(0, action); + insertAction(nullptr, action); } /*! @@ -3100,7 +3100,7 @@ void QWidget::addActions(QList<QAction*> actions) #endif { for(int i = 0; i < actions.count(); i++) - insertAction(0, actions.at(i)); + insertAction(nullptr, actions.at(i)); } /*! @@ -3125,7 +3125,7 @@ void QWidget::insertAction(QAction *before, QAction *action) int pos = d->actions.indexOf(before); if (pos < 0) { - before = 0; + before = nullptr; pos = d->actions.size(); } d->actions.insert(pos, action); @@ -4606,7 +4606,7 @@ void QWidgetPrivate::updateFont(const QFont &font) Q_Q(QWidget); #ifndef QT_NO_STYLE_STYLESHEET const QStyleSheetStyle* cssStyle; - cssStyle = extra ? qt_styleSheet(extra->style) : 0; + cssStyle = extra ? qt_styleSheet(extra->style) : nullptr; const bool useStyleSheetPropagationInWidgetStyles = QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); #endif @@ -4842,7 +4842,7 @@ void qt_qpa_set_cursor(QWidget *w, bool force) if (!w->testAttribute(Qt::WA_WState_Created)) return; - static QPointer<QWidget> lastUnderMouse = 0; + static QPointer<QWidget> lastUnderMouse = nullptr; if (force) { lastUnderMouse = w; } else if (lastUnderMouse) { @@ -5119,7 +5119,7 @@ void QWidget::setGraphicsEffect(QGraphicsEffect *effect) if (d->graphicsEffect) { d->invalidateBackingStore(rect()); delete d->graphicsEffect; - d->graphicsEffect = 0; + d->graphicsEffect = nullptr; } if (effect) { @@ -5313,7 +5313,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP setSystemClip(sharedPainter->paintEngine(), 1, QRegion()); sharedPainter->restore(); } - sourced->context = 0; + sourced->context = nullptr; if (repaintManager) repaintManager->markNeedsFlush(q, rgn, offset); @@ -5431,7 +5431,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (!sharedPainter) paintEngine->d_func()->systemRect = QRect(); else - paintEngine->d_func()->currentClipDevice = 0; + paintEngine->d_func()->currentClipDevice = nullptr; setSystemClip(pdev->paintEngine(), 1, QRegion()); } @@ -5492,7 +5492,7 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, if (paintRegion.isEmpty()) return; - QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0; + QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : nullptr; // Use the target's shared painter if set (typically set when doing // "other->render(widget);" in the widget's paintEvent. @@ -5553,7 +5553,7 @@ void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectLis const QPoint &offset, DrawWidgetFlags flags , QPainter *sharedPainter, QWidgetRepaintManager *repaintManager) { - QWidget *w = 0; + QWidget *w = nullptr; QRect boundingRect; bool dirtyBoundingRect = true; const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren); @@ -5847,7 +5847,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg if (count%2) { // odd number of [*] -> replace last one int lastIndex = cap.lastIndexOf(placeHolder, index - 1); if (widget->isWindowModified() - && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget)) + && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, nullptr, widget)) cap.replace(lastIndex, 3, QWidget::tr("*")); else cap.remove(lastIndex, 3); @@ -6299,7 +6299,7 @@ void QWidget::setFocus(Qt::FocusReason reason) return; #if QT_CONFIG(graphicsview) - QWidget *previousProxyFocus = 0; + QWidget *previousProxyFocus = nullptr; if (const auto &topData = window()->d_func()->extra) { if (topData->proxyWidget && topData->proxyWidget->hasFocus()) { previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); @@ -6439,12 +6439,12 @@ void QWidgetPrivate::updateFocusChild() if (q->isHidden()) { while (w && w->isHidden()) { w->d_func()->focus_child = q; - w = w->isWindow() ? 0 : w->parentWidget(); + w = w->isWindow() ? nullptr : w->parentWidget(); } } else { while (w) { w->d_func()->focus_child = q; - w = w->isWindow() ? 0 : w->parentWidget(); + w = w->isWindow() ? nullptr : w->parentWidget(); } } @@ -6490,7 +6490,7 @@ void QWidget::clearFocus() while (w) { // Just like setFocus(), we update (clear) the focus_child of our parents if (w->d_func()->focus_child == this) - w->d_func()->focus_child = 0; + w->d_func()->focus_child = nullptr; w = w->parentWidget(); } @@ -6511,7 +6511,7 @@ void QWidget::clearFocus() if (hasFocus()) { // Update proxy state - QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); + QApplicationPrivate::setFocusWidget(nullptr, Qt::OtherFocusReason); #ifndef QT_NO_ACCESSIBILITY QAccessibleEvent event(this, QAccessible::Focus); QAccessible::updateAccessibility(&event); @@ -6588,10 +6588,10 @@ bool QWidget::focusNextPrevChild(bool next) */ if (wrappingOccurred) { QWindow *window = windowHandle(); - if (window != 0) { + if (window != nullptr) { QWindowPrivate *winp = qt_window_private(window); - if (winp->platformWindow != 0) { + if (winp->platformWindow != nullptr) { QFocusEvent event(QEvent::FocusIn, reason); event.ignore(); winp->platformWindow->windowEvent(&event); @@ -6669,7 +6669,7 @@ bool QWidget::isActiveWindow() const } #endif - if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) { + if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, this)) { if(tlw->windowType() == Qt::Tool && !tlw->isModal() && (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow())) @@ -6825,9 +6825,9 @@ void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw) focus_child->clearFocus(); // separate the focus chain into new (children of myself) and old (the rest) - QWidget *firstOld = 0; + QWidget *firstOld = nullptr; //QWidget *firstNew = q; //invariant - QWidget *o = 0; // last in the old list + QWidget *o = nullptr; // last in the old list QWidget *n = q; // last in the new list bool prevWasNew = true; @@ -7835,7 +7835,7 @@ void QWidgetPrivate::show_helper() #endif if (QApplicationPrivate::hidden_focus_widget == q) { - QApplicationPrivate::hidden_focus_widget = 0; + QApplicationPrivate::hidden_focus_widget = nullptr; q->setFocus(Qt::OtherFocusReason); } @@ -7934,7 +7934,7 @@ void QWidgetPrivate::hide_helper() bool isEmbedded = false; #if QT_CONFIG(graphicsview) - isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0; + isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != nullptr; #else Q_UNUSED(isEmbedded); #endif @@ -8127,7 +8127,7 @@ void QWidgetPrivate::setVisible(bool visible) QCoreApplication::sendEvent(q, &showToParentEvent); } else { // hide if (QApplicationPrivate::hidden_focus_widget == q) - QApplicationPrivate::hidden_focus_widget = 0; + QApplicationPrivate::hidden_focus_widget = nullptr; // hw: The test on getOpaqueRegion() needs to be more intelligent // currently it doesn't work if the widget is hidden (the region will @@ -8820,7 +8820,7 @@ bool QWidget::event(QEvent *event) case Qt::ActionsContextMenu: if (d->actions.count()) { QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(), - 0, this); + nullptr, this); break; } Q_FALLTHROUGH(); @@ -10012,9 +10012,9 @@ QLayout *QWidget::takeLayout() Q_D(QWidget); QLayout *l = layout(); if (!l) - return 0; - d->layout = 0; - l->setParent(0); + return nullptr; + d->layout = nullptr; + l->setParent(nullptr); return l; } @@ -10136,10 +10136,10 @@ QWidget *QWidget::childAt(const QPoint &p) const QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const { if (children.isEmpty()) - return 0; + return nullptr; if (!pointInsideRectAndMask(p)) - return 0; + return nullptr; return childAtRecursiveHelper(p, ignoreChildrenInDestructor); } @@ -10167,7 +10167,7 @@ QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChil // We have found our target; namely the child at position 'p'. return child; } - return 0; + return nullptr; } void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) @@ -10380,7 +10380,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) if (f & Qt::Window) // Frame geometry likely changes, refresh. d->data.fstrut_dirty = true; - QWidget *desktopWidget = 0; + QWidget *desktopWidget = nullptr; if (parent && parent->windowType() == Qt::Desktop) desktopWidget = parent; bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; @@ -10408,7 +10408,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) d->setParent_sys(parent, f); if (desktopWidget) - parent = 0; + parent = nullptr; #ifndef QT_NO_OPENGL if (d->textureChildSeen && parent) { @@ -10522,7 +10522,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) // programmer specified desktop widget const QDesktopScreenWidget *sw = qobject_cast<const QDesktopScreenWidget *>(newparent); targetScreen = sw ? sw->screenNumber() : 0; - newparent = 0; + newparent = nullptr; } setWinId(0); @@ -10532,19 +10532,19 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) if (q->windowHandle()) { q->windowHandle()->setFlags(f); QWidget *parentWithWindow = - newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : 0; + newparent ? (newparent->windowHandle() ? newparent : newparent->nativeParentWidget()) : nullptr; if (parentWithWindow) { QWidget *topLevel = parentWithWindow->window(); if ((f & Qt::Window) && topLevel && topLevel->windowHandle()) { q->windowHandle()->setTransientParent(topLevel->windowHandle()); - q->windowHandle()->setParent(0); + q->windowHandle()->setParent(nullptr); } else { - q->windowHandle()->setTransientParent(0); + q->windowHandle()->setTransientParent(nullptr); q->windowHandle()->setParent(parentWithWindow->windowHandle()); } } else { - q->windowHandle()->setTransientParent(0); - q->windowHandle()->setParent(0); + q->windowHandle()->setTransientParent(nullptr); + q->windowHandle()->setParent(nullptr); } } } @@ -10575,7 +10575,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) continue; QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow); - QWidget *childWidget = childWW ? childWW->widget() : 0; + QWidget *childWidget = childWW ? childWW->widget() : nullptr; if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow))) childWindow->setParent(newParentWindow); } @@ -11981,7 +11981,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const return 0; #else if (!extra || !extra->topextra || !extra->topextra->window) - return 0; + return nullptr; if (!extra->topextra->shareContext) { auto ctx = qt_make_unique<QOpenGLContext>(); @@ -12040,7 +12040,7 @@ QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const if (d->extra) { return d->extra->proxyWidget; } - return 0; + return nullptr; } #endif @@ -12101,7 +12101,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) qApp->d_func()->closePopup(this); if (this == QApplicationPrivate::active_window) - QApplication::setActiveWindow(0); + QApplication::setActiveWindow(nullptr); if (QWidget::mouseGrabber() == this) releaseMouse(); if (QWidget::keyboardGrabber() == this) @@ -12165,7 +12165,7 @@ QPaintEngine *QWidget::paintEngine() const const_cast<QWidgetPrivate *>(d_func())->noPaintOnScreen = 1; #endif - return 0; //##### @@@ + return nullptr; //##### @@@ } // Do not call QWindow::mapToGlobal() until QPlatformWindow is properly showing. @@ -12252,10 +12252,10 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const return t.transform.inverted().map(windowLocal); } -QWidget *qt_pressGrab = 0; -QWidget *qt_mouseGrb = 0; +QWidget *qt_pressGrab = nullptr; +QWidget *qt_mouseGrb = nullptr; static bool mouseGrabWithCursor = false; -static QWidget *keyboardGrb = 0; +static QWidget *keyboardGrb = nullptr; static inline QWindow *grabberWindow(const QWidget *w) { @@ -12267,7 +12267,7 @@ static inline QWindow *grabberWindow(const QWidget *w) } #ifndef QT_NO_CURSOR -static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = 0) +static void grabMouseForWidget(QWidget *widget, const QCursor *cursor = nullptr) #else static void grabMouseForWidget(QWidget *widget) #endif @@ -12287,7 +12287,7 @@ static void grabMouseForWidget(QWidget *widget) } qt_mouseGrb = widget; - qt_pressGrab = 0; + qt_pressGrab = nullptr; } static void releaseMouseGrabOfWidget(QWidget *widget) @@ -12303,7 +12303,7 @@ static void releaseMouseGrabOfWidget(QWidget *widget) window->setMouseGrabEnabled(false); } } - qt_mouseGrb = 0; + qt_mouseGrb = nullptr; } /*! @@ -12432,7 +12432,7 @@ void QWidget::releaseKeyboard() if (keyboardGrb == this) { if (QWindow *window = grabberWindow(this)) window->setKeyboardGrabEnabled(false); - keyboardGrb = 0; + keyboardGrb = nullptr; } } @@ -12509,8 +12509,8 @@ void QWidget::activateWindow() */ int QWidget::metric(PaintDeviceMetric m) const { - QWindow *topLevelWindow = 0; - QScreen *screen = 0; + QWindow *topLevelWindow = nullptr; + QScreen *screen = nullptr; if (QWidget *topLevel = window()) { topLevelWindow = topLevel->windowHandle(); if (topLevelWindow) @@ -12596,14 +12596,14 @@ QPainter *QWidget::sharedPainter() const { // Someone sent a paint event directly to the widget if (!d_func()->redirectDev) - return 0; + return nullptr; QPainter *sp = d_func()->sharedPainter(); if (!sp || !sp->isActive()) - return 0; + return nullptr; if (sp->paintEngine()->paintDevice() != d_func()->redirectDev) - return 0; + return nullptr; return sp; } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 62da3fabf4..6915782cb3 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -420,7 +420,7 @@ public: void setVisible(bool); void setEnabled_helper(bool); - static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0); + static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = nullptr); void updateFrameStrut(); QRect frameStrut() const; diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp index 6eebaca42c..9649e51b92 100644 --- a/src/widgets/kernel/qwidgetaction.cpp +++ b/src/widgets/kernel/qwidgetaction.cpp @@ -146,7 +146,7 @@ void QWidgetAction::setDefaultWidget(QWidget *widget) setVisible(!(widget->isHidden() && widget->testAttribute(Qt::WA_WState_ExplicitShowHide))); d->defaultWidget->hide(); - d->defaultWidget->setParent(0); + d->defaultWidget->setParent(nullptr); d->defaultWidgetInUse = false; if (!isEnabled()) d->defaultWidget->setEnabled(false); @@ -177,7 +177,7 @@ QWidget *QWidgetAction::requestWidget(QWidget *parent) QWidget *w = createWidget(parent); if (!w) { if (d->defaultWidgetInUse || !d->defaultWidget) - return 0; + return nullptr; d->defaultWidget->setParent(parent); d->defaultWidgetInUse = true; return d->defaultWidget; @@ -203,7 +203,7 @@ void QWidgetAction::releaseWidget(QWidget *widget) if (widget == d->defaultWidget) { d->defaultWidget->hide(); - d->defaultWidget->setParent(0); + d->defaultWidget->setParent(nullptr); d->defaultWidgetInUse = false; return; } @@ -251,7 +251,7 @@ bool QWidgetAction::eventFilter(QObject *obj, QEvent *event) QWidget *QWidgetAction::createWidget(QWidget *parent) { Q_UNUSED(parent) - return 0; + return nullptr; } /*! diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index c3211e275f..135a1527ac 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -695,7 +695,7 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget) return qt_dummy_platformTextureList(); } - return 0; + return nullptr; } #else @@ -788,7 +788,7 @@ bool QWidgetRepaintManager::syncAllowed() QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData(); if (textureListWatcher && !textureListWatcher->isLocked()) { textureListWatcher->deleteLater(); - textureListWatcher = 0; + textureListWatcher = nullptr; } else if (!tlwExtra->widgetTextures.empty()) { bool skipSync = false; for (const auto &tl : tlwExtra->widgetTextures) { @@ -822,7 +822,7 @@ void QWidgetRepaintManager::paintAndFlush() if (hasStaticContents() && !store->size().isEmpty() ) { // Repaint existing dirty area and newly visible area. const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); - const QRegion staticRegion(staticContents(0, clipRect)); + const QRegion staticRegion(staticContents(nullptr, clipRect)); QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height()); newVisible -= staticRegion; dirty += newVisible; @@ -1008,13 +1008,13 @@ void QWidgetRepaintManager::paintAndFlush() QPoint offset; if (w != tlw) offset += w->mapTo(tlw, QPoint()); - wd->drawWidget(store->paintDevice(), toBePainted, offset, flags, 0, this); + wd->drawWidget(store->paintDevice(), toBePainted, offset, flags, nullptr, this); } // Paint the rest with composition. if (repaintAllWidgets || !dirtyCopy.isEmpty()) { QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive; - tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, 0, this); + tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this); } store->endPaint(); @@ -1108,7 +1108,7 @@ void QWidgetRepaintManager::flush() for (QWidget *w : qExchange(needsFlushWidgets, {})) { QWidgetPrivate *wd = w->d_func(); Q_ASSERT(wd->needsFlush); - QPlatformTextureList *widgetTexturesForNative = wd->textureChildSeen ? widgetTexturesFor(tlw, w) : 0; + QPlatformTextureList *widgetTexturesForNative = wd->textureChildSeen ? widgetTexturesFor(tlw, w) : nullptr; flush(w, *wd->needsFlush, widgetTexturesForNative); *wd->needsFlush = QRegion(); } @@ -1284,7 +1284,7 @@ QRegion QWidgetRepaintManager::staticContents(QWidget *parent, const QRect &with wd->clipToEffectiveMask(visible); if (visible.isEmpty()) continue; - wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true); + wd->subtractOpaqueSiblings(visible, nullptr, /*alsoNonOpaque=*/true); visible.translate(offset); region += visible; @@ -1331,7 +1331,7 @@ void QWidgetPrivate::invalidateBackingStore_resizeHelper(const QPoint &oldPos, c if (!staticContents || graphicsEffect) { QRegion staticChildren; - QWidgetRepaintManager *bs = 0; + QWidgetRepaintManager *bs = nullptr; if (offset.isNull() && (bs = maybeRepaintManager())) staticChildren = bs->staticContents(q, oldWidgetRect); const bool hasStaticChildren = !staticChildren.isEmpty(); diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index 02b4ea20a7..41600d2143 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -125,12 +125,12 @@ static const QVariant::Handler widgets_handler = { clear, isNull, #ifndef QT_NO_DATASTREAM - 0, - 0, + nullptr, + nullptr, #endif compare, convert, - 0, + nullptr, #if !defined(QT_NO_DEBUG_STREAM) streamDebug #else diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 596343c52f..904067afda 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -57,10 +57,10 @@ QT_BEGIN_NAMESPACE Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets(); -Q_WIDGETS_EXPORT QWidget *qt_button_down = 0; // widget got last button-down +Q_WIDGETS_EXPORT QWidget *qt_button_down = nullptr; // widget got last button-down // popup control -QWidget *qt_popup_down = 0; // popup that contains the pressed widget +QWidget *qt_popup_down = nullptr; // popup that contains the pressed widget extern int openPopupCount; bool qt_replay_popup_mouse_event = false; extern bool qt_try_modal(QWidget *widget, QEvent::Type type); @@ -156,7 +156,7 @@ QOpenGLContext *QWidgetWindowPrivate::shareContext() const #endif // opengl QWidgetWindow::QWidgetWindow(QWidget *widget) - : QWindow(*new QWidgetWindowPrivate(), 0) + : QWindow(*new QWidgetWindowPrivate(), nullptr) , m_widget(widget) { updateObjectName(); @@ -179,7 +179,7 @@ QAccessibleInterface *QWidgetWindow::accessibleRoot() const { if (m_widget) return QAccessible::queryAccessibleInterface(m_widget); - return 0; + return nullptr; } #endif @@ -374,7 +374,7 @@ bool QWidgetWindow::event(QEvent *event) #endif // QT_NO_CONTEXTMENU case QEvent::WindowBlocked: - qt_button_down = 0; + qt_button_down = nullptr; break; case QEvent::UpdateRequest: @@ -393,7 +393,7 @@ bool QWidgetWindow::event(QEvent *event) return QWindow::event(event); } -QPointer<QWidget> qt_last_mouse_receiver = 0; +QPointer<QWidget> qt_last_mouse_receiver = nullptr; void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) { @@ -406,7 +406,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) return; #endif if (event->type() == QEvent::Leave) { - QWidget *enter = 0; + QWidget *enter = nullptr; // Check from window system event queue if the next queued enter targets a window // in the same window hierarchy (e.g. enter a child of this window). If so, // remove the enter event from queue and handle both in single dispatch. @@ -484,13 +484,13 @@ QWidget *QWidgetWindow::getFocusWidget(FocusWidgets fw) void QWidgetWindow::handleFocusInEvent(QFocusEvent *e) { - QWidget *focusWidget = 0; + QWidget *focusWidget = nullptr; if (e->reason() == Qt::BacktabFocusReason) focusWidget = getFocusWidget(LastFocusWidget); else if (e->reason() == Qt::TabFocusReason) focusWidget = getFocusWidget(FirstFocusWidget); - if (focusWidget != 0) + if (focusWidget != nullptr) focusWidget->setFocus(); } @@ -513,8 +513,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) QWidget *popupChild = activePopupWidget->childAt(mapped); if (activePopupWidget != qt_popup_down) { - qt_button_down = 0; - qt_popup_down = 0; + qt_button_down = nullptr; + qt_popup_down = nullptr; } switch (event->type()) { @@ -589,7 +589,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) && qt_replay_popup_mouse_event && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) { if (m_widget->windowType() != Qt::Popup) - qt_button_down = 0; + qt_button_down = nullptr; if (event->type() == QEvent::MouseButtonPress) { // the popup disappeared, replay the mouse press event QWidget *w = QApplication::widgetAt(event->globalPos()); @@ -636,8 +636,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) #endif if (releaseAfter) { - qt_button_down = 0; - qt_popup_down = 0; + qt_button_down = nullptr; + qt_popup_down = nullptr; } return; } @@ -1050,7 +1050,7 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long #if QT_CONFIG(tabletevent) void QWidgetWindow::handleTabletEvent(QTabletEvent *event) { - static QPointer<QWidget> qt_tablet_target = 0; + static QPointer<QWidget> qt_tablet_target = nullptr; QWidget *widget = qt_tablet_target; @@ -1076,7 +1076,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) } if (event->type() == QEvent::TabletRelease && event->buttons() == Qt::NoButton) - qt_tablet_target = 0; + qt_tablet_target = nullptr; } #endif // QT_CONFIG(tabletevent) @@ -1084,7 +1084,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) void QWidgetWindow::handleGestureEvent(QNativeGestureEvent *e) { // copy-pasted code to find correct widget follows: - QObject *receiver = 0; + QObject *receiver = nullptr; if (QApplicationPrivate::inPopupMode()) { QWidget *popup = QApplication::activePopupWidget(); QWidget *popupFocusWidget = popup->focusWidget(); diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index fd8581edbb..b4d889fdfa 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -58,8 +58,8 @@ public: Q_DECLARE_PUBLIC(QWindowContainer) QWindowContainerPrivate() - : window(0) - , oldFocusWindow(0) + : window(nullptr) + , oldFocusWindow(nullptr) , usesNativeWidgets(false) { } @@ -70,7 +70,7 @@ public: QWindowContainer *wc = qobject_cast<QWindowContainer *>(w); if (wc) return wc->d_func(); - return 0; + return nullptr; } void updateGeometry() { @@ -90,7 +90,7 @@ public: void updateUsesNativeWidgets() { - if (window->parent() == 0) + if (window->parent() == nullptr) return; Q_Q(QWindowContainer); if (q->internalWinId()) { @@ -295,7 +295,7 @@ bool QWindowContainer::event(QEvent *e) case QEvent::ChildRemoved: { QChildEvent *ce = static_cast<QChildEvent *>(e); if (ce->child() == d->window) - d->window = 0; + d->window = nullptr; break; } // The only thing we are interested in is making sure our sizes stay diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index 42691d6b77..b310da5781 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -456,7 +456,7 @@ const QStateMachinePrivate::Handler qt_gui_statemachine_handler = { cloneEvent }; -static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = 0; +static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = nullptr; void qRegisterGuiStateMachine() { qt_guistatemachine_last_handler = QStateMachinePrivate::handler; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 861dd7a54c..6b3e3679ae 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -123,7 +123,7 @@ QT_BEGIN_NAMESPACE static QWindow *qt_getWindow(const QWidget *widget) { - return widget ? widget->window()->windowHandle() : 0; + return widget ? widget->window()->windowHandle() : nullptr; } /*! @@ -353,7 +353,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush); break; } case PE_FrameStatusBarItem: - qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0); + qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, nullptr); break; case PE_IndicatorHeaderArrow: if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { @@ -450,7 +450,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q #endif // QT_CONFIG(tabbar) case PE_FrameTabWidget: case PE_FrameWindow: - qDrawWinPanel(p, opt->rect, opt->palette, false, 0); + qDrawWinPanel(p, opt->rect, opt->palette, false, nullptr); break; case PE_FrameLineEdit: proxy()->drawPrimitive(PE_Frame, opt, p, widget); @@ -493,17 +493,17 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q x -= 2; if (opt->rect.height() > 4) { qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, x+3, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } else { if (opt->rect.width() > 4) { int y = opt->rect.height() / 3; qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, 2, y+3, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } p->restore(); @@ -818,7 +818,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q #if QT_CONFIG(toolbutton) static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbutton, - const QRect &rect, QPainter *painter, const QWidget *widget = 0) + const QRect &rect, QPainter *painter, const QWidget *widget = nullptr) { QStyle::PrimitiveElement pe; switch (toolbutton->arrowType) { @@ -1016,7 +1016,7 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const { const QWidget *widget = option->widget; - const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1; + const int textMargin = proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1; QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding const bool wrapText = option->features & QStyleOptionViewItem::WrapText; @@ -2931,8 +2931,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_TabBarScrollLeftButton: { const bool vertical = opt->rect.width() < opt->rect.height(); const Qt::LayoutDirection ld = widget->layoutDirection(); - const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, widget), QApplication::globalStrut().width()); - const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, widget); + const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget), QApplication::globalStrut().width()); + const int buttonOverlap = proxy()->pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, nullptr, widget); r = vertical ? QRect(0, opt->rect.height() - (buttonWidth * 2) + buttonOverlap, opt->rect.width(), buttonWidth) : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - (buttonWidth * 2) + buttonOverlap, 0, buttonWidth, opt->rect.height())); @@ -2940,7 +2940,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_TabBarScrollRightButton: { const bool vertical = opt->rect.width() < opt->rect.height(); const Qt::LayoutDirection ld = widget->layoutDirection(); - const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, widget), QApplication::globalStrut().width()); + const int buttonWidth = qMax(proxy()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, widget), QApplication::globalStrut().width()); r = vertical ? QRect(0, opt->rect.height() - buttonWidth, opt->rect.width(), buttonWidth) : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - buttonWidth, 0, buttonWidth, opt->rect.height())); @@ -3030,8 +3030,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget*>(opt); - bool canClose = dwOpt == 0 ? true : dwOpt->closable; - bool canFloat = dwOpt == 0 ? false : dwOpt->floatable; + bool canClose = dwOpt == nullptr ? true : dwOpt->closable; + bool canFloat = dwOpt == nullptr ? false : dwOpt->floatable; const bool verticalTitleBar = dwOpt && dwOpt->verticalTitleBar; @@ -3134,7 +3134,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false); if (d->cachedOption) { delete d->cachedOption; - d->cachedOption = 0; + d->cachedOption = nullptr; } d->cachedOption = new QStyleOptionViewItem(*vopt); } diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp index 5739678932..cfaa5a2011 100644 --- a/src/widgets/styles/qproxystyle.cpp +++ b/src/widgets/styles/qproxystyle.cpp @@ -90,7 +90,7 @@ void QProxyStylePrivate::ensureBaseStyle() const if (qstrcmp(baseStyle->metaObject()->className(), q->metaObject()->className()) == 0) { delete baseStyle; - baseStyle = 0; + baseStyle = nullptr; } } } diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp index b0ce5e52cf..2c4f6f83a1 100644 --- a/src/widgets/styles/qstylefactory.cpp +++ b/src/widgets/styles/qstylefactory.cpp @@ -88,7 +88,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, */ QStyle *QStyleFactory::create(const QString& key) { - QStyle *ret = 0; + QStyle *ret = nullptr; QString style = key.toLower(); #if QT_CONFIG(style_windows) if (style == QLatin1String("windows")) diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 9477ca86da..61a59b03c1 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -132,7 +132,7 @@ bool isInstanceOf(QObject *obj, QAccessible::Role role) bool hasAncestor(QObject *obj, QAccessible::Role role) { bool found = false; - QObject *parent = obj ? obj->parent() : 0; + QObject *parent = obj ? obj->parent() : nullptr; while (parent && !found) { if (isInstanceOf(parent, role)) found = true; diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index e5e93ecc66..1af839c841 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -151,7 +151,7 @@ QT_BEGIN_NAMESPACE QStyleOption::QStyleOption(int version, int type) : version(version), type(type), state(QStyle::State_None), - direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0) + direction(QGuiApplication::layoutDirection()), fontMetrics(QFont()), styleObject(nullptr) { } @@ -3085,7 +3085,7 @@ QStyleOptionViewItem::QStyleOptionViewItem() : QStyleOption(Version, SO_ViewItem), displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft), textElideMode(Qt::ElideMiddle), decorationPosition(Left), - showDecorationSelected(false), features(None), widget(0), + showDecorationSelected(false), features(None), widget(nullptr), checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid) { } @@ -3097,7 +3097,7 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version) : QStyleOption(version, SO_ViewItem), displayAlignment(Qt::AlignLeft), decorationAlignment(Qt::AlignLeft), textElideMode(Qt::ElideMiddle), decorationPosition(Left), - showDecorationSelected(false), features(None), widget(0), + showDecorationSelected(false), features(None), widget(nullptr), checkState(Qt::Unchecked), viewItemPosition(QStyleOptionViewItem::Invalid) { } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 24a397a274..c40bbbc96c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -133,7 +133,7 @@ public: }; -static QStyleSheetStyleCaches *styleSheetCaches = 0; +static QStyleSheetStyleCaches *styleSheetCaches = nullptr; /* RECURSION_GUARD: * the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like: @@ -144,16 +144,16 @@ static QStyleSheetStyleCaches *styleSheetCaches = 0; * The first instance of QStyleSheetStyle will set globalStyleSheetStyle to itself. The second one * will notice the globalStyleSheetStyle is not istelf and call its base style directly. */ -static const QStyleSheetStyle *globalStyleSheetStyle = 0; +static const QStyleSheetStyle *globalStyleSheetStyle = nullptr; class QStyleSheetStyleRecursionGuard { public: QStyleSheetStyleRecursionGuard(const QStyleSheetStyle *that) - : guarded(globalStyleSheetStyle == 0) + : guarded(globalStyleSheetStyle == nullptr) { if (guarded) globalStyleSheetStyle = that; } - ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = 0; } + ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = nullptr; } bool guarded; }; #define RECURSION_GUARD(RETURN) \ @@ -371,7 +371,7 @@ struct QStyleSheetBackgroundData : public QSharedData struct QStyleSheetBorderData : public QSharedData { - QStyleSheetBorderData() : bi(0) + QStyleSheetBorderData() : bi(nullptr) { for (int i = 0; i < 4; i++) { borders[i] = 0; @@ -379,7 +379,7 @@ struct QStyleSheetBorderData : public QSharedData } } - QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(0) + QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(nullptr) { for (int i = 0; i < 4; i++) { borders[i] = b[i]; @@ -396,7 +396,7 @@ struct QStyleSheetBorderData : public QSharedData const QStyleSheetBorderImageData *borderImage() const { return bi; } - bool hasBorderImage() const { return bi!=0; } + bool hasBorderImage() const { return bi!=nullptr; } QSharedDataPointer<QStyleSheetBorderImageData> bi; @@ -413,7 +413,7 @@ struct QStyleSheetBorderData : public QSharedData if (!radii[i].isEmpty()) return false; } - if (bi != 0 && bi->pixmap.hasAlpha()) + if (bi != nullptr && bi->pixmap.hasAlpha()) return false; return true; } @@ -502,7 +502,7 @@ struct QStyleSheetImageData : public QSharedData class QRenderRule { public: - QRenderRule() : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { } + QRenderRule() : features(0), hasFont(false), pal(nullptr), b(nullptr), bg(nullptr), bd(nullptr), ou(nullptr), geo(nullptr), p(nullptr), img(nullptr), clipset(0) { } QRenderRule(const QVector<QCss::Declaration> &, const QObject *); QRect borderRect(const QRect &r) const; @@ -538,18 +538,18 @@ public: bool hasModification() const; - bool hasPalette() const { return pal != 0; } - bool hasBackground() const { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); } + bool hasPalette() const { return pal != nullptr; } + bool hasBackground() const { return bg != nullptr && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); } bool hasGradientBackground() const { return bg && bg->brush.style() >= Qt::LinearGradientPattern && bg->brush.style() <= Qt::ConicalGradientPattern; } bool hasNativeBorder() const { - return bd == 0 + return bd == nullptr || (!bd->hasBorderImage() && bd->styles[0] == BorderStyle_Native); } bool hasNativeOutline() const { - return (ou == 0 + return (ou == nullptr || (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native)); } @@ -563,14 +563,14 @@ public: return features & StyleFeature_BackgroundColor; } - bool hasBox() const { return b != 0; } - bool hasBorder() const { return bd != 0; } - bool hasOutline() const { return ou != 0; } - bool hasPosition() const { return p != 0; } - bool hasGeometry() const { return geo != 0; } + bool hasBox() const { return b != nullptr; } + bool hasBorder() const { return bd != nullptr; } + bool hasOutline() const { return ou != nullptr; } + bool hasPosition() const { return p != nullptr; } + bool hasGeometry() const { return geo != nullptr; } bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); } - bool hasImage() const { return img != 0; } - bool hasIcon() const { return iconPtr != 0; } + bool hasImage() const { return img != nullptr; } + bool hasIcon() const { return iconPtr != nullptr; } QSize minimumContentsSize() const { return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); } @@ -910,7 +910,7 @@ static QStyle::StandardPixmap subControlIcon(int pe) } QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject *object) -: features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) +: features(0), hasFont(false), pal(nullptr), b(nullptr), bg(nullptr), bd(nullptr), ou(nullptr), geo(nullptr), p(nullptr), img(nullptr), clipset(0) { QPalette palette = QGuiApplication::palette(); // ###: ideally widget's palette ValueExtractor v(declarations, palette); @@ -1134,11 +1134,11 @@ QSize QRenderRule::boxSize(const QSize &cs, int flags) const void QRenderRule::fixupBorder(int nativeWidth) { - if (bd == 0) + if (bd == nullptr) return; if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) { - bd->bi = 0; + bd->bi = nullptr; // ignore the color, border of edges that have none border-style QBrush color = pal ? pal->foreground : QBrush(); const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid() @@ -1515,7 +1515,7 @@ public: do { result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-')); metaObject = metaObject->superClass(); - } while (metaObject != 0); + } while (metaObject != nullptr); return result; } QString attribute(NodePtr node, const QString& name) const override @@ -1539,7 +1539,7 @@ public: return className; } else if (name == QLatin1String("style")) { QWidget *w = qobject_cast<QWidget *>(obj); - QStyleSheetStyle *proxy = w ? qt_styleSheet(w->style()) : 0; + QStyleSheetStyle *proxy = w ? qt_styleSheet(w->style()) : nullptr; if (proxy) { QString styleName = QString::fromLatin1(proxy->baseStyle()->metaObject()->className()); cache[name] = styleName; @@ -1575,7 +1575,7 @@ public: if (uc == e && !*c) return true; metaObject = metaObject->superClass(); - } while (metaObject != 0); + } while (metaObject != nullptr); return false; } bool hasAttributes(NodePtr) const override @@ -1583,11 +1583,11 @@ public: QStringList nodeIds(NodePtr node) const override { return isNullNode(node) ? QStringList() : QStringList(OBJECT_PTR(node)->objectName()); } bool isNullNode(NodePtr node) const override - { return node.ptr == 0; } + { return node.ptr == nullptr; } NodePtr parentNode(NodePtr node) const override - { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentObject(OBJECT_PTR(node)); return n; } + { NodePtr n; n.ptr = isNullNode(node) ? nullptr : parentObject(OBJECT_PTR(node)); return n; } NodePtr previousSiblingNode(NodePtr) const override - { NodePtr n; n.ptr = 0; return n; } + { NodePtr n; n.ptr = nullptr; return n; } NodePtr duplicateNode(NodePtr node) const override { return node; } void freeNode(NodePtr) const override @@ -1700,22 +1700,22 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w) #if QT_CONFIG(spinbox) if (qobject_cast<const QAbstractSpinBox *>(w)) - return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w); + return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, nullptr, w); #endif #if QT_CONFIG(combobox) if (qobject_cast<const QComboBox *>(w)) - return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w); + return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, nullptr, w); #endif #if QT_CONFIG(menu) if (qobject_cast<const QMenu *>(w)) - return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w); + return base->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, w); #endif #if QT_CONFIG(menubar) if (qobject_cast<const QMenuBar *>(w)) - return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w); + return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, w); #endif #ifndef QT_NO_FRAME if (const QFrame *frame = qobject_cast<const QFrame *>(w)) { @@ -1725,9 +1725,9 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w) #endif if (qstrcmp(w->metaObject()->className(), "QTipLabel") == 0) - return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, w); + return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, nullptr, w); - return base->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, w); + return base->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, w); } static quint64 pseudoClass(QStyle::State state) @@ -2243,21 +2243,21 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec case PseudoElement_Indicator: case PseudoElement_MenuCheckMark: if (sz.width() == -1) - sz.setWidth(base->pixelMetric(PM_IndicatorWidth, 0, w)); + sz.setWidth(base->pixelMetric(PM_IndicatorWidth, nullptr, w)); if (sz.height() == -1) - sz.setHeight(base->pixelMetric(PM_IndicatorHeight, 0, w)); + sz.setHeight(base->pixelMetric(PM_IndicatorHeight, nullptr, w)); break; case PseudoElement_ExclusiveIndicator: case PseudoElement_GroupBoxIndicator: if (sz.width() == -1) - sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, 0, w)); + sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, nullptr, w)); if (sz.height() == -1) - sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, 0, w)); + sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, nullptr, w)); break; case PseudoElement_PushButtonMenuIndicator: { - int pm = base->pixelMetric(PM_MenuButtonIndicator, 0, w); + int pm = base->pixelMetric(PM_MenuButtonIndicator, nullptr, w); if (sz.width() == -1) sz.setWidth(pm); if (sz.height() == -1) @@ -2291,12 +2291,12 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec case PseudoElement_ToolButtonMenu: if (sz.width() == -1) - sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, 0, w)); + sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, nullptr, w)); break; case PseudoElement_HeaderViewUpArrow: case PseudoElement_HeaderViewDownArrow: { - int pm = base->pixelMetric(PM_HeaderMargin, 0, w); + int pm = base->pixelMetric(PM_HeaderMargin, nullptr, w); if (sz.width() == -1) sz.setWidth(pm); if (sz.height() == 1) @@ -2309,7 +2309,7 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec case PseudoElement_ScrollBarAddLine: case PseudoElement_ScrollBarSubLine: case PseudoElement_ScrollBarSlider: { - int pm = pixelMetric(QStyle::PM_ScrollBarExtent, 0, w); + int pm = pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, w); if (sz.width() == -1) sz.setWidth(pm); if (sz.height() == -1) @@ -2319,7 +2319,7 @@ QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rec case PseudoElement_DockWidgetCloseButton: case PseudoElement_DockWidgetFloatButton: { - int iconSize = pixelMetric(PM_SmallIconSize, 0, w); + int iconSize = pixelMetric(PM_SmallIconSize, nullptr, w); return QSize(iconSize, iconSize); } @@ -2956,7 +2956,7 @@ void QStyleSheetStyle::unpolish(QWidget *w) setGeometry(w); w->setAttribute(Qt::WA_StyleSheetTarget, false); w->setAttribute(Qt::WA_StyleSheet, false); - QObject::disconnect(w, 0, this, 0); + QObject::disconnect(w, nullptr, this, nullptr); #if QT_CONFIG(scrollarea) if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) { QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)), @@ -3395,7 +3395,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC tb->icon.paint(p, ir); } else { int iconSize = pixelMetric(PM_SmallIconSize, tb, w); - pm = standardIcon(SP_TitleBarMenuButton, 0, w).pixmap(iconSize, iconSize); + pm = standardIcon(SP_TitleBarMenuButton, nullptr, w).pixmap(iconSize, iconSize); drawItemPixmap(p, ir, Qt::AlignCenter, pm); } } @@ -3407,9 +3407,9 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC QSize sz = subSubRule.contentsRect(ir).size(); if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) - pm = standardIcon(SP_DockWidgetCloseButton, 0, w).pixmap(sz); + pm = standardIcon(SP_DockWidgetCloseButton, nullptr, w).pixmap(sz); else - pm = standardIcon(SP_TitleBarCloseButton, 0, w).pixmap(sz); + pm = standardIcon(SP_TitleBarCloseButton, nullptr, w).pixmap(sz); drawItemPixmap(p, ir, Qt::AlignCenter, pm); } @@ -3430,7 +3430,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC continue; QRenderRule subSubRule = renderRule(w, opt, pe); subSubRule.drawRule(p, ir); - pm = standardIcon(subControlIcon(pe), 0, w).pixmap(subSubRule.contentsRect(ir).size()); + pm = standardIcon(subControlIcon(pe), nullptr, w).pixmap(subSubRule.contentsRect(ir).size()); drawItemPixmap(p, ir, Qt::AlignCenter, pm); } @@ -4280,7 +4280,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (pe1 != PseudoElement_None) { QRenderRule subRule = renderRule(w, opt, pe1); - if (subRule.bg != 0 || subRule.hasDrawable()) { + if (subRule.bg != nullptr || subRule.hasDrawable()) { //We test subRule.bg directly because hasBackground() would return false for background:none. //But we still don't want the default drawning in that case (example for QScrollBar::add-page) (task 198926) subRule.drawRule(p, opt->rect); @@ -5088,7 +5088,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op case CT_GroupBox: case CT_LineEdit: #if QT_CONFIG(spinbox) - if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) + if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : nullptr)) return csz; // we only care about the size hint of the line edit #endif if (rule.hasBox() || !rule.hasNativeBorder()) { @@ -5729,7 +5729,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove); if (!subRule.hasDrawable()) break; - subRule.img = 0; + subRule.img = nullptr; QRect gr = positionRect(w, rule, subRule, PseudoElement_SliderGroove, opt->rect, opt->direction); switch (sc) { case SC_SliderGroove: @@ -5739,8 +5739,8 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp QRect cr = subRule.contentsRect(gr); QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderHandle); int len = horizontal ? subRule2.size().width() : subRule2.size().height(); - subRule2.img = 0; - subRule2.geo = 0; + subRule2.img = nullptr; + subRule2.geo = nullptr; cr = positionRect(w, subRule2, PseudoElement_SliderHandle, cr, opt->direction); int thickness = horizontal ? cr.height() : cr.width(); int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition, @@ -5848,7 +5848,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c QRect ir = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator, opt, w); ir = visualRect(opt->direction, opt->rect, ir); - int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, 0, w); + int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, nullptr, w); QRect cr = rule.contentsRect(opt->rect); ir.setRect(ir.left() + ir.width() + spacing, cr.y(), cr.width() - ir.width() - spacing, cr.height()); diff --git a/src/widgets/util/qcolormap.cpp b/src/widgets/util/qcolormap.cpp index 6dacc97261..57e61690e9 100644 --- a/src/widgets/util/qcolormap.cpp +++ b/src/widgets/util/qcolormap.cpp @@ -59,7 +59,7 @@ public: int numcolors; }; -static QColormapPrivate *screenMap = 0; +static QColormapPrivate *screenMap = nullptr; void QColormap::initialize() { @@ -83,7 +83,7 @@ void QColormap::initialize() void QColormap::cleanup() { delete screenMap; - screenMap = 0; + screenMap = nullptr; } QColormap QColormap::instance(int /*screen*/) diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 3c0271e7c2..72fa557790 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -1262,7 +1262,7 @@ Qt::MatchFlags QCompleter::filterMode() const void QCompleter::setPopup(QAbstractItemView *popup) { Q_D(QCompleter); - Q_ASSERT(popup != 0); + Q_ASSERT(popup != nullptr); if (d->popup) { QObject::disconnect(d->popup->selectionModel(), nullptr, this, nullptr); QObject::disconnect(d->popup, nullptr, this, nullptr); diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 03df937938..064be873b9 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -114,19 +114,19 @@ static QMouseEvent *copyMouseEvent(QEvent *e) } #endif // QT_CONFIG(graphicsview) default: - return 0; + return nullptr; } } class PressDelayHandler : public QObject { private: - PressDelayHandler(QObject *parent = 0) + PressDelayHandler(QObject *parent = nullptr) : QObject(parent) , pressDelayTimer(0) , sendingEvent(false) , mouseButton(Qt::NoButton) - , mouseTarget(0) + , mouseTarget(nullptr) , mouseEventSource(Qt::MouseEventNotSynthesized) { } @@ -138,7 +138,7 @@ public: static PressDelayHandler *instance() { - static PressDelayHandler *inst = 0; + static PressDelayHandler *inst = nullptr; if (!inst) inst = new PressDelayHandler(QCoreApplication::instance()); return inst; @@ -192,10 +192,10 @@ public: result = true; // consume this event } else if (mouseTarget && scrollerIsActive) { // we grabbed the mouse expicitly when the scroller became active, so undo that now - sendMouseEvent(0, UngrabMouseBefore); + sendMouseEvent(nullptr, UngrabMouseBefore); } - pressDelayEvent.reset(0); - mouseTarget = 0; + pressDelayEvent.reset(nullptr); + mouseTarget = nullptr; return result; } @@ -208,9 +208,9 @@ public: killTimer(pressDelayTimer); pressDelayTimer = 0; } - pressDelayEvent.reset(0); + pressDelayEvent.reset(nullptr); } - mouseTarget = 0; + mouseTarget = nullptr; } void scrollerBecameActive() @@ -222,8 +222,8 @@ public: killTimer(pressDelayTimer); pressDelayTimer = 0; } - pressDelayEvent.reset(0); - mouseTarget = 0; + pressDelayEvent.reset(nullptr); + mouseTarget = nullptr; } else if (mouseTarget) { // we did send a press, so we need to fake a release now @@ -261,7 +261,7 @@ protected: qFGDebug() << "QFG: timer event: re-sending mouse press to " << mouseTarget; sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore); } - pressDelayEvent.reset(0); + pressDelayEvent.reset(nullptr); if (pressDelayTimer) { killTimer(pressDelayTimer); @@ -276,7 +276,7 @@ protected: sendingEvent = true; #if QT_CONFIG(graphicsview) - QGraphicsItem *grabber = 0; + QGraphicsItem *grabber = nullptr; if (mouseTarget->parentWidget()) { if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) { if (gv->scene()) @@ -350,7 +350,7 @@ QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject { d_func()->q_ptr = this; d_func()->receiver = receiver; - d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0; + d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : nullptr; d_func()->button = button; } @@ -358,7 +358,7 @@ QFlickGesture::~QFlickGesture() { } QFlickGesturePrivate::QFlickGesturePrivate() - : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false) + : receiverScroller(nullptr), button(Qt::NoButton), macIgnoreWheel(false) { } @@ -420,11 +420,11 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, return Ignore; } - const QMouseEvent *me = 0; + const QMouseEvent *me = nullptr; #if QT_CONFIG(graphicsview) - const QGraphicsSceneMouseEvent *gsme = 0; + const QGraphicsSceneMouseEvent *gsme = nullptr; #endif - const QTouchEvent *te = 0; + const QTouchEvent *te = nullptr; QPoint globalPos; // qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button; diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index df05bbf71c..fec373d45c 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -300,7 +300,7 @@ QScroller *QScroller::scroller(QObject *target) { if (!target) { qWarning("QScroller::scroller() was called with a null target."); - return 0; + return nullptr; } if (qt_allScrollers()->contains(target)) @@ -476,7 +476,7 @@ void QScroller::ungrabGesture(QObject *target) QGestureRecognizer::unregisterRecognizer(sp->recognizerType); // do not delete the recognizer. The QGestureManager is doing this. - sp->recognizer = 0; + sp->recognizer = nullptr; } #endif // QT_NO_GESTURES @@ -502,7 +502,7 @@ QScroller::~QScroller() #ifndef QT_NO_GESTURES QGestureRecognizer::unregisterRecognizer(d->recognizerType); // do not delete the recognizer. The QGestureManager is doing this. - d->recognizer = 0; + d->recognizer = nullptr; #endif qt_allScrollers()->remove(d->target); qt_activeScrollers()->removeOne(this); @@ -879,7 +879,7 @@ void QScroller::setSnapPositionsY(qreal first, qreal interval) QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target) : target(_target) #ifndef QT_NO_GESTURES - , recognizer(0) + , recognizer(nullptr) , recognizerType(Qt::CustomGesture) #endif , state(QScroller::Inactive) @@ -900,7 +900,7 @@ QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target) void QScrollerPrivate::init() { - setDpiFromWidget(0); + setDpiFromWidget(nullptr); monotonicTimer.start(); } diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp index df6b899fe4..0306f54faa 100644 --- a/src/widgets/util/qscrollerproperties.cpp +++ b/src/widgets/util/qscrollerproperties.cpp @@ -46,8 +46,8 @@ QT_BEGIN_NAMESPACE -static QScrollerPropertiesPrivate *userDefaults = 0; -static QScrollerPropertiesPrivate *systemDefaults = 0; +static QScrollerPropertiesPrivate *userDefaults = nullptr; +static QScrollerPropertiesPrivate *systemDefaults = nullptr; QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults() { @@ -200,7 +200,7 @@ void QScrollerProperties::setDefaultScrollerProperties(const QScrollerProperties void QScrollerProperties::unsetDefaultScrollerProperties() { delete userDefaults; - userDefaults = 0; + userDefaults = nullptr; } /*! diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index ae81cc5661..ee52139913 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -453,7 +453,7 @@ void QSystemTrayIconPrivate::_q_emitActivated(QPlatformSystemTrayIcon::Activatio } ////////////////////////////////////////////////////////////////////// -static QBalloonTip *theSolitaryBalloonTip = 0; +static QBalloonTip *theSolitaryBalloonTip = nullptr; void QBalloonTip::showBalloon(const QIcon &icon, const QString &title, const QString &message, QSystemTrayIcon *trayIcon, @@ -475,7 +475,7 @@ void QBalloonTip::hideBalloon() return; theSolitaryBalloonTip->hide(); delete theSolitaryBalloonTip; - theSolitaryBalloonTip = 0; + theSolitaryBalloonTip = nullptr; } void QBalloonTip::updateBalloonPosition(const QPoint& pos) @@ -493,7 +493,7 @@ bool QBalloonTip::isBalloonVisible() QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title, const QString &message, QSystemTrayIcon *ti) - : QWidget(0, Qt::ToolTip), + : QWidget(nullptr, Qt::ToolTip), trayIcon(ti), timerId(-1), showArrow(true) @@ -583,7 +583,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title, QBalloonTip::~QBalloonTip() { - theSolitaryBalloonTip = 0; + theSolitaryBalloonTip = nullptr; } void QBalloonTip::paintEvent(QPaintEvent *) diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 0c7bb94a91..86c11f98ed 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -97,7 +97,7 @@ private: }; QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) - : QWidget(0, Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint) + : QWidget(nullptr, Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint) , q(qIn) { setObjectName(QStringLiteral("QSystemTrayIconSys")); @@ -218,7 +218,7 @@ private: //////////////////////////////////////////////////////////////////////////// QSystemTrayIconPrivate::QSystemTrayIconPrivate() - : sys(0), + : sys(nullptr), qpa_sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon()), visible(false), trayWatcher(nullptr) diff --git a/src/widgets/util/qundogroup.cpp b/src/widgets/util/qundogroup.cpp index 9bd63d4232..ae439743bc 100644 --- a/src/widgets/util/qundogroup.cpp +++ b/src/widgets/util/qundogroup.cpp @@ -47,7 +47,7 @@ class QUndoGroupPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QUndoGroup) public: - QUndoGroupPrivate() : active(0) {} + QUndoGroupPrivate() : active(nullptr) {} QUndoStack *active; QList<QUndoStack*> stack_list; @@ -113,7 +113,7 @@ QUndoGroup::~QUndoGroup() QList<QUndoStack *>::iterator it = d->stack_list.begin(); QList<QUndoStack *>::iterator end = d->stack_list.end(); while (it != end) { - (*it)->d_func()->group = 0; + (*it)->d_func()->group = nullptr; ++it; } } @@ -154,8 +154,8 @@ void QUndoGroup::removeStack(QUndoStack *stack) if (d->stack_list.removeAll(stack) == 0) return; if (stack == d->active) - setActiveStack(0); - stack->d_func()->group = 0; + setActiveStack(nullptr); + stack->d_func()->group = nullptr; } /*! @@ -190,7 +190,7 @@ void QUndoGroup::setActiveStack(QUndoStack *stack) if (d->active == stack) return; - if (d->active != 0) { + if (d->active != nullptr) { disconnect(d->active, SIGNAL(canUndoChanged(bool)), this, SIGNAL(canUndoChanged(bool))); disconnect(d->active, SIGNAL(undoTextChanged(QString)), @@ -207,7 +207,7 @@ void QUndoGroup::setActiveStack(QUndoStack *stack) d->active = stack; - if (d->active == 0) { + if (d->active == nullptr) { emit canUndoChanged(false); emit undoTextChanged(QString()); emit canRedoChanged(false); @@ -265,7 +265,7 @@ QUndoStack *QUndoGroup::activeStack() const void QUndoGroup::undo() { Q_D(QUndoGroup); - if (d->active != 0) + if (d->active != nullptr) d->active->undo(); } @@ -282,7 +282,7 @@ void QUndoGroup::undo() void QUndoGroup::redo() { Q_D(QUndoGroup); - if (d->active != 0) + if (d->active != nullptr) d->active->redo(); } @@ -298,7 +298,7 @@ void QUndoGroup::redo() bool QUndoGroup::canUndo() const { Q_D(const QUndoGroup); - return d->active != 0 && d->active->canUndo(); + return d->active != nullptr && d->active->canUndo(); } /*! @@ -313,7 +313,7 @@ bool QUndoGroup::canUndo() const bool QUndoGroup::canRedo() const { Q_D(const QUndoGroup); - return d->active != 0 && d->active->canRedo(); + return d->active != nullptr && d->active->canRedo(); } /*! @@ -328,7 +328,7 @@ bool QUndoGroup::canRedo() const QString QUndoGroup::undoText() const { Q_D(const QUndoGroup); - return d->active == 0 ? QString() : d->active->undoText(); + return d->active == nullptr ? QString() : d->active->undoText(); } /*! @@ -343,7 +343,7 @@ QString QUndoGroup::undoText() const QString QUndoGroup::redoText() const { Q_D(const QUndoGroup); - return d->active == 0 ? QString() : d->active->redoText(); + return d->active == nullptr ? QString() : d->active->redoText(); } /*! @@ -358,7 +358,7 @@ QString QUndoGroup::redoText() const bool QUndoGroup::isClean() const { Q_D(const QUndoGroup); - return d->active == 0 || d->active->isClean(); + return d->active == nullptr || d->active->isClean(); } #ifndef QT_NO_ACTION diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 8788c42252..f188b8298a 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -128,7 +128,7 @@ QUndoCommand::QUndoCommand(const QString &text, QUndoCommand *parent) QUndoCommand::QUndoCommand(QUndoCommand *parent) { d = new QUndoCommandPrivate; - if (parent != 0) + if (parent != nullptr) parent->d->child_list.append(this); } @@ -336,7 +336,7 @@ int QUndoCommand::childCount() const const QUndoCommand *QUndoCommand::child(int index) const { if (index < 0 || index >= d->child_list.count()) - return 0; + return nullptr; return d->child_list.at(index); } @@ -559,7 +559,7 @@ QUndoStack::~QUndoStack() { #if QT_CONFIG(undogroup) Q_D(QUndoStack); - if (d->group != 0) + if (d->group != nullptr) d->group->removeStack(this); #endif clear(); @@ -640,7 +640,7 @@ void QUndoStack::push(QUndoCommand *cmd) bool macro = !d->macro_stack.isEmpty(); - QUndoCommand *cur = 0; + QUndoCommand *cur = nullptr; if (macro) { QUndoCommand *macro_cmd = d->macro_stack.constLast(); if (!macro_cmd->d->child_list.isEmpty()) @@ -654,7 +654,7 @@ void QUndoStack::push(QUndoCommand *cmd) d->clean_index = -1; // we've deleted the clean state } - bool try_merge = cur != 0 + bool try_merge = cur != nullptr && cur->id() != -1 && cur->id() == cmd->id() && (macro || d->index != d->clean_index); @@ -1225,7 +1225,7 @@ const QUndoCommand *QUndoStack::command(int index) const Q_D(const QUndoStack); if (index < 0 || index >= d->command_list.count()) - return 0; + return nullptr; return d->command_list.at(index); } @@ -1305,11 +1305,11 @@ void QUndoStack::setActive(bool active) #else Q_D(QUndoStack); - if (d->group != 0) { + if (d->group != nullptr) { if (active) d->group->setActiveStack(this); else if (d->group->activeStack() == this) - d->group->setActiveStack(0); + d->group->setActiveStack(nullptr); } #endif } @@ -1320,7 +1320,7 @@ bool QUndoStack::isActive() const return true; #else Q_D(const QUndoStack); - return d->group == 0 || d->group->activeStack() == this; + return d->group == nullptr || d->group->activeStack() == this; #endif } diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index f59d87fb9d..9ca83a1da2 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -54,7 +54,7 @@ class QUndoModel : public QAbstractItemModel { Q_OBJECT public: - QUndoModel(QObject *parent = 0); + QUndoModel(QObject *parent = nullptr); QUndoStack *stack() const; @@ -92,7 +92,7 @@ private: QUndoModel::QUndoModel(QObject *parent) : QAbstractItemModel(parent) { - m_stack = 0; + m_stack = nullptr; m_sel_model = new QItemSelectionModel(this, this); connect(m_sel_model, SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(setStackCurrentIndex(QModelIndex))); @@ -114,13 +114,13 @@ void QUndoModel::setStack(QUndoStack *stack) if (m_stack == stack) return; - if (m_stack != 0) { + if (m_stack != nullptr) { disconnect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged())); disconnect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged())); disconnect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*))); } m_stack = stack; - if (m_stack != 0) { + if (m_stack != nullptr) { connect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged())); connect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged())); connect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*))); @@ -133,7 +133,7 @@ void QUndoModel::stackDestroyed(QObject *obj) { if (obj != m_stack) return; - m_stack = 0; + m_stack = nullptr; stackChanged(); } @@ -147,7 +147,7 @@ void QUndoModel::stackChanged() void QUndoModel::setStackCurrentIndex(const QModelIndex &index) { - if (m_stack == 0) + if (m_stack == nullptr) return; if (index == selectedIndex()) @@ -161,12 +161,12 @@ void QUndoModel::setStackCurrentIndex(const QModelIndex &index) QModelIndex QUndoModel::selectedIndex() const { - return m_stack == 0 ? QModelIndex() : createIndex(m_stack->index(), 0); + return m_stack == nullptr ? QModelIndex() : createIndex(m_stack->index(), 0); } QModelIndex QUndoModel::index(int row, int column, const QModelIndex &parent) const { - if (m_stack == 0) + if (m_stack == nullptr) return QModelIndex(); if (parent.isValid()) @@ -188,7 +188,7 @@ QModelIndex QUndoModel::parent(const QModelIndex&) const int QUndoModel::rowCount(const QModelIndex &parent) const { - if (m_stack == 0) + if (m_stack == nullptr) return 0; if (parent.isValid()) @@ -204,7 +204,7 @@ int QUndoModel::columnCount(const QModelIndex&) const QVariant QUndoModel::data(const QModelIndex &index, int role) const { - if (m_stack == 0) + if (m_stack == nullptr) return QVariant(); if (index.column() != 0) @@ -274,9 +274,9 @@ class QUndoViewPrivate : public QListViewPrivate public: QUndoViewPrivate() : #if QT_CONFIG(undogroup) - group(0), + group(nullptr), #endif - model(0) {} + model(nullptr) {} #if QT_CONFIG(undogroup) QPointer<QUndoGroup> group; @@ -370,7 +370,7 @@ void QUndoView::setStack(QUndoStack *stack) { Q_D(QUndoView); #if QT_CONFIG(undogroup) - setGroup(0); + setGroup(nullptr); #endif d->model->setStack(stack); } @@ -393,19 +393,19 @@ void QUndoView::setGroup(QUndoGroup *group) if (d->group == group) return; - if (d->group != 0) { + if (d->group != nullptr) { disconnect(d->group, SIGNAL(activeStackChanged(QUndoStack*)), d->model, SLOT(setStack(QUndoStack*))); } d->group = group; - if (d->group != 0) { + if (d->group != nullptr) { connect(d->group, SIGNAL(activeStackChanged(QUndoStack*)), d->model, SLOT(setStack(QUndoStack*))); d->model->setStack(d->group->activeStack()); } else { - d->model->setStack(0); + d->model->setStack(nullptr); } } diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 19528d61d2..022f41738c 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -177,7 +177,7 @@ QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type) checkable(false), checked(false), autoRepeat(false), autoExclusive(false), down(false), blockRefresh(false), pressed(false), #if QT_CONFIG(buttongroup) - group(0), + group(nullptr), #endif autoRepeatDelay(AUTO_REPEAT_DELAY), autoRepeatInterval(AUTO_REPEAT_INTERVAL), @@ -217,14 +217,14 @@ QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const Q_Q(const QAbstractButton); QList<QAbstractButton *> buttonList = queryButtonList(); if (!autoExclusive || buttonList.count() == 1) // no group - return 0; + return nullptr; for (int i = 0; i < buttonList.count(); ++i) { QAbstractButton *b = buttonList.at(i); if (b->d_func()->checked && b != q) return b; } - return checked ? const_cast<QAbstractButton *>(q) : 0; + return checked ? const_cast<QAbstractButton *>(q) : nullptr; } void QAbstractButtonPrivate::notifyChecked() @@ -257,7 +257,7 @@ void QAbstractButtonPrivate::moveFocus(int key) if (!fb || !buttonList.contains(fb)) return; - QAbstractButton *candidate = 0; + QAbstractButton *candidate = nullptr; int bestScore = -1; QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0))); QPoint goal = target.center(); @@ -1272,7 +1272,7 @@ QSize QAbstractButton::iconSize() const Q_D(const QAbstractButton); if (d->iconSize.isValid()) return d->iconSize; - int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, 0, this); + int e = style()->pixelMetric(QStyle::PM_ButtonIconSize, nullptr, this); return QSize(e, e); } diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index d2372a7be9..320b3bf7ef 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -161,10 +161,10 @@ QT_BEGIN_NAMESPACE */ QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() - :hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded), + :hbar(nullptr), vbar(nullptr), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded), shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored), - viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0), - xoffset(0), yoffset(0), viewportFilter(0) + viewport(nullptr), cornerWidget(nullptr), left(0), top(0), right(0), bottom(0), + xoffset(0), yoffset(0), viewportFilter(nullptr) { } @@ -329,12 +329,12 @@ void QAbstractScrollAreaPrivate::layoutChildren() void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrollbar, bool *needVerticalScrollbar) { Q_Q(QAbstractScrollArea); - bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar); + bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, hbar); bool needh = *needHorizontalScrollbar || ((hbarpolicy != Qt::ScrollBarAlwaysOff) && ((hbarpolicy == Qt::ScrollBarAlwaysOn && !htransient) || ((hbarpolicy == Qt::ScrollBarAsNeeded || htransient) && hbar->minimum() < hbar->maximum() && !hbar->sizeHint().isEmpty()))); - bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar); + bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, vbar); bool needv = *needVerticalScrollbar || ((vbarpolicy != Qt::ScrollBarAlwaysOff) && ((vbarpolicy == Qt::ScrollBarAlwaysOn && !vtransient) || ((vbarpolicy == Qt::ScrollBarAsNeeded || vtransient) && vbar->minimum() < vbar->maximum() && !vbar->sizeHint().isEmpty()))); @@ -352,7 +352,7 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol const QRect widgetRect = q->rect(); - const bool hasCornerWidget = (cornerWidget != 0); + const bool hasCornerWidget = (cornerWidget != nullptr); QPoint cornerOffset((needv && vscrollOverlap == 0) ? vsbExt : 0, (needh && hscrollOverlap == 0) ? hsbExt : 0); QRect controlsRect; @@ -794,7 +794,7 @@ void QAbstractScrollArea::addScrollBarWidget(QWidget *widget, Qt::Alignment alig { Q_D(QAbstractScrollArea); - if (widget == 0) + if (widget == nullptr) return; const Qt::Orientation scrollBarOrientation @@ -894,8 +894,8 @@ bool QAbstractScrollArea::eventFilter(QObject *o, QEvent *e) if (d->hbarpolicy == Qt::ScrollBarAsNeeded && d->vbarpolicy == Qt::ScrollBarAsNeeded) { QScrollBar *sbar = static_cast<QScrollBar*>(o); QScrollBar *sibling = sbar == d->hbar ? d->vbar : d->hbar; - if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sbar) && - sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, sibling)) + if (sbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, sbar) && + sibling->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, sibling)) d->setScrollBarTransient(sibling, e->type() == QEvent::HoverLeave); } } @@ -1389,10 +1389,10 @@ bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos ) void QAbstractScrollAreaPrivate::flashScrollBars() { - bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, hbar); + bool htransient = hbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, hbar); if ((hbarpolicy != Qt::ScrollBarAlwaysOff) && (hbarpolicy == Qt::ScrollBarAsNeeded || htransient)) hbar->d_func()->flash(); - bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, vbar); + bool vtransient = vbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, vbar); if ((vbarpolicy != Qt::ScrollBarAlwaysOff) && (vbarpolicy == Qt::ScrollBarAsNeeded || vtransient)) vbar->d_func()->flash(); } diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index b1e1c9bc1b..6a0d2f5019 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -848,9 +848,9 @@ void QAbstractSpinBox::changeEvent(QEvent *event) switch (event->type()) { case QEvent::StyleChange: - d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this); + d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, nullptr, this); d->spinClickThresholdTimerInterval = - style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this); + style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, nullptr, this); if (d->edit) d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)); d->stepModifier = static_cast<Qt::KeyboardModifier>(style()->styleHint(QStyle::SH_SpinBox_StepModifier, nullptr, this)); @@ -1043,7 +1043,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event) steps *= 10; if (!up) steps *= -1; - if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, 0, this)) { + if (style()->styleHint(QStyle::SH_SpinBox_AnimateButton, nullptr, this)) { d->buttonState = (Keyboard | (up ? Up : Down)); } if (d->spinClickTimerId == -1) @@ -1421,14 +1421,14 @@ void QAbstractSpinBox::mouseReleaseEvent(QMouseEvent *event) */ QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate() - : edit(0), type(QVariant::Invalid), spinClickTimerId(-1), + : edit(nullptr), type(QVariant::Invalid), spinClickTimerId(-1), spinClickTimerInterval(100), spinClickThresholdTimerId(-1), spinClickThresholdTimerInterval(-1), effectiveSpinRepeatRate(1), buttonState(None), cachedText(QLatin1String("\x01")), cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false), ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), stepModifier(Qt::ControlModifier), acceleration(0), hoverControl(QStyle::SC_None), - buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0), showGroupSeparator(0), + buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(nullptr), showGroupSeparator(0), wheelDeltaRemainder(0) { } diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index 669faa92c7..c3fd37d8e9 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE void QButtonGroupPrivate::detectCheckedButton() { QAbstractButton *previous = checkedButton; - checkedButton = 0; + checkedButton = nullptr; if (exclusive) return; for (int i = 0; i < buttonList.count(); i++) { @@ -119,7 +119,7 @@ QButtonGroup::~QButtonGroup() { Q_D(QButtonGroup); for (int i = 0; i < d->buttonList.count(); ++i) - d->buttonList.at(i)->d_func()->group = 0; + d->buttonList.at(i)->d_func()->group = nullptr; } /*! @@ -273,7 +273,7 @@ void QButtonGroup::removeButton(QAbstractButton *button) d->detectCheckedButton(); } if (button->d_func()->group == this) { - button->d_func()->group = 0; + button->d_func()->group = nullptr; d->buttonList.removeAll(button); d->mapping.remove(button); } diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 749ae96df2..fe1133c6c7 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -559,7 +559,7 @@ void QCalendarDateValidator::setFormat(const QString &format) separator += nextChar; quoting = false; } else { - QCalendarDateSectionValidator *validator = 0; + QCalendarDateSectionValidator *validator = nullptr; if (nextChar == QLatin1Char('d')) { offset = qMin(4, countRepeat(format, pos)); validator = &m_dayValidator; @@ -640,9 +640,9 @@ class QCalendarTextNavigator: public QObject { Q_OBJECT public: - QCalendarTextNavigator(QObject *parent = 0) - : QObject(parent), m_dateText(0), m_dateFrame(0), m_dateValidator(0), - m_widget(0), m_editDelay(1500), m_date(QDate::currentDate()) {} + QCalendarTextNavigator(QObject *parent = nullptr) + : QObject(parent), m_dateText(nullptr), m_dateFrame(nullptr), m_dateValidator(nullptr), + m_widget(nullptr), m_editDelay(1500), m_date(QDate::currentDate()) {} QWidget *widget() const; void setWidget(QWidget *widget); @@ -752,9 +752,9 @@ void QCalendarTextNavigator::removeDateLabel() m_dateFrame->hide(); m_dateFrame->deleteLater(); delete m_dateValidator; - m_dateFrame = 0; - m_dateText = 0; - m_dateValidator = 0; + m_dateFrame = nullptr; + m_dateText = nullptr; + m_dateValidator = nullptr; } bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e) @@ -858,7 +858,7 @@ class QCalendarModel : public QAbstractTableModel { Q_OBJECT public: - QCalendarModel(QObject *parent = 0); + QCalendarModel(QObject *parent = nullptr); int rowCount(const QModelIndex &) const override { return RowCount + m_firstRow; } @@ -951,7 +951,7 @@ class QCalendarView : public QTableView { Q_OBJECT public: - QCalendarView(QWidget *parent = 0); + QCalendarView(QWidget *parent = nullptr); void internalUpdate() { updateGeometries(); } void setReadOnly(bool enable); @@ -1599,7 +1599,7 @@ class QCalendarDelegate : public QItemDelegate { Q_OBJECT public: - QCalendarDelegate(QCalendarWidgetPrivate *w, QObject *parent = 0) + QCalendarDelegate(QCalendarWidgetPrivate *w, QObject *parent = nullptr) : QItemDelegate(parent), calendarWidgetPrivate(w) { } virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, @@ -1734,11 +1734,11 @@ void QCalendarDelegate::paintCell(QPainter *painter, const QRect &rect, QDate da QCalendarWidgetPrivate::QCalendarWidgetPrivate() : QWidgetPrivate() { - m_model = 0; - m_view = 0; - m_delegate = 0; - m_selection = 0; - m_navigator = 0; + m_model = nullptr; + m_view = nullptr; + m_delegate = nullptr; + m_selection = nullptr; + m_navigator = nullptr; m_dateEditEnabled = false; navBarVisible = true; oldFocusPolicy = Qt::StrongFocus; @@ -1748,7 +1748,7 @@ void QCalendarWidgetPrivate::setNavigatorEnabled(bool enable) { Q_Q(QCalendarWidget); - bool navigatorEnabled = (m_navigator->widget() != 0); + bool navigatorEnabled = (m_navigator->widget() != nullptr); if (enable == navigatorEnabled) return; @@ -1760,7 +1760,7 @@ void QCalendarWidgetPrivate::setNavigatorEnabled(bool enable) q, SLOT(_q_editingFinished())); m_view->installEventFilter(m_navigator); } else { - m_navigator->setWidget(0); + m_navigator->setWidget(nullptr); q->disconnect(m_navigator, SIGNAL(dateChanged(QDate)), q, SLOT(_q_slotChangeDate(QDate))); q->disconnect(m_navigator, SIGNAL(editingFinished()), @@ -1847,8 +1847,8 @@ void QCalendarWidgetPrivate::createNavigationBar(QWidget *widget) void QCalendarWidgetPrivate::updateButtonIcons() { Q_Q(QCalendarWidget); - prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, 0, q)); - nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, 0, q)); + prevMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowRight : QStyle::SP_ArrowLeft, nullptr, q)); + nextMonth->setIcon(q->style()->standardIcon(q->isRightToLeft() ? QStyle::SP_ArrowLeft : QStyle::SP_ArrowRight, nullptr, q)); } void QCalendarWidgetPrivate::updateMonthMenu() diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 3be163ff75..8c8aaf8ae3 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -764,7 +764,7 @@ QCalendarWidget *QDateTimeEdit::calendarWidget() const { Q_D(const QDateTimeEdit); if (!d->calendarPopup || !(d->sections & QDateTimeParser::DateSectionMask)) - return 0; + return nullptr; if (!d->monthCalendar) { const_cast<QDateTimeEditPrivate*>(d)->initCalendarPopup(); } @@ -1221,7 +1221,7 @@ void QDateTimeEdit::focusInEvent(QFocusEvent *event) { Q_D(QDateTimeEdit); QAbstractSpinBox::focusInEvent(event); - QString *frm = 0; + QString *frm = nullptr; const int oldPos = d->edit->cursorPosition(); if (!d->formatExplicitlySet) { if (d->displayFormat == d->defaultTimeFormat) { @@ -1668,7 +1668,7 @@ QDateTimeEditPrivate::QDateTimeEditPrivate() minimum = QDATETIMEEDIT_COMPAT_DATE_MIN.startOfDay(); maximum = QDATETIMEEDIT_DATE_MAX.endOfDay(); arrowState = QStyle::State_None; - monthCalendar = 0; + monthCalendar = nullptr; readLocaleSettings(); #ifdef QT_KEYPAD_NAVIGATION diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 9096ee82f6..9867cb5540 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -178,15 +178,15 @@ public: }; QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient) - : orientation(orient), buttonLayout(0), internalRemove(false), center(false) + : orientation(orient), buttonLayout(nullptr), internalRemove(false), center(false) { } void QDialogButtonBoxPrivate::initLayout() { Q_Q(QDialogButtonBox); - layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q)); - bool createNewLayout = buttonLayout == 0 + layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, nullptr, q)); + bool createNewLayout = buttonLayout == nullptr || (orientation == Qt::Horizontal && qobject_cast<QVBoxLayout *>(buttonLayout) != 0) || (orientation == Qt::Vertical && qobject_cast<QHBoxLayout *>(buttonLayout) != 0); if (createNewLayout) { @@ -329,8 +329,8 @@ void QDialogButtonBoxPrivate::layoutButtons() ++currentLayout; } - QWidget *lastWidget = 0; - q->setFocusProxy(0); + QWidget *lastWidget = nullptr; + q->setFocusProxy(nullptr); for (int i = 0; i < buttonLayout->count(); ++i) { QLayoutItem *item = buttonLayout->itemAt(i); if (QWidget *widget = item->widget()) { @@ -408,13 +408,13 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut icon = QStyle::SP_RestoreDefaultsButton; break; case QDialogButtonBox::NoButton: - return 0; + return nullptr; ; } QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q); QStyle *style = q->style(); - if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0) - button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q)); + if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, nullptr, q) && icon != 0) + button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), nullptr, q)); if (style != QApplication::style()) // Propagate style button->setStyle(style); standardButtonHash.insert(button, sbutton); @@ -743,7 +743,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) } } if (!d->internalRemove) - button->setParent(0); + button->setParent(nullptr); } /*! @@ -781,7 +781,7 @@ QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role) Q_D(QDialogButtonBox); if (Q_UNLIKELY(role <= InvalidRole || role >= NRoles)) { qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added"); - return 0; + return nullptr; } QPushButton *button = new QPushButton(text, this); d->addButton(button, role); @@ -963,7 +963,7 @@ bool QDialogButtonBox::event(QEvent *event) QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole]; QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0)); bool hasDefault = false; - QWidget *dialog = 0; + QWidget *dialog = nullptr; QWidget *p = this; while (p && !p->isWindow()) { p = p->parentWidget(); diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 5900326087..87f4519dd6 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -85,27 +85,27 @@ QPlaceHolderItem::QPlaceHolderItem(QWidget *w) */ QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem) - : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags) + : widgetItem(_widgetItem), subinfo(nullptr), placeHolderItem(nullptr), pos(0), size(-1), flags(NoFlags) { } QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo) - : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags) + : widgetItem(nullptr), subinfo(_subinfo), placeHolderItem(nullptr), pos(0), size(-1), flags(NoFlags) { } QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem) - : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags) + : widgetItem(nullptr), subinfo(nullptr), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags) { } QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other) - : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos), + : widgetItem(other.widgetItem), subinfo(nullptr), placeHolderItem(nullptr), pos(other.pos), size(other.size), flags(other.flags) { - if (other.subinfo != 0) + if (other.subinfo != nullptr) subinfo = new QDockAreaLayoutInfo(*other.subinfo); - else if (other.placeHolderItem != 0) + else if (other.placeHolderItem != nullptr) placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); } @@ -117,16 +117,16 @@ QDockAreaLayoutItem::~QDockAreaLayoutItem() bool QDockAreaLayoutItem::skip() const { - if (placeHolderItem != 0) + if (placeHolderItem != nullptr) return true; if (flags & GapItem) return false; - if (widgetItem != 0) + if (widgetItem != nullptr) return widgetItem->isEmpty(); - if (subinfo != 0) { + if (subinfo != nullptr) { for (int i = 0; i < subinfo->item_list.count(); ++i) { if (!subinfo->item_list.at(i).skip()) return false; @@ -140,7 +140,7 @@ QSize QDockAreaLayoutItem::minimumSize() const { if (widgetItem) return widgetItem->minimumSize().grownBy(widgetItem->widget()->contentsMargins()); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->minimumSize(); return QSize(0, 0); } @@ -149,7 +149,7 @@ QSize QDockAreaLayoutItem::maximumSize() const { if (widgetItem) return widgetItem->maximumSize().grownBy(widgetItem->widget()->contentsMargins()); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->maximumSize(); return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); } @@ -161,22 +161,22 @@ bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const { - if ((flags & GapItem) || placeHolderItem != 0) + if ((flags & GapItem) || placeHolderItem != nullptr) return false; - if (widgetItem != 0) + if (widgetItem != nullptr) return ((widgetItem->expandingDirections() & o) == o); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->expansive(o); return false; } QSize QDockAreaLayoutItem::sizeHint() const { - if (placeHolderItem != 0) + if (placeHolderItem != nullptr) return QSize(0, 0); if (widgetItem) return widgetItem->sizeHint().grownBy(widgetItem->widget()->contentsMargins()); - if (subinfo != 0) + if (subinfo != nullptr) return subinfo->sizeHint(); return QSize(-1, -1); } @@ -185,14 +185,14 @@ QDockAreaLayoutItem &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other) { widgetItem = other.widgetItem; - if (other.subinfo == 0) - subinfo = 0; + if (other.subinfo == nullptr) + subinfo = nullptr; else subinfo = new QDockAreaLayoutInfo(*other.subinfo); delete placeHolderItem; - if (other.placeHolderItem == 0) - placeHolderItem = 0; + if (other.placeHolderItem == nullptr) + placeHolderItem = nullptr; else placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem); @@ -210,7 +210,7 @@ QDockAreaLayoutItem #if QT_CONFIG(tabbar) static quintptr tabId(const QDockAreaLayoutItem &item) { - if (item.widgetItem == 0) + if (item.widgetItem == nullptr) return 0; return reinterpret_cast<quintptr>(item.widgetItem->widget()); } @@ -219,9 +219,9 @@ static quintptr tabId(const QDockAreaLayoutItem &item) static const int zero = 0; QDockAreaLayoutInfo::QDockAreaLayoutInfo() - : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0) + : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(nullptr) #if QT_CONFIG(tabbar) - , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth) + , tabbed(false), tabBar(nullptr), tabBarShape(QTabBar::RoundedSouth) #endif { } @@ -231,7 +231,7 @@ QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPositio QMainWindow *window) : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window) #if QT_CONFIG(tabbar) - , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) + , tabbed(false), tabBar(nullptr), tabBarShape(static_cast<QTabBar::Shape>(tbshape)) #endif { #if !QT_CONFIG(tabbar) @@ -250,7 +250,7 @@ void QDockAreaLayoutInfo::clear() rect = QRect(); #if QT_CONFIG(tabbar) tabbed = false; - tabBar = 0; + tabBar = nullptr; #endif } @@ -403,7 +403,7 @@ QSize QDockAreaLayoutInfo::sizeHint() const int a = 0, b = 0; int min_perp = 0; int max_perp = QWIDGETSIZE_MAX; - const QDockAreaLayoutItem *previous = 0; + const QDockAreaLayoutItem *previous = nullptr; for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); if (item.skip()) @@ -552,7 +552,7 @@ void QDockAreaLayoutInfo::fitItems() int max_size = realMaxSize(*this); int last_index = -1; - const QDockAreaLayoutItem *previous = 0; + const QDockAreaLayoutItem *previous = nullptr; for (int i = 0; i < item_list.size(); ++i) { QDockAreaLayoutItem &item = item_list[i]; if (item.skip()) @@ -633,7 +633,7 @@ void QDockAreaLayoutInfo::fitItems() item.size = ls.size; item.pos = ls.pos; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { item.subinfo->rect = itemRect(i); item.subinfo->fitItems(); } @@ -771,7 +771,7 @@ QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos, if (item.pos + item.size < pos) continue; - if (item.subinfo != 0 + if (item.subinfo != nullptr #if QT_CONFIG(tabbar) && !item.subinfo->tabbed #endif @@ -967,7 +967,7 @@ int QDockAreaLayoutInfo::separatorMove(int index, int delta) const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep; item.size = ls.size - separatorSpace; item.pos = ls.pos; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { item.subinfo->rect = itemRect(i); item.subinfo->fitItems(); } @@ -979,7 +979,7 @@ int QDockAreaLayoutInfo::separatorMove(int index, int delta) void QDockAreaLayoutInfo::unnest(int index) { QDockAreaLayoutItem &item = item_list[index]; - if (item.subinfo == 0) + if (item.subinfo == nullptr) return; if (item.subinfo->item_list.count() > 1) return; @@ -988,14 +988,14 @@ void QDockAreaLayoutInfo::unnest(int index) item_list.removeAt(index); } else if (item.subinfo->item_list.count() == 1) { QDockAreaLayoutItem &child = item.subinfo->item_list.first(); - if (child.widgetItem != 0) { + if (child.widgetItem != nullptr) { item.widgetItem = child.widgetItem; delete item.subinfo; - item.subinfo = 0; - } else if (child.subinfo != 0) { + item.subinfo = nullptr; + } else if (child.subinfo != nullptr) { QDockAreaLayoutInfo *tmp = item.subinfo; item.subinfo = child.subinfo; - child.subinfo = 0; + child.subinfo = nullptr; tmp->item_list.clear(); delete tmp; } @@ -1009,7 +1009,7 @@ void QDockAreaLayoutInfo::remove(const QList<int> &path) if (path.count() > 1) { const int index = path.first(); QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); item.subinfo->remove(path.mid(1)); unnest(index); } else { @@ -1028,13 +1028,13 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path) if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->plug(path.mid(1)); } QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.widgetItem != 0); + Q_ASSERT(item.widgetItem != nullptr); Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem); item.flags &= ~QDockAreaLayoutItem::GapItem; return item.widgetItem; @@ -1047,7 +1047,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) const int index = path.first(); if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->unplug(path.mid(1)); } @@ -1078,7 +1078,7 @@ QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path) quintptr QDockAreaLayoutInfo::currentTabId() const { - if (!tabbed || tabBar == 0) + if (!tabbed || tabBar == nullptr) return 0; int index = tabBar->currentIndex(); @@ -1095,7 +1095,7 @@ void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget) void QDockAreaLayoutInfo::setCurrentTabId(quintptr id) { - if (!tabbed || tabBar == 0) + if (!tabbed || tabBar == nullptr) return; for (int i = 0; i < tabBar->count(); ++i) { @@ -1114,7 +1114,7 @@ static QRect dockedGeometry(QWidget *widget) QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(widget->layout()); - if(layout != 0 && layout->nativeWindowDeco()) + if (layout && layout->nativeWindowDeco()) titleHeight = layout->titleHeight(); QRect result = widget->geometry(); @@ -1138,7 +1138,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid if (path.count() > 1) { QDockAreaLayoutItem &item = item_list[index]; - if (item.subinfo == 0 + if (item.subinfo == nullptr #if QT_CONFIG(tabbar) || (item.subinfo->tabbed && !insert_tabbed) #endif @@ -1149,7 +1149,7 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid QDockAreaLayoutInfo *subinfo = item.subinfo; QLayoutItem *widgetItem = item.widgetItem; QPlaceHolderItem *placeHolderItem = item.placeHolderItem; - QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect; + QRect r = subinfo == nullptr ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect; Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; #if !QT_CONFIG(tabbar) @@ -1160,11 +1160,11 @@ bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWid //item become a new top-level item.subinfo = new_info; - item.widgetItem = 0; - item.placeHolderItem = 0; + item.widgetItem = nullptr; + item.placeHolderItem = nullptr; QDockAreaLayoutItem new_item - = widgetItem == 0 + = widgetItem == nullptr ? QDockAreaLayoutItem(subinfo) : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem); new_item.size = pick(opposite, r.size()); @@ -1265,16 +1265,16 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget) return this; #endif - if (item.widgetItem != 0 && item.widgetItem->widget() == widget) + if (item.widgetItem != nullptr && item.widgetItem->widget() == widget) return this; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { if (QDockAreaLayoutInfo *result = item.subinfo->info(widget)) return result; } } - return 0; + return nullptr; } QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) @@ -1284,7 +1284,7 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path) index = -index - 1; if (index >= item_list.count()) return this; - if (path.count() == 1 || item_list[index].subinfo == 0) + if (path.count() == 1 || item_list[index].subinfo == nullptr) return this; return item_list[index].subinfo->info(path.mid(1)); } @@ -1341,7 +1341,7 @@ QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const const int index = path.first(); if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->itemRect(path.mid(1)); } @@ -1374,7 +1374,7 @@ QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const const int index = path.first(); if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list.at(index); - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->separatorRect(path.mid(1)); } return separatorRect(index); @@ -1395,7 +1395,7 @@ QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const continue; if (item.pos + item.size > pos) { - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { QList<int> result = item.subinfo->findSeparator(_pos); if (!result.isEmpty()) { result.prepend(i); @@ -1428,7 +1428,7 @@ QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) co for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { QList<int> result = item.subinfo->indexOfPlaceHolder(objectName); if (!result.isEmpty()) { result.prepend(i); @@ -1437,7 +1437,7 @@ QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) co continue; } - if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) { + if (item.placeHolderItem != nullptr && item.placeHolderItem->objectName == objectName) { QList<int> result; result << i; return result; @@ -1452,10 +1452,10 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const for (int i = 0; i < item_list.size(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.placeHolderItem != 0) + if (item.placeHolderItem != nullptr) continue; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { QList<int> result = item.subinfo->indexOf(widget); if (!result.isEmpty()) { result.prepend(i); @@ -1477,7 +1477,7 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const { QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); - Q_ASSERT(result != 0); + Q_ASSERT(result != nullptr); return result; } @@ -1536,7 +1536,7 @@ QDockWidget *QDockAreaLayoutInfo::apply(bool animate) if (item.flags & QDockAreaLayoutItem::GapItem) continue; - if (item.subinfo != 0) { + if (item.subinfo != nullptr) { item.subinfo->apply(animate); continue; } @@ -1681,7 +1681,7 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem) = new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow); item_list[index].subinfo = new_info; new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem)); - item_list[index].widgetItem = 0; + item_list[index].widgetItem = nullptr; new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem)); new_info->tabbed = true; new_info->updateTabBar(); @@ -1703,7 +1703,7 @@ void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation, = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow); item_list[index].subinfo = new_info; new_info->item_list.append(QDockAreaLayoutItem(item_list.at(index).widgetItem)); - item_list[index].widgetItem = 0; + item_list[index].widgetItem = nullptr; new_info->item_list.append(QDockAreaLayoutItem(dockWidgetItem)); } } @@ -1714,7 +1714,7 @@ QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path) const int index = path.first(); if (path.count() > 1) { const QDockAreaLayoutItem &item = item_list[index]; - Q_ASSERT(item.subinfo != 0); + Q_ASSERT(item.subinfo != nullptr); return item.subinfo->item(path.mid(1)); } return item_list[index]; @@ -1724,7 +1724,7 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const { for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.placeHolderItem != 0) + if (item.placeHolderItem != nullptr) continue; if (item.subinfo) { if (QLayoutItem *ret = item.subinfo->itemAt(x, index)) @@ -1734,14 +1734,14 @@ QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const return item.widgetItem; } } - return 0; + return nullptr; } QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) { for (int i = 0; i < item_list.count(); ++i) { QDockAreaLayoutItem &item = item_list[i]; - if (item.placeHolderItem != 0) + if (item.placeHolderItem != nullptr) continue; else if (item.subinfo) { if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) { @@ -1752,14 +1752,14 @@ QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index) if ((*x)++ == index) { item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget()); QLayoutItem *ret = item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; if (item.size != -1) item.flags |= QDockAreaLayoutItem::KeepSize; return ret; } } } - return 0; + return nullptr; } void QDockAreaLayoutInfo::deleteAllLayoutItems() @@ -1770,7 +1770,7 @@ void QDockAreaLayoutInfo::deleteAllLayoutItems() item.subinfo->deleteAllLayoutItems(); } else { delete item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; } } } @@ -1801,7 +1801,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.widgetItem != 0) { + if (item.widgetItem != nullptr) { stream << (uchar) WidgetMarker; QWidget *w = item.widgetItem->widget(); QString name = w->objectName(); @@ -1825,7 +1825,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const stream << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize()); } - } else if (item.placeHolderItem != 0) { + } else if (item.placeHolderItem != nullptr) { stream << (uchar) WidgetMarker; stream << item.placeHolderItem->objectName; uchar flags = 0; @@ -1840,7 +1840,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const } else { stream << item.pos << item.size << (int)0 << (int)0; } - } else if (item.subinfo != 0) { + } else if (item.subinfo != nullptr) { stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize()); item.subinfo->saveState(stream); } @@ -1894,7 +1894,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> continue; } - QDockWidget *widget = 0; + QDockWidget *widget = nullptr; for (int j = 0; j < widgets.count(); ++j) { if (widgets.at(j)->objectName() == name) { widget = widgets.takeAt(j); @@ -1902,7 +1902,7 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } } - if (widget == 0) { + if (widget == nullptr) { QPlaceHolderItem *placeHolder = new QPlaceHolderItem; QDockAreaLayoutItem item(placeHolder); @@ -2081,7 +2081,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this); - if (that->tabBar == 0) { + if (that->tabBar == nullptr) { that->tabBar = mainWindowLayout()->getTabBar(); that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape)); that->tabBar->setDrawBase(true); @@ -2101,7 +2101,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const gap = true; continue; } - if (item.widgetItem == 0) + if (item.widgetItem == nullptr) continue; QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget()); @@ -2155,12 +2155,12 @@ void QDockAreaLayoutInfo::setTabBarShape(int shape) if (shape == tabBarShape) return; tabBarShape = shape; - if (tabBar != 0) + if (tabBar != nullptr) tabBar->setShape(static_cast<QTabBar::Shape>(shape)); for (int i = 0; i < item_list.count(); ++i) { QDockAreaLayoutItem &item = item_list[i]; - if (item.subinfo != 0) + if (item.subinfo != nullptr) item.subinfo->setTabBarShape(shape); } } @@ -2192,7 +2192,7 @@ QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.subinfo != 0) + if (item.subinfo != nullptr) result += item.subinfo->usedTabBars(); } @@ -2212,7 +2212,7 @@ QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const for (int i = 0; i < item_list.count(); ++i) { const QDockAreaLayoutItem &item = item_list.at(i); - if (item.subinfo != 0) + if (item.subinfo != nullptr) result += item.subinfo->usedSeparatorWidgets(); } @@ -2277,7 +2277,7 @@ void QDockAreaLayoutInfo::moveTab(int from, int to) QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) { mainWindow = win; - sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win); + sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, win); #if QT_CONFIG(tabbar) const int tabShape = QTabBar::RoundedSouth; #else @@ -2291,7 +2291,7 @@ QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true) = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win); docks[QInternal::BottomDock] = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win); - centralWidgetItem = 0; + centralWidgetItem = nullptr; corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea; @@ -2491,7 +2491,7 @@ QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget) return result; } - return 0; + return nullptr; } QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) @@ -2623,7 +2623,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, QSize center_hint(0, 0); QSize center_min(0, 0); QSize center_max(0, 0); - const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty(); + const bool have_central = centralWidgetItem != nullptr && !centralWidgetItem->isEmpty(); if (have_central) { center_hint = centralWidgetRect.size(); if (!center_hint.isValid()) @@ -2670,7 +2670,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, QSize bottom_max = docks[QInternal::BottomDock].maximumSize(); bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min); - if (_ver_struct_list != 0) { + if (_ver_struct_list != nullptr) { QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list; ver_struct_list.resize(3); @@ -2732,7 +2732,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, ver_struct_list[1].maximumSize = QWIDGETSIZE_MAX; } - if (_hor_struct_list != 0) { + if (_hor_struct_list != nullptr) { QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list; hor_struct_list.resize(3); @@ -2803,7 +2803,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::TopDock].isEmpty()) { QRect r = docks[QInternal::TopDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea || docks[QInternal::LeftDock].isEmpty() ? rect.left() : hor_struct_list->at(1).pos); @@ -2811,7 +2811,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, || docks[QInternal::RightDock].isEmpty() ? rect.right() : hor_struct_list->at(2).pos - sep - 1); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(rect.top()); r.setBottom(ver_struct_list->at(1).pos - sep - 1); } @@ -2823,7 +2823,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::BottomDock].isEmpty()) { QRect r = docks[QInternal::BottomDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea || docks[QInternal::LeftDock].isEmpty() ? rect.left() : hor_struct_list->at(1).pos); @@ -2831,7 +2831,7 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, || docks[QInternal::RightDock].isEmpty() ? rect.right() : hor_struct_list->at(2).pos - sep - 1); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(ver_struct_list->at(2).pos); r.setBottom(rect.bottom()); } @@ -2843,11 +2843,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::LeftDock].isEmpty()) { QRect r = docks[QInternal::LeftDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(rect.left()); r.setRight(hor_struct_list->at(1).pos - sep - 1); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea || docks[QInternal::TopDock].isEmpty() ? rect.top() : ver_struct_list->at(1).pos); @@ -2863,11 +2863,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, if (!docks[QInternal::RightDock].isEmpty()) { QRect r = docks[QInternal::RightDock].rect; - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { r.setLeft(hor_struct_list->at(2).pos); r.setRight(rect.right()); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea || docks[QInternal::TopDock].isEmpty() ? rect.top() : ver_struct_list->at(1).pos); @@ -2881,11 +2881,11 @@ void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list, // center --------------------------------------------------- - if (hor_struct_list != 0) { + if (hor_struct_list != nullptr) { centralWidgetRect.setLeft(hor_struct_list->at(1).pos); centralWidgetRect.setWidth(hor_struct_list->at(1).size); } - if (ver_struct_list != 0) { + if (ver_struct_list != nullptr) { centralWidgetRect.setTop(ver_struct_list->at(1).pos); centralWidgetRect.setHeight(ver_struct_list->at(1).size); } @@ -2919,7 +2919,7 @@ QSize QDockAreaLayout::sizeHint() const int top_sep = 0; int bottom_sep = 0; - if (centralWidgetItem != 0) { + if (centralWidgetItem != nullptr) { left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep; right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep; top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep; @@ -2930,7 +2930,7 @@ QSize QDockAreaLayout::sizeHint() const QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0); QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep); QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep); - QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint(); + QSize center = centralWidgetItem == nullptr ? QSize(0, 0) : centralWidgetItem->sizeHint(); int row1 = top.width(); int row2 = left.width() + center.width() + right.width(); @@ -2969,7 +2969,7 @@ QSize QDockAreaLayout::minimumSize() const int top_sep = 0; int bottom_sep = 0; - if (centralWidgetItem != 0) { + if (centralWidgetItem != nullptr) { left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep; right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep; top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep; @@ -2980,7 +2980,7 @@ QSize QDockAreaLayout::minimumSize() const QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0); QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep); QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep); - QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize(); + QSize center = centralWidgetItem == nullptr ? QSize(0, 0) : centralWidgetItem->minimumSize(); int row1 = top.width(); int row2 = left.width() + center.width() + right.width(); @@ -3040,7 +3040,7 @@ QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget) bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) { - QDockAreaLayoutItem *item = 0; + QDockAreaLayoutItem *item = nullptr; const auto groups = mainWindow->findChildren<QDockWidgetGroupWindow *>(QString(), Qt::FindDirectChildrenOnly); for (QDockWidgetGroupWindow *dwgw : groups) { @@ -3059,7 +3059,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) } QPlaceHolderItem *placeHolder = item->placeHolderItem; - Q_ASSERT(placeHolder != 0); + Q_ASSERT(placeHolder != nullptr); item->widgetItem = new QDockWidgetItem(dockWidget); @@ -3069,7 +3069,7 @@ bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget) } dockWidget->setVisible(!placeHolder->hidden); - item->placeHolderItem = 0; + item->placeHolderItem = nullptr; delete placeHolder; return true; @@ -3116,7 +3116,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second) return; QDockAreaLayoutInfo *info = this->info(path); - Q_ASSERT(info != 0); + Q_ASSERT(info != nullptr); info->tab(path.last(), new QDockWidgetItem(second)); removePlaceHolder(second->objectName()); @@ -3181,7 +3181,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, return; QDockAreaLayoutInfo *info = this->info(path); - Q_ASSERT(info != 0); + Q_ASSERT(info != nullptr); info->split(path.last(), orientation, new QDockWidgetItem(dockWidget)); removePlaceHolder(dockWidget->objectName()); @@ -3193,7 +3193,7 @@ void QDockAreaLayout::apply(bool animate) for (int i = 0; i < QInternal::DockCount; ++i) docks[i].apply(animate); - if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) { + if (centralWidgetItem != nullptr && !centralWidgetItem->isEmpty()) { widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animate); } @@ -3255,9 +3255,9 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or QVector<QLayoutStruct> list; if (index == QInternal::LeftDock || index == QInternal::RightDock) - getGrid(0, &list); + getGrid(nullptr, &list); else - getGrid(&list, 0); + getGrid(&list, nullptr); int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock ? 0 : 1; @@ -3271,9 +3271,9 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or fallbackToSizeHints = false; if (index == QInternal::LeftDock || index == QInternal::RightDock) - setGrid(0, &list); + setGrid(nullptr, &list); else - setGrid(&list, 0); + setGrid(&list, nullptr); apply(false); @@ -3330,7 +3330,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const { - Q_ASSERT(x != 0); + Q_ASSERT(x != nullptr); for (int i = 0; i < QInternal::DockCount; ++i) { const QDockAreaLayoutInfo &dock = docks[i]; @@ -3341,12 +3341,12 @@ QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const if (centralWidgetItem && (*x)++ == index) return centralWidgetItem; - return 0; + return nullptr; } QLayoutItem *QDockAreaLayout::takeAt(int *x, int index) { - Q_ASSERT(x != 0); + Q_ASSERT(x != nullptr); for (int i = 0; i < QInternal::DockCount; ++i) { QDockAreaLayoutInfo &dock = docks[i]; @@ -3356,11 +3356,11 @@ QLayoutItem *QDockAreaLayout::takeAt(int *x, int index) if (centralWidgetItem && (*x)++ == index) { QLayoutItem *ret = centralWidgetItem; - centralWidgetItem = 0; + centralWidgetItem = nullptr; return ret; } - return 0; + return nullptr; } void QDockAreaLayout::deleteAllLayoutItems() @@ -3399,7 +3399,7 @@ QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const QRect QDockAreaLayout::gapRect(const QList<int> &path) const { const QDockAreaLayoutInfo *info = this->info(path); - if (info == 0) + if (info == nullptr) return QRect(); int index = path.last(); if (index < 0 || index >= info->item_list.count()) @@ -3419,7 +3419,7 @@ void QDockAreaLayout::keepSize(QDockWidget *w) void QDockAreaLayout::styleChangedEvent() { - sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow); + sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, mainWindow); if (isValid()) fitLayout(); } diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index bcbd3dd2d4..299e5da8d3 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -197,7 +197,7 @@ QSize QDockWidgetTitleButton::sizeHint() const { ensurePolished(); - int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this); + int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, nullptr, this); if (!icon().isNull()) { const QSize sz = icon().actualSize(dockButtonIconSize()); size += qMax(sz.width(), sz.height()); @@ -226,7 +226,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *) opt.init(this); opt.state |= QStyle::State_AutoRaise; - if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this)) + if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, nullptr, this)) { if (isEnabled() && underMouse() && !isChecked() && !isDown()) opt.state |= QStyle::State_Raised; @@ -311,12 +311,12 @@ QLayoutItem *QDockWidgetLayout::itemAt(int index) const int cnt = 0; for (int i = 0; i < item_list.count(); ++i) { QLayoutItem *item = item_list.at(i); - if (item == 0) + if (item == nullptr) continue; if (index == cnt++) return item; } - return 0; + return nullptr; } QLayoutItem *QDockWidgetLayout::takeAt(int index) @@ -324,7 +324,7 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index) int j = 0; for (int i = 0; i < item_list.count(); ++i) { QLayoutItem *item = item_list.at(i); - if (item == 0) + if (item == nullptr) continue; if (index == j) { item_list[i] = 0; @@ -333,7 +333,7 @@ QLayoutItem *QDockWidgetLayout::takeAt(int index) } ++j; } - return 0; + return nullptr; } int QDockWidgetLayout::count() const @@ -362,7 +362,7 @@ QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) co const bool nativeDeco = nativeWindowDeco(floating); int fw = floating && !nativeDeco - ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w) + ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, w) : 0; const int th = titleHeight(); @@ -394,7 +394,7 @@ QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) co uint explicitMin = 0; uint explicitMax = 0; - if (w->d_func()->extra != 0) { + if (w->d_func()->extra != nullptr) { explicitMin = w->d_func()->extra->explicitMinSize; explicitMax = w->d_func()->extra->explicitMaxSize; } @@ -448,7 +448,7 @@ QSize QDockWidgetLayout::minimumSize() const QWidget *QDockWidgetLayout::widgetForRole(Role r) const { QLayoutItem *item = item_list.at(r); - return item == 0 ? 0 : item->widget(); + return item == nullptr ? nullptr : item->widget(); } QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const @@ -459,12 +459,12 @@ QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const void QDockWidgetLayout::setWidgetForRole(Role r, QWidget *w) { QWidget *old = widgetForRole(r); - if (old != 0) { + if (old != nullptr) { old->hide(); removeWidget(old); } - if (w != 0) { + if (w != nullptr) { addChildWidget(w); item_list[r] = new QWidgetItemV2(w); w->show(); @@ -505,8 +505,8 @@ int QDockWidgetLayout::minimumTitleWidth() const int titleHeight = this->titleHeight(); - int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); - int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); + int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, nullptr, q); + int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, q); return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) @@ -531,7 +531,7 @@ int QDockWidgetLayout::titleHeight() const perp(verticalTitleBar, floatSize)); QFontMetrics titleFontMetrics = q->fontMetrics(); - int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); + int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, nullptr, q); return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw); } @@ -543,7 +543,7 @@ void QDockWidgetLayout::setGeometry(const QRect &geometry) bool nativeDeco = nativeWindowDeco(); int fw = q->isFloating() && !nativeDeco - ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q) + ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, q) : 0; if (nativeDeco) { @@ -730,7 +730,7 @@ void QDockWidgetPrivate::updateButtons() QStyleOptionDockWidget opt; q->initStyleOption(&opt); - bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; + bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != nullptr; bool nativeDeco = dwLayout->nativeWindowDeco(); bool hideButtons = nativeDeco || customTitleBar; @@ -777,18 +777,18 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) { Q_Q(QDockWidget); - if (state != 0) + if (state != nullptr) return; QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q); - Q_ASSERT(layout != 0); - if (layout->pluggingWidget != 0) // the main window is animating a docking operation + Q_ASSERT(layout != nullptr); + if (layout->pluggingWidget != nullptr) // the main window is animating a docking operation return; state = new QDockWidgetPrivate::DragState; state->pressPos = pos; state->dragging = false; - state->widgetItem = 0; + state->widgetItem = nullptr; state->ownWidgetItem = false; state->nca = nca; state->ctrlDrag = false; @@ -804,14 +804,14 @@ void QDockWidgetPrivate::startDrag(bool group) { Q_Q(QDockWidget); - if (state == 0 || state->dragging) + if (state == nullptr || state->dragging) return; QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q); - Q_ASSERT(layout != 0); + Q_ASSERT(layout != nullptr); state->widgetItem = layout->unplug(q, group); - if (state->widgetItem == 0) { + if (state->widgetItem == nullptr) { /* I have a QMainWindow parent, but I was never inserted with QMainWindow::addDockWidget, so the QMainWindowLayout has no widget item for me. :( I have to create it myself, and then @@ -838,7 +838,7 @@ void QDockWidgetPrivate::startDrag(bool group) void QDockWidgetPrivate::endDrag(bool abort) { Q_Q(QDockWidget); - Q_ASSERT(state != 0); + Q_ASSERT(state != nullptr); q->releaseMouse(); @@ -881,7 +881,7 @@ void QDockWidgetPrivate::endDrag(bool abort) } } delete state; - state = 0; + state = nullptr; } void QDockWidgetPrivate::setResizerActive(bool active) @@ -900,7 +900,7 @@ bool QDockWidgetPrivate::isAnimating() const Q_Q(const QDockWidget); QMainWindowLayout *mainWinLayout = qt_mainwindow_layout_from_dock(q); - if (mainWinLayout == 0) + if (mainWinLayout == nullptr) return false; return (const void*)mainWinLayout->pluggingWidget == (const void*)q; @@ -925,7 +925,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) // is not (but allow moving if the window is floating) (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) || (qobject_cast<QMainWindow*>(parent) == 0 && !floatingTab) || - isAnimating() || state != 0) { + isAnimating() || state != nullptr) { return false; } @@ -972,7 +972,7 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q); if (!dwlayout->nativeWindowDeco()) { if (!state->dragging - && mwlayout->pluggingWidget == 0 + && mwlayout->pluggingWidget == nullptr && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { startDrag(); @@ -1019,7 +1019,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) { Q_Q(QDockWidget); - int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); + int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, q); QWidget *tl = q->topLevelWidget(); QRect geo = tl->geometry(); @@ -1035,21 +1035,21 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) case QEvent::NonClientAreaMouseButtonPress: if (!titleRect.contains(event->globalPos())) break; - if (state != 0) + if (state != nullptr) break; if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0) break; if (isAnimating()) break; initDrag(event->pos(), true); - if (state == 0) + if (state == nullptr) break; state->ctrlDrag = (event->modifiers() & Qt::ControlModifier) || (!hasFeature(this, QDockWidget::DockWidgetMovable) && q->isFloating()); startDrag(); break; case QEvent::NonClientAreaMouseMove: - if (state == 0 || !state->dragging) + if (state == nullptr || !state->dragging) break; #ifndef Q_OS_MAC @@ -1085,7 +1085,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event) { Q_Q(QDockWidget); - if (state == 0 || !state->dragging || !state->nca) + if (state == nullptr || !state->dragging || !state->nca) return; if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0) @@ -1098,7 +1098,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event) return; QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q); - Q_ASSERT(layout != 0); + Q_ASSERT(layout != nullptr); QPoint globalMousePos = event->pos() + state->pressPos; layout->hover(state->widgetItem, globalMousePos); @@ -1384,7 +1384,7 @@ void QDockWidget::setFloating(bool floating) Q_D(QDockWidget); // the initial click of a double-click may have started a drag... - if (d->state != 0) + if (d->state != nullptr) d->endDrag(true); QRect r = d->undockedGeometry; @@ -1479,7 +1479,7 @@ void QDockWidget::paintEvent(QPaintEvent *event) QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); - bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; + bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != nullptr; bool nativeDeco = layout->nativeWindowDeco(); if (!nativeDeco && !customTitleBar) { @@ -1516,7 +1516,7 @@ bool QDockWidget::event(QEvent *event) switch (event->type()) { #ifndef QT_NO_ACTION case QEvent::Hide: - if (layout != 0) + if (layout != nullptr) layout->keepSize(this); d->toggleViewAction->setChecked(false); emit visibilityChanged(false); @@ -1542,12 +1542,12 @@ bool QDockWidget::event(QEvent *event) break; case QEvent::ZOrderChange: { bool onTop = false; - if (win != 0) { + if (win != nullptr) { const QObjectList &siblings = win->children(); onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; } #if QT_CONFIG(tabbar) - if (!isFloating() && layout != 0 && onTop) + if (!isFloating() && layout != nullptr && onTop) layout->raise(this); #endif break; @@ -1591,7 +1591,7 @@ bool QDockWidget::event(QEvent *event) break; case QEvent::Resize: // if the mainwindow is plugging us, we don't want to update undocked geometry - if (isFloating() && layout != 0 && layout->pluggingWidget != this) + if (isFloating() && layout != nullptr && layout->pluggingWidget != this) d->undockedGeometry = geometry(); // Usually the window won't get resized while it's being moved, but it can happen, diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index e69366d7c8..ee4095cb36 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -93,7 +93,7 @@ private: QElapsedTimer checkTime; }; -static QAlphaWidget* q_blend = 0; +static QAlphaWidget* q_blend = nullptr; /* Constructs a QAlphaWidget. @@ -285,7 +285,7 @@ void QAlphaWidget::render() lower(); } } - q_blend = 0; + q_blend = nullptr; deleteLater(); } else { alphaBlend(); @@ -377,13 +377,13 @@ private: QPixmap pm; }; -static QRollEffect* q_roll = 0; +static QRollEffect* q_roll = nullptr; /* Construct a QRollEffect widget. */ QRollEffect::QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient) - : QWidget(0, f), orientation(orient) + : QWidget(nullptr, f), orientation(orient) { #ifndef Q_OS_WIN setEnabled(false); @@ -550,7 +550,7 @@ void QRollEffect::scroll() lower(); } } - q_roll = 0; + q_roll = nullptr; deleteLater(); } } @@ -563,7 +563,7 @@ void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time) { if (q_roll) { q_roll->deleteLater(); - q_roll = 0; + q_roll = nullptr; } if (!w) @@ -585,7 +585,7 @@ void qFadeEffect(QWidget* w, int time) { if (q_blend) { q_blend->deleteLater(); - q_blend = 0; + q_blend = nullptr; } if (!w) diff --git a/src/widgets/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp index ee24e92c7e..4d64c24db3 100644 --- a/src/widgets/widgets/qfocusframe.cpp +++ b/src/widgets/widgets/qfocusframe.cpp @@ -55,8 +55,8 @@ class QFocusFramePrivate : public QWidgetPrivate bool showFrameAboveWidget; public: QFocusFramePrivate() { - widget = 0; - frameParent = 0; + widget = nullptr; + frameParent = nullptr; sendChildEvents = false; showFrameAboveWidget = false; } @@ -159,7 +159,7 @@ QFocusFrame::QFocusFrame(QWidget *parent) setAttribute(Qt::WA_TransparentForMouseEvents); setFocusPolicy(Qt::NoFocus); setAttribute(Qt::WA_NoChildEventsForParent, true); - setAttribute(Qt::WA_AcceptDrops, style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)); + setAttribute(Qt::WA_AcceptDrops, style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, nullptr, this)); } /*! @@ -184,7 +184,7 @@ QFocusFrame::setWidget(QWidget *widget) { Q_D(QFocusFrame); - if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)) + if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, nullptr, this)) d->showFrameAboveWidget = true; else d->showFrameAboveWidget = false; @@ -205,7 +205,7 @@ QFocusFrame::setWidget(QWidget *widget) d->widget = widget; d->widget->installEventFilter(this); QWidget *p = widget->parentWidget(); - QWidget *prev = 0; + QWidget *prev = nullptr; if (d->showFrameAboveWidget) { // Find the right parent for the focus frame. while (p) { @@ -231,7 +231,7 @@ QFocusFrame::setWidget(QWidget *widget) } d->update(); } else { - d->widget = 0; + d->widget = nullptr; hide(); } } @@ -290,7 +290,7 @@ QFocusFrame::eventFilter(QObject *o, QEvent *e) case QEvent::ParentChange: if (d->showFrameAboveWidget) { QWidget *w = d->widget; - setWidget(0); + setWidget(nullptr); setWidget(w); } else { d->update(); @@ -304,13 +304,13 @@ QFocusFrame::eventFilter(QObject *o, QEvent *e) setPalette(d->widget->palette()); break; case QEvent::ZOrderChange: - if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, 0, this)) + if (style()->styleHint(QStyle::SH_FocusFrame_AboveWidget, nullptr, this)) raise(); else stackUnder(d->widget); break; case QEvent::Destroy: - setWidget(0); + setWidget(nullptr); break; default: break; diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index f7fe072302..048fe42948 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -424,8 +424,8 @@ void QGroupBoxPrivate::_q_fixFocus(Qt::FocusReason reason) Q_Q(QGroupBox); QWidget *fw = q->focusWidget(); if (!fw || fw == q) { - QWidget * best = 0; - QWidget * candidate = 0; + QWidget * best = nullptr; + QWidget * candidate = nullptr; QWidget * w = q; while ((w = w->nextInFocusChain()) != q) { if (q->isAncestorOf(w) && (w->focusPolicy() & Qt::TabFocus) == Qt::TabFocus && w->isVisibleTo(q)) { diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp index 282714843c..3ddada4514 100644 --- a/src/widgets/widgets/qlcdnumber.cpp +++ b/src/widgets/widgets/qlcdnumber.cpp @@ -51,7 +51,7 @@ class QLCDNumberPrivate : public QFramePrivate public: void init(); void internalSetString(const QString& s); - void drawString(const QString& s, QPainter &, QBitArray * = 0, bool = true); + void drawString(const QString& s, QPainter &, QBitArray * = nullptr, bool = true); //void drawString(const QString &, QPainter &, QBitArray * = 0) const; void drawDigit(const QPoint &, QPainter &, int, char, char = ' '); void drawSegment(const QPoint &, char, QPainter &, int, bool = false); @@ -212,7 +212,7 @@ static QString double2string(double num, int base, int ndigits, bool *oflow) *oflow = true; return s; } - s = int2string((int)num, base, ndigits, 0); + s = int2string((int)num, base, ndigits, nullptr); } else { // decimal base int nd = ndigits; do { @@ -706,7 +706,7 @@ void QLCDNumber::paintEvent(QPaintEvent *) if (d->smallPoint) d->drawString(d->digitStr, p, &d->points, false); else - d->drawString(d->digitStr, p, 0, false); + d->drawString(d->digitStr, p, nullptr, false); } diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index dc767cdae6..bcd6614ee4 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -446,7 +446,7 @@ void QLineEdit::addAction(QAction *action, ActionPosition position) { Q_D(QLineEdit); QWidget::addAction(action); - d->addAction(action, 0, position); + d->addAction(action, nullptr, position); } /*! @@ -640,15 +640,15 @@ void QLineEdit::setCompleter(QCompleter *c) if (c == d->control->completer()) return; if (d->control->completer()) { - disconnect(d->control->completer(), 0, this, 0); - d->control->completer()->setWidget(0); + disconnect(d->control->completer(), nullptr, this, nullptr); + d->control->completer()->setWidget(nullptr); if (d->control->completer()->parent() == this) delete d->control->completer(); } d->control->setCompleter(c); if (!c) return; - if (c->widget() == 0) + if (c->widget() == nullptr) c->setWidget(this); if (hasFocus()) { QObject::connect(d->control->completer(), SIGNAL(activated(QString)), @@ -683,7 +683,7 @@ QSize QLineEdit::sizeHint() const Q_D(const QLineEdit); ensurePolished(); QFontMetrics fm(font()); - const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); + const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this); const QMargins tm = d->effectiveTextMargins(); int h = qMax(fm.height(), qMax(14, iconSize - 2)) + 2 * QLineEditPrivate::verticalMargin + tm.top() + tm.bottom() @@ -1951,7 +1951,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) #endif #if QT_CONFIG(completer) if (d->control->completer()) { - QObject::disconnect(d->control->completer(), 0, this, 0); + QObject::disconnect(d->control->completer(), nullptr, this, nullptr); } #endif QWidget::focusOutEvent(e); @@ -2190,7 +2190,7 @@ QMenu *QLineEdit::createStandardContextMenu() Q_D(QLineEdit); QMenu *popup = new QMenu(this); popup->setObjectName(QLatin1String("qt_edit_menu")); - QAction *action = 0; + QAction *action = nullptr; if (!isReadOnly()) { action = popup->addAction(QLineEdit::tr("&Undo") + ACCEL_KEY(QKeySequence::Undo)); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index d2b5f87906..feb34ef403 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -487,7 +487,7 @@ QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters() { Q_Q(const QLineEdit); SideWidgetParameters result; - result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q); + result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q); result.margin = result.iconSize / 4; result.widgetWidth = result.iconSize + 6; result.widgetHeight = result.iconSize + 2; @@ -566,12 +566,12 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE { Q_Q(QLineEdit); if (!newAction) - return 0; + return nullptr; if (!hasSideWidgets()) { // initial setup. QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); lastTextSize = q->text().size(); } - QWidget *w = 0; + QWidget *w = nullptr; // Store flags about QWidgetAction here since removeAction() may be called from ~QAction, // in which a qobject_cast<> no longer works. #if QT_CONFIG(action) diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index a11fea6bbe..5ae402b992 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -151,7 +151,7 @@ public: }; QLineEditPrivate() - : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0), + : control(nullptr), frame(1), contextMenuEnabled(1), cursorVisible(0), dragEnabled(0), clickCausedFocus(0), edited(0), hscroll(0), vscroll(0), alignment(Qt::AlignLeading | Qt::AlignVCenter), textMargins{0, 0, 0, 0}, diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 16ed699137..7f0f3342b6 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -78,7 +78,7 @@ class QMainWindowPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QMainWindow) public: inline QMainWindowPrivate() - : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) + : layout(nullptr), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) #ifdef Q_OS_OSX , useUnifiedToolBar(false) #endif @@ -94,7 +94,7 @@ public: static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) { - return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); + return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(nullptr); } }; @@ -152,10 +152,10 @@ void QMainWindowPrivate::init() topLayout->addItem(layout, 1, 1); #else - layout = new QMainWindowLayout(q, 0); + layout = new QMainWindowLayout(q, nullptr); #endif - const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); + const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, q); iconSize = QSize(metric, metric); q->setAttribute(Qt::WA_Hover); } @@ -452,7 +452,7 @@ void QMainWindow::setIconSize(const QSize &iconSize) Q_D(QMainWindow); QSize sz = iconSize; if (!sz.isValid()) { - const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); + const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, this); sz = QSize(metric, metric); } if (d->iconSize != sz) { @@ -652,8 +652,8 @@ QWidget *QMainWindow::takeCentralWidget() Q_D(QMainWindow); QWidget *oldcentralwidget = d->layout->centralWidget(); if (oldcentralwidget) { - oldcentralwidget->setParent(0); - d->layout->setCentralWidget(0); + oldcentralwidget->setParent(nullptr); + d->layout->setCentralWidget(nullptr); } return oldcentralwidget; } @@ -1478,7 +1478,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event) QMenu *QMainWindow::createPopupMenu() { Q_D(QMainWindow); - QMenu *menu = 0; + QMenu *menu = nullptr; #if QT_CONFIG(dockwidget) QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>(); if (dockwidgets.size()) { diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 0fb3a86cf8..30562d8270 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -101,14 +101,14 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutItem &item, QStri << " gap:" << (item.flags & QDockAreaLayoutItem::GapItem) << " keepSize:" << (item.flags & QDockAreaLayoutItem::KeepSize) << '\n'; indent += QLatin1String(" "); - if (item.widgetItem != 0) { + if (item.widgetItem != nullptr) { qout << indent << "widget: " << item.widgetItem->widget()->metaObject()->className() << " \"" << item.widgetItem->widget()->windowTitle() << "\"\n"; - } else if (item.subinfo != 0) { + } else if (item.subinfo != nullptr) { qout << indent << "subinfo:\n"; dumpLayout(qout, *item.subinfo, indent + QLatin1String(" ")); - } else if (item.placeHolderItem != 0) { + } else if (item.placeHolderItem != nullptr) { QRect r = item.placeHolderItem->topLevelRect; qout << indent << "placeHolder: " << "pos: " << item.pos << " size:" << item.size @@ -272,7 +272,7 @@ public: int frameWidth() const { return nativeWindowDeco() ? 0 : - parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, parentWidget()); + parentWidget()->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, parentWidget()); } QDockWidgetGroupWindow *groupWindow() const @@ -727,7 +727,7 @@ void QMainWindowLayoutState::deleteCentralWidgetItem() { #if QT_CONFIG(dockwidget) delete dockAreaLayout.centralWidgetItem; - dockAreaLayout.centralWidgetItem = 0; + dockAreaLayout.centralWidgetItem = nullptr; #else delete centralWidgetItem; centralWidgetItem = 0; @@ -749,7 +749,7 @@ QLayoutItem *QMainWindowLayoutState::itemAt(int index, int *x) const return centralWidgetItem; #endif - return 0; + return nullptr; } QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x) @@ -770,7 +770,7 @@ QLayoutItem *QMainWindowLayoutState::takeAt(int index, int *x) } #endif - return 0; + return nullptr; } QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const @@ -803,7 +803,7 @@ QList<int> QMainWindowLayoutState::indexOf(QWidget *widget) const bool QMainWindowLayoutState::contains(QWidget *widget) const { #if QT_CONFIG(dockwidget) - if (dockAreaLayout.centralWidgetItem != 0 && dockAreaLayout.centralWidgetItem->widget() == widget) + if (dockAreaLayout.centralWidgetItem != nullptr && dockAreaLayout.centralWidgetItem->widget() == widget) return true; if (!dockAreaLayout.indexOf(widget).isEmpty()) return true; @@ -821,11 +821,11 @@ bool QMainWindowLayoutState::contains(QWidget *widget) const void QMainWindowLayoutState::setCentralWidget(QWidget *widget) { - QLayoutItem *item = 0; + QLayoutItem *item = nullptr; //make sure we remove the widget deleteCentralWidgetItem(); - if (widget != 0) + if (widget != nullptr) item = new QWidgetItemV2(widget); #if QT_CONFIG(dockwidget) @@ -837,7 +837,7 @@ void QMainWindowLayoutState::setCentralWidget(QWidget *widget) QWidget *QMainWindowLayoutState::centralWidget() const { - QLayoutItem *item = 0; + QLayoutItem *item = nullptr; #if QT_CONFIG(dockwidget) item = dockAreaLayout.centralWidgetItem; @@ -845,9 +845,9 @@ QWidget *QMainWindowLayoutState::centralWidget() const item = centralWidgetItem; #endif - if (item != 0) + if (item != nullptr) return item->widget(); - return 0; + return nullptr; } QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget, @@ -978,7 +978,7 @@ QLayoutItem *QMainWindowLayoutState::item(const QList<int> &path) return dockAreaLayout.item(path.mid(1)).widgetItem; #endif // QT_CONFIG(dockwidget) - return 0; + return nullptr; } QRect QMainWindowLayoutState::itemRect(const QList<int> &path) const @@ -1029,7 +1029,7 @@ QLayoutItem *QMainWindowLayoutState::plug(const QList<int> &path) return dockAreaLayout.plug(path.mid(1)); #endif // QT_CONFIG(dockwidget) - return 0; + return nullptr; } QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowLayoutState *other) @@ -1040,7 +1040,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowL Q_UNUSED(other); #else if (i == 0) - return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : 0); + return toolBarAreaLayout.unplug(path.mid(1), other ? &other->toolBarAreaLayout : nullptr); #endif #if QT_CONFIG(dockwidget) @@ -1048,7 +1048,7 @@ QLayoutItem *QMainWindowLayoutState::unplug(const QList<int> &path, QMainWindowL return dockAreaLayout.unplug(path.mid(1)); #endif // QT_CONFIG(dockwidget) - return 0; + return nullptr; } void QMainWindowLayoutState::saveState(QDataStream &stream) const @@ -1198,7 +1198,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, continue; } QDockAreaLayoutInfo *info = dockAreaLayout.info(oldPath); - if (info == 0) { + if (info == nullptr) { continue; } info->item_list.append(QDockAreaLayoutItem(new QDockWidgetItem(w))); @@ -1249,7 +1249,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, if (oldPath.isEmpty()) { continue; } - toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(0, w); + toolBarAreaLayout.docks[oldPath.at(0)].insertToolBar(nullptr, w); } } } @@ -1755,7 +1755,7 @@ void QMainWindowTabBar::mouseReleaseEvent(QMouseEvent *e) if (dockPriv->state && dockPriv->state->dragging) { dockPriv->endDrag(); } - draggingDock = 0; + draggingDock = nullptr; } QTabBar::mouseReleaseEvent(e); } @@ -1780,7 +1780,7 @@ bool QMainWindowTabBar::event(QEvent *e) QTabBar *QMainWindowLayout::getTabBar() { - QTabBar *result = 0; + QTabBar *result = nullptr; if (!unusedTabBars.isEmpty()) { result = unusedTabBars.takeLast(); } else { @@ -1800,7 +1800,7 @@ QTabBar *QMainWindowLayout::getTabBar() // Allocates a new separator widget if needed QWidget *QMainWindowLayout::getSeparatorWidget() { - QWidget *result = 0; + QWidget *result = nullptr; if (!unusedSeparatorWidgets.isEmpty()) { result = unusedSeparatorWidgets.takeLast(); } else { @@ -1829,16 +1829,16 @@ QDockAreaLayoutInfo *QMainWindowLayout::dockInfo(QWidget *widget) if (info) return info; } - return 0; + return nullptr; } void QMainWindowLayout::tabChanged() { QTabBar *tb = qobject_cast<QTabBar*>(sender()); - if (tb == 0) + if (tb == nullptr) return; QDockAreaLayoutInfo *info = dockInfo(tb); - if (info == 0) + if (info == nullptr) return; QDockWidget *activated = info->apply(false); @@ -1866,7 +1866,7 @@ void QMainWindowLayout::tabMoved(int from, int to) void QMainWindowLayout::raise(QDockWidget *widget) { QDockAreaLayoutInfo *info = dockInfo(widget); - if (info == 0) + if (info == nullptr) return; if (!info->tabbed) return; @@ -1897,7 +1897,7 @@ QLayoutItem *QMainWindowLayout::itemAt(int index) const if (statusbar && x++ == index) return statusbar; - return 0; + return nullptr; } QLayoutItem *QMainWindowLayout::takeAt(int index) @@ -1909,7 +1909,7 @@ QLayoutItem *QMainWindowLayout::takeAt(int index) if (QWidget *w = ret->widget()) { widgetAnimator.abort(w); if (w == pluggingWidget) - pluggingWidget = 0; + pluggingWidget = nullptr; } if (savedState.isValid() ) { @@ -1934,11 +1934,11 @@ QLayoutItem *QMainWindowLayout::takeAt(int index) if (statusbar && x++ == index) { QLayoutItem *ret = statusbar; - statusbar = 0; + statusbar = nullptr; return ret; } - return 0; + return nullptr; } void QMainWindowLayout::setGeometry(const QRect &_r) @@ -2033,7 +2033,7 @@ static void fixToolBarOrientation(QLayoutItem *item, int dockPos) { #if QT_CONFIG(toolbar) QToolBar *toolBar = qobject_cast<QToolBar*>(item->widget()); - if (toolBar == 0) + if (toolBar == nullptr) return; QRect oldGeo = toolBar->geometry(); @@ -2146,7 +2146,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) if (layout->nativeWindowDeco()) { globalRect.adjust(0, layout->titleHeight(), 0, 0); } else { - int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, widget); + int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, nullptr, widget); globalRect.adjust(-fw, -fw, fw, fw); } } @@ -2214,7 +2214,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) QDockAreaLayoutItem &item = dstParentInfo->item_list[idx]; Q_ASSERT(item.widgetItem->widget() == dwgw); delete item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; item.subinfo = new QDockAreaLayoutInfo(std::move(*srcInfo)); *srcInfo = QDockAreaLayoutInfo(); item.subinfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() @@ -2238,7 +2238,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) savedState.clear(); currentGapPos.clear(); - pluggingWidget = 0; + pluggingWidget = nullptr; #if QT_CONFIG(dockwidget) setCurrentHoveredFloat(nullptr); #endif @@ -2283,16 +2283,16 @@ void QMainWindowLayout::restore(bool keepSavedState) if (!keepSavedState) savedState.clear(); currentGapPos.clear(); - pluggingWidget = 0; + pluggingWidget = nullptr; updateGapIndicator(); } QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout) - : QLayout(parentLayout ? static_cast<QWidget *>(0) : mainwindow) + : QLayout(parentLayout ? static_cast<QWidget *>(nullptr) : mainwindow) , layoutState(mainwindow) , savedState(mainwindow) , dockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks) - , statusbar(0) + , statusbar(nullptr) #if QT_CONFIG(dockwidget) #if QT_CONFIG(tabbar) , _documentMode(false) @@ -2303,14 +2303,14 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay #endif #endif // QT_CONFIG(dockwidget) , widgetAnimator(this) - , pluggingWidget(0) + , pluggingWidget(nullptr) { if (parentLayout) setParent(parentLayout); #if QT_CONFIG(dockwidget) #if QT_CONFIG(tabbar) - sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainwindow); + sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, nullptr, mainwindow); #endif #if QT_CONFIG(tabwidget) @@ -2318,7 +2318,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay tabPositions[i] = QTabWidget::South; #endif #endif // QT_CONFIG(dockwidget) - pluggingWidget = 0; + pluggingWidget = nullptr; setObjectName(mainwindow->objectName() + QLatin1String("_layout")); } @@ -2354,7 +2354,7 @@ void QMainWindowLayout::setStatusBar(QStatusBar *sb) if (sb) addChildWidget(sb); delete statusbar; - statusbar = sb ? new QWidgetItemV2(sb) : 0; + statusbar = sb ? new QWidgetItemV2(sb) : nullptr; invalidate(); } #endif // QT_CONFIG(statusbar) @@ -2366,7 +2366,7 @@ QWidget *QMainWindowLayout::centralWidget() const void QMainWindowLayout::setCentralWidget(QWidget *widget) { - if (widget != 0) + if (widget != nullptr) addChildWidget(widget); layoutState.setCentralWidget(widget); if (savedState.isValid()) { @@ -2453,7 +2453,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) #endif QList<int> path = layoutState.indexOf(widget); if (path.isEmpty()) - return 0; + return nullptr; QLayoutItem *item = layoutState.item(path); if (widget->isWindow()) @@ -2561,7 +2561,7 @@ static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) { if (!parentWidget()->isVisible() || parentWidget()->isMinimized() - || pluggingWidget != 0 || widgetItem == 0) + || pluggingWidget != nullptr || widgetItem == nullptr) return; QWidget *widget = widgetItem->widget(); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 6e3de1b1ff..3272ac440b 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -245,7 +245,7 @@ static inline bool useScrollBar(const QRect &childrenRect, const QSize &maxViewp static inline QMdiArea *mdiAreaParent(QWidget *widget) { if (!widget) - return 0; + return nullptr; QWidget *parent = widget->parentWidget(); while (parent) { @@ -253,7 +253,7 @@ static inline QMdiArea *mdiAreaParent(QWidget *widget) return area; parent = parent->parentWidget(); } - return 0; + return nullptr; } #if QT_CONFIG(tabwidget) @@ -352,7 +352,7 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0)); const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1) - + widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, 0, widgets.at(0)); + + widgets.at(0)->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widgets.at(0)); const int n = widgets.size(); const int nrows = qMax((domain.height() - (topOffset + bottomOffset)) / dy, 1); @@ -648,7 +648,7 @@ void QMdiAreaTabBar::contextMenuEvent(QContextMenuEvent *event) QMdiSubWindow *QMdiAreaTabBar::subWindowFromIndex(int index) const { if (index < 0 || index >= count()) - return 0; + return nullptr; QMdiArea *mdiArea = qobject_cast<QMdiArea *>(parentWidget()); Q_ASSERT(mdiArea); @@ -667,15 +667,15 @@ QMdiSubWindow *QMdiAreaTabBar::subWindowFromIndex(int index) const \internal */ QMdiAreaPrivate::QMdiAreaPrivate() - : cascader(0), - regularTiler(0), - iconTiler(0), - placer(0), + : cascader(nullptr), + regularTiler(nullptr), + iconTiler(nullptr), + placer(nullptr), #if QT_CONFIG(rubberband) - rubberBand(0), + rubberBand(nullptr), #endif #if QT_CONFIG(tabbar) - tabBar(0), + tabBar(nullptr), #endif activationOrder(QMdiArea::CreationOrder), viewMode(QMdiArea::SubWindowView), @@ -1070,7 +1070,7 @@ void QMdiAreaPrivate::emitWindowActivated(QMdiSubWindow *activeWindow) Q_ASSERT(aboutToBecomeActive == activeWindow); active = activeWindow; - aboutToBecomeActive = 0; + aboutToBecomeActive = nullptr; Q_ASSERT(active->d_func()->isActive); #if QT_CONFIG(tabbar) @@ -1093,20 +1093,20 @@ void QMdiAreaPrivate::resetActiveWindow(QMdiSubWindow *deactivatedWindow) if (deactivatedWindow) { if (deactivatedWindow != active) return; - active = 0; + active = nullptr; if ((aboutToBecomeActive || isActivated || lastWindowAboutToBeDestroyed()) && !isExplicitlyDeactivated(deactivatedWindow) && !q->window()->isMinimized()) { return; } - emit q->subWindowActivated(0); + emit q->subWindowActivated(nullptr); return; } if (aboutToBecomeActive) return; - active = 0; - emit q->subWindowActivated(0); + active = nullptr; + emit q->subWindowActivated(nullptr); } /*! @@ -1171,7 +1171,7 @@ void QMdiAreaPrivate::updateScrollBars() QSize hbarExtent = hbar->sizeHint(); QSize vbarExtent = vbar->sizeHint(); - if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) { + if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)) { const int doubleFrameWidth = frameWidth * 2; if (hbarpolicy == Qt::ScrollBarAlwaysOn) maxSize.rheight() -= doubleFrameWidth; @@ -1232,7 +1232,7 @@ void QMdiAreaPrivate::internalRaise(QMdiSubWindow *mdiChild) const if (!sanityCheck(mdiChild, "QMdiArea::internalRaise") || childWindows.size() < 2) return; - QMdiSubWindow *stackUnderChild = 0; + QMdiSubWindow *stackUnderChild = nullptr; if (!windowStaysOnTop(mdiChild)) { const auto children = viewport->children(); // take a copy, as raising/stacking under changes the order for (QObject *object : children) { @@ -1282,8 +1282,8 @@ QRect QMdiAreaPrivate::resizeToMinimumTileSize(const QSize &minSubWindowSize, in minAreaHeight += hbar->height(); if (vbar->isVisible()) minAreaWidth += vbar->width(); - if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)) { - const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q); + if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)) { + const int frame = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, q); minAreaWidth += 2 * frame; minAreaHeight += 2 * frame; } @@ -1427,7 +1427,7 @@ void QMdiAreaPrivate::disconnectSubWindow(QObject *subWindow) return; Q_Q(QMdiArea); - QObject::disconnect(subWindow, 0, q, 0); + QObject::disconnect(subWindow, nullptr, q, nullptr); subWindow->removeEventFilter(q); } @@ -1438,11 +1438,11 @@ QMdiSubWindow *QMdiAreaPrivate::nextVisibleSubWindow(int increaseFactor, QMdiAre int removedIndex, int fromIndex) const { if (childWindows.isEmpty()) - return 0; + return nullptr; Q_Q(const QMdiArea); const QList<QMdiSubWindow *> subWindows = q->subWindowList(order); - QMdiSubWindow *current = 0; + QMdiSubWindow *current = nullptr; if (removedIndex < 0) { if (fromIndex >= 0 && fromIndex < subWindows.size()) @@ -1482,7 +1482,7 @@ QMdiSubWindow *QMdiAreaPrivate::nextVisibleSubWindow(int increaseFactor, QMdiAre if (!subWindows.at(index)->isHidden()) return subWindows.at(index); - return 0; + return nullptr; } /*! @@ -1603,7 +1603,7 @@ void QMdiAreaPrivate::setViewMode(QMdiArea::ViewMode mode) { // SubWindowView #if QT_CONFIG(tabbar) delete tabBar; - tabBar = 0; + tabBar = nullptr; #endif // QT_CONFIG(tabbar) viewMode = mode; @@ -1704,7 +1704,7 @@ QMdiArea::QMdiArea(QWidget *parent) setFrameStyle(QFrame::NoFrame); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setViewport(0); + setViewport(nullptr); setFocusPolicy(Qt::NoFocus); QApplication::instance()->installEventFilter(this); } @@ -1716,16 +1716,16 @@ QMdiArea::~QMdiArea() { Q_D(QMdiArea); delete d->cascader; - d->cascader = 0; + d->cascader = nullptr; delete d->regularTiler; - d->regularTiler = 0; + d->regularTiler = nullptr; delete d->iconTiler; - d->iconTiler = 0; + d->iconTiler = nullptr; delete d->placer; - d->placer = 0; + d->placer = nullptr; } /*! @@ -1760,8 +1760,8 @@ QSize QMdiArea::sizeHint() const QSize QMdiArea::minimumSizeHint() const { Q_D(const QMdiArea); - QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, this), - style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, this)); + QSize size(style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, nullptr, this), + style()->pixelMetric(QStyle::PM_TitleBarHeight, nullptr, this)); size = size.expandedTo(QAbstractScrollArea::minimumSizeHint()); if (!d->scrollBarsEnabled()) { for (QMdiSubWindow *child : d->childWindows) { @@ -1965,7 +1965,7 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla { if (Q_UNLIKELY(!widget)) { qWarning("QMdiArea::addSubWindow: null pointer to widget"); - return 0; + return nullptr; } Q_D(QMdiArea); @@ -2027,7 +2027,7 @@ void QMdiArea::removeSubWindow(QWidget *widget) d->childWindows.removeAll(child); d->indicesToActivatedChildren.removeAll(index); d->updateActiveWindow(index, d->active == child); - child->setParent(0); + child->setParent(nullptr); return; } @@ -2036,7 +2036,7 @@ void QMdiArea::removeSubWindow(QWidget *widget) if (!sanityCheck(child, "QMdiArea::removeSubWindow")) continue; if (child->widget() == widget) { - child->setWidget(0); + child->setWidget(nullptr); Q_ASSERT(!child->widget()); found = true; break; diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index a0286dfcb1..84568c35db 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -253,7 +253,7 @@ static inline ControlElement<T> *ptr(QWidget *widget) && strcmp(widget->metaObject()->className(), T::staticMetaObject.className()) == 0) { return static_cast<ControlElement<T> *>(widget); } - return 0; + return nullptr; } QString QMdiSubWindowPrivate::originalWindowTitle() @@ -364,7 +364,7 @@ class ControlLabel : public QWidget { Q_OBJECT public: - ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0); + ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = nullptr); QSize sizeHint() const override; @@ -481,8 +481,8 @@ void ControlLabel::updateWindowIcon() { QIcon menuIcon = windowIcon(); if (menuIcon.isNull()) - menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget()); - const int iconSize = style()->pixelMetric(QStyle::PM_TitleBarButtonIconSize, 0, parentWidget()); + menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, nullptr, parentWidget()); + const int iconSize = style()->pixelMetric(QStyle::PM_TitleBarButtonIconSize, nullptr, parentWidget()); label = menuIcon.pixmap(iconSize); update(); } @@ -496,7 +496,7 @@ class ControllerWidget : public QWidget { Q_OBJECT public: - ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0); + ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = nullptr); QSize sizeHint() const override; void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible); inline bool hasVisibleControls() const @@ -542,7 +542,7 @@ ControllerWidget::ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent) activeControl(QStyle::SC_None), hoverControl(QStyle::SC_None), visibleControls(QStyle::SC_None), - mdiArea(0) + mdiArea(nullptr) { if (subWindow->parentWidget()) mdiArea = qobject_cast<QMdiArea *>(subWindow->parentWidget()->parentWidget()); @@ -697,10 +697,10 @@ void ControllerWidget::initStyleOption(QStyleOptionComplex *option) const */ ControlContainer::ControlContainer(QMdiSubWindow *mdiChild) : QObject(mdiChild), - previousLeft(0), - previousRight(0), + previousLeft(nullptr), + previousRight(nullptr), #if QT_CONFIG(menubar) - m_menuBar(0), + m_menuBar(nullptr), #endif mdiChild(mdiChild) { @@ -725,9 +725,9 @@ ControlContainer::~ControlContainer() removeButtonsFromMenuBar(); #endif delete m_menuLabel; - m_menuLabel = 0; + m_menuLabel = nullptr; delete m_controllerWidget; - m_controllerWidget = 0; + m_controllerWidget = nullptr; } #if QT_CONFIG(menubar) @@ -741,12 +741,12 @@ QMenuBar *QMdiSubWindowPrivate::menuBar() const #else Q_Q(const QMdiSubWindow); if (!q->isMaximized() || drawTitleBarWhenMaximized() || isChildOfTabbedQMdiArea(q)) - return 0; + return nullptr; if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) return mainWindow->menuBar(); - return 0; + return nullptr; #endif } @@ -790,50 +790,50 @@ void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar) { if (menuBar && menuBar != m_menuBar) { // m_menubar was deleted while sub-window was maximized - previousRight = 0; - previousLeft = 0; + previousRight = nullptr; + previousLeft = nullptr; m_menuBar = menuBar; } if (!m_menuBar || !mdiChild || qt_widget_private(mdiChild->window())->data.in_destructor) return; - QMdiSubWindow *child = 0; + QMdiSubWindow *child = nullptr; if (m_controllerWidget) { QWidget *currentRight = m_menuBar->cornerWidget(Qt::TopRightCorner); if (currentRight == m_controllerWidget) { if (ControlElement<ControllerWidget> *ce = ptr<ControllerWidget>(previousRight)) { if (!ce->mdiChild || !ce->mdiChild->isMaximized()) - previousRight = 0; + previousRight = nullptr; else child = ce->mdiChild; } m_menuBar->setCornerWidget(previousRight, Qt::TopRightCorner); if (previousRight) { previousRight->show(); - previousRight = 0; + previousRight = nullptr; } } m_controllerWidget->hide(); - m_controllerWidget->setParent(0); + m_controllerWidget->setParent(nullptr); } if (m_menuLabel) { QWidget *currentLeft = m_menuBar->cornerWidget(Qt::TopLeftCorner); if (currentLeft == m_menuLabel) { if (ControlElement<ControlLabel> *ce = ptr<ControlLabel>(previousLeft)) { if (!ce->mdiChild || !ce->mdiChild->isMaximized()) - previousLeft = 0; + previousLeft = nullptr; else if (!child) child = mdiChild; } m_menuBar->setCornerWidget(previousLeft, Qt::TopLeftCorner); if (previousLeft) { previousLeft->show(); - previousLeft = 0; + previousLeft = nullptr; } } m_menuLabel->hide(); - m_menuLabel->setParent(0); + m_menuLabel->setParent(nullptr); } m_menuBar->update(); if (child) @@ -854,14 +854,14 @@ void ControlContainer::updateWindowIcon(const QIcon &windowIcon) \internal */ QMdiSubWindowPrivate::QMdiSubWindowPrivate() - : baseWidget(0), - restoreFocusWidget(0), - controlContainer(0), + : baseWidget(nullptr), + restoreFocusWidget(nullptr), + controlContainer(nullptr), #if QT_CONFIG(sizegrip) - sizeGrip(0), + sizeGrip(nullptr), #endif #if QT_CONFIG(rubberband) - rubberBand(0), + rubberBand(nullptr), #endif userMinimumSize(0,0), resizeEnabled(true), @@ -926,7 +926,7 @@ void QMdiSubWindowPrivate::_q_enterInteractiveMode() pressPos = QPoint(q->width() / 2, titleBarHeight() - 1); } else if (actions[ResizeAction] && actions[ResizeAction] == action) { currentOperation = q->isLeftToRight() ? BottomRightResize : BottomLeftResize; - int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q) / 2; + int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q) / 2; int x = q->isLeftToRight() ? q->width() - offset : offset; pressPos = QPoint(x, q->height() - offset); } else { @@ -1009,8 +1009,8 @@ void QMdiSubWindowPrivate::removeBaseWidget() lastChildWindowTitle.clear(); // QTBUG-47993: parent widget can be reset before this call if (baseWidget->parentWidget() == q) - baseWidget->setParent(0); - baseWidget = 0; + baseWidget->setParent(nullptr); + baseWidget = nullptr; isWidgetHiddenByUs = false; } @@ -1047,19 +1047,19 @@ void QMdiSubWindowPrivate::createSystemMenu() systemMenu->installEventFilter(q); const QStyle *style = q->style(); addToSystemMenu(RestoreAction, QMdiSubWindow::tr("&Restore"), SLOT(showNormal())); - actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, 0, q)); + actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, nullptr, q)); actions[RestoreAction]->setEnabled(false); addToSystemMenu(MoveAction, QMdiSubWindow::tr("&Move"), SLOT(_q_enterInteractiveMode())); addToSystemMenu(ResizeAction, QMdiSubWindow::tr("&Size"), SLOT(_q_enterInteractiveMode())); addToSystemMenu(MinimizeAction, QMdiSubWindow::tr("Mi&nimize"), SLOT(showMinimized())); - actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, 0, q)); + actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, nullptr, q)); addToSystemMenu(MaximizeAction, QMdiSubWindow::tr("Ma&ximize"), SLOT(showMaximized())); - actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, 0, q)); + actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, nullptr, q)); addToSystemMenu(StayOnTopAction, QMdiSubWindow::tr("Stay on &Top"), SLOT(_q_updateStaysOnTopHint())); actions[StayOnTopAction]->setCheckable(true); systemMenu->addSeparator(); addToSystemMenu(CloseAction, QMdiSubWindow::tr("&Close"), SLOT(close())); - actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, 0, q)); + actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, nullptr, q)); #if !defined(QT_NO_SHORTCUT) actions[CloseAction]->setShortcuts(QKeySequence::Close); #endif @@ -1461,7 +1461,7 @@ void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus) ensureWindowState(Qt::WindowActive); } - int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); + int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q); int titleBarHeight = this->titleBarHeight(); QRegion windowDecoration = QRegion(0, 0, q->width(), q->height()); windowDecoration -= QRegion(frameWidth, titleBarHeight, q->width() - 2 * frameWidth, @@ -1543,7 +1543,7 @@ QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const int width = q->width(); int height = q->height(); int titleBarHeight = this->titleBarHeight(); - int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); + int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q); int cornerConst = titleBarHeight - frameWidth; int titleBarConst = 2 * titleBarHeight; @@ -1738,7 +1738,7 @@ void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const if (q->isMaximized() && !drawTitleBarWhenMaximized()) *margin = 0; else - *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); + *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, q); QStyleOptionTitleBar opt = this->titleBarOptions(); int tempWidth = 0; @@ -1767,7 +1767,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const if (isChildOfTabbedQMdiArea(q)) return false; - if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) + if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, nullptr, q)) return true; #if !QT_CONFIG(menubar) || !QT_CONFIG(mainwindow) Q_UNUSED(isChildOfQMdiSubWindow); @@ -1833,7 +1833,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar() if (!controlContainer || isChildOfTabbedQMdiArea(q)) return; - QMenuBar *currentMenuBar = 0; + QMenuBar *currentMenuBar = nullptr; #if QT_CONFIG(mainwindow) if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) { // NB! We can't use menuBar() here because that one will actually create @@ -1863,7 +1863,7 @@ void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild) return; } - QWidget *titleWidget = 0; + QWidget *titleWidget = nullptr; if (isRequestFromChild) titleWidget = baseWidget; else @@ -2131,7 +2131,7 @@ QSize QMdiSubWindowPrivate::iconSize() const Q_Q(const QMdiSubWindow); if (!parent || q->windowFlags() & Qt::FramelessWindowHint) return QSize(-1, -1); - return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight()); + return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, nullptr, q), titleBarHeight()); } #if QT_CONFIG(sizegrip) @@ -2233,7 +2233,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags) // We don't want the menu icon by default on mac. #ifndef Q_OS_MAC if (windowIcon().isNull()) - d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); + d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, nullptr, this); else d->menuIcon = windowIcon(); #endif @@ -2340,7 +2340,7 @@ QWidget *QMdiSubWindow::maximizedButtonsWidget() const && !isChildOfTabbedQMdiArea(this)) { return d->controlContainer->controllerWidget(); } - return 0; + return nullptr; } /*! @@ -2353,7 +2353,7 @@ QWidget *QMdiSubWindow::maximizedSystemMenuIconWidget() const && !isChildOfTabbedQMdiArea(this)) { return d->controlContainer->systemMenuLabel(); } - return 0; + return nullptr; } /*! @@ -2476,7 +2476,7 @@ void QMdiSubWindow::setSystemMenu(QMenu *systemMenu) if (d->systemMenu) { delete d->systemMenu; - d->systemMenu = 0; + d->systemMenu = nullptr; } if (!systemMenu) @@ -2860,7 +2860,7 @@ bool QMdiSubWindow::event(QEvent *event) case QEvent::WindowIconChange: d->menuIcon = windowIcon(); if (d->menuIcon.isNull()) - d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); + d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, nullptr, this); if (d->controlContainer) d->controlContainer->updateWindowIcon(d->menuIcon); if (!maximizedSystemMenuIconWidget()) @@ -3135,7 +3135,7 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) if (isMinimized() && !d->hasBorder(d->cachedStyleOptions)) return; - frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); + frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, nullptr, this); // ### Ensure that we do not require setting the cliprect for 4.4 if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions)) @@ -3510,7 +3510,7 @@ QSize QMdiSubWindow::minimumSizeHint() const if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this))) sizeGripHeight = d->sizeGrip->height(); else if (parent() && isMacStyle(style()) && !d->sizeGrip) - sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this); + sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, nullptr, this); minHeight = qMax(minHeight, decorationHeight + sizeGripHeight); #endif diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 51b458f03a..e7f80263c8 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE -QMenu *QMenuPrivate::mouseDown = 0; +QMenu *QMenuPrivate::mouseDown = nullptr; /* QMenu code */ // internal class used for the torn off popup @@ -96,7 +96,7 @@ class QTornOffMenu : public QMenu public: QTornOffMenuPrivate(QMenu *p) : causedMenu(p), initialized(false) { tornoff = 1; - causedPopup.widget = 0; + causedPopup.widget = nullptr; causedPopup.action = p->d_func()->causedPopup.action; causedStack = p->d_func()->calcCausedStack(); } @@ -106,11 +106,11 @@ class QTornOffMenu : public QMenu QSize size = menuSize; const QPoint p = (!initialized) ? causedMenu->pos() : q->pos(); QRect screen = popupGeometry(QDesktopWidgetPrivate::screenNumber(p)); - const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); - const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, q); + const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, q); + const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, nullptr, q); if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) { - const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); - const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuHMargin, 0, q); + const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); + const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, q); scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown); size.setWidth(qMin(actionRects.at(getLastVisibleAction()).right() + fw + hmargin + rightmargin + 1, screen.width())); size.setHeight(screen.height() - desktopFrame * 2 - titleBarHeight); @@ -202,15 +202,15 @@ void QMenuPrivate::init() if (!tornPopup.isNull()) tornPopup->updateWindowTitle(); }); - q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, q)); - if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, 0, q)) { + q->setMouseTracking(q->style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, q)); + if (q->style()->styleHint(QStyle::SH_Menu_Scrollable, nullptr, q)) { scroll = new QMenuPrivate::QMenuScroller; scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; } sloppyState.initialize(q); delayState.initialize(q); - mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, q); + mousePopupDelay = q->style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, nullptr, q); } QPlatformMenu *QMenuPrivate::createPlatformMenu() @@ -262,7 +262,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w)); } else { QStyleOption opt; - item->setIconSize(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0)); + item->setIconSize(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, nullptr)); } } else { item->setIcon(QIcon()); @@ -283,7 +283,7 @@ void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenu action->menu()->setPlatformMenu(platformMenu->createSubMenu()); item->setMenu(action->menu()->platformMenu()); } else { - item->setMenu(0); + item->setMenu(nullptr); } } @@ -304,7 +304,7 @@ QPlatformMenuItem * QMenuPrivate::insertActionInPlatformMenu(const QAction *acti int QMenuPrivate::scrollerHeight() const { Q_Q(const QMenu); - return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q)); + return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, nullptr, q)); } // Windows and KDE allow menus to cover the taskbar, while GNOME and macOS @@ -541,9 +541,9 @@ void QMenuPrivate::hideUpToMenuBar() while(caused) { #if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { - mb->d_func()->setCurrentAction(0); + mb->d_func()->setCurrentAction(nullptr); mb->d_func()->setKeyboardMode(false); - caused = 0; + caused = nullptr; } else #endif if (QMenu *m = qobject_cast<QMenu*>(caused)) { @@ -551,12 +551,12 @@ void QMenuPrivate::hideUpToMenuBar() if (!m->d_func()->tornoff) hideMenu(m); if (!fadeMenus) // Mac doesn't clear the action until after hidden. - m->d_func()->setCurrentAction(0); - } else { caused = 0; + m->d_func()->setCurrentAction(nullptr); + } else { caused = nullptr; } } } - setCurrentAction(0); + setCurrentAction(nullptr); } void QMenuPrivate::hideMenu(QMenu *menu) @@ -573,7 +573,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) QEventLoop eventLoop; QAction *activeAction = currentAction; - menu->setActiveAction(0); + menu->setActiveAction(nullptr); QTimer::singleShot(60, &eventLoop, SLOT(quit())); eventLoop.exec(); @@ -587,10 +587,10 @@ void QMenuPrivate::hideMenu(QMenu *menu) blocker.unblock(); #endif // QT_CONFIG(effects) if (activeMenu == menu) - activeMenu = 0; - menu->d_func()->causedPopup.action = 0; + activeMenu = nullptr; + menu->d_func()->causedPopup.action = nullptr; menu->close(); - menu->d_func()->causedPopup.widget = 0; + menu->d_func()->causedPopup.widget = nullptr; } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) @@ -617,7 +617,7 @@ void QMenuPrivate::setSyncAction() Q_Q(QMenu); QAction *current = currentAction; if(current && (!current->isEnabled() || current->menu() || current->isSeparator())) - current = 0; + current = nullptr; for(QWidget *caused = q; caused;) { if (QMenu *m = qobject_cast<QMenu*>(caused)) { caused = m->d_func()->causedPopup.widget; @@ -645,7 +645,7 @@ void QMenuPrivate::setFirstActionActive() } QAction *act = actions.at(i); if (!act->isSeparator() && - (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q) + (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q) || act->isEnabled())) { setCurrentAction(act); break; @@ -661,7 +661,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason if (action && (action->isSeparator() - || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q)))) + || (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q)))) action = nullptr; // Reselect the currently active action in case mouse moved over other menu items when @@ -718,8 +718,8 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason if (popup == -1) { #if QT_CONFIG(effects) // kill any running effect - qFadeEffect(0); - qScrollEffect(0); + qFadeEffect(nullptr); + qScrollEffect(nullptr); #endif hideMenu(hideActiveMenu); } else if (!currentAction || !currentAction->menu()) { @@ -867,13 +867,13 @@ QWidget *QMenuPrivate::topCausedWidget() const QAction *QMenuPrivate::actionAt(QPoint p) const { if (!rect().contains(p)) //sanity check - return 0; + return nullptr; for(int i = 0; i < actionRects.count(); i++) { if (actionRects.at(i).contains(p)) return actions.at(i); } - return 0; + return nullptr; } void QMenuPrivate::setOverrideMenuAction(QAction *a) @@ -976,7 +976,7 @@ QMenuPrivate::ScrollerTearOffItem::ScrollerTearOffItem(QMenuPrivate::ScrollerTea : QWidget(parent, f), menuPrivate(mPrivate), scrollType(type) { if (parent) - setMouseTracking(parent->style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, parent)); + setMouseTracking(parent->style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, parent)); } void QMenuPrivate::ScrollerTearOffItem::paintEvent(QPaintEvent *e) @@ -991,7 +991,7 @@ void QMenuPrivate::ScrollerTearOffItem::paintEvent(QPaintEvent *e) menuPrivate->drawScroller(&p, scrollType, QRect(0, 0, width(), menuPrivate->scrollerHeight())); //paint the tear off if (scrollType == QMenuPrivate::ScrollerTearOffItem::ScrollUp) { - QRect rect(0, 0, width(), parent->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, parent)); + QRect rect(0, 0, width(), parent->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, parent)); if (menuPrivate->scroll && menuPrivate->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) rect.translate(0, menuPrivate->scrollerHeight()); menuPrivate->drawTearOff(&p, rect); @@ -1066,8 +1066,8 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc int newOffset = 0; const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0; const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0; - const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q); - const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); + const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, q); + const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); if (location == QMenuScroller::ScrollTop) { for(int i = 0, saccum = 0; i < actions.count(); i++) { @@ -1108,7 +1108,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc if (!(newScrollFlags & QMenuScroller::ScrollDown) && (scroll->scrollFlags & QMenuScroller::ScrollDown)) { newOffset = q->height() - (saccum - newOffset) - fw*2 - vmargin - topmargin - bottommargin; //last item at bottom if (tearoff) - newOffset -= q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, q); + newOffset -= q->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, q); } if (!(newScrollFlags & QMenuScroller::ScrollUp) && (scroll->scrollFlags & QMenuScroller::ScrollUp)) { @@ -1119,7 +1119,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc newOffset -= vmargin; QRect screen = popupGeometry(); - const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); + const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, q); if (q->height() < screen.height()-(desktopFrame*2)-1) { QRect geom = q->geometry(); if (newOffset > scroll->scrollOffset && (scroll->scrollFlags & newScrollFlags & QMenuScroller::ScrollUp)) { //scroll up @@ -1181,7 +1181,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool activ if (actionRects.at(i).isNull()) continue; if (!act->isSeparator() && - (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q) + (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q) || act->isEnabled())) { if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown) scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollBottom, active); @@ -1196,7 +1196,7 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool activ if (actionRects.at(i).isNull()) continue; if (!act->isSeparator() && - (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q) + (q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q) || act->isEnabled())) { if(scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) scrollMenu(act, QMenuPrivate::QMenuScroller::ScrollTop, active); @@ -1217,8 +1217,8 @@ void QMenuPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool pag updateActionRects(); const int topScroll = (scroll->scrollFlags & QMenuScroller::ScrollUp) ? scrollerHeight() : 0; const int botScroll = (scroll->scrollFlags & QMenuScroller::ScrollDown) ? scrollerHeight() : 0; - const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, 0, q); - const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, q); + const int vmargin = q->style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, q); + const int fw = q->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, q); const int offset = topScroll ? topScroll-vmargin : 0; if (direction == QMenuScroller::ScrollUp) { for(int i = 0, saccum = 0; i < actions.count(); i++) { @@ -1299,7 +1299,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) tearRect.translate(0, scrollerHeight()); q->update(tearRect); if (tearRect.contains(pos) && hasMouseMoved(e->globalPos())) { - setCurrentAction(0); + setCurrentAction(nullptr); tearoffHighlighted = 1; if (e->type() == QEvent::MouseButtonRelease) { if (!tornPopup) @@ -1318,7 +1318,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) for(QWidget *caused = causedPopup.widget; caused;) { bool passOnEvent = false; - QWidget *next_widget = 0; + QWidget *next_widget = nullptr; QPoint cpos = caused->mapFromGlobal(e->globalPos()); #if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) { @@ -1439,7 +1439,7 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e #endif action->showStatusText(topCausedWidget()); } else { - actionAboutToTrigger = 0; + actionAboutToTrigger = nullptr; } } @@ -2258,7 +2258,7 @@ QAction *QMenu::actionAt(const QPoint &pt) const { if (QAction *ret = d_func()->actionAt(pt)) return ret; - return 0; + return nullptr; } /*! @@ -2380,7 +2380,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) const QSize menuSizeHint(sizeHint()); QSize size = menuSizeHint; - const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this); + const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, nullptr, this); bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen); // if the screens have very different geometries and the menu is too big, we have to recalculate @@ -2424,7 +2424,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) pos.setY(newY); if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone - && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) { + && !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, nullptr, this)) { int below_height = above_height + d->scroll->scrollOffset; for (int i2 = i; i2 < d->actionRects.count(); i2++) below_height += d->actionRects.at(i2).height(); @@ -2483,7 +2483,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } } } - const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); + const int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, nullptr, this); QMenu *caused = qobject_cast<QMenu*>(d_func()->causedPopup.widget); if (caused && caused->geometry().width() + menuSizeHint.width() + subMenuOffset < screen.width()) { QRect parentActionRect(caused->d_func()->actionRect(caused->d_func()->currentAction)); @@ -2553,8 +2553,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction) qScrollEffect(this, hGuess | vGuess); } else { // kill any running effect - qFadeEffect(0); - qScrollEffect(0); + qFadeEffect(nullptr); + qScrollEffect(nullptr); show(); } @@ -2690,22 +2690,22 @@ void QMenu::hideEvent(QHideEvent *) emit aboutToHide(); if (d->eventLoop) d->eventLoop->exit(); - d->setCurrentAction(0); + d->setCurrentAction(nullptr); #ifndef QT_NO_ACCESSIBILITY QAccessibleEvent event(this, QAccessible::PopupMenuEnd); QAccessible::updateAccessibility(&event); #endif #if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) - mb->d_func()->setCurrentAction(0); + mb->d_func()->setCurrentAction(nullptr); #endif if (QMenuPrivate::mouseDown == this) QMenuPrivate::mouseDown = nullptr; d->hasHadMouse = false; if (d->activeMenu) d->hideMenu(d->activeMenu); - d->causedPopup.widget = 0; - d->causedPopup.action = 0; + d->causedPopup.widget = nullptr; + d->causedPopup.action = nullptr; if (d->scroll) d->scroll->scrollTimer.stop(); //make sure the timer stops } @@ -2729,9 +2729,9 @@ void QMenu::paintEvent(QPaintEvent *e) style()->drawPrimitive(QStyle::PE_PanelMenu, &menuOpt, &p, this); //calculate the scroll up / down rect - const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); - const int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin,0, this); - const int vmargin = style()->pixelMetric(QStyle::PM_MenuVMargin, 0, this); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this); + const int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin,nullptr, this); + const int vmargin = style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, this); QRect scrollUpRect, scrollDownRect; const int leftmargin = fw + hmargin + d->leftmargin; @@ -2751,7 +2751,7 @@ void QMenu::paintEvent(QPaintEvent *e) QRect tearOffRect; if (d->tearoff) { tearOffRect.setRect(leftmargin, topmargin, contentWidth, - style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, this)); if (d->scroll && d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) tearOffRect.translate(0, d->scrollerHeight()); } @@ -2871,7 +2871,7 @@ void QMenu::mousePressEvent(QMouseEvent *e) && QRect(d->noReplayFor->mapToGlobal(QPoint()), d->noReplayFor->size()).contains(e->globalPos())) setAttribute(Qt::WA_NoMouseReplay); if (d->eventLoop) // synchronous operation - d->syncAction = 0; + d->syncAction = nullptr; d->hideUpToMenuBar(); return; } @@ -2921,12 +2921,12 @@ void QMenu::changeEvent(QEvent *e) if (e->type() == QEvent::StyleChange || e->type() == QEvent::FontChange || e->type() == QEvent::LayoutDirectionChange) { d->itemsDirty = 1; - setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, 0, this)); + setMouseTracking(style()->styleHint(QStyle::SH_Menu_MouseTracking, nullptr, this)); if (isVisible()) resize(sizeHint()); - if (!style()->styleHint(QStyle::SH_Menu_Scrollable, 0, this)) { + if (!style()->styleHint(QStyle::SH_Menu_Scrollable, nullptr, this)) { delete d->scroll; - d->scroll = 0; + d->scroll = nullptr; } else if (!d->scroll) { d->scroll = new QMenuPrivate::QMenuScroller; d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone; @@ -3095,7 +3095,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) case Qt::Key_Up: case Qt::Key_Down: { key_consumed = true; - QAction *nextAction = 0; + QAction *nextAction = nullptr; QMenuPrivate::QMenuScroller::ScrollLocation scroll_loc = QMenuPrivate::QMenuScroller::ScrollStay; if (!d->currentAction) { if(key == Qt::Key_Down) { @@ -3104,7 +3104,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (d->actionRects.at(i).isNull()) continue; if (!act->isSeparator() && - (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this) + (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this) || act->isEnabled())) { nextAction = act; break; @@ -3116,7 +3116,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (d->actionRects.at(i).isNull()) continue; if (!act->isSeparator() && - (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this) + (style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this) || act->isEnabled())) { nextAction = act; break; @@ -3130,7 +3130,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (key == Qt::Key_Up) { for(int next_i = i-1; true; next_i--) { if (next_i == -1) { - if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this)) + if (!style()->styleHint(QStyle::SH_Menu_SelectionWrap, nullptr, this)) break; if (d->scroll) scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; @@ -3143,13 +3143,13 @@ void QMenu::keyPressEvent(QKeyEvent *e) continue; if (next->isSeparator() || (!next->isEnabled() && - !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this))) + !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this))) continue; nextAction = next; if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp)) { int topVisible = d->scrollerHeight(); if (d->tearoff) - topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this); + topVisible += style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, this); if (((y + d->scroll->scrollOffset) - topVisible) <= d->actionRects.at(next_i).height()) scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop; } @@ -3161,7 +3161,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) y += d->actionRects.at(i).height(); for(int next_i = i+1; true; next_i++) { if (next_i == d->actionRects.count()) { - if(!style()->styleHint(QStyle::SH_Menu_SelectionWrap, 0, this)) + if (!style()->styleHint(QStyle::SH_Menu_SelectionWrap, nullptr, this)) break; if (d->scroll) scroll_loc = QMenuPrivate::QMenuScroller::ScrollTop; @@ -3174,7 +3174,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) continue; if (next->isSeparator() || (!next->isEnabled() && - !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, this))) + !style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, this))) continue; nextAction = next; if (d->scroll && (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollDown)) { @@ -3182,7 +3182,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (d->scroll->scrollFlags & QMenuPrivate::QMenuScroller::ScrollUp) bottomVisible -= d->scrollerHeight(); if (d->tearoff) - bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this); + bottomVisible -= style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, this); if ((y + d->scroll->scrollOffset + d->actionRects.at(next_i).height()) > bottomVisible) scroll_loc = QMenuPrivate::QMenuScroller::ScrollBottom; } @@ -3212,7 +3212,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) Q_FALLTHROUGH(); case Qt::Key_Left: { if (d->currentAction && !d->scroll) { - QAction *nextAction = 0; + QAction *nextAction = nullptr; if (key == Qt::Key_Left) { QRect actionR = d->actionRect(d->currentAction); for(int x = actionR.left()-1; !nextAction && x >= 0; x--) @@ -3241,7 +3241,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) break; key_consumed = true; - if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) + if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this)) { d->hideMenu(this); #if QT_CONFIG(menubar) @@ -3253,7 +3253,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Space: - if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this)) + if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, nullptr, this)) break; // for motif, fall through Q_FALLTHROUGH(); @@ -3319,8 +3319,8 @@ void QMenu::keyPressEvent(QKeyEvent *e) if ((!e->modifiers() || e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ShiftModifier) && e->text().length()==1) { bool activateAction = false; - QAction *nextAction = 0; - if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, 0, this) && !e->modifiers()) { + QAction *nextAction = nullptr; + if (style()->styleHint(QStyle::SH_Menu_KeyboardSearch, nullptr, this) && !e->modifiers()) { int best_match_count = 0; d->searchBufferTimer.start(2000, this); d->searchBuffer += e->text(); @@ -3343,7 +3343,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) #ifndef QT_NO_SHORTCUT else { int clashCount = 0; - QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; + QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr; QChar c = e->text().at(0).toUpper(); for(int i = 0; i < d->actions.size(); ++i) { if (d->actionRects.at(i).isNull()) @@ -3432,7 +3432,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) QMenuPrivate::mouseDown = this; if (d->activeMenu) - d->activeMenu->d_func()->setCurrentAction(0); + d->activeMenu->d_func()->setCurrentAction(nullptr); QMenuSloppyState::MouseEventResult sloppyEventResult = d->sloppyState.processMouseEvent(e->localPos(), action, d->currentAction); if (sloppyEventResult == QMenuSloppyState::EventShouldBePropagated) { @@ -3462,7 +3462,7 @@ void QMenu::leaveEvent(QEvent *) Q_D(QMenu); d->hasReceievedEnter = false; if (!d->activeMenu && d->currentAction) - setActiveAction(0); + setActiveAction(nullptr); } /*! @@ -3525,7 +3525,7 @@ void QMenu::actionEvent(QActionEvent *e) } else if (e->type() == QEvent::ActionRemoved) { e->action()->disconnect(this); if (e->action() == d->currentAction) - d->currentAction = 0; + d->currentAction = nullptr; if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) { if (QWidget *widget = d->widgetItems.value(wa)) { #ifdef Q_OS_OSX @@ -3601,7 +3601,7 @@ void QMenu::internalDelayedPopup() #endif screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(pos())); - int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this); + int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, nullptr, this); const QRect actionRect(d->actionRect(d->currentAction)); QPoint subMenuPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); if (subMenuPos.x() > screen.right()) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index afa5ca7142..2de7cdff71 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -90,7 +90,7 @@ QMenuBarExtension::QMenuBarExtension(QWidget *parent) #if QT_CONFIG(menu) setPopupMode(QToolButton::InstantPopup); #endif - setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget())); + setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, nullptr, parentWidget())); } void QMenuBarExtension::paintEvent(QPaintEvent *) @@ -106,7 +106,7 @@ void QMenuBarExtension::paintEvent(QPaintEvent *) QSize QMenuBarExtension::sizeHint() const { - int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, 0, parentWidget()); + int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, nullptr, parentWidget()); return QSize(ext, ext); } @@ -120,14 +120,14 @@ QAction *QMenuBarPrivate::actionAt(QPoint p) const if(actionRect(actions.at(i)).contains(p)) return actions.at(i); } - return 0; + return nullptr; } QRect QMenuBarPrivate::menuRect(bool extVisible) const { Q_Q(const QMenuBar); - int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); + int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q); QRect result = q->rect(); result.adjust(hmargin, 0, -hmargin, 0); @@ -167,13 +167,13 @@ void QMenuBarPrivate::updateGeometries() Q_Q(QMenuBar); if(!itemsDirty) return; - int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q)*2); + int q_width = q->width()-(q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q)*2); int q_start = -1; if(leftWidget || rightWidget) { - int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q) - + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); - int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q) - + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); + int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q) + + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q); + int hmargin = q->style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q) + + q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q); if (leftWidget && leftWidget->isVisible()) { QSize sz = leftWidget->sizeHint(); q_width -= sz.width(); @@ -198,7 +198,7 @@ void QMenuBarPrivate::updateGeometries() } #endif calcActionRects(q_width, q_start); - currentAction = 0; + currentAction = nullptr; #ifndef QT_NO_SHORTCUT if(itemsDirty) { for(int j = 0; j < shortcutIndexMap.size(); ++j) @@ -246,7 +246,7 @@ void QMenuBarPrivate::updateGeometries() pop->clear(); pop->addActions(hiddenActions); - int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q); + int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q); int x = q->isRightToLeft() ? menuRect.left() - extension->sizeHint().width() + 1 : menuRect.right(); @@ -285,8 +285,8 @@ void QMenuBarPrivate::focusFirstAction() void QMenuBarPrivate::setKeyboardMode(bool b) { Q_Q(QMenuBar); - if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) { - setCurrentAction(0); + if (b && !q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, q)) { + setCurrentAction(nullptr); return; } keyboardState = b; @@ -298,11 +298,11 @@ void QMenuBarPrivate::setKeyboardMode(bool b) q->setFocus(Qt::MenuBarFocusReason); } else { if(!popupState) - setCurrentAction(0); + setCurrentAction(nullptr); if(keyboardFocusWidget) { if (QApplication::focusWidget() == q) keyboardFocusWidget->setFocus(Qt::MenuBarFocusReason); - keyboardFocusWidget = 0; + keyboardFocusWidget = nullptr; } } q->update(); @@ -372,9 +372,9 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat doChildEffects = (popup && !activeMenu); Q_Q(QMenuBar); - QWidget *fw = 0; + QWidget *fw = nullptr; if(QMenu *menu = activeMenu) { - activeMenu = 0; + activeMenu = nullptr; if (popup) { fw = q->window()->focusWidget(); q->setFocus(Qt::NoFocusReason); @@ -419,14 +419,14 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const const QStyle *style = q->style(); - const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, 0, q); + const int itemSpacing = style->pixelMetric(QStyle::PM_MenuBarItemSpacing, nullptr, q); int max_item_height = 0, separator = -1, separator_start = 0, separator_len = 0; //calculate size const QFontMetrics fm = q->fontMetrics(); - const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, 0, q), - vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q), - icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q); + const int hmargin = style->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, q), + vmargin = style->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, q), + icone = style->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q); for(int i = 0; i < actions.count(); i++) { QAction *action = actions.at(i); if(!action->isVisible()) @@ -436,7 +436,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const //calc what I think the size is.. if(action->isSeparator()) { - if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, 0, q)) + if (style->styleHint(QStyle::SH_DrawMenuBarSeparator, nullptr, q)) separator = i; continue; //we don't really position these! } else { @@ -470,7 +470,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const } //calculate position - const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, q); + const int fw = q->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, q); int x = fw + ((start == -1) ? hmargin : start) + itemSpacing; int y = fw + vmargin; for(int i = 0; i < actions.count(); i++) { @@ -703,7 +703,7 @@ void QMenuBarPrivate::init() q->hide(); q->setBackgroundRole(QPalette::Button); handleReparent(); - q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); + q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, nullptr, q)); extension = new QMenuBarExtension(q); extension->setFocusPolicy(Qt::NoFocus); @@ -715,7 +715,7 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c { Q_Q(const QMenuBar); const_cast<QMenuBarPrivate*>(this)->updateGeometries(); - bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q); + bool allowActiveAndDisabled = q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, nullptr, q); const int start = (_start == -1 && increment == -1) ? actions.count() : _start; const int end = increment == -1 ? 0 : actions.count() - 1; @@ -729,7 +729,7 @@ QAction *QMenuBarPrivate::getNextAction(const int _start, const int increment) c if (_start != -1) //let's try from the beginning or the end return getNextAction(-1, increment); - return 0; + return nullptr; } /*! @@ -749,7 +749,7 @@ QMenuBar::~QMenuBar() { Q_D(QMenuBar); delete d->platformMenuBar; - d->platformMenuBar = 0; + d->platformMenuBar = nullptr; } /*! @@ -1001,7 +1001,7 @@ void QMenuBar::paintEvent(QPaintEvent *e) style()->drawControl(QStyle::CE_MenuBarItem, &opt, &p, this); } //draw border - if(int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this)) { + if (int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this)) { QRegion borderReg; borderReg += QRect(0, 0, fw, height()); //left borderReg += QRect(width()-fw, 0, fw, height()); //right @@ -1054,7 +1054,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) QAction *action = d->actionAt(e->pos()); if (!action || !d->isVisible(action) || !action->isEnabled()) { - d->setCurrentAction(0); + d->setCurrentAction(nullptr); #if QT_CONFIG(whatsthis) if (QWhatsThis::inWhatsThisMode()) QWhatsThis::showText(e->globalPos(), d->whatsThis, this); @@ -1064,7 +1064,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) if(d->currentAction == action && d->popupState) { if(QMenu *menu = d->activeMenu) { - d->activeMenu = 0; + d->activeMenu = nullptr; menu->setAttribute(Qt::WA_NoMouseReplay); menu->hide(); } @@ -1124,7 +1124,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) case Qt::Key_Enter: case Qt::Key_Space: case Qt::Key_Return: { - if(!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this) || !d->currentAction) + if (!style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this) || !d->currentAction) break; if(d->currentAction->menu()) { d->popupAction(d->currentAction, true); @@ -1153,7 +1153,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) #ifndef QT_NO_SHORTCUT if (!key_consumed && e->matches(QKeySequence::Cancel)) { - d->setCurrentAction(0); + d->setCurrentAction(nullptr); d->setKeyboardMode(false); key_consumed = true; } @@ -1163,7 +1163,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) (!e->modifiers() || (e->modifiers()&(Qt::MetaModifier|Qt::AltModifier))) && e->text().length()==1 && !d->popupState) { int clashCount = 0; - QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; + QAction *first = nullptr, *currentSelected = nullptr, *firstAfterCurrent = nullptr; { const QChar c = e->text().at(0).toUpper(); for(int i = 0; i < d->actions.size(); ++i) { @@ -1187,7 +1187,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e) } } } - QAction *next_action = 0; + QAction *next_action = nullptr; if(clashCount >= 1) { if(clashCount == 1 || !d->currentAction || (currentSelected && !firstAfterCurrent)) next_action = first; @@ -1233,14 +1233,14 @@ void QMenuBar::leaveEvent(QEvent *) { Q_D(QMenuBar); if((!hasFocus() && !d->popupState) || - (d->currentAction && d->currentAction->menu() == 0)) - d->setCurrentAction(0); + (d->currentAction && d->currentAction->menu() == nullptr)) + d->setCurrentAction(nullptr); } QPlatformMenu *QMenuBarPrivate::getPlatformMenu(const QAction *action) { if (!action || !action->menu()) - return 0; + return nullptr; QPlatformMenu *platformMenu = action->menu()->platformMenu(); if (!platformMenu && platformMenuBar) { @@ -1353,7 +1353,7 @@ void QMenuBar::focusOutEvent(QFocusEvent *) { Q_D(QMenuBar); if(!d->popupState) { - d->setCurrentAction(0); + d->setCurrentAction(nullptr); d->setKeyboardMode(false); } } @@ -1366,7 +1366,7 @@ void QMenuBar::timerEvent (QTimerEvent *e) Q_D(QMenuBar); if (e->timerId() == d->autoReleaseTimer.timerId()) { d->autoReleaseTimer.stop(); - d->setCurrentAction(0); + d->setCurrentAction(nullptr); } QWidget::timerEvent(e); } @@ -1420,7 +1420,7 @@ void QMenuBarPrivate::handleReparent() newWindow->createWinId(); platformMenuBar->handleReparent(newWindow->windowHandle()); } else { - platformMenuBar->handleReparent(0); + platformMenuBar->handleReparent(nullptr); } } } @@ -1433,7 +1433,7 @@ void QMenuBar::changeEvent(QEvent *e) Q_D(QMenuBar); if(e->type() == QEvent::StyleChange) { d->itemsDirty = true; - setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, this)); + setMouseTracking(style()->styleHint(QStyle::SH_MenuBar_MouseTracking, nullptr, this)); if(parentWidget()) resize(parentWidget()->width(), heightForWidth(parentWidget()->width())); d->updateGeometries(); @@ -1542,7 +1542,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event) d->platformMenuBar->handleReparent(handle); } - if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) { + if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, this)) { if (d->altPressed) { switch (event->type()) { case QEvent::KeyPress: @@ -1618,10 +1618,10 @@ QSize QMenuBar::minimumSizeHint() const ensurePolished(); QSize ret(0, 0); const_cast<QMenuBarPrivate*>(d)->updateGeometries(); - const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this); - const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); - int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); - int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); + const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this); + const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this); + int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this); + int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this); if(as_gui_menubar) { int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width(); d->calcActionRects(w - (2 * fw), 0); @@ -1670,10 +1670,10 @@ QSize QMenuBar::sizeHint() const ensurePolished(); QSize ret(0, 0); const_cast<QMenuBarPrivate*>(d)->updateGeometries(); - const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, 0, this); - const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); - int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); - int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); + const int hmargin = style()->pixelMetric(QStyle::PM_MenuBarHMargin, nullptr, this); + const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this); + int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this); + int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this); if(as_gui_menubar) { const int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width(); d->calcActionRects(w - (2 * fw), 0); @@ -1722,9 +1722,9 @@ int QMenuBar::heightForWidth(int) const const_cast<QMenuBarPrivate*>(d)->updateGeometries(); int height = 0; - const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, this); - int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this); - int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this); + const int vmargin = style()->pixelMetric(QStyle::PM_MenuBarVMargin, nullptr, this); + int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, nullptr, this); + int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, nullptr, this); if(as_gui_menubar) { for (int i = 0; i < d->actionRects.count(); ++i) height = qMax(height, d->actionRects.at(i).height()); @@ -1770,7 +1770,7 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id) activateAction(act, QAction::Trigger); //100 is the same as the default value in QPushButton::animateClick autoReleaseTimer.start(100, q); - } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, q)) { + } else if (act && q->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, nullptr, q)) { // When we open a menu using a shortcut, we should end up in keyboard state setKeyboardMode(true); } @@ -1836,7 +1836,7 @@ void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner) QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const { Q_D(const QMenuBar); - QWidget *w = 0; + QWidget *w = nullptr; switch(corner) { case Qt::TopLeftCorner: w = d->leftWidget; @@ -1875,7 +1875,7 @@ void QMenuBar::setNativeMenuBar(bool nativeMenuBar) if (nativeMenuBar != bool(d->platformMenuBar)) { if (!nativeMenuBar) { delete d->platformMenuBar; - d->platformMenuBar = 0; + d->platformMenuBar = nullptr; } else { if (!d->platformMenuBar) d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 0a81931b57..1856f0296b 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -81,7 +81,7 @@ class QPlainTextDocumentLayoutPrivate : public QAbstractTextDocumentLayoutPrivat Q_DECLARE_PUBLIC(QPlainTextDocumentLayout) public: QPlainTextDocumentLayoutPrivate() { - mainViewPrivate = 0; + mainViewPrivate = nullptr; width = 0; maximumWidth = 0; maximumWidthBlockNumber = 0; @@ -755,7 +755,7 @@ void QPlainTextEditPrivate::updateViewport() } QPlainTextEditPrivate::QPlainTextEditPrivate() - : control(0), + : control(nullptr), tabChangesFocus(false), lineWrap(QPlainTextEdit::WidgetWidth), wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), @@ -1302,7 +1302,7 @@ QPlainTextEdit::~QPlainTextEdit() Q_D(QPlainTextEdit); if (d->documentLayoutPtr) { if (d->documentLayoutPtr->priv()->mainViewPrivate == d) - d->documentLayoutPtr->priv()->mainViewPrivate = 0; + d->documentLayoutPtr->priv()->mainViewPrivate = nullptr; } } @@ -1321,7 +1321,7 @@ QPlainTextEdit::~QPlainTextEdit() void QPlainTextEdit::setDocument(QTextDocument *document) { Q_D(QPlainTextEdit); - QPlainTextDocumentLayout *documentLayout = 0; + QPlainTextDocumentLayout *documentLayout = nullptr; if (!document) { document = new QTextDocument(d->control); @@ -1891,7 +1891,7 @@ void QPlainTextEditPrivate::relayoutDocument() int width = viewport->width(); - if (documentLayout->priv()->mainViewPrivate == 0 + if (documentLayout->priv()->mainViewPrivate == nullptr || documentLayout->priv()->mainViewPrivate == this || width > documentLayout->textWidth()) { documentLayout->priv()->mainViewPrivate = this; diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index f48b5706f7..b0d3ba51f9 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -297,7 +297,7 @@ QDialog *QPushButtonPrivate::dialogParent() const if (const QDialog *dialog = qobject_cast<const QDialog *>(p)) return const_cast<QDialog *>(dialog); } - return 0; + return nullptr; } #endif @@ -353,7 +353,7 @@ bool QPushButton::autoDefault() const { Q_D(const QPushButton); if(d->autoDefault == QPushButtonPrivate::Auto) - return ( d->dialogParent() != 0 ); + return ( d->dialogParent() != nullptr ); return d->autoDefault; } @@ -496,7 +496,7 @@ void QPushButton::focusOutEvent(QFocusEvent *e) #if QT_CONFIG(dialog) QDialog *dlg = qobject_cast<QDialog*>(window()); if (dlg) - dlg->d_func()->setDefault(0); + dlg->d_func()->setDefault(nullptr); else d->defaultButton = false; #endif diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp index 68aa545082..ce08e3439a 100644 --- a/src/widgets/widgets/qscrollarea.cpp +++ b/src/widgets/widgets/qscrollarea.cpp @@ -259,7 +259,7 @@ void QScrollArea::setWidget(QWidget *widget) return; delete d->widget; - d->widget = 0; + d->widget = nullptr; d->hbar->setValue(0); d->vbar->setValue(0); if (widget->parentWidget() != d->viewport) @@ -285,9 +285,9 @@ QWidget *QScrollArea::takeWidget() { Q_D(QScrollArea); QWidget *w = d->widget; - d->widget = 0; + d->widget = nullptr; if (w) - w->setParent(0); + w->setParent(nullptr); return w; } diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 08d771a27a..34ea017279 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -224,7 +224,7 @@ void QScrollBarPrivate::setTransient(bool value) if (transient != value) { transient = value; if (q->isVisible()) { - if (q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)) + if (q->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, q)) q->update(); } else if (!transient) { q->show(); @@ -235,7 +235,7 @@ void QScrollBarPrivate::setTransient(bool value) void QScrollBarPrivate::flash() { Q_Q(QScrollBar); - if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q)) { + if (!flashed && q->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, q)) { flashed = true; if (!q->isVisible()) q->show(); @@ -319,7 +319,7 @@ void QScrollBar::initStyleOption(QStyleOptionSlider *option) const option->upsideDown = d->invertedAppearance; if (d->orientation == Qt::Horizontal) option->state |= QStyle::State_Horizontal; - if ((d->flashed || !d->transient) && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) + if ((d->flashed || !d->transient) && style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this)) option->state |= QStyle::State_On; } @@ -376,7 +376,7 @@ void QScrollBarPrivate::init() invertedControls = true; pressedControl = hoverControl = QStyle::SC_None; pointerOutsidePressedControl = false; - transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, q); + transient = q->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, q); flashed = false; flashTimer = 0; q->setFocusPolicy(Qt::NoFocus); @@ -392,7 +392,7 @@ void QScrollBarPrivate::init() /*! \reimp */ void QScrollBar::contextMenuEvent(QContextMenuEvent *event) { - if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, this)) { + if (!style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, nullptr, this)) { QAbstractSlider::contextMenuEvent(event); return ; } @@ -412,7 +412,7 @@ void QScrollBar::contextMenuEvent(QContextMenuEvent *event) QAction *actScrollDn = menu->addAction(horiz ? tr("Scroll right") : tr("Scroll down")); QAction *actionSelected = menu->exec(event->globalPos()); delete menu; - if (actionSelected == 0) + if (actionSelected == nullptr) /* do nothing */ ; else if (actionSelected == actScrollHere) setValue(d_func()->pixelPosToRangeValue(horiz ? event->pos().x() : event->pos().y())); @@ -472,11 +472,11 @@ bool QScrollBar::event(QEvent *event) d_func()->updateHoverControl(he->pos()); break; case QEvent::StyleChange: - d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)); + d_func()->setTransient(style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this)); break; case QEvent::Timer: if (static_cast<QTimerEvent *>(event)->timerId() == d->flashTimer) { - if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, 0, this)) { + if (d->flashed && style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, this)) { d->flashed = false; update(); } @@ -545,7 +545,7 @@ void QScrollBar::mousePressEvent(QMouseEvent *e) d->stopRepeatAction(); bool midButtonAbsPos = style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, - 0, this); + nullptr, this); QStyleOptionSlider opt; initStyleOption(&opt); diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 662d4c9e92..2a4b4a0ad4 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -128,7 +128,7 @@ QSizeGripPrivate::QSizeGripPrivate() : dxMax(0) , dyMax(0) , gotMousePress(false) - , tlw(0) + , tlw(nullptr) , m_platformSizeGrip(false) { } diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index b7c3426e08..70f05033ea 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -137,7 +137,7 @@ public: perhaps Qt::WindowStaysOnTopHint. */ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) - : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | Qt::FramelessWindowHint | f) + : QWidget(*(new QSplashScreenPrivate()), nullptr, Qt::SplashScreen | Qt::FramelessWindowHint | f) { setPixmap(pixmap); // Does an implicit repaint } @@ -271,14 +271,14 @@ inline static bool waitForWindowExposed(QWindow *window, int timeout = 1000) if (remaining <= 0) break; QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); #if defined(Q_OS_WINRT) WaitForSingleObjectEx(GetCurrentThread(), TimeOutMs, false); #elif defined(Q_OS_WIN) Sleep(uint(TimeOutMs)); #else struct timespec ts = { TimeOutMs / 1000, (TimeOutMs % 1000) * 1000 * 1000 }; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); #endif } return window->isExposed(); diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 1a5fb7f251..090aa5cc8b 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -1494,7 +1494,7 @@ int QSplitter::closestLegalPosition(int pos, int index) bool QSplitter::opaqueResize() const { Q_D(const QSplitter); - return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, 0, this); + return d->opaqueResizeSet ? d->opaque : style()->styleHint(QStyle::SH_Splitter_OpaqueResize, nullptr, this); } @@ -1639,7 +1639,7 @@ int QSplitter::handleWidth() const if (d->handleWidth >= 0) { return d->handleWidth; } else { - return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); + return style()->pixelMetric(QStyle::PM_SplitterWidth, nullptr, this); } } diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index f863964c58..a565d4ab4c 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -49,7 +49,7 @@ class QStackedWidgetPrivate : public QFramePrivate { Q_DECLARE_PUBLIC(QStackedWidget) public: - QStackedWidgetPrivate():layout(0){} + QStackedWidgetPrivate():layout(nullptr){} QStackedLayout *layout; bool blockChildAdd; }; diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index 943b576ee3..4a1fef8b65 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -229,11 +229,11 @@ QStatusBar::QStatusBar(QWidget * parent) : QWidget(*new QStatusBarPrivate, parent, { }) { Q_D(QStatusBar); - d->box = 0; - d->timer = 0; + d->box = nullptr; + d->timer = nullptr; #if QT_CONFIG(sizegrip) - d->resizer = 0; + d->resizer = nullptr; setSizeGripEnabled(true); // causes reformat() #else reformat(); @@ -451,7 +451,7 @@ void QStatusBar::setSizeGripEnabled(bool enabled) d->showSizeGrip = true; } else { delete d->resizer; - d->resizer = 0; + d->resizer = nullptr; d->showSizeGrip = false; } reformat(); @@ -497,7 +497,7 @@ void QStatusBar::reformat() int i; QStatusBarPrivate::SBItem* item; - for (i=0,item=0; i<d->items.size(); ++i) { + for (i=0,item=nullptr; i<d->items.size(); ++i) { item = d->items.at(i); if (!item || item->p) break; @@ -508,7 +508,7 @@ void QStatusBar::reformat() l->addStretch(0); - for (item=0; i<d->items.size(); ++i) { + for (item=nullptr; i<d->items.size(); ++i) { item = d->items.at(i); if (!item) break; @@ -556,7 +556,7 @@ void QStatusBar::showMessage(const QString &message, int timeout) d->timer->start(timeout); } else if (d->timer) { delete d->timer; - d->timer = 0; + d->timer = nullptr; } if (d->tempItem == message) return; @@ -578,7 +578,7 @@ void QStatusBar::clearMessage() return; if (d->timer) { qDeleteInEventHandler(d->timer); - d->timer = 0; + d->timer = nullptr; } d->tempItem.clear(); hideOrShow(); @@ -617,7 +617,7 @@ void QStatusBar::hideOrShow() Q_D(QStatusBar); bool haveMessage = !d->tempItem.isEmpty(); - QStatusBarPrivate::SBItem* item = 0; + QStatusBarPrivate::SBItem* item = nullptr; for (int i=0; i<d->items.size(); ++i) { item = d->items.at(i); if (!item || item->p) @@ -711,7 +711,7 @@ bool QStatusBar::event(QEvent *e) // Calculate new strut height and call reformat() if it has changed int maxH = fontMetrics().height(); - QStatusBarPrivate::SBItem* item = 0; + QStatusBarPrivate::SBItem* item = nullptr; for (int i=0; i<d->items.size(); ++i) { item = d->items.at(i); if (!item) @@ -731,7 +731,7 @@ bool QStatusBar::event(QEvent *e) update(); } if (e->type() == QEvent::ChildRemoved) { - QStatusBarPrivate::SBItem* item = 0; + QStatusBarPrivate::SBItem* item = nullptr; for (int i=0; i<d->items.size(); ++i) { item = d->items.at(i); if (!item) diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index dfe362bdca..4e75cca704 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -76,7 +76,7 @@ class CloseButton : public QAbstractButton Q_OBJECT public: - explicit CloseButton(QWidget *parent = 0); + explicit CloseButton(QWidget *parent = nullptr); QSize sizeHint() const override; QSize minimumSizeHint() const override @@ -424,18 +424,18 @@ void QTabBarPrivate::init() rightB->setAccessibleName(QTabBar::tr("Scroll Right")); #endif q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, q)); - useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, q); + elideMode = Qt::TextElideMode(q->style()->styleHint(QStyle::SH_TabBar_ElideMode, nullptr, q)); + useScrollButtons = !q->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, nullptr, q); } QTabBarPrivate::Tab *QTabBarPrivate::at(int index) { - return validIndex(index)?&tabList[index]:0; + return validIndex(index)?&tabList[index]:nullptr; } const QTabBarPrivate::Tab *QTabBarPrivate::at(int index) const { - return validIndex(index)?&tabList[index]:0; + return validIndex(index)?&tabList[index]:nullptr; } int QTabBarPrivate::indexAtPos(const QPoint &p) const @@ -460,7 +460,7 @@ void QTabBarPrivate::layoutTabs() bool vertTabs = verticalTabs(shape); int tabChainIndex = 0; - Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, 0, q)); + Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, nullptr, q)); QVector<QLayoutStruct> tabChain(tabList.count() + 2); // We put an empty item at the front and back and set its expansive attribute @@ -787,7 +787,7 @@ void QTabBarPrivate::_q_closeTab() Q_Q(QTabBar); QObject *object = q->sender(); int tabToClose = -1; - QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, q); + QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)q->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, q); for (int i = 0; i < tabList.count(); ++i) { if (closeSide == QTabBar::LeftSide) { if (tabList.at(i).leftWidget == object) { @@ -984,7 +984,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) if (d->closeButtonOnTabs) { QStyleOptionTab opt; initStyleOption(&opt, index); - ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this); + ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this); QAbstractButton *closeButton = new CloseButton(this); connect(closeButton, SIGNAL(clicked()), this, SLOT(_q_closeTab())); setTabButton(index, closeSide, closeButton); @@ -1019,12 +1019,12 @@ void QTabBar::removeTab(int index) if (d->tabList[index].leftWidget) { d->tabList[index].leftWidget->hide(); d->tabList[index].leftWidget->deleteLater(); - d->tabList[index].leftWidget = 0; + d->tabList[index].leftWidget = nullptr; } if (d->tabList[index].rightWidget) { d->tabList[index].rightWidget->hide(); d->tabList[index].rightWidget->deleteLater(); - d->tabList[index].rightWidget = 0; + d->tabList[index].rightWidget = nullptr; } int newIndex = d->tabList[index].lastTab; @@ -1395,7 +1395,7 @@ QSize QTabBar::iconSize() const Q_D(const QTabBar); if (d->iconSize.isValid()) return d->iconSize; - int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, 0, this); + int iconExtent = style()->pixelMetric(QStyle::PM_TabBarIconSize, nullptr, this); return QSize(iconExtent, iconExtent); } @@ -1797,7 +1797,7 @@ void QTabBar::paintEvent(QPaintEvent *) if (!d->dragInProgress) p.drawControl(QStyle::CE_TabBarTab, tab); else { - int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); + int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, nullptr, this); if (verticalTabs(d->shape)) d->movingTab->setGeometry(tab.rect.adjusted(0, -taboverlap, 0, taboverlap)); else @@ -2065,7 +2065,7 @@ void QTabBarPrivate::setupMovableTab() if (!movingTab) movingTab = new QMovableTabWidget(q); - int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q); + int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, nullptr ,q); QRect grabRect = q->tabRect(pressedIndex); if (verticalTabs(shape)) grabRect.adjust(0, -taboverlap, 0, taboverlap); @@ -2221,9 +2221,9 @@ void QTabBar::changeEvent(QEvent *event) switch (event->type()) { case QEvent::StyleChange: if (!d->elideModeSetByUser) - d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); + d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, nullptr, this)); if (!d->useScrollButtonsSetByUser) - d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); + d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, nullptr, this); Q_FALLTHROUGH(); case QEvent::FontChange: d->textSizes.clear(); @@ -2333,16 +2333,16 @@ void QTabBar::setTabsClosable(bool closable) if (d->closeButtonOnTabs == closable) return; d->closeButtonOnTabs = closable; - ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this); + ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this); if (!closable) { for (int i = 0; i < d->tabList.count(); ++i) { if (closeSide == LeftSide && d->tabList[i].leftWidget) { d->tabList[i].leftWidget->deleteLater(); - d->tabList[i].leftWidget = 0; + d->tabList[i].leftWidget = nullptr; } if (closeSide == RightSide && d->tabList[i].rightWidget) { d->tabList[i].rightWidget->deleteLater(); - d->tabList[i].rightWidget = 0; + d->tabList[i].rightWidget = nullptr; } } } else { @@ -2637,8 +2637,8 @@ CloseButton::CloseButton(QWidget *parent) QSize CloseButton::sizeHint() const { ensurePolished(); - int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); - int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this); + int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, nullptr, this); + int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, nullptr, this); return QSize(width, height); } @@ -2671,7 +2671,7 @@ void CloseButton::paintEvent(QPaintEvent *) if (const QTabBar *tb = qobject_cast<const QTabBar *>(parent())) { int index = tb->currentIndex(); - QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb); + QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, tb); if (tb->tabButton(index, position) == this) opt.state |= QStyle::State_Selected; } diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 5552c43548..6f77579108 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -105,9 +105,9 @@ public: struct Tab { inline Tab(const QIcon &ico, const QString &txt) : enabled(true) , shortcutId(0), text(txt), icon(ico), - leftWidget(0), rightWidget(0), lastTab(-1), dragOffset(0) + leftWidget(nullptr), rightWidget(nullptr), lastTab(-1), dragOffset(0) #if QT_CONFIG(animation) - , animation(0) + , animation(nullptr) #endif // animation {} bool operator==(const Tab &other) const { return &other == this; } diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index 2b3b8280bb..28c91a89e7 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -215,9 +215,9 @@ public: }; QTabWidgetPrivate::QTabWidgetPrivate() - : tabs(0), stack(0), dirty(true), + : tabs(nullptr), stack(nullptr), dirty(true), pos(QTabWidget::North), shape(QTabWidget::Rounded), - leftCornerWidget(0), rightCornerWidget(0) + leftCornerWidget(nullptr), rightCornerWidget(nullptr) {} QTabWidgetPrivate::~QTabWidgetPrivate() @@ -249,7 +249,7 @@ void QTabWidgetPrivate::init() q->setFocusPolicy(Qt::TabFocus); q->setFocusProxy(tabs); q->setTabPosition(static_cast<QTabWidget::TabPosition> (q->style()->styleHint( - QStyle::SH_TabWidget_DefaultTabPosition, 0, q ))); + QStyle::SH_TabWidget_DefaultTabPosition, nullptr, q ))); } @@ -280,7 +280,7 @@ void QTabWidgetPrivate::initBasicStyleOption(QStyleOptionTabWidgetFrame *option) if (q->documentMode()) option->lineWidth = 0; else - option->lineWidth = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, q); + option->lineWidth = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, q); switch (pos) { case QTabWidget::North: @@ -319,7 +319,7 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const Q_D(const QTabWidget); d->initBasicStyleOption(option); - int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, 0, this); + int exth = style()->pixelMetric(QStyle::PM_TabBarBaseHeight, nullptr, this); QSize t(0, d->stack->frameWidth()); if (d->tabs->isVisibleTo(const_cast<QTabWidget *>(this))) { t = d->tabs->sizeHint(); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index dd2ea3f18f..10de7d0b9e 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -117,7 +117,7 @@ public: }; QTextEditPrivate::QTextEditPrivate() - : control(0), + : control(nullptr), autoFormatting(QTextEdit::AutoNone), tabChangesFocus(false), lineWrap(QTextEdit::WidgetWidth), lineWrapColumnOrWidth(0), wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere), clickCausedFocus(0), diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 79182dfa33..b4e90c7d71 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -91,7 +91,7 @@ void QToolBarPrivate::init() q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar); QStyle *style = q->style(); - int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); + int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, q); iconSize = QSize(e, e); layout = new QToolBarLayout(q); @@ -99,7 +99,7 @@ void QToolBarPrivate::init() toggleViewAction = new QAction(q); toggleViewAction->setCheckable(true); - q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q )); + q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, nullptr, q )); QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), q, SLOT(_q_toggleView(bool))); } @@ -173,21 +173,21 @@ void QToolBarPrivate::initDrag(const QPoint &pos) { Q_Q(QToolBar); - if (state != 0) + if (state != nullptr) return; QMainWindow *win = qobject_cast<QMainWindow*>(parent); - Q_ASSERT(win != 0); + Q_ASSERT(win != nullptr); QMainWindowLayout *layout = qt_mainwindow_layout(win); - Q_ASSERT(layout != 0); - if (layout->pluggingWidget != 0) // the main window is animating a docking operation + Q_ASSERT(layout != nullptr); + if (layout->pluggingWidget != nullptr) // the main window is animating a docking operation return; state = new DragState; state->pressPos = pos; state->dragging = false; state->moving = false; - state->widgetItem = 0; + state->widgetItem = nullptr; if (q->isRightToLeft()) state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y()); @@ -197,19 +197,19 @@ void QToolBarPrivate::startDrag(bool moving) { Q_Q(QToolBar); - Q_ASSERT(state != 0); + Q_ASSERT(state != nullptr); if ((moving && state->moving) || state->dragging) return; QMainWindow *win = qobject_cast<QMainWindow*>(parent); - Q_ASSERT(win != 0); + Q_ASSERT(win != nullptr); QMainWindowLayout *layout = qt_mainwindow_layout(win); - Q_ASSERT(layout != 0); + Q_ASSERT(layout != nullptr); if (!moving) { state->widgetItem = layout->unplug(q); - Q_ASSERT(state->widgetItem != 0); + Q_ASSERT(state->widgetItem != nullptr); } state->dragging = !moving; state->moving = moving; @@ -218,13 +218,13 @@ void QToolBarPrivate::startDrag(bool moving) void QToolBarPrivate::endDrag() { Q_Q(QToolBar); - Q_ASSERT(state != 0); + Q_ASSERT(state != nullptr); q->releaseMouse(); if (state->dragging) { QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); - Q_ASSERT(layout != 0); + Q_ASSERT(layout != nullptr); if (!layout->plug(state->widgetItem)) { if (q->isFloatable()) { @@ -239,7 +239,7 @@ void QToolBarPrivate::endDrag() } delete state; - state = 0; + state = nullptr; } bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) @@ -278,7 +278,7 @@ bool QToolBarPrivate::mousePressEvent(QMouseEvent *event) bool QToolBarPrivate::mouseReleaseEvent(QMouseEvent*) { - if (state != 0) { + if (state != nullptr) { endDrag(); return true; } else { @@ -310,13 +310,13 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) } QMainWindow *win = qobject_cast<QMainWindow*>(parent); - if (win == 0) + if (win == nullptr) return true; QMainWindowLayout *layout = qt_mainwindow_layout(win); - Q_ASSERT(layout != 0); + Q_ASSERT(layout != nullptr); - if (layout->pluggingWidget == 0 + if (layout->pluggingWidget == nullptr && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { const bool wasDragging = state->dragging; const bool moving = !q->isWindow() && (orientation == Qt::Vertical ? @@ -673,16 +673,16 @@ void QToolBar::setIconSize(const QSize &iconSize) if (mw && mw->layout()) { QLayout *layout = mw->layout(); int i = 0; - QLayoutItem *item = 0; + QLayoutItem *item = nullptr; do { item = layout->itemAt(i++); if (item && (item->widget() == this)) sz = mw->iconSize(); - } while (!sz.isValid() && item != 0); + } while (!sz.isValid() && item != nullptr); } } if (!sz.isValid()) { - const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); + const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, nullptr, this); sz = QSize(metric, metric); } if (d->iconSize != sz) { @@ -945,7 +945,7 @@ QAction *QToolBar::actionAt(const QPoint &p) const QWidget *widget = childAt(p); int index = d->layout->indexOf(widget); if (index == -1) - return 0; + return nullptr; QLayoutItem *item = d->layout->itemAt(index); return static_cast<QToolBarItem*>(item)->action; } @@ -966,7 +966,7 @@ void QToolBar::actionEvent(QActionEvent *event) switch (event->type()) { case QEvent::ActionAdded: { - Q_ASSERT_X(widgetAction == 0 || d->layout->indexOf(widgetAction) == -1, + Q_ASSERT_X(widgetAction == nullptr || d->layout->indexOf(widgetAction) == -1, "QToolBar", "widgets cannot be inserted multiple times"); // reparent the action to this toolbar if it has been created @@ -974,7 +974,7 @@ void QToolBar::actionEvent(QActionEvent *event) // preserve Qt 4.1.x behavior. The widget is already // reparented to us due to the createWidget call inside // createItem() - if (widgetAction != 0 && widgetAction->d_func()->autoCreated) + if (widgetAction != nullptr && widgetAction->d_func()->autoCreated) widgetAction->setParent(this); int index = d->layout->count(); @@ -1059,18 +1059,18 @@ void QToolBar::paintEvent(QPaintEvent *) */ static bool waitForPopup(QToolBar *tb, QWidget *popup) { - if (popup == 0 || popup->isHidden()) + if (popup == nullptr || popup->isHidden()) return false; QWidget *w = popup; - while (w != 0) { + while (w != nullptr) { if (w == tb) return true; w = w->parentWidget(); } QMenu *menu = qobject_cast<QMenu*>(popup); - if (menu == 0) + if (menu == nullptr) return false; QAction *action = menu->menuAction(); @@ -1161,7 +1161,7 @@ bool QToolBar::event(QEvent *event) return true; break; case QEvent::Leave: - if (d->state != 0 && d->state->dragging) { + if (d->state != nullptr && d->state->dragging) { #ifdef Q_OS_WIN // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); @@ -1213,7 +1213,7 @@ QWidget *QToolBar::widgetForAction(QAction *action) const int index = d->layout->indexOf(action); if (index == -1) - return 0; + return nullptr; return d->layout->itemAt(index)->widget(); } @@ -1233,7 +1233,7 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const option->initFrom(this); if (orientation() == Qt::Horizontal) option->state |= QStyle::State_Horizontal; - option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this); + option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, nullptr, this); option->features = d->layout->movable() ? QStyleOptionToolBar::Movable : QStyleOptionToolBar::None; @@ -1247,7 +1247,7 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const return; QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); - Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()", + Q_ASSERT_X(layout != nullptr, "QToolBar::initStyleOption()", "QMainWindow->layout() != QMainWindowLayout"); layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this)); diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index adc329131c..493c094cc1 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -91,7 +91,7 @@ bool QToolBarAreaLayoutItem::skip() const { if (gap) return false; - return widgetItem == 0 || widgetItem->isEmpty(); + return widgetItem == nullptr || widgetItem->isEmpty(); } /****************************************************************************** @@ -302,7 +302,7 @@ QLayoutItem *QToolBarAreaLayoutInfo::insertToolBar(QToolBar *before, QToolBar *t void QToolBarAreaLayoutInfo::insertItem(QToolBar *before, QLayoutItem *item) { - if (before == 0) { + if (before == nullptr) { if (lines.isEmpty()) lines.append(QToolBarAreaLayoutLine(o)); lines.last().toolBarItems.append(item); @@ -330,7 +330,7 @@ void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar) QToolBarAreaLayoutItem &item = line.toolBarItems[k]; if (item.widgetItem->widget() == toolBar) { delete item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; line.toolBarItems.removeAt(k); if (line.toolBarItems.isEmpty() && j < lines.count() - 1) @@ -344,7 +344,7 @@ void QToolBarAreaLayoutInfo::removeToolBar(QToolBar *toolBar) void QToolBarAreaLayoutInfo::insertToolBarBreak(QToolBar *before) { - if (before == 0) { + if (before == nullptr) { if (!lines.isEmpty() && lines.constLast().toolBarItems.isEmpty()) return; lines.append(QToolBarAreaLayoutLine(o)); @@ -729,7 +729,7 @@ QRect QToolBarAreaLayout::rectHint(const QRect &r) const QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const { - Q_ASSERT(x != 0); + Q_ASSERT(x != nullptr); for (int i = 0; i < QInternal::DockCount; ++i) { const QToolBarAreaLayoutInfo &dock = docks[i]; @@ -744,12 +744,12 @@ QLayoutItem *QToolBarAreaLayout::itemAt(int *x, int index) const } } - return 0; + return nullptr; } QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index) { - Q_ASSERT(x != 0); + Q_ASSERT(x != nullptr); for (int i = 0; i < QInternal::DockCount; ++i) { QToolBarAreaLayoutInfo &dock = docks[i]; @@ -768,7 +768,7 @@ QLayoutItem *QToolBarAreaLayout::takeAt(int *x, int index) } } - return 0; + return nullptr; } void QToolBarAreaLayout::deleteAllLayoutItems() @@ -783,7 +783,7 @@ void QToolBarAreaLayout::deleteAllLayoutItems() QToolBarAreaLayoutItem &item = line.toolBarItems[k]; if (!item.gap) delete item.widgetItem; - item.widgetItem = 0; + item.widgetItem = nullptr; } } } @@ -811,7 +811,7 @@ QLayoutItem *QToolBarAreaLayout::insertToolBar(QToolBar *before, QToolBar *toolB { QInternal::DockPosition pos = findToolBar(before); if (pos == QInternal::DockCount) - return 0; + return nullptr; return docks[pos].insertToolBar(before, toolBar); } @@ -826,7 +826,7 @@ void QToolBarAreaLayout::removeToolBar(QToolBar *toolBar) QLayoutItem *QToolBarAreaLayout::addToolBar(QInternal::DockPosition pos, QToolBar *toolBar) { - return docks[pos].insertToolBar(0, toolBar); + return docks[pos].insertToolBar(nullptr, toolBar); } void QToolBarAreaLayout::insertToolBarBreak(QToolBar *before) @@ -847,7 +847,7 @@ void QToolBarAreaLayout::removeToolBarBreak(QToolBar *before) void QToolBarAreaLayout::addToolBarBreak(QInternal::DockPosition pos) { - docks[pos].insertToolBarBreak(0); + docks[pos].insertToolBarBreak(nullptr); } void QToolBarAreaLayout::moveToolBar(QToolBar *toolbar, int p) @@ -878,7 +878,7 @@ void QToolBarAreaLayout::insertItem(QToolBar *before, QLayoutItem *item) void QToolBarAreaLayout::apply(bool animate) { QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); - Q_ASSERT(layout != 0); + Q_ASSERT(layout != nullptr); Qt::LayoutDirection dir = mainWindow->layoutDirection(); @@ -1117,13 +1117,13 @@ QToolBarAreaLayoutItem *QToolBarAreaLayout::item(const QList<int> &path) Q_ASSERT(path.count() == 3); if (path.at(0) < 0 || path.at(0) >= QInternal::DockCount) - return 0; + return nullptr; QToolBarAreaLayoutInfo &info = docks[path.at(0)]; if (path.at(1) < 0 || path.at(1) >= info.lines.count()) - return 0; + return nullptr; QToolBarAreaLayoutLine &line = info.lines[path.at(1)]; if (path.at(2) < 0 || path.at(2) >= line.toolBarItems.count()) - return 0; + return nullptr; return &(line.toolBarItems[path.at(2)]); } @@ -1143,10 +1143,10 @@ QLayoutItem *QToolBarAreaLayout::plug(const QList<int> &path) QToolBarAreaLayoutItem *item = this->item(path); if (Q_UNLIKELY(!item)) { qWarning() << "No item at" << path; - return 0; + return nullptr; } Q_ASSERT(item->gap); - Q_ASSERT(item->widgetItem != 0); + Q_ASSERT(item->widgetItem != nullptr); item->gap = false; return item->widgetItem; } @@ -1352,14 +1352,14 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar* rect = unpackRect(geom0, geom1, &floating); } - QToolBar *toolBar = 0; + QToolBar *toolBar = nullptr; for (int x = 0; x < toolBars.count(); ++x) { if (toolBars.at(x)->objectName() == objectName) { toolBar = toolBars.takeAt(x); break; } } - if (toolBar == 0) { + if (toolBar == nullptr) { continue; } diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index ec60309806..89c7f32b28 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -69,13 +69,13 @@ extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); */ QToolBarItem::QToolBarItem(QWidget *widget) - : QWidgetItem(widget), action(0), customWidget(false) + : QWidgetItem(widget), action(nullptr), customWidget(false) { } bool QToolBarItem::isEmpty() const { - return action == 0 || !action->isVisible(); + return action == nullptr || !action->isVisible(); } /****************************************************************************** @@ -84,7 +84,7 @@ bool QToolBarItem::isEmpty() const QToolBarLayout::QToolBarLayout(QWidget *parent) : QLayout(parent), expanded(false), animating(false), dirty(true), - expanding(false), empty(true), expandFlag(false), popupMenu(0) + expanding(false), empty(true), expandFlag(false), popupMenu(nullptr) { QToolBar *tb = qobject_cast<QToolBar*>(parent); if (!tb) @@ -132,15 +132,15 @@ bool QToolBarLayout::hasExpandFlag() const void QToolBarLayout::setUsePopupMenu(bool set) { - if (!dirty && ((popupMenu == 0) == set)) + if (!dirty && ((popupMenu == nullptr) == set)) invalidate(); if (!set) { QObject::connect(extension, SIGNAL(clicked(bool)), this, SLOT(setExpanded(bool)), Qt::UniqueConnection); extension->setPopupMode(QToolButton::DelayedPopup); - extension->setMenu(0); + extension->setMenu(nullptr); delete popupMenu; - popupMenu = 0; + popupMenu = nullptr; } else { QObject::disconnect(extension, SIGNAL(clicked(bool)), this, SLOT(setExpanded(bool))); @@ -169,21 +169,21 @@ void QToolBarLayout::addItem(QLayoutItem*) QLayoutItem *QToolBarLayout::itemAt(int index) const { if (index < 0 || index >= items.count()) - return 0; + return nullptr; return items.at(index); } QLayoutItem *QToolBarLayout::takeAt(int index) { if (index < 0 || index >= items.count()) - return 0; + return nullptr; QToolBarItem *item = items.takeAt(index); if (popupMenu) popupMenu->removeAction(item->action); QWidgetAction *widgetAction = qobject_cast<QWidgetAction*>(item->action); - if (widgetAction != 0 && item->customWidget) { + if (widgetAction != nullptr && item->customWidget) { widgetAction->releaseWidget(item->widget()); } else { // destroy the QToolButton/QToolBarSeparator @@ -251,7 +251,7 @@ bool QToolBarLayout::movable() const if (!tb) return false; QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget()); - return tb->isMovable() && win != 0; + return tb->isMovable() && win != nullptr; } void QToolBarLayout::updateGeomArray() const @@ -343,7 +343,7 @@ void QToolBarLayout::updateGeomArray() const static bool defaultWidgetAction(QToolBarItem *item) { QWidgetAction *a = qobject_cast<QWidgetAction*>(item->action); - return a != 0 && a->defaultWidget() == item->widget(); + return a != nullptr && a->defaultWidget() == item->widget(); } void QToolBarLayout::updateMacBorderMetrics() @@ -568,7 +568,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) // widgets into the menu. If only custom widget actions are chopped off, the popup menu // is empty. So we show the little extension button to show something is chopped off, // but we make it disabled. - extension->setEnabled(popupMenu == 0 || !extensionMenuContainsOnlyWidgetActions); + extension->setEnabled(popupMenu == nullptr || !extensionMenuContainsOnlyWidgetActions); // we have to do the show/hide here, because it triggers more calls to setGeometry :( for (int i = 0; i < showWidgets.count(); ++i) @@ -615,7 +615,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const ++rows; // we want to expand to at least two rows int space = total_w/rows + spacing + extensionExtent; space = qMax(space, min_w - pick(o, margins) - handleExtent); - if (win != 0) + if (win != nullptr) space = qMin(space, pick(o, win->size()) - pick(o, margins) - handleExtent); int w = 0; @@ -651,7 +651,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const w += pick(Qt::Horizontal, margins) + handleExtent + spacing + extensionExtent; w = qMax(w, min_w); - if (win != 0) + if (win != nullptr) w = qMin(w, pick(o, win->size())); h += pick(Qt::Vertical, margins) - spacing; //there is no spacing before the first row @@ -710,14 +710,14 @@ QToolBarItem *QToolBarLayout::createItem(QAction *action) { bool customWidget = false; bool standardButtonWidget = false; - QWidget *widget = 0; + QWidget *widget = nullptr; QToolBar *tb = qobject_cast<QToolBar*>(parentWidget()); if (!tb) - return (QToolBarItem *)0; + return (QToolBarItem *)nullptr; if (QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action)) { widget = widgetAction->requestWidget(tb); - if (widget != 0) { + if (widget != nullptr) { widget->setAttribute(Qt::WA_LayoutUsesWidgetRect); customWidget = true; } diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp index 4d7f543a99..4767394842 100644 --- a/src/widgets/widgets/qtoolbox.cpp +++ b/src/widgets/widgets/qtoolbox.cpp @@ -111,7 +111,7 @@ public: typedef std::vector<std::unique_ptr<Page>> PageList; inline QToolBoxPrivate() - : currentPage(0) + : currentPage(nullptr) { } void _q_buttonClicked(); @@ -157,7 +157,7 @@ const QToolBoxPrivate::Page *QToolBoxPrivate::page(int index) const void QToolBoxPrivate::updateTabs() { - QToolBoxButton *lastButton = currentPage ? currentPage->button : 0; + QToolBoxButton *lastButton = currentPage ? currentPage->button : nullptr; bool after = false; int index = 0; for (const auto &page : pageList) { @@ -184,7 +184,7 @@ QSize QToolBoxButton::sizeHint() const { QSize iconSize(8, 8); if (!icon().isNull()) { - int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() /* QToolBox */); + int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, parentWidget() /* QToolBox */); iconSize += QSize(icone + 2, icone); } QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8); @@ -197,7 +197,7 @@ QSize QToolBoxButton::minimumSizeHint() const { if (icon().isNull()) return QSize(); - int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() /* QToolBox */); + int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, parentWidget() /* QToolBox */); return QSize(icone + 8, icone + 8); } @@ -378,7 +378,7 @@ int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon, const QS QWidget *current = d->currentPage->widget; int oldindex = indexOf(current); if (index <= oldindex) { - d->currentPage = 0; // trigger change + d->currentPage = nullptr; // trigger change setCurrentIndex(oldindex); } } @@ -472,10 +472,10 @@ void QToolBoxPrivate::_q_widgetDestroyed(QObject *object) pageList.erase(std::remove_if(pageList.begin(), pageList.end(), pageEquals(c)), pageList.end()); if (pageList.empty()) { - currentPage = 0; + currentPage = nullptr; emit q->currentChanged(-1); } else if (removeCurrent) { - currentPage = 0; + currentPage = nullptr; q->setCurrentIndex(0); } } @@ -562,7 +562,7 @@ QWidget *QToolBox::widget(int index) const int QToolBox::indexOf(QWidget *widget) const { Q_D(const QToolBox); - const QToolBoxPrivate::Page *c = (widget ? d->page(widget) : 0); + const QToolBoxPrivate::Page *c = (widget ? d->page(widget) : nullptr); if (!c) return -1; const auto it = std::find_if(d->pageList.cbegin(), d->pageList.cend(), pageEquals(c)); diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index b00b219386..263fe5d8ce 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -202,7 +202,7 @@ QToolButton::QToolButton(QWidget * parent) void QToolButtonPrivate::init() { Q_Q(QToolButton); - defaultAction = 0; + defaultAction = nullptr; #if QT_CONFIG(toolbar) if (qobject_cast<QToolBar*>(parent)) autoRaise = true; @@ -227,7 +227,7 @@ void QToolButtonPrivate::init() #endif setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem); - delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, q); + delay = q->style()->styleHint(QStyle::SH_ToolButton_PopupDelay, nullptr, q); } /*! @@ -477,10 +477,10 @@ void QToolButton::actionEvent(QActionEvent *event) break; case QEvent::ActionRemoved: if (d->defaultAction == action) - d->defaultAction = 0; + d->defaultAction = nullptr; #if QT_CONFIG(menu) if (action == d->menuAction) - d->menuAction = 0; + d->menuAction = nullptr; #endif action->disconnect(this); break; @@ -583,7 +583,7 @@ void QToolButton::changeEvent(QEvent *e) || e->type() == QEvent::MacSizeChange #endif ) { - d->delay = style()->styleHint(QStyle::SH_ToolButton_PopupDelay, 0, this); + d->delay = style()->styleHint(QStyle::SH_ToolButton_PopupDelay, nullptr, this); d->setLayoutItemMargins(QStyle::SE_ToolButtonLayoutItem); } #endif @@ -649,7 +649,7 @@ void QToolButton::setMenu(QMenu* menu) { Q_D(QToolButton); - if (d->menuAction == (menu ? menu->menuAction() : 0)) + if (d->menuAction == (menu ? menu->menuAction() : nullptr)) return; if (d->menuAction) @@ -659,7 +659,7 @@ void QToolButton::setMenu(QMenu* menu) d->menuAction = menu->menuAction(); addAction(d->menuAction); } else { - d->menuAction = 0; + d->menuAction = nullptr; } // changing the menu set may change the size hint, so reset it diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp index 486d65d92c..cec6ba1dea 100644 --- a/src/widgets/widgets/qwidgetanimator.cpp +++ b/src/widgets/widgets/qwidgetanimator.cpp @@ -99,7 +99,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo #if QT_CONFIG(animation) //If the QStyle has animations, animate - if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, widget)) { + if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, widget)) { AnimationMap::const_iterator it = m_animation_map.constFind(widget); if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) return; diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 9cdae4f28f..a242947c11 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -964,7 +964,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields) if (maskFields.isEmpty() || delimiter == 0) { if (m_maskData) { delete [] m_maskData; - m_maskData = 0; + m_maskData = nullptr; m_maxLength = 32767; internalSetText(QString(), -1, false); } diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 1c169c3325..0b3c30312d 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -125,7 +125,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor) } QWidgetTextControlPrivate::QWidgetTextControlPrivate() - : doc(0), cursorOn(false), cursorVisible(false), cursorIsFocusIndicator(false), + : doc(nullptr), cursorOn(false), cursorVisible(false), cursorIsFocusIndicator(false), #ifndef Q_OS_ANDROID interactionFlags(Qt::TextEditorInteraction), #else @@ -683,7 +683,7 @@ void QWidgetTextControlPrivate::_q_contentsChanged(int from, int charsRemoved, i // always report the right number of removed chars, but in lack of the real string use spaces QString oldText = QString(charsRemoved, QLatin1Char(' ')); - QAccessibleEvent *ev = 0; + QAccessibleEvent *ev = nullptr; if (charsRemoved == 0) { ev = new QAccessibleTextInsertEvent(q->parent(), from, newText); } else if (charsAdded == 0) { @@ -906,12 +906,12 @@ void QWidgetTextControl::setDocument(QTextDocument *document) d->doc->disconnect(this); d->doc->documentLayout()->disconnect(this); - d->doc->documentLayout()->setPaintDevice(0); + d->doc->documentLayout()->setPaintDevice(nullptr); if (d->doc->parent() == this) delete d->doc; - d->doc = 0; + d->doc = nullptr; d->setContent(Qt::RichText, QString(), document); } @@ -2302,7 +2302,7 @@ QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget d->linkToCopy = anchorAt(pos); if (d->linkToCopy.isEmpty() && !showTextSelectionActions) - return 0; + return nullptr; QMenu *menu = new QMenu(parent); QAction *a; @@ -2656,7 +2656,7 @@ void QWidgetTextControl::print(QPagedPaintDevice *printer) const Q_D(const QWidgetTextControl); if (!printer) return; - QTextDocument *tempDoc = 0; + QTextDocument *tempDoc = nullptr; const QTextDocument *doc = d->doc; if (QPagedPaintDevicePrivate::get(printer)->printSelectionOnly) { if (!d->cursor.hasSelection()) -- cgit v1.2.3 From da94625f38692365217b4647dd721fa5ea14c6ff Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Tue, 3 Dec 2019 16:11:37 +0100 Subject: Fix sizeHint of QProgressDialog to have enough space for window margins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some styles, notably QMacStyle, use different margins for widgets and for windows. For these margins to be returned correctly, we have to tell the style that we want them for a toplevel widget. This was done correctly when laying out the dialog, but not when calculating the sizeHint, leading to a default size of the dialog that was too small to fit the text. As a drive-by, change variable names in the sizeHint method to be a bit more readable. Change-Id: Ib4168c7be176fa816241ebcc5f9235db4a7f982f Fixes: QTBUG-80272 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 13bbb1d9b9411e6eb65848efa8c0d481109b8868) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/widgets/dialogs/qprogressdialog.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index e1a6bce5b1..9507053ffe 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -708,14 +708,17 @@ void QProgressDialog::setValue(int progress) QSize QProgressDialog::sizeHint() const { Q_D(const QProgressDialog); - QSize sh = d->label ? d->label->sizeHint() : QSize(0, 0); - QSize bh = d->bar->sizeHint(); - int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin); - int spacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); - int h = margin * 2 + bh.height() + sh.height() + spacing; + QSize labelSize = d->label ? d->label->sizeHint() : QSize(0, 0); + QSize barSize = d->bar->sizeHint(); + int marginBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, this); + int spacing = style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, this); + int marginLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, this); + int marginRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, this); + + int height = marginBottom * 2 + barSize.height() + labelSize.height() + spacing; if (d->cancel) - h += d->cancel->sizeHint().height() + spacing; - return QSize(qMax(200, sh.width() + 2 * margin), h); + height += d->cancel->sizeHint().height() + spacing; + return QSize(qMax(200, labelSize.width() + marginLeft + marginRight), height); } /*!\reimp -- cgit v1.2.3 From d8fa009a15cdd6d9aa0cbeef949a7c480680a566 Mon Sep 17 00:00:00 2001 From: Andrew Patterson <andrew@avenza.com> Date: Tue, 12 Nov 2019 11:23:11 -0500 Subject: Make setModel() virtual Task-number: QTBUG-74255 Change-Id: I354e547dd75019a964f4b8e4f087a72e610816f3 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/widgets/qcombobox.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 4f89d7f542..1b80f90c74 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -170,7 +170,7 @@ public: void setItemDelegate(QAbstractItemDelegate *delegate); QAbstractItemModel *model() const; - void setModel(QAbstractItemModel *model); + virtual void setModel(QAbstractItemModel *model); QModelIndex rootModelIndex() const; void setRootModelIndex(const QModelIndex &index); -- cgit v1.2.3 From 49063c34d6314c59ec9529550e0639832796372e Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Mon, 18 Nov 2019 13:51:01 +0100 Subject: Fix crash when a date-time has an invalid time-zone QDateTime is a friend of QTimeZone, so can access its internals; but it must check the zone is valid before doing so. Expanded tst_QDateTime::invalid() and made it data-driven to catch the failure cases. Commented on a test-case that caught a mistake in my first attempt at this, and on QDateTimeParser's surprising reliance on a quirk of QDateTime::toMSecsSinceEpoch()'s behavior. Fixes: QTBUG-80146 Change-Id: I24856e19ff9bf402152d17d71f83be84e366faad Reviewed-by: Alex Blasche <alexander.blasche@qt.io> --- src/corelib/time/qdatetime.cpp | 32 ++++++++++++++++++++++---------- src/corelib/time/qdatetimeparser.cpp | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 9b0bc688c9..8de4f7caf8 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -3410,6 +3410,7 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT DaylightStatus hint, QDate *zoneDate, QTime *zoneTime) { + Q_ASSERT(zone.isValid()); // Get the effective data from QTimeZone QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs, int(hint)); // Docs state any time before 1970-01-01 will *not* have any DST applied @@ -3799,8 +3800,9 @@ QTimeZone QDateTime::timeZone() const case Qt::OffsetFromUTC: return QTimeZone(d->m_offsetFromUtc); case Qt::TimeZone: - Q_ASSERT(d->m_timeZone.isValid()); - return d->m_timeZone; + if (d->m_timeZone.isValid()) + return d->m_timeZone; + break; case Qt::LocalTime: return QTimeZone::systemTimeZone(); } @@ -3884,6 +3886,7 @@ QString QDateTime::timeZoneAbbreviation() const #if !QT_CONFIG(timezone) break; #else + Q_ASSERT(d->m_timeZone.isValid()); return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch()); #endif // timezone case Qt::LocalTime: { @@ -3920,6 +3923,7 @@ bool QDateTime::isDaylightTime() const #if !QT_CONFIG(timezone) break; #else + Q_ASSERT(d->m_timeZone.isValid()); return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); #endif // timezone case Qt::LocalTime: { @@ -4044,6 +4048,10 @@ void QDateTime::setTimeZone(const QTimeZone &toZone) */ qint64 QDateTime::toMSecsSinceEpoch() const { + // Note: QDateTimeParser relies on this producing a useful result, even when + // !isValid(), at least when the invalidity is a time in a fall-back (that + // we'll have adjusted to lie outside it, but marked invalid because it's + // not what was asked for). Other things may be doing similar. switch (getSpec(d)) { case Qt::UTC: return getMSecs(d); @@ -4058,12 +4066,13 @@ qint64 QDateTime::toMSecsSinceEpoch() const } case Qt::TimeZone: -#if !QT_CONFIG(timezone) - return 0; -#else - return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone, - extractDaylightStatus(getStatus(d))); +#if QT_CONFIG(timezone) + if (d->m_timeZone.isValid()) { + return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone, + extractDaylightStatus(getStatus(d))); + } #endif + return 0; } Q_UNREACHABLE(); return 0; @@ -4158,9 +4167,11 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs) case Qt::TimeZone: Q_ASSERT(!d.isShort()); #if QT_CONFIG(timezone) + d.detach(); + if (!d->m_timeZone.isValid()) + break; // Docs state any LocalTime before 1970-01-01 will *not* have any DST applied // but all affected times afterwards will have DST applied. - d.detach(); if (msecs >= 0) { status = mergeDaylightStatus(status, d->m_timeZone.d->isDaylightTime(msecs) @@ -4433,7 +4444,7 @@ static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime; localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time); #if QT_CONFIG(timezone) - } else if (spec == Qt::TimeZone) { + } else if (spec == Qt::TimeZone && d->m_timeZone.isValid()) { QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, QDateTimePrivate::UnknownDaylightTime, @@ -5094,7 +5105,8 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone { QDateTime dt; dt.setTimeZone(timeZone); - dt.setMSecsSinceEpoch(msecs); + if (timeZone.isValid()) + dt.setMSecsSinceEpoch(msecs); return dt; } diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 74db2bdfd5..61214b0c7e 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1363,7 +1363,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, // given date (which might be a spring-forward, skipping an hour). if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) { qint64 msecs = when.toMSecsSinceEpoch(); - // Fortunately, that gets a useful answer ... + // Fortunately, that gets a useful answer, even though when is invalid ... const QDateTime replace = #if QT_CONFIG(timezone) tspec == Qt::TimeZone -- cgit v1.2.3 From 187f4428239ace0a0c5b55d582729434d6e7ec82 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Fri, 29 Nov 2019 16:27:32 +0100 Subject: QTimeZonePrivate: remove some Q_LIKELY markers Although the relevant conditions are indeed likely, we don't want to push the less likely branch into hard-to-load pages; they're not anomalous conditions, merely ones with lower probability. Change-Id: Icc12a921d38d8c398cd832964e9d57d7648698b2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qtimezoneprivate.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp index 00dc8b4ced..cb019fa1a5 100644 --- a/src/corelib/time/qtimezoneprivate.cpp +++ b/src/corelib/time/qtimezoneprivate.cpp @@ -380,18 +380,15 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs, On the first pass, the case we consider is what hint told us to expect (except when hint was -1 and didn't actually tell us what to expect), so it's likely right. We only get a second pass if the first failed, - by which time the second case, that we're trying, is likely right. If - an overwhelming majority of calls have hint == -1, the Q_LIKELY here - shall be wrong half the time; otherwise, its errors shall be rarer - than that. + by which time the second case, that we're trying, is likely right. */ if (nextFirst ? i == 0 : i) { Q_ASSERT(nextStart != invalidMSecs()); - if (Q_LIKELY(nextStart <= nextTran.atMSecsSinceEpoch)) + if (nextStart <= nextTran.atMSecsSinceEpoch) return nextTran; } else { // If next is invalid, nextFirst is false, to route us here first: - if (nextStart == invalidMSecs() || Q_LIKELY(nextStart > tran.atMSecsSinceEpoch)) + if (nextStart == invalidMSecs() || nextStart > tran.atMSecsSinceEpoch) return tran; } } @@ -420,7 +417,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs, int early = offsetFromUtc(recent); int late = offsetFromUtc(imminent); - if (Q_LIKELY(early == late)) { // > 99% of the time + if (early == late) { // > 99% of the time utcEpochMSecs = forLocalMSecs - early * 1000; } else { // Close to a DST transition: early > late is near a fall-back, @@ -432,7 +429,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs, const qint64 forStd = forLocalMSecs - offsetInStd * 1000; // Best guess at the answer: const qint64 hinted = hint > 0 ? forDst : forStd; - if (Q_LIKELY(offsetFromUtc(hinted) == (hint > 0 ? offsetInDst : offsetInStd))) { + if (offsetFromUtc(hinted) == (hint > 0 ? offsetInDst : offsetInStd)) { utcEpochMSecs = hinted; } else if (hint <= 0 && offsetFromUtc(forDst) == offsetInDst) { utcEpochMSecs = forDst; -- cgit v1.2.3 From 653c1aab185fe59a523f16ffe0cf7b9173c2ff68 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Mon, 2 Dec 2019 12:55:31 +0100 Subject: Fix handling of trailing space at the end of an ISO date-time If milliseconds were followed by a space, the space was included in the count of "digits" read as the fractional part; since we read (up to) four digits (so that we round correctly if extras are given), a harmless apce could cause scaling down by too large a power of ten. Since QString::toInt() ignores leading space, we were also allowing interior space at the start of the milliseconds, which we should not, so catch that at the same time. Added tests, including one for the rounding that's the reason for reading the extra digit, when present. Fixes: QTBUG-80445 Change-Id: I606b29a94818a101f45c8b59a0f5d1f78893d78f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetime.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 8de4f7caf8..84b8a63c48 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2375,7 +2375,12 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, if (!ok) return QTime(); if (size > 8 && (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.'))) { - const QStringRef msecStr(string.mid(9, 4)); + QStringRef msecStr(string.mid(9, 4)); + // toInt() ignores leading spaces, so catch them before calling it + if (!msecStr.isEmpty() && !msecStr.at(0).isDigit()) + return QTime(); + // We do, however, want to ignore *trailing* spaces. + msecStr = msecStr.trimmed(); int msecInt = msecStr.isEmpty() ? 0 : msecStr.toInt(&ok); if (!ok) return QTime(); -- cgit v1.2.3 From 6b5f848ebd007e71f0ae5d81e834f5a2a5765aac Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 3 Dec 2019 11:17:31 +0100 Subject: Allow lower-case for the T and Z in ISO 8601 date format Cite RFC 3339 as basis for allowing a space in place of the T, too. The RFC mentions that ISO 8601 accepts t and z for T and Z, so test for them case-insensitively. Add a test for this. Change-Id: Iba700c8d74d485df154d27300aab7b1958e1ccef Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetime.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 84b8a63c48..4a1724bd39 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -5220,10 +5220,12 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) QStringRef isoString(&string); isoString = isoString.mid(10); // trim "yyyy-MM-dd" - // Must be left with T and at least one digit for the hour: + // Must be left with T (or space) and at least one digit for the hour: if (isoString.size() < 2 - || !(isoString.startsWith(QLatin1Char('T')) - // FIXME: QSql relies on QVariant::toDateTime() accepting a space here: + || !(isoString.startsWith(QLatin1Char('T'), Qt::CaseInsensitive) + // RFC 3339 (section 5.6) allows a space here. (It actually + // allows any separator one considers more readable, merely + // giving space as an example - but let's not go wild !) || isoString.startsWith(QLatin1Char(' ')))) { return QDateTime(); } @@ -5231,7 +5233,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) int offset = 0; // Check end of string for Time Zone definition, either Z for UTC or [+-]HH:mm for Offset - if (isoString.endsWith(QLatin1Char('Z'))) { + if (isoString.endsWith(QLatin1Char('Z'), Qt::CaseInsensitive)) { spec = Qt::UTC; isoString.chop(1); // trim 'Z' } else { -- cgit v1.2.3 From ca7033935a26e2a11c7d872a6673e828eddf49ca Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Wed, 4 Dec 2019 15:22:26 +0100 Subject: Tell the truth about QDateTimeEdit's range-of-values properties There were factual errors. Important details were omitted. The \sa blocks were haphazard and cluttered. Change-Id: I76ceb00830c36699c48529b64808844faf09391e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/widgets/widgets/qdatetimeedit.cpp | 200 +++++++++++++++++++--------------- 1 file changed, 115 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index e26993fb23..9189319364 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -90,12 +90,10 @@ QT_BEGIN_NAMESPACE today's date, and restricted the valid date range to today plus or minus 365 days. We've set the order to month, day, year. - The minimum value for QDateTimeEdit is 14 September 1752. You can - change this by calling setMinimumDate(), taking into account that - the minimum value for QDate is 2 January 4713BC. - - Other useful functions are setMaximumDate(), setMinimumTime() - and setMaximumTime(). + The range of valid values for a QDateTimeEdit is controlled by the properties + \l minimumDateTime, \l maximumDateTime, and their respective date and time + components. By default, any date-time from the start of 100 CE to the end of + 9999 CE is valid. \section1 Using a Pop-up Calendar Widget @@ -223,10 +221,16 @@ QDateTimeEdit::~QDateTimeEdit() When setting this property the timespec of the QDateTimeEdit remains the same and the timespec of the new QDateTime is ignored. - By default, this property contains a date that refers to January 1, - 2000 and a time of 00:00:00 and 0 milliseconds. + By default, this property is set to the start of 2000 CE. It can only be set + to a valid QDateTime value. If any operation causes this property to have an + invalid date-time as value, it is reset to the value of the \l minimumDateTime + property. + + If the QDateTimeEdit has no date fields, setting this property sets the + widget's date-range to start and end on the date of the new value of this + property. - \sa date, time + \sa date, time, minimumDateTime, maximumDateTime */ QDateTime QDateTimeEdit::dateTime() const @@ -329,25 +333,23 @@ void QDateTimeEdit::setCalendar(QCalendar calendar) } /*! - \property QDateTimeEdit::minimumDateTime \since 4.4 + \property QDateTimeEdit::minimumDateTime \brief the minimum datetime of the date time edit - When setting this property the \l maximumDateTime() is adjusted if - necessary to ensure that the range remains valid. If the datetime is - not a valid QDateTime object, this function does nothing. - - The default minimumDateTime can be restored with - clearMinimumDateTime() + Changing this property implicitly updates the \l minimumDate and \l + minimumTime properties to the date and time parts of this property, + respectively. When setting this property, the \l maximumDateTime is adjusted, + if necessary, to ensure that the range remains valid. Otherwise, changing this + property preserves the \l minimumDateTime property. - By default, this property contains a date that refers to September 14, - 1752 and a time of 00:00:00 and 0 milliseconds. + This property can only be set to a valid QDateTime value. The earliest + date-time that setMinimumDateTime() accepts is the start of 100 CE. The + property's default is the start of September 14, 1752 CE. This default can be + restored with clearMinimumDateTime(). - \sa maximumDateTime(), minimumTime(), maximumTime(), minimumDate(), - maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(), - clearMaximumDateTime(), clearMinimumDate(), - clearMaximumDate(), clearMinimumTime(), clearMaximumTime() + \sa maximumDateTime, minimumTime, minimumDate, setDateTimeRange(), QDateTime::isValid() */ QDateTime QDateTimeEdit::minimumDateTime() const @@ -372,25 +374,23 @@ void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt) } /*! - \property QDateTimeEdit::maximumDateTime \since 4.4 + \property QDateTimeEdit::maximumDateTime \brief the maximum datetime of the date time edit - When setting this property the \l minimumDateTime() is adjusted if - necessary to ensure that the range remains valid. If the datetime is - not a valid QDateTime object, this function does nothing. + Changing this property implicitly updates the \l maximumDate and \l + maximumTime properties to the date and time parts of this property, + respectively. When setting this property, the \l minimumDateTime is adjusted, + if necessary, to ensure that the range remains valid. Otherwise, changing this + property preserves the \l minimumDateTime property. - The default maximumDateTime can be restored with + This property can only be set to a valid QDateTime value. The latest + date-time that setMaximumDateTime() accepts is the end of 9999 CE. This is the + default for this property. This default can be restored with clearMaximumDateTime(). - By default, this property contains a date that refers to 31 December, - 9999 and a time of 23:59:59 and 999 milliseconds. - - \sa minimumDateTime(), minimumTime(), maximumTime(), minimumDate(), - maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(), - clearMinimumDateTime(), clearMinimumDate(), - clearMaximumDate(), clearMinimumTime(), clearMaximumTime() + \sa minimumDateTime, maximumTime, maximumDate(), setDateTimeRange(), QDateTime::isValid() */ QDateTime QDateTimeEdit::maximumDateTime() const @@ -414,11 +414,12 @@ void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt) } } - /*! - Convenience function to set minimum and maximum date time with one - function call. \since 4.4 + \brief Set the range of allowed date-times for the date time edit. + + This convenience function sets the \l minimumDateTime and \l maximumDateTime + properties. \snippet code/src_gui_widgets_qdatetimeedit.cpp 1 @@ -426,21 +427,18 @@ void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt) \snippet code/src_gui_widgets_qdatetimeedit.cpp 2 - If either \a min or \a max are not valid, this function does - nothing. + If either \a min or \a max is invalid, this function does nothing. If \a max + is less than \a min, \a min is used also as \a max. - \sa setMinimumDate(), maximumDate(), setMaximumDate(), - clearMinimumDate(), setMinimumTime(), maximumTime(), - setMaximumTime(), clearMinimumTime(), QDateTime::isValid() + \sa minimumDateTime, maximumDateTime, setDateRange(), setTimeRange(), QDateTime::isValid() */ void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max) { Q_D(QDateTimeEdit); + // FIXME: does none of the range checks applied to setMin/setMax methods ! const QDateTime minimum = min.toTimeSpec(d->spec); - QDateTime maximum = max.toTimeSpec(d->spec); - if (min > max) - maximum = minimum; + const QDateTime maximum = (min > max ? minimum : max.toTimeSpec(d->spec)); d->setRange(minimum, maximum); } @@ -449,15 +447,20 @@ void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max) \brief the minimum date of the date time edit - When setting this property the \l maximumDate is adjusted if - necessary, to ensure that the range remains valid. If the date is - not a valid QDate object, this function does nothing. + Changing this property updates the date of the \l minimumDateTime property + while preserving the \l minimumTime property. When setting this property, + the \l maximumDate is adjusted, if necessary, to ensure that the range remains + valid. When this happens, the \l maximumTime property is also adjusted if it + is less than the \l minimumTime property. Otherwise, changes to this property + preserve the \l maximumDateTime property. - By default, this property contains a date that refers to September 14, 1752. - The minimum date must be at least the first day in year 100, otherwise - setMinimumDate() has no effect. + This property can only be set to a valid QDate object describing a date on + which the current \l minimumTime property makes a valid QDateTime object. The + earliest date that setMinimumDate() accepts is the start of 100 CE. The + default for this property is September 14, 1752 CE. This default can be + restored with clearMinimumDateTime(). - \sa minimumTime(), maximumTime(), setDateRange() + \sa maximumDate, minimumTime, minimumDateTime, setDateRange(), QDate::isValid() */ QDate QDateTimeEdit::minimumDate() const @@ -484,13 +487,20 @@ void QDateTimeEdit::clearMinimumDate() \brief the maximum date of the date time edit - When setting this property the \l minimumDate is adjusted if - necessary to ensure that the range remains valid. If the date is - not a valid QDate object, this function does nothing. - - By default, this property contains a date that refers to December 31, 9999. + Changing this property updates the date of the \l maximumDateTime property + while preserving the \l maximumTime property. When setting this property, the + \l minimumDate is adjusted, if necessary, to ensure that the range remains + valid. When this happens, the \l minimumTime property is also adjusted if it + is greater than the \l maximumTime property. Otherwise, changes to this + property preserve the \l minimumDateTime property. + + This property can only be set to a valid QDate object describing a date on + which the current \l maximumTime property makes a valid QDateTime object. The + latest date that setMaximumDate() accepts is the end of 9999 CE. This is the + default for this property. This default can be restored with + clearMaximumDateTime(). - \sa minimumDate, minimumTime, maximumTime, setDateRange() + \sa minimumDate, maximumTime, maximumDateTime, setDateRange(), QDate::isValid() */ QDate QDateTimeEdit::maximumDate() const @@ -502,9 +512,8 @@ QDate QDateTimeEdit::maximumDate() const void QDateTimeEdit::setMaximumDate(const QDate &max) { Q_D(QDateTimeEdit); - if (max.isValid()) { + if (max.isValid()) setMaximumDateTime(QDateTime(max, d->maximum.toTime(), d->spec)); - } } void QDateTimeEdit::clearMaximumDate() @@ -517,13 +526,18 @@ void QDateTimeEdit::clearMaximumDate() \brief the minimum time of the date time edit - When setting this property the \l maximumTime is adjusted if - necessary, to ensure that the range remains valid. If the time is - not a valid QTime object, this function does nothing. + Changing this property updates the time of the \l minimumDateTime property + while preserving the \l minimumDate and \l maximumDate properties. If those + date properties coincide, when setting this property, the \l maximumTime + property is adjusted, if necessary, to ensure that the range remains + valid. Otherwise, changing this property preserves the \l maximumDateTime + property. - By default, this property contains a time of 00:00:00 and 0 milliseconds. + This property can be set to any valid QTime value. By default, this property + contains a time of 00:00:00 and 0 milliseconds. This default can be restored + with clearMinimumTime(). - \sa maximumTime, minimumDate, maximumDate, setTimeRange() + \sa maximumTime, minimumDate, minimumDateTime, setTimeRange(), QTime::isValid() */ QTime QDateTimeEdit::minimumTime() const @@ -551,13 +565,18 @@ void QDateTimeEdit::clearMinimumTime() \brief the maximum time of the date time edit - When setting this property, the \l minimumTime is adjusted if - necessary to ensure that the range remains valid. If the time is - not a valid QTime object, this function does nothing. + Changing this property updates the time of the \l maximumDateTime property + while preserving the \l minimumDate and \l maximumDate properties. If those + date properties coincide, when setting this property, the \l minimumTime + property is adjusted, if necessary, to ensure that the range remains + valid. Otherwise, changing this property preserves the \l minimumDateTime + property. - By default, this property contains a time of 23:59:59 and 999 milliseconds. + This property can be set to any valid QTime value. By default, this property + contains a time of 23:59:59 and 999 milliseconds. This default can be restored + with clearMaximumTime(). - \sa minimumTime, minimumDate, maximumDate, setTimeRange() + \sa minimumTime, maximumDate, maximumDateTime, setTimeRange(), QTime::isValid() */ QTime QDateTimeEdit::maximumTime() const { @@ -580,8 +599,10 @@ void QDateTimeEdit::clearMaximumTime() } /*! - Convenience function to set minimum and maximum date with one - function call. + \brief Set the range of allowed dates for the date time edit. + + This convenience function sets the \l minimumDate and \l maximumDate + properties. \snippet code/src_gui_widgets_qdatetimeedit.cpp 3 @@ -589,12 +610,14 @@ void QDateTimeEdit::clearMaximumTime() \snippet code/src_gui_widgets_qdatetimeedit.cpp 4 - If either \a min or \a max are not valid, this function does - nothing. + If either \a min or \a max is invalid, this function does nothing. This + function preserves the \l minimumTime property. If \a max is less than \a min, + the new maximumDateTime property shall be the new minimumDateTime property. If + \a max is equal to \a min and the \l maximumTime property was less then the \l + minimumTime property, the \l maximumTime property is set to the \l minimumTime + property. Otherwise, this preserves the \l maximumTime property. - \sa setMinimumDate(), maximumDate(), setMaximumDate(), - clearMinimumDate(), setMinimumTime(), maximumTime(), - setMaximumTime(), clearMinimumTime(), QDate::isValid() + \sa minimumDate, maximumDate, setDateTimeRange(), QDate::isValid() */ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) @@ -607,8 +630,16 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) } /*! - Convenience function to set minimum and maximum time with one - function call. + \brief Set the range of allowed times for the date time edit. + + This convenience function sets the \l minimumTime and \l maximumTime + properties. + + Note that these only constrain the date time edit's value on, + respectively, the \l minimumDate and \l maximumDate. When these date + properties do not coincide, times after \a maximumTime are allowed on dates + before \l maximumDate and times before \a minimumTime are allowed on dates + after \l minimumDate. \snippet code/src_gui_widgets_qdatetimeedit.cpp 5 @@ -616,12 +647,11 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) \snippet code/src_gui_widgets_qdatetimeedit.cpp 6 - If either \a min or \a max are not valid, this function does - nothing. + If either \a min or \a max is invalid, this function does nothing. This + function preserves the \l minimumDate and \l maximumDate properties. If those + properties coincide and max is \a less than \a min, \a min is used as \a max. - \sa setMinimumDate(), maximumDate(), setMaximumDate(), - clearMinimumDate(), setMinimumTime(), maximumTime(), - setMaximumTime(), clearMinimumTime(), QTime::isValid() + \sa minimumTime, maximumTime, setDateTimeRange(), QTime::isValid() */ void QDateTimeEdit::setTimeRange(const QTime &min, const QTime &max) @@ -865,7 +895,7 @@ QString QDateTimeEdit::sectionText(Section section) const Note that if you specify a two digit year, it will be interpreted to be in the century in which the date time edit was initialized. - The default century is the 21 (2000-2099). + The default century is the 21st (2000-2099). If you specify an invalid format the format will not be set. -- cgit v1.2.3 From 29adc0eed9b9dc3cce92f8acaaeaed3ab1bc6414 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan <sona.kurazyan@qt.io> Date: Thu, 5 Dec 2019 16:45:31 +0100 Subject: Fix updating the text cursor position after editing In some cases when editing the text (for example when removing the selected text, or pasting a text block) the text cursor position is updated, but its visual x position is not updated. This causes the next cursor movements to start from a wrong position. Force the update for those cases. Fixes: QTBUG-78479 Change-Id: Ia496be62beec58660f5e1695e5aafae09c79684e Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/gui/text/qtextcursor.cpp | 1 + src/widgets/widgets/qwidgettextcontrol.cpp | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index c88497840f..056a854789 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2261,6 +2261,7 @@ void QTextCursor::insertFragment(const QTextDocumentFragment &fragment) d->remove(); fragment.d->insert(*this); d->priv->endEditBlock(); + d->setX(); if (fragment.d && fragment.d->doc) d->priv->mergeCachedResources(fragment.d->doc->docHandle()); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 1c169c3325..83e2315c36 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1283,6 +1283,8 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) } else { QTextCursor localCursor = cursor; localCursor.deletePreviousChar(); + if (cursor.d) + cursor.d->setX(); } goto accept; } @@ -1322,9 +1324,13 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e) else if (e == QKeySequence::Delete) { QTextCursor localCursor = cursor; localCursor.deleteChar(); + if (cursor.d) + cursor.d->setX(); } else if (e == QKeySequence::Backspace) { QTextCursor localCursor = cursor; localCursor.deletePreviousChar(); + if (cursor.d) + cursor.d->setX(); }else if (e == QKeySequence::DeleteEndOfWord) { if (!cursor.hasSelection()) cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor); -- cgit v1.2.3 From cedf0207d1ebd931fe155ca04abbf3cb0702854a Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Wed, 4 Dec 2019 19:36:33 +0100 Subject: Use Q_NAMESPACE for the Qt namespace, and remove the old moc hack to support it Since I can't #include qobjectdefs from qnamespace because of circular dependency, move the Qt macro in the qtmetamacros.h header. Deprecate QObject::staticQtMetaObject since now one can just use Qt::staticMetaObject Change-Id: I11982aa17c2afa2067486b113f8052672f3695eb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/corelib/global/qnamespace.h | 200 ++++++++++++++----------------- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/kernel/qobject.h | 6 - src/corelib/kernel/qobjectdefs.h | 185 +---------------------------- src/corelib/kernel/qtmetamacros.h | 233 +++++++++++++++++++++++++++++++++++++ src/tools/moc/generator.cpp | 11 +- 6 files changed, 325 insertions(+), 312 deletions(-) create mode 100644 src/corelib/kernel/qtmetamacros.h (limited to 'src') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 047ed8e7b3..6ae04f0c7b 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -41,6 +41,7 @@ #define QNAMESPACE_H #include <QtCore/qglobal.h> +#include <QtCore/qtmetamacros.h> #if defined(__OBJC__) && !defined(__cplusplus) # warning "File built in Objective-C mode (.m), but using Qt requires Objective-C++ (.mm)" @@ -48,29 +49,10 @@ QT_BEGIN_NAMESPACE -#if !defined(Q_QDOC) && !defined(Q_MOC_RUN) struct QMetaObject; -const QMetaObject *qt_getQtMetaObject() noexcept; // defined in qobject.h (which can't be included here) -#define QT_Q_ENUM(ENUM) \ - inline const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return qt_getQtMetaObject(); } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } -#define QT_Q_FLAG(ENUM) QT_Q_ENUM(ENUM) -#else -#define QT_Q_ENUM Q_ENUM -#define QT_Q_FLAG Q_FLAG -#endif - -#ifndef Q_MOC_RUN -namespace -#else -class Q_CORE_EXPORT -#endif -Qt { -#if defined(Q_MOC_RUN) - Q_OBJECT -public: -#endif +namespace Qt { + Q_NAMESPACE_EXPORT(Q_CORE_EXPORT) enum GlobalColor { color0, @@ -1767,102 +1749,96 @@ public: }; #ifndef Q_QDOC - // NOTE: Generally, do not add QT_Q_ENUM if a corresponding Q_Q_FLAG exists. - QT_Q_ENUM(ScrollBarPolicy) - QT_Q_ENUM(FocusPolicy) - QT_Q_ENUM(ContextMenuPolicy) - QT_Q_ENUM(ArrowType) - QT_Q_ENUM(ToolButtonStyle) - QT_Q_ENUM(PenStyle) - QT_Q_ENUM(PenCapStyle) - QT_Q_ENUM(PenJoinStyle) - QT_Q_ENUM(BrushStyle) - QT_Q_ENUM(FillRule) - QT_Q_ENUM(MaskMode) - QT_Q_ENUM(BGMode) - QT_Q_ENUM(ClipOperation) - QT_Q_ENUM(SizeMode) - QT_Q_ENUM(Axis) - QT_Q_ENUM(Corner) - QT_Q_ENUM(Edge) - QT_Q_ENUM(LayoutDirection) - QT_Q_ENUM(SizeHint) - QT_Q_ENUM(Orientation) - QT_Q_ENUM(DropAction) - QT_Q_FLAG(Alignment) - QT_Q_ENUM(TextFlag) - QT_Q_FLAG(Orientations) - QT_Q_FLAG(SplitBehavior) - QT_Q_FLAG(DropActions) - QT_Q_FLAG(Edges) - QT_Q_FLAG(DockWidgetAreas) - QT_Q_FLAG(ToolBarAreas) - QT_Q_ENUM(DockWidgetArea) - QT_Q_ENUM(ToolBarArea) - QT_Q_ENUM(TextFormat) - QT_Q_ENUM(TextElideMode) - QT_Q_ENUM(DateFormat) - QT_Q_ENUM(TimeSpec) - QT_Q_ENUM(DayOfWeek) - QT_Q_ENUM(CursorShape) - QT_Q_ENUM(GlobalColor) - QT_Q_ENUM(AspectRatioMode) - QT_Q_ENUM(TransformationMode) - QT_Q_FLAG(ImageConversionFlags) - QT_Q_ENUM(Key) - QT_Q_ENUM(ShortcutContext) - QT_Q_ENUM(TextInteractionFlag) - QT_Q_FLAG(TextInteractionFlags) - QT_Q_ENUM(ItemSelectionMode) - QT_Q_ENUM(ItemSelectionOperation) - QT_Q_FLAG(ItemFlags) - QT_Q_ENUM(CheckState) - QT_Q_ENUM(ItemDataRole) - QT_Q_ENUM(SortOrder) - QT_Q_ENUM(CaseSensitivity) - QT_Q_FLAG(MatchFlags) - QT_Q_FLAG(KeyboardModifiers) - QT_Q_FLAG(MouseButtons) - QT_Q_ENUM(WindowType) - QT_Q_ENUM(WindowState) - QT_Q_ENUM(WindowModality) - QT_Q_ENUM(WidgetAttribute) - QT_Q_ENUM(ApplicationAttribute) - QT_Q_FLAG(WindowFlags) - QT_Q_FLAG(WindowStates) - QT_Q_ENUM(FocusReason) - QT_Q_ENUM(InputMethodHint) - QT_Q_ENUM(InputMethodQuery) - QT_Q_FLAG(InputMethodHints) - QT_Q_ENUM(EnterKeyType) - QT_Q_FLAG(InputMethodQueries) - QT_Q_FLAG(TouchPointStates) - QT_Q_ENUM(ScreenOrientation) - QT_Q_FLAG(ScreenOrientations) - QT_Q_ENUM(ConnectionType) - QT_Q_ENUM(ApplicationState) + // NOTE: Generally, do not add Q_ENUM_NS if a corresponding Q_FLAG_NS exists. + Q_ENUM_NS(ScrollBarPolicy) + Q_ENUM_NS(FocusPolicy) + Q_ENUM_NS(ContextMenuPolicy) + Q_ENUM_NS(ArrowType) + Q_ENUM_NS(ToolButtonStyle) + Q_ENUM_NS(PenStyle) + Q_ENUM_NS(PenCapStyle) + Q_ENUM_NS(PenJoinStyle) + Q_ENUM_NS(BrushStyle) + Q_ENUM_NS(FillRule) + Q_ENUM_NS(MaskMode) + Q_ENUM_NS(BGMode) + Q_ENUM_NS(ClipOperation) + Q_ENUM_NS(SizeMode) + Q_ENUM_NS(Axis) + Q_ENUM_NS(Corner) + Q_ENUM_NS(Edge) + Q_ENUM_NS(LayoutDirection) + Q_ENUM_NS(SizeHint) + Q_ENUM_NS(Orientation) + Q_ENUM_NS(DropAction) + Q_FLAG_NS(Alignment) + Q_ENUM_NS(TextFlag) + Q_FLAG_NS(Orientations) + Q_FLAG_NS(SplitBehavior) + Q_FLAG_NS(DropActions) + Q_FLAG_NS(Edges) + Q_FLAG_NS(DockWidgetAreas) + Q_FLAG_NS(ToolBarAreas) + Q_ENUM_NS(DockWidgetArea) + Q_ENUM_NS(ToolBarArea) + Q_ENUM_NS(TextFormat) + Q_ENUM_NS(TextElideMode) + Q_ENUM_NS(DateFormat) + Q_ENUM_NS(TimeSpec) + Q_ENUM_NS(DayOfWeek) + Q_ENUM_NS(CursorShape) + Q_ENUM_NS(GlobalColor) + Q_ENUM_NS(AspectRatioMode) + Q_ENUM_NS(TransformationMode) + Q_FLAG_NS(ImageConversionFlags) + Q_ENUM_NS(Key) + Q_ENUM_NS(ShortcutContext) + Q_ENUM_NS(TextInteractionFlag) + Q_FLAG_NS(TextInteractionFlags) + Q_ENUM_NS(ItemSelectionMode) + Q_ENUM_NS(ItemSelectionOperation) + Q_FLAG_NS(ItemFlags) + Q_ENUM_NS(CheckState) + Q_ENUM_NS(ItemDataRole) + Q_ENUM_NS(SortOrder) + Q_ENUM_NS(CaseSensitivity) + Q_FLAG_NS(MatchFlags) + Q_FLAG_NS(KeyboardModifiers) + Q_FLAG_NS(MouseButtons) + Q_ENUM_NS(WindowType) + Q_ENUM_NS(WindowState) + Q_ENUM_NS(WindowModality) + Q_ENUM_NS(WidgetAttribute) + Q_ENUM_NS(ApplicationAttribute) + Q_FLAG_NS(WindowFlags) + Q_FLAG_NS(WindowStates) + Q_ENUM_NS(FocusReason) + Q_ENUM_NS(InputMethodHint) + Q_ENUM_NS(InputMethodQuery) + Q_FLAG_NS(InputMethodHints) + Q_ENUM_NS(EnterKeyType) + Q_FLAG_NS(InputMethodQueries) + Q_FLAG_NS(TouchPointStates) + Q_ENUM_NS(ScreenOrientation) + Q_FLAG_NS(ScreenOrientations) + Q_ENUM_NS(ConnectionType) + Q_ENUM_NS(ApplicationState) #ifndef QT_NO_GESTURES - QT_Q_ENUM(GestureState) - QT_Q_ENUM(GestureType) - QT_Q_ENUM(NativeGestureType) + Q_ENUM_NS(GestureState) + Q_ENUM_NS(GestureType) + Q_ENUM_NS(NativeGestureType) #endif - QT_Q_ENUM(CursorMoveStyle) - QT_Q_ENUM(TimerType) - QT_Q_ENUM(ScrollPhase) - QT_Q_ENUM(MouseEventSource) - QT_Q_FLAG(MouseEventFlag) - QT_Q_ENUM(ChecksumType) - QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy) - QT_Q_ENUM(TabFocusBehavior) + Q_ENUM_NS(CursorMoveStyle) + Q_ENUM_NS(TimerType) + Q_ENUM_NS(ScrollPhase) + Q_ENUM_NS(MouseEventSource) + Q_FLAG_NS(MouseEventFlag) + Q_ENUM_NS(ChecksumType) + Q_ENUM_NS(HighDpiScaleFactorRoundingPolicy) + Q_ENUM_NS(TabFocusBehavior) #endif // Q_DOC } -#ifdef Q_MOC_RUN - ; -#endif - -#undef QT_Q_ENUM -#undef QT_Q_FLAG typedef bool (*qInternalCallback)(void **); diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index b1e1bb8b4a..4484dfdce9 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1163,7 +1163,7 @@ QMetaProperty QMetaObject::property(int index) const const QMetaObject *scope = 0; if (qstrcmp(scope_name, "Qt") == 0) - scope = &QObject::staticQtMetaObject; + scope = &Qt::staticMetaObject; else scope = QMetaObject_findMetaObject(this, scope_name); if (scope) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 296552c2f2..ca5275a3ac 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -434,9 +434,6 @@ protected: protected: QScopedPointer<QObjectData> d_ptr; - static const QMetaObject staticQtMetaObject; - friend inline const QMetaObject *qt_getQtMetaObject() noexcept; - friend struct QMetaObject; friend struct QMetaObjectPrivate; friend class QMetaCallEvent; @@ -467,9 +464,6 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch const char *amember, Qt::ConnectionType atype) const { return connect(asender, asignal, this, amember, atype); } -inline const QMetaObject *qt_getQtMetaObject() noexcept -{ return &QObject::staticQtMetaObject; } - #if QT_DEPRECATED_SINCE(5, 0) template<typename T> inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 9f654b0318..90e3aa02d8 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -46,199 +46,16 @@ #endif #include <QtCore/qnamespace.h> - #include <QtCore/qobjectdefs_impl.h> +#include <QtCore/qtmetamacros.h> QT_BEGIN_NAMESPACE - class QByteArray; struct QArrayData; typedef QArrayData QByteArrayData; class QString; -#ifndef Q_MOC_OUTPUT_REVISION -#define Q_MOC_OUTPUT_REVISION 67 -#endif - -// The following macros can be defined by tools that understand Qt -// to have the information from the macro. -#ifndef QT_ANNOTATE_CLASS -# define QT_ANNOTATE_CLASS(type, ...) -#endif -#ifndef QT_ANNOTATE_CLASS2 -# define QT_ANNOTATE_CLASS2(type, a1, a2) -#endif -#ifndef QT_ANNOTATE_FUNCTION -# define QT_ANNOTATE_FUNCTION(x) -#endif -#ifndef QT_ANNOTATE_ACCESS_SPECIFIER -# define QT_ANNOTATE_ACCESS_SPECIFIER(x) -#endif - -// The following macros are our "extensions" to C++ -// They are used, strictly speaking, only by the moc. - -#ifndef Q_MOC_RUN -#ifndef QT_NO_META_MACROS -# if defined(QT_NO_KEYWORDS) -# define QT_NO_EMIT -# else -# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS -# define slots Q_SLOTS -# define signals Q_SIGNALS -# endif -# endif -# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot) -# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal) -# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature) -# define Q_EMIT -#ifndef QT_NO_EMIT -# define emit -#endif -#ifndef Q_CLASSINFO -# define Q_CLASSINFO(name, value) -#endif -#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) -#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) -#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) -#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) -#ifndef Q_REVISION -# define Q_REVISION(v) -#endif -#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text) -#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text) -#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) -#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) -#define Q_ENUM_IMPL(ENUM) \ - friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } -#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) -#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) -#define Q_ENUM_NS_IMPL(ENUM) \ - inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } -#define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) -#define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) -#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) -#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) -#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) -#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) -#endif // QT_NO_META_MACROS - -#ifndef QT_NO_TRANSLATION -// full set of tr functions -# define QT_TR_FUNCTIONS \ - static inline QString tr(const char *s, const char *c = nullptr, int n = -1) \ - { return staticMetaObject.tr(s, c, n); } \ - QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) \ - { return staticMetaObject.tr(s, c, n); } -#else -// inherit the ones from QObject -# define QT_TR_FUNCTIONS -#endif - -#ifdef Q_CLANG_QDOC -#define QT_TR_FUNCTIONS -#endif - -// ### Qt6: remove -#define Q_OBJECT_CHECK /* empty, unused since Qt 5.2 */ - -#if defined(Q_CC_INTEL) -// Cannot redefine the visibility of a method in an exported class -# define Q_DECL_HIDDEN_STATIC_METACALL -#else -# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN -#endif - -#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306 -# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") -#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501 -# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override") -#else -# define Q_OBJECT_NO_OVERRIDE_WARNING -#endif - -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600 -# define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes") -#else -# define Q_OBJECT_NO_ATTRIBUTES_WARNING -#endif - -/* qmake ignore Q_OBJECT */ -#define Q_OBJECT \ -public: \ - QT_WARNING_PUSH \ - Q_OBJECT_NO_OVERRIDE_WARNING \ - static const QMetaObject staticMetaObject; \ - virtual const QMetaObject *metaObject() const; \ - virtual void *qt_metacast(const char *); \ - virtual int qt_metacall(QMetaObject::Call, int, void **); \ - QT_TR_FUNCTIONS \ -private: \ - Q_OBJECT_NO_ATTRIBUTES_WARNING \ - Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ - QT_WARNING_POP \ - struct QPrivateSignal {}; \ - QT_ANNOTATE_CLASS(qt_qobject, "") - -/* qmake ignore Q_OBJECT */ -#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") - -#ifndef QT_NO_META_MACROS -/* qmake ignore Q_GADGET */ -#define Q_GADGET \ -public: \ - static const QMetaObject staticMetaObject; \ - void qt_check_for_QGADGET_macro(); \ - typedef void QtGadgetHelper; \ -private: \ - QT_WARNING_PUSH \ - Q_OBJECT_NO_ATTRIBUTES_WARNING \ - Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ - QT_WARNING_POP \ - QT_ANNOTATE_CLASS(qt_qgadget, "") \ - /*end*/ - -/* qmake ignore Q_NAMESPACE_EXPORT */ -#define Q_NAMESPACE_EXPORT(...) \ - extern __VA_ARGS__ const QMetaObject staticMetaObject; \ - QT_ANNOTATE_CLASS(qt_qnamespace, "") \ - /*end*/ - -/* qmake ignore Q_NAMESPACE */ -#define Q_NAMESPACE Q_NAMESPACE_EXPORT() \ - /*end*/ - -#endif // QT_NO_META_MACROS - -#else // Q_MOC_RUN -#define slots slots -#define signals signals -#define Q_SLOTS Q_SLOTS -#define Q_SIGNALS Q_SIGNALS -#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) -#define Q_INTERFACES(x) Q_INTERFACES(x) -#define Q_PROPERTY(text) Q_PROPERTY(text) -#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text) -#define Q_REVISION(v) Q_REVISION(v) -#define Q_OVERRIDE(text) Q_OVERRIDE(text) -#define Q_ENUMS(x) Q_ENUMS(x) -#define Q_FLAGS(x) Q_FLAGS(x) -#define Q_ENUM(x) Q_ENUM(x) -#define Q_FLAGS(x) Q_FLAGS(x) - /* qmake ignore Q_OBJECT */ -#define Q_OBJECT Q_OBJECT - /* qmake ignore Q_OBJECT */ -#define Q_OBJECT_FAKE Q_OBJECT_FAKE - /* qmake ignore Q_GADGET */ -#define Q_GADGET Q_GADGET -#define Q_SCRIPTABLE Q_SCRIPTABLE -#define Q_INVOKABLE Q_INVOKABLE -#define Q_SIGNAL Q_SIGNAL -#define Q_SLOT Q_SLOT -#endif //Q_MOC_RUN #ifndef QT_NO_META_MACROS // macro for onaming members diff --git a/src/corelib/kernel/qtmetamacros.h b/src/corelib/kernel/qtmetamacros.h new file mode 100644 index 0000000000..19b6bfa358 --- /dev/null +++ b/src/corelib/kernel/qtmetamacros.h @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTMETAMACROS_H +#define QTMETAMACROS_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +#ifndef Q_MOC_OUTPUT_REVISION +#define Q_MOC_OUTPUT_REVISION 67 +#endif + +// The following macros can be defined by tools that understand Qt +// to have the information from the macro. +#ifndef QT_ANNOTATE_CLASS +# define QT_ANNOTATE_CLASS(type, ...) +#endif +#ifndef QT_ANNOTATE_CLASS2 +# define QT_ANNOTATE_CLASS2(type, a1, a2) +#endif +#ifndef QT_ANNOTATE_FUNCTION +# define QT_ANNOTATE_FUNCTION(x) +#endif +#ifndef QT_ANNOTATE_ACCESS_SPECIFIER +# define QT_ANNOTATE_ACCESS_SPECIFIER(x) +#endif + +// The following macros are our "extensions" to C++ +// They are used, strictly speaking, only by the moc. + +#ifndef Q_MOC_RUN +#ifndef QT_NO_META_MACROS +# if defined(QT_NO_KEYWORDS) +# define QT_NO_EMIT +# else +# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS +# define slots Q_SLOTS +# define signals Q_SIGNALS +# endif +# endif +# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot) +# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal) +# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature) +# define Q_EMIT +#ifndef QT_NO_EMIT +# define emit +#endif +#ifndef Q_CLASSINFO +# define Q_CLASSINFO(name, value) +#endif +#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) +#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) +#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) +#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) +#ifndef Q_REVISION +# define Q_REVISION(v) +#endif +#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text) +#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text) +#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) +#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) +#define Q_ENUM_IMPL(ENUM) \ + friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } +#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) +#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) +#define Q_ENUM_NS_IMPL(ENUM) \ + inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } +#define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) +#define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) +#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) +#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) +#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) +#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) +#endif // QT_NO_META_MACROS + +#ifndef QT_NO_TRANSLATION +// full set of tr functions +# define QT_TR_FUNCTIONS \ + static inline QString tr(const char *s, const char *c = nullptr, int n = -1) \ + { return staticMetaObject.tr(s, c, n); } \ + QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) \ + { return staticMetaObject.tr(s, c, n); } +#else +// inherit the ones from QObject +# define QT_TR_FUNCTIONS +#endif + +#ifdef Q_CLANG_QDOC +#define QT_TR_FUNCTIONS +#endif + +// ### Qt6: remove +#define Q_OBJECT_CHECK /* empty, unused since Qt 5.2 */ + +#if defined(Q_CC_INTEL) +// Cannot redefine the visibility of a method in an exported class +# define Q_DECL_HIDDEN_STATIC_METACALL +#else +# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN +#endif + +#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306 +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") +#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501 +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override") +#else +# define Q_OBJECT_NO_OVERRIDE_WARNING +#endif + +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600 +# define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes") +#else +# define Q_OBJECT_NO_ATTRIBUTES_WARNING +#endif + +/* qmake ignore Q_OBJECT */ +#define Q_OBJECT \ +public: \ + QT_WARNING_PUSH \ + Q_OBJECT_NO_OVERRIDE_WARNING \ + static const QMetaObject staticMetaObject; \ + virtual const QMetaObject *metaObject() const; \ + virtual void *qt_metacast(const char *); \ + virtual int qt_metacall(QMetaObject::Call, int, void **); \ + QT_TR_FUNCTIONS \ +private: \ + Q_OBJECT_NO_ATTRIBUTES_WARNING \ + Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ + QT_WARNING_POP \ + struct QPrivateSignal {}; \ + QT_ANNOTATE_CLASS(qt_qobject, "") + +/* qmake ignore Q_OBJECT */ +#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") + +#ifndef QT_NO_META_MACROS +/* qmake ignore Q_GADGET */ +#define Q_GADGET \ +public: \ + static const QMetaObject staticMetaObject; \ + void qt_check_for_QGADGET_macro(); \ + typedef void QtGadgetHelper; \ +private: \ + QT_WARNING_PUSH \ + Q_OBJECT_NO_ATTRIBUTES_WARNING \ + Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ + QT_WARNING_POP \ + QT_ANNOTATE_CLASS(qt_qgadget, "") \ + /*end*/ + +/* qmake ignore Q_NAMESPACE_EXPORT */ +#define Q_NAMESPACE_EXPORT(...) \ + extern __VA_ARGS__ const QMetaObject staticMetaObject; \ + QT_ANNOTATE_CLASS(qt_qnamespace, "") \ + /*end*/ + +/* qmake ignore Q_NAMESPACE */ +#define Q_NAMESPACE Q_NAMESPACE_EXPORT() \ + /*end*/ + +#endif // QT_NO_META_MACROS + +#else // Q_MOC_RUN +#define slots slots +#define signals signals +#define Q_SLOTS Q_SLOTS +#define Q_SIGNALS Q_SIGNALS +#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) +#define Q_INTERFACES(x) Q_INTERFACES(x) +#define Q_PROPERTY(text) Q_PROPERTY(text) +#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text) +#define Q_REVISION(v) Q_REVISION(v) +#define Q_OVERRIDE(text) Q_OVERRIDE(text) +#define Q_ENUMS(x) Q_ENUMS(x) +#define Q_FLAGS(x) Q_FLAGS(x) +#define Q_ENUM(x) Q_ENUM(x) +#define Q_FLAGS(x) Q_FLAGS(x) + /* qmake ignore Q_OBJECT */ +#define Q_OBJECT Q_OBJECT + /* qmake ignore Q_OBJECT */ +#define Q_OBJECT_FAKE Q_OBJECT_FAKE + /* qmake ignore Q_GADGET */ +#define Q_GADGET Q_GADGET +#define Q_SCRIPTABLE Q_SCRIPTABLE +#define Q_INVOKABLE Q_INVOKABLE +#define Q_SIGNAL Q_SIGNAL +#define Q_SLOT Q_SLOT +#endif //Q_MOC_RUN + +QT_END_NAMESPACE + +#endif // QTMETAMACROS_H diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index ace3a4c9f3..a9bf934e79 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -194,7 +194,6 @@ static bool qualifiedNameEquals(const QByteArray &qualifiedName, const QByteArra void Generator::generateCode() { - bool isQt = (cdef->classname == "Qt"); bool isQObject = (cdef->classname == "QObject"); bool isConstructible = !cdef->constructorList.isEmpty(); @@ -452,7 +451,7 @@ void Generator::generateCode() // // Generate internal qt_static_metacall() function // - const bool hasStaticMetaCall = !isQt && + const bool hasStaticMetaCall = (cdef->hasQObject || !cdef->methodList.isEmpty() || !cdef->propertyList.isEmpty() || !cdef->constructorList.isEmpty()); if (hasStaticMetaCall) @@ -534,10 +533,7 @@ void Generator::generateCode() // // Finally create and initialize the static meta object // - if (isQt) - fprintf(out, "QT_INIT_METAOBJECT const QMetaObject QObject::staticQtMetaObject = { {\n"); - else - fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = { {\n", cdef->qualified.constData()); + fprintf(out, "QT_INIT_METAOBJECT const QMetaObject %s::staticMetaObject = { {\n", cdef->qualified.constData()); if (isQObject) fprintf(out, " nullptr,\n"); @@ -559,9 +555,6 @@ void Generator::generateCode() fprintf(out, " qt_meta_extradata_%s,\n", qualifiedClassNameIdentifier.constData()); fprintf(out, " nullptr\n} };\n\n"); - if(isQt) - return; - if (!cdef->hasQObject) return; -- cgit v1.2.3 From 2a887a517eaaa2c5324aecf3b919899b7a86ff4a Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@qt.io> Date: Fri, 6 Dec 2019 18:30:55 +0100 Subject: QCalendar: Optimize std::vector access As we assert on the size of the vector before accessing it, there is no point in using the checked at() method over operator[]. Besides, if at() throws, what are we going to do with the exception anyway. Incidentally, this also works around a compiler bug causing binary incompatibility in QtQml. Change-Id: I460e7514429daecabc304eb2c5f96ed715008b0a Fixes: QTBUG-80535 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/corelib/time/qcalendar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index d308aeba2b..6a4623ce92 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -100,7 +100,7 @@ struct Registry { if (id == QCalendar::System::User) { byId.push_back(calendar); } else { - Q_ASSERT(byId.at(size_t(id)) == nullptr); + Q_ASSERT(byId[size_t(id)] == nullptr); byId[size_t(id)] = calendar; } if (id == QCalendar::System::Gregorian) { @@ -618,7 +618,7 @@ const QCalendarBackend *QCalendarBackend::fromEnum(QCalendar::System system) if (calendarRegistry.isDestroyed() || system == QCalendar::System::User) return nullptr; Q_ASSERT(calendarRegistry->byId.size() >= size_t(system)); - if (auto *c = calendarRegistry->byId.at(size_t(system))) + if (auto *c = calendarRegistry->byId[size_t(system)]) return c; switch (system) { case QCalendar::System::Gregorian: -- cgit v1.2.3 From 4c3c63d4cbb81b38e88e06b72749e7e01497b6f1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Wed, 4 Dec 2019 09:49:34 +0100 Subject: QMetaType: add more static-less API In prevision to Qt6 which is going to discourrage the use of the integer id, add some missing API to the staticless QMetaType API: - Add a way to construct a QMetaType from a type without calling qMetaTypeId: QMetaType::fromType<T>() - Add equality operators - Add a QMetaType::name() function - Add a default constructor (by adding a default parameter to the existing ctor) Change-Id: I95487c1c31bdf0d773717daa9d5452cbced30673 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/kernel/qmetatype.cpp | 43 +++++++++++++++++++++++++++++++++++++++- src/corelib/kernel/qmetatype.h | 14 ++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 3f0b8900e4..af9a2e0dd2 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -506,6 +506,31 @@ struct DefinedTypesFilter { Destructs this object. */ +/*! + \fn template<typename T> QMetaType QMetaType::fromType() + \since 5.15 + + Returns the QMetaType corresponding to the type in the template parameter. +*/ + +/*! \fn bool operator==(const QMetaType &a, const QMetaType &b) + \since 5.15 + \relates QMetaType + \overload + + Returns \c true if the QMetaType \a a represents the same type + as the QMetaType \a b, otherwise returns \c false. +*/ + +/*! \fn bool operator!=(const QMetaType &a, const QMetaType &c) + \since 5.15 + \relates QMetaType + \overload + + Returns \c true if the QMetaType \a a represents a difference type + than the QMetaType \a b, otherwise returns \c false. +*/ + #define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName) \ { #RealName, sizeof(#RealName) - 1, MetaTypeId }, @@ -930,7 +955,7 @@ constexpr MetaTypeOffsets<QtPrivate::Indexes<QMetaType::HighestInternalId + 1>:: pointer if no matching type was found. The returned pointer must not be deleted. - \sa type(), isRegistered(), Type + \sa type(), isRegistered(), Type, name() */ const char *QMetaType::typeName(int typeId) { @@ -950,6 +975,20 @@ const char *QMetaType::typeName(int typeId) #undef QT_METATYPE_TYPEID_TYPENAME_CONVERTER } +/*! + \since 5.15 + + Returns the type name associated with this QMetaType, or a null + pointer if no matching type was found. The returned pointer must not be + deleted. + + \sa typeName() +*/ +QByteArray QMetaType::name() const +{ + return QMetaType::typeName(m_typeId); +} + /* Similar to QMetaType::type(), but only looks in the static set of types. */ @@ -2214,6 +2253,8 @@ QMetaType QMetaType::typeInfo(const int type) \since 5.0 Constructs a QMetaType object that contains all information about type \a typeId. + + \note: The default parameter was added in Qt 5.15 */ QMetaType::QMetaType(const int typeId) : m_typeId(typeId) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 240828bc9a..825f767425 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -572,7 +572,7 @@ public: static bool load(QDataStream &stream, int type, void *data); #endif - explicit QMetaType(const int type); // ### Qt6: drop const + explicit QMetaType(const int type = QMetaType::UnknownType); // ### Qt6: drop const inline ~QMetaType(); inline bool isValid() const; @@ -581,12 +581,24 @@ public: inline int sizeOf() const; inline TypeFlags flags() const; inline const QMetaObject *metaObject() const; + QT_PREPEND_NAMESPACE(QByteArray) name() const; inline void *create(const void *copy = nullptr) const; inline void destroy(void *data) const; inline void *construct(void *where, const void *copy = nullptr) const; inline void destruct(void *data) const; + template<typename T> + static QMetaType fromType() + { return QMetaType(qMetaTypeId<T>()); } + + friend bool operator==(const QMetaType &a, const QMetaType &b) + { return a.m_typeId == b.m_typeId; } + + friend bool operator!=(const QMetaType &a, const QMetaType &b) + { return a.m_typeId != b.m_typeId; } + + public: template<typename T> static bool registerComparators() -- cgit v1.2.3 From d7e7befe500931afce6dee00bea81ac85b32a69f Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Wed, 3 Dec 2014 11:43:57 -0800 Subject: Tell the compiler that QArrayData returns aligned pointers GCC 4.9 and later support the __attribute__((alloc_align)) attributes that indicate the alignment of the data. To make it work on GCC since 4.7 and Clang as of 3.6, we instead use __builtin_assume_aligned(). I don't know which version of ICC first implemented this, but ICC 15 does and it also reports itself as GCC 4.9. Change-Id: I58bd914b9bdd0ed3349ba56fa78220ab06114852 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydata.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 0063cf046f..94182a531c 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -218,16 +218,23 @@ struct QTypedArrayData AllocationOptions options = Default) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T), - alignof(AlignmentDummy), capacity, options)); + void *result = QArrayData::allocate(sizeof(T), + alignof(AlignmentDummy), capacity, options); +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) + result = __builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); +#endif + return static_cast<QTypedArrayData *>(result); } static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity, AllocationOptions options = Default) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - return static_cast<QTypedArrayData *>(QArrayData::reallocateUnaligned(data, sizeof(T), - capacity, options)); + void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options)); +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) + result =__builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); +#endif + return static_cast<QTypedArrayData *>(result); } static void deallocate(QArrayData *data) -- cgit v1.2.3 From 329ec3a268d636cc2cd4e403b5323c4d65723d33 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Thu, 6 Aug 2015 13:03:29 -0700 Subject: Tell the compiler that QArrayData::allocate allocates memory ICC, GCC and Clang support __attribute__((malloc)) that tells them that the function returns newly allocated memory which doesn't alias anything else. Though technically we may return memory that has already been used (the shared null or such), that should not be a problem. Change-Id: Id3d5c7bf4d4c45069621ffff13f7f81f8b08ea3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydata.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 94182a531c..a2d9901677 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -109,7 +109,11 @@ struct Q_CORE_EXPORT QArrayData return result; } - Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment, + Q_REQUIRED_RESULT +#if defined(Q_CC_GNU) + __attribute__((__malloc__)) +#endif + static QArrayData *allocate(size_t objectSize, size_t alignment, size_t capacity, AllocationOptions options = Default) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, size_t newCapacity, AllocationOptions newOptions = Default) noexcept; -- cgit v1.2.3 From 41287d355b9571db0fbdf5841b31595705af0102 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Fri, 11 Oct 2013 13:42:01 -0700 Subject: Add QArrayData::sharedNullData() Just to simplify a few operations, like detecting when a QChar* or char* coming from a QString or QByteArray, respectively, were null data. While you're not supposed to dereference the pointer returned by QVector::data() unless you know that the array is non-empty, that is permitted for QString and QByteArray. That is, QString().constData() must return a valid pointer to a null QChar. Change-Id: I80b4b62f203dc841e5c99c20c51d92ca576e4bfe Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydata.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a2d9901677..a91dd54262 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -122,6 +122,12 @@ struct Q_CORE_EXPORT QArrayData static const QArrayData shared_null[2]; static QArrayData *sharedNull() noexcept { return const_cast<QArrayData*>(shared_null); } + static void *sharedNullData() + { + QArrayData *const null = const_cast<QArrayData *>(&shared_null[1]); + Q_ASSERT(sharedNull()->data() == null); + return null; + } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::AllocationOptions) @@ -273,6 +279,12 @@ struct QTypedArrayData Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return allocate(/* capacity */ 0); } + + static T *sharedNullData() + { + Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + return static_cast<T *>(QArrayData::sharedNullData()); + } }; template <class T, size_t N> -- cgit v1.2.3 From bf0b4f332a2f1ec9860c610d98cd27e483869bec Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 4 Jun 2012 21:06:49 +0200 Subject: Rename QArrayData::AllocateOptions enum and update some flags Rename to QArrayData::ArrayOptions in preparation for these flags being in the array itself, instead of used just for allocating new ones. For that reason, rename QArrayData::Default to DefaultAllocationFlags. And introduce QArray::DefaultRawFlags to mean the flags needed for creating a raw (static) QArrayData. Also rename QArrayData::Grow to GrowsForward, so we may add GrowsBackward in the future. Change-Id: I536d9b34124f775d53cf810f62d6b0eaada8daef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.cpp | 16 ++++++++-------- src/corelib/text/qbytearray.h | 2 +- src/corelib/text/qstring.cpp | 2 +- src/corelib/tools/qarraydata.cpp | 6 +++--- src/corelib/tools/qarraydata.h | 32 +++++++++++++++++--------------- src/corelib/tools/qarraydatapointer.h | 2 +- src/corelib/tools/qvector.h | 20 ++++++++++---------- 7 files changed, 41 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 4a00c664c0..380730775d 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1776,7 +1776,7 @@ void QByteArray::resize(int size) d = x; } else { if (d->ref.isShared() || uint(size) + 1u > d->alloc) - reallocData(uint(size) + 1u, d->detachFlags() | Data::Grow); + reallocData(uint(size) + 1u, d->detachFlags() | Data::GrowsForward); if (d->alloc) { d->size = size; d->data()[size] = '\0'; @@ -1803,7 +1803,7 @@ QByteArray &QByteArray::fill(char ch, int size) return *this; } -void QByteArray::reallocData(uint alloc, Data::AllocationOptions options) +void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) { if (d->ref.isShared() || IS_RAW_DATA(d)) { Data *x = Data::allocate(alloc, options); @@ -1901,7 +1901,7 @@ QByteArray &QByteArray::prepend(const char *str, int len) { if (str) { if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) - reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); + reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memmove(d->data()+len, d->data(), d->size); memcpy(d->data(), str, len); d->size += len; @@ -1927,7 +1927,7 @@ QByteArray &QByteArray::prepend(const char *str, int len) QByteArray &QByteArray::prepend(char ch) { if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) - reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow); + reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); memmove(d->data()+1, d->data(), d->size); d->data()[0] = ch; ++d->size; @@ -1965,7 +1965,7 @@ QByteArray &QByteArray::append(const QByteArray &ba) *this = ba; } else if (ba.d->size != 0) { if (d->ref.isShared() || uint(d->size + ba.d->size) + 1u > d->alloc) - reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::Grow); + reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, ba.d->data(), ba.d->size); d->size += ba.d->size; d->data()[d->size] = '\0'; @@ -1997,7 +1997,7 @@ QByteArray& QByteArray::append(const char *str) if (str) { const int len = int(strlen(str)); if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) - reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); + reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, str, len + 1); // include null terminator d->size += len; } @@ -2022,7 +2022,7 @@ QByteArray &QByteArray::append(const char *str, int len) len = qstrlen(str); if (str && len) { if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) - reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::Grow); + reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, str, len); // include null terminator d->size += len; d->data()[d->size] = '\0'; @@ -2050,7 +2050,7 @@ QByteArray &QByteArray::append(const char *str, int len) QByteArray& QByteArray::append(char ch) { if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) - reallocData(uint(d->size) + 2u, d->detachFlags() | Data::Grow); + reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); d->data()[d->size++] = ch; d->data()[d->size] = '\0'; return *this; diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 1376e26260..4d56cd93fd 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -445,7 +445,7 @@ public: private: operator QNoImplicitBoolCast() const; Data *d; - void reallocData(uint alloc, Data::AllocationOptions options); + void reallocData(uint alloc, Data::ArrayOptions options); void expand(int i); QByteArray nulTerminated() const; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index dcdc87181e..5f5b0acd15 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2351,7 +2351,7 @@ void QString::reallocData(uint alloc, bool grow) { auto allocOptions = d->detachFlags(); if (grow) - allocOptions |= QArrayData::Grow; + allocOptions |= QArrayData::GrowsForward; if (d->ref.isShared() || IS_RAW_DATA(d)) { Data *x = Data::allocate(alloc, allocOptions); diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index ed7dfe2e41..592faf39c3 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -170,7 +170,7 @@ static inline size_t calculateBlockSize(size_t &capacity, size_t objectSize, siz // Calculate the byte size // allocSize = objectSize * capacity + headerSize, but checked for overflow // plus padded to grow in size - if (options & QArrayData::Grow) { + if (options & QArrayData::GrowsForward) { auto r = qCalculateGrowingBlockSize(capacity, objectSize, headerSize); capacity = r.elementCount; return r.size; @@ -188,7 +188,7 @@ static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint opt } QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options) noexcept + size_t capacity, ArrayOptions options) noexcept { // Alignment is a power of two Q_ASSERT(alignment >= alignof(QArrayData) @@ -227,7 +227,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, } QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t capacity, - AllocationOptions options) noexcept + ArrayOptions options) noexcept { Q_ASSERT(data); Q_ASSERT(data->isMutable()); diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index a91dd54262..c2da2767c3 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -76,15 +77,16 @@ struct Q_CORE_EXPORT QArrayData return alloc != 0; } - enum AllocationOption { + enum ArrayOption { CapacityReserved = 0x1, RawData = 0x4, - Grow = 0x8, + GrowsForward = 0x8, - Default = 0 + DefaultAllocationFlags = 0, + DefaultRawFlags = 0 }; - Q_DECLARE_FLAGS(AllocationOptions, AllocationOption) + Q_DECLARE_FLAGS(ArrayOptions, ArrayOption) size_t detachCapacity(size_t newSize) const { @@ -93,17 +95,17 @@ struct Q_CORE_EXPORT QArrayData return newSize; } - AllocationOptions detachFlags() const + ArrayOptions detachFlags() const { - AllocationOptions result; + ArrayOptions result; if (capacityReserved) result |= CapacityReserved; return result; } - AllocationOptions cloneFlags() const + ArrayOptions cloneFlags() const { - AllocationOptions result; + ArrayOptions result; if (capacityReserved) result |= CapacityReserved; return result; @@ -114,9 +116,9 @@ struct Q_CORE_EXPORT QArrayData __attribute__((__malloc__)) #endif static QArrayData *allocate(size_t objectSize, size_t alignment, - size_t capacity, AllocationOptions options = Default) noexcept; + size_t capacity, ArrayOptions options = DefaultAllocationFlags) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, - size_t newCapacity, AllocationOptions newOptions = Default) noexcept; + size_t newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept; static void deallocate(QArrayData *data, size_t objectSize, size_t alignment) noexcept; @@ -130,7 +132,7 @@ struct Q_CORE_EXPORT QArrayData } }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::AllocationOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::ArrayOptions) template <class T> struct QTypedArrayData @@ -225,7 +227,7 @@ struct QTypedArrayData class AlignmentDummy { QArrayData header; T data; }; Q_REQUIRED_RESULT static QTypedArrayData *allocate(size_t capacity, - AllocationOptions options = Default) + ArrayOptions options = DefaultAllocationFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); void *result = QArrayData::allocate(sizeof(T), @@ -237,10 +239,10 @@ struct QTypedArrayData } static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity, - AllocationOptions options = Default) + ArrayOptions options = DefaultAllocationFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options)); + void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options); #if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) result =__builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); #endif @@ -254,7 +256,7 @@ struct QTypedArrayData } static QTypedArrayData *fromRawData(const T *data, size_t n, - AllocationOptions options = Default) + ArrayOptions options = DefaultRawFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); QTypedArrayData *result = allocate(0, options | RawData); diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index b8a1ef5d68..ffeaff5862 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -155,7 +155,7 @@ public: } private: - Q_REQUIRED_RESULT Data *clone(QArrayData::AllocationOptions options) const + Q_REQUIRED_RESULT Data *clone(QArrayData::ArrayOptions options) const { Data *x = Data::allocate(d->detachCapacity(d->size), options); Q_CHECK_PTR(x); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 5def2eceb2..3220ba1463 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -307,9 +307,9 @@ public: private: // ### Qt6: remove methods, they are unused - void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); + void reallocData(const int size, const int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); void reallocData(const int sz) { reallocData(sz, d->alloc); } - void realloc(int alloc, QArrayData::AllocationOptions options = QArrayData::Default); + void realloc(int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); void freeData(Data *d); void defaultConstruct(T *from, T *to); void copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom); @@ -422,7 +422,7 @@ void QVector<T>::resize(int asize) if (asize == d->size) return detach(); if (asize > int(d->alloc) || !isDetached()) { // there is not enough space - QArrayData::AllocationOptions opt = asize > int(d->alloc) ? QArrayData::Grow : QArrayData::Default; + QArrayData::ArrayOptions opt = asize > int(d->alloc) ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags; realloc(qMax(int(d->alloc), asize), opt); } if (asize < d->size) @@ -580,7 +580,7 @@ QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant #endif template <typename T> -void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::AllocationOptions options) +void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::ArrayOptions options) { Q_ASSERT(asize >= 0 && asize <= aalloc); Data *x = d; @@ -680,7 +680,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo } template<typename T> -void QVector<T>::realloc(int aalloc, QArrayData::AllocationOptions options) +void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) { Q_ASSERT(aalloc >= d->size); Data *x = d; @@ -767,7 +767,7 @@ void QVector<T>::append(const T &t) const bool isTooSmall = uint(d->size + 1) > d->alloc; if (!isDetached() || isTooSmall) { T copy(t); - QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default); + QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); realloc(isTooSmall ? d->size + 1 : d->alloc, opt); if (QTypeInfo<T>::isComplex) @@ -789,7 +789,7 @@ void QVector<T>::append(T &&t) { const bool isTooSmall = uint(d->size + 1) > d->alloc; if (!isDetached() || isTooSmall) { - QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default); + QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); realloc(isTooSmall ? d->size + 1 : d->alloc, opt); } @@ -820,7 +820,7 @@ typename QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, c if (n != 0) { const T copy(t); if (!isDetached() || d->size + n > int(d->alloc)) - realloc(d->size + n, QArrayData::Grow); + realloc(d->size + n, QArrayData::GrowsForward); if (!QTypeInfoQuery<T>::isRelocatable) { T *b = d->end(); T *i = d->end() + n; @@ -853,7 +853,7 @@ typename QVector<T>::iterator QVector<T>::insert(iterator before, T &&t) const auto offset = std::distance(d->begin(), before); if (!isDetached() || d->size + 1 > int(d->alloc)) - realloc(d->size + 1, QArrayData::Grow); + realloc(d->size + 1, QArrayData::GrowsForward); if (!QTypeInfoQuery<T>::isRelocatable) { T *i = d->end(); T *j = i + 1; @@ -961,7 +961,7 @@ QVector<T> &QVector<T>::operator+=(const QVector &l) uint newSize = d->size + l.d->size; const bool isTooSmall = newSize > d->alloc; if (!isDetached() || isTooSmall) { - QArrayData::AllocationOptions opt(isTooSmall ? QArrayData::Grow : QArrayData::Default); + QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); realloc(isTooSmall ? newSize : d->alloc, opt); } -- cgit v1.2.3 From 64db4861bfcacc8849e8452b73d5c940d97aefd0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 4 Jun 2012 21:36:46 +0200 Subject: Replace QArrayData::capacityReserved with a full flags field Instead of stealing one bit from the alloc field, let's use a full 32-bit for the flags. The first flag to be in the field is the CapacityReserved (even though the allocate() function will store some others there, not relevant for now). This is done in preparation for the need for more flags necessary anyway. Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/kernel/qmetaobject.cpp | 1 - src/corelib/text/qbytearray.h | 8 ++------ src/corelib/text/qstring.h | 13 ++++--------- src/corelib/text/qstringliteral.h | 2 +- src/corelib/tools/qarraydata.cpp | 4 ++-- src/corelib/tools/qarraydata.h | 12 ++++++------ src/corelib/tools/qvector.h | 15 ++++----------- 7 files changed, 19 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 4484dfdce9..b51bb616b2 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -160,7 +160,6 @@ static inline const QByteArray stringData(const QMetaObject *mo, int index) const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; Q_ASSERT(data.ptr->ref.isStatic()); Q_ASSERT(data.ptr->alloc == 0); - Q_ASSERT(data.ptr->capacityReserved == 0); Q_ASSERT(data.ptr->size >= 0); return data; } diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 4d56cd93fd..2808494407 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -509,9 +509,7 @@ inline void QByteArray::reserve(int asize) if (d->ref.isShared() || uint(asize) + 1u > d->alloc) { reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved); } else { - // cannot set unconditionally, since d could be the shared_null or - // otherwise static - d->capacityReserved = true; + d->flags |= Data::CapacityReserved; } } @@ -520,9 +518,7 @@ inline void QByteArray::squeeze() if (d->ref.isShared() || uint(d->size) + 1u < d->alloc) { reallocData(uint(d->size) + 1u, d->detachFlags() & ~Data::CapacityReserved); } else { - // cannot set unconditionally, since d could be shared_null or - // otherwise static. - d->capacityReserved = false; + d->flags &= ~Data::CapacityReserved; } } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 4635962057..630a33c4ae 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1266,10 +1266,8 @@ inline void QString::reserve(int asize) if (d->ref.isShared() || uint(asize) >= d->alloc) reallocData(qMax(asize, d->size) + 1u); - if (!d->capacityReserved) { - // cannot set unconditionally, since d could be the shared_null/shared_empty (which is const) - d->capacityReserved = true; - } + // we're not shared anymore, for sure + d->flags |= Data::CapacityReserved; } inline void QString::squeeze() @@ -1277,11 +1275,8 @@ inline void QString::squeeze() if (d->ref.isShared() || uint(d->size) + 1u < d->alloc) reallocData(uint(d->size) + 1u); - if (d->capacityReserved) { - // cannot set unconditionally, since d could be shared_null or - // otherwise static. - d->capacityReserved = false; - } + // we're not shared anymore, for sure + d->flags &= ~Data::CapacityReserved; } inline QString &QString::setUtf16(const ushort *autf16, int asize) diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 2a7e607c63..b407bf6bc0 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -75,7 +75,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, /**/ #define Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_REFCOUNT_INITIALIZE_STATIC, size, 0, 0, offset } \ + { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::DefaultAllocationFlags, size, 0, offset } \ /**/ #define Q_STATIC_STRING_DATA_HEADER_INITIALIZER(size) \ diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 592faf39c3..ce6f138497 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -183,7 +183,7 @@ static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint opt { header = static_cast<QArrayData *>(::realloc(header, allocSize)); if (header) - header->capacityReserved = bool(options & QArrayData::CapacityReserved); + header->flags = options; return header; } @@ -219,7 +219,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, header->ref.atomic.storeRelaxed(1); header->size = 0; header->alloc = capacity; - header->capacityReserved = bool(options & CapacityReserved); + header->flags = options; header->offset = data - quintptr(header); } diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index c2da2767c3..9a3b53338c 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -49,9 +49,9 @@ QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QArrayData { QtPrivate::RefCount ref; + uint flags; int size; - uint alloc : 31; - uint capacityReserved : 1; + uint alloc; qptrdiff offset; // in bytes from beginning of header @@ -90,7 +90,7 @@ struct Q_CORE_EXPORT QArrayData size_t detachCapacity(size_t newSize) const { - if (capacityReserved && newSize < alloc) + if (flags & CapacityReserved && newSize < alloc) return alloc; return newSize; } @@ -98,7 +98,7 @@ struct Q_CORE_EXPORT QArrayData ArrayOptions detachFlags() const { ArrayOptions result; - if (capacityReserved) + if (flags & CapacityReserved) result |= CapacityReserved; return result; } @@ -106,7 +106,7 @@ struct Q_CORE_EXPORT QArrayData ArrayOptions cloneFlags() const { ArrayOptions result; - if (capacityReserved) + if (flags & CapacityReserved) result |= CapacityReserved; return result; } @@ -304,7 +304,7 @@ struct QArrayDataPointerRef }; #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_REFCOUNT_INITIALIZE_STATIC, size, 0, 0, offset } \ + { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::DefaultAllocationFlags, size, 0, offset } \ /**/ #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 3220ba1463..d64673cc16 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -119,12 +119,7 @@ public: *this = QVector<T>(); return; } - realloc(d->size); - } - if (d->capacityReserved) { - // capacity reserved in a read only memory would be useless - // this checks avoid writing to such memory. - d->capacityReserved = 0; + realloc(d->size, QArrayData::ArrayOptions(d->flags)); } } @@ -376,10 +371,10 @@ inline QVector<T>::QVector(const QVector<T> &v) if (v.d->ref.ref()) { d = v.d; } else { - if (v.d->capacityReserved) { + if (v.d->flags & Data::CapacityReserved) { d = Data::allocate(v.d->alloc); Q_CHECK_PTR(d); - d->capacityReserved = true; + d->flags |= Data::CapacityReserved; } else { d = Data::allocate(v.d->size); Q_CHECK_PTR(d); @@ -412,7 +407,7 @@ void QVector<T>::reserve(int asize) if (asize > int(d->alloc)) realloc(asize); if (isDetached()) - d->capacityReserved = 1; + d->flags |= Data::CapacityReserved; Q_ASSERT(capacity() >= asize); } @@ -644,7 +639,6 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Arra Data::deallocate(x); QT_RETHROW; } - x->capacityReserved = d->capacityReserved; } else { Q_ASSERT(int(d->alloc) == aalloc); // resize, without changing allocation size Q_ASSERT(isDetached()); // can be done only on detached d @@ -723,7 +717,6 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) Data::deallocate(x); QT_RETHROW; } - x->capacityReserved = d->capacityReserved; Q_ASSERT(d != x); if (!d->ref.deref()) { -- cgit v1.2.3 From 8fb45ae5b8b8ad276aeb9bc9e40f351f47523087 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 4 Jun 2012 22:04:13 +0200 Subject: Introduce QArrayData::allocatedCapacity() and use it instead of d->alloc In almost all cases, use d->allocatedCapacity() or d->constAllocatedCapacity() instead of d->alloc, since they do the same thing (right now). In the future, the functions will be changed. There is a separate const version because most const code should not need to know the allocation size -- only mutating code should need to know that There are a few cases where d->alloc was replaced with a better alternative, like d->size. The one case that remains in the code will be replaced by a different test when it's available. Change-Id: I48135469db4caf150f82df93fff42d2309b23719 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/text/qbytearray.cpp | 26 +++++++++---------- src/corelib/text/qbytearray.h | 6 ++--- src/corelib/text/qstring.cpp | 16 ++++++------ src/corelib/text/qstring.h | 12 ++++----- src/corelib/tools/qarraydata.h | 14 ++++++++-- src/corelib/tools/qarraydataops.h | 18 ++++++------- src/corelib/tools/qvector.h | 53 +++++++++++++++++++------------------- 8 files changed, 79 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index b51bb616b2..d9feb76d04 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -159,7 +159,7 @@ static inline const QByteArray stringData(const QMetaObject *mo, int index) Q_ASSERT(priv(mo->d.data)->revision >= 7); const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; Q_ASSERT(data.ptr->ref.isStatic()); - Q_ASSERT(data.ptr->alloc == 0); + Q_ASSERT(data.ptr->allocatedCapacity() == 0); Q_ASSERT(data.ptr->size >= 0); return data; } diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 380730775d..d70977b841 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1207,9 +1207,9 @@ QByteArray &QByteArray::operator=(const char *str) x = Data::allocate(0); } else { const int len = int(strlen(str)); - const uint fullLen = len + 1; - if (d->ref.isShared() || fullLen > d->alloc - || (len < d->size && fullLen < uint(d->alloc >> 1))) + const int fullLen = len + 1; + if (d->ref.isShared() || fullLen > int(d->allocatedCapacity()) + || (len < d->size && fullLen < int(d->allocatedCapacity() >> 1))) reallocData(fullLen, d->detachFlags()); x = d; memcpy(x->data(), str, fullLen); // include null terminator @@ -1775,9 +1775,9 @@ void QByteArray::resize(int size) x->data()[size] = '\0'; d = x; } else { - if (d->ref.isShared() || uint(size) + 1u > d->alloc) + if (d->ref.isShared() || size > capacity()) reallocData(uint(size) + 1u, d->detachFlags() | Data::GrowsForward); - if (d->alloc) { + if (d->allocatedCapacity()) { d->size = size; d->data()[size] = '\0'; } @@ -1900,7 +1900,7 @@ QByteArray &QByteArray::prepend(const char *str) QByteArray &QByteArray::prepend(const char *str, int len) { if (str) { - if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) + if (d->ref.isShared() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memmove(d->data()+len, d->data(), d->size); memcpy(d->data(), str, len); @@ -1926,7 +1926,7 @@ QByteArray &QByteArray::prepend(const char *str, int len) QByteArray &QByteArray::prepend(char ch) { - if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) + if (d->ref.isShared() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); memmove(d->data()+1, d->data(), d->size); d->data()[0] = ch; @@ -1964,7 +1964,7 @@ QByteArray &QByteArray::append(const QByteArray &ba) if (d->size == 0 && d->ref.isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.d->size != 0) { - if (d->ref.isShared() || uint(d->size + ba.d->size) + 1u > d->alloc) + if (d->ref.isShared() || d->size + ba.d->size > capacity()) reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, ba.d->data(), ba.d->size); d->size += ba.d->size; @@ -1996,7 +1996,7 @@ QByteArray& QByteArray::append(const char *str) { if (str) { const int len = int(strlen(str)); - if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) + if (d->ref.isShared() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, str, len + 1); // include null terminator d->size += len; @@ -2021,7 +2021,7 @@ QByteArray &QByteArray::append(const char *str, int len) if (len < 0) len = qstrlen(str); if (str && len) { - if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) + if (d->ref.isShared() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, str, len); // include null terminator d->size += len; @@ -2049,7 +2049,7 @@ QByteArray &QByteArray::append(const char *str, int len) QByteArray& QByteArray::append(char ch) { - if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) + if (d->ref.isShared() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); d->data()[d->size++] = ch; d->data()[d->size] = '\0'; @@ -2576,7 +2576,7 @@ QByteArray QByteArray::repeated(int times) const QByteArray result; result.reserve(resultSize); - if (result.d->alloc != uint(resultSize) + 1u) + if (result.capacity() != resultSize) return QByteArray(); // not enough memory memcpy(result.d->data(), d->data(), d->size); @@ -4469,7 +4469,7 @@ QByteArray QByteArray::fromRawData(const char *data, int size) */ QByteArray &QByteArray::setRawData(const char *data, uint size) { - if (d->ref.isShared() || d->alloc) { + if (d->ref.isShared() || d->allocatedCapacity()) { *this = fromRawData(data, size); } else { if (data) { diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 2808494407..c161e92743 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -502,11 +502,11 @@ inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) { d->ref.ref(); } inline int QByteArray::capacity() const -{ return d->alloc ? d->alloc - 1 : 0; } +{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline void QByteArray::reserve(int asize) { - if (d->ref.isShared() || uint(asize) + 1u > d->alloc) { + if (d->ref.isShared() || asize > capacity()) { reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved); } else { d->flags |= Data::CapacityReserved; @@ -515,7 +515,7 @@ inline void QByteArray::reserve(int asize) inline void QByteArray::squeeze() { - if (d->ref.isShared() || uint(d->size) + 1u < d->alloc) { + if (d->ref.isShared() || d->size < capacity()) { reallocData(uint(d->size) + 1u, d->detachFlags() & ~Data::CapacityReserved); } else { d->flags &= ~Data::CapacityReserved; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 5f5b0acd15..e00f2998b0 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2270,7 +2270,7 @@ void QString::resize(int size) return; } - if (d->ref.isShared() || uint(size) + 1u > d->alloc) + if (d->ref.isShared() || uint(size) + 1u > d->allocatedCapacity()) reallocData(uint(size) + 1u, true); if (d->alloc) { d->size = size; @@ -2592,7 +2592,7 @@ QString& QString::insert(int i, const QChar *unicode, int size) return *this; const ushort *s = (const ushort *)unicode; - if (s >= d->data() && s < d->data() + d->alloc) { + if (s >= d->data() && s < d->data() + d->size) { // Part of me - take a copy ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar))); Q_CHECK_PTR(tmp); @@ -2658,7 +2658,7 @@ QString &QString::append(const QString &str) if (d == Data::sharedNull()) { operator=(str); } else { - if (d->ref.isShared() || uint(d->size + str.d->size) + 1u > d->alloc) + if (d->ref.isShared() || d->size + str.d->size > capacity()) reallocData(uint(d->size + str.d->size) + 1u, true); memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar)); d->size += str.d->size; @@ -2677,7 +2677,7 @@ QString &QString::append(const QString &str) QString &QString::append(const QChar *str, int len) { if (str && len > 0) { - if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) + if (d->ref.isShared() || uint(d->size + len) + 1u > d->allocatedCapacity()) reallocData(uint(d->size + len) + 1u, true); memcpy(d->data() + d->size, str, len * sizeof(QChar)); d->size += len; @@ -2696,7 +2696,7 @@ QString &QString::append(QLatin1String str) const char *s = str.latin1(); if (s) { int len = str.size(); - if (d->ref.isShared() || uint(d->size + len) + 1u > d->alloc) + if (d->ref.isShared() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, true); ushort *i = d->data() + d->size; qt_from_latin1(i, s, uint(len)); @@ -2743,7 +2743,7 @@ QString &QString::append(QLatin1String str) */ QString &QString::append(QChar ch) { - if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) + if (d->ref.isShared() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, true); d->data()[d->size++] = ch.unicode(); d->data()[d->size] = '\0'; @@ -7954,7 +7954,7 @@ QString QString::repeated(int times) const QString result; result.reserve(resultSize); - if (result.d->alloc != uint(resultSize) + 1u) + if (result.capacity() != resultSize) return QString(); // not enough memory memcpy(result.d->data(), d->data(), d->size * sizeof(ushort)); @@ -9149,7 +9149,7 @@ QString QString::fromRawData(const QChar *unicode, int size) */ QString &QString::setRawData(const QChar *unicode, int size) { - if (d->ref.isShared() || d->alloc) { + if (d->ref.isShared() || d->allocatedCapacity()) { *this = fromRawData(unicode, size); } else { if (unicode) { diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 630a33c4ae..4d853bfc72 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -274,7 +274,7 @@ public: void truncate(int pos); void chop(int n); - int capacity() const; + inline int capacity() const; inline void reserve(int size); inline void squeeze(); @@ -542,7 +542,7 @@ public: inline QString &prepend(QLatin1String s) { return insert(0, s); } inline QString &operator+=(QChar c) { - if (d->ref.isShared() || uint(d->size) + 2u > d->alloc) + if (d->ref.isShared() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, true); d->data()[d->size++] = c.unicode(); d->data()[d->size] = '\0'; @@ -1049,7 +1049,7 @@ inline void QString::clear() inline QString::QString(const QString &other) noexcept : d(other.d) { Q_ASSERT(&other != this); d->ref.ref(); } inline int QString::capacity() const -{ return d->alloc ? d->alloc - 1 : 0; } +{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline QString &QString::setNum(short n, int base) { return setNum(qlonglong(n), base); } inline QString &QString::setNum(ushort n, int base) @@ -1263,8 +1263,8 @@ inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); } inline void QString::reserve(int asize) { - if (d->ref.isShared() || uint(asize) >= d->alloc) - reallocData(qMax(asize, d->size) + 1u); + if (d->ref.isShared() || asize >= capacity()) + reallocData(qMax(asize, size()) + 1u); // we're not shared anymore, for sure d->flags |= Data::CapacityReserved; @@ -1272,7 +1272,7 @@ inline void QString::reserve(int asize) inline void QString::squeeze() { - if (d->ref.isShared() || uint(d->size) + 1u < d->alloc) + if (d->ref.isShared() || d->size < capacity()) reallocData(uint(d->size) + 1u); // we're not shared anymore, for sure diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 9a3b53338c..feee557131 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -55,6 +55,16 @@ struct Q_CORE_EXPORT QArrayData qptrdiff offset; // in bytes from beginning of header + inline size_t allocatedCapacity() + { + return alloc; + } + + inline size_t constAllocatedCapacity() const + { + return alloc; + } + void *data() { Q_ASSERT(size == 0 @@ -90,8 +100,8 @@ struct Q_CORE_EXPORT QArrayData size_t detachCapacity(size_t newSize) const { - if (flags & CapacityReserved && newSize < alloc) - return alloc; + if (flags & CapacityReserved && newSize < constAllocatedCapacity()) + return constAllocatedCapacity(); return newSize; } diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 8e19525f07..7724049be8 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -63,7 +63,7 @@ struct QPodArrayOps Q_ASSERT(this->isMutable()); Q_ASSERT(!this->ref.isShared()); Q_ASSERT(newSize > uint(this->size)); - Q_ASSERT(newSize <= this->alloc); + Q_ASSERT(newSize <= this->allocatedCapacity()); ::memset(static_cast<void *>(this->end()), 0, (newSize - this->size) * sizeof(T)); this->size = int(newSize); @@ -74,7 +74,7 @@ struct QPodArrayOps Q_ASSERT(this->isMutable()); Q_ASSERT(!this->ref.isShared()); Q_ASSERT(b < e); - Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size)); + Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); ::memcpy(static_cast<void *>(this->end()), static_cast<const void *>(b), (e - b) * sizeof(T)); @@ -85,7 +85,7 @@ struct QPodArrayOps { Q_ASSERT(this->isMutable()); Q_ASSERT(!this->ref.isShared()); - Q_ASSERT(n <= this->alloc - uint(this->size)); + Q_ASSERT(n <= uint(this->allocatedCapacity() - this->size)); T *iter = this->end(); const T *const end = iter + n; @@ -119,7 +119,7 @@ struct QPodArrayOps Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end Q_ASSERT(b < e); Q_ASSERT(e <= where || b > this->end()); // No overlap - Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size)); + Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); ::memmove(static_cast<void *>(where + (e - b)), static_cast<void *>(where), (static_cast<const T*>(this->end()) - where) * sizeof(T)); @@ -150,7 +150,7 @@ struct QGenericArrayOps Q_ASSERT(this->isMutable()); Q_ASSERT(!this->ref.isShared()); Q_ASSERT(newSize > uint(this->size)); - Q_ASSERT(newSize <= this->alloc); + Q_ASSERT(newSize <= this->allocatedCapacity()); T *const begin = this->begin(); do { @@ -163,7 +163,7 @@ struct QGenericArrayOps Q_ASSERT(this->isMutable()); Q_ASSERT(!this->ref.isShared()); Q_ASSERT(b < e); - Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size)); + Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); T *iter = this->end(); for (; b != e; ++iter, ++b) { @@ -176,7 +176,7 @@ struct QGenericArrayOps { Q_ASSERT(this->isMutable()); Q_ASSERT(!this->ref.isShared()); - Q_ASSERT(n <= this->alloc - uint(this->size)); + Q_ASSERT(n <= size_t(this->allocatedCapacity() - this->size)); T *iter = this->end(); const T *const end = iter + n; @@ -220,7 +220,7 @@ struct QGenericArrayOps Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end Q_ASSERT(b < e); Q_ASSERT(e <= where || b > this->end()); // No overlap - Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size)); + Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); // Array may be truncated at where in case of exceptions @@ -316,7 +316,7 @@ struct QMovableArrayOps Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end Q_ASSERT(b < e); Q_ASSERT(e <= where || b > this->end()); // No overlap - Q_ASSERT(size_t(e - b) <= this->alloc - uint(this->size)); + Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); // Provides strong exception safety guarantee, // provided T::~T() nothrow diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index d64673cc16..2be7fa01e0 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -110,7 +110,7 @@ public: void resize(int size); - inline int capacity() const { return int(d->alloc); } + inline int capacity() const { return d->constAllocatedCapacity(); } void reserve(int size); inline void squeeze() { @@ -303,7 +303,7 @@ public: private: // ### Qt6: remove methods, they are unused void reallocData(const int size, const int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); - void reallocData(const int sz) { reallocData(sz, d->alloc); } + void reallocData(const int sz) { reallocData(sz, d->allocatedCapacity()); } void realloc(int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); void freeData(Data *d); void defaultConstruct(T *from, T *to); @@ -372,14 +372,14 @@ inline QVector<T>::QVector(const QVector<T> &v) d = v.d; } else { if (v.d->flags & Data::CapacityReserved) { - d = Data::allocate(v.d->alloc); + d = Data::allocate(v.d->allocatedCapacity()); Q_CHECK_PTR(d); d->flags |= Data::CapacityReserved; } else { d = Data::allocate(v.d->size); Q_CHECK_PTR(d); } - if (d->alloc) { + if (v.d->size) { copyConstruct(v.d->begin(), v.d->end(), d->begin()); d->size = v.d->size; } @@ -397,18 +397,18 @@ void QVector<T>::detach() return; if (!isDetached()) - realloc(int(d->alloc)); + realloc(d->allocatedCapacity()); Q_ASSERT(isDetached()); } template <typename T> void QVector<T>::reserve(int asize) { - if (asize > int(d->alloc)) - realloc(asize); - if (isDetached()) + if (asize > int(d->allocatedCapacity())) + realloc(asize, typename Data::ArrayOptions(d->flags | Data::CapacityReserved)); + else if (isDetached()) d->flags |= Data::CapacityReserved; - Q_ASSERT(capacity() >= asize); + Q_ASSERT(int(d->allocatedCapacity()) >= asize); } template <typename T> @@ -416,9 +416,10 @@ void QVector<T>::resize(int asize) { if (asize == d->size) return detach(); - if (asize > int(d->alloc) || !isDetached()) { // there is not enough space - QArrayData::ArrayOptions opt = asize > int(d->alloc) ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags; - realloc(qMax(int(d->alloc), asize), opt); + int oldAlloc = d->allocatedCapacity(); + if (asize > oldAlloc || !isDetached()) { // there is not enough space + QArrayData::ArrayOptions opt = asize > oldAlloc ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags; + realloc(qMax(oldAlloc, asize), opt); } if (asize < d->size) destruct(begin() + asize, end()); @@ -583,7 +584,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Arra const bool isShared = d->ref.isShared(); if (aalloc != 0) { - if (aalloc != int(d->alloc) || isShared) { + if (aalloc != int(d->allocatedCapacity()) || isShared) { QT_TRY { // allocate memory x = Data::allocate(aalloc, options); @@ -640,7 +641,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Arra QT_RETHROW; } } else { - Q_ASSERT(int(d->alloc) == aalloc); // resize, without changing allocation size + Q_ASSERT(int(d->allocatedCapacity()) == aalloc); // resize, without changing allocation size Q_ASSERT(isDetached()); // can be done only on detached d Q_ASSERT(x == d); // in this case we do not need to allocate anything if (asize <= d->size) { @@ -667,9 +668,9 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Arra } Q_ASSERT(d->data()); - Q_ASSERT(uint(d->size) <= d->alloc); + Q_ASSERT(d->size <= int(d->allocatedCapacity())); Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull()); - Q_ASSERT(d->alloc >= uint(aalloc)); + Q_ASSERT(int(d->allocatedCapacity()) >= aalloc); Q_ASSERT(d->size == asize); } @@ -757,11 +758,11 @@ Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const template <typename T> void QVector<T>::append(const T &t) { - const bool isTooSmall = uint(d->size + 1) > d->alloc; + const bool isTooSmall = d->size >= int(d->allocatedCapacity()); if (!isDetached() || isTooSmall) { T copy(t); QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); - realloc(isTooSmall ? d->size + 1 : d->alloc, opt); + realloc(isTooSmall ? d->size + 1 : d->allocatedCapacity(), opt); if (QTypeInfo<T>::isComplex) new (d->end()) T(std::move(copy)); @@ -780,10 +781,10 @@ void QVector<T>::append(const T &t) template <typename T> void QVector<T>::append(T &&t) { - const bool isTooSmall = uint(d->size + 1) > d->alloc; + const bool isTooSmall = uint(d->size + 1) > d->allocatedCapacity(); if (!isDetached() || isTooSmall) { QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); - realloc(isTooSmall ? d->size + 1 : d->alloc, opt); + realloc(isTooSmall ? d->size + 1 : d->allocatedCapacity(), opt); } new (d->end()) T(std::move(t)); @@ -795,7 +796,7 @@ template <typename T> void QVector<T>::removeLast() { Q_ASSERT(!isEmpty()); - Q_ASSERT(d->alloc); + Q_ASSERT(d->allocatedCapacity()); if (d->ref.isShared()) detach(); @@ -812,7 +813,7 @@ typename QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, c const auto offset = std::distance(d->begin(), before); if (n != 0) { const T copy(t); - if (!isDetached() || d->size + n > int(d->alloc)) + if (!isDetached() || d->size + n > int(d->allocatedCapacity())) realloc(d->size + n, QArrayData::GrowsForward); if (!QTypeInfoQuery<T>::isRelocatable) { T *b = d->end(); @@ -889,7 +890,7 @@ typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend) // FIXME we could do a proper realloc, which copy constructs only needed data. // FIXME we are about to delete data - maybe it is good time to shrink? // FIXME the shrink is also an issue in removeLast, that is just a copy + reduce of this. - if (d->alloc) { + if (d->allocatedCapacity()) { detach(); abegin = d->begin() + itemsUntouched; aend = abegin + itemsToErase; @@ -952,13 +953,13 @@ QVector<T> &QVector<T>::operator+=(const QVector &l) *this = l; } else { uint newSize = d->size + l.d->size; - const bool isTooSmall = newSize > d->alloc; + const bool isTooSmall = newSize > d->allocatedCapacity(); if (!isDetached() || isTooSmall) { QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); - realloc(isTooSmall ? newSize : d->alloc, opt); + realloc(isTooSmall ? newSize : d->allocatedCapacity(), opt); } - if (d->alloc) { + if (l.d->size) { T *w = d->begin() + newSize; T *i = l.d->end(); T *b = l.d->begin(); -- cgit v1.2.3 From f6a151024b03158bcf46dc86e346d4227f8ca9d4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 4 Jun 2012 22:31:26 +0200 Subject: Introduce flags to indicate the QArrayData type These flags allow us to determine what type of data QArrayData is carrying. There are currently only two supported types: - raw data type: constructed via fromRawData or static data - allocated data type: regular data done via heap allocation The QArrayData object is usually allocated on the heap, unless its own reference count is -1 (indicating static const QArrayData). Such object should have a type of RawDataType, since we can't call free(). Add GrowsBackward for completeness as well as the StaticDataFlags default for static data. Change-Id: Icc915a468a2acf2eae91a94e82451f852d382c92 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.cpp | 15 +++++------ src/corelib/text/qbytearray.h | 2 +- src/corelib/text/qstring.cpp | 17 +++++------- src/corelib/text/qstring.h | 2 +- src/corelib/text/qstringliteral.h | 2 +- src/corelib/tools/qarraydata.cpp | 57 +++++++++++++++++++++++++-------------- src/corelib/tools/qarraydata.h | 42 ++++++++++++++++++----------- 7 files changed, 79 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index d70977b841..fa328a6d26 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -63,7 +63,7 @@ #include <string.h> #include <stdlib.h> -#define IS_RAW_DATA(d) ((d)->offset != sizeof(QByteArrayData)) +#define IS_RAW_DATA(d) (!(d)->isMutable()) QT_BEGIN_NAMESPACE @@ -4469,16 +4469,13 @@ QByteArray QByteArray::fromRawData(const char *data, int size) */ QByteArray &QByteArray::setRawData(const char *data, uint size) { - if (d->ref.isShared() || d->allocatedCapacity()) { + if (!data || !size) { + clear(); + } else if (d->ref.isShared() || (d->flags & Data::RawDataType) == 0) { *this = fromRawData(data, size); } else { - if (data) { - d->size = size; - d->offset = data - reinterpret_cast<char *>(d); - } else { - d->offset = sizeof(QByteArrayData); - d->size = 0; - } + d->size = size; + d->offset = data - reinterpret_cast<char *>(d); } return *this; } diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index c161e92743..611cacc646 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -495,7 +495,7 @@ inline const char *QByteArray::data() const inline const char *QByteArray::constData() const { return d->data(); } inline void QByteArray::detach() -{ if (d->ref.isShared() || (d->offset != sizeof(QByteArrayData))) reallocData(uint(d->size) + 1u, d->detachFlags()); } +{ if (d->ref.isShared() || !d->isMutable()) reallocData(uint(d->size) + 1u, d->detachFlags()); } inline bool QByteArray::isDetached() const { return !d->ref.isShared(); } inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index e00f2998b0..d0f141e079 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -100,7 +100,7 @@ #define ULLONG_MAX quint64_C(18446744073709551615) #endif -#define IS_RAW_DATA(d) ((d)->offset != sizeof(QStringData)) +#define IS_RAW_DATA(d) (!(d)->isMutable()) QT_BEGIN_NAMESPACE @@ -2272,7 +2272,7 @@ void QString::resize(int size) if (d->ref.isShared() || uint(size) + 1u > d->allocatedCapacity()) reallocData(uint(size) + 1u, true); - if (d->alloc) { + if (d->flags & Data::AllocatedDataType) { d->size = size; d->data()[size] = '\0'; } @@ -9149,16 +9149,13 @@ QString QString::fromRawData(const QChar *unicode, int size) */ QString &QString::setRawData(const QChar *unicode, int size) { - if (d->ref.isShared() || d->allocatedCapacity()) { + if (!unicode || !size) { + clear(); + } else if (d->ref.isShared() || !IS_RAW_DATA(d)) { *this = fromRawData(unicode, size); } else { - if (unicode) { - d->size = size; - d->offset = reinterpret_cast<const char *>(unicode) - reinterpret_cast<char *>(d); - } else { - d->offset = sizeof(QStringData); - d->size = 0; - } + d->size = size; + d->offset = reinterpret_cast<const char *>(unicode) - reinterpret_cast<char *>(d); } return *this; } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 4d853bfc72..03d83eeab9 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1041,7 +1041,7 @@ inline QChar *QString::data() inline const QChar *QString::constData() const { return reinterpret_cast<const QChar*>(d->data()); } inline void QString::detach() -{ if (d->ref.isShared() || (d->offset != sizeof(QStringData))) reallocData(uint(d->size) + 1u); } +{ if (d->ref.isShared() || !d->isMutable()) reallocData(uint(d->size) + 1u); } inline bool QString::isDetached() const { return !d->ref.isShared(); } inline void QString::clear() diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index b407bf6bc0..796909dcab 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -75,7 +75,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, /**/ #define Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::DefaultAllocationFlags, size, 0, offset } \ + { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, size, 0, offset } \ /**/ #define Q_STATIC_STRING_DATA_HEADER_INITIALIZER(size) \ diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index ce6f138497..bc48619349 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -153,17 +153,17 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") const QArrayData QArrayData::shared_null[2] = { - { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, sizeof(QArrayData) }, // shared null + { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared null /* zero initialized terminator */}; -static const QArrayData qt_array[3] = { - { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, sizeof(QArrayData) }, // shared empty - { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, sizeof(QArrayData) }, // unsharable empty +static const QArrayData emptyNotNullShared[2] = { + { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared empty /* zero initialized terminator */}; QT_WARNING_POP -static const QArrayData &qt_array_empty = qt_array[0]; +static const QArrayData &qt_array_empty = emptyNotNullShared[0]; + static inline size_t calculateBlockSize(size_t &capacity, size_t objectSize, size_t headerSize, uint options) { @@ -179,6 +179,17 @@ static inline size_t calculateBlockSize(size_t &capacity, size_t objectSize, siz } } +static QArrayData *allocateData(size_t allocSize, uint options) +{ + QArrayData *header = static_cast<QArrayData *>(::malloc(allocSize)); + if (header) { + header->ref.atomic.storeRelaxed(1); + header->flags = options; + header->size = 0; + } + return header; +} + static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint options) { header = static_cast<QArrayData *>(::realloc(header, allocSize)); @@ -194,38 +205,43 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, Q_ASSERT(alignment >= alignof(QArrayData) && !(alignment & (alignment - 1))); - // Don't allocate empty headers - if (!(options & RawData) && !capacity) + if (capacity == 0) + // optimization for empty headers return const_cast<QArrayData *>(&qt_array_empty); size_t headerSize = sizeof(QArrayData); - // Allocate extra (alignment - alignof(QArrayData)) padding bytes so we - // can properly align the data array. This assumes malloc is able to - // provide appropriate alignment for the header -- as it should! - // Padding is skipped when allocating a header for RawData. - if (!(options & RawData)) - headerSize += (alignment - alignof(QArrayData)); + if (alignment > alignof(QArrayData)) { + // Allocate extra (alignment - Q_ALIGNOF(QArrayData)) padding bytes so we + // can properly align the data array. This assumes malloc is able to + // provide appropriate alignment for the header -- as it should! + headerSize += alignment - alignof(QArrayData); + } if (headerSize > size_t(MaxAllocSize)) return nullptr; size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); - QArrayData *header = static_cast<QArrayData *>(::malloc(allocSize)); + options |= ArrayOption(AllocatedDataType); + QArrayData *header = allocateData(allocSize, options); if (header) { quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); - - header->ref.atomic.storeRelaxed(1); - header->size = 0; - header->alloc = capacity; - header->flags = options; header->offset = data - quintptr(header); + header->alloc = capacity; } return header; } +QArrayData *QArrayData::prepareRawData(ArrayOptions options) Q_DECL_NOTHROW +{ + QArrayData *header = allocateData(sizeof(QArrayData), (options & ~DataTypeBits) | RawDataType); + if (header) + header->alloc = 0; + return header; +} + QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t capacity, ArrayOptions options) noexcept { @@ -233,9 +249,10 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, Q_ASSERT(data->isMutable()); Q_ASSERT(!data->ref.isShared()); + options |= ArrayOption(AllocatedDataType); size_t headerSize = sizeof(QArrayData); size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); - QArrayData *header = static_cast<QArrayData *>(reallocateData(data, allocSize, options)); + QArrayData *header = reallocateData(data, allocSize, options); if (header) header->alloc = capacity; return header; diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index feee557131..babccc6017 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -48,6 +48,24 @@ QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QArrayData { + enum ArrayOption { + RawDataType = 0x0001, //!< this class is really a QArrayData + AllocatedDataType = 0x0002, //!< this class is really a QArrayAllocatedData + DataTypeBits = 0x000f, + + CapacityReserved = 0x0010, //!< the capacity was reserved by the user, try to keep it + GrowsForward = 0x0020, //!< allocate with eyes towards growing through append() + GrowsBackwards = 0x0040, //!< allocate with eyes towards growing through prepend() + + /// this option is used by the Q_ARRAY_LITERAL and similar macros + StaticDataFlags = RawDataType, + /// this option is used by the allocate() function + DefaultAllocationFlags = 0, + /// this option is used by the prepareRawData() function + DefaultRawFlags = 0 + }; + Q_DECLARE_FLAGS(ArrayOptions, ArrayOption) + QtPrivate::RefCount ref; uint flags; int size; @@ -84,20 +102,9 @@ struct Q_CORE_EXPORT QArrayData // follow COW principles. bool isMutable() const { - return alloc != 0; + return flags & AllocatedDataType; } - enum ArrayOption { - CapacityReserved = 0x1, - RawData = 0x4, - GrowsForward = 0x8, - - DefaultAllocationFlags = 0, - DefaultRawFlags = 0 - }; - - Q_DECLARE_FLAGS(ArrayOptions, ArrayOption) - size_t detachCapacity(size_t newSize) const { if (flags & CapacityReserved && newSize < constAllocatedCapacity()) @@ -107,7 +114,7 @@ struct Q_CORE_EXPORT QArrayData ArrayOptions detachFlags() const { - ArrayOptions result; + ArrayOptions result = DefaultAllocationFlags; if (flags & CapacityReserved) result |= CapacityReserved; return result; @@ -115,7 +122,7 @@ struct Q_CORE_EXPORT QArrayData ArrayOptions cloneFlags() const { - ArrayOptions result; + ArrayOptions result = DefaultAllocationFlags; if (flags & CapacityReserved) result |= CapacityReserved; return result; @@ -129,6 +136,8 @@ struct Q_CORE_EXPORT QArrayData size_t capacity, ArrayOptions options = DefaultAllocationFlags) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, size_t newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept; + Q_REQUIRED_RESULT static QArrayData *prepareRawData(ArrayOptions options = ArrayOptions(RawDataType)) + Q_DECL_NOTHROW; static void deallocate(QArrayData *data, size_t objectSize, size_t alignment) noexcept; @@ -269,7 +278,7 @@ struct QTypedArrayData ArrayOptions options = DefaultRawFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - QTypedArrayData *result = allocate(0, options | RawData); + QTypedArrayData *result = static_cast<QTypedArrayData *>(prepareRawData(options)); if (result) { Q_ASSERT(!result->ref.isShared()); // No shared empty, please! @@ -302,6 +311,7 @@ struct QTypedArrayData template <class T, size_t N> struct QStaticArrayData { + // static arrays are of type RawDataType QArrayData header; T data[N]; }; @@ -314,7 +324,7 @@ struct QArrayDataPointerRef }; #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::DefaultAllocationFlags, size, 0, offset } \ + { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, size, 0, offset } \ /**/ #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ -- cgit v1.2.3 From 551c665b7d3730e45e99dc87ccc144dd53f8e432 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Thu, 17 Oct 2019 15:47:41 +0200 Subject: Remove unused private method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3502c3c0451e7829fff0159a5d0891df34d04fe7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/tools/qvector.h | 102 -------------------------------------------- 1 file changed, 102 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 2be7fa01e0..8bd350e6eb 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -301,9 +301,6 @@ public: inline QVector<T> toVector() const { return *this; } private: - // ### Qt6: remove methods, they are unused - void reallocData(const int size, const int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); - void reallocData(const int sz) { reallocData(sz, d->allocatedCapacity()); } void realloc(int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); void freeData(Data *d); void defaultConstruct(T *from, T *to); @@ -575,105 +572,6 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant #endif -template <typename T> -void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::ArrayOptions options) -{ - Q_ASSERT(asize >= 0 && asize <= aalloc); - Data *x = d; - - const bool isShared = d->ref.isShared(); - - if (aalloc != 0) { - if (aalloc != int(d->allocatedCapacity()) || isShared) { - QT_TRY { - // allocate memory - x = Data::allocate(aalloc, options); - Q_CHECK_PTR(x); - // aalloc is bigger then 0 so it is not [un]sharedEmpty - Q_ASSERT(!x->ref.isStatic()); - x->size = asize; - - T *srcBegin = d->begin(); - T *srcEnd = asize > d->size ? d->end() : d->begin() + asize; - T *dst = x->begin(); - - if (!QTypeInfoQuery<T>::isRelocatable || (isShared && QTypeInfo<T>::isComplex)) { - QT_TRY { - if (isShared || !std::is_nothrow_move_constructible<T>::value) { - // we can not move the data, we need to copy construct it - while (srcBegin != srcEnd) - new (dst++) T(*srcBegin++); - } else { - while (srcBegin != srcEnd) - new (dst++) T(std::move(*srcBegin++)); - } - } QT_CATCH (...) { - // destruct already copied objects - destruct(x->begin(), dst); - QT_RETHROW; - } - } else { - ::memcpy(static_cast<void *>(dst), static_cast<void *>(srcBegin), (srcEnd - srcBegin) * sizeof(T)); - dst += srcEnd - srcBegin; - - // destruct unused / not moved data - if (asize < d->size) - destruct(d->begin() + asize, d->end()); - } - - if (asize > d->size) { - // construct all new objects when growing - if (!QTypeInfo<T>::isComplex) { - ::memset(static_cast<void *>(dst), 0, (static_cast<T *>(x->end()) - dst) * sizeof(T)); - } else { - QT_TRY { - while (dst != x->end()) - new (dst++) T(); - } QT_CATCH (...) { - // destruct already copied objects - destruct(x->begin(), dst); - QT_RETHROW; - } - } - } - } QT_CATCH (...) { - Data::deallocate(x); - QT_RETHROW; - } - } else { - Q_ASSERT(int(d->allocatedCapacity()) == aalloc); // resize, without changing allocation size - Q_ASSERT(isDetached()); // can be done only on detached d - Q_ASSERT(x == d); // in this case we do not need to allocate anything - if (asize <= d->size) { - destruct(x->begin() + asize, x->end()); // from future end to current end - } else { - defaultConstruct(x->end(), x->begin() + asize); // from current end to future end - } - x->size = asize; - } - } else { - x = Data::sharedNull(); - } - if (d != x) { - if (!d->ref.deref()) { - if (!QTypeInfoQuery<T>::isRelocatable || !aalloc || (isShared && QTypeInfo<T>::isComplex)) { - // data was copy constructed, we need to call destructors - // or if !alloc we did nothing to the old 'd'. - freeData(d); - } else { - Data::deallocate(d); - } - } - d = x; - } - - Q_ASSERT(d->data()); - Q_ASSERT(d->size <= int(d->allocatedCapacity())); - Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull()); - Q_ASSERT(int(d->allocatedCapacity()) >= aalloc); - Q_ASSERT(d->size == asize); -} - template<typename T> void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) { -- cgit v1.2.3 From cde2fde3f0ee1551b4907b3d8b82f0be5f20af25 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Thu, 14 Nov 2019 12:21:04 +0100 Subject: Fix a use-after-free problem in QByteArray::replace if the string pointed to by after is part of the QByteArray, we were trying to protect against a use-after-free by copying after. Unfortunately, it was not used later on in the code instead of the original after. Change-Id: I2f2263e4bb1855e802bba2fc08db34762c66887a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index fa328a6d26..d7fcfce90c 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2351,7 +2351,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after if (bsize == asize) { if (bsize) { while ((index = matcher.indexIn(*this, index)) != -1) { - memcpy(d + index, after, asize); + memcpy(d + index, a, asize); index += bsize; } } @@ -2370,7 +2370,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after to = index; } if (asize) { - memcpy(d + to, after, asize); + memcpy(d + to, a, asize); to += asize; } index += bsize; @@ -2422,7 +2422,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after int moveto = insertstart + asize; memmove(d + moveto, d + movestart, (moveend - movestart)); if (asize) - memcpy(d + insertstart, after, asize); + memcpy(d + insertstart, a, asize); moveend = movestart - bsize; } } -- cgit v1.2.3 From b6aa133cf556c962e666b8facc9ade9fab0dedbd Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 5 Jun 2012 18:04:38 +0200 Subject: Make the AllocOptions flag to QVector::reallocData mandatory This forces us to calculate the reallocation flags properly. Change-Id: I3486b193ad6732df666fc9ddad96831c9fbe068c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qvector.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 8bd350e6eb..9ef2ace471 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -301,7 +301,7 @@ public: inline QVector<T> toVector() const { return *this; } private: - void realloc(int alloc, QArrayData::ArrayOptions options = QArrayData::DefaultAllocationFlags); + void realloc(int alloc, QArrayData::ArrayOptions options); void freeData(Data *d); void defaultConstruct(T *from, T *to); void copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom); @@ -394,7 +394,7 @@ void QVector<T>::detach() return; if (!isDetached()) - realloc(d->allocatedCapacity()); + realloc(d->allocatedCapacity(), d->detachFlags()); Q_ASSERT(isDetached()); } @@ -415,7 +415,9 @@ void QVector<T>::resize(int asize) return detach(); int oldAlloc = d->allocatedCapacity(); if (asize > oldAlloc || !isDetached()) { // there is not enough space - QArrayData::ArrayOptions opt = asize > oldAlloc ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags; + QArrayData::ArrayOptions opt = d->detachFlags(); + if (asize > oldAlloc) + opt |= QArrayData::GrowsForward; realloc(qMax(oldAlloc, asize), opt); } if (asize < d->size) @@ -630,9 +632,9 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) d = x; Q_ASSERT(d->data()); - Q_ASSERT(uint(d->size) <= d->alloc); + Q_ASSERT(uint(d->size) <= d->allocatedCapacity()); Q_ASSERT(d != Data::sharedNull()); - Q_ASSERT(d->alloc >= uint(aalloc)); + Q_ASSERT(d->allocatedCapacity() >= uint(aalloc)); } #if defined(Q_CC_MSVC) @@ -657,9 +659,11 @@ template <typename T> void QVector<T>::append(const T &t) { const bool isTooSmall = d->size >= int(d->allocatedCapacity()); + QArrayData::ArrayOptions opt = d->detachFlags(); if (!isDetached() || isTooSmall) { T copy(t); - QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); + if (isTooSmall) + opt |= QArrayData::GrowsForward; realloc(isTooSmall ? d->size + 1 : d->allocatedCapacity(), opt); if (QTypeInfo<T>::isComplex) @@ -853,7 +857,7 @@ QVector<T> &QVector<T>::operator+=(const QVector &l) uint newSize = d->size + l.d->size; const bool isTooSmall = newSize > d->allocatedCapacity(); if (!isDetached() || isTooSmall) { - QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); + QArrayData::ArrayOptions opt(isTooSmall ? d->flags | QArrayData::GrowsForward : d->flags); realloc(isTooSmall ? newSize : d->allocatedCapacity(), opt); } @@ -951,7 +955,7 @@ Q_OUTOFLINE_TEMPLATE QVector<T> QVector<T>::mid(int pos, int len) const } QVector<T> midResult; - midResult.realloc(len); + midResult.realloc(len, QArrayData::DefaultAllocationFlags); T *srcFrom = d->begin() + pos; T *srcTo = d->begin() + pos + len; midResult.copyConstruct(srcFrom, srcTo, midResult.data()); -- cgit v1.2.3 From a3aa2fcfa72ab69bdbded26dcd43e37b35796a17 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 11 Jun 2012 18:45:02 +0200 Subject: Introduce the Mutable flag and move QArrayDataPointer::needsDetach The Mutable flag now contains the information on whether the data this QArrayData points to is mutable. This decouples the mutability / immutability setting from the allocation and from the type of data, opening the way for mutable raw or foreign data. There are still plenty of places in the source code that check the size of the allocation when it actually wants d->isMutable(). Fixing this will require reviewing all the code, so is left for later. The needsDetach() function is moved to QArrayData and de-constified. It returns true when a reallocation is necessary if the data is to be modified. Change-Id: I17e2bc5a3f6ef1f3eba8a205acd9852b95524f57 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.cpp | 24 ++++++++++++------------ src/corelib/text/qbytearray.h | 8 +++++--- src/corelib/text/qstring.cpp | 18 +++++++++--------- src/corelib/text/qstring.h | 10 ++++++---- src/corelib/tools/qarraydata.cpp | 3 ++- src/corelib/tools/qarraydata.h | 12 +++++++++++- src/corelib/tools/qarraydatapointer.h | 7 +------ src/corelib/tools/qvector.h | 3 ++- 8 files changed, 48 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index d7fcfce90c..da91a93700 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -63,7 +63,7 @@ #include <string.h> #include <stdlib.h> -#define IS_RAW_DATA(d) (!(d)->isMutable()) +#define IS_RAW_DATA(d) ((d)->flags & QArrayData::RawDataType) QT_BEGIN_NAMESPACE @@ -1208,7 +1208,7 @@ QByteArray &QByteArray::operator=(const char *str) } else { const int len = int(strlen(str)); const int fullLen = len + 1; - if (d->ref.isShared() || fullLen > int(d->allocatedCapacity()) + if (d->needsDetach() || fullLen > int(d->allocatedCapacity()) || (len < d->size && fullLen < int(d->allocatedCapacity() >> 1))) reallocData(fullLen, d->detachFlags()); x = d; @@ -1755,7 +1755,7 @@ void QByteArray::resize(int size) if (size < 0) size = 0; - if (IS_RAW_DATA(d) && !d->ref.isShared() && size < d->size) { + if (!d->ref.isShared() && !d->isMutable() && size < d->size) { d->size = size; return; } @@ -1775,9 +1775,9 @@ void QByteArray::resize(int size) x->data()[size] = '\0'; d = x; } else { - if (d->ref.isShared() || size > capacity()) + if (d->needsDetach() || size > capacity()) reallocData(uint(size) + 1u, d->detachFlags() | Data::GrowsForward); - if (d->allocatedCapacity()) { + if (d->isMutable()) { d->size = size; d->data()[size] = '\0'; } @@ -1805,7 +1805,7 @@ QByteArray &QByteArray::fill(char ch, int size) void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) { - if (d->ref.isShared() || IS_RAW_DATA(d)) { + if (d->needsDetach()) { Data *x = Data::allocate(alloc, options); Q_CHECK_PTR(x); x->size = qMin(int(alloc) - 1, d->size); @@ -1900,7 +1900,7 @@ QByteArray &QByteArray::prepend(const char *str) QByteArray &QByteArray::prepend(const char *str, int len) { if (str) { - if (d->ref.isShared() || d->size + len > capacity()) + if (d->needsDetach() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memmove(d->data()+len, d->data(), d->size); memcpy(d->data(), str, len); @@ -1926,7 +1926,7 @@ QByteArray &QByteArray::prepend(const char *str, int len) QByteArray &QByteArray::prepend(char ch) { - if (d->ref.isShared() || d->size + 1 > capacity()) + if (d->needsDetach() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); memmove(d->data()+1, d->data(), d->size); d->data()[0] = ch; @@ -1964,7 +1964,7 @@ QByteArray &QByteArray::append(const QByteArray &ba) if (d->size == 0 && d->ref.isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.d->size != 0) { - if (d->ref.isShared() || d->size + ba.d->size > capacity()) + if (d->needsDetach() || d->size + ba.d->size > capacity()) reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, ba.d->data(), ba.d->size); d->size += ba.d->size; @@ -1996,7 +1996,7 @@ QByteArray& QByteArray::append(const char *str) { if (str) { const int len = int(strlen(str)); - if (d->ref.isShared() || d->size + len > capacity()) + if (d->needsDetach() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, str, len + 1); // include null terminator d->size += len; @@ -2021,7 +2021,7 @@ QByteArray &QByteArray::append(const char *str, int len) if (len < 0) len = qstrlen(str); if (str && len) { - if (d->ref.isShared() || d->size + len > capacity()) + if (d->needsDetach() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); memcpy(d->data() + d->size, str, len); // include null terminator d->size += len; @@ -2049,7 +2049,7 @@ QByteArray &QByteArray::append(const char *str, int len) QByteArray& QByteArray::append(char ch) { - if (d->ref.isShared() || d->size + 1 > capacity()) + if (d->needsDetach() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); d->data()[d->size++] = ch; d->data()[d->size] = '\0'; diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 611cacc646..597bc8bcb3 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -495,7 +495,7 @@ inline const char *QByteArray::data() const inline const char *QByteArray::constData() const { return d->data(); } inline void QByteArray::detach() -{ if (d->ref.isShared() || !d->isMutable()) reallocData(uint(d->size) + 1u, d->detachFlags()); } +{ if (d->needsDetach()) reallocData(uint(d->size) + 1u, d->detachFlags()); } inline bool QByteArray::isDetached() const { return !d->ref.isShared(); } inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) @@ -506,7 +506,7 @@ inline int QByteArray::capacity() const inline void QByteArray::reserve(int asize) { - if (d->ref.isShared() || asize > capacity()) { + if (d->needsDetach() || asize > capacity()) { reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved); } else { d->flags |= Data::CapacityReserved; @@ -515,7 +515,9 @@ inline void QByteArray::reserve(int asize) inline void QByteArray::squeeze() { - if (d->ref.isShared() || d->size < capacity()) { + if ((d->flags & Data::CapacityReserved) == 0) + return; + if (d->needsDetach() || d->size < capacity()) { reallocData(uint(d->size) + 1u, d->detachFlags() & ~Data::CapacityReserved); } else { d->flags &= ~Data::CapacityReserved; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index d0f141e079..ab08d497bd 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -100,7 +100,7 @@ #define ULLONG_MAX quint64_C(18446744073709551615) #endif -#define IS_RAW_DATA(d) (!(d)->isMutable()) +#define IS_RAW_DATA(d) ((d)->flags & QArrayData::RawDataType) QT_BEGIN_NAMESPACE @@ -2265,14 +2265,14 @@ void QString::resize(int size) if (size < 0) size = 0; - if (IS_RAW_DATA(d) && !d->ref.isShared() && size < d->size) { + if (!d->ref.isShared() && !d->isMutable() && size < d->size) { d->size = size; return; } - if (d->ref.isShared() || uint(size) + 1u > d->allocatedCapacity()) + if (d->needsDetach() || size > capacity()) reallocData(uint(size) + 1u, true); - if (d->flags & Data::AllocatedDataType) { + if (d->isMutable()) { d->size = size; d->data()[size] = '\0'; } @@ -2353,7 +2353,7 @@ void QString::reallocData(uint alloc, bool grow) if (grow) allocOptions |= QArrayData::GrowsForward; - if (d->ref.isShared() || IS_RAW_DATA(d)) { + if (d->needsDetach()) { Data *x = Data::allocate(alloc, allocOptions); Q_CHECK_PTR(x); x->size = qMin(int(alloc) - 1, d->size); @@ -2658,7 +2658,7 @@ QString &QString::append(const QString &str) if (d == Data::sharedNull()) { operator=(str); } else { - if (d->ref.isShared() || d->size + str.d->size > capacity()) + if (d->needsDetach() || d->size + str.d->size > capacity()) reallocData(uint(d->size + str.d->size) + 1u, true); memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar)); d->size += str.d->size; @@ -2696,7 +2696,7 @@ QString &QString::append(QLatin1String str) const char *s = str.latin1(); if (s) { int len = str.size(); - if (d->ref.isShared() || d->size + len > capacity()) + if (d->needsDetach() || d->size + len > capacity()) reallocData(uint(d->size + len) + 1u, true); ushort *i = d->data() + d->size; qt_from_latin1(i, s, uint(len)); @@ -2743,7 +2743,7 @@ QString &QString::append(QLatin1String str) */ QString &QString::append(QChar ch) { - if (d->ref.isShared() || d->size + 1 > capacity()) + if (d->needsDetach() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, true); d->data()[d->size++] = ch.unicode(); d->data()[d->size] = '\0'; @@ -6457,7 +6457,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, const ushort *QString::utf16() const { - if (IS_RAW_DATA(d)) { + if (!d->isMutable()) { // ensure '\0'-termination for ::fromRawData strings const_cast<QString*>(this)->reallocData(uint(d->size) + 1u); } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 03d83eeab9..fd674284fe 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -542,7 +542,7 @@ public: inline QString &prepend(QLatin1String s) { return insert(0, s); } inline QString &operator+=(QChar c) { - if (d->ref.isShared() || d->size + 1 > capacity()) + if (d->needsDetach() || d->size + 1 > capacity()) reallocData(uint(d->size) + 2u, true); d->data()[d->size++] = c.unicode(); d->data()[d->size] = '\0'; @@ -1041,7 +1041,7 @@ inline QChar *QString::data() inline const QChar *QString::constData() const { return reinterpret_cast<const QChar*>(d->data()); } inline void QString::detach() -{ if (d->ref.isShared() || !d->isMutable()) reallocData(uint(d->size) + 1u); } +{ if (d->needsDetach()) reallocData(uint(d->size) + 1u); } inline bool QString::isDetached() const { return !d->ref.isShared(); } inline void QString::clear() @@ -1263,7 +1263,7 @@ inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); } inline void QString::reserve(int asize) { - if (d->ref.isShared() || asize >= capacity()) + if (d->needsDetach() || asize >= capacity()) reallocData(qMax(asize, size()) + 1u); // we're not shared anymore, for sure @@ -1272,7 +1272,9 @@ inline void QString::reserve(int asize) inline void QString::squeeze() { - if (d->ref.isShared() || d->size < capacity()) + if ((d->flags & Data::CapacityReserved) == 0) + return; + if (d->needsDetach() || d->size < capacity()) reallocData(uint(d->size) + 1u); // we're not shared anymore, for sure diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index bc48619349..3123d7467f 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -222,7 +222,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, return nullptr; size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); - options |= ArrayOption(AllocatedDataType); + options |= AllocatedDataType | Mutable; QArrayData *header = allocateData(allocSize, options); if (header) { quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) @@ -252,6 +252,7 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, options |= ArrayOption(AllocatedDataType); size_t headerSize = sizeof(QArrayData); size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); + options |= AllocatedDataType | Mutable; QArrayData *header = reallocateData(data, allocSize, options); if (header) header->alloc = capacity; diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index babccc6017..8c21fd55c8 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -56,6 +56,7 @@ struct Q_CORE_EXPORT QArrayData CapacityReserved = 0x0010, //!< the capacity was reserved by the user, try to keep it GrowsForward = 0x0020, //!< allocate with eyes towards growing through append() GrowsBackwards = 0x0040, //!< allocate with eyes towards growing through prepend() + Mutable = 0x0080, //!< the data can be changed; doesn't say anything about the header /// this option is used by the Q_ARRAY_LITERAL and similar macros StaticDataFlags = RawDataType, @@ -102,7 +103,16 @@ struct Q_CORE_EXPORT QArrayData // follow COW principles. bool isMutable() const { - return flags & AllocatedDataType; + return flags & Mutable; + } + + // Returns true if a detach is necessary before modifying the data + // This method is intentionally not const: if you want to know whether + // detaching is necessary, you should be in a non-const function already + bool needsDetach() + { + // ### optimize me -- this currently requires 3 conditionals! + return !isMutable() || ref.isShared(); } size_t detachCapacity(size_t newSize) const diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index ffeaff5862..b7236d485a 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -126,11 +126,6 @@ public: return d; } - bool needsDetach() const - { - return (!d->isMutable() || d->ref.isShared()); - } - void swap(QArrayDataPointer &other) noexcept { qSwap(d, other.d); @@ -144,7 +139,7 @@ public: bool detach() { - if (needsDetach()) { + if (d->needsDetach()) { Data *copy = clone(d->detachFlags()); QArrayDataPointer old(d); d = copy; diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 9ef2ace471..a596beedcf 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -390,10 +390,11 @@ inline QVector<T>::QVector(const QVector<T> &v) template <typename T> void QVector<T>::detach() { + // ### check whether this is still required if (d->ref.isStatic()) return; - if (!isDetached()) + if (d->needsDetach()) realloc(d->allocatedCapacity(), d->detachFlags()); Q_ASSERT(isDetached()); } -- cgit v1.2.3 From 62c673ccc6f81cee09a25f5acceec2768cea4672 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 11 Jun 2012 19:42:05 +0200 Subject: Add reference-count manipulation functions to QArrayData and hide ref The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/serialization/qbinaryjsonvalue.cpp | 8 ++++---- src/corelib/text/qbytearray.cpp | 22 +++++++++++----------- src/corelib/text/qbytearray.h | 8 ++++---- src/corelib/text/qstring.cpp | 14 +++++++------- src/corelib/text/qstring.h | 8 ++++---- src/corelib/text/qstringliteral.h | 2 +- src/corelib/tools/qarraydata.cpp | 6 +++--- src/corelib/tools/qarraydata.h | 26 +++++++++++++++++++++++--- src/corelib/tools/qarraydataops.h | 26 +++++++++++++------------- src/corelib/tools/qarraydatapointer.h | 4 ++-- src/corelib/tools/qvector.h | 20 ++++++++++---------- 12 files changed, 83 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index d9feb76d04..f093111a8c 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -158,7 +158,7 @@ static inline const QByteArray stringData(const QMetaObject *mo, int index) { Q_ASSERT(priv(mo->d.data)->revision >= 7); const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; - Q_ASSERT(data.ptr->ref.isStatic()); + Q_ASSERT(data.ptr->isStatic()); Q_ASSERT(data.ptr->allocatedCapacity() == 0); Q_ASSERT(data.ptr->size >= 0); return data; diff --git a/src/corelib/serialization/qbinaryjsonvalue.cpp b/src/corelib/serialization/qbinaryjsonvalue.cpp index 5e3a01ad38..46a1b80104 100644 --- a/src/corelib/serialization/qbinaryjsonvalue.cpp +++ b/src/corelib/serialization/qbinaryjsonvalue.cpp @@ -66,7 +66,7 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, case QJsonValue::String: { QString s = v.toString(parent); stringData = s.data_ptr(); - stringData->ref.ref(); + stringData->ref(); break; } case QJsonValue::Array: @@ -82,7 +82,7 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, QBinaryJsonValue::QBinaryJsonValue(QString string) : stringData(*reinterpret_cast<QStringData **>(&string)), t(QJsonValue::String) { - stringData->ref.ref(); + stringData->ref(); } QBinaryJsonValue::QBinaryJsonValue(const QBinaryJsonArray &a) @@ -101,7 +101,7 @@ QBinaryJsonValue::QBinaryJsonValue(const QBinaryJsonObject &o) QBinaryJsonValue::~QBinaryJsonValue() { - if (t == QJsonValue::String && stringData && !stringData->ref.deref()) + if (t == QJsonValue::String && stringData && !stringData->deref()) free(stringData); if (d && !d->ref.deref()) @@ -134,7 +134,7 @@ QString QBinaryJsonValue::toString() const { if (t != QJsonValue::String) return QString(); - stringData->ref.ref(); // the constructor below doesn't add a ref. + stringData->ref(); // the constructor below doesn't add a ref. QStringDataPtr holder = { stringData }; return QString(holder); } diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index da91a93700..78395a47e3 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1184,8 +1184,8 @@ QByteArray qUncompress(const uchar* data, int nbytes) */ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept { - other.d->ref.ref(); - if (!d->ref.deref()) + other.d->ref(); + if (!d->deref()) Data::deallocate(d); d = other.d; return *this; @@ -1215,8 +1215,8 @@ QByteArray &QByteArray::operator=(const char *str) memcpy(x->data(), str, fullLen); // include null terminator x->size = len; } - x->ref.ref(); - if (!d->ref.deref()) + x->ref(); + if (!d->deref()) Data::deallocate(d); d = x; return *this; @@ -1755,12 +1755,12 @@ void QByteArray::resize(int size) if (size < 0) size = 0; - if (!d->ref.isShared() && !d->isMutable() && size < d->size) { + if (!d->isShared() && !d->isMutable() && size < d->size) { d->size = size; return; } - if (d->size == 0 && d->ref.isStatic()) { + if (d->size == 0 && d->isStatic()) { // // Optimize the idiom: // QByteArray a; @@ -1811,7 +1811,7 @@ void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) x->size = qMin(int(alloc) - 1, d->size); ::memcpy(x->data(), d->data(), x->size); x->data()[x->size] = '\0'; - if (!d->ref.deref()) + if (!d->deref()) Data::deallocate(d); d = x; } else { @@ -1869,7 +1869,7 @@ QByteArray QByteArray::nulTerminated() const QByteArray &QByteArray::prepend(const QByteArray &ba) { - if (d->size == 0 && d->ref.isStatic() && !IS_RAW_DATA(ba.d)) { + if (d->size == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.d->size != 0) { QByteArray tmp = *this; @@ -1961,7 +1961,7 @@ QByteArray &QByteArray::prepend(char ch) QByteArray &QByteArray::append(const QByteArray &ba) { - if (d->size == 0 && d->ref.isStatic() && !IS_RAW_DATA(ba.d)) { + if (d->size == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.d->size != 0) { if (d->needsDetach() || d->size + ba.d->size > capacity()) @@ -3239,7 +3239,7 @@ QByteArray QByteArray::toUpper_helper(QByteArray &a) void QByteArray::clear() { - if (!d->ref.deref()) + if (!d->deref()) Data::deallocate(d); d = Data::sharedNull(); } @@ -4471,7 +4471,7 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) { if (!data || !size) { clear(); - } else if (d->ref.isShared() || (d->flags & Data::RawDataType) == 0) { + } else if (d->isShared() || (d->flags & Data::RawDataType) == 0) { *this = fromRawData(data, size); } else { d->size = size; diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 597bc8bcb3..e9e4eecd26 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -123,7 +123,7 @@ template<int N> struct QStaticByteArrayData QByteArrayData *data_ptr() const { - Q_ASSERT(ba.ref.isStatic()); + Q_ASSERT(ba.isStatic()); return const_cast<QByteArrayData *>(&ba); } }; @@ -469,7 +469,7 @@ public: Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options) inline QByteArray::QByteArray() noexcept : d(Data::sharedNull()) { } -inline QByteArray::~QByteArray() { if (!d->ref.deref()) Data::deallocate(d); } +inline QByteArray::~QByteArray() { if (!d->deref()) Data::deallocate(d); } inline int QByteArray::size() const { return d->size; } @@ -497,9 +497,9 @@ inline const char *QByteArray::constData() const inline void QByteArray::detach() { if (d->needsDetach()) reallocData(uint(d->size) + 1u, d->detachFlags()); } inline bool QByteArray::isDetached() const -{ return !d->ref.isShared(); } +{ return !d->isShared(); } inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) -{ d->ref.ref(); } +{ d->ref(); } inline int QByteArray::capacity() const { int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index ab08d497bd..3e9deba29a 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2265,7 +2265,7 @@ void QString::resize(int size) if (size < 0) size = 0; - if (!d->ref.isShared() && !d->isMutable() && size < d->size) { + if (!d->isShared() && !d->isMutable() && size < d->size) { d->size = size; return; } @@ -2359,7 +2359,7 @@ void QString::reallocData(uint alloc, bool grow) x->size = qMin(int(alloc) - 1, d->size); ::memcpy(x->data(), d->data(), x->size * sizeof(QChar)); x->data()[x->size] = 0; - if (!d->ref.deref()) + if (!d->deref()) Data::deallocate(d); d = x; } else { @@ -2391,8 +2391,8 @@ void QString::expand(int i) QString &QString::operator=(const QString &other) noexcept { - other.d->ref.ref(); - if (!d->ref.deref()) + other.d->ref(); + if (!d->deref()) Data::deallocate(d); d = other.d; return *this; @@ -2677,7 +2677,7 @@ QString &QString::append(const QString &str) QString &QString::append(const QChar *str, int len) { if (str && len > 0) { - if (d->ref.isShared() || uint(d->size + len) + 1u > d->allocatedCapacity()) + if (d->isShared() || uint(d->size + len) + 1u > d->allocatedCapacity()) reallocData(uint(d->size + len) + 1u, true); memcpy(d->data() + d->size, str, len * sizeof(QChar)); d->size += len; @@ -5372,7 +5372,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size) QString::Data *QString::fromAscii_helper(const char *str, int size) { QString s = fromUtf8(str, size); - s.d->ref.ref(); + s.d->ref(); return s.d; } @@ -9151,7 +9151,7 @@ QString &QString::setRawData(const QChar *unicode, int size) { if (!unicode || !size) { clear(); - } else if (d->ref.isShared() || !IS_RAW_DATA(d)) { + } else if (d->isShared() || !IS_RAW_DATA(d)) { *this = fromRawData(unicode, size); } else { d->size = size; diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index fd674284fe..bcc1200125 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2019 Intel Corporation. ** Copyright (C) 2019 Mail.ru Group. ** Contact: https://www.qt.io/licensing/ ** @@ -1043,11 +1043,11 @@ inline const QChar *QString::constData() const inline void QString::detach() { if (d->needsDetach()) reallocData(uint(d->size) + 1u); } inline bool QString::isDetached() const -{ return !d->ref.isShared(); } +{ return !d->isShared(); } inline void QString::clear() { if (!isNull()) *this = QString(); } inline QString::QString(const QString &other) noexcept : d(other.d) -{ Q_ASSERT(&other != this); d->ref.ref(); } +{ Q_ASSERT(&other != this); d->ref(); } inline int QString::capacity() const { int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline QString &QString::setNum(short n, int base) @@ -1259,7 +1259,7 @@ inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); } inline QString::QString() noexcept : d(Data::sharedNull()) {} -inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); } +inline QString::~QString() { if (!d->deref()) Data::deallocate(d); } inline void QString::reserve(int asize) { diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 796909dcab..7b4d2d04f5 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -94,7 +94,7 @@ struct QStaticStringData QStringData *data_ptr() const { - Q_ASSERT(str.ref.isStatic()); + Q_ASSERT(str.isStatic()); return const_cast<QStringData *>(static_cast<const QStringData*>(&str)); } }; diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 3123d7467f..fdd441c7de 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -183,7 +183,7 @@ static QArrayData *allocateData(size_t allocSize, uint options) { QArrayData *header = static_cast<QArrayData *>(::malloc(allocSize)); if (header) { - header->ref.atomic.storeRelaxed(1); + header->ref_.atomic.storeRelaxed(1); header->flags = options; header->size = 0; } @@ -247,7 +247,7 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, { Q_ASSERT(data); Q_ASSERT(data->isMutable()); - Q_ASSERT(!data->ref.isShared()); + Q_ASSERT(!data->isShared()); options |= ArrayOption(AllocatedDataType); size_t headerSize = sizeof(QArrayData); @@ -267,7 +267,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize, && !(alignment & (alignment - 1))); Q_UNUSED(objectSize) Q_UNUSED(alignment) - Q_ASSERT_X(data == 0 || !data->ref.isStatic(), "QArrayData::deallocate", + Q_ASSERT_X(data == 0 || !data->isStatic(), "QArrayData::deallocate", "Static data cannot be deleted"); ::free(data); } diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 8c21fd55c8..183cf9f002 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -67,7 +67,7 @@ struct Q_CORE_EXPORT QArrayData }; Q_DECLARE_FLAGS(ArrayOptions, ArrayOption) - QtPrivate::RefCount ref; + QtPrivate::RefCount ref_; uint flags; int size; uint alloc; @@ -84,6 +84,16 @@ struct Q_CORE_EXPORT QArrayData return alloc; } + bool ref() + { + return ref_.ref(); + } + + bool deref() + { + return ref_.deref(); + } + void *data() { Q_ASSERT(size == 0 @@ -106,13 +116,23 @@ struct Q_CORE_EXPORT QArrayData return flags & Mutable; } + bool isStatic() const + { + return ref_.isStatic(); + } + + bool isShared() const + { + return ref_.isShared(); + } + // Returns true if a detach is necessary before modifying the data // This method is intentionally not const: if you want to know whether // detaching is necessary, you should be in a non-const function already bool needsDetach() { // ### optimize me -- this currently requires 3 conditionals! - return !isMutable() || ref.isShared(); + return !isMutable() || isShared(); } size_t detachCapacity(size_t newSize) const @@ -290,7 +310,7 @@ struct QTypedArrayData Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); QTypedArrayData *result = static_cast<QTypedArrayData *>(prepareRawData(options)); if (result) { - Q_ASSERT(!result->ref.isShared()); // No shared empty, please! + Q_ASSERT(!result->isShared()); // No shared empty, please! result->offset = reinterpret_cast<const char *>(data) - reinterpret_cast<const char *>(result); diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 7724049be8..777f0d839f 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -61,7 +61,7 @@ struct QPodArrayOps void appendInitialize(size_t newSize) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(newSize > uint(this->size)); Q_ASSERT(newSize <= this->allocatedCapacity()); @@ -72,7 +72,7 @@ struct QPodArrayOps void copyAppend(const T *b, const T *e) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(b < e); Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); @@ -84,7 +84,7 @@ struct QPodArrayOps void copyAppend(size_t n, const T &t) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(n <= uint(this->allocatedCapacity() - this->size)); T *iter = this->end(); @@ -97,7 +97,7 @@ struct QPodArrayOps void truncate(size_t newSize) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(newSize < size_t(this->size)); this->size = int(newSize); @@ -106,7 +106,7 @@ struct QPodArrayOps void destroyAll() // Call from destructors, ONLY! { Q_ASSERT(this->isMutable()); - Q_ASSERT(this->ref.atomic.loadRelaxed() == 0); + Q_ASSERT(this->ref_.atomic.loadRelaxed() == 0); // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. @@ -115,7 +115,7 @@ struct QPodArrayOps void insert(T *where, const T *b, const T *e) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end Q_ASSERT(b < e); Q_ASSERT(e <= where || b > this->end()); // No overlap @@ -148,7 +148,7 @@ struct QGenericArrayOps void appendInitialize(size_t newSize) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(newSize > uint(this->size)); Q_ASSERT(newSize <= this->allocatedCapacity()); @@ -161,7 +161,7 @@ struct QGenericArrayOps void copyAppend(const T *b, const T *e) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(b < e); Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); @@ -175,7 +175,7 @@ struct QGenericArrayOps void copyAppend(size_t n, const T &t) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(n <= size_t(this->allocatedCapacity() - this->size)); T *iter = this->end(); @@ -189,7 +189,7 @@ struct QGenericArrayOps void truncate(size_t newSize) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(newSize < size_t(this->size)); const T *const b = this->begin(); @@ -204,7 +204,7 @@ struct QGenericArrayOps // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. - Q_ASSERT(this->ref.atomic.loadRelaxed() == 0); + Q_ASSERT(this->ref_.atomic.loadRelaxed() == 0); const T *const b = this->begin(); const T *i = this->end(); @@ -216,7 +216,7 @@ struct QGenericArrayOps void insert(T *where, const T *b, const T *e) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end Q_ASSERT(b < e); Q_ASSERT(e <= where || b > this->end()); // No overlap @@ -312,7 +312,7 @@ struct QMovableArrayOps void insert(T *where, const T *b, const T *e) { Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->ref.isShared()); + Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end Q_ASSERT(b < e); Q_ASSERT(e <= where || b > this->end()); // No overlap diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index b7236d485a..86997985d1 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -58,7 +58,7 @@ public: } QArrayDataPointer(const QArrayDataPointer &other) - : d(other.d->ref.ref() + : d(other.d->ref() ? other.d : other.clone(other.d->cloneFlags())) { @@ -109,7 +109,7 @@ public: ~QArrayDataPointer() { - if (!d->ref.deref()) { + if (!d->deref()) { if (d->isMutable()) (*this)->destroyAll(); Data::deallocate(d); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index a596beedcf..d9512ee90e 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -89,7 +89,7 @@ public: explicit QVector(int size); QVector(int size, const T &t); inline QVector(const QVector<T> &v); - inline ~QVector() { if (!d->ref.deref()) freeData(d); } + inline ~QVector() { if (!d->deref()) freeData(d); } QVector<T> &operator=(const QVector<T> &v); QVector(QVector<T> &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } QVector<T> &operator=(QVector<T> &&other) noexcept @@ -114,17 +114,17 @@ public: void reserve(int size); inline void squeeze() { - if (d->size < int(d->alloc)) { + if (d->size < int(d->allocatedCapacity())) { if (!d->size) { *this = QVector<T>(); return; } - realloc(d->size, QArrayData::ArrayOptions(d->flags)); + realloc(d->size, d->detachFlags()); } } inline void detach(); - inline bool isDetached() const { return !d->ref.isShared(); } + inline bool isDetached() const { return !d->isShared(); } inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; } @@ -365,7 +365,7 @@ void QVector<T>::destruct(T *from, T *to) template <typename T> inline QVector<T>::QVector(const QVector<T> &v) { - if (v.d->ref.ref()) { + if (v.d->ref()) { d = v.d; } else { if (v.d->flags & Data::CapacityReserved) { @@ -391,7 +391,7 @@ template <typename T> void QVector<T>::detach() { // ### check whether this is still required - if (d->ref.isStatic()) + if (d->isStatic()) return; if (d->needsDetach()) @@ -581,14 +581,14 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) Q_ASSERT(aalloc >= d->size); Data *x = d; - const bool isShared = d->ref.isShared(); + const bool isShared = d->isShared(); QT_TRY { // allocate memory x = Data::allocate(aalloc, options); Q_CHECK_PTR(x); // aalloc is bigger then 0 so it is not [un]sharedEmpty - Q_ASSERT(!x->ref.isStatic()); + Q_ASSERT(!x->isStatic()); x->size = d->size; T *srcBegin = d->begin(); @@ -621,7 +621,7 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) } Q_ASSERT(d != x); - if (!d->ref.deref()) { + if (!d->deref()) { if (!QTypeInfoQuery<T>::isRelocatable || !aalloc || (isShared && QTypeInfo<T>::isComplex)) { // data was copy constructed, we need to call destructors // or if !alloc we did nothing to the old 'd'. @@ -701,7 +701,7 @@ void QVector<T>::removeLast() Q_ASSERT(!isEmpty()); Q_ASSERT(d->allocatedCapacity()); - if (d->ref.isShared()) + if (d->isShared()) detach(); --d->size; if (QTypeInfo<T>::isComplex) -- cgit v1.2.3 From 812a611dc05e5facd036856625ccb9274fdcb117 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 11 Jun 2012 21:26:23 +0200 Subject: Stop using the reference counter to store data state Instead of using the reference count to store whether the data is sharable and whether the header is immutable, move the settings to the flags member. This allows us to save one comparison per deref() or needsDetach(). It also allows for the possibility of mutable data pointed to by a static header. Change-Id: Ie678a2ff2bb9bce73497cb6138b431c465b0f3bb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qstring.cpp | 2 +- src/corelib/text/qstringliteral.h | 2 +- src/corelib/tools/qarraydata.cpp | 13 +++++++------ src/corelib/tools/qarraydata.h | 27 +++++++++++++++++---------- src/corelib/tools/qarraydataops.h | 4 ++-- src/corelib/tools/qvector.h | 2 +- 6 files changed, 29 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 3e9deba29a..4d3f2016ac 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2677,7 +2677,7 @@ QString &QString::append(const QString &str) QString &QString::append(const QChar *str, int len) { if (str && len > 0) { - if (d->isShared() || uint(d->size + len) + 1u > d->allocatedCapacity()) + if (d->needsDetach() || uint(d->size + len) + 1u > d->allocatedCapacity()) reallocData(uint(d->size + len) + 1u, true); memcpy(d->data() + d->size, str, len * sizeof(QChar)); d->size += len; diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 7b4d2d04f5..a0d4ddc30b 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -75,7 +75,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, /**/ #define Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, size, 0, offset } \ + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, size, 0, offset } \ /**/ #define Q_STATIC_STRING_DATA_HEADER_INITIALIZER(size) \ diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index fdd441c7de..aa7fac15ef 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -153,11 +153,11 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") const QArrayData QArrayData::shared_null[2] = { - { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared null + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared null /* zero initialized terminator */}; static const QArrayData emptyNotNullShared[2] = { - { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared empty + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared empty /* zero initialized terminator */}; QT_WARNING_POP @@ -183,7 +183,7 @@ static QArrayData *allocateData(size_t allocSize, uint options) { QArrayData *header = static_cast<QArrayData *>(::malloc(allocSize)); if (header) { - header->ref_.atomic.storeRelaxed(1); + header->ref_.storeRelaxed(1); header->flags = options; header->size = 0; } @@ -222,7 +222,8 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, return nullptr; size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); - options |= AllocatedDataType | Mutable; + options |= AllocatedDataType | MutableData; + options &= ~ImmutableHeader; QArrayData *header = allocateData(allocSize, options); if (header) { quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) @@ -249,10 +250,10 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, Q_ASSERT(data->isMutable()); Q_ASSERT(!data->isShared()); - options |= ArrayOption(AllocatedDataType); size_t headerSize = sizeof(QArrayData); size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); - options |= AllocatedDataType | Mutable; + options |= AllocatedDataType | MutableData; + options &= ~ImmutableHeader; QArrayData *header = reallocateData(data, allocSize, options); if (header) header->alloc = capacity; diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 183cf9f002..56d61340f0 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -56,18 +56,19 @@ struct Q_CORE_EXPORT QArrayData CapacityReserved = 0x0010, //!< the capacity was reserved by the user, try to keep it GrowsForward = 0x0020, //!< allocate with eyes towards growing through append() GrowsBackwards = 0x0040, //!< allocate with eyes towards growing through prepend() - Mutable = 0x0080, //!< the data can be changed; doesn't say anything about the header + MutableData = 0x0080, //!< the data can be changed; doesn't say anything about the header + ImmutableHeader = 0x0100, //!< the header is static, it can't be changed /// this option is used by the Q_ARRAY_LITERAL and similar macros - StaticDataFlags = RawDataType, + StaticDataFlags = RawDataType | ImmutableHeader, /// this option is used by the allocate() function - DefaultAllocationFlags = 0, + DefaultAllocationFlags = MutableData, /// this option is used by the prepareRawData() function DefaultRawFlags = 0 }; Q_DECLARE_FLAGS(ArrayOptions, ArrayOption) - QtPrivate::RefCount ref_; + QBasicAtomicInt ref_; uint flags; int size; uint alloc; @@ -84,13 +85,19 @@ struct Q_CORE_EXPORT QArrayData return alloc; } + /// Returns true if sharing took place bool ref() { - return ref_.ref(); + if (!isStatic()) + ref_.ref(); + return true; } + /// Returns false if deallocation is necessary bool deref() { + if (isStatic()) + return true; return ref_.deref(); } @@ -113,17 +120,17 @@ struct Q_CORE_EXPORT QArrayData // follow COW principles. bool isMutable() const { - return flags & Mutable; + return flags & MutableData; } bool isStatic() const { - return ref_.isStatic(); + return flags & ImmutableHeader; } bool isShared() const { - return ref_.isShared(); + return ref_.loadRelaxed() != 1; } // Returns true if a detach is necessary before modifying the data @@ -131,7 +138,7 @@ struct Q_CORE_EXPORT QArrayData // detaching is necessary, you should be in a non-const function already bool needsDetach() { - // ### optimize me -- this currently requires 3 conditionals! + // requires two conditionals return !isMutable() || isShared(); } @@ -354,7 +361,7 @@ struct QArrayDataPointerRef }; #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_REFCOUNT_INITIALIZE_STATIC, QArrayData::StaticDataFlags, size, 0, offset } \ + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, size, 0, offset } \ /**/ #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 777f0d839f..11494a5f6f 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -106,7 +106,7 @@ struct QPodArrayOps void destroyAll() // Call from destructors, ONLY! { Q_ASSERT(this->isMutable()); - Q_ASSERT(this->ref_.atomic.loadRelaxed() == 0); + Q_ASSERT(this->ref_.loadRelaxed() == 0); // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. @@ -204,7 +204,7 @@ struct QGenericArrayOps // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. - Q_ASSERT(this->ref_.atomic.loadRelaxed() == 0); + Q_ASSERT(this->ref_.loadRelaxed() == 0); const T *const b = this->begin(); const T *i = this->end(); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index d9512ee90e..bf422e72d4 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -701,7 +701,7 @@ void QVector<T>::removeLast() Q_ASSERT(!isEmpty()); Q_ASSERT(d->allocatedCapacity()); - if (d->isShared()) + if (d->needsDetach()) detach(); --d->size; if (QTypeInfo<T>::isComplex) -- cgit v1.2.3 From 8f3189f7a266abf29f241551f72f24027de18287 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Wed, 13 Jun 2012 13:58:53 +0200 Subject: Add the QArrayDataOps::parameter_type typedef It's a typedef meant to replace the "const T &" parameters (hence the name). But it's actually just a T for POD types, so we don't create references to them. Change-Id: I10c746d5e852c957ec84319712597478c4dc872c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydataops.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 11494a5f6f..5b59221f10 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -58,6 +58,8 @@ template <class T> struct QPodArrayOps : QTypedArrayData<T> { + typedef T parameter_type; + void appendInitialize(size_t newSize) { Q_ASSERT(this->isMutable()); @@ -81,7 +83,7 @@ struct QPodArrayOps this->size += e - b; } - void copyAppend(size_t n, const T &t) + void copyAppend(size_t n, parameter_type t) { Q_ASSERT(this->isMutable()); Q_ASSERT(!this->isShared()); @@ -145,6 +147,8 @@ template <class T> struct QGenericArrayOps : QTypedArrayData<T> { + typedef const T ¶meter_type; + void appendInitialize(size_t newSize) { Q_ASSERT(this->isMutable()); @@ -172,7 +176,7 @@ struct QGenericArrayOps } } - void copyAppend(size_t n, const T &t) + void copyAppend(size_t n, parameter_type t) { Q_ASSERT(this->isMutable()); Q_ASSERT(!this->isShared()); -- cgit v1.2.3 From f2569c0ff75eb9a8418bb065c33c318f0a44c8ed Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 10 Aug 2015 15:15:07 -0700 Subject: Add QArrayDataOps::moveAppend() Same as copyAppend() but calls the move constructor Change-Id: I7de033f80b0e4431b7f1ffff13f9399e39b5fee4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydataops.h | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 5b59221f10..ac7fc7bc4e 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -83,6 +83,9 @@ struct QPodArrayOps this->size += e - b; } + void moveAppend(T *b, T *e) + { copyAppend(b, e); } + void copyAppend(size_t n, parameter_type t) { Q_ASSERT(this->isMutable()); @@ -176,6 +179,20 @@ struct QGenericArrayOps } } + void moveAppend(T *b, T *e) + { + Q_ASSERT(this->isMutable() || b == e); + Q_ASSERT(!this->isShared() || b == e); + Q_ASSERT(b <= e); + Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + + T *iter = this->end(); + for (; b != e; ++iter, ++b) { + new (iter) T(std::move(*b)); + ++this->size; + } + } + void copyAppend(size_t n, parameter_type t) { Q_ASSERT(this->isMutable()); @@ -414,6 +431,45 @@ struct QMovableArrayOps (--e)->~T(); } while (e != b); } + + void moveAppend(T *b, T *e) + { + Q_ASSERT(this->isMutable()); + Q_ASSERT(!this->isShared()); + Q_ASSERT(b <= e); + Q_ASSERT(e <= this->begin() || b > this->end()); // No overlap + Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + + // Provides strong exception safety guarantee, + // provided T::~T() nothrow + + struct CopyConstructor + { + CopyConstructor(T *w) : where(w) {} + + void copy(const T *src, const T *const srcEnd) + { + n = 0; + for (; src != srcEnd; ++src) { + new (where + n) T(std::move(*src)); + ++n; + } + n = 0; + } + + ~CopyConstructor() + { + while (n) + where[--n].~T(); + } + + T *const where; + size_t n; + } copier(this->end()); + + copier.copy(b, e); + this->size += (e - b); + } }; template <class T, class = void> -- cgit v1.2.3 From add048bc4eee8e4422fe2b434b4b817f56693d33 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Thu, 14 Jun 2012 15:05:34 +0200 Subject: Start moving QArrayData's size and data pointer to the main class This requires that the allocation functions return two pointers: the d pointer and the pointer to the actual data. Ported QArrayDataPointer & SimpleVector to the inlined size & data. For now, the size and offset members are not yet removed from QArrayData, to let QVector, QByteArray and QString compile unmodified. Change-Id: I8489300976723d75b8fd5831427b1e2bba486196 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.cpp | 29 +++++---- src/corelib/text/qstring.cpp | 28 ++++---- src/corelib/tools/qarraydata.cpp | 29 ++++++--- src/corelib/tools/qarraydata.h | 81 ++++++++++++----------- src/corelib/tools/qarraydataops.h | 6 +- src/corelib/tools/qarraydatapointer.h | 118 +++++++++++++++++++++++++--------- src/corelib/tools/qvector.h | 20 +++--- 7 files changed, 194 insertions(+), 117 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 78395a47e3..7562227d7d 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -731,7 +731,7 @@ QByteArray qUncompress(const uchar* data, int nbytes) return invalidCompressedData(); } - QScopedPointer<QByteArray::Data, QByteArrayDataDeleter> d(QByteArray::Data::allocate(expectedSize + 1)); + QScopedPointer<QByteArray::Data, QByteArrayDataDeleter> d(QByteArray::Data::allocate(expectedSize + 1).first); if (Q_UNLIKELY(d.data() == nullptr)) return invalidCompressedData(); @@ -764,7 +764,8 @@ QByteArray qUncompress(const uchar* data, int nbytes) return invalidCompressedData(); } else { // grow the block - QByteArray::Data *p = QByteArray::Data::reallocateUnaligned(d.data(), len + 1); + char *dataPointer = d->data(); + QByteArray::Data *p = QByteArray::Data::reallocateUnaligned(d.data(), dataPointer, len + 1).first; if (Q_UNLIKELY(p == nullptr)) return invalidCompressedData(); d.take(); // don't free @@ -1204,7 +1205,7 @@ QByteArray &QByteArray::operator=(const char *str) if (!str) { x = Data::sharedNull(); } else if (!*str) { - x = Data::allocate(0); + x = Data::allocate(0).first; } else { const int len = int(strlen(str)); const int fullLen = len + 1; @@ -1693,9 +1694,9 @@ QByteArray::QByteArray(const char *data, int size) if (size < 0) size = int(strlen(data)); if (!size) { - d = Data::allocate(0); + d = Data::allocate(0).first; } else { - d = Data::allocate(uint(size) + 1u); + d = Data::allocate(uint(size) + 1u).first; Q_CHECK_PTR(d); d->size = size; memcpy(d->data(), data, size); @@ -1714,9 +1715,9 @@ QByteArray::QByteArray(const char *data, int size) QByteArray::QByteArray(int size, char ch) { if (size <= 0) { - d = Data::allocate(0); + d = Data::allocate(0).first; } else { - d = Data::allocate(uint(size) + 1u); + d = Data::allocate(uint(size) + 1u).first; Q_CHECK_PTR(d); d->size = size; memset(d->data(), ch, size); @@ -1732,7 +1733,7 @@ QByteArray::QByteArray(int size, char ch) QByteArray::QByteArray(int size, Qt::Initialization) { - d = Data::allocate(uint(size) + 1u); + d = Data::allocate(uint(size) + 1u).first; Q_CHECK_PTR(d); d->size = size; d->data()[size] = '\0'; @@ -1769,7 +1770,7 @@ void QByteArray::resize(int size) // which is used in place of the Qt 3 idiom: // QByteArray a(sz); // - Data *x = Data::allocate(uint(size) + 1u); + Data *x = Data::allocate(uint(size) + 1u).first; Q_CHECK_PTR(x); x->size = size; x->data()[size] = '\0'; @@ -1806,7 +1807,7 @@ QByteArray &QByteArray::fill(char ch, int size) void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) { if (d->needsDetach()) { - Data *x = Data::allocate(alloc, options); + Data *x = Data::allocate(alloc, options).first; Q_CHECK_PTR(x); x->size = qMin(int(alloc) - 1, d->size); ::memcpy(x->data(), d->data(), x->size); @@ -1815,7 +1816,7 @@ void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) Data::deallocate(d); d = x; } else { - Data *x = Data::reallocateUnaligned(d, alloc, options); + Data *x = Data::reallocateUnaligned(d, d->data(), alloc, options).first; Q_CHECK_PTR(x); d = x; } @@ -3130,7 +3131,7 @@ QByteArray QByteArray::mid(int pos, int len) const return QByteArray(); case QContainerImplHelper::Empty: { - QByteArrayDataPtr empty = { Data::allocate(0) }; + QByteArrayDataPtr empty = { Data::allocate(0).first }; return QByteArray(empty); } case QContainerImplHelper::Full: @@ -4444,9 +4445,9 @@ QByteArray QByteArray::fromRawData(const char *data, int size) if (!data) { x = Data::sharedNull(); } else if (!size) { - x = Data::allocate(0); + x = Data::allocate(0).first; } else { - x = Data::fromRawData(data, size); + x = Data::fromRawData(data, size).ptr; Q_CHECK_PTR(x); } QByteArrayDataPtr dataPtr = { x }; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 4d3f2016ac..8ae365338d 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2109,9 +2109,9 @@ QString::QString(const QChar *unicode, int size) ++size; } if (!size) { - d = Data::allocate(0); + d = Data::allocate(0).first; } else { - d = Data::allocate(size + 1); + d = Data::allocate(size + 1).first; Q_CHECK_PTR(d); d->size = size; memcpy(d->data(), unicode, size * sizeof(QChar)); @@ -2129,9 +2129,9 @@ QString::QString(const QChar *unicode, int size) QString::QString(int size, QChar ch) { if (size <= 0) { - d = Data::allocate(0); + d = Data::allocate(0).first; } else { - d = Data::allocate(size + 1); + d = Data::allocate(size + 1).first; Q_CHECK_PTR(d); d->size = size; d->data()[size] = '\0'; @@ -2151,7 +2151,7 @@ QString::QString(int size, QChar ch) */ QString::QString(int size, Qt::Initialization) { - d = Data::allocate(size + 1); + d = Data::allocate(size + 1).first; Q_CHECK_PTR(d); d->size = size; d->data()[size] = '\0'; @@ -2169,7 +2169,7 @@ QString::QString(int size, Qt::Initialization) */ QString::QString(QChar ch) { - d = Data::allocate(2); + d = Data::allocate(2).first; Q_CHECK_PTR(d); d->size = 1; d->data()[0] = ch.unicode(); @@ -2354,7 +2354,7 @@ void QString::reallocData(uint alloc, bool grow) allocOptions |= QArrayData::GrowsForward; if (d->needsDetach()) { - Data *x = Data::allocate(alloc, allocOptions); + Data *x = Data::allocate(alloc, allocOptions).first; Q_CHECK_PTR(x); x->size = qMin(int(alloc) - 1, d->size); ::memcpy(x->data(), d->data(), x->size * sizeof(QChar)); @@ -2363,7 +2363,7 @@ void QString::reallocData(uint alloc, bool grow) Data::deallocate(d); d = x; } else { - Data *p = Data::reallocateUnaligned(d, alloc, allocOptions); + Data *p = Data::reallocateUnaligned(d, d->data(), alloc, allocOptions).first; Q_CHECK_PTR(p); d = p; } @@ -4898,7 +4898,7 @@ QString QString::mid(int position, int n) const return QString(); case QContainerImplHelper::Empty: { - QStringDataPtr empty = { Data::allocate(0) }; + QStringDataPtr empty = { Data::allocate(0).first }; return QString(empty); } case QContainerImplHelper::Full: @@ -5354,11 +5354,11 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size) if (!str) { d = Data::sharedNull(); } else if (size == 0 || (!*str && size < 0)) { - d = Data::allocate(0); + d = Data::allocate(0).first; } else { if (size < 0) size = qstrlen(str); - d = Data::allocate(size + 1); + d = Data::allocate(size + 1).first; Q_CHECK_PTR(d); d->size = size; d->data()[size] = '\0'; @@ -5418,7 +5418,7 @@ QString QString::fromLocal8Bit_helper(const char *str, int size) if (!str) return QString(); if (size == 0 || (!*str && size < 0)) { - QStringDataPtr empty = { Data::allocate(0) }; + QStringDataPtr empty = { Data::allocate(0).first }; return QString(empty); } #if QT_CONFIG(textcodec) @@ -9124,9 +9124,9 @@ QString QString::fromRawData(const QChar *unicode, int size) if (!unicode) { x = Data::sharedNull(); } else if (!size) { - x = Data::allocate(0); + x = Data::allocate(0).first; } else { - x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size); + x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size).ptr; Q_CHECK_PTR(x); } QStringDataPtr dataPtr = { x }; diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index aa7fac15ef..8052c2ca69 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -198,16 +198,19 @@ static QArrayData *reallocateData(QArrayData *header, size_t allocSize, uint opt return header; } -QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, +void *QArrayData::allocate(QArrayData **dptr, size_t objectSize, size_t alignment, size_t capacity, ArrayOptions options) noexcept { + Q_ASSERT(dptr); // Alignment is a power of two Q_ASSERT(alignment >= alignof(QArrayData) && !(alignment & (alignment - 1))); - if (capacity == 0) + if (capacity == 0) { // optimization for empty headers - return const_cast<QArrayData *>(&qt_array_empty); + *dptr = const_cast<QArrayData *>(&qt_array_empty); + return sharedNullData(); + } size_t headerSize = sizeof(QArrayData); @@ -225,14 +228,17 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, options |= AllocatedDataType | MutableData; options &= ~ImmutableHeader; QArrayData *header = allocateData(allocSize, options); + quintptr data = 0; if (header) { - quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) + // find where offset should point to so that data() is aligned to alignment bytes + data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); header->offset = data - quintptr(header); header->alloc = capacity; } - return header; + *dptr = header; + return reinterpret_cast<void *>(data); } QArrayData *QArrayData::prepareRawData(ArrayOptions options) Q_DECL_NOTHROW @@ -243,8 +249,9 @@ QArrayData *QArrayData::prepareRawData(ArrayOptions options) Q_DECL_NOTHROW return header; } -QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t capacity, - ArrayOptions options) noexcept +QPair<QArrayData *, void *> +QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer, + size_t objectSize, size_t capacity, ArrayOptions options) noexcept { Q_ASSERT(data); Q_ASSERT(data->isMutable()); @@ -252,12 +259,14 @@ QArrayData *QArrayData::reallocateUnaligned(QArrayData *data, size_t objectSize, size_t headerSize = sizeof(QArrayData); size_t allocSize = calculateBlockSize(capacity, objectSize, headerSize, options); + qptrdiff offset = reinterpret_cast<char *>(dataPointer) - reinterpret_cast<char *>(data); options |= AllocatedDataType | MutableData; - options &= ~ImmutableHeader; QArrayData *header = reallocateData(data, allocSize, options); - if (header) + if (header) { header->alloc = capacity; - return header; + dataPointer = reinterpret_cast<char *>(header) + offset; + } + return qMakePair(static_cast<QArrayData *>(header), dataPointer); } void QArrayData::deallocate(QArrayData *data, size_t objectSize, diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 56d61340f0..6cf0ea1cb6 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -41,11 +41,14 @@ #ifndef QARRAYDATA_H #define QARRAYDATA_H -#include <QtCore/qrefcount.h> +#include <QtCore/qpair.h> +#include <QtCore/qatomic.h> #include <string.h> QT_BEGIN_NAMESPACE +template <class T> struct QTypedArrayData; + struct Q_CORE_EXPORT QArrayData { enum ArrayOption { @@ -169,10 +172,12 @@ struct Q_CORE_EXPORT QArrayData #if defined(Q_CC_GNU) __attribute__((__malloc__)) #endif - static QArrayData *allocate(size_t objectSize, size_t alignment, + static void *allocate(QArrayData **pdata, size_t objectSize, size_t alignment, size_t capacity, ArrayOptions options = DefaultAllocationFlags) noexcept; Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize, size_t newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) noexcept; + Q_REQUIRED_RESULT static QPair<QArrayData *, void *> reallocateUnaligned(QArrayData *data, void *dataPointer, + size_t objectSize, size_t newCapacity, ArrayOptions newOptions = DefaultAllocationFlags) Q_DECL_NOTHROW; Q_REQUIRED_RESULT static QArrayData *prepareRawData(ArrayOptions options = ArrayOptions(RawDataType)) Q_DECL_NOTHROW; static void deallocate(QArrayData *data, size_t objectSize, @@ -190,6 +195,23 @@ struct Q_CORE_EXPORT QArrayData Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::ArrayOptions) +template <class T, size_t N> +struct QStaticArrayData +{ + // static arrays are of type RawDataType + QArrayData header; + T data[N]; +}; + +// Support for returning QArrayDataPointer<T> from functions +template <class T> +struct QArrayDataPointerRef +{ + QTypedArrayData<T> *ptr; + T *data; + uint size; +}; + template <class T> struct QTypedArrayData : QArrayData @@ -282,27 +304,26 @@ struct QTypedArrayData class AlignmentDummy { QArrayData header; T data; }; - Q_REQUIRED_RESULT static QTypedArrayData *allocate(size_t capacity, + Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(size_t capacity, ArrayOptions options = DefaultAllocationFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - void *result = QArrayData::allocate(sizeof(T), - alignof(AlignmentDummy), capacity, options); + QArrayData *d; + void *result = QArrayData::allocate(&d, sizeof(T), alignof(AlignmentDummy), capacity, options); #if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) result = __builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); #endif - return static_cast<QTypedArrayData *>(result); + return qMakePair(static_cast<QTypedArrayData *>(d), static_cast<T *>(result)); } - static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity, + static QPair<QTypedArrayData *, T *> + reallocateUnaligned(QTypedArrayData *data, T *dataPointer, size_t capacity, ArrayOptions options = DefaultAllocationFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - void *result = QArrayData::reallocateUnaligned(data, sizeof(T), capacity, options); -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) - result =__builtin_assume_aligned(result, Q_ALIGNOF(AlignmentDummy)); -#endif - return static_cast<QTypedArrayData *>(result); + QPair<QArrayData *, void *> pair = + QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, options); + return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second)); } static void deallocate(QArrayData *data) @@ -311,17 +332,18 @@ struct QTypedArrayData QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); } - static QTypedArrayData *fromRawData(const T *data, size_t n, + static QArrayDataPointerRef<T> fromRawData(const T *data, size_t n, ArrayOptions options = DefaultRawFlags) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - QTypedArrayData *result = static_cast<QTypedArrayData *>(prepareRawData(options)); - if (result) { - Q_ASSERT(!result->isShared()); // No shared empty, please! - - result->offset = reinterpret_cast<const char *>(data) - - reinterpret_cast<const char *>(result); - result->size = int(n); + QArrayDataPointerRef<T> result = { + static_cast<QTypedArrayData *>(prepareRawData(options)), const_cast<T *>(data), uint(n) + }; + if (result.ptr) { + Q_ASSERT(!result.ptr->isShared()); // No shared empty, please! + result.ptr->offset = reinterpret_cast<const char *>(data) + - reinterpret_cast<const char *>(result.ptr); + result.ptr->size = int(n); } return result; } @@ -345,21 +367,6 @@ struct QTypedArrayData } }; -template <class T, size_t N> -struct QStaticArrayData -{ - // static arrays are of type RawDataType - QArrayData header; - T data[N]; -}; - -// Support for returning QArrayDataPointer<T> from functions -template <class T> -struct QArrayDataPointerRef -{ - QTypedArrayData<T> *ptr; -}; - #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, size, 0, offset } \ /**/ @@ -412,7 +419,9 @@ struct QArrayDataPointerRef \ QArrayDataPointerRef<Type> ref = \ { static_cast<QTypedArrayData<Type> *>( \ - const_cast<QArrayData *>(&literal.header)) }; \ + const_cast<QArrayData *>(&literal.header)), \ + const_cast<Type *>(literal.data), \ + Size }; \ /**/ namespace QtPrivate { diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index ac7fc7bc4e..8fe35952bf 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE +template <class T> struct QArrayDataPointer; + namespace QtPrivate { QT_WARNING_PUSH @@ -56,7 +58,7 @@ QT_WARNING_DISABLE_GCC("-Wstringop-overflow") template <class T> struct QPodArrayOps - : QTypedArrayData<T> + : public QArrayDataPointer<T> { typedef T parameter_type; @@ -148,7 +150,7 @@ QT_WARNING_POP template <class T> struct QGenericArrayOps - : QTypedArrayData<T> + : public QArrayDataPointer<T> { typedef const T ¶meter_type; diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 86997985d1..c52b84f4ce 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -52,26 +52,38 @@ private: typedef QArrayDataOps<T> DataOps; public: + typedef typename Data::iterator iterator; + typedef typename Data::const_iterator const_iterator; + QArrayDataPointer() noexcept - : d(Data::sharedNull()) + : d(Data::sharedNull()), b(Data::sharedNullData()), size(0) { } QArrayDataPointer(const QArrayDataPointer &other) - : d(other.d->ref() - ? other.d - : other.clone(other.d->cloneFlags())) + : d(other.d), b(other.b), size(other.size) + { + if (!other.d->ref()) { + // must clone + QPair<Data *, T *> pair = other.clone(other.d->cloneFlags()); + d = pair.first; + b = pair.second; + } + } + + QArrayDataPointer(Data *header, T *data, size_t n = 0) + : d(header), b(data), size(n) { } - explicit QArrayDataPointer(QTypedArrayData<T> *ptr) - : d(ptr) + explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> data, size_t n = 0) + : d(data.first), b(data.second), size(n) { - Q_CHECK_PTR(ptr); + Q_CHECK_PTR(d); } QArrayDataPointer(QArrayDataPointerRef<T> ref) - : d(ref.ptr) + : d(ref.ptr), b(ref.data), size(ref.size) { } @@ -83,7 +95,7 @@ public: } QArrayDataPointer(QArrayDataPointer &&other) noexcept - : d(other.d) + : d(other.d), b(other.b), size(other.size) { other.d = Data::sharedNull(); } @@ -95,16 +107,28 @@ public: return *this; } - DataOps &operator*() const + DataOps &operator*() + { + Q_ASSERT(d); + return *static_cast<DataOps *>(this); + } + + DataOps *operator->() + { + Q_ASSERT(d); + return static_cast<DataOps *>(this); + } + + const DataOps &operator*() const { Q_ASSERT(d); - return *static_cast<DataOps *>(d); + return *static_cast<const DataOps *>(this); } - DataOps *operator->() const + const DataOps *operator->() const { Q_ASSERT(d); - return static_cast<DataOps *>(d); + return static_cast<const DataOps *>(this); } ~QArrayDataPointer() @@ -121,62 +145,92 @@ public: return d == Data::sharedNull(); } - Data *data() const - { - return d; - } + T *data() { return b; } + const T *data() const { return b; } + + iterator begin() { return data(); } + iterator end() { return data() + size; } + const_iterator begin() const { return data(); } + const_iterator end() const { return data() + size; } + const_iterator constBegin() const { return data(); } + const_iterator constEnd() const { return data() + size; } void swap(QArrayDataPointer &other) noexcept { qSwap(d, other.d); + qSwap(b, other.b); + qSwap(size, other.size); } void clear() { - QArrayDataPointer tmp(d); + QArrayDataPointer tmp(d, b, size); d = Data::sharedNull(); + b = reinterpret_cast<T *>(d); + size = 0; } bool detach() { if (d->needsDetach()) { - Data *copy = clone(d->detachFlags()); - QArrayDataPointer old(d); - d = copy; + QPair<Data *, T *> copy = clone(d->detachFlags()); + QArrayDataPointer old(d, b, size); + d = copy.first; + b = copy.second; return true; } return false; } + // forwards from QArrayData + int allocatedCapacity() { return d->allocatedCapacity(); } + int constAllocatedCapacity() const { return d->constAllocatedCapacity(); } + int refCounterValue() const { return d->refCounterValue(); } + bool ref() { return d->ref(); } + bool deref() { return d->deref(); } + bool isMutable() const { return d->isMutable(); } + bool isStatic() const { return d->isStatic(); } + bool isShared() const { return d->isShared(); } + bool needsDetach() const { return d->needsDetach(); } + size_t detachCapacity(size_t newSize) const { return d->detachCapacity(newSize); } + typename Data::ArrayOptions &flags() { return reinterpret_cast<typename Data::ArrayOptions &>(d->flags); } + typename Data::ArrayOptions flags() const { return typename Data::ArrayOption(d->flags); } + typename Data::ArrayOptions detachFlags() const { return d->detachFlags(); } + typename Data::ArrayOptions cloneFlags() const { return d->cloneFlags(); } + private: - Q_REQUIRED_RESULT Data *clone(QArrayData::ArrayOptions options) const + Q_REQUIRED_RESULT QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const { - Data *x = Data::allocate(d->detachCapacity(d->size), options); - Q_CHECK_PTR(x); - QArrayDataPointer copy(x); - - if (d->size) - copy->copyAppend(d->begin(), d->end()); + QPair<Data *, T *> pair = Data::allocate(d->detachCapacity(size), + options); + Q_CHECK_PTR(pair.first); + QArrayDataPointer copy(pair.first, pair.second, 0); + if (size) + copy->copyAppend(begin(), end()); - Data *result = copy.d; + pair.first = copy.d; copy.d = Data::sharedNull(); - return result; + return pair; } Data *d; + T *b; + +public: + uint size; }; template <class T> inline bool operator==(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<T> &rhs) { - return lhs.data() == rhs.data(); + return lhs.data() == rhs.data() && lhs.size == rhs.size; } template <class T> inline bool operator!=(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<T> &rhs) { - return lhs.data() != rhs.data(); + return lhs.data() != rhs.data() || lhs.size != rhs.size; } template <class T> diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index bf422e72d4..330bf8bb98 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -369,11 +369,11 @@ inline QVector<T>::QVector(const QVector<T> &v) d = v.d; } else { if (v.d->flags & Data::CapacityReserved) { - d = Data::allocate(v.d->allocatedCapacity()); + d = Data::allocate(v.d->allocatedCapacity()).first; Q_CHECK_PTR(d); d->flags |= Data::CapacityReserved; } else { - d = Data::allocate(v.d->size); + d = Data::allocate(v.d->size).first; Q_CHECK_PTR(d); } if (v.d->size) { @@ -394,9 +394,10 @@ void QVector<T>::detach() if (d->isStatic()) return; - if (d->needsDetach()) + if (d->needsDetach()) { realloc(d->allocatedCapacity(), d->detachFlags()); - Q_ASSERT(isDetached()); + Q_ASSERT(isDetached()); + } } template <typename T> @@ -497,7 +498,7 @@ QVector<T>::QVector(int asize) { Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0."); if (Q_LIKELY(asize > 0)) { - d = Data::allocate(asize); + d = Data::allocate(asize).first; Q_CHECK_PTR(d); d->size = asize; defaultConstruct(d->begin(), d->end()); @@ -511,7 +512,7 @@ QVector<T>::QVector(int asize, const T &t) { Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0."); if (asize > 0) { - d = Data::allocate(asize); + d = Data::allocate(asize).first; Q_CHECK_PTR(d); d->size = asize; T* i = d->end(); @@ -531,7 +532,7 @@ template <typename T> QVector<T>::QVector(std::initializer_list<T> args) { if (args.size() > 0) { - d = Data::allocate(args.size()); + d = Data::allocate(args.size()).first; Q_CHECK_PTR(d); // std::initializer_list<T>::iterator is guaranteed to be // const T* ([support.initlist]/1), so can be memcpy'ed away from by copyConstruct @@ -585,7 +586,8 @@ void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) QT_TRY { // allocate memory - x = Data::allocate(aalloc, options); + auto pair = Data::allocate(aalloc, options); + x = pair.first; Q_CHECK_PTR(x); // aalloc is bigger then 0 so it is not [un]sharedEmpty Q_ASSERT(!x->isStatic()); @@ -749,7 +751,7 @@ typename QVector<T>::iterator QVector<T>::insert(iterator before, T &&t) Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); const auto offset = std::distance(d->begin(), before); - if (!isDetached() || d->size + 1 > int(d->alloc)) + if (!isDetached() || d->size + 1 > int(d->allocatedCapacity())) realloc(d->size + 1, QArrayData::GrowsForward); if (!QTypeInfoQuery<T>::isRelocatable) { T *i = d->end(); -- cgit v1.2.3 From 4802f96d4d5b2bea62073295edde1eaa348033db Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Fri, 25 Oct 2019 10:05:15 +0200 Subject: Various cleanups in qarraydataops and qarraydatapointer Various cleanups. Add copyAppend overload for forward iterators and a insert overload for inserting n elements. Change-Id: Ic41cd20818b8307e957948d04ef6379368defa55 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydataops.h | 282 ++++++++++++++++++++++++++++++---- src/corelib/tools/qarraydatapointer.h | 109 +++++++------ 2 files changed, 304 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 8fe35952bf..dbd535fa3e 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -41,6 +42,7 @@ #define QARRAYDATAOPS_H #include <QtCore/qarraydata.h> +#include <QtCore/qcontainertools_impl.h> #include <new> #include <string.h> @@ -73,12 +75,26 @@ struct QPodArrayOps this->size = int(newSize); } + template<typename iterator> + void copyAppend(iterator b, iterator e, QtPrivate::IfIsForwardIterator<iterator> = true) + { + Q_ASSERT(this->isMutable() || b == e); + Q_ASSERT(!this->isShared() || b == e); + Q_ASSERT(std::distance(b, e) >= 0 && size_t(std::distance(b, e)) <= this->allocatedCapacity() - this->size); + + T *iter = this->end(); + for (; b != e; ++iter, ++b) { + new (iter) T(*b); + ++this->size; + } + } + void copyAppend(const T *b, const T *e) { - Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->isShared()); - Q_ASSERT(b < e); - Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); + Q_ASSERT(this->isMutable() || b == e); + Q_ASSERT(!this->isShared() || b == e); + Q_ASSERT(b <= e); + Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); ::memcpy(static_cast<void *>(this->end()), static_cast<const void *>(b), (e - b) * sizeof(T)); @@ -90,8 +106,8 @@ struct QPodArrayOps void copyAppend(size_t n, parameter_type t) { - Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->isShared()); + Q_ASSERT(this->isMutable() || n == 0); + Q_ASSERT(!this->isShared() || n == 0); Q_ASSERT(n <= uint(this->allocatedCapacity() - this->size)); T *iter = this->end(); @@ -113,7 +129,7 @@ struct QPodArrayOps void destroyAll() // Call from destructors, ONLY! { Q_ASSERT(this->isMutable()); - Q_ASSERT(this->ref_.loadRelaxed() == 0); + Q_ASSERT(this->d->ref_.loadRelaxed() == 0); // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. @@ -124,9 +140,9 @@ struct QPodArrayOps Q_ASSERT(this->isMutable()); Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end - Q_ASSERT(b < e); + Q_ASSERT(b <= e); Q_ASSERT(e <= where || b > this->end()); // No overlap - Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); + Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); ::memmove(static_cast<void *>(where + (e - b)), static_cast<void *>(where), (static_cast<const T*>(this->end()) - where) * sizeof(T)); @@ -134,17 +150,56 @@ struct QPodArrayOps this->size += (e - b); } + void insert(T *where, size_t n, T t) + { + Q_ASSERT(!this->isShared()); + Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end + Q_ASSERT(this->allocatedCapacity() - this->size >= n); + + ::memmove(static_cast<void *>(where + n), static_cast<void *>(where), + (static_cast<const T*>(this->end()) - where) * sizeof(T)); + this->size += n; // PODs can't throw on copy + while (n--) + *where++ = t; + } + void erase(T *b, T *e) { Q_ASSERT(this->isMutable()); Q_ASSERT(b < e); Q_ASSERT(b >= this->begin() && b < this->end()); - Q_ASSERT(e > this->begin() && e < this->end()); + Q_ASSERT(e > this->begin() && e <= this->end()); ::memmove(static_cast<void *>(b), static_cast<void *>(e), (static_cast<T *>(this->end()) - e) * sizeof(T)); this->size -= (e - b); } + + void assign(T *b, T *e, parameter_type t) + { + Q_ASSERT(b <= e); + Q_ASSERT(b >= this->begin() && e <= this->end()); + + while (b != e) + ::memcpy(static_cast<void *>(b++), static_cast<const void *>(&t), sizeof(T)); + } + + bool compare(const T *begin1, const T *begin2, size_t n) const + { + // only use memcmp for fundamental types or pointers. + // Other types could have padding in the data structure or custom comparison + // operators that would break the comparison using memcmp + if (QArrayDataPointer<T>::pass_parameter_by_value) + return ::memcmp(begin1, begin2, n * sizeof(T)) == 0; + const T *end1 = begin1 + n; + while (begin1 != end1) { + if (*begin1 == *begin2) + ++begin1, ++begin2; + else + return false; + } + return true; + } }; QT_WARNING_POP @@ -161,18 +216,18 @@ struct QGenericArrayOps Q_ASSERT(newSize > uint(this->size)); Q_ASSERT(newSize <= this->allocatedCapacity()); - T *const begin = this->begin(); + T *const b = this->begin(); do { - new (begin + this->size) T; + new (b + this->size) T; } while (uint(++this->size) != newSize); } - void copyAppend(const T *b, const T *e) + template<typename iterator> + void copyAppend(iterator b, iterator e, QtPrivate::IfIsForwardIterator<iterator> = true) { - Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->isShared()); - Q_ASSERT(b < e); - Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); + Q_ASSERT(this->isMutable() || b == e); + Q_ASSERT(!this->isShared() || b == e); + Q_ASSERT(std::distance(b, e) >= 0 && size_t(std::distance(b, e)) <= this->allocatedCapacity() - this->size); T *iter = this->end(); for (; b != e; ++iter, ++b) { @@ -181,6 +236,18 @@ struct QGenericArrayOps } } + void copyAppend(const T *b, const T *e) + { + Q_ASSERT(this->isMutable() || b == e); + Q_ASSERT(!this->isShared() || b == e); + Q_ASSERT(std::distance(b, e) >= 0 && size_t(std::distance(b, e)) <= this->allocatedCapacity() - this->size); + + T *iter = this->end(); + this->size += e - b; + for (; b != e; ++iter, ++b) + new (iter) T(*b); + } + void moveAppend(T *b, T *e) { Q_ASSERT(this->isMutable() || b == e); @@ -197,8 +264,8 @@ struct QGenericArrayOps void copyAppend(size_t n, parameter_type t) { - Q_ASSERT(this->isMutable()); - Q_ASSERT(!this->isShared()); + Q_ASSERT(this->isMutable() || n == 0); + Q_ASSERT(!this->isShared() || n == 0); Q_ASSERT(n <= size_t(this->allocatedCapacity() - this->size)); T *iter = this->end(); @@ -227,7 +294,7 @@ struct QGenericArrayOps // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. - Q_ASSERT(this->ref_.loadRelaxed() == 0); + Q_ASSERT(this->d->ref_.loadRelaxed() == 0); const T *const b = this->begin(); const T *i = this->end(); @@ -241,9 +308,9 @@ struct QGenericArrayOps Q_ASSERT(this->isMutable()); Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end - Q_ASSERT(b < e); + Q_ASSERT(b <= e); Q_ASSERT(e <= where || b > this->end()); // No overlap - Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); + Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); // Array may be truncated at where in case of exceptions @@ -302,25 +369,112 @@ struct QGenericArrayOps } } + void insert(T *where, size_t n, T t) + { + Q_ASSERT(!this->isShared()); + Q_ASSERT(where >= this->begin() && where <= this->end()); + Q_ASSERT(this->allocatedCapacity() - this->size >= n); + + // Array may be truncated at where in case of exceptions + T *const end = this->end(); + const T *readIter = end; + T *writeIter = end + n; + + const T *const step1End = where + qMax<size_t>(n, end - where); + + struct Destructor + { + Destructor(T *&it) + : iter(&it) + , end(it) + { + } + + void commit() + { + iter = &end; + } + + ~Destructor() + { + for (; *iter != end; --*iter) + (*iter)->~T(); + } + + T **iter; + T *end; + } destroyer(writeIter); + + // Construct new elements in array + do { + --readIter, --writeIter; + new (writeIter) T(*readIter); + } while (writeIter != step1End); + + while (writeIter != end) { + --n, --writeIter; + new (writeIter) T(t); + } + + destroyer.commit(); + this->size += destroyer.end - end; + + // Copy assign over existing elements + while (readIter != where) { + --readIter, --writeIter; + *writeIter = *readIter; + } + + while (writeIter != where) { + --n, --writeIter; + *writeIter = t; + } + } + void erase(T *b, T *e) { Q_ASSERT(this->isMutable()); Q_ASSERT(b < e); Q_ASSERT(b >= this->begin() && b < this->end()); - Q_ASSERT(e > this->begin() && e < this->end()); + Q_ASSERT(e > this->begin() && e <= this->end()); const T *const end = this->end(); - do { + // move (by assignment) the elements from e to end + // onto b to the new end + while (e != end) { *b = *e; ++b, ++e; - } while (e != end); + } + // destroy the final elements at the end + // here, b points to the new end and e to the actual end do { (--e)->~T(); --this->size; } while (e != b); } + + void assign(T *b, T *e, parameter_type t) + { + Q_ASSERT(b <= e); + Q_ASSERT(b >= this->begin() && e <= this->end()); + + while (b != e) + *b++ = t; + } + + bool compare(const T *begin1, const T *begin2, size_t n) const + { + const T *end1 = begin1 + n; + while (begin1 != end1) { + if (*begin1 == *begin2) + ++begin1, ++begin2; + else + return false; + } + return true; + } }; template <class T> @@ -331,15 +485,16 @@ struct QMovableArrayOps // using QGenericArrayOps<T>::copyAppend; // using QGenericArrayOps<T>::truncate; // using QGenericArrayOps<T>::destroyAll; + typedef typename QGenericArrayOps<T>::parameter_type parameter_type; void insert(T *where, const T *b, const T *e) { Q_ASSERT(this->isMutable()); Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end - Q_ASSERT(b < e); + Q_ASSERT(b <= e); Q_ASSERT(e <= where || b > this->end()); // No overlap - Q_ASSERT(e - b <= this->allocatedCapacity() - this->size); + Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); // Provides strong exception safety guarantee, // provided T::~T() nothrow @@ -399,16 +554,80 @@ struct QMovableArrayOps this->size += (e - b); } + void insert(T *where, size_t n, T t) + { + Q_ASSERT(!this->isShared()); + Q_ASSERT(where >= this->begin() && where <= this->end()); + Q_ASSERT(this->allocatedCapacity() - this->size >= n); + + // Provides strong exception safety guarantee, + // provided T::~T() nothrow + + struct ReversibleDisplace + { + ReversibleDisplace(T *start, T *finish, size_t diff) + : begin(start) + , end(finish) + , displace(diff) + { + ::memmove(static_cast<void *>(begin + displace), static_cast<void *>(begin), + (end - begin) * sizeof(T)); + } + + void commit() { displace = 0; } + + ~ReversibleDisplace() + { + if (displace) + ::memmove(static_cast<void *>(begin), static_cast<void *>(begin + displace), + (end - begin) * sizeof(T)); + } + + T *const begin; + T *const end; + size_t displace; + + } displace(where, this->end(), n); + + struct CopyConstructor + { + CopyConstructor(T *w) : where(w) {} + + void copy(size_t count, parameter_type proto) + { + n = 0; + while (count--) { + new (where + n) T(proto); + ++n; + } + n = 0; + } + + ~CopyConstructor() + { + while (n) + where[--n].~T(); + } + + T *const where; + size_t n; + } copier(where); + + copier.copy(n, t); + displace.commit(); + this->size += n; + } + void erase(T *b, T *e) { Q_ASSERT(this->isMutable()); Q_ASSERT(b < e); Q_ASSERT(b >= this->begin() && b < this->end()); - Q_ASSERT(e > this->begin() && e < this->end()); + Q_ASSERT(e > this->begin() && e <= this->end()); struct Mover { - Mover(T *&start, const T *finish, int &sz) + Mover(T *&start, const T *finish, uint &sz) : destination(start) , source(start) , n(finish - start) @@ -425,9 +644,10 @@ struct QMovableArrayOps T *&destination; const T *const source; size_t n; - int &size; + uint &size; } mover(e, this->end(), this->size); + // destroy the elements we're erasing do { // Exceptions or not, dtor called once per instance (--e)->~T(); @@ -449,7 +669,7 @@ struct QMovableArrayOps { CopyConstructor(T *w) : where(w) {} - void copy(const T *src, const T *const srcEnd) + void copy(T *src, const T *const srcEnd) { n = 0; for (; src != srcEnd; ++src) { diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index c52b84f4ce..9103064bd9 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -41,6 +41,7 @@ #define QARRAYDATAPOINTER_H #include <QtCore/qarraydataops.h> +#include <QtCore/qcontainertools_impl.h> QT_BEGIN_NAMESPACE @@ -56,38 +57,33 @@ public: typedef typename Data::const_iterator const_iterator; QArrayDataPointer() noexcept - : d(Data::sharedNull()), b(Data::sharedNullData()), size(0) + : d(Data::sharedNull()), ptr(Data::sharedNullData()), size(0) { } - QArrayDataPointer(const QArrayDataPointer &other) - : d(other.d), b(other.b), size(other.size) + QArrayDataPointer(const QArrayDataPointer &other) noexcept + : d(other.d), ptr(other.ptr), size(other.size) { - if (!other.d->ref()) { - // must clone - QPair<Data *, T *> pair = other.clone(other.d->cloneFlags()); - d = pair.first; - b = pair.second; - } + other.d->ref(); } - QArrayDataPointer(Data *header, T *data, size_t n = 0) - : d(header), b(data), size(n) + QArrayDataPointer(Data *header, T *adata, size_t n = 0) noexcept + : d(header), ptr(adata), size(n) { } - explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> data, size_t n = 0) - : d(data.first), b(data.second), size(n) + explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, size_t n = 0) + : d(adata.first), ptr(adata.second), size(n) { Q_CHECK_PTR(d); } - QArrayDataPointer(QArrayDataPointerRef<T> ref) - : d(ref.ptr), b(ref.data), size(ref.size) + QArrayDataPointer(QArrayDataPointerRef<T> dd) noexcept + : d(dd.ptr), ptr(dd.data), size(dd.size) { } - QArrayDataPointer &operator=(const QArrayDataPointer &other) + QArrayDataPointer &operator=(const QArrayDataPointer &other) noexcept { QArrayDataPointer tmp(other); this->swap(tmp); @@ -95,9 +91,11 @@ public: } QArrayDataPointer(QArrayDataPointer &&other) noexcept - : d(other.d), b(other.b), size(other.size) + : d(other.d), ptr(other.ptr), size(other.size) { other.d = Data::sharedNull(); + other.ptr = Data::sharedNullData(); + other.size = 0; } QArrayDataPointer &operator=(QArrayDataPointer &&other) noexcept @@ -107,25 +105,25 @@ public: return *this; } - DataOps &operator*() + DataOps &operator*() noexcept { Q_ASSERT(d); return *static_cast<DataOps *>(this); } - DataOps *operator->() + DataOps *operator->() noexcept { Q_ASSERT(d); return static_cast<DataOps *>(this); } - const DataOps &operator*() const + const DataOps &operator*() const noexcept { Q_ASSERT(d); return *static_cast<const DataOps *>(this); } - const DataOps *operator->() const + const DataOps *operator->() const noexcept { Q_ASSERT(d); return static_cast<const DataOps *>(this); @@ -140,43 +138,41 @@ public: } } - bool isNull() const + bool isNull() const noexcept { return d == Data::sharedNull(); } - T *data() { return b; } - const T *data() const { return b; } + T *data() noexcept { return ptr; } + const T *data() const noexcept { return ptr; } - iterator begin() { return data(); } - iterator end() { return data() + size; } - const_iterator begin() const { return data(); } - const_iterator end() const { return data() + size; } - const_iterator constBegin() const { return data(); } - const_iterator constEnd() const { return data() + size; } + iterator begin(iterator = iterator()) noexcept { return data(); } + iterator end(iterator = iterator()) noexcept { return data() + size; } + const_iterator begin(const_iterator = const_iterator()) const noexcept { return data(); } + const_iterator end(const_iterator = const_iterator()) const noexcept { return data() + size; } + const_iterator constBegin(const_iterator = const_iterator()) const noexcept { return data(); } + const_iterator constEnd(const_iterator = const_iterator()) const noexcept { return data() + size; } void swap(QArrayDataPointer &other) noexcept { qSwap(d, other.d); - qSwap(b, other.b); + qSwap(ptr, other.ptr); qSwap(size, other.size); } - void clear() + void clear() Q_DECL_NOEXCEPT_EXPR(std::is_nothrow_destructible<T>::value) { - QArrayDataPointer tmp(d, b, size); - d = Data::sharedNull(); - b = reinterpret_cast<T *>(d); - size = 0; + QArrayDataPointer tmp; + swap(tmp); } bool detach() { if (d->needsDetach()) { QPair<Data *, T *> copy = clone(d->detachFlags()); - QArrayDataPointer old(d, b, size); + QArrayDataPointer old(d, ptr, size); d = copy.first; - b = copy.second; + ptr = copy.second; return true; } @@ -184,20 +180,20 @@ public: } // forwards from QArrayData - int allocatedCapacity() { return d->allocatedCapacity(); } - int constAllocatedCapacity() const { return d->constAllocatedCapacity(); } - int refCounterValue() const { return d->refCounterValue(); } - bool ref() { return d->ref(); } - bool deref() { return d->deref(); } - bool isMutable() const { return d->isMutable(); } - bool isStatic() const { return d->isStatic(); } - bool isShared() const { return d->isShared(); } - bool needsDetach() const { return d->needsDetach(); } - size_t detachCapacity(size_t newSize) const { return d->detachCapacity(newSize); } - typename Data::ArrayOptions &flags() { return reinterpret_cast<typename Data::ArrayOptions &>(d->flags); } - typename Data::ArrayOptions flags() const { return typename Data::ArrayOption(d->flags); } - typename Data::ArrayOptions detachFlags() const { return d->detachFlags(); } - typename Data::ArrayOptions cloneFlags() const { return d->cloneFlags(); } + size_t allocatedCapacity() noexcept { return d->allocatedCapacity(); } + size_t constAllocatedCapacity() const noexcept { return d->constAllocatedCapacity(); } + int refCounterValue() const noexcept { return d->refCounterValue(); } + bool ref() noexcept { return d->ref(); } + bool deref() noexcept { return d->deref(); } + bool isMutable() const noexcept { return d->isMutable(); } + bool isStatic() const noexcept { return d->isStatic(); } + bool isShared() const noexcept { return d->isShared(); } + bool needsDetach() const noexcept { return d->needsDetach(); } + size_t detachCapacity(size_t newSize) const noexcept { return d->detachCapacity(newSize); } + typename Data::ArrayOptions &flags() noexcept { return reinterpret_cast<typename Data::ArrayOptions &>(d->flags); } + typename Data::ArrayOptions flags() const noexcept { return typename Data::ArrayOption(d->flags); } + typename Data::ArrayOptions detachFlags() const noexcept { return d->detachFlags(); } + typename Data::ArrayOptions cloneFlags() const noexcept { return d->cloneFlags(); } private: Q_REQUIRED_RESULT QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const @@ -214,27 +210,28 @@ private: return pair; } +protected: Data *d; - T *b; + T *ptr; public: uint size; }; template <class T> -inline bool operator==(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<T> &rhs) +inline bool operator==(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<T> &rhs) noexcept { return lhs.data() == rhs.data() && lhs.size == rhs.size; } template <class T> -inline bool operator!=(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<T> &rhs) +inline bool operator!=(const QArrayDataPointer<T> &lhs, const QArrayDataPointer<T> &rhs) noexcept { return lhs.data() != rhs.data() || lhs.size != rhs.size; } template <class T> -inline void swap(QArrayDataPointer<T> &p1, QArrayDataPointer<T> &p2) +inline void qSwap(QArrayDataPointer<T> &p1, QArrayDataPointer<T> &p2) noexcept { p1.swap(p2); } -- cgit v1.2.3 From 37e054993b763c022ab5f4a4d34e92ddffba34f5 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 4 Nov 2019 13:37:16 +0100 Subject: Get rid of the operator[](uint) overloads Those make no sense and where probably only there to workaround bugs in some old compilers. Change-Id: I5b196cc5306ac1c6307257b70179278d82d383c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qbytearray.cpp | 10 ---------- src/corelib/text/qbytearray.h | 6 ------ src/corelib/text/qstring.cpp | 13 ------------- src/corelib/text/qstring.h | 6 ------ 4 files changed, 35 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 7562227d7d..841c02f1e4 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1458,16 +1458,6 @@ QByteArray &QByteArray::operator=(const char *str) Same as at(\a i). */ -/*! \fn QByteRef QByteArray::operator[](uint i) - - \overload -*/ - -/*! \fn char QByteArray::operator[](uint i) const - - \overload -*/ - /*! \fn char QByteArray::front() const \since 5.10 diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index e9e4eecd26..67a7e5da3d 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -208,9 +208,7 @@ public: inline char at(int i) const; inline char operator[](int i) const; - inline char operator[](uint i) const; Q_REQUIRED_RESULT inline QByteRef operator[](int i); - Q_REQUIRED_RESULT inline QByteRef operator[](uint i); Q_REQUIRED_RESULT char front() const { return at(0); } Q_REQUIRED_RESULT inline QByteRef front(); Q_REQUIRED_RESULT char back() const { return at(size() - 1); } @@ -477,8 +475,6 @@ inline char QByteArray::at(int i) const { Q_ASSERT(uint(i) < uint(size())); return d->data()[i]; } inline char QByteArray::operator[](int i) const { Q_ASSERT(uint(i) < uint(size())); return d->data()[i]; } -inline char QByteArray::operator[](uint i) const -{ Q_ASSERT(i < uint(size())); return d->data()[i]; } inline bool QByteArray::isEmpty() const { return d->size == 0; } @@ -599,8 +595,6 @@ public: inline QByteRef QByteArray::operator[](int i) { Q_ASSERT(i >= 0); detach(); return QByteRef(*this, i); } -inline QByteRef QByteArray::operator[](uint i) -{ detach(); return QByteRef(*this, i); } inline QByteRef QByteArray::front() { return operator[](0); } inline QByteRef QByteArray::back() { return operator[](size() - 1); } inline QByteArray::iterator QByteArray::begin() diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 8ae365338d..3b6c3fb70f 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -5742,19 +5742,6 @@ QString QString::trimmed_helper(QString &str) \overload operator[]() */ -/*! \fn QCharRef QString::operator[](uint position) - -\overload operator[]() - -Returns the character at the specified \a position in the string as a -modifiable reference. -*/ - -/*! \fn const QChar QString::operator[](uint position) const - Equivalent to \c at(position). -\overload operator[]() -*/ - /*! \fn QChar QString::front() const \since 5.10 diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index bcc1200125..74528b47c5 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -291,8 +291,6 @@ public: inline const QChar at(int i) const; const QChar operator[](int i) const; Q_REQUIRED_RESULT QCharRef operator[](int i); - const QChar operator[](uint i) const; - Q_REQUIRED_RESULT QCharRef operator[](uint i); Q_REQUIRED_RESULT inline QChar front() const { return at(0); } Q_REQUIRED_RESULT inline QCharRef front(); @@ -1028,8 +1026,6 @@ inline const QChar QString::at(int i) const { Q_ASSERT(uint(i) < uint(size())); return QChar(d->data()[i]); } inline const QChar QString::operator[](int i) const { Q_ASSERT(uint(i) < uint(size())); return QChar(d->data()[i]); } -inline const QChar QString::operator[](uint i) const -{ Q_ASSERT(i < uint(size())); return QChar(d->data()[i]); } inline bool QString::isEmpty() const { return d->size == 0; } inline const QChar *QString::unicode() const @@ -1285,8 +1281,6 @@ inline QString &QString::setUtf16(const ushort *autf16, int asize) { return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); } inline QCharRef QString::operator[](int i) { Q_ASSERT(i >= 0); detach(); return QCharRef(*this, i); } -inline QCharRef QString::operator[](uint i) -{ detach(); return QCharRef(*this, i); } inline QCharRef QString::front() { return operator[](0); } inline QCharRef QString::back() { return operator[](size() - 1); } inline QString::iterator QString::begin() -- cgit v1.2.3 From 3d9bae304cb1fa8f5f6f8854141fc8ecca92a333 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Fri, 15 Nov 2019 12:28:56 +0100 Subject: Fix potential out of bounds write in the JSON writer If a small string (1 or 2 chars) would require a JSON escape sequence when writing out the string, the code could write out of bounds of the byte array. Fix that by always allocating at least 16 bytes of space. Change-Id: I4d023e7ed837b25b0a5dcf6cfaaf94aa55695b9f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/serialization/qjsonwriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp index 31fb16c112..590b59f09c 100644 --- a/src/corelib/serialization/qjsonwriter.cpp +++ b/src/corelib/serialization/qjsonwriter.cpp @@ -60,7 +60,8 @@ static inline uchar hexdig(uint u) static QByteArray escapedString(const QString &s) { - QByteArray ba(s.length(), Qt::Uninitialized); + // give it a minimum size to ensure the resize() below always adds enough space + QByteArray ba(qMax(s.length(), 16), Qt::Uninitialized); uchar *cursor = reinterpret_cast<uchar *>(const_cast<char *>(ba.constData())); const uchar *ba_end = cursor + ba.length(); -- cgit v1.2.3 From b42a2b3c3338a320a438bc081cb885fd4547f01f Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Wed, 13 Jun 2012 18:22:27 +0200 Subject: Inline the size and begin pointer in QVector Add QGenericArray to simplify operations. This class can be shared by other tool classes. If there is nothing else to share it, we can move the code onto qvector.h. The one candidate is QList. All tests pass and valgrind is good. Change-Id: Ieaa80709caf5f50520aa97312ab726396f5475eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/global/qt_pch.h | 2 +- src/corelib/text/qbytearraylist.h | 2 + src/corelib/tools/qarraydataops.h | 53 +- src/corelib/tools/qarraydatapointer.h | 2 +- src/corelib/tools/qvector.h | 1012 +++++++++++++-------------------- src/corelib/tools/tools.pri | 1 - src/sql/kernel/qsqlindex.cpp | 3 - 7 files changed, 433 insertions(+), 642 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h index 0dfd6c745f..1663d9392f 100644 --- a/src/corelib/global/qt_pch.h +++ b/src/corelib/global/qt_pch.h @@ -67,7 +67,7 @@ #include <qcoreevent.h> #include <qiodevice.h> #include <qlist.h> -#include <qvariant.h> /* All moc genereated code has this include */ +//#include <qvariant.h> /* All moc genereated code has this include */ #include <qobject.h> #include <qregexp.h> #include <qscopedpointer.h> diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h index 4b6c926960..e113c6059c 100644 --- a/src/corelib/text/qbytearraylist.h +++ b/src/corelib/text/qbytearraylist.h @@ -80,8 +80,10 @@ public: inline QByteArray join(char sep) const { return QtPrivate::QByteArrayList_join(self(), &sep, 1); } +#if 0 inline int indexOf(const char *needle, int from = 0) const { return QtPrivate::QByteArrayList_indexOf(self(), needle, from); } +#endif private: typedef QVector<QByteArray> Self; diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index dbd535fa3e..f3de6b65a9 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -150,7 +150,7 @@ struct QPodArrayOps this->size += (e - b); } - void insert(T *where, size_t n, T t) + void insert(T *where, size_t n, parameter_type t) { Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where < this->end()); // Use copyAppend at end @@ -163,6 +163,19 @@ struct QPodArrayOps *where++ = t; } + void insert(T *where, T &&t) + { + Q_ASSERT(!this->isShared()); + Q_ASSERT(where >= this->begin() && where <= this->end()); + Q_ASSERT(this->allocatedCapacity() - this->size >= 1); + + ::memmove(static_cast<void *>(where + 1), static_cast<void *>(where), + (static_cast<const T*>(this->end()) - where) * sizeof(T)); + this->size += 1; + new (where) T(std::move(t)); + } + + void erase(T *b, T *e) { Q_ASSERT(this->isMutable()); @@ -369,7 +382,7 @@ struct QGenericArrayOps } } - void insert(T *where, size_t n, T t) + void insert(T *where, size_t n, parameter_type t) { Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where <= this->end()); @@ -431,6 +444,33 @@ struct QGenericArrayOps } } + void insert(T *where, T &&t) + { + Q_ASSERT(!this->isShared()); + Q_ASSERT(where >= this->begin() && where <= this->end()); + Q_ASSERT(this->allocatedCapacity() - this->size >= 1); + + // Array may be truncated at where in case of exceptions + T *const end = this->end(); + + if (where != end) { + // Move elements in array + T *readIter = end - 1; + T *writeIter = end; + new (writeIter) T(std::move(*readIter)); + while (readIter > where) { + --readIter; + --writeIter; + *writeIter = std::move(*readIter); + } + *where = std::move(t); + } else { + new (where) T(std::move(t)); + } + + ++this->size; + } + void erase(T *b, T *e) { Q_ASSERT(this->isMutable()); @@ -554,7 +594,7 @@ struct QMovableArrayOps this->size += (e - b); } - void insert(T *where, size_t n, T t) + void insert(T *where, size_t n, parameter_type t) { Q_ASSERT(!this->isShared()); Q_ASSERT(where >= this->begin() && where <= this->end()); @@ -618,6 +658,9 @@ struct QMovableArrayOps this->size += n; } + // use moving insert + using QGenericArrayOps<T>::insert; + void erase(T *b, T *e) { Q_ASSERT(this->isMutable()); @@ -627,7 +670,7 @@ struct QMovableArrayOps struct Mover { - Mover(T *&start, const T *finish, uint &sz) + Mover(T *&start, const T *finish, int &sz) : destination(start) , source(start) , n(finish - start) @@ -644,7 +687,7 @@ struct QMovableArrayOps T *&destination; const T *const source; size_t n; - uint &size; + int &size; } mover(e, this->end(), this->size); // destroy the elements we're erasing diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 9103064bd9..3d850c0144 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -215,7 +215,7 @@ protected: T *ptr; public: - uint size; + int size; }; template <class T> diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 330bf8bb98..640809cd14 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Intel Corporation ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -40,22 +41,14 @@ #ifndef QVECTOR_H #define QVECTOR_H -#include <QtCore/qalgorithms.h> -#include <QtCore/qiterator.h> -#include <QtCore/qrefcount.h> -#include <QtCore/qarraydata.h> +#include <QtCore/qarraydatapointer.h> +#include <QtCore/qnamespace.h> #include <QtCore/qhashfunctions.h> -#include <QtCore/qcontainertools_impl.h> +#include <QtCore/qiterator.h> -#include <iterator> +#include <functional> +#include <limits> #include <initializer_list> -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) -#include <vector> -#endif -#include <stdlib.h> -#include <string.h> - -#include <algorithm> QT_BEGIN_NAMESPACE @@ -79,85 +72,233 @@ class QVector #endif { typedef QTypedArrayData<T> Data; - Data *d; + typedef QArrayDataOps<T> DataOps; + typedef QArrayDataPointer<T> DataPointer; + + DataPointer d; template <typename V, typename U> friend int QtPrivate::indexOf(const QVector<V> &list, const U &u, int from); template <typename V, typename U> friend int QtPrivate::lastIndexOf(const QVector<V> &list, const U &u, int from); public: - inline QVector() noexcept : d(Data::sharedNull()) { } - explicit QVector(int size); - QVector(int size, const T &t); - inline QVector(const QVector<T> &v); - inline ~QVector() { if (!d->deref()) freeData(d); } - QVector<T> &operator=(const QVector<T> &v); - QVector(QVector<T> &&other) noexcept : d(other.d) { other.d = Data::sharedNull(); } - QVector<T> &operator=(QVector<T> &&other) noexcept - { QVector moved(std::move(other)); swap(moved); return *this; } + typedef T Type; + typedef T value_type; + typedef value_type *pointer; + typedef const value_type *const_pointer; + typedef value_type &reference; + typedef const value_type &const_reference; + typedef int size_type; + typedef qptrdiff difference_type; + typedef typename Data::iterator iterator; + typedef typename Data::const_iterator const_iterator; + typedef iterator Iterator; + typedef const_iterator ConstIterator; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + // ### The line below triggers too earely instantiation of QTypeInfo<QVariant> in qvariant.h + //typedef typename DataOps::parameter_type parameter_type; + typedef const_reference parameter_type; + +private: + void resize_internal(int i, Qt::Initialization); + bool isValidIterator(const_iterator i) const + { + const std::less<const T*> less = {}; + return !less(d->end(), i) && !less(i, d->begin()); + } + QVector(DataPointer dd) noexcept + : d(dd) + { + } + +public: + inline QVector() noexcept { } + explicit QVector(int size) + : d(Data::allocate(size)) + { + if (size) + d->appendInitialize(size); + } + QVector(int size, const T &t) + : d(Data::allocate(size)) + { + if (size) + d->copyAppend(size, t); + } + + inline QVector(const QVector<T> &other) noexcept : d(other.d) {} + QVector(QVector<T> &&other) noexcept : d(std::move(other.d)) {} + inline QVector(std::initializer_list<T> args) + : d(Data::allocate(args.size())) + { + if (args.size()) + d->copyAppend(args.begin(), args.end()); + } + + ~QVector() /*noexcept(std::is_nothrow_destructible<T>::value)*/ {} + QVector<T> &operator=(const QVector<T> &other) { d = other.d; return *this; } + QVector &operator=(QVector &&other) noexcept(std::is_nothrow_destructible<T>::value) + { + d = std::move(other.d); + return *this; + } + QVector<T> &operator=(std::initializer_list<T> args) + { + d = DataPointer(Data::allocate(args.size())); + if (args.size()) + d->copyAppend(args.begin(), args.end()); + return *this; + } + template <typename InputIterator, QtPrivate::IfIsForwardIterator<InputIterator> = true> + QVector(InputIterator i1, InputIterator i2) + : d(Data::allocate(std::distance(i1, i2))) + { + if (std::distance(i1, i2)) + d->copyAppend(i1, i2); + } + + template <typename InputIterator, QtPrivate::IfIsNotForwardIterator<InputIterator> = true> + QVector(InputIterator i1, InputIterator i2) + : QVector() + { + QtPrivate::reserveIfForwardIterator(this, i1, i2); + std::copy(i1, i2, std::back_inserter(*this)); + } + void swap(QVector<T> &other) noexcept { qSwap(d, other.d); } - inline QVector(std::initializer_list<T> args); - QVector<T> &operator=(std::initializer_list<T> args); - template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true> - inline QVector(InputIterator first, InputIterator last); - explicit QVector(QArrayDataPointerRef<T> ref) noexcept : d(ref.ptr) {} - bool operator==(const QVector<T> &v) const; - inline bool operator!=(const QVector<T> &v) const { return !(*this == v); } + friend bool operator==(const QVector &l, const QVector &r) + { + if (l.size() != r.size()) + return false; + if (l.begin() == r.begin()) + return true; - inline int size() const { return d->size; } + // do element-by-element comparison + return l.d->compare(l.begin(), r.begin(), l.size()); + } + friend bool operator!=(const QVector &l, const QVector &r) + { + return !(l == r); + } - inline bool isEmpty() const { return d->size == 0; } + int size() const noexcept { return int(d->size); } + int count() const noexcept { return size(); } + int length() const noexcept { return size(); } - void resize(int size); + inline bool isEmpty() const noexcept { return d->size == 0; } - inline int capacity() const { return d->constAllocatedCapacity(); } - void reserve(int size); - inline void squeeze() + void resize(int size) { - if (d->size < int(d->allocatedCapacity())) { - if (!d->size) { - *this = QVector<T>(); - return; - } - realloc(d->size, d->detachFlags()); - } + resize_internal(size, Qt::Uninitialized); + if (size > this->size()) + d->appendInitialize(size); + } + void resize(int size, parameter_type c) + { + resize_internal(size, Qt::Uninitialized); + if (size > this->size()) + d->copyAppend(size - this->size(), c); } - inline void detach(); - inline bool isDetached() const { return !d->isShared(); } + inline int capacity() const { return int(d->constAllocatedCapacity()); } + void reserve(int size); + inline void squeeze(); + + void detach() { d.detach(); } + bool isDetached() const noexcept { return !d->isShared(); } inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; } - inline T *data() { detach(); return d->begin(); } - inline const T *data() const { return d->begin(); } - inline const T *constData() const { return d->begin(); } - void clear(); - - const T &at(int i) const; - T &operator[](int i); - const T &operator[](int i) const; - void append(const T &t); - void append(T &&t); - inline void append(const QVector<T> &l) { *this += l; } + pointer data() { detach(); return d->data(); } + const_pointer data() const noexcept { return d->data(); } + const_pointer constData() const noexcept { return d->data(); } + void clear() { + if (!size()) + return; + if (d->needsDetach()) { + // must allocate memory + DataPointer detached(Data::allocate(d.allocatedCapacity(), d->detachFlags())); + d.swap(detached); + } else { + d->truncate(0); + } + } + + const_reference at(int i) const noexcept + { + Q_ASSERT_X(size_t(i) < size_t(d->size), "QVector::at", "index out of range"); + return data()[i]; + } + reference operator[](int i) + { + Q_ASSERT_X(size_t(i) < size_t(d->size), "QVector::operator[]", "index out of range"); + detach(); + return data()[i]; + } + const_reference operator[](int i) const noexcept { return at(i); } + void append(const_reference t) + { append(const_iterator(std::addressof(t)), const_iterator(std::addressof(t)) + 1); } + void append(const_iterator i1, const_iterator i2); + void append(value_type &&t); + void append(const QVector<T> &l) { append(l.constBegin(), l.constEnd()); } void prepend(T &&t); void prepend(const T &t); - void insert(int i, T &&t); - void insert(int i, const T &t); - void insert(int i, int n, const T &t); - void replace(int i, const T &t); - void remove(int i); - void remove(int i, int n); - inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(d->begin()); } - inline void removeLast(); - T takeFirst() { Q_ASSERT(!isEmpty()); T r = std::move(first()); removeFirst(); return r; } - T takeLast() { Q_ASSERT(!isEmpty()); T r = std::move(last()); removeLast(); return r; } - - QVector<T> &fill(const T &t, int size = -1); - - int indexOf(const T &t, int from = 0) const; - int lastIndexOf(const T &t, int from = -1) const; - bool contains(const T &t) const; - int count(const T &t) const; + iterator insert(int i, parameter_type t) + { return insert(i, 1, t); } + iterator insert(int i, int n, parameter_type t); + iterator insert(const_iterator before, parameter_type t) + { + Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); + return insert(before, 1, t); + } + iterator insert(const_iterator before, int n, parameter_type t) + { + Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); + return insert(std::distance(constBegin(), before), n, t); + } + inline iterator insert(const_iterator before, T &&t) + { + Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); + return insert(std::distance(constBegin(), before), std::move(t)); + } + iterator insert(int i, T &&t); +#if 0 + template< class InputIt > + iterator insert( const_iterator pos, InputIt first, InputIt last ); + iterator insert( const_iterator pos, std::initializer_list<T> ilist ); +#endif + void replace(int i, const T &t) + { + Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range"); + const T copy(t); + data()[i] = copy; + } + void replace(int i, T &&t) + { + Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range"); + const T copy(std::move(t)); + data()[i] = std::move(copy); + } + + void remove(int i, int n = 1); + void removeFirst() { Q_ASSERT(!isEmpty()); remove(0); } + void removeLast() { Q_ASSERT(!isEmpty()); remove(size() - 1); } + value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); remove(0); return v; } + value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); remove(size() - 1); return v; } + + QVector<T> &fill(parameter_type t, int size = -1); + + int indexOf(const T &t, int from = 0) const noexcept; + int lastIndexOf(const T &t, int from = -1) const noexcept; + bool contains(const T &t) const noexcept + { + return indexOf(t) != -1; + } + int count(const T &t) const noexcept + { + return int(std::count(&*cbegin(), &*cend(), t)); + } // QList compatibility void removeAt(int i) { remove(i); } @@ -166,10 +307,10 @@ public: const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t); if (cit == ce) return 0; + int index = cit - this->cbegin(); // next operation detaches, so ce, cit, t may become invalidated: const T tCopy = t; - const int firstFoundIdx = std::distance(this->cbegin(), cit); - const iterator e = end(), it = std::remove(begin() + firstFoundIdx, e, tCopy); + const iterator e = end(), it = std::remove(begin() + index, e, tCopy); const int result = std::distance(it, e); erase(it, e); return result; @@ -182,7 +323,6 @@ public: remove(i); return true; } - int length() const { return size(); } T takeAt(int i) { T t = std::move((*this)[i]); remove(i); return t; } void move(int from, int to) { @@ -199,32 +339,26 @@ public: } // STL-style - typedef typename Data::iterator iterator; - typedef typename Data::const_iterator const_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - inline iterator begin() { detach(); return d->begin(); } - inline const_iterator begin() const noexcept { return d->constBegin(); } - inline const_iterator cbegin() const noexcept { return d->constBegin(); } - inline const_iterator constBegin() const noexcept { return d->constBegin(); } - inline iterator end() { detach(); return d->end(); } - inline const_iterator end() const noexcept { return d->constEnd(); } - inline const_iterator cend() const noexcept { return d->constEnd(); } - inline const_iterator constEnd() const noexcept { return d->constEnd(); } + iterator begin() { detach(); return d->begin(); } + iterator end() { detach(); return d->end(); } + + const_iterator begin() const noexcept { return d->constBegin(); } + const_iterator end() const noexcept { return d->constEnd(); } + const_iterator cbegin() const noexcept { return d->constBegin(); } + const_iterator cend() const noexcept { return d->constEnd(); } + const_iterator constBegin() const noexcept { return d->constBegin(); } + const_iterator constEnd() const noexcept { return d->constEnd(); } reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } - iterator insert(iterator before, int n, const T &x); - inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); } - inline iterator insert(iterator before, T &&x); + iterator erase(iterator begin, iterator end); inline iterator erase(iterator pos) { return erase(pos, pos+1); } // more Qt - inline int count() const { return d->size; } inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); } inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); } @@ -235,7 +369,7 @@ public: inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; } QVector<T> mid(int pos, int len = -1) const; - T value(int i) const; + T value(int i) const { return value(i, T()); } T value(int i, const T &defaultValue) const; void swapItemsAt(int i, int j) { @@ -246,15 +380,6 @@ public: } // STL compatibility - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef qptrdiff difference_type; - typedef iterator Iterator; - typedef const_iterator ConstIterator; - typedef int size_type; inline void push_back(const T &t) { append(t); } void push_back(T &&t) { append(std::move(t)); } void push_front(T &&t) { prepend(std::move(t)); } @@ -263,14 +388,14 @@ public: void pop_front() { removeFirst(); } inline bool empty() const { return d->size == 0; } - inline T& front() { return first(); } + inline reference front() { return first(); } inline const_reference front() const { return first(); } inline reference back() { return last(); } inline const_reference back() const { return last(); } void shrink_to_fit() { squeeze(); } // comfort - QVector<T> &operator+=(const QVector<T> &l); + QVector<T> &operator+=(const QVector<T> &l) { append(l.cbegin(), l.cend()); return *this; } inline QVector<T> operator+(const QVector<T> &l) const { QVector n = *this; n += l; return n; } inline QVector<T> &operator+=(const T &t) @@ -284,34 +409,12 @@ public: inline QVector<T> &operator<<(T &&t) { append(std::move(t)); return *this; } -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) - Q_DECL_DEPRECATED_X("Use QVector<T>(vector.begin(), vector.end()) instead.") - static inline QVector<T> fromStdVector(const std::vector<T> &vector) - { return QVector<T>(vector.begin(), vector.end()); } - Q_DECL_DEPRECATED_X("Use std::vector<T>(vector.begin(), vector.end()) instead.") - inline std::vector<T> toStdVector() const - { return std::vector<T>(d->begin(), d->end()); } -#endif - // Consider deprecating in 6.4 or later static QVector<T> fromList(const QVector<T> &list) { return list; } QVector<T> toList() const { return *this; } static inline QVector<T> fromVector(const QVector<T> &vector) { return vector; } inline QVector<T> toVector() const { return *this; } - -private: - void realloc(int alloc, QArrayData::ArrayOptions options); - void freeData(Data *d); - void defaultConstruct(T *from, T *to); - void copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom); - void destruct(T *from, T *to); - bool isValidIterator(const iterator &i) const - { - const std::less<const T*> less = {}; - return !less(d->end(), i) && !less(i, d->begin()); - } - class AlignmentDummy { Data header; T array[1]; }; }; #if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 @@ -321,153 +424,86 @@ template <typename InputIterator, QVector(InputIterator, InputIterator) -> QVector<ValueType>; #endif -#ifdef Q_CC_MSVC -// behavior change: an object of POD type constructed with an initializer of the form () -// will be default-initialized -# pragma warning ( push ) -# pragma warning ( disable : 4345 ) -# pragma warning(disable : 4127) // conditional expression is constant -#endif - template <typename T> -void QVector<T>::defaultConstruct(T *from, T *to) +inline void QVector<T>::resize_internal(int newSize, Qt::Initialization) { - if (QTypeInfo<T>::isComplex) { - while (from != to) { - new (from++) T(); + Q_ASSERT(newSize >= 0); + + if (d->needsDetach() || newSize > capacity()) { + // must allocate memory + DataPointer detached(Data::allocate(d->detachCapacity(newSize), + d->detachFlags())); + if (size() && newSize) { + detached->copyAppend(constBegin(), constBegin() + qMin(newSize, size())); } - } else { - ::memset(static_cast<void *>(from), 0, (to - from) * sizeof(T)); + d.swap(detached); } -} -template <typename T> -void QVector<T>::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom) -{ - if (QTypeInfo<T>::isComplex) { - while (srcFrom != srcTo) - new (dstFrom++) T(*srcFrom++); - } else { - ::memcpy(static_cast<void *>(dstFrom), static_cast<const void *>(srcFrom), (srcTo - srcFrom) * sizeof(T)); - } + if (newSize < size()) + d->truncate(newSize); } template <typename T> -void QVector<T>::destruct(T *from, T *to) +void QVector<T>::reserve(int asize) { - if (QTypeInfo<T>::isComplex) { - while (from != to) { - from++->~T(); + // capacity() == 0 for immutable data, so this will force a detaching below + if (asize <= capacity()) { + if (d->flags() & Data::CapacityReserved) + return; // already reserved, don't shrink + if (!d->isShared()) { + // accept current allocation, don't shrink + d->flags() |= Data::CapacityReserved; + return; } } + + DataPointer detached(Data::allocate(qMax(asize, size()), + d->detachFlags() | Data::CapacityReserved)); + detached->copyAppend(constBegin(), constEnd()); + d.swap(detached); } template <typename T> -inline QVector<T>::QVector(const QVector<T> &v) +inline void QVector<T>::squeeze() { - if (v.d->ref()) { - d = v.d; - } else { - if (v.d->flags & Data::CapacityReserved) { - d = Data::allocate(v.d->allocatedCapacity()).first; - Q_CHECK_PTR(d); - d->flags |= Data::CapacityReserved; - } else { - d = Data::allocate(v.d->size).first; - Q_CHECK_PTR(d); - } - if (v.d->size) { - copyConstruct(v.d->begin(), v.d->end(), d->begin()); - d->size = v.d->size; + if (d->needsDetach() || size() != capacity()) { + // must allocate memory + DataPointer detached(Data::allocate(size(), d->detachFlags() & ~Data::CapacityReserved)); + if (size()) { + detached->copyAppend(constBegin(), constEnd()); } + d.swap(detached); } } -#if defined(Q_CC_MSVC) -#pragma warning( pop ) -#endif - template <typename T> -void QVector<T>::detach() +inline void QVector<T>::remove(int i, int n) { - // ### check whether this is still required - if (d->isStatic()) + Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QVector::remove", "index out of range"); + Q_ASSERT_X(n >= 0, "QVector::remove", "invalid count"); + + if (n == 0) return; - if (d->needsDetach()) { - realloc(d->allocatedCapacity(), d->detachFlags()); - Q_ASSERT(isDetached()); + const size_t newSize = size() - n; + if (d->needsDetach() || + ((d->flags() & Data::CapacityReserved) == 0 + && newSize < d->allocatedCapacity()/2)) { + // allocate memory + DataPointer detached(Data::allocate(d->detachCapacity(newSize), + d->detachFlags() & ~(Data::GrowsBackwards | Data::GrowsForward))); + const_iterator where = constBegin() + i; + if (newSize) { + detached->copyAppend(constBegin(), where); + detached->copyAppend(where + n, constEnd()); + } + d.swap(detached); + } else { + // we're detached and we can just move data around + d->erase(d->begin() + i, d->begin() + i + n); } } -template <typename T> -void QVector<T>::reserve(int asize) -{ - if (asize > int(d->allocatedCapacity())) - realloc(asize, typename Data::ArrayOptions(d->flags | Data::CapacityReserved)); - else if (isDetached()) - d->flags |= Data::CapacityReserved; - Q_ASSERT(int(d->allocatedCapacity()) >= asize); -} - -template <typename T> -void QVector<T>::resize(int asize) -{ - if (asize == d->size) - return detach(); - int oldAlloc = d->allocatedCapacity(); - if (asize > oldAlloc || !isDetached()) { // there is not enough space - QArrayData::ArrayOptions opt = d->detachFlags(); - if (asize > oldAlloc) - opt |= QArrayData::GrowsForward; - realloc(qMax(oldAlloc, asize), opt); - } - if (asize < d->size) - destruct(begin() + asize, end()); - else - defaultConstruct(end(), begin() + asize); - d->size = asize; -} -template <typename T> -inline void QVector<T>::clear() -{ - if (!d->size) - return; - destruct(begin(), end()); - d->size = 0; -} -template <typename T> -inline const T &QVector<T>::at(int i) const -{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range"); - return d->begin()[i]; } -template <typename T> -inline const T &QVector<T>::operator[](int i) const -{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range"); - return d->begin()[i]; } -template <typename T> -inline T &QVector<T>::operator[](int i) -{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range"); - return data()[i]; } -template <typename T> -inline void QVector<T>::insert(int i, const T &t) -{ Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range"); - insert(begin() + i, 1, t); } -template <typename T> -inline void QVector<T>::insert(int i, int n, const T &t) -{ Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range"); - insert(begin() + i, n, t); } -template <typename T> -inline void QVector<T>::insert(int i, T &&t) -{ Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range"); - insert(begin() + i, std::move(t)); } -template <typename T> -inline void QVector<T>::remove(int i, int n) -{ Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= d->size, "QVector<T>::remove", "index out of range"); - erase(d->begin() + i, d->begin() + i + n); } -template <typename T> -inline void QVector<T>::remove(int i) -{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::remove", "index out of range"); - erase(d->begin() + i, d->begin() + i + 1); } template <typename T> inline void QVector<T>::prepend(const T &t) { insert(begin(), 1, t); } @@ -475,304 +511,106 @@ template <typename T> inline void QVector<T>::prepend(T &&t) { insert(begin(), std::move(t)); } -template <typename T> -inline void QVector<T>::replace(int i, const T &t) -{ - Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range"); - const T copy(t); - data()[i] = copy; -} - -template <typename T> -QVector<T> &QVector<T>::operator=(const QVector<T> &v) +template<typename T> +inline T QVector<T>::value(int i, const T &defaultValue) const { - if (v.d != d) { - QVector<T> tmp(v); - tmp.swap(*this); - } - return *this; + return size_t(i) < size_t(d->size) ? at(i) : defaultValue; } template <typename T> -QVector<T>::QVector(int asize) +inline void QVector<T>::append(const_iterator i1, const_iterator i2) { - Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0."); - if (Q_LIKELY(asize > 0)) { - d = Data::allocate(asize).first; - Q_CHECK_PTR(d); - d->size = asize; - defaultConstruct(d->begin(), d->end()); + if (i1 == i2) + return; + const size_t newSize = size() + std::distance(i1, i2); + if (d->needsDetach() || newSize > d->allocatedCapacity()) { + DataPointer detached(Data::allocate(d->detachCapacity(newSize), + d->detachFlags() | Data::GrowsForward)); + detached->copyAppend(constBegin(), constEnd()); + detached->copyAppend(i1, i2); + d.swap(detached); } else { - d = Data::sharedNull(); + // we're detached and we can just move data around + d->copyAppend(i1, i2); } } template <typename T> -QVector<T>::QVector(int asize, const T &t) +inline void QVector<T>::append(value_type &&t) { - Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0."); - if (asize > 0) { - d = Data::allocate(asize).first; - Q_CHECK_PTR(d); - d->size = asize; - T* i = d->end(); - while (i != d->begin()) - new (--i) T(t); + const size_t newSize = size() + 1; + const bool isTooSmall = newSize > d->allocatedCapacity(); + const bool isOverlapping = std::addressof(*d->begin()) <= std::addressof(t) + && std::addressof(t) < std::addressof(*d->end()); + if (isTooSmall || d->needsDetach() || Q_UNLIKELY(isOverlapping)) { + typename Data::ArrayOptions flags = d->detachFlags(); + if (isTooSmall) + flags |= Data::GrowsForward; + DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags)); + detached->copyAppend(constBegin(), constEnd()); + detached->moveAppend(std::addressof(t), std::addressof(t) + 1); + d.swap(detached); } else { - d = Data::sharedNull(); + // we're detached and we can just move data around + d->moveAppend(std::addressof(t), std::addressof(t) + 1); } } -#if defined(Q_CC_MSVC) -QT_WARNING_PUSH -QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant -#endif // Q_CC_MSVC - template <typename T> -QVector<T>::QVector(std::initializer_list<T> args) +inline typename QVector<T>::iterator +QVector<T>::insert(int i, int n, parameter_type t) { - if (args.size() > 0) { - d = Data::allocate(args.size()).first; - Q_CHECK_PTR(d); - // std::initializer_list<T>::iterator is guaranteed to be - // const T* ([support.initlist]/1), so can be memcpy'ed away from by copyConstruct - copyConstruct(args.begin(), args.end(), d->begin()); - d->size = int(args.size()); - } else { - d = Data::sharedNull(); - } -} + Q_ASSERT_X(size_t(i) <= size_t(d->size), "QVector<T>::insert", "index out of range"); -template <typename T> -QVector<T> &QVector<T>::operator=(std::initializer_list<T> args) -{ - QVector<T> tmp(args); - tmp.swap(*this); - return *this; -} - -#if defined(Q_CC_MSVC) -QT_WARNING_POP -#endif // Q_CC_MSVC - -template <typename T> -template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator>> -QVector<T>::QVector(InputIterator first, InputIterator last) - : QVector() -{ - QtPrivate::reserveIfForwardIterator(this, first, last); - std::copy(first, last, std::back_inserter(*this)); -} - -template <typename T> -void QVector<T>::freeData(Data *x) -{ - destruct(x->begin(), x->end()); - Data::deallocate(x); -} - -#if defined(Q_CC_MSVC) -QT_WARNING_PUSH -QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant -#endif - -template<typename T> -void QVector<T>::realloc(int aalloc, QArrayData::ArrayOptions options) -{ - Q_ASSERT(aalloc >= d->size); - Data *x = d; - - const bool isShared = d->isShared(); + // we don't have a quick exit for n == 0 + // it's not worth wasting CPU cycles for that - QT_TRY { - // allocate memory - auto pair = Data::allocate(aalloc, options); - x = pair.first; - Q_CHECK_PTR(x); - // aalloc is bigger then 0 so it is not [un]sharedEmpty - Q_ASSERT(!x->isStatic()); - x->size = d->size; - - T *srcBegin = d->begin(); - T *srcEnd = d->end(); - T *dst = x->begin(); - - if (!QTypeInfoQuery<T>::isRelocatable || (isShared && QTypeInfo<T>::isComplex)) { - QT_TRY { - if (isShared || !std::is_nothrow_move_constructible<T>::value) { - // we can not move the data, we need to copy construct it - while (srcBegin != srcEnd) - new (dst++) T(*srcBegin++); - } else { - while (srcBegin != srcEnd) - new (dst++) T(std::move(*srcBegin++)); - } - } QT_CATCH (...) { - // destruct already copied objects - destruct(x->begin(), dst); - QT_RETHROW; - } - } else { - ::memcpy(static_cast<void *>(dst), static_cast<void *>(srcBegin), (srcEnd - srcBegin) * sizeof(T)); - dst += srcEnd - srcBegin; - } - - } QT_CATCH (...) { - Data::deallocate(x); - QT_RETHROW; - } + const size_t newSize = size() + n; + if (d->needsDetach() || newSize > d->allocatedCapacity()) { + typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward; + if (size_t(i) <= newSize / 4) + flags |= Data::GrowsBackwards; - Q_ASSERT(d != x); - if (!d->deref()) { - if (!QTypeInfoQuery<T>::isRelocatable || !aalloc || (isShared && QTypeInfo<T>::isComplex)) { - // data was copy constructed, we need to call destructors - // or if !alloc we did nothing to the old 'd'. - freeData(d); + DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags)); + const_iterator where = constBegin() + i; + detached->copyAppend(constBegin(), where); + detached->copyAppend(n, t); + detached->copyAppend(where, constEnd()); + d.swap(detached); + } else { + // we're detached and we can just move data around + if (i == size()) { + d->copyAppend(n, t); } else { - Data::deallocate(d); + T copy(t); + d->insert(d.begin() + i, n, copy); } } - d = x; - - Q_ASSERT(d->data()); - Q_ASSERT(uint(d->size) <= d->allocatedCapacity()); - Q_ASSERT(d != Data::sharedNull()); - Q_ASSERT(d->allocatedCapacity() >= uint(aalloc)); -} - -#if defined(Q_CC_MSVC) -QT_WARNING_POP -#endif - -template<typename T> -Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const -{ - if (uint(i) >= uint(d->size)) { - return T(); - } - return d->begin()[i]; -} -template<typename T> -Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const -{ - return uint(i) >= uint(d->size) ? defaultValue : d->begin()[i]; -} - -template <typename T> -void QVector<T>::append(const T &t) -{ - const bool isTooSmall = d->size >= int(d->allocatedCapacity()); - QArrayData::ArrayOptions opt = d->detachFlags(); - if (!isDetached() || isTooSmall) { - T copy(t); - if (isTooSmall) - opt |= QArrayData::GrowsForward; - realloc(isTooSmall ? d->size + 1 : d->allocatedCapacity(), opt); - - if (QTypeInfo<T>::isComplex) - new (d->end()) T(std::move(copy)); - else - *d->end() = std::move(copy); - - } else { - if (QTypeInfo<T>::isComplex) - new (d->end()) T(t); - else - *d->end() = t; - } - ++d->size; -} - -template <typename T> -void QVector<T>::append(T &&t) -{ - const bool isTooSmall = uint(d->size + 1) > d->allocatedCapacity(); - if (!isDetached() || isTooSmall) { - QArrayData::ArrayOptions opt(isTooSmall ? QArrayData::GrowsForward : QArrayData::DefaultAllocationFlags); - realloc(isTooSmall ? d->size + 1 : d->allocatedCapacity(), opt); - } - - new (d->end()) T(std::move(t)); - - ++d->size; -} - -template <typename T> -void QVector<T>::removeLast() -{ - Q_ASSERT(!isEmpty()); - Q_ASSERT(d->allocatedCapacity()); - - if (d->needsDetach()) - detach(); - --d->size; - if (QTypeInfo<T>::isComplex) - (d->data() + d->size)->~T(); + return d.begin() + i; } template <typename T> -typename QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, const T &t) +inline typename QVector<T>::iterator +QVector<T>::insert(int i, T &&t) { - Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); + Q_ASSERT_X(size_t(i) <= size_t(d->size), "QVector<T>::insert", "index out of range"); - const auto offset = std::distance(d->begin(), before); - if (n != 0) { - const T copy(t); - if (!isDetached() || d->size + n > int(d->allocatedCapacity())) - realloc(d->size + n, QArrayData::GrowsForward); - if (!QTypeInfoQuery<T>::isRelocatable) { - T *b = d->end(); - T *i = d->end() + n; - while (i != b) - new (--i) T; - i = d->end(); - T *j = i + n; - b = d->begin() + offset; - while (i != b) - *--j = *--i; - i = b+n; - while (i != b) - *--i = copy; - } else { - T *b = d->begin() + offset; - T *i = b + n; - memmove(static_cast<void *>(i), static_cast<const void *>(b), (d->size - offset) * sizeof(T)); - while (i != b) - new (--i) T(copy); - } - d->size += n; - } - return d->begin() + offset; -} + const size_t newSize = size() + 1; + if (d->needsDetach() || newSize > d->allocatedCapacity()) { + typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward; + if (size_t(i) <= newSize / 4) + flags |= Data::GrowsBackwards; -template <typename T> -typename QVector<T>::iterator QVector<T>::insert(iterator before, T &&t) -{ - Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); - - const auto offset = std::distance(d->begin(), before); - if (!isDetached() || d->size + 1 > int(d->allocatedCapacity())) - realloc(d->size + 1, QArrayData::GrowsForward); - if (!QTypeInfoQuery<T>::isRelocatable) { - T *i = d->end(); - T *j = i + 1; - T *b = d->begin() + offset; - // The new end-element needs to be constructed, the rest must be move assigned - if (i != b) { - new (--j) T(std::move(*--i)); - while (i != b) - *--j = std::move(*--i); - *b = std::move(t); - } else { - new (b) T(std::move(t)); - } + DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags)); + const_iterator where = constBegin() + i; + detached->copyAppend(constBegin(), where); + detached->moveAppend(std::addressof(t), std::addressof(t) + 1); + detached->copyAppend(where, constEnd()); + d.swap(detached); } else { - T *b = d->begin() + offset; - memmove(static_cast<void *>(b + 1), static_cast<const void *>(b), (d->size - offset) * sizeof(T)); - new (b) T(std::move(t)); + d->insert(d.begin() + i, std::move(t)); } - d->size += 1; - return d->begin() + offset; + return d.begin() + i; } template <typename T> @@ -780,102 +618,33 @@ typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend) { Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid"); Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid"); + Q_ASSERT(aend >= abegin); - const auto itemsToErase = aend - abegin; - - if (!itemsToErase) - return abegin; - - Q_ASSERT(abegin >= d->begin()); - Q_ASSERT(aend <= d->end()); - Q_ASSERT(abegin <= aend); - - const auto itemsUntouched = abegin - d->begin(); - - // FIXME we could do a proper realloc, which copy constructs only needed data. - // FIXME we are about to delete data - maybe it is good time to shrink? - // FIXME the shrink is also an issue in removeLast, that is just a copy + reduce of this. - if (d->allocatedCapacity()) { - detach(); - abegin = d->begin() + itemsUntouched; - aend = abegin + itemsToErase; - if (!QTypeInfoQuery<T>::isRelocatable) { - iterator moveBegin = abegin + itemsToErase; - iterator moveEnd = d->end(); - while (moveBegin != moveEnd) { - if (QTypeInfo<T>::isComplex) - static_cast<T *>(abegin)->~T(); - new (abegin++) T(*moveBegin++); - } - if (abegin < d->end()) { - // destroy rest of instances - destruct(abegin, d->end()); - } - } else { - destruct(abegin, aend); - // QTBUG-53605: static_cast<void *> masks clang errors of the form - // error: destination for this 'memmove' call is a pointer to class containing a dynamic class - // FIXME maybe use std::is_polymorphic (as soon as allowed) to avoid the memmove - memmove(static_cast<void *>(abegin), static_cast<void *>(aend), - (d->size - itemsToErase - itemsUntouched) * sizeof(T)); - } - d->size -= int(itemsToErase); - } - return d->begin() + itemsUntouched; -} - -template <typename T> -bool QVector<T>::operator==(const QVector<T> &v) const -{ - if (d == v.d) - return true; - if (d->size != v.d->size) - return false; - const T *vb = v.d->begin(); - const T *b = d->begin(); - const T *e = d->end(); - return std::equal(b, e, QT_MAKE_CHECKED_ARRAY_ITERATOR(vb, v.d->size)); -} + // d.begin() so we don't detach just yet + int i = std::distance(d.begin(), abegin); + int n = std::distance(abegin, aend); + remove(i, n); -template <typename T> -QVector<T> &QVector<T>::fill(const T &from, int asize) -{ - const T copy(from); - resize(asize < 0 ? d->size : asize); - if (d->size) { - T *i = d->end(); - T *b = d->begin(); - while (i != b) - *--i = copy; - } - return *this; + return d.begin() + i; } template <typename T> -QVector<T> &QVector<T>::operator+=(const QVector &l) +inline QVector<T> &QVector<T>::fill(parameter_type t, int newSize) { - if (d->size == 0) { - *this = l; + if (newSize == -1) + newSize = size(); + if (d->needsDetach() || newSize > capacity()) { + // must allocate memory + DataPointer detached(Data::allocate(d->detachCapacity(newSize), + d->detachFlags())); + detached->copyAppend(newSize, t); + d.swap(detached); } else { - uint newSize = d->size + l.d->size; - const bool isTooSmall = newSize > d->allocatedCapacity(); - if (!isDetached() || isTooSmall) { - QArrayData::ArrayOptions opt(isTooSmall ? d->flags | QArrayData::GrowsForward : d->flags); - realloc(isTooSmall ? newSize : d->allocatedCapacity(), opt); - } - - if (l.d->size) { - T *w = d->begin() + newSize; - T *i = l.d->end(); - T *b = l.d->begin(); - while (i != b) { - if (QTypeInfo<T>::isComplex) - new (--w) T(*--i); - else - *--w = *--i; - } - d->size = newSize; - } + // we're detached + const T copy(t); + d->assign(d.begin(), d.begin() + qMin(size(), newSize), t); + if (newSize > size()) + d->copyAppend(newSize - size(), copy); } return *this; } @@ -916,54 +685,35 @@ int lastIndexOf(const QVector<T> &vector, const U &u, int from) } template <typename T> -int QVector<T>::indexOf(const T &t, int from) const +int QVector<T>::indexOf(const T &t, int from) const noexcept { return QtPrivate::indexOf<T, T>(*this, t, from); } template <typename T> -int QVector<T>::lastIndexOf(const T &t, int from) const +int QVector<T>::lastIndexOf(const T &t, int from) const noexcept { return QtPrivate::lastIndexOf(*this, t, from); } template <typename T> -bool QVector<T>::contains(const T &t) const -{ - const T *b = d->begin(); - const T *e = d->end(); - return std::find(b, e, t) != e; -} - -template <typename T> -int QVector<T>::count(const T &t) const -{ - const T *b = d->begin(); - const T *e = d->end(); - return int(std::count(b, e, t)); -} - -template <typename T> -Q_OUTOFLINE_TEMPLATE QVector<T> QVector<T>::mid(int pos, int len) const +inline QVector<T> QVector<T>::mid(int pos, int len) const { using namespace QtPrivate; - switch (QContainerImplHelper::mid(d->size, &pos, &len)) { + switch (QContainerImplHelper::mid(d.size, &pos, &len)) { case QContainerImplHelper::Null: case QContainerImplHelper::Empty: - return QVector<T>(); + return QVector(); case QContainerImplHelper::Full: return *this; case QContainerImplHelper::Subset: break; } - QVector<T> midResult; - midResult.realloc(len, QArrayData::DefaultAllocationFlags); - T *srcFrom = d->begin() + pos; - T *srcTo = d->begin() + pos + len; - midResult.copyConstruct(srcFrom, srcTo, midResult.data()); - midResult.d->size = len; - return midResult; + // Allocate memory + DataPointer copied(Data::allocate(len)); + copied->copyAppend(constBegin() + pos, constBegin() + pos + len); + return copied; } Q_DECLARE_SEQUENTIAL_ITERATOR(Vector) diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 40c84157cd..a1b243dd5f 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -47,7 +47,6 @@ HEADERS += \ tools/qvector.h \ tools/qversionnumber.h - SOURCES += \ tools/qarraydata.cpp \ tools/qbitarray.cpp \ diff --git a/src/sql/kernel/qsqlindex.cpp b/src/sql/kernel/qsqlindex.cpp index 60b0ef6965..5781f24b5c 100644 --- a/src/sql/kernel/qsqlindex.cpp +++ b/src/sql/kernel/qsqlindex.cpp @@ -44,9 +44,6 @@ QT_BEGIN_NAMESPACE -// ### Qt 6: remove the static assertion, the 'sorts' field was changed from QList to QVector in Qt 5.6 -Q_STATIC_ASSERT((sizeof(QList<bool>) == sizeof(QVector<bool>))); - /*! \class QSqlIndex \brief The QSqlIndex class provides functions to manipulate and -- cgit v1.2.3 From 746ab4bbd6ebf2147ce93390738c8a71d6a4a335 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 19 Jun 2012 17:31:00 +0200 Subject: Inline the size and data pointer members in QString I'd have preferred to use QArrayDataPointer<ushort> for QString, but that option wasn't the best one. QArrayDataPointer try to do some operations using QArrayDataOps and that would expand to unnecessary code. What's more, the existing code expected to be able to modify and access the d pointer. Instead, this commit introduces QStringPrivate (named differently from QStringData to catch potential users), which contains the three members. This POD class is also used in QJsonValue to store the "inlined" QString. QHashedString in qtdeclarative will need a similar solution. Change-Id: I33f072158e6e2cd031d4d2ffc81f4a8dbaf4e616 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/serialization/qbinaryjsonvalue.cpp | 16 +- src/corelib/serialization/qbinaryjsonvalue_p.h | 7 +- src/corelib/text/qstring.cpp | 421 +++++++++++++------------ src/corelib/text/qstring.h | 108 +++---- src/corelib/text/qstringliteral.h | 44 +-- 5 files changed, 304 insertions(+), 292 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qbinaryjsonvalue.cpp b/src/corelib/serialization/qbinaryjsonvalue.cpp index 46a1b80104..92a8fd7ec5 100644 --- a/src/corelib/serialization/qbinaryjsonvalue.cpp +++ b/src/corelib/serialization/qbinaryjsonvalue.cpp @@ -66,7 +66,7 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, case QJsonValue::String: { QString s = v.toString(parent); stringData = s.data_ptr(); - stringData->ref(); + stringData.d->ref(); break; } case QJsonValue::Array: @@ -80,9 +80,10 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, } QBinaryJsonValue::QBinaryJsonValue(QString string) - : stringData(*reinterpret_cast<QStringData **>(&string)), t(QJsonValue::String) + : d(nullptr), t(QJsonValue::String) { - stringData->ref(); + stringData = *(QStringPrivate *)(&string); + stringData.d->ref(); } QBinaryJsonValue::QBinaryJsonValue(const QBinaryJsonArray &a) @@ -101,8 +102,8 @@ QBinaryJsonValue::QBinaryJsonValue(const QBinaryJsonObject &o) QBinaryJsonValue::~QBinaryJsonValue() { - if (t == QJsonValue::String && stringData && !stringData->deref()) - free(stringData); + if (t == QJsonValue::String && !stringData.d->deref()) + QTypedArrayData<ushort>::deallocate(stringData.d); if (d && !d->ref.deref()) delete d; @@ -134,9 +135,8 @@ QString QBinaryJsonValue::toString() const { if (t != QJsonValue::String) return QString(); - stringData->ref(); // the constructor below doesn't add a ref. - QStringDataPtr holder = { stringData }; - return QString(holder); + stringData.d->ref(); // the constructor below doesn't add a ref. + return QString(stringData); } void QBinaryJsonValue::detach() diff --git a/src/corelib/serialization/qbinaryjsonvalue_p.h b/src/corelib/serialization/qbinaryjsonvalue_p.h index 498fc62ecd..f2ca1a8094 100644 --- a/src/corelib/serialization/qbinaryjsonvalue_p.h +++ b/src/corelib/serialization/qbinaryjsonvalue_p.h @@ -85,18 +85,17 @@ public: ~QBinaryJsonValue(); QBinaryJsonValue(QBinaryJsonValue &&other) noexcept - : ui(other.ui), + : stringData(other.stringData), d(other.d), t(other.t) { - other.ui = 0; other.d = nullptr; other.t = QJsonValue::Null; } QBinaryJsonValue &operator =(QBinaryJsonValue &&other) noexcept { - qSwap(ui, other.ui); + qSwap(stringData, other.stringData); qSwap(d, other.d); qSwap(t, other.t); return *this; @@ -122,7 +121,7 @@ private: quint64 ui; bool b; double dbl; - QStringData *stringData; + QStringPrivate stringData; const QBinaryJsonPrivate::Base *base; }; QBinaryJsonPrivate::MutableData *d = nullptr; // needed for Objects and Arrays diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 3b6c3fb70f..e1cd018351 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -100,7 +100,7 @@ #define ULLONG_MAX quint64_C(18446744073709551615) #endif -#define IS_RAW_DATA(d) ((d)->flags & QArrayData::RawDataType) +#define IS_RAW_DATA(d) ((d.d)->flags & QArrayData::RawDataType) QT_BEGIN_NAMESPACE @@ -2100,8 +2100,10 @@ int QString::toUcs4_helper(const ushort *uc, int length, uint *out) */ QString::QString(const QChar *unicode, int size) { - if (!unicode) { - d = Data::sharedNull(); + if (!unicode) { + d.d = Data::sharedNull(); + d.b = Data::sharedNullData(); + d.size = 0; } else { if (size < 0) { size = 0; @@ -2109,13 +2111,18 @@ QString::QString(const QChar *unicode, int size) ++size; } if (!size) { - d = Data::allocate(0).first; + QPair<Data *, ushort *> pair = Data::allocate(0); + d.d = pair.first; + d.b = pair.second; + d.size = 0; } else { - d = Data::allocate(size + 1).first; - Q_CHECK_PTR(d); - d->size = size; - memcpy(d->data(), unicode, size * sizeof(QChar)); - d->data()[size] = '\0'; + QPair<Data *, ushort *> pair = Data::allocate(size + 1); + d.d = pair.first; + d.b = pair.second; + d.size = size; + Q_CHECK_PTR(d.d); + memcpy(d.b, unicode, size * sizeof(QChar)); + d.b[size] = '\0'; } } } @@ -2128,15 +2135,20 @@ QString::QString(const QChar *unicode, int size) */ QString::QString(int size, QChar ch) { - if (size <= 0) { - d = Data::allocate(0).first; + if (size <= 0) { + QPair<Data *, ushort *> pair = Data::allocate(0); + d.d = pair.first; + d.b = pair.second; + d.size = 0; } else { - d = Data::allocate(size + 1).first; - Q_CHECK_PTR(d); - d->size = size; - d->data()[size] = '\0'; - ushort *i = d->data() + size; - ushort *b = d->data(); + QPair<Data *, ushort *> pair = Data::allocate(size + 1); + d.d = pair.first; + d.b = pair.second; + d.size = size; + Q_CHECK_PTR(d.d); + d.b[size] = '\0'; + ushort *i = d.b + size; + ushort *b = d.b; const ushort value = ch.unicode(); while (i != b) *--i = value; @@ -2151,10 +2163,12 @@ QString::QString(int size, QChar ch) */ QString::QString(int size, Qt::Initialization) { - d = Data::allocate(size + 1).first; - Q_CHECK_PTR(d); - d->size = size; - d->data()[size] = '\0'; + QPair<Data *, ushort *> pair = Data::allocate(size + 1); + d.d = pair.first; + d.b = pair.second; + d.size = size; + Q_CHECK_PTR(d.d); + d.b[size] = '\0'; } /*! \fn QString::QString(QLatin1String str) @@ -2169,11 +2183,13 @@ QString::QString(int size, Qt::Initialization) */ QString::QString(QChar ch) { - d = Data::allocate(2).first; - Q_CHECK_PTR(d); - d->size = 1; - d->data()[0] = ch.unicode(); - d->data()[1] = '\0'; + QPair<Data *, ushort *> pair = Data::allocate(2); + d.d = pair.first; + d.b = pair.second; + d.size = 1; + Q_CHECK_PTR(d.d); + d.b[0] = ch.unicode(); + d.b[1] = '\0'; } /*! \fn QString::QString(const QByteArray &ba) @@ -2195,7 +2211,7 @@ QString::QString(QChar ch) \internal */ -/*! \fn QString::QString(QStringDataPtr) +/*! \fn QString::QString(QStringPrivate) \internal */ @@ -2265,16 +2281,16 @@ void QString::resize(int size) if (size < 0) size = 0; - if (!d->isShared() && !d->isMutable() && size < d->size) { - d->size = size; + if (!d.d->isShared() && !d.d->isMutable() && size < int(d.size)) { + d.size = size; return; } - if (d->needsDetach() || size > capacity()) + if (d.d->needsDetach() || size > capacity()) reallocData(uint(size) + 1u, true); - if (d->isMutable()) { - d->size = size; - d->data()[size] = '\0'; + if (d.d->isMutable()) { + d.size = size; + d.b[size] = '\0'; } } @@ -2294,7 +2310,7 @@ void QString::resize(int size, QChar fillChar) resize(size); const int difference = length() - oldSize; if (difference > 0) - std::fill_n(d->begin() + oldSize, difference, fillChar.unicode()); + std::fill_n(d.b + oldSize, difference, fillChar.unicode()); } /*! \fn int QString::capacity() const @@ -2349,30 +2365,33 @@ void QString::resize(int size, QChar fillChar) void QString::reallocData(uint alloc, bool grow) { - auto allocOptions = d->detachFlags(); + auto allocOptions = d.d->detachFlags(); if (grow) allocOptions |= QArrayData::GrowsForward; - if (d->needsDetach()) { - Data *x = Data::allocate(alloc, allocOptions).first; - Q_CHECK_PTR(x); - x->size = qMin(int(alloc) - 1, d->size); - ::memcpy(x->data(), d->data(), x->size * sizeof(QChar)); - x->data()[x->size] = 0; - if (!d->deref()) - Data::deallocate(d); - d = x; + if (d.d->needsDetach()) { + QPair<Data *, ushort *> pair = Data::allocate(alloc, allocOptions); + Q_CHECK_PTR(pair.first); + d.size = qMin(alloc - 1, d.size); + ::memcpy(pair.second, d.b, d.size * sizeof(QChar)); + pair.second[d.size] = 0; + if (!d.d->deref()) + Data::deallocate(d.d); + d.d = pair.first; + d.b = pair.second; } else { - Data *p = Data::reallocateUnaligned(d, d->data(), alloc, allocOptions).first; - Q_CHECK_PTR(p); - d = p; + QPair<Data *, ushort *> pair = + Data::reallocateUnaligned(static_cast<Data *>(d.d), d.b, alloc, allocOptions); + Q_CHECK_PTR(pair.first); + d.d = pair.first; + d.b = pair.second; } } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void QString::expand(int i) { - resize(qMax(i + 1, d->size), QLatin1Char(' ')); + resize(qMax(i + 1, size()), QLatin1Char(' ')); } #endif @@ -2391,9 +2410,9 @@ void QString::expand(int i) QString &QString::operator=(const QString &other) noexcept { - other.d->ref(); - if (!d->deref()) - Data::deallocate(d); + other.d.d->ref(); + if (!d.d->deref()) + Data::deallocate(d.d); d = other.d; return *this; } @@ -2415,9 +2434,9 @@ QString &QString::operator=(const QString &other) noexcept QString &QString::operator=(QLatin1String other) { if (isDetached() && other.size() <= capacity()) { // assumes d->alloc == 0 -> !isDetached() (sharedNull) - d->size = other.size(); - d->data()[other.size()] = 0; - qt_from_latin1(d->data(), other.latin1(), other.size()); + d.size = other.size(); + d.b[other.size()] = 0; + qt_from_latin1(d.b, other.latin1(), other.size()); } else { *this = fromLatin1(other.latin1(), other.size()); } @@ -2480,10 +2499,9 @@ QString &QString::operator=(QChar ch) { if (isDetached() && capacity() >= 1) { // assumes d->alloc == 0 -> !isDetached() (sharedNull) // re-use existing capacity: - ushort *dat = d->data(); - dat[0] = ch.unicode(); - dat[1] = 0; - d->size = 1; + d.b[0] = ch.unicode(); + d.b[1] = 0; + d.size = 1; } else { operator=(QString(ch)); } @@ -2569,13 +2587,13 @@ QString &QString::insert(int i, QLatin1String str) return *this; int len = str.size(); - if (Q_UNLIKELY(i > d->size)) + if (Q_UNLIKELY(i > size())) resize(i + len, QLatin1Char(' ')); else - resize(d->size + len); + resize(size() + len); - ::memmove(d->data() + i + len, d->data() + i, (d->size - i - len) * sizeof(QChar)); - qt_from_latin1(d->data() + i, s, uint(len)); + ::memmove(d.b + i + len, d.b + i, (d.size - i - len) * sizeof(QChar)); + qt_from_latin1(d.b + i, s, uint(len)); return *this; } @@ -2592,7 +2610,7 @@ QString& QString::insert(int i, const QChar *unicode, int size) return *this; const ushort *s = (const ushort *)unicode; - if (s >= d->data() && s < d->data() + d->size) { + if (s >= d.b && s < d.b + d.size) { // Part of me - take a copy ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar))); Q_CHECK_PTR(tmp); @@ -2602,13 +2620,13 @@ QString& QString::insert(int i, const QChar *unicode, int size) return *this; } - if (Q_UNLIKELY(i > d->size)) + if (Q_UNLIKELY(i > int(d.size))) resize(i + size, QLatin1Char(' ')); else - resize(d->size + size); + resize(d.size + size); - ::memmove(d->data() + i + size, d->data() + i, (d->size - i - size) * sizeof(QChar)); - memcpy(d->data() + i, s, size * sizeof(QChar)); + ::memmove(d.b + i + size, d.b + i, (d.size - i - size) * sizeof(QChar)); + memcpy(d.b + i, s, size * sizeof(QChar)); return *this; } @@ -2622,15 +2640,15 @@ QString& QString::insert(int i, const QChar *unicode, int size) QString& QString::insert(int i, QChar ch) { if (i < 0) - i += d->size; + i += d.size; if (i < 0) return *this; - if (Q_UNLIKELY(i > d->size)) + if (Q_UNLIKELY(i > size())) resize(i + 1, QLatin1Char(' ')); else - resize(d->size + 1); - ::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar)); - d->data()[i] = ch.unicode(); + resize(d.size + 1); + ::memmove(d.b + i + 1, d.b + i, (d.size - i - 1) * sizeof(QChar)); + d.b[i] = ch.unicode(); return *this; } @@ -2654,15 +2672,15 @@ QString& QString::insert(int i, QChar ch) */ QString &QString::append(const QString &str) { - if (str.d != Data::sharedNull()) { - if (d == Data::sharedNull()) { + if (!str.isNull()) { + if (isNull()) { operator=(str); } else { - if (d->needsDetach() || d->size + str.d->size > capacity()) - reallocData(uint(d->size + str.d->size) + 1u, true); - memcpy(d->data() + d->size, str.d->data(), str.d->size * sizeof(QChar)); - d->size += str.d->size; - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + str.size() > capacity()) + reallocData(uint(size() + str.size()) + 1u, true); + memcpy(d.b + d.size, str.d.b, str.d.size * sizeof(QChar)); + d.size += str.d.size; + d.b[d.size] = '\0'; } } return *this; @@ -2677,11 +2695,11 @@ QString &QString::append(const QString &str) QString &QString::append(const QChar *str, int len) { if (str && len > 0) { - if (d->needsDetach() || uint(d->size + len) + 1u > d->allocatedCapacity()) - reallocData(uint(d->size + len) + 1u, true); - memcpy(d->data() + d->size, str, len * sizeof(QChar)); - d->size += len; - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, true); + memcpy(d.b + d.size, str, len * sizeof(QChar)); + d.size += len; + d.b[d.size] = '\0'; } return *this; } @@ -2696,12 +2714,12 @@ QString &QString::append(QLatin1String str) const char *s = str.latin1(); if (s) { int len = str.size(); - if (d->needsDetach() || d->size + len > capacity()) - reallocData(uint(d->size + len) + 1u, true); - ushort *i = d->data() + d->size; + if (d.d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, true); + ushort *i = d.b + d.size; qt_from_latin1(i, s, uint(len)); i[len] = '\0'; - d->size += len; + d.size += len; } return *this; } @@ -2743,10 +2761,10 @@ QString &QString::append(QLatin1String str) */ QString &QString::append(QChar ch) { - if (d->needsDetach() || d->size + 1 > capacity()) - reallocData(uint(d->size) + 2u, true); - d->data()[d->size++] = ch.unicode(); - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + 1 > capacity()) + reallocData(uint(d.size) + 2u, true); + d.b[d.size++] = ch.unicode(); + d.b[d.size] = '\0'; return *this; } @@ -2839,16 +2857,16 @@ QString &QString::append(QChar ch) QString &QString::remove(int pos, int len) { if (pos < 0) // count from end of string - pos += d->size; - if (uint(pos) >= uint(d->size)) { + pos += size(); + if (uint(pos) >= uint(size())) { // range problems - } else if (len >= d->size - pos) { + } else if (len >= size() - pos) { resize(pos); // truncate } else if (len > 0) { detach(); - memmove(d->data() + pos, d->data() + pos + len, - (d->size - pos - len + 1) * sizeof(ushort)); - d->size -= len; + memmove(d.b + pos, d.b + pos + len, + (d.size - pos - len + 1) * sizeof(ushort)); + d.size -= len; } return *this; } @@ -2993,10 +3011,10 @@ QString &QString::replace(int pos, int len, const QString &after) */ QString &QString::replace(int pos, int len, const QChar *unicode, int size) { - if (uint(pos) > uint(d->size)) + if (uint(pos) > uint(this->size())) return *this; - if (len > d->size - pos) - len = d->size - pos; + if (len > this->size() - pos) + len = this->size() - pos; uint index = pos; replace_helper(&index, 1, len, unicode, size); @@ -3060,10 +3078,10 @@ bool pointsIntoRange(const QChar *ptr, const ushort *base, int len) */ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen) { - // Copy after if it lies inside our own d->data() area (which we could + // Copy after if it lies inside our own d.b area (which we could // possibly invalidate via a realloc or modify by replacement). QChar *afterBuffer = nullptr; - if (pointsIntoRange(after, d->data(), d->size)) // Use copy in place of vulnerable original: + if (pointsIntoRange(after, d.b, d.size)) // Use copy in place of vulnerable original: after = afterBuffer = textCopy(after, alen); QT_TRY { @@ -3071,36 +3089,36 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar // replace in place detach(); for (int i = 0; i < nIndices; ++i) - memcpy(d->data() + indices[i], after, alen * sizeof(QChar)); + memcpy(d.b + indices[i], after, alen * sizeof(QChar)); } else if (alen < blen) { // replace from front detach(); uint to = indices[0]; if (alen) - memcpy(d->data()+to, after, alen*sizeof(QChar)); + memcpy(d.b+to, after, alen*sizeof(QChar)); to += alen; uint movestart = indices[0] + blen; for (int i = 1; i < nIndices; ++i) { int msize = indices[i] - movestart; if (msize > 0) { - memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); + memmove(d.b + to, d.b + movestart, msize * sizeof(QChar)); to += msize; } if (alen) { - memcpy(d->data() + to, after, alen * sizeof(QChar)); + memcpy(d.b + to, after, alen * sizeof(QChar)); to += alen; } movestart = indices[i] + blen; } - int msize = d->size - movestart; + int msize = d.size - movestart; if (msize > 0) - memmove(d->data() + to, d->data() + movestart, msize * sizeof(QChar)); - resize(d->size - nIndices*(blen-alen)); + memmove(d.b + to, d.b + movestart, msize * sizeof(QChar)); + resize(d.size - nIndices*(blen-alen)); } else { // replace from back int adjust = nIndices*(alen-blen); - int newLen = d->size + adjust; - int moveend = d->size; + int newLen = d.size + adjust; + int moveend = d.size; resize(newLen); while (nIndices) { @@ -3108,9 +3126,9 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar int movestart = indices[nIndices] + blen; int insertstart = indices[nIndices] + nIndices*(alen-blen); int moveto = insertstart + alen; - memmove(d->data() + moveto, d->data() + movestart, + memmove(d.b + moveto, d.b + movestart, (moveend - movestart)*sizeof(QChar)); - memcpy(d->data() + insertstart, after, alen * sizeof(QChar)); + memcpy(d.b + insertstart, after, alen * sizeof(QChar)); moveend = movestart-blen; } } @@ -3136,7 +3154,7 @@ QString &QString::replace(const QChar *before, int blen, const QChar *after, int alen, Qt::CaseSensitivity cs) { - if (d->size == 0) { + if (d.size == 0) { if (blen) return *this; } else { @@ -3171,10 +3189,10 @@ QString &QString::replace(const QChar *before, int blen, We're about to change data, that before and after might point into, and we'll need that data for our next batch of indices. */ - if (!afterBuffer && pointsIntoRange(after, d->data(), d->size)) + if (!afterBuffer && pointsIntoRange(after, d.b, d.size)) after = afterBuffer = textCopy(after, alen); - if (!beforeBuffer && pointsIntoRange(before, d->data(), d->size)) { + if (!beforeBuffer && pointsIntoRange(before, d.b, d.size)) { beforeBuffer = textCopy(before, blen); matcher = QStringMatcher(beforeBuffer, blen, cs); } @@ -3203,13 +3221,13 @@ QString &QString::replace(const QChar *before, int blen, */ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs) { - if (after.d->size == 0) + if (after.size() == 0) return remove(ch, cs); - if (after.d->size == 1) + if (after.size() == 1) return replace(ch, after.front(), cs); - if (d->size == 0) + if (size() == 0) return *this; ushort cc = (cs == Qt::CaseSensitive ? ch.unicode() : ch.toCaseFolded().unicode()); @@ -3219,14 +3237,14 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs uint indices[1024]; uint pos = 0; if (cs == Qt::CaseSensitive) { - while (pos < 1024 && index < d->size) { - if (d->data()[index] == cc) + while (pos < 1024 && index < size()) { + if (d.b[index] == cc) indices[pos++] = index; index++; } } else { - while (pos < 1024 && index < d->size) { - if (QChar::toCaseFolded(d->data()[index]) == cc) + while (pos < 1024 && index < size()) { + if (QChar::toCaseFolded(d.b[index]) == cc) indices[pos++] = index; index++; } @@ -3234,12 +3252,12 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs if (!pos) // Nothing to replace break; - replace_helper(indices, pos, 1, after.constData(), after.d->size); + replace_helper(indices, pos, 1, after.constData(), after.size()); if (Q_LIKELY(index == -1)) // Nothing left to replace break; // The call to replace_helper just moved what index points at: - index += pos*(after.d->size - 1); + index += pos*(after.size() - 1); } return *this; } @@ -3254,13 +3272,13 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs */ QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs) { - if (d->size) { + if (d.size) { const int idx = indexOf(before, 0, cs); if (idx != -1) { detach(); const ushort a = after.unicode(); - ushort *i = d->data(); - const ushort *e = i + d->size; + ushort *i = d.b; + ushort *const e = i + d.size; i += idx; *i = a; if (cs == Qt::CaseSensitive) { @@ -3321,7 +3339,7 @@ QString &QString::replace(QLatin1String before, const QString &after, Qt::CaseSe int blen = before.size(); QVarLengthArray<ushort> b(blen); qt_from_latin1(b.data(), before.latin1(), blen); - return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs); + return replace((const QChar *)b.data(), blen, after.constData(), after.d.size, cs); } /*! @@ -3341,7 +3359,7 @@ QString &QString::replace(const QString &before, QLatin1String after, Qt::CaseSe int alen = after.size(); QVarLengthArray<ushort> a(alen); qt_from_latin1(a.data(), after.latin1(), alen); - return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs); + return replace(before.constData(), before.d.size, (const QChar *)a.data(), alen, cs); } /*! @@ -3377,7 +3395,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs) */ bool operator==(const QString &s1, const QString &s2) noexcept { - if (s1.d->size != s2.d->size) + if (s1.d.size != s2.d.size) return false; return qt_compare_strings(s1, s2, Qt::CaseSensitive) == 0; @@ -3390,7 +3408,7 @@ bool operator==(const QString &s1, const QString &s2) noexcept */ bool QString::operator==(QLatin1String other) const noexcept { - if (d->size != other.size()) + if (size() != other.size()) return false; return qt_compare_strings(*this, other, Qt::CaseSensitive) == 0; @@ -3936,7 +3954,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after) if (isEmpty() && rx2.indexIn(*this) == -1) return *this; - reallocData(uint(d->size) + 1u); + reallocData(uint(d.size) + 1u); int index = 0; int numCaptures = rx2.captureCount(); @@ -4035,8 +4053,8 @@ QString& QString::replace(const QRegExp &rx, const QString &after) } if (!pos) break; - replacements[pos].pos = d->size; - int newlen = d->size + adjust; + replacements[pos].pos = d.size; + int newlen = d.size + adjust; // to continue searching at the right position after we did // the first round of replacements @@ -4051,14 +4069,14 @@ QString& QString::replace(const QRegExp &rx, const QString &after) while (i < pos) { int copyend = replacements[i].pos; int size = copyend - copystart; - memcpy(static_cast<void*>(uc), static_cast<const void *>(d->data() + copystart), size * sizeof(QChar)); + memcpy(static_cast<void*>(uc), static_cast<const void *>(d.b + copystart), size * sizeof(QChar)); uc += size; - memcpy(static_cast<void *>(uc), static_cast<const void *>(after.d->data()), al * sizeof(QChar)); + memcpy(static_cast<void *>(uc), static_cast<const void *>(after.d.b), al * sizeof(QChar)); uc += al; copystart = copyend + replacements[i].length; i++; } - memcpy(static_cast<void *>(uc), static_cast<const void *>(d->data() + copystart), (d->size - copystart) * sizeof(QChar)); + memcpy(static_cast<void *>(uc), static_cast<const void *>(d.b + copystart), (d.size - copystart) * sizeof(QChar)); newstring.resize(newlen); *this = newstring; caretMode = QRegExp::CaretWontMatch; @@ -4098,7 +4116,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after) if (!iterator.hasNext()) // no matches at all return *this; - reallocData(uint(d->size) + 1u); + reallocData(uint(d.size) + 1u); int numCaptures = re.captureCount(); @@ -4850,9 +4868,9 @@ QString QString::section(const QRegularExpression &re, int start, int end, Secti */ QString QString::left(int n) const { - if (uint(n) >= uint(d->size)) + if (uint(n) >= uint(size())) return *this; - return QString((const QChar*) d->data(), n); + return QString((const QChar*) d.b, n); } /*! @@ -4868,9 +4886,9 @@ QString QString::left(int n) const */ QString QString::right(int n) const { - if (uint(n) >= uint(d->size)) + if (uint(n) >= uint(size())) return *this; - return QString((const QChar*) d->data() + d->size - n, n); + return QString(constData() + size() - n, n); } /*! @@ -4893,18 +4911,19 @@ QString QString::right(int n) const QString QString::mid(int position, int n) const { using namespace QtPrivate; - switch (QContainerImplHelper::mid(d->size, &position, &n)) { + switch (QContainerImplHelper::mid(size(), &position, &n)) { case QContainerImplHelper::Null: return QString(); case QContainerImplHelper::Empty: { - QStringDataPtr empty = { Data::allocate(0).first }; + QPair<Data *, ushort *> pair = Data::allocate(0); + QStringPrivate empty = { pair.first, pair.second, 0 }; return QString(empty); } case QContainerImplHelper::Full: return *this; case QContainerImplHelper::Subset: - return QString((const QChar*)d->data() + position, n); + return QString(constData() + position, n); } Q_UNREACHABLE(); return QString(); @@ -5151,7 +5170,7 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) // Swap the d pointers. // Kids, avert your eyes. Don't try this at home. - QArrayData *ba_d = s.d; + QArrayData *ba_d = s.d.d; // multiply the allocated capacity by sizeof(ushort) ba_d->alloc *= sizeof(ushort); @@ -5348,31 +5367,38 @@ QVector<uint> QtPrivate::convertToUcs4(QStringView string) return qt_convert_to_ucs4(string); } -QString::Data *QString::fromLatin1_helper(const char *str, int size) +QStringPrivate QString::fromLatin1_helper(const char *str, int size) { - Data *d; + QStringPrivate d; if (!str) { - d = Data::sharedNull(); + d.d = Data::sharedNull(); + d.b = Data::sharedNullData(); + d.size = 0; } else if (size == 0 || (!*str && size < 0)) { - d = Data::allocate(0).first; + QPair<Data *, ushort *> pair = Data::allocate(0); + d.d = pair.first; + d.b = pair.second; + d.size = 0; } else { if (size < 0) size = qstrlen(str); - d = Data::allocate(size + 1).first; - Q_CHECK_PTR(d); - d->size = size; - d->data()[size] = '\0'; - ushort *dst = d->data(); + QPair<Data *, ushort *> pair = Data::allocate(size + 1); + d.d = pair.first; + d.b = pair.second; + d.size = size; + Q_CHECK_PTR(d.d); + d.b[size] = '\0'; + ushort *dst = d.b; qt_from_latin1(dst, str, uint(size)); } return d; } -QString::Data *QString::fromAscii_helper(const char *str, int size) +QStringPrivate QString::fromAscii_helper(const char *str, int size) { QString s = fromUtf8(str, size); - s.d->ref(); + s.d.d->ref(); return s.d; } @@ -5418,7 +5444,8 @@ QString QString::fromLocal8Bit_helper(const char *str, int size) if (!str) return QString(); if (size == 0 || (!*str && size < 0)) { - QStringDataPtr empty = { Data::allocate(0).first }; + QPair<Data *, ushort *> pair = Data::allocate(0); + QStringPrivate empty = { pair.first, pair.second, 0 }; return QString(empty); } #if QT_CONFIG(textcodec) @@ -5588,7 +5615,7 @@ QString& QString::setUnicode(const QChar *unicode, int size) { resize(size); if (unicode && size) - memcpy(d->data(), unicode, size * sizeof(QChar)); + memcpy(d.b, unicode, size * sizeof(QChar)); return *this; } @@ -5821,7 +5848,7 @@ QString QString::trimmed_helper(QString &str) void QString::truncate(int pos) { - if (pos < d->size) + if (pos < size()) resize(pos); } @@ -5843,7 +5870,7 @@ void QString::truncate(int pos) void QString::chop(int n) { if (n > 0) - resize(d->size - n); + resize(d.size - n); } /*! @@ -5860,10 +5887,10 @@ void QString::chop(int n) QString& QString::fill(QChar ch, int size) { - resize(size < 0 ? d->size : size); - if (d->size) { - QChar *i = (QChar*)d->data() + d->size; - QChar *b = (QChar*)d->data(); + resize(size < 0 ? d.size : size); + if (d.size) { + QChar *i = (QChar*)d.b + d.size; + QChar *b = (QChar*)d.b; while (i != b) *--i = ch; } @@ -6444,11 +6471,11 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, const ushort *QString::utf16() const { - if (!d->isMutable()) { + if (!d.d->isMutable()) { // ensure '\0'-termination for ::fromRawData strings - const_cast<QString*>(this)->reallocData(uint(d->size) + 1u); + const_cast<QString*>(this)->reallocData(uint(d.size) + 1u); } - return d->data(); + return d.b; } /*! @@ -6477,8 +6504,8 @@ QString QString::leftJustified(int width, QChar fill, bool truncate) const if (padlen > 0) { result.resize(len+padlen); if (len) - memcpy(result.d->data(), d->data(), sizeof(QChar)*len); - QChar *uc = (QChar*)result.d->data() + len; + memcpy(result.d.b, d.b, sizeof(QChar)*len); + QChar *uc = (QChar*)result.d.b + len; while (padlen--) * uc++ = fill; } else { @@ -6515,11 +6542,11 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const int padlen = width - len; if (padlen > 0) { result.resize(len+padlen); - QChar *uc = (QChar*)result.d->data(); + QChar *uc = (QChar*)result.d.b; while (padlen--) * uc++ = fill; if (len) - memcpy(static_cast<void *>(uc), static_cast<const void *>(d->data()), sizeof(QChar)*len); + memcpy(static_cast<void *>(uc), static_cast<const void *>(d.b), sizeof(QChar)*len); } else { if (truncate) result = left(width); @@ -7928,7 +7955,7 @@ QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavio */ QString QString::repeated(int times) const { - if (d->size == 0) + if (d.size == 0) return *this; if (times <= 1) { @@ -7937,27 +7964,27 @@ QString QString::repeated(int times) const return QString(); } - const int resultSize = times * d->size; + const int resultSize = times * d.size; QString result; result.reserve(resultSize); if (result.capacity() != resultSize) return QString(); // not enough memory - memcpy(result.d->data(), d->data(), d->size * sizeof(ushort)); + memcpy(result.d.b, d.b, d.size * sizeof(ushort)); - int sizeSoFar = d->size; - ushort *end = result.d->data() + sizeSoFar; + int sizeSoFar = d.size; + ushort *end = result.d.b + sizeSoFar; const int halfResultSize = resultSize >> 1; while (sizeSoFar <= halfResultSize) { - memcpy(end, result.d->data(), sizeSoFar * sizeof(ushort)); + memcpy(end, result.d.b, sizeSoFar * sizeof(ushort)); end += sizeSoFar; sizeSoFar <<= 1; } - memcpy(end, result.d->data(), (resultSize - sizeSoFar) * sizeof(ushort)); - result.d->data()[resultSize] = '\0'; - result.d->size = resultSize; + memcpy(end, result.d.b, (resultSize - sizeSoFar) * sizeof(ushort)); + result.d.b[resultSize] = '\0'; + result.d.size = resultSize; return result; } @@ -8957,8 +8984,8 @@ QString QtPrivate::argToQString(QLatin1String pattern, size_t n, const ArgBase * */ bool QString::isSimpleText() const { - const ushort *p = d->data(); - const ushort * const end = p + d->size; + const ushort *p = d.b; + const ushort * const end = p + d.size; while (p < end) { ushort uc = *p; // sort out regions of complex text formatting @@ -9107,17 +9134,21 @@ bool QString::isRightToLeft() const */ QString QString::fromRawData(const QChar *unicode, int size) { - Data *x; + QStringPrivate x; + x.size = size; if (!unicode) { - x = Data::sharedNull(); + x.d = Data::sharedNull(); + x.b = Data::sharedNullData(); } else if (!size) { - x = Data::allocate(0).first; + QPair<Data *, ushort *> pair = Data::allocate(0); + x.d = pair.first; + x.b = pair.second; } else { - x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size).ptr; - Q_CHECK_PTR(x); + x.b = const_cast<ushort *>(reinterpret_cast<const ushort *>(unicode)); + x.d = Data::fromRawData(x.b, size).ptr; + Q_CHECK_PTR(x.d); } - QStringDataPtr dataPtr = { x }; - return QString(dataPtr); + return QString(x); } /*! @@ -9138,11 +9169,11 @@ QString &QString::setRawData(const QChar *unicode, int size) { if (!unicode || !size) { clear(); - } else if (d->isShared() || !IS_RAW_DATA(d)) { + } else if (d.d->isShared() || !IS_RAW_DATA(d)) { *this = fromRawData(unicode, size); } else { - d->size = size; - d->offset = reinterpret_cast<const char *>(unicode) - reinterpret_cast<char *>(d); + d.size = size; + d.b = const_cast<ushort *>(reinterpret_cast<const ushort *>(unicode)); } return *this; } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 74528b47c5..c2168af889 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -48,7 +48,7 @@ #include <QtCore/qchar.h> #include <QtCore/qbytearray.h> -#include <QtCore/qrefcount.h> +#include <QtCore/qarraydata.h> #include <QtCore/qnamespace.h> #include <QtCore/qstringliteral.h> #include <QtCore/qstringalgorithms.h> @@ -246,9 +246,8 @@ qsizetype QStringView::lastIndexOf(QLatin1String s, qsizetype from, Qt::CaseSens class Q_CORE_EXPORT QString { + typedef QTypedArrayData<ushort> Data; public: - typedef QStringData Data; - inline QString() noexcept; explicit QString(const QChar *unicode, int size = -1); QString(QChar c); @@ -259,12 +258,13 @@ public: QString &operator=(QChar c); QString &operator=(const QString &) noexcept; QString &operator=(QLatin1String latin1); - inline QString(QString && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + inline QString(QString &&other) noexcept : d(std::move(other.d)) + { other.d.d = Data::sharedNull(); other.d.b = Data::sharedNullData(); other.d.size = 0; } inline QString &operator=(QString &&other) noexcept { qSwap(d, other.d); return *this; } inline void swap(QString &other) noexcept { qSwap(d, other.d); } - inline int size() const { return d->size; } - inline int count() const { return d->size; } + inline int size() const { return d.size; } + inline int count() const { return d.size; } inline int length() const; inline bool isEmpty() const; void resize(int size); @@ -285,7 +285,7 @@ public: inline void detach(); inline bool isDetached() const; - inline bool isSharedWith(const QString &other) const { return d == other.d; } + inline bool isSharedWith(const QString &other) const { return d.d == other.d.d; } void clear(); inline const QChar at(int i) const; @@ -540,10 +540,10 @@ public: inline QString &prepend(QLatin1String s) { return insert(0, s); } inline QString &operator+=(QChar c) { - if (d->needsDetach() || d->size + 1 > capacity()) - reallocData(uint(d->size) + 2u, true); - d->data()[d->size++] = c.unicode(); - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || int(d.size + 1) > capacity()) + reallocData(uint(d.size) + 2u, true); + d.b[d.size++] = c.unicode(); + d.b[d.size] = '\0'; return *this; } @@ -656,8 +656,7 @@ public: // note - this are all inline so we can benefit from strlen() compile time optimizations static inline QString fromLatin1(const char *str, int size = -1) { - QStringDataPtr dataPtr = { fromLatin1_helper(str, (str && size == -1) ? int(strlen(str)) : size) }; - return QString(dataPtr); + return QString(fromLatin1_helper(str, (str && size == -1) ? int(strlen(str)) : size)); } static inline QString fromUtf8(const char *str, int size = -1) { @@ -908,17 +907,17 @@ public: struct Null { }; QT_DEPRECATED_X("use QString()") static const Null null; - inline QString(const Null &): d(Data::sharedNull()) {} + inline QString(const Null &) { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } inline QString &operator=(const Null &) { *this = QString(); return *this; } #endif - inline bool isNull() const { return d == Data::sharedNull(); } + inline bool isNull() const { return d.d == Data::sharedNull(); } bool isSimpleText() const; bool isRightToLeft() const; QString(int size, Qt::Initialization); - Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {} + explicit QString(QStringPrivate dd) : d(dd) {} private: #if defined(QT_NO_CAST_FROM_ASCII) @@ -930,7 +929,7 @@ private: QString &operator=(const QByteArray &a); #endif - Data *d; + QStringPrivate d; friend inline bool operator==(QChar, const QString &) noexcept; friend inline bool operator< (QChar, const QString &) noexcept; @@ -968,8 +967,8 @@ private: static QString trimmed_helper(QString &str); static QString simplified_helper(const QString &str); static QString simplified_helper(QString &str); - static Data *fromLatin1_helper(const char *str, int size = -1); - static Data *fromAscii_helper(const char *str, int size = -1); + static QStringPrivate fromLatin1_helper(const char *str, int size = -1); + static QStringPrivate fromAscii_helper(const char *str, int size = -1); static QString fromUtf8_helper(const char *str, int size); static QString fromLocal8Bit_helper(const char *, int size); static QByteArray toLatin1_helper(const QString &); @@ -1005,7 +1004,7 @@ private: } public: - typedef Data * DataPtr; + typedef QStringPrivate DataPtr; inline DataPtr &data_ptr() { return d; } }; @@ -1021,31 +1020,31 @@ QString QStringView::toString() const inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1.latin1(), aLatin1.size())) { } inline int QString::length() const -{ return d->size; } +{ return d.size; } inline const QChar QString::at(int i) const -{ Q_ASSERT(uint(i) < uint(size())); return QChar(d->data()[i]); } +{ Q_ASSERT(uint(i) < uint(size())); return QChar(d.b[i]); } inline const QChar QString::operator[](int i) const -{ Q_ASSERT(uint(i) < uint(size())); return QChar(d->data()[i]); } +{ Q_ASSERT(uint(i) < uint(size())); return QChar(d.b[i]); } inline bool QString::isEmpty() const -{ return d->size == 0; } +{ return d.size == 0; } inline const QChar *QString::unicode() const -{ return reinterpret_cast<const QChar*>(d->data()); } +{ return reinterpret_cast<const QChar*>(d.b); } inline const QChar *QString::data() const -{ return reinterpret_cast<const QChar*>(d->data()); } +{ return reinterpret_cast<const QChar*>(d.b); } inline QChar *QString::data() -{ detach(); return reinterpret_cast<QChar*>(d->data()); } +{ detach(); return reinterpret_cast<QChar*>(d.b); } inline const QChar *QString::constData() const -{ return reinterpret_cast<const QChar*>(d->data()); } +{ return reinterpret_cast<const QChar*>(d.b); } inline void QString::detach() -{ if (d->needsDetach()) reallocData(uint(d->size) + 1u); } +{ if (d.d->needsDetach()) reallocData(d.size + 1u); } inline bool QString::isDetached() const -{ return !d->isShared(); } +{ return !d.d->isShared(); } inline void QString::clear() { if (!isNull()) *this = QString(); } inline QString::QString(const QString &other) noexcept : d(other.d) -{ Q_ASSERT(&other != this); d->ref(); } +{ Q_ASSERT(&other != this); d.d->ref(); } inline int QString::capacity() const -{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } +{ int realCapacity = d.d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline QString &QString::setNum(short n, int base) { return setNum(qlonglong(n), base); } inline QString &QString::setNum(ushort n, int base) @@ -1150,8 +1149,8 @@ public: inline operator QChar() const { using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_LIKELY(i < s.d->size)) - return QChar(s.d->data()[i]); + if (Q_LIKELY(i < s.size())) + return QChar(s.constData()[i]); #ifdef QT_DEBUG warn(WarningType::OutOfRange, EmittingClass::QCharRef); #endif @@ -1160,7 +1159,7 @@ public: inline QCharRef &operator=(QChar c) { using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_UNLIKELY(i >= s.d->size)) { + if (Q_UNLIKELY(i >= s.size())) { #ifdef QT_DEBUG warn(WarningType::OutOfRange, EmittingClass::QCharRef); #endif @@ -1172,7 +1171,7 @@ public: #endif s.detach(); } - s.d->data()[i] = c.unicode(); + s.d.b[i] = c.unicode(); return *this; } @@ -1254,27 +1253,27 @@ inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); } inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); } -inline QString::QString() noexcept : d(Data::sharedNull()) {} -inline QString::~QString() { if (!d->deref()) Data::deallocate(d); } +inline QString::QString() noexcept { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } +inline QString::~QString() { if (!d.d->deref()) Data::deallocate(d.d); } inline void QString::reserve(int asize) { - if (d->needsDetach() || asize >= capacity()) + if (d.d->needsDetach() || asize >= capacity()) reallocData(qMax(asize, size()) + 1u); // we're not shared anymore, for sure - d->flags |= Data::CapacityReserved; + d.d->flags |= Data::CapacityReserved; } inline void QString::squeeze() { - if ((d->flags & Data::CapacityReserved) == 0) + if ((d.d->flags & Data::CapacityReserved) == 0) return; - if (d->needsDetach() || d->size < capacity()) - reallocData(uint(d->size) + 1u); + if (d.d->needsDetach() || int(d.size) < capacity()) + reallocData(uint(d.size) + 1u); // we're not shared anymore, for sure - d->flags &= ~Data::CapacityReserved; + d.d->flags &= ~Data::CapacityReserved; } inline QString &QString::setUtf16(const ushort *autf16, int asize) @@ -1284,21 +1283,21 @@ inline QCharRef QString::operator[](int i) inline QCharRef QString::front() { return operator[](0); } inline QCharRef QString::back() { return operator[](size() - 1); } inline QString::iterator QString::begin() -{ detach(); return reinterpret_cast<QChar*>(d->data()); } +{ detach(); return reinterpret_cast<QChar*>(d.b); } inline QString::const_iterator QString::begin() const -{ return reinterpret_cast<const QChar*>(d->data()); } +{ return reinterpret_cast<const QChar*>(d.b); } inline QString::const_iterator QString::cbegin() const -{ return reinterpret_cast<const QChar*>(d->data()); } +{ return reinterpret_cast<const QChar*>(d.b); } inline QString::const_iterator QString::constBegin() const -{ return reinterpret_cast<const QChar*>(d->data()); } +{ return reinterpret_cast<const QChar*>(d.b); } inline QString::iterator QString::end() -{ detach(); return reinterpret_cast<QChar*>(d->data() + d->size); } +{ detach(); return reinterpret_cast<QChar*>(d.b + d.size); } inline QString::const_iterator QString::end() const -{ return reinterpret_cast<const QChar*>(d->data() + d->size); } +{ return reinterpret_cast<const QChar*>(d.b + d.size); } inline QString::const_iterator QString::cend() const -{ return reinterpret_cast<const QChar*>(d->data() + d->size); } +{ return reinterpret_cast<const QChar*>(d.b + d.size); } inline QString::const_iterator QString::constEnd() const -{ return reinterpret_cast<const QChar*>(d->data() + d->size); } +{ return reinterpret_cast<const QChar*>(d.b + d.size); } #if QT_STRINGVIEW_LEVEL < 2 inline bool QString::contains(const QString &s, Qt::CaseSensitivity cs) const { return indexOf(s, 0, cs) != -1; } @@ -1525,7 +1524,8 @@ inline QString QString::fromStdU32String(const std::u32string &s) inline std::u32string QString::toStdU32String() const { std::u32string u32str(length(), char32_t(0)); - int len = toUcs4_helper(d->data(), length(), reinterpret_cast<uint*>(&u32str[0])); + int len = toUcs4_helper(reinterpret_cast<const ushort *>(constData()), length(), + reinterpret_cast<uint*>(&u32str[0])); u32str.resize(len); return u32str; } @@ -1657,7 +1657,7 @@ public: inline const QChar *unicode() const { if (!m_string) - return reinterpret_cast<const QChar *>(QString::Data::sharedNull()->data()); + return reinterpret_cast<const QChar *>(QString::Data::sharedNullData()); return m_string->unicode() + m_position; } inline const QChar *data() const { return unicode(); } diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index a0d4ddc30b..a8cf8e2c64 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -49,8 +49,6 @@ QT_BEGIN_NAMESPACE -typedef QTypedArrayData<ushort> QStringData; - // all our supported compilers support Unicode string literals, // even if their Q_COMPILER_UNICODE_STRING has been revoked due // to lacking stdlib support. But QStringLiteral only needs the @@ -65,43 +63,27 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, #define QStringLiteral(str) \ ([]() noexcept -> QString { \ enum { Size = sizeof(QT_UNICODE_LITERAL(str))/2 - 1 }; \ - static const QStaticStringData<Size> qstring_literal = { \ - Q_STATIC_STRING_DATA_HEADER_INITIALIZER(Size), \ - QT_UNICODE_LITERAL(str) }; \ - QStringDataPtr holder = { qstring_literal.data_ptr() }; \ - const QString qstring_literal_temp(holder); \ - return qstring_literal_temp; \ + static const QArrayData qstring_literal = { \ + Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, Size, 0, sizeof(QArrayData) \ + }; \ + QStringPrivate holder = { \ + const_cast<QArrayData *>(&qstring_literal), \ + reinterpret_cast<ushort *>(const_cast<qunicodechar *>(QT_UNICODE_LITERAL(str))), \ + Size \ + }; \ + return QString(holder); \ }()) \ /**/ -#define Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, size, 0, offset } \ - /**/ - -#define Q_STATIC_STRING_DATA_HEADER_INITIALIZER(size) \ - Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, sizeof(QStringData)) \ - /**/ - #if QT_DEPRECATED_SINCE(5, 14) # define QStringViewLiteral(str) QStringView(QT_UNICODE_LITERAL(str), QtPrivate::Deprecated) #endif -template <int N> -struct QStaticStringData -{ - QArrayData str; - qunicodechar data[N + 1]; - - QStringData *data_ptr() const - { - Q_ASSERT(str.isStatic()); - return const_cast<QStringData *>(static_cast<const QStringData*>(&str)); - } -}; - -struct QStringDataPtr +struct QStringPrivate { - QStringData *ptr; + QArrayData *d; + ushort *b; + uint size; }; QT_END_NAMESPACE -- cgit v1.2.3 From e58b44d557b859b7b55869f1e137aa1bc8968307 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 11 Nov 2019 15:00:51 +0100 Subject: Change representation of string data in the meta object Don't store our string data as QByteArrayLiterals anymore, but revert back to simply storing them as an array of char* and offsets into that array. This is required to be able to inline size and begin into QByteArray itself. Once that change is done, we can then avoid creating copies of the string data again. Change-Id: I362a54581caefdb1b3da4a7ab922d37e2e63dc02 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/kernel/qmetaobject.cpp | 33 ++++++++++++++++++------------- src/corelib/kernel/qmetaobjectbuilder.cpp | 22 ++++++++++----------- src/corelib/kernel/qobjectdefs.h | 2 +- src/dbus/qdbusmetaobject.cpp | 2 +- src/tools/moc/generator.cpp | 13 +++++------- 5 files changed, 36 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f093111a8c..87cced41f8 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -154,19 +154,29 @@ QT_BEGIN_NAMESPACE static inline const QMetaObjectPrivate *priv(const uint* data) { return reinterpret_cast<const QMetaObjectPrivate*>(data); } +static inline const char *rawStringData(const QMetaObject *mo, int index) +{ + Q_ASSERT(priv(mo->d.data)->revision >= 7); + uint offset = mo->d.stringdata[2*index]; + return reinterpret_cast<const char *>(mo->d.stringdata) + offset; +} + static inline const QByteArray stringData(const QMetaObject *mo, int index) { Q_ASSERT(priv(mo->d.data)->revision >= 7); - const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; - Q_ASSERT(data.ptr->isStatic()); - Q_ASSERT(data.ptr->allocatedCapacity() == 0); - Q_ASSERT(data.ptr->size >= 0); - return data; + uint offset = mo->d.stringdata[2*index]; + uint length = mo->d.stringdata[2*index + 1]; + const char *string = reinterpret_cast<const char *>(mo->d.stringdata) + offset; + return QByteArray::fromRawData(string, length); } -static inline const char *rawStringData(const QMetaObject *mo, int index) +static inline const char *rawTypeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) { - return stringData(mo, index).data(); + if (typeInfo & IsUnresolvedType) { + return rawStringData(mo, typeInfo & TypeNameIndexMask); + } else { + return QMetaType::typeName(typeInfo); + } } static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) @@ -180,16 +190,11 @@ static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeIn } } -static inline const char *rawTypeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) -{ - return typeNameFromTypeInfo(mo, typeInfo).constData(); -} - static inline int typeFromTypeInfo(const QMetaObject *mo, uint typeInfo) { if (!(typeInfo & IsUnresolvedType)) return typeInfo; - return QMetaType::type(stringData(mo, typeInfo & TypeNameIndexMask)); + return QMetaType::type(rawStringData(mo, typeInfo & TypeNameIndexMask)); } class QMetaMethodPrivate : public QMetaMethod @@ -576,7 +581,7 @@ static bool methodMatch(const QMetaObject *m, int handle, if (int(m->d.data[handle + 1]) != argc) return false; - if (stringData(m, m->d.data[handle]) != name) + if (rawStringData(m, m->d.data[handle]) != name) return false; int paramsIndex = m->d.data[handle + 2] + 1; diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index aab9e05182..2487681f78 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1103,13 +1103,13 @@ int QMetaStringTable::enter(const QByteArray &value) int QMetaStringTable::preferredAlignment() { - return alignof(QByteArrayData); + return alignof(uint); } // Returns the size (in bytes) required for serializing this string table. int QMetaStringTable::blobSize() const { - int size = m_entries.size() * sizeof(QByteArrayData); + int size = m_entries.size() * 2*sizeof(uint); Entries::const_iterator it; for (it = m_entries.constBegin(); it != m_entries.constEnd(); ++it) size += it.key().size() + 1; @@ -1120,14 +1120,12 @@ static void writeString(char *out, int i, const QByteArray &str, const int offsetOfStringdataMember, int &stringdataOffset) { int size = str.size(); - qptrdiff offset = offsetOfStringdataMember + stringdataOffset - - i * sizeof(QByteArrayData); - const QByteArrayData data = - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset); + int offset = offsetOfStringdataMember + stringdataOffset; + uint offsetLen[2] = { uint(offset), uint(size) }; - memcpy(out + i * sizeof(QByteArrayData), &data, sizeof(QByteArrayData)); + memcpy(out + 2 * i * sizeof(uint), &offsetLen, 2*sizeof(uint)); - memcpy(out + offsetOfStringdataMember + stringdataOffset, str.constData(), size); + memcpy(out + offset, str.constData(), size); out[offsetOfStringdataMember + stringdataOffset + size] = '\0'; stringdataOffset += size + 1; @@ -1141,7 +1139,7 @@ void QMetaStringTable::writeBlob(char *out) const { Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1))); - int offsetOfStringdataMember = m_entries.size() * sizeof(QByteArrayData); + int offsetOfStringdataMember = m_entries.size() * 2*sizeof(uint); int stringdataOffset = 0; // qt_metacast expects the first string in the string table to be the class name. @@ -1282,10 +1280,10 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, char *str = reinterpret_cast<char *>(buf + size); if (buf) { if (relocatable) { - meta->d.stringdata = reinterpret_cast<const QByteArrayData *>((quintptr)size); + meta->d.stringdata = reinterpret_cast<const uint *>((quintptr)size); meta->d.data = reinterpret_cast<uint *>((quintptr)pmetaSize); } else { - meta->d.stringdata = reinterpret_cast<const QByteArrayData *>(str); + meta->d.stringdata = reinterpret_cast<const uint *>(str); meta->d.data = reinterpret_cast<uint *>(data); } } @@ -1553,7 +1551,7 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output, quintptr dataOffset = (quintptr)dataMo->d.data; output->d.superdata = superclass; - output->d.stringdata = reinterpret_cast<const QByteArrayData *>(buf + stringdataOffset); + output->d.stringdata = reinterpret_cast<const uint *>(buf + stringdataOffset); output->d.data = reinterpret_cast<const uint *>(buf + dataOffset); output->d.extradata = 0; output->d.relatedMetaObjects = 0; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 90e3aa02d8..c4b9979293 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -424,7 +424,7 @@ struct Q_CORE_EXPORT QMetaObject struct { // private data SuperData superdata; - const QByteArrayData *stringdata; + const uint *stringdata; const uint *data; typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **); StaticMetacallFunction static_metacall; diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 806cf7b415..9a51fbc224 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -547,7 +547,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) obj->d.relatedMetaObjects = 0; obj->d.static_metacall = 0; obj->d.extradata = 0; - obj->d.stringdata = reinterpret_cast<const QByteArrayData *>(string_data); + obj->d.stringdata = reinterpret_cast<const uint *>(string_data); obj->d.superdata = &QDBusAbstractInterface::staticMetaObject; } diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index a9bf934e79..7c35af8709 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -236,7 +236,7 @@ void Generator::generateCode() // const int constCharArraySizeLimit = 65535; fprintf(out, "struct qt_meta_stringdata_%s_t {\n", qualifiedClassNameIdentifier.constData()); - fprintf(out, " QByteArrayData data[%d];\n", strings.size()); + fprintf(out, " const uint offsetsAndSize[%d];\n", strings.size()*2); { int stringDataLength = 0; int stringDataCounter = 0; @@ -259,11 +259,8 @@ void Generator::generateCode() // stringdata.stringdata member, and 2) the stringdata.data index of the // QByteArrayData being defined. This calculation relies on the // QByteArrayData::data() implementation returning simply "this + offset". - fprintf(out, "#define QT_MOC_LITERAL(idx, ofs, len) \\\n" - " Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n" - " qptrdiff(offsetof(qt_meta_stringdata_%s_t, stringdata0) + ofs \\\n" - " - idx * sizeof(QByteArrayData)) \\\n" - " )\n", + fprintf(out, "#define QT_MOC_LITERAL(ofs, len) \\\n" + " uint(offsetof(qt_meta_stringdata_%s_t, stringdata0) + ofs), len \n", qualifiedClassNameIdentifier.constData()); fprintf(out, "static const qt_meta_stringdata_%s_t qt_meta_stringdata_%s = {\n", @@ -273,7 +270,7 @@ void Generator::generateCode() int idx = 0; for (int i = 0; i < strings.size(); ++i) { const QByteArray &str = strings.at(i); - fprintf(out, "QT_MOC_LITERAL(%d, %d, %d)", i, idx, str.length()); + fprintf(out, "QT_MOC_LITERAL(%d, %d)", idx, str.length()); if (i != strings.size() - 1) fputc(',', out); const QByteArray comment = str.length() > 32 ? str.left(29) + "..." : str; @@ -541,7 +538,7 @@ void Generator::generateCode() fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", purestSuperClass.constData()); else fprintf(out, " nullptr,\n"); - fprintf(out, " qt_meta_stringdata_%s.data,\n" + fprintf(out, " qt_meta_stringdata_%s.offsetsAndSize,\n" " qt_meta_data_%s,\n", qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData()); if (hasStaticMetaCall) -- cgit v1.2.3 From 00fbc087dd54b31e97b1557766b037b00120c43f Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 25 Jun 2012 17:41:51 +0200 Subject: Inline the size and data pointers in QByteArray Change-Id: I82feeb2c9bd2900f421fc0c8d78698b1e83db043 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/global/qt_pch.h | 2 +- src/corelib/kernel/qobjectdefs.h | 2 +- src/corelib/text/qbytearray.cpp | 496 +++++++++++++++++++------------------- src/corelib/text/qbytearray.h | 139 +++++------ src/corelib/text/qbytearraylist.h | 5 - src/corelib/text/qstring.cpp | 20 +- src/corelib/text/qstring.h | 10 +- src/corelib/tools/qarraydataops.h | 5 - 8 files changed, 329 insertions(+), 350 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h index 1663d9392f..0dfd6c745f 100644 --- a/src/corelib/global/qt_pch.h +++ b/src/corelib/global/qt_pch.h @@ -67,7 +67,7 @@ #include <qcoreevent.h> #include <qiodevice.h> #include <qlist.h> -//#include <qvariant.h> /* All moc genereated code has this include */ +#include <qvariant.h> /* All moc genereated code has this include */ #include <qobject.h> #include <qregexp.h> #include <qscopedpointer.h> diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index c4b9979293..229c97236e 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE class QByteArray; struct QArrayData; -typedef QArrayData QByteArrayData; +struct QByteArrayData; class QString; diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 841c02f1e4..c13a6d3379 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -731,27 +731,25 @@ QByteArray qUncompress(const uchar* data, int nbytes) return invalidCompressedData(); } - QScopedPointer<QByteArray::Data, QByteArrayDataDeleter> d(QByteArray::Data::allocate(expectedSize + 1).first); + QPair<QByteArray::Data *, char *> pair = QByteArray::Data::allocate(expectedSize + 1); + QScopedPointer<QByteArray::Data, QByteArrayDataDeleter> d(pair.first); if (Q_UNLIKELY(d.data() == nullptr)) return invalidCompressedData(); - d->size = expectedSize; forever { ulong alloc = len; - int res = ::uncompress((uchar*)d->data(), &len, + int res = ::uncompress((uchar*)pair.second, &len, data+4, nbytes-4); switch (res) { - case Z_OK: + case Z_OK: { Q_ASSERT(len <= alloc); Q_UNUSED(alloc); - d->size = len; - d->data()[len] = 0; - { - QByteArrayDataPtr dataPtr = { d.take() }; - return QByteArray(dataPtr); - } + QByteArrayData dataPtr = { d.take(), pair.second, uint(len) }; + pair.second[len] = '\0'; + return QByteArray(dataPtr); + } case Z_MEM_ERROR: qWarning("qUncompress: Z_MEM_ERROR: Not enough memory"); @@ -764,12 +762,12 @@ QByteArray qUncompress(const uchar* data, int nbytes) return invalidCompressedData(); } else { // grow the block - char *dataPointer = d->data(); - QByteArray::Data *p = QByteArray::Data::reallocateUnaligned(d.data(), dataPointer, len + 1).first; - if (Q_UNLIKELY(p == nullptr)) + pair = QByteArray::Data::reallocateUnaligned(d.data(), pair.second, len + 1); + Q_CHECK_PTR(pair.first); + if (Q_UNLIKELY(pair.first == nullptr)) return invalidCompressedData(); d.take(); // don't free - d.reset(p); + d.reset(pair.first); } continue; @@ -1185,9 +1183,9 @@ QByteArray qUncompress(const uchar* data, int nbytes) */ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept { - other.d->ref(); - if (!d->deref()) - Data::deallocate(d); + other.d.d->ref(); + if (!d.d->deref()) + Data::deallocate(d.d); d = other.d; return *this; } @@ -1201,25 +1199,28 @@ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept QByteArray &QByteArray::operator=(const char *str) { - Data *x; - if (!str) { - x = Data::sharedNull(); - } else if (!*str) { - x = Data::allocate(0).first; + if (!str || !*str) { + QPair<Data *, char *> pair; + if (!str) { + pair = qMakePair(Data::sharedNull(), Data::sharedNullData()); + } else { + pair = Data::allocate(0); + pair.first->ref(); + } + if (!d.d->deref()) + Data::deallocate(d.d); + d.d = pair.first; + d.b = pair.second; + d.size = 0; } else { const int len = int(strlen(str)); - const int fullLen = len + 1; - if (d->needsDetach() || fullLen > int(d->allocatedCapacity()) - || (len < d->size && fullLen < int(d->allocatedCapacity() >> 1))) - reallocData(fullLen, d->detachFlags()); - x = d; - memcpy(x->data(), str, fullLen); // include null terminator - x->size = len; + const size_t fullLen = len + 1; + if (d.d->needsDetach() || fullLen > d.d->allocatedCapacity() + || (len < size() && fullLen < (d.d->allocatedCapacity() >> 1))) + reallocData(fullLen, d.d->detachFlags()); + memcpy(d.b, str, fullLen); // include null terminator + d.size = len; } - x->ref(); - if (!d->deref()) - Data::deallocate(d); - d = x; return *this; } @@ -1555,7 +1556,7 @@ QByteArray &QByteArray::operator=(const char *str) */ void QByteArray::truncate(int pos) { - if (pos < d->size) + if (pos < size()) resize(pos); } @@ -1575,7 +1576,7 @@ void QByteArray::truncate(int pos) void QByteArray::chop(int n) { if (n > 0) - resize(d->size - n); + resize(size() - n); } @@ -1679,19 +1680,19 @@ void QByteArray::chop(int n) QByteArray::QByteArray(const char *data, int size) { if (!data) { - d = Data::sharedNull(); + d.d = Data::sharedNull(); + d.b = Data::sharedNullData(); + d.size = 0; } else { if (size < 0) size = int(strlen(data)); - if (!size) { - d = Data::allocate(0).first; - } else { - d = Data::allocate(uint(size) + 1u).first; - Q_CHECK_PTR(d); - d->size = size; - memcpy(d->data(), data, size); - d->data()[size] = '\0'; - } + QPair<Data *, char *> pair = Data::allocate(uint(size) + 1u); + Q_CHECK_PTR(pair.first); + d.d = pair.first; + d.b = pair.second; + d.size = size; + memcpy(d.b, data, size); + d.b[size] = '\0'; } } @@ -1705,13 +1706,18 @@ QByteArray::QByteArray(const char *data, int size) QByteArray::QByteArray(int size, char ch) { if (size <= 0) { - d = Data::allocate(0).first; + QPair<Data *, char *> pair = Data::allocate(0); + d.d = pair.first; + d.b = pair.second; + d.size = 0; } else { - d = Data::allocate(uint(size) + 1u).first; - Q_CHECK_PTR(d); - d->size = size; - memset(d->data(), ch, size); - d->data()[size] = '\0'; + QPair<Data *, char *> pair = Data::allocate(uint(size) + 1u); + Q_CHECK_PTR(pair.first); + d.d = pair.first; + d.b = pair.second; + d.size = size; + memset(d.b, ch, size); + d.b[size] = '\0'; } } @@ -1723,10 +1729,12 @@ QByteArray::QByteArray(int size, char ch) QByteArray::QByteArray(int size, Qt::Initialization) { - d = Data::allocate(uint(size) + 1u).first; - Q_CHECK_PTR(d); - d->size = size; - d->data()[size] = '\0'; + QPair<Data *, char *> pair = Data::allocate(uint(size) + 1u); + Q_CHECK_PTR(pair.first); + d.d = pair.first; + d.b = pair.second; + d.size = size; + d.b[size] = '\0'; } /*! @@ -1746,31 +1754,26 @@ void QByteArray::resize(int size) if (size < 0) size = 0; - if (!d->isShared() && !d->isMutable() && size < d->size) { - d->size = size; + if (!d.d->isShared() && !d.d->isMutable() && size < int(d.size)) { + d.size = size; return; } - if (d->size == 0 && d->isStatic()) { - // - // Optimize the idiom: - // QByteArray a; - // a.resize(sz); - // ... - // which is used in place of the Qt 3 idiom: - // QByteArray a(sz); - // - Data *x = Data::allocate(uint(size) + 1u).first; - Q_CHECK_PTR(x); - x->size = size; - x->data()[size] = '\0'; - d = x; + if (size == 0 && !(d.d->flags & Data::CapacityReserved)) { + QPair<Data *, char *> pair = Data::allocate(0); + if (!d.d->deref()) + Data::deallocate(d.d); + d.d = pair.first; + d.b = pair.second; + d.size = 0; } else { - if (d->needsDetach() || size > capacity()) - reallocData(uint(size) + 1u, d->detachFlags() | Data::GrowsForward); - if (d->isMutable()) { - d->size = size; - d->data()[size] = '\0'; + if (d.d->needsDetach() || size > capacity() + || (!(d.d->flags & Data::CapacityReserved) && size < int(d.size) + && size < (capacity() >> 1))) + reallocData(uint(size) + 1u, d.d->detachFlags() | Data::GrowsForward); + d.size = size; + if (d.d->isMutable()) { + d.b[size] = '\0'; } } } @@ -1788,33 +1791,36 @@ void QByteArray::resize(int size) QByteArray &QByteArray::fill(char ch, int size) { - resize(size < 0 ? d->size : size); - if (d->size) - memset(d->data(), ch, d->size); + resize(size < 0 ? this->size() : size); + if (this->size()) + memset(d.b, ch, this->size()); return *this; } void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) { - if (d->needsDetach()) { - Data *x = Data::allocate(alloc, options).first; - Q_CHECK_PTR(x); - x->size = qMin(int(alloc) - 1, d->size); - ::memcpy(x->data(), d->data(), x->size); - x->data()[x->size] = '\0'; - if (!d->deref()) - Data::deallocate(d); - d = x; + if (d.d->needsDetach()) { + QPair<Data *, char *> pair = Data::allocate(alloc, options); + Q_CHECK_PTR(pair.first); + d.size = qMin(alloc - 1, d.size); + ::memcpy(pair.second, d.b, d.size); + pair.second[d.size] = 0; + if (!d.d->deref()) + Data::deallocate(d.d); + d.d = pair.first; + d.b = pair.second; } else { - Data *x = Data::reallocateUnaligned(d, d->data(), alloc, options).first; - Q_CHECK_PTR(x); - d = x; + QPair<Data *, char *> pair = + Data::reallocateUnaligned(static_cast<Data *>(d.d), d.b, alloc, options); + Q_CHECK_PTR(pair.first); + d.d = pair.first; + d.b = pair.second; } } void QByteArray::expand(int i) { - resize(qMax(i + 1, d->size)); + resize(qMax(i + 1, size())); } /*! @@ -1829,7 +1835,7 @@ void QByteArray::expand(int i) QByteArray QByteArray::nulTerminated() const { // is this fromRawData? - if (!IS_RAW_DATA(d)) + if (!IS_RAW_DATA(d.d)) return *this; // no, then we're sure we're zero terminated QByteArray copy(*this); @@ -1860,9 +1866,9 @@ QByteArray QByteArray::nulTerminated() const QByteArray &QByteArray::prepend(const QByteArray &ba) { - if (d->size == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { + if (size() == 0 && d.d->isStatic() && !IS_RAW_DATA(ba.d.d)) { *this = ba; - } else if (ba.d->size != 0) { + } else if (ba.size() != 0) { QByteArray tmp = *this; *this = ba; append(tmp); @@ -1891,12 +1897,12 @@ QByteArray &QByteArray::prepend(const char *str) QByteArray &QByteArray::prepend(const char *str, int len) { if (str) { - if (d->needsDetach() || d->size + len > capacity()) - reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); - memmove(d->data()+len, d->data(), d->size); - memcpy(d->data(), str, len); - d->size += len; - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, d.d->detachFlags() | Data::GrowsForward); + memmove(d.b+len, d.b, d.size); + memcpy(d.b, str, len); + d.size += len; + d.b[d.size] = '\0'; } return *this; } @@ -1917,12 +1923,12 @@ QByteArray &QByteArray::prepend(const char *str, int len) QByteArray &QByteArray::prepend(char ch) { - if (d->needsDetach() || d->size + 1 > capacity()) - reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); - memmove(d->data()+1, d->data(), d->size); - d->data()[0] = ch; - ++d->size; - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + 1 > capacity()) + reallocData(uint(size()) + 2u, d.d->detachFlags() | Data::GrowsForward); + memmove(d.b+1, d.b, d.size); + d.b[0] = ch; + ++d.size; + d.b[d.size] = '\0'; return *this; } @@ -1952,14 +1958,14 @@ QByteArray &QByteArray::prepend(char ch) QByteArray &QByteArray::append(const QByteArray &ba) { - if (d->size == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { + if (size() == 0 && d.d->isStatic() && !IS_RAW_DATA(ba.d.d)) { *this = ba; - } else if (ba.d->size != 0) { - if (d->needsDetach() || d->size + ba.d->size > capacity()) - reallocData(uint(d->size + ba.d->size) + 1u, d->detachFlags() | Data::GrowsForward); - memcpy(d->data() + d->size, ba.d->data(), ba.d->size); - d->size += ba.d->size; - d->data()[d->size] = '\0'; + } else if (ba.size() != 0) { + if (d.d->needsDetach() || size() + ba.size() > capacity()) + reallocData(uint(size() + ba.size()) + 1u, d.d->detachFlags() | Data::GrowsForward); + memcpy(d.b + d.size, ba.data(), ba.size()); + d.size += ba.size(); + d.b[d.size] = '\0'; } return *this; } @@ -1987,10 +1993,10 @@ QByteArray& QByteArray::append(const char *str) { if (str) { const int len = int(strlen(str)); - if (d->needsDetach() || d->size + len > capacity()) - reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); - memcpy(d->data() + d->size, str, len + 1); // include null terminator - d->size += len; + if (d.d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, d.d->detachFlags() | Data::GrowsForward); + memcpy(d.b + d.size, str, len + 1); // include null terminator + d.size += len; } return *this; } @@ -2012,11 +2018,11 @@ QByteArray &QByteArray::append(const char *str, int len) if (len < 0) len = qstrlen(str); if (str && len) { - if (d->needsDetach() || d->size + len > capacity()) - reallocData(uint(d->size + len) + 1u, d->detachFlags() | Data::GrowsForward); - memcpy(d->data() + d->size, str, len); // include null terminator - d->size += len; - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, d.d->detachFlags() | Data::GrowsForward); + memcpy(d.b + d.size, str, len); + d.size += len; + d.b[d.size] = '\0'; } return *this; } @@ -2040,10 +2046,10 @@ QByteArray &QByteArray::append(const char *str, int len) QByteArray& QByteArray::append(char ch) { - if (d->needsDetach() || d->size + 1 > capacity()) - reallocData(uint(d->size) + 2u, d->detachFlags() | Data::GrowsForward); - d->data()[d->size++] = ch; - d->data()[d->size] = '\0'; + if (d.d->needsDetach() || size() + 1 > capacity()) + reallocData(uint(size()) + 2u, d.d->detachFlags() | Data::GrowsForward); + d.b[d.size++] = ch; + d.b[d.size] = '\0'; return *this; } @@ -2084,7 +2090,7 @@ static inline QByteArray &qbytearray_insert(QByteArray *ba, QByteArray &QByteArray::insert(int i, const QByteArray &ba) { QByteArray copy(ba); - return qbytearray_insert(this, i, copy.d->data(), copy.d->size); + return qbytearray_insert(this, i, copy.constData(), copy.size()); } /*! @@ -2166,7 +2172,7 @@ QByteArray &QByteArray::insert(int i, int count, char ch) int oldsize = size(); resize(qMax(i, oldsize) + count); - char *dst = d->data(); + char *dst = d.b; if (i > oldsize) ::memset(dst + oldsize, 0x20, i - oldsize); else if (i < oldsize) @@ -2191,14 +2197,14 @@ QByteArray &QByteArray::insert(int i, int count, char ch) QByteArray &QByteArray::remove(int pos, int len) { - if (len <= 0 || uint(pos) >= uint(d->size)) + if (len <= 0 || uint(pos) >= uint(size())) return *this; detach(); - if (len >= d->size - pos) { + if (len >= size() - pos) { resize(pos); } else { - memmove(d->data() + pos, d->data() + pos + len, d->size - pos - len); - resize(d->size - len); + memmove(d.b + pos, d.b + pos + len, size() - pos - len); + resize(size() - len); } return *this; } @@ -2215,9 +2221,9 @@ QByteArray &QByteArray::remove(int pos, int len) QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after) { - if (len == after.d->size && (pos + len <= d->size)) { + if (len == after.size() && (pos + len <= size())) { detach(); - memmove(d->data() + pos, after.d->data(), len*sizeof(char)); + memmove(d.b + pos, after.data(), len*sizeof(char)); return *this; } else { QByteArray copy(after); @@ -2252,9 +2258,9 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after) */ QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) { - if (len == alen && (pos + len <= d->size)) { + if (len == alen && (pos + len <= size())) { detach(); - memcpy(d->data() + pos, after, len*sizeof(char)); + memcpy(d.b + pos, after, len*sizeof(char)); return *this; } else { remove(pos, len); @@ -2277,14 +2283,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) QByteArray &QByteArray::replace(const QByteArray &before, const QByteArray &after) { - if (isNull() || before.d == after.d) - return *this; - - QByteArray aft = after; - if (after.d == d) - aft.detach(); - - return replace(before.constData(), before.size(), aft.constData(), aft.size()); + return replace(before.constData(), before.size(), after.constData(), after.size()); } /*! @@ -2297,11 +2296,7 @@ QByteArray &QByteArray::replace(const QByteArray &before, const QByteArray &afte QByteArray &QByteArray::replace(const char *c, const QByteArray &after) { - QByteArray aft = after; - if (after.d == d) - aft.detach(); - - return replace(c, qstrlen(c), aft.constData(), aft.size()); + return replace(c, qstrlen(c), after.constData(), after.size()); } /*! @@ -2321,13 +2316,13 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after // protect against before or after being part of this const char *a = after; const char *b = before; - if (after >= d->data() && after < d->data() + d->size) { + if (after >= constBegin() && after < constEnd()) { char *copy = (char *)malloc(asize); Q_CHECK_PTR(copy); memcpy(copy, after, asize); a = copy; } - if (before >= d->data() && before < d->data() + d->size) { + if (before >= constBegin() && before < constEnd()) { char *copy = (char *)malloc(bsize); Q_CHECK_PTR(copy); memcpy(copy, before, bsize); @@ -2336,8 +2331,8 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after QByteArrayMatcher matcher(before, bsize); int index = 0; - int len = d->size; - char *d = data(); + int len = size(); + char *d = data(); // detaches if (bsize == asize) { if (bsize) { @@ -2404,7 +2399,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after resize(newlen); len = newlen; } - d = this->d->data(); + d = this->d.b; // data(), without the detach() check while(pos) { pos--; @@ -2476,8 +2471,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after QByteArray &QByteArray::replace(char before, const QByteArray &after) { char b[2] = { before, '\0' }; - QByteArray cb = fromRawData(b, 1); - return replace(cb, after); + return replace(b, 1, after.constData(), after.size()); } /*! \fn QByteArray &QByteArray::replace(char before, const QString &after) @@ -2511,9 +2505,9 @@ QByteArray &QByteArray::replace(char before, const QByteArray &after) QByteArray &QByteArray::replace(char before, char after) { - if (d->size) { + if (!isEmpty()) { char *i = data(); - char *e = i + d->size; + char *e = i + size(); for (; i != e; ++i) if (*i == before) * i = after; @@ -2554,7 +2548,7 @@ QList<QByteArray> QByteArray::split(char sep) const */ QByteArray QByteArray::repeated(int times) const { - if (d->size == 0) + if (isEmpty()) return *this; if (times <= 1) { @@ -2563,27 +2557,27 @@ QByteArray QByteArray::repeated(int times) const return QByteArray(); } - const int resultSize = times * d->size; + const int resultSize = times * size(); QByteArray result; result.reserve(resultSize); if (result.capacity() != resultSize) return QByteArray(); // not enough memory - memcpy(result.d->data(), d->data(), d->size); + memcpy(result.d.b, data(), size()); - int sizeSoFar = d->size; - char *end = result.d->data() + sizeSoFar; + int sizeSoFar = size(); + char *end = result.d.b + sizeSoFar; const int halfResultSize = resultSize >> 1; while (sizeSoFar <= halfResultSize) { - memcpy(end, result.d->data(), sizeSoFar); + memcpy(end, result.d.b, sizeSoFar); end += sizeSoFar; sizeSoFar <<= 1; } - memcpy(end, result.d->data(), resultSize - sizeSoFar); - result.d->data()[resultSize] = '\0'; - result.d->size = resultSize; + memcpy(end, result.d.b, resultSize - sizeSoFar); + result.d.b[resultSize] = '\0'; + result.d.size = resultSize; return result; } @@ -2605,17 +2599,17 @@ QByteArray QByteArray::repeated(int times) const int QByteArray::indexOf(const QByteArray &ba, int from) const { - const int ol = ba.d->size; + const int ol = ba.size(); if (ol == 0) return from; if (ol == 1) - return indexOf(*ba.d->data(), from); + return indexOf(ba[0], from); - const int l = d->size; - if (from > d->size || ol + from > l) + const int l = size(); + if (from > l || ol + from > l) return -1; - return qFindByteArray(d->data(), d->size, from, ba.d->data(), ol); + return qFindByteArray(data(), size(), from, ba.data(), ol); } /*! \fn int QByteArray::indexOf(const QString &str, int from) const @@ -2649,13 +2643,13 @@ int QByteArray::indexOf(const char *c, int from) const if (ol == 1) return indexOf(*c, from); - const int l = d->size; - if (from > d->size || ol + from > l) + const int l = size(); + if (from > l || ol + from > l) return -1; if (ol == 0) return from; - return qFindByteArray(d->data(), d->size, from, c, ol); + return qFindByteArray(data(), size(), from, c, ol); } /*! @@ -2674,13 +2668,13 @@ int QByteArray::indexOf(const char *c, int from) const int QByteArray::indexOf(char ch, int from) const { if (from < 0) - from = qMax(from + d->size, 0); - if (from < d->size) { - const char *n = d->data() + from - 1; - const char *e = d->data() + d->size; + from = qMax(from + size(), 0); + if (from < size()) { + const char *n = data() + from - 1; + const char *e = end(); while (++n != e) if (*n == ch) - return n - d->data(); + return n - data(); } return -1; } @@ -2735,11 +2729,11 @@ static int lastIndexOfHelper(const char *haystack, int l, const char *needle, in int QByteArray::lastIndexOf(const QByteArray &ba, int from) const { - const int ol = ba.d->size; + const int ol = ba.size(); if (ol == 1) - return lastIndexOf(*ba.d->data(), from); + return lastIndexOf(ba[0], from); - return lastIndexOfHelper(d->data(), d->size, ba.d->data(), ol, from); + return lastIndexOfHelper(data(), size(), ba.data(), ol, from); } /*! \fn int QByteArray::lastIndexOf(const QString &str, int from) const @@ -2774,7 +2768,7 @@ int QByteArray::lastIndexOf(const char *str, int from) const if (ol == 1) return lastIndexOf(*str, from); - return lastIndexOfHelper(d->data(), d->size, str, ol, from); + return lastIndexOfHelper(data(), size(), str, ol, from); } /*! @@ -2794,12 +2788,12 @@ int QByteArray::lastIndexOf(const char *str, int from) const int QByteArray::lastIndexOf(char ch, int from) const { if (from < 0) - from += d->size; - else if (from > d->size) - from = d->size-1; + from += size(); + else if (from > size()) + from = size()-1; if (from >= 0) { - const char *b = d->data(); - const char *n = d->data() + from + 1; + const char *b = data(); + const char *n = b + from + 1; while (n-- != b) if (*n == ch) return n - b; @@ -2818,7 +2812,7 @@ int QByteArray::count(const QByteArray &ba) const { int num = 0; int i = -1; - if (d->size > 500 && ba.d->size > 5) { + if (size() > 500 && ba.size() > 5) { QByteArrayMatcher matcher(ba); while ((i = matcher.indexIn(*this, i + 1)) != -1) ++num; @@ -2853,8 +2847,8 @@ int QByteArray::count(const char *str) const int QByteArray::count(char ch) const { int num = 0; - const char *i = d->data() + d->size; - const char *b = d->data(); + const char *i = end(); + const char *b = begin(); while (i != b) if (*--i == ch) ++num; @@ -2904,11 +2898,11 @@ int QByteArray::count(char ch) const */ bool QByteArray::startsWith(const QByteArray &ba) const { - if (d == ba.d || ba.d->size == 0) - return true; - if (d->size < ba.d->size) + if (size() < ba.size()) return false; - return memcmp(d->data(), ba.d->data(), ba.d->size) == 0; + if (data() == ba.data() || ba.size() == 0) + return true; + return memcmp(data(), ba.data(), ba.size()) == 0; } /*! \overload @@ -2921,9 +2915,9 @@ bool QByteArray::startsWith(const char *str) const if (!str || !*str) return true; const int len = int(strlen(str)); - if (d->size < len) + if (size() < len) return false; - return qstrncmp(d->data(), str, len) == 0; + return qstrncmp(data(), str, len) == 0; } /*! \overload @@ -2933,9 +2927,9 @@ bool QByteArray::startsWith(const char *str) const */ bool QByteArray::startsWith(char ch) const { - if (d->size == 0) + if (size() == 0) return false; - return d->data()[0] == ch; + return data()[0] == ch; } /*! @@ -2949,11 +2943,11 @@ bool QByteArray::startsWith(char ch) const */ bool QByteArray::endsWith(const QByteArray &ba) const { - if (d == ba.d || ba.d->size == 0) - return true; - if (d->size < ba.d->size) + if (size() < ba.size()) return false; - return memcmp(d->data() + d->size - ba.d->size, ba.d->data(), ba.d->size) == 0; + if (end() == ba.end() || ba.size() == 0) + return true; + return memcmp(end() - ba.size(), ba.data(), ba.size()) == 0; } /*! \overload @@ -2966,9 +2960,9 @@ bool QByteArray::endsWith(const char *str) const if (!str || !*str) return true; const int len = int(strlen(str)); - if (d->size < len) + if (size() < len) return false; - return qstrncmp(d->data() + d->size - len, str, len) == 0; + return qstrncmp(end() - len, str, len) == 0; } /* @@ -3050,9 +3044,9 @@ bool QByteArray::isLower() const */ bool QByteArray::endsWith(char ch) const { - if (d->size == 0) + if (size() == 0) return false; - return d->data()[d->size - 1] == ch; + return data()[size() - 1] == ch; } /*! @@ -3070,11 +3064,11 @@ bool QByteArray::endsWith(char ch) const QByteArray QByteArray::left(int len) const { - if (len >= d->size) + if (len >= size()) return *this; if (len < 0) len = 0; - return QByteArray(d->data(), len); + return QByteArray(data(), len); } /*! @@ -3092,11 +3086,11 @@ QByteArray QByteArray::left(int len) const QByteArray QByteArray::right(int len) const { - if (len >= d->size) + if (len >= size()) return *this; if (len < 0) len = 0; - return QByteArray(d->data() + d->size - len, len); + return QByteArray(end() - len, len); } /*! @@ -3121,13 +3115,14 @@ QByteArray QByteArray::mid(int pos, int len) const return QByteArray(); case QContainerImplHelper::Empty: { - QByteArrayDataPtr empty = { Data::allocate(0).first }; + auto alloc = Data::allocate(0); + QByteArrayData empty = { alloc.first, alloc.second, 0 }; return QByteArray(empty); } case QContainerImplHelper::Full: return *this; case QContainerImplHelper::Subset: - return QByteArray(d->data() + pos, len); + return QByteArray(d.b + pos, len); } Q_UNREACHABLE(); return QByteArray(); @@ -3230,9 +3225,11 @@ QByteArray QByteArray::toUpper_helper(QByteArray &a) void QByteArray::clear() { - if (!d->deref()) - Data::deallocate(d); - d = Data::sharedNull(); + if (!d.d->deref()) + Data::deallocate(d.d); + d.d = Data::sharedNull(); + d.b = Data::sharedNullData(); + d.size = 0; } #if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)) @@ -3709,13 +3706,13 @@ QByteArray QByteArray::trimmed_helper(QByteArray &a) QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const { QByteArray result; - int len = d->size; + int len = size(); int padlen = width - len; if (padlen > 0) { result.resize(len+padlen); if (len) - memcpy(result.d->data(), d->data(), len); - memset(result.d->data()+len, fill, padlen); + memcpy(result.d.b, data(), len); + memset(result.d.b+len, fill, padlen); } else { if (truncate) result = left(width); @@ -3746,13 +3743,13 @@ QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const QByteArray QByteArray::rightJustified(int width, char fill, bool truncate) const { QByteArray result; - int len = d->size; + int len = size(); int padlen = width - len; if (padlen > 0) { result.resize(len+padlen); if (len) - memcpy(result.d->data()+padlen, data(), len); - memset(result.d->data(), fill, padlen); + memcpy(result.d.b+padlen, data(), len); + memset(result.d.b, fill, padlen); } else { if (truncate) result = left(width); @@ -3762,7 +3759,10 @@ QByteArray QByteArray::rightJustified(int width, char fill, bool truncate) const return result; } -bool QByteArray::isNull() const { return d == QArrayData::sharedNull(); } +bool QByteArray::isNull() const +{ + return d.d == QArrayData::sharedNull(); +} static qlonglong toIntegral_helper(const char *data, bool *ok, int base, qlonglong) { @@ -4089,19 +4089,19 @@ QByteArray QByteArray::toBase64(Base64Options options) const const char padchar = '='; int padlen = 0; - QByteArray tmp((d->size + 2) / 3 * 4, Qt::Uninitialized); + QByteArray tmp((size() + 2) / 3 * 4, Qt::Uninitialized); int i = 0; char *out = tmp.data(); - while (i < d->size) { + while (i < size()) { // encode 3 bytes at a time int chunk = 0; - chunk |= int(uchar(d->data()[i++])) << 16; - if (i == d->size) { + chunk |= int(uchar(data()[i++])) << 16; + if (i == size()) { padlen = 2; } else { - chunk |= int(uchar(d->data()[i++])) << 8; - if (i == d->size) + chunk |= int(uchar(data()[i++])) << 8; + if (i == size()) padlen = 1; else chunk |= int(uchar(data()[i++])); @@ -4431,17 +4431,23 @@ QByteArray QByteArray::number(double n, char f, int prec) QByteArray QByteArray::fromRawData(const char *data, int size) { - Data *x; + QByteArrayData x; if (!data) { - x = Data::sharedNull(); + x.d = Data::sharedNull(); + x.b = Data::sharedNullData(); + x.size = 0; } else if (!size) { - x = Data::allocate(0).first; + QPair<Data *, char *> pair = Data::allocate(0); + x.d = pair.first; + x.b = pair.second; + x.size = 0; } else { - x = Data::fromRawData(data, size).ptr; - Q_CHECK_PTR(x); + x.d = Data::fromRawData(data, size).ptr; + Q_CHECK_PTR(x.d); + x.b = const_cast<char *>(data); + x.size = size; } - QByteArrayDataPtr dataPtr = { x }; - return QByteArray(dataPtr); + return QByteArray(x); } /*! @@ -4462,11 +4468,11 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) { if (!data || !size) { clear(); - } else if (d->isShared() || (d->flags & Data::RawDataType) == 0) { + } else if (d.d->isShared() || (d.d->flags & Data::RawDataType) == 0) { *this = fromRawData(data, size); } else { - d->size = size; - d->offset = data - reinterpret_cast<char *>(d); + d.size = size; + d.b = const_cast<char *>(data); } return *this; } @@ -4579,14 +4585,14 @@ QByteArray QByteArray::fromHex(const QByteArray &hexEncoded) */ QByteArray QByteArray::toHex(char separator) const { - if (!d->size) + if (isEmpty()) return QByteArray(); - const int length = separator ? (d->size * 3 - 1) : (d->size * 2); + const int length = separator ? (size() * 3 - 1) : (size() * 2); QByteArray hex(length, Qt::Uninitialized); char *hexData = hex.data(); - const uchar *data = (const uchar *)d->data(); - for (int i = 0, o = 0; i < d->size; ++i) { + const uchar *data = (const uchar *)this->data(); + for (int i = 0, o = 0; i < size(); ++i) { hexData[o++] = QtMiscUtils::toHexLower(data[i] >> 4); hexData[o++] = QtMiscUtils::toHexLower(data[i] & 0xf); diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 67a7e5da3d..f97f64f556 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -114,40 +114,22 @@ class QByteRef; class QString; class QDataStream; -typedef QArrayData QByteArrayData; - -template<int N> struct QStaticByteArrayData -{ - QByteArrayData ba; - char data[N + 1]; - - QByteArrayData *data_ptr() const - { - Q_ASSERT(ba.isStatic()); - return const_cast<QByteArrayData *>(&ba); - } -}; - -struct QByteArrayDataPtr +struct QByteArrayData { - QByteArrayData *ptr; + QArrayData *d; + char *b; + uint size; }; -#define Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) - /**/ - -#define Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(size) \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, sizeof(QByteArrayData)) \ - /**/ - # define QByteArrayLiteral(str) \ ([]() -> QByteArray { \ enum { Size = sizeof(str) - 1 }; \ - static const QStaticByteArrayData<Size> qbytearray_literal = { \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER(Size), \ - str }; \ - QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; \ + static const QArrayData qbytearray_literal = { \ + Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, Size, 0, sizeof(QArrayData) }; \ + QByteArrayData holder = { \ + const_cast<QArrayData *>(&qbytearray_literal), \ + const_cast<char *>(str), \ + Size }; \ const QByteArray ba(holder); \ return ba; \ }()) \ @@ -177,10 +159,10 @@ public: QByteArray &operator=(const QByteArray &) noexcept; QByteArray &operator=(const char *str); - inline QByteArray(QByteArray && other) noexcept : d(other.d) { other.d = Data::sharedNull(); } + inline QByteArray(QByteArray && other) noexcept : d(std::move(other.d)) + { other.d.d = Data::sharedNull(); other.d.b = Data::sharedNullData(); other.d.size = 0; } inline QByteArray &operator=(QByteArray &&other) noexcept { qSwap(d, other.d); return *this; } - inline void swap(QByteArray &other) noexcept { qSwap(d, other.d); } @@ -203,7 +185,8 @@ public: inline const char *constData() const; inline void detach(); inline bool isDetached() const; - inline bool isSharedWith(const QByteArray &other) const { return d == other.d; } + inline bool isSharedWith(const QByteArray &other) const + { return data() == other.data() && size() == other.size(); } void clear(); inline char at(int i) const; @@ -431,18 +414,18 @@ public: static inline QByteArray fromStdString(const std::string &s); inline std::string toStdString() const; - inline int count() const { return d->size; } - int length() const { return d->size; } + inline int count() const { return int(d.size); } + int length() const { return int(d.size); } bool isNull() const; - inline QByteArray(QByteArrayDataPtr dd) - : d(static_cast<Data *>(dd.ptr)) + explicit inline QByteArray(const QByteArrayData &dd) + : d(dd) { } private: operator QNoImplicitBoolCast() const; - Data *d; + QByteArrayData d; void reallocData(uint alloc, Data::ArrayOptions options); void expand(int i); QByteArray nulTerminated() const; @@ -460,63 +443,63 @@ private: friend class QString; friend Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes); public: - typedef Data * DataPtr; + typedef QByteArrayData DataPtr; inline DataPtr &data_ptr() { return d; } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options) -inline QByteArray::QByteArray() noexcept : d(Data::sharedNull()) { } -inline QByteArray::~QByteArray() { if (!d->deref()) Data::deallocate(d); } +inline QByteArray::QByteArray() noexcept { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } +inline QByteArray::~QByteArray() { if (!d.d->deref()) Data::deallocate(d.d); } inline int QByteArray::size() const -{ return d->size; } +{ return int(d.size); } inline char QByteArray::at(int i) const -{ Q_ASSERT(uint(i) < uint(size())); return d->data()[i]; } +{ Q_ASSERT(uint(i) < uint(size())); return d.b[i]; } inline char QByteArray::operator[](int i) const -{ Q_ASSERT(uint(i) < uint(size())); return d->data()[i]; } +{ Q_ASSERT(uint(i) < uint(size())); return d.b[i]; } inline bool QByteArray::isEmpty() const -{ return d->size == 0; } +{ return size() == 0; } #ifndef QT_NO_CAST_FROM_BYTEARRAY inline QByteArray::operator const char *() const -{ return d->data(); } +{ return data(); } inline QByteArray::operator const void *() const -{ return d->data(); } +{ return data(); } #endif inline char *QByteArray::data() -{ detach(); return d->data(); } +{ detach(); return d.b; } inline const char *QByteArray::data() const -{ return d->data(); } +{ return d.b; } inline const char *QByteArray::constData() const -{ return d->data(); } +{ return d.b; } inline void QByteArray::detach() -{ if (d->needsDetach()) reallocData(uint(d->size) + 1u, d->detachFlags()); } +{ if (d.d->needsDetach()) reallocData(uint(size()) + 1u, d.d->detachFlags()); } inline bool QByteArray::isDetached() const -{ return !d->isShared(); } +{ return !d.d->isShared(); } inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) -{ d->ref(); } +{ d.d->ref(); } inline int QByteArray::capacity() const -{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } +{ int realCapacity = d.d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline void QByteArray::reserve(int asize) { - if (d->needsDetach() || asize > capacity()) { - reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved); + if (d.d->needsDetach() || asize > capacity()) { + reallocData(qMax(uint(size()), uint(asize)) + 1u, d.d->detachFlags() | Data::CapacityReserved); } else { - d->flags |= Data::CapacityReserved; + d.d->flags |= Data::CapacityReserved; } } inline void QByteArray::squeeze() { - if ((d->flags & Data::CapacityReserved) == 0) + if ((d.d->flags & Data::CapacityReserved) == 0) return; - if (d->needsDetach() || d->size < capacity()) { - reallocData(uint(d->size) + 1u, d->detachFlags() & ~Data::CapacityReserved); + if (d.d->needsDetach() || size() < capacity()) { + reallocData(uint(size()) + 1u, d.d->detachFlags() & ~Data::CapacityReserved); } else { - d->flags &= ~Data::CapacityReserved; + d.d->flags &= uint(~Data::CapacityReserved); } } @@ -550,8 +533,8 @@ public: inline operator char() const { using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_LIKELY(i < a.d->size)) - return a.d->data()[i]; + if (Q_LIKELY(i < a.size())) + return a.constData()[i]; #ifdef QT_DEBUG warn(WarningType::OutOfRange, EmittingClass::QByteRef); #endif @@ -560,7 +543,7 @@ public: inline QByteRef &operator=(char c) { using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_UNLIKELY(i >= a.d->size)) { + if (Q_UNLIKELY(i >= a.size())) { #ifdef QT_DEBUG warn(WarningType::OutOfRange, EmittingClass::QByteRef); #endif @@ -572,7 +555,7 @@ public: #endif a.detach(); } - a.d->data()[i] = c; + a.d.b[i] = c; return *this; } inline QByteRef &operator=(const QByteRef &c) @@ -580,17 +563,17 @@ public: return operator=(char(c)); } inline bool operator==(char c) const - { return a.d->data()[i] == c; } + { return a.data()[i] == c; } inline bool operator!=(char c) const - { return a.d->data()[i] != c; } + { return a.data()[i] != c; } inline bool operator>(char c) const - { return a.d->data()[i] > c; } + { return a.data()[i] > c; } inline bool operator>=(char c) const - { return a.d->data()[i] >= c; } + { return a.data()[i] >= c; } inline bool operator<(char c) const - { return a.d->data()[i] < c; } + { return a.data()[i] < c; } inline bool operator<=(char c) const - { return a.d->data()[i] <= c; } + { return a.data()[i] <= c; } }; inline QByteRef QByteArray::operator[](int i) @@ -598,23 +581,23 @@ inline QByteRef QByteArray::operator[](int i) inline QByteRef QByteArray::front() { return operator[](0); } inline QByteRef QByteArray::back() { return operator[](size() - 1); } inline QByteArray::iterator QByteArray::begin() -{ detach(); return d->data(); } +{ return data(); } inline QByteArray::const_iterator QByteArray::begin() const -{ return d->data(); } +{ return data(); } inline QByteArray::const_iterator QByteArray::cbegin() const -{ return d->data(); } +{ return data(); } inline QByteArray::const_iterator QByteArray::constBegin() const -{ return d->data(); } +{ return data(); } inline QByteArray::iterator QByteArray::end() -{ detach(); return d->data() + d->size; } +{ return data() + size(); } inline QByteArray::const_iterator QByteArray::end() const -{ return d->data() + d->size; } +{ return data() + size(); } inline QByteArray::const_iterator QByteArray::cend() const -{ return d->data() + d->size; } +{ return data() + size(); } inline QByteArray::const_iterator QByteArray::constEnd() const -{ return d->data() + d->size; } +{ return data() + size(); } inline QByteArray &QByteArray::append(int n, char ch) -{ return insert(d->size, n, ch); } +{ return insert(size(), n, ch); } inline QByteArray &QByteArray::prepend(int n, char ch) { return insert(0, n, ch); } inline QByteArray &QByteArray::operator+=(char c) diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h index e113c6059c..d02fa6d20f 100644 --- a/src/corelib/text/qbytearraylist.h +++ b/src/corelib/text/qbytearraylist.h @@ -80,11 +80,6 @@ public: inline QByteArray join(char sep) const { return QtPrivate::QByteArrayList_join(self(), &sep, 1); } -#if 0 - inline int indexOf(const char *needle, int from = 0) const - { return QtPrivate::QByteArrayList_indexOf(self(), needle, from); } -#endif - private: typedef QVector<QByteArray> Self; Self *self() { return static_cast<Self *>(this); } diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index e1cd018351..7758687f0f 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2288,8 +2288,8 @@ void QString::resize(int size) if (d.d->needsDetach() || size > capacity()) reallocData(uint(size) + 1u, true); + d.size = size; if (d.d->isMutable()) { - d.size = size; d.b[size] = '\0'; } } @@ -5170,24 +5170,24 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) // Swap the d pointers. // Kids, avert your eyes. Don't try this at home. - QArrayData *ba_d = s.d.d; + QByteArrayData ba_d = { + s.d.d, + reinterpret_cast<char *>(s.d.b), + length + }; // multiply the allocated capacity by sizeof(ushort) - ba_d->alloc *= sizeof(ushort); + ba_d.d->alloc *= sizeof(ushort); // reset ourselves to QString() s.d = QString().d; // do the in-place conversion - uchar *dst = reinterpret_cast<uchar *>(ba_d->data()); - qt_to_latin1(dst, data, length); - dst[length] = '\0'; - - QByteArrayDataPtr badptr = { ba_d }; - return QByteArray(badptr); + qt_to_latin1(reinterpret_cast<uchar *>(ba_d.b), data, length); + ba_d.b[length] = '\0'; + return QByteArray(ba_d); } - /*! \fn QByteArray QString::toLatin1() const diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index c2168af889..96c0ec7ceb 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -263,8 +263,8 @@ public: inline QString &operator=(QString &&other) noexcept { qSwap(d, other.d); return *this; } inline void swap(QString &other) noexcept { qSwap(d, other.d); } - inline int size() const { return d.size; } - inline int count() const { return d.size; } + inline int size() const { return int(d.size); } + inline int count() const { return int(d.size); } inline int length() const; inline bool isEmpty() const; void resize(int size); @@ -1020,7 +1020,7 @@ QString QStringView::toString() const inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1.latin1(), aLatin1.size())) { } inline int QString::length() const -{ return d.size; } +{ return int(d.size); } inline const QChar QString::at(int i) const { Q_ASSERT(uint(i) < uint(size())); return QChar(d.b[i]); } inline const QChar QString::operator[](int i) const @@ -1259,7 +1259,7 @@ inline QString::~QString() { if (!d.d->deref()) Data::deallocate(d.d); } inline void QString::reserve(int asize) { if (d.d->needsDetach() || asize >= capacity()) - reallocData(qMax(asize, size()) + 1u); + reallocData(uint(qMax(asize, size())) + 1u); // we're not shared anymore, for sure d.d->flags |= Data::CapacityReserved; @@ -1273,7 +1273,7 @@ inline void QString::squeeze() reallocData(uint(d.size) + 1u); // we're not shared anymore, for sure - d.d->flags &= ~Data::CapacityReserved; + d.d->flags &= uint(~Data::CapacityReserved); } inline QString &QString::setUtf16(const ushort *autf16, int asize) diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index f3de6b65a9..8ca181edf1 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -199,11 +199,6 @@ struct QPodArrayOps bool compare(const T *begin1, const T *begin2, size_t n) const { - // only use memcmp for fundamental types or pointers. - // Other types could have padding in the data structure or custom comparison - // operators that would break the comparison using memcmp - if (QArrayDataPointer<T>::pass_parameter_by_value) - return ::memcmp(begin1, begin2, n * sizeof(T)) == 0; const T *end1 = begin1 + n; while (begin1 != end1) { if (*begin1 == *begin2) -- cgit v1.2.3 From eab6eb64d2fab21c4791738323ca7d670a907de1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 25 Jun 2012 21:22:19 +0200 Subject: Final removal of the size and offset members from QArrayData Those members are not required anymore and now part of the object itself. Change-Id: If9eb5355ca8f2cf9528f6f63ca4e172acc9f9aed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.h | 2 +- src/corelib/text/qstringliteral.h | 2 +- src/corelib/tools/qarraydata.cpp | 6 ++--- src/corelib/tools/qarraydata.h | 49 ++++----------------------------------- 4 files changed, 8 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index f97f64f556..9abe7d74e3 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -125,7 +125,7 @@ struct QByteArrayData ([]() -> QByteArray { \ enum { Size = sizeof(str) - 1 }; \ static const QArrayData qbytearray_literal = { \ - Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, Size, 0, sizeof(QArrayData) }; \ + Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }; \ QByteArrayData holder = { \ const_cast<QArrayData *>(&qbytearray_literal), \ const_cast<char *>(str), \ diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index a8cf8e2c64..61570fe042 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -64,7 +64,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, ([]() noexcept -> QString { \ enum { Size = sizeof(QT_UNICODE_LITERAL(str))/2 - 1 }; \ static const QArrayData qstring_literal = { \ - Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, Size, 0, sizeof(QArrayData) \ + Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 \ }; \ QStringPrivate holder = { \ const_cast<QArrayData *>(&qstring_literal), \ diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 8052c2ca69..9c3848fa7a 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -153,11 +153,11 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") const QArrayData QArrayData::shared_null[2] = { - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared null + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }, // shared null /* zero initialized terminator */}; static const QArrayData emptyNotNullShared[2] = { - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0, 0, sizeof(QArrayData) }, // shared empty + { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }, // shared empty /* zero initialized terminator */}; QT_WARNING_POP @@ -185,7 +185,6 @@ static QArrayData *allocateData(size_t allocSize, uint options) if (header) { header->ref_.storeRelaxed(1); header->flags = options; - header->size = 0; } return header; } @@ -233,7 +232,6 @@ void *QArrayData::allocate(QArrayData **dptr, size_t objectSize, size_t alignmen // find where offset should point to so that data() is aligned to alignment bytes data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); - header->offset = data - quintptr(header); header->alloc = capacity; } diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 6cf0ea1cb6..483f6d5edb 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -73,11 +73,8 @@ struct Q_CORE_EXPORT QArrayData QBasicAtomicInt ref_; uint flags; - int size; uint alloc; - qptrdiff offset; // in bytes from beginning of header - inline size_t allocatedCapacity() { return alloc; @@ -104,20 +101,6 @@ struct Q_CORE_EXPORT QArrayData return ref_.deref(); } - void *data() - { - Q_ASSERT(size == 0 - || offset < 0 || size_t(offset) >= sizeof(QArrayData)); - return reinterpret_cast<char *>(this) + offset; - } - - const void *data() const - { - Q_ASSERT(size == 0 - || offset < 0 || size_t(offset) >= sizeof(QArrayData)); - return reinterpret_cast<const char *>(this) + offset; - } - // This refers to array data mutability, not "header data" represented by // data members in QArrayData. Shared data (array and header) must still // follow COW principles. @@ -188,7 +171,6 @@ struct Q_CORE_EXPORT QArrayData static void *sharedNullData() { QArrayData *const null = const_cast<QArrayData *>(&shared_null[1]); - Q_ASSERT(sharedNull()->data() == null); return null; } }; @@ -292,16 +274,6 @@ struct QTypedArrayData typedef const T* const_iterator; #endif - T *data() { return static_cast<T *>(QArrayData::data()); } - const T *data() const { return static_cast<const T *>(QArrayData::data()); } - - iterator begin(iterator = iterator()) { return data(); } - iterator end(iterator = iterator()) { return data() + size; } - const_iterator begin(const_iterator = const_iterator()) const { return data(); } - const_iterator end(const_iterator = const_iterator()) const { return data() + size; } - const_iterator constBegin(const_iterator = const_iterator()) const { return data(); } - const_iterator constEnd(const_iterator = const_iterator()) const { return data() + size; } - class AlignmentDummy { QArrayData header; T data; }; Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(size_t capacity, @@ -341,9 +313,6 @@ struct QTypedArrayData }; if (result.ptr) { Q_ASSERT(!result.ptr->isShared()); // No shared empty, please! - result.ptr->offset = reinterpret_cast<const char *>(data) - - reinterpret_cast<const char *>(result.ptr); - result.ptr->size = int(n); } return result; } @@ -367,15 +336,6 @@ struct QTypedArrayData } }; -#define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset) \ - { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, size, 0, offset } \ - /**/ - -#define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ - Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size,\ - ((sizeof(QArrayData) + (alignof(type) - 1)) & ~(alignof(type) - 1) )) \ - /**/ - //////////////////////////////////////////////////////////////////////////////// // Q_ARRAY_LITERAL @@ -411,16 +371,15 @@ struct QTypedArrayData Q_ARRAY_LITERAL_CHECK_LITERAL_TYPE(Type); \ \ /* Portable compile-time array size computation */ \ - Q_CONSTEXPR Type data[] = { __VA_ARGS__ }; Q_UNUSED(data); \ + static Type const data[] = { __VA_ARGS__ }; \ enum { Size = sizeof(data) / sizeof(data[0]) }; \ \ - static const QStaticArrayData<Type, Size> literal = { \ - Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(Type, Size), { __VA_ARGS__ } }; \ + static const QArrayData literal = { Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }; \ \ QArrayDataPointerRef<Type> ref = \ { static_cast<QTypedArrayData<Type> *>( \ - const_cast<QArrayData *>(&literal.header)), \ - const_cast<Type *>(literal.data), \ + const_cast<QArrayData *>(&literal)), \ + const_cast<Type *>(data), \ Size }; \ /**/ -- cgit v1.2.3 From f247e94b51a825b09c33ad09098622677801a3b8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 19 Jun 2012 13:03:43 +0200 Subject: Enlarge QVariant's private to fit the new QString and QByteArray Change-Id: I8baecd0a4db13200b34cdd7c8aebc2a1cc0a0c75 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/kernel/qvariant.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 21802aee85..0457b6fbad 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -396,7 +396,7 @@ class Q_CORE_EXPORT QVariant struct Private { inline Private() noexcept : type(Invalid), is_shared(false), is_null(true) - { data.ptr = nullptr; } + {} // Internal constructor for initialized variants. explicit inline Private(uint variantType) noexcept @@ -412,6 +412,7 @@ class Q_CORE_EXPORT QVariant #endif union Data { + void *threeptr[3] = { nullptr, nullptr, nullptr }; char c; uchar uc; short s; -- cgit v1.2.3 From db89349bdba2fcc03b2f7e2d23f549a9ec5dc0e3 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 25 Nov 2019 17:53:55 +0100 Subject: Optimize QArrayDataOps::compare for primitive types Change-Id: If726e3ee8a3635dcec2a316f1a829392de298634 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydataops.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 8ca181edf1..f3de6b65a9 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -199,6 +199,11 @@ struct QPodArrayOps bool compare(const T *begin1, const T *begin2, size_t n) const { + // only use memcmp for fundamental types or pointers. + // Other types could have padding in the data structure or custom comparison + // operators that would break the comparison using memcmp + if (QArrayDataPointer<T>::pass_parameter_by_value) + return ::memcmp(begin1, begin2, n * sizeof(T)) == 0; const T *end1 = begin1 + n; while (begin1 != end1) { if (*begin1 == *begin2) -- cgit v1.2.3 From 7cc977759b84204427c1667e5b21ac75c3f7f5ab Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Mon, 9 Dec 2013 22:13:10 -0800 Subject: Use <type_traits> to properly have QVector<T>::parameter_type That allows us to pass by value for all fundamental and pointer types. This requires some magic to remove methods taking a T&& to avoid ambiguous overloads for QVector<int/qsizetype>. Remove them for all cases where parameter_type is T, as copying or moving will do exactly the same thing for those types. Change-Id: I8133fecd3ac29bb8f6ae57376e680bc3d616afbf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/tools/qarraydataops.h | 6 +++--- src/corelib/tools/qarraydatapointer.h | 7 +++++-- src/corelib/tools/qvector.h | 29 +++++++++++++++-------------- 3 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index f3de6b65a9..6b110c5143 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -62,7 +62,7 @@ template <class T> struct QPodArrayOps : public QArrayDataPointer<T> { - typedef T parameter_type; + typedef typename QArrayDataPointer<T>::parameter_type parameter_type; void appendInitialize(size_t newSize) { @@ -113,7 +113,7 @@ struct QPodArrayOps T *iter = this->end(); const T *const end = iter + n; for (; iter != end; ++iter) - ::memcpy(iter, &t, sizeof(T)); + *iter = t; this->size += int(n); } @@ -220,7 +220,7 @@ template <class T> struct QGenericArrayOps : public QArrayDataPointer<T> { - typedef const T ¶meter_type; + typedef typename QArrayDataPointer<T>::parameter_type parameter_type; void appendInitialize(size_t newSize) { diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 3d850c0144..1f81689af3 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -55,6 +55,9 @@ private: public: typedef typename Data::iterator iterator; typedef typename Data::const_iterator const_iterator; + enum { pass_parameter_by_value = std::is_fundamental<T>::value || std::is_pointer<T>::value }; + + typedef typename std::conditional<pass_parameter_by_value, T, const T &>::type parameter_type; QArrayDataPointer() noexcept : d(Data::sharedNull()), ptr(Data::sharedNullData()), size(0) @@ -131,8 +134,8 @@ public: ~QArrayDataPointer() { - if (!d->deref()) { - if (d->isMutable()) + if (!deref()) { + if (isMutable()) (*this)->destroyAll(); Data::deallocate(d); } diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 640809cd14..df6db45abc 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -49,6 +49,7 @@ #include <functional> #include <limits> #include <initializer_list> +#include <type_traits> QT_BEGIN_NAMESPACE @@ -74,6 +75,7 @@ class QVector typedef QTypedArrayData<T> Data; typedef QArrayDataOps<T> DataOps; typedef QArrayDataPointer<T> DataPointer; + class DisableRValueRefs {}; DataPointer d; @@ -95,9 +97,8 @@ public: typedef const_iterator ConstIterator; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - // ### The line below triggers too earely instantiation of QTypeInfo<QVariant> in qvariant.h - //typedef typename DataOps::parameter_type parameter_type; - typedef const_reference parameter_type; + typedef typename DataPointer::parameter_type parameter_type; + using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type; private: void resize_internal(int i, Qt::Initialization); @@ -242,7 +243,7 @@ public: void append(const_iterator i1, const_iterator i2); void append(value_type &&t); void append(const QVector<T> &l) { append(l.constBegin(), l.constEnd()); } - void prepend(T &&t); + void prepend(rvalue_ref t); void prepend(const T &t); iterator insert(int i, parameter_type t) { return insert(i, 1, t); } @@ -257,12 +258,12 @@ public: Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); return insert(std::distance(constBegin(), before), n, t); } - inline iterator insert(const_iterator before, T &&t) + iterator insert(const_iterator before, rvalue_ref t) { Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid"); return insert(std::distance(constBegin(), before), std::move(t)); } - iterator insert(int i, T &&t); + iterator insert(int i, rvalue_ref t); #if 0 template< class InputIt > iterator insert( const_iterator pos, InputIt first, InputIt last ); @@ -274,7 +275,7 @@ public: const T copy(t); data()[i] = copy; } - void replace(int i, T &&t) + void replace(int i, rvalue_ref t) { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range"); const T copy(std::move(t)); @@ -381,8 +382,8 @@ public: // STL compatibility inline void push_back(const T &t) { append(t); } - void push_back(T &&t) { append(std::move(t)); } - void push_front(T &&t) { prepend(std::move(t)); } + void push_back(rvalue_ref t) { append(std::move(t)); } + void push_front(rvalue_ref t) { prepend(std::move(t)); } inline void push_front(const T &t) { prepend(t); } void pop_back() { removeLast(); } void pop_front() { removeFirst(); } @@ -404,9 +405,9 @@ public: { append(t); return *this; } inline QVector<T> &operator<<(const QVector<T> &l) { *this += l; return *this; } - inline QVector<T> &operator+=(T &&t) + inline QVector<T> &operator+=(rvalue_ref t) { append(std::move(t)); return *this; } - inline QVector<T> &operator<<(T &&t) + inline QVector<T> &operator<<(rvalue_ref t) { append(std::move(t)); return *this; } // Consider deprecating in 6.4 or later @@ -508,7 +509,7 @@ template <typename T> inline void QVector<T>::prepend(const T &t) { insert(begin(), 1, t); } template <typename T> -inline void QVector<T>::prepend(T &&t) +void QVector<T>::prepend(rvalue_ref t) { insert(begin(), std::move(t)); } template<typename T> @@ -590,8 +591,8 @@ QVector<T>::insert(int i, int n, parameter_type t) } template <typename T> -inline typename QVector<T>::iterator -QVector<T>::insert(int i, T &&t) +typename QVector<T>::iterator +QVector<T>::insert(int i, rvalue_ref t) { Q_ASSERT_X(size_t(i) <= size_t(d->size), "QVector<T>::insert", "index out of range"); -- cgit v1.2.3 From 063e39df13dd53975d7d6615aa9f7e8429648aed Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Wed, 13 Nov 2019 09:29:42 +0100 Subject: Get rid of QCharRef and QByteRef We already detach immediately since change c2d2757bccc68e1b981df059786c2e76f2969530. That basically removes the main purpose of having QChar/ByteRef, and we can just as well get rid of those classes for Qt 6. Change-Id: I8dc566a1948ddc29c0cb8a77ec7310654a7219a4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/doc/src/dontdocument.qdoc | 2 +- src/corelib/text/qbytearray.cpp | 58 +------------- src/corelib/text/qbytearray.h | 89 ++-------------------- src/corelib/text/qchar.h | 1 - src/corelib/text/qstring.cpp | 42 +---------- src/corelib/text/qstring.h | 138 ++-------------------------------- src/corelib/text/qstringbuilder.cpp | 4 +- src/corelib/text/qstringbuilder.h | 10 --- 8 files changed, 23 insertions(+), 321 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/src/dontdocument.qdoc b/src/corelib/doc/src/dontdocument.qdoc index 19ca7db299..d7859a45af 100644 --- a/src/corelib/doc/src/dontdocument.qdoc +++ b/src/corelib/doc/src/dontdocument.qdoc @@ -29,7 +29,7 @@ \dontdocument (QMacAutoReleasePool QIncompatibleFlag QGenericAtomicOps QAtomicTraits QAtomicOps QBasicAtomicInteger QBasicAtomicPointer QBasicMutex QInternal QArgument QReturnArgument QArrayData QTypedArrayData QStaticByteArrayData - QByteRef QStaticStringData QListSpecialMethods QListData QScopedPointerDeleter + QStaticStringData QListSpecialMethods QListData QScopedPointerDeleter QScopedPointerArrayDeleter QScopedPointerPodDeleter QScopedPointerObjectDeleteLater QMetaTypeId2 QObjectData QObjectUserData QMapNodeBase QMapNode QMapDataBase QMapData QHashData QHashNode QArrayDataPointer QTextStreamManipulator diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index c13a6d3379..95f6e2a860 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1423,7 +1423,7 @@ QByteArray &QByteArray::operator=(const char *str) \sa operator[]() */ -/*! \fn QByteRef QByteArray::operator[](int i) +/*! \fn char &QByteArray::operator[](int i) Returns the byte at index position \a i as a modifiable reference. @@ -1434,21 +1434,6 @@ QByteArray &QByteArray::operator=(const char *str) Example: \snippet code/src_corelib_tools_qbytearray.cpp 9 - The return value is of type QByteRef, a helper class for - QByteArray. When you get an object of type QByteRef, you can use - it as if it were a char &. If you assign to it, the assignment - will apply to the character in the QByteArray from which you got - the reference. - - \note Before Qt 5.14 it was possible to use this operator to access - a character at an out-of-bounds position in the byte array, and - then assign to such a position, causing the byte array to be - automatically resized. Furthermore, assigning a value to the - returned QByteRef would cause a detach of the byte array, even if the - byte array has been copied in the meanwhile (and the QByteRef kept - alive while the copy was taken). These behaviors are deprecated, - and will be changed in a future version of Qt. - \sa at() */ @@ -1490,7 +1475,7 @@ QByteArray &QByteArray::operator=(const char *str) */ /*! - \fn QByteRef QByteArray::front() + \fn char &QByteArray::front() \since 5.10 Returns a reference to the first character in the byte array. @@ -1505,7 +1490,7 @@ QByteArray &QByteArray::operator=(const char *str) */ /*! - \fn QByteRef QByteArray::back() + \fn char &QByteArray::back() \since 5.10 Returns a reference to the last character in the byte array. @@ -4904,41 +4889,4 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA \sa QStringLiteral */ -namespace QtPrivate { -namespace DeprecatedRefClassBehavior { -void warn(WarningType w, EmittingClass c) -{ - static const char deprecatedBehaviorString[] = - "The corresponding behavior is deprecated, and will be changed" - " in a future version of Qt."; - - const char *emittingClassName = nullptr; - const char *containerClassName = nullptr; - - switch (c) { - case EmittingClass::QByteRef: - emittingClassName = "QByteRef"; - containerClassName = "QByteArray"; - break; - case EmittingClass::QCharRef: - emittingClassName = "QCharRef"; - containerClassName = "QString"; - break; - } - - switch (w) { - case WarningType::OutOfRange: - qWarning("Using %s with an index pointing outside the valid range of a %s. %s", - emittingClassName, containerClassName, deprecatedBehaviorString); - break; - case WarningType::DelayedDetach: - qWarning("Using %s with on a %s that is not already detached. %s", - emittingClassName, containerClassName, deprecatedBehaviorString); - break; - } -} -} // namespace DeprecatedRefClassBehavior -} // namespace QtPrivate - - QT_END_NAMESPACE diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 9abe7d74e3..e4291eae4e 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -110,7 +110,6 @@ Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...); Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len, Qt::ChecksumType standard = Qt::ChecksumIso3309); -class QByteRef; class QString; class QDataStream; @@ -191,11 +190,11 @@ public: inline char at(int i) const; inline char operator[](int i) const; - Q_REQUIRED_RESULT inline QByteRef operator[](int i); + Q_REQUIRED_RESULT inline char &operator[](int i); Q_REQUIRED_RESULT char front() const { return at(0); } - Q_REQUIRED_RESULT inline QByteRef front(); + Q_REQUIRED_RESULT inline char &front(); Q_REQUIRED_RESULT char back() const { return at(size() - 1); } - Q_REQUIRED_RESULT inline QByteRef back(); + Q_REQUIRED_RESULT inline char &back(); int indexOf(char c, int from = 0) const; int indexOf(const char *c, int from = 0) const; @@ -439,7 +438,6 @@ private: static QByteArray simplified_helper(const QByteArray &a); static QByteArray simplified_helper(QByteArray &a); - friend class QByteRef; friend class QString; friend Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes); public: @@ -503,83 +501,10 @@ inline void QByteArray::squeeze() } } -namespace QtPrivate { -namespace DeprecatedRefClassBehavior { - enum class EmittingClass { - QByteRef, - QCharRef, - }; - - enum class WarningType { - OutOfRange, - DelayedDetach, - }; - - Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void warn(WarningType w, EmittingClass c); -} // namespace DeprecatedAssignmentOperatorBehavior -} // namespace QtPrivate - -class -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -Q_CORE_EXPORT -#endif -QByteRef { // ### Qt 7: remove - QByteArray &a; - int i; - inline QByteRef(QByteArray &array, int idx) - : a(array),i(idx) {} - friend class QByteArray; -public: - inline operator char() const - { - using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_LIKELY(i < a.size())) - return a.constData()[i]; -#ifdef QT_DEBUG - warn(WarningType::OutOfRange, EmittingClass::QByteRef); -#endif - return char(0); - } - inline QByteRef &operator=(char c) - { - using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_UNLIKELY(i >= a.size())) { -#ifdef QT_DEBUG - warn(WarningType::OutOfRange, EmittingClass::QByteRef); -#endif - a.expand(i); - } else { -#ifdef QT_DEBUG - if (Q_UNLIKELY(!a.isDetached())) - warn(WarningType::DelayedDetach, EmittingClass::QByteRef); -#endif - a.detach(); - } - a.d.b[i] = c; - return *this; - } - inline QByteRef &operator=(const QByteRef &c) - { - return operator=(char(c)); - } - inline bool operator==(char c) const - { return a.data()[i] == c; } - inline bool operator!=(char c) const - { return a.data()[i] != c; } - inline bool operator>(char c) const - { return a.data()[i] > c; } - inline bool operator>=(char c) const - { return a.data()[i] >= c; } - inline bool operator<(char c) const - { return a.data()[i] < c; } - inline bool operator<=(char c) const - { return a.data()[i] <= c; } -}; - -inline QByteRef QByteArray::operator[](int i) -{ Q_ASSERT(i >= 0); detach(); return QByteRef(*this, i); } -inline QByteRef QByteArray::front() { return operator[](0); } -inline QByteRef QByteArray::back() { return operator[](size() - 1); } +inline char &QByteArray::operator[](int i) +{ Q_ASSERT(i >= 0 && i < size()); return data()[i]; } +inline char &QByteArray::front() { return operator[](0); } +inline char &QByteArray::back() { return operator[](size() - 1); } inline QByteArray::iterator QByteArray::begin() { return data(); } inline QByteArray::const_iterator QByteArray::begin() const diff --git a/src/corelib/text/qchar.h b/src/corelib/text/qchar.h index a3d5d7a65e..9d0741af8b 100644 --- a/src/corelib/text/qchar.h +++ b/src/corelib/text/qchar.h @@ -439,7 +439,6 @@ public: Unicode_12_0, Unicode_12_1 }; - // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO inline Category category() const noexcept { return QChar::category(ucs); } inline Direction direction() const noexcept { return QChar::direction(ucs); } diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 7758687f0f..d2d7104cd5 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -1359,28 +1359,6 @@ const QString::Null QString::null = { }; \sa QT_NO_CAST_TO_ASCII, QT_NO_CAST_FROM_ASCII, QT_RESTRICTED_CAST_FROM_ASCII */ -/*! - \class QCharRef - \inmodule QtCore - \reentrant - \brief The QCharRef class is a helper class for QString. - - \internal - - \ingroup string-processing - - When you get an object of type QCharRef, if you can assign to it, - the assignment will apply to the character in the string from - which you got the reference. That is its whole purpose in life. - The QCharRef becomes invalid once modifications are made to the - string: if you want to keep the character, copy it into a QChar. - - Most of the QChar member functions also exist in QCharRef. - However, they are not explicitly documented here. - - \sa QString::operator[](), QString::at(), QChar -*/ - /*! \class QString \inmodule QtCore @@ -5737,7 +5715,7 @@ QString QString::trimmed_helper(QString &str) */ /*! - \fn QCharRef QString::operator[](int position) + \fn QChar &QString::operator[](int position) Returns the character at the specified \a position in the string as a modifiable reference. @@ -5746,20 +5724,6 @@ QString QString::trimmed_helper(QString &str) \snippet qstring/main.cpp 85 - The return value is of type QCharRef, a helper class for QString. - When you get an object of type QCharRef, you can use it as if it - were a reference to a QChar. If you assign to it, the assignment will apply to - the character in the QString from which you got the reference. - - \note Before Qt 5.14 it was possible to use this operator to access - a character at an out-of-bounds position in the string, and - then assign to such a position, causing the string to be - automatically resized. Furthermore, assigning a value to the - returned QCharRef would cause a detach of the string, even if the - string has been copied in the meanwhile (and the QCharRef kept - alive while the copy was taken). These behaviors are deprecated, - and will be changed in a future version of Qt. - \sa at() */ @@ -5800,7 +5764,7 @@ QString QString::trimmed_helper(QString &str) */ /*! - \fn QCharRef QString::front() + \fn QChar &QString::front() \since 5.10 Returns a reference to the first character in the string. @@ -5815,7 +5779,7 @@ QString QString::trimmed_helper(QString &str) */ /*! - \fn QCharRef QString::back() + \fn QChar &QString::back() \since 5.10 Returns a reference to the last character in the string. diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 96c0ec7ceb..3048c7a8cc 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -70,7 +70,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSString); QT_BEGIN_NAMESPACE -class QCharRef; class QRegExp; class QRegularExpression; class QRegularExpressionMatch; @@ -290,12 +289,12 @@ public: inline const QChar at(int i) const; const QChar operator[](int i) const; - Q_REQUIRED_RESULT QCharRef operator[](int i); + Q_REQUIRED_RESULT QChar &operator[](int i); Q_REQUIRED_RESULT inline QChar front() const { return at(0); } - Q_REQUIRED_RESULT inline QCharRef front(); + Q_REQUIRED_RESULT inline QChar &front(); Q_REQUIRED_RESULT inline QChar back() const { return at(size() - 1); } - Q_REQUIRED_RESULT inline QCharRef back(); + Q_REQUIRED_RESULT inline QChar &back(); Q_REQUIRED_RESULT QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar = QLatin1Char(' ')) const; @@ -979,7 +978,6 @@ private: static qlonglong toIntegral_helper(const QChar *data, int len, bool *ok, int base); static qulonglong toIntegral_helper(const QChar *data, uint len, bool *ok, int base); void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen); - friend class QCharRef; friend class QTextCodec; friend class QStringRef; friend class QStringView; @@ -1131,128 +1129,6 @@ inline QString QString::fromWCharArray(const wchar_t *string, int size) : fromUcs4(reinterpret_cast<const uint *>(string), size); } -class -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -Q_CORE_EXPORT -#endif -QCharRef { // ### Qt 7: remove - QString &s; - int i; - inline QCharRef(QString &str, int idx) - : s(str),i(idx) {} - friend class QString; -public: - - // most QChar operations repeated here - - // all this is not documented: We just say "like QChar" and let it be. - inline operator QChar() const - { - using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_LIKELY(i < s.size())) - return QChar(s.constData()[i]); -#ifdef QT_DEBUG - warn(WarningType::OutOfRange, EmittingClass::QCharRef); -#endif - return QChar(); - } - inline QCharRef &operator=(QChar c) - { - using namespace QtPrivate::DeprecatedRefClassBehavior; - if (Q_UNLIKELY(i >= s.size())) { -#ifdef QT_DEBUG - warn(WarningType::OutOfRange, EmittingClass::QCharRef); -#endif - s.resize(i + 1, QLatin1Char(' ')); - } else { -#ifdef QT_DEBUG - if (Q_UNLIKELY(!s.isDetached())) - warn(WarningType::DelayedDetach, EmittingClass::QCharRef); -#endif - s.detach(); - } - s.d.b[i] = c.unicode(); - return *this; - } - - // An operator= for each QChar cast constructors -#ifndef QT_NO_CAST_FROM_ASCII - inline QT_ASCII_CAST_WARN QCharRef &operator=(char c) - { return operator=(QChar::fromLatin1(c)); } - inline QT_ASCII_CAST_WARN QCharRef &operator=(uchar c) - { return operator=(QChar::fromLatin1(c)); } -#endif - inline QCharRef &operator=(const QCharRef &c) { return operator=(QChar(c)); } - inline QCharRef &operator=(ushort rc) { return operator=(QChar(rc)); } - inline QCharRef &operator=(short rc) { return operator=(QChar(rc)); } - inline QCharRef &operator=(uint rc) { return operator=(QChar(rc)); } - inline QCharRef &operator=(int rc) { return operator=(QChar(rc)); } - - // each function... - inline bool isNull() const { return QChar(*this).isNull(); } - inline bool isPrint() const { return QChar(*this).isPrint(); } - inline bool isPunct() const { return QChar(*this).isPunct(); } - inline bool isSpace() const { return QChar(*this).isSpace(); } - inline bool isMark() const { return QChar(*this).isMark(); } - inline bool isLetter() const { return QChar(*this).isLetter(); } - inline bool isNumber() const { return QChar(*this).isNumber(); } - inline bool isLetterOrNumber() { return QChar(*this).isLetterOrNumber(); } - inline bool isDigit() const { return QChar(*this).isDigit(); } - inline bool isLower() const { return QChar(*this).isLower(); } - inline bool isUpper() const { return QChar(*this).isUpper(); } - inline bool isTitleCase() const { return QChar(*this).isTitleCase(); } - - inline int digitValue() const { return QChar(*this).digitValue(); } - QChar toLower() const { return QChar(*this).toLower(); } - QChar toUpper() const { return QChar(*this).toUpper(); } - QChar toTitleCase () const { return QChar(*this).toTitleCase(); } - - QChar::Category category() const { return QChar(*this).category(); } - QChar::Direction direction() const { return QChar(*this).direction(); } - QChar::JoiningType joiningType() const { return QChar(*this).joiningType(); } -#if QT_DEPRECATED_SINCE(5, 3) - QT_DEPRECATED QChar::Joining joining() const - { - switch (QChar(*this).joiningType()) { - case QChar::Joining_Causing: return QChar::Center; - case QChar::Joining_Dual: return QChar::Dual; - case QChar::Joining_Right: return QChar::Right; - case QChar::Joining_None: - case QChar::Joining_Left: - case QChar::Joining_Transparent: - default: return QChar::OtherJoining; - } - } -#endif - bool hasMirrored() const { return QChar(*this).hasMirrored(); } - QChar mirroredChar() const { return QChar(*this).mirroredChar(); } - QString decomposition() const { return QChar(*this).decomposition(); } - QChar::Decomposition decompositionTag() const { return QChar(*this).decompositionTag(); } - uchar combiningClass() const { return QChar(*this).combiningClass(); } - - inline QChar::Script script() const { return QChar(*this).script(); } - - QChar::UnicodeVersion unicodeVersion() const { return QChar(*this).unicodeVersion(); } - - inline uchar cell() const { return QChar(*this).cell(); } - inline uchar row() const { return QChar(*this).row(); } - inline void setCell(uchar cell); - inline void setRow(uchar row); - -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED char toAscii() const { return QChar(*this).toLatin1(); } -#endif - char toLatin1() const { return QChar(*this).toLatin1(); } - ushort unicode() const { return QChar(*this).unicode(); } - ushort& unicode() { return s.data()[i].unicode(); } - -}; -Q_DECLARE_TYPEINFO(QCharRef, Q_MOVABLE_TYPE); - -inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); } -inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); } - - inline QString::QString() noexcept { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } inline QString::~QString() { if (!d.d->deref()) Data::deallocate(d.d); } @@ -1278,10 +1154,10 @@ inline void QString::squeeze() inline QString &QString::setUtf16(const ushort *autf16, int asize) { return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); } -inline QCharRef QString::operator[](int i) -{ Q_ASSERT(i >= 0); detach(); return QCharRef(*this, i); } -inline QCharRef QString::front() { return operator[](0); } -inline QCharRef QString::back() { return operator[](size() - 1); } +inline QChar &QString::operator[](int i) +{ Q_ASSERT(i >= 0 && i < size()); return data()[i]; } +inline QChar &QString::front() { return operator[](0); } +inline QChar &QString::back() { return operator[](size() - 1); } inline QString::iterator QString::begin() { detach(); return reinterpret_cast<QChar*>(d.b); } inline QString::const_iterator QString::begin() const diff --git a/src/corelib/text/qstringbuilder.cpp b/src/corelib/text/qstringbuilder.cpp index cf443ec369..29bd216e80 100644 --- a/src/corelib/text/qstringbuilder.cpp +++ b/src/corelib/text/qstringbuilder.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE \list \li QString, QStringRef, (since 5.10:) QStringView - \li QChar, QCharRef, QLatin1Char, (since 5.10:) \c char16_t, + \li QChar, QLatin1Char, (since 5.10:) \c char16_t, \li QLatin1String, \li (since 5.10:) \c{const char16_t[]} (\c{u"foo"}), \li QByteArray, \c char, \c{const char[]}. @@ -108,7 +108,7 @@ QT_BEGIN_NAMESPACE This function is usable with arguments of type \c QString, \c QLatin1String, \c QStringRef, - \c QChar, \c QCharRef, \c QLatin1Char, and \c char. + \c QChar, \c QLatin1Char, and \c char. */ /* \fn template <typename A, typename B> QByteArray QStringBuilder<A, B>::toLatin1() const diff --git a/src/corelib/text/qstringbuilder.h b/src/corelib/text/qstringbuilder.h index 288d98d633..45fd270b66 100644 --- a/src/corelib/text/qstringbuilder.h +++ b/src/corelib/text/qstringbuilder.h @@ -231,16 +231,6 @@ template <> struct QConcatenable<QChar::SpecialCharacter> : private QAbstractCon { *out++ = c; } }; -template <> struct QConcatenable<QCharRef> : private QAbstractConcatenable -{ - typedef QCharRef type; - typedef QString ConvertTo; - enum { ExactSize = true }; - static int size(QCharRef) { return 1; } - static inline void appendTo(QCharRef c, QChar *&out) - { *out++ = QChar(c); } -}; - template <> struct QConcatenable<QLatin1String> : private QAbstractConcatenable { typedef QLatin1String type; -- cgit v1.2.3 From 8e34d49201b46b1e16cd3a8c99236f03a8250ff9 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Wed, 13 Nov 2019 18:59:09 +0100 Subject: Use the QByteArray::DataPointer typedef instead of QByteArrayData The goal here is to move things over to QArrayDataPointer. This prepares for it. Change-Id: I32f54a47594274799600c618f7341c200ceaa306 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/kernel/qobjectdefs.h | 1 - src/corelib/text/qbytearray.cpp | 6 +++--- src/corelib/text/qbytearray.h | 11 ++++++----- src/corelib/text/qbytearray_p.h | 2 +- src/corelib/text/qstring.cpp | 2 +- src/corelib/tools/qbitarray.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 229c97236e..657cb9940b 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE class QByteArray; struct QArrayData; -struct QByteArrayData; class QString; diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 95f6e2a860..feeb0409b4 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -746,7 +746,7 @@ QByteArray qUncompress(const uchar* data, int nbytes) case Z_OK: { Q_ASSERT(len <= alloc); Q_UNUSED(alloc); - QByteArrayData dataPtr = { d.take(), pair.second, uint(len) }; + QByteArray::DataPointer dataPtr = { d.take(), pair.second, uint(len) }; pair.second[len] = '\0'; return QByteArray(dataPtr); } @@ -3101,7 +3101,7 @@ QByteArray QByteArray::mid(int pos, int len) const case QContainerImplHelper::Empty: { auto alloc = Data::allocate(0); - QByteArrayData empty = { alloc.first, alloc.second, 0 }; + QByteArray::DataPointer empty = { alloc.first, alloc.second, 0 }; return QByteArray(empty); } case QContainerImplHelper::Full: @@ -4416,7 +4416,7 @@ QByteArray QByteArray::number(double n, char f, int prec) QByteArray QByteArray::fromRawData(const char *data, int size) { - QByteArrayData x; + QByteArray::DataPointer x; if (!data) { x.d = Data::sharedNull(); x.b = Data::sharedNullData(); diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index e4291eae4e..19bf4fa1e5 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -136,10 +136,14 @@ struct QByteArrayData class Q_CORE_EXPORT QByteArray { +public: + using DataPointer = QByteArrayData; private: typedef QTypedArrayData<char> Data; + DataPointer d; public: + enum Base64Option { Base64Encoding = 0, Base64UrlEncoding = 1, @@ -417,14 +421,14 @@ public: int length() const { return int(d.size); } bool isNull() const; - explicit inline QByteArray(const QByteArrayData &dd) + inline DataPointer &data_ptr() { return d; } + explicit inline QByteArray(const DataPointer &dd) : d(dd) { } private: operator QNoImplicitBoolCast() const; - QByteArrayData d; void reallocData(uint alloc, Data::ArrayOptions options); void expand(int i); QByteArray nulTerminated() const; @@ -440,9 +444,6 @@ private: friend class QString; friend Q_CORE_EXPORT QByteArray qUncompress(const uchar *data, int nbytes); -public: - typedef QByteArrayData DataPtr; - inline DataPtr &data_ptr() { return d; } }; Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options) diff --git a/src/corelib/text/qbytearray_p.h b/src/corelib/text/qbytearray_p.h index 3c6257f786..d6a5e277b3 100644 --- a/src/corelib/text/qbytearray_p.h +++ b/src/corelib/text/qbytearray_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE enum { // Define as enum to force inlining. Don't expose MaxAllocSize in a public header. - MaxByteArraySize = MaxAllocSize - sizeof(std::remove_pointer<QByteArray::DataPtr>::type) + MaxByteArraySize = MaxAllocSize - sizeof(std::remove_pointer<QByteArray::DataPointer>::type) }; QT_END_NAMESPACE diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index d2d7104cd5..cb83a31df1 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -5148,7 +5148,7 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) // Swap the d pointers. // Kids, avert your eyes. Don't try this at home. - QByteArrayData ba_d = { + QByteArray::DataPointer ba_d = { s.d.d, reinterpret_cast<char *>(s.d.b), length diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index 9b0e931aca..4ea613a442 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -106,7 +106,7 @@ public: static QBitArray fromBits(const char *data, qsizetype len); public: - typedef QByteArray::DataPtr DataPtr; + typedef QByteArray::DataPointer DataPtr; inline DataPtr &data_ptr() { return d.data_ptr(); } }; -- cgit v1.2.3 From 20041afe3bdb3d3476c02897b8da288cba6011f4 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Wed, 13 Nov 2019 20:33:50 +0100 Subject: Use QArrayDataPointer to implement QByteArray Change-Id: I2ee28023c2dea9fc3160400112c59a47566a4868 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qbytearray.cpp | 219 +++++++++++++--------------------- src/corelib/text/qbytearray.h | 58 ++++----- src/corelib/text/qstring.cpp | 16 +-- src/corelib/tools/qarraydata.cpp | 1 + src/corelib/tools/qarraydatapointer.h | 7 ++ 5 files changed, 126 insertions(+), 175 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index feeb0409b4..3f5fef80e2 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -63,7 +63,7 @@ #include <string.h> #include <stdlib.h> -#define IS_RAW_DATA(d) ((d)->flags & QArrayData::RawDataType) +#define IS_RAW_DATA(d) ((d)->flags() & QArrayData::RawDataType) QT_BEGIN_NAMESPACE @@ -1183,9 +1183,6 @@ QByteArray qUncompress(const uchar* data, int nbytes) */ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept { - other.d.d->ref(); - if (!d.d->deref()) - Data::deallocate(d.d); d = other.d; return *this; } @@ -1205,20 +1202,15 @@ QByteArray &QByteArray::operator=(const char *str) pair = qMakePair(Data::sharedNull(), Data::sharedNullData()); } else { pair = Data::allocate(0); - pair.first->ref(); } - if (!d.d->deref()) - Data::deallocate(d.d); - d.d = pair.first; - d.b = pair.second; - d.size = 0; + d = QByteArrayData(pair.first, pair.second, 0); } else { const int len = int(strlen(str)); const size_t fullLen = len + 1; - if (d.d->needsDetach() || fullLen > d.d->allocatedCapacity() - || (len < size() && fullLen < (d.d->allocatedCapacity() >> 1))) - reallocData(fullLen, d.d->detachFlags()); - memcpy(d.b, str, fullLen); // include null terminator + if (d->needsDetach() || fullLen > d->allocatedCapacity() + || (len < size() && fullLen < (d->allocatedCapacity() >> 1))) + reallocData(fullLen, d->detachFlags()); + memcpy(d.data(), str, fullLen); // include null terminator d.size = len; } return *this; @@ -1665,19 +1657,13 @@ void QByteArray::chop(int n) QByteArray::QByteArray(const char *data, int size) { if (!data) { - d.d = Data::sharedNull(); - d.b = Data::sharedNullData(); - d.size = 0; + d = DataPointer(); } else { if (size < 0) size = int(strlen(data)); - QPair<Data *, char *> pair = Data::allocate(uint(size) + 1u); - Q_CHECK_PTR(pair.first); - d.d = pair.first; - d.b = pair.second; - d.size = size; - memcpy(d.b, data, size); - d.b[size] = '\0'; + d = DataPointer(Data::allocate(uint(size) + 1u), size); + memcpy(d.data(), data, size); + d.data()[size] = '\0'; } } @@ -1691,18 +1677,11 @@ QByteArray::QByteArray(const char *data, int size) QByteArray::QByteArray(int size, char ch) { if (size <= 0) { - QPair<Data *, char *> pair = Data::allocate(0); - d.d = pair.first; - d.b = pair.second; - d.size = 0; + d = DataPointer(Data::allocate(0), 0); } else { - QPair<Data *, char *> pair = Data::allocate(uint(size) + 1u); - Q_CHECK_PTR(pair.first); - d.d = pair.first; - d.b = pair.second; - d.size = size; - memset(d.b, ch, size); - d.b[size] = '\0'; + d = DataPointer(Data::allocate(uint(size) + 1u), size); + memset(d.data(), ch, size); + d.data()[size] = '\0'; } } @@ -1714,12 +1693,8 @@ QByteArray::QByteArray(int size, char ch) QByteArray::QByteArray(int size, Qt::Initialization) { - QPair<Data *, char *> pair = Data::allocate(uint(size) + 1u); - Q_CHECK_PTR(pair.first); - d.d = pair.first; - d.b = pair.second; - d.size = size; - d.b[size] = '\0'; + d = DataPointer(Data::allocate(uint(size) + 1u), size); + d.data()[size] = '\0'; } /*! @@ -1739,26 +1714,21 @@ void QByteArray::resize(int size) if (size < 0) size = 0; - if (!d.d->isShared() && !d.d->isMutable() && size < int(d.size)) { + if (!d->isShared() && !d->isMutable() && size < int(d.size)) { d.size = size; return; } - if (size == 0 && !(d.d->flags & Data::CapacityReserved)) { - QPair<Data *, char *> pair = Data::allocate(0); - if (!d.d->deref()) - Data::deallocate(d.d); - d.d = pair.first; - d.b = pair.second; - d.size = 0; + if (size == 0 && !(d->flags() & Data::CapacityReserved)) { + d = DataPointer(Data::allocate(0), 0); } else { - if (d.d->needsDetach() || size > capacity() - || (!(d.d->flags & Data::CapacityReserved) && size < int(d.size) + if (d->needsDetach() || size > capacity() + || (!(d->flags() & Data::CapacityReserved) && size < int(d.size) && size < (capacity() >> 1))) - reallocData(uint(size) + 1u, d.d->detachFlags() | Data::GrowsForward); + reallocData(uint(size) + 1u, d->detachFlags() | Data::GrowsForward); d.size = size; - if (d.d->isMutable()) { - d.b[size] = '\0'; + if (d->isMutable()) { + d.data()[size] = '\0'; } } } @@ -1778,28 +1748,19 @@ QByteArray &QByteArray::fill(char ch, int size) { resize(size < 0 ? this->size() : size); if (this->size()) - memset(d.b, ch, this->size()); + memset(d.data(), ch, this->size()); return *this; } void QByteArray::reallocData(uint alloc, Data::ArrayOptions options) { - if (d.d->needsDetach()) { - QPair<Data *, char *> pair = Data::allocate(alloc, options); - Q_CHECK_PTR(pair.first); - d.size = qMin(alloc - 1, d.size); - ::memcpy(pair.second, d.b, d.size); - pair.second[d.size] = 0; - if (!d.d->deref()) - Data::deallocate(d.d); - d.d = pair.first; - d.b = pair.second; + if (d->needsDetach()) { + DataPointer dd(Data::allocate(alloc, options), qMin(int(alloc) - 1, d.size)); + ::memcpy(dd.data(), d.data(), dd.size); + dd.data()[dd.size] = 0; + d = dd; } else { - QPair<Data *, char *> pair = - Data::reallocateUnaligned(static_cast<Data *>(d.d), d.b, alloc, options); - Q_CHECK_PTR(pair.first); - d.d = pair.first; - d.b = pair.second; + d.reallocate(alloc, options); } } @@ -1820,7 +1781,7 @@ void QByteArray::expand(int i) QByteArray QByteArray::nulTerminated() const { // is this fromRawData? - if (!IS_RAW_DATA(d.d)) + if (!IS_RAW_DATA(d)) return *this; // no, then we're sure we're zero terminated QByteArray copy(*this); @@ -1851,7 +1812,7 @@ QByteArray QByteArray::nulTerminated() const QByteArray &QByteArray::prepend(const QByteArray &ba) { - if (size() == 0 && d.d->isStatic() && !IS_RAW_DATA(ba.d.d)) { + if (size() == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.size() != 0) { QByteArray tmp = *this; @@ -1882,12 +1843,12 @@ QByteArray &QByteArray::prepend(const char *str) QByteArray &QByteArray::prepend(const char *str, int len) { if (str) { - if (d.d->needsDetach() || size() + len > capacity()) - reallocData(uint(size() + len) + 1u, d.d->detachFlags() | Data::GrowsForward); - memmove(d.b+len, d.b, d.size); - memcpy(d.b, str, len); + if (d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, d->detachFlags() | Data::GrowsForward); + memmove(d.data()+len, d.data(), d.size); + memcpy(d.data(), str, len); d.size += len; - d.b[d.size] = '\0'; + d.data()[d.size] = '\0'; } return *this; } @@ -1908,12 +1869,12 @@ QByteArray &QByteArray::prepend(const char *str, int len) QByteArray &QByteArray::prepend(char ch) { - if (d.d->needsDetach() || size() + 1 > capacity()) - reallocData(uint(size()) + 2u, d.d->detachFlags() | Data::GrowsForward); - memmove(d.b+1, d.b, d.size); - d.b[0] = ch; + if (d->needsDetach() || size() + 1 > capacity()) + reallocData(uint(size()) + 2u, d->detachFlags() | Data::GrowsForward); + memmove(d.data()+1, d.data(), d.size); + d.data()[0] = ch; ++d.size; - d.b[d.size] = '\0'; + d.data()[d.size] = '\0'; return *this; } @@ -1943,14 +1904,14 @@ QByteArray &QByteArray::prepend(char ch) QByteArray &QByteArray::append(const QByteArray &ba) { - if (size() == 0 && d.d->isStatic() && !IS_RAW_DATA(ba.d.d)) { + if (size() == 0 && d->isStatic() && !IS_RAW_DATA(ba.d)) { *this = ba; } else if (ba.size() != 0) { - if (d.d->needsDetach() || size() + ba.size() > capacity()) - reallocData(uint(size() + ba.size()) + 1u, d.d->detachFlags() | Data::GrowsForward); - memcpy(d.b + d.size, ba.data(), ba.size()); + if (d->needsDetach() || size() + ba.size() > capacity()) + reallocData(uint(size() + ba.size()) + 1u, d->detachFlags() | Data::GrowsForward); + memcpy(d.data() + d.size, ba.data(), ba.size()); d.size += ba.size(); - d.b[d.size] = '\0'; + d.data()[d.size] = '\0'; } return *this; } @@ -1978,9 +1939,9 @@ QByteArray& QByteArray::append(const char *str) { if (str) { const int len = int(strlen(str)); - if (d.d->needsDetach() || size() + len > capacity()) - reallocData(uint(size() + len) + 1u, d.d->detachFlags() | Data::GrowsForward); - memcpy(d.b + d.size, str, len + 1); // include null terminator + if (d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, d->detachFlags() | Data::GrowsForward); + memcpy(d.data() + d.size, str, len + 1); // include null terminator d.size += len; } return *this; @@ -2003,11 +1964,11 @@ QByteArray &QByteArray::append(const char *str, int len) if (len < 0) len = qstrlen(str); if (str && len) { - if (d.d->needsDetach() || size() + len > capacity()) - reallocData(uint(size() + len) + 1u, d.d->detachFlags() | Data::GrowsForward); - memcpy(d.b + d.size, str, len); + if (d->needsDetach() || size() + len > capacity()) + reallocData(uint(size() + len) + 1u, d->detachFlags() | Data::GrowsForward); + memcpy(d.data() + d.size, str, len); d.size += len; - d.b[d.size] = '\0'; + d.data()[d.size] = '\0'; } return *this; } @@ -2031,10 +1992,10 @@ QByteArray &QByteArray::append(const char *str, int len) QByteArray& QByteArray::append(char ch) { - if (d.d->needsDetach() || size() + 1 > capacity()) - reallocData(uint(size()) + 2u, d.d->detachFlags() | Data::GrowsForward); - d.b[d.size++] = ch; - d.b[d.size] = '\0'; + if (d->needsDetach() || size() + 1 > capacity()) + reallocData(uint(size()) + 2u, d->detachFlags() | Data::GrowsForward); + d.data()[d.size++] = ch; + d.data()[d.size] = '\0'; return *this; } @@ -2157,7 +2118,7 @@ QByteArray &QByteArray::insert(int i, int count, char ch) int oldsize = size(); resize(qMax(i, oldsize) + count); - char *dst = d.b; + char *dst = d.data(); if (i > oldsize) ::memset(dst + oldsize, 0x20, i - oldsize); else if (i < oldsize) @@ -2188,7 +2149,7 @@ QByteArray &QByteArray::remove(int pos, int len) if (len >= size() - pos) { resize(pos); } else { - memmove(d.b + pos, d.b + pos + len, size() - pos - len); + memmove(d.data() + pos, d.data() + pos + len, size() - pos - len); resize(size() - len); } return *this; @@ -2208,7 +2169,7 @@ QByteArray &QByteArray::replace(int pos, int len, const QByteArray &after) { if (len == after.size() && (pos + len <= size())) { detach(); - memmove(d.b + pos, after.data(), len*sizeof(char)); + memmove(d.data() + pos, after.data(), len*sizeof(char)); return *this; } else { QByteArray copy(after); @@ -2245,7 +2206,7 @@ QByteArray &QByteArray::replace(int pos, int len, const char *after, int alen) { if (len == alen && (pos + len <= size())) { detach(); - memcpy(d.b + pos, after, len*sizeof(char)); + memcpy(d.data() + pos, after, len*sizeof(char)); return *this; } else { remove(pos, len); @@ -2384,7 +2345,7 @@ QByteArray &QByteArray::replace(const char *before, int bsize, const char *after resize(newlen); len = newlen; } - d = this->d.b; // data(), without the detach() check + d = this->d.data(); // data(), without the detach() check while(pos) { pos--; @@ -2549,19 +2510,19 @@ QByteArray QByteArray::repeated(int times) const if (result.capacity() != resultSize) return QByteArray(); // not enough memory - memcpy(result.d.b, data(), size()); + memcpy(result.d.data(), data(), size()); int sizeSoFar = size(); - char *end = result.d.b + sizeSoFar; + char *end = result.d.data() + sizeSoFar; const int halfResultSize = resultSize >> 1; while (sizeSoFar <= halfResultSize) { - memcpy(end, result.d.b, sizeSoFar); + memcpy(end, result.d.data(), sizeSoFar); end += sizeSoFar; sizeSoFar <<= 1; } - memcpy(end, result.d.b, resultSize - sizeSoFar); - result.d.b[resultSize] = '\0'; + memcpy(end, result.d.data(), resultSize - sizeSoFar); + result.d.data()[resultSize] = '\0'; result.d.size = resultSize; return result; } @@ -3107,7 +3068,7 @@ QByteArray QByteArray::mid(int pos, int len) const case QContainerImplHelper::Full: return *this; case QContainerImplHelper::Subset: - return QByteArray(d.b + pos, len); + return QByteArray(d.data() + pos, len); } Q_UNREACHABLE(); return QByteArray(); @@ -3210,11 +3171,7 @@ QByteArray QByteArray::toUpper_helper(QByteArray &a) void QByteArray::clear() { - if (!d.d->deref()) - Data::deallocate(d.d); - d.d = Data::sharedNull(); - d.b = Data::sharedNullData(); - d.size = 0; + d.clear(); } #if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)) @@ -3696,8 +3653,8 @@ QByteArray QByteArray::leftJustified(int width, char fill, bool truncate) const if (padlen > 0) { result.resize(len+padlen); if (len) - memcpy(result.d.b, data(), len); - memset(result.d.b+len, fill, padlen); + memcpy(result.d.data(), data(), len); + memset(result.d.data()+len, fill, padlen); } else { if (truncate) result = left(width); @@ -3733,8 +3690,8 @@ QByteArray QByteArray::rightJustified(int width, char fill, bool truncate) const if (padlen > 0) { result.resize(len+padlen); if (len) - memcpy(result.d.b+padlen, data(), len); - memset(result.d.b, fill, padlen); + memcpy(result.d.data()+padlen, data(), len); + memset(result.d.data(), fill, padlen); } else { if (truncate) result = left(width); @@ -3746,7 +3703,7 @@ QByteArray QByteArray::rightJustified(int width, char fill, bool truncate) const bool QByteArray::isNull() const { - return d.d == QArrayData::sharedNull(); + return d->isNull(); } static qlonglong toIntegral_helper(const char *data, bool *ok, int base, qlonglong) @@ -4418,19 +4375,10 @@ QByteArray QByteArray::fromRawData(const char *data, int size) { QByteArray::DataPointer x; if (!data) { - x.d = Data::sharedNull(); - x.b = Data::sharedNullData(); - x.size = 0; } else if (!size) { - QPair<Data *, char *> pair = Data::allocate(0); - x.d = pair.first; - x.b = pair.second; - x.size = 0; + x = DataPointer(Data::allocate(0), 0); } else { - x.d = Data::fromRawData(data, size).ptr; - Q_CHECK_PTR(x.d); - x.b = const_cast<char *>(data); - x.size = size; + x = Data::fromRawData(data, size); } return QByteArray(x); } @@ -4453,12 +4401,13 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) { if (!data || !size) { clear(); - } else if (d.d->isShared() || (d.d->flags & Data::RawDataType) == 0) { - *this = fromRawData(data, size); - } else { - d.size = size; - d.b = const_cast<char *>(data); } +// else if (d->isShared() || (d->flags() & Data::RawDataType) == 0) { + *this = fromRawData(data, size); +// } else { +// d.size = size; +// d.data() = const_cast<char *>(data); +// } return *this; } diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 19bf4fa1e5..af8e4da36d 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -44,6 +44,7 @@ #include <QtCore/qrefcount.h> #include <QtCore/qnamespace.h> #include <QtCore/qarraydata.h> +#include <QtCore/qarraydatapointer.h> #include <QtCore/qcontainerfwd.h> #include <stdlib.h> @@ -113,12 +114,7 @@ Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len, class QString; class QDataStream; -struct QByteArrayData -{ - QArrayData *d; - char *b; - uint size; -}; +using QByteArrayData = QArrayDataPointer<char>; # define QByteArrayLiteral(str) \ ([]() -> QByteArray { \ @@ -126,7 +122,7 @@ struct QByteArrayData static const QArrayData qbytearray_literal = { \ Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 }; \ QByteArrayData holder = { \ - const_cast<QArrayData *>(&qbytearray_literal), \ + static_cast<QTypedArrayData<char> *>(const_cast<QArrayData *>(&qbytearray_literal)), \ const_cast<char *>(str), \ Size }; \ const QByteArray ba(holder); \ @@ -162,14 +158,13 @@ public: QByteArray &operator=(const QByteArray &) noexcept; QByteArray &operator=(const char *str); - inline QByteArray(QByteArray && other) noexcept : d(std::move(other.d)) - { other.d.d = Data::sharedNull(); other.d.b = Data::sharedNullData(); other.d.size = 0; } + inline QByteArray(QByteArray && other) noexcept + { qSwap(d, other.d); } inline QByteArray &operator=(QByteArray &&other) noexcept { qSwap(d, other.d); return *this; } inline void swap(QByteArray &other) noexcept { qSwap(d, other.d); } - inline int size() const; inline bool isEmpty() const; void resize(int size); @@ -417,8 +412,9 @@ public: static inline QByteArray fromStdString(const std::string &s); inline std::string toStdString() const; - inline int count() const { return int(d.size); } - int length() const { return int(d.size); } + inline int size() const { return d->size; } + inline int count() const { return size(); } + inline int length() const { return size(); } bool isNull() const; inline DataPointer &data_ptr() { return d; } @@ -448,15 +444,13 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options) -inline QByteArray::QByteArray() noexcept { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } -inline QByteArray::~QByteArray() { if (!d.d->deref()) Data::deallocate(d.d); } -inline int QByteArray::size() const -{ return int(d.size); } +inline QByteArray::QByteArray() noexcept {} +inline QByteArray::~QByteArray() {} inline char QByteArray::at(int i) const -{ Q_ASSERT(uint(i) < uint(size())); return d.b[i]; } +{ Q_ASSERT(uint(i) < uint(size())); return d.data()[i]; } inline char QByteArray::operator[](int i) const -{ Q_ASSERT(uint(i) < uint(size())); return d.b[i]; } +{ Q_ASSERT(uint(i) < uint(size())); return d.data()[i]; } inline bool QByteArray::isEmpty() const { return size() == 0; } @@ -467,38 +461,38 @@ inline QByteArray::operator const void *() const { return data(); } #endif inline char *QByteArray::data() -{ detach(); return d.b; } +{ detach(); return d.data(); } inline const char *QByteArray::data() const -{ return d.b; } +{ return d.data(); } inline const char *QByteArray::constData() const -{ return d.b; } +{ return d.data(); } inline void QByteArray::detach() -{ if (d.d->needsDetach()) reallocData(uint(size()) + 1u, d.d->detachFlags()); } +{ if (d->needsDetach()) reallocData(uint(size()) + 1u, d->detachFlags()); } inline bool QByteArray::isDetached() const -{ return !d.d->isShared(); } +{ return !d->isShared(); } inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) -{ d.d->ref(); } +{} inline int QByteArray::capacity() const -{ int realCapacity = d.d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } +{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline void QByteArray::reserve(int asize) { - if (d.d->needsDetach() || asize > capacity()) { - reallocData(qMax(uint(size()), uint(asize)) + 1u, d.d->detachFlags() | Data::CapacityReserved); + if (d->needsDetach() || asize > capacity()) { + reallocData(qMax(uint(size()), uint(asize)) + 1u, d->detachFlags() | Data::CapacityReserved); } else { - d.d->flags |= Data::CapacityReserved; + d->flags() |= Data::CapacityReserved; } } inline void QByteArray::squeeze() { - if ((d.d->flags & Data::CapacityReserved) == 0) + if ((d->flags() & Data::CapacityReserved) == 0) return; - if (d.d->needsDetach() || size() < capacity()) { - reallocData(uint(size()) + 1u, d.d->detachFlags() & ~Data::CapacityReserved); + if (d->needsDetach() || size() < capacity()) { + reallocData(uint(size()) + 1u, d->detachFlags() & ~Data::CapacityReserved); } else { - d.d->flags &= uint(~Data::CapacityReserved); + d->flags() &= uint(~Data::CapacityReserved); } } diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index cb83a31df1..d394b8aebc 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -5148,21 +5148,21 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) // Swap the d pointers. // Kids, avert your eyes. Don't try this at home. - QByteArray::DataPointer ba_d = { - s.d.d, - reinterpret_cast<char *>(s.d.b), - length - }; + + auto *dd = static_cast<QTypedArrayData<char> *>(s.d.d); + char *ddata = reinterpret_cast<char *>(s.d.b); + + QByteArray::DataPointer ba_d = { dd, ddata, length }; // multiply the allocated capacity by sizeof(ushort) - ba_d.d->alloc *= sizeof(ushort); + dd->alloc *= sizeof(ushort); // reset ourselves to QString() s.d = QString().d; // do the in-place conversion - qt_to_latin1(reinterpret_cast<uchar *>(ba_d.b), data, length); - ba_d.b[length] = '\0'; + qt_to_latin1(reinterpret_cast<uchar *>(ddata), data, length); + ddata[length] = '\0'; return QByteArray(ba_d); } diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 9c3848fa7a..4c9324255f 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -185,6 +185,7 @@ static QArrayData *allocateData(size_t allocSize, uint options) if (header) { header->ref_.storeRelaxed(1); header->flags = options; + header->alloc = 0; } return header; } diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 1f81689af3..1d13344991 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -198,6 +198,13 @@ public: typename Data::ArrayOptions detachFlags() const noexcept { return d->detachFlags(); } typename Data::ArrayOptions cloneFlags() const noexcept { return d->cloneFlags(); } + void reallocate(uint alloc, typename Data::ArrayOptions options) + { + auto pair = Data::reallocateUnaligned(d, ptr, alloc, options); + d = pair.first; + ptr = pair.second; + } + private: Q_REQUIRED_RESULT QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const { -- cgit v1.2.3 From f8d2975b6a8b36bf8dd304c99783947a72081b79 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Thu, 14 Nov 2019 11:40:46 +0100 Subject: Use QString::DataPointer instead of QStringPrivate Preparations to move QString over to use QArrayDataPointer instead of it's own private struct. Change-Id: I7796a595393394083f6a85863e3c710ebbdea149 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/serialization/qbinaryjsonvalue.cpp | 2 +- src/corelib/serialization/qbinaryjsonvalue_p.h | 2 +- src/corelib/text/qstring.cpp | 12 ++++++------ src/corelib/text/qstring.h | 13 +++++++------ 4 files changed, 15 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qbinaryjsonvalue.cpp b/src/corelib/serialization/qbinaryjsonvalue.cpp index 92a8fd7ec5..b24bd0fc89 100644 --- a/src/corelib/serialization/qbinaryjsonvalue.cpp +++ b/src/corelib/serialization/qbinaryjsonvalue.cpp @@ -82,7 +82,7 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, QBinaryJsonValue::QBinaryJsonValue(QString string) : d(nullptr), t(QJsonValue::String) { - stringData = *(QStringPrivate *)(&string); + stringData = string.data_ptr(); stringData.d->ref(); } diff --git a/src/corelib/serialization/qbinaryjsonvalue_p.h b/src/corelib/serialization/qbinaryjsonvalue_p.h index f2ca1a8094..4b39b05316 100644 --- a/src/corelib/serialization/qbinaryjsonvalue_p.h +++ b/src/corelib/serialization/qbinaryjsonvalue_p.h @@ -121,7 +121,7 @@ private: quint64 ui; bool b; double dbl; - QStringPrivate stringData; + QString::DataPointer stringData; const QBinaryJsonPrivate::Base *base; }; QBinaryJsonPrivate::MutableData *d = nullptr; // needed for Objects and Arrays diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index d394b8aebc..0f313e21ed 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -4895,7 +4895,7 @@ QString QString::mid(int position, int n) const case QContainerImplHelper::Empty: { QPair<Data *, ushort *> pair = Data::allocate(0); - QStringPrivate empty = { pair.first, pair.second, 0 }; + DataPointer empty = { pair.first, pair.second, 0 }; return QString(empty); } case QContainerImplHelper::Full: @@ -5345,9 +5345,9 @@ QVector<uint> QtPrivate::convertToUcs4(QStringView string) return qt_convert_to_ucs4(string); } -QStringPrivate QString::fromLatin1_helper(const char *str, int size) +QString::DataPointer QString::fromLatin1_helper(const char *str, int size) { - QStringPrivate d; + DataPointer d; if (!str) { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); @@ -5373,7 +5373,7 @@ QStringPrivate QString::fromLatin1_helper(const char *str, int size) return d; } -QStringPrivate QString::fromAscii_helper(const char *str, int size) +QString::DataPointer QString::fromAscii_helper(const char *str, int size) { QString s = fromUtf8(str, size); s.d.d->ref(); @@ -5423,7 +5423,7 @@ QString QString::fromLocal8Bit_helper(const char *str, int size) return QString(); if (size == 0 || (!*str && size < 0)) { QPair<Data *, ushort *> pair = Data::allocate(0); - QStringPrivate empty = { pair.first, pair.second, 0 }; + QString::DataPointer empty = { pair.first, pair.second, 0 }; return QString(empty); } #if QT_CONFIG(textcodec) @@ -9098,7 +9098,7 @@ bool QString::isRightToLeft() const */ QString QString::fromRawData(const QChar *unicode, int size) { - QStringPrivate x; + QString::DataPointer x; x.size = size; if (!unicode) { x.d = Data::sharedNull(); diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 3048c7a8cc..27dc99b2e5 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -247,6 +247,8 @@ class Q_CORE_EXPORT QString { typedef QTypedArrayData<ushort> Data; public: + typedef QStringPrivate DataPointer; + inline QString() noexcept; explicit QString(const QChar *unicode, int size = -1); QString(QChar c); @@ -916,7 +918,7 @@ public: bool isRightToLeft() const; QString(int size, Qt::Initialization); - explicit QString(QStringPrivate dd) : d(dd) {} + explicit QString(DataPointer dd) : d(dd) {} private: #if defined(QT_NO_CAST_FROM_ASCII) @@ -928,7 +930,7 @@ private: QString &operator=(const QByteArray &a); #endif - QStringPrivate d; + DataPointer d; friend inline bool operator==(QChar, const QString &) noexcept; friend inline bool operator< (QChar, const QString &) noexcept; @@ -966,8 +968,8 @@ private: static QString trimmed_helper(QString &str); static QString simplified_helper(const QString &str); static QString simplified_helper(QString &str); - static QStringPrivate fromLatin1_helper(const char *str, int size = -1); - static QStringPrivate fromAscii_helper(const char *str, int size = -1); + static DataPointer fromLatin1_helper(const char *str, int size = -1); + static DataPointer fromAscii_helper(const char *str, int size = -1); static QString fromUtf8_helper(const char *str, int size); static QString fromLocal8Bit_helper(const char *, int size); static QByteArray toLatin1_helper(const QString &); @@ -1002,8 +1004,7 @@ private: } public: - typedef QStringPrivate DataPtr; - inline DataPtr &data_ptr() { return d; } + inline DataPointer &data_ptr() { return d; } }; // -- cgit v1.2.3 From 10f39c908db2e3df933de8fbc553204e9bee65d7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sat, 7 Dec 2019 20:34:12 +0100 Subject: PSQL: set correct empty QVariant in QPSQLResult::record() Since the QSqlField used to retrieve the data is reused in the loop, the default empty value of the QSqlField is not set for all except the first field since it was implicitly set by QSqlField::setType() only when the value is invalid. Therefore we have to call QSqlField::setValue() directly. Change-Id: I1d3abe4e3c46f6378f9ff25529a79bbe33bb7b74 Reviewed-by: Robert Szefner <robertsz27@interia.pl> Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 760685f64b..78ede6a0d3 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -838,6 +838,7 @@ QSqlRecord QPSQLResult::record() const } int ptype = PQftype(d->result, i); f.setType(qDecodePSQLType(ptype)); + f.setValue(QVariant(f.type())); // only set in setType() when it's invalid before int len = PQfsize(d->result, i); int precision = PQfmod(d->result, i); -- cgit v1.2.3 From 4d391514b075c65b33f55b2d1900f66e9bce985f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Fri, 6 Dec 2019 15:59:59 +0100 Subject: Fix crash on debug output of null QColorSpace Change-Id: I7d1d20d7dc2c5ac10dbe8d0a0b4111e8198bfabf Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/painting/qcolorspace.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 937bb505c9..9631fdb416 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -784,10 +784,12 @@ QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace) QDebugStateSaver saver(dbg); dbg.nospace(); dbg << "QColorSpace("; - if (colorSpace.d_ptr->namedColorSpace) - dbg << colorSpace.d_ptr->namedColorSpace << ", "; - dbg << colorSpace.primaries() << ", " << colorSpace.transferFunction(); - dbg << ", gamma=" << colorSpace.gamma(); + if (colorSpace.d_ptr) { + if (colorSpace.d_ptr->namedColorSpace) + dbg << colorSpace.d_ptr->namedColorSpace << ", "; + dbg << colorSpace.primaries() << ", " << colorSpace.transferFunction(); + dbg << ", gamma=" << colorSpace.gamma(); + } dbg << ')'; return dbg; } -- cgit v1.2.3 From 7be4bbcbc51f198cd1e1b40adaf310a04422ac1e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Mon, 9 Dec 2019 15:05:28 +0100 Subject: rhi: metal: Do not fail pipeline creation upon compiler warnings Change-Id: I39384de56d74cf9f1d345a5d395cc07030c6a2ab Fixes: QTBUG-80629 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/rhi/qrhimetal.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 131b2da802..3ecc56d147 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -3149,7 +3149,10 @@ id<MTLLibrary> QRhiMetalData::createMetalLib(const QShader &shader, QShader::Var [opts release]; // src is autoreleased - if (err) { + // if lib is null and err is non-null, we had errors (fail) + // if lib is non-null and err is non-null, we had warnings (success) + // if lib is non-null and err is null, there were no errors or warnings (success) + if (!lib) { const QString msg = QString::fromNSString(err.localizedDescription); *error = msg; return nil; -- cgit v1.2.3 From e0a43e348c7af9e8bc5519e7e8a4b7502ad89f3f Mon Sep 17 00:00:00 2001 From: James McDonnell <jmcdonnell@blackberry.com> Date: Thu, 21 Nov 2019 11:09:24 -0500 Subject: Register the screen pulse event Future versions of QNX will, by default, require the use of registered events. Currently, event registration is supported but optional. Change-Id: Ie45484d5ca9fa832a28ccf08cb1764cf24262dcc Reviewed-by: Dan Cape <dcape@qnx.com> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io> --- .../platforms/qnx/qqnxscreeneventthread.cpp | 24 +++++++++++++++++++--- src/plugins/platforms/qnx/qqnxscreeneventthread.h | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp index 1b5f3b4954..491c314488 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp @@ -60,6 +60,18 @@ static const int c_screenCode = _PULSE_CODE_MINAVAIL + 0; static const int c_armCode = _PULSE_CODE_MINAVAIL + 1; static const int c_quitCode = _PULSE_CODE_MINAVAIL + 2; +#if !defined(screen_register_event) +int screen_register_event(screen_context_t, struct sigevent *event) +{ + return MsgRegisterEvent(event, -1); +} + +int screen_unregister_event(struct sigevent *event) +{ + return MsgUnregisterEvent(event); +} +#endif + QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context) : QThread() , m_screenContext(context) @@ -75,10 +87,14 @@ QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context) qFatal("QQnxScreenEventThread: Can't continue without a channel connection"); } - struct sigevent screenEvent; - SIGEV_PULSE_INIT(&screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0); + SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0); + if (screen_register_event(m_screenContext, &m_screenEvent) == -1) { + ConnectDetach(m_connectionId); + ChannelDestroy(m_channelId); + qFatal("QQnxScreenEventThread: Can't continue without a registered event"); + } - screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &screenEvent); + screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &m_screenEvent); } QQnxScreenEventThread::~QQnxScreenEventThread() @@ -86,6 +102,8 @@ QQnxScreenEventThread::~QQnxScreenEventThread() // block until thread terminates shutdown(); + screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, nullptr); + screen_unregister_event(&m_screenEvent); ConnectDetach(m_connectionId); ChannelDestroy(m_channelId); } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.h b/src/plugins/platforms/qnx/qqnxscreeneventthread.h index 3c8d197545..e5b762369c 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventthread.h +++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.h @@ -45,6 +45,7 @@ #include <QtCore/QMutex> #include <screen/screen.h> +#include <sys/siginfo.h> QT_BEGIN_NAMESPACE @@ -73,6 +74,7 @@ private: int m_channelId; int m_connectionId; + struct sigevent m_screenEvent; screen_context_t m_screenContext; bool m_emitNeededOnNextScreenPulse = true; int m_screenPulsesSinceLastArmPulse = 0; -- cgit v1.2.3 From 009abcd7b66738bece6cf354776dfb2ef401636b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 8 Nov 2019 11:03:14 +0100 Subject: QWidget: React to platform surface being created or destroyed The platform window may create or destroy its surface from other entry points than the QWidget API, in which case QWidget needs to sync up its own state to match. In particular WA_WState_Created and the winId needs to be recomputed. Fixes: QTBUG-69289 Fixes: QTBUG-77350 Change-Id: I769e58ead3c2efcf8c451c363108848feade9388 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/widgets/kernel/qwidget.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 5a0ea58cf8..dcc694efe4 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8624,6 +8624,23 @@ bool QWidget::event(QEvent *event) } } switch (event->type()) { + case QEvent::PlatformSurface: { + // Sync up QWidget's view of whether or not the widget has been created + switch (static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) { + case QPlatformSurfaceEvent::SurfaceCreated: + if (!testAttribute(Qt::WA_WState_Created)) + create(); + break; + case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed: + if (testAttribute(Qt::WA_WState_Created)) { + // Child windows have already been destroyed by QWindow, + // so we skip them here. + destroy(false, false); + } + break; + } + break; + } case QEvent::MouseMove: mouseMoveEvent((QMouseEvent*)event); break; -- cgit v1.2.3 From 8339ce2155752eb8fa0f49f3fe4b24f9643ae463 Mon Sep 17 00:00:00 2001 From: Alexander Volkov <a.volkov@rusbitech.ru> Date: Tue, 3 Dec 2019 17:34:06 +0300 Subject: Avoid crash in menu that was previously shown as submenu Reset sloppyState for the previous submenu, so that if it will be shown as a menu, it will not use an incorrect pointer. Fixes: QTBUG-80528 Change-Id: If2ba8c3a664983ee76eb90d2c9a8096e2bd0a4e6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/widgets/qmenu.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 51b458f03a..57ef7905d9 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -789,6 +789,8 @@ void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAc m_use_reset_action = true; m_time.stop(); m_action_rect = actionRect; + if (m_sub_menu) + QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = nullptr; m_sub_menu = subMenu; QMenuPrivate::get(subMenu)->sloppyState.m_parent = this; m_reset_action = resetAction; -- cgit v1.2.3 From 5272c35073aefee01751647dfb265aa3abf49823 Mon Sep 17 00:00:00 2001 From: Alexander Volkov <a.volkov@rusbitech.ru> Date: Thu, 5 Dec 2019 13:21:09 +0300 Subject: Doc: Clarify ownership of added menu for QMenuBar::addMenu(QMenu *) Change-Id: Iaafba9557ece36607c86d5be4fbb5e4ac2e459d3 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/widgets/widgets/qmenubar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 3d31a3b73a..7a751597bc 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -851,7 +851,8 @@ QMenu *QMenuBar::addMenu(const QIcon &icon, const QString &title) } /*! - Appends \a menu to the menu bar. Returns the menu's menuAction(). + Appends \a menu to the menu bar. Returns the menu's menuAction(). The menu bar + does not take ownership of the menu. \note The returned QAction object can be used to hide the corresponding menu. -- cgit v1.2.3 From baed8534bc1dac36a9d0ef4240fc14398076a192 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Tue, 5 Nov 2019 14:06:46 +0100 Subject: Move the tooltip out of the way of very large mouse cursors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users that have large mouse pointers configured in their settings can not see tooltips, as they are obscured by the pointer. Native applications on Windows and macOS have the same problem, which includes the tooltips for the minimize/maximize/close controls in the window frame of e.g. Explorer. Introduce QPlatformCursor::size that returns a value that is based on the user's settings, or a default value. We can then use that value to move the tooltip out of the way. On Windows, the calculation of the cursor size is based on experimenting with the settings, which are in logical independent pixels. The placement of the tooltip attempts to keep existing behavior, and to not end up with a tooltip that's very far away from the tip of the arrow even for very large mouse cursors. [ChangeLog][QtWidgets][QToolTip] Make sure that the tooltip is not obscured by very large mouse pointers on Windows and macOS. Change-Id: I8e13b7a166bfe8b59cef4765c950f90fefeaef9d Fixes: QTBUG-79627 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/gui/kernel/qplatformcursor.cpp | 8 +++++ src/gui/kernel/qplatformcursor.h | 1 + src/plugins/platforms/cocoa/qcocoacursor.h | 3 ++ src/plugins/platforms/cocoa/qcocoacursor.mm | 25 ++++++++++++++ src/plugins/platforms/windows/qwindowscursor.cpp | 25 ++++++++++++++ src/plugins/platforms/windows/qwindowscursor.h | 2 ++ src/widgets/kernel/qtooltip.cpp | 43 +++++++++++++++--------- 7 files changed, 92 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index 49eff2ad23..aabf28a727 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -131,6 +131,14 @@ void QPlatformCursor::setPos(const QPoint &pos) QWindowSystemInterface::handleMouseEvent(0, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove); } +/*! + Returns the size of the cursor, in native pixels. +*/ +QSize QPlatformCursor::size() const +{ + return QSize(16, 16); +} + // End of display and pointer event handling code // Beginning of built-in cursor graphics // from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h index f36a73c861..f3871d8780 100644 --- a/src/gui/kernel/qplatformcursor.h +++ b/src/gui/kernel/qplatformcursor.h @@ -96,6 +96,7 @@ public: #endif // QT_NO_CURSOR virtual QPoint pos() const; virtual void setPos(const QPoint &pos); + virtual QSize size() const; static Capabilities capabilities() { return m_capabilities; } static void setCapabilities(Capabilities c) { m_capabilities = c; } diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index 58b9ef2151..5b008eff35 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -56,6 +56,9 @@ public: void changeCursor(QCursor *cursor, QWindow *window) override; QPoint pos() const override; void setPos(const QPoint &position) override; + + QSize size() const override; + private: QHash<Qt::CursorShape, NSCursor *> m_cursors; NSCursor *convertCursor(QCursor *cursor); diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index 87a57c78c8..e0d623fc4c 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -85,6 +85,31 @@ void QCocoaCursor::setPos(const QPoint &position) CFRelease(e); } + +QSize QCocoaCursor::size() const +{ + NSCursor *cocoaCursor = NSCursor.currentSystemCursor; + if (!cocoaCursor) + return QPlatformCursor::size(); + NSImage *cursorImage = cocoaCursor.image; + if (!cursorImage) + return QPlatformCursor::size(); + + QSizeF size = QSizeF::fromCGSize(cursorImage.size); + NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; + NSDictionary *accessSettings = [defaults persistentDomainForName:@"com.apple.universalaccess"]; + if (accessSettings == nil) + return size.toSize(); + + float sizeScale = [accessSettings[@"mouseDriverCursorSize"] floatValue]; + if (sizeScale > 0) { + size.rwidth() *= sizeScale; + size.rheight() *= sizeScale; + } + + return size.toSize(); +} + NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) { if (!cursor) diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 17e8cffb76..59457f1720 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -50,6 +50,7 @@ #include <QtGui/qscreen.h> #include <QtGui/private/qguiapplication_p.h> // getPixmapCursor() #include <QtGui/private/qhighdpiscaling_p.h> +#include <QtCore/private/qwinregistry_p.h> #include <QtCore/qdebug.h> #include <QtCore/qscopedpointer.h> @@ -686,6 +687,30 @@ void QWindowsCursor::setPos(const QPoint &pos) SetCursorPos(pos.x() , pos.y()); } +/* + The standard size is 32x32, even though the cursor is actually just + 16 pixels large. If a large cursor is set in the accessibility settings, + then the cursor increases with 8 pixels for each step. +*/ +QSize QWindowsCursor::size() const +{ + const QPair<DWORD,bool> cursorSizeSetting = + QWinRegistryKey(HKEY_CURRENT_USER, LR"(Control Panel\Cursors)") + .dwordValue(L"CursorBaseSize"); + const int baseSize = screenCursorSize(m_screen).width() / 2; + if (!cursorSizeSetting.second) + return QSize(baseSize / 2, baseSize / 2); + + // The registry values are dpi-independent, so we need to scale the result. + int cursorSizeValue = cursorSizeSetting.first * m_screen->logicalDpi().first + / m_screen->logicalBaseDpi().first; + + // map from registry value 32-256 to 0-14, and from there to pixels + cursorSizeValue = (cursorSizeValue - 2 * baseSize) / baseSize; + const int cursorSize = baseSize + cursorSizeValue * (baseSize / 2); + return QSize(cursorSize, cursorSize); +} + QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const { switch (action) { diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index b896f4c7a9..cf3635bd6b 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -113,6 +113,8 @@ public: QPoint pos() const override; void setPos(const QPoint &pos) override; + QSize size() const override; + static HCURSOR createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor = 1); static HCURSOR createPixmapCursor(const PixmapCursor &pc, qreal scaleFactor = 1) { return createPixmapCursor(pc.pixmap, pc.hotSpot, scaleFactor); } static PixmapCursor customCursor(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr); diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 97a279d65d..1ec3612457 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -53,11 +53,14 @@ #endif #include <qtextdocument.h> #include <qdebug.h> +#include <qpa/qplatformscreen.h> +#include <qpa/qplatformcursor.h> #include <private/qstylesheetstyle_p.h> #ifndef QT_NO_TOOLTIP #include <qlabel.h> #include <QtWidgets/private/qlabel_p.h> +#include <QtGui/private/qhighdpiscaling_p.h> #include <qtooltip.h> QT_BEGIN_NAMESPACE @@ -398,24 +401,34 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) } #endif //QT_NO_STYLE_STYLESHEET - - QRect screen = QDesktopWidgetPrivate::screenGeometry(getTipScreen(pos, w)); - QPoint p = pos; - p += QPoint(2, 16); - - if (p.x() + this->width() > screen.x() + screen.width()) + int screenNumber = getTipScreen(pos, w); + QScreen *screen = QGuiApplication::screens().at(screenNumber); + if (screen) { + const QPlatformScreen *platformScreen = screen->handle(); + const QSize cursorSize = QHighDpi::fromNativePixels(platformScreen->cursor()->size(), + platformScreen); + QPoint offset(2, cursorSize.height()); + // assuming an arrow shape, we can just move to the side for very large cursors + if (cursorSize.height() > 2 * this->height()) + offset = QPoint(cursorSize.width() / 2, 0); + + p += offset; + + QRect screenRect = screen->geometry(); + if (p.x() + this->width() > screenRect.x() + screenRect.width()) p.rx() -= 4 + this->width(); - if (p.y() + this->height() > screen.y() + screen.height()) + if (p.y() + this->height() > screenRect.y() + screenRect.height()) p.ry() -= 24 + this->height(); - if (p.y() < screen.y()) - p.setY(screen.y()); - if (p.x() + this->width() > screen.x() + screen.width()) - p.setX(screen.x() + screen.width() - this->width()); - if (p.x() < screen.x()) - p.setX(screen.x()); - if (p.y() + this->height() > screen.y() + screen.height()) - p.setY(screen.y() + screen.height() - this->height()); + if (p.y() < screenRect.y()) + p.setY(screenRect.y()); + if (p.x() + this->width() > screenRect.x() + screenRect.width()) + p.setX(screenRect.x() + screenRect.width() - this->width()); + if (p.x() < screenRect.x()) + p.setX(screenRect.x()); + if (p.y() + this->height() > screenRect.y() + screenRect.height()) + p.setY(screenRect.y() + screenRect.height() - this->height()); + } this->move(p); } -- cgit v1.2.3 From 9608e996a237d9a69a3e29f533e4f430cf9016c1 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 6 Dec 2019 21:03:54 +0100 Subject: QAIV::sizeHintForIndex: return correct size when no delegate is set QAIV::sizeHintForIndex checks if a delegate is set for this view but does not check if there are row/column delegates which may be appropriate for this task. Fix it by retrieving the correct delegate directly with delegateForIndex(). Change-Id: I264359b12e1983aab3a917db7dbcab11253a448f Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/itemviews/qabstractitemview.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 67c01adea7..bb219393f3 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3074,9 +3074,10 @@ void QAbstractItemView::keyboardSearch(const QString &search) QSize QAbstractItemView::sizeHintForIndex(const QModelIndex &index) const { Q_D(const QAbstractItemView); - if (!d->isIndexValid(index) || !d->itemDelegate) + if (!d->isIndexValid(index)) return QSize(); - return d->delegateForIndex(index)->sizeHint(d->viewOptionsV1(), index); + const auto delegate = d->delegateForIndex(index); + return delegate ? delegate->sizeHint(d->viewOptionsV1(), index) : QSize(); } /*! -- cgit v1.2.3 From 46d21a3b34c2d252db14419a45957991acea949d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 27 Nov 2019 19:51:11 +0100 Subject: QPushButton: fix icon + text layouting in RTL mode The fusion style did not properly handle the text layouting for a QPushButton in RTL mode. Also the menu indicator was not adjusted in this case. Fix it by calling the base class implementation as QCommonStyle does it mostly right. Since Fusion does not handle State_On or State_Sunken but QCommonStyle does, explicitly mask them out. Fixes: QTBUG-80083 Change-Id: Ide7bf997b4f4a5b61fcb8ea4a1a152122daef1e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/styles/qcommonstyle.cpp | 22 +++++++------- src/widgets/styles/qfusionstyle.cpp | 57 +++---------------------------------- 2 files changed, 15 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 271b43fe89..09d65f0346 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1363,7 +1363,6 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (!button->icon.isNull()) { //Center both icon and text - QRect iconRect; QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && button->state & State_HasFocus) mode = QIcon::Active; @@ -1372,28 +1371,29 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, state = QIcon::On; QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state); - int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio(); int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio(); int labelWidth = pixmapWidth; int labelHeight = pixmapHeight; int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() - int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); - if (!button->text.isEmpty()) + if (!button->text.isEmpty()) { + int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); labelWidth += (textWidth + iconSpacing); + } - iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, - textRect.y() + (textRect.height() - labelHeight) / 2, - pixmapWidth, pixmapHeight); + QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, + textRect.y() + (textRect.height() - labelHeight) / 2, + pixmapWidth, pixmapHeight); iconRect = visualRect(button->direction, textRect, iconRect); - tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead - - if (button->direction == Qt::RightToLeft) + if (button->direction == Qt::RightToLeft) { + tf |= Qt::AlignRight; textRect.setRight(iconRect.left() - iconSpacing); - else + } else { + tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); + } if (button->state & (State_On | State_Sunken)) iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index b58dc1660a..3bffd7873f 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1770,59 +1770,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio break; case CE_PushButtonLabel: if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) { - QRect ir = button->rect; - uint tf = Qt::AlignVCenter; - if (styleHint(SH_UnderlineShortcut, button, widget)) - tf |= Qt::TextShowMnemonic; - else - tf |= Qt::TextHideMnemonic; - - if (!button->icon.isNull()) { - //Center both icon and text - QPoint point; - - QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal - : QIcon::Disabled; - if (mode == QIcon::Normal && button->state & State_HasFocus) - mode = QIcon::Active; - QIcon::State state = QIcon::Off; - if (button->state & State_On) - state = QIcon::On; - - QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state); - int w = pixmap.width() / pixmap.devicePixelRatio(); - int h = pixmap.height() / pixmap.devicePixelRatio(); - - if (!button->text.isEmpty()) - w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2; - - point = QPoint(ir.x() + ir.width() / 2 - w / 2, - ir.y() + ir.height() / 2 - h / 2); - - w = pixmap.width() / pixmap.devicePixelRatio(); - - if (button->direction == Qt::RightToLeft) - point.rx() += w; - - painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap); - - if (button->direction == Qt::RightToLeft) - ir.translate(-point.x() - 2, 0); - else - ir.translate(point.x() + w, 0); - - // left-align text if there is - if (!button->text.isEmpty()) - tf |= Qt::AlignLeft; - - } else { - tf |= Qt::AlignHCenter; - } - - if (button->features & QStyleOptionButton::HasMenu) - ir = ir.adjusted(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget), 0); - proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled), - button->text, QPalette::ButtonText); + QStyleOptionButton b(*button); + // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style + b.state &= ~(State_On | State_Sunken); + QCommonStyle::drawControl(element, &b, painter, widget); } break; case CE_MenuBarEmptyArea: -- cgit v1.2.3 From c27123d7435e9451f3e44d9e823734e605279d0a Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 4 Dec 2019 20:23:37 +0100 Subject: QAbstractItemView: add a note about ToolTipRole in dataChanged() Qt::ToolTipRole is not honored by dataChanged() which may be a little bit surprising. Therefore add a small note about this behavior. Fixes: QTBUG-78726 Change-Id: Ic4361f55e55ab59d5bae2fdb98907a62055604c5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/widgets/itemviews/qabstractitemview.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 7ede46dbec..b07faf8be4 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -3318,6 +3318,8 @@ void QAbstractItemView::update(const QModelIndex &index) The \a roles which have been changed can either be an empty container (meaning everything has changed), or a non-empty container with the subset of roles which have changed. + + \note: Qt::ToolTipRole is not honored by dataChanged() in the views provided by Qt. */ void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) { -- cgit v1.2.3 From 8310981b806979642b025358055d394ee9045003 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 3 Dec 2019 11:40:59 +0100 Subject: Prefer QDate::startOfDay() over QDateTime(const QDate &) The latter can be invalid if midnight is skipped by a spring-forward. Change-Id: Ibf98d165557229f19622774ebf9a27bb0911c7a7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 4a1724bd39..ffb4892c99 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -5214,7 +5214,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) if (!date.isValid()) return QDateTime(); if (size == 10) - return QDateTime(date); + return date.startOfDay(); Qt::TimeSpec spec = Qt::LocalTime; QStringRef isoString(&string); -- cgit v1.2.3 From f16bd401896479ed984eb087758c19e9e551139f Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Thu, 5 Dec 2019 15:03:02 +0100 Subject: Convert some uses of QStringRef to QStringView There remain QStringRef uses where QString::splitRef() is used. Requires converting some .count()s to .size()s, as QStringView lacks count(); and some .toInt()s need to be handled by QLocale::c(). Change-Id: If9a49e063d217671ea9335a82e4bf977b7b48be0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetime.cpp | 51 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index ffb4892c99..0d8aaabd2e 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -127,7 +127,7 @@ static const char qt_shortMonthNames[][4] = { "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -static int qt_monthNumberFromShortName(QStringRef shortName) +static int qt_monthNumberFromShortName(QStringView shortName) { for (unsigned int i = 0; i < sizeof(qt_shortMonthNames) / sizeof(qt_shortMonthNames[0]); ++i) { if (shortName == QLatin1String(qt_shortMonthNames[i], 3)) @@ -136,9 +136,9 @@ static int qt_monthNumberFromShortName(QStringRef shortName) return -1; } static int qt_monthNumberFromShortName(const QString &shortName) -{ return qt_monthNumberFromShortName(QStringRef(&shortName)); } +{ return qt_monthNumberFromShortName(QStringView(shortName)); } -static int fromShortMonthName(const QStringRef &monthName, int year) +static int fromShortMonthName(QStringView monthName, int year) { // Assume that English monthnames are the default int month = qt_monthNumberFromShortName(monthName); @@ -207,7 +207,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset) #if QT_CONFIG(datestring) // Parse offset in [+-]HH[[:]mm] format -static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcept +static int fromOffsetString(QStringView offsetString, bool *valid) noexcept { *valid = false; @@ -228,22 +228,23 @@ static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcep return 0; // Split the hour and minute parts - const QStringRef time = offsetString.mid(1); - int hhLen = time.indexOf(QLatin1Char(':')); - int mmIndex; + const QStringView time = offsetString.mid(1); + qsizetype hhLen = time.indexOf(QLatin1Char(':')); + qsizetype mmIndex; if (hhLen == -1) mmIndex = hhLen = 2; // [+-]HHmm or [+-]HH format else mmIndex = hhLen + 1; - const QStringRef hhRef = time.left(hhLen); + const QLocale C = QLocale::c(); + const QStringView hhRef = time.left(qMin(hhLen, time.size())); bool ok = false; - const int hour = hhRef.toInt(&ok); + const int hour = C.toInt(hhRef, &ok); if (!ok) return 0; - const QStringRef mmRef = time.mid(mmIndex); - const int minute = mmRef.isEmpty() ? 0 : mmRef.toInt(&ok); + const QStringView mmRef = time.mid(qMin(mmIndex, time.size())); + const int minute = mmRef.isEmpty() ? 0 : C.toInt(mmRef, &ok); if (!ok || minute < 0 || minute > 59) return 0; @@ -2324,7 +2325,7 @@ int QTime::msecsTo(const QTime &t) const #if QT_CONFIG(datestring) -static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, bool *isMidnight24) +static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool *isMidnight24) { if (isMidnight24) *isMidnight24 = false; @@ -2333,11 +2334,12 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, if (size < 5) return QTime(); + const QLocale C(QLocale::c()); bool ok = false; - int hour = string.mid(0, 2).toInt(&ok); + int hour = C.toInt(string.mid(0, 2), &ok); if (!ok) return QTime(); - const int minute = string.mid(3, 2).toInt(&ok); + const int minute = C.toInt(string.mid(3, 2), &ok); if (!ok) return QTime(); int second = 0; @@ -2358,11 +2360,11 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, // seconds is 4. E.g. 12:34,99999 will expand to 12:34:59.9994. The milliseconds // will then be rounded up AND clamped to 999. - const QStringRef minuteFractionStr = string.mid(6, 5); - const long minuteFractionInt = minuteFractionStr.toLong(&ok); + const QStringView minuteFractionStr = string.mid(6, qMin(qsizetype(5), string.size() - 6)); + const long minuteFractionInt = C.toLong(minuteFractionStr, &ok); if (!ok) return QTime(); - const float minuteFraction = double(minuteFractionInt) / (std::pow(double(10), minuteFractionStr.count())); + const float minuteFraction = double(minuteFractionInt) / (std::pow(double(10), minuteFractionStr.size())); const float secondWithMs = minuteFraction * 60; const float secondNoMs = std::floor(secondWithMs); @@ -2371,20 +2373,20 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, msec = qMin(qRound(secondFraction * 1000.0), 999); } else { // HH:mm:ss or HH:mm:ss.zzz - second = string.mid(6, 2).toInt(&ok); + second = C.toInt(string.mid(6, qMin(qsizetype(2), string.size() - 6)), &ok); if (!ok) return QTime(); if (size > 8 && (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.'))) { - QStringRef msecStr(string.mid(9, 4)); + QStringView msecStr(string.mid(9, qMin(qsizetype(4), string.size() - 9))); // toInt() ignores leading spaces, so catch them before calling it if (!msecStr.isEmpty() && !msecStr.at(0).isDigit()) return QTime(); // We do, however, want to ignore *trailing* spaces. msecStr = msecStr.trimmed(); - int msecInt = msecStr.isEmpty() ? 0 : msecStr.toInt(&ok); + int msecInt = msecStr.isEmpty() ? 0 : C.toInt(msecStr, &ok); if (!ok) return QTime(); - const double secondFraction(msecInt / (std::pow(double(10), msecStr.count()))); + const double secondFraction(msecInt / (std::pow(double(10), msecStr.size()))); msec = qMin(qRound(secondFraction * 1000.0), 999); } } @@ -2433,7 +2435,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format) case Qt::ISODateWithMs: case Qt::TextDate: default: - return fromIsoTimeString(QStringRef(&string), format, nullptr); + return fromIsoTimeString(QStringView(string), format, nullptr); } } @@ -5217,8 +5219,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) return date.startOfDay(); Qt::TimeSpec spec = Qt::LocalTime; - QStringRef isoString(&string); - isoString = isoString.mid(10); // trim "yyyy-MM-dd" + QStringView isoString = QStringView(string).mid(10); // trim "yyyy-MM-dd" // Must be left with T (or space) and at least one digit for the hour: if (isoString.size() < 2 @@ -5364,7 +5365,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format) if (parts.count() == 5) return QDateTime(date, time, Qt::LocalTime); - QStringRef tz = parts.at(5); + QStringView tz = parts.at(5); if (!tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive)) return QDateTime(); tz = tz.mid(3); -- cgit v1.2.3 From 03dc30acca4976c716c723ff46d503d35459b2a0 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland <eirik.aavitsland@qt.io> Date: Tue, 3 Dec 2019 13:39:08 +0100 Subject: Fix QPushButton style sheet style for overlay (content) image Unlike comparable widgets like QLabel or QFrame, QPushButton would not render a content image specified in the stylesheet, unless a border style was also specified. Fix by explicitly rendering the content image, if set, in the native-border codepath also. Although the doc warns about the QPushButton border style having to be set in order for the background styling to take effect (since the native border painting otherwise hides it), the previous behavior does seem unexpected. Fixes: QTBUG-72029 Change-Id: I8b979b010515dab4dcf2f00344a187c87eeec096 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/styles/qstylesheetstyle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index aab4b74c4b..98c85684ae 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3493,6 +3493,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q } else { QWindowsStyle::drawControl(ce, &btnOpt, p, w); } + rule.drawImage(p, rule.contentsRect(opt->rect)); if (!customMenu) return; } else { -- cgit v1.2.3 From c3bd5ffdc8a3b459f18ba6e35fca93e29f3b0ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Sun, 8 Dec 2019 23:47:10 +0100 Subject: Don't wrap feature detection macros with QT_HAS_FOO() variants Using wrappers for these macros is problematic when for example passing the -frewrite-includes flag to preprocess sources before shipping off to distcc or Icecream. It will also start producing warnings when compilers implement http://eel.is/c++draft/cpp.cond#7.sentence-2. See for example https://reviews.llvm.org/D49091 Both https://clang.llvm.org/docs/LanguageExtensions.html and the SD-6 document at https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations recommend defining '__has_foo(x) 0' as a fallback for compilers without the macros, so that's what we go for. Change-Id: I0298cd3b4a6ff6618821e34642a5ddd6728be767 Reviewed-by: Alex Richardson <arichardson.kde@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qcompilerdetection.h | 77 +++++++++++++++---------------- src/corelib/global/qconfig-bootstrapped.h | 4 +- src/corelib/global/qendian.h | 4 +- src/corelib/global/qglobal.cpp | 4 +- src/corelib/global/qglobal.h | 2 +- src/corelib/global/qglobal_p.h | 4 +- src/corelib/global/qlogging.cpp | 8 ++-- src/corelib/global/qnumeric_p.h | 2 +- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- src/corelib/io/qprocess.cpp | 2 +- src/corelib/io/qstandardpaths.cpp | 2 +- src/corelib/io/qstorageinfo_unix.cpp | 2 +- src/corelib/kernel/qdeadlinetimer.h | 4 +- src/corelib/kernel/qobject.h | 4 +- src/corelib/kernel/qtimer.h | 6 +-- src/corelib/kernel/qvariant.h | 6 +-- src/corelib/serialization/qcborarray.h | 2 +- src/corelib/serialization/qcbormap.h | 2 +- src/corelib/serialization/qcborvalue.h | 6 +-- src/corelib/text/qbytearray.cpp | 2 +- src/corelib/text/qbytearray.h | 2 +- src/corelib/text/qstring.h | 2 +- src/corelib/thread/qfutex_p.h | 4 +- src/corelib/thread/qmutex.h | 10 ++-- src/corelib/tools/qalgorithms.h | 4 +- src/corelib/tools/qscopeguard.h | 4 +- 26 files changed, 84 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e47f284a42..60dc7ce688 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -505,6 +505,39 @@ # error "Qt has not been tested with this compiler - see http://www.qt-project.org/" #endif +/* + * SG10's SD-6 feature detection and some useful extensions from Clang and GCC + * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations + * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros + * Not using wrapper macros, per http://eel.is/c++draft/cpp.cond#7.sentence-2 + */ +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif +#ifndef __has_include +# define __has_include(x) 0 +#endif +#ifndef __has_include_next +# define __has_include_next(x) 0 +#endif + +// Kept around until all submodules have transitioned +#define QT_HAS_BUILTIN(x) __has_builtin(x) +#define QT_HAS_FEATURE(x) __has_feature(x) +#define QT_HAS_ATTRIBUTE(x) __has_attribute(x) +#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#define QT_HAS_INCLUDE(x) __has_include(x) +#define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x) + /* * C++11 support * @@ -1031,37 +1064,6 @@ # endif #endif -/* - * SG10's SD-6 feature detection and some useful extensions from Clang and GCC - * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations - * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros - */ -#ifdef __has_builtin -# define QT_HAS_BUILTIN(x) __has_builtin(x) -#else -# define QT_HAS_BUILTIN(x) 0 -#endif -#ifdef __has_attribute -# define QT_HAS_ATTRIBUTE(x) __has_attribute(x) -#else -# define QT_HAS_ATTRIBUTE(x) 0 -#endif -#ifdef __has_cpp_attribute -# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -#else -# define QT_HAS_CPP_ATTRIBUTE(x) 0 -#endif -#ifdef __has_include -# define QT_HAS_INCLUDE(x) __has_include(x) -#else -# define QT_HAS_INCLUDE(x) 0 -#endif -#ifdef __has_include_next -# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x) -#else -# define QT_HAS_INCLUDE_NEXT(x) 0 -#endif - /* * C++11 keywords and expressions */ @@ -1138,7 +1140,7 @@ # define Q_DECL_ALIGN(n) alignas(n) #endif -#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && !defined(Q_CC_CLANG) // P0188R1 +#if __has_cpp_attribute(nodiscard) && !defined(Q_CC_CLANG) // P0188R1 // Can't use [[nodiscard]] with Clang, see https://bugs.llvm.org/show_bug.cgi?id=33518 # undef Q_REQUIRED_RESULT # define Q_REQUIRED_RESULT [[nodiscard]] @@ -1240,11 +1242,6 @@ #ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR # define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x) #endif -#ifdef __has_feature -# define QT_HAS_FEATURE(x) __has_feature(x) -#else -# define QT_HAS_FEATURE(x) 0 -#endif /* * Warning/diagnostic handling @@ -1335,11 +1332,11 @@ } while (false) #if defined(__cplusplus) -#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +#if __has_cpp_attribute(clang::fallthrough) # define Q_FALLTHROUGH() [[clang::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) +#elif __has_cpp_attribute(gnu::fallthrough) # define Q_FALLTHROUGH() [[gnu::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) +#elif __has_cpp_attribute(fallthrough) # define Q_FALLTHROUGH() [[fallthrough]] #endif #endif diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index e6ad80525a..c6f071bc3f 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -75,13 +75,13 @@ # define QT_FEATURE_alloca_malloc_h -1 #endif #define QT_CRYPTOGRAPHICHASH_ONLY_SHA1 -#define QT_FEATURE_cxx11_random (QT_HAS_INCLUDE(<random>) ? 1 : -1) +#define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1) #define QT_NO_DATASTREAM #define QT_FEATURE_datestring 1 #define QT_FEATURE_datetimeparser -1 #define QT_FEATURE_easingcurve -1 #define QT_FEATURE_etw -1 -#define QT_FEATURE_getauxval (QT_HAS_INCLUDE(<sys/auxv.h>) ? 1 : -1) +#define QT_FEATURE_getauxval (__has_include(<sys/auxv.h>) ? 1 : -1) #define QT_FEATURE_getentropy -1 #define QT_NO_GEOM_VARIANT #define QT_FEATURE_hijricalendar -1 diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 5cd9d3160b..257efbbdbe 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -66,7 +66,7 @@ template <typename T> Q_ALWAYS_INLINE void qToUnaligned(const T src, void *dest) // Using sizeof(T) inside memcpy function produces internal compiler error with // MSVC2008/ARM in tst_endian -> use extra indirection to resolve size of T. const size_t size = sizeof(T); -#if QT_HAS_BUILTIN(__builtin_memcpy) +#if __has_builtin(__builtin_memcpy) __builtin_memcpy #else memcpy @@ -78,7 +78,7 @@ template <typename T> Q_ALWAYS_INLINE T qFromUnaligned(const void *src) { T dest; const size_t size = sizeof(T); -#if QT_HAS_BUILTIN(__builtin_memcpy) +#if __has_builtin(__builtin_memcpy) __builtin_memcpy #else memcpy diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4ab5bd2edb..b662233d4e 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -92,7 +92,7 @@ # include <sys/systeminfo.h> #endif -#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>) +#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>) # include <IOKit/IOKitLib.h> # include <private/qcore_mac_p.h> #endif @@ -3041,7 +3041,7 @@ enum { */ QByteArray QSysInfo::machineUniqueId() { -#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>) +#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>) char uuid[UuidStringLen + 1]; io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); QCFString stringRef = (CFStringRef)IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1e26e9453a..e335916eac 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -769,7 +769,7 @@ inline void qt_noop(void) {} #if !defined(QT_NO_EXCEPTIONS) # if !defined(Q_MOC_RUN) -# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_FEATURE(cxx_exceptions)) || \ +# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_feature(cxx_exceptions)) || \ (defined(Q_CC_GNU) && !defined(__EXCEPTIONS)) # define QT_NO_EXCEPTIONS # endif diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h index 58bc8b7bf3..5ab84fa8be 100644 --- a/src/corelib/global/qglobal_p.h +++ b/src/corelib/global/qglobal_p.h @@ -74,7 +74,7 @@ Q_CORE_EXPORT time_t qMkTime(struct tm *when); QT_END_NAMESPACE -#if !QT_HAS_BUILTIN(__builtin_available) +#if !__has_builtin(__builtin_available) #include <initializer_list> #include <QtCore/qoperatingsystemversion.h> #include <QtCore/qversionnumber.h> @@ -142,7 +142,7 @@ QT_END_NAMESPACE QT_BUILTIN_AVAILABLE1, \ QT_BUILTIN_AVAILABLE0, ) #define __builtin_available(...) QT_BUILTIN_AVAILABLE_CHOOSER(__VA_ARGS__)(__VA_ARGS__) -#endif // !QT_HAS_BUILTIN(__builtin_available) +#endif // !__has_builtin(__builtin_available) #endif // defined(__cplusplus) #endif // QGLOBAL_P_H diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 17f2246082..5a7f8242de 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -70,7 +70,7 @@ #if QT_CONFIG(slog2) #include <sys/slog2.h> #endif -#if QT_HAS_INCLUDE(<paths.h>) +#if __has_include(<paths.h>) #include <paths.h> #endif @@ -106,7 +106,7 @@ # if __UCLIBC_HAS_BACKTRACE__ # define QLOGGING_HAVE_BACKTRACE # endif -# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (QT_HAS_INCLUDE(<cxxabi.h>) && QT_HAS_INCLUDE(<execinfo.h>)) +# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include(<cxxabi.h>) && __has_include(<execinfo.h>)) # define QLOGGING_HAVE_BACKTRACE # endif #endif @@ -116,7 +116,7 @@ extern char *__progname; #endif #ifndef QT_BOOTSTRAPPED -#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || QT_HAS_INCLUDE(<sys/syscall.h>)) +#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include(<sys/syscall.h>)) # include <sys/syscall.h> # if defined(Q_OS_ANDROID) && !defined(SYS_gettid) @@ -1276,7 +1276,7 @@ void QMessagePattern::setPattern(const QString &pattern) #if defined(QLOGGING_HAVE_BACKTRACE) && !defined(QT_BOOTSTRAPPED) // make sure the function has "Message" in the name so the function is removed -#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize)) \ +#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || __has_attribute(optimize)) \ && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) // force skipping the frame pointer, to save the backtrace() function some work __attribute__((optimize("omit-frame-pointer"))) diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 86e7997680..fdfcbda6ca 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -249,7 +249,7 @@ QT_WARNING_POP // size_t. Implementations for 8- and 16-bit types will work but may not be as // efficient. Implementations for 64-bit may be missing on 32-bit platforms. -#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflow) +#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || __has_builtin(__builtin_add_overflow) // GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows template <typename T> inline diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index c3abec8989..38cb6a423d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -55,7 +55,7 @@ #include <stdio.h> #include <errno.h> -#if QT_HAS_INCLUDE(<paths.h>) +#if __has_include(<paths.h>) # include <paths.h> #endif #ifndef _PATH_TMP // from <paths.h> diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 35ca2542f7..3a77242d7c 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -100,7 +100,7 @@ QT_END_NAMESPACE #include <private/qcore_unix_p.h> #endif -#if QT_HAS_INCLUDE(<paths.h>) +#if __has_include(<paths.h>) #include <paths.h> #endif diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index 02adda3d6c..bca454fc7a 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -48,7 +48,7 @@ #include <qcoreapplication.h> #endif -#if QT_HAS_INCLUDE(<paths.h>) +#if __has_include(<paths.h>) #include <paths.h> #endif diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 1e72241e68..37b8a60c37 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -108,7 +108,7 @@ # endif // QT_LARGEFILE_SUPPORT #endif // Q_OS_BSD4 -#if QT_HAS_INCLUDE(<paths.h>) +#if __has_include(<paths.h>) # include <paths.h> #endif #ifndef _PATH_MOUNTED diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h index 9dd92481d2..99e09eb31f 100644 --- a/src/corelib/kernel/qdeadlinetimer.h +++ b/src/corelib/kernel/qdeadlinetimer.h @@ -52,7 +52,7 @@ #include <limits> -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) # include <chrono> #endif @@ -120,7 +120,7 @@ public: QDeadlineTimer &operator-=(qint64 msecs) { *this = *this + (-msecs); return *this; } -#if QT_HAS_INCLUDE(<chrono>) || defined(Q_CLANG_QDOC) +#if __has_include(<chrono>) || defined(Q_CLANG_QDOC) template <class Clock, class Duration> QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline_, Qt::TimerType type_ = Qt::CoarseTimer) : t2(0) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 540b8b32c1..f5d7c22e3a 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -55,7 +55,7 @@ #include <QtCore/qobject_impl.h> -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) # include <chrono> #endif @@ -160,7 +160,7 @@ public: void moveToThread(QThread *thread); int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer); -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) Q_ALWAYS_INLINE int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer) { diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index eb7185c12d..6bbfd741d9 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -47,7 +47,7 @@ #include <QtCore/qbasictimer.h> // conceptual inheritance #include <QtCore/qobject.h> -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) # include <chrono> #endif @@ -177,7 +177,7 @@ Q_SIGNALS: void timeout(QPrivateSignal); public: -#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC) +#if __has_include(<chrono>) || defined(Q_QDOC) void setInterval(std::chrono::milliseconds value) { setInterval(int(value.count())); @@ -223,7 +223,7 @@ private: static void singleShotImpl(int msec, Qt::TimerType timerType, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj); -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) static Qt::TimerType defaultTypeFor(std::chrono::milliseconds interval) { return defaultTypeFor(int(interval.count())); } diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index e7d3d9c835..a4957472ec 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -53,7 +53,7 @@ #include <QtCore/qbytearraylist.h> #endif -#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L +#if __has_include(<variant>) && __cplusplus >= 201703L #include <variant> #elif defined(Q_CLANG_QDOC) namespace std { template<typename...> struct variant; } @@ -370,7 +370,7 @@ class Q_CORE_EXPORT QVariant static inline QVariant fromValue(const T &value) { return QVariant(qMetaTypeId<T>(), &value, QTypeInfo<T>::isPointer); } -#if (QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L) || defined(Q_CLANG_QDOC) +#if (__has_include(<variant>) && __cplusplus >= 201703L) || defined(Q_CLANG_QDOC) template<typename... Types> static inline QVariant fromStdVariant(const std::variant<Types...> &value) { @@ -544,7 +544,7 @@ inline QVariant QVariant::fromValue(const QVariant &value) return value; } -#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L +#if __has_include(<variant>) && __cplusplus >= 201703L template<> inline QVariant QVariant::fromValue(const std::monostate &) { diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h index e06544f245..fe06b8630f 100644 --- a/src/corelib/serialization/qcborarray.h +++ b/src/corelib/serialization/qcborarray.h @@ -214,7 +214,7 @@ public: bool contains(const QCborValue &value) const; int compare(const QCborArray &other) const noexcept Q_DECL_PURE_FUNCTION; -#if 0 && QT_HAS_INCLUDE(<compare>) +#if 0 && __has_include(<compare>) std::strong_ordering operator<=>(const QCborArray &other) const { int c = compare(other); diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h index 4aea901eef..6636ce776a 100644 --- a/src/corelib/serialization/qcbormap.h +++ b/src/corelib/serialization/qcbormap.h @@ -245,7 +245,7 @@ public: { const_iterator it = find(key); return it != end(); } int compare(const QCborMap &other) const noexcept Q_DECL_PURE_FUNCTION; -#if 0 && QT_HAS_INCLUDE(<compare>) +#if 0 && __has_include(<compare>) std::strong_ordering operator<=>(const QCborMap &other) const { int c = compare(other); diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index f79fc572c4..914103b0a5 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -59,7 +59,7 @@ # undef False #endif -#if 0 && QT_HAS_INCLUDE(<compare>) +#if 0 && __has_include(<compare>) # include <compare> #endif @@ -261,7 +261,7 @@ public: QCborValueRef operator[](const QString & key); int compare(const QCborValue &other) const; -#if 0 && QT_HAS_INCLUDE(<compare>) +#if 0 && __has_include(<compare>) std::strong_ordering operator<=>(const QCborValue &other) const { int c = compare(other); @@ -411,7 +411,7 @@ public: int compare(const QCborValue &other) const { return concrete().compare(other); } -#if 0 && QT_HAS_INCLUDE(<compare>) +#if 0 && __has_include(<compare>) std::strong_ordering operator<=>(const QCborValue &other) const { int c = compare(other); diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index c50e087c10..e89caabdb0 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -332,7 +332,7 @@ int qstricmp(const char *str1, const char *str2) return int(Incomplete); }; -#if defined(__SSE4_1__) && !(defined(__SANITIZE_ADDRESS__) || QT_HAS_FEATURE(address_sanitizer)) +#if defined(__SSE4_1__) && !(defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)) enum { PageSize = 4096, PageMask = PageSize - 1 }; const __m128i zero = _mm_setzero_si128(); forever { diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 7c571706d8..5d8ccbfb1a 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -254,7 +254,7 @@ public: void chop(int n); #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) -# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_CPP_ATTRIBUTE(nodiscard) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_cpp_attribute(nodiscard) // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 # pragma push_macro("Q_REQUIRED_RESULT") # undef Q_REQUIRED_RESULT diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 5def2c81a1..1669d7c94a 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -487,7 +487,7 @@ public: Q_REQUIRED_RESULT QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const; #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC) -# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_CPP_ATTRIBUTE(nodiscard) +# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_cpp_attribute(nodiscard) // required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941 # pragma push_macro("Q_REQUIRED_RESULT") # undef Q_REQUIRED_RESULT diff --git a/src/corelib/thread/qfutex_p.h b/src/corelib/thread/qfutex_p.h index 7bec4554b7..f287b752d7 100644 --- a/src/corelib/thread/qfutex_p.h +++ b/src/corelib/thread/qfutex_p.h @@ -81,7 +81,7 @@ QT_END_NAMESPACE // if not defined in linux/futex.h # define FUTEX_PRIVATE_FLAG 128 // added in v2.6.22 -# if QT_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__) +# if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__) # include <sanitizer/tsan_interface.h> inline void _q_tsan_acquire(void *addr, void *addr2) { @@ -98,7 +98,7 @@ inline void _q_tsan_release(void *addr, void *addr2) # else inline void _q_tsan_acquire(void *, void *) {} inline void _q_tsan_release(void *, void *) {} -# endif // QT_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__) +# endif // __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__) QT_BEGIN_NAMESPACE namespace QtLinuxFutex { diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index c693ff65d8..93c4bf23e8 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -44,7 +44,7 @@ #include <QtCore/qatomic.h> #include <new> -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) # include <chrono> # include <limits> #endif @@ -147,7 +147,7 @@ public: // Lockable concept bool try_lock() QT_MUTEX_LOCK_NOEXCEPT { return tryLock(); } -#if QT_HAS_INCLUDE(<chrono>) || defined(Q_CLANG_QDOC) +#if __has_include(<chrono>) || defined(Q_CLANG_QDOC) // TimedLockable concept template <class Rep, class Period> bool try_lock_for(std::chrono::duration<Rep, Period> duration) @@ -175,7 +175,7 @@ private: friend class QRecursiveMutex; friend class ::tst_QMutex; -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) template<class Rep, class Period> static int convertToMilliseconds(std::chrono::duration<Rep, Period> duration) { @@ -213,7 +213,7 @@ public: using QMutex::tryLock; using QMutex::unlock; using QMutex::try_lock; -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) using QMutex::try_lock_for; using QMutex::try_lock_until; #endif @@ -295,7 +295,7 @@ public: inline void unlock() noexcept {} inline bool isRecursive() const noexcept { return true; } -#if QT_HAS_INCLUDE(<chrono>) +#if __has_include(<chrono>) template <class Rep, class Period> inline bool try_lock_for(std::chrono::duration<Rep, Period> duration) noexcept { diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index b01ce0db58..aa79e0d4a9 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -535,7 +535,7 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera # define QT_HAS_BUILTIN_CTZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept { -# if QT_HAS_BUILTIN(__builtin_ctzs) +# if __has_builtin(__builtin_ctzs) return __builtin_ctzs(v); # else return __builtin_ctz(v); @@ -544,7 +544,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept #define QT_HAS_BUILTIN_CLZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept { -# if QT_HAS_BUILTIN(__builtin_clzs) +# if __has_builtin(__builtin_clzs) return __builtin_clzs(v); # else return __builtin_clz(v) - 16U; diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index 45c3f93da4..40d2747b1d 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -51,7 +51,7 @@ template <typename F> QScopeGuard<F> qScopeGuard(F f); template <typename F> class -#if QT_HAS_CPP_ATTRIBUTE(nodiscard) +#if __has_cpp_attribute(nodiscard) // Q_REQUIRED_RESULT can be defined as __warn_unused_result__ or as [[nodiscard]] // but the 1st one has some limitations for example can be placed only on functions. Q_REQUIRED_RESULT @@ -91,7 +91,7 @@ private: template <typename F> -#if QT_HAS_CPP_ATTRIBUTE(nodiscard) +#if __has_cpp_attribute(nodiscard) Q_REQUIRED_RESULT #endif QScopeGuard<F> qScopeGuard(F f) -- cgit v1.2.3 From c978de990b6c448184e13a3c45d9aa268492b48a Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Wed, 26 Jun 2019 13:23:12 +1000 Subject: wasm: set focus on canvas on new screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows user to utilize the application without having to click on it first to cause the focus-in event. Change-Id: Ibc9582254dda91eb14ebcdf4b8ea4a4f862aa88d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/wasm/qwasmscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 37f1ea832a..b6c9b9e377 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -54,6 +54,8 @@ QWasmScreen::QWasmScreen(const QString &canvasId) m_compositor = new QWasmCompositor(this); m_eventTranslator = new QWasmEventTranslator(this); updateQScreenAndCanvasRenderSize(); + emscripten::val canvas = emscripten::val::global(m_canvasId.toUtf8().constData()); + canvas.call<void>("focus"); } QWasmScreen::~QWasmScreen() -- cgit v1.2.3 From c69a2448ab129d88411a4778f2350dcf971dc623 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Wed, 4 Dec 2019 15:06:36 +0100 Subject: macOS: support copying lazily provided data to the clipboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using always EagerRequest type forces the application to provide the data at copy or drag-begin time, even though the data might never be requested (pasted or dropped into another application). For data that is expensive to generate, this is wasteful, and on other platforms Qt uses the functionality provided by the native clipboard to allow for on-demand retrieval of data. Changing the request type to LazyRequest for the cocoa clipboard works, but then we need to make sure that we resolve all promises at shutdown time so that the data is available (which is what the end user expects). Commit ad0d2f463a0905c4705660d96e8a514539c51d36 disabled this for lazy requests to prevent crashes when using drag'n'drop, where the QMacPasteboard object is short-lived and stack allocated. We definitely don't need to worry about lazy data that is not yet retrieved at the end of a drag'n'drop operation, so limit the fix from the previous commit to the drag'n'drop scenario. [ChangeLog][QtGui][QClipboard] Support lazily provided copying of data to the clipboard on macOS Change-Id: Id2203999024a0d9d854d6933d39077cc4af925d0 Fixes: QTBUG-76263 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/cocoa/qcocoaclipboard.mm | 2 +- src/plugins/platforms/cocoa/qmacclipboard.mm | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index a35c153084..141940cc50 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -67,7 +67,7 @@ void QCocoaClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) } pasteBoard->sync(); - pasteBoard->setMimeData(data); + pasteBoard->setMimeData(data, QMacPasteboard::LazyRequest); emitChanged(mode); } } diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 358a6b49fd..654647b35a 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -138,8 +138,12 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) QMacPasteboard::~QMacPasteboard() { - // commit all promises for paste after exit close - resolvingBeforeDestruction = true; + /* + Commit all promises for paste when shutting down, + unless we are the stack-allocated clipboard used by QCocoaDrag. + */ + if (mime_type == QMacInternalPasteboardMime::MIME_DND) + resolvingBeforeDestruction = true; PasteboardResolvePromises(paste); if (paste) CFRelease(paste); -- cgit v1.2.3 From e40e82ede1660e6467291002862732a536558f08 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha <andre.rocha@qt.io> Date: Fri, 6 Dec 2019 20:09:29 +0100 Subject: Add "checkable" state to accessible menu item The information about whether a menu item may be checked is necessary to allow the platform code (in particular, Windows UI Automation layer) to make this information available to screen readers. Task-number: QTBUG-80551 Change-Id: Ibfcc4f2da1ebc68e7dc5df2cd46bbfc0a177da12 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/widgets/accessible/qaccessiblemenu.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 7f87288520..048d4062b8 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -299,6 +299,8 @@ QAccessible::State QAccessibleMenuItem::state() const s.disabled = true; if (m_action->isChecked()) s.checked = true; + if (m_action->isCheckable()) + s.checkable = true; return s; } -- cgit v1.2.3 From b209270825cc2c3345d094e3dd547604c64e0b26 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha <andre.rocha@qt.io> Date: Fri, 6 Dec 2019 20:21:41 +0100 Subject: Windows QPA: Export "checkable" info for menu items through UI Automation In order to allow screen readers to say checked/unchecked for checkable menu items, this information has to be provided through UI Automation. Checkable menu items should implement the "Toggle" UI Automation pattern. The "checkable" state must also be supported by QAccessibleMenuItem, which is being added by a separated change. Task-number: QTBUG-80551 Change-Id: I661668310d1b6b4701d0c0efdb1dcfd15d0db729 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index e5a9f275ae..cc293b777c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -289,7 +289,8 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow break; case UIA_TogglePatternId: // Checkbox controls. - if (accessible->role() == QAccessible::CheckBox) { + if (accessible->role() == QAccessible::CheckBox + || (accessible->role() == QAccessible::MenuItem && accessible->state().checkable)) { *pRetVal = new QWindowsUiaToggleProvider(id()); } break; -- cgit v1.2.3 From 95689c645fb42260d920091658b2d39c920abf00 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland <eirik.aavitsland@qt.io> Date: Mon, 2 Dec 2019 10:44:40 +0100 Subject: Make inputmask 'X' mask character require non-blank input The implementation for the X mask would accept any printable character. Since that includes the blank character, there was no difference in behavior between the requiring X and optional x: both would allow the input to be unset, i.e. blank. This change should be seen in conjunction with the doc improvement da0af1e. [ChangeLog][QtWidgets][QLineEdit] Inputmask X character now requires non-blank input. Fixes: QTBUG-76320 Change-Id: I3e0363e9be5c13373a157cce69c99379615b5829 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/widgets/widgets/qlineedit.cpp | 4 ++-- src/widgets/widgets/qwidgetlinecontrol.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index bcd6614ee4..19a95be0ff 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1214,8 +1214,8 @@ QMargins QLineEdit::textMargins() const \row \li \c a \li ASCII alphabetic character permitted but not required. \row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9. \row \li \c n \li ASCII alphanumeric character permitted but not required. - \row \li \c X \li Any character required. - \row \li \c x \li Any character permitted but not required. + \row \li \c X \li Any non-blank character required. + \row \li \c x \li Any non-blank character permitted but not required. \row \li \c 9 \li ASCII digit required. 0-9. \row \li \c 0 \li ASCII digit permitted but not required. \row \li \c D \li ASCII digit required. 1-9. diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index a242947c11..9dd61c2c6a 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1090,7 +1090,7 @@ bool QWidgetLineControl::isValidInput(QChar key, QChar mask) const return true; break; case 'X': - if (key.isPrint()) + if (key.isPrint() && key != m_blank) return true; break; case 'x': -- cgit v1.2.3 From 30e32870a052fda1a23099e46864242e52d94a17 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Wed, 4 Dec 2019 14:58:27 +0100 Subject: QCocoaEventDispatcher: make 'interrupt' work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit even if we are currently inside processEvents (apparently called manually and not from QEventLoop::exec()). A carefully crafted application (see, for example, the linked QTBUG or even updated auto-test) can trigger itself into failing to exit the current (potentially nested) event loop. We can harden our Cocoa event dispatcher to detect such condition and properly propagate 'interrupt' to where it'll do its job, indeed, interrupting the real event loop (aka [NSApp run]). This mainly means we have to undo what bool blocker would erroneously do. Also, long live (as people love to say these days) to another tricky (somewhat) auto-test (surely, it's not flaky!). Fixes: QTBUG-79477 Change-Id: I794f0cda23e24d36be67f2bb63d52b74be057c31 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- .../platforms/cocoa/qcocoaeventdispatcher.h | 1 + .../platforms/cocoa/qcocoaeventdispatcher.mm | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index 69587a24be..b8d2532b8e 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -186,6 +186,7 @@ public: QAtomicInt serialNumber; int lastSerial; bool interrupt; + bool propagateInterrupt = false; static void postedEventsSourceCallback(void *info); static void waitingObserverCallback(CFRunLoopObserverRef observer, diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 110c82bf1f..94b9e62eab 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -84,13 +84,12 @@ #include "private/qthread_p.h" #include "private/qguiapplication_p.h" #include <qdebug.h> +#include <qscopeguard.h> #include <AppKit/AppKit.h> QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE - static inline CFRunLoopRef mainRunLoop() { return CFRunLoopGetMain(); @@ -348,6 +347,16 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QCocoaEventDispatcher); + + // In rare rather corner cases a user's application messes with + // QEventLoop::exec()/exit() and QCoreApplication::processEvents(), + // we have to undo what bool blocker normally does. + d->propagateInterrupt = false; + const auto boolBlockerUndo = qScopeGuard([d](){ + if (d->propagateInterrupt) + d->interrupt = true; + d->propagateInterrupt = false; + }); QBoolBlocker interruptBlocker(d->interrupt, false); bool interruptLater = false; @@ -496,7 +505,16 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // When called "manually", always process posted events and timers + bool oldInterrupt = d->interrupt; d->processPostedEvents(); + if (!oldInterrupt && d->interrupt && !d->currentModalSession()) { + // We had direct processEvent call, coming not from QEventLoop::exec(). + // One of the posted events triggered an application to interrupt the loop. + // But bool blocker will reset d->interrupt to false, so the real event + // loop will never notice it was interrupted. Now we'll have to fix it by + // enforcing the value of d->interrupt. + d->propagateInterrupt = true; + } retVal = d->processTimers() || retVal; } -- cgit v1.2.3 From 42aa740df72af0c14f19a498f779d130e8303e54 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Tue, 10 Dec 2019 09:00:11 +0100 Subject: rcc: Fix namespace handling for initializer rcc currently always writes the namespace mangling macros in both the initializer constructor and destructor. This patch add the missing handling of the --namespace option for that part of the generated code. [ChangeLog][Tools][rcc] rcc now generates correct code when using the --namespace option. Change-Id: I7e5e608eb0ad267d11d601fc69c1a87d3f655a6e Fixes: QTBUG-80649 Reviewed-by: hjk <hjk@qt.io> --- src/tools/rcc/rcc.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 9acbce25ff..7185219d34 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -1478,13 +1478,19 @@ bool RCCResourceLibrary::writeInitializer() writeString(" return 1;\n"); writeString("}\n\n"); - writeByteArray( - "namespace {\n" - " struct initializer {\n" - " initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n" - " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n" - " } dummy;\n" - "}\n"); + + writeString("namespace {\n" + " struct initializer {\n"); + + if (m_useNameSpace) { + writeByteArray(" initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n" + " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n"); + } else { + writeByteArray(" initializer() { " + initResources + "(); }\n" + " ~initializer() { " + cleanResources + "(); }\n"); + } + writeString(" } dummy;\n" + "}\n"); } else if (m_format == Binary) { int i = 4; -- cgit v1.2.3 From 53804f553d446c962764ba3365a8b390436fceb4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Tue, 10 Dec 2019 10:43:53 +0100 Subject: rhi: gl: Destructure mat3 correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per std140 packing rules. Change-Id: I85663d36a9fa617ea387e8f201677471b2ebd948 Fixes: QTBUG-80655 Reviewed-by: Christian Strømme <christian.stromme@qt.io> --- src/gui/rhi/qrhigles2.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 563d59b318..e4490ceedb 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2428,7 +2428,15 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); break; case QShaderDescription::Mat3: - f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); + { + // 4 floats per column (or row, if row-major) + float mat[9]; + const float *srcMat = reinterpret_cast<const float *>(src); + memcpy(mat, srcMat, 3 * sizeof(float)); + memcpy(mat + 3, srcMat + 4, 3 * sizeof(float)); + memcpy(mat + 6, srcMat + 8, 3 * sizeof(float)); + f->glUniformMatrix3fv(uniform.glslLocation, 1, GL_FALSE, mat); + } break; case QShaderDescription::Mat4: f->glUniformMatrix4fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); -- cgit v1.2.3 From bf65c277892f6f322fa689c06d81ba9b1d9a8038 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Mon, 2 Dec 2019 16:15:14 +0100 Subject: Fix more mis-handling of spaces in ISO date format strings ISO date format doesn't allow spaces within a date, although 3339 does allow a space to replace the T between date and time. Sixteen tests added to check this all failed. So clean up the handling of spaces in the parsing of ISO date-time strings. [ChangeLog][QtCore][QDateTime] ISO 8601: parsing of dates now requires a punctuator as separator (it previously allowed any non-digit; officially only a dash should be allowed) and parsing of date-times no longer tolerates spaces in the numeric fields: an internal space is only allowed in an ISO 8601 date-time as replacement for the T between date and time. Change-Id: I24d110e71d416ecef74e196d5ee270b59d1bd813 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetime.cpp | 104 +++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 0d8aaabd2e..a8d643d483 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1626,6 +1626,29 @@ qint64 QDate::daysTo(const QDate &d) const */ #if QT_CONFIG(datestring) +namespace { + +struct ParsedInt { int value = 0; bool ok = false; }; + +/* + /internal + + Read an int that must be the whole text. QStringRef::toInt() will ignore + spaces happily; but ISO date format should not. +*/ +ParsedInt readInt(QStringView text) +{ + ParsedInt result; + for (const auto &ch : text) { + if (ch.isSpace()) + return result; + } + result.value = QLocale::c().toInt(text, &result.ok); + return result; +} + +} + /*! Returns the QDate represented by the \a string, using the \a format given, or an invalid date if the string cannot be @@ -1677,17 +1700,18 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format) return QDate(year, month, day); } #endif // textdate - case Qt::ISODate: { - // Semi-strict parsing, must be long enough and have non-numeric separators - if (string.size() < 10 || string.at(4).isDigit() || string.at(7).isDigit() - || (string.size() > 10 && string.at(10).isDigit())) { - return QDate(); - } - const int year = string.midRef(0, 4).toInt(); - if (year <= 0 || year > 9999) - return QDate(); - return QDate(year, string.midRef(5, 2).toInt(), string.midRef(8, 2).toInt()); + case Qt::ISODate: + // Semi-strict parsing, must be long enough and have punctuators as separators + if (string.size() >= 10 && string.at(4).isPunct() && string.at(7).isPunct() + && (string.size() == 10 || !string.at(10).isDigit())) { + QStringView view(string); + const ParsedInt year = readInt(view.mid(0, 4)); + const ParsedInt month = readInt(view.mid(5, 2)); + const ParsedInt day = readInt(view.mid(8, 2)); + if (year.ok && year.value > 0 && year.value <= 9999 && month.ok && day.ok) + return QDate(year.value, month.value, day.value); } + break; } return QDate(); } @@ -2331,17 +2355,15 @@ static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool * *isMidnight24 = false; const int size = string.size(); - if (size < 5) + if (size < 5 || string.at(2) != QLatin1Char(':')) return QTime(); - const QLocale C(QLocale::c()); - bool ok = false; - int hour = C.toInt(string.mid(0, 2), &ok); - if (!ok) - return QTime(); - const int minute = C.toInt(string.mid(3, 2), &ok); - if (!ok) + ParsedInt hour = readInt(string.mid(0, 2)); + ParsedInt minute = readInt(string.mid(3, 2)); + if (!hour.ok || !minute.ok) return QTime(); + // FIXME: ISO 8601 allows [,.]\d+ after hour, just as it does after minute + int second = 0; int msec = 0; @@ -2361,44 +2383,56 @@ static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool * // will then be rounded up AND clamped to 999. const QStringView minuteFractionStr = string.mid(6, qMin(qsizetype(5), string.size() - 6)); - const long minuteFractionInt = C.toLong(minuteFractionStr, &ok); - if (!ok) + const ParsedInt parsed = readInt(minuteFractionStr); + if (!parsed.ok) return QTime(); - const float minuteFraction = double(minuteFractionInt) / (std::pow(double(10), minuteFractionStr.size())); + const float secondWithMs + = double(parsed.value) * 60 / (std::pow(double(10), minuteFractionStr.size())); - const float secondWithMs = minuteFraction * 60; - const float secondNoMs = std::floor(secondWithMs); - const float secondFraction = secondWithMs - secondNoMs; - second = secondNoMs; + second = std::floor(secondWithMs); + const float secondFraction = secondWithMs - second; msec = qMin(qRound(secondFraction * 1000.0), 999); - } else { + } else if (string.at(5) == QLatin1Char(':')) { // HH:mm:ss or HH:mm:ss.zzz - second = C.toInt(string.mid(6, qMin(qsizetype(2), string.size() - 6)), &ok); - if (!ok) + const ParsedInt parsed = readInt(string.mid(6, qMin(qsizetype(2), string.size() - 6))); + if (!parsed.ok) return QTime(); - if (size > 8 && (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.'))) { + second = parsed.value; + if (size <= 8) { + // No fractional part to read + } else if (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.')) { QStringView msecStr(string.mid(9, qMin(qsizetype(4), string.size() - 9))); - // toInt() ignores leading spaces, so catch them before calling it + bool ok = true; + // Can't use readInt() here, as we *do* allow trailing space - but not leading: if (!msecStr.isEmpty() && !msecStr.at(0).isDigit()) return QTime(); - // We do, however, want to ignore *trailing* spaces. msecStr = msecStr.trimmed(); - int msecInt = msecStr.isEmpty() ? 0 : C.toInt(msecStr, &ok); + int msecInt = msecStr.isEmpty() ? 0 : QLocale::c().toInt(msecStr, &ok); if (!ok) return QTime(); const double secondFraction(msecInt / (std::pow(double(10), msecStr.size()))); msec = qMin(qRound(secondFraction * 1000.0), 999); + } else { +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) // behavior change + // Stray cruft after date-time: tolerate trailing space, but nothing else. + for (const auto &ch : string.mid(8)) { + if (!ch.isSpace()) + return QTime(); + } +#endif } + } else { + return QTime(); } const bool isISODate = format == Qt::ISODate || format == Qt::ISODateWithMs; - if (isISODate && hour == 24 && minute == 0 && second == 0 && msec == 0) { + if (isISODate && hour.value == 24 && minute.value == 0 && second == 0 && msec == 0) { if (isMidnight24) *isMidnight24 = true; - hour = 0; + hour.value = 0; } - return QTime(hour, minute, second, msec); + return QTime(hour.value, minute.value, second, msec); } /*! -- cgit v1.2.3 From e6de661a8aa96b5905ea7ba4cd5d76bd06da3f93 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Tue, 10 Dec 2019 10:52:03 +0100 Subject: rhi: gl: Handle struct and array of struct uniforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have intentionally limited support for advanced things like arrays in a uniform block. There is one very common case however: a one dimensional array of a struct. Typical example for Qt Quick 3D: struct LightSource { vec4 position; ... }; layout (std140, binding = 1) uniform cbBufferLights { int uNumLights; LightSource lights[MAX_NUM_LIGHTS]; }; With GLSL (uniform blocks disabled) this gets turned into two structs where one has a 'lights' member that is an array of the other struct. Teach the OpenGL backend of QRhi how to handle this. This makes the QRhi port of Qt Quick3D functional with the OpenGL backend as well. Change-Id: I6a09b93276794f7ecdd38f5bfbd3491a9ef58146 Fixes: QTBUG-80628 Reviewed-by: Christian Strømme <christian.stromme@qt.io> --- src/gui/rhi/qrhigles2.cpp | 67 +++++++++++++++++++++++++++++++++++++-------- src/gui/rhi/qrhigles2_p_p.h | 9 +++++- 2 files changed, 63 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index e4490ceedb..3fb2ec38a7 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2927,21 +2927,64 @@ bool QRhiGles2::linkProgram(GLuint program) return true; } -void QRhiGles2::gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, +void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable &var, + const QByteArray &namePrefix, + int binding, + int baseOffset, + GLuint program, + QVector<QGles2UniformDescription> *dst) +{ + if (var.type == QShaderDescription::Struct) { + qWarning("Nested structs are not supported at the moment. '%s' ignored.", + qPrintable(var.name)); + return; + } + QGles2UniformDescription uniform; + uniform.type = var.type; + const QByteArray name = namePrefix + var.name.toUtf8(); + uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); + if (uniform.glslLocation >= 0) { + uniform.binding = binding; + uniform.offset = uint(baseOffset + var.offset); + uniform.size = var.size; + dst->append(uniform); + } +} + +void QRhiGles2::gatherUniforms(GLuint program, + const QShaderDescription::UniformBlock &ub, QVector<QGles2UniformDescription> *dst) { - const QByteArray prefix = ub.structName.toUtf8() + '.'; + QByteArray prefix = ub.structName.toUtf8() + '.'; for (const QShaderDescription::BlockVariable &blockMember : ub.members) { - // ### no array support for now - QGles2UniformDescription uniform; - uniform.type = blockMember.type; - const QByteArray name = prefix + blockMember.name.toUtf8(); - uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); - if (uniform.glslLocation >= 0) { - uniform.binding = ub.binding; - uniform.offset = uint(blockMember.offset); - uniform.size = blockMember.size; - dst->append(uniform); + if (blockMember.type == QShaderDescription::Struct) { + prefix += blockMember.name.toUtf8(); + const int baseOffset = blockMember.offset; + if (blockMember.arrayDims.isEmpty()) { + for (const QShaderDescription::BlockVariable &structMember : blockMember.structMembers) + registerUniformIfActive(structMember, prefix, ub.binding, baseOffset, program, dst); + } else { + if (blockMember.arrayDims.count() > 1) { + qWarning("Array of struct '%s' has more than one dimension. Only the first dimension is used.", + qPrintable(blockMember.name)); + } + const int dim = blockMember.arrayDims.first(); + const int elemSize = blockMember.size / dim; + int elemOffset = baseOffset; + for (int di = 0; di < dim; ++di) { + const QByteArray arrayPrefix = prefix + '[' + QByteArray::number(di) + ']' + '.'; + for (const QShaderDescription::BlockVariable &structMember : blockMember.structMembers) + registerUniformIfActive(structMember, arrayPrefix, ub.binding, elemOffset, program, dst); + elemOffset += elemSize; + } + } + } else { + if (!blockMember.arrayDims.isEmpty()) { + qWarning("Arrays are only supported for structs at the moment. '%s' ignored.", + qPrintable(blockMember.name)); + continue; + } + registerUniformIfActive(blockMember, prefix, ub.binding, 0, program, dst); } } } diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index 0283fadb4e..4a98011d3d 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -706,7 +706,14 @@ public: QByteArray shaderSource(const QRhiShaderStage &shaderStage, int *glslVersion); bool compileShader(GLuint program, const QRhiShaderStage &shaderStage, int *glslVersion); bool linkProgram(GLuint program); - void gatherUniforms(GLuint program, const QShaderDescription::UniformBlock &ub, + void registerUniformIfActive(const QShaderDescription::BlockVariable &var, + const QByteArray &namePrefix, + int binding, + int baseOffset, + GLuint program, + QVector<QGles2UniformDescription> *dst); + void gatherUniforms(GLuint program, + const QShaderDescription::UniformBlock &ub, QVector<QGles2UniformDescription> *dst); void gatherSamplers(GLuint program, const QShaderDescription::InOutVariable &v, QVector<QGles2SamplerDescription> *dst); -- cgit v1.2.3 From 382f1a221b353892844dc7b1495741c4669955e7 Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Thu, 31 Oct 2019 12:26:00 +1000 Subject: wasm: fix getOpenFileContent doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The callback should be named the same as the function expects Change-Id: I4ca73958313c93c0d68e7205d8641c4104247e0c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp index 7ccd827a04..4b4fb869f9 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp @@ -146,13 +146,13 @@ dialog.exec(); //! [14] //! [15] -auto fileOpenCompleted = [](const QString &fileName, const QByteArray &fileContent) { +auto fileContentReady = [](const QString &fileName, const QByteArray &fileContent) { if (fileName.isEmpty()) { // No file was selected } else { // Use fileName and fileContent } -} +}; QFileDialog::getOpenFileContent("Images (*.png *.xpm *.jpg)", fileContentReady); //! [15] -- cgit v1.2.3 From 6ffedc07a77a8e3d46851b74cf9456d5abf6f612 Mon Sep 17 00:00:00 2001 From: Robert Szefner <r.szefner@hydro-partner.pl> Date: Sat, 7 Dec 2019 00:05:47 +0100 Subject: PSQL: Optimize QPSQLResult::data() function for date and time types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minor performance optimalizations: - No need to check if the date and time are correct because the QDate, QTime and QDateTime parsing functions already perform these checks - No need to add minute part to the UTC offset before parsing the date, because the QDateTime class can parse time zone offset both in form ±hh:mm and ±hh Change-Id: Id74b7ae075135c5c8cf420247c49b5f12fe88899 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 34 ++++++++----------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 78ede6a0d3..e0f82eee73 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -692,40 +692,24 @@ QVariant QPSQLResult::data(int i) return dbl; } case QVariant::Date: - if (val[0] == '\0') { - return QVariant(QDate()); - } else { #if QT_CONFIG(datestring) - return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate)); + return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate)); #else - return QVariant(QString::fromLatin1(val)); + return QVariant(QString::fromLatin1(val)); #endif - } - case QVariant::Time: { - const QString str = QString::fromLatin1(val); + case QVariant::Time: #if QT_CONFIG(datestring) - if (str.isEmpty()) - return QVariant(QTime()); - else - return QVariant(QTime::fromString(str, Qt::ISODate)); + return QVariant(QTime::fromString(QString::fromLatin1(val), Qt::ISODate)); #else - return QVariant(str); + return QVariant(QString::fromLatin1(val)); #endif - } - case QVariant::DateTime: { - QString dtval = QString::fromLatin1(val); + case QVariant::DateTime: #if QT_CONFIG(datestring) - if (dtval.length() < 10) { - return QVariant(QDateTime()); - } else { - QChar sign = dtval[dtval.size() - 3]; - if (sign == QLatin1Char('-') || sign == QLatin1Char('+')) dtval += QLatin1String(":00"); - return QVariant(QDateTime::fromString(dtval, Qt::ISODate).toLocalTime()); - } + return QVariant(QDateTime::fromString(QString::fromLatin1(val), + Qt::ISODate).toLocalTime()); #else - return QVariant(dtval); + return QVariant(QString::fromLatin1(val)); #endif - } case QVariant::ByteArray: { size_t len; unsigned char *data = PQunescapeBytea((const unsigned char*)val, &len); -- cgit v1.2.3 From 0d4dea728ff3b7f15a7ddb22d94c54087e98f53d Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Fri, 31 May 2019 15:52:52 -0700 Subject: MIME: Make the internal database direct content, not a Qt resource MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This saves us from having to bootstrap rcc in regular (non-cross) compilations, as it can now link to QtCore. Actually un-bootstrapping rcc is left as an exercise for the reader. This commit discovered that MSVC cannot handle constexpr arrays bigger than 256 kB, at which point it simply starts claiming that the constant expressions using it are not constexpr. ICC has a similar problem at 64 kB, but it tells you why ("note: type "const unsigned char [65537]" too large for constant-expression evaluation"). Note also that this requires gzip or zstd to be in PATH for compression to happen. RCC linked to zlib, which is always present due to the bundled copy. gzip's presence is not likely to be a problem on Unix systems, but could be for Windows users, especially MSVC ones. If gzip is not present, QtCore's size will increase by about 1910 kB of read-only (sharable) data. Change-Id: I2b1955a995ad40f3b89afffd15a3e65a94670242 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/corelib/mimetypes/mime/generate.bat | 73 +++++++++++++++++++++ src/corelib/mimetypes/mime/generate.pl | 113 ++++++++++++++++++++++++++++++++ src/corelib/mimetypes/mime/hexdump.ps1 | 43 ++++++++++++ src/corelib/mimetypes/mimetypes.pri | 29 +++++++- src/corelib/mimetypes/qmimedatabase.cpp | 11 +++- src/corelib/mimetypes/qmimeprovider.cpp | 95 +++++++++++++++++++++++++-- src/corelib/mimetypes/qmimeprovider_p.h | 11 ++++ src/src.pro | 4 +- 8 files changed, 366 insertions(+), 13 deletions(-) create mode 100644 src/corelib/mimetypes/mime/generate.bat create mode 100644 src/corelib/mimetypes/mime/generate.pl create mode 100644 src/corelib/mimetypes/mime/hexdump.ps1 (limited to 'src') diff --git a/src/corelib/mimetypes/mime/generate.bat b/src/corelib/mimetypes/mime/generate.bat new file mode 100644 index 0000000000..f63fc63693 --- /dev/null +++ b/src/corelib/mimetypes/mime/generate.bat @@ -0,0 +1,73 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Copyright (C) 2019 Intel Corporation. +:: Contact: https://www.qt.io/licensing/ +:: +:: This file is part of the tools applications of the Qt Toolkit. +:: +:: $QT_BEGIN_LICENSE:GPL-EXCEPT$ +:: 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 The Qt Company. For licensing terms +:: and conditions see https://www.qt.io/terms-conditions. For further +:: information use the contact form at https://www.qt.io/contact-us. +:: +:: GNU General Public License Usage +:: Alternatively, this file may be used under the terms of the GNU +:: General Public License version 3 as published by the Free Software +:: Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +:: included in the packaging of this file. Please review the following +:: information to ensure the GNU General Public License requirements will +:: be met: https://www.gnu.org/licenses/gpl-3.0.html. +:: +:: $QT_END_LICENSE$ +:: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +@echo off +setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS +set me=%~dp0 + +:: Check if certain tools are in PATH +for %%C in (gzip.exe zstd.exe perl.exe) do set %%C=%%~$PATH:C + +:: If perl is in PATH, just let it do everything +if not "%perl.exe%" == "" goto PuntToPerl + +set COMPRESS= +set MACRO=MIME_DATABASE_IS_UNCOMPRESSED +if not "%gzip.exe%" == "" ( + set COMPRESS=gzip -9 + set MACRO=MIME_DATABASE_IS_GZIP +) + +:: Check if zstd support was enabled +if /i "%~1" == "--zstd" ( + shift + if not "%zstd.exe%" == "" ( + set COMPRESS=zstd -19 + set MACRO=MIME_DATABASE_IS_ZSTD + ) +) + +if not "%COMPRESS%" == "" goto CompressedCommon + +:: No Compression and no Perl +:: Just hex-dump with Powershell +powershell -ExecutionPolicy Bypass %me%hexdump.ps1 %1 %1 +exit /b %errorlevel% + +:CompressedCommon +:: Compress to a temporary file, then hex-dump using Powershell +echo #define %MACRO% +set tempfile=generate%RANDOM%.tmp +%COMPRESS% < %1 > %tempfile% +powershell -ExecutionPolicy Bypass %me%hexdump.ps1 %tempfile% %1 +del %tempfile% +exit /b %errorlevel% + +:PuntToPerl +perl %me%generate.pl %* +exit /b %errorlevel% diff --git a/src/corelib/mimetypes/mime/generate.pl b/src/corelib/mimetypes/mime/generate.pl new file mode 100644 index 0000000000..0f87d61f8e --- /dev/null +++ b/src/corelib/mimetypes/mime/generate.pl @@ -0,0 +1,113 @@ +#!/usr/bin/perl +############################################################################# +## +## Copyright (C) 2019 Intel Corporation. +## Contact: https://www.qt.io/licensing/ +## +## This file is the build configuration utility of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +use strict; +use warnings; +use Config; +local $/; # Enable "slurp" mode + +sub checkCommand($) { + use File::Spec::Functions; + my $cmd = $_[0] . $Config{_exe}; + for my $path (path()) { + return 1 if -x catfile($path, $cmd); + } + return 0; +} + +my $data; +my $compress; +my $macro; +my $zlib = eval 'use Compress::Zlib; use IO::Compress::Gzip; return 1;'; +my $fname = shift @ARGV; + +if ($zlib) { + # Prefer internal zlib support (useful on Windows where gzip.exe isn't + # always presnet) + $macro = "MIME_DATABASE_IS_GZIP"; +} elsif (checkCommand("gzip")) { + # No builtin support for compression (old Perl?) + $compress = "gzip -c9"; + $macro = "MIME_DATABASE_IS_GZIP"; +} + +# Check if Qt is being built with zstd support +if ($fname eq "--zstd") { + $fname = shift @ARGV; + if (checkCommand("zstd")) { + $compress = "zstd -cq19 --single-thread"; + $macro = "MIME_DATABASE_IS_ZSTD"; + } +} + +# Check if xml (from xmlstarlet) is in $PATH +my $cmd; +if (checkCommand("xml")) { + # Minify the data before compressing + $cmd = "xml sel -D -B -t -c / $fname"; + $cmd .= "| $compress" if $compress; +} elsif ($compress) { + $cmd = "$compress < $fname" +} +if ($cmd) { + # Run the command and read everything + open CMD, "$cmd |"; + $data = <CMD>; + close CMD; + die("Failed to run $cmd") if ($? >> 8); +} else { + # No command, just read the file + open F, "<$fname"; + $data = <F>; + close F; +} + +# Do we need to compress with zlib? +if (!$compress && $zlib) { + $data = eval q{ + use Compress::Zlib; + use IO::Compress::Gzip qw(gzip); + my $compressed; + gzip \$data => \$compressed, + Minimal => 1, + Level => Z_BEST_COMPRESSION; + return $compressed; + }; +} + +# Now print as hex +printf "#define %s\n", $macro if $macro; +printf "static const unsigned char mimetype_database[] = {"; +my $i = 0; +map { + printf "\n " if $i++ % 12 == 0; + printf "0x%02x, ", ord $_ +} split //, $data; +printf "\n};\n"; +printf "static constexpr size_t MimeTypeDatabaseOriginalSize = %d;\n", + (stat $fname)[7]; diff --git a/src/corelib/mimetypes/mime/hexdump.ps1 b/src/corelib/mimetypes/mime/hexdump.ps1 new file mode 100644 index 0000000000..25ce8138fa --- /dev/null +++ b/src/corelib/mimetypes/mime/hexdump.ps1 @@ -0,0 +1,43 @@ +############################################################################# +## +## Copyright (C) 2019 Intel Corporation. +## Contact: https://www.qt.io/licensing/ +## +## This file is the build configuration utility of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +param([String]$path, [String]$orig) + +"static const unsigned char mimetype_database[] = {" +ForEach ($byte in Get-Content -Encoding byte -ReadCount 16 -path $path) { +# if (($byte -eq 0).count -ne 16) { + $hex = $byte | Foreach-Object { + " 0x" + ("{0:x}" -f $_).PadLeft( 2, "0" ) + "," + } + " $hex" +# } +} +"};" + +$file = Get-Childitem -file $orig +"static constexpr size_t MimeTypeDatabaseOriginalSize = " + $file.length + ";" diff --git a/src/corelib/mimetypes/mimetypes.pri b/src/corelib/mimetypes/mimetypes.pri index 62bbe348e4..8cbe7b69ae 100644 --- a/src/corelib/mimetypes/mimetypes.pri +++ b/src/corelib/mimetypes/mimetypes.pri @@ -21,5 +21,32 @@ qtConfig(mimetype) { mimetypes/qmimeglobpattern.cpp \ mimetypes/qmimeprovider.cpp - qtConfig(mimetype-database): RESOURCES += mimetypes/mimetypes.qrc + MIME_DATABASE = mimetypes/mime/packages/freedesktop.org.xml + OTHER_FILES += $$MIME_DATABASE + + qtConfig(mimetype-database) { + outpath = .rcc + debug_and_release { + CONFIG(debug, debug|release): outpath = .rcc/debug + else: outpath = .rcc/release + } + + mimedb.depends = $$PWD/mime/generate.pl + equals(MAKEFILE_GENERATOR, MSVC.NET)|equals(MAKEFILE_GENERATOR, MSBUILD)|isEmpty(QMAKE_SH) { + mimedb.commands = cmd /c $$shell_path($$PWD/mime/generate.bat) + mimedb.depends += $$PWD/mime/generate.bat $$PWD/mime/hexdump.ps1 + } else { + mimedb.commands = perl $${mimedb.depends} + } + + qtConfig(zstd): mimedb.commands += --zstd + mimedb.commands += ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT} + + mimedb.output = $$outpath/qmimeprovider_database.cpp + mimedb.input = MIME_DATABASE + mimedb.variable_out = INCLUDED_SOURCES + QMAKE_EXTRA_COMPILERS += mimedb + INCLUDEPATH += $$outpath + unset(outpath) + } } diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp index 1fbcc31fae..10b2190966 100644 --- a/src/corelib/mimetypes/qmimedatabase.cpp +++ b/src/corelib/mimetypes/qmimedatabase.cpp @@ -102,13 +102,18 @@ void QMimeDatabasePrivate::loadProviders() const auto fdoIterator = std::find_if(mimeDirs.constBegin(), mimeDirs.constEnd(), [](const QString &mimeDir) -> bool { return QFileInfo::exists(mimeDir + QStringLiteral("/packages/freedesktop.org.xml")); } ); - if (fdoIterator == mimeDirs.constEnd()) - mimeDirs.prepend(QLatin1String(":/qt-project.org/qmime")); //qDebug() << "mime dirs:" << mimeDirs; Providers currentProviders; std::swap(m_providers, currentProviders); - m_providers.reserve(mimeDirs.size()); + + if (QMimeXMLProvider::InternalDatabaseAvailable && fdoIterator == mimeDirs.constEnd()) { + m_providers.reserve(mimeDirs.size() + 1); + m_providers.push_back(Providers::value_type(new QMimeXMLProvider(this, QMimeXMLProvider::InternalDatabase))); + } else { + m_providers.reserve(mimeDirs.size()); + } + for (const QString &mimeDir : qAsConst(mimeDirs)) { const QString cacheFile = mimeDir + QStringLiteral("/mime.cache"); QFileInfo fileInfo(cacheFile); diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index c61759025c..4aee772366 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -1,7 +1,8 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -45,6 +46,7 @@ #include "qmimemagicrulematcher_p.h" #include <QXmlStreamReader> +#include <QBuffer> #include <QDir> #include <QFile> #include <QByteArrayMatcher> @@ -52,12 +54,33 @@ #include <QDateTime> #include <QtEndian> -static void initResources() -{ #if QT_CONFIG(mimetype_database) - Q_INIT_RESOURCE(mimetypes); +# if defined(Q_CC_MSVC) +# pragma section(".qtmimedatabase", read, shared) +__declspec(allocate(".qtmimedatabase")) __declspec(align(4096)) +# elif defined(Q_OS_DARWIN) +__attribute__((section("__TEXT,.qtmimedatabase"), aligned(4096))) +# elif (defined(Q_OF_ELF) || defined(Q_OS_WIN)) && defined(Q_CC_GNU) +__attribute__((section(".qtmimedatabase"), aligned(4096))) +# endif + +# include "qmimeprovider_database.cpp" + +# ifdef MIME_DATABASE_IS_ZSTD +# if !QT_CONFIG(zstd) +# error "MIME database is zstd but no support compiled in!" +# endif +# include <zstd.h> +# endif +# ifdef MIME_DATABASE_IS_GZIP +# ifdef QT_NO_COMPRESS +# error "MIME database is zlib but no support compiled in!" +# endif +# define ZLIB_CONST +# include <zconf.h> +# include <zlib.h> +# endif #endif -} QT_BEGIN_NAMESPACE @@ -597,10 +620,55 @@ void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate &data) //// +#if QT_CONFIG(mimetype_database) +static QString internalMimeFileName() +{ + return QStringLiteral("<internal MIME data>"); +} + +QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db, InternalDatabaseEnum) + : QMimeProviderBase(db, internalMimeFileName()) +{ + Q_STATIC_ASSERT_X(sizeof(mimetype_database), "Bundled MIME database is empty"); + Q_STATIC_ASSERT_X(sizeof(mimetype_database) <= MimeTypeDatabaseOriginalSize, + "Compressed MIME database is larger than the original size"); + Q_STATIC_ASSERT_X(MimeTypeDatabaseOriginalSize <= 16*1024*1024, + "Bundled MIME database is too big"); + const char *data = reinterpret_cast<const char *>(mimetype_database); + qsizetype size = MimeTypeDatabaseOriginalSize; + +#ifdef MIME_DATABASE_IS_ZSTD + // uncompress with libzstd + std::unique_ptr<char []> uncompressed(new char[size]); + size = ZSTD_decompress(uncompressed.get(), size, mimetype_database, sizeof(mimetype_database)); + Q_ASSERT(!ZSTD_isError(size)); + data = uncompressed.get(); +#elif defined(MIME_DATABASE_IS_GZIP) + std::unique_ptr<char []> uncompressed(new char[size]); + z_stream zs = {}; + zs.next_in = mimetype_database; + zs.avail_in = sizeof(mimetype_database); + zs.next_out = reinterpret_cast<Bytef *>(uncompressed.get()); + zs.avail_out = size; + + int res = inflateInit2(&zs, MAX_WBITS | 32); + Q_ASSERT(res == Z_OK); + res = inflate(&zs, Z_FINISH); + Q_ASSERT(res == Z_STREAM_END); + res = inflateEnd(&zs); + Q_ASSERT(res == Z_OK); + + data = uncompressed.get(); + size = zs.total_out; +#endif + + load(data, size); +} +#endif + QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db, const QString &directory) : QMimeProviderBase(db, directory) { - initResources(); ensureLoaded(); } @@ -692,6 +760,19 @@ bool QMimeXMLProvider::load(const QString &fileName, QString *errorMessage) return parser.parse(&file, fileName, errorMessage); } +#if QT_CONFIG(mimetype_database) +void QMimeXMLProvider::load(const char *data, qsizetype len) +{ + QBuffer buffer; + buffer.setData(QByteArray::fromRawData(data, len)); + buffer.open(QIODevice::ReadOnly); + QString errorMessage; + QMimeTypeParser parser(*this); + if (!parser.parse(&buffer, internalMimeFileName(), &errorMessage)) + qWarning("QMimeDatabase: Error loading internal MIME data\n%s", qPrintable(errorMessage)); +} +#endif + void QMimeXMLProvider::addGlobPattern(const QMimeGlobPattern &glob) { m_mimeTypeGlobs.addGlob(glob); diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h index b6268210c0..0629df8a95 100644 --- a/src/corelib/mimetypes/qmimeprovider_p.h +++ b/src/corelib/mimetypes/qmimeprovider_p.h @@ -132,6 +132,16 @@ private: class QMimeXMLProvider : public QMimeProviderBase { public: + enum InternalDatabaseEnum { InternalDatabase }; +#if QT_CONFIG(mimetype_database) + enum : bool { InternalDatabaseAvailable = true }; + QMimeXMLProvider(QMimeDatabasePrivate *db, InternalDatabaseEnum); +#else + enum : bool { InternalDatabaseAvailable = false }; + QMimeXMLProvider(QMimeDatabasePrivate *db, InternalDatabaseEnum) + : QMimeProviderBase(db, QString()) + { Q_UNREACHABLE() }; +#endif QMimeXMLProvider(QMimeDatabasePrivate *db, const QString &directory); ~QMimeXMLProvider(); @@ -156,6 +166,7 @@ public: private: void load(const QString &fileName); + void load(const char *data, qsizetype len); typedef QHash<QString, QMimeType> NameMimeTypeMap; NameMimeTypeMap m_nameMimeTypeMap; diff --git a/src/src.pro b/src/src.pro index 8ff3ec4c1f..592f0cf644 100644 --- a/src/src.pro +++ b/src/src.pro @@ -70,7 +70,7 @@ src_winmain.depends = sub-corelib # just for the module .pri file src_corelib.subdir = $$PWD/corelib src_corelib.target = sub-corelib -src_corelib.depends = src_tools_moc src_tools_rcc src_tools_tracegen +src_corelib.depends = src_tools_moc src_tools_tracegen src_xml.subdir = $$PWD/xml src_xml.target = sub-xml @@ -118,7 +118,7 @@ src_angle.target = sub-angle src_gui.subdir = $$PWD/gui src_gui.target = sub-gui -src_gui.depends = src_corelib +src_gui.depends = src_corelib src_tools_rcc src_platformheaders.subdir = $$PWD/platformheaders src_platformheaders.target = sub-platformheaders -- cgit v1.2.3 From 6bef90f3cfb886d74ac9ed38efeb8d80b7181011 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 26 Nov 2019 07:27:14 -0800 Subject: QTest::toString(QBitArray): fix Mismatched free() / delete / delete [] ==8015== Mismatched free() / delete / delete [] ==8015== at 0x483958B: operator delete[](void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==8015== by 0x48752D6: QTestResult::compare(bool, char const*, char*, char*, char const*, char const*, char const*, int) (qtestresult.cpp:356) ==8015== Address 0x602eb30 is 0 bytes inside a block of size 12 alloc'd ==8015== at 0x483777F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==8015== by 0x44AAE2: char* QTest::toString<QBitArray>(QBitArray const&) (qtest.h:98) ==8015== by 0x44D212: bool QTest::qCompare<QBitArray>(QBitArray const&, QBitArray const&, char const*, char const*, char const*, int) (qtestcase.h:352) Change-Id: Ia2aa807ffa8a4c798425fffd15dabfebfd63fdbd Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/testlib/qtest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 27fe08e8f4..3b1ffb389e 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -95,7 +95,7 @@ template<> inline char *toString(const QByteArray &ba) template<> inline char *toString(const QBitArray &ba) { qsizetype size = ba.size(); - char *str = static_cast<char *>(malloc(size + 1)); + char *str = new char[size + 1]; for (qsizetype i = 0; i < size; ++i) str[i] = "01"[ba.testBit(i)]; str[size] = '\0'; -- cgit v1.2.3 From a77fdc9847bcf730862f262aac0a2c4e921f4411 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Sun, 8 Dec 2019 15:14:49 -0800 Subject: Doc: remove the claim that zero timers execute after GUI events This ties our hands on what we can do in our implementations. I don't care if you've depended on this in your code. It was wrong. Fixes: QTBUG-80600 Change-Id: I568dea4813b448fe9ba6fffd15de8865a27f0a35 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> --- src/corelib/kernel/qtimer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 948f697dc5..4d8778ecf5 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -84,10 +84,10 @@ QT_BEGIN_NAMESPACE must start and stop the timer in its thread; it is not possible to start a timer from another thread. - As a special case, a QTimer with a timeout of 0 will time out as - soon as all the events in the window system's event queue have - been processed. This can be used to do heavy work while providing - a snappy user interface: + As a special case, a QTimer with a timeout of 0 will time out as soon as + possible, though the ordering between zero timers and other sources of + events is unspecified. Zero timers can be used to do some work while still + providing a snappy user interface: \snippet timers/timers.cpp 4 \snippet timers/timers.cpp 5 -- cgit v1.2.3 From 5a26bf9d65b75db3abefa967beb13b2510719bd5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Wed, 11 Dec 2019 09:30:26 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in macOS-specific code It is being deprecated. Change-Id: If1b0b058140e197d41efae93025c4eefc2ed9bbd Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/gui/text/qfont.cpp | 2 +- src/plugins/platforms/cocoa/qcocoatheme.h | 2 +- src/widgets/kernel/qmacgesturerecognizer.cpp | 4 ++-- src/widgets/widgets/qmaccocoaviewcontainer_mac.mm | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index e162015aba..9ede90d8de 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2707,7 +2707,7 @@ bool QFontInfo::fixedPitch() const QChar ch[2] = { QLatin1Char('i'), QLatin1Char('m') }; QGlyphLayoutArray<2> g; int l = 2; - if (!engine->stringToCMap(ch, 2, &g, &l, 0)) + if (!engine->stringToCMap(ch, 2, &g, &l, {})) Q_UNREACHABLE(); Q_ASSERT(l == 2); engine->fontDef.fixedPitch = g.advances[0] == g.advances[1]; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h index a00cbdfea3..50e56ef1bf 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.h +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -70,7 +70,7 @@ public: const QPalette *palette(Palette type = SystemPalette) const override; const QFont *font(Font type = SystemFont) const override; QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; - QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = 0) const override; + QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = {}) const override; QVariant themeHint(ThemeHint hint) const override; QString standardButtonText(int button) const override; diff --git a/src/widgets/kernel/qmacgesturerecognizer.cpp b/src/widgets/kernel/qmacgesturerecognizer.cpp index d39b93e320..aac115a2cf 100644 --- a/src/widgets/kernel/qmacgesturerecognizer.cpp +++ b/src/widgets/kernel/qmacgesturerecognizer.cpp @@ -149,8 +149,8 @@ QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *e void QMacPinchGestureRecognizer::reset(QGesture *gesture) { QPinchGesture *g = static_cast<QPinchGesture *>(gesture); - g->setChangeFlags(0); - g->setTotalChangeFlags(0); + g->setChangeFlags({}); + g->setTotalChangeFlags({}); g->setScaleFactor(1.0f); g->setTotalScaleFactor(1.0f); g->setLastScaleFactor(1.0f); diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index 88baf0410b..f261314c64 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -138,7 +138,7 @@ QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate() */ QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *view, QWidget *parent) - : QWidget(*new QMacCocoaViewContainerPrivate, parent, 0) + : QWidget(*new QMacCocoaViewContainerPrivate, parent, {}) { // Ensures that we have a QWindow, even if we're not a top level widget setAttribute(Qt::WA_NativeWindow); -- cgit v1.2.3 From a7108ec6cfb6411e40a4012f3e6d3b5d5fb9631d Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Wed, 11 Dec 2019 10:51:22 +0100 Subject: Fix CVE-2019-19244 in SQLite Fixes: QTBUG-80635 Change-Id: I718349e28ec76ea164dd50f2a985f2074dd6bdbd Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> --- .../0001-Fix-CVE-2019-19244-in-SQLite.patch | 26 ++++++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch (limited to 'src') diff --git a/src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch b/src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch new file mode 100644 index 0000000000..9906292860 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch @@ -0,0 +1,26 @@ +From 676425e522e08eb0e7dfaacdac79a5de27542322 Mon Sep 17 00:00:00 2001 +From: Andy Shaw <andy.shaw@qt.io> +Date: Wed, 11 Dec 2019 10:51:22 +0100 +Subject: [PATCH 53/53] Fix CVE-2019-19244 in SQLite + +Fixes: QTBUG-80635 +Change-Id: I718349e28ec76ea164dd50f2a985f2074dd6bdbd +--- + src/3rdparty/sqlite/sqlite3.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index 8fd740b300..bd647ca1c2 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -131679,6 +131679,7 @@ SQLITE_PRIVATE int sqlite3Select( + */ + if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct + && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 ++ && p->pWin==0 + ){ + p->selFlags &= ~SF_Distinct; + pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index 8fd740b300..bd647ca1c2 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -131679,6 +131679,7 @@ SQLITE_PRIVATE int sqlite3Select( */ if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0 + && p->pWin==0 ){ p->selFlags &= ~SF_Distinct; pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0); -- cgit v1.2.3 From f08038fca79b0828da11fbf35f4165d6efa4de2f Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Fri, 29 Nov 2019 11:49:28 +0100 Subject: Remove deprecated QGL* classes Removes QGL paths in sub-attaq and chip examples. The boxes example depended on QGL and has been removed. The corresponding module and test directories for the opengl module are now empty, but has been left there so we can move the QOpenGL* classes there. [ChangeLog][QtOpenGL] The deprecated QGL* classes have been removed. Fixes: QTBUG-74408 Change-Id: I52f56409af8f6901359462a7ba162103d051fe3d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/opengl/doc/snippets/code/src_opengl_qgl.cpp | 182 - .../doc/snippets/code/src_opengl_qglbuffer.cpp | 60 - .../doc/snippets/code/src_opengl_qglcolormap.cpp | 71 - .../doc/snippets/code/src_opengl_qglfunctions.cpp | 86 - .../snippets/code/src_opengl_qglpixelbuffer.cpp | 69 - .../snippets/code/src_opengl_qglshaderprogram.cpp | 104 - .../code/src_opengl_qgraphicsshadereffect.cpp | 95 - src/opengl/doc/src/qtopengl-examples.qdoc | 9 +- src/opengl/doc/src/qtopengl-module.qdoc | 13 +- src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp | 173 - src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h | 167 - .../gl2paintengineex/qglcustomshaderstage.cpp | 137 - .../gl2paintengineex/qglcustomshaderstage_p.h | 86 - .../gl2paintengineex/qglengineshadermanager.cpp | 875 --- .../gl2paintengineex/qglengineshadermanager_p.h | 508 -- .../gl2paintengineex/qglengineshadersource_p.h | 523 -- src/opengl/gl2paintengineex/qglgradientcache.cpp | 225 - src/opengl/gl2paintengineex/qglgradientcache_p.h | 103 - src/opengl/gl2paintengineex/qglshadercache_p.h | 86 - .../gl2paintengineex/qpaintengineex_opengl2.cpp | 2515 --------- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 334 -- .../gl2paintengineex/qtextureglyphcache_gl.cpp | 414 -- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 171 - src/opengl/opengl.pro | 49 +- src/opengl/qgl.cpp | 5558 -------------------- src/opengl/qgl.h | 524 -- src/opengl/qgl_p.h | 556 -- src/opengl/qglbuffer.cpp | 568 -- src/opengl/qglbuffer.h | 125 - src/opengl/qglcolormap.cpp | 296 -- src/opengl/qglcolormap.h | 99 - src/opengl/qglframebufferobject.cpp | 1466 ------ src/opengl/qglframebufferobject.h | 149 - src/opengl/qglframebufferobject_p.h | 157 - src/opengl/qglfunctions.cpp | 1330 ----- src/opengl/qglfunctions.h | 1688 ------ src/opengl/qglpaintdevice.cpp | 239 - src/opengl/qglpaintdevice_p.h | 113 - src/opengl/qglpixelbuffer.cpp | 654 --- src/opengl/qglpixelbuffer.h | 104 - src/opengl/qglpixelbuffer_p.h | 107 - src/opengl/qglshaderprogram.cpp | 3237 ------------ src/opengl/qglshaderprogram.h | 303 -- src/opengl/qgraphicsshadereffect.cpp | 272 - src/opengl/qgraphicsshadereffect_p.h | 90 - 45 files changed, 8 insertions(+), 24682 deletions(-) delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qgl.cpp delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qglbuffer.cpp delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qglcolormap.cpp delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qglfunctions.cpp delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qglpixelbuffer.cpp delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qglshaderprogram.cpp delete mode 100644 src/opengl/doc/snippets/code/src_opengl_qgraphicsshadereffect.cpp delete mode 100644 src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp delete mode 100644 src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h delete mode 100644 src/opengl/gl2paintengineex/qglcustomshaderstage.cpp delete mode 100644 src/opengl/gl2paintengineex/qglcustomshaderstage_p.h delete mode 100644 src/opengl/gl2paintengineex/qglengineshadermanager.cpp delete mode 100644 src/opengl/gl2paintengineex/qglengineshadermanager_p.h delete mode 100644 src/opengl/gl2paintengineex/qglengineshadersource_p.h delete mode 100644 src/opengl/gl2paintengineex/qglgradientcache.cpp delete mode 100644 src/opengl/gl2paintengineex/qglgradientcache_p.h delete mode 100644 src/opengl/gl2paintengineex/qglshadercache_p.h delete mode 100644 src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp delete mode 100644 src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h delete mode 100644 src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp delete mode 100644 src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h delete mode 100644 src/opengl/qgl.cpp delete mode 100644 src/opengl/qgl.h delete mode 100644 src/opengl/qgl_p.h delete mode 100644 src/opengl/qglbuffer.cpp delete mode 100644 src/opengl/qglbuffer.h delete mode 100644 src/opengl/qglcolormap.cpp delete mode 100644 src/opengl/qglcolormap.h delete mode 100644 src/opengl/qglframebufferobject.cpp delete mode 100644 src/opengl/qglframebufferobject.h delete mode 100644 src/opengl/qglframebufferobject_p.h delete mode 100644 src/opengl/qglfunctions.cpp delete mode 100644 src/opengl/qglfunctions.h delete mode 100644 src/opengl/qglpaintdevice.cpp delete mode 100644 src/opengl/qglpaintdevice_p.h delete mode 100644 src/opengl/qglpixelbuffer.cpp delete mode 100644 src/opengl/qglpixelbuffer.h delete mode 100644 src/opengl/qglpixelbuffer_p.h delete mode 100644 src/opengl/qglshaderprogram.cpp delete mode 100644 src/opengl/qglshaderprogram.h delete mode 100644 src/opengl/qgraphicsshadereffect.cpp delete mode 100644 src/opengl/qgraphicsshadereffect_p.h (limited to 'src') diff --git a/src/opengl/doc/snippets/code/src_opengl_qgl.cpp b/src/opengl/doc/snippets/code/src_opengl_qgl.cpp deleted file mode 100644 index a73ee2cdc5..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qgl.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QGLFormat fmt; -fmt.setAlpha(true); -fmt.setStereo(true); -QGLFormat::setDefaultFormat(fmt); -//! [0] - - -//! [1] -QGLFormat fmt; -fmt.setDoubleBuffer(false); // single buffer -fmt.setDirectRendering(false); // software rendering -MyGLWidget* myWidget = new MyGLWidget(fmt, ...); -//! [1] - - -//! [2] -QGLFormat fmt; -fmt.setOverlay(true); -fmt.setStereo(true); -MyGLWidget* myWidget = new MyGLWidget(fmt, ...); -if (!myWidget->format().stereo()) { - // ok, goggles off - if (!myWidget->format().hasOverlay()) { - qFatal("Cool hardware required"); - } -} -//! [2] - - -//! [3] -// The rendering in MyGLWidget depends on using -// stencil buffer and alpha channel -MyGLWidget::MyGLWidget(QWidget* parent) - : QGLWidget(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel), parent) -{ - if (!format().stencil()) - qWarning("Could not get stencil buffer; results will be suboptimal"); - if (!format().alpha()) - qWarning("Could not get alpha channel; results will be suboptimal"); - ... -} -//! [3] - - -//! [4] -QApplication a(argc, argv); -QGLFormat f; -f.setDoubleBuffer(false); -QGLFormat::setDefaultFormat(f); -//! [4] - - -//! [5] -QGLFormat f = QGLFormat::defaultOverlayFormat(); -f.setDoubleBuffer(true); -QGLFormat::setDefaultOverlayFormat(f); -//! [5] - - -//! [6] -// ...continued from above -MyGLWidget* myWidget = new MyGLWidget(QGLFormat(QGL::HasOverlay), ...); -if (myWidget->format().hasOverlay()) { - // Yes, we got an overlay, let's check _its_ format: - QGLContext* olContext = myWidget->overlayContext(); - if (olContext->format().doubleBuffer()) - ; // yes, we got a double buffered overlay - else - ; // no, only single buffered overlays are available -} -//! [6] - - -//! [7] -QGLContext *cx; -// ... -QGLFormat f; -f.setStereo(true); -cx->setFormat(f); -if (!cx->create()) - exit(); // no OpenGL support, or cannot render on the specified paintdevice -if (!cx->format().stereo()) - exit(); // could not create stereo context -//! [7] - - -//! [8] -class MyGLDrawer : public QGLWidget -{ - Q_OBJECT // must include this if you use Qt signals/slots - -public: - MyGLDrawer(QWidget *parent) - : QGLWidget(parent) {} - -protected: - - void initializeGL() override - { - // Set up the rendering context, define display lists etc.: - ... - glClearColor(0.0, 0.0, 0.0, 0.0); - glEnable(GL_DEPTH_TEST); - ... - } - - void resizeGL(int w, int h) override - { - // setup viewport, projection etc.: - glViewport(0, 0, (GLint)w, (GLint)h); - ... - glFrustum(...); - ... - } - - void paintGL() override - { - // draw the scene: - ... - glRotatef(...); - glMaterialfv(...); - glBegin(GL_QUADS); - glVertex3f(...); - glVertex3f(...); - ... - glEnd(); - ... - } - -}; -//! [8] diff --git a/src/opengl/doc/snippets/code/src_opengl_qglbuffer.cpp b/src/opengl/doc/snippets/code/src_opengl_qglbuffer.cpp deleted file mode 100644 index 11ef88ab37..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qglbuffer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] - QGLBuffer buffer1(QGLBuffer::IndexBuffer); - buffer1.create(); - - QGLBuffer buffer2 = buffer1; -//! [0] - -//! [1] - QGLBuffer::release(QGLBuffer::VertexBuffer); -//! [1] diff --git a/src/opengl/doc/snippets/code/src_opengl_qglcolormap.cpp b/src/opengl/doc/snippets/code/src_opengl_qglcolormap.cpp deleted file mode 100644 index 12a089944f..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qglcolormap.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -#include <QApplication> -#include <QGLColormap> - -int main() -{ - QApplication app(argc, argv); - - MySuperGLWidget widget; // a QGLWidget in color-index mode - QGLColormap colormap; - - // This will fill the colormap with colors ranging from - // black to white. - for (int i = 0; i < colormap.size(); i++) - colormap.setEntry(i, qRgb(i, i, i)); - - widget.setColormap(colormap); - widget.show(); - return app.exec(); -} -//! [0] diff --git a/src/opengl/doc/snippets/code/src_opengl_qglfunctions.cpp b/src/opengl/doc/snippets/code/src_opengl_qglfunctions.cpp deleted file mode 100644 index c848ae7ede..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qglfunctions.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] - class MyGLWidget : public QGLWidget, protected QGLFunctions - { - Q_OBJECT - public: - MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {} - - protected: - void initializeGL(); - void paintGL(); - }; - - void MyGLWidget::initializeGL() - { - initializeGLFunctions(); - } -//! [0] - -//! [1] - void MyGLWidget::paintGL() - { - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, textureId); - ... - } -//! [1] - -//! [2] - QGLFunctions glFuncs(QGLContext::currentContext()); - glFuncs.glActiveTexture(GL_TEXTURE1); -//! [2] - -//! [3] - QGLFunctions funcs(QGLContext::currentContext()); - bool npot = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures); -//! [3] diff --git a/src/opengl/doc/snippets/code/src_opengl_qglpixelbuffer.cpp b/src/opengl/doc/snippets/code/src_opengl_qglpixelbuffer.cpp deleted file mode 100644 index f6fbe6ddb4..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qglpixelbuffer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QGLPixelBuffer pbuffer(...); -... -pbuffer.makeCurrent(); -GLuint dynamicTexture = pbuffer.generateDynamicTexture(); -pbuffer.bindToDynamicTexture(dynamicTexture); -... -pbuffer.releaseFromDynamicTexture(); -//! [0] - - -//! [1] -QGLPixelBuffer pbuffer(...); -... -pbuffer.makeCurrent(); -GLuint dynamicTexture = pbuffer.generateDynamicTexture(); -... -pbuffer.updateDynamicTexture(dynamicTexture); -//! [1] diff --git a/src/opengl/doc/snippets/code/src_opengl_qglshaderprogram.cpp b/src/opengl/doc/snippets/code/src_opengl_qglshaderprogram.cpp deleted file mode 100644 index 04492499e8..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qglshaderprogram.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QGLShader shader(QGLShader::Vertex); -shader.compileSourceCode(code); - -QGLShaderProgram program(context); -program.addShader(shader); -program.link(); - -program.bind(); -//! [0] - -//! [1] -program.addShaderFromSourceCode(QGLShader::Vertex, - "attribute highp vec4 vertex;\n" - "uniform highp mat4 matrix;\n" - "void main(void)\n" - "{\n" - " gl_Position = matrix * vertex;\n" - "}"); -program.addShaderFromSourceCode(QGLShader::Fragment, - "uniform mediump vec4 color;\n" - "void main(void)\n" - "{\n" - " gl_FragColor = color;\n" - "}"); -program.link(); -program.bind(); - -int vertexLocation = program.attributeLocation("vertex"); -int matrixLocation = program.uniformLocation("matrix"); -int colorLocation = program.uniformLocation("color"); -//! [1] - -//! [2] -static GLfloat const triangleVertices[] = { - 60.0f, 10.0f, 0.0f, - 110.0f, 110.0f, 0.0f, - 10.0f, 110.0f, 0.0f -}; - -QColor color(0, 255, 0, 255); - -QMatrix4x4 pmvMatrix; -pmvMatrix.ortho(rect()); - -program.enableAttributeArray(vertexLocation); -program.setAttributeArray(vertexLocation, triangleVertices, 3); -program.setUniformValue(matrixLocation, pmvMatrix); -program.setUniformValue(colorLocation, color); - -glDrawArrays(GL_TRIANGLES, 0, 3); - -program.disableAttributeArray(vertexLocation); -//! [2] diff --git a/src/opengl/doc/snippets/code/src_opengl_qgraphicsshadereffect.cpp b/src/opengl/doc/snippets/code/src_opengl_qgraphicsshadereffect.cpp deleted file mode 100644 index 461e96e094..0000000000 --- a/src/opengl/doc/snippets/code/src_opengl_qgraphicsshadereffect.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] - static char const colorizeShaderCode[] = - "uniform lowp vec4 effectColor;\n" - "lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) {\n" - " vec4 src = texture2D(imageTexture, textureCoords);\n" - " float gray = dot(src.rgb, vec3(0.212671, 0.715160, 0.072169));\n" - " vec4 colorize = 1.0-((1.0-gray)*(1.0-effectColor));\n" - " return vec4(colorize.rgb, src.a);\n" - "}"; -//! [0] - -//! [1] - class ColorizeEffect : public QGraphicsShaderEffect - { - Q_OBJECT - public: - ColorizeEffect(QObject *parent = 0) - : QGraphicsShaderEffect(parent), color(Qt::black) - { - setPixelShaderFragment(colorizeShaderCode); - } - - QColor effectColor() const { return color; } - void setEffectColor(const QColor& c) - { - color = c; - setUniformsDirty(); - } - - protected: - void setUniforms(QGLShaderProgram *program) - { - program->setUniformValue("effectColor", color); - } - - private: - QColor color; - }; -//! [1] - -//! [2] - lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) { - return texture2D(imageTexture, textureCoords); - } -//! [2] diff --git a/src/opengl/doc/src/qtopengl-examples.qdoc b/src/opengl/doc/src/qtopengl-examples.qdoc index de80c92883..8770d6247e 100644 --- a/src/opengl/doc/src/qtopengl-examples.qdoc +++ b/src/opengl/doc/src/qtopengl-examples.qdoc @@ -33,12 +33,11 @@ \image opengl-examples.png - These examples describe how to use the \l {Qt OpenGL} module. For new code, - please use the OpenGL classes in the \l {Qt GUI} module. + These examples describe how to use the \l {Qt OpenGL} module. - Qt provides support for integration with OpenGL implementations on all - platforms, giving developers the opportunity to display hardware accelerated - 3D graphics alongside a more conventional user interface. + Qt provides support for integration with OpenGL implementations, giving + developers the opportunity to display hardware accelerated 3D graphics + alongside a more conventional user interface. These examples demonstrate the basic techniques used to take advantage of OpenGL in Qt applications. diff --git a/src/opengl/doc/src/qtopengl-module.qdoc b/src/opengl/doc/src/qtopengl-module.qdoc index 336d37c73f..24df4aec76 100644 --- a/src/opengl/doc/src/qtopengl-module.qdoc +++ b/src/opengl/doc/src/qtopengl-module.qdoc @@ -34,8 +34,7 @@ \brief The Qt OpenGL module offers classes that make it easy to use OpenGL in Qt applications. - \warning This module should not be used anymore for new code. Please - use the corresponding OpenGL classes in \l{Qt GUI}. + \warning This module should not be used anymore for new code. OpenGL is a standard API for rendering 3D graphics. OpenGL only deals with 3D rendering and provides little or no support for GUI @@ -48,9 +47,6 @@ the United States and other countries. The Qt OpenGL module makes it easy to use OpenGL in Qt applications. - It provides an OpenGL widget class that can be used just like any - other Qt widget, except that it opens an OpenGL display buffer where - you can use the OpenGL API to render the contents. To include the definitions of the module's classes, use the following directive: @@ -63,11 +59,4 @@ \snippet code/doc_src_qtopengl.pro 1 \endif - - The Qt OpenGL module is implemented as a platform-independent Qt/C++ - wrapper around the platform-dependent GLX (version 1.3 or later), - WGL, or AGL C APIs. Although the basic functionality provided is very - similar to Mark Kilgard's GLUT library, applications using the Qt - OpenGL module can take advantage of the whole Qt API for - non-OpenGL-specific GUI functionality. */ diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp b/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp deleted file mode 100644 index 979ea19fee..0000000000 --- a/src/opengl/gl2paintengineex/qgl2pexvertexarray.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgl2pexvertexarray_p.h" - -#include <private/qbezier_p.h> - -QT_BEGIN_NAMESPACE - -void QGL2PEXVertexArray::clear() -{ - vertexArray.reset(); - vertexArrayStops.reset(); - boundingRectDirty = true; -} - - -QGLRect QGL2PEXVertexArray::boundingRect() const -{ - if (boundingRectDirty) - return QGLRect(0.0, 0.0, 0.0, 0.0); - else - return QGLRect(minX, minY, maxX, maxY); -} - -void QGL2PEXVertexArray::addClosingLine(int index) -{ - QPointF point(vertexArray.at(index)); - if (point != QPointF(vertexArray.last())) - vertexArray.add(point); -} - -void QGL2PEXVertexArray::addCentroid(const QVectorPath &path, int subPathIndex) -{ - const QPointF *const points = reinterpret_cast<const QPointF *>(path.points()); - const QPainterPath::ElementType *const elements = path.elements(); - - QPointF sum = points[subPathIndex]; - int count = 1; - - for (int i = subPathIndex + 1; i < path.elementCount() && (!elements || elements[i] != QPainterPath::MoveToElement); ++i) { - sum += points[i]; - ++count; - } - - const QPointF centroid = sum / qreal(count); - vertexArray.add(centroid); -} - -void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline) -{ - const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); - const QPainterPath::ElementType* const elements = path.elements(); - - if (boundingRectDirty) { - minX = maxX = points[0].x(); - minY = maxY = points[0].y(); - boundingRectDirty = false; - } - - if (!outline && !path.isConvex()) - addCentroid(path, 0); - - int lastMoveTo = vertexArray.size(); - vertexArray.add(points[0]); // The first element is always a moveTo - - do { - if (!elements) { -// qDebug("QVectorPath has no elements"); - // If the path has a null elements pointer, the elements implicitly - // start with a moveTo (already added) and continue with lineTos: - for (int i=1; i<path.elementCount(); ++i) - lineToArray(points[i].x(), points[i].y()); - - break; - } -// qDebug("QVectorPath has element types"); - - for (int i=1; i<path.elementCount(); ++i) { - switch (elements[i]) { - case QPainterPath::MoveToElement: - if (!outline) - addClosingLine(lastMoveTo); -// qDebug("element[%d] is a MoveToElement", i); - vertexArrayStops.add(vertexArray.size()); - if (!outline) { - if (!path.isConvex()) addCentroid(path, i); - lastMoveTo = vertexArray.size(); - } - lineToArray(points[i].x(), points[i].y()); // Add the moveTo as a new vertex - break; - case QPainterPath::LineToElement: -// qDebug("element[%d] is a LineToElement", i); - lineToArray(points[i].x(), points[i].y()); - break; - case QPainterPath::CurveToElement: { - QBezier b = QBezier::fromPoints(*(((const QPointF *) points) + i - 1), - points[i], - points[i+1], - points[i+2]); - QRectF bounds = b.bounds(); - // threshold based on same algorithm as in qtriangulatingstroker.cpp - int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6)); - if (threshold < 3) threshold = 3; - qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1); - for (int t=0; t<threshold; ++t) { - QPointF pt = b.pointAt(t * one_over_threshold_minus_1); - lineToArray(pt.x(), pt.y()); - } - i += 2; - break; } - default: - break; - } - } - } while (0); - - if (!outline) - addClosingLine(lastMoveTo); - vertexArrayStops.add(vertexArray.size()); -} - -void QGL2PEXVertexArray::lineToArray(const GLfloat x, const GLfloat y) -{ - vertexArray.add(QGLPoint(x, y)); - - if (x > maxX) - maxX = x; - else if (x < minX) - minX = x; - if (y > maxY) - maxY = y; - else if (y < minY) - minY = y; -} - -QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h b/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h deleted file mode 100644 index 5c95268790..0000000000 --- a/src/opengl/gl2paintengineex/qgl2pexvertexarray_p.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QGL2PEXVERTEXARRAY_P_H -#define QGL2PEXVERTEXARRAY_P_H - -#include <QRectF> - -#include <private/qdatabuffer_p.h> -#include <private/qvectorpath_p.h> -#include <private/qgl_p.h> - -QT_BEGIN_NAMESPACE - -class QGLPoint -{ -public: - QGLPoint(GLfloat new_x, GLfloat new_y) : - x(new_x), y(new_y) {}; - - QGLPoint(const QPointF &p) : - x(p.x()), y(p.y()) {}; - - QGLPoint(const QPointF* p) : - x(p->x()), y(p->y()) {}; - - GLfloat x; - GLfloat y; - - operator QPointF() {return QPointF(x,y);} - operator QPointF() const {return QPointF(x,y);} -}; - -struct QGLRect -{ - QGLRect(const QRectF &r) - : left(r.left()), top(r.top()), right(r.right()), bottom(r.bottom()) {} - - QGLRect(GLfloat l, GLfloat t, GLfloat r, GLfloat b) - : left(l), top(t), right(r), bottom(b) {} - - GLfloat left; - GLfloat top; - GLfloat right; - GLfloat bottom; - - operator QRectF() const {return QRectF(left, top, right-left, bottom-top);} -}; - -class QGL2PEXVertexArray -{ -public: - QGL2PEXVertexArray() : - vertexArray(0), vertexArrayStops(0), - maxX(-2e10), maxY(-2e10), minX(2e10), minY(2e10), - boundingRectDirty(true) - { } - - inline void addRect(const QRectF &rect) - { - qreal top = rect.top(); - qreal left = rect.left(); - qreal bottom = rect.bottom(); - qreal right = rect.right(); - - vertexArray << QGLPoint(left, top) - << QGLPoint(right, top) - << QGLPoint(right, bottom) - << QGLPoint(right, bottom) - << QGLPoint(left, bottom) - << QGLPoint(left, top); - } - - inline void addQuad(const QRectF &rect) - { - qreal top = rect.top(); - qreal left = rect.left(); - qreal bottom = rect.bottom(); - qreal right = rect.right(); - - vertexArray << QGLPoint(left, top) - << QGLPoint(right, top) - << QGLPoint(left, bottom) - << QGLPoint(right, bottom); - - } - - inline void addVertex(const GLfloat x, const GLfloat y) - { - vertexArray.add(QGLPoint(x, y)); - } - - void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline = true); - void clear(); - - QGLPoint* data() {return vertexArray.data();} - int *stops() const { return vertexArrayStops.data(); } - int stopCount() const { return vertexArrayStops.size(); } - QGLRect boundingRect() const; - - int vertexCount() const { return vertexArray.size(); } - - void lineToArray(const GLfloat x, const GLfloat y); - -private: - QDataBuffer<QGLPoint> vertexArray; - QDataBuffer<int> vertexArrayStops; - - GLfloat maxX; - GLfloat maxY; - GLfloat minX; - GLfloat minY; - bool boundingRectDirty; - void addClosingLine(int index); - void addCentroid(const QVectorPath &path, int subPathIndex); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp b/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp deleted file mode 100644 index 7d6d4595ba..0000000000 --- a/src/opengl/gl2paintengineex/qglcustomshaderstage.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglcustomshaderstage_p.h" -#include "qglengineshadermanager_p.h" -#include "qpaintengineex_opengl2_p.h" -#include <private/qpainter_p.h> - -QT_BEGIN_NAMESPACE - -class QGLCustomShaderStagePrivate -{ -public: - QGLCustomShaderStagePrivate() : - m_manager(0) {} - - QPointer<QGLEngineShaderManager> m_manager; - QByteArray m_source; -}; - - - - -QGLCustomShaderStage::QGLCustomShaderStage() - : d_ptr(new QGLCustomShaderStagePrivate) -{ -} - -QGLCustomShaderStage::~QGLCustomShaderStage() -{ - Q_D(QGLCustomShaderStage); - if (d->m_manager) { - d->m_manager->removeCustomStage(); - d->m_manager->sharedShaders->cleanupCustomStage(this); - } - delete d_ptr; -} - -void QGLCustomShaderStage::setUniformsDirty() -{ - Q_D(QGLCustomShaderStage); - if (d->m_manager) - d->m_manager->setDirty(); // ### Probably a bit overkill! -} - -bool QGLCustomShaderStage::setOnPainter(QPainter* p) -{ - Q_D(QGLCustomShaderStage); - if (p->paintEngine()->type() != QPaintEngine::OpenGL2) { - qWarning("QGLCustomShaderStage::setOnPainter() - paint engine not OpenGL2"); - return false; - } - if (d->m_manager) - qWarning("Custom shader is already set on a painter"); - - QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx*>(p->paintEngine()); - d->m_manager = QGL2PaintEngineExPrivate::shaderManagerForEngine(engine); - Q_ASSERT(d->m_manager); - - d->m_manager->setCustomStage(this); - return true; -} - -void QGLCustomShaderStage::removeFromPainter(QPainter* p) -{ - Q_D(QGLCustomShaderStage); - if (p->paintEngine()->type() != QPaintEngine::OpenGL2) - return; - - QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx*>(p->paintEngine()); - d->m_manager = QGL2PaintEngineExPrivate::shaderManagerForEngine(engine); - Q_ASSERT(d->m_manager); - - // Just set the stage to null, don't call removeCustomStage(). - // This should leave the program in a compiled/linked state - // if the next custom shader stage is this one again. - d->m_manager->setCustomStage(0); - d->m_manager = 0; -} - -QByteArray QGLCustomShaderStage::source() const -{ - Q_D(const QGLCustomShaderStage); - return d->m_source; -} - -// Called by the shader manager if another custom shader is attached or -// the manager is deleted -void QGLCustomShaderStage::setInactive() -{ - Q_D(QGLCustomShaderStage); - d->m_manager = 0; -} - -void QGLCustomShaderStage::setSource(const QByteArray& s) -{ - Q_D(QGLCustomShaderStage); - d->m_source = s; -} - -QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h b/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h deleted file mode 100644 index 77421ebdd3..0000000000 --- a/src/opengl/gl2paintengineex/qglcustomshaderstage_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGL_CUSTOM_SHADER_STAGE_H -#define QGL_CUSTOM_SHADER_STAGE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QGLShaderProgram> - -QT_BEGIN_NAMESPACE - - -class QGLCustomShaderStagePrivate; -class Q_OPENGL_EXPORT QGLCustomShaderStage -{ - Q_DECLARE_PRIVATE(QGLCustomShaderStage) -public: - QGLCustomShaderStage(); - virtual ~QGLCustomShaderStage(); - virtual void setUniforms(QGLShaderProgram*) {} - - void setUniformsDirty(); - - bool setOnPainter(QPainter*); - void removeFromPainter(QPainter*); - QByteArray source() const; - - void setInactive(); -protected: - void setSource(const QByteArray&); - -private: - QGLCustomShaderStagePrivate* d_ptr; -}; - - -QT_END_NAMESPACE - - -#endif diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp deleted file mode 100644 index 47e8531959..0000000000 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ /dev/null @@ -1,875 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglengineshadermanager_p.h" -#include "qglengineshadersource_p.h" -#include "qpaintengineex_opengl2_p.h" -#include "qglshadercache_p.h" - -#include <QtGui/private/qopenglcontext_p.h> - -#if defined(QT_DEBUG) -#include <QMetaEnum> -#endif - -#include <algorithm> - -// #define QT_GL_SHARED_SHADER_DEBUG - -QT_BEGIN_NAMESPACE - -class QGLEngineSharedShadersResource : public QOpenGLSharedResource -{ -public: - QGLEngineSharedShadersResource(QOpenGLContext *ctx) - : QOpenGLSharedResource(ctx->shareGroup()) - , m_shaders(new QGLEngineSharedShaders(QGLContext::fromOpenGLContext(ctx))) - { - } - - ~QGLEngineSharedShadersResource() - { - delete m_shaders; - } - - void invalidateResource() override - { - delete m_shaders; - m_shaders = 0; - } - - void freeResource(QOpenGLContext *) override - { - } - - QGLEngineSharedShaders *shaders() const { return m_shaders; } - -private: - QGLEngineSharedShaders *m_shaders; -}; - -class QGLShaderStorage -{ -public: - QGLEngineSharedShaders *shadersForThread(const QGLContext *context) { - QOpenGLMultiGroupSharedResource *&shaders = m_storage.localData(); - if (!shaders) - shaders = new QOpenGLMultiGroupSharedResource; - QGLEngineSharedShadersResource *resource = - shaders->value<QGLEngineSharedShadersResource>(context->contextHandle()); - return resource ? resource->shaders() : 0; - } - -private: - QThreadStorage<QOpenGLMultiGroupSharedResource *> m_storage; -}; - -Q_GLOBAL_STATIC(QGLShaderStorage, qt_shader_storage); - -QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLContext *context) -{ - return qt_shader_storage()->shadersForThread(context); -} - -const char* QGLEngineSharedShaders::qShaderSnippets[] = { - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0 -}; - -QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) - : blitShaderProg(0) - , simpleShaderProg(0) -{ - -/* - Rather than having the shader source array statically initialised, it is initialised - here instead. This is to allow new shader names to be inserted or existing names moved - around without having to change the order of the glsl strings. It is hoped this will - make future hard-to-find runtime bugs more obvious and generally give more solid code. -*/ - static bool snippetsPopulated = false; - if (!snippetsPopulated) { - - const char** code = qShaderSnippets; // shortcut - - code[MainVertexShader] = qglslMainVertexShader; - code[MainWithTexCoordsVertexShader] = qglslMainWithTexCoordsVertexShader; - code[MainWithTexCoordsAndOpacityVertexShader] = qglslMainWithTexCoordsAndOpacityVertexShader; - - code[UntransformedPositionVertexShader] = qglslUntransformedPositionVertexShader; - code[PositionOnlyVertexShader] = qglslPositionOnlyVertexShader; - code[ComplexGeometryPositionOnlyVertexShader] = qglslComplexGeometryPositionOnlyVertexShader; - code[PositionWithPatternBrushVertexShader] = qglslPositionWithPatternBrushVertexShader; - code[PositionWithLinearGradientBrushVertexShader] = qglslPositionWithLinearGradientBrushVertexShader; - code[PositionWithConicalGradientBrushVertexShader] = qglslPositionWithConicalGradientBrushVertexShader; - code[PositionWithRadialGradientBrushVertexShader] = qglslPositionWithRadialGradientBrushVertexShader; - code[PositionWithTextureBrushVertexShader] = qglslPositionWithTextureBrushVertexShader; - code[AffinePositionWithPatternBrushVertexShader] = qglslAffinePositionWithPatternBrushVertexShader; - code[AffinePositionWithLinearGradientBrushVertexShader] = qglslAffinePositionWithLinearGradientBrushVertexShader; - code[AffinePositionWithConicalGradientBrushVertexShader] = qglslAffinePositionWithConicalGradientBrushVertexShader; - code[AffinePositionWithRadialGradientBrushVertexShader] = qglslAffinePositionWithRadialGradientBrushVertexShader; - code[AffinePositionWithTextureBrushVertexShader] = qglslAffinePositionWithTextureBrushVertexShader; - - code[MainFragmentShader_CMO] = qglslMainFragmentShader_CMO; - code[MainFragmentShader_CM] = qglslMainFragmentShader_CM; - code[MainFragmentShader_MO] = qglslMainFragmentShader_MO; - code[MainFragmentShader_M] = qglslMainFragmentShader_M; - code[MainFragmentShader_CO] = qglslMainFragmentShader_CO; - code[MainFragmentShader_C] = qglslMainFragmentShader_C; - code[MainFragmentShader_O] = qglslMainFragmentShader_O; - code[MainFragmentShader] = qglslMainFragmentShader; - code[MainFragmentShader_ImageArrays] = qglslMainFragmentShader_ImageArrays; - - code[ImageSrcFragmentShader] = qglslImageSrcFragmentShader; - code[ImageSrcWithPatternFragmentShader] = qglslImageSrcWithPatternFragmentShader; - code[NonPremultipliedImageSrcFragmentShader] = qglslNonPremultipliedImageSrcFragmentShader; - code[CustomImageSrcFragmentShader] = qglslCustomSrcFragmentShader; // Calls "customShader", which must be appended - code[SolidBrushSrcFragmentShader] = qglslSolidBrushSrcFragmentShader; - if (!context->contextHandle()->isOpenGLES()) - code[TextureBrushSrcFragmentShader] = qglslTextureBrushSrcFragmentShader_desktop; - else - code[TextureBrushSrcFragmentShader] = qglslTextureBrushSrcFragmentShader_ES; - code[TextureBrushSrcWithPatternFragmentShader] = qglslTextureBrushSrcWithPatternFragmentShader; - code[PatternBrushSrcFragmentShader] = qglslPatternBrushSrcFragmentShader; - code[LinearGradientBrushSrcFragmentShader] = qglslLinearGradientBrushSrcFragmentShader; - code[RadialGradientBrushSrcFragmentShader] = qglslRadialGradientBrushSrcFragmentShader; - code[ConicalGradientBrushSrcFragmentShader] = qglslConicalGradientBrushSrcFragmentShader; - code[ShockingPinkSrcFragmentShader] = qglslShockingPinkSrcFragmentShader; - - code[NoMaskFragmentShader] = ""; - code[MaskFragmentShader] = qglslMaskFragmentShader; - code[RgbMaskFragmentShaderPass1] = qglslRgbMaskFragmentShaderPass1; - code[RgbMaskFragmentShaderPass2] = qglslRgbMaskFragmentShaderPass2; - code[RgbMaskWithGammaFragmentShader] = ""; //### - - code[NoCompositionModeFragmentShader] = ""; - code[MultiplyCompositionModeFragmentShader] = ""; //### - code[ScreenCompositionModeFragmentShader] = ""; //### - code[OverlayCompositionModeFragmentShader] = ""; //### - code[DarkenCompositionModeFragmentShader] = ""; //### - code[LightenCompositionModeFragmentShader] = ""; //### - code[ColorDodgeCompositionModeFragmentShader] = ""; //### - code[ColorBurnCompositionModeFragmentShader] = ""; //### - code[HardLightCompositionModeFragmentShader] = ""; //### - code[SoftLightCompositionModeFragmentShader] = ""; //### - code[DifferenceCompositionModeFragmentShader] = ""; //### - code[ExclusionCompositionModeFragmentShader] = ""; //### - -#if defined(QT_DEBUG) - // Check that all the elements have been filled: - for (int i = 0; i < TotalSnippetCount; ++i) { - if (Q_UNLIKELY(!qShaderSnippets[i])) { - qFatal("Shader snippet for %s (#%d) is missing!", - snippetNameStr(SnippetName(i)).constData(), i); - } - } -#endif - snippetsPopulated = true; - } - - QGLShader* fragShader; - QGLShader* vertexShader; - QByteArray vertexSource; - QByteArray fragSource; - - // Compile up the simple shader: - vertexSource.append(qShaderSnippets[MainVertexShader]); - vertexSource.append(qShaderSnippets[PositionOnlyVertexShader]); - - fragSource.append(qShaderSnippets[MainFragmentShader]); - fragSource.append(qShaderSnippets[ShockingPinkSrcFragmentShader]); - - simpleShaderProg = new QGLShaderProgram(context, 0); - - CachedShader simpleShaderCache(fragSource, vertexSource); - - bool inCache = simpleShaderCache.load(simpleShaderProg, context); - - if (!inCache) { - vertexShader = new QGLShader(QGLShader::Vertex, context, 0); - shaders.append(vertexShader); - if (!vertexShader->compileSourceCode(vertexSource)) - qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile"); - - fragShader = new QGLShader(QGLShader::Fragment, context, 0); - shaders.append(fragShader); - if (!fragShader->compileSourceCode(fragSource)) - qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile"); - - simpleShaderProg->addShader(vertexShader); - simpleShaderProg->addShader(fragShader); - - simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); - simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); - simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); - simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); - } - - simpleShaderProg->link(); - - if (Q_UNLIKELY(!simpleShaderProg->isLinked())) { - qCritical("Errors linking simple shader: %s", qPrintable(simpleShaderProg->log())); - } else { - if (!inCache) - simpleShaderCache.store(simpleShaderProg, context); - } - - // Compile the blit shader: - vertexSource.clear(); - vertexSource.append(qShaderSnippets[MainWithTexCoordsVertexShader]); - vertexSource.append(qShaderSnippets[UntransformedPositionVertexShader]); - - fragSource.clear(); - fragSource.append(qShaderSnippets[MainFragmentShader]); - fragSource.append(qShaderSnippets[ImageSrcFragmentShader]); - - blitShaderProg = new QGLShaderProgram(context, 0); - - CachedShader blitShaderCache(fragSource, vertexSource); - - inCache = blitShaderCache.load(blitShaderProg, context); - - if (!inCache) { - vertexShader = new QGLShader(QGLShader::Vertex, context, 0); - shaders.append(vertexShader); - if (!vertexShader->compileSourceCode(vertexSource)) - qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile"); - - fragShader = new QGLShader(QGLShader::Fragment, context, 0); - shaders.append(fragShader); - if (!fragShader->compileSourceCode(fragSource)) - qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile"); - - blitShaderProg->addShader(vertexShader); - blitShaderProg->addShader(fragShader); - - blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); - blitShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); - } - - blitShaderProg->link(); - if (Q_UNLIKELY(!blitShaderProg->isLinked())) { - qCritical("Errors linking blit shader: %s", qPrintable(blitShaderProg->log())); - } else { - if (!inCache) - blitShaderCache.store(blitShaderProg, context); - } - -#ifdef QT_GL_SHARED_SHADER_DEBUG - qDebug(" -> QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread()); -#endif -} - -QGLEngineSharedShaders::~QGLEngineSharedShaders() -{ -#ifdef QT_GL_SHARED_SHADER_DEBUG - qDebug(" -> ~QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread()); -#endif - qDeleteAll(shaders); - shaders.clear(); - - qDeleteAll(cachedPrograms); - cachedPrograms.clear(); - - if (blitShaderProg) { - delete blitShaderProg; - blitShaderProg = 0; - } - - if (simpleShaderProg) { - delete simpleShaderProg; - simpleShaderProg = 0; - } -} - -#if defined (QT_DEBUG) -QByteArray QGLEngineSharedShaders::snippetNameStr(SnippetName name) -{ - QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("SnippetName")); - return QByteArray(m.valueToKey(name)); -} -#endif - -// The address returned here will only be valid until next time this function is called. -// The program is return bound. -QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineShaderProg &prog) -{ - for (int i = 0; i < cachedPrograms.size(); ++i) { - QGLEngineShaderProg *cachedProg = cachedPrograms.at(i); - if (*cachedProg == prog) { - // Move the program to the top of the list as a poor-man's cache algo - cachedPrograms.move(i, 0); - cachedProg->program->bind(); - return cachedProg; - } - } - - QScopedPointer<QGLEngineShaderProg> newProg; - - do { - QByteArray fragSource; - // Insert the custom stage before the srcPixel shader to work around an ATI driver bug - // where you cannot forward declare a function that takes a sampler as argument. - if (prog.srcPixelFragShader == CustomImageSrcFragmentShader) - fragSource.append(prog.customStageSource); - fragSource.append(qShaderSnippets[prog.mainFragShader]); - fragSource.append(qShaderSnippets[prog.srcPixelFragShader]); - if (prog.compositionFragShader) - fragSource.append(qShaderSnippets[prog.compositionFragShader]); - if (prog.maskFragShader) - fragSource.append(qShaderSnippets[prog.maskFragShader]); - - QByteArray vertexSource; - vertexSource.append(qShaderSnippets[prog.mainVertexShader]); - vertexSource.append(qShaderSnippets[prog.positionVertexShader]); - - QScopedPointer<QGLShaderProgram> shaderProgram(new QGLShaderProgram); - - CachedShader shaderCache(fragSource, vertexSource); - bool inCache = shaderCache.load(shaderProgram.data(), QGLContext::currentContext()); - - if (!inCache) { - - QScopedPointer<QGLShader> fragShader(new QGLShader(QGLShader::Fragment)); - QByteArray description; -#if defined(QT_DEBUG) - // Name the shader for easier debugging - description.append("Fragment shader: main="); - description.append(snippetNameStr(prog.mainFragShader)); - description.append(", srcPixel="); - description.append(snippetNameStr(prog.srcPixelFragShader)); - if (prog.compositionFragShader) { - description.append(", composition="); - description.append(snippetNameStr(prog.compositionFragShader)); - } - if (prog.maskFragShader) { - description.append(", mask="); - description.append(snippetNameStr(prog.maskFragShader)); - } - fragShader->setObjectName(QString::fromLatin1(description)); -#endif - if (!fragShader->compileSourceCode(fragSource)) { - qWarning() << "Warning:" << description << "failed to compile!"; - break; - } - - QScopedPointer<QGLShader> vertexShader(new QGLShader(QGLShader::Vertex)); -#if defined(QT_DEBUG) - // Name the shader for easier debugging - description.clear(); - description.append("Vertex shader: main="); - description.append(snippetNameStr(prog.mainVertexShader)); - description.append(", position="); - description.append(snippetNameStr(prog.positionVertexShader)); - vertexShader->setObjectName(QString::fromLatin1(description)); -#endif - if (!vertexShader->compileSourceCode(vertexSource)) { - qWarning() << "Warning:" << description << "failed to compile!"; - break; - } - - shaders.append(vertexShader.data()); - shaders.append(fragShader.data()); - shaderProgram->addShader(vertexShader.take()); - shaderProgram->addShader(fragShader.take()); - - // We have to bind the vertex attribute names before the program is linked: - shaderProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); - if (prog.useTextureCoords) - shaderProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); - if (prog.useOpacityAttribute) - shaderProgram->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR); - if (prog.usePmvMatrixAttribute) { - shaderProgram->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); - shaderProgram->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); - shaderProgram->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); - } - } - - newProg.reset(new QGLEngineShaderProg(prog)); - newProg->program = shaderProgram.take(); - - newProg->program->link(); - if (newProg->program->isLinked()) { - if (!inCache) - shaderCache.store(newProg->program, QGLContext::currentContext()); - } else { - QString error; - error = QLatin1String("Shader program failed to link,"); -#if defined(QT_DEBUG) - QLatin1String br("\n"); - error += QLatin1String("\n Shaders Used:\n"); - for (int i = 0; i < newProg->program->shaders().count(); ++i) { - QGLShader *shader = newProg->program->shaders().at(i); - error += QLatin1String(" ") + shader->objectName() + QLatin1String(": \n") - + QLatin1String(shader->sourceCode()) + br; - } -#endif - error += QLatin1String(" Error Log:\n") - + QLatin1String(" ") + newProg->program->log(); - qWarning() << error; - break; - } - - newProg->program->bind(); - - if (newProg->maskFragShader != QGLEngineSharedShaders::NoMaskFragmentShader) { - GLuint location = newProg->program->uniformLocation("maskTexture"); - newProg->program->setUniformValue(location, QT_MASK_TEXTURE_UNIT); - } - - if (cachedPrograms.count() > 30) { - // The cache is full, so delete the last 5 programs in the list. - // These programs will be least used, as a program us bumped to - // the top of the list when it's used. - for (int i = 0; i < 5; ++i) { - delete cachedPrograms.last(); - cachedPrograms.removeLast(); - } - } - - cachedPrograms.insert(0, newProg.data()); - } while (false); - - return newProg.take(); -} - -void QGLEngineSharedShaders::cleanupCustomStage(QGLCustomShaderStage* stage) -{ - auto hasStageAsCustomShaderSouce = [stage](QGLEngineShaderProg *cachedProg) -> bool { - if (cachedProg->customStageSource == stage->source()) { - delete cachedProg; - return true; - } - return false; - }; - cachedPrograms.erase(std::remove_if(cachedPrograms.begin(), cachedPrograms.end(), - hasStageAsCustomShaderSouce), - cachedPrograms.end()); -} - - -QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) - : ctx(context), - shaderProgNeedsChanging(true), - complexGeometry(false), - srcPixelType(Qt::NoBrush), - opacityMode(NoOpacity), - maskType(NoMask), - compositionMode(QPainter::CompositionMode_SourceOver), - customSrcStage(0), - currentShaderProg(0) -{ - sharedShaders = QGLEngineSharedShaders::shadersForContext(context); -} - -QGLEngineShaderManager::~QGLEngineShaderManager() -{ - //### - removeCustomStage(); -} - -GLuint QGLEngineShaderManager::getUniformLocation(Uniform id) -{ - if (!currentShaderProg) - return 0; - - QVector<uint> &uniformLocations = currentShaderProg->uniformLocations; - if (uniformLocations.isEmpty()) - uniformLocations.fill(GLuint(-1), NumUniforms); - - static const char *const uniformNames[] = { - "imageTexture", - "patternColor", - "globalOpacity", - "depth", - "maskTexture", - "fragmentColor", - "linearData", - "angle", - "halfViewportSize", - "fmp", - "fmp2_m_radius2", - "inverse_2_fmp2_m_radius2", - "sqrfr", - "bradius", - "invertedTextureSize", - "brushTransform", - "brushTexture", - "matrix", - "translateZ" - }; - - if (uniformLocations.at(id) == GLuint(-1)) - uniformLocations[id] = currentShaderProg->program->uniformLocation(uniformNames[id]); - - return uniformLocations.at(id); -} - - -void QGLEngineShaderManager::optimiseForBrushTransform(QTransform::TransformationType transformType) -{ - Q_UNUSED(transformType); // Currently ignored -} - -void QGLEngineShaderManager::setDirty() -{ - shaderProgNeedsChanging = true; -} - -void QGLEngineShaderManager::setSrcPixelType(Qt::BrushStyle style) -{ - Q_ASSERT(style != Qt::NoBrush); - if (srcPixelType == PixelSrcType(style)) - return; - - srcPixelType = style; - shaderProgNeedsChanging = true; //### -} - -void QGLEngineShaderManager::setSrcPixelType(PixelSrcType type) -{ - if (srcPixelType == type) - return; - - srcPixelType = type; - shaderProgNeedsChanging = true; //### -} - -void QGLEngineShaderManager::setOpacityMode(OpacityMode mode) -{ - if (opacityMode == mode) - return; - - opacityMode = mode; - shaderProgNeedsChanging = true; //### -} - -void QGLEngineShaderManager::setMaskType(MaskType type) -{ - if (maskType == type) - return; - - maskType = type; - shaderProgNeedsChanging = true; //### -} - -void QGLEngineShaderManager::setCompositionMode(QPainter::CompositionMode mode) -{ - if (compositionMode == mode) - return; - - compositionMode = mode; - shaderProgNeedsChanging = true; //### -} - -void QGLEngineShaderManager::setCustomStage(QGLCustomShaderStage* stage) -{ - if (customSrcStage) - removeCustomStage(); - customSrcStage = stage; - shaderProgNeedsChanging = true; -} - -void QGLEngineShaderManager::removeCustomStage() -{ - if (customSrcStage) - customSrcStage->setInactive(); - customSrcStage = 0; - shaderProgNeedsChanging = true; -} - -QGLShaderProgram* QGLEngineShaderManager::currentProgram() -{ - if (currentShaderProg) - return currentShaderProg->program; - else - return sharedShaders->simpleProgram(); -} - -void QGLEngineShaderManager::useSimpleProgram() -{ - sharedShaders->simpleProgram()->bind(); - QGLContextPrivate* ctx_d = ctx->d_func(); - ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); - ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); - shaderProgNeedsChanging = true; -} - -void QGLEngineShaderManager::useBlitProgram() -{ - sharedShaders->blitProgram()->bind(); - QGLContextPrivate* ctx_d = ctx->d_func(); - ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); - shaderProgNeedsChanging = true; -} - -QGLShaderProgram* QGLEngineShaderManager::simpleProgram() -{ - return sharedShaders->simpleProgram(); -} - -QGLShaderProgram* QGLEngineShaderManager::blitProgram() -{ - return sharedShaders->blitProgram(); -} - - - -// Select & use the correct shader program using the current state. -// Returns \c true if program needed changing. -bool QGLEngineShaderManager::useCorrectShaderProg() -{ - if (!shaderProgNeedsChanging) - return false; - - bool useCustomSrc = customSrcStage != 0; - if (useCustomSrc && srcPixelType != QGLEngineShaderManager::ImageSrc && srcPixelType != Qt::TexturePattern) { - useCustomSrc = false; - qWarning("QGLEngineShaderManager - Ignoring custom shader stage for non image src"); - } - - QGLEngineShaderProg requiredProgram; - - bool texCoords = false; - - // Choose vertex shader shader position function (which typically also sets - // varyings) and the source pixel (srcPixel) fragment shader function: - requiredProgram.positionVertexShader = QGLEngineSharedShaders::InvalidSnippetName; - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::InvalidSnippetName; - bool isAffine = brushTransform.isAffine(); - if ( (srcPixelType >= Qt::Dense1Pattern) && (srcPixelType <= Qt::DiagCrossPattern) ) { - if (isAffine) - requiredProgram.positionVertexShader = QGLEngineSharedShaders::AffinePositionWithPatternBrushVertexShader; - else - requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionWithPatternBrushVertexShader; - - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::PatternBrushSrcFragmentShader; - } - else switch (srcPixelType) { - default: - case Qt::NoBrush: - qFatal("QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set"); - break; - case QGLEngineShaderManager::ImageSrc: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::ImageSrcFragmentShader; - requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; - texCoords = true; - break; - case QGLEngineShaderManager::NonPremultipliedImageSrc: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::NonPremultipliedImageSrcFragmentShader; - requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; - texCoords = true; - break; - case QGLEngineShaderManager::PatternSrc: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::ImageSrcWithPatternFragmentShader; - requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; - texCoords = true; - break; - case QGLEngineShaderManager::TextureSrcWithPattern: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::TextureBrushSrcWithPatternFragmentShader; - requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader - : QGLEngineSharedShaders::PositionWithTextureBrushVertexShader; - break; - case Qt::SolidPattern: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::SolidBrushSrcFragmentShader; - requiredProgram.positionVertexShader = QGLEngineSharedShaders::PositionOnlyVertexShader; - break; - case Qt::LinearGradientPattern: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::LinearGradientBrushSrcFragmentShader; - requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithLinearGradientBrushVertexShader - : QGLEngineSharedShaders::PositionWithLinearGradientBrushVertexShader; - break; - case Qt::ConicalGradientPattern: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::ConicalGradientBrushSrcFragmentShader; - requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithConicalGradientBrushVertexShader - : QGLEngineSharedShaders::PositionWithConicalGradientBrushVertexShader; - break; - case Qt::RadialGradientPattern: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::RadialGradientBrushSrcFragmentShader; - requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithRadialGradientBrushVertexShader - : QGLEngineSharedShaders::PositionWithRadialGradientBrushVertexShader; - break; - case Qt::TexturePattern: - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::TextureBrushSrcFragmentShader; - requiredProgram.positionVertexShader = isAffine ? QGLEngineSharedShaders::AffinePositionWithTextureBrushVertexShader - : QGLEngineSharedShaders::PositionWithTextureBrushVertexShader; - break; - }; - - if (useCustomSrc) { - requiredProgram.srcPixelFragShader = QGLEngineSharedShaders::CustomImageSrcFragmentShader; - requiredProgram.customStageSource = customSrcStage->source(); - } - - const bool hasCompose = compositionMode > QPainter::CompositionMode_Plus; - const bool hasMask = maskType != QGLEngineShaderManager::NoMask; - - // Choose fragment shader main function: - if (opacityMode == AttributeOpacity) { - Q_ASSERT(!hasCompose && !hasMask); - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_ImageArrays; - } else { - bool useGlobalOpacity = (opacityMode == UniformOpacity); - if (hasCompose && hasMask && useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_CMO; - if (hasCompose && hasMask && !useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_CM; - if (!hasCompose && hasMask && useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_MO; - if (!hasCompose && hasMask && !useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_M; - if (hasCompose && !hasMask && useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_CO; - if (hasCompose && !hasMask && !useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_C; - if (!hasCompose && !hasMask && useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader_O; - if (!hasCompose && !hasMask && !useGlobalOpacity) - requiredProgram.mainFragShader = QGLEngineSharedShaders::MainFragmentShader; - } - - if (hasMask) { - if (maskType == PixelMask) { - requiredProgram.maskFragShader = QGLEngineSharedShaders::MaskFragmentShader; - texCoords = true; - } else if (maskType == SubPixelMaskPass1) { - requiredProgram.maskFragShader = QGLEngineSharedShaders::RgbMaskFragmentShaderPass1; - texCoords = true; - } else if (maskType == SubPixelMaskPass2) { - requiredProgram.maskFragShader = QGLEngineSharedShaders::RgbMaskFragmentShaderPass2; - texCoords = true; - } else if (maskType == SubPixelWithGammaMask) { - requiredProgram.maskFragShader = QGLEngineSharedShaders::RgbMaskWithGammaFragmentShader; - texCoords = true; - } else { - qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type"); - } - } else { - requiredProgram.maskFragShader = QGLEngineSharedShaders::NoMaskFragmentShader; - } - - if (hasCompose) { - switch (compositionMode) { - case QPainter::CompositionMode_Multiply: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::MultiplyCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_Screen: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::ScreenCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_Overlay: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::OverlayCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_Darken: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::DarkenCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_Lighten: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::LightenCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_ColorDodge: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::ColorDodgeCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_ColorBurn: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::ColorBurnCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_HardLight: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::HardLightCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_SoftLight: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::SoftLightCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_Difference: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::DifferenceCompositionModeFragmentShader; - break; - case QPainter::CompositionMode_Exclusion: - requiredProgram.compositionFragShader = QGLEngineSharedShaders::ExclusionCompositionModeFragmentShader; - break; - default: - qWarning("QGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode"); - } - } else { - requiredProgram.compositionFragShader = QGLEngineSharedShaders::NoCompositionModeFragmentShader; - } - - // Choose vertex shader main function - if (opacityMode == AttributeOpacity) { - Q_ASSERT(texCoords); - requiredProgram.mainVertexShader = QGLEngineSharedShaders::MainWithTexCoordsAndOpacityVertexShader; - } else if (texCoords) { - requiredProgram.mainVertexShader = QGLEngineSharedShaders::MainWithTexCoordsVertexShader; - } else { - requiredProgram.mainVertexShader = QGLEngineSharedShaders::MainVertexShader; - } - requiredProgram.useTextureCoords = texCoords; - requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity); - if (complexGeometry && srcPixelType == Qt::SolidPattern) { - requiredProgram.positionVertexShader = QGLEngineSharedShaders::ComplexGeometryPositionOnlyVertexShader; - requiredProgram.usePmvMatrixAttribute = false; - } else { - requiredProgram.usePmvMatrixAttribute = true; - - // Force complexGeometry off, since we currently don't support that mode for - // non-solid brushes - complexGeometry = false; - } - - // At this point, requiredProgram is fully populated so try to find the program in the cache - currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); - - if (currentShaderProg && useCustomSrc) { - customSrcStage->setUniforms(currentShaderProg->program); - } - - // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it - // doesn't use are disabled) - QGLContextPrivate* ctx_d = ctx->d_func(); - ctx_d->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, true); - ctx_d->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, currentShaderProg && currentShaderProg->useTextureCoords); - ctx_d->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, currentShaderProg && currentShaderProg->useOpacityAttribute); - - shaderProgNeedsChanging = false; - return true; -} - -QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h deleted file mode 100644 index d23b3ad550..0000000000 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ /dev/null @@ -1,508 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -/* - VERTEX SHADERS - ============== - - Vertex shaders are specified as multiple (partial) shaders. On desktop, - this works fine. On ES, QGLShader & QGLShaderProgram will make partial - shaders work by concatenating the source in each QGLShader and compiling - it as a single shader. This is abstracted nicely by QGLShaderProgram and - the GL2 engine doesn't need to worry about it. - - Generally, there's two vertex shader objects. The position shaders are - the ones which set gl_Position. There's also two "main" vertex shaders, - one which just calls the position shader and another which also passes - through some texture coordinates from a vertex attribute array to a - varying. These texture coordinates are used for mask position in text - rendering and for the source coordinates in drawImage/drawPixmap. There's - also a "Simple" vertex shader for rendering a solid colour (used to render - into the stencil buffer where the actual colour value is discarded). - - The position shaders for brushes look scary. This is because many of the - calculations which logically belong in the fragment shader have been moved - into the vertex shader to improve performance. This is why the position - calculation is in a separate shader. Not only does it calculate the - position, but it also calculates some data to be passed to the fragment - shader as a varying. It is optimal to move as much of the calculation as - possible into the vertex shader as this is executed less often. - - The varyings passed to the fragment shaders are interpolated (which is - cheap). Unfortunately, GL will apply perspective correction to the - interpolation calusing errors. To get around this, the vertex shader must - apply perspective correction itself and set the w-value of gl_Position to - zero. That way, GL will be tricked into thinking it doesn't need to apply a - perspective correction and use linear interpolation instead (which is what - we want). Of course, if the brush transform is affeine, no perspective - correction is needed and a simpler vertex shader can be used instead. - - So there are the following "main" vertex shaders: - qglslMainVertexShader - qglslMainWithTexCoordsVertexShader - - And the following position vertex shaders: - qglslPositionOnlyVertexShader - qglslPositionWithTextureBrushVertexShader - qglslPositionWithPatternBrushVertexShader - qglslPositionWithLinearGradientBrushVertexShader - qglslPositionWithRadialGradientBrushVertexShader - qglslPositionWithConicalGradientBrushVertexShader - qglslAffinePositionWithTextureBrushVertexShader - qglslAffinePositionWithPatternBrushVertexShader - qglslAffinePositionWithLinearGradientBrushVertexShader - qglslAffinePositionWithRadialGradientBrushVertexShader - qglslAffinePositionWithConicalGradientBrushVertexShader - - Leading to 23 possible vertex shaders - - - FRAGMENT SHADERS - ================ - - Fragment shaders are also specified as multiple (partial) shaders. The - different fragment shaders represent the different stages in Qt's fragment - pipeline. There are 1-3 stages in this pipeline: First stage is to get the - fragment's colour value. The next stage is to get the fragment's mask value - (coverage value for anti-aliasing) and the final stage is to blend the - incoming fragment with the background (for composition modes not supported - by GL). - - Of these, the first stage will always be present. If Qt doesn't need to - apply anti-aliasing (because it's off or handled by multisampling) then - the coverage value doesn't need to be applied. (Note: There are two types - of mask, one for regular anti-aliasing and one for sub-pixel anti- - aliasing.) If the composition mode is one which GL supports natively then - the blending stage doesn't need to be applied. - - As eash stage can have multiple implementations, they are abstracted as - GLSL function calls with the following signatures: - - Brushes & image drawing are implementations of "qcolorp vec4 srcPixel()": - qglslImageSrcFragShader - qglslImageSrcWithPatternFragShader - qglslNonPremultipliedImageSrcFragShader - qglslSolidBrushSrcFragShader - qglslTextureBrushSrcFragShader - qglslTextureBrushWithPatternFragShader - qglslPatternBrushSrcFragShader - qglslLinearGradientBrushSrcFragShader - qglslRadialGradientBrushSrcFragShader - qglslConicalGradientBrushSrcFragShader - NOTE: It is assumed the colour returned by srcPixel() is pre-multiplied - - Masks are implementations of "qcolorp vec4 applyMask(qcolorp vec4 src)": - qglslMaskFragmentShader - qglslRgbMaskFragmentShaderPass1 - qglslRgbMaskFragmentShaderPass2 - qglslRgbMaskWithGammaFragmentShader - - Composition modes are "qcolorp vec4 compose(qcolorp vec4 src)": - qglslColorBurnCompositionModeFragmentShader - qglslColorDodgeCompositionModeFragmentShader - qglslDarkenCompositionModeFragmentShader - qglslDifferenceCompositionModeFragmentShader - qglslExclusionCompositionModeFragmentShader - qglslHardLightCompositionModeFragmentShader - qglslLightenCompositionModeFragmentShader - qglslMultiplyCompositionModeFragmentShader - qglslOverlayCompositionModeFragmentShader - qglslScreenCompositionModeFragmentShader - qglslSoftLightCompositionModeFragmentShader - - - Note: In the future, some GLSL compilers will support an extension allowing - a new 'color' precision specifier. To support this, qcolorp is used for - all color components so it can be defined to colorp or lowp depending upon - the implementation. - - So there are differnt frament shader main functions, depending on the - number & type of pipelines the fragment needs to go through. - - The choice of which main() fragment shader string to use depends on: - - Use of global opacity - - Brush style (some brushes apply opacity themselves) - - Use & type of mask (TODO: Need to support high quality anti-aliasing & text) - - Use of non-GL Composition mode - - Leading to the following fragment shader main functions: - gl_FragColor = compose(applyMask(srcPixel()*globalOpacity)); - gl_FragColor = compose(applyMask(srcPixel())); - gl_FragColor = applyMask(srcPixel()*globalOpacity); - gl_FragColor = applyMask(srcPixel()); - gl_FragColor = compose(srcPixel()*globalOpacity); - gl_FragColor = compose(srcPixel()); - gl_FragColor = srcPixel()*globalOpacity; - gl_FragColor = srcPixel(); - - Called: - qglslMainFragmentShader_CMO - qglslMainFragmentShader_CM - qglslMainFragmentShader_MO - qglslMainFragmentShader_M - qglslMainFragmentShader_CO - qglslMainFragmentShader_C - qglslMainFragmentShader_O - qglslMainFragmentShader - - Where: - M = Mask - C = Composition - O = Global Opacity - - - CUSTOM SHADER CODE - ================== - - The use of custom shader code is supported by the engine for drawImage and - drawPixmap calls. This is implemented via hooks in the fragment pipeline. - - The custom shader is passed to the engine as a partial fragment shader - (QGLCustomShaderStage). The shader will implement a pre-defined method name - which Qt's fragment pipeline will call: - - lowp vec4 customShader(lowp sampler2d imageTexture, highp vec2 textureCoords) - - The provided src and srcCoords parameters can be used to sample from the - source image. - - Transformations, clipping, opacity, and composition modes set using QPainter - will be respected when using the custom shader hook. -*/ - -#ifndef QGLENGINE_SHADER_MANAGER_H -#define QGLENGINE_SHADER_MANAGER_H - -#include <QGLShader> -#include <QGLShaderProgram> -#include <QPainter> -#include <private/qgl_p.h> -#include <private/qglcustomshaderstage_p.h> - -QT_BEGIN_NAMESPACE - - - -/* -struct QGLEngineCachedShaderProg -{ - QGLEngineCachedShaderProg(QGLEngineShaderManager::ShaderName vertexMain, - QGLEngineShaderManager::ShaderName vertexPosition, - QGLEngineShaderManager::ShaderName fragMain, - QGLEngineShaderManager::ShaderName pixelSrc, - QGLEngineShaderManager::ShaderName mask, - QGLEngineShaderManager::ShaderName composition); - - int cacheKey; - QGLShaderProgram* program; -} -*/ - -static const GLuint QT_VERTEX_COORDS_ATTR = 0; -static const GLuint QT_TEXTURE_COORDS_ATTR = 1; -static const GLuint QT_OPACITY_ATTR = 2; -static const GLuint QT_PMV_MATRIX_1_ATTR = 3; -static const GLuint QT_PMV_MATRIX_2_ATTR = 4; -static const GLuint QT_PMV_MATRIX_3_ATTR = 5; - -class QGLEngineShaderProg; - -class Q_OPENGL_EXPORT QGLEngineSharedShaders -{ - Q_GADGET -public: - - enum SnippetName { - MainVertexShader, - MainWithTexCoordsVertexShader, - MainWithTexCoordsAndOpacityVertexShader, - - // UntransformedPositionVertexShader must be first in the list: - UntransformedPositionVertexShader, - PositionOnlyVertexShader, - ComplexGeometryPositionOnlyVertexShader, - PositionWithPatternBrushVertexShader, - PositionWithLinearGradientBrushVertexShader, - PositionWithConicalGradientBrushVertexShader, - PositionWithRadialGradientBrushVertexShader, - PositionWithTextureBrushVertexShader, - AffinePositionWithPatternBrushVertexShader, - AffinePositionWithLinearGradientBrushVertexShader, - AffinePositionWithConicalGradientBrushVertexShader, - AffinePositionWithRadialGradientBrushVertexShader, - AffinePositionWithTextureBrushVertexShader, - - // MainFragmentShader_CMO must be first in the list: - MainFragmentShader_CMO, - MainFragmentShader_CM, - MainFragmentShader_MO, - MainFragmentShader_M, - MainFragmentShader_CO, - MainFragmentShader_C, - MainFragmentShader_O, - MainFragmentShader, - MainFragmentShader_ImageArrays, - - // ImageSrcFragmentShader must be first in the list:: - ImageSrcFragmentShader, - ImageSrcWithPatternFragmentShader, - NonPremultipliedImageSrcFragmentShader, - CustomImageSrcFragmentShader, - SolidBrushSrcFragmentShader, - TextureBrushSrcFragmentShader, - TextureBrushSrcWithPatternFragmentShader, - PatternBrushSrcFragmentShader, - LinearGradientBrushSrcFragmentShader, - RadialGradientBrushSrcFragmentShader, - ConicalGradientBrushSrcFragmentShader, - ShockingPinkSrcFragmentShader, - - // NoMaskFragmentShader must be first in the list: - NoMaskFragmentShader, - MaskFragmentShader, - RgbMaskFragmentShaderPass1, - RgbMaskFragmentShaderPass2, - RgbMaskWithGammaFragmentShader, - - // NoCompositionModeFragmentShader must be first in the list: - NoCompositionModeFragmentShader, - MultiplyCompositionModeFragmentShader, - ScreenCompositionModeFragmentShader, - OverlayCompositionModeFragmentShader, - DarkenCompositionModeFragmentShader, - LightenCompositionModeFragmentShader, - ColorDodgeCompositionModeFragmentShader, - ColorBurnCompositionModeFragmentShader, - HardLightCompositionModeFragmentShader, - SoftLightCompositionModeFragmentShader, - DifferenceCompositionModeFragmentShader, - ExclusionCompositionModeFragmentShader, - - TotalSnippetCount, InvalidSnippetName - }; -#if defined (QT_DEBUG) - Q_ENUMS(SnippetName) - static QByteArray snippetNameStr(SnippetName snippetName); -#endif - -/* - // These allow the ShaderName enum to be used as a cache key - const int mainVertexOffset = 0; - const int positionVertexOffset = (1<<2) - PositionOnlyVertexShader; - const int mainFragOffset = (1<<6) - MainFragmentShader_CMO; - const int srcPixelOffset = (1<<10) - ImageSrcFragmentShader; - const int maskOffset = (1<<14) - NoMaskShader; - const int compositionOffset = (1 << 16) - MultiplyCompositionModeFragmentShader; -*/ - - QGLEngineSharedShaders(const QGLContext *context); - ~QGLEngineSharedShaders(); - - QGLShaderProgram *simpleProgram() { return simpleShaderProg; } - QGLShaderProgram *blitProgram() { return blitShaderProg; } - // Compile the program if it's not already in the cache, return the item in the cache. - QGLEngineShaderProg *findProgramInCache(const QGLEngineShaderProg &prog); - // Compile the custom shader if it's not already in the cache, return the item in the cache. - - static QGLEngineSharedShaders *shadersForContext(const QGLContext *context); - - // Ideally, this would be static and cleanup all programs in all contexts which - // contain the custom code. Currently it is just a hint and we rely on deleted - // custom shaders being cleaned up by being kicked out of the cache when it's - // full. - void cleanupCustomStage(QGLCustomShaderStage* stage); - -private: - QGLShaderProgram *blitShaderProg; - QGLShaderProgram *simpleShaderProg; - QList<QGLEngineShaderProg*> cachedPrograms; - QList<QGLShader *> shaders; - - static const char* qShaderSnippets[TotalSnippetCount]; -}; - - -class QGLEngineShaderProg -{ -public: - QGLEngineShaderProg() : program(nullptr) {} - - ~QGLEngineShaderProg() { - if (program) - delete program; - } - - QGLEngineSharedShaders::SnippetName mainVertexShader; - QGLEngineSharedShaders::SnippetName positionVertexShader; - QGLEngineSharedShaders::SnippetName mainFragShader; - QGLEngineSharedShaders::SnippetName srcPixelFragShader; - QGLEngineSharedShaders::SnippetName maskFragShader; - QGLEngineSharedShaders::SnippetName compositionFragShader; - - QByteArray customStageSource; //TODO: Decent cache key for custom stages - QGLShaderProgram* program; - - QVector<uint> uniformLocations; - - bool useTextureCoords; - bool useOpacityAttribute; - bool usePmvMatrixAttribute; - - bool operator==(const QGLEngineShaderProg& other) const { - // We don't care about the program - return ( mainVertexShader == other.mainVertexShader && - positionVertexShader == other.positionVertexShader && - mainFragShader == other.mainFragShader && - srcPixelFragShader == other.srcPixelFragShader && - maskFragShader == other.maskFragShader && - compositionFragShader == other.compositionFragShader && - customStageSource == other.customStageSource - ); - } -}; - -class Q_OPENGL_EXPORT QGLEngineShaderManager : public QObject -{ - Q_OBJECT -public: - QGLEngineShaderManager(QGLContext* context); - ~QGLEngineShaderManager(); - - enum MaskType {NoMask, PixelMask, SubPixelMaskPass1, SubPixelMaskPass2, SubPixelWithGammaMask}; - enum PixelSrcType { - ImageSrc = Qt::TexturePattern+1, - NonPremultipliedImageSrc = Qt::TexturePattern+2, - PatternSrc = Qt::TexturePattern+3, - TextureSrcWithPattern = Qt::TexturePattern+4 - }; - - enum Uniform { - ImageTexture, - PatternColor, - GlobalOpacity, - Depth, - MaskTexture, - FragmentColor, - LinearData, - Angle, - HalfViewportSize, - Fmp, - Fmp2MRadius2, - Inverse2Fmp2MRadius2, - SqrFr, - BRadius, - InvertedTextureSize, - BrushTransform, - BrushTexture, - Matrix, - TranslateZ, - NumUniforms - }; - - enum OpacityMode { - NoOpacity, - UniformOpacity, - AttributeOpacity - }; - - // There are optimizations we can do, depending on the brush transform: - // 1) May not have to apply perspective-correction - // 2) Can use lower precision for matrix - void optimiseForBrushTransform(QTransform::TransformationType transformType); - void setSrcPixelType(Qt::BrushStyle); - void setSrcPixelType(PixelSrcType); // For non-brush sources, like pixmaps & images - void setOpacityMode(OpacityMode); - void setMaskType(MaskType); - void setCompositionMode(QPainter::CompositionMode); - void setCustomStage(QGLCustomShaderStage* stage); - void removeCustomStage(); - - GLuint getUniformLocation(Uniform id); - - void setDirty(); // someone has manually changed the current shader program - bool useCorrectShaderProg(); // returns true if the shader program needed to be changed - - void useSimpleProgram(); - void useBlitProgram(); - void setHasComplexGeometry(bool hasComplexGeometry) - { - complexGeometry = hasComplexGeometry; - shaderProgNeedsChanging = true; - } - bool hasComplexGeometry() const - { - return complexGeometry; - } - - QGLShaderProgram* currentProgram(); // Returns pointer to the shader the manager has chosen - QGLShaderProgram* simpleProgram(); // Used to draw into e.g. stencil buffers - QGLShaderProgram* blitProgram(); // Used to blit a texture into the framebuffer - - QGLEngineSharedShaders* sharedShaders; - -private: - QGLContext* ctx; - bool shaderProgNeedsChanging; - bool complexGeometry; - - // Current state variables which influence the choice of shader: - QTransform brushTransform; - int srcPixelType; - OpacityMode opacityMode; - MaskType maskType; - QPainter::CompositionMode compositionMode; - QGLCustomShaderStage* customSrcStage; - - QGLEngineShaderProg* currentShaderProg; -}; - -QT_END_NAMESPACE - -#endif //QGLENGINE_SHADER_MANAGER_H diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h deleted file mode 100644 index a667af9b96..0000000000 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ /dev/null @@ -1,523 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#ifndef QGL_ENGINE_SHADER_SOURCE_H -#define QGL_ENGINE_SHADER_SOURCE_H - -#include "qglengineshadermanager_p.h" - -QT_BEGIN_NAMESPACE - - - -static const char* const qglslMainVertexShader = "\n\ - void setPosition(); \n\ - void main(void) \n\ - { \n\ - setPosition(); \n\ - }\n"; - -static const char* const qglslMainWithTexCoordsVertexShader = "\n\ - attribute highp vec2 textureCoordArray; \n\ - varying highp vec2 textureCoords; \n\ - void setPosition(); \n\ - void main(void) \n\ - { \n\ - setPosition(); \n\ - textureCoords = textureCoordArray; \n\ - }\n"; - -static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\n\ - attribute highp vec2 textureCoordArray; \n\ - attribute lowp float opacityArray; \n\ - varying highp vec2 textureCoords; \n\ - varying lowp float opacity; \n\ - void setPosition(); \n\ - void main(void) \n\ - { \n\ - setPosition(); \n\ - textureCoords = textureCoordArray; \n\ - opacity = opacityArray; \n\ - }\n"; - -// NOTE: We let GL do the perspective correction so texture lookups in the fragment -// shader are also perspective corrected. -static const char* const qglslPositionOnlyVertexShader = "\n\ - attribute highp vec2 vertexCoordsArray; \n\ - attribute highp vec3 pmvMatrix1; \n\ - attribute highp vec3 pmvMatrix2; \n\ - attribute highp vec3 pmvMatrix3; \n\ - void setPosition(void) \n\ - { \n\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ - gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ - }\n"; - -static const char* const qglslComplexGeometryPositionOnlyVertexShader = "\n\ - uniform highp mat3 matrix; \n\ - uniform highp float translateZ; \n\ - attribute highp vec2 vertexCoordsArray; \n\ - void setPosition(void) \n\ - { \n\ - vec3 v = matrix * vec3(vertexCoordsArray, 1.0); \n\ - vec4 vz = mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, translateZ, 1) * vec4(v, 1.0); \n\ - gl_Position = vec4(vz.xyz, 1.0);\n\ - } \n"; - -static const char* const qglslUntransformedPositionVertexShader = "\n\ - attribute highp vec4 vertexCoordsArray; \n\ - void setPosition(void) \n\ - { \n\ - gl_Position = vertexCoordsArray; \n\ - }\n"; - -// Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 -static const char* const qglslPositionWithPatternBrushVertexShader = "\n\ - attribute highp vec2 vertexCoordsArray; \n\ - attribute highp vec3 pmvMatrix1; \n\ - attribute highp vec3 pmvMatrix2; \n\ - attribute highp vec3 pmvMatrix3; \n\ - uniform mediump vec2 halfViewportSize; \n\ - uniform highp vec2 invertedTextureSize; \n\ - uniform highp mat3 brushTransform; \n\ - varying highp vec2 patternTexCoords; \n\ - void setPosition(void) \n\ - { \n\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ - gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ - patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\ - }\n"; - -static const char* const qglslAffinePositionWithPatternBrushVertexShader - = qglslPositionWithPatternBrushVertexShader; - -static const char* const qglslPatternBrushSrcFragmentShader = "\n\ - uniform sampler2D brushTexture; \n\ - uniform lowp vec4 patternColor; \n\ - varying highp vec2 patternTexCoords;\n\ - lowp vec4 srcPixel() \n\ - { \n\ - return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \n\ - }\n"; - - -// Linear Gradient Brush -static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\n\ - attribute highp vec2 vertexCoordsArray; \n\ - attribute highp vec3 pmvMatrix1; \n\ - attribute highp vec3 pmvMatrix2; \n\ - attribute highp vec3 pmvMatrix3; \n\ - uniform mediump vec2 halfViewportSize; \n\ - uniform highp vec3 linearData; \n\ - uniform highp mat3 brushTransform; \n\ - varying mediump float index; \n\ - void setPosition() \n\ - { \n\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ - gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ - index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\ - }\n"; - -static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader - = qglslPositionWithLinearGradientBrushVertexShader; - -static const char* const qglslLinearGradientBrushSrcFragmentShader = "\n\ - uniform sampler2D brushTexture; \n\ - varying mediump float index; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - mediump vec2 val = vec2(index, 0.5); \n\ - return texture2D(brushTexture, val); \n\ - }\n"; - - -// Conical Gradient Brush -static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\n\ - attribute highp vec2 vertexCoordsArray; \n\ - attribute highp vec3 pmvMatrix1; \n\ - attribute highp vec3 pmvMatrix2; \n\ - attribute highp vec3 pmvMatrix3; \n\ - uniform mediump vec2 halfViewportSize; \n\ - uniform highp mat3 brushTransform; \n\ - varying highp vec2 A; \n\ - void setPosition(void) \n\ - { \n\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ - gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ - A = hTexCoords.xy * invertedHTexCoordsZ; \n\ - }\n"; - -static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader - = qglslPositionWithConicalGradientBrushVertexShader; - -static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\ - #define INVERSE_2PI 0.1591549430918953358 \n\ - uniform sampler2D brushTexture; \n\ - uniform mediump float angle; \n\ - varying highp vec2 A; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - highp float t; \n\ - if (abs(A.y) == abs(A.x)) \n\ - t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\ - else \n\ - t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\ - return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \n\ - }\n"; - - -// Radial Gradient Brush -static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\n\ - attribute highp vec2 vertexCoordsArray;\n\ - attribute highp vec3 pmvMatrix1; \n\ - attribute highp vec3 pmvMatrix2; \n\ - attribute highp vec3 pmvMatrix3; \n\ - uniform mediump vec2 halfViewportSize; \n\ - uniform highp mat3 brushTransform; \n\ - uniform highp vec2 fmp; \n\ - uniform mediump vec3 bradius; \n\ - varying highp float b; \n\ - varying highp vec2 A; \n\ - void setPosition(void) \n\ - {\n\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ - gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ - A = hTexCoords.xy * invertedHTexCoordsZ; \n\ - b = bradius.x + 2.0 * dot(A, fmp); \n\ - }\n"; - -static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader - = qglslPositionWithRadialGradientBrushVertexShader; - -static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\ - uniform sampler2D brushTexture; \n\ - uniform highp float fmp2_m_radius2; \n\ - uniform highp float inverse_2_fmp2_m_radius2; \n\ - uniform highp float sqrfr; \n\ - varying highp float b; \n\ - varying highp vec2 A; \n\ - uniform mediump vec3 bradius; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - highp float c = sqrfr-dot(A, A); \n\ - highp float det = b*b - 4.0*fmp2_m_radius2*c; \n\ - lowp vec4 result = vec4(0.0); \n\ - if (det >= 0.0) { \n\ - highp float detSqrt = sqrt(det); \n\ - highp float w = max((-b - detSqrt) * inverse_2_fmp2_m_radius2, (-b + detSqrt) * inverse_2_fmp2_m_radius2); \n\ - if (bradius.y + w * bradius.z >= 0.0) \n\ - result = texture2D(brushTexture, vec2(w, 0.5)); \n\ - } \n\ - return result; \n\ - }\n"; - - -// Texture Brush -static const char* const qglslPositionWithTextureBrushVertexShader = "\n\ - attribute highp vec2 vertexCoordsArray; \n\ - attribute highp vec3 pmvMatrix1; \n\ - attribute highp vec3 pmvMatrix2; \n\ - attribute highp vec3 pmvMatrix3; \n\ - uniform mediump vec2 halfViewportSize; \n\ - uniform highp vec2 invertedTextureSize; \n\ - uniform highp mat3 brushTransform; \n\ - varying highp vec2 brushTextureCoords; \n\ - void setPosition(void) \n\ - { \n\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ - gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ - brushTextureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ - }\n"; - -static const char* const qglslAffinePositionWithTextureBrushVertexShader - = qglslPositionWithTextureBrushVertexShader; - -// OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead, -// we emulate GL_REPEAT by only taking the fractional part of the texture coords. -// TODO: Special case POT textures which don't need this emulation -static const char* const qglslTextureBrushSrcFragmentShader_ES = "\n\ - varying highp vec2 brushTextureCoords; \n\ - uniform sampler2D brushTexture; \n\ - lowp vec4 srcPixel() { \n\ - return texture2D(brushTexture, fract(brushTextureCoords)); \n\ - }\n"; - -static const char* const qglslTextureBrushSrcFragmentShader_desktop = "\n\ - varying highp vec2 brushTextureCoords; \n\ - uniform sampler2D brushTexture; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - return texture2D(brushTexture, brushTextureCoords); \n\ - }\n"; - -static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\ - varying highp vec2 brushTextureCoords; \n\ - uniform lowp vec4 patternColor; \n\ - uniform sampler2D brushTexture; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - return patternColor * (1.0 - texture2D(brushTexture, brushTextureCoords).r); \n\ - }\n"; - -// Solid Fill Brush -static const char* const qglslSolidBrushSrcFragmentShader = "\n\ - uniform lowp vec4 fragmentColor; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - return fragmentColor; \n\ - }\n"; - -static const char* const qglslImageSrcFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ - uniform sampler2D imageTexture; \n\ - lowp vec4 srcPixel() \n\ - { \n" - "return texture2D(imageTexture, textureCoords); \n" - "}\n"; - -static const char* const qglslCustomSrcFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ - uniform sampler2D imageTexture; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - return customShader(imageTexture, textureCoords); \n\ - }\n"; - -static const char* const qglslImageSrcWithPatternFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ - uniform lowp vec4 patternColor; \n\ - uniform sampler2D imageTexture; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\ - }\n"; - -static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\n\ - varying highp vec2 textureCoords; \n\ - uniform sampler2D imageTexture; \n\ - lowp vec4 srcPixel() \n\ - { \n\ - lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\ - sample.rgb = sample.rgb * sample.a; \n\ - return sample; \n\ - }\n"; - -static const char* const qglslShockingPinkSrcFragmentShader = "\n\ - lowp vec4 srcPixel() \n\ - { \n\ - return vec4(0.98, 0.06, 0.75, 1.0); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_ImageArrays = "\n\ - varying lowp float opacity; \n\ - lowp vec4 srcPixel(); \n\ - void main() \n\ - { \n\ - gl_FragColor = srcPixel() * opacity; \n\ - }\n"; - -static const char* const qglslMainFragmentShader_CMO = "\n\ - uniform lowp float globalOpacity; \n\ - lowp vec4 srcPixel(); \n\ - lowp vec4 applyMask(lowp vec4); \n\ - lowp vec4 compose(lowp vec4); \n\ - void main() \n\ - { \n\ - gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_CM = "\n\ - lowp vec4 srcPixel(); \n\ - lowp vec4 applyMask(lowp vec4); \n\ - lowp vec4 compose(lowp vec4); \n\ - void main() \n\ - { \n\ - gl_FragColor = applyMask(compose(srcPixel())); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_MO = "\n\ - uniform lowp float globalOpacity; \n\ - lowp vec4 srcPixel(); \n\ - lowp vec4 applyMask(lowp vec4); \n\ - void main() \n\ - { \n\ - gl_FragColor = applyMask(srcPixel()*globalOpacity); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_M = "\n\ - lowp vec4 srcPixel(); \n\ - lowp vec4 applyMask(lowp vec4); \n\ - void main() \n\ - { \n\ - gl_FragColor = applyMask(srcPixel()); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_CO = "\n\ - uniform lowp float globalOpacity; \n\ - lowp vec4 srcPixel(); \n\ - lowp vec4 compose(lowp vec4); \n\ - void main() \n\ - { \n\ - gl_FragColor = compose(srcPixel()*globalOpacity); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_C = "\n\ - lowp vec4 srcPixel(); \n\ - lowp vec4 compose(lowp vec4); \n\ - void main() \n\ - { \n\ - gl_FragColor = compose(srcPixel()); \n\ - }\n"; - -static const char* const qglslMainFragmentShader_O = "\n\ - uniform lowp float globalOpacity; \n\ - lowp vec4 srcPixel(); \n\ - void main() \n\ - { \n\ - gl_FragColor = srcPixel()*globalOpacity; \n\ - }\n"; - -static const char* const qglslMainFragmentShader = "\n\ - lowp vec4 srcPixel(); \n\ - void main() \n\ - { \n\ - gl_FragColor = srcPixel(); \n\ - }\n"; - -static const char* const qglslMaskFragmentShader = "\n\ - varying highp vec2 textureCoords;\n\ - uniform sampler2D maskTexture;\n\ - lowp vec4 applyMask(lowp vec4 src) \n\ - {\n\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ - return src * mask.a; \n\ - }\n"; - -// For source over with subpixel antialiasing, the final color is calculated per component as follows -// (.a is alpha component, .c is red, green or blue component): -// alpha = src.a * mask.c * opacity -// dest.c = dest.c * (1 - alpha) + src.c * alpha -// -// In the first pass, calculate: dest.c = dest.c * (1 - alpha) with blend funcs: zero, 1 - source color -// In the second pass, calculate: dest.c = dest.c + src.c * alpha with blend funcs: one, one -// -// If source is a solid color (src is constant), only the first pass is needed, with blend funcs: constant, 1 - source color - -// For source composition with subpixel antialiasing, the final color is calculated per component as follows: -// alpha = src.a * mask.c * opacity -// dest.c = dest.c * (1 - mask.c) + src.c * alpha -// - -static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\ - varying highp vec2 textureCoords;\n\ - uniform sampler2D maskTexture;\n\ - lowp vec4 applyMask(lowp vec4 src) \n\ - { \n\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ - return src.a * mask; \n\ - }\n"; - -static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\ - varying highp vec2 textureCoords;\n\ - uniform sampler2D maskTexture;\n\ - lowp vec4 applyMask(lowp vec4 src) \n\ - { \n\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ - return src * mask; \n\ - }\n"; - -/* - Left to implement: - RgbMaskFragmentShader, - RgbMaskWithGammaFragmentShader, - - MultiplyCompositionModeFragmentShader, - ScreenCompositionModeFragmentShader, - OverlayCompositionModeFragmentShader, - DarkenCompositionModeFragmentShader, - LightenCompositionModeFragmentShader, - ColorDodgeCompositionModeFragmentShader, - ColorBurnCompositionModeFragmentShader, - HardLightCompositionModeFragmentShader, - SoftLightCompositionModeFragmentShader, - DifferenceCompositionModeFragmentShader, - ExclusionCompositionModeFragmentShader, -*/ - -QT_END_NAMESPACE - -#endif // GLGC_SHADER_SOURCE_H diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp deleted file mode 100644 index fc5e236ca6..0000000000 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglgradientcache_p.h" -#include <private/qdrawhelper_p.h> -#include <private/qgl_p.h> -#include <QtCore/qmutex.h> -#include <QtCore/qrandom.h> - -QT_BEGIN_NAMESPACE - -class QGL2GradientCacheWrapper -{ -public: - QGL2GradientCache *cacheForContext(const QGLContext *context) { - QMutexLocker lock(&m_mutex); - return m_resource.value<QGL2GradientCache>(context->contextHandle()); - } - -private: - QOpenGLMultiGroupSharedResource m_resource; - QMutex m_mutex; -}; - -Q_GLOBAL_STATIC(QGL2GradientCacheWrapper, qt_gradient_caches) - -QGL2GradientCache::QGL2GradientCache(QOpenGLContext *ctx) - : QOpenGLSharedResource(ctx->shareGroup()) -{ -} - -QGL2GradientCache::~QGL2GradientCache() -{ - cache.clear(); -} - -QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) -{ - return qt_gradient_caches()->cacheForContext(context); -} - -void QGL2GradientCache::invalidateResource() -{ - QMutexLocker lock(&m_mutex); - cache.clear(); -} - -void QGL2GradientCache::freeResource(QOpenGLContext *) -{ - cleanCache(); -} - -void QGL2GradientCache::cleanCache() -{ - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - QMutexLocker lock(&m_mutex); - QGLGradientColorTableHash::const_iterator it = cache.constBegin(); - for (; it != cache.constEnd(); ++it) { - const CacheInfo &cache_info = it.value(); - funcs->glDeleteTextures(1, &cache_info.texId); - } - cache.clear(); -} - -GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity) -{ - QMutexLocker lock(&m_mutex); - quint64 hash_val = 0; - - const QGradientStops stops = gradient.stops(); - for (int i = 0; i < stops.size() && i <= 2; i++) - hash_val += stops[i].second.rgba(); - - QGLGradientColorTableHash::const_iterator it = cache.constFind(hash_val); - - if (it == cache.constEnd()) - return addCacheElement(hash_val, gradient, opacity); - else { - do { - const CacheInfo &cache_info = it.value(); - if (cache_info.stops == stops && cache_info.opacity == opacity - && cache_info.interpolationMode == gradient.interpolationMode()) - { - return cache_info.texId; - } - ++it; - } while (it != cache.constEnd() && it.key() == hash_val); - // an exact match for these stops and opacity was not found, create new cache - return addCacheElement(hash_val, gradient, opacity); - } -} - - -GLuint QGL2GradientCache::addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity) -{ - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - if (cache.size() == maxCacheSize()) { - int elem_to_remove = QRandomGenerator::global()->bounded(maxCacheSize()); - quint64 key = cache.keys()[elem_to_remove]; - - // need to call glDeleteTextures on each removed cache entry: - QGLGradientColorTableHash::const_iterator it = cache.constFind(key); - do { - funcs->glDeleteTextures(1, &it.value().texId); - } while (++it != cache.constEnd() && it.key() == key); - cache.remove(key); // may remove more than 1, but OK - } - - CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode()); - uint buffer[1024]; - generateGradientColorTable(gradient, buffer, paletteSize(), opacity); - funcs->glGenTextures(1, &cache_entry.texId); - funcs->glBindTexture(GL_TEXTURE_2D, cache_entry.texId); - funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, paletteSize(), 1, - 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - return cache.insert(hash_val, cache_entry).value().texId; -} - - -// GL's expects pixels in RGBA (when using GL_RGBA), bin-endian (ABGR on x86). -// Qt always stores in ARGB reguardless of the byte-order the mancine uses. -static inline uint qtToGlColor(uint c) -{ - uint o; -#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - o = (c & 0xff00ff00) // alpha & green already in the right place - | ((c >> 16) & 0x000000ff) // red - | ((c << 16) & 0x00ff0000); // blue -#else //Q_BIG_ENDIAN - o = (c << 8) - | ((c >> 24) & 0x000000ff); -#endif // Q_BYTE_ORDER - return o; -} - -//TODO: Let GL generate the texture using an FBO -void QGL2GradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, qreal opacity) const -{ - int pos = 0; - const QGradientStops s = gradient.stops(); - bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation); - - uint alpha = qRound(opacity * 256); - // Qt LIES! It returns ARGB (on little-endian AND on big-endian) - uint current_color = ARGB_COMBINE_ALPHA(s[0].second.rgba(), alpha); - qreal incr = 1.0 / qreal(size); - qreal fpos = 1.5 * incr; - colorTable[pos++] = qtToGlColor(qPremultiply(current_color)); - - while (fpos <= s.first().first) { - colorTable[pos] = colorTable[pos - 1]; - pos++; - fpos += incr; - } - - if (colorInterpolation) - current_color = qPremultiply(current_color); - - const int sLast = s.size() - 1; - for (int i = 0; i < sLast; ++i) { - qreal delta = 1/(s[i+1].first - s[i].first); - uint next_color = ARGB_COMBINE_ALPHA(s[i + 1].second.rgba(), alpha); - if (colorInterpolation) - next_color = qPremultiply(next_color); - - while (fpos < s[i+1].first && pos < size) { - int dist = int(256 * ((fpos - s[i].first) * delta)); - int idist = 256 - dist; - if (colorInterpolation) - colorTable[pos] = qtToGlColor(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist)); - else - colorTable[pos] = qtToGlColor(qPremultiply(INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist))); - ++pos; - fpos += incr; - } - current_color = next_color; - } - - Q_ASSERT(s.size() > 0); - - uint last_color = qtToGlColor(qPremultiply(ARGB_COMBINE_ALPHA(s[sLast].second.rgba(), alpha))); - for (;pos < size; ++pos) - colorTable[pos] = last_color; - - // Make sure the last color stop is represented at the end of the table - colorTable[size-1] = last_color; -} - -QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qglgradientcache_p.h b/src/opengl/gl2paintengineex/qglgradientcache_p.h deleted file mode 100644 index 3c9da982e9..0000000000 --- a/src/opengl/gl2paintengineex/qglgradientcache_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLGRADIENTCACHE_P_H -#define QGLGRADIENTCACHE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QMultiHash> -#include <QObject> -#include <QtOpenGL/QtOpenGL> -#include <private/qgl_p.h> -#include <QtCore/qmutex.h> - -QT_BEGIN_NAMESPACE - -class QGL2GradientCache : public QOpenGLSharedResource -{ - struct CacheInfo - { - inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) : - stops(s), opacity(op), interpolationMode(mode) {} - - GLuint texId; - QGradientStops stops; - qreal opacity; - QGradient::InterpolationMode interpolationMode; - }; - - typedef QMultiHash<quint64, CacheInfo> QGLGradientColorTableHash; - -public: - static QGL2GradientCache *cacheForContext(const QGLContext *context); - - QGL2GradientCache(QOpenGLContext *); - ~QGL2GradientCache(); - - GLuint getBuffer(const QGradient &gradient, qreal opacity); - inline int paletteSize() const { return 1024; } - - void invalidateResource() override; - void freeResource(QOpenGLContext *ctx) override; - -private: - inline int maxCacheSize() const { return 60; } - inline void generateGradientColorTable(const QGradient& gradient, - uint *colorTable, - int size, qreal opacity) const; - GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity); - void cleanCache(); - - QGLGradientColorTableHash cache; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -#endif // QGLGRADIENTCACHE_P_H diff --git a/src/opengl/gl2paintengineex/qglshadercache_p.h b/src/opengl/gl2paintengineex/qglshadercache_p.h deleted file mode 100644 index 4204e3e256..0000000000 --- a/src/opengl/gl2paintengineex/qglshadercache_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QGLSHADERCACHE_P_H -#define QGLSHADERCACHE_P_H - -#include <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE - - -class QGLShaderProgram; -class QGLContext; - -class CachedShader -{ -public: - inline CachedShader(const QByteArray &, const QByteArray &) - {} - - inline bool isCached() - { - return false; - } - - inline bool load(QGLShaderProgram *, const QGLContext *) - { - return false; - } - - inline bool store(QGLShaderProgram *, const QGLContext *) - { - return false; - } -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp deleted file mode 100644 index 2546f6dc13..0000000000 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ /dev/null @@ -1,2515 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - When the active program changes, we need to update it's uniforms. - We could track state for each program and only update stale uniforms - - Could lead to lots of overhead if there's a lot of programs - We could update all the uniforms when the program changes - - Could end up updating lots of uniforms which don't need updating - - Updating uniforms should be cheap, so the overhead of updating up-to-date - uniforms should be minimal. It's also less complex. - - Things which _may_ cause a different program to be used: - - Change in brush/pen style - - Change in painter opacity - - Change in composition mode - - Whenever we set a mode on the shader manager - it needs to tell us if it had - to switch to a different program. - - The shader manager should only switch when we tell it to. E.g. if we set a new - brush style and then switch to transparent painter, we only want it to compile - and use the correct program when we really need it. -*/ - -// #define QT_OPENGL_CACHE_AS_VBOS - -#include "qglgradientcache_p.h" -#include "qpaintengineex_opengl2_p.h" - -#include <string.h> //for memcpy -#include <qmath.h> - -#include <private/qgl_p.h> -#include <private/qpaintengineex_p.h> -#include <QPaintEngine> -#include <private/qpainter_p.h> -#include <private/qfontengine_p.h> -#include <private/qdatabuffer_p.h> -#include <private/qstatictext_p.h> -#include <QtGui/private/qtriangulator_p.h> - -#include "qglengineshadermanager_p.h" -#include "qgl2pexvertexarray_p.h" -#include "qtextureglyphcache_gl_p.h" - -#include <QDebug> - -#ifndef QT_OPENGL_ES_2 -# include <qopenglfunctions_1_1.h> -#endif - -QT_BEGIN_NAMESPACE - - - -Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert); - -////////////////////////////////// Private Methods ////////////////////////////////////////// - -QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate() -{ - delete shaderManager; - - while (pathCaches.size()) { - QVectorPath::CacheEntry *e = *(pathCaches.constBegin()); - e->cleanup(e->engine, e->data); - e->data = 0; - e->engine = 0; - } - - if (elementIndicesVBOId != 0) { - glDeleteBuffers(1, &elementIndicesVBOId); - elementIndicesVBOId = 0; - } -} - -void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id) -{ -// glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); //### Is it always this texture unit? - if (id != GLuint(-1) && id == lastTextureUsed) - return; - - lastTextureUsed = id; - - if (smoothPixmapTransform) { - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode); - glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode); -} - - -inline QColor qt_premultiplyColor(QColor c, GLfloat opacity) -{ - qreal alpha = c.alphaF() * opacity; - c.setAlphaF(alpha); - c.setRedF(c.redF() * alpha); - c.setGreenF(c.greenF() * alpha); - c.setBlueF(c.blueF() * alpha); - return c; -} - - -void QGL2PaintEngineExPrivate::setBrush(const QBrush& brush) -{ - if (qbrush_fast_equals(currentBrush, brush)) - return; - - const Qt::BrushStyle newStyle = qbrush_style(brush); - Q_ASSERT(newStyle != Qt::NoBrush); - - currentBrush = brush; - if (!currentBrushPixmap.isNull()) - currentBrushPixmap = QPixmap(); - brushUniformsDirty = true; // All brushes have at least one uniform - - if (newStyle > Qt::SolidPattern) - brushTextureDirty = true; - - if (currentBrush.style() == Qt::TexturePattern - && qHasPixmapTexture(brush) && brush.texture().isQBitmap()) - { - shaderManager->setSrcPixelType(QGLEngineShaderManager::TextureSrcWithPattern); - } else { - shaderManager->setSrcPixelType(newStyle); - } - shaderManager->optimiseForBrushTransform(currentBrush.transform().type()); -} - - -void QGL2PaintEngineExPrivate::useSimpleShader() -{ - shaderManager->useSimpleProgram(); - - if (matrixDirty) - updateMatrix(); -} - -// ####TODO Properly #ifdef this class to use #define symbols actually defined -// by OpenGL/ES includes -#ifndef GL_MIRRORED_REPEAT_IBM -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -void QGL2PaintEngineExPrivate::updateBrushTexture() -{ - Q_Q(QGL2PaintEngineEx); -// qDebug("QGL2PaintEngineExPrivate::updateBrushTexture()"); - Qt::BrushStyle style = currentBrush.style(); - - if ( (style >= Qt::Dense1Pattern) && (style <= Qt::DiagCrossPattern) ) { - // Get the image data for the pattern - QImage texImage = qt_imageForBrush(style, false); - - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - ctx->d_func()->bindTexture(texImage, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); - updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform); - } - else if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) { - // Gradiant brush: All the gradiants use the same texture - - const QGradient* g = currentBrush.gradient(); - - // We apply global opacity in the fragment shaders, so we always pass 1.0 - // for opacity to the cache. - GLuint texId = QGL2GradientCache::cacheForContext(ctx)->getBuffer(*g, 1.0); - - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - glBindTexture(GL_TEXTURE_2D, texId); - - if (g->spread() == QGradient::RepeatSpread || g->type() == QGradient::ConicalGradient) - updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform); - else if (g->spread() == QGradient::ReflectSpread) - updateTextureFilter(GL_TEXTURE_2D, GL_MIRRORED_REPEAT_IBM, q->state()->renderHints & QPainter::SmoothPixmapTransform); - else - updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, q->state()->renderHints & QPainter::SmoothPixmapTransform); - } - else if (style == Qt::TexturePattern) { - currentBrushPixmap = currentBrush.texture(); - - int max_texture_size = ctx->d_func()->maxTextureSize(); - if (currentBrushPixmap.width() > max_texture_size || currentBrushPixmap.height() > max_texture_size) - currentBrushPixmap = currentBrushPixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); - - GLuint wrapMode = GL_REPEAT; - if (ctx->contextHandle()->isOpenGLES()) { - // OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead, - // we emulate GL_REPEAT by only taking the fractional part of the texture coords - // in the qopenglslTextureBrushSrcFragmentShader program. - wrapMode = GL_CLAMP_TO_EDGE; - } - - glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); - QGLTexture *tex = ctx->d_func()->bindTexture(currentBrushPixmap, GL_TEXTURE_2D, GL_RGBA, - QGLContext::InternalBindOption | - QGLContext::CanFlipNativePixmapBindOption); - updateTextureFilter(GL_TEXTURE_2D, wrapMode, q->state()->renderHints & QPainter::SmoothPixmapTransform); - textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1; - } - brushTextureDirty = false; -} - - -void QGL2PaintEngineExPrivate::updateBrushUniforms() -{ -// qDebug("QGL2PaintEngineExPrivate::updateBrushUniforms()"); - Qt::BrushStyle style = currentBrush.style(); - - if (style == Qt::NoBrush) - return; - - QTransform brushQTransform = currentBrush.transform(); - - if (style == Qt::SolidPattern) { - QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::FragmentColor), col); - } - else { - // All other brushes have a transform and thus need the translation point: - QPointF translationPoint; - - if (style <= Qt::DiagCrossPattern) { - QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); - - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); - - QVector2D halfViewportSize(width*0.5, height*0.5); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); - } - else if (style == Qt::LinearGradientPattern) { - const QLinearGradient *g = static_cast<const QLinearGradient *>(currentBrush.gradient()); - - QPointF realStart = g->start(); - QPointF realFinal = g->finalStop(); - translationPoint = realStart; - - QPointF l = realFinal - realStart; - - QVector3D linearData( - l.x(), - l.y(), - 1.0f / (l.x() * l.x() + l.y() * l.y()) - ); - - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::LinearData), linearData); - - QVector2D halfViewportSize(width*0.5, height*0.5); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); - } - else if (style == Qt::ConicalGradientPattern) { - const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient()); - translationPoint = g->center(); - - GLfloat angle = -qDegreesToRadians(g->angle()); - - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Angle), angle); - - QVector2D halfViewportSize(width*0.5, height*0.5); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); - } - else if (style == Qt::RadialGradientPattern) { - const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush.gradient()); - QPointF realCenter = g->center(); - QPointF realFocal = g->focalPoint(); - qreal realRadius = g->centerRadius() - g->focalRadius(); - translationPoint = realFocal; - - QPointF fmp = realCenter - realFocal; - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp), fmp); - - GLfloat fmp2_m_radius2 = -fmp.x() * fmp.x() - fmp.y() * fmp.y() + realRadius*realRadius; - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp2MRadius2), fmp2_m_radius2); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Inverse2Fmp2MRadius2), - GLfloat(1.0 / (2.0*fmp2_m_radius2))); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::SqrFr), - GLfloat(g->focalRadius() * g->focalRadius())); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BRadius), - GLfloat(2 * (g->centerRadius() - g->focalRadius()) * g->focalRadius()), - g->focalRadius(), - g->centerRadius() - g->focalRadius()); - - QVector2D halfViewportSize(width*0.5, height*0.5); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); - } - else if (style == Qt::TexturePattern) { - const QPixmap& texPixmap = currentBrush.texture(); - - if (qHasPixmapTexture(currentBrush) && currentBrush.texture().isQBitmap()) { - QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); - } - - QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 / texPixmap.height()); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::InvertedTextureSize), invertedTextureSize); - - QVector2D halfViewportSize(width*0.5, height*0.5); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); - } - else - qWarning("QGL2PaintEngineEx: Unimplemented fill style"); - - const QPointF &brushOrigin = q->state()->brushOrigin; - QTransform matrix = q->state()->matrix; - matrix.translate(brushOrigin.x(), brushOrigin.y()); - - QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y()); - qreal m22 = -1; - qreal dy = height; - if (device->isFlipped()) { - m22 = 1; - dy = 0; - } - QTransform gl_to_qt(1, 0, 0, m22, 0, dy); - QTransform inv_matrix; - if (style == Qt::TexturePattern && textureInvertedY == -1) - inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate; - else - inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate; - - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTransform), inv_matrix); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTexture), QT_BRUSH_TEXTURE_UNIT); - } - brushUniformsDirty = false; -} - - -// This assumes the shader manager has already setup the correct shader program -void QGL2PaintEngineExPrivate::updateMatrix() -{ -// qDebug("QGL2PaintEngineExPrivate::updateMatrix()"); - - const QTransform& transform = q->state()->matrix; - - // The projection matrix converts from Qt's coordinate system to GL's coordinate system - // * GL's viewport is 2x2, Qt's is width x height - // * GL has +y -> -y going from bottom -> top, Qt is the other way round - // * GL has [0,0] in the center, Qt has it in the top-left - // - // This results in the Projection matrix below, which is multiplied by the painter's - // transformation matrix, as shown below: - // - // Projection Matrix Painter Transform - // ------------------------------------------------ ------------------------ - // | 2.0 / width | 0.0 | -1.0 | | m11 | m21 | dx | - // | 0.0 | -2.0 / height | 1.0 | * | m12 | m22 | dy | - // | 0.0 | 0.0 | 1.0 | | m13 | m23 | m33 | - // ------------------------------------------------ ------------------------ - // - // NOTE: The resultant matrix is also transposed, as GL expects column-major matracies - - const GLfloat wfactor = 2.0f / width; - GLfloat hfactor = -2.0f / height; - - GLfloat dx = transform.dx(); - GLfloat dy = transform.dy(); - - if (device->isFlipped()) { - hfactor *= -1; - dy -= height; - } - - // Non-integer translates can have strange effects for some rendering operations such as - // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid. - if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) { - // 0.50 needs to rounded down to 0.0 for consistency with raster engine: - dx = std::ceil(dx - 0.5f); - dy = std::ceil(dy - 0.5f); - } - pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); - pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); - pmvMatrix[2][0] = (wfactor * dx) - transform.m33(); - pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13(); - pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23(); - pmvMatrix[2][1] = (hfactor * dy) + transform.m33(); - pmvMatrix[0][2] = transform.m13(); - pmvMatrix[1][2] = transform.m23(); - pmvMatrix[2][2] = transform.m33(); - - // 1/10000 == 0.0001, so we have good enough res to cover curves - // that span the entire widget... - inverseScale = qMax(1 / qMax( qMax(qAbs(transform.m11()), qAbs(transform.m22())), - qMax(qAbs(transform.m12()), qAbs(transform.m21())) ), - qreal(0.0001)); - - matrixDirty = false; - matrixUniformDirty = true; - - // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only - // need to do this once for every matrix change and persists across all shader programs. - glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); - glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); - glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); - - dasher.setInvScale(inverseScale); - stroker.setInvScale(inverseScale); -} - - -void QGL2PaintEngineExPrivate::updateCompositionMode() -{ - // NOTE: The entire paint engine works on pre-multiplied data - which is why some of these - // composition modes look odd. -// qDebug() << "QGL2PaintEngineExPrivate::updateCompositionMode() - Setting GL composition mode for " << q->state()->composition_mode; - switch(q->state()->composition_mode) { - case QPainter::CompositionMode_SourceOver: - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - break; - case QPainter::CompositionMode_DestinationOver: - glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); - break; - case QPainter::CompositionMode_Clear: - glBlendFunc(GL_ZERO, GL_ZERO); - break; - case QPainter::CompositionMode_Source: - glBlendFunc(GL_ONE, GL_ZERO); - break; - case QPainter::CompositionMode_Destination: - glBlendFunc(GL_ZERO, GL_ONE); - break; - case QPainter::CompositionMode_SourceIn: - glBlendFunc(GL_DST_ALPHA, GL_ZERO); - break; - case QPainter::CompositionMode_DestinationIn: - glBlendFunc(GL_ZERO, GL_SRC_ALPHA); - break; - case QPainter::CompositionMode_SourceOut: - glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ZERO); - break; - case QPainter::CompositionMode_DestinationOut: - glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); - break; - case QPainter::CompositionMode_SourceAtop: - glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - break; - case QPainter::CompositionMode_DestinationAtop: - glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA); - break; - case QPainter::CompositionMode_Xor: - glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - break; - case QPainter::CompositionMode_Plus: - glBlendFunc(GL_ONE, GL_ONE); - break; - default: - qWarning("Unsupported composition mode"); - break; - } - - compositionModeDirty = false; -} - -static inline void setCoords(GLfloat *coords, const QGLRect &rect) -{ - coords[0] = rect.left; - coords[1] = rect.top; - coords[2] = rect.right; - coords[3] = rect.top; - coords[4] = rect.right; - coords[5] = rect.bottom; - coords[6] = rect.left; - coords[7] = rect.bottom; -} - -void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern) -{ - // Setup for texture drawing - currentBrush = noBrush; - shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc); - - if (snapToPixelGrid) { - snapToPixelGrid = false; - matrixDirty = true; - } - - if (prepareForDraw(opaque)) - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); - - if (pattern) { - QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); - } - - GLfloat dx = 1.0 / textureSize.width(); - GLfloat dy = 1.0 / textureSize.height(); - - QGLRect srcTextureRect(src.left*dx, src.top*dy, src.right*dx, src.bottom*dy); - - setCoords(staticVertexCoordinateArray, dest); - setCoords(staticTextureCoordinateArray, srcTextureRect); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); -} - -void QGL2PaintEngineEx::beginNativePainting() -{ - Q_D(QGL2PaintEngineEx); - ensureActive(); - d->transferMode(BrushDrawingMode); - - d->nativePaintingActive = true; - - d->glUseProgram(0); - - // Disable all the vertex attribute arrays: - for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) - d->glDisableVertexAttribArray(i); - -#ifndef QT_OPENGL_ES_2 - if (!d->ctx->contextHandle()->isOpenGLES()) { - const QGLContext *ctx = d->ctx; - const QGLFormat &fmt = d->device->format(); - if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1) - || (fmt.majorVersion() == 3 && fmt.minorVersion() == 1 && ctx->contextHandle()->hasExtension(QByteArrayLiteral("GL_ARB_compatibility"))) - || fmt.profile() == QGLFormat::CompatibilityProfile) - { - // be nice to people who mix OpenGL 1.x code with QPainter commands - // by setting modelview and projection matrices to mirror the GL 1 - // paint engine - const QTransform& mtx = state()->matrix; - - float mv_matrix[4][4] = - { - { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) }, - { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) }, - { 0, 0, 1, 0 }, - { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) } - }; - - const QSize sz = d->device->size(); - - QOpenGLFunctions_1_1 *gl1funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_1>(); - gl1funcs->initializeOpenGLFunctions(); - - gl1funcs->glMatrixMode(GL_PROJECTION); - gl1funcs->glLoadIdentity(); - gl1funcs->glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999); - - gl1funcs->glMatrixMode(GL_MODELVIEW); - gl1funcs->glLoadMatrixf(&mv_matrix[0][0]); - } - } -#endif - - d->lastTextureUsed = GLuint(-1); - d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); - d->resetGLState(); - - d->shaderManager->setDirty(); - - d->needsSync = true; -} - -void QGL2PaintEngineExPrivate::resetGLState() -{ - glDisable(GL_BLEND); - glActiveTexture(GL_TEXTURE0); - glDisable(GL_STENCIL_TEST); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDepthMask(true); - glDepthFunc(GL_LESS); - glClearDepthf(1); - glStencilMask(0xff); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc(GL_ALWAYS, 0, 0xff); - ctx->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); - ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false); - ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); -#ifndef QT_OPENGL_ES_2 - if (!ctx->contextHandle()->isOpenGLES()) { - // gl_Color, corresponding to vertex attribute 3, may have been changed - float color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; - glVertexAttrib4fv(3, color); - } -#endif -} - -bool QGL2PaintEngineExPrivate::resetOpenGLContextActiveEngine() -{ - QOpenGLContext *guiGlContext = ctx->contextHandle(); - QOpenGLContextPrivate *guiGlContextPrivate = - guiGlContext ? QOpenGLContextPrivate::get(guiGlContext) : 0; - - if (guiGlContextPrivate && guiGlContextPrivate->active_engine) { - ctx->d_func()->refreshCurrentFbo(); - guiGlContextPrivate->active_engine = 0; - return true; - } - - return false; -} - -void QGL2PaintEngineEx::endNativePainting() -{ - Q_D(QGL2PaintEngineEx); - d->needsSync = true; - d->nativePaintingActive = false; -} - -void QGL2PaintEngineEx::invalidateState() -{ - Q_D(QGL2PaintEngineEx); - d->needsSync = true; -} - -bool QGL2PaintEngineEx::isNativePaintingActive() const { - Q_D(const QGL2PaintEngineEx); - return d->nativePaintingActive; -} - -bool QGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const -{ - // The paint engine does not support projected cached glyph drawing - if (t.type() == QTransform::TxProject) - return false; - - // The font engine might not support filling the glyph cache - // with the given transform applied, in which case we need to - // fall back to the QPainterPath code-path. - if (!fontEngine->supportsTransformation(t)) { - // Except that drawing paths is slow, so for scales between - // 0.5 and 2.0 we leave the glyph cache untransformed and deal - // with the transform ourselves when painting, resulting in - // drawing 1x cached glyphs with a smooth-scale. - float det = t.determinant(); - if (det >= 0.25f && det <= 4.f) { - // Assuming the baseclass still agrees - return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); - } - - return false; // Fall back to path-drawing - } - - return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); -} - -void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) -{ - if (newMode == mode) - return; - - if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) { - lastTextureUsed = GLuint(-1); - } - - if (newMode == TextDrawingMode) { - shaderManager->setHasComplexGeometry(true); - } else { - shaderManager->setHasComplexGeometry(false); - } - - if (newMode == ImageDrawingMode) { - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); - setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray); - } - - if (newMode == ImageArrayDrawingMode) { - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); - setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); - setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data()); - } - - // This needs to change when we implement high-quality anti-aliasing... - if (newMode != TextDrawingMode) - shaderManager->setMaskType(QGLEngineShaderManager::NoMask); - - mode = newMode; -} - -struct QGL2PEVectorPathCache -{ -#ifdef QT_OPENGL_CACHE_AS_VBOS - GLuint vbo; - GLuint ibo; -#else - float *vertices; - void *indices; -#endif - int vertexCount; - int indexCount; - GLenum primitiveType; - qreal iscale; - QVertexIndexVector::Type indexType; -}; - -void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data) -{ - QGL2PEVectorPathCache *c = (QGL2PEVectorPathCache *) data; -#ifdef QT_OPENGL_CACHE_AS_VBOS - Q_ASSERT(engine->type() == QPaintEngine::OpenGL2); - static_cast<QGL2PaintEngineEx *>(engine)->d_func()->unusedVBOSToClean << c->vbo; - if (c->ibo) - d->unusedIBOSToClean << c->ibo; -#else - Q_UNUSED(engine); - free(c->vertices); - free(c->indices); -#endif - delete c; -} - -// Assumes everything is configured for the brush you want to use -void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) -{ - transferMode(BrushDrawingMode); - - if (snapToPixelGrid) { - snapToPixelGrid = false; - matrixDirty = true; - } - - // Might need to call updateMatrix to re-calculate inverseScale - if (matrixDirty) - updateMatrix(); - - const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); - - // Check to see if there's any hints - if (path.shape() == QVectorPath::RectangleHint) { - QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y()); - prepareForDraw(currentBrush.isOpaque()); - composite(rect); - } else if (path.isConvex()) { - - if (path.isCacheable()) { - QVectorPath::CacheEntry *data = path.lookupCacheData(q); - QGL2PEVectorPathCache *cache; - - bool updateCache = false; - - if (data) { - cache = (QGL2PEVectorPathCache *) data->data; - // Check if scale factor is exceeded for curved paths and generate curves if so... - if (path.isCurved()) { - qreal scaleFactor = cache->iscale / inverseScale; - if (scaleFactor < 0.5 || scaleFactor > 2.0) { -#ifdef QT_OPENGL_CACHE_AS_VBOS - glDeleteBuffers(1, &cache->vbo); - cache->vbo = 0; - Q_ASSERT(cache->ibo == 0); -#else - free(cache->vertices); - Q_ASSERT(cache->indices == 0); -#endif - updateCache = true; - } - } - } else { - cache = new QGL2PEVectorPathCache; - data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); - updateCache = true; - } - - // Flatten the path at the current scale factor and fill it into the cache struct. - if (updateCache) { - vertexCoordinateArray.clear(); - vertexCoordinateArray.addPath(path, inverseScale, false); - int vertexCount = vertexCoordinateArray.vertexCount(); - int floatSizeInBytes = vertexCount * 2 * sizeof(float); - cache->vertexCount = vertexCount; - cache->indexCount = 0; - cache->primitiveType = GL_TRIANGLE_FAN; - cache->iscale = inverseScale; -#ifdef QT_OPENGL_CACHE_AS_VBOS - glGenBuffers(1, &cache->vbo); - glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); - glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW); - cache->ibo = 0; -#else - cache->vertices = (float *) malloc(floatSizeInBytes); - memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); - cache->indices = 0; -#endif - } - - prepareForDraw(currentBrush.isOpaque()); -#ifdef QT_OPENGL_CACHE_AS_VBOS - glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0); -#else - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); -#endif - glDrawArrays(cache->primitiveType, 0, cache->vertexCount); - - } else { - // printf(" - Marking path as cachable...\n"); - // Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable - path.makeCacheable(); - vertexCoordinateArray.clear(); - vertexCoordinateArray.addPath(path, inverseScale, false); - prepareForDraw(currentBrush.isOpaque()); - drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN); - } - - } else { - bool useCache = path.isCacheable(); - if (useCache) { - QRectF bbox = path.controlPointRect(); - // If the path doesn't fit within these limits, it is possible that the triangulation will fail. - useCache &= (bbox.left() > -0x8000 * inverseScale) - && (bbox.right() < 0x8000 * inverseScale) - && (bbox.top() > -0x8000 * inverseScale) - && (bbox.bottom() < 0x8000 * inverseScale); - } - - if (useCache) { - QVectorPath::CacheEntry *data = path.lookupCacheData(q); - QGL2PEVectorPathCache *cache; - - bool updateCache = false; - - if (data) { - cache = (QGL2PEVectorPathCache *) data->data; - // Check if scale factor is exceeded for curved paths and generate curves if so... - if (path.isCurved()) { - qreal scaleFactor = cache->iscale / inverseScale; - if (scaleFactor < 0.5 || scaleFactor > 2.0) { -#ifdef QT_OPENGL_CACHE_AS_VBOS - glDeleteBuffers(1, &cache->vbo); - glDeleteBuffers(1, &cache->ibo); -#else - free(cache->vertices); - free(cache->indices); -#endif - updateCache = true; - } - } - } else { - cache = new QGL2PEVectorPathCache; - data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); - updateCache = true; - } - - // Flatten the path at the current scale factor and fill it into the cache struct. - if (updateCache) { - QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); - cache->vertexCount = polys.vertices.size() / 2; - cache->indexCount = polys.indices.size(); - cache->primitiveType = GL_TRIANGLES; - cache->iscale = inverseScale; - cache->indexType = polys.indices.type(); -#ifdef QT_OPENGL_CACHE_AS_VBOS - glGenBuffers(1, &cache->vbo); - glGenBuffers(1, &cache->ibo); - glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); - - if (polys.indices.type() == QVertexIndexVector::UnsignedInt) - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint32) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW); - else - glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint16) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW); - - QVarLengthArray<float> vertices(polys.vertices.size()); - for (int i = 0; i < polys.vertices.size(); ++i) - vertices[i] = float(inverseScale * polys.vertices.at(i)); - glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW); -#else - cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size()); - if (polys.indices.type() == QVertexIndexVector::UnsignedInt) { - cache->indices = (quint32 *) malloc(sizeof(quint32) * polys.indices.size()); - memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size()); - } else { - cache->indices = (quint16 *) malloc(sizeof(quint16) * polys.indices.size()); - memcpy(cache->indices, polys.indices.data(), sizeof(quint16) * polys.indices.size()); - } - for (int i = 0; i < polys.vertices.size(); ++i) - cache->vertices[i] = float(inverseScale * polys.vertices.at(i)); -#endif - } - - prepareForDraw(currentBrush.isOpaque()); -#ifdef QT_OPENGL_CACHE_AS_VBOS - glBindBuffer(GL_ARRAY_BUFFER, cache->vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo); - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0); - if (cache->indexType == QVertexIndexVector::UnsignedInt) - glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, 0); - else - glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); -#else - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); - if (cache->indexType == QVertexIndexVector::UnsignedInt) - glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, (qint32 *)cache->indices); - else - glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, (qint16 *)cache->indices); -#endif - - } else { - // printf(" - Marking path as cachable...\n"); - // Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable - path.makeCacheable(); - - if (!device->format().stencil()) { - // If there is no stencil buffer, triangulate the path instead. - - QRectF bbox = path.controlPointRect(); - // If the path doesn't fit within these limits, it is possible that the triangulation will fail. - bool withinLimits = (bbox.left() > -0x8000 * inverseScale) - && (bbox.right() < 0x8000 * inverseScale) - && (bbox.top() > -0x8000 * inverseScale) - && (bbox.bottom() < 0x8000 * inverseScale); - if (withinLimits) { - QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); - - QVarLengthArray<float> vertices(polys.vertices.size()); - for (int i = 0; i < polys.vertices.size(); ++i) - vertices[i] = float(inverseScale * polys.vertices.at(i)); - - prepareForDraw(currentBrush.isOpaque()); - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData()); - if (polys.indices.type() == QVertexIndexVector::UnsignedInt) - glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_INT, polys.indices.data()); - else - glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_SHORT, polys.indices.data()); - } else { - // We can't handle big, concave painter paths with OpenGL without stencil buffer. - qWarning("Painter path exceeds +/-32767 pixels."); - } - return; - } - - // The path is too complicated & needs the stencil technique - vertexCoordinateArray.clear(); - vertexCoordinateArray.addPath(path, inverseScale, false); - - fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); - - glStencilMask(0xff); - glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - - if (q->state()->clipTestEnabled) { - // Pass when high bit is set, replace stencil value with current clip - glStencilFunc(GL_NOTEQUAL, q->state()->currentClip, GL_STENCIL_HIGH_BIT); - } else if (path.hasWindingFill()) { - // Pass when any bit is set, replace stencil value with 0 - glStencilFunc(GL_NOTEQUAL, 0, 0xff); - } else { - // Pass when high bit is set, replace stencil value with 0 - glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); - } - prepareForDraw(currentBrush.isOpaque()); - - // Stencil the brush onto the dest buffer - composite(vertexCoordinateArray.boundingRect()); - glStencilMask(0); - updateClipScissorTest(); - } - } -} - - -void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, - int count, - int *stops, - int stopCount, - const QGLRect &bounds, - StencilFillMode mode) -{ - Q_ASSERT(count || stops); - -// qDebug("QGL2PaintEngineExPrivate::fillStencilWithVertexArray()"); - glStencilMask(0xff); // Enable stencil writes - - if (dirtyStencilRegion.intersects(currentScissorBounds)) { - const QRegion clearRegion = dirtyStencilRegion.intersected(currentScissorBounds); - glClearStencil(0); // Clear to zero - for (const QRect &rect : clearRegion) { -#ifndef QT_GL_NO_SCISSOR_TEST - setScissor(rect); -#endif - glClear(GL_STENCIL_BUFFER_BIT); - } - - dirtyStencilRegion -= currentScissorBounds; - -#ifndef QT_GL_NO_SCISSOR_TEST - updateClipScissorTest(); -#endif - } - - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // Disable color writes - useSimpleShader(); - glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d - - if (mode == WindingFillMode) { - Q_ASSERT(stops && !count); - if (q->state()->clipTestEnabled) { - // Flatten clip values higher than current clip, and set high bit to match current clip - glStencilFunc(GL_LEQUAL, GL_STENCIL_HIGH_BIT | q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); - glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - composite(bounds); - - glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT, GL_STENCIL_HIGH_BIT); - } else if (!stencilClean) { - // Clear stencil buffer within bounding rect - glStencilFunc(GL_ALWAYS, 0, 0xff); - glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); - composite(bounds); - } - - // Inc. for front-facing triangle - glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_INCR_WRAP); - // Dec. for back-facing "holes" - glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_DECR_WRAP); - glStencilMask(~GL_STENCIL_HIGH_BIT); - drawVertexArrays(data, stops, stopCount, GL_TRIANGLE_FAN); - - if (q->state()->clipTestEnabled) { - // Clear high bit of stencil outside of path - glStencilFunc(GL_EQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); - glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - glStencilMask(GL_STENCIL_HIGH_BIT); - composite(bounds); - } - } else if (mode == OddEvenFillMode) { - glStencilMask(GL_STENCIL_HIGH_BIT); - glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit - drawVertexArrays(data, stops, stopCount, GL_TRIANGLE_FAN); - - } else { // TriStripStrokeFillMode - Q_ASSERT(count && !stops); // tristrips generated directly, so no vertexArray or stops - glStencilMask(GL_STENCIL_HIGH_BIT); -#if 0 - glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); - glDrawArrays(GL_TRIANGLE_STRIP, 0, count); -#else - - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - if (q->state()->clipTestEnabled) { - glStencilFunc(GL_LEQUAL, q->state()->currentClip | GL_STENCIL_HIGH_BIT, - ~GL_STENCIL_HIGH_BIT); - } else { - glStencilFunc(GL_ALWAYS, GL_STENCIL_HIGH_BIT, 0xff); - } - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); - glDrawArrays(GL_TRIANGLE_STRIP, 0, count); -#endif - } - - // Enable color writes & disable stencil writes - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); -} - -/* - If the maximum value in the stencil buffer is GL_STENCIL_HIGH_BIT - 1, - restore the stencil buffer to a pristine state. The current clip region - is set to 1, and the rest to 0. -*/ -void QGL2PaintEngineExPrivate::resetClipIfNeeded() -{ - if (maxClip != (GL_STENCIL_HIGH_BIT - 1)) - return; - - Q_Q(QGL2PaintEngineEx); - - useSimpleShader(); - glEnable(GL_STENCIL_TEST); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - - QRectF bounds = q->state()->matrix.inverted().mapRect(QRectF(0, 0, width, height)); - QGLRect rect(bounds.left(), bounds.top(), bounds.right(), bounds.bottom()); - - // Set high bit on clip region - glStencilFunc(GL_LEQUAL, q->state()->currentClip, 0xff); - glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT); - glStencilMask(GL_STENCIL_HIGH_BIT); - composite(rect); - - // Reset clipping to 1 and everything else to zero - glStencilFunc(GL_NOTEQUAL, 0x01, GL_STENCIL_HIGH_BIT); - glStencilOp(GL_ZERO, GL_REPLACE, GL_REPLACE); - glStencilMask(0xff); - composite(rect); - - q->state()->currentClip = 1; - q->state()->canRestoreClip = false; - - maxClip = 1; - - glStencilMask(0x0); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); -} - -bool QGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache) -{ - Q_Q(QGL2PaintEngineEx); - - Q_ASSERT(cache.transform().type() <= QTransform::TxScale); - - QTransform &transform = q->state()->matrix; - transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22()); - bool ret = prepareForDraw(false); - transform.scale(cache.transform().m11(), cache.transform().m22()); - - return ret; -} - -bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) -{ - if (brushTextureDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) - updateBrushTexture(); - - if (compositionModeDirty) - updateCompositionMode(); - - if (matrixDirty) - updateMatrix(); - - const bool stateHasOpacity = q->state()->opacity < 0.99f; - if (q->state()->composition_mode == QPainter::CompositionMode_Source - || (q->state()->composition_mode == QPainter::CompositionMode_SourceOver - && srcPixelsAreOpaque && !stateHasOpacity)) - { - glDisable(GL_BLEND); - } else { - glEnable(GL_BLEND); - } - - QGLEngineShaderManager::OpacityMode opacityMode; - if (mode == ImageArrayDrawingMode) { - opacityMode = QGLEngineShaderManager::AttributeOpacity; - } else { - opacityMode = stateHasOpacity ? QGLEngineShaderManager::UniformOpacity - : QGLEngineShaderManager::NoOpacity; - if (stateHasOpacity && (mode != ImageDrawingMode)) { - // Using a brush - bool brushIsPattern = (currentBrush.style() >= Qt::Dense1Pattern) && - (currentBrush.style() <= Qt::DiagCrossPattern); - - if ((currentBrush.style() == Qt::SolidPattern) || brushIsPattern) - opacityMode = QGLEngineShaderManager::NoOpacity; // Global opacity handled by srcPixel shader - } - } - shaderManager->setOpacityMode(opacityMode); - - bool changed = shaderManager->useCorrectShaderProg(); - // If the shader program needs changing, we change it and mark all uniforms as dirty - if (changed) { - // The shader program has changed so mark all uniforms as dirty: - brushUniformsDirty = true; - opacityUniformDirty = true; - matrixUniformDirty = true; - translateZUniformDirty = true; - } - - if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) - updateBrushUniforms(); - - if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) { - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity); - opacityUniformDirty = false; - } - - if (matrixUniformDirty && shaderManager->hasComplexGeometry()) { - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Matrix), - pmvMatrix); - matrixUniformDirty = false; - } - - if (translateZUniformDirty && shaderManager->hasComplexGeometry()) { - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::TranslateZ), - translateZ); - translateZUniformDirty = false; - } - - return changed; -} - -void QGL2PaintEngineExPrivate::composite(const QGLRect& boundingRect) -{ - setCoords(staticVertexCoordinateArray, boundingRect); - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); -} - -// Draws the vertex array as a set of <vertexArrayStops.size()> triangle fans. -void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, int stopCount, - GLenum primitive) -{ - // Now setup the pointer to the vertex array: - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); - - int previousStop = 0; - for (int i=0; i<stopCount; ++i) { - int stop = stops[i]; -/* - qDebug("Drawing triangle fan for vertecies %d -> %d:", previousStop, stop-1); - for (int i=previousStop; i<stop; ++i) - qDebug(" %02d: [%.2f, %.2f]", i, vertexArray.data()[i].x, vertexArray.data()[i].y); -*/ - glDrawArrays(primitive, previousStop, stop - previousStop); - previousStop = stop; - } -} - -/////////////////////////////////// Public Methods ////////////////////////////////////////// - -QGL2PaintEngineEx::QGL2PaintEngineEx() - : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))) -{ -} - -QGL2PaintEngineEx::~QGL2PaintEngineEx() -{ -} - -void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) -{ - Q_D(QGL2PaintEngineEx); - - if (qbrush_style(brush) == Qt::NoBrush) - return; - ensureActive(); - d->setBrush(brush); - d->fill(path); -} - -Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp - - -void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) -{ - Q_D(QGL2PaintEngineEx); - - const QBrush &penBrush = qpen_brush(pen); - if (qpen_style(pen) == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush) - return; - - QGL2PaintEngineState *s = state(); - if (qt_pen_is_cosmetic(pen, s->renderHints) && !qt_scaleForTransform(s->transform(), 0)) { - // QTriangulatingStroker class is not meant to support cosmetically sheared strokes. - QPaintEngineEx::stroke(path, pen); - return; - } - - ensureActive(); - d->setBrush(penBrush); - d->stroke(path, pen); -} - -void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) -{ - const QGL2PaintEngineState *s = q->state(); - if (snapToPixelGrid) { - snapToPixelGrid = false; - matrixDirty = true; - } - - const Qt::PenStyle penStyle = qpen_style(pen); - const QBrush &penBrush = qpen_brush(pen); - const bool opaque = penBrush.isOpaque() && s->opacity > 0.99; - - transferMode(BrushDrawingMode); - - // updateMatrix() is responsible for setting the inverse scale on - // the strokers, so we need to call it here and not wait for - // prepareForDraw() down below. - updateMatrix(); - - QRectF clip = q->state()->matrix.inverted().mapRect(q->state()->clipEnabled - ? q->state()->rectangleClip - : QRectF(0, 0, width, height)); - - if (penStyle == Qt::SolidLine) { - stroker.process(path, pen, clip, s->renderHints); - - } else { // Some sort of dash - dasher.process(path, pen, clip, s->renderHints); - - QVectorPath dashStroke(dasher.points(), - dasher.elementCount(), - dasher.elementTypes()); - stroker.process(dashStroke, pen, clip, s->renderHints); - } - - if (!stroker.vertexCount()) - return; - - if (opaque) { - prepareForDraw(opaque); - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, stroker.vertices()); - glDrawArrays(GL_TRIANGLE_STRIP, 0, stroker.vertexCount() / 2); - -// QBrush b(Qt::green); -// d->setBrush(&b); -// d->prepareForDraw(true); -// glDrawArrays(GL_LINE_STRIP, 0, d->stroker.vertexCount() / 2); - - } else { - qreal width = qpen_widthf(pen) / 2; - if (width == 0) - width = 0.5; - qreal extra = pen.joinStyle() == Qt::MiterJoin - ? qMax(pen.miterLimit() * width, width) - : width; - - if (qt_pen_is_cosmetic(pen, s->renderHints)) - extra = extra * inverseScale; - - QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra); - - fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2, - 0, 0, bounds, QGL2PaintEngineExPrivate::TriStripStrokeFillMode); - - glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - - // Pass when any bit is set, replace stencil value with 0 - glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); - prepareForDraw(false); - - // Stencil the brush onto the dest buffer - composite(bounds); - - glStencilMask(0); - - updateClipScissorTest(); - } -} - -void QGL2PaintEngineEx::penChanged() { } -void QGL2PaintEngineEx::brushChanged() { } -void QGL2PaintEngineEx::brushOriginChanged() { } - -void QGL2PaintEngineEx::opacityChanged() -{ -// qDebug("QGL2PaintEngineEx::opacityChanged()"); - Q_D(QGL2PaintEngineEx); - state()->opacityChanged = true; - - Q_ASSERT(d->shaderManager); - d->brushUniformsDirty = true; - d->opacityUniformDirty = true; -} - -void QGL2PaintEngineEx::compositionModeChanged() -{ -// qDebug("QGL2PaintEngineEx::compositionModeChanged()"); - Q_D(QGL2PaintEngineEx); - state()->compositionModeChanged = true; - d->compositionModeDirty = true; -} - -void QGL2PaintEngineEx::renderHintsChanged() -{ - Q_D(QGL2PaintEngineEx); - state()->renderHintsChanged = true; - -#if !defined(QT_OPENGL_ES_2) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - if (!d->ctx->contextHandle()->isOpenGLES()) { - if ((state()->renderHints & QPainter::Antialiasing) -#if QT_DEPRECATED_SINCE(5, 14) - || (state()->renderHints & QPainter::HighQualityAntialiasing) -#endif - ) - d->glEnable(GL_MULTISAMPLE); - else - d->glDisable(GL_MULTISAMPLE); - } -QT_WARNING_POP -#endif - - d->lastTextureUsed = GLuint(-1); - d->brushTextureDirty = true; -// qDebug("QGL2PaintEngineEx::renderHintsChanged() not implemented!"); -} - -void QGL2PaintEngineEx::transformChanged() -{ - Q_D(QGL2PaintEngineEx); - d->matrixDirty = true; - state()->matrixChanged = true; -} - - -static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy) -{ - return QRectF(r.x() * sx, r.y() * sy, r.width() * sx, r.height() * sy); -} - -void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, const QRectF & src) -{ - Q_D(QGL2PaintEngineEx); - QGLContext *ctx = d->ctx; - - int max_texture_size = ctx->d_func()->maxTextureSize(); - if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) { - QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); - - const qreal sx = scaled.width() / qreal(pixmap.width()); - const qreal sy = scaled.height() / qreal(pixmap.height()); - - drawPixmap(dest, scaled, scaleRect(src, sx, sy)); - return; - } - - ensureActive(); - d->transferMode(ImageDrawingMode); - - QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption|QGLContext::CanFlipNativePixmapBindOption; -#ifdef QGL_USE_TEXTURE_POOL - bindOptions |= QGLContext::TemporarilyCachedBindOption; -#endif - - d->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - QGLTexture *texture = - ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, bindOptions); - - GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top(); - GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom(); - QGLRect srcRect(src.left(), top, src.right(), bottom); - - bool isBitmap = pixmap.isQBitmap(); - bool isOpaque = !isBitmap && !pixmap.hasAlpha(); - - d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, - state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); - d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap); - - if (texture->options&QGLContext::TemporarilyCachedBindOption) { - // pixmap was temporarily cached as a QImage texture by pooling system - // and should be destroyed immediately - QGLTextureCache::instance()->remove(ctx, texture->id); - } -} - -void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src, - Qt::ImageConversionFlags) -{ - Q_D(QGL2PaintEngineEx); - QGLContext *ctx = d->ctx; - - int max_texture_size = ctx->d_func()->maxTextureSize(); - if (image.width() > max_texture_size || image.height() > max_texture_size) { - QImage scaled = image.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); - - const qreal sx = scaled.width() / qreal(image.width()); - const qreal sy = scaled.height() / qreal(image.height()); - - drawImage(dest, scaled, scaleRect(src, sx, sy)); - return; - } - - ensureActive(); - d->transferMode(ImageDrawingMode); - - d->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - - QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption; -#ifdef QGL_USE_TEXTURE_POOL - bindOptions |= QGLContext::TemporarilyCachedBindOption; -#endif - - QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, bindOptions); - GLuint id = texture->id; - - d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, - state()->renderHints & QPainter::SmoothPixmapTransform, id); - d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel()); - - if (texture->options&QGLContext::TemporarilyCachedBindOption) { - // image was temporarily cached by texture pooling system - // and should be destroyed immediately - QGLTextureCache::instance()->remove(ctx, texture->id); - } -} - -void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) -{ - Q_D(QGL2PaintEngineEx); - - ensureActive(); - - QPainterState *s = state(); - - // don't try to cache huge fonts or vastly transformed fonts - QFontEngine *fontEngine = textItem->fontEngine(); - if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) { - - QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None - ? fontEngine->glyphFormat : d->glyphCacheFormat; - - if (glyphFormat == QFontEngine::Format_A32) { - if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() - || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate - || (s->composition_mode != QPainter::CompositionMode_Source - && s->composition_mode != QPainter::CompositionMode_SourceOver)) - { - glyphFormat = QFontEngine::Format_A8; - } - } - - d->drawCachedGlyphs(glyphFormat, textItem); - } else { - QPaintEngineEx::drawStaticTextItem(textItem); - } -} - -bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) -{ - Q_D(QGL2PaintEngineEx); - if (!d->shaderManager) - return false; - - ensureActive(); - d->transferMode(ImageDrawingMode); - - d->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - d->glBindTexture(GL_TEXTURE_2D, textureId); - - QGLRect srcRect(src.left(), src.bottom(), src.right(), src.top()); - - d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, - state()->renderHints & QPainter::SmoothPixmapTransform, textureId); - d->drawTexture(dest, srcRect, size, false); - return true; -} - -void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem) -{ - Q_D(QGL2PaintEngineEx); - - ensureActive(); - QGL2PaintEngineState *s = state(); - - const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); - - QTransform::TransformationType txtype = s->matrix.type(); - - QFontEngine::GlyphFormat glyphFormat = ti.fontEngine->glyphFormat != QFontEngine::Format_None - ? ti.fontEngine->glyphFormat : d->glyphCacheFormat; - - if (glyphFormat == QFontEngine::Format_A32) { - if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() - || d->device->alphaRequested() || txtype > QTransform::TxTranslate - || (state()->composition_mode != QPainter::CompositionMode_Source - && state()->composition_mode != QPainter::CompositionMode_SourceOver)) - { - glyphFormat = QFontEngine::Format_A8; - } - } - - if (shouldDrawCachedGlyphs(ti.fontEngine, s->matrix)) { - QVarLengthArray<QFixedPoint> positions; - QVarLengthArray<glyph_t> glyphs; - QTransform matrix = QTransform::fromTranslate(p.x(), p.y()); - ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); - - { - QStaticTextItem staticTextItem; - staticTextItem.setFontEngine(ti.fontEngine); - staticTextItem.glyphs = glyphs.data(); - staticTextItem.numGlyphs = glyphs.size(); - staticTextItem.glyphPositions = positions.data(); - - d->drawCachedGlyphs(glyphFormat, &staticTextItem); - } - return; - } - - QPaintEngineEx::drawTextItem(p, ti); -} - -namespace { - - class QOpenGLStaticTextUserData: public QStaticTextUserData - { - public: - QOpenGLStaticTextUserData() - : QStaticTextUserData(OpenGLUserData), cacheSize(0, 0), cacheSerialNumber(0) - { - } - - ~QOpenGLStaticTextUserData() - { - } - - QSize cacheSize; - QGL2PEXVertexArray vertexCoordinateArray; - QGL2PEXVertexArray textureCoordinateArray; - QFontEngine::GlyphFormat glyphFormat; - int cacheSerialNumber; - }; - -} - - -// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO - -void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat, - QStaticTextItem *staticTextItem) -{ - Q_Q(QGL2PaintEngineEx); - - QGL2PaintEngineState *s = q->state(); - - void *cacheKey = const_cast<QGLContext *>(QGLContextPrivate::contextGroup(ctx)->context()); - bool recreateVertexArrays = false; - - QTransform glyphCacheTransform; - QFontEngine *fe = staticTextItem->fontEngine(); - if (fe->supportsTransformation(s->matrix)) { - // The font-engine supports rendering glyphs with the current transform, so we - // build a glyph-cache with the scale pre-applied, so that the cache contains - // glyphs with the appropriate resolution in the case of retina displays. - glyphCacheTransform = s->matrix.type() < QTransform::TxRotate ? - QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : - QTransform::fromScale( - QVector2D(s->matrix.m11(), s->matrix.m12()).length(), - QVector2D(s->matrix.m21(), s->matrix.m22()).length()); - } - - QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform); - if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == 0) { - cache = new QGLTextureGlyphCache(glyphFormat, glyphCacheTransform); - fe->setGlyphCache(cacheKey, cache); - recreateVertexArrays = true; - } - - if (staticTextItem->userDataNeedsUpdate) { - recreateVertexArrays = true; - } else if (staticTextItem->userData() == 0) { - recreateVertexArrays = true; - } else if (staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) { - recreateVertexArrays = true; - } else { - QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData()); - if (userData->glyphFormat != glyphFormat) { - recreateVertexArrays = true; - } else if (userData->cacheSerialNumber != cache->serialNumber()) { - recreateVertexArrays = true; - } - } - - // We only need to update the cache with new glyphs if we are actually going to recreate the vertex arrays. - // If the cache size has changed, we do need to regenerate the vertices, but we don't need to repopulate the - // cache so this text is performed before we test if the cache size has changed. - if (recreateVertexArrays) { - cache->setPaintEnginePrivate(this); - if (!cache->populate(fe, staticTextItem->numGlyphs, - staticTextItem->glyphs, staticTextItem->glyphPositions)) { - // No space for glyphs in cache. We need to reset it and try again. - cache->clear(); - cache->populate(fe, staticTextItem->numGlyphs, - staticTextItem->glyphs, staticTextItem->glyphPositions); - } - cache->fillInPendingGlyphs(); - } - - if (cache->width() == 0 || cache->height() == 0) - return; - - transferMode(TextDrawingMode); - - int margin = fe->glyphMargin(glyphFormat); - - GLfloat dx = 1.0 / cache->width(); - GLfloat dy = 1.0 / cache->height(); - - // Use global arrays by default - QGL2PEXVertexArray *vertexCoordinates = &vertexCoordinateArray; - QGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray; - - if (staticTextItem->useBackendOptimizations) { - QOpenGLStaticTextUserData *userData = 0; - - if (staticTextItem->userData() == 0 - || staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) { - - userData = new QOpenGLStaticTextUserData(); - staticTextItem->setUserData(userData); - - } else { - userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData()); - } - - userData->glyphFormat = glyphFormat; - userData->cacheSerialNumber = cache->serialNumber(); - - // Use cache if backend optimizations is turned on - vertexCoordinates = &userData->vertexCoordinateArray; - textureCoordinates = &userData->textureCoordinateArray; - - QSize size(cache->width(), cache->height()); - if (userData->cacheSize != size) { - recreateVertexArrays = true; - userData->cacheSize = size; - } - } - - if (recreateVertexArrays) { - vertexCoordinates->clear(); - textureCoordinates->clear(); - - bool supportsSubPixelPositions = fe->supportsSubPixelPositions(); - for (int i=0; i<staticTextItem->numGlyphs; ++i) { - QFixed subPixelPosition; - if (supportsSubPixelPositions) - subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x); - - QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition); - - const QTextureGlyphCache::Coord &c = cache->coords[glyph]; - if (c.isNull()) - continue; - - int x = qFloor(staticTextItem->glyphPositions[i].x.toReal() * cache->transform().m11()) + c.baseLineX - margin; - int y = qRound(staticTextItem->glyphPositions[i].y.toReal() * cache->transform().m22()) - c.baseLineY - margin; - - vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h)); - textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); - } - - staticTextItem->userDataNeedsUpdate = false; - } - - int numGlyphs = vertexCoordinates->vertexCount() / 4; - if (numGlyphs == 0) - return; - - if (elementIndices.size() < numGlyphs*6) { - Q_ASSERT(elementIndices.size() % 6 == 0); - int j = elementIndices.size() / 6 * 4; - while (j < numGlyphs*4) { - elementIndices.append(j + 0); - elementIndices.append(j + 0); - elementIndices.append(j + 1); - elementIndices.append(j + 2); - elementIndices.append(j + 3); - elementIndices.append(j + 3); - - j += 4; - } - -#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) - if (elementIndicesVBOId == 0) - glGenBuffers(1, &elementIndicesVBOId); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementIndicesVBOId); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementIndices.size() * sizeof(GLushort), - elementIndices.constData(), GL_STATIC_DRAW); -#endif - } else { -#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementIndicesVBOId); -#endif - } - - setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data()); - setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data()); - - if (!snapToPixelGrid) { - snapToPixelGrid = true; - matrixDirty = true; - } - - QBrush pensBrush = q->state()->pen.brush(); - setBrush(pensBrush); - - if (glyphFormat == QFontEngine::Format_A32) { - - // Subpixel antialiasing without gamma correction - - QPainter::CompositionMode compMode = q->state()->composition_mode; - Q_ASSERT(compMode == QPainter::CompositionMode_Source - || compMode == QPainter::CompositionMode_SourceOver); - - shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass1); - - if (pensBrush.style() == Qt::SolidPattern) { - // Solid patterns can get away with only one pass. - QColor c = pensBrush.color(); - qreal oldOpacity = q->state()->opacity; - if (compMode == QPainter::CompositionMode_Source) { - c = qt_premultiplyColor(c, q->state()->opacity); - q->state()->opacity = 1; - opacityUniformDirty = true; - } - - compositionModeDirty = false; // I can handle this myself, thank you very much - prepareForCachedGlyphDraw(*cache); - - // prepareForCachedGlyphDraw() have set the opacity on the current shader, so the opacity state can now be reset. - if (compMode == QPainter::CompositionMode_Source) { - q->state()->opacity = oldOpacity; - opacityUniformDirty = true; - } - - glEnable(GL_BLEND); - glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR); - glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); - } else { - // Other brush styles need two passes. - - qreal oldOpacity = q->state()->opacity; - if (compMode == QPainter::CompositionMode_Source) { - q->state()->opacity = 1; - opacityUniformDirty = true; - pensBrush = Qt::white; - setBrush(pensBrush); - } - - compositionModeDirty = false; // I can handle this myself, thank you very much - prepareForCachedGlyphDraw(*cache); - glEnable(GL_BLEND); - glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - - glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); - glBindTexture(GL_TEXTURE_2D, cache->texture()); - updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); - -#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) - glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0); -#else - glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data()); -#endif - - shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass2); - - if (compMode == QPainter::CompositionMode_Source) { - q->state()->opacity = oldOpacity; - opacityUniformDirty = true; - pensBrush = q->state()->pen.brush(); - setBrush(pensBrush); - } - - compositionModeDirty = false; - prepareForCachedGlyphDraw(*cache); - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); - } - compositionModeDirty = true; - } else { - // Grayscale/mono glyphs - - shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); - prepareForCachedGlyphDraw(*cache); - } - - QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest; - if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) { - - glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT); - if (lastMaskTextureUsed != cache->texture()) { - glBindTexture(GL_TEXTURE_2D, cache->texture()); - lastMaskTextureUsed = cache->texture(); - } - - if (cache->filterMode() != filterMode) { - if (filterMode == QGLTextureGlyphCache::Linear) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - cache->setFilterMode(filterMode); - } - } - -#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) - glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -#else - glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data()); -#endif -} - -void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, - QPainter::PixmapFragmentHints hints) -{ - Q_D(QGL2PaintEngineEx); - // Use fallback for extended composition modes. - if (state()->composition_mode > QPainter::CompositionMode_Plus) { - QPaintEngineEx::drawPixmapFragments(fragments, fragmentCount, pixmap, hints); - return; - } - - ensureActive(); - int max_texture_size = d->ctx->d_func()->maxTextureSize(); - if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) { - QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); - d->drawPixmapFragments(fragments, fragmentCount, scaled, hints); - } else { - d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); - } -} - - -void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragment *fragments, - int fragmentCount, const QPixmap &pixmap, - QPainter::PixmapFragmentHints hints) -{ - GLfloat dx = 1.0f / pixmap.size().width(); - GLfloat dy = 1.0f / pixmap.size().height(); - - vertexCoordinateArray.clear(); - textureCoordinateArray.clear(); - opacityArray.reset(); - - if (snapToPixelGrid) { - snapToPixelGrid = false; - matrixDirty = true; - } - - bool allOpaque = true; - - for (int i = 0; i < fragmentCount; ++i) { - qreal s = 0; - qreal c = 1; - if (fragments[i].rotation != 0) { - s = qFastSin(qDegreesToRadians(fragments[i].rotation)); - c = qFastCos(qDegreesToRadians(fragments[i].rotation)); - } - - qreal right = 0.5 * fragments[i].scaleX * fragments[i].width; - qreal bottom = 0.5 * fragments[i].scaleY * fragments[i].height; - QGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c); - QGLPoint bottomLeft(-right * c - bottom * s, -right * s + bottom * c); - - vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); - vertexCoordinateArray.addVertex(-bottomLeft.x + fragments[i].x, -bottomLeft.y + fragments[i].y); - vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); - vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); - vertexCoordinateArray.addVertex(bottomLeft.x + fragments[i].x, bottomLeft.y + fragments[i].y); - vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); - - QGLRect src(fragments[i].sourceLeft * dx, fragments[i].sourceTop * dy, - (fragments[i].sourceLeft + fragments[i].width) * dx, - (fragments[i].sourceTop + fragments[i].height) * dy); - - textureCoordinateArray.addVertex(src.right, src.bottom); - textureCoordinateArray.addVertex(src.right, src.top); - textureCoordinateArray.addVertex(src.left, src.top); - textureCoordinateArray.addVertex(src.left, src.top); - textureCoordinateArray.addVertex(src.left, src.bottom); - textureCoordinateArray.addVertex(src.right, src.bottom); - - qreal opacity = fragments[i].opacity * q->state()->opacity; - opacityArray << opacity << opacity << opacity << opacity << opacity << opacity; - allOpaque &= (opacity >= 0.99f); - } - - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, - QGLContext::InternalBindOption - | QGLContext::CanFlipNativePixmapBindOption); - - if (texture->options & QGLContext::InvertedYBindOption) { - // Flip texture y-coordinate. - QGLPoint *data = textureCoordinateArray.data(); - for (int i = 0; i < 6 * fragmentCount; ++i) - data[i].y = 1 - data[i].y; - } - - transferMode(ImageArrayDrawingMode); - - bool isBitmap = pixmap.isQBitmap(); - bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)) && allOpaque; - - updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, - q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); - - // Setup for texture drawing - currentBrush = noBrush; - shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc - : QGLEngineShaderManager::ImageSrc); - if (prepareForDraw(isOpaque)) - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT); - - if (isBitmap) { - QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); - shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); - } - - glDrawArrays(GL_TRIANGLES, 0, 6 * fragmentCount); -} - -bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) -{ - Q_D(QGL2PaintEngineEx); - -// qDebug("QGL2PaintEngineEx::begin()"); - if (pdev->devType() == QInternal::OpenGL) - d->device = static_cast<QGLPaintDevice*>(pdev); - else - d->device = QGLPaintDevice::getDevice(pdev); - - if (!d->device) - return false; - - d->ctx = d->device->context(); - d->ctx->d_ptr->active_engine = this; - - d->resetOpenGLContextActiveEngine(); - - const QSize sz = d->device->size(); - d->width = sz.width(); - d->height = sz.height(); - d->mode = BrushDrawingMode; - d->brushTextureDirty = true; - d->brushUniformsDirty = true; - d->matrixUniformDirty = true; - d->matrixDirty = true; - d->compositionModeDirty = true; - d->opacityUniformDirty = true; - d->translateZUniformDirty = true; - d->needsSync = true; - d->useSystemClip = !systemClip().isEmpty(); - d->currentBrush = QBrush(); - - d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); - d->stencilClean = true; - - // Calling begin paint should make the correct context current. So, any - // code which calls into GL or otherwise needs a current context *must* - // go after beginPaint: - d->device->beginPaint(); - - d->initializeOpenGLFunctions(); - - d->shaderManager = new QGLEngineShaderManager(d->ctx); - - d->glDisable(GL_STENCIL_TEST); - d->glDisable(GL_DEPTH_TEST); - d->glDisable(GL_SCISSOR_TEST); - -#if !defined(QT_OPENGL_ES_2) - if (!d->ctx->contextHandle()->isOpenGLES()) - d->glDisable(GL_MULTISAMPLE); -#endif - - d->glyphCacheFormat = QFontEngine::Format_A8; - -#if !defined(QT_OPENGL_ES_2) - if (!d->ctx->contextHandle()->isOpenGLES()) { - d->glyphCacheFormat = QFontEngine::Format_A32; - d->multisamplingAlwaysEnabled = false; - } else { - d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers(); - } -#else - // OpenGL ES can't switch MSAA off, so if the gl paint device is - // multisampled, it's always multisampled. - d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers(); -#endif - - return true; -} - -bool QGL2PaintEngineEx::end() -{ - Q_D(QGL2PaintEngineEx); - - QGLContext *ctx = d->ctx; - d->glUseProgram(0); - d->transferMode(BrushDrawingMode); - d->device->endPaint(); - - ctx->d_ptr->active_engine = 0; - ctx->makeCurrent(); - d->resetOpenGLContextActiveEngine(); - d->resetGLState(); - - delete d->shaderManager; - d->shaderManager = 0; - d->currentBrush = QBrush(); - -#ifdef QT_OPENGL_CACHE_AS_VBOS - if (!d->unusedVBOSToClean.isEmpty()) { - d->glDeleteBuffers(d->unusedVBOSToClean.size(), d->unusedVBOSToClean.constData()); - d->unusedVBOSToClean.clear(); - } - if (!d->unusedIBOSToClean.isEmpty()) { - d->glDeleteBuffers(d->unusedIBOSToClean.size(), d->unusedIBOSToClean.constData()); - d->unusedIBOSToClean.clear(); - } -#endif - - return false; -} - -void QGL2PaintEngineEx::ensureActive() -{ - Q_D(QGL2PaintEngineEx); - QGLContext *ctx = d->ctx; - - if (isActive() && (ctx->d_ptr->active_engine != this || d->resetOpenGLContextActiveEngine())) { - ctx->d_ptr->active_engine = this; - d->needsSync = true; - } - - d->device->ensureActiveTarget(); - - if (d->needsSync) { - d->transferMode(BrushDrawingMode); - d->glViewport(0, 0, d->width, d->height); - d->needsSync = false; - d->lastMaskTextureUsed = 0; - d->shaderManager->setDirty(); - d->ctx->d_func()->syncGlState(); - for (int i = 0; i < 3; ++i) - d->vertexAttribPointers[i] = (GLfloat*)-1; // Assume the pointers are clobbered - setState(state()); - } -} - -void QGL2PaintEngineExPrivate::updateClipScissorTest() -{ - Q_Q(QGL2PaintEngineEx); - if (q->state()->clipTestEnabled) { - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); - } else { - glDisable(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 0, 0xff); - } - -#ifdef QT_GL_NO_SCISSOR_TEST - currentScissorBounds = QRect(0, 0, width, height); -#else - QRect bounds = q->state()->rectangleClip; - if (!q->state()->clipEnabled) { - if (useSystemClip) - bounds = systemClip.boundingRect(); - else - bounds = QRect(0, 0, width, height); - } else { - if (useSystemClip) - bounds = bounds.intersected(systemClip.boundingRect()); - else - bounds = bounds.intersected(QRect(0, 0, width, height)); - } - - currentScissorBounds = bounds; - - if (bounds == QRect(0, 0, width, height)) { - glDisable(GL_SCISSOR_TEST); - } else { - glEnable(GL_SCISSOR_TEST); - setScissor(bounds); - } -#endif -} - -void QGL2PaintEngineExPrivate::setScissor(const QRect &rect) -{ - const int left = rect.left(); - const int width = rect.width(); - int bottom = height - (rect.top() + rect.height()); - if (device->isFlipped()) { - bottom = rect.top(); - } - const int height = rect.height(); - - glScissor(left, bottom, width, height); -} - -void QGL2PaintEngineEx::clipEnabledChanged() -{ - Q_D(QGL2PaintEngineEx); - - state()->clipChanged = true; - - if (painter()->hasClipping()) - d->regenerateClip(); - else - d->systemStateChanged(); -} - -void QGL2PaintEngineExPrivate::clearClip(uint value) -{ - dirtyStencilRegion -= currentScissorBounds; - - glStencilMask(0xff); - glClearStencil(value); - glClear(GL_STENCIL_BUFFER_BIT); - glStencilMask(0x0); - - q->state()->needsClipBufferClear = false; -} - -void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value) -{ - transferMode(BrushDrawingMode); - - if (snapToPixelGrid) { - snapToPixelGrid = false; - matrixDirty = true; - } - - if (matrixDirty) - updateMatrix(); - - stencilClean = false; - - const bool singlePass = !path.hasWindingFill() - && (((q->state()->currentClip == maxClip - 1) && q->state()->clipTestEnabled) - || q->state()->needsClipBufferClear); - const uint referenceClipValue = q->state()->needsClipBufferClear ? 1 : q->state()->currentClip; - - if (q->state()->needsClipBufferClear) - clearClip(1); - - if (path.isEmpty()) { - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_LEQUAL, value, ~GL_STENCIL_HIGH_BIT); - return; - } - - if (q->state()->clipTestEnabled) - glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); - else - glStencilFunc(GL_ALWAYS, 0, 0xff); - - vertexCoordinateArray.clear(); - vertexCoordinateArray.addPath(path, inverseScale, false); - - if (!singlePass) - fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); - - glColorMask(false, false, false, false); - glEnable(GL_STENCIL_TEST); - useSimpleShader(); - - if (singlePass) { - // Under these conditions we can set the new stencil value in a single - // pass, by using the current value and the "new value" as the toggles - - glStencilFunc(GL_LEQUAL, referenceClipValue, ~GL_STENCIL_HIGH_BIT); - glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT); - glStencilMask(value ^ referenceClipValue); - - drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN); - } else { - glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - glStencilMask(0xff); - - if (!q->state()->clipTestEnabled && path.hasWindingFill()) { - // Pass when any clip bit is set, set high bit - glStencilFunc(GL_NOTEQUAL, GL_STENCIL_HIGH_BIT, ~GL_STENCIL_HIGH_BIT); - composite(vertexCoordinateArray.boundingRect()); - } - - // Pass when high bit is set, replace stencil value with new clip value - glStencilFunc(GL_NOTEQUAL, value, GL_STENCIL_HIGH_BIT); - - composite(vertexCoordinateArray.boundingRect()); - } - - glStencilFunc(GL_LEQUAL, value, ~GL_STENCIL_HIGH_BIT); - glStencilMask(0); - - glColorMask(true, true, true, true); -} - -void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) -{ -// qDebug("QGL2PaintEngineEx::clip()"); - Q_D(QGL2PaintEngineEx); - - state()->clipChanged = true; - - ensureActive(); - - if (op == Qt::ReplaceClip) { - op = Qt::IntersectClip; - if (d->hasClipOperations()) { - d->systemStateChanged(); - state()->canRestoreClip = false; - } - } - -#ifndef QT_GL_NO_SCISSOR_TEST - if (!path.isEmpty() && op == Qt::IntersectClip && (path.shape() == QVectorPath::RectangleHint)) { - const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); - QRectF rect(points[0], points[2]); - - if (state()->matrix.type() <= QTransform::TxScale - || (state()->matrix.type() == QTransform::TxRotate - && qFuzzyIsNull(state()->matrix.m11()) - && qFuzzyIsNull(state()->matrix.m22()))) - { - state()->rectangleClip = state()->rectangleClip.intersected(state()->matrix.mapRect(rect).toRect()); - d->updateClipScissorTest(); - return; - } - } -#endif - - const QRect pathRect = state()->matrix.mapRect(path.controlPointRect()).toAlignedRect(); - - switch (op) { - case Qt::NoClip: - if (d->useSystemClip) { - state()->clipTestEnabled = true; - state()->currentClip = 1; - } else { - state()->clipTestEnabled = false; - } - state()->rectangleClip = QRect(0, 0, d->width, d->height); - state()->canRestoreClip = false; - d->updateClipScissorTest(); - break; - case Qt::IntersectClip: - state()->rectangleClip = state()->rectangleClip.intersected(pathRect); - d->updateClipScissorTest(); - d->resetClipIfNeeded(); - ++d->maxClip; - d->writeClip(path, d->maxClip); - state()->currentClip = d->maxClip; - state()->clipTestEnabled = true; - break; - default: - break; - } -} - -void QGL2PaintEngineExPrivate::regenerateClip() -{ - systemStateChanged(); - replayClipOperations(); -} - -void QGL2PaintEngineExPrivate::systemStateChanged() -{ - Q_Q(QGL2PaintEngineEx); - - q->state()->clipChanged = true; - - if (systemClip.isEmpty()) { - useSystemClip = false; - } else { - if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) { - QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(currentClipDevice)->window()); - useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter; - } else { - useSystemClip = true; - } - } - - q->state()->clipTestEnabled = false; - q->state()->needsClipBufferClear = true; - - q->state()->currentClip = 1; - maxClip = 1; - - q->state()->rectangleClip = useSystemClip ? systemClip.boundingRect() : QRect(0, 0, width, height); - updateClipScissorTest(); - - if (systemClip.rectCount() == 1) { - if (systemClip.boundingRect() == QRect(0, 0, width, height)) - useSystemClip = false; -#ifndef QT_GL_NO_SCISSOR_TEST - // scissoring takes care of the system clip - return; -#endif - } - - if (useSystemClip) { - clearClip(0); - - QPainterPath path; - path.addRegion(systemClip); - - q->state()->currentClip = 0; - writeClip(qtVectorPathForPath(q->state()->matrix.inverted().map(path)), 1); - q->state()->currentClip = 1; - q->state()->clipTestEnabled = true; - } -} - -void QGL2PaintEngineEx::setTranslateZ(GLfloat z) -{ - Q_D(QGL2PaintEngineEx); - if (d->translateZ != z) { - d->translateZ = z; - d->translateZUniformDirty = true; - } -} - -void QGL2PaintEngineEx::setState(QPainterState *new_state) -{ - // qDebug("QGL2PaintEngineEx::setState()"); - - Q_D(QGL2PaintEngineEx); - - QGL2PaintEngineState *s = static_cast<QGL2PaintEngineState *>(new_state); - QGL2PaintEngineState *old_state = state(); - - QPaintEngineEx::setState(s); - - if (s->isNew) { - // Newly created state object. The call to setState() - // will either be followed by a call to begin(), or we are - // setting the state as part of a save(). - s->isNew = false; - return; - } - - // Setting the state as part of a restore(). - - if (old_state == s || old_state->renderHintsChanged) - renderHintsChanged(); - - if (old_state == s || old_state->matrixChanged) - d->matrixDirty = true; - - if (old_state == s || old_state->compositionModeChanged) - d->compositionModeDirty = true; - - if (old_state == s || old_state->opacityChanged) - d->opacityUniformDirty = true; - - if (old_state == s || old_state->clipChanged) { - if (old_state && old_state != s && old_state->canRestoreClip) { - d->updateClipScissorTest(); - d->glDepthFunc(GL_LEQUAL); - } else { - d->regenerateClip(); - } - } -} - -QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const -{ - if (orig) - const_cast<QGL2PaintEngineEx *>(this)->ensureActive(); - - QGL2PaintEngineState *s; - if (!orig) - s = new QGL2PaintEngineState(); - else - s = new QGL2PaintEngineState(*static_cast<QGL2PaintEngineState *>(orig)); - - s->matrixChanged = false; - s->compositionModeChanged = false; - s->opacityChanged = false; - s->renderHintsChanged = false; - s->clipChanged = false; - - return s; -} - -QGL2PaintEngineState::QGL2PaintEngineState(QGL2PaintEngineState &other) - : QPainterState(other) -{ - isNew = true; - needsClipBufferClear = other.needsClipBufferClear; - clipTestEnabled = other.clipTestEnabled; - currentClip = other.currentClip; - canRestoreClip = other.canRestoreClip; - rectangleClip = other.rectangleClip; -} - -QGL2PaintEngineState::QGL2PaintEngineState() -{ - isNew = true; - needsClipBufferClear = true; - clipTestEnabled = false; - canRestoreClip = true; -} - -QGL2PaintEngineState::~QGL2PaintEngineState() -{ -} - -QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h deleted file mode 100644 index 762aac2f65..0000000000 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ /dev/null @@ -1,334 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPAINTENGINEEX_OPENGL2_P_H -#define QPAINTENGINEEX_OPENGL2_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QDebug> - -#include <private/qpaintengineex_p.h> -#include <private/qglengineshadermanager_p.h> -#include <private/qgl2pexvertexarray_p.h> -#include <private/qglpaintdevice_p.h> -#include <private/qfontengine_p.h> -#include <private/qdatabuffer_p.h> -#include <private/qtriangulatingstroker_p.h> -#include <private/qopenglextensions_p.h> - -enum EngineMode { - ImageDrawingMode, - TextDrawingMode, - BrushDrawingMode, - ImageArrayDrawingMode -}; - -QT_BEGIN_NAMESPACE - -#define GL_STENCIL_HIGH_BIT GLuint(0x80) -#define QT_BRUSH_TEXTURE_UNIT GLuint(0) -#define QT_IMAGE_TEXTURE_UNIT GLuint(0) //Can be the same as brush texture unit -#define QT_MASK_TEXTURE_UNIT GLuint(1) -#define QT_BACKGROUND_TEXTURE_UNIT GLuint(2) - -class QGL2PaintEngineExPrivate; - - -class QGL2PaintEngineState : public QPainterState -{ -public: - QGL2PaintEngineState(QGL2PaintEngineState &other); - QGL2PaintEngineState(); - ~QGL2PaintEngineState(); - - uint isNew : 1; - uint needsClipBufferClear : 1; - uint clipTestEnabled : 1; - uint canRestoreClip : 1; - uint matrixChanged : 1; - uint compositionModeChanged : 1; - uint opacityChanged : 1; - uint renderHintsChanged : 1; - uint clipChanged : 1; - uint currentClip : 8; - - QRect rectangleClip; -}; - -class Q_OPENGL_EXPORT QGL2PaintEngineEx : public QPaintEngineEx -{ - Q_DECLARE_PRIVATE(QGL2PaintEngineEx) -public: - QGL2PaintEngineEx(); - ~QGL2PaintEngineEx(); - - bool begin(QPaintDevice *device) override; - void ensureActive(); - bool end() override; - - virtual void clipEnabledChanged() override; - virtual void penChanged() override; - virtual void brushChanged() override; - virtual void brushOriginChanged() override; - virtual void opacityChanged() override; - virtual void compositionModeChanged() override; - virtual void renderHintsChanged() override; - virtual void transformChanged() override; - - virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; - virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, - QPainter::PixmapFragmentHints hints) override; - virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, - Qt::ImageConversionFlags flags = Qt::AutoColor) override; - virtual void drawTextItem(const QPointF &p, const QTextItem &textItem) override; - virtual void fill(const QVectorPath &path, const QBrush &brush) override; - virtual void stroke(const QVectorPath &path, const QPen &pen) override; - virtual void clip(const QVectorPath &path, Qt::ClipOperation op) override; - - virtual void drawStaticTextItem(QStaticTextItem *textItem) override; - - bool drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr); - - Type type() const override { return OpenGL2; } - - virtual void setState(QPainterState *s) override; - virtual QPainterState *createState(QPainterState *orig) const override; - inline QGL2PaintEngineState *state() { - return static_cast<QGL2PaintEngineState *>(QPaintEngineEx::state()); - } - inline const QGL2PaintEngineState *state() const { - return static_cast<const QGL2PaintEngineState *>(QPaintEngineEx::state()); - } - - void beginNativePainting() override; - void endNativePainting() override; - - void invalidateState(); - - void setRenderTextActive(bool); - - bool isNativePaintingActive() const; - bool requiresPretransformedGlyphPositions(QFontEngine *, const QTransform &) const override { return false; } - bool shouldDrawCachedGlyphs(QFontEngine *, const QTransform &) const override; - - void setTranslateZ(GLfloat z); - -private: - Q_DISABLE_COPY_MOVE(QGL2PaintEngineEx) -}; - -class QGL2PaintEngineExPrivate : public QPaintEngineExPrivate, protected QOpenGLExtensions -{ - Q_DECLARE_PUBLIC(QGL2PaintEngineEx) -public: - enum StencilFillMode { - OddEvenFillMode, - WindingFillMode, - TriStripStrokeFillMode - }; - - QGL2PaintEngineExPrivate(QGL2PaintEngineEx *q_ptr) : - q(q_ptr), - shaderManager(nullptr), - width(0), height(0), - ctx(nullptr), - useSystemClip(true), - elementIndicesVBOId(0), - opacityArray(0), - snapToPixelGrid(false), - nativePaintingActive(false), - inverseScale(1), - lastMaskTextureUsed(0), - translateZ(0) - { } - - ~QGL2PaintEngineExPrivate(); - - void updateBrushTexture(); - void updateBrushUniforms(); - void updateMatrix(); - void updateCompositionMode(); - void updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id = GLuint(-1)); - - void resetGLState(); - bool resetOpenGLContextActiveEngine(); - - // fill, stroke, drawTexture, drawPixmaps & drawCachedGlyphs are the main rendering entry-points, - // however writeClip can also be thought of as en entry point as it does similar things. - void fill(const QVectorPath &path); - void stroke(const QVectorPath &path, const QPen &pen); - void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false); - void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, - QPainter::PixmapFragmentHints hints); - void drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat, QStaticTextItem *staticTextItem); - - // Calls glVertexAttributePointer if the pointer has changed - inline void setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer); - - // draws whatever is in the vertex array: - void drawVertexArrays(const float *data, int *stops, int stopCount, GLenum primitive); - void drawVertexArrays(QGL2PEXVertexArray &vertexArray, GLenum primitive) { - drawVertexArrays((const float *) vertexArray.data(), vertexArray.stops(), vertexArray.stopCount(), primitive); - } - - // Composites the bounding rect onto dest buffer: - void composite(const QGLRect& boundingRect); - - // Calls drawVertexArrays to render into stencil buffer: - void fillStencilWithVertexArray(const float *data, int count, int *stops, int stopCount, const QGLRect &bounds, StencilFillMode mode); - void fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill) { - fillStencilWithVertexArray((const float *) vertexArray.data(), 0, vertexArray.stops(), vertexArray.stopCount(), - vertexArray.boundingRect(), - useWindingFill ? WindingFillMode : OddEvenFillMode); - } - - void setBrush(const QBrush& brush); - void transferMode(EngineMode newMode); - bool prepareForDraw(bool srcPixelsAreOpaque); // returns true if the program has changed - bool prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache); - inline void useSimpleShader(); - inline GLuint location(const QGLEngineShaderManager::Uniform uniform) { - return shaderManager->getUniformLocation(uniform); - } - - void clearClip(uint value); - void writeClip(const QVectorPath &path, uint value); - void resetClipIfNeeded(); - - void updateClipScissorTest(); - void setScissor(const QRect &rect); - void regenerateClip(); - void systemStateChanged() override; - - - static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } - static QGL2PaintEngineExPrivate *getData(QGL2PaintEngineEx *engine) { return engine->d_func(); } - static void cleanupVectorPath(QPaintEngineEx *engine, void *data); - - - QGL2PaintEngineEx* q; - QGLEngineShaderManager* shaderManager; - QGLPaintDevice* device; - int width, height; - QGLContext *ctx; - EngineMode mode; - QFontEngine::GlyphFormat glyphCacheFormat; - - // Dirty flags - bool matrixDirty; // Implies matrix uniforms are also dirty - bool compositionModeDirty; - bool brushTextureDirty; - bool brushUniformsDirty; - bool opacityUniformDirty; - bool matrixUniformDirty; - bool translateZUniformDirty; - - bool stencilClean; // Has the stencil not been used for clipping so far? - bool useSystemClip; - QRegion dirtyStencilRegion; - QRect currentScissorBounds; - uint maxClip; - - QBrush currentBrush; // May not be the state's brush! - const QBrush noBrush; - - QPixmap currentBrushPixmap; - - QGL2PEXVertexArray vertexCoordinateArray; - QGL2PEXVertexArray textureCoordinateArray; - QVector<GLushort> elementIndices; - GLuint elementIndicesVBOId; - QDataBuffer<GLfloat> opacityArray; - GLfloat staticVertexCoordinateArray[8]; - GLfloat staticTextureCoordinateArray[8]; - - bool snapToPixelGrid; - bool nativePaintingActive; - GLfloat pmvMatrix[3][3]; - GLfloat inverseScale; - - GLuint lastTextureUsed; - GLuint lastMaskTextureUsed; - - bool needsSync; - bool multisamplingAlwaysEnabled; - - GLfloat depthRange[2]; - - float textureInvertedY; - - QTriangulatingStroker stroker; - QDashedStrokeProcessor dasher; - - QSet<QVectorPath::CacheEntry *> pathCaches; - QVector<GLuint> unusedVBOSToClean; - QVector<GLuint> unusedIBOSToClean; - - const GLfloat *vertexAttribPointers[3]; - - GLfloat translateZ; -}; - - -void QGL2PaintEngineExPrivate::setVertexAttributePointer(unsigned int arrayIndex, const GLfloat *pointer) -{ - Q_ASSERT(arrayIndex < 3); - if (pointer == vertexAttribPointers[arrayIndex]) - return; - - vertexAttribPointers[arrayIndex] = pointer; - if (arrayIndex == QT_OPACITY_ATTR) - glVertexAttribPointer(arrayIndex, 1, GL_FLOAT, GL_FALSE, 0, pointer); - else - glVertexAttribPointer(arrayIndex, 2, GL_FLOAT, GL_FALSE, 0, pointer); -} - -QT_END_NAMESPACE - -#endif // QPAINTENGINEEX_OPENGL2_P_H diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp deleted file mode 100644 index d5ce4efd1a..0000000000 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtextureglyphcache_gl_p.h" -#include "qpaintengineex_opengl2_p.h" -#include "qglfunctions.h" -#include "private/qglengineshadersource_p.h" - -QT_BEGIN_NAMESPACE - - -static int next_qgltextureglyphcache_serial_number() -{ - static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); - return 1 + serial.fetchAndAddRelaxed(1); -} - -QGLTextureGlyphCache::QGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) - : QImageTextureGlyphCache(format, matrix) - , m_textureResource(0) - , pex(0) - , m_blitProgram(0) - , m_filterMode(Nearest) - , m_serialNumber(next_qgltextureglyphcache_serial_number()) -{ -#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG - qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, QOpenGLContext::currentContext()); -#endif - m_vertexCoordinateArray[0] = -1.0f; - m_vertexCoordinateArray[1] = -1.0f; - m_vertexCoordinateArray[2] = 1.0f; - m_vertexCoordinateArray[3] = -1.0f; - m_vertexCoordinateArray[4] = 1.0f; - m_vertexCoordinateArray[5] = 1.0f; - m_vertexCoordinateArray[6] = -1.0f; - m_vertexCoordinateArray[7] = 1.0f; - - m_textureCoordinateArray[0] = 0.0f; - m_textureCoordinateArray[1] = 0.0f; - m_textureCoordinateArray[2] = 1.0f; - m_textureCoordinateArray[3] = 0.0f; - m_textureCoordinateArray[4] = 1.0f; - m_textureCoordinateArray[5] = 1.0f; - m_textureCoordinateArray[6] = 0.0f; - m_textureCoordinateArray[7] = 1.0f; -} - -QGLTextureGlyphCache::~QGLTextureGlyphCache() -{ -#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG - qDebug(" -> ~QGLTextureGlyphCache() %p.", this); -#endif - delete m_blitProgram; - if (m_textureResource) - m_textureResource->free(); -} - -void QGLTextureGlyphCache::createTextureData(int width, int height) -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - if (ctx == 0) { - qWarning("QGLTextureGlyphCache::createTextureData: Called with no context"); - return; - } - QOpenGLFunctions *funcs = ctx->contextHandle()->functions(); - - // create in QImageTextureGlyphCache baseclass is meant to be called - // only to create the initial image and does not preserve the content, - // so we don't call when this function is called from resize. - if ((!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) && image().isNull()) - QImageTextureGlyphCache::createTextureData(width, height); - - // Make the lower glyph texture size 16 x 16. - if (width < 16) - width = 16; - if (height < 16) - height = 16; - - if (m_textureResource && !m_textureResource->m_texture) { - delete m_textureResource; - m_textureResource = 0; - } - - if (!m_textureResource) - m_textureResource = new QGLGlyphTexture(ctx); - - funcs->glGenTextures(1, &m_textureResource->m_texture); - funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture); - - m_textureResource->m_width = width; - m_textureResource->m_height = height; - - if (m_format == QFontEngine::Format_A32) { - QVarLengthArray<uchar> data(width * height * 4); - for (int i = 0; i < data.size(); ++i) - data[i] = 0; - funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); - } else { - QVarLengthArray<uchar> data(width * height); - for (int i = 0; i < data.size(); ++i) - data[i] = 0; - funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]); - } - - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - m_filterMode = Nearest; -} - -void QGLTextureGlyphCache::resizeTextureData(int width, int height) -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - if (ctx == 0) { - qWarning("QGLTextureGlyphCache::resizeTextureData: Called with no context"); - return; - } - QOpenGLFunctions *funcs = ctx->contextHandle()->functions(); - - int oldWidth = m_textureResource->m_width; - int oldHeight = m_textureResource->m_height; - - // Make the lower glyph texture size 16 x 16. - if (width < 16) - width = 16; - if (height < 16) - height = 16; - - GLuint oldTexture = m_textureResource->m_texture; - createTextureData(width, height); - - if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) { - QImageTextureGlyphCache::resizeTextureData(width, height); - Q_ASSERT(image().depth() == 8); - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); - funcs->glDeleteTextures(1, &oldTexture); - return; - } - - // ### the QTextureGlyphCache API needs to be reworked to allow - // ### resizeTextureData to fail - - ctx->d_ptr->refreshCurrentFbo(); - - funcs->glBindFramebuffer(GL_FRAMEBUFFER, m_textureResource->m_fbo); - - GLuint tmp_texture; - funcs->glGenTextures(1, &tmp_texture); - funcs->glBindTexture(GL_TEXTURE_2D, tmp_texture); - funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - m_filterMode = Nearest; - funcs->glBindTexture(GL_TEXTURE_2D, 0); - funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, tmp_texture, 0); - - funcs->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - funcs->glBindTexture(GL_TEXTURE_2D, oldTexture); - - if (pex != 0) - pex->transferMode(BrushDrawingMode); - - funcs->glDisable(GL_STENCIL_TEST); - funcs->glDisable(GL_DEPTH_TEST); - funcs->glDisable(GL_SCISSOR_TEST); - funcs->glDisable(GL_BLEND); - - funcs->glViewport(0, 0, oldWidth, oldHeight); - - QGLShaderProgram *blitProgram = 0; - if (pex == 0) { - if (m_blitProgram == 0) { - m_blitProgram = new QGLShaderProgram(ctx); - - { - QString source; - source.append(QLatin1String(qglslMainWithTexCoordsVertexShader)); - source.append(QLatin1String(qglslUntransformedPositionVertexShader)); - - QGLShader *vertexShader = new QGLShader(QGLShader::Vertex, m_blitProgram); - vertexShader->compileSourceCode(source); - - m_blitProgram->addShader(vertexShader); - } - - { - QString source; - source.append(QLatin1String(qglslMainFragmentShader)); - source.append(QLatin1String(qglslImageSrcFragmentShader)); - - QGLShader *fragmentShader = new QGLShader(QGLShader::Fragment, m_blitProgram); - fragmentShader->compileSourceCode(source); - - m_blitProgram->addShader(fragmentShader); - } - - m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); - m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); - - m_blitProgram->link(); - } - - funcs->glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray); - funcs->glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray); - - m_blitProgram->bind(); - m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR)); - m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR)); - m_blitProgram->disableAttributeArray(int(QT_OPACITY_ATTR)); - - blitProgram = m_blitProgram; - - } else { - pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray); - pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray); - - pex->shaderManager->useBlitProgram(); - blitProgram = pex->shaderManager->blitProgram(); - } - - blitProgram->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT); - - funcs->glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture); - - funcs->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight); - - funcs->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, 0); - funcs->glDeleteTextures(1, &tmp_texture); - funcs->glDeleteTextures(1, &oldTexture); - - funcs->glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->current_fbo); - - if (pex != 0) { - funcs->glViewport(0, 0, pex->width, pex->height); - pex->updateClipScissorTest(); - } -} - -void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - if (ctx == 0) { - qWarning("QGLTextureGlyphCache::fillTexture: Called with no context"); - return; - } - QOpenGLFunctions *funcs = ctx->contextHandle()->functions(); - - if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) { - QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition); - - funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture); - const QImage &texture = image(); - const uchar *bits = texture.constBits(); - bits += c.y * texture.bytesPerLine() + c.x; - for (int i=0; i<c.h; ++i) { - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, c.w, 1, GL_ALPHA, GL_UNSIGNED_BYTE, bits); - bits += texture.bytesPerLine(); - } - return; - } - - QImage mask = textureMapForGlyph(glyph, subPixelPosition); - const int maskWidth = mask.width(); - const int maskHeight = mask.height(); - - if (mask.format() == QImage::Format_Mono) { - mask = mask.convertToFormat(QImage::Format_Indexed8); - for (int y = 0; y < maskHeight; ++y) { - uchar *src = (uchar *) mask.scanLine(y); - for (int x = 0; x < maskWidth; ++x) - src[x] = -src[x]; // convert 0 and 1 into 0 and 255 - } - } else if (mask.depth() == 32) { - // Make the alpha component equal to the average of the RGB values. - // This is needed when drawing sub-pixel antialiased text on translucent targets. - for (int y = 0; y < maskHeight; ++y) { - quint32 *src = (quint32 *) mask.scanLine(y); - for (int x = 0; x < maskWidth; ++x) { - int r = qRed(src[x]); - int g = qGreen(src[x]); - int b = qBlue(src[x]); - int avg; - if (mask.format() == QImage::Format_RGB32) - avg = (r + g + b + 1) / 3; // "+1" for rounding. - else // Format_ARGB_Premultiplied - avg = qAlpha(src[x]); - if (ctx->contextHandle()->isOpenGLES()) { - // swizzle the bits to accommodate for the GL_RGBA upload. - src[x] = (avg << 24) | (r << 0) | (g << 8) | (b << 16); - } else { - src[x] = (src[x] & 0x00ffffff) | (avg << 24); - } - } - } - } - - funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture); - if (mask.depth() == 32) { - GLenum format = GL_RGBA; -#if !defined(QT_OPENGL_ES_2) - if (!ctx->contextHandle()->isOpenGLES()) - format = GL_BGRA; -#endif - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, format, GL_UNSIGNED_BYTE, mask.bits()); - } else { - // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is - // not a multiple of four bytes. The bug appeared on a computer with 32-bit Windows Vista - // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a - // multiple of four bytes per line, and most of the glyph shows up correctly in the - // texture, which makes me think that this is a driver bug. - // One workaround is to make sure the mask width is a multiple of four bytes, for instance - // by converting it to a format with four bytes per pixel. Another is to copy one line at a - // time. - - if (!ctx->d_ptr->workaround_brokenAlphaTexSubImage_init) { - // don't know which driver versions exhibit this bug, so be conservative for now - const QByteArray vendorString(reinterpret_cast<const char*>(funcs->glGetString(GL_VENDOR))); - ctx->d_ptr->workaround_brokenAlphaTexSubImage = vendorString.indexOf("NVIDIA") >= 0; - ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true; - } - - if (ctx->d_ptr->workaround_brokenAlphaTexSubImage) { - for (int i = 0; i < maskHeight; ++i) - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); - } else { - funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); - } - } -} - -int QGLTextureGlyphCache::glyphPadding() const -{ - return 1; -} - -int QGLTextureGlyphCache::maxTextureWidth() const -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - if (ctx == 0) - return QImageTextureGlyphCache::maxTextureWidth(); - else - return ctx->d_ptr->maxTextureSize(); -} - -int QGLTextureGlyphCache::maxTextureHeight() const -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - if (ctx == 0) - return QImageTextureGlyphCache::maxTextureHeight(); - - if (ctx->d_ptr->workaround_brokenTexSubImage) - return qMin(1024, ctx->d_ptr->maxTextureSize()); - else - return ctx->d_ptr->maxTextureSize(); -} - -void QGLTextureGlyphCache::clear() -{ - m_textureResource->free(); - m_textureResource = 0; - - m_w = 0; - m_h = 0; - m_cx = 0; - m_cy = 0; - m_currentRowHeight = 0; - coords.clear(); -} - -QT_END_NAMESPACE diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h deleted file mode 100644 index 7c12ce8998..0000000000 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTEXTUREGLYPHCACHE_GL_P_H -#define QTEXTUREGLYPHCACHE_GL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <private/qtextureglyphcache_p.h> -#include <private/qgl_p.h> -#include <qglshaderprogram.h> -#include <qglframebufferobject.h> -#include <qopenglfunctions.h> - -// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG - -QT_BEGIN_NAMESPACE - -class QGL2PaintEngineExPrivate; - -struct QGLGlyphTexture : public QOpenGLSharedResource -{ - QGLGlyphTexture(const QGLContext *ctx) - : QOpenGLSharedResource(ctx->contextHandle()->shareGroup()) - , m_fbo(0) - , m_width(0) - , m_height(0) - { - if (ctx && QGLFramebufferObject::hasOpenGLFramebufferObjects() && !ctx->d_ptr->workaround_brokenFBOReadBack) - ctx->contextHandle()->functions()->glGenFramebuffers(1, &m_fbo); - -#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG - qDebug(" -> QGLGlyphTexture() %p for context %p.", this, ctx); -#endif - } - - void freeResource(QOpenGLContext *context) override - { - const QGLContext *ctx = QGLContext::fromOpenGLContext(context); -#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG - qDebug("~QGLGlyphTexture() %p for context %p.", this, ctx); -#else - Q_UNUSED(ctx); -#endif - if (ctx && m_fbo) - ctx->contextHandle()->functions()->glDeleteFramebuffers(1, &m_fbo); - if (m_width || m_height) - ctx->contextHandle()->functions()->glDeleteTextures(1, &m_texture); - } - - void invalidateResource() override - { - m_texture = 0; - m_fbo = 0; - m_width = 0; - m_height = 0; - } - - GLuint m_texture; - GLuint m_fbo; - int m_width; - int m_height; -}; - -class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache -{ -public: - QGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix); - ~QGLTextureGlyphCache(); - - virtual void createTextureData(int width, int height) override; - virtual void resizeTextureData(int width, int height) override; - virtual void fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) override; - virtual int glyphPadding() const override; - virtual int maxTextureWidth() const override; - virtual int maxTextureHeight() const override; - - inline GLuint texture() const { - QGLTextureGlyphCache *that = const_cast<QGLTextureGlyphCache *>(this); - QGLGlyphTexture *glyphTexture = that->m_textureResource; - return glyphTexture ? glyphTexture->m_texture : 0; - } - - inline int width() const { - QGLTextureGlyphCache *that = const_cast<QGLTextureGlyphCache *>(this); - QGLGlyphTexture *glyphTexture = that->m_textureResource; - return glyphTexture ? glyphTexture->m_width : 0; - } - inline int height() const { - QGLTextureGlyphCache *that = const_cast<QGLTextureGlyphCache *>(this); - QGLGlyphTexture *glyphTexture = that->m_textureResource; - return glyphTexture ? glyphTexture->m_height : 0; - } - - inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } - - inline const QOpenGLContextGroup *contextGroup() const { return m_textureResource ? m_textureResource->group() : nullptr; } - - inline int serialNumber() const { return m_serialNumber; } - - enum FilterMode { - Nearest, - Linear - }; - FilterMode filterMode() const { return m_filterMode; } - void setFilterMode(FilterMode m) { m_filterMode = m; } - - void clear(); - -private: - QGLGlyphTexture *m_textureResource; - - QGL2PaintEngineExPrivate *pex; - QGLShaderProgram *m_blitProgram; - FilterMode m_filterMode; - - GLfloat m_vertexCoordinateArray[8]; - GLfloat m_textureCoordinateArray[8]; - - int m_serialNumber; -}; - -QT_END_NAMESPACE - -#endif - diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 8b2349ff2f..811eecaeba 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -1,57 +1,14 @@ TARGET = QtOpenGL -QT = core-private gui-private widgets-private +QT = core-private gui-private DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH -msvc:equals(QT_ARCH, i386): QMAKE_LFLAGS += /BASE:0x63000000 -solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 - QMAKE_DOCS = $$PWD/doc/qtopengl.qdocconf qtConfig(opengl): CONFIG += opengl qtConfig(opengles2): CONFIG += opengles2 -HEADERS += qgl.h \ - qgl_p.h \ - qglcolormap.h \ - qglfunctions.h \ - qglpixelbuffer.h \ - qglpixelbuffer_p.h \ - qglframebufferobject.h \ - qglframebufferobject_p.h \ - qglpaintdevice_p.h \ - qglbuffer.h \ - qtopenglglobal.h - -SOURCES += qgl.cpp \ - qglcolormap.cpp \ - qglfunctions.cpp \ - qglpixelbuffer.cpp \ - qglframebufferobject.cpp \ - qglpaintdevice.cpp \ - qglbuffer.cpp \ - -HEADERS += qglshaderprogram.h \ - gl2paintengineex/qglgradientcache_p.h \ - gl2paintengineex/qglengineshadermanager_p.h \ - gl2paintengineex/qgl2pexvertexarray_p.h \ - gl2paintengineex/qpaintengineex_opengl2_p.h \ - gl2paintengineex/qglengineshadersource_p.h \ - gl2paintengineex/qglcustomshaderstage_p.h \ - gl2paintengineex/qtextureglyphcache_gl_p.h \ - gl2paintengineex/qglshadercache_p.h - -SOURCES += qglshaderprogram.cpp \ - gl2paintengineex/qglgradientcache.cpp \ - gl2paintengineex/qglengineshadermanager.cpp \ - gl2paintengineex/qgl2pexvertexarray.cpp \ - gl2paintengineex/qpaintengineex_opengl2.cpp \ - gl2paintengineex/qglcustomshaderstage.cpp \ - gl2paintengineex/qtextureglyphcache_gl.cpp - -qtConfig(graphicseffect) { - HEADERS += qgraphicsshadereffect_p.h - SOURCES += qgraphicsshadereffect.cpp -} +HEADERS += \ + qtopenglglobal.h load(qt_module) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp deleted file mode 100644 index 4108b70094..0000000000 --- a/src/opengl/qgl.cpp +++ /dev/null @@ -1,5558 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qapplication.h" -#include "qplatformdefs.h" -#include "qgl.h" -#include <qdebug.h> -#include <qglfunctions.h> - -#include <qdatetime.h> - -#include <stdlib.h> // malloc - -#include "qpixmap.h" -#include "qimage.h" -#include "qgl_p.h" - -#include "gl2paintengineex/qpaintengineex_opengl2_p.h" - -#include <qpa/qplatformopenglcontext.h> - -#include <qglpixelbuffer.h> -#include <qglframebufferobject.h> -#include <private/qopenglextensions_p.h> - -#include <private/qimage_p.h> -#include <qpa/qplatformpixmap.h> -#include <private/qglpixelbuffer_p.h> -#include <private/qimagepixmapcleanuphooks_p.h> -#include "qcolormap.h" -#include "qfile.h" -#include <qmutex.h> - -#include "qsurfaceformat.h" -#include <private/qapplication_p.h> -#include <qpa/qplatformopenglcontext.h> -#include <qpa/qplatformwindow.h> - -#ifndef QT_OPENGL_ES_2 -#include <qopenglfunctions_1_1.h> -#endif - -// #define QT_GL_CONTEXT_RESOURCE_DEBUG - -QT_BEGIN_NAMESPACE - -class QGLDefaultExtensions -{ -public: - QGLDefaultExtensions() - { - QGLTemporaryContext tempContext; - Q_ASSERT(QOpenGLContext::currentContext()); - QOpenGLExtensions *ext = qgl_extensions(); - Q_ASSERT(ext); - extensions = ext->openGLExtensions(); - features = ext->openGLFeatures(); - } - - QOpenGLFunctions::OpenGLFeatures features; - QOpenGLExtensions::OpenGLExtensions extensions; -}; - -Q_GLOBAL_STATIC(QGLDefaultExtensions, qtDefaultExtensions) - -bool qgl_hasFeature(QOpenGLFunctions::OpenGLFeature feature) -{ - if (QOpenGLContext::currentContext()) - return QOpenGLContext::currentContext()->functions()->hasOpenGLFeature(feature); - return qtDefaultExtensions()->features & feature; -} - -bool qgl_hasExtension(QOpenGLExtensions::OpenGLExtension extension) -{ - if (QOpenGLContext::currentContext()) - return qgl_extensions()->hasOpenGLExtension(extension); - return qtDefaultExtensions()->extensions & extension; -} - -QOpenGLExtensions::OpenGLExtensions extensions; - -/* - Returns the GL extensions for the current QOpenGLContext. If there is no - current QOpenGLContext, a default context will be created and the extensions - for that context will be returned instead. -*/ -QOpenGLExtensions* qgl_extensions() -{ - if (QOpenGLContext *context = QOpenGLContext::currentContext()) - return static_cast<QOpenGLExtensions *>(context->functions()); - - Q_ASSERT(false); - return 0; -} - -QOpenGLFunctions *qgl_functions() -{ - return qgl_extensions(); // QOpenGLExtensions is just a subclass of QOpenGLFunctions -} - -#ifndef QT_OPENGL_ES_2 -QOpenGLFunctions_1_1 *qgl1_functions() -{ - QOpenGLFunctions_1_1 *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_1>(); - f->initializeOpenGLFunctions(); - return f; -} -#endif - -struct QGLThreadContext { - ~QGLThreadContext() { - if (context) - context->doneCurrent(); - } - QGLContext *context; -}; - -Q_GLOBAL_STATIC(QGLFormat, qgl_default_format) - -class QGLDefaultOverlayFormat: public QGLFormat -{ -public: - inline QGLDefaultOverlayFormat() - { - setOption(QGL::FormatOption(0xffffU << 16)); // turn off all options - setOption(QGL::DirectRendering); - setPlane(1); - } -}; -Q_GLOBAL_STATIC(QGLDefaultOverlayFormat, defaultOverlayFormatInstance) - -Q_GLOBAL_STATIC(QGLSignalProxy, theSignalProxy) -QGLSignalProxy *QGLSignalProxy::instance() -{ - QGLSignalProxy *proxy = theSignalProxy(); - if (proxy && qApp && proxy->thread() != qApp->thread()) { - if (proxy->thread() == QThread::currentThread()) - proxy->moveToThread(qApp->thread()); - } - return proxy; -} - - -/*! - \namespace QGL - \inmodule QtOpenGL - - \brief The QGL namespace specifies miscellaneous identifiers used - in the Qt OpenGL module. -*/ - -/*! - \enum QGL::FormatOption - - This enum specifies the format options that can be used to configure an OpenGL - context. These are set using QGLFormat::setOption(). - - \value DoubleBuffer Specifies the use of double buffering. - \value DepthBuffer Enables the use of a depth buffer. - \value Rgba Specifies that the context should use RGBA as its pixel format. - \value AlphaChannel Enables the use of an alpha channel. - \value AccumBuffer Enables the use of an accumulation buffer. - \value StencilBuffer Enables the use of a stencil buffer. - \value StereoBuffers Enables the use of a stereo buffers for use with visualization hardware. - \value DirectRendering Specifies that the context is used for direct rendering to a display. - \value HasOverlay Enables the use of an overlay. - \value SampleBuffers Enables the use of sample buffers. - \value DeprecatedFunctions Enables the use of deprecated functionality for OpenGL 3.x - contexts. A context with deprecated functionality enabled is - called a full context in the OpenGL specification. - \value SingleBuffer Specifies the use of a single buffer, as opposed to double buffers. - \value NoDepthBuffer Disables the use of a depth buffer. - \value ColorIndex Specifies that the context should use a color index as its pixel format. - \value NoAlphaChannel Disables the use of an alpha channel. - \value NoAccumBuffer Disables the use of an accumulation buffer. - \value NoStencilBuffer Disables the use of a stencil buffer. - \value NoStereoBuffers Disables the use of stereo buffers. - \value IndirectRendering Specifies that the context is used for indirect rendering to a buffer. - \value NoOverlay Disables the use of an overlay. - \value NoSampleBuffers Disables the use of sample buffers. - \value NoDeprecatedFunctions Disables the use of deprecated functionality for OpenGL 3.x - contexts. A context with deprecated functionality disabled is - called a forward compatible context in the OpenGL specification. -*/ - -/***************************************************************************** - QGLFormat implementation - *****************************************************************************/ - - -/*! - \class QGLFormat - \inmodule QtOpenGL - \obsolete - - \brief The QGLFormat class specifies the display format of an OpenGL - rendering context. - - A display format has several characteristics: - \list - \li \l{setDoubleBuffer()}{Double or single buffering.} - \li \l{setDepth()}{Depth buffer.} - \li \l{setRgba()}{RGBA or color index mode.} - \li \l{setAlpha()}{Alpha channel.} - \li \l{setAccum()}{Accumulation buffer.} - \li \l{setStencil()}{Stencil buffer.} - \li \l{setStereo()}{Stereo buffers.} - \li \l{setDirectRendering()}{Direct rendering.} - \li \l{setOverlay()}{Presence of an overlay.} - \li \l{setPlane()}{Plane of an overlay.} - \li \l{setSampleBuffers()}{Multisample buffers.} - \endlist - - You can also specify preferred bit depths for the color buffer, - depth buffer, alpha buffer, accumulation buffer and the stencil - buffer with the functions: setRedBufferSize(), setGreenBufferSize(), - setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(), - setAccumBufferSize() and setStencilBufferSize(). - - Note that even if you specify that you prefer a 32 bit depth - buffer (e.g. with setDepthBufferSize(32)), the format that is - chosen may not have a 32 bit depth buffer, even if there is a - format available with a 32 bit depth buffer. The main reason for - this is how the system dependant picking algorithms work on the - different platforms, and some format options may have higher - precedence than others. - - You create and tell a QGLFormat object what rendering options you - want from an OpenGL rendering context. - - OpenGL drivers or accelerated hardware may or may not support - advanced features such as alpha channel or stereographic viewing. - If you request some features that the driver/hardware does not - provide when you create a QGLWidget, you will get a rendering - context with the nearest subset of features. - - There are different ways to define the display characteristics of - a rendering context. One is to create a QGLFormat and make it the - default for the entire application: - \snippet code/src_opengl_qgl.cpp 0 - - Or you can specify the desired format when creating an object of - your QGLWidget subclass: - \snippet code/src_opengl_qgl.cpp 1 - - After the widget has been created, you can find out which of the - requested features the system was able to provide: - \snippet code/src_opengl_qgl.cpp 2 - - \legalese - OpenGL is a trademark of Silicon Graphics, Inc. in the - United States and other countries. - \endlegalese - - \sa QGLContext, QGLWidget -*/ - -#ifndef QT_OPENGL_ES - -static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]) -{ -#define M(row,col) m[col*4+row] - out[0] = - M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3]; - out[1] = - M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3]; - out[2] = - M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3]; - out[3] = - M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3]; -#undef M -} - -static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, - const GLdouble model[16], const GLdouble proj[16], - const GLint viewport[4], - GLdouble * winx, GLdouble * winy, GLdouble * winz) -{ - GLdouble in[4], out[4]; - - in[0] = objx; - in[1] = objy; - in[2] = objz; - in[3] = 1.0; - transform_point(out, model, in); - transform_point(in, proj, out); - - if (in[3] == 0.0) - return GL_FALSE; - - in[0] /= in[3]; - in[1] /= in[3]; - in[2] /= in[3]; - - *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2; - *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2; - - *winz = (1 + in[2]) / 2; - return GL_TRUE; -} - -#endif // !QT_OPENGL_ES - -/*! - Constructs a QGLFormat object with the following default settings: - \list - \li \l{setDoubleBuffer()}{Double buffer:} Enabled. - \li \l{setDepth()}{Depth buffer:} Enabled. - \li \l{setRgba()}{RGBA:} Enabled (i.e., color index disabled). - \li \l{setAlpha()}{Alpha channel:} Disabled. - \li \l{setAccum()}{Accumulator buffer:} Disabled. - \li \l{setStencil()}{Stencil buffer:} Enabled. - \li \l{setStereo()}{Stereo:} Disabled. - \li \l{setDirectRendering()}{Direct rendering:} Enabled. - \li \l{setOverlay()}{Overlay:} Disabled. - \li \l{setPlane()}{Plane:} 0 (i.e., normal plane). - \li \l{setSampleBuffers()}{Multisample buffers:} Disabled. - \endlist -*/ - -QGLFormat::QGLFormat() -{ - d = new QGLFormatPrivate; -} - - -/*! - Creates a QGLFormat object that is a copy of the current - defaultFormat(). - - If \a options is not 0, the default format is modified by the - specified format options. The \a options parameter should be - QGL::FormatOption values OR'ed together. - - This constructor makes it easy to specify a certain desired format - in classes derived from QGLWidget, for example: - \snippet code/src_opengl_qgl.cpp 3 - - Note that there are QGL::FormatOption values to turn format settings - both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer, - QGL::DirectRendering and QGL::IndirectRendering, etc. - - The \a plane parameter defaults to 0 and is the plane which this - format should be associated with. Not all OpenGL implementations - supports overlay/underlay rendering planes. - - \sa defaultFormat(), setOption(), setPlane() -*/ - -QGLFormat::QGLFormat(QGL::FormatOptions options, int plane) -{ - d = new QGLFormatPrivate; - QGL::FormatOptions newOpts = options; - d->opts = defaultFormat().d->opts; - d->opts |= (newOpts & 0xffff); - d->opts &= ~(newOpts >> 16); - d->pln = plane; -} - -/*! - \internal -*/ -void QGLFormat::detach() -{ - if (d->ref.loadRelaxed() != 1) { - QGLFormatPrivate *newd = new QGLFormatPrivate(d); - if (!d->ref.deref()) - delete d; - d = newd; - } -} - -/*! - Constructs a copy of \a other. -*/ - -QGLFormat::QGLFormat(const QGLFormat &other) -{ - d = other.d; - d->ref.ref(); -} - -/*! - Assigns \a other to this object. -*/ - -QGLFormat &QGLFormat::operator=(const QGLFormat &other) -{ - if (d != other.d) { - other.d->ref.ref(); - if (!d->ref.deref()) - delete d; - d = other.d; - } - return *this; -} - -/*! - Destroys the QGLFormat. -*/ -QGLFormat::~QGLFormat() -{ - if (!d->ref.deref()) - delete d; -} - -/*! - Returns an OpenGL format for the window format specified by \a format. -*/ -QGLFormat QGLFormat::fromSurfaceFormat(const QSurfaceFormat &format) -{ - QGLFormat retFormat; - if (format.alphaBufferSize() >= 0) - retFormat.setAlphaBufferSize(format.alphaBufferSize()); - if (format.blueBufferSize() >= 0) - retFormat.setBlueBufferSize(format.blueBufferSize()); - if (format.greenBufferSize() >= 0) - retFormat.setGreenBufferSize(format.greenBufferSize()); - if (format.redBufferSize() >= 0) - retFormat.setRedBufferSize(format.redBufferSize()); - if (format.depthBufferSize() >= 0) - retFormat.setDepthBufferSize(format.depthBufferSize()); - if (format.samples() > 1) { - retFormat.setSampleBuffers(true); - retFormat.setSamples(format.samples()); - } - if (format.stencilBufferSize() > 0) { - retFormat.setStencil(true); - retFormat.setStencilBufferSize(format.stencilBufferSize()); - } - retFormat.setSwapInterval(format.swapInterval()); - retFormat.setDoubleBuffer(format.swapBehavior() != QSurfaceFormat::SingleBuffer); - retFormat.setStereo(format.stereo()); - retFormat.setVersion(format.majorVersion(), format.minorVersion()); - retFormat.setProfile(static_cast<QGLFormat::OpenGLContextProfile>(format.profile())); - return retFormat; -} - -/*! - Returns a window format for the OpenGL format specified by \a format. -*/ -QSurfaceFormat QGLFormat::toSurfaceFormat(const QGLFormat &format) -{ - QSurfaceFormat retFormat; - if (format.alpha()) - retFormat.setAlphaBufferSize(format.alphaBufferSize() == -1 ? 1 : format.alphaBufferSize()); - if (format.blueBufferSize() >= 0) - retFormat.setBlueBufferSize(format.blueBufferSize()); - if (format.greenBufferSize() >= 0) - retFormat.setGreenBufferSize(format.greenBufferSize()); - if (format.redBufferSize() >= 0) - retFormat.setRedBufferSize(format.redBufferSize()); - if (format.depth()) - retFormat.setDepthBufferSize(format.depthBufferSize() == -1 ? 1 : format.depthBufferSize()); - retFormat.setSwapBehavior(format.doubleBuffer() ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::SingleBuffer); - if (format.sampleBuffers()) - retFormat.setSamples(format.samples() == -1 ? 4 : format.samples()); - if (format.stencil()) - retFormat.setStencilBufferSize(format.stencilBufferSize() == -1 ? 1 : format.stencilBufferSize()); - retFormat.setSwapInterval(format.swapInterval()); - retFormat.setStereo(format.stereo()); - retFormat.setMajorVersion(format.majorVersion()); - retFormat.setMinorVersion(format.minorVersion()); - retFormat.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(format.profile())); - // QGLFormat has no way to set DeprecatedFunctions, that is, to tell that forward - // compatibility should not be requested. Some drivers fail to ignore the fwdcompat - // bit with compatibility profiles so make sure it is not set. - if (format.profile() == QGLFormat::CompatibilityProfile) - retFormat.setOption(QSurfaceFormat::DeprecatedFunctions); - return retFormat; -} - -void QGLContextPrivate::setupSharing() { - Q_Q(QGLContext); - QOpenGLContext *sharedContext = guiGlContext->shareContext(); - if (sharedContext) { - QGLContext *actualSharedContext = QGLContext::fromOpenGLContext(sharedContext); - sharing = true; - QGLContextGroup::addShare(q, actualSharedContext); - } -} - -void QGLContextPrivate::refreshCurrentFbo() -{ - QOpenGLContextPrivate *guiGlContextPrivate = - guiGlContext ? QOpenGLContextPrivate::get(guiGlContext) : 0; - - // if QOpenGLFramebufferObjects have been used in the mean-time, we've lost our cached value - if (guiGlContextPrivate && guiGlContextPrivate->qgl_current_fbo_invalid) { - GLint current; - QOpenGLFunctions *funcs = qgl_functions(); - funcs->glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤t); - - current_fbo = current; - - guiGlContextPrivate->qgl_current_fbo_invalid = false; - } -} - -void QGLContextPrivate::setCurrentFbo(GLuint fbo) -{ - current_fbo = fbo; - - QOpenGLContextPrivate *guiGlContextPrivate = - guiGlContext ? QOpenGLContextPrivate::get(guiGlContext) : 0; - - if (guiGlContextPrivate) - guiGlContextPrivate->qgl_current_fbo_invalid = false; -} - - -/*! - \fn bool QGLFormat::doubleBuffer() const - - Returns \c true if double buffering is enabled; otherwise returns - false. Double buffering is enabled by default. - - \sa setDoubleBuffer() -*/ - -/*! - If \a enable is true sets double buffering; otherwise sets single - buffering. - - Double buffering is enabled by default. - - Double buffering is a technique where graphics are rendered on an - off-screen buffer and not directly to the screen. When the drawing - has been completed, the program calls a swapBuffers() function to - exchange the screen contents with the buffer. The result is - flicker-free drawing and often better performance. - - Note that single buffered contexts are currently not supported - with EGL. - - \sa doubleBuffer(), QGLContext::swapBuffers(), - QGLWidget::swapBuffers() -*/ - -void QGLFormat::setDoubleBuffer(bool enable) -{ - setOption(enable ? QGL::DoubleBuffer : QGL::SingleBuffer); -} - - -/*! - \fn bool QGLFormat::depth() const - - Returns \c true if the depth buffer is enabled; otherwise returns - false. The depth buffer is enabled by default. - - \sa setDepth(), setDepthBufferSize() -*/ - -/*! - If \a enable is true enables the depth buffer; otherwise disables - the depth buffer. - - The depth buffer is enabled by default. - - The purpose of a depth buffer (or Z-buffering) is to remove hidden - surfaces. Pixels are assigned Z values based on the distance to - the viewer. A pixel with a high Z value is closer to the viewer - than a pixel with a low Z value. This information is used to - decide whether to draw a pixel or not. - - \sa depth(), setDepthBufferSize() -*/ - -void QGLFormat::setDepth(bool enable) -{ - setOption(enable ? QGL::DepthBuffer : QGL::NoDepthBuffer); -} - - -/*! - \fn bool QGLFormat::rgba() const - - Returns \c true if RGBA color mode is set. Returns \c false if color - index mode is set. The default color mode is RGBA. - - \sa setRgba() -*/ - -/*! - If \a enable is true sets RGBA mode. If \a enable is false sets - color index mode. - - The default color mode is RGBA. - - RGBA is the preferred mode for most OpenGL applications. In RGBA - color mode you specify colors as red + green + blue + alpha - quadruplets. - - In color index mode you specify an index into a color lookup - table. - - \sa rgba() -*/ - -void QGLFormat::setRgba(bool enable) -{ - setOption(enable ? QGL::Rgba : QGL::ColorIndex); -} - - -/*! - \fn bool QGLFormat::alpha() const - - Returns \c true if the alpha buffer in the framebuffer is enabled; - otherwise returns \c false. The alpha buffer is disabled by default. - - \sa setAlpha(), setAlphaBufferSize() -*/ - -/*! - If \a enable is true enables the alpha buffer; otherwise disables - the alpha buffer. - - The alpha buffer is disabled by default. - - The alpha buffer is typically used for implementing transparency - or translucency. The A in RGBA specifies the transparency of a - pixel. - - \sa alpha(), setAlphaBufferSize() -*/ - -void QGLFormat::setAlpha(bool enable) -{ - setOption(enable ? QGL::AlphaChannel : QGL::NoAlphaChannel); -} - - -/*! - \fn bool QGLFormat::accum() const - - Returns \c true if the accumulation buffer is enabled; otherwise - returns \c false. The accumulation buffer is disabled by default. - - \sa setAccum(), setAccumBufferSize() -*/ - -/*! - If \a enable is true enables the accumulation buffer; otherwise - disables the accumulation buffer. - - The accumulation buffer is disabled by default. - - The accumulation buffer is used to create blur effects and - multiple exposures. - - \sa accum(), setAccumBufferSize() -*/ - -void QGLFormat::setAccum(bool enable) -{ - setOption(enable ? QGL::AccumBuffer : QGL::NoAccumBuffer); -} - - -/*! - \fn bool QGLFormat::stencil() const - - Returns \c true if the stencil buffer is enabled; otherwise returns - false. The stencil buffer is enabled by default. - - \sa setStencil(), setStencilBufferSize() -*/ - -/*! - If \a enable is true enables the stencil buffer; otherwise - disables the stencil buffer. - - The stencil buffer is enabled by default. - - The stencil buffer masks certain parts of the drawing area so that - masked parts are not drawn on. - - \sa stencil(), setStencilBufferSize() -*/ - -void QGLFormat::setStencil(bool enable) -{ - setOption(enable ? QGL::StencilBuffer: QGL::NoStencilBuffer); -} - - -/*! - \fn bool QGLFormat::stereo() const - - Returns \c true if stereo buffering is enabled; otherwise returns - false. Stereo buffering is disabled by default. - - \sa setStereo() -*/ - -/*! - If \a enable is true enables stereo buffering; otherwise disables - stereo buffering. - - Stereo buffering is disabled by default. - - Stereo buffering provides extra color buffers to generate left-eye - and right-eye images. - - \sa stereo() -*/ - -void QGLFormat::setStereo(bool enable) -{ - setOption(enable ? QGL::StereoBuffers : QGL::NoStereoBuffers); -} - - -/*! - \fn bool QGLFormat::directRendering() const - - Returns \c true if direct rendering is enabled; otherwise returns - false. - - Direct rendering is enabled by default. - - \sa setDirectRendering() -*/ - -/*! - If \a enable is true enables direct rendering; otherwise disables - direct rendering. - - Direct rendering is enabled by default. - - Enabling this option will make OpenGL bypass the underlying window - system and render directly from hardware to the screen, if this is - supported by the system. - - \sa directRendering() -*/ - -void QGLFormat::setDirectRendering(bool enable) -{ - setOption(enable ? QGL::DirectRendering : QGL::IndirectRendering); -} - -/*! - \fn bool QGLFormat::sampleBuffers() const - - Returns \c true if multisample buffer support is enabled; otherwise - returns \c false. - - The multisample buffer is disabled by default. - - \sa setSampleBuffers() -*/ - -/*! - If \a enable is true, a GL context with multisample buffer support - is picked; otherwise ignored. - - \sa sampleBuffers(), setSamples(), samples() -*/ -void QGLFormat::setSampleBuffers(bool enable) -{ - setOption(enable ? QGL::SampleBuffers : QGL::NoSampleBuffers); -} - -/*! - Returns the number of samples per pixel when multisampling is - enabled. By default, the highest number of samples that is - available is used. - - \sa setSampleBuffers(), sampleBuffers(), setSamples() -*/ -int QGLFormat::samples() const -{ - return d->numSamples; -} - -/*! - Set the preferred number of samples per pixel when multisampling - is enabled to \a numSamples. By default, the highest number of - samples available is used. - - \sa setSampleBuffers(), sampleBuffers(), samples() -*/ -void QGLFormat::setSamples(int numSamples) -{ - detach(); - if (numSamples < 0) { - qWarning("QGLFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples); - return; - } - d->numSamples = numSamples; - setSampleBuffers(numSamples > 0); -} - -/*! - \since 4.2 - - Set the preferred swap interval. This can be used to sync the GL - drawing into a system window to the vertical refresh of the screen. - Setting an \a interval value of 0 will turn the vertical refresh syncing - off, any value higher than 0 will turn the vertical syncing on. - - Under Windows and under X11, where the \c{WGL_EXT_swap_control} - and \c{GLX_SGI_video_sync} extensions are used, the \a interval - parameter can be used to set the minimum number of video frames - that are displayed before a buffer swap will occur. In effect, - setting the \a interval to 10, means there will be 10 vertical - retraces between every buffer swap. - - Under Windows the \c{WGL_EXT_swap_control} extension has to be present, - and under X11 the \c{GLX_SGI_video_sync} extension has to be present. -*/ -void QGLFormat::setSwapInterval(int interval) -{ - detach(); - d->swapInterval = interval; -} - -/*! - \since 4.2 - - Returns the currently set swap interval. -1 is returned if setting - the swap interval isn't supported in the system GL implementation. -*/ -int QGLFormat::swapInterval() const -{ - return d->swapInterval; -} - -/*! - \fn bool QGLFormat::hasOverlay() const - - Returns \c true if overlay plane is enabled; otherwise returns \c false. - - Overlay is disabled by default. - - \sa setOverlay() -*/ - -/*! - If \a enable is true enables an overlay plane; otherwise disables - the overlay plane. - - Enabling the overlay plane will cause QGLWidget to create an - additional context in an overlay plane. See the QGLWidget - documentation for further information. - - \sa hasOverlay() -*/ - -void QGLFormat::setOverlay(bool enable) -{ - setOption(enable ? QGL::HasOverlay : QGL::NoOverlay); -} - -/*! - Returns the plane of this format. The default for normal formats - is 0, which means the normal plane. The default for overlay - formats is 1, which is the first overlay plane. - - \sa setPlane(), defaultOverlayFormat() -*/ -int QGLFormat::plane() const -{ - return d->pln; -} - -/*! - Sets the requested plane to \a plane. 0 is the normal plane, 1 is - the first overlay plane, 2 is the second overlay plane, etc.; -1, - -2, etc. are underlay planes. - - Note that in contrast to other format specifications, the plane - specifications will be matched exactly. This means that if you - specify a plane that the underlying OpenGL system cannot provide, - an \l{QGLWidget::isValid()}{invalid} QGLWidget will be - created. - - \sa plane() -*/ -void QGLFormat::setPlane(int plane) -{ - detach(); - d->pln = plane; -} - -/*! - Sets the format option to \a opt. - - \sa testOption() -*/ - -void QGLFormat::setOption(QGL::FormatOptions opt) -{ - detach(); - if (opt & 0xffff) - d->opts |= opt; - else - d->opts &= ~(opt >> 16); -} - - - -/*! - Returns \c true if format option \a opt is set; otherwise returns \c false. - - \sa setOption() -*/ - -bool QGLFormat::testOption(QGL::FormatOptions opt) const -{ - if (opt & 0xffff) - return (d->opts & opt) != 0; - else - return (d->opts & (opt >> 16)) == 0; -} - -/*! - Set the minimum depth buffer size to \a size. - - \sa depthBufferSize(), setDepth(), depth() -*/ -void QGLFormat::setDepthBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size); - return; - } - d->depthSize = size; - setDepth(size > 0); -} - -/*! - Returns the depth buffer size. - - \sa depth(), setDepth(), setDepthBufferSize() -*/ -int QGLFormat::depthBufferSize() const -{ - return d->depthSize; -} - -/*! - \since 4.2 - - Set the preferred red buffer size to \a size. - - \sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize() -*/ -void QGLFormat::setRedBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setRedBufferSize: Cannot set negative red buffer size %d", size); - return; - } - d->redSize = size; -} - -/*! - \since 4.2 - - Returns the red buffer size. - - \sa setRedBufferSize() -*/ -int QGLFormat::redBufferSize() const -{ - return d->redSize; -} - -/*! - \since 4.2 - - Set the preferred green buffer size to \a size. - - \sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize() -*/ -void QGLFormat::setGreenBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size); - return; - } - d->greenSize = size; -} - -/*! - \since 4.2 - - Returns the green buffer size. - - \sa setGreenBufferSize() -*/ -int QGLFormat::greenBufferSize() const -{ - return d->greenSize; -} - -/*! - \since 4.2 - - Set the preferred blue buffer size to \a size. - - \sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize() -*/ -void QGLFormat::setBlueBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size); - return; - } - d->blueSize = size; -} - -/*! - \since 4.2 - - Returns the blue buffer size. - - \sa setBlueBufferSize() -*/ -int QGLFormat::blueBufferSize() const -{ - return d->blueSize; -} - -/*! - Set the preferred alpha buffer size to \a size. - This function implicitly enables the alpha channel. - - \sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize() -*/ -void QGLFormat::setAlphaBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size); - return; - } - d->alphaSize = size; - setAlpha(size > 0); -} - -/*! - Returns the alpha buffer size. - - \sa alpha(), setAlpha(), setAlphaBufferSize() -*/ -int QGLFormat::alphaBufferSize() const -{ - return d->alphaSize; -} - -/*! - Set the preferred accumulation buffer size, where \a size is the - bit depth for each RGBA component. - - \sa accum(), setAccum(), accumBufferSize() -*/ -void QGLFormat::setAccumBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size); - return; - } - d->accumSize = size; - setAccum(size > 0); -} - -/*! - Returns the accumulation buffer size. - - \sa setAccumBufferSize(), accum(), setAccum() -*/ -int QGLFormat::accumBufferSize() const -{ - return d->accumSize; -} - -/*! - Set the preferred stencil buffer size to \a size. - - \sa stencilBufferSize(), setStencil(), stencil() -*/ -void QGLFormat::setStencilBufferSize(int size) -{ - detach(); - if (size < 0) { - qWarning("QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size); - return; - } - d->stencilSize = size; - setStencil(size > 0); -} - -/*! - Returns the stencil buffer size. - - \sa stencil(), setStencil(), setStencilBufferSize() -*/ -int QGLFormat::stencilBufferSize() const -{ - return d->stencilSize; -} - -/*! - \since 4.7 - - Set the OpenGL version to the \a major and \a minor numbers. If a - context compatible with the requested OpenGL version cannot be - created, a context compatible with version 1.x is created instead. - - \sa majorVersion(), minorVersion() -*/ -void QGLFormat::setVersion(int major, int minor) -{ - if (major < 1 || minor < 0) { - qWarning("QGLFormat::setVersion: Cannot set zero or negative version number %d.%d", major, minor); - return; - } - detach(); - d->majorVersion = major; - d->minorVersion = minor; -} - -/*! - \since 4.7 - - Returns the OpenGL major version. - - \sa setVersion(), minorVersion() -*/ -int QGLFormat::majorVersion() const -{ - return d->majorVersion; -} - -/*! - \since 4.7 - - Returns the OpenGL minor version. - - \sa setVersion(), majorVersion() -*/ -int QGLFormat::minorVersion() const -{ - return d->minorVersion; -} - -/*! - \enum QGLFormat::OpenGLContextProfile - \since 4.7 - - This enum describes the OpenGL context profiles that can be - specified for contexts implementing OpenGL version 3.2 or - higher. These profiles are different from OpenGL ES profiles. - - \value NoProfile OpenGL version is lower than 3.2. - \value CoreProfile Functionality deprecated in OpenGL version 3.0 is not available. - \value CompatibilityProfile Functionality from earlier OpenGL versions is available. -*/ - -/*! - \since 4.7 - - Set the OpenGL context profile to \a profile. The \a profile is - ignored if the requested OpenGL version is less than 3.2. - - \sa profile() -*/ -void QGLFormat::setProfile(OpenGLContextProfile profile) -{ - detach(); - d->profile = profile; -} - -/*! - \since 4.7 - - Returns the OpenGL context profile. - - \sa setProfile() -*/ -QGLFormat::OpenGLContextProfile QGLFormat::profile() const -{ - return d->profile; -} - - -/*! - \fn bool QGLFormat::hasOpenGL() - - Returns \c true if the window system has any OpenGL support; - otherwise returns \c false. - - \warning This function must not be called until the QApplication - object has been created. -*/ -bool QGLFormat::hasOpenGL() -{ - return QApplicationPrivate::platformIntegration() - ->hasCapability(QPlatformIntegration::OpenGL); -} - -/*! - \fn bool QGLFormat::hasOpenGLOverlays() - - Returns \c true if the window system supports OpenGL overlays; - otherwise returns \c false. - - \warning This function must not be called until the QApplication - object has been created. -*/ -bool QGLFormat::hasOpenGLOverlays() -{ - return false; -} - -QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(const QString &versionString) -{ - QGLFormat::OpenGLVersionFlags versionFlags = QGLFormat::OpenGL_Version_None; - - if (versionString.startsWith(QLatin1String("OpenGL ES"))) { - const auto parts = versionString.splitRef(QLatin1Char(' ')); - if (parts.size() >= 3) { - if (parts[2].startsWith(QLatin1String("1."))) { - if (parts[1].endsWith(QLatin1String("-CM"))) { - versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_0 | - QGLFormat::OpenGL_ES_CommonLite_Version_1_0; - if (parts[2].startsWith(QLatin1String("1.1"))) - versionFlags |= QGLFormat::OpenGL_ES_Common_Version_1_1 | - QGLFormat::OpenGL_ES_CommonLite_Version_1_1; - } else { - // Not -CM, must be CL, CommonLite - versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_0; - if (parts[2].startsWith(QLatin1String("1.1"))) - versionFlags |= QGLFormat::OpenGL_ES_CommonLite_Version_1_1; - } - } else { - // OpenGL ES version 2.0 or higher - versionFlags |= QGLFormat::OpenGL_ES_Version_2_0; - } - } else { - // if < 3 parts to the name, it is an unrecognised OpenGL ES - qWarning("Unrecognised OpenGL ES version"); - } - } else { - // not ES, regular OpenGL, the version numbers are first in the string - if (versionString.startsWith(QLatin1String("1."))) { - switch (versionString[2].toLatin1()) { - case '5': - versionFlags |= QGLFormat::OpenGL_Version_1_5; - Q_FALLTHROUGH(); - case '4': - versionFlags |= QGLFormat::OpenGL_Version_1_4; - Q_FALLTHROUGH(); - case '3': - versionFlags |= QGLFormat::OpenGL_Version_1_3; - Q_FALLTHROUGH(); - case '2': - versionFlags |= QGLFormat::OpenGL_Version_1_2; - Q_FALLTHROUGH(); - case '1': - versionFlags |= QGLFormat::OpenGL_Version_1_1; - Q_FALLTHROUGH(); - default: - break; - } - } else if (versionString.startsWith(QLatin1String("2."))) { - versionFlags |= QGLFormat::OpenGL_Version_1_1 | - QGLFormat::OpenGL_Version_1_2 | - QGLFormat::OpenGL_Version_1_3 | - QGLFormat::OpenGL_Version_1_4 | - QGLFormat::OpenGL_Version_1_5 | - QGLFormat::OpenGL_Version_2_0; - if (versionString[2].toLatin1() == '1') - versionFlags |= QGLFormat::OpenGL_Version_2_1; - } else if (versionString.startsWith(QLatin1String("3."))) { - versionFlags |= QGLFormat::OpenGL_Version_1_1 | - QGLFormat::OpenGL_Version_1_2 | - QGLFormat::OpenGL_Version_1_3 | - QGLFormat::OpenGL_Version_1_4 | - QGLFormat::OpenGL_Version_1_5 | - QGLFormat::OpenGL_Version_2_0 | - QGLFormat::OpenGL_Version_2_1 | - QGLFormat::OpenGL_Version_3_0; - switch (versionString[2].toLatin1()) { - case '3': - versionFlags |= QGLFormat::OpenGL_Version_3_3; - Q_FALLTHROUGH(); - case '2': - versionFlags |= QGLFormat::OpenGL_Version_3_2; - Q_FALLTHROUGH(); - case '1': - versionFlags |= QGLFormat::OpenGL_Version_3_1; - Q_FALLTHROUGH(); - case '0': - break; - default: - versionFlags |= QGLFormat::OpenGL_Version_3_1 | - QGLFormat::OpenGL_Version_3_2 | - QGLFormat::OpenGL_Version_3_3; - break; - } - } else if (versionString.startsWith(QLatin1String("4."))) { - versionFlags |= QGLFormat::OpenGL_Version_1_1 | - QGLFormat::OpenGL_Version_1_2 | - QGLFormat::OpenGL_Version_1_3 | - QGLFormat::OpenGL_Version_1_4 | - QGLFormat::OpenGL_Version_1_5 | - QGLFormat::OpenGL_Version_2_0 | - QGLFormat::OpenGL_Version_2_1 | - QGLFormat::OpenGL_Version_3_0 | - QGLFormat::OpenGL_Version_3_1 | - QGLFormat::OpenGL_Version_3_2 | - QGLFormat::OpenGL_Version_3_3 | - QGLFormat::OpenGL_Version_4_0; - switch (versionString[2].toLatin1()) { - case '3': - versionFlags |= QGLFormat::OpenGL_Version_4_3; - Q_FALLTHROUGH(); - case '2': - versionFlags |= QGLFormat::OpenGL_Version_4_2; - Q_FALLTHROUGH(); - case '1': - versionFlags |= QGLFormat::OpenGL_Version_4_1; - Q_FALLTHROUGH(); - case '0': - break; - default: - versionFlags |= QGLFormat::OpenGL_Version_4_1 | - QGLFormat::OpenGL_Version_4_2 | - QGLFormat::OpenGL_Version_4_3; - break; - } - } else { - versionFlags |= QGLFormat::OpenGL_Version_1_1 | - QGLFormat::OpenGL_Version_1_2 | - QGLFormat::OpenGL_Version_1_3 | - QGLFormat::OpenGL_Version_1_4 | - QGLFormat::OpenGL_Version_1_5 | - QGLFormat::OpenGL_Version_2_0 | - QGLFormat::OpenGL_Version_2_1 | - QGLFormat::OpenGL_Version_3_0 | - QGLFormat::OpenGL_Version_3_1 | - QGLFormat::OpenGL_Version_3_2 | - QGLFormat::OpenGL_Version_3_3 | - QGLFormat::OpenGL_Version_4_0 | - QGLFormat::OpenGL_Version_4_1 | - QGLFormat::OpenGL_Version_4_2 | - QGLFormat::OpenGL_Version_4_3; - } - } - return versionFlags; -} - -/*! - \enum QGLFormat::OpenGLVersionFlag - \since 4.2 - - This enum describes the various OpenGL versions that are - recognized by Qt. Use the QGLFormat::openGLVersionFlags() function - to identify which versions that are supported at runtime. - - \value OpenGL_Version_None If no OpenGL is present or if no OpenGL context is current. - - \value OpenGL_Version_1_1 OpenGL version 1.1 or higher is present. - - \value OpenGL_Version_1_2 OpenGL version 1.2 or higher is present. - - \value OpenGL_Version_1_3 OpenGL version 1.3 or higher is present. - - \value OpenGL_Version_1_4 OpenGL version 1.4 or higher is present. - - \value OpenGL_Version_1_5 OpenGL version 1.5 or higher is present. - - \value OpenGL_Version_2_0 OpenGL version 2.0 or higher is present. - Note that version 2.0 supports all the functionality of version 1.5. - - \value OpenGL_Version_2_1 OpenGL version 2.1 or higher is present. - - \value OpenGL_Version_3_0 OpenGL version 3.0 or higher is present. - - \value OpenGL_Version_3_1 OpenGL version 3.1 or higher is present. - Note that OpenGL version 3.1 or higher does not necessarily support all the features of - version 3.0 and lower. - - \value OpenGL_Version_3_2 OpenGL version 3.2 or higher is present. - - \value OpenGL_Version_3_3 OpenGL version 3.3 or higher is present. - - \value OpenGL_Version_4_0 OpenGL version 4.0 or higher is present. - - \value OpenGL_Version_4_1 OpenGL version 4.1 or higher is present. - - \value OpenGL_Version_4_2 OpenGL version 4.2 or higher is present. - - \value OpenGL_Version_4_3 OpenGL version 4.3 or higher is present. - - \value OpenGL_ES_CommonLite_Version_1_0 OpenGL ES version 1.0 Common Lite or higher is present. - - \value OpenGL_ES_Common_Version_1_0 OpenGL ES version 1.0 Common or higher is present. - The Common profile supports all the features of Common Lite. - - \value OpenGL_ES_CommonLite_Version_1_1 OpenGL ES version 1.1 Common Lite or higher is present. - - \value OpenGL_ES_Common_Version_1_1 OpenGL ES version 1.1 Common or higher is present. - The Common profile supports all the features of Common Lite. - - \value OpenGL_ES_Version_2_0 OpenGL ES version 2.0 or higher is present. - Note that OpenGL ES version 2.0 does not support all the features of OpenGL ES 1.x. - So if OpenGL_ES_Version_2_0 is returned, none of the ES 1.x flags are returned. - - See also \l{http://www.opengl.org} for more information about the different - revisions of OpenGL. - - \sa openGLVersionFlags() -*/ - -/*! - \since 4.2 - - Identifies, at runtime, which OpenGL versions that are supported - by the current platform. - - Note that if OpenGL version 1.5 is supported, its predecessors - (i.e., version 1.4 and lower) are also supported. To identify the - support of a particular feature, like multi texturing, test for - the version in which the feature was first introduced (i.e., - version 1.3 in the case of multi texturing) to adapt to the largest - possible group of runtime platforms. - - This function needs a valid current OpenGL context to work; - otherwise it will return OpenGL_Version_None. - - \sa hasOpenGL(), hasOpenGLOverlays() -*/ -QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags() -{ - static bool cachedDefault = false; - static OpenGLVersionFlags defaultVersionFlags = OpenGL_Version_None; - QGLContext *currentCtx = const_cast<QGLContext *>(QGLContext::currentContext()); - QGLTemporaryContext *tmpContext = 0; - - if (currentCtx && currentCtx->d_func()->version_flags_cached) - return currentCtx->d_func()->version_flags; - - if (!currentCtx) { - if (cachedDefault) { - return defaultVersionFlags; - } else { - if (!hasOpenGL()) - return defaultVersionFlags; - tmpContext = new QGLTemporaryContext; - cachedDefault = true; - } - } - - QString versionString(QLatin1String(reinterpret_cast<const char*>(qgl_functions()->glGetString(GL_VERSION)))); - OpenGLVersionFlags versionFlags = qOpenGLVersionFlagsFromString(versionString); - if (currentCtx) { - currentCtx->d_func()->version_flags_cached = true; - currentCtx->d_func()->version_flags = versionFlags; - } - if (tmpContext) { - defaultVersionFlags = versionFlags; - delete tmpContext; - } - - return versionFlags; -} - - -/*! - Returns the default QGLFormat for the application. All QGLWidget - objects that are created use this format unless another format is - specified, e.g. when they are constructed. - - If no special default format has been set using - setDefaultFormat(), the default format is the same as that created - with QGLFormat(). - - \sa setDefaultFormat() -*/ - -QGLFormat QGLFormat::defaultFormat() -{ - return *qgl_default_format(); -} - -/*! - Sets a new default QGLFormat for the application to \a f. For - example, to set single buffering as the default instead of double - buffering, your main() might contain code like this: - \snippet code/src_opengl_qgl.cpp 4 - - \sa defaultFormat() -*/ - -void QGLFormat::setDefaultFormat(const QGLFormat &f) -{ - *qgl_default_format() = f; -} - - -/*! - Returns the default QGLFormat for overlay contexts. - - The default overlay format is: - \list - \li \l{setDoubleBuffer()}{Double buffer:} Disabled. - \li \l{setDepth()}{Depth buffer:} Disabled. - \li \l{setRgba()}{RGBA:} Disabled (i.e., color index enabled). - \li \l{setAlpha()}{Alpha channel:} Disabled. - \li \l{setAccum()}{Accumulator buffer:} Disabled. - \li \l{setStencil()}{Stencil buffer:} Disabled. - \li \l{setStereo()}{Stereo:} Disabled. - \li \l{setDirectRendering()}{Direct rendering:} Enabled. - \li \l{setOverlay()}{Overlay:} Disabled. - \li \l{setSampleBuffers()}{Multisample buffers:} Disabled. - \li \l{setPlane()}{Plane:} 1 (i.e., first overlay plane). - \endlist - - \sa setDefaultFormat() -*/ - -QGLFormat QGLFormat::defaultOverlayFormat() -{ - return *defaultOverlayFormatInstance(); -} - -/*! - Sets a new default QGLFormat for overlay contexts to \a f. This - format is used whenever a QGLWidget is created with a format that - hasOverlay() enabled. - - For example, to get a double buffered overlay context (if - available), use code like this: - - \snippet code/src_opengl_qgl.cpp 5 - - As usual, you can find out after widget creation whether the - underlying OpenGL system was able to provide the requested - specification: - - \snippet code/src_opengl_qgl.cpp 6 - - \sa defaultOverlayFormat() -*/ - -void QGLFormat::setDefaultOverlayFormat(const QGLFormat &f) -{ - QGLFormat *defaultFormat = defaultOverlayFormatInstance(); - *defaultFormat = f; - // Make sure the user doesn't request that the overlays themselves - // have overlays, since it is unlikely that the system supports - // infinitely many planes... - defaultFormat->setOverlay(false); -} - - -/*! - Returns \c true if all the options of the two QGLFormat objects - \a a and \a b are equal; otherwise returns \c false. - - \relates QGLFormat -*/ - -bool operator==(const QGLFormat& a, const QGLFormat& b) -{ - return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts - && a.d->pln == b.d->pln - && a.d->alphaSize == b.d->alphaSize - && a.d->accumSize == b.d->accumSize - && a.d->stencilSize == b.d->stencilSize - && a.d->depthSize == b.d->depthSize - && a.d->redSize == b.d->redSize - && a.d->greenSize == b.d->greenSize - && a.d->blueSize == b.d->blueSize - && a.d->numSamples == b.d->numSamples - && a.d->swapInterval == b.d->swapInterval - && a.d->majorVersion == b.d->majorVersion - && a.d->minorVersion == b.d->minorVersion - && a.d->profile == b.d->profile); -} - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QGLFormat &f) -{ - const QGLFormatPrivate * const d = f.d; - - QDebugStateSaver saver(dbg); - dbg.nospace() << "QGLFormat(" - << "options " << d->opts - << ", plane " << d->pln - << ", depthBufferSize " << d->depthSize - << ", accumBufferSize " << d->accumSize - << ", stencilBufferSize " << d->stencilSize - << ", redBufferSize " << d->redSize - << ", greenBufferSize " << d->greenSize - << ", blueBufferSize " << d->blueSize - << ", alphaBufferSize " << d->alphaSize - << ", samples " << d->numSamples - << ", swapInterval " << d->swapInterval - << ", majorVersion " << d->majorVersion - << ", minorVersion " << d->minorVersion - << ", profile " << d->profile - << ')'; - - return dbg; -} -#endif - - -/*! - Returns \c false if all the options of the two QGLFormat objects - \a a and \a b are equal; otherwise returns \c true. - - \relates QGLFormat -*/ - -bool operator!=(const QGLFormat& a, const QGLFormat& b) -{ - return !(a == b); -} - -struct QGLContextGroupList { - void append(QGLContextGroup *group) { - QMutexLocker locker(&m_mutex); - m_list.append(group); - } - - void remove(QGLContextGroup *group) { - QMutexLocker locker(&m_mutex); - m_list.removeOne(group); - } - - QList<QGLContextGroup *> m_list; - QRecursiveMutex m_mutex; -}; - -Q_GLOBAL_STATIC(QGLContextGroupList, qt_context_groups) - -/***************************************************************************** - QGLContext implementation - *****************************************************************************/ - -QGLContextGroup::QGLContextGroup(const QGLContext *context) - : m_context(context), m_refs(1) -{ - qt_context_groups()->append(this); -} - -QGLContextGroup::~QGLContextGroup() -{ - qt_context_groups()->remove(this); -} - -const QGLContext *qt_gl_transfer_context(const QGLContext *ctx) -{ - if (!ctx) - return 0; - QList<const QGLContext *> shares - (QGLContextPrivate::contextGroup(ctx)->shares()); - if (shares.size() >= 2) - return (ctx == shares.at(0)) ? shares.at(1) : shares.at(0); - else - return 0; -} - -QGLContextPrivate::QGLContextPrivate(QGLContext *context) - : internal_context(false) - , q_ptr(context) - , texture_destroyer(0) - , functions(0) -{ - group = new QGLContextGroup(context); - - texture_destroyer = new QGLTextureDestroyer; -} - -QGLContextPrivate::~QGLContextPrivate() -{ - delete functions; - - if (!group->m_refs.deref()) { - Q_ASSERT(group->context() == q_ptr); - delete group; - } - - delete texture_destroyer; -} - -void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) -{ - Q_Q(QGLContext); - glFormat = reqFormat = format; - valid = false; - q->setDevice(dev); - - guiGlContext = 0; - ownContext = false; - fbo = 0; - crWin = false; - initDone = false; - sharing = false; - max_texture_size = -1; - version_flags_cached = false; - version_flags = QGLFormat::OpenGL_Version_None; - current_fbo = 0; - default_fbo = 0; - active_engine = 0; - workaround_needsFullClearOnEveryFrame = false; - workaround_brokenFBOReadBack = false; - workaround_brokenTexSubImage = false; - workaroundsCached = false; - - workaround_brokenTextureFromPixmap = false; - workaround_brokenTextureFromPixmap_init = false; - - workaround_brokenAlphaTexSubImage = false; - workaround_brokenAlphaTexSubImage_init = false; - - for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) - vertexAttributeArraysEnabledState[i] = false; -} - -QGLContext* QGLContext::currentCtx = 0; - -/* - QGLTemporaryContext implementation -*/ -class QGLTemporaryContextPrivate -{ -public: - QWindow *window; - QOpenGLContext *context; - - QGLContext *oldContext; -}; - -QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) - : d(new QGLTemporaryContextPrivate) -{ - d->oldContext = const_cast<QGLContext *>(QGLContext::currentContext()); - - d->window = new QWindow; - d->window->setSurfaceType(QWindow::OpenGLSurface); - d->window->setGeometry(QRect(0, 0, 3, 3)); - d->window->create(); - - d->context = new QOpenGLContext; -#if !defined(QT_OPENGL_ES) - if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { - // On desktop, request latest released version - QSurfaceFormat format; -#if defined(Q_OS_MAC) - // OS X is limited to OpenGL 3.2 Core Profile at present - // so set that here. If we use compatibility profile it - // only reports 2.x contexts. - format.setMajorVersion(3); - format.setMinorVersion(2); - format.setProfile(QSurfaceFormat::CoreProfile); -#else - format.setMajorVersion(4); - format.setMinorVersion(3); -#endif - d->context->setFormat(format); - } -#endif // QT_OPENGL_ES - d->context->create(); - d->context->makeCurrent(d->window); -} - -QGLTemporaryContext::~QGLTemporaryContext() -{ - if (d->oldContext) - d->oldContext->makeCurrent(); - - delete d->context; - delete d->window; -} - -/* - Read back the contents of the currently bound framebuffer, used in - QGLWidget::grabFrameBuffer(), QGLPixelbuffer::toImage() and - QGLFramebufferObject::toImage() -*/ - -static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, bool include_alpha) -{ - Q_ASSERT(!img.isNull()); - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - // OpenGL gives RGBA; Qt wants ARGB - uint *p = (uint*)img.bits(); - uint *end = p + w*h; - if (alpha_format && include_alpha) { - while (p < end) { - uint a = *p << 24; - *p = (*p >> 8) | a; - p++; - } - } else { - // This is an old legacy fix for PowerPC based Macs, which - // we shouldn't remove - while (p < end) { - *p = 0xff000000 | (*p>>8); - ++p; - } - } - } else { - // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB - for (int y = 0; y < h; y++) { - uint *q = (uint*)img.scanLine(y); - for (int x=0; x < w; ++x) { - const uint pixel = *q; - if (alpha_format && include_alpha) { - *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) - | (pixel & 0xff00ff00); - } else { - *q = 0xff000000 | ((pixel << 16) & 0xff0000) - | ((pixel >> 16) & 0xff) | (pixel & 0x00ff00); - } - - q++; - } - } - - } - img = img.mirrored(); -} - -QImage qt_gl_read_frame_buffer(const QSize &size, bool alpha_format, bool include_alpha) -{ - QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied - : QImage::Format_RGB32); - if (img.isNull()) - return QImage(); - int w = size.width(); - int h = size.height(); - qgl_functions()->glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); - convertFromGLImage(img, w, h, alpha_format, include_alpha); - return img; -} - -QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alpha) -{ - QImage img(size, alpha_format ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32); - if (img.isNull()) - return QImage(); - int w = size.width(); - int h = size.height(); -#ifndef QT_OPENGL_ES - if (!QOpenGLContext::currentContext()->isOpenGLES()) { - - qgl1_functions()->glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); - } -#endif // QT_OPENGL_ES - convertFromGLImage(img, w, h, alpha_format, include_alpha); - return img; -} - -Q_GLOBAL_STATIC(QGLTextureCache, qt_gl_texture_cache) - -QGLTextureCache::QGLTextureCache() - : m_cache(64*1024) // cache ~64 MB worth of textures - this is not accurate though -{ - QImagePixmapCleanupHooks::instance()->addPlatformPixmapModificationHook(cleanupTexturesForPixampData); - QImagePixmapCleanupHooks::instance()->addPlatformPixmapDestructionHook(cleanupBeforePixmapDestruction); - QImagePixmapCleanupHooks::instance()->addImageHook(cleanupTexturesForCacheKey); -} - -QGLTextureCache::~QGLTextureCache() -{ - QImagePixmapCleanupHooks::instance()->removePlatformPixmapModificationHook(cleanupTexturesForPixampData); - QImagePixmapCleanupHooks::instance()->removePlatformPixmapDestructionHook(cleanupBeforePixmapDestruction); - QImagePixmapCleanupHooks::instance()->removeImageHook(cleanupTexturesForCacheKey); -} - -void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, int cost) -{ - QWriteLocker locker(&m_lock); - const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)}; - const bool inserted = m_cache.insert(cacheKey, texture, cost); - Q_UNUSED(inserted) Q_ASSERT(inserted); -} - -void QGLTextureCache::remove(qint64 key) -{ - QWriteLocker locker(&m_lock); - QMutexLocker groupLocker(&qt_context_groups()->m_mutex); - QList<QGLContextGroup *>::const_iterator it = qt_context_groups()->m_list.constBegin(); - while (it != qt_context_groups()->m_list.constEnd()) { - const QGLTextureCacheKey cacheKey = {key, *it}; - m_cache.remove(cacheKey); - ++it; - } -} - -bool QGLTextureCache::remove(QGLContext* ctx, GLuint textureId) -{ - QWriteLocker locker(&m_lock); - QList<QGLTextureCacheKey> keys = m_cache.keys(); - for (int i = 0; i < keys.size(); ++i) { - QGLTexture *tex = m_cache.object(keys.at(i)); - if (tex->id == textureId && tex->context == ctx) { - tex->options |= QGLContext::MemoryManagedBindOption; // forces a glDeleteTextures() call - m_cache.remove(keys.at(i)); - return true; - } - } - return false; -} - -void QGLTextureCache::removeContextTextures(QGLContext* ctx) -{ - QWriteLocker locker(&m_lock); - QList<QGLTextureCacheKey> keys = m_cache.keys(); - for (int i = 0; i < keys.size(); ++i) { - const QGLTextureCacheKey &key = keys.at(i); - if (m_cache.object(key)->context == ctx) - m_cache.remove(key); - } -} - -/* - a hook that removes textures from the cache when a pixmap/image - is deref'ed -*/ -void QGLTextureCache::cleanupTexturesForCacheKey(qint64 cacheKey) -{ - qt_gl_texture_cache()->remove(cacheKey); -} - - -void QGLTextureCache::cleanupTexturesForPixampData(QPlatformPixmap* pmd) -{ - cleanupTexturesForCacheKey(pmd->cacheKey()); -} - -void QGLTextureCache::cleanupBeforePixmapDestruction(QPlatformPixmap* pmd) -{ - // Remove any bound textures first: - cleanupTexturesForPixampData(pmd); -} - -QGLTextureCache *QGLTextureCache::instance() -{ - return qt_gl_texture_cache(); -} - -// DDS format structure -struct DDSFormat { - quint32 dwSize; - quint32 dwFlags; - quint32 dwHeight; - quint32 dwWidth; - quint32 dwLinearSize; - quint32 dummy1; - quint32 dwMipMapCount; - quint32 dummy2[11]; - struct { - quint32 dummy3[2]; - quint32 dwFourCC; - quint32 dummy4[5]; - } ddsPixelFormat; -}; - -// compressed texture pixel formats -#define FOURCC_DXT1 0x31545844 -#define FOURCC_DXT2 0x32545844 -#define FOURCC_DXT3 0x33545844 -#define FOURCC_DXT4 0x34545844 -#define FOURCC_DXT5 0x35545844 - -// ####TODO Properly #ifdef this class to use #define symbols actually defined -// by system GL includes -#ifndef GL_COMPRESSED_RGB_S3TC_DXT1_EXT -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#endif - -#ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#endif - -#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#endif - -#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_GENERATE_MIPMAP_SGIS -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -/*! - \class QGLContext - \inmodule QtOpenGL - \obsolete - - \brief The QGLContext class encapsulates an OpenGL rendering context. - - An OpenGL rendering context is a complete set of OpenGL state - variables. The rendering context's \l {QGL::FormatOption} {format} - is set in the constructor, but it can also be set later with - setFormat(). The format options that are actually set are returned - by format(); the options you asked for are returned by - requestedFormat(). Note that after a QGLContext object has been - constructed, the actual OpenGL context must be created by - explicitly calling the \l{create()} - function. The makeCurrent() function makes this context the - current rendering context. You can make \e no context current - using doneCurrent(). The reset() function will reset the context - and make it invalid. - - You can examine properties of the context with, e.g. isValid(), - isSharing(), initialized(), windowCreated() and - overlayTransparentColor(). - - If you're using double buffering you can swap the screen contents - with the off-screen buffer using swapBuffers(). - - Please note that QGLContext is not thread safe. -*/ - -/*! - \enum QGLContext::BindOption - \since 4.6 - - A set of options to decide how to bind a texture using bindTexture(). - - \value NoBindOption Don't do anything, pass the texture straight - through. - - \value InvertedYBindOption Specifies that the texture should be flipped - over the X axis so that the texture coordinate 0,0 corresponds to - the top left corner. Inverting the texture implies a deep copy - prior to upload. - - \value MipmapBindOption Specifies that bindTexture() should try - to generate mipmaps. If the GL implementation supports the \c - GL_SGIS_generate_mipmap extension, mipmaps will be automatically - generated for the texture. Mipmap generation is only supported for - the \c GL_TEXTURE_2D target. - - \value PremultipliedAlphaBindOption Specifies that the image should be - uploaded with premultiplied alpha and does a conversion accordingly. - - \value LinearFilteringBindOption Specifies that the texture filtering - should be set to GL_LINEAR. Default is GL_NEAREST. If mipmap is - also enabled, filtering will be set to GL_LINEAR_MIPMAP_LINEAR. - - \value DefaultBindOption In Qt 4.5 and earlier, bindTexture() - would mirror the image and automatically generate mipmaps. This - option helps preserve this default behavior. - - \omitvalue CanFlipNativePixmapBindOption \omit Used by x11 from pixmap to choose - whether or not it can bind the pixmap upside down or not. \endomit - - \omitvalue MemoryManagedBindOption \omit Used by paint engines to - indicate that the pixmap should be memory managed along side with - the pixmap/image that it stems from, e.g. installing destruction - hooks in them. \endomit - - \omitvalue TemporarilyCachedBindOption \omit Used by paint engines on some - platforms to indicate that the pixmap or image texture is possibly - cached only temporarily and must be destroyed immediately after the use. \endomit - - \omitvalue InternalBindOption -*/ - -/*! - \obsolete - - Constructs an OpenGL context for the given paint \a device, which - can be a widget or a pixmap. The \a format specifies several - display options for the context. - - If the underlying OpenGL/Window system cannot satisfy all the - features requested in \a format, the nearest subset of features - will be used. After creation, the format() method will return the - actual format obtained. - - Note that after a QGLContext object has been constructed, \l - create() must be called explicitly to create the actual OpenGL - context. The context will be \l {isValid()}{invalid} if it was not - possible to obtain a GL context at all. -*/ - -QGLContext::QGLContext(const QGLFormat &format, QPaintDevice *device) - : d_ptr(new QGLContextPrivate(this)) -{ - Q_D(QGLContext); - d->init(device, format); -} - -/*! - Constructs an OpenGL context with the given \a format which - specifies several display options for the context. - - If the underlying OpenGL/Window system cannot satisfy all the - features requested in \a format, the nearest subset of features - will be used. After creation, the format() method will return the - actual format obtained. - - Note that after a QGLContext object has been constructed, \l - create() must be called explicitly to create the actual OpenGL - context. The context will be \l {isValid()}{invalid} if it was not - possible to obtain a GL context at all. - - \sa format(), isValid() -*/ -QGLContext::QGLContext(const QGLFormat &format) - : d_ptr(new QGLContextPrivate(this)) -{ - Q_D(QGLContext); - d->init(0, format); -} - -static void qDeleteQGLContext(void *handle) -{ - QGLContext *context = static_cast<QGLContext *>(handle); - delete context; -} - -QGLContext::QGLContext(QOpenGLContext *context) - : d_ptr(new QGLContextPrivate(this)) -{ - Q_D(QGLContext); - d->init(0, QGLFormat::fromSurfaceFormat(context->format())); - d->guiGlContext = context; - d->guiGlContext->setQGLContextHandle(this, qDeleteQGLContext); - d->ownContext = false; - d->valid = context->isValid(); - d->setupSharing(); -} - -/*! - Returns the OpenGL context handle. -*/ -QOpenGLContext *QGLContext::contextHandle() const -{ - Q_D(const QGLContext); - return d->guiGlContext; -} - -/*! - Returns an OpenGL context for the window context specified by the \a context - parameter. -*/ -QGLContext *QGLContext::fromOpenGLContext(QOpenGLContext *context) -{ - if (!context) - return 0; - if (context->qGLContextHandle()) { - return reinterpret_cast<QGLContext *>(context->qGLContextHandle()); - } - QGLContext *glContext = new QGLContext(context); - //Don't call create on context. This can cause the platformFormat to be set on the widget, which - //will cause the platformWindow to be recreated. - return glContext; -} - -/*! - Destroys the OpenGL context and frees its resources. -*/ - -QGLContext::~QGLContext() -{ - // remove any textures cached in this context - QGLTextureCache::instance()->removeContextTextures(this); - - // clean up resources specific to this context - d_ptr->cleanup(); - - QGLSignalProxy::instance()->emitAboutToDestroyContext(this); - reset(); -} - -void QGLContextPrivate::cleanup() -{ -} - -#define ctx q_ptr -void QGLContextPrivate::setVertexAttribArrayEnabled(int arrayIndex, bool enabled) -{ - Q_Q(QGLContext); - Q_ASSERT(arrayIndex < QT_GL_VERTEX_ARRAY_TRACKED_COUNT); -#ifdef glEnableVertexAttribArray - Q_ASSERT(glEnableVertexAttribArray); -#endif - - if (vertexAttributeArraysEnabledState[arrayIndex] && !enabled) - q->functions()->glDisableVertexAttribArray(arrayIndex); - - if (!vertexAttributeArraysEnabledState[arrayIndex] && enabled) - q->functions()->glEnableVertexAttribArray(arrayIndex); - - vertexAttributeArraysEnabledState[arrayIndex] = enabled; -} - -void QGLContextPrivate::syncGlState() -{ - Q_Q(QGLContext); -#ifdef glEnableVertexAttribArray - Q_ASSERT(glEnableVertexAttribArray); -#endif - for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) { - if (vertexAttributeArraysEnabledState[i]) - q->functions()->glEnableVertexAttribArray(i); - else - q->functions()->glDisableVertexAttribArray(i); - } - -} -#undef ctx - -void QGLContextPrivate::swapRegion(const QRegion &) -{ - Q_Q(QGLContext); - q->swapBuffers(); -} - -/*! - \overload - - Reads the compressed texture file \a fileName and generates a 2D GL - texture from it. - - This function can load DirectDrawSurface (DDS) textures in the - DXT1, DXT3 and DXT5 DDS formats if the \c GL_ARB_texture_compression - and \c GL_EXT_texture_compression_s3tc extensions are supported. - - Since 4.6.1, textures in the ETC1 format can be loaded if the - \c GL_OES_compressed_ETC1_RGB8_texture extension is supported - and the ETC1 texture has been encapsulated in the PVR container format. - Also, textures in the PVRTC2 and PVRTC4 formats can be loaded - if the \c GL_IMG_texture_compression_pvrtc extension is supported. - - \sa deleteTexture() -*/ - -GLuint QGLContext::bindTexture(const QString &fileName) -{ - QGLTexture texture(this); - QSize size = texture.bindCompressedTexture(fileName); - if (!size.isValid()) - return 0; - return texture.id; -} - -static inline QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format) -{ - if (texture_format == GL_BGRA) { - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return ((src_pixel << 24) & 0xff000000) - | ((src_pixel >> 24) & 0x000000ff) - | ((src_pixel << 8) & 0x00ff0000) - | ((src_pixel >> 8) & 0x0000ff00); - } else { - return src_pixel; - } - } else { // GL_RGBA - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (src_pixel << 8) | ((src_pixel >> 24) & 0xff); - } else { - return ((src_pixel << 16) & 0xff0000) - | ((src_pixel >> 16) & 0xff) - | (src_pixel & 0xff00ff00); - } - } -} - -static void convertToGLFormatHelper(QImage &dst, const QImage &img, GLenum texture_format) -{ - Q_ASSERT(dst.depth() == 32); - Q_ASSERT(img.depth() == 32); - - if (dst.size() != img.size()) { - int target_width = dst.width(); - int target_height = dst.height(); - qreal sx = target_width / qreal(img.width()); - qreal sy = target_height / qreal(img.height()); - - quint32 *dest = (quint32 *) dst.scanLine(0); // NB! avoid detach here - const uchar *srcPixels = img.constScanLine(img.height() - 1); - int sbpl = img.bytesPerLine(); - int dbpl = dst.bytesPerLine(); - - int ix = int(0x00010000 / sx); - int iy = int(0x00010000 / sy); - - quint32 basex = int(0.5 * ix); - quint32 srcy = int(0.5 * iy); - - // scale, swizzle and mirror in one loop - while (target_height--) { - const uint *src = (const quint32 *) (srcPixels - (srcy >> 16) * sbpl); - int srcx = basex; - for (int x=0; x<target_width; ++x) { - dest[x] = qt_gl_convertToGLFormatHelper(src[srcx >> 16], texture_format); - srcx += ix; - } - dest = (quint32 *)(((uchar *) dest) + dbpl); - srcy += iy; - } - } else { - const int width = img.width(); - const int height = img.height(); - const uint *p = (const uint*) img.scanLine(img.height() - 1); - uint *q = (uint*) dst.scanLine(0); - - if (texture_format == GL_BGRA) { - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - // mirror + swizzle - for (int i=0; i < height; ++i) { - const uint *end = p + width; - while (p < end) { - *q = ((*p << 24) & 0xff000000) - | ((*p >> 24) & 0x000000ff) - | ((*p << 8) & 0x00ff0000) - | ((*p >> 8) & 0x0000ff00); - p++; - q++; - } - p -= 2 * width; - } - } else { - const uint bytesPerLine = img.bytesPerLine(); - for (int i=0; i < height; ++i) { - memcpy(q, p, bytesPerLine); - q += width; - p -= width; - } - } - } else { - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - for (int i=0; i < height; ++i) { - const uint *end = p + width; - while (p < end) { - *q = (*p << 8) | ((*p >> 24) & 0xff); - p++; - q++; - } - p -= 2 * width; - } - } else { - for (int i=0; i < height; ++i) { - const uint *end = p + width; - while (p < end) { - *q = ((*p << 16) & 0xff0000) | ((*p >> 16) & 0xff) | (*p & 0xff00ff00); - p++; - q++; - } - p -= 2 * width; - } - } - } - } -} - -/*! \internal */ -QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - Q_Q(QGLContext); - - const qint64 key = image.cacheKey(); - QGLTexture *texture = textureCacheLookup(key, target); - if (texture) { - if (image.paintingActive()) { - // A QPainter is active on the image - take the safe route and replace the texture. - q->deleteTexture(texture->id); - texture = 0; - } else { - qgl_functions()->glBindTexture(target, texture->id); - return texture; - } - } - - if (!texture) - texture = bindTexture(image, target, format, key, options); - // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null - Q_ASSERT(texture); - - // Enable the cleanup hooks for this image so that the texture cache entry is removed when the - // image gets deleted: - QImagePixmapCleanupHooks::enableCleanupHooks(image); - - return texture; -} - -// #define QGL_BIND_TEXTURE_DEBUG - -// ####TODO Properly #ifdef this file to use #define symbols actually defined -// by OpenGL/ES includes -#ifndef GL_UNSIGNED_INT_8_8_8_8_REV -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#endif - -// map from Qt's ARGB endianness-dependent format to GL's big-endian RGBA layout -static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) -{ - const int width = img.width(); - const int height = img.height(); - - if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV - || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) - { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); - } - } else { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); - } - } -} - -QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint internalFormat, - const qint64 key, QGLContext::BindOptions options) -{ - Q_Q(QGLContext); - QOpenGLFunctions *funcs = qgl_functions(); - -#ifdef QGL_BIND_TEXTURE_DEBUG - printf("QGLContextPrivate::bindTexture(), imageSize=(%d,%d), internalFormat =0x%x, options=%x, key=%llx\n", - image.width(), image.height(), internalFormat, int(options), key); - QTime time; - time.start(); -#endif - -#ifndef QT_NO_DEBUG - // Reset the gl error stack...git - while (funcs->glGetError() != GL_NO_ERROR) ; -#endif - - // Scale the pixmap if needed. GL textures needs to have the - // dimensions 2^n+2(border) x 2^m+2(border), unless we're using GL - // 2.0 or use the GL_TEXTURE_RECTANGLE texture target - int tx_w = qNextPowerOfTwo(image.width() - 1); - int tx_h = qNextPowerOfTwo(image.height() - 1); - - QImage img = image; - - if (!qgl_extensions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures) - && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0) - && (target == GL_TEXTURE_2D && (tx_w != image.width() || tx_h != image.height()))) - { - img = img.scaled(tx_w, tx_h); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - upscaled to %dx%d (%d ms)\n", tx_w, tx_h, time.elapsed()); - -#endif - } - - GLuint filtering = options & QGLContext::LinearFilteringBindOption ? GL_LINEAR : GL_NEAREST; - - GLuint tx_id; - funcs->glGenTextures(1, &tx_id); - funcs->glBindTexture(target, tx_id); - funcs->glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filtering); - - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - bool genMipmap = !ctx->isOpenGLES(); - if (glFormat.directRendering() - && (qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::GenerateMipmap)) - && target == GL_TEXTURE_2D - && (options & QGLContext::MipmapBindOption)) - { -#if !defined(QT_OPENGL_ES_2) - if (genMipmap) { - funcs->glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST); - funcs->glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); - } else { - funcs->glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); - genMipmap = true; - } -#else - funcs->glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); - genMipmap = true; -#endif - funcs->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, options & QGLContext::LinearFilteringBindOption - ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - generating mipmaps (%d ms)\n", time.elapsed()); -#endif - } else { - funcs->glTexParameteri(target, GL_TEXTURE_MIN_FILTER, filtering); - } - - QImage::Format target_format = img.format(); - bool premul = options & QGLContext::PremultipliedAlphaBindOption; - bool needsbyteswap = true; - GLenum externalFormat; - GLuint pixel_type; - if (target_format == QImage::Format_RGBA8888 - || target_format == QImage::Format_RGBA8888_Premultiplied - || target_format == QImage::Format_RGBX8888) { - externalFormat = GL_RGBA; - pixel_type = GL_UNSIGNED_BYTE; - needsbyteswap = false; - } else if (qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat)) { - externalFormat = GL_BGRA; - needsbyteswap = false; - if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_2) - pixel_type = GL_UNSIGNED_INT_8_8_8_8_REV; - else - pixel_type = GL_UNSIGNED_BYTE; - } else { - externalFormat = GL_RGBA; - pixel_type = GL_UNSIGNED_BYTE; - } - - switch (target_format) { - case QImage::Format_ARGB32: - if (premul) { - img = img.convertToFormat(target_format = QImage::Format_ARGB32_Premultiplied); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - converted ARGB32 -> ARGB32_Premultiplied (%d ms) \n", time.elapsed()); -#endif - } - break; - case QImage::Format_ARGB32_Premultiplied: - if (!premul) { - img = img.convertToFormat(target_format = QImage::Format_ARGB32); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - converted ARGB32_Premultiplied -> ARGB32 (%d ms)\n", time.elapsed()); -#endif - } - break; - case QImage::Format_RGBA8888: - if (premul) { - img = img.convertToFormat(target_format = QImage::Format_RGBA8888_Premultiplied); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - converted RGBA8888 -> RGBA8888_Premultiplied (%d ms) \n", time.elapsed()); -#endif - } - break; - case QImage::Format_RGBA8888_Premultiplied: - if (!premul) { - img = img.convertToFormat(target_format = QImage::Format_RGBA8888); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - converted RGBA8888_Premultiplied -> RGBA8888 (%d ms) \n", time.elapsed()); -#endif - } - break; - case QImage::Format_RGB16: - pixel_type = GL_UNSIGNED_SHORT_5_6_5; - externalFormat = GL_RGB; - internalFormat = GL_RGB; - needsbyteswap = false; - break; - case QImage::Format_RGB32: - case QImage::Format_RGBX8888: - break; - default: - // Ideally more formats would be converted directly to an RGBA8888 format, - // but we are only guaranteed to have a fast conversion to an ARGB format. - if (img.hasAlphaChannel()) { - img = img.convertToFormat(premul - ? QImage::Format_ARGB32_Premultiplied - : QImage::Format_ARGB32); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - converted to 32-bit alpha format (%d ms)\n", time.elapsed()); -#endif - } else { - img = img.convertToFormat(QImage::Format_RGB32); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - converted to 32-bit (%d ms)\n", time.elapsed()); -#endif - } - } - - if (options & QGLContext::InvertedYBindOption) { - if (img.isDetached()) { - int ipl = img.bytesPerLine() / 4; - int h = img.height(); - for (int y=0; y<h/2; ++y) { - int *a = (int *) img.scanLine(y); - int *b = (int *) img.scanLine(h - y - 1); - for (int x=0; x<ipl; ++x) - qSwap(a[x], b[x]); - } - } else { - // Create a new image and copy across. If we use the - // above in-place code then a full copy of the image is - // made before the lines are swapped, which processes the - // data twice. This version should only do it once. - img = img.mirrored(); - } -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - flipped bits over y (%d ms)\n", time.elapsed()); -#endif - } - - if (needsbyteswap) { - // The only case where we end up with a depth different from - // 32 in the switch above is for the RGB16 case, where we do - // not need a byteswap. - Q_ASSERT(img.depth() == 32); - qgl_byteSwapImage(img, pixel_type); -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - did byte swapping (%d ms)\n", time.elapsed()); -#endif - } - if (ctx->isOpenGLES()) { - // OpenGL/ES requires that the internal and external formats be - // identical. - internalFormat = externalFormat; - } -#ifdef QGL_BIND_TEXTURE_DEBUG - printf(" - uploading, image.format=%d, externalFormat=0x%x, internalFormat=0x%x, pixel_type=0x%x\n", - img.format(), externalFormat, internalFormat, pixel_type); -#endif - - const QImage &constRef = img; // to avoid detach in bits()... - funcs->glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat, - pixel_type, constRef.bits()); - if (genMipmap && ctx->isOpenGLES()) - q->functions()->glGenerateMipmap(target); -#ifndef QT_NO_DEBUG - GLenum error = funcs->glGetError(); - if (error != GL_NO_ERROR) { - qWarning(" - texture upload failed, error code 0x%x, enum: %d (%x)\n", error, target, target); - } -#endif - -#ifdef QGL_BIND_TEXTURE_DEBUG - static int totalUploadTime = 0; - totalUploadTime += time.elapsed(); - printf(" - upload done in %d ms, (accumulated: %d ms)\n", time.elapsed(), totalUploadTime); -#endif - - - // this assumes the size of a texture is always smaller than the max cache size - int cost = img.width()*img.height()*4/1024; - QGLTexture *texture = new QGLTexture(q, tx_id, target, options); - QGLTextureCache::instance()->insert(q, key, texture, cost); - - return texture; -} - -QGLTexture *QGLContextPrivate::textureCacheLookup(const qint64 key, GLenum target) -{ - Q_Q(QGLContext); - QGLTexture *texture = QGLTextureCache::instance()->getTexture(q, key); - if (texture && texture->target == target - && (texture->context == q || QGLContext::areSharing(q, texture->context))) - { - return texture; - } - return 0; -} - -/*! \internal */ -QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options) -{ - Q_Q(QGLContext); - QPlatformPixmap *pd = pixmap.handle(); - Q_UNUSED(pd); - - const qint64 key = pixmap.cacheKey(); - QGLTexture *texture = textureCacheLookup(key, target); - if (texture) { - if (pixmap.paintingActive()) { - // A QPainter is active on the pixmap - take the safe route and replace the texture. - q->deleteTexture(texture->id); - texture = 0; - } else { - qgl_functions()->glBindTexture(target, texture->id); - return texture; - } - } - - if (!texture) { - QImage image; - QPaintEngine* paintEngine = pixmap.paintEngine(); - if (!paintEngine || paintEngine->type() != QPaintEngine::Raster) - image = pixmap.toImage(); - else { - // QRasterPixmapData::toImage() will deep-copy the backing QImage if there's an active QPainter on it. - // For performance reasons, we don't want that here, so we temporarily redirect the paint engine. - QPaintDevice* currentPaintDevice = paintEngine->paintDevice(); - paintEngine->setPaintDevice(0); - image = pixmap.toImage(); - paintEngine->setPaintDevice(currentPaintDevice); - } - - // If the system depth is 16 and the pixmap doesn't have an alpha channel - // then we convert it to RGB16 in the hope that it gets uploaded as a 16 - // bit texture which is much faster to access than a 32-bit one. - if (pixmap.depth() == 16 && !image.hasAlphaChannel() ) - image = image.convertToFormat(QImage::Format_RGB16); - texture = bindTexture(image, target, format, key, options); - } - // NOTE: bindTexture(const QImage&, GLenum, GLint, const qint64, bool) should never return null - Q_ASSERT(texture); - - if (texture->id > 0) - QImagePixmapCleanupHooks::enableCleanupHooks(pixmap); - - return texture; -} - -/*! \internal */ -int QGLContextPrivate::maxTextureSize() -{ - if (max_texture_size != -1) - return max_texture_size; - - QOpenGLFunctions *funcs = qgl_functions(); - funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); - -#ifndef QT_OPENGL_ES - Q_Q(QGLContext); - if (!q->contextHandle()->isOpenGLES()) { - GLenum proxy = GL_PROXY_TEXTURE_2D; - - GLint size; - GLint next = 64; - funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - gl1funcs->glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &size); - if (size == 0) { - return max_texture_size; - } - do { - size = next; - next = size * 2; - - if (next > max_texture_size) - break; - funcs->glTexImage2D(proxy, 0, GL_RGBA, next, next, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - gl1funcs->glGetTexLevelParameteriv(proxy, 0, GL_TEXTURE_WIDTH, &next); - } while (next > size); - - max_texture_size = size; - } -#endif - - return max_texture_size; -} - -/*! - Returns a QGLFunctions object that is initialized for this context. - */ -QGLFunctions *QGLContext::functions() const -{ - QGLContextPrivate *d = const_cast<QGLContextPrivate *>(d_func()); - if (!d->functions) { - d->functions = new QGLFunctions(this); - d->functions->initializeGLFunctions(this); - } - return d->functions; -} - -/*! - Generates and binds a 2D GL texture to the current context, based - on \a image. The generated texture id is returned and can be used in - later \c glBindTexture() calls. - - \overload -*/ -GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format) -{ - if (image.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, target, format, DefaultBindOption); - return texture->id; -} - -/*! - \since 4.6 - - Generates and binds a 2D GL texture to the current context, based - on \a image. The generated texture id is returned and can be used - in later \c glBindTexture() calls. - - The \a target parameter specifies the texture target. The default - target is \c GL_TEXTURE_2D. - - The \a format parameter sets the internal format for the - texture. The default format is \c GL_RGBA. - - The binding \a options are a set of options used to decide how to - bind the texture to the context. - - The texture that is generated is cached, so multiple calls to - bindTexture() with the same QImage will return the same texture - id. - - Note that we assume default values for the glPixelStore() and - glPixelTransfer() parameters. - - \sa deleteTexture() -*/ -GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format, BindOptions options) -{ - if (image.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(image, target, format, options); - return texture->id; -} - -/*! \overload - - Generates and binds a 2D GL texture based on \a pixmap. -*/ -GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) -{ - if (pixmap.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(pixmap, target, format, DefaultBindOption); - return texture->id; -} - -/*! - \overload - \since 4.6 - - Generates and binds a 2D GL texture to the current context, based - on \a pixmap. -*/ -GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, BindOptions options) -{ - if (pixmap.isNull()) - return 0; - - Q_D(QGLContext); - QGLTexture *texture = d->bindTexture(pixmap, target, format, options); - return texture->id; -} - -/*! - Removes the texture identified by \a id from the texture cache, - and calls glDeleteTextures() to delete the texture from the - context. - - \sa bindTexture() -*/ -void QGLContext::deleteTexture(GLuint id) -{ - if (QGLTextureCache::instance()->remove(this, id)) - return; - qgl_functions()->glDeleteTextures(1, &id); -} - -void qt_add_rect_to_array(const QRectF &r, GLfloat *array) -{ - qreal left = r.left(); - qreal right = r.right(); - qreal top = r.top(); - qreal bottom = r.bottom(); - - array[0] = left; - array[1] = top; - array[2] = right; - array[3] = top; - array[4] = right; - array[5] = bottom; - array[6] = left; - array[7] = bottom; -} - -void qt_add_texcoords_to_array(qreal x1, qreal y1, qreal x2, qreal y2, GLfloat *array) -{ - array[0] = x1; - array[1] = y1; - array[2] = x2; - array[3] = y1; - array[4] = x2; - array[5] = y2; - array[6] = x1; - array[7] = y2; -} - -#if !defined(QT_OPENGL_ES_2) - -static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint textureHeight, GLenum textureTarget) -{ - QOpenGLFunctions *funcs = qgl_functions(); - GLfloat tx = 1.0f; - GLfloat ty = 1.0f; - -#ifdef QT_OPENGL_ES - Q_UNUSED(textureWidth); - Q_UNUSED(textureHeight); - Q_UNUSED(textureTarget); -#else - if (textureTarget != GL_TEXTURE_2D && !QOpenGLContext::currentContext()->isOpenGLES()) { - if (textureWidth == -1 || textureHeight == -1) { - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - gl1funcs->glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); - gl1funcs->glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); - } - - tx = GLfloat(textureWidth); - ty = GLfloat(textureHeight); - } -#endif - - GLfloat texCoordArray[4*2] = { - 0, ty, tx, ty, tx, 0, 0, 0 - }; - - GLfloat vertexArray[4*2]; - qt_add_rect_to_array(target, vertexArray); - - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - gl1funcs->glVertexPointer(2, GL_FLOAT, 0, vertexArray); - gl1funcs->glTexCoordPointer(2, GL_FLOAT, 0, texCoordArray); - - gl1funcs->glEnableClientState(GL_VERTEX_ARRAY); - gl1funcs->glEnableClientState(GL_TEXTURE_COORD_ARRAY); - funcs->glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - gl1funcs->glDisableClientState(GL_VERTEX_ARRAY); - gl1funcs->glDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - -#endif // !QT_OPENGL_ES_2 - -/*! - \since 4.4 - - This function supports the following use cases: - - \list - \li On OpenGL and OpenGL ES 1.x it draws the given texture, \a textureId, - to the given target rectangle, \a target, in OpenGL model space. The - \a textureTarget should be a 2D texture target. - \li On OpenGL and OpenGL ES 2.x, if a painter is active, not inside a - beginNativePainting / endNativePainting block, and uses the - engine with type QPaintEngine::OpenGL2, the function will draw the given - texture, \a textureId, to the given target rectangle, \a target, - respecting the current painter state. This will let you draw a texture - with the clip, transform, render hints, and composition mode set by the - painter. Note that the texture target needs to be GL_TEXTURE_2D for this - use case, and that this is the only supported use case under OpenGL ES 2.x. - \endlist - -*/ -void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) -{ -#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2) - if (d_ptr->active_engine && - d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { - QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine); - if (!eng->isNativePaintingActive()) { - QRectF src(0, 0, target.width(), target.height()); - QSize size(target.width(), target.height()); - if (eng->drawTexture(target, textureId, size, src)) - return; - } - } -#endif - -#ifndef QT_OPENGL_ES_2 - QOpenGLFunctions *funcs = qgl_functions(); - if (!contextHandle()->isOpenGLES()) { -#ifdef QT_OPENGL_ES - if (textureTarget != GL_TEXTURE_2D) { - qWarning("QGLContext::drawTexture(): texture target must be GL_TEXTURE_2D on OpenGL ES"); - return; - } -#else - const bool wasEnabled = funcs->glIsEnabled(GL_TEXTURE_2D); - GLint oldTexture; - funcs->glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); -#endif - - funcs->glEnable(textureTarget); - funcs->glBindTexture(textureTarget, textureId); - - qDrawTextureRect(target, -1, -1, textureTarget); - -#ifdef QT_OPENGL_ES - funcs->glDisable(textureTarget); -#else - if (!wasEnabled) - funcs->glDisable(textureTarget); - funcs->glBindTexture(textureTarget, oldTexture); -#endif - return; - } -#else - Q_UNUSED(target); - Q_UNUSED(textureId); - Q_UNUSED(textureTarget); -#endif - qWarning("drawTexture() with OpenGL ES 2.0 requires an active OpenGL2 paint engine"); -} - -/*! - \since 4.4 - - This function supports the following use cases: - - \list - \li By default it draws the given texture, \a textureId, - at the given \a point in OpenGL model space. The - \a textureTarget should be a 2D texture target. - \li If a painter is active, not inside a - beginNativePainting / endNativePainting block, and uses the - engine with type QPaintEngine::OpenGL2, the function will draw the given - texture, \a textureId, at the given \a point, - respecting the current painter state. This will let you draw a texture - with the clip, transform, render hints, and composition mode set by the - painter. Note that the texture target needs to be GL_TEXTURE_2D for this - use case. - \endlist - - \note This function is not supported under any version of OpenGL ES. -*/ -void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) -{ -#ifdef QT_OPENGL_ES - Q_UNUSED(point); - Q_UNUSED(textureId); - Q_UNUSED(textureTarget); -#else - if (!contextHandle()->isOpenGLES()) { - QOpenGLFunctions *funcs = qgl_functions(); - const bool wasEnabled = funcs->glIsEnabled(GL_TEXTURE_2D); - GLint oldTexture; - funcs->glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); - - funcs->glEnable(textureTarget); - funcs->glBindTexture(textureTarget, textureId); - - GLint textureWidth; - GLint textureHeight; - - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - gl1funcs->glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); - gl1funcs->glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); - - if (d_ptr->active_engine && - d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { - QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine); - if (!eng->isNativePaintingActive()) { - QRectF dest(point, QSizeF(textureWidth, textureHeight)); - QRectF src(0, 0, textureWidth, textureHeight); - QSize size(textureWidth, textureHeight); - if (eng->drawTexture(dest, textureId, size, src)) - return; - } - } - - qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget); - - if (!wasEnabled) - funcs->glDisable(textureTarget); - funcs->glBindTexture(textureTarget, oldTexture); - return; - } -#endif - qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead"); -} - -/*! - This function sets the limit for the texture cache to \a size, - expressed in kilobytes. - - By default, the cache limit is approximately 64 MB. - - \sa textureCacheLimit() -*/ -void QGLContext::setTextureCacheLimit(int size) -{ - QGLTextureCache::instance()->setMaxCost(size); -} - -/*! - Returns the current texture cache limit in kilobytes. - - \sa setTextureCacheLimit() -*/ -int QGLContext::textureCacheLimit() -{ - return QGLTextureCache::instance()->maxCost(); -} - - -/*! - \fn QGLFormat QGLContext::format() const - - Returns the frame buffer format that was obtained (this may be a - subset of what was requested). - - \sa requestedFormat() -*/ - -/*! - \fn QGLFormat QGLContext::requestedFormat() const - - Returns the frame buffer format that was originally requested in - the constructor or setFormat(). - - \sa format() -*/ - -/*! - Sets a \a format for this context. The context is \l{reset()}{reset}. - - Call create() to create a new GL context that tries to match the - new format. - - \snippet code/src_opengl_qgl.cpp 7 - - \sa format(), reset(), create() -*/ - -void QGLContext::setFormat(const QGLFormat &format) -{ - Q_D(QGLContext); - reset(); - d->glFormat = d->reqFormat = format; -} - -/*! - \internal -*/ -void QGLContext::setDevice(QPaintDevice *pDev) -{ - Q_D(QGLContext); - // Do not touch the valid flag here. The context is either a new one and - // valid is not yet set or it is adapted from a valid QOpenGLContext in which - // case it must remain valid. - d->paintDevice = pDev; - if (d->paintDevice && (d->paintDevice->devType() != QInternal::Widget - && d->paintDevice->devType() != QInternal::Pixmap - && d->paintDevice->devType() != QInternal::Pbuffer)) { - qWarning("QGLContext: Unsupported paint device type"); - } -} - -/*! - \fn bool QGLContext::isValid() const - - Returns \c true if a GL rendering context has been successfully - created; otherwise returns \c false. -*/ - -/*! - \fn void QGLContext::setValid(bool valid) - \internal - - Forces the GL rendering context to be valid. -*/ - -/*! - \fn bool QGLContext::isSharing() const - - Returns \c true if this context is sharing its GL context with - another QGLContext, otherwise false is returned. Note that context - sharing might not be supported between contexts with different - formats. -*/ - -/*! - Returns \c true if \a context1 and \a context2 are sharing their - GL resources such as textures, shader programs, etc; - otherwise returns \c false. - - \since 4.6 -*/ -bool QGLContext::areSharing(const QGLContext *context1, const QGLContext *context2) -{ - if (!context1 || !context2) - return false; - return context1->d_ptr->group == context2->d_ptr->group; -} - -/*! - \fn bool QGLContext::deviceIsPixmap() const - - Returns \c true if the paint device of this context is a pixmap; - otherwise returns \c false. - - Since Qt 5 the paint device is never actually a pixmap. renderPixmap() is - however still simulated using framebuffer objects and readbacks, and this - function will return \c true in this case. -*/ - -/*! - \fn bool QGLContext::windowCreated() const - - Returns \c true if a window has been created for this context; - otherwise returns \c false. - - \sa setWindowCreated() -*/ - -/*! - \fn void QGLContext::setWindowCreated(bool on) - - If \a on is true the context has had a window created for it. If - \a on is false no window has been created for the context. - - \sa windowCreated() -*/ - -/*! - \fn uint QGLContext::colorIndex(const QColor& c) const - - \internal - - Returns a colormap index for the color c, in ColorIndex mode. Used - by qglColor() and qglClearColor(). -*/ -uint QGLContext::colorIndex(const QColor&) const -{ - return 0; -} - -/*! - \fn bool QGLContext::initialized() const - - Returns \c true if this context has been initialized, i.e. if - QGLWidget::initializeGL() has been performed on it; otherwise - returns \c false. - - \sa setInitialized() -*/ - -/*! - \fn void QGLContext::setInitialized(bool on) - - If \a on is true the context has been initialized, i.e. - QGLContext::setInitialized() has been called on it. If \a on is - false the context has not been initialized. - - \sa initialized() -*/ - -/*! - \fn const QGLContext* QGLContext::currentContext() - - Returns the current context, i.e. the context to which any OpenGL - commands will currently be directed. Returns 0 if no context is - current. - - \sa makeCurrent() -*/ - -/*! - \fn QColor QGLContext::overlayTransparentColor() const - - If this context is a valid context in an overlay plane, returns - the plane's transparent color. Otherwise returns an \l{QColor::isValid()}{invalid} color. - - The returned color's \l{QColormap::pixel()}{pixel} value is - the index of the transparent color in the colormap of the overlay - plane. (Naturally, the color's RGB values are meaningless.) - - The returned QColor object will generally work as expected only - when passed as the argument to QGLWidget::qglColor() or - QGLWidget::qglClearColor(). Under certain circumstances it can - also be used to draw transparent graphics with a QPainter. -*/ -QColor QGLContext::overlayTransparentColor() const -{ - return QColor(); // Invalid color -} - -/*! - Creates the GL context. Returns \c true if it was successful in - creating a valid GL rendering context on the paint device - specified in the constructor; otherwise returns \c false (i.e. the - context is invalid). - - If the OpenGL implementation on your system does not support the requested - version of OpenGL context, then QGLContext will try to create the closest - matching version. The actual created context properties can be queried - using the QGLFormat returned by the format() function. For example, if - you request a context that supports OpenGL 4.3 Core profile but the driver - and/or hardware only supports version 3.2 Core profile contexts then you will - get a 3.2 Core profile context. - - After successful creation, format() returns the set of features of - the created GL rendering context. - - If \a shareContext points to a valid QGLContext, this method will - try to establish OpenGL display list and texture object sharing - between this context and the \a shareContext. Note that this may - fail if the two contexts have different \l {format()} {formats}. - Use isSharing() to see if sharing is in effect. - - \warning Implementation note: initialization of C++ class - members usually takes place in the class constructor. QGLContext - is an exception because it must be simple to customize. The - virtual functions chooseContext() (and chooseVisual() for X11) can - be reimplemented in a subclass to select a particular context. The - problem is that virtual functions are not properly called during - construction (even though this is correct C++) because C++ - constructs class hierarchies from the bottom up. For this reason - we need a create() function. - - \sa chooseContext(), format(), isValid() -*/ - -bool QGLContext::create(const QGLContext* shareContext) -{ - Q_D(QGLContext); - if (!d->paintDevice && !d->guiGlContext) - return false; - - reset(); - d->valid = chooseContext(shareContext); - if (d->valid && d->paintDevice && d->paintDevice->devType() == QInternal::Widget) { - QWidgetPrivate *wd = qt_widget_private(static_cast<QWidget *>(d->paintDevice)); - wd->usesDoubleBufferedGLContext = d->glFormat.doubleBuffer(); - } - return d->valid; -} - -bool QGLContext::isValid() const -{ - Q_D(const QGLContext); - return d->valid; -} - -void QGLContext::setValid(bool valid) -{ - Q_D(QGLContext); - d->valid = valid; -} - -bool QGLContext::isSharing() const -{ - Q_D(const QGLContext); - return d->group->isSharing(); -} - -QGLFormat QGLContext::format() const -{ - Q_D(const QGLContext); - return d->glFormat; -} - -QGLFormat QGLContext::requestedFormat() const -{ - Q_D(const QGLContext); - return d->reqFormat; -} - - QPaintDevice* QGLContext::device() const -{ - Q_D(const QGLContext); - return d->paintDevice; -} - -bool QGLContext::deviceIsPixmap() const -{ - Q_D(const QGLContext); - return !d->readback_target_size.isEmpty(); -} - - -bool QGLContext::windowCreated() const -{ - Q_D(const QGLContext); - return d->crWin; -} - - -void QGLContext::setWindowCreated(bool on) -{ - Q_D(QGLContext); - d->crWin = on; -} - -bool QGLContext::initialized() const -{ - Q_D(const QGLContext); - return d->initDone; -} - -void QGLContext::setInitialized(bool on) -{ - Q_D(QGLContext); - d->initDone = on; -} - -const QGLContext* QGLContext::currentContext() -{ - if (const QOpenGLContext *threadContext = QOpenGLContext::currentContext()) { - return QGLContext::fromOpenGLContext(const_cast<QOpenGLContext *>(threadContext)); - } - return 0; -} - -void QGLContextPrivate::setCurrentContext(QGLContext *context) -{ - Q_UNUSED(context); -} - -/*! - Moves the QGLContext to the given \a thread. - - Enables calling swapBuffers() and makeCurrent() on the context in - the given thread. -*/ -void QGLContext::moveToThread(QThread *thread) -{ - Q_D(QGLContext); - if (d->guiGlContext) - d->guiGlContext->moveToThread(thread); -} - -/*! - \fn bool QGLContext::chooseContext(const QGLContext* shareContext = 0) - - This semi-internal function is called by create(). It creates a - system-dependent OpenGL handle that matches the format() of \a - shareContext as closely as possible, returning true if successful - or false if a suitable handle could not be found. - - On Windows, it calls the virtual function choosePixelFormat(), - which finds a matching pixel format identifier. On X11, it calls - the virtual function chooseVisual() which finds an appropriate X - visual. On other platforms it may work differently. -*/ -bool QGLContext::chooseContext(const QGLContext* shareContext) -{ - Q_D(QGLContext); - if(!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) { - // Unlike in Qt 4, the only possible target is a widget backed by an OpenGL-based - // QWindow. Pixmaps in particular are not supported anymore as paint devices since - // starting from Qt 5 QPixmap is raster-backed on almost all platforms. - d->valid = false; - }else { - QWidget *widget = static_cast<QWidget *>(d->paintDevice); - QGLFormat glformat = format(); - QSurfaceFormat winFormat = QGLFormat::toSurfaceFormat(glformat); - if (widget->testAttribute(Qt::WA_TranslucentBackground)) - winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8)); - - QWindow *window = widget->windowHandle(); - if (!window->handle() - || window->surfaceType() != QWindow::OpenGLSurface - || window->requestedFormat() != winFormat) - { - window->setSurfaceType(QWindow::OpenGLSurface); - window->setFormat(winFormat); - window->destroy(); - window->create(); - } - - if (d->ownContext) - delete d->guiGlContext; - d->ownContext = true; - QOpenGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0; - d->guiGlContext = new QOpenGLContext; - d->guiGlContext->setFormat(winFormat); - d->guiGlContext->setShareContext(shareGlContext); - d->valid = d->guiGlContext->create(); - - if (d->valid) - d->guiGlContext->setQGLContextHandle(this, 0); - - d->glFormat = QGLFormat::fromSurfaceFormat(d->guiGlContext->format()); - d->setupSharing(); - } - - - return d->valid; -} - -/*! - \fn void QGLContext::reset() - - Resets the context and makes it invalid. - - \sa create(), isValid() -*/ -void QGLContext::reset() -{ - Q_D(QGLContext); - if (!d->valid) - return; - d->cleanup(); - - d->crWin = false; - d->sharing = false; - d->valid = false; - d->transpColor = QColor(); - d->initDone = false; - QGLContextGroup::removeShare(this); - if (d->guiGlContext) { - if (QOpenGLContext::currentContext() == d->guiGlContext) - doneCurrent(); - if (d->ownContext) { - if (d->guiGlContext->thread() == QThread::currentThread()) - delete d->guiGlContext; - else - d->guiGlContext->deleteLater(); - } else - d->guiGlContext->setQGLContextHandle(0,0); - d->guiGlContext = 0; - } - d->ownContext = false; -} - -/*! - \fn void QGLContext::makeCurrent() - - Makes this context the current OpenGL rendering context. All GL - functions you call operate on this context until another context - is made current. - - In some very rare cases the underlying call may fail. If this - occurs an error message is output to stderr. - - If you call this from a thread other than the main UI thread, - make sure you've first pushed the context to the relevant thread - from the UI thread using moveToThread(). -*/ -void QGLContext::makeCurrent() -{ - Q_D(QGLContext); - if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) - return; - - QWidget *widget = static_cast<QWidget *>(d->paintDevice); - if (!widget->windowHandle()) - return; - - if (d->guiGlContext->makeCurrent(widget->windowHandle())) { - if (!d->workaroundsCached) { - d->workaroundsCached = true; - const char *renderer = reinterpret_cast<const char *>(d->guiGlContext->functions()->glGetString(GL_RENDERER)); - if (renderer && strstr(renderer, "Mali")) { - d->workaround_brokenFBOReadBack = true; - } - } - } -} - -/*! - \fn void QGLContext::swapBuffers() const - - Call this to finish a frame of OpenGL rendering, and make sure to - call makeCurrent() again before issuing any further OpenGL commands, - for example as part of a new frame. -*/ -void QGLContext::swapBuffers() const -{ - Q_D(const QGLContext); - if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) - return; - - QWidget *widget = static_cast<QWidget *>(d->paintDevice); - if (!widget->windowHandle()) - return; - - d->guiGlContext->swapBuffers(widget->windowHandle()); -} - -/*! - \fn void QGLContext::doneCurrent() - - Makes no GL context the current context. Normally, you do not need - to call this function; QGLContext calls it as necessary. -*/ -void QGLContext::doneCurrent() -{ - Q_D(QGLContext); - d->guiGlContext->doneCurrent(); -} - -/*! - \fn QPaintDevice* QGLContext::device() const - - Returns the paint device set for this context. - - \sa QGLContext::QGLContext() -*/ - -/***************************************************************************** - QGLWidget implementation - *****************************************************************************/ - - -/*! - \class QGLWidget - \inmodule QtOpenGL - \obsolete - - \brief The QGLWidget class is a widget for rendering OpenGL graphics. - - QGLWidget provides functionality for displaying OpenGL graphics - integrated into a Qt application. It is very simple to use. You - inherit from it and use the subclass like any other QWidget, - except that you have the choice between using QPainter and - standard OpenGL rendering commands. - - \note This class is part of the legacy \l {Qt OpenGL} module and, - like the other \c QGL classes, should be avoided in the new - applications. Instead, starting from Qt 5.4, prefer using - QOpenGLWidget and the \c QOpenGL classes. - - QGLWidget provides three convenient virtual functions that you can - reimplement in your subclass to perform the typical OpenGL tasks: - - \list - \li paintGL() - Renders the OpenGL scene. Gets called whenever the widget - needs to be updated. - \li resizeGL() - Sets up the OpenGL viewport, projection, etc. Gets - called whenever the widget has been resized (and also when it - is shown for the first time because all newly created widgets get a - resize event automatically). - \li initializeGL() - Sets up the OpenGL rendering context, defines display - lists, etc. Gets called once before the first time resizeGL() or - paintGL() is called. - \endlist - - Here is a rough outline of how a QGLWidget subclass might look: - - \snippet code/src_opengl_qgl.cpp 8 - - If you need to trigger a repaint from places other than paintGL() - (a typical example is when using \l{QTimer}{timers} to - animate scenes), you should call the widget's updateGL() function. - - Your widget's OpenGL rendering context is made current when - paintGL(), resizeGL(), or initializeGL() is called. If you need to - call the standard OpenGL API functions from other places (e.g. in - your widget's constructor or in your own paint functions), you - must call makeCurrent() first. - - QGLWidget provides functions for requesting a new display - \l{QGLFormat}{format} and you can also create widgets with - customized rendering \l{QGLContext}{contexts}. - - You can also share OpenGL display lists between QGLWidget objects (see - the documentation of the QGLWidget constructors for details). - - Note that under Windows, the QGLContext belonging to a QGLWidget - has to be recreated when the QGLWidget is reparented. This is - necessary due to limitations on the Windows platform. This will - most likely cause problems for users that have subclassed and - installed their own QGLContext on a QGLWidget. It is possible to - work around this issue by putting the QGLWidget inside a dummy - widget and then reparenting the dummy widget, instead of the - QGLWidget. This will side-step the issue altogether, and is what - we recommend for users that need this kind of functionality. - - On \macos, when Qt is built with Cocoa support, a QGLWidget - can't have any sibling widgets placed ontop of itself. This is due - to limitations in the Cocoa API and is not supported by Apple. - - \section1 Overlays - - The QGLWidget creates a GL overlay context in addition to the - normal context if overlays are supported by the underlying system. - - If you want to use overlays, you specify it in the - \l{QGLFormat}{format}. (Note: Overlay must be requested in the format - passed to the QGLWidget constructor.) Your GL widget should also - implement some or all of these virtual methods: - - \list - \li paintOverlayGL() - \li resizeOverlayGL() - \li initializeOverlayGL() - \endlist - - These methods work in the same way as the normal paintGL() etc. - functions, except that they will be called when the overlay - context is made current. You can explicitly make the overlay - context current by using makeOverlayCurrent(), and you can access - the overlay context directly (e.g. to ask for its transparent - color) by calling overlayContext(). - - On X servers in which the default visual is in an overlay plane, - non-GL Qt windows can also be used for overlays. - - \section1 Painting Techniques - - As described above, subclass QGLWidget to render pure 3D content in the - following way: - - \list - \li Reimplement the QGLWidget::initializeGL() and QGLWidget::resizeGL() to - set up the OpenGL state and provide a perspective transformation. - \li Reimplement QGLWidget::paintGL() to paint the 3D scene, calling only - OpenGL functions to draw on the widget. - \endlist - - It is also possible to draw 2D graphics onto a QGLWidget subclass, it is necessary - to reimplement QGLWidget::paintEvent() and do the following: - - \list - \li Construct a QPainter object. - \li Initialize it for use on the widget with the QPainter::begin() function. - \li Draw primitives using QPainter's member functions. - \li Call QPainter::end() to finish painting. - \endlist - - \section1 Threading - - As of Qt version 4.8, support for doing threaded GL rendering has - been improved. There are three scenarios that we currently support: - \list - \li 1. Buffer swapping in a thread. - - Swapping buffers in a double buffered context may be a - synchronous, locking call that may be a costly operation in some - GL implementations. Especially so on embedded devices. It's not - optimal to have the CPU idling while the GPU is doing a buffer - swap. In those cases it is possible to do the rendering in the - main thread and do the actual buffer swap in a separate - thread. This can be done with the following steps: - - 1. Call doneCurrent() in the main thread when the rendering is - finished. - - 2. Call QGLContext::moveToThread(swapThread) to transfer ownership - of the context to the swapping thread. - - 3. Notify the swapping thread that it can grab the context. - - 4. Make the rendering context current in the swapping thread with - makeCurrent() and then call swapBuffers(). - - 5. Call doneCurrent() in the swapping thread. - - 6. Call QGLContext::moveToThread(qApp->thread()) and notify the - main thread that swapping is done. - - Doing this will free up the main thread so that it can continue - with, for example, handling UI events or network requests. Even if - there is a context swap involved, it may be preferable compared to - having the main thread wait while the GPU finishes the swap - operation. Note that this is highly implementation dependent. - - \li 2. Texture uploading in a thread. - - Doing texture uploads in a thread may be very useful for - applications handling large amounts of images that needs to be - displayed, like for instance a photo gallery application. This is - supported in Qt through the existing bindTexture() API. A simple - way of doing this is to create two sharing QGLWidgets. One is made - current in the main GUI thread, while the other is made current in - the texture upload thread. The widget in the uploading thread is - never shown, it is only used for sharing textures with the main - thread. For each texture that is bound via bindTexture(), notify - the main thread so that it can start using the texture. - - \li 3. Using QPainter to draw into a QGLWidget in a thread. - - In Qt 4.8, it is possible to draw into a QGLWidget using a - QPainter in a separate thread. Note that this is also possible for - QGLPixelBuffers and QGLFramebufferObjects. Since this is only - supported in the GL 2 paint engine, OpenGL 2.0 or OpenGL ES 2.0 is - required. - - QGLWidgets can only be created in the main GUI thread. This means - a call to doneCurrent() is necessary to release the GL context - from the main thread, before the widget can be drawn into by - another thread. You then need to call QGLContext::moveToThread() - to transfer ownership of the context to the thread in which you - want to make it current. - Also, the main GUI thread will dispatch resize and - paint events to a QGLWidget when the widget is resized, or parts - of it becomes exposed or needs redrawing. It is therefore - necessary to handle those events because the default - implementations inside QGLWidget will try to make the QGLWidget's - context current, which again will interfere with any threads - rendering into the widget. Reimplement QGLWidget::paintEvent() and - QGLWidget::resizeEvent() to notify the rendering thread that a - resize or update is necessary, and be careful not to call the base - class implementation. If you are rendering an animation, it might - not be necessary to handle the paint event at all since the - rendering thread is doing regular updates. Then it would be enough - to reimplement QGLWidget::paintEvent() to do nothing. - - \endlist - - As a general rule when doing threaded rendering: be aware that - binding and releasing contexts in different threads have to be - synchronized by the user. A GL rendering context can only be - current in one thread at any time. If you try to open a QPainter - on a QGLWidget and the widget's rendering context is current in - another thread, it will fail. - - In addition to this, rendering using raw GL calls in a separate - thread is supported. - - \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other - countries.} - - \sa QOpenGLWidget, QGLPixelBuffer -*/ - -/*! - Constructs an OpenGL widget with a \a parent widget. - - The \l{QGLFormat::defaultFormat()}{default format} is - used. The widget will be \l{isValid()}{invalid} if the - system has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. - - The \a parent and widget flag, \a f, arguments are passed - to the QWidget constructor. - - If \a shareWidget is a valid QGLWidget, this widget will share - OpenGL display lists and texture objects with \a shareWidget. But - if \a shareWidget and this widget have different \l {format()} - {formats}, sharing might not be possible. You can check whether - sharing is in effect by calling isSharing(). - - The initialization of OpenGL rendering state, etc. should be done - by overriding the initializeGL() function, rather than in the - constructor of your QGLWidget subclass. - - \sa QGLFormat::defaultFormat(), {Textures Example} -*/ - -QGLWidget::QGLWidget(QWidget *parent, const QGLWidget* shareWidget, Qt::WindowFlags f) - : QWidget(*(new QGLWidgetPrivate), parent, f) -{ - Q_D(QGLWidget); - d->init(new QGLContext(QGLFormat::defaultFormat(), this), shareWidget); -} - -/*! - \internal - */ -QGLWidget::QGLWidget(QGLWidgetPrivate &dd, const QGLFormat &format, QWidget *parent, const QGLWidget *shareWidget, Qt::WindowFlags f) - : QWidget(dd, parent, f) -{ - Q_D(QGLWidget); - d->init(new QGLContext(format, this), shareWidget); - -} - - -/*! - Constructs an OpenGL widget with parent \a parent. - - The \a format argument specifies the desired - \l{QGLFormat}{rendering options}. - If the underlying OpenGL/Window system - cannot satisfy all the features requested in \a format, the - nearest subset of features will be used. After creation, the - format() method will return the actual format obtained. - - The widget will be \l{isValid()}{invalid} if the system - has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. - - The \a parent and widget flag, \a f, arguments are passed - to the QWidget constructor. - - If \a shareWidget is a valid QGLWidget, this widget will share - OpenGL display lists and texture objects with \a shareWidget. But - if \a shareWidget and this widget have different \l {format()} - {formats}, sharing might not be possible. You can check whether - sharing is in effect by calling isSharing(). - - The initialization of OpenGL rendering state, etc. should be done - by overriding the initializeGL() function, rather than in the - constructor of your QGLWidget subclass. - - \sa QGLFormat::defaultFormat(), isValid() -*/ - -QGLWidget::QGLWidget(const QGLFormat &format, QWidget *parent, const QGLWidget* shareWidget, - Qt::WindowFlags f) - : QWidget(*(new QGLWidgetPrivate), parent, f) -{ - Q_D(QGLWidget); - d->init(new QGLContext(format, this), shareWidget); -} - -/*! - Constructs an OpenGL widget with parent \a parent. - - The \a context argument is a pointer to the QGLContext that - you wish to be bound to this widget. This allows you to pass in - your own QGLContext sub-classes. - - The widget will be \l{isValid()}{invalid} if the system - has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. - - The \a parent and widget flag, \a f, arguments are passed - to the QWidget constructor. - - If \a shareWidget is a valid QGLWidget, this widget will share - OpenGL display lists and texture objects with \a shareWidget. But - if \a shareWidget and this widget have different \l {format()} - {formats}, sharing might not be possible. You can check whether - sharing is in effect by calling isSharing(). - - The initialization of OpenGL rendering state, etc. should be done - by overriding the initializeGL() function, rather than in the - constructor of your QGLWidget subclass. - - \sa QGLFormat::defaultFormat(), isValid() -*/ -QGLWidget::QGLWidget(QGLContext *context, QWidget *parent, const QGLWidget *shareWidget, - Qt::WindowFlags f) - : QWidget(*(new QGLWidgetPrivate), parent, f) -{ - Q_D(QGLWidget); - d->init(context, shareWidget); -} - -/*! - Destroys the widget. -*/ - -QGLWidget::~QGLWidget() -{ - Q_D(QGLWidget); - delete d->glcx; - d->glcx = 0; - d->cleanupColormaps(); -} - -/*! - \fn QGLFormat QGLWidget::format() const - - Returns the format of the contained GL rendering context. -*/ - -/*! - \fn bool QGLWidget::doubleBuffer() const - - Returns \c true if the contained GL rendering context has double - buffering; otherwise returns \c false. - - \sa QGLFormat::doubleBuffer() -*/ - -/*! - \fn void QGLWidget::setAutoBufferSwap(bool on) - - If \a on is true automatic GL buffer swapping is switched on; - otherwise it is switched off. - - If \a on is true and the widget is using a double-buffered format, - the background and foreground GL buffers will automatically be - swapped after each paintGL() call. - - The buffer auto-swapping is on by default. - - \sa autoBufferSwap(), doubleBuffer(), swapBuffers() -*/ - -/*! - \fn bool QGLWidget::autoBufferSwap() const - - Returns \c true if the widget is doing automatic GL buffer swapping; - otherwise returns \c false. - - \sa setAutoBufferSwap() -*/ - -/*! - \fn QFunctionPointer QGLContext::getProcAddress(const QString &proc) const - - Returns a function pointer to the GL extension function passed in - \a proc. \nullptr is returned if a pointer to the function could not be - obtained. -*/ -QFunctionPointer QGLContext::getProcAddress(const QString &procName) const -{ - Q_D(const QGLContext); - return d->guiGlContext->getProcAddress(procName.toLatin1()); -} - -/*! - \fn bool QGLWidget::isValid() const - - Returns \c true if the widget has a valid GL rendering context; - otherwise returns \c false. A widget will be invalid if the system - has no \l{QGLFormat::hasOpenGL()}{OpenGL support}. -*/ - -bool QGLWidget::isValid() const -{ - Q_D(const QGLWidget); - return d->glcx && d->glcx->isValid(); -} - -/*! - \fn bool QGLWidget::isSharing() const - - Returns \c true if this widget's GL context is shared with another GL - context, otherwise false is returned. Context sharing might not be - possible if the widgets use different formats. - - \sa format() -*/ - -bool QGLWidget::isSharing() const -{ - Q_D(const QGLWidget); - return d->glcx->isSharing(); -} - -/*! - \fn void QGLWidget::makeCurrent() - - Makes this widget the current widget for OpenGL operations, i.e. - makes the widget's rendering context the current OpenGL rendering - context. -*/ - -void QGLWidget::makeCurrent() -{ - Q_D(QGLWidget); - d->makeCurrent(); -} - -bool QGLWidgetPrivate::makeCurrent() -{ - glcx->makeCurrent(); - return QGLContext::currentContext() == glcx; -} - -/*! - \fn void QGLWidget::doneCurrent() - - Makes no GL context the current context. Normally, you do not need - to call this function; QGLContext calls it as necessary. However, - it may be useful in multithreaded environments. -*/ - -void QGLWidget::doneCurrent() -{ - Q_D(QGLWidget); - d->glcx->doneCurrent(); -} - -/*! - \fn void QGLWidget::swapBuffers() - - Swaps the screen contents with an off-screen buffer. This only - works if the widget's format specifies double buffer mode. - - Normally, there is no need to explicitly call this function - because it is done automatically after each widget repaint, i.e. - each time after paintGL() has been executed. - - \sa doubleBuffer(), setAutoBufferSwap(), QGLFormat::setDoubleBuffer() -*/ - -void QGLWidget::swapBuffers() -{ - Q_D(QGLWidget); - d->glcx->swapBuffers(); -} - - -/*! - \fn const QGLContext* QGLWidget::overlayContext() const - - Returns the overlay context of this widget, or \nullptr if this - widget has no overlay. - - \sa context() -*/ -const QGLContext* QGLWidget::overlayContext() const -{ - return nullptr; -} - -/*! - \fn void QGLWidget::makeOverlayCurrent() - - Makes the overlay context of this widget current. Use this if you - need to issue OpenGL commands to the overlay context outside of - initializeOverlayGL(), resizeOverlayGL(), and paintOverlayGL(). - - Does nothing if this widget has no overlay. - - \sa makeCurrent() -*/ -void QGLWidget::makeOverlayCurrent() -{ -} - -/*! - \obsolete - - Sets a new format for this widget. - - If the underlying OpenGL/Window system cannot satisfy all the - features requested in \a format, the nearest subset of features will - be used. After creation, the format() method will return the actual - rendering context format obtained. - - The widget will be assigned a new QGLContext, and the initializeGL() - function will be executed for this new context before the first - resizeGL() or paintGL(). - - This method will try to keep display list and texture object sharing - in effect with other QGLWidget objects, but changing the format might make - sharing impossible. Use isSharing() to see if sharing is still in - effect. - - \sa format(), isSharing(), isValid() -*/ - -void QGLWidget::setFormat(const QGLFormat &format) -{ - setContext(new QGLContext(format,this)); -} - - - - -/*! - \fn QGLContext *QGLWidget::context() const - - Returns the context of this widget. - - It is possible that the context is not valid (see isValid()), for - example, if the underlying hardware does not support the format - attributes that were requested. -*/ - -/*! - \fn void QGLWidget::setContext(QGLContext *context, - const QGLContext* shareContext, - bool deleteOldContext) - \obsolete - - Sets a new context for this widget. The QGLContext \a context must - be created using \e new. QGLWidget will delete \a context when - another context is set or when the widget is destroyed. - - If \a context is invalid, QGLContext::create() is performed on - it. The initializeGL() function will then be executed for the new - context before the first resizeGL() or paintGL(). - - If \a context is invalid, this method will try to keep display list - and texture object sharing in effect, or (if \a shareContext points - to a valid context) start display list and texture object sharing - with that context, but sharing might be impossible if the two - contexts have different \l {format()} {formats}. Use isSharing() to - see whether sharing is in effect. - - If \a deleteOldContext is true (the default), the existing context - will be deleted. You may use false here if you have kept a pointer - to the old context (as returned by context()), and want to restore - that context later. - - \note This function is obsolete and should no longer be used. If you were - using it to recreate the context for a QGLWidget, you should instead create a - new QGLWidget or use the QOpenGLContext API in conjunction with QWindow. - There is currently no officially supported way to substitute QGLWidget's - context with your own implementation of QGLContext. - - \sa context(), isSharing() -*/ -void QGLWidget::setContext(QGLContext *context, - const QGLContext* shareContext, - bool deleteOldContext) -{ - Q_D(QGLWidget); - if (context == 0) { - qWarning("QGLWidget::setContext: Cannot set null context"); - return; - } - - if (context->device() == 0) // a context may refere to more than 1 window. - context->setDevice(this); //but its better to point to 1 of them than none of them. - - QGLContext* oldcx = d->glcx; - d->glcx = context; - - if (!d->glcx->isValid()) - d->glcx->create(shareContext ? shareContext : oldcx); - - if (deleteOldContext) - delete oldcx; -} - -/*! - \fn void QGLWidget::updateGL() - - Updates the widget by calling glDraw(). -*/ - -void QGLWidget::updateGL() -{ - Q_D(QGLWidget); - const bool targetIsOffscreen = !d->glcx->d_ptr->readback_target_size.isEmpty(); - if (updatesEnabled() && (testAttribute(Qt::WA_Mapped) || targetIsOffscreen)) - glDraw(); -} - - -/*! - \fn void QGLWidget::updateOverlayGL() - - Updates the widget's overlay (if any). Will cause the virtual - function paintOverlayGL() to be executed. - - The widget's rendering context will become the current context and - initializeGL() will be called if it hasn't already been called. -*/ -void QGLWidget::updateOverlayGL() -{ -} - -/*! - This virtual function is called once before the first call to - paintGL() or resizeGL(), and then once whenever the widget has - been assigned a new QGLContext. Reimplement it in a subclass. - - This function should set up any required OpenGL context rendering - flags, defining display lists, etc. - - There is no need to call makeCurrent() because this has already - been done when this function is called. -*/ - -void QGLWidget::initializeGL() -{ -} - - -/*! - This virtual function is called whenever the widget needs to be - painted. Reimplement it in a subclass. - - There is no need to call makeCurrent() because this has already - been done when this function is called. -*/ - -void QGLWidget::paintGL() -{ - qgl_functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -} - - -/*! - \fn void QGLWidget::resizeGL(int width , int height) - - This virtual function is called whenever the widget has been - resized. The new size is passed in \a width and \a height. - Reimplement it in a subclass. - - There is no need to call makeCurrent() because this has already - been done when this function is called. -*/ - -void QGLWidget::resizeGL(int, int) -{ -} - - - -/*! - This virtual function is used in the same manner as initializeGL() - except that it operates on the widget's overlay context instead of - the widget's main context. This means that initializeOverlayGL() - is called once before the first call to paintOverlayGL() or - resizeOverlayGL(). Reimplement it in a subclass. - - This function should set up any required OpenGL context rendering - flags, defining display lists, etc. for the overlay context. - - There is no need to call makeOverlayCurrent() because this has - already been done when this function is called. -*/ - -void QGLWidget::initializeOverlayGL() -{ -} - - -/*! - This virtual function is used in the same manner as paintGL() - except that it operates on the widget's overlay context instead of - the widget's main context. This means that paintOverlayGL() is - called whenever the widget's overlay needs to be painted. - Reimplement it in a subclass. - - There is no need to call makeOverlayCurrent() because this has - already been done when this function is called. -*/ - -void QGLWidget::paintOverlayGL() -{ -} - - -/*! - \fn void QGLWidget::resizeOverlayGL(int width , int height) - - This virtual function is used in the same manner as paintGL() - except that it operates on the widget's overlay context instead of - the widget's main context. This means that resizeOverlayGL() is - called whenever the widget has been resized. The new size is - passed in \a width and \a height. Reimplement it in a subclass. - - There is no need to call makeOverlayCurrent() because this has - already been done when this function is called. -*/ - -void QGLWidget::resizeOverlayGL(int, int) -{ -} - -/*!\reimp -*/ -bool QGLWidget::event(QEvent *e) -{ - Q_D(QGLWidget); - - // A re-parent will destroy the window and re-create it. We should not reset the context while it happens. - if (e->type() == QEvent::ParentAboutToChange) - d->parent_changing = true; - - if (e->type() == QEvent::ParentChange) - d->parent_changing = false; - - return QWidget::event(e); -} - -/*! - \fn void QGLWidget::paintEvent(QPaintEvent *event) - - Handles paint events passed in the \a event parameter. Will cause - the virtual paintGL() function to be called. - - The widget's rendering context will become the current context and - initializeGL() will be called if it hasn't already been called. -*/ - -void QGLWidget::paintEvent(QPaintEvent *) -{ - if (updatesEnabled()) { - glDraw(); - updateOverlayGL(); - } -} - - -/*! - \fn void QGLWidget::resizeEvent(QResizeEvent *event) - - Handles resize events that are passed in the \a event parameter. - Calls the virtual function resizeGL(). -*/ -void QGLWidget::resizeEvent(QResizeEvent *e) -{ - Q_D(QGLWidget); - - QWidget::resizeEvent(e); - if (!isValid()) - return; - if (!d->makeCurrent()) - return; - if (!d->glcx->initialized()) - glInit(); - const qreal scaleFactor = (window() && window()->windowHandle()) ? - window()->windowHandle()->devicePixelRatio() : 1.0; - - resizeGL(width() * scaleFactor, height() * scaleFactor); -} - -/*! - Renders the current scene on a pixmap and returns the pixmap. - - You can use this method on both visible and invisible QGLWidget objects. - - Internally the function renders into a framebuffer object and performs pixel - readback. This has a performance penalty, meaning that this function is not - suitable to be called at a high frequency. - - After creating and binding the framebuffer object, the function will call - initializeGL(), resizeGL(), and paintGL(). On the next normal update - initializeGL() and resizeGL() will be triggered again since the size of the - destination pixmap and the QGLWidget's size may differ. - - The size of the pixmap will be \a w pixels wide and \a h pixels high unless - one of these parameters is 0 (the default), in which case the pixmap will - have the same size as the widget. - - Care must be taken when using framebuffer objects in paintGL() in - combination with this function. To switch back to the default framebuffer, - use QGLFramebufferObject::bindDefault(). Binding FBO 0 is wrong since - renderPixmap() uses a custom framebuffer instead of the one provided by the - windowing system. - - \a useContext is ignored. Historically this parameter enabled the usage of - the existing GL context. This is not supported anymore since additional - contexts are never created. - - Overlays are not rendered onto the pixmap. - - If the GL rendering context and the desktop have different bit - depths, the result will most likely look surprising. - - Note that the creation of display lists, modifications of the view - frustum etc. should be done from within initializeGL(). If this is - not done, the temporary QGLContext will not be initialized - properly, and the rendered pixmap may be incomplete/corrupted. -*/ - -QPixmap QGLWidget::renderPixmap(int w, int h, bool useContext) -{ - Q_UNUSED(useContext); - Q_D(QGLWidget); - - QSize sz = size(); - if ((w > 0) && (h > 0)) - sz = QSize(w, h); - - QPixmap pm; - if (d->glcx->isValid()) { - d->glcx->makeCurrent(); - QGLFramebufferObject fbo(sz, QGLFramebufferObject::CombinedDepthStencil); - fbo.bind(); - d->glcx->setInitialized(false); - uint prevDefaultFbo = d->glcx->d_ptr->default_fbo; - d->glcx->d_ptr->default_fbo = fbo.handle(); - d->glcx->d_ptr->readback_target_size = sz; - updateGL(); - fbo.release(); - pm = QPixmap::fromImage(fbo.toImage()); - d->glcx->d_ptr->default_fbo = prevDefaultFbo; - d->glcx->setInitialized(false); - d->glcx->d_ptr->readback_target_size = QSize(); - } - - return pm; -} - -/*! - Returns an image of the frame buffer. If \a withAlpha is true the - alpha channel is included. - - Depending on your hardware, you can explicitly select which color - buffer to grab with a glReadBuffer() call before calling this - function. - - On QNX the back buffer is not preserved when swapBuffers() is called. The back buffer - where this function reads from, might thus not contain the same content as the front buffer. - In order to retrieve what is currently visible on the screen, swapBuffers() - has to be executed prior to this function call. -*/ -QImage QGLWidget::grabFrameBuffer(bool withAlpha) -{ - makeCurrent(); - QImage res; - qreal pixelRatio = devicePixelRatioF(); - int w = pixelRatio * width(); - int h = pixelRatio * height(); - if (format().rgba()) - res = qt_gl_read_frame_buffer(QSize(w, h), format().alpha(), withAlpha); - res.setDevicePixelRatio(pixelRatio); - return res; -} - - - -/*! - Initializes OpenGL for this widget's context. Calls the virtual - function initializeGL(). -*/ - -void QGLWidget::glInit() -{ - Q_D(QGLWidget); - if (!isValid()) - return; - if (!d->makeCurrent()) - return; - initializeGL(); - d->glcx->setInitialized(true); -} - - -/*! - Executes the virtual function paintGL(). - - The widget's rendering context will become the current context and - initializeGL() will be called if it hasn't already been called. -*/ - -void QGLWidget::glDraw() -{ - Q_D(QGLWidget); - if (!isValid()) - return; - if (!d->makeCurrent()) - return; -#ifndef QT_OPENGL_ES - if (d->glcx->deviceIsPixmap() && !d->glcx->contextHandle()->isOpenGLES()) - qgl1_functions()->glDrawBuffer(GL_FRONT); -#endif - QSize readback_target_size = d->glcx->d_ptr->readback_target_size; - if (!d->glcx->initialized()) { - glInit(); - const qreal scaleFactor = (window() && window()->windowHandle()) ? - window()->windowHandle()->devicePixelRatio() : 1.0; - int w, h; - if (readback_target_size.isEmpty()) { - w = d->glcx->device()->width() * scaleFactor; - h = d->glcx->device()->height() * scaleFactor; - } else { - w = readback_target_size.width(); - h = readback_target_size.height(); - } - resizeGL(w, h); // New context needs this "resize" - } - paintGL(); - if (doubleBuffer() && readback_target_size.isEmpty()) { - if (d->autoSwap) - swapBuffers(); - } else { - qgl_functions()->glFlush(); - } -} - -/*! - Convenience function for specifying a drawing color to OpenGL. - Calls glColor4 (in RGBA mode) or glIndex (in color-index mode) - with the color \a c. Applies to this widgets GL context. - - \note This function is not supported on OpenGL/ES 2.0 systems. - - \sa qglClearColor(), QGLContext::currentContext(), QColor -*/ - -void QGLWidget::qglColor(const QColor& c) const -{ -#if !defined(QT_OPENGL_ES_2) -#ifdef QT_OPENGL_ES - qgl_functions()->glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF()); -#else - Q_D(const QGLWidget); - const QGLContext *ctx = QGLContext::currentContext(); - if (ctx && !ctx->contextHandle()->isOpenGLES()) { - if (ctx->format().rgba()) - qgl1_functions()->glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF()); - else if (!d->cmap.isEmpty()) { // QGLColormap in use? - int i = d->cmap.find(c.rgb()); - if (i < 0) - i = d->cmap.findNearest(c.rgb()); - qgl1_functions()->glIndexi(i); - } else - qgl1_functions()->glIndexi(ctx->colorIndex(c)); - } -#endif //QT_OPENGL_ES -#else - Q_UNUSED(c); -#endif //QT_OPENGL_ES_2 -} - -/*! - Convenience function for specifying the clearing color to OpenGL. - Calls glClearColor (in RGBA mode) or glClearIndex (in color-index - mode) with the color \a c. Applies to this widgets GL context. - - \sa qglColor(), QGLContext::currentContext(), QColor -*/ - -void QGLWidget::qglClearColor(const QColor& c) const -{ -#ifdef QT_OPENGL_ES - qgl_functions()->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); -#else - Q_D(const QGLWidget); - const QGLContext *ctx = QGLContext::currentContext(); - if (ctx && !ctx->contextHandle()->isOpenGLES()) { - if (ctx->format().rgba()) - qgl_functions()->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); - else if (!d->cmap.isEmpty()) { // QGLColormap in use? - int i = d->cmap.find(c.rgb()); - if (i < 0) - i = d->cmap.findNearest(c.rgb()); - qgl1_functions()->glClearIndex(i); - } else { - qgl1_functions()->glClearIndex(ctx->colorIndex(c)); - } - } else { - qgl_functions()->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); - } -#endif -} - - -/*! - Converts the image \a img into the unnamed format expected by - OpenGL functions such as glTexImage2D(). The returned image is not - usable as a QImage, but QImage::width(), QImage::height() and - QImage::bits() may be used with OpenGL. The GL format used is - \c GL_RGBA. - - \omit ### - - \l opengl/texture example - The following few lines are from the texture example. Most of the - code is irrelevant, so we just quote the relevant bits: - - \quotefromfile opengl/texture/gltexobj.cpp - \skipto tex1 - \printline tex1 - \printline gllogo.bmp - - We create \e tex1 (and another variable) for OpenGL, and load a real - image into \e buf. - - \skipto convertToGLFormat - \printline convertToGLFormat - - A few lines later, we convert \e buf into OpenGL format and store it - in \e tex1. - - \skipto glTexImage2D - \printline glTexImage2D - \printline tex1.bits - - Note the dimension restrictions for texture images as described in - the glTexImage2D() documentation. The width must be 2^m + 2*border - and the height 2^n + 2*border where m and n are integers and - border is either 0 or 1. - - Another function in the same example uses \e tex1 with OpenGL. - - \endomit -*/ - -QImage QGLWidget::convertToGLFormat(const QImage& img) -{ - QImage res(img.size(), QImage::Format_ARGB32); - convertToGLFormatHelper(res, img.convertToFormat(QImage::Format_ARGB32), GL_RGBA); - return res; -} - - -/*! - \fn QGLColormap & QGLWidget::colormap() const - - Returns the colormap for this widget. - - Usually it is only top-level widgets that can have different - colormaps installed. Asking for the colormap of a child widget - will return the colormap for the child's top-level widget. - - If no colormap has been set for this widget, the QGLColormap - returned will be empty. - - \sa setColormap(), QGLColormap::isEmpty() -*/ -const QGLColormap & QGLWidget::colormap() const -{ - Q_D(const QGLWidget); - return d->cmap; -} - -/*! - \fn void QGLWidget::setColormap(const QGLColormap & cmap) - - Set the colormap for this widget to \a cmap. Usually it is only - top-level widgets that can have colormaps installed. - - \sa colormap() -*/ -void QGLWidget::setColormap(const QGLColormap & c) -{ - Q_UNUSED(c); -} - -#ifndef QT_OPENGL_ES - -static void qt_save_gl_state() -{ - QOpenGLFunctions *funcs = qgl_functions(); - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - - gl1funcs->glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); - gl1funcs->glPushAttrib(GL_ALL_ATTRIB_BITS); - gl1funcs->glMatrixMode(GL_TEXTURE); - gl1funcs->glPushMatrix(); - gl1funcs->glLoadIdentity(); - gl1funcs->glMatrixMode(GL_PROJECTION); - gl1funcs->glPushMatrix(); - gl1funcs->glMatrixMode(GL_MODELVIEW); - gl1funcs->glPushMatrix(); - - gl1funcs->glShadeModel(GL_FLAT); - funcs->glDisable(GL_CULL_FACE); - funcs->glDisable(GL_LIGHTING); - funcs->glDisable(GL_STENCIL_TEST); - funcs->glDisable(GL_DEPTH_TEST); - funcs->glEnable(GL_BLEND); - funcs->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); -} - -static void qt_restore_gl_state() -{ - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - - gl1funcs->glMatrixMode(GL_TEXTURE); - gl1funcs->glPopMatrix(); - gl1funcs->glMatrixMode(GL_PROJECTION); - gl1funcs->glPopMatrix(); - gl1funcs->glMatrixMode(GL_MODELVIEW); - gl1funcs->glPopMatrix(); - gl1funcs->glPopAttrib(); - gl1funcs->glPopClientAttrib(); -} - -static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, - const QFont &font) -{ - GLfloat color[4]; - qgl_functions()->glGetFloatv(GL_CURRENT_COLOR, &color[0]); - - QColor col; - col.setRgbF(color[0], color[1], color[2],color[3]); - QPen old_pen = p->pen(); - QFont old_font = p->font(); - - p->setPen(col); - p->setFont(font); - p->drawText(x, y, str); - - p->setPen(old_pen); - p->setFont(old_font); -} - -#endif // !QT_OPENGL_ES - -/*! - Renders the string \a str into the GL context of this widget. - - \a x and \a y are specified in window coordinates, with the origin - in the upper left-hand corner of the window. If \a font is not - specified, the currently set application font will be used to - render the string. To change the color of the rendered text you can - use the glColor() call (or the qglColor() convenience function), - just before the renderText() call. - - \note This function clears the stencil buffer. - - \note This function is not supported on OpenGL/ES systems. - - \note This function temporarily disables depth-testing when the - text is drawn. - - \note This function can only be used inside a - QPainter::beginNativePainting()/QPainter::endNativePainting() block - if a painter is active on the QGLWidget. -*/ - -void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font) -{ -#ifndef QT_OPENGL_ES - Q_D(QGLWidget); - if (!d->glcx->contextHandle()->isOpenGLES()) { - Q_D(QGLWidget); - if (str.isEmpty() || !isValid()) - return; - - QOpenGLFunctions *funcs = qgl_functions(); - GLint view[4]; - bool use_scissor_testing = funcs->glIsEnabled(GL_SCISSOR_TEST); - if (!use_scissor_testing) - funcs->glGetIntegerv(GL_VIEWPORT, &view[0]); - int width = d->glcx->device()->width(); - int height = d->glcx->device()->height(); - bool auto_swap = autoBufferSwap(); - - QPaintEngine *engine = paintEngine(); - - qt_save_gl_state(); - - QPainter *p; - bool reuse_painter = false; - if (engine->isActive()) { - reuse_painter = true; - p = engine->painter(); - - funcs->glDisable(GL_DEPTH_TEST); - funcs->glViewport(0, 0, width, height); - } else { - setAutoBufferSwap(false); - // disable glClear() as a result of QPainter::begin() - d->disable_clear_on_painter_begin = true; - p = new QPainter(this); - } - - QRect viewport(view[0], view[1], view[2], view[3]); - if (!use_scissor_testing && viewport != rect()) { - // if the user hasn't set a scissor box, we set one that - // covers the current viewport - funcs->glScissor(view[0], view[1], view[2], view[3]); - funcs->glEnable(GL_SCISSOR_TEST); - } else if (use_scissor_testing) { - // use the scissor box set by the user - funcs->glEnable(GL_SCISSOR_TEST); - } - - qt_gl_draw_text(p, x, y, str, font); - - if (!reuse_painter) { - p->end(); - delete p; - setAutoBufferSwap(auto_swap); - d->disable_clear_on_painter_begin = false; - } - - qt_restore_gl_state(); - - return; - } -#else // QT_OPENGL_ES - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(str); - Q_UNUSED(font); -#endif - qWarning("QGLWidget::renderText is not supported under OpenGL/ES"); -} - -/*! \overload - - \a x, \a y and \a z are specified in scene or object coordinates - relative to the currently set projection and model matrices. This - can be useful if you want to annotate models with text labels and - have the labels move with the model as it is rotated etc. - - \note This function is not supported on OpenGL/ES systems. - - \note If depth testing is enabled before this function is called, - then the drawn text will be depth-tested against the models that - have already been drawn in the scene. Use \c{glDisable(GL_DEPTH_TEST)} - before calling this function to annotate the models without - depth-testing the text. - - \note This function can only be used inside a - QPainter::beginNativePainting()/QPainter::endNativePainting() block - if a painter is active on the QGLWidget. -*/ -void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font) -{ -#ifndef QT_OPENGL_ES - Q_D(QGLWidget); - if (!d->glcx->contextHandle()->isOpenGLES()) { - Q_D(QGLWidget); - if (str.isEmpty() || !isValid()) - return; - - QOpenGLFunctions *funcs = qgl_functions(); - bool auto_swap = autoBufferSwap(); - - int width = d->glcx->device()->width(); - int height = d->glcx->device()->height(); - GLdouble model[4 * 4], proj[4 * 4]; - GLint view[4]; - QOpenGLFunctions_1_1 *gl1funcs = qgl1_functions(); - gl1funcs->glGetDoublev(GL_MODELVIEW_MATRIX, &model[0]); - gl1funcs->glGetDoublev(GL_PROJECTION_MATRIX, &proj[0]); - funcs->glGetIntegerv(GL_VIEWPORT, &view[0]); - GLdouble win_x = 0, win_y = 0, win_z = 0; - qgluProject(x, y, z, &model[0], &proj[0], &view[0], - &win_x, &win_y, &win_z); - const int dpr = d->glcx->device()->devicePixelRatioF(); - win_x /= dpr; - win_y /= dpr; - win_y = height - win_y; // y is inverted - - QPaintEngine *engine = paintEngine(); - - QPainter *p; - bool reuse_painter = false; - bool use_depth_testing = funcs->glIsEnabled(GL_DEPTH_TEST); - bool use_scissor_testing = funcs->glIsEnabled(GL_SCISSOR_TEST); - - qt_save_gl_state(); - - if (engine->isActive()) { - reuse_painter = true; - p = engine->painter(); - } else { - setAutoBufferSwap(false); - // disable glClear() as a result of QPainter::begin() - d->disable_clear_on_painter_begin = true; - p = new QPainter(this); - } - - QRect viewport(view[0], view[1], view[2], view[3]); - if (!use_scissor_testing && viewport != rect()) { - funcs->glScissor(view[0], view[1], view[2], view[3]); - funcs->glEnable(GL_SCISSOR_TEST); - } else if (use_scissor_testing) { - funcs->glEnable(GL_SCISSOR_TEST); - } - funcs->glViewport(0, 0, width * dpr, height * dpr); - gl1funcs->glAlphaFunc(GL_GREATER, 0.0); - funcs->glEnable(GL_ALPHA_TEST); - if (use_depth_testing) - funcs->glEnable(GL_DEPTH_TEST); - - // The only option in Qt 5 is the shader-based OpenGL 2 paint engine. - // Setting fixed pipeline transformations is futile. Instead, pass the - // extra values directly and let the engine figure the matrices out. - static_cast<QGL2PaintEngineEx *>(p->paintEngine())->setTranslateZ(-2 * win_z); - - qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font); - - static_cast<QGL2PaintEngineEx *>(p->paintEngine())->setTranslateZ(0); - - if (!reuse_painter) { - p->end(); - delete p; - setAutoBufferSwap(auto_swap); - d->disable_clear_on_painter_begin = false; - } - - qt_restore_gl_state(); - - return; - } -#else // QT_OPENGL_ES - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(z); - Q_UNUSED(str); - Q_UNUSED(font); -#endif - qWarning("QGLWidget::renderText is not supported under OpenGL/ES"); -} - -QGLFormat QGLWidget::format() const -{ - Q_D(const QGLWidget); - return d->glcx->format(); -} - -QGLContext *QGLWidget::context() const -{ - Q_D(const QGLWidget); - return d->glcx; -} - -bool QGLWidget::doubleBuffer() const -{ - Q_D(const QGLWidget); - return d->glcx->d_ptr->glFormat.testOption(QGL::DoubleBuffer); -} - -void QGLWidget::setAutoBufferSwap(bool on) -{ - Q_D(QGLWidget); - d->autoSwap = on; -} - -bool QGLWidget::autoBufferSwap() const -{ - Q_D(const QGLWidget); - return d->autoSwap; -} - -/*! - Calls QGLContext:::bindTexture(\a image, \a target, \a format) on the currently - set context. - - \sa deleteTexture() -*/ -GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format) -{ - if (image.isNull()) - return 0; - - Q_D(QGLWidget); - return d->glcx->bindTexture(image, target, format, QGLContext::DefaultBindOption); -} - -/*! - \overload - \since 4.6 - - The binding \a options are a set of options used to decide how to - bind the texture to the context. - */ -GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) -{ - if (image.isNull()) - return 0; - - Q_D(QGLWidget); - return d->glcx->bindTexture(image, target, format, options); -} - - -/*! - Calls QGLContext:::bindTexture(\a pixmap, \a target, \a format) on the currently - set context. - - \sa deleteTexture() -*/ -GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format) -{ - if (pixmap.isNull()) - return 0; - - Q_D(QGLWidget); - return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption); -} - -/*! - \overload - \since 4.6 - - Generates and binds a 2D GL texture to the current context, based - on \a pixmap. The generated texture id is returned and can be used in - - The binding \a options are a set of options used to decide how to - bind the texture to the context. - */ -GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - Q_D(QGLWidget); - return d->glcx->bindTexture(pixmap, target, format, options); -} - -/*! \overload - - Calls QGLContext::bindTexture(\a fileName) on the currently set context. - - \sa deleteTexture() -*/ -GLuint QGLWidget::bindTexture(const QString &fileName) -{ - Q_D(QGLWidget); - return d->glcx->bindTexture(fileName); -} - -/*! - Calls QGLContext::deleteTexture(\a id) on the currently set - context. - - \sa bindTexture() -*/ -void QGLWidget::deleteTexture(GLuint id) -{ - Q_D(QGLWidget); - d->glcx->deleteTexture(id); -} - -/*! - \since 4.4 - - Calls the corresponding QGLContext::drawTexture() with - \a target, \a textureId, and \a textureTarget for this - widget's context. -*/ -void QGLWidget::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) -{ - Q_D(QGLWidget); - d->glcx->drawTexture(target, textureId, textureTarget); -} - -/*! - \since 4.4 - - Calls the corresponding QGLContext::drawTexture() with - \a point, \a textureId, and \a textureTarget for this - widget's context. -*/ -void QGLWidget::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) -{ - Q_D(QGLWidget); - d->glcx->drawTexture(point, textureId, textureTarget); -} - -Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_gl_2_engine) - -Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() -{ - return qt_gl_2_engine()->engine(); -} - -/*! - \internal - - Returns the GL widget's paint engine. -*/ -QPaintEngine *QGLWidget::paintEngine() const -{ - return qt_qgl_paint_engine(); -} - -void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget *shareWidget) -{ - Q_Q(QGLWidget); - q->setAttribute(Qt::WA_PaintOnScreen); - q->setAttribute(Qt::WA_NoSystemBackground); - q->setAutoFillBackground(true); // for compatibility - - mustHaveWindowHandle = 1; - q->setAttribute(Qt::WA_NativeWindow); - q->setWindowFlag(Qt::MSWindowsOwnDC); - - initContext(context, shareWidget); -} - -/* - This is the shared initialization for all platforms. Called from QGLWidgetPrivate::init() -*/ -void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWidget) -{ - Q_Q(QGLWidget); - - glDevice.setWidget(q); - - glcx = 0; - autoSwap = true; - - if (context && !context->device()) - context->setDevice(q); - q->setContext(context, shareWidget ? shareWidget->context() : 0); - - if (!glcx) - glcx = new QGLContext(QGLFormat::defaultFormat(), q); -} - -bool QGLWidgetPrivate::renderCxPm(QPixmap*) -{ - return false; -} - -/*! \internal - Free up any allocated colormaps. This fn is only called for - top-level widgets. -*/ -void QGLWidgetPrivate::cleanupColormaps() -{ -} - -void QGLContextGroup::addShare(const QGLContext *context, const QGLContext *share) { - Q_ASSERT(context && share); - if (context->d_ptr->group == share->d_ptr->group) - return; - - // Make sure 'context' is not already shared with another group of contexts. - Q_ASSERT(context->d_ptr->group->m_refs.loadRelaxed() == 1); - - // Free 'context' group resources and make it use the same resources as 'share'. - QGLContextGroup *group = share->d_ptr->group; - delete context->d_ptr->group; - context->d_ptr->group = group; - group->m_refs.ref(); - - // Maintain a list of all the contexts in each group of sharing contexts. - // The list is empty if the "share" context wasn't sharing already. - if (group->m_shares.isEmpty()) - group->m_shares.append(share); - group->m_shares.append(context); -} - -void QGLContextGroup::removeShare(const QGLContext *context) { - // Remove the context from the group. - QGLContextGroup *group = context->d_ptr->group; - if (group->m_shares.isEmpty()) - return; - group->m_shares.removeAll(context); - - // Update context group representative. - Q_ASSERT(group->m_shares.size() != 0); - if (group->m_context == context) - group->m_context = group->m_shares.at(0); - - // If there is only one context left, then make the list empty. - if (group->m_shares.size() == 1) - group->m_shares.clear(); -} - -QSize QGLTexture::bindCompressedTexture - (const QString& fileName, const char *format) -{ - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) - return QSize(); - QByteArray contents = file.readAll(); - file.close(); - return bindCompressedTexture - (contents.constData(), contents.size(), format); -} - -// PVR header format for container files that store textures compressed -// with the ETC1, PVRTC2, and PVRTC4 encodings. Format information from the -// PowerVR SDK at http://www.imgtec.com/powervr/insider/powervr-sdk.asp -// "PVRTexTool Reference Manual, version 1.11f". -struct PvrHeader -{ - quint32 headerSize; - quint32 height; - quint32 width; - quint32 mipMapCount; - quint32 flags; - quint32 dataSize; - quint32 bitsPerPixel; - quint32 redMask; - quint32 greenMask; - quint32 blueMask; - quint32 alphaMask; - quint32 magic; - quint32 surfaceCount; -}; - -#define PVR_MAGIC 0x21525650 // "PVR!" in little-endian - -#define PVR_FORMAT_MASK 0x000000FF -#define PVR_FORMAT_PVRTC2 0x00000018 -#define PVR_FORMAT_PVRTC4 0x00000019 -#define PVR_FORMAT_ETC1 0x00000036 - -#define PVR_HAS_MIPMAPS 0x00000100 -#define PVR_TWIDDLED 0x00000200 -#define PVR_NORMAL_MAP 0x00000400 -#define PVR_BORDER_ADDED 0x00000800 -#define PVR_CUBE_MAP 0x00001000 -#define PVR_FALSE_COLOR_MIPMAPS 0x00002000 -#define PVR_VOLUME_TEXTURE 0x00004000 -#define PVR_ALPHA_IN_TEXTURE 0x00008000 -#define PVR_VERTICAL_FLIP 0x00010000 - -#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - -#ifndef GL_ETC1_RGB8_OES -#define GL_ETC1_RGB8_OES 0x8D64 -#endif - -bool QGLTexture::canBindCompressedTexture - (const char *buf, int len, const char *format, bool *hasAlpha) -{ - if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) { - // Compressed texture loading only supported on little-endian - // systems such as x86 and ARM at the moment. - return false; - } - if (!format) { - // Auto-detect the format from the header. - if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) { - *hasAlpha = true; - return true; - } else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) { - const PvrHeader *pvrHeader = - reinterpret_cast<const PvrHeader *>(buf); - *hasAlpha = (pvrHeader->alphaMask != 0); - return true; - } - } else { - // Validate the format against the header. - if (!qstricmp(format, "DDS")) { - if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) { - *hasAlpha = true; - return true; - } - } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) { - if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) { - const PvrHeader *pvrHeader = - reinterpret_cast<const PvrHeader *>(buf); - *hasAlpha = (pvrHeader->alphaMask != 0); - return true; - } - } - } - return false; -} - -#define ctx QGLContext::currentContext() - -QSize QGLTexture::bindCompressedTexture - (const char *buf, int len, const char *format) -{ - if (QSysInfo::ByteOrder != QSysInfo::LittleEndian) { - // Compressed texture loading only supported on little-endian - // systems such as x86 and ARM at the moment. - return QSize(); - } - if (!format) { - // Auto-detect the format from the header. - if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) - return bindCompressedTextureDDS(buf, len); - else if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) - return bindCompressedTexturePVR(buf, len); - } else { - // Validate the format against the header. - if (!qstricmp(format, "DDS")) { - if (len >= 4 && !qstrncmp(buf, "DDS ", 4)) - return bindCompressedTextureDDS(buf, len); - } else if (!qstricmp(format, "PVR") || !qstricmp(format, "ETC1")) { - if (len >= 52 && !qstrncmp(buf + 44, "PVR!", 4)) - return bindCompressedTexturePVR(buf, len); - } - } - return QSize(); -} - -QSize QGLTexture::bindCompressedTextureDDS(const char *buf, int len) -{ - // We only support 2D texture loading at present. - if (target != GL_TEXTURE_2D) - return QSize(); - - // Bail out if the necessary extension is not present. - if (!qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::DDSTextureCompression)) { - qWarning("QGLContext::bindTexture(): DDS texture compression is not supported."); - return QSize(); - } - - const DDSFormat *ddsHeader = reinterpret_cast<const DDSFormat *>(buf + 4); - if (!ddsHeader->dwLinearSize) { - qWarning("QGLContext::bindTexture(): DDS image size is not valid."); - return QSize(); - } - - int blockSize = 16; - GLenum format; - - switch(ddsHeader->ddsPixelFormat.dwFourCC) { - case FOURCC_DXT1: - format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - blockSize = 8; - break; - case FOURCC_DXT3: - format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; - case FOURCC_DXT5: - format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; - default: - qWarning("QGLContext::bindTexture(): DDS image format not supported."); - return QSize(); - } - - const GLubyte *pixels = - reinterpret_cast<const GLubyte *>(buf + ddsHeader->dwSize + 4); - - QOpenGLFunctions *funcs = qgl_functions(); - funcs->glGenTextures(1, &id); - funcs->glBindTexture(GL_TEXTURE_2D, id); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - int size; - int offset = 0; - int available = len - int(ddsHeader->dwSize + 4); - int w = ddsHeader->dwWidth; - int h = ddsHeader->dwHeight; - - // load mip-maps - for(int i = 0; i < (int) ddsHeader->dwMipMapCount; ++i) { - if (w == 0) w = 1; - if (h == 0) h = 1; - - size = ((w+3)/4) * ((h+3)/4) * blockSize; - if (size > available) - break; - qgl_extensions()->glCompressedTexImage2D(GL_TEXTURE_2D, i, format, w, h, 0, - size, pixels + offset); - offset += size; - available -= size; - - // half size for each mip-map level - w = w/2; - h = h/2; - } - - // DDS images are not inverted. - options &= ~QGLContext::InvertedYBindOption; - - return QSize(ddsHeader->dwWidth, ddsHeader->dwHeight); -} - -QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len) -{ - // We only support 2D texture loading at present. Cube maps later. - if (target != GL_TEXTURE_2D) - return QSize(); - - // Determine which texture format we will be loading. - const PvrHeader *pvrHeader = reinterpret_cast<const PvrHeader *>(buf); - GLenum textureFormat; - quint32 minWidth, minHeight; - switch (pvrHeader->flags & PVR_FORMAT_MASK) { - case PVR_FORMAT_PVRTC2: - if (pvrHeader->alphaMask) - textureFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - else - textureFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - minWidth = 16; - minHeight = 8; - break; - - case PVR_FORMAT_PVRTC4: - if (pvrHeader->alphaMask) - textureFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - else - textureFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - minWidth = 8; - minHeight = 8; - break; - - case PVR_FORMAT_ETC1: - textureFormat = GL_ETC1_RGB8_OES; - minWidth = 4; - minHeight = 4; - break; - - default: - qWarning("QGLContext::bindTexture(): PVR image format 0x%x not supported.", int(pvrHeader->flags & PVR_FORMAT_MASK)); - return QSize(); - } - - // Bail out if the necessary extension is not present. - if (textureFormat == GL_ETC1_RGB8_OES) { - if (!qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::ETC1TextureCompression)) { - qWarning("QGLContext::bindTexture(): ETC1 texture compression is not supported."); - return QSize(); - } - } else { - if (!qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::PVRTCTextureCompression)) { - qWarning("QGLContext::bindTexture(): PVRTC texture compression is not supported."); - return QSize(); - } - } - - // Boundary check on the buffer size. - quint32 bufferSize = pvrHeader->headerSize + pvrHeader->dataSize; - if (bufferSize > quint32(len)) { - qWarning("QGLContext::bindTexture(): PVR image size is not valid."); - return QSize(); - } - - // Create the texture. - QOpenGLFunctions *funcs = qgl_functions(); - funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - funcs->glGenTextures(1, &id); - funcs->glBindTexture(GL_TEXTURE_2D, id); - if (pvrHeader->mipMapCount) { - if ((options & QGLContext::LinearFilteringBindOption) != 0) { - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - } else { - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); - } - } else if ((options & QGLContext::LinearFilteringBindOption) != 0) { - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - - // Load the compressed mipmap levels. - const GLubyte *buffer = - reinterpret_cast<const GLubyte *>(buf + pvrHeader->headerSize); - bufferSize = pvrHeader->dataSize; - quint32 level = 0; - quint32 width = pvrHeader->width; - quint32 height = pvrHeader->height; - while (bufferSize > 0 && level <= pvrHeader->mipMapCount) { - quint32 size = - (qMax(width, minWidth) * qMax(height, minHeight) * - pvrHeader->bitsPerPixel) / 8; - if (size > bufferSize) - break; - qgl_extensions()->glCompressedTexImage2D(GL_TEXTURE_2D, GLint(level), textureFormat, - GLsizei(width), GLsizei(height), 0, - GLsizei(size), buffer); - width /= 2; - height /= 2; - buffer += size; - ++level; - } - - // Restore the default pixel alignment for later texture uploads. - funcs->glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - - // Set the invert flag for the texture. The "vertical flip" - // flag in PVR is the opposite sense to our sense of inversion. - options.setFlag(QGLContext::InvertedYBindOption, !(pvrHeader->flags & PVR_VERTICAL_FLIP)); - - return QSize(pvrHeader->width, pvrHeader->height); -} - -#undef ctx - -QT_END_NAMESPACE diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h deleted file mode 100644 index f5accbeb3c..0000000000 --- a/src/opengl/qgl.h +++ /dev/null @@ -1,524 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGL_H -#define QGL_H - -#ifndef QT_NO_OPENGL - -#include <QtGui/qopengl.h> -#include <QtWidgets/qwidget.h> -#include <QtGui/qpaintengine.h> -#include <QtOpenGL/qglcolormap.h> -#include <QtCore/qmap.h> -#include <QtCore/qscopedpointer.h> - -#include <QtGui/QSurfaceFormat> - -QT_BEGIN_NAMESPACE - - - - -class QPixmap; -class QGLWidgetPrivate; -class QGLContextPrivate; - -// Namespace class: -namespace QGL -{ - enum FormatOption { - DoubleBuffer = 0x0001, - DepthBuffer = 0x0002, - Rgba = 0x0004, - AlphaChannel = 0x0008, - AccumBuffer = 0x0010, - StencilBuffer = 0x0020, - StereoBuffers = 0x0040, - DirectRendering = 0x0080, - HasOverlay = 0x0100, - SampleBuffers = 0x0200, - DeprecatedFunctions = 0x0400, - SingleBuffer = DoubleBuffer << 16, - NoDepthBuffer = DepthBuffer << 16, - ColorIndex = Rgba << 16, - NoAlphaChannel = AlphaChannel << 16, - NoAccumBuffer = AccumBuffer << 16, - NoStencilBuffer = StencilBuffer << 16, - NoStereoBuffers = StereoBuffers << 16, - IndirectRendering = DirectRendering << 16, - NoOverlay = HasOverlay << 16, - NoSampleBuffers = SampleBuffers << 16, - NoDeprecatedFunctions = DeprecatedFunctions << 16 - }; - Q_DECLARE_FLAGS(FormatOptions, FormatOption) -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGL::FormatOptions) - -class QGLFormatPrivate; - -class Q_OPENGL_EXPORT QGLFormat -{ -public: - QGLFormat(); - QGLFormat(QGL::FormatOptions options, int plane = 0); - QGLFormat(const QGLFormat &other); - QGLFormat &operator=(const QGLFormat &other); - ~QGLFormat(); - - void setDepthBufferSize(int size); - int depthBufferSize() const; - - void setAccumBufferSize(int size); - int accumBufferSize() const; - - void setRedBufferSize(int size); - int redBufferSize() const; - - void setGreenBufferSize(int size); - int greenBufferSize() const; - - void setBlueBufferSize(int size); - int blueBufferSize() const; - - void setAlphaBufferSize(int size); - int alphaBufferSize() const; - - void setStencilBufferSize(int size); - int stencilBufferSize() const; - - void setSampleBuffers(bool enable); - bool sampleBuffers() const; - - void setSamples(int numSamples); - int samples() const; - - void setSwapInterval(int interval); - int swapInterval() const; - - bool doubleBuffer() const; - void setDoubleBuffer(bool enable); - bool depth() const; - void setDepth(bool enable); - bool rgba() const; - void setRgba(bool enable); - bool alpha() const; - void setAlpha(bool enable); - bool accum() const; - void setAccum(bool enable); - bool stencil() const; - void setStencil(bool enable); - bool stereo() const; - void setStereo(bool enable); - bool directRendering() const; - void setDirectRendering(bool enable); - bool hasOverlay() const; - void setOverlay(bool enable); - - int plane() const; - void setPlane(int plane); - - void setOption(QGL::FormatOptions opt); - bool testOption(QGL::FormatOptions opt) const; - - static QGLFormat defaultFormat(); - static void setDefaultFormat(const QGLFormat& f); - - static QGLFormat defaultOverlayFormat(); - static void setDefaultOverlayFormat(const QGLFormat& f); - - static bool hasOpenGL(); - static bool hasOpenGLOverlays(); - - void setVersion(int major, int minor); - int majorVersion() const; - int minorVersion() const; - - enum OpenGLContextProfile { - NoProfile, - CoreProfile, - CompatibilityProfile - }; - - void setProfile(OpenGLContextProfile profile); - OpenGLContextProfile profile() const; - - enum OpenGLVersionFlag { - OpenGL_Version_None = 0x00000000, - OpenGL_Version_1_1 = 0x00000001, - OpenGL_Version_1_2 = 0x00000002, - OpenGL_Version_1_3 = 0x00000004, - OpenGL_Version_1_4 = 0x00000008, - OpenGL_Version_1_5 = 0x00000010, - OpenGL_Version_2_0 = 0x00000020, - OpenGL_Version_2_1 = 0x00000040, - OpenGL_ES_Common_Version_1_0 = 0x00000080, - OpenGL_ES_CommonLite_Version_1_0 = 0x00000100, - OpenGL_ES_Common_Version_1_1 = 0x00000200, - OpenGL_ES_CommonLite_Version_1_1 = 0x00000400, - OpenGL_ES_Version_2_0 = 0x00000800, - OpenGL_Version_3_0 = 0x00001000, - OpenGL_Version_3_1 = 0x00002000, - OpenGL_Version_3_2 = 0x00004000, - OpenGL_Version_3_3 = 0x00008000, - OpenGL_Version_4_0 = 0x00010000, - OpenGL_Version_4_1 = 0x00020000, - OpenGL_Version_4_2 = 0x00040000, - OpenGL_Version_4_3 = 0x00080000 - }; - Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) - - static OpenGLVersionFlags openGLVersionFlags(); - - static QGLFormat fromSurfaceFormat(const QSurfaceFormat &format); - static QSurfaceFormat toSurfaceFormat(const QGLFormat &format); -private: - QGLFormatPrivate *d; - - void detach(); - - friend Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&); - friend Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&); -#ifndef QT_NO_DEBUG_STREAM - friend Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &); -#endif -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFormat::OpenGLVersionFlags) - -Q_OPENGL_EXPORT bool operator==(const QGLFormat&, const QGLFormat&); -Q_OPENGL_EXPORT bool operator!=(const QGLFormat&, const QGLFormat&); - -#ifndef QT_NO_DEBUG_STREAM -Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QGLFormat &); -#endif - -class QGLFunctions; - -class Q_OPENGL_EXPORT QGLContext -{ - Q_DECLARE_PRIVATE(QGLContext) -public: - QGLContext(const QGLFormat& format, QPaintDevice* device); - QGLContext(const QGLFormat& format); - virtual ~QGLContext(); - - virtual bool create(const QGLContext* shareContext = nullptr); - bool isValid() const; - bool isSharing() const; - void reset(); - - static bool areSharing(const QGLContext *context1, const QGLContext *context2); - - QGLFormat format() const; - QGLFormat requestedFormat() const; - void setFormat(const QGLFormat& format); - - void moveToThread(QThread *thread); - - virtual void makeCurrent(); - virtual void doneCurrent(); - - virtual void swapBuffers() const; - - QGLFunctions *functions() const; - - enum BindOption { - NoBindOption = 0x0000, - InvertedYBindOption = 0x0001, - MipmapBindOption = 0x0002, - PremultipliedAlphaBindOption = 0x0004, - LinearFilteringBindOption = 0x0008, - - MemoryManagedBindOption = 0x0010, // internal flag - CanFlipNativePixmapBindOption = 0x0020, // internal flag - TemporarilyCachedBindOption = 0x0040, // internal flag - - DefaultBindOption = LinearFilteringBindOption - | InvertedYBindOption - | MipmapBindOption, - InternalBindOption = MemoryManagedBindOption - | PremultipliedAlphaBindOption - }; - Q_DECLARE_FLAGS(BindOptions, BindOption) - - GLuint bindTexture(const QImage &image, GLenum target, GLint format, - BindOptions options); - GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - BindOptions options); - - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, - GLint format = GL_RGBA); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, - GLint format = GL_RGBA); - GLuint bindTexture(const QString &fileName); - - void deleteTexture(GLuint tx_id); - - void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - - static void setTextureCacheLimit(int size); - static int textureCacheLimit(); - - QFunctionPointer getProcAddress(const QString &proc) const; - QPaintDevice* device() const; - QColor overlayTransparentColor() const; - - static const QGLContext* currentContext(); - - static QGLContext *fromOpenGLContext(QOpenGLContext *platformContext); - QOpenGLContext *contextHandle() const; - -protected: - virtual bool chooseContext(const QGLContext* shareContext = nullptr); - - bool deviceIsPixmap() const; - bool windowCreated() const; - void setWindowCreated(bool on); - bool initialized() const; - void setInitialized(bool on); - - uint colorIndex(const QColor& c) const; - void setValid(bool valid); - void setDevice(QPaintDevice *pDev); - -protected: - static QGLContext* currentCtx; - -private: - QGLContext(QOpenGLContext *windowContext); - - QScopedPointer<QGLContextPrivate> d_ptr; - - friend class QGLPixelBuffer; - friend class QGLPixelBufferPrivate; - friend class QGLWidget; - friend class QGLWidgetPrivate; - friend class QGLGlyphCache; - friend class QGL2PaintEngineEx; - friend class QGL2PaintEngineExPrivate; - friend class QGLEngineShaderManager; - friend class QGLTextureGlyphCache; - friend struct QGLGlyphTexture; - friend class QGLContextGroup; - friend class QGLPixmapBlurFilter; - friend class QGLTexture; - friend QGLFormat::OpenGLVersionFlags QGLFormat::openGLVersionFlags(); - friend class QGLFramebufferObject; - friend class QGLFramebufferObjectPrivate; - friend class QGLFBOGLPaintDevice; - friend class QGLPaintDevice; - friend class QGLWidgetGLPaintDevice; - friend class QX11GLSharedContexts; - friend class QGLContextResourceBase; - friend class QSGDistanceFieldGlyphCache; -private: - Q_DISABLE_COPY(QGLContext) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGLContext::BindOptions) - -class Q_OPENGL_EXPORT QGLWidget : public QWidget -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QGLWidget) -public: - explicit QGLWidget(QWidget* parent=nullptr, - const QGLWidget* shareWidget = nullptr, Qt::WindowFlags f=Qt::WindowFlags()); - explicit QGLWidget(QGLContext *context, QWidget* parent=nullptr, - const QGLWidget* shareWidget = nullptr, Qt::WindowFlags f=Qt::WindowFlags()); - explicit QGLWidget(const QGLFormat& format, QWidget* parent=nullptr, - const QGLWidget* shareWidget = nullptr, Qt::WindowFlags f=Qt::WindowFlags()); - ~QGLWidget(); - - void qglColor(const QColor& c) const; - void qglClearColor(const QColor& c) const; - - bool isValid() const; - bool isSharing() const; - - void makeCurrent(); - void doneCurrent(); - - bool doubleBuffer() const; - void swapBuffers(); - - QGLFormat format() const; - void setFormat(const QGLFormat& format); - - QGLContext* context() const; - void setContext(QGLContext* context, const QGLContext* shareContext = nullptr, - bool deleteOldContext = true); - - QPixmap renderPixmap(int w = 0, int h = 0, bool useContext = false); - QImage grabFrameBuffer(bool withAlpha = false); - - void makeOverlayCurrent(); - const QGLContext* overlayContext() const; - - static QImage convertToGLFormat(const QImage& img); - - const QGLColormap & colormap() const; - void setColormap(const QGLColormap & map); - - void renderText(int x, int y, const QString & str, - const QFont & fnt = QFont()); - void renderText(double x, double y, double z, const QString & str, - const QFont & fnt = QFont()); - QPaintEngine *paintEngine() const override; - - GLuint bindTexture(const QImage &image, GLenum target, GLint format, - QGLContext::BindOptions options); - GLuint bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - QGLContext::BindOptions options); - - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, - GLint format = GL_RGBA); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, - GLint format = GL_RGBA); - - GLuint bindTexture(const QString &fileName); - - void deleteTexture(GLuint tx_id); - - void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - -public Q_SLOTS: - virtual void updateGL(); - virtual void updateOverlayGL(); - -protected: - bool event(QEvent *) override; - virtual void initializeGL(); - virtual void resizeGL(int w, int h); - virtual void paintGL(); - - virtual void initializeOverlayGL(); - virtual void resizeOverlayGL(int w, int h); - virtual void paintOverlayGL(); - - void setAutoBufferSwap(bool on); - bool autoBufferSwap() const; - - void paintEvent(QPaintEvent*) override; - void resizeEvent(QResizeEvent*) override; - - virtual void glInit(); - virtual void glDraw(); - - QGLWidget(QGLWidgetPrivate &dd, - const QGLFormat &format = QGLFormat(), - QWidget *parent = nullptr, - const QGLWidget* shareWidget = nullptr, - Qt::WindowFlags f = Qt::WindowFlags()); -private: - Q_DISABLE_COPY(QGLWidget) - - friend class QGLDrawable; - friend class QGLPixelBuffer; - friend class QGLPixelBufferPrivate; - friend class QGLContext; - friend class QGLContextPrivate; - friend class QGLOverlayWidget; - friend class QGLPaintDevice; - friend class QGLWidgetGLPaintDevice; -}; - - -// -// QGLFormat inline functions -// - -inline bool QGLFormat::doubleBuffer() const -{ - return testOption(QGL::DoubleBuffer); -} - -inline bool QGLFormat::depth() const -{ - return testOption(QGL::DepthBuffer); -} - -inline bool QGLFormat::rgba() const -{ - return testOption(QGL::Rgba); -} - -inline bool QGLFormat::alpha() const -{ - return testOption(QGL::AlphaChannel); -} - -inline bool QGLFormat::accum() const -{ - return testOption(QGL::AccumBuffer); -} - -inline bool QGLFormat::stencil() const -{ - return testOption(QGL::StencilBuffer); -} - -inline bool QGLFormat::stereo() const -{ - return testOption(QGL::StereoBuffers); -} - -inline bool QGLFormat::directRendering() const -{ - return testOption(QGL::DirectRendering); -} - -inline bool QGLFormat::hasOverlay() const -{ - return testOption(QGL::HasOverlay); -} - -inline bool QGLFormat::sampleBuffers() const -{ - return testOption(QGL::SampleBuffers); -} - -QT_END_NAMESPACE - -#endif // QT_NO_OPENGL -#endif // QGL_H diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h deleted file mode 100644 index 4e52c0f5e9..0000000000 --- a/src/opengl/qgl_p.h +++ /dev/null @@ -1,556 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGL_P_H -#define QGL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the QGLWidget class. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - -#include "QtOpenGL/qgl.h" -#include "QtOpenGL/qglcolormap.h" -#include "QtCore/qmap.h" -#include "QtCore/qthread.h" -#include "QtCore/qthreadstorage.h" -#include "QtCore/qhashfunctions.h" -#include "QtCore/qatomic.h" -#include "QtWidgets/private/qwidget_p.h" -#include "QtGui/private/qopenglcontext_p.h" -#include "QtGui/private/qopenglextensions_p.h" -#include "qcache.h" -#include "qglpaintdevice_p.h" - -#include <QtGui/QOpenGLContext> - -QT_BEGIN_NAMESPACE - -class QGLContext; -class QGLOverlayWidget; -class QPixmap; -class QOpenGLExtensions; - -class QGLFormatPrivate -{ -public: - QGLFormatPrivate() - : ref(1) - { - opts = QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering - | QGL::StencilBuffer | QGL::DeprecatedFunctions; - pln = 0; - depthSize = accumSize = stencilSize = redSize = greenSize = blueSize = alphaSize = -1; - numSamples = -1; - swapInterval = -1; - majorVersion = 2; - minorVersion = 0; - profile = QGLFormat::NoProfile; - } - QGLFormatPrivate(const QGLFormatPrivate *other) - : ref(1), - opts(other->opts), - pln(other->pln), - depthSize(other->depthSize), - accumSize(other->accumSize), - stencilSize(other->stencilSize), - redSize(other->redSize), - greenSize(other->greenSize), - blueSize(other->blueSize), - alphaSize(other->alphaSize), - numSamples(other->numSamples), - swapInterval(other->swapInterval), - majorVersion(other->majorVersion), - minorVersion(other->minorVersion), - profile(other->profile) - { - } - QAtomicInt ref; - QGL::FormatOptions opts; - int pln; - int depthSize; - int accumSize; - int stencilSize; - int redSize; - int greenSize; - int blueSize; - int alphaSize; - int numSamples; - int swapInterval; - int majorVersion; - int minorVersion; - QGLFormat::OpenGLContextProfile profile; -}; - -class Q_OPENGL_EXPORT QGLWidgetPrivate : public QWidgetPrivate -{ - Q_DECLARE_PUBLIC(QGLWidget) -public: - QGLWidgetPrivate() : QWidgetPrivate() - , disable_clear_on_painter_begin(false) - , parent_changing(false) - { - } - - ~QGLWidgetPrivate() {} - - void init(QGLContext *context, const QGLWidget* shareWidget); - void initContext(QGLContext *context, const QGLWidget* shareWidget); - bool renderCxPm(QPixmap *pixmap); - void cleanupColormaps(); - void aboutToDestroy() override { - if (glcx && !parent_changing) - glcx->reset(); - } - - bool makeCurrent(); - - QGLContext *glcx; - QGLWidgetGLPaintDevice glDevice; - bool autoSwap; - - QGLColormap cmap; - - bool disable_clear_on_painter_begin; - bool parent_changing; -}; - -// QGLContextPrivate has the responsibility of creating context groups. -// QGLContextPrivate maintains the reference counter and destroys -// context groups when needed. -class QGLContextGroup -{ -public: - ~QGLContextGroup(); - - const QGLContext *context() const {return m_context;} - bool isSharing() const { return m_shares.size() >= 2; } - QList<const QGLContext *> shares() const { return m_shares; } - - static void addShare(const QGLContext *context, const QGLContext *share); - static void removeShare(const QGLContext *context); - -private: - QGLContextGroup(const QGLContext *context); - - const QGLContext *m_context; // context group's representative - QList<const QGLContext *> m_shares; - QAtomicInt m_refs; - - friend class QGLContext; - friend class QGLContextPrivate; - friend class QGLContextGroupResourceBase; -}; - -// Get the context that resources for "ctx" will transfer to once -// "ctx" is destroyed. Returns null if nothing is sharing with ctx. -const QGLContext *qt_gl_transfer_context(const QGLContext *); - -/* - QGLTemporaryContext - the main objective of this class is to have a way of - creating a GL context and making it current, without going via QGLWidget - and friends. At certain points during GL initialization we need a current - context in order decide what GL features are available, and to resolve GL - extensions. Having a light-weight way of creating such a context saves - initial application startup time, and it doesn't wind up creating recursive - conflicts. - The class currently uses a private d pointer to hide the platform specific - types. This could possibly been done inline with #ifdef'ery, but it causes - major headaches on e.g. X11 due to namespace pollution. -*/ -class QGLTemporaryContextPrivate; -class QGLTemporaryContext { -public: - explicit QGLTemporaryContext(bool directRendering = true, QWidget *parent = nullptr); - ~QGLTemporaryContext(); - -private: - QScopedPointer<QGLTemporaryContextPrivate> d; -}; - -class QGLTexture; -class QGLTextureDestroyer; - -// This probably needs to grow to GL_MAX_VERTEX_ATTRIBS, but 3 is ok for now as that's -// all the GL2 engine uses: -#define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3 - -class QGLContextResourceBase; - -class QGLContextPrivate -{ - Q_DECLARE_PUBLIC(QGLContext) -public: - explicit QGLContextPrivate(QGLContext *context); - ~QGLContextPrivate(); - QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, - QGLContext::BindOptions options); - QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key, - QGLContext::BindOptions options); - QGLTexture *bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - QGLContext::BindOptions options); - QGLTexture *textureCacheLookup(const qint64 key, GLenum target); - void init(QPaintDevice *dev, const QGLFormat &format); - int maxTextureSize(); - - void cleanup(); - - void setVertexAttribArrayEnabled(int arrayIndex, bool enabled = true); - void syncGlState(); // Makes sure the GL context's state is what we think it is - void swapRegion(const QRegion ®ion); - - QOpenGLContext *guiGlContext; - // true if QGLContext owns the QOpenGLContext (for who deletes who) - bool ownContext; - - void setupSharing(); - void refreshCurrentFbo(); - void setCurrentFbo(GLuint fbo); - - QGLFormat glFormat; - QGLFormat reqFormat; - GLuint fbo; - - uint valid : 1; - uint sharing : 1; - uint initDone : 1; - uint crWin : 1; - uint internal_context : 1; - uint version_flags_cached : 1; - - // workarounds for driver/hw bugs on different platforms - uint workaround_needsFullClearOnEveryFrame : 1; - uint workaround_brokenFBOReadBack : 1; - uint workaround_brokenTexSubImage : 1; - uint workaroundsCached : 1; - - uint workaround_brokenTextureFromPixmap : 1; - uint workaround_brokenTextureFromPixmap_init : 1; - - uint workaround_brokenAlphaTexSubImage : 1; - uint workaround_brokenAlphaTexSubImage_init : 1; - - QPaintDevice *paintDevice; - QSize readback_target_size; - QColor transpColor; - QGLContext *q_ptr; - QGLFormat::OpenGLVersionFlags version_flags; - - QGLContextGroup *group; - GLint max_texture_size; - - GLuint current_fbo; - GLuint default_fbo; - QPaintEngine *active_engine; - QGLTextureDestroyer *texture_destroyer; - - QGLFunctions *functions; - - bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT]; - - static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; } - - static void setCurrentContext(QGLContext *context); -}; - -// Temporarily make a context current if not already current or -// shared with the current contex. The previous context is made -// current when the object goes out of scope. -class Q_OPENGL_EXPORT QGLShareContextScope -{ -public: - QGLShareContextScope(const QGLContext *ctx) - : m_oldContext(nullptr) - { - QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); - if (currentContext != ctx && !QGLContext::areSharing(ctx, currentContext)) { - m_oldContext = currentContext; - m_ctx = const_cast<QGLContext *>(ctx); - m_ctx->makeCurrent(); - } else { - m_ctx = currentContext; - } - } - - operator QGLContext *() - { - return m_ctx; - } - - QGLContext *operator->() - { - return m_ctx; - } - - ~QGLShareContextScope() - { - if (m_oldContext) - m_oldContext->makeCurrent(); - } - -private: - QGLContext *m_oldContext; - QGLContext *m_ctx; -}; - -QT_END_NAMESPACE -Q_DECLARE_METATYPE(GLuint) -QT_BEGIN_NAMESPACE - -class Q_OPENGL_EXPORT QGLTextureDestroyer -{ -public: - void emitFreeTexture(QGLContext *context, QPlatformPixmap *, GLuint id) { - if (context->contextHandle()) - (new QOpenGLSharedResourceGuard(context->contextHandle(), id, freeTextureFunc))->free(); - } - -private: - static void freeTextureFunc(QOpenGLFunctions *, GLuint id) { - QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &id); - } -}; - -class Q_OPENGL_EXPORT QGLSignalProxy : public QObject -{ - Q_OBJECT -public: - void emitAboutToDestroyContext(const QGLContext *context) { - emit aboutToDestroyContext(context); - } - static QGLSignalProxy *instance(); -Q_SIGNALS: - void aboutToDestroyContext(const QGLContext *context); -}; - -class QGLTexture { -public: - explicit QGLTexture(QGLContext *ctx = nullptr, GLuint tx_id = 0, GLenum tx_target = GL_TEXTURE_2D, - QGLContext::BindOptions opt = QGLContext::DefaultBindOption) - : context(ctx), - id(tx_id), - target(tx_target), - options(opt) - {} - - ~QGLTexture() { - if (options & QGLContext::MemoryManagedBindOption) { - Q_ASSERT(context); - QPlatformPixmap *boundPixmap = nullptr; - context->d_ptr->texture_destroyer->emitFreeTexture(context, boundPixmap, id); - } - } - - QGLContext *context; - GLuint id; - GLenum target; - - QGLContext::BindOptions options; - - bool canBindCompressedTexture - (const char *buf, int len, const char *format, bool *hasAlpha); - QSize bindCompressedTexture - (const QString& fileName, const char *format = nullptr); - QSize bindCompressedTexture - (const char *buf, int len, const char *format = nullptr); - QSize bindCompressedTextureDDS(const char *buf, int len); - QSize bindCompressedTexturePVR(const char *buf, int len); -}; - -struct QGLTextureCacheKey { - qint64 key; - QGLContextGroup *group; -}; - -inline bool operator==(const QGLTextureCacheKey &a, const QGLTextureCacheKey &b) -{ - return a.key == b.key && a.group == b.group; -} - -inline uint qHash(const QGLTextureCacheKey &key) -{ - return qHash(key.key) ^ qHash(key.group); -} - - -class Q_AUTOTEST_EXPORT QGLTextureCache { -public: - QGLTextureCache(); - ~QGLTextureCache(); - - void insert(QGLContext *ctx, qint64 key, QGLTexture *texture, int cost); - void remove(qint64 key); - inline int size(); - inline void setMaxCost(int newMax); - inline int maxCost(); - inline QGLTexture* getTexture(QGLContext *ctx, qint64 key); - - bool remove(QGLContext *ctx, GLuint textureId); - void removeContextTextures(QGLContext *ctx); - static QGLTextureCache *instance(); - static void cleanupTexturesForCacheKey(qint64 cacheKey); - static void cleanupTexturesForPixampData(QPlatformPixmap* pixmap); - static void cleanupBeforePixmapDestruction(QPlatformPixmap* pixmap); - -private: - QCache<QGLTextureCacheKey, QGLTexture> m_cache; - QReadWriteLock m_lock; -}; - -int QGLTextureCache::size() { - QReadLocker locker(&m_lock); - return m_cache.size(); -} - -void QGLTextureCache::setMaxCost(int newMax) -{ - QWriteLocker locker(&m_lock); - m_cache.setMaxCost(newMax); -} - -int QGLTextureCache::maxCost() -{ - QReadLocker locker(&m_lock); - return m_cache.maxCost(); -} - -QGLTexture* QGLTextureCache::getTexture(QGLContext *ctx, qint64 key) -{ - // Can't be a QReadLocker since QCache::object() modifies the cache (reprioritizes the object) - QWriteLocker locker(&m_lock); - const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)}; - return m_cache.object(cacheKey); -} - -Q_OPENGL_EXPORT extern QPaintEngine* qt_qgl_paint_engine(); - -QOpenGLExtensions* qgl_extensions(); -bool qgl_hasFeature(QOpenGLFunctions::OpenGLFeature feature); -bool qgl_hasExtension(QOpenGLExtensions::OpenGLExtension extension); - -// Put a guard around a GL object identifier and its context. -// When the context goes away, a shared context will be used -// in its place. If there are no more shared contexts, then -// the identifier is returned as zero - it is assumed that the -// context destruction cleaned up the identifier in this case. -class QGLSharedResourceGuardBase : public QOpenGLSharedResource -{ -public: - QGLSharedResourceGuardBase(QGLContext *context, GLuint id) - : QOpenGLSharedResource(context->contextHandle()->shareGroup()) - , m_id(id) - { - } - - GLuint id() const - { - return m_id; - } - -protected: - void invalidateResource() override - { - m_id = 0; - } - - void freeResource(QOpenGLContext *context) override - { - if (m_id) { - freeResource(QGLContext::fromOpenGLContext(context), m_id); - } - } - - virtual void freeResource(QGLContext *ctx, GLuint id) = 0; - -private: - GLuint m_id; -}; - -template <typename Func> -class QGLSharedResourceGuard : public QGLSharedResourceGuardBase -{ -public: - QGLSharedResourceGuard(QGLContext *context, GLuint id, Func func) - : QGLSharedResourceGuardBase(context, id) - , m_func(func) - { - } - -protected: - void freeResource(QGLContext *ctx, GLuint id) override - { - m_func(ctx, id); - } - -private: - Func m_func; -}; - -template <typename Func> -QGLSharedResourceGuardBase *createSharedResourceGuard(QGLContext *context, GLuint id, Func cleanupFunc) -{ - return new QGLSharedResourceGuard<Func>(context, id, cleanupFunc); -} - -// this is a class that wraps a QThreadStorage object for storing -// thread local instances of the GL 1 and GL 2 paint engines - -template <class T> -class QGLEngineThreadStorage -{ -public: - QPaintEngine *engine() { - QPaintEngine *&localEngine = storage.localData(); - if (!localEngine) - localEngine = new T; - return localEngine; - } - -private: - QThreadStorage<QPaintEngine *> storage; -}; -QT_END_NAMESPACE - -#endif // QGL_P_H diff --git a/src/opengl/qglbuffer.cpp b/src/opengl/qglbuffer.cpp deleted file mode 100644 index bb9c2affbd..0000000000 --- a/src/opengl/qglbuffer.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtOpenGL/qgl.h> -#include <QtOpenGL/private/qgl_p.h> -#include <private/qopenglextensions_p.h> -#include <QtCore/qatomic.h> -#include "qglbuffer.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGLBuffer - \inmodule QtOpenGL - \brief The QGLBuffer class provides functions for creating and managing GL buffer objects. - \since 4.7 - \obsolete - \ingroup painting-3D - - Buffer objects are created in the GL server so that the - client application can avoid uploading vertices, indices, - texture image data, etc every time they are needed. - - QGLBuffer objects can be copied around as a reference to the - underlying GL buffer object: - - \snippet code/src_opengl_qglbuffer.cpp 0 - - QGLBuffer performs a shallow copy when objects are copied in this - manner, but does not implement copy-on-write semantics. The original - object will be affected whenever the copy is modified. - - \note This class has been deprecated in favor of QOpenGLBuffer. -*/ - -/*! - \enum QGLBuffer::Type - This enum defines the type of GL buffer object to create with QGLBuffer. - - \value VertexBuffer Vertex buffer object for use when specifying - vertex arrays. - \value IndexBuffer Index buffer object for use with \c{glDrawElements()}. - \value PixelPackBuffer Pixel pack buffer object for reading pixel - data from the GL server (for example, with \c{glReadPixels()}). - Not supported under OpenGL/ES. - \value PixelUnpackBuffer Pixel unpack buffer object for writing pixel - data to the GL server (for example, with \c{glTexImage2D()}). - Not supported under OpenGL/ES. -*/ - -/*! - \enum QGLBuffer::UsagePattern - This enum defines the usage pattern of a QGLBuffer object. - - \value StreamDraw The data will be set once and used a few times - for drawing operations. Under OpenGL/ES 1.1 this is identical - to StaticDraw. - \value StreamRead The data will be set once and used a few times - for reading data back from the GL server. Not supported - under OpenGL/ES. - \value StreamCopy The data will be set once and used a few times - for reading data back from the GL server for use in further - drawing operations. Not supported under OpenGL/ES. - \value StaticDraw The data will be set once and used many times - for drawing operations. - \value StaticRead The data will be set once and used many times - for reading data back from the GL server. Not supported - under OpenGL/ES. - \value StaticCopy The data will be set once and used many times - for reading data back from the GL server for use in further - drawing operations. Not supported under OpenGL/ES. - \value DynamicDraw The data will be modified repeatedly and used - many times for drawing operations. - \value DynamicRead The data will be modified repeatedly and used - many times for reading data back from the GL server. - Not supported under OpenGL/ES. - \value DynamicCopy The data will be modified repeatedly and used - many times for reading data back from the GL server for - use in further drawing operations. Not supported under OpenGL/ES. -*/ - -/*! - \enum QGLBuffer::Access - This enum defines the access mode for QGLBuffer::map(). - - \value ReadOnly The buffer will be mapped for reading only. - \value WriteOnly The buffer will be mapped for writing only. - \value ReadWrite The buffer will be mapped for reading and writing. -*/ - -class QGLBufferPrivate -{ -public: - QGLBufferPrivate(QGLBuffer::Type t) - : ref(1), - type(t), - guard(0), - usagePattern(QGLBuffer::StaticDraw), - actualUsagePattern(QGLBuffer::StaticDraw), - funcs(0) - { - } - - QAtomicInt ref; - QGLBuffer::Type type; - QGLSharedResourceGuardBase *guard; - QGLBuffer::UsagePattern usagePattern; - QGLBuffer::UsagePattern actualUsagePattern; - QOpenGLExtensions *funcs; -}; - -/*! - Constructs a new buffer object of type QGLBuffer::VertexBuffer. - - Note: this constructor just creates the QGLBuffer instance. The actual - buffer object in the GL server is not created until create() is called. - - \sa create() -*/ -QGLBuffer::QGLBuffer() - : d_ptr(new QGLBufferPrivate(QGLBuffer::VertexBuffer)) -{ -} - -/*! - Constructs a new buffer object of \a type. - - Note: this constructor just creates the QGLBuffer instance. The actual - buffer object in the GL server is not created until create() is called. - - \sa create() -*/ -QGLBuffer::QGLBuffer(QGLBuffer::Type type) - : d_ptr(new QGLBufferPrivate(type)) -{ -} - -/*! - Constructs a shallow copy of \a other. - - Note: QGLBuffer does not implement copy-on-write semantics, - so \a other will be affected whenever the copy is modified. -*/ -QGLBuffer::QGLBuffer(const QGLBuffer &other) - : d_ptr(other.d_ptr) -{ - d_ptr->ref.ref(); -} - -#define ctx QGLContext::currentContext(); - -/*! - Destroys this buffer object, including the storage being - used in the GL server. -*/ -QGLBuffer::~QGLBuffer() -{ - if (!d_ptr->ref.deref()) { - destroy(); - delete d_ptr; - } -} - -/*! - Assigns a shallow copy of \a other to this object. - - Note: QGLBuffer does not implement copy-on-write semantics, - so \a other will be affected whenever the copy is modified. -*/ -QGLBuffer &QGLBuffer::operator=(const QGLBuffer &other) -{ - if (d_ptr != other.d_ptr) { - other.d_ptr->ref.ref(); - if (!d_ptr->ref.deref()) { - destroy(); - delete d_ptr; - } - d_ptr = other.d_ptr; - } - return *this; -} - -/*! - Returns the type of buffer represented by this object. -*/ -QGLBuffer::Type QGLBuffer::type() const -{ - Q_D(const QGLBuffer); - return d->type; -} - -/*! - Returns the usage pattern for this buffer object. - The default value is StaticDraw. - - \sa setUsagePattern() -*/ -QGLBuffer::UsagePattern QGLBuffer::usagePattern() const -{ - Q_D(const QGLBuffer); - return d->usagePattern; -} - -/*! - Sets the usage pattern for this buffer object to \a value. - This function must be called before allocate() or write(). - - \sa usagePattern(), allocate(), write() -*/ -void QGLBuffer::setUsagePattern(QGLBuffer::UsagePattern value) -{ - Q_D(QGLBuffer); - d->usagePattern = d->actualUsagePattern = value; -} - -#undef ctx - -namespace { - void freeBufferFunc(QGLContext *ctx, GLuint id) - { - Q_ASSERT(ctx); - ctx->contextHandle()->functions()->glDeleteBuffers(1, &id); - } -} - -/*! - Creates the buffer object in the GL server. Returns \c true if - the object was created; false otherwise. - - This function must be called with a current QGLContext. - The buffer will be bound to and can only be used in - that context (or any other context that is shared with it). - - This function will return false if the GL implementation - does not support buffers, or there is no current QGLContext. - - \sa isCreated(), allocate(), write(), destroy() -*/ -bool QGLBuffer::create() -{ - Q_D(QGLBuffer); - if (d->guard && d->guard->id()) - return true; - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - if (ctx) { - delete d->funcs; - d->funcs = new QOpenGLExtensions(ctx->contextHandle()); - if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers)) - return false; - - GLuint bufferId = 0; - d->funcs->glGenBuffers(1, &bufferId); - if (bufferId) { - if (d->guard) - d->guard->free(); - - d->guard = createSharedResourceGuard(ctx, bufferId, freeBufferFunc); - return true; - } - } - return false; -} - -#define ctx QGLContext::currentContext() - -/*! - Returns \c true if this buffer has been created; false otherwise. - - \sa create(), destroy() -*/ -bool QGLBuffer::isCreated() const -{ - Q_D(const QGLBuffer); - return d->guard && d->guard->id(); -} - -/*! - Destroys this buffer object, including the storage being - used in the GL server. All references to the buffer will - become invalid. -*/ -void QGLBuffer::destroy() -{ - Q_D(QGLBuffer); - if (d->guard) { - d->guard->free(); - d->guard = 0; - } -} - -/*! - Reads the \a count bytes in this buffer starting at \a offset - into \a data. Returns \c true on success; false if reading from - the buffer is not supported. Buffer reading is not supported - under OpenGL/ES. - - It is assumed that this buffer has been bound to the current context. - - \sa write(), bind() -*/ -bool QGLBuffer::read(int offset, void *data, int count) -{ -#if !defined(QT_OPENGL_ES) - Q_D(QGLBuffer); - if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id() || !d->funcs->d()->GetBufferSubData) - return false; - while (d->funcs->glGetError() != GL_NO_ERROR) ; // Clear error state. - d->funcs->glGetBufferSubData(d->type, offset, count, data); - return d->funcs->glGetError() == GL_NO_ERROR; -#else - Q_UNUSED(offset); - Q_UNUSED(data); - Q_UNUSED(count); - return false; -#endif -} - -/*! - Replaces the \a count bytes of this buffer starting at \a offset - with the contents of \a data. Any other bytes in the buffer - will be left unmodified. - - It is assumed that create() has been called on this buffer and that - it has been bound to the current context. - - \sa create(), read(), allocate() -*/ -void QGLBuffer::write(int offset, const void *data, int count) -{ -#ifndef QT_NO_DEBUG - if (!isCreated()) - qWarning("QGLBuffer::allocate(): buffer not created"); -#endif - Q_D(QGLBuffer); - if (d->guard && d->guard->id()) - d->funcs->glBufferSubData(d->type, offset, count, data); -} - -/*! - Allocates \a count bytes of space to the buffer, initialized to - the contents of \a data. Any previous contents will be removed. - - It is assumed that create() has been called on this buffer and that - it has been bound to the current context. - - \sa create(), read(), write() -*/ -void QGLBuffer::allocate(const void *data, int count) -{ -#ifndef QT_NO_DEBUG - if (!isCreated()) - qWarning("QGLBuffer::allocate(): buffer not created"); -#endif - Q_D(QGLBuffer); - if (d->guard && d->guard->id()) - d->funcs->glBufferData(d->type, count, data, d->actualUsagePattern); -} - -/*! - \fn void QGLBuffer::allocate(int count) - \overload - - Allocates \a count bytes of space to the buffer. Any previous - contents will be removed. - - It is assumed that create() has been called on this buffer and that - it has been bound to the current context. - - \sa create(), write() -*/ - -/*! - Binds the buffer associated with this object to the current - GL context. Returns \c false if binding was not possible, usually because - type() is not supported on this GL implementation. - - The buffer must be bound to the same QGLContext current when create() - was called, or to another QGLContext that is sharing with it. - Otherwise, false will be returned from this function. - - \sa release(), create() -*/ -bool QGLBuffer::bind() -{ -#ifndef QT_NO_DEBUG - if (!isCreated()) - qWarning("QGLBuffer::bind(): buffer not created"); -#endif - Q_D(const QGLBuffer); - GLuint bufferId = d->guard ? d->guard->id() : 0; - if (bufferId) { - if (d->guard->group() != QOpenGLContextGroup::currentContextGroup()) { -#ifndef QT_NO_DEBUG - qWarning("QGLBuffer::bind: buffer is not valid in the current context"); -#endif - return false; - } - d->funcs->glBindBuffer(d->type, bufferId); - return true; - } else { - return false; - } -} - -/*! - Releases the buffer associated with this object from the - current GL context. - - This function must be called with the same QGLContext current - as when bind() was called on the buffer. - - \sa bind() -*/ -void QGLBuffer::release() -{ -#ifndef QT_NO_DEBUG - if (!isCreated()) - qWarning("QGLBuffer::release(): buffer not created"); -#endif - Q_D(const QGLBuffer); - if (d->guard && d->guard->id()) - d->funcs->glBindBuffer(d->type, 0); -} - -#undef ctx - -/*! - Releases the buffer associated with \a type in the current - QGLContext. - - This function is a direct call to \c{glBindBuffer(type, 0)} - for use when the caller does not know which QGLBuffer has - been bound to the context but wants to make sure that it - is released. - - \snippet code/src_opengl_qglbuffer.cpp 1 -*/ -void QGLBuffer::release(QGLBuffer::Type type) -{ - if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) - ctx->functions()->glBindBuffer(GLenum(type), 0); -} - -#define ctx QGLContext::currentContext() - -/*! - Returns the GL identifier associated with this buffer; zero if - the buffer has not been created. - - \sa isCreated() -*/ -GLuint QGLBuffer::bufferId() const -{ - Q_D(const QGLBuffer); - return d->guard ? d->guard->id() : 0; -} - -#ifndef GL_BUFFER_SIZE -#define GL_BUFFER_SIZE 0x8764 -#endif - -/*! - Returns the size of the data in this buffer, for reading operations. - Returns -1 if fetching the buffer size is not supported, or the - buffer has not been created. - - It is assumed that this buffer has been bound to the current context. - - \sa isCreated(), bind() -*/ -int QGLBuffer::size() const -{ - Q_D(const QGLBuffer); - if (!d->guard || !d->guard->id()) - return -1; - GLint value = -1; - d->funcs->glGetBufferParameteriv(d->type, GL_BUFFER_SIZE, &value); - return value; -} - -/*! - Maps the contents of this buffer into the application's memory - space and returns a pointer to it. Returns null if memory - mapping is not possible. The \a access parameter indicates the - type of access to be performed. - - It is assumed that create() has been called on this buffer and that - it has been bound to the current context. - - This function is only supported under OpenGL/ES if the - \c{GL_OES_mapbuffer} extension is present. - - \sa unmap(), create(), bind() -*/ -void *QGLBuffer::map(QGLBuffer::Access access) -{ - Q_D(QGLBuffer); -#ifndef QT_NO_DEBUG - if (!isCreated()) - qWarning("QGLBuffer::map(): buffer not created"); -#endif - if (!d->guard || !d->guard->id()) - return 0; - return d->funcs->glMapBuffer(d->type, access); -} - -/*! - Unmaps the buffer after it was mapped into the application's - memory space with a previous call to map(). Returns \c true if - the unmap succeeded; false otherwise. - - It is assumed that this buffer has been bound to the current context, - and that it was previously mapped with map(). - - This function is only supported under OpenGL/ES if the - \c{GL_OES_mapbuffer} extension is present. - - \sa map() -*/ -bool QGLBuffer::unmap() -{ - Q_D(QGLBuffer); -#ifndef QT_NO_DEBUG - if (!isCreated()) - qWarning("QGLBuffer::unmap(): buffer not created"); -#endif - if (!d->guard || !d->guard->id()) - return false; - return d->funcs->glUnmapBuffer(d->type) == GL_TRUE; -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglbuffer.h b/src/opengl/qglbuffer.h deleted file mode 100644 index daf5227c66..0000000000 --- a/src/opengl/qglbuffer.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLBUFFER_H -#define QGLBUFFER_H - -#include <QtCore/qscopedpointer.h> -#include <QtOpenGL/qgl.h> - -QT_BEGIN_NAMESPACE - - -class QGLBufferPrivate; - -class Q_OPENGL_EXPORT QGLBuffer -{ -public: - enum Type - { - VertexBuffer = 0x8892, // GL_ARRAY_BUFFER - IndexBuffer = 0x8893, // GL_ELEMENT_ARRAY_BUFFER - PixelPackBuffer = 0x88EB, // GL_PIXEL_PACK_BUFFER - PixelUnpackBuffer = 0x88EC // GL_PIXEL_UNPACK_BUFFER - }; - - QGLBuffer(); - explicit QGLBuffer(QGLBuffer::Type type); - QGLBuffer(const QGLBuffer &other); - ~QGLBuffer(); - - QGLBuffer &operator=(const QGLBuffer &other); - - enum UsagePattern - { - StreamDraw = 0x88E0, // GL_STREAM_DRAW - StreamRead = 0x88E1, // GL_STREAM_READ - StreamCopy = 0x88E2, // GL_STREAM_COPY - StaticDraw = 0x88E4, // GL_STATIC_DRAW - StaticRead = 0x88E5, // GL_STATIC_READ - StaticCopy = 0x88E6, // GL_STATIC_COPY - DynamicDraw = 0x88E8, // GL_DYNAMIC_DRAW - DynamicRead = 0x88E9, // GL_DYNAMIC_READ - DynamicCopy = 0x88EA // GL_DYNAMIC_COPY - }; - - enum Access - { - ReadOnly = 0x88B8, // GL_READ_ONLY - WriteOnly = 0x88B9, // GL_WRITE_ONLY - ReadWrite = 0x88BA // GL_READ_WRITE - }; - - QGLBuffer::Type type() const; - - QGLBuffer::UsagePattern usagePattern() const; - void setUsagePattern(QGLBuffer::UsagePattern value); - - bool create(); - bool isCreated() const; - - void destroy(); - - bool bind(); - void release(); - - static void release(QGLBuffer::Type type); - - GLuint bufferId() const; - - int size() const; - - bool read(int offset, void *data, int count); - void write(int offset, const void *data, int count); - - void allocate(const void *data, int count); - inline void allocate(int count) { allocate(nullptr, count); } - - void *map(QGLBuffer::Access access); - bool unmap(); - -private: - QGLBufferPrivate *d_ptr; - - Q_DECLARE_PRIVATE(QGLBuffer) -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/opengl/qglcolormap.cpp b/src/opengl/qglcolormap.cpp deleted file mode 100644 index f314a9715d..0000000000 --- a/src/opengl/qglcolormap.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QGLColormap - \brief The QGLColormap class is used for installing custom colormaps into - a QGLWidget. - - \obsolete - \inmodule QtOpenGL - \ingroup painting-3D - \ingroup shared - - QGLColormap provides a platform independent way of specifying and - installing indexed colormaps for a QGLWidget. QGLColormap is - especially useful when using the OpenGL color-index mode. - - Under X11 you must use an X server that supports either a \c - PseudoColor or \c DirectColor visual class. If your X server - currently only provides a \c GrayScale, \c TrueColor, \c - StaticColor or \c StaticGray visual, you will not be able to - allocate colorcells for writing. If this is the case, try setting - your X server to 8 bit mode. It should then provide you with at - least a \c PseudoColor visual. Note that you may experience - colormap flashing if your X server is running in 8 bit mode. - - The size() of the colormap is always set to 256 - colors. Note that under Windows you can also install colormaps - in child widgets. - - This class uses \l{implicit sharing} as a memory and speed - optimization. - - Example of use: - \snippet code/src_opengl_qglcolormap.cpp 0 - - \sa QGLWidget::setColormap(), QGLWidget::colormap() -*/ - -/*! - \fn Qt::HANDLE QGLColormap::handle() - - \internal - - Returns the handle for this color map. -*/ - -/*! - \fn void QGLColormap::setHandle(Qt::HANDLE handle) - - \internal - - Sets the handle for this color map to \a handle. -*/ - -#include "qglcolormap.h" - -QT_BEGIN_NAMESPACE - -QGLColormap::QGLColormapData QGLColormap::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0 }; - -/*! - Construct a QGLColormap. -*/ -QGLColormap::QGLColormap() - : d(&shared_null) -{ - d->ref.ref(); -} - - -/*! - Construct a shallow copy of \a map. -*/ -QGLColormap::QGLColormap(const QGLColormap &map) - : d(map.d) -{ - d->ref.ref(); -} - -/*! - Dereferences the QGLColormap and deletes it if this was the last - reference to it. -*/ -QGLColormap::~QGLColormap() -{ - if (!d->ref.deref()) - cleanup(d); -} - -void QGLColormap::cleanup(QGLColormap::QGLColormapData *x) -{ - delete x->cells; - x->cells = 0; - delete x; -} - -/*! - Assign a shallow copy of \a map to this QGLColormap. -*/ -QGLColormap & QGLColormap::operator=(const QGLColormap &map) -{ - map.d->ref.ref(); - if (!d->ref.deref()) - cleanup(d); - d = map.d; - return *this; -} - -/*! - \fn void QGLColormap::detach() - \internal - - Detaches this QGLColormap from the shared block. -*/ - -void QGLColormap::detach_helper() -{ - QGLColormapData *x = new QGLColormapData; - x->ref.storeRelaxed(1); - x->cmapHandle = 0; - x->cells = 0; - if (d->cells) { - x->cells = new QVector<QRgb>(256); - *x->cells = *d->cells; - } - if (!d->ref.deref()) - cleanup(d); - d = x; -} - -/*! - Set cell at index \a idx in the colormap to color \a color. -*/ -void QGLColormap::setEntry(int idx, QRgb color) -{ - detach(); - if (!d->cells) - d->cells = new QVector<QRgb>(256); - d->cells->replace(idx, color); -} - -/*! - Set an array of cells in this colormap. \a count is the number of - colors that should be set, \a colors is the array of colors, and - \a base is the starting index. The first element in \a colors - is set at \a base in the colormap. -*/ -void QGLColormap::setEntries(int count, const QRgb *colors, int base) -{ - detach(); - if (!d->cells) - d->cells = new QVector<QRgb>(256); - - Q_ASSERT_X(colors && base >= 0 && (base + count) <= d->cells->size(), "QGLColormap::setEntries", - "preconditions not met"); - for (int i = 0; i < count; ++i) - setEntry(base + i, colors[i]); -} - -/*! - Returns the QRgb value in the colorcell with index \a idx. -*/ -QRgb QGLColormap::entryRgb(int idx) const -{ - if (d == &shared_null || !d->cells) - return 0; - else - return d->cells->at(idx); -} - -/*! - \overload - - Set the cell with index \a idx in the colormap to color \a color. -*/ -void QGLColormap::setEntry(int idx, const QColor &color) -{ - setEntry(idx, color.rgb()); -} - -/*! - Returns the QRgb value in the colorcell with index \a idx. -*/ -QColor QGLColormap::entryColor(int idx) const -{ - if (d == &shared_null || !d->cells) - return QColor(); - else - return QColor(d->cells->at(idx)); -} - -/*! - Returns \c true if the colormap is empty or it is not in use - by a QGLWidget; otherwise returns \c false. - - A colormap with no color values set is considered to be empty. - For historical reasons, a colormap that has color values set - but which is not in use by a QGLWidget is also considered empty. - - Compare size() with zero to determine if the colormap is empty - regardless of whether it is in use by a QGLWidget or not. - - \sa size() -*/ -bool QGLColormap::isEmpty() const -{ - return d == &shared_null || d->cells == 0 || d->cells->size() == 0 || d->cmapHandle == 0; -} - - -/*! - Returns the number of colorcells in the colormap. -*/ -int QGLColormap::size() const -{ - return d->cells ? d->cells->size() : 0; -} - -/*! - Returns the index of the color \a color. If \a color is not in the - map, -1 is returned. -*/ -int QGLColormap::find(QRgb color) const -{ - if (d->cells) - return d->cells->indexOf(color); - return -1; -} - -/*! - Returns the index of the color that is the closest match to color - \a color. -*/ -int QGLColormap::findNearest(QRgb color) const -{ - int idx = find(color); - if (idx >= 0) - return idx; - int mapSize = size(); - int mindist = 200000; - int r = qRed(color); - int g = qGreen(color); - int b = qBlue(color); - int rx, gx, bx, dist; - for (int i = 0; i < mapSize; ++i) { - QRgb ci = d->cells->at(i); - rx = r - qRed(ci); - gx = g - qGreen(ci); - bx = b - qBlue(ci); - dist = rx * rx + gx * gx + bx * bx; // calculate distance - if (dist < mindist) { // minimal? - mindist = dist; - idx = i; - } - } - return idx; -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglcolormap.h b/src/opengl/qglcolormap.h deleted file mode 100644 index b59b56e040..0000000000 --- a/src/opengl/qglcolormap.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLCOLORMAP_H -#define QGLCOLORMAP_H - -#include <QtGui/qcolor.h> -#include <QtCore/qvector.h> -#include <QtOpenGL/qtopenglglobal.h> - -QT_BEGIN_NAMESPACE - - -class Q_OPENGL_EXPORT QGLColormap -{ -public: - QGLColormap(); - QGLColormap(const QGLColormap &); - ~QGLColormap(); - - QGLColormap &operator=(const QGLColormap &); - - bool isEmpty() const; - int size() const; - void detach(); - - void setEntries(int count, const QRgb * colors, int base = 0); - void setEntry(int idx, QRgb color); - void setEntry(int idx, const QColor & color); - QRgb entryRgb(int idx) const; - QColor entryColor(int idx) const; - int find(QRgb color) const; - int findNearest(QRgb color) const; - -protected: - Qt::HANDLE handle() { return d ? d->cmapHandle : nullptr; } - void setHandle(Qt::HANDLE ahandle) { d->cmapHandle = ahandle; } - -private: - struct QGLColormapData { - QBasicAtomicInt ref; - QVector<QRgb> *cells; - Qt::HANDLE cmapHandle; - }; - - QGLColormapData *d; - static struct QGLColormapData shared_null; - static void cleanup(QGLColormapData *x); - void detach_helper(); - - friend class QGLWidget; - friend class QGLWidgetPrivate; -}; - -inline void QGLColormap::detach() -{ - if (d->ref.loadRelaxed() != 1) - detach_helper(); -} - -QT_END_NAMESPACE - -#endif // QGLCOLORMAP_H diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp deleted file mode 100644 index d0f82a85fa..0000000000 --- a/src/opengl/qglframebufferobject.cpp +++ /dev/null @@ -1,1466 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglframebufferobject.h" -#include "qglframebufferobject_p.h" - -#include <qdebug.h> -#include <private/qgl_p.h> -#include <private/qfont_p.h> -#include "gl2paintengineex/qpaintengineex_opengl2_p.h" - -#include <qimage.h> -#include <qwindow.h> - -QT_BEGIN_NAMESPACE - -extern QImage qt_gl_read_frame_buffer(const QSize&, bool, bool); - -#define QGL_FUNC_CONTEXT const QGLContext *ctx = QGLContext::currentContext(); -#define QGL_FUNCP_CONTEXT const QGLContext *ctx = QGLContext::currentContext(); - -#ifndef QT_NO_DEBUG -#define QT_RESET_GLERROR() \ -{ \ - while (QOpenGLContext::currentContext()->functions()->glGetError() != GL_NO_ERROR) {} \ -} -#define QT_CHECK_GLERROR() \ -{ \ - GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); \ - if (err != GL_NO_ERROR) { \ - qDebug("[%s line %d] GL Error: %d", \ - __FILE__, __LINE__, (int)err); \ - } \ -} -#else -#define QT_RESET_GLERROR() {} -#define QT_CHECK_GLERROR() {} -#endif - -// ####TODO Properly #ifdef this class to use #define symbols actually defined -// by OpenGL/ES includes -#ifndef GL_MAX_SAMPLES -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_RENDERBUFFER_SAMPLES -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#endif - -#ifndef GL_DEPTH24_STENCIL8 -#define GL_DEPTH24_STENCIL8 0x88F0 -#endif - -#ifndef GL_DEPTH_COMPONENT24 -#define GL_DEPTH_COMPONENT24 0x81A6 -#endif - -#ifndef GL_DEPTH_COMPONENT24_OES -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif - -#ifndef GL_READ_FRAMEBUFFER -#define GL_READ_FRAMEBUFFER 0x8CA8 -#endif - -#ifndef GL_DRAW_FRAMEBUFFER -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#endif - -#ifndef GL_DEPTH_STENCIL_ATTACHMENT -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#endif - -#ifndef GL_DEPTH_STENCIL -#define GL_DEPTH_STENCIL 0x84F9 -#endif - -/*! - \class QGLFramebufferObjectFormat - \inmodule QtOpenGL - \brief The QGLFramebufferObjectFormat class specifies the format of an OpenGL - framebuffer object. - - \since 4.6 - \obsolete - - \ingroup painting-3D - - A framebuffer object has several characteristics: - \list - \li \l{setSamples()}{Number of samples per pixels.} - \li \l{setAttachment()}{Depth and/or stencil attachments.} - \li \l{setTextureTarget()}{Texture target.} - \li \l{setInternalTextureFormat()}{Internal texture format.} - \endlist - - Note that the desired attachments or number of samples per pixels might not - be supported by the hardware driver. Call QGLFramebufferObject::format() - after creating a QGLFramebufferObject to find the exact format that was - used to create the frame buffer object. - - \note This class has been deprecated in favor of QOpenGLFramebufferObjectFormat. - - \sa QGLFramebufferObject -*/ - -/*! - \internal -*/ -void QGLFramebufferObjectFormat::detach() -{ - if (d->ref.loadRelaxed() != 1) { - QGLFramebufferObjectFormatPrivate *newd - = new QGLFramebufferObjectFormatPrivate(d); - if (!d->ref.deref()) - delete d; - d = newd; - } -} - -/*! - Creates a QGLFramebufferObjectFormat object for specifying - the format of an OpenGL framebuffer object. - - By default the format specifies a non-multisample framebuffer object with no - attachments, texture target \c GL_TEXTURE_2D, and internal format \c GL_RGBA8. - On OpenGL/ES systems, the default internal format is \c GL_RGBA. - - \sa samples(), attachment(), internalTextureFormat() -*/ - -QGLFramebufferObjectFormat::QGLFramebufferObjectFormat() -{ - d = new QGLFramebufferObjectFormatPrivate; -} - -/*! - Constructs a copy of \a other. -*/ - -QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other) -{ - d = other.d; - d->ref.ref(); -} - -/*! - Assigns \a other to this object. -*/ - -QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFramebufferObjectFormat &other) -{ - if (d != other.d) { - other.d->ref.ref(); - if (!d->ref.deref()) - delete d; - d = other.d; - } - return *this; -} - -/*! - Destroys the QGLFramebufferObjectFormat. -*/ -QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() -{ - if (!d->ref.deref()) - delete d; -} - -/*! - Sets the number of samples per pixel for a multisample framebuffer object - to \a samples. The default sample count of 0 represents a regular - non-multisample framebuffer object. - - If the desired amount of samples per pixel is not supported by the hardware - then the maximum number of samples per pixel will be used. Note that - multisample framebuffer objects cannot be bound as textures. Also, the - \c{GL_EXT_framebuffer_multisample} extension is required to create a - framebuffer with more than one sample per pixel. - - \sa samples() -*/ -void QGLFramebufferObjectFormat::setSamples(int samples) -{ - detach(); - d->samples = samples; -} - -/*! - Returns the number of samples per pixel if a framebuffer object - is a multisample framebuffer object. Otherwise, returns 0. - The default value is 0. - - \sa setSamples() -*/ -int QGLFramebufferObjectFormat::samples() const -{ - return d->samples; -} - -/*! - \since 4.8 - - Enables mipmapping if \a enabled is true; otherwise disables it. - - Mipmapping is disabled by default. - - If mipmapping is enabled, additional memory will be allocated for - the mipmap levels. The mipmap levels can be updated by binding the - texture and calling glGenerateMipmap(). Mipmapping cannot be enabled - for multisampled framebuffer objects. - - \sa mipmap(), QGLFramebufferObject::texture() -*/ -void QGLFramebufferObjectFormat::setMipmap(bool enabled) -{ - detach(); - d->mipmap = enabled; -} - -/*! - \since 4.8 - - Returns \c true if mipmapping is enabled. - - \sa setMipmap() -*/ -bool QGLFramebufferObjectFormat::mipmap() const -{ - return d->mipmap; -} - -/*! - Sets the attachment configuration of a framebuffer object to \a attachment. - - \sa attachment() -*/ -void QGLFramebufferObjectFormat::setAttachment(QGLFramebufferObject::Attachment attachment) -{ - detach(); - d->attachment = attachment; -} - -/*! - Returns the configuration of the depth and stencil buffers attached to - a framebuffer object. The default is QGLFramebufferObject::NoAttachment. - - \sa setAttachment() -*/ -QGLFramebufferObject::Attachment QGLFramebufferObjectFormat::attachment() const -{ - return d->attachment; -} - -/*! - Sets the texture target of the texture attached to a framebuffer object to - \a target. Ignored for multisample framebuffer objects. - - \sa textureTarget(), samples() -*/ -void QGLFramebufferObjectFormat::setTextureTarget(GLenum target) -{ - detach(); - d->target = target; -} - -/*! - Returns the texture target of the texture attached to a framebuffer object. - Ignored for multisample framebuffer objects. The default is - \c GL_TEXTURE_2D. - - \sa setTextureTarget(), samples() -*/ -GLenum QGLFramebufferObjectFormat::textureTarget() const -{ - return d->target; -} - -/*! - Sets the internal format of a framebuffer object's texture or - multisample framebuffer object's color buffer to - \a internalTextureFormat. - - \sa internalTextureFormat() -*/ -void QGLFramebufferObjectFormat::setInternalTextureFormat(GLenum internalTextureFormat) -{ - detach(); - d->internal_format = internalTextureFormat; -} - -/*! - Returns the internal format of a framebuffer object's texture or - multisample framebuffer object's color buffer. The default is - \c GL_RGBA8 on desktop OpenGL systems, and \c GL_RGBA on - OpenGL/ES systems. - - \sa setInternalTextureFormat() -*/ -GLenum QGLFramebufferObjectFormat::internalTextureFormat() const -{ - return d->internal_format; -} - -/*! - Returns \c true if all the options of this framebuffer object format - are the same as \a other; otherwise returns \c false. -*/ -bool QGLFramebufferObjectFormat::operator==(const QGLFramebufferObjectFormat& other) const -{ - if (d == other.d) - return true; - else - return d->equals(other.d); -} - -/*! - Returns \c false if all the options of this framebuffer object format - are the same as \a other; otherwise returns \c true. -*/ -bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& other) const -{ - return !(*this == other); -} - -void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, - QGLFramebufferObject::Attachment attachment) -{ - fbo = f; - m_thisFBO = fbo->d_func()->fbo(); // This shouldn't be needed - - // The context that the fbo was created in may not have depth - // and stencil buffers, but the fbo itself might. - fboFormat = QGLContext::currentContext()->format(); - if (attachment == QGLFramebufferObject::CombinedDepthStencil) { - fboFormat.setDepth(true); - fboFormat.setStencil(true); - } else if (attachment == QGLFramebufferObject::Depth) { - fboFormat.setDepth(true); - fboFormat.setStencil(false); - } else { - fboFormat.setDepth(false); - fboFormat.setStencil(false); - } - - GLenum format = f->format().internalTextureFormat(); - reqAlpha = (format != GL_RGB -#ifdef GL_RGB5 - && format != GL_RGB5 -#endif -#ifdef GL_RGB8 - && format != GL_RGB8 -#endif - ); -} - -QGLContext *QGLFBOGLPaintDevice::context() const -{ - return const_cast<QGLContext *>(QGLContext::currentContext()); -} - -bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const -{ - QGL_FUNCP_CONTEXT; - if (!ctx) - return false; // Context no longer exists. - GLenum status = ctx->contextHandle()->functions()->glCheckFramebufferStatus(GL_FRAMEBUFFER); - switch(status) { - case GL_NO_ERROR: - case GL_FRAMEBUFFER_COMPLETE: - return true; - case GL_FRAMEBUFFER_UNSUPPORTED: - qDebug("QGLFramebufferObject: Unsupported framebuffer format."); - break; - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - qDebug("QGLFramebufferObject: Framebuffer incomplete attachment."); - break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - qDebug("QGLFramebufferObject: Framebuffer incomplete, missing attachment."); - break; -#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT - case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT: - qDebug("QGLFramebufferObject: Framebuffer incomplete, duplicate attachment."); - break; -#endif -#ifdef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: - qDebug("QGLFramebufferObject: Framebuffer incomplete, attached images must have same dimensions."); - break; -#endif -#ifdef GL_FRAMEBUFFER_INCOMPLETE_FORMATS - case GL_FRAMEBUFFER_INCOMPLETE_FORMATS: - qDebug("QGLFramebufferObject: Framebuffer incomplete, attached images must have same format."); - break; -#endif -#ifdef GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: - qDebug("QGLFramebufferObject: Framebuffer incomplete, missing draw buffer."); - break; -#endif -#ifdef GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: - qDebug("QGLFramebufferObject: Framebuffer incomplete, missing read buffer."); - break; -#endif -#ifdef GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE - case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: - qDebug("QGLFramebufferObject: Framebuffer incomplete, attachments must have same number of samples per pixel."); - break; -#endif - default: - qDebug() <<"QGLFramebufferObject: An undefined error has occurred: "<< status; - break; - } - return false; -} - -namespace -{ - void freeFramebufferFunc(QGLContext *ctx, GLuint id) - { - Q_ASSERT(ctx); - ctx->contextHandle()->functions()->glDeleteFramebuffers(1, &id); - } - - void freeRenderbufferFunc(QGLContext *ctx, GLuint id) - { - Q_ASSERT(ctx); - ctx->contextHandle()->functions()->glDeleteRenderbuffers(1, &id); - } - - void freeTextureFunc(QGLContext *ctx, GLuint id) - { - Q_UNUSED(ctx); - ctx->contextHandle()->functions()->glDeleteTextures(1, &id); - } -} - -void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, - QGLFramebufferObject::Attachment attachment, - GLenum texture_target, GLenum internal_format, - GLint samples, bool mipmap) -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - - funcs.initializeOpenGLFunctions(); - - if (!funcs.hasOpenGLFeature(QOpenGLFunctions::Framebuffers)) - return; - - ctx->d_ptr->refreshCurrentFbo(); - - size = sz; - target = texture_target; - // texture dimensions - - QT_RESET_GLERROR(); // reset error state - GLuint fbo = 0; - funcs.glGenFramebuffers(1, &fbo); - funcs.glBindFramebuffer(GL_FRAMEBUFFER, fbo); - - GLuint texture = 0; - GLuint color_buffer = 0; - GLuint depth_buffer = 0; - GLuint stencil_buffer = 0; - - QT_CHECK_GLERROR(); - // init texture - if (samples == 0) { - funcs.glGenTextures(1, &texture); - funcs.glBindTexture(target, texture); - funcs.glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - if (mipmap) { - int width = size.width(); - int height = size.height(); - int level = 0; - while (width > 1 || height > 1) { - width = qMax(1, width >> 1); - height = qMax(1, height >> 1); - ++level; - funcs.glTexImage2D(target, level, internal_format, width, height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - } - } - funcs.glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - funcs.glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs.glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - funcs.glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - funcs.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - target, texture, 0); - - QT_CHECK_GLERROR(); - valid = checkFramebufferStatus(); - funcs.glBindTexture(target, 0); - - color_buffer = 0; - } else { - mipmap = false; - GLint maxSamples; - funcs.glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); - - samples = qBound(0, int(samples), int(maxSamples)); - - funcs.glGenRenderbuffers(1, &color_buffer); - funcs.glBindRenderbuffer(GL_RENDERBUFFER, color_buffer); - if (funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample) && samples > 0) { - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - internal_format, size.width(), size.height()); - } else { - samples = 0; - funcs.glRenderbufferStorage(GL_RENDERBUFFER, internal_format, - size.width(), size.height()); - } - - funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, color_buffer); - - QT_CHECK_GLERROR(); - valid = checkFramebufferStatus(); - - if (valid) - funcs.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples); - } - - // In practice, a combined depth-stencil buffer is supported by all desktop platforms, while a - // separate stencil buffer is not. On embedded devices however, a combined depth-stencil buffer - // might not be supported while separate buffers are, according to QTBUG-12861. - - if (attachment == QGLFramebufferObject::CombinedDepthStencil - && funcs.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil)) { - // depth and stencil buffer needs another extension - funcs.glGenRenderbuffers(1, &depth_buffer); - funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); - Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); -#ifndef Q_OS_WASM - if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH24_STENCIL8, size.width(), size.height()); - else - funcs.glRenderbufferStorage(GL_RENDERBUFFER, - GL_DEPTH24_STENCIL8, size.width(), size.height()); - - stencil_buffer = depth_buffer; - funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, depth_buffer); - funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, - GL_RENDERBUFFER, stencil_buffer); -#else - // webgl does not allow separate depth and stencil attachments - if (samples != 0) { - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH_STENCIL, size.width(), size.height()); - } else { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, - size.width(), size.height()); - } - stencil_buffer = depth_buffer; - funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, - GL_RENDERBUFFER, depth_buffer); -#endif - - valid = checkFramebufferStatus(); - if (!valid) { - funcs.glDeleteRenderbuffers(1, &depth_buffer); - stencil_buffer = depth_buffer = 0; - } - } - - if (depth_buffer == 0 && (attachment == QGLFramebufferObject::CombinedDepthStencil - || (attachment == QGLFramebufferObject::Depth))) - { - funcs.glGenRenderbuffers(1, &depth_buffer); - funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); - Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); - if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) { -#ifdef QT_OPENGL_ES - if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)) { - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH_COMPONENT24_OES, size.width(), size.height()); - } else { - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH_COMPONENT16, size.width(), size.height()); - } -#else - if (ctx->contextHandle()->isOpenGLES()) { - if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)) - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH_COMPONENT24, size.width(), size.height()); - else - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH_COMPONENT16, size.width(), size.height()); - } else { - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, - GL_DEPTH_COMPONENT, size.width(), size.height()); - } -#endif - } else { -#ifdef QT_OPENGL_ES - if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)) { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24_OES, - size.width(), size.height()); - } else { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, - size.width(), size.height()); - } -#else - if (ctx->contextHandle()->isOpenGLES()) { - if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)) { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, - size.width(), size.height()); - } else { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, - size.width(), size.height()); - } - } else { - funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, size.width(), size.height()); - } -#endif - } - funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, depth_buffer); - valid = checkFramebufferStatus(); - if (!valid) { - funcs.glDeleteRenderbuffers(1, &depth_buffer); - depth_buffer = 0; - } - } - - if (stencil_buffer == 0 && (attachment == QGLFramebufferObject::CombinedDepthStencil)) { - funcs.glGenRenderbuffers(1, &stencil_buffer); - funcs.glBindRenderbuffer(GL_RENDERBUFFER, stencil_buffer); - Q_ASSERT(funcs.glIsRenderbuffer(stencil_buffer)); - -#ifdef QT_OPENGL_ES - GLenum storage = GL_STENCIL_INDEX8; -#else - GLenum storage = ctx->contextHandle()->isOpenGLES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX; -#endif - - if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) - funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, storage, size.width(), size.height()); - else - funcs.glRenderbufferStorage(GL_RENDERBUFFER, storage, size.width(), size.height()); - - funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, - GL_RENDERBUFFER, stencil_buffer); - valid = checkFramebufferStatus(); - if (!valid) { - funcs.glDeleteRenderbuffers(1, &stencil_buffer); - stencil_buffer = 0; - } - } - - // The FBO might have become valid after removing the depth or stencil buffer. - valid = checkFramebufferStatus(); - - if (depth_buffer && stencil_buffer) { - fbo_attachment = QGLFramebufferObject::CombinedDepthStencil; - } else if (depth_buffer) { - fbo_attachment = QGLFramebufferObject::Depth; - } else { - fbo_attachment = QGLFramebufferObject::NoAttachment; - } - - funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->current_fbo); - if (valid) { - fbo_guard = createSharedResourceGuard(ctx, fbo, freeFramebufferFunc); - if (color_buffer) - color_buffer_guard = createSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc); - else - texture_guard = createSharedResourceGuard(ctx, texture, freeTextureFunc); - if (depth_buffer) - depth_buffer_guard = createSharedResourceGuard(ctx, depth_buffer, freeRenderbufferFunc); - if (stencil_buffer) { - if (stencil_buffer == depth_buffer) - stencil_buffer_guard = depth_buffer_guard; - else - stencil_buffer_guard = createSharedResourceGuard(ctx, stencil_buffer, freeRenderbufferFunc); - } - } else { - if (color_buffer) - funcs.glDeleteRenderbuffers(1, &color_buffer); - else - funcs.glDeleteTextures(1, &texture); - if (depth_buffer) - funcs.glDeleteRenderbuffers(1, &depth_buffer); - if (stencil_buffer && depth_buffer != stencil_buffer) - funcs.glDeleteRenderbuffers(1, &stencil_buffer); - funcs.glDeleteFramebuffers(1, &fbo); - } - QT_CHECK_GLERROR(); - - format.setTextureTarget(target); - format.setSamples(int(samples)); - format.setAttachment(fbo_attachment); - format.setInternalTextureFormat(internal_format); - format.setMipmap(mipmap); - - glDevice.setFBO(q, attachment); -} - -/*! - \class QGLFramebufferObject - \inmodule QtOpenGL - \brief The QGLFramebufferObject class encapsulates an OpenGL framebuffer object. - \since 4.2 - - \obsolete - - \ingroup painting-3D - - The QGLFramebufferObject class encapsulates an OpenGL framebuffer - object, defined by the \c{GL_EXT_framebuffer_object} extension. In - addition it provides a rendering surface that can be painted on - with a QPainter, rendered to using native GL calls, or both. This - surface can be bound and used as a regular texture in your own GL - drawing code. By default, the QGLFramebufferObject class - generates a 2D GL texture (using the \c{GL_TEXTURE_2D} target), - which is used as the internal rendering target. - - \b{It is important to have a current GL context when creating a - QGLFramebufferObject, otherwise initialization will fail.} - - OpenGL framebuffer objects and pbuffers (see - \l{QGLPixelBuffer}{QGLPixelBuffer}) can both be used to render to - offscreen surfaces, but there are a number of advantages with - using framebuffer objects instead of pbuffers: - - \list 1 - \li A framebuffer object does not require a separate rendering - context, so no context switching will occur when switching - rendering targets. There is an overhead involved in switching - targets, but in general it is cheaper than a context switch to a - pbuffer. - - \li Rendering to dynamic textures (i.e. render-to-texture - functionality) works on all platforms. No need to do explicit copy - calls from a render buffer into a texture, as was necessary on - systems that did not support the \c{render_texture} extension. - - \li It is possible to attach several rendering buffers (or texture - objects) to the same framebuffer object, and render to all of them - without doing a context switch. - - \li The OpenGL framebuffer extension is a pure GL extension with no - system dependant WGL, CGL, or GLX parts. This makes using - framebuffer objects more portable. - \endlist - - When using a QPainter to paint to a QGLFramebufferObject you should take - care that the QGLFramebufferObject is created with the CombinedDepthStencil - attachment for QPainter to be able to render correctly. - Note that you need to create a QGLFramebufferObject with more than one - sample per pixel for primitives to be antialiased when drawing using a - QPainter. To create a multisample framebuffer object you should use one of - the constructors that take a QGLFramebufferObjectFormat parameter, and set - the QGLFramebufferObjectFormat::samples() property to a non-zero value. - - When painting to a QGLFramebufferObject using QPainter, the state of - the current GL context will be altered by the paint engine to reflect - its needs. Applications should not rely upon the GL state being reset - to its original conditions, particularly the current shader program, - GL viewport, texture units, and drawing modes. - - For multisample framebuffer objects a color render buffer is created, - otherwise a texture with the specified texture target is created. - The color render buffer or texture will have the specified internal - format, and will be bound to the \c GL_COLOR_ATTACHMENT0 - attachment in the framebuffer object. - - If you want to use a framebuffer object with multisampling enabled - as a texture, you first need to copy from it to a regular framebuffer - object using QGLContext::blitFramebuffer(). - - \section1 Threading - - As of Qt 4.8, it's possible to draw into a QGLFramebufferObject - using a QPainter in a separate thread. Note that OpenGL 2.0 or - OpenGL ES 2.0 is required for this to work. - - \note This class has been deprecated in favor of QOpenGLFramebufferObject. -*/ - - -/*! - \enum QGLFramebufferObject::Attachment - \since 4.3 - - This enum type is used to configure the depth and stencil buffers - attached to the framebuffer object when it is created. - - \value NoAttachment No attachment is added to the framebuffer object. Note that the - OpenGL depth and stencil tests won't work when rendering to a - framebuffer object without any depth or stencil buffers. - This is the default value. - - \value CombinedDepthStencil If the \c GL_EXT_packed_depth_stencil extension is present, - a combined depth and stencil buffer is attached. - If the extension is not present, only a depth buffer is attached. - - \value Depth A depth buffer is attached to the framebuffer object. - - \sa attachment() -*/ - - -/*! \fn QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) - - Constructs an OpenGL framebuffer object and binds a 2D GL texture - to the buffer of the size \a size. The texture is bound to the - \c GL_COLOR_ATTACHMENT0 target in the framebuffer object. - - The \a target parameter is used to specify the GL texture - target. The default target is \c GL_TEXTURE_2D. Keep in mind that - \c GL_TEXTURE_2D textures must have a power of 2 width and height - (e.g. 256x512), unless you are using OpenGL 2.0 or higher. - - By default, no depth and stencil buffers are attached. This behavior - can be toggled using one of the overloaded constructors. - - The default internal texture format is \c GL_RGBA8 for desktop - OpenGL, and \c GL_RGBA for OpenGL/ES. - - It is important that you have a current GL context set when - creating the QGLFramebufferObject, otherwise the initialization - will fail. - - \sa size(), texture(), attachment() -*/ - -QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) - : d_ptr(new QGLFramebufferObjectPrivate) -{ - Q_D(QGLFramebufferObject); - d->init(this, size, NoAttachment, target, -#ifndef QT_OPENGL_ES_2 - QOpenGLContext::currentContext()->isOpenGLES() ? GL_RGBA : GL_RGBA8 -#else - GL_RGBA -#endif - ); -} - -/*! \overload - - Constructs an OpenGL framebuffer object and binds a 2D GL texture - to the buffer of the given \a width and \a height. - - \sa size(), texture() -*/ -QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target) - : d_ptr(new QGLFramebufferObjectPrivate) -{ - Q_D(QGLFramebufferObject); - d->init(this, QSize(width, height), NoAttachment, target, -#ifndef QT_OPENGL_ES_2 - QOpenGLContext::currentContext()->isOpenGLES() ? GL_RGBA : GL_RGBA8 -#else - GL_RGBA -#endif - ); -} - -/*! \overload - - Constructs an OpenGL framebuffer object of the given \a size based on the - supplied \a format. -*/ - -QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebufferObjectFormat &format) - : d_ptr(new QGLFramebufferObjectPrivate) -{ - Q_D(QGLFramebufferObject); - d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), - format.samples(), format.mipmap()); -} - -/*! \overload - - Constructs an OpenGL framebuffer object of the given \a width and \a height - based on the supplied \a format. -*/ - -QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat &format) - : d_ptr(new QGLFramebufferObjectPrivate) -{ - Q_D(QGLFramebufferObject); - d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), - format.internalTextureFormat(), format.samples(), format.mipmap()); -} - -/*! \overload - - Constructs an OpenGL framebuffer object and binds a texture to the - buffer of the given \a width and \a height. - - The \a attachment parameter describes the depth/stencil buffer - configuration, \a target the texture target and \a internal_format - the internal texture format. The default texture target is \c - GL_TEXTURE_2D, while the default internal format is \c GL_RGBA8 - for desktop OpenGL and \c GL_RGBA for OpenGL/ES. - - \sa size(), texture(), attachment() -*/ -QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment attachment, - GLenum target, GLenum internal_format) - : d_ptr(new QGLFramebufferObjectPrivate) -{ - Q_D(QGLFramebufferObject); - if (!internal_format) -#ifdef QT_OPENGL_ES_2 - internal_format = GL_RGBA; -#else - internal_format = QOpenGLContext::currentContext()->isOpenGLES() ? GL_RGBA : GL_RGBA8; -#endif - d->init(this, QSize(width, height), attachment, target, internal_format); -} - -/*! \overload - - Constructs an OpenGL framebuffer object and binds a texture to the - buffer of the given \a size. - - The \a attachment parameter describes the depth/stencil buffer - configuration, \a target the texture target and \a internal_format - the internal texture format. The default texture target is \c - GL_TEXTURE_2D, while the default internal format is \c GL_RGBA8 - for desktop OpenGL and \c GL_RGBA for OpenGL/ES. - - \sa size(), texture(), attachment() -*/ -QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachment, - GLenum target, GLenum internal_format) - : d_ptr(new QGLFramebufferObjectPrivate) -{ - Q_D(QGLFramebufferObject); - if (!internal_format) -#ifdef QT_OPENGL_ES_2 - internal_format = GL_RGBA; -#else - internal_format = QOpenGLContext::currentContext()->isOpenGLES() ? GL_RGBA : GL_RGBA8; -#endif - d->init(this, size, attachment, target, internal_format); -} - -/*! - \fn QGLFramebufferObject::~QGLFramebufferObject() - - Destroys the framebuffer object and frees any allocated resources. -*/ -QGLFramebufferObject::~QGLFramebufferObject() -{ - Q_D(QGLFramebufferObject); - - delete d->engine; - - if (d->texture_guard) - d->texture_guard->free(); - if (d->color_buffer_guard) - d->color_buffer_guard->free(); - if (d->depth_buffer_guard) - d->depth_buffer_guard->free(); - if (d->stencil_buffer_guard && d->stencil_buffer_guard != d->depth_buffer_guard) - d->stencil_buffer_guard->free(); - if (d->fbo_guard) - d->fbo_guard->free(); -} - -/*! - \fn bool QGLFramebufferObject::isValid() const - - Returns \c true if the framebuffer object is valid. - - The framebuffer can become invalid if the initialization process - fails, the user attaches an invalid buffer to the framebuffer - object, or a non-power of two width/height is specified as the - texture size if the texture target is \c{GL_TEXTURE_2D}. - The non-power of two limitation does not apply if the OpenGL version - is 2.0 or higher, or if the GL_ARB_texture_non_power_of_two extension - is present. - - The framebuffer can also become invalid if the QGLContext that - the framebuffer was created within is destroyed and there are - no other shared contexts that can take over ownership of the - framebuffer. -*/ -bool QGLFramebufferObject::isValid() const -{ - Q_D(const QGLFramebufferObject); - return d->valid && d->fbo_guard && d->fbo_guard->id(); -} - -/*! - \fn bool QGLFramebufferObject::bind() - - Switches rendering from the default, windowing system provided - framebuffer to this framebuffer object. - Returns \c true upon success, false otherwise. - - \sa release() -*/ -bool QGLFramebufferObject::bind() -{ - if (!isValid()) - return false; - Q_D(QGLFramebufferObject); - QGL_FUNC_CONTEXT; - if (!ctx) - return false; // Context no longer exists. - const QGLContext *current = QGLContext::currentContext(); -#ifdef QT_DEBUG - if (!current || - QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)) - { - qWarning("QGLFramebufferObject::bind() called from incompatible context"); - } -#endif - d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, d->fbo()); - d->valid = d->checkFramebufferStatus(); - if (d->valid && current) - current->d_ptr->setCurrentFbo(d->fbo()); - return d->valid; -} - -/*! - \fn bool QGLFramebufferObject::release() - - Switches rendering back to the default, windowing system provided - framebuffer. - Returns \c true upon success, false otherwise. - - \sa bind() -*/ -bool QGLFramebufferObject::release() -{ - if (!isValid()) - return false; - Q_D(QGLFramebufferObject); - QGL_FUNC_CONTEXT; - if (!ctx) - return false; // Context no longer exists. - - const QGLContext *current = QGLContext::currentContext(); - -#ifdef QT_DEBUG - if (!current || - QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)) - { - qWarning("QGLFramebufferObject::release() called from incompatible context"); - } -#endif - - if (current) { - current->d_ptr->setCurrentFbo(current->d_ptr->default_fbo); - d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, current->d_ptr->default_fbo); - } - - return true; -} - -/*! - \fn GLuint QGLFramebufferObject::texture() const - - Returns the texture id for the texture attached as the default - rendering target in this framebuffer object. This texture id can - be bound as a normal texture in your own GL code. - - If a multisample framebuffer object is used then the value returned - from this function will be invalid. -*/ -GLuint QGLFramebufferObject::texture() const -{ - Q_D(const QGLFramebufferObject); - return d->texture_guard ? d->texture_guard->id() : 0; -} - -/*! - \fn QSize QGLFramebufferObject::size() const - - Returns the size of the texture attached to this framebuffer - object. -*/ -QSize QGLFramebufferObject::size() const -{ - Q_D(const QGLFramebufferObject); - return d->size; -} - -/*! - Returns the format of this framebuffer object. -*/ -QGLFramebufferObjectFormat QGLFramebufferObject::format() const -{ - Q_D(const QGLFramebufferObject); - return d->format; -} - -/*! - \fn QImage QGLFramebufferObject::toImage() const - - Returns the contents of this framebuffer object as a QImage. - - The returned image has a format of premultiplied ARGB32 or RGB32. The latter is used - only when internalTextureFormat() is set to \c GL_RGB. - - If the rendering in the framebuffer was not done with premultiplied alpha in mind, - create a wrapper QImage with a non-premultiplied format. This is necessary before - performing operations like QImage::save() because otherwise the image data would get - unpremultiplied, even though it was not premultiplied in the first place. To create - such a wrapper without performing a copy of the pixel data, do the following: - - \code - QImage fboImage(fbo.toImage()); - QImage image(fboImage.constBits(), fboImage.width(), fboImage.height(), QImage::Format_ARGB32); - \endcode - - On QNX the back buffer is not preserved when a buffer swap occures. So this function - might return old content. -*/ -QImage QGLFramebufferObject::toImage() const -{ - Q_D(const QGLFramebufferObject); - if (!d->valid) - return QImage(); - - // qt_gl_read_frame_buffer doesn't work on a multisample FBO - if (format().samples() != 0) { - QGLFramebufferObject temp(size(), QGLFramebufferObjectFormat()); - - QRect rect(QPoint(0, 0), size()); - blitFramebuffer(&temp, rect, const_cast<QGLFramebufferObject *>(this), rect); - - return temp.toImage(); - } - - bool wasBound = isBound(); - if (!wasBound) - const_cast<QGLFramebufferObject *>(this)->bind(); - QImage image = qt_gl_read_frame_buffer(d->size, format().internalTextureFormat() != GL_RGB, true); - if (!wasBound) - const_cast<QGLFramebufferObject *>(this)->release(); - - return image; -} - -Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_buffer_2_engine) - -/*! \reimp */ -QPaintEngine *QGLFramebufferObject::paintEngine() const -{ - Q_D(const QGLFramebufferObject); - if (d->engine) - return d->engine; - - QPaintEngine *engine = qt_buffer_2_engine()->engine(); - if (engine->isActive() && engine->paintDevice() != this) { - d->engine = new QGL2PaintEngineEx; - return d->engine; - } - return engine; -} - -/*! - \fn bool QGLFramebufferObject::bindDefault() - - Switches rendering back to the default, windowing system provided - framebuffer. - Returns \c true upon success, false otherwise. - - \sa bind(), release() -*/ -bool QGLFramebufferObject::bindDefault() -{ - QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); - - if (ctx) { - QOpenGLFunctions functions(ctx->contextHandle()); - if (!functions.hasOpenGLFeature(QOpenGLFunctions::Framebuffers)) - return false; - - ctx->d_ptr->setCurrentFbo(ctx->d_ptr->default_fbo); - functions.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->default_fbo); -#ifdef QT_DEBUG - } else { - qWarning("QGLFramebufferObject::bindDefault() called without current context."); -#endif - } - - return ctx != 0; -} - -/*! - \fn bool QGLFramebufferObject::hasOpenGLFramebufferObjects() - - Returns \c true if the OpenGL \c{GL_EXT_framebuffer_object} extension - is present on this system; otherwise returns \c false. -*/ -bool QGLFramebufferObject::hasOpenGLFramebufferObjects() -{ - return qgl_hasFeature(QOpenGLFunctions::Framebuffers); -} - -/*! - \since 4.4 - - Draws the given texture, \a textureId, to the given target rectangle, - \a target, in OpenGL model space. The \a textureTarget should be a 2D - texture target. - - The framebuffer object should be bound when calling this function. - - Equivalent to the corresponding QGLContext::drawTexture(). -*/ -void QGLFramebufferObject::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) -{ - const_cast<QGLContext *>(QGLContext::currentContext())->drawTexture(target, textureId, textureTarget); -} - -/*! - \since 4.4 - - Draws the given texture, \a textureId, at the given \a point in OpenGL - model space. The \a textureTarget should be a 2D texture target. - - The framebuffer object should be bound when calling this function. - - Equivalent to the corresponding QGLContext::drawTexture(). -*/ -void QGLFramebufferObject::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) -{ - const_cast<QGLContext *>(QGLContext::currentContext())->drawTexture(point, textureId, textureTarget); -} - -/*! \reimp */ -int QGLFramebufferObject::metric(PaintDeviceMetric metric) const -{ - Q_D(const QGLFramebufferObject); - - float dpmx = qt_defaultDpiX()*100./2.54; - float dpmy = qt_defaultDpiY()*100./2.54; - int w = d->size.width(); - int h = d->size.height(); - switch (metric) { - case PdmWidth: - return w; - - case PdmHeight: - return h; - - case PdmWidthMM: - return qRound(w * 1000 / dpmx); - - case PdmHeightMM: - return qRound(h * 1000 / dpmy); - - case PdmNumColors: - return 0; - - case PdmDepth: - return 32;//d->depth; - - case PdmDpiX: - return qRound(dpmx * 0.0254); - - case PdmDpiY: - return qRound(dpmy * 0.0254); - - case PdmPhysicalDpiX: - return qRound(dpmx * 0.0254); - - case PdmPhysicalDpiY: - return qRound(dpmy * 0.0254); - - case QPaintDevice::PdmDevicePixelRatio: - return 1; - - case QPaintDevice::PdmDevicePixelRatioScaled: - return 1 * QPaintDevice::devicePixelRatioFScale(); - - default: - qWarning("QGLFramebufferObject::metric(), Unhandled metric type: %d.\n", metric); - break; - } - return 0; -} - -/*! - \fn GLuint QGLFramebufferObject::handle() const - - Returns the GL framebuffer object handle for this framebuffer - object (returned by the \c{glGenFrameBuffersEXT()} function). This - handle can be used to attach new images or buffers to the - framebuffer. The user is responsible for cleaning up and - destroying these objects. -*/ -GLuint QGLFramebufferObject::handle() const -{ - Q_D(const QGLFramebufferObject); - return d->fbo(); -} - -/*! \fn int QGLFramebufferObject::devType() const - \internal -*/ - - -/*! - Returns the status of the depth and stencil buffers attached to - this framebuffer object. -*/ - -QGLFramebufferObject::Attachment QGLFramebufferObject::attachment() const -{ - Q_D(const QGLFramebufferObject); - if (d->valid) - return d->fbo_attachment; - return NoAttachment; -} - -/*! - \since 4.5 - - Returns \c true if the framebuffer object is currently bound to a context, - otherwise false is returned. -*/ - -bool QGLFramebufferObject::isBound() const -{ - Q_D(const QGLFramebufferObject); - const QGLContext *current = QGLContext::currentContext(); - if (current) { - current->d_ptr->refreshCurrentFbo(); - return current->d_ptr->current_fbo == d->fbo(); - } - - return false; -} - -/*! - \fn bool QGLFramebufferObject::hasOpenGLFramebufferBlit() - - \since 4.6 - - Returns \c true if the OpenGL \c{GL_EXT_framebuffer_blit} extension - is present on this system; otherwise returns \c false. - - \sa blitFramebuffer() -*/ -bool QGLFramebufferObject::hasOpenGLFramebufferBlit() -{ - return QOpenGLExtensions(QOpenGLContext::currentContext()).hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit); -} - -/*! - \since 4.6 - - Blits from the \a sourceRect rectangle in the \a source framebuffer - object to the \a targetRect rectangle in the \a target framebuffer object. - - If \a source or \a target is 0, the default framebuffer will be used - instead of a framebuffer object as source or target respectively. - - The \a buffers parameter should be a mask consisting of any combination of - \c GL_COLOR_BUFFER_BIT, \c GL_DEPTH_BUFFER_BIT, and - \c GL_STENCIL_BUFFER_BIT. Any buffer type that is not present both - in the source and target buffers is ignored. - - The \a sourceRect and \a targetRect rectangles may have different sizes; - in this case \a buffers should not contain \c GL_DEPTH_BUFFER_BIT or - \c GL_STENCIL_BUFFER_BIT. The \a filter parameter should be set to - \c GL_LINEAR or \c GL_NEAREST, and specifies whether linear or nearest - interpolation should be used when scaling is performed. - - If \a source equals \a target a copy is performed within the same buffer. - Results are undefined if the source and target rectangles overlap and - have different sizes. The sizes must also be the same if any of the - framebuffer objects are multisample framebuffers. - - Note that the scissor test will restrict the blit area if enabled. - - This function will have no effect unless hasOpenGLFramebufferBlit() returns - true. - - \sa hasOpenGLFramebufferBlit() -*/ -void QGLFramebufferObject::blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect, - QGLFramebufferObject *source, const QRect &sourceRect, - GLbitfield buffers, - GLenum filter) -{ - const QGLContext *ctx = QGLContext::currentContext(); - if (!ctx || !ctx->contextHandle()) - return; - - QOpenGLExtensions functions(ctx->contextHandle()); - if (!functions.hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)) - return; - - QSurface *surface = ctx->contextHandle()->surface(); - - const int height = static_cast<QWindow *>(surface)->height(); - - const int sh = source ? source->height() : height; - const int th = target ? target->height() : height; - - const int sx0 = sourceRect.left(); - const int sx1 = sourceRect.left() + sourceRect.width(); - const int sy0 = sh - (sourceRect.top() + sourceRect.height()); - const int sy1 = sh - sourceRect.top(); - - const int tx0 = targetRect.left(); - const int tx1 = targetRect.left() + targetRect.width(); - const int ty0 = th - (targetRect.top() + targetRect.height()); - const int ty1 = th - targetRect.top(); - - ctx->d_ptr->refreshCurrentFbo(); - - functions.glBindFramebuffer(GL_READ_FRAMEBUFFER, source ? source->handle() : 0); - functions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, target ? target->handle() : 0); - - functions.glBlitFramebuffer(sx0, sy0, sx1, sy1, - tx0, ty0, tx1, ty1, - buffers, filter); - - functions.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->current_fbo); -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h deleted file mode 100644 index c88063cbb5..0000000000 --- a/src/opengl/qglframebufferobject.h +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLFRAMEBUFFEROBJECT_H -#define QGLFRAMEBUFFEROBJECT_H - -#include <QtOpenGL/qgl.h> -#include <QtGui/qpaintdevice.h> - -QT_BEGIN_NAMESPACE - - -class QGLFramebufferObjectPrivate; -class QGLFramebufferObjectFormat; - -class Q_OPENGL_EXPORT QGLFramebufferObject : public QPaintDevice -{ - Q_DECLARE_PRIVATE(QGLFramebufferObject) -public: - enum Attachment { - NoAttachment, - CombinedDepthStencil, - Depth - }; - - QGLFramebufferObject(const QSize &size, GLenum target = GL_TEXTURE_2D); - QGLFramebufferObject(int width, int height, GLenum target = GL_TEXTURE_2D); - - QGLFramebufferObject(const QSize &size, Attachment attachment, - GLenum target = GL_TEXTURE_2D, GLenum internal_format = 0); - QGLFramebufferObject(int width, int height, Attachment attachment, - GLenum target = GL_TEXTURE_2D, GLenum internal_format = 0); - - QGLFramebufferObject(const QSize &size, const QGLFramebufferObjectFormat &format); - QGLFramebufferObject(int width, int height, const QGLFramebufferObjectFormat &format); - - virtual ~QGLFramebufferObject(); - - QGLFramebufferObjectFormat format() const; - - bool isValid() const; - bool isBound() const; - bool bind(); - bool release(); - - GLuint texture() const; - QSize size() const; - QImage toImage() const; - Attachment attachment() const; - - QPaintEngine *paintEngine() const override; - GLuint handle() const; - - static bool bindDefault(); - - static bool hasOpenGLFramebufferObjects(); - - void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - - static bool hasOpenGLFramebufferBlit(); - static void blitFramebuffer(QGLFramebufferObject *target, const QRect &targetRect, - QGLFramebufferObject *source, const QRect &sourceRect, - GLbitfield buffers = GL_COLOR_BUFFER_BIT, - GLenum filter = GL_NEAREST); - -protected: - int metric(PaintDeviceMetric metric) const override; - int devType() const override { return QInternal::FramebufferObject; } - -private: - Q_DISABLE_COPY(QGLFramebufferObject) - QScopedPointer<QGLFramebufferObjectPrivate> d_ptr; - friend class QGLPaintDevice; - friend class QGLFBOGLPaintDevice; -}; - -class QGLFramebufferObjectFormatPrivate; -class Q_OPENGL_EXPORT QGLFramebufferObjectFormat -{ -public: - QGLFramebufferObjectFormat(); - QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other); - QGLFramebufferObjectFormat &operator=(const QGLFramebufferObjectFormat &other); - ~QGLFramebufferObjectFormat(); - - void setSamples(int samples); - int samples() const; - - void setMipmap(bool enabled); - bool mipmap() const; - - void setAttachment(QGLFramebufferObject::Attachment attachment); - QGLFramebufferObject::Attachment attachment() const; - - void setTextureTarget(GLenum target); - GLenum textureTarget() const; - - void setInternalTextureFormat(GLenum internalTextureFormat); - GLenum internalTextureFormat() const; - - bool operator==(const QGLFramebufferObjectFormat& other) const; - bool operator!=(const QGLFramebufferObjectFormat& other) const; - -private: - QGLFramebufferObjectFormatPrivate *d; - - void detach(); -}; - -QT_END_NAMESPACE - -#endif // QGLFRAMEBUFFEROBJECT_H diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h deleted file mode 100644 index 9d536527c3..0000000000 --- a/src/opengl/qglframebufferobject_p.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLFRAMEBUFFEROBJECT_P_H -#define QGLFRAMEBUFFEROBJECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <qglframebufferobject.h> -#include <private/qglpaintdevice_p.h> -#include <private/qgl_p.h> -#include <private/qopenglextensions_p.h> - -QT_BEGIN_NAMESPACE - -class QGLFramebufferObjectFormatPrivate -{ -public: - QGLFramebufferObjectFormatPrivate() - : ref(1), - samples(0), - attachment(QGLFramebufferObject::NoAttachment), - target(GL_TEXTURE_2D), - mipmap(false) - { -#ifndef QT_OPENGL_ES_2 - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - const bool isES = ctx ? ctx->isOpenGLES() : QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL; - internal_format = isES ? GL_RGBA : GL_RGBA8; -#else - internal_format = GL_RGBA; -#endif - } - QGLFramebufferObjectFormatPrivate - (const QGLFramebufferObjectFormatPrivate *other) - : ref(1), - samples(other->samples), - attachment(other->attachment), - target(other->target), - internal_format(other->internal_format), - mipmap(other->mipmap) - { - } - bool equals(const QGLFramebufferObjectFormatPrivate *other) - { - return samples == other->samples && - attachment == other->attachment && - target == other->target && - internal_format == other->internal_format && - mipmap == other->mipmap; - } - - QAtomicInt ref; - int samples; - QGLFramebufferObject::Attachment attachment; - GLenum target; - GLenum internal_format; - uint mipmap : 1; -}; - -class QGLFBOGLPaintDevice : public QGLPaintDevice -{ -public: - virtual QPaintEngine* paintEngine() const override {return fbo->paintEngine();} - virtual QSize size() const override {return fbo->size();} - virtual QGLContext* context() const override; - virtual QGLFormat format() const override {return fboFormat;} - virtual bool alphaRequested() const override { return reqAlpha; } - - void setFBO(QGLFramebufferObject* f, - QGLFramebufferObject::Attachment attachment); - -private: - QGLFramebufferObject* fbo; - QGLFormat fboFormat; - bool reqAlpha; -}; - -class QGLFramebufferObjectPrivate -{ -public: - QGLFramebufferObjectPrivate() : fbo_guard(nullptr), texture_guard(nullptr), depth_buffer_guard(nullptr) - , stencil_buffer_guard(nullptr), color_buffer_guard(nullptr) - , valid(false), engine(nullptr) {} - ~QGLFramebufferObjectPrivate() {} - - void init(QGLFramebufferObject *q, const QSize& sz, - QGLFramebufferObject::Attachment attachment, - GLenum internal_format, GLenum texture_target, - GLint samples = 0, bool mipmap = false); - bool checkFramebufferStatus() const; - QGLSharedResourceGuardBase *fbo_guard; - QGLSharedResourceGuardBase *texture_guard; - QGLSharedResourceGuardBase *depth_buffer_guard; - QGLSharedResourceGuardBase *stencil_buffer_guard; - QGLSharedResourceGuardBase *color_buffer_guard; - GLenum target; - QSize size; - QGLFramebufferObjectFormat format; - uint valid : 1; - QGLFramebufferObject::Attachment fbo_attachment; - mutable QPaintEngine *engine; - QGLFBOGLPaintDevice glDevice; - QOpenGLExtensions funcs; - - inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; } -}; - - -QT_END_NAMESPACE - -#endif // QGLFRAMEBUFFEROBJECT_P_H diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp deleted file mode 100644 index b20311bec4..0000000000 --- a/src/opengl/qglfunctions.cpp +++ /dev/null @@ -1,1330 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglfunctions.h" -#include "qgl_p.h" -#include "QtGui/private/qopenglcontext_p.h" -#include <private/qopengl_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QGLFunctions - \inmodule QtOpenGL - \brief The QGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API. - \since 4.8 - \obsolete - \ingroup painting-3D - - OpenGL ES 2.0 defines a subset of the OpenGL specification that is - common across many desktop and embedded OpenGL implementations. - However, it can be difficult to use the functions from that subset - because they need to be resolved manually on desktop systems. - - QGLFunctions provides a guaranteed API that is available on all - OpenGL systems and takes care of function resolution on systems - that need it. The recommended way to use QGLFunctions is by - direct inheritance: - - \snippet code/src_opengl_qglfunctions.cpp 0 - - The \c{paintGL()} function can then use any of the OpenGL ES 2.0 - functions without explicit resolution, such as glActiveTexture() - in the following example: - - \snippet code/src_opengl_qglfunctions.cpp 1 - - QGLFunctions can also be used directly for ad-hoc invocation - of OpenGL ES 2.0 functions on all platforms: - - \snippet code/src_opengl_qglfunctions.cpp 2 - - QGLFunctions provides wrappers for all OpenGL ES 2.0 functions, - except those like \c{glDrawArrays()}, \c{glViewport()}, and - \c{glBindTexture()} that don't have portability issues. - - Including the header for QGLFunctions will also define all of - the OpenGL ES 2.0 macro constants that are not already defined by - the system's OpenGL headers, such as \c{GL_TEXTURE1} above. - - The hasOpenGLFeature() and openGLFeatures() functions can be used - to determine if the OpenGL implementation has a major OpenGL ES 2.0 - feature. For example, the following checks if non power of two - textures are available: - - \snippet code/src_opengl_qglfunctions.cpp 3 - - \note This class has been deprecated in favor of QOpenGLFunctions. -*/ - -/*! - \enum QGLFunctions::OpenGLFeature - This enum defines OpenGL ES 2.0 features that may be optional - on other platforms. - - \value Multitexture glActiveTexture() function is available. - \value Shaders Shader functions are available. - \value Buffers Vertex and index buffer functions are available. - \value Framebuffers Framebuffer object functions are available. - \value BlendColor glBlendColor() is available. - \value BlendEquation glBlendEquation() is available. - \value BlendEquationSeparate glBlendEquationSeparate() is available. - \value BlendFuncSeparate glBlendFuncSeparate() is available. - \value BlendSubtract Blend subtract mode is available. - \value CompressedTextures Compressed texture functions are available. - \value Multisample glSampleCoverage() function is available. - \value StencilSeparate Separate stencil functions are available. - \value NPOTTextures Non power of two textures are available. -*/ - -// Hidden private fields for additional extension data. -struct QGLFunctionsPrivateEx : public QGLFunctionsPrivate, public QOpenGLSharedResource -{ - QGLFunctionsPrivateEx(QOpenGLContext *context) - : QGLFunctionsPrivate(QGLContext::fromOpenGLContext(context)) - , QOpenGLSharedResource(context->shareGroup()) - , m_features(-1) - { - funcs = new QOpenGLFunctions(context); - funcs->initializeOpenGLFunctions(); - } - - ~QGLFunctionsPrivateEx() - { - delete funcs; - } - - void invalidateResource() override - { - m_features = -1; - } - - void freeResource(QOpenGLContext *) override - { - // no gl resources to free - } - - int m_features; -}; - -Q_GLOBAL_STATIC(QOpenGLMultiGroupSharedResource, qt_gl_functions_resource) - -static QGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0) -{ - if (!context) - context = QGLContext::currentContext(); - Q_ASSERT(context); - QGLFunctionsPrivateEx *funcs = - reinterpret_cast<QGLFunctionsPrivateEx *> - (qt_gl_functions_resource()->value<QGLFunctionsPrivateEx>(context->contextHandle())); - return funcs; -} - -/*! - Constructs a default function resolver. The resolver cannot - be used until initializeGLFunctions() is called to specify - the context. - - \sa initializeGLFunctions() -*/ -QGLFunctions::QGLFunctions() - : d_ptr(0) -{ -} - -/*! - Constructs a function resolver for \a context. If \a context - is \nullptr, then the resolver will be created for the current - QGLContext. - - An object constructed in this way can only be used with \a context - and other contexts that share with it. Use initializeGLFunctions() - to change the object's context association. - - \sa initializeGLFunctions() -*/ -QGLFunctions::QGLFunctions(const QGLContext *context) - : d_ptr(qt_gl_functions(context)) -{ -} - -/*! - \fn QGLFunctions::~QGLFunctions() - - Destroys this function resolver. -*/ - -static int qt_gl_resolve_features() -{ - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (ctx->isOpenGLES()) { - // OpenGL ES 2 - int features = QGLFunctions::Multitexture | - QGLFunctions::Shaders | - QGLFunctions::Buffers | - QGLFunctions::Framebuffers | - QGLFunctions::BlendColor | - QGLFunctions::BlendEquation | - QGLFunctions::BlendEquationSeparate | - QGLFunctions::BlendFuncSeparate | - QGLFunctions::BlendSubtract | - QGLFunctions::CompressedTextures | - QGLFunctions::Multisample | - QGLFunctions::StencilSeparate; - QOpenGLExtensionMatcher extensions; - if (extensions.match("GL_OES_texture_npot")) - features |= QGLFunctions::NPOTTextures; - if (extensions.match("GL_IMG_texture_npot")) - features |= QGLFunctions::NPOTTextures; - return features; - } else { - // OpenGL - int features = 0; - QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags(); - QOpenGLExtensionMatcher extensions; - - // Recognize features by extension name. - if (extensions.match("GL_ARB_multitexture")) - features |= QGLFunctions::Multitexture; - if (extensions.match("GL_ARB_shader_objects")) - features |= QGLFunctions::Shaders; - if (extensions.match("GL_EXT_framebuffer_object") || - extensions.match("GL_ARB_framebuffer_object")) - features |= QGLFunctions::Framebuffers; - if (extensions.match("GL_EXT_blend_color")) - features |= QGLFunctions::BlendColor; - if (extensions.match("GL_EXT_blend_equation_separate")) - features |= QGLFunctions::BlendEquationSeparate; - if (extensions.match("GL_EXT_blend_func_separate")) - features |= QGLFunctions::BlendFuncSeparate; - if (extensions.match("GL_EXT_blend_subtract")) - features |= QGLFunctions::BlendSubtract; - if (extensions.match("GL_ARB_texture_compression")) - features |= QGLFunctions::CompressedTextures; - if (extensions.match("GL_ARB_multisample")) - features |= QGLFunctions::Multisample; - if (extensions.match("GL_ARB_texture_non_power_of_two")) - features |= QGLFunctions::NPOTTextures; - - // Recognize features by minimum OpenGL version. - if (versions & QGLFormat::OpenGL_Version_1_2) { - features |= QGLFunctions::BlendColor | - QGLFunctions::BlendEquation; - } - if (versions & QGLFormat::OpenGL_Version_1_3) { - features |= QGLFunctions::Multitexture | - QGLFunctions::CompressedTextures | - QGLFunctions::Multisample; - } - if (versions & QGLFormat::OpenGL_Version_1_4) - features |= QGLFunctions::BlendFuncSeparate; - if (versions & QGLFormat::OpenGL_Version_1_5) - features |= QGLFunctions::Buffers; - if (versions & QGLFormat::OpenGL_Version_2_0) { - features |= QGLFunctions::Shaders | - QGLFunctions::StencilSeparate | - QGLFunctions::BlendEquationSeparate | - QGLFunctions::NPOTTextures; - } - return features; - } -} - -/*! - Returns the set of features that are present on this system's - OpenGL implementation. - - It is assumed that the QGLContext associated with this function - resolver is current. - - \sa hasOpenGLFeature() -*/ -QGLFunctions::OpenGLFeatures QGLFunctions::openGLFeatures() const -{ - QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr); - if (!d) - return { }; - if (d->m_features == -1) - d->m_features = qt_gl_resolve_features(); - return QGLFunctions::OpenGLFeatures(d->m_features); -} - -/*! - Returns \c true if \a feature is present on this system's OpenGL - implementation; false otherwise. - - It is assumed that the QGLContext associated with this function - resolver is current. - - \sa openGLFeatures() -*/ -bool QGLFunctions::hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const -{ - QGLFunctionsPrivateEx *d = static_cast<QGLFunctionsPrivateEx *>(d_ptr); - if (!d) - return false; - if (d->m_features == -1) - d->m_features = qt_gl_resolve_features(); - return (d->m_features & int(feature)) != 0; -} - -/*! - Initializes GL function resolution for \a context. If \a context - is \nullptr, then the current QGLContext will be used. - - After calling this function, the QGLFunctions object can only be - used with \a context and other contexts that share with it. - Call initializeGLFunctions() again to change the object's context - association. -*/ -void QGLFunctions::initializeGLFunctions(const QGLContext *context) -{ - d_ptr = qt_gl_functions(context); -} - -/*! - \fn void QGLFunctions::glActiveTexture(GLenum texture) - - Convenience function that calls glActiveTexture(\a texture). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glActiveTexture.xml}{glActiveTexture()}. -*/ - -/*! - \fn void QGLFunctions::glAttachShader(GLuint program, GLuint shader) - - Convenience function that calls glAttachShader(\a program, \a shader). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glAttachShader.xml}{glAttachShader()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name) - - Convenience function that calls glBindAttribLocation(\a program, \a index, \a name). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBindAttribLocation.xml}{glBindAttribLocation()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer) - - Convenience function that calls glBindBuffer(\a target, \a buffer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBindBuffer.xml}{glBindBuffer()}. -*/ - -/*! - \fn void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer) - - Convenience function that calls glBindFramebuffer(\a target, \a framebuffer). - - Note that Qt will translate a \a framebuffer argument of 0 to the currently - bound QOpenGLContext's defaultFramebufferObject(). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBindFramebuffer.xml}{glBindFramebuffer()}. -*/ - -/*! - \fn void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer) - - Convenience function that calls glBindRenderbuffer(\a target, \a renderbuffer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBindRenderbuffer.xml}{glBindRenderbuffer()}. -*/ - -/*! - \fn void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) - - Convenience function that calls glBlendColor(\a red, \a green, \a blue, \a alpha). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendColor.xml}{glBlendColor()}. -*/ - -/*! - \fn void QGLFunctions::glBlendEquation(GLenum mode) - - Convenience function that calls glBlendEquation(\a mode). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquation.xml}{glBlendEquation()}. -*/ - -/*! - \fn void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) - - Convenience function that calls glBlendEquationSeparate(\a modeRGB, \a modeAlpha). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquationSeparate.xml}{glBlendEquationSeparate()}. -*/ - -/*! - \fn void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) - - Convenience function that calls glBlendFuncSeparate(\a srcRGB, \a dstRGB, \a srcAlpha, \a dstAlpha). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendFuncSeparate.xml}{glBlendFuncSeparate()}. -*/ - -/*! - \fn void QGLFunctions::glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage) - - Convenience function that calls glBufferData(\a target, \a size, \a data, \a usage). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferData.xml}{glBufferData()}. -*/ - -/*! - \fn void QGLFunctions::glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data) - - Convenience function that calls glBufferSubData(\a target, \a offset, \a size, \a data). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferSubData.xml}{glBufferSubData()}. -*/ - -/*! - \fn GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target) - - Convenience function that calls glCheckFramebufferStatus(\a target). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glCheckFramebufferStatus.xml}{glCheckFramebufferStatus()}. -*/ - -/*! - \fn void QGLFunctions::glClearDepthf(GLclampf depth) - - Convenience function that calls glClearDepth(\a depth) on - desktop OpenGL systems and glClearDepthf(\a depth) on - embedded OpenGL ES systems. - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glClearDepthf.xml}{glClearDepthf()}. -*/ - -/*! - \fn void QGLFunctions::glCompileShader(GLuint shader) - - Convenience function that calls glCompileShader(\a shader). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glCompileShader.xml}{glCompileShader()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) - - Convenience function that calls glCompressedTexImage2D(\a target, \a level, \a internalformat, \a width, \a height, \a border, \a imageSize, \a data). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexImage2D.xml}{glCompressedTexImage2D()}. -*/ - -/*! - \fn void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) - - Convenience function that calls glCompressedTexSubImage2D(\a target, \a level, \a xoffset, \a yoffset, \a width, \a height, \a format, \a imageSize, \a data). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexSubImage2D.xml}{glCompressedTexSubImage2D()}. -*/ - -/*! - \fn GLuint QGLFunctions::glCreateProgram() - - Convenience function that calls glCreateProgram(). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateProgram.xml}{glCreateProgram()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn GLuint QGLFunctions::glCreateShader(GLenum type) - - Convenience function that calls glCreateShader(\a type). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateShader.xml}{glCreateShader()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers) - - Convenience function that calls glDeleteBuffers(\a n, \a buffers). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteBuffers.xml}{glDeleteBuffers()}. -*/ - -/*! - \fn void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) - - Convenience function that calls glDeleteFramebuffers(\a n, \a framebuffers). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteFramebuffers.xml}{glDeleteFramebuffers()}. -*/ - -/*! - \fn void QGLFunctions::glDeleteProgram(GLuint program) - - Convenience function that calls glDeleteProgram(\a program). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteProgram.xml}{glDeleteProgram()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) - - Convenience function that calls glDeleteRenderbuffers(\a n, \a renderbuffers). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteRenderbuffers.xml}{glDeleteRenderbuffers()}. -*/ - -/*! - \fn void QGLFunctions::glDeleteShader(GLuint shader) - - Convenience function that calls glDeleteShader(\a shader). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteShader.xml}{glDeleteShader()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar) - - Convenience function that calls glDepthRange(\a zNear, \a zFar) on - desktop OpenGL systems and glDepthRangef(\a zNear, \a zFar) on - embedded OpenGL ES systems. - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDepthRangef.xml}{glDepthRangef()}. -*/ - -/*! - \fn void QGLFunctions::glDetachShader(GLuint program, GLuint shader) - - Convenience function that calls glDetachShader(\a program, \a shader). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDetachShader.xml}{glDetachShader()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glDisableVertexAttribArray(GLuint index) - - Convenience function that calls glDisableVertexAttribArray(\a index). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glDisableVertexAttribArray.xml}{glDisableVertexAttribArray()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glEnableVertexAttribArray(GLuint index) - - Convenience function that calls glEnableVertexAttribArray(\a index). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glEnableVertexAttribArray.xml}{glEnableVertexAttribArray()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) - - Convenience function that calls glFramebufferRenderbuffer(\a target, \a attachment, \a renderbuffertarget, \a renderbuffer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferRenderbuffer.xml}{glFramebufferRenderbuffer()}. -*/ - -/*! - \fn void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) - - Convenience function that calls glFramebufferTexture2D(\a target, \a attachment, \a textarget, \a texture, \a level). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferTexture2D.xml}{glFramebufferTexture2D()}. -*/ - -/*! - \fn void QGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers) - - Convenience function that calls glGenBuffers(\a n, \a buffers). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGenBuffers.xml}{glGenBuffers()}. -*/ - -/*! - \fn void QGLFunctions::glGenerateMipmap(GLenum target) - - Convenience function that calls glGenerateMipmap(\a target). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGenerateMipmap.xml}{glGenerateMipmap()}. -*/ - -/*! - \fn void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers) - - Convenience function that calls glGenFramebuffers(\a n, \a framebuffers). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGenFramebuffers.xml}{glGenFramebuffers()}. -*/ - -/*! - \fn void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) - - Convenience function that calls glGenRenderbuffers(\a n, \a renderbuffers). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGenRenderbuffers.xml}{glGenRenderbuffers()}. -*/ - -/*! - \fn void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) - - Convenience function that calls glGetActiveAttrib(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveAttrib.xml}{glGetActiveAttrib()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) - - Convenience function that calls glGetActiveUniform(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveUniform.xml}{glGetActiveUniform()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) - - Convenience function that calls glGetAttachedShaders(\a program, \a maxcount, \a count, \a shaders). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttachedShaders.xml}{glGetAttachedShaders()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn int QGLFunctions::glGetAttribLocation(GLuint program, const char* name) - - Convenience function that calls glGetAttribLocation(\a program, \a name). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttribLocation.xml}{glGetAttribLocation()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) - - Convenience function that calls glGetBufferParameteriv(\a target, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetBufferParameteriv.xml}{glGetBufferParameteriv()}. -*/ - -/*! - \fn void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) - - Convenience function that calls glGetFramebufferAttachmentParameteriv(\a target, \a attachment, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetFramebufferAttachmentParameteriv.xml}{glGetFramebufferAttachmentParameteriv()}. -*/ - -/*! - \fn void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params) - - Convenience function that calls glGetProgramiv(\a program, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramiv.xml}{glGetProgramiv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) - - Convenience function that calls glGetProgramInfoLog(\a program, \a bufsize, \a length, \a infolog). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramInfoLog.xml}{glGetProgramInfoLog()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) - - Convenience function that calls glGetRenderbufferParameteriv(\a target, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetRenderbufferParameteriv.xml}{glGetRenderbufferParameteriv()}. -*/ - -/*! - \fn void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params) - - Convenience function that calls glGetShaderiv(\a shader, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderiv.xml}{glGetShaderiv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) - - Convenience function that calls glGetShaderInfoLog(\a shader, \a bufsize, \a length, \a infolog). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderInfoLog.xml}{glGetShaderInfoLog()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) - - Convenience function that calls glGetShaderPrecisionFormat(\a shadertype, \a precisiontype, \a range, \a precision). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderPrecisionFormat.xml}{glGetShaderPrecisionFormat()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) - - Convenience function that calls glGetShaderSource(\a shader, \a bufsize, \a length, \a source). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderSource.xml}{glGetShaderSource()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params) - - Convenience function that calls glGetUniformfv(\a program, \a location, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformfv.xml}{glGetUniformfv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params) - - Convenience function that calls glGetUniformiv(\a program, \a location, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformiv.xml}{glGetUniformiv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn int QGLFunctions::glGetUniformLocation(GLuint program, const char* name) - - Convenience function that calls glGetUniformLocation(\a program, \a name). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformLocation.xml}{glGetUniformLocation()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) - - Convenience function that calls glGetVertexAttribfv(\a index, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribfv.xml}{glGetVertexAttribfv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) - - Convenience function that calls glGetVertexAttribiv(\a index, \a pname, \a params). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribiv.xml}{glGetVertexAttribiv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) - - Convenience function that calls glGetVertexAttribPointerv(\a index, \a pname, \a pointer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribPointerv.xml}{glGetVertexAttribPointerv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn GLboolean QGLFunctions::glIsBuffer(GLuint buffer) - - Convenience function that calls glIsBuffer(\a buffer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glIsBuffer.xml}{glIsBuffer()}. -*/ - -/*! - \fn GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer) - - Convenience function that calls glIsFramebuffer(\a framebuffer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glIsFramebuffer.xml}{glIsFramebuffer()}. -*/ - -/*! - \fn GLboolean QGLFunctions::glIsProgram(GLuint program) - - Convenience function that calls glIsProgram(\a program). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glIsProgram.xml}{glIsProgram()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer) - - Convenience function that calls glIsRenderbuffer(\a renderbuffer). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glIsRenderbuffer.xml}{glIsRenderbuffer()}. -*/ - -/*! - \fn GLboolean QGLFunctions::glIsShader(GLuint shader) - - Convenience function that calls glIsShader(\a shader). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glIsShader.xml}{glIsShader()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glLinkProgram(GLuint program) - - Convenience function that calls glLinkProgram(\a program). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glLinkProgram.xml}{glLinkProgram()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glReleaseShaderCompiler() - - Convenience function that calls glReleaseShaderCompiler(). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glReleaseShaderCompiler.xml}{glReleaseShaderCompiler()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) - - Convenience function that calls glRenderbufferStorage(\a target, \a internalformat, \a width, \a height). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glRenderbufferStorage.xml}{glRenderbufferStorage()}. -*/ - -/*! - \fn void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert) - - Convenience function that calls glSampleCoverage(\a value, \a invert). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glSampleCoverage.xml}{glSampleCoverage()}. -*/ - -/*! - \fn void QGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length) - - Convenience function that calls glShaderBinary(\a n, \a shaders, \a binaryformat, \a binary, \a length). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderBinary.xml}{glShaderBinary()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) - - Convenience function that calls glShaderSource(\a shader, \a count, \a string, \a length). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderSource.xml}{glShaderSource()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) - - Convenience function that calls glStencilFuncSeparate(\a face, \a func, \a ref, \a mask). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilFuncSeparate.xml}{glStencilFuncSeparate()}. -*/ - -/*! - \fn void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask) - - Convenience function that calls glStencilMaskSeparate(\a face, \a mask). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilMaskSeparate.xml}{glStencilMaskSeparate()}. -*/ - -/*! - \fn void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) - - Convenience function that calls glStencilOpSeparate(\a face, \a fail, \a zfail, \a zpass). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilOpSeparate.xml}{glStencilOpSeparate()}. -*/ - -/*! - \fn void QGLFunctions::glUniform1f(GLint location, GLfloat x) - - Convenience function that calls glUniform1f(\a location, \a x). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1f.xml}{glUniform1f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v) - - Convenience function that calls glUniform1fv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1fv.xml}{glUniform1fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform1i(GLint location, GLint x) - - Convenience function that calls glUniform1i(\a location, \a x). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1i.xml}{glUniform1i()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v) - - Convenience function that calls glUniform1iv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1iv.xml}{glUniform1iv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y) - - Convenience function that calls glUniform2f(\a location, \a x, \a y). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2f.xml}{glUniform2f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v) - - Convenience function that calls glUniform2fv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2fv.xml}{glUniform2fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y) - - Convenience function that calls glUniform2i(\a location, \a x, \a y). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2i.xml}{glUniform2i()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v) - - Convenience function that calls glUniform2iv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2iv.xml}{glUniform2iv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) - - Convenience function that calls glUniform3f(\a location, \a x, \a y, \a z). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3f.xml}{glUniform3f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v) - - Convenience function that calls glUniform3fv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3fv.xml}{glUniform3fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z) - - Convenience function that calls glUniform3i(\a location, \a x, \a y, \a z). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3i.xml}{glUniform3i()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v) - - Convenience function that calls glUniform3iv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3iv.xml}{glUniform3iv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) - - Convenience function that calls glUniform4f(\a location, \a x, \a y, \a z, \a w). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4f.xml}{glUniform4f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v) - - Convenience function that calls glUniform4fv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4fv.xml}{glUniform4fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) - - Convenience function that calls glUniform4i(\a location, \a x, \a y, \a z, \a w). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4i.xml}{glUniform4i()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v) - - Convenience function that calls glUniform4iv(\a location, \a count, \a v). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4iv.xml}{glUniform4iv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - - Convenience function that calls glUniformMatrix2fv(\a location, \a count, \a transpose, \a value). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix2fv.xml}{glUniformMatrix2fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - - Convenience function that calls glUniformMatrix3fv(\a location, \a count, \a transpose, \a value). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix3fv.xml}{glUniformMatrix3fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) - - Convenience function that calls glUniformMatrix4fv(\a location, \a count, \a transpose, \a value). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix4fv.xml}{glUniformMatrix4fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glUseProgram(GLuint program) - - Convenience function that calls glUseProgram(\a program). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glUseProgram.xml}{glUseProgram()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glValidateProgram(GLuint program) - - Convenience function that calls glValidateProgram(\a program). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glValidateProgram.xml}{glValidateProgram()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x) - - Convenience function that calls glVertexAttrib1f(\a indx, \a x). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1f.xml}{glVertexAttrib1f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values) - - Convenience function that calls glVertexAttrib1fv(\a indx, \a values). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1fv.xml}{glVertexAttrib1fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) - - Convenience function that calls glVertexAttrib2f(\a indx, \a x, \a y). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2f.xml}{glVertexAttrib2f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values) - - Convenience function that calls glVertexAttrib2fv(\a indx, \a values). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2fv.xml}{glVertexAttrib2fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) - - Convenience function that calls glVertexAttrib3f(\a indx, \a x, \a y, \a z). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3f.xml}{glVertexAttrib3f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values) - - Convenience function that calls glVertexAttrib3fv(\a indx, \a values). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3fv.xml}{glVertexAttrib3fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) - - Convenience function that calls glVertexAttrib4f(\a indx, \a x, \a y, \a z, \a w). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4f.xml}{glVertexAttrib4f()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values) - - Convenience function that calls glVertexAttrib4fv(\a indx, \a values). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4fv.xml}{glVertexAttrib4fv()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -/*! - \fn void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) - - Convenience function that calls glVertexAttribPointer(\a indx, \a size, \a type, \a normalized, \a stride, \a ptr). - - For more information, see the OpenGL ES 2.0 documentation for - \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttribPointer.xml}{glVertexAttribPointer()}. - - This convenience function will do nothing on OpenGL ES 1.x systems. -*/ - -QGLFunctionsPrivate::QGLFunctionsPrivate(const QGLContext *) - : funcs(0) -{ -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglfunctions.h b/src/opengl/qglfunctions.h deleted file mode 100644 index d8c5249a1a..0000000000 --- a/src/opengl/qglfunctions.h +++ /dev/null @@ -1,1688 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLFUNCTIONS_H -#define QGLFUNCTIONS_H - -#include <QtOpenGL/qgl.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/qopenglfunctions.h> - -QT_BEGIN_NAMESPACE - -struct QGLFunctionsPrivate; - -class Q_OPENGL_EXPORT QGLFunctions -{ -public: - QGLFunctions(); - explicit QGLFunctions(const QGLContext *context); - ~QGLFunctions() {} - - enum OpenGLFeature - { - Multitexture = 0x0001, - Shaders = 0x0002, - Buffers = 0x0004, - Framebuffers = 0x0008, - BlendColor = 0x0010, - BlendEquation = 0x0020, - BlendEquationSeparate = 0x0040, - BlendFuncSeparate = 0x0080, - BlendSubtract = 0x0100, - CompressedTextures = 0x0200, - Multisample = 0x0400, - StencilSeparate = 0x0800, - NPOTTextures = 0x1000 - }; - Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) - - QGLFunctions::OpenGLFeatures openGLFeatures() const; - bool hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const; - - void initializeGLFunctions(const QGLContext *context = nullptr); - - void glActiveTexture(GLenum texture); - void glAttachShader(GLuint program, GLuint shader); - void glBindAttribLocation(GLuint program, GLuint index, const char* name); - void glBindBuffer(GLenum target, GLuint buffer); - void glBindFramebuffer(GLenum target, GLuint framebuffer); - void glBindRenderbuffer(GLenum target, GLuint renderbuffer); - void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - void glBlendEquation(GLenum mode); - void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); - void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); - void glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage); - void glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data); - GLenum glCheckFramebufferStatus(GLenum target); - void glClearDepthf(GLclampf depth); - void glCompileShader(GLuint shader); - void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); - void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); - GLuint glCreateProgram(); - GLuint glCreateShader(GLenum type); - void glDeleteBuffers(GLsizei n, const GLuint* buffers); - void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers); - void glDeleteProgram(GLuint program); - void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers); - void glDeleteShader(GLuint shader); - void glDepthRangef(GLclampf zNear, GLclampf zFar); - void glDetachShader(GLuint program, GLuint shader); - void glDisableVertexAttribArray(GLuint index); - void glEnableVertexAttribArray(GLuint index); - void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void glGenBuffers(GLsizei n, GLuint* buffers); - void glGenerateMipmap(GLenum target); - void glGenFramebuffers(GLsizei n, GLuint* framebuffers); - void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers); - void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); - void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); - void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); - int glGetAttribLocation(GLuint program, const char* name); - void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); - void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params); - void glGetProgramiv(GLuint program, GLenum pname, GLint* params); - void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); - void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params); - void glGetShaderiv(GLuint shader, GLenum pname, GLint* params); - void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); - void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); - void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source); - void glGetUniformfv(GLuint program, GLint location, GLfloat* params); - void glGetUniformiv(GLuint program, GLint location, GLint* params); - int glGetUniformLocation(GLuint program, const char* name); - void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); - void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); - void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer); - GLboolean glIsBuffer(GLuint buffer); - GLboolean glIsFramebuffer(GLuint framebuffer); - GLboolean glIsProgram(GLuint program); - GLboolean glIsRenderbuffer(GLuint renderbuffer); - GLboolean glIsShader(GLuint shader); - void glLinkProgram(GLuint program); - void glReleaseShaderCompiler(); - void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void glSampleCoverage(GLclampf value, GLboolean invert); - void glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length); - void glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length); - void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); - void glStencilMaskSeparate(GLenum face, GLuint mask); - void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); - void glUniform1f(GLint location, GLfloat x); - void glUniform1fv(GLint location, GLsizei count, const GLfloat* v); - void glUniform1i(GLint location, GLint x); - void glUniform1iv(GLint location, GLsizei count, const GLint* v); - void glUniform2f(GLint location, GLfloat x, GLfloat y); - void glUniform2fv(GLint location, GLsizei count, const GLfloat* v); - void glUniform2i(GLint location, GLint x, GLint y); - void glUniform2iv(GLint location, GLsizei count, const GLint* v); - void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z); - void glUniform3fv(GLint location, GLsizei count, const GLfloat* v); - void glUniform3i(GLint location, GLint x, GLint y, GLint z); - void glUniform3iv(GLint location, GLsizei count, const GLint* v); - void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void glUniform4fv(GLint location, GLsizei count, const GLfloat* v); - void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w); - void glUniform4iv(GLint location, GLsizei count, const GLint* v); - void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); - void glUseProgram(GLuint program); - void glValidateProgram(GLuint program); - void glVertexAttrib1f(GLuint indx, GLfloat x); - void glVertexAttrib1fv(GLuint indx, const GLfloat* values); - void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); - void glVertexAttrib2fv(GLuint indx, const GLfloat* values); - void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); - void glVertexAttrib3fv(GLuint indx, const GLfloat* values); - void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void glVertexAttrib4fv(GLuint indx, const GLfloat* values); - void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); - -private: - QGLFunctionsPrivate *d_ptr; - static bool isInitialized(const QGLFunctionsPrivate *d) { return d != nullptr; } -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFunctions::OpenGLFeatures) - -struct QGLFunctionsPrivate -{ - QGLFunctionsPrivate(const QGLContext *context = nullptr); - QOpenGLFunctions *funcs; -}; - -inline void QGLFunctions::glActiveTexture(GLenum texture) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glActiveTexture(texture); -} - -inline void QGLFunctions::glAttachShader(GLuint program, GLuint shader) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glAttachShader(program, shader); -} - -inline void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBindAttribLocation(program, index, name); -} - -inline void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBindBuffer(target, buffer); -} - -inline void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer) -{ - if (framebuffer == 0) - framebuffer = QOpenGLContext::currentContext()->defaultFramebufferObject(); - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBindFramebuffer(target, framebuffer); -} - -inline void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBindRenderbuffer(target, renderbuffer); -} - -inline void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBlendColor(red, green, blue, alpha); -} - -inline void QGLFunctions::glBlendEquation(GLenum mode) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBlendEquation(mode); -} - -inline void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBlendEquationSeparate(modeRGB, modeAlpha); -} - -inline void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); -} - -inline void QGLFunctions::glBufferData(GLenum target, qopengl_GLsizeiptr size, const void* data, GLenum usage) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBufferData(target, size, data, usage); -} - -inline void QGLFunctions::glBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, const void* data) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glBufferSubData(target, offset, size, data); -} - -inline GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glCheckFramebufferStatus(target); -} - -inline void QGLFunctions::glClearDepthf(GLclampf depth) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glClearDepthf(depth); -} - -inline void QGLFunctions::glCompileShader(GLuint shader) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glCompileShader(shader); -} - -inline void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); -} - -inline void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); -} - -inline GLuint QGLFunctions::glCreateProgram() -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glCreateProgram(); -} - -inline GLuint QGLFunctions::glCreateShader(GLenum type) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glCreateShader(type); -} - -inline void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDeleteBuffers(n, buffers); -} - -inline void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDeleteFramebuffers(n, framebuffers); -} - -inline void QGLFunctions::glDeleteProgram(GLuint program) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDeleteProgram(program); -} - -inline void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDeleteRenderbuffers(n, renderbuffers); -} - -inline void QGLFunctions::glDeleteShader(GLuint shader) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDeleteShader(shader); -} - -inline void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glDepthRangef(zNear, zFar); -} - -inline void QGLFunctions::glDetachShader(GLuint program, GLuint shader) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDetachShader(program, shader); -} - -inline void QGLFunctions::glDisableVertexAttribArray(GLuint index) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glDisableVertexAttribArray(index); -} - -inline void QGLFunctions::glEnableVertexAttribArray(GLuint index) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glEnableVertexAttribArray(index); -} - -inline void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); -} - -inline void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glFramebufferTexture2D(target, attachment, textarget, texture, level); -} - -inline void QGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGenBuffers(n, buffers); -} - -inline void QGLFunctions::glGenerateMipmap(GLenum target) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGenerateMipmap(target); -} - -inline void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGenFramebuffers(n, framebuffers); -} - -inline void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGenRenderbuffers(n, renderbuffers); -} - -inline void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetActiveAttrib(program, index, bufsize, length, size, type, name); -} - -inline void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetActiveUniform(program, index, bufsize, length, size, type, name); -} - -inline void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetAttachedShaders(program, maxcount, count, shaders); -} - -inline int QGLFunctions::glGetAttribLocation(GLuint program, const char* name) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glGetAttribLocation(program, name); -} - -inline void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetBufferParameteriv(target, pname, params); -} - -inline void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); -} - -inline void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetProgramiv(program, pname, params); -} - -inline void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetProgramInfoLog(program, bufsize, length, infolog); -} - -inline void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetRenderbufferParameteriv(target, pname, params); -} - -inline void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetShaderiv(shader, pname, params); -} - -inline void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetShaderInfoLog(shader, bufsize, length, infolog); -} - -inline void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); -} - -inline void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetShaderSource(shader, bufsize, length, source); -} - -inline void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetUniformfv(program, location, params); -} - -inline void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetUniformiv(program, location, params); -} - -inline int QGLFunctions::glGetUniformLocation(GLuint program, const char* name) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glGetUniformLocation(program, name); -} - -inline void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetVertexAttribfv(index, pname, params); -} - -inline void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetVertexAttribiv(index, pname, params); -} - -inline void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glGetVertexAttribPointerv(index, pname, pointer); -} - -inline GLboolean QGLFunctions::glIsBuffer(GLuint buffer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glIsBuffer(buffer); -} - -inline GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glIsFramebuffer(framebuffer); -} - -inline GLboolean QGLFunctions::glIsProgram(GLuint program) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glIsProgram(program); -} - -inline GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glIsRenderbuffer(renderbuffer); -} - -inline GLboolean QGLFunctions::glIsShader(GLuint shader) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - return d_ptr->funcs->glIsShader(shader); -} - -inline void QGLFunctions::glLinkProgram(GLuint program) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glLinkProgram(program); -} - -inline void QGLFunctions::glReleaseShaderCompiler() -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glReleaseShaderCompiler(); -} - -inline void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glRenderbufferStorage(target, internalformat, width, height); -} - -inline void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glSampleCoverage(value, invert); -} - -inline void QGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glShaderBinary(n, shaders, binaryformat, binary, length); -} - -inline void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glShaderSource(shader, count, string, length); -} - -inline void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glStencilFuncSeparate(face, func, ref, mask); -} - -inline void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glStencilMaskSeparate(face, mask); -} - -inline void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glStencilOpSeparate(face, fail, zfail, zpass); -} - -inline void QGLFunctions::glUniform1f(GLint location, GLfloat x) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform1f(location, x); -} - -inline void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform1fv(location, count, v); -} - -inline void QGLFunctions::glUniform1i(GLint location, GLint x) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform1i(location, x); -} - -inline void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform1iv(location, count, v); -} - -inline void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform2f(location, x, y); -} - -inline void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform2fv(location, count, v); -} - -inline void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform2i(location, x, y); -} - -inline void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform2iv(location, count, v); -} - -inline void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform3f(location, x, y, z); -} - -inline void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform3fv(location, count, v); -} - -inline void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform3i(location, x, y, z); -} - -inline void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform3iv(location, count, v); -} - -inline void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform4f(location, x, y, z, w); -} - -inline void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform4fv(location, count, v); -} - -inline void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform4i(location, x, y, z, w); -} - -inline void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniform4iv(location, count, v); -} - -inline void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniformMatrix2fv(location, count, transpose, value); -} - -inline void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniformMatrix3fv(location, count, transpose, value); -} - -inline void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUniformMatrix4fv(location, count, transpose, value); -} - -inline void QGLFunctions::glUseProgram(GLuint program) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glUseProgram(program); -} - -inline void QGLFunctions::glValidateProgram(GLuint program) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glValidateProgram(program); -} - -inline void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib1f(indx, x); -} - -inline void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib1fv(indx, values); -} - -inline void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib2f(indx, x, y); -} - -inline void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib2fv(indx, values); -} - -inline void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib3f(indx, x, y, z); -} - -inline void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib3fv(indx, values); -} - -inline void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib4f(indx, x, y, z, w); -} - -inline void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttrib4fv(indx, values); -} - -inline void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) -{ - Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); - d_ptr->funcs->glVertexAttribPointer(indx, size, type, normalized, stride, ptr); -} - -#ifndef GL_ACTIVE_ATTRIBUTE_MAX_LENGTH -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#endif -#ifndef GL_ACTIVE_ATTRIBUTES -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#endif -#ifndef GL_ACTIVE_TEXTURE -#define GL_ACTIVE_TEXTURE 0x84E0 -#endif -#ifndef GL_ACTIVE_UNIFORM_MAX_LENGTH -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#endif -#ifndef GL_ACTIVE_UNIFORMS -#define GL_ACTIVE_UNIFORMS 0x8B86 -#endif -#ifndef GL_ALIASED_LINE_WIDTH_RANGE -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif -#ifndef GL_ALIASED_POINT_SIZE_RANGE -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#endif -#ifndef GL_ALPHA -#define GL_ALPHA 0x1906 -#endif -#ifndef GL_ALPHA_BITS -#define GL_ALPHA_BITS 0x0D55 -#endif -#ifndef GL_ALWAYS -#define GL_ALWAYS 0x0207 -#endif -#ifndef GL_ARRAY_BUFFER -#define GL_ARRAY_BUFFER 0x8892 -#endif -#ifndef GL_ARRAY_BUFFER_BINDING -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#endif -#ifndef GL_ATTACHED_SHADERS -#define GL_ATTACHED_SHADERS 0x8B85 -#endif -#ifndef GL_BACK -#define GL_BACK 0x0405 -#endif -#ifndef GL_BLEND -#define GL_BLEND 0x0BE2 -#endif -#ifndef GL_BLEND_COLOR -#define GL_BLEND_COLOR 0x8005 -#endif -#ifndef GL_BLEND_DST_ALPHA -#define GL_BLEND_DST_ALPHA 0x80CA -#endif -#ifndef GL_BLEND_DST_RGB -#define GL_BLEND_DST_RGB 0x80C8 -#endif -#ifndef GL_BLEND_EQUATION -#define GL_BLEND_EQUATION 0x8009 -#endif -#ifndef GL_BLEND_EQUATION_ALPHA -#define GL_BLEND_EQUATION_ALPHA 0x883D -#endif -#ifndef GL_BLEND_EQUATION_RGB -#define GL_BLEND_EQUATION_RGB 0x8009 -#endif -#ifndef GL_BLEND_SRC_ALPHA -#define GL_BLEND_SRC_ALPHA 0x80CB -#endif -#ifndef GL_BLEND_SRC_RGB -#define GL_BLEND_SRC_RGB 0x80C9 -#endif -#ifndef GL_BLUE_BITS -#define GL_BLUE_BITS 0x0D54 -#endif -#ifndef GL_BOOL -#define GL_BOOL 0x8B56 -#endif -#ifndef GL_BOOL_VEC2 -#define GL_BOOL_VEC2 0x8B57 -#endif -#ifndef GL_BOOL_VEC3 -#define GL_BOOL_VEC3 0x8B58 -#endif -#ifndef GL_BOOL_VEC4 -#define GL_BOOL_VEC4 0x8B59 -#endif -#ifndef GL_BUFFER_SIZE -#define GL_BUFFER_SIZE 0x8764 -#endif -#ifndef GL_BUFFER_USAGE -#define GL_BUFFER_USAGE 0x8765 -#endif -#ifndef GL_BYTE -#define GL_BYTE 0x1400 -#endif -#ifndef GL_CCW -#define GL_CCW 0x0901 -#endif -#ifndef GL_CLAMP_TO_EDGE -#define GL_CLAMP_TO_EDGE 0x812F -#endif -#ifndef GL_COLOR_ATTACHMENT0 -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#endif -#ifndef GL_COLOR_BUFFER_BIT -#define GL_COLOR_BUFFER_BIT 0x00004000 -#endif -#ifndef GL_COLOR_CLEAR_VALUE -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#endif -#ifndef GL_COLOR_WRITEMASK -#define GL_COLOR_WRITEMASK 0x0C23 -#endif -#ifndef GL_COMPILE_STATUS -#define GL_COMPILE_STATUS 0x8B81 -#endif -#ifndef GL_COMPRESSED_TEXTURE_FORMATS -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#endif -#ifndef GL_CONSTANT_ALPHA -#define GL_CONSTANT_ALPHA 0x8003 -#endif -#ifndef GL_CONSTANT_COLOR -#define GL_CONSTANT_COLOR 0x8001 -#endif -#ifndef GL_CULL_FACE -#define GL_CULL_FACE 0x0B44 -#endif -#ifndef GL_CULL_FACE_MODE -#define GL_CULL_FACE_MODE 0x0B45 -#endif -#ifndef GL_CURRENT_PROGRAM -#define GL_CURRENT_PROGRAM 0x8B8D -#endif -#ifndef GL_CURRENT_VERTEX_ATTRIB -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#endif -#ifndef GL_CW -#define GL_CW 0x0900 -#endif -#ifndef GL_DECR -#define GL_DECR 0x1E03 -#endif -#ifndef GL_DECR_WRAP -#define GL_DECR_WRAP 0x8508 -#endif -#ifndef GL_DELETE_STATUS -#define GL_DELETE_STATUS 0x8B80 -#endif -#ifndef GL_DEPTH_ATTACHMENT -#define GL_DEPTH_ATTACHMENT 0x8D00 -#endif -#ifndef GL_DEPTH_BITS -#define GL_DEPTH_BITS 0x0D56 -#endif -#ifndef GL_DEPTH_BUFFER_BIT -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#endif -#ifndef GL_DEPTH_CLEAR_VALUE -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#endif -#ifndef GL_DEPTH_COMPONENT -#define GL_DEPTH_COMPONENT 0x1902 -#endif -#ifndef GL_DEPTH_COMPONENT16 -#define GL_DEPTH_COMPONENT16 0x81A5 -#endif -#ifndef GL_DEPTH_FUNC -#define GL_DEPTH_FUNC 0x0B74 -#endif -#ifndef GL_DEPTH_RANGE -#define GL_DEPTH_RANGE 0x0B70 -#endif -#ifndef GL_DEPTH_TEST -#define GL_DEPTH_TEST 0x0B71 -#endif -#ifndef GL_DEPTH_WRITEMASK -#define GL_DEPTH_WRITEMASK 0x0B72 -#endif -#ifndef GL_DITHER -#define GL_DITHER 0x0BD0 -#endif -#ifndef GL_DONT_CARE -#define GL_DONT_CARE 0x1100 -#endif -#ifndef GL_DST_ALPHA -#define GL_DST_ALPHA 0x0304 -#endif -#ifndef GL_DST_COLOR -#define GL_DST_COLOR 0x0306 -#endif -#ifndef GL_DYNAMIC_DRAW -#define GL_DYNAMIC_DRAW 0x88E8 -#endif -#ifndef GL_ELEMENT_ARRAY_BUFFER -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#endif -#ifndef GL_ELEMENT_ARRAY_BUFFER_BINDING -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#endif -#ifndef GL_EQUAL -#define GL_EQUAL 0x0202 -#endif -#ifndef GL_EXTENSIONS -#define GL_EXTENSIONS 0x1F03 -#endif -#ifndef GL_FALSE -#define GL_FALSE 0 -#endif -#ifndef GL_FASTEST -#define GL_FASTEST 0x1101 -#endif -#ifndef GL_FIXED -#define GL_FIXED 0x140C -#endif -#ifndef GL_FLOAT -#define GL_FLOAT 0x1406 -#endif -#ifndef GL_FLOAT_MAT2 -#define GL_FLOAT_MAT2 0x8B5A -#endif -#ifndef GL_FLOAT_MAT3 -#define GL_FLOAT_MAT3 0x8B5B -#endif -#ifndef GL_FLOAT_MAT4 -#define GL_FLOAT_MAT4 0x8B5C -#endif -#ifndef GL_FLOAT_VEC2 -#define GL_FLOAT_VEC2 0x8B50 -#endif -#ifndef GL_FLOAT_VEC3 -#define GL_FLOAT_VEC3 0x8B51 -#endif -#ifndef GL_FLOAT_VEC4 -#define GL_FLOAT_VEC4 0x8B52 -#endif -#ifndef GL_FRAGMENT_SHADER -#define GL_FRAGMENT_SHADER 0x8B30 -#endif -#ifndef GL_FRAMEBUFFER -#define GL_FRAMEBUFFER 0x8D40 -#endif -#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#endif -#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#endif -#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#endif -#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#endif -#ifndef GL_FRAMEBUFFER_BINDING -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#endif -#ifndef GL_FRAMEBUFFER_COMPLETE -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#endif -#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#endif -#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#endif -#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#endif -#ifndef GL_FRAMEBUFFER_UNSUPPORTED -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#endif -#ifndef GL_FRONT -#define GL_FRONT 0x0404 -#endif -#ifndef GL_FRONT_AND_BACK -#define GL_FRONT_AND_BACK 0x0408 -#endif -#ifndef GL_FRONT_FACE -#define GL_FRONT_FACE 0x0B46 -#endif -#ifndef GL_FUNC_ADD -#define GL_FUNC_ADD 0x8006 -#endif -#ifndef GL_FUNC_REVERSE_SUBTRACT -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif -#ifndef GL_FUNC_SUBTRACT -#define GL_FUNC_SUBTRACT 0x800A -#endif -#ifndef GL_GENERATE_MIPMAP_HINT -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#endif -#ifndef GL_GEQUAL -#define GL_GEQUAL 0x0206 -#endif -#ifndef GL_GREATER -#define GL_GREATER 0x0204 -#endif -#ifndef GL_GREEN_BITS -#define GL_GREEN_BITS 0x0D53 -#endif -#ifndef GL_HIGH_FLOAT -#define GL_HIGH_FLOAT 0x8DF2 -#endif -#ifndef GL_HIGH_INT -#define GL_HIGH_INT 0x8DF5 -#endif -#ifndef GL_IMPLEMENTATION_COLOR_READ_FORMAT -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#endif -#ifndef GL_IMPLEMENTATION_COLOR_READ_TYPE -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#endif -#ifndef GL_INCR -#define GL_INCR 0x1E02 -#endif -#ifndef GL_INCR_WRAP -#define GL_INCR_WRAP 0x8507 -#endif -#ifndef GL_INFO_LOG_LENGTH -#define GL_INFO_LOG_LENGTH 0x8B84 -#endif -#ifndef GL_INT -#define GL_INT 0x1404 -#endif -#ifndef GL_INT_VEC2 -#define GL_INT_VEC2 0x8B53 -#endif -#ifndef GL_INT_VEC3 -#define GL_INT_VEC3 0x8B54 -#endif -#ifndef GL_INT_VEC4 -#define GL_INT_VEC4 0x8B55 -#endif -#ifndef GL_INVALID_ENUM -#define GL_INVALID_ENUM 0x0500 -#endif -#ifndef GL_INVALID_FRAMEBUFFER_OPERATION -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#endif -#ifndef GL_INVALID_OPERATION -#define GL_INVALID_OPERATION 0x0502 -#endif -#ifndef GL_INVALID_VALUE -#define GL_INVALID_VALUE 0x0501 -#endif -#ifndef GL_INVERT -#define GL_INVERT 0x150A -#endif -#ifndef GL_KEEP -#define GL_KEEP 0x1E00 -#endif -#ifndef GL_LEQUAL -#define GL_LEQUAL 0x0203 -#endif -#ifndef GL_LESS -#define GL_LESS 0x0201 -#endif -#ifndef GL_LINEAR -#define GL_LINEAR 0x2601 -#endif -#ifndef GL_LINEAR_MIPMAP_LINEAR -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#endif -#ifndef GL_LINEAR_MIPMAP_NEAREST -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#endif -#ifndef GL_LINE_LOOP -#define GL_LINE_LOOP 0x0002 -#endif -#ifndef GL_LINES -#define GL_LINES 0x0001 -#endif -#ifndef GL_LINE_STRIP -#define GL_LINE_STRIP 0x0003 -#endif -#ifndef GL_LINE_WIDTH -#define GL_LINE_WIDTH 0x0B21 -#endif -#ifndef GL_LINK_STATUS -#define GL_LINK_STATUS 0x8B82 -#endif -#ifndef GL_LOW_FLOAT -#define GL_LOW_FLOAT 0x8DF0 -#endif -#ifndef GL_LOW_INT -#define GL_LOW_INT 0x8DF3 -#endif -#ifndef GL_LUMINANCE -#define GL_LUMINANCE 0x1909 -#endif -#ifndef GL_LUMINANCE_ALPHA -#define GL_LUMINANCE_ALPHA 0x190A -#endif -#ifndef GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#endif -#ifndef GL_MAX_CUBE_MAP_TEXTURE_SIZE -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#endif -#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif -#ifndef GL_MAX_RENDERBUFFER_SIZE -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#endif -#ifndef GL_MAX_TEXTURE_IMAGE_UNITS -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#endif -#ifndef GL_MAX_TEXTURE_SIZE -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#endif -#ifndef GL_MAX_VARYING_VECTORS -#define GL_MAX_VARYING_VECTORS 0x8DFC -#endif -#ifndef GL_MAX_VERTEX_ATTRIBS -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#endif -#ifndef GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#endif -#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#endif -#ifndef GL_MAX_VIEWPORT_DIMS -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#endif -#ifndef GL_MEDIUM_FLOAT -#define GL_MEDIUM_FLOAT 0x8DF1 -#endif -#ifndef GL_MEDIUM_INT -#define GL_MEDIUM_INT 0x8DF4 -#endif -#ifndef GL_MIRRORED_REPEAT -#define GL_MIRRORED_REPEAT 0x8370 -#endif -#ifndef GL_NEAREST -#define GL_NEAREST 0x2600 -#endif -#ifndef GL_NEAREST_MIPMAP_LINEAR -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#endif -#ifndef GL_NEAREST_MIPMAP_NEAREST -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#endif -#ifndef GL_NEVER -#define GL_NEVER 0x0200 -#endif -#ifndef GL_NICEST -#define GL_NICEST 0x1102 -#endif -#ifndef GL_NO_ERROR -#define GL_NO_ERROR 0 -#endif -#ifndef GL_NONE -#define GL_NONE 0 -#endif -#ifndef GL_NOTEQUAL -#define GL_NOTEQUAL 0x0205 -#endif -#ifndef GL_NUM_COMPRESSED_TEXTURE_FORMATS -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#endif -#ifndef GL_NUM_SHADER_BINARY_FORMATS -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#endif -#ifndef GL_ONE -#define GL_ONE 1 -#endif -#ifndef GL_ONE_MINUS_CONSTANT_ALPHA -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#endif -#ifndef GL_ONE_MINUS_CONSTANT_COLOR -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#endif -#ifndef GL_ONE_MINUS_DST_ALPHA -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#endif -#ifndef GL_ONE_MINUS_DST_COLOR -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#endif -#ifndef GL_ONE_MINUS_SRC_ALPHA -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#endif -#ifndef GL_ONE_MINUS_SRC_COLOR -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#endif -#ifndef GL_OUT_OF_MEMORY -#define GL_OUT_OF_MEMORY 0x0505 -#endif -#ifndef GL_PACK_ALIGNMENT -#define GL_PACK_ALIGNMENT 0x0D05 -#endif -#ifndef GL_POINTS -#define GL_POINTS 0x0000 -#endif -#ifndef GL_POLYGON_OFFSET_FACTOR -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#endif -#ifndef GL_POLYGON_OFFSET_FILL -#define GL_POLYGON_OFFSET_FILL 0x8037 -#endif -#ifndef GL_POLYGON_OFFSET_UNITS -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#endif -#ifndef GL_RED_BITS -#define GL_RED_BITS 0x0D52 -#endif -#ifndef GL_RENDERBUFFER -#define GL_RENDERBUFFER 0x8D41 -#endif -#ifndef GL_RENDERBUFFER_ALPHA_SIZE -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#endif -#ifndef GL_RENDERBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#endif -#ifndef GL_RENDERBUFFER_BLUE_SIZE -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#endif -#ifndef GL_RENDERBUFFER_DEPTH_SIZE -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#endif -#ifndef GL_RENDERBUFFER_GREEN_SIZE -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#endif -#ifndef GL_RENDERBUFFER_HEIGHT -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#endif -#ifndef GL_RENDERBUFFER_INTERNAL_FORMAT -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#endif -#ifndef GL_RENDERBUFFER_RED_SIZE -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#endif -#ifndef GL_RENDERBUFFER_STENCIL_SIZE -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#endif -#ifndef GL_RENDERBUFFER_WIDTH -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#endif -#ifndef GL_RENDERER -#define GL_RENDERER 0x1F01 -#endif -#ifndef GL_REPEAT -#define GL_REPEAT 0x2901 -#endif -#ifndef GL_REPLACE -#define GL_REPLACE 0x1E01 -#endif -#ifndef GL_RGB -#define GL_RGB 0x1907 -#endif -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif -#ifndef GL_RGB5_A1 -#define GL_RGB5_A1 0x8057 -#endif -#ifndef GL_RGBA -#define GL_RGBA 0x1908 -#endif -#ifndef GL_RGBA4 -#define GL_RGBA4 0x8056 -#endif -#ifndef GL_BGRA -#define GL_BGRA 0x80E1 -#endif -#ifndef GL_SAMPLE_ALPHA_TO_COVERAGE -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#endif -#ifndef GL_SAMPLE_BUFFERS -#define GL_SAMPLE_BUFFERS 0x80A8 -#endif -#ifndef GL_SAMPLE_COVERAGE -#define GL_SAMPLE_COVERAGE 0x80A0 -#endif -#ifndef GL_SAMPLE_COVERAGE_INVERT -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#endif -#ifndef GL_SAMPLE_COVERAGE_VALUE -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#endif -#ifndef GL_SAMPLER_2D -#define GL_SAMPLER_2D 0x8B5E -#endif -#ifndef GL_SAMPLER_CUBE -#define GL_SAMPLER_CUBE 0x8B60 -#endif -#ifndef GL_SAMPLES -#define GL_SAMPLES 0x80A9 -#endif -#ifndef GL_SCISSOR_BOX -#define GL_SCISSOR_BOX 0x0C10 -#endif -#ifndef GL_SCISSOR_TEST -#define GL_SCISSOR_TEST 0x0C11 -#endif -#ifndef GL_SHADER_BINARY_FORMATS -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#endif -#ifndef GL_SHADER_COMPILER -#define GL_SHADER_COMPILER 0x8DFA -#endif -#ifndef GL_SHADER_SOURCE_LENGTH -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#endif -#ifndef GL_SHADER_TYPE -#define GL_SHADER_TYPE 0x8B4F -#endif -#ifndef GL_SHADING_LANGUAGE_VERSION -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#endif -#ifndef GL_SHORT -#define GL_SHORT 0x1402 -#endif -#ifndef GL_SRC_ALPHA -#define GL_SRC_ALPHA 0x0302 -#endif -#ifndef GL_SRC_ALPHA_SATURATE -#define GL_SRC_ALPHA_SATURATE 0x0308 -#endif -#ifndef GL_SRC_COLOR -#define GL_SRC_COLOR 0x0300 -#endif -#ifndef GL_STATIC_DRAW -#define GL_STATIC_DRAW 0x88E4 -#endif -#ifndef GL_STENCIL_ATTACHMENT -#define GL_STENCIL_ATTACHMENT 0x8D20 -#endif -#ifndef GL_STENCIL_BACK_FAIL -#define GL_STENCIL_BACK_FAIL 0x8801 -#endif -#ifndef GL_STENCIL_BACK_FUNC -#define GL_STENCIL_BACK_FUNC 0x8800 -#endif -#ifndef GL_STENCIL_BACK_PASS_DEPTH_FAIL -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#endif -#ifndef GL_STENCIL_BACK_PASS_DEPTH_PASS -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#endif -#ifndef GL_STENCIL_BACK_REF -#define GL_STENCIL_BACK_REF 0x8CA3 -#endif -#ifndef GL_STENCIL_BACK_VALUE_MASK -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#endif -#ifndef GL_STENCIL_BACK_WRITEMASK -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif -#ifndef GL_STENCIL_BITS -#define GL_STENCIL_BITS 0x0D57 -#endif -#ifndef GL_STENCIL_BUFFER_BIT -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#endif -#ifndef GL_STENCIL_CLEAR_VALUE -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#endif -#ifndef GL_STENCIL_FAIL -#define GL_STENCIL_FAIL 0x0B94 -#endif -#ifndef GL_STENCIL_FUNC -#define GL_STENCIL_FUNC 0x0B92 -#endif -#ifndef GL_STENCIL_INDEX -#define GL_STENCIL_INDEX 0x1901 -#endif -#ifndef GL_STENCIL_INDEX8 -#define GL_STENCIL_INDEX8 0x8D48 -#endif -#ifndef GL_STENCIL_PASS_DEPTH_FAIL -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#endif -#ifndef GL_STENCIL_PASS_DEPTH_PASS -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#endif -#ifndef GL_STENCIL_REF -#define GL_STENCIL_REF 0x0B97 -#endif -#ifndef GL_STENCIL_TEST -#define GL_STENCIL_TEST 0x0B90 -#endif -#ifndef GL_STENCIL_VALUE_MASK -#define GL_STENCIL_VALUE_MASK 0x0B93 -#endif -#ifndef GL_STENCIL_WRITEMASK -#define GL_STENCIL_WRITEMASK 0x0B98 -#endif -#ifndef GL_STREAM_DRAW -#define GL_STREAM_DRAW 0x88E0 -#endif -#ifndef GL_SUBPIXEL_BITS -#define GL_SUBPIXEL_BITS 0x0D50 -#endif -#ifndef GL_TEXTURE0 -#define GL_TEXTURE0 0x84C0 -#endif -#ifndef GL_TEXTURE -#define GL_TEXTURE 0x1702 -#endif -#ifndef GL_TEXTURE10 -#define GL_TEXTURE10 0x84CA -#endif -#ifndef GL_TEXTURE1 -#define GL_TEXTURE1 0x84C1 -#endif -#ifndef GL_TEXTURE11 -#define GL_TEXTURE11 0x84CB -#endif -#ifndef GL_TEXTURE12 -#define GL_TEXTURE12 0x84CC -#endif -#ifndef GL_TEXTURE13 -#define GL_TEXTURE13 0x84CD -#endif -#ifndef GL_TEXTURE14 -#define GL_TEXTURE14 0x84CE -#endif -#ifndef GL_TEXTURE15 -#define GL_TEXTURE15 0x84CF -#endif -#ifndef GL_TEXTURE16 -#define GL_TEXTURE16 0x84D0 -#endif -#ifndef GL_TEXTURE17 -#define GL_TEXTURE17 0x84D1 -#endif -#ifndef GL_TEXTURE18 -#define GL_TEXTURE18 0x84D2 -#endif -#ifndef GL_TEXTURE19 -#define GL_TEXTURE19 0x84D3 -#endif -#ifndef GL_TEXTURE20 -#define GL_TEXTURE20 0x84D4 -#endif -#ifndef GL_TEXTURE2 -#define GL_TEXTURE2 0x84C2 -#endif -#ifndef GL_TEXTURE21 -#define GL_TEXTURE21 0x84D5 -#endif -#ifndef GL_TEXTURE22 -#define GL_TEXTURE22 0x84D6 -#endif -#ifndef GL_TEXTURE23 -#define GL_TEXTURE23 0x84D7 -#endif -#ifndef GL_TEXTURE24 -#define GL_TEXTURE24 0x84D8 -#endif -#ifndef GL_TEXTURE25 -#define GL_TEXTURE25 0x84D9 -#endif -#ifndef GL_TEXTURE26 -#define GL_TEXTURE26 0x84DA -#endif -#ifndef GL_TEXTURE27 -#define GL_TEXTURE27 0x84DB -#endif -#ifndef GL_TEXTURE28 -#define GL_TEXTURE28 0x84DC -#endif -#ifndef GL_TEXTURE29 -#define GL_TEXTURE29 0x84DD -#endif -#ifndef GL_TEXTURE_2D -#define GL_TEXTURE_2D 0x0DE1 -#endif -#ifndef GL_TEXTURE30 -#define GL_TEXTURE30 0x84DE -#endif -#ifndef GL_TEXTURE3 -#define GL_TEXTURE3 0x84C3 -#endif -#ifndef GL_TEXTURE31 -#define GL_TEXTURE31 0x84DF -#endif -#ifndef GL_TEXTURE4 -#define GL_TEXTURE4 0x84C4 -#endif -#ifndef GL_TEXTURE5 -#define GL_TEXTURE5 0x84C5 -#endif -#ifndef GL_TEXTURE6 -#define GL_TEXTURE6 0x84C6 -#endif -#ifndef GL_TEXTURE7 -#define GL_TEXTURE7 0x84C7 -#endif -#ifndef GL_TEXTURE8 -#define GL_TEXTURE8 0x84C8 -#endif -#ifndef GL_TEXTURE9 -#define GL_TEXTURE9 0x84C9 -#endif -#ifndef GL_TEXTURE_BINDING_2D -#define GL_TEXTURE_BINDING_2D 0x8069 -#endif -#ifndef GL_TEXTURE_BINDING_CUBE_MAP -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#endif -#ifndef GL_TEXTURE_CUBE_MAP -#define GL_TEXTURE_CUBE_MAP 0x8513 -#endif -#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_X -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#endif -#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Y -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#endif -#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Z -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#endif -#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_X -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#endif -#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Y -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#endif -#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Z -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#endif -#ifndef GL_TEXTURE_MAG_FILTER -#define GL_TEXTURE_MAG_FILTER 0x2800 -#endif -#ifndef GL_TEXTURE_MIN_FILTER -#define GL_TEXTURE_MIN_FILTER 0x2801 -#endif -#ifndef GL_TEXTURE_WRAP_S -#define GL_TEXTURE_WRAP_S 0x2802 -#endif -#ifndef GL_TEXTURE_WRAP_T -#define GL_TEXTURE_WRAP_T 0x2803 -#endif -#ifndef GL_TRIANGLE_FAN -#define GL_TRIANGLE_FAN 0x0006 -#endif -#ifndef GL_TRIANGLES -#define GL_TRIANGLES 0x0004 -#endif -#ifndef GL_TRIANGLE_STRIP -#define GL_TRIANGLE_STRIP 0x0005 -#endif -#ifndef GL_TRUE -#define GL_TRUE 1 -#endif -#ifndef GL_UNPACK_ALIGNMENT -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#endif -#ifndef GL_UNSIGNED_BYTE -#define GL_UNSIGNED_BYTE 0x1401 -#endif -#ifndef GL_UNSIGNED_INT -#define GL_UNSIGNED_INT 0x1405 -#endif -#ifndef GL_UNSIGNED_SHORT -#define GL_UNSIGNED_SHORT 0x1403 -#endif -#ifndef GL_UNSIGNED_SHORT_4_4_4_4 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#endif -#ifndef GL_UNSIGNED_SHORT_5_5_5_1 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#endif -#ifndef GL_UNSIGNED_SHORT_5_6_5 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#endif -#ifndef GL_VALIDATE_STATUS -#define GL_VALIDATE_STATUS 0x8B83 -#endif -#ifndef GL_VENDOR -#define GL_VENDOR 0x1F00 -#endif -#ifndef GL_VERSION -#define GL_VERSION 0x1F02 -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_ENABLED -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_NORMALIZED -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_POINTER -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_SIZE -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_STRIDE -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#endif -#ifndef GL_VERTEX_ATTRIB_ARRAY_TYPE -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#endif -#ifndef GL_VERTEX_SHADER -#define GL_VERTEX_SHADER 0x8B31 -#endif -#ifndef GL_VIEWPORT -#define GL_VIEWPORT 0x0BA2 -#endif -#ifndef GL_ZERO -#define GL_ZERO 0 -#endif - -QT_END_NAMESPACE - -#endif diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp deleted file mode 100644 index c5151f66bb..0000000000 --- a/src/opengl/qglpaintdevice.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <private/qglpaintdevice_p.h> -#include <private/qgl_p.h> -#include <private/qglpixelbuffer_p.h> -#include <private/qglframebufferobject_p.h> -#include <qopenglfunctions.h> -#include <qwindow.h> - -QT_BEGIN_NAMESPACE - -QGLPaintDevice::QGLPaintDevice() - : m_thisFBO(0) -{ -} - -QGLPaintDevice::~QGLPaintDevice() -{ -} - -int QGLPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const -{ - switch(metric) { - case PdmWidth: - return size().width(); - case PdmHeight: - return size().height(); - case PdmDepth: { - const QGLFormat f = format(); - return f.redBufferSize() + f.greenBufferSize() + f.blueBufferSize() + f.alphaBufferSize(); - } - case PdmDevicePixelRatio: - return 1; - case PdmDevicePixelRatioScaled: - return 1 * QPaintDevice::devicePixelRatioFScale(); - default: - qWarning("QGLPaintDevice::metric() - metric %d not known", metric); - return 0; - } -} - -void QGLPaintDevice::beginPaint() -{ - // Make sure our context is the current one: - QGLContext *ctx = context(); - ctx->makeCurrent(); - - ctx->d_func()->refreshCurrentFbo(); - - // Record the currently bound FBO so we can restore it again - // in endPaint() and bind this device's FBO - // - // Note: m_thisFBO could be zero if the paint device is not - // backed by an FBO (e.g. window back buffer). But there could - // be a previous FBO bound to the context which we need to - // explicitly unbind. Otherwise the painting will go into - // the previous FBO instead of to the window. - m_previousFBO = ctx->d_func()->current_fbo; - - if (m_previousFBO != m_thisFBO) { - ctx->d_func()->setCurrentFbo(m_thisFBO); - ctx->contextHandle()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_thisFBO); - } - - // Set the default fbo for the context to m_thisFBO so that - // if some raw GL code between beginNativePainting() and - // endNativePainting() calls QGLFramebufferObject::release(), - // painting will revert to the window surface's fbo. - ctx->d_ptr->default_fbo = m_thisFBO; -} - -void QGLPaintDevice::ensureActiveTarget() -{ - QGLContext* ctx = context(); - if (ctx != QGLContext::currentContext()) - ctx->makeCurrent(); - - ctx->d_func()->refreshCurrentFbo(); - - if (ctx->d_ptr->current_fbo != m_thisFBO) { - ctx->d_func()->setCurrentFbo(m_thisFBO); - ctx->contextHandle()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_thisFBO); - } - - ctx->d_ptr->default_fbo = m_thisFBO; -} - -void QGLPaintDevice::endPaint() -{ - // Make sure the FBO bound at beginPaint is re-bound again here: - QGLContext *ctx = context(); - ctx->makeCurrent(); - - ctx->d_func()->refreshCurrentFbo(); - - if (m_previousFBO != ctx->d_func()->current_fbo) { - ctx->d_func()->setCurrentFbo(m_previousFBO); - ctx->contextHandle()->functions()->glBindFramebuffer(GL_FRAMEBUFFER, m_previousFBO); - } - - ctx->d_ptr->default_fbo = 0; -} - -QGLFormat QGLPaintDevice::format() const -{ - return context()->format(); -} - -bool QGLPaintDevice::alphaRequested() const -{ - return context()->d_func()->reqFormat.alpha(); -} - -bool QGLPaintDevice::isFlipped() const -{ - return false; -} - -////////////////// QGLWidgetGLPaintDevice ////////////////// - -QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() -{ -} - -QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const -{ - return glWidget->paintEngine(); -} - -void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) -{ - glWidget = w; -} - -void QGLWidgetGLPaintDevice::beginPaint() -{ - QGLPaintDevice::beginPaint(); - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) { - if (glWidget->testAttribute(Qt::WA_TranslucentBackground)) - funcs->glClearColor(0.0, 0.0, 0.0, 0.0); - else { - const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color(); - float alpha = c.alphaF(); - funcs->glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); - } - if (context()->d_func()->workaround_needsFullClearOnEveryFrame) - funcs->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - else - funcs->glClear(GL_COLOR_BUFFER_BIT); - } -} - -void QGLWidgetGLPaintDevice::endPaint() -{ - if (glWidget->autoBufferSwap()) - glWidget->swapBuffers(); - QGLPaintDevice::endPaint(); -} - - -QSize QGLWidgetGLPaintDevice::size() const -{ - return glWidget->size() * (glWidget->windowHandle() ? - glWidget->windowHandle()->devicePixelRatio() : qApp->devicePixelRatio()); -} - -QGLContext* QGLWidgetGLPaintDevice::context() const -{ - return const_cast<QGLContext*>(glWidget->context()); -} - -// returns the QGLPaintDevice for the given QPaintDevice -QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) -{ - QGLPaintDevice* glpd = 0; - - switch(pd->devType()) { - case QInternal::Widget: - // Should not be called on a non-gl widget: - Q_ASSERT(qobject_cast<QGLWidget*>(static_cast<QWidget*>(pd))); - glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice); - break; - case QInternal::Pbuffer: - glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice); - break; - case QInternal::FramebufferObject: - glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice); - break; - case QInternal::Pixmap: { - qWarning("Pixmap type not supported for GL rendering"); - break; - } - default: - qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); - break; - } - - return glpd; -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h deleted file mode 100644 index bfecdabd53..0000000000 --- a/src/opengl/qglpaintdevice_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLPAINTDEVICE_P_H -#define QGLPAINTDEVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of the Qt OpenGL module. This header file may change from -// version to version without notice, or even be removed. -// -// We mean it. -// - - -#include <qpaintdevice.h> -#include <QtOpenGL/qgl.h> - - -QT_BEGIN_NAMESPACE - -class Q_OPENGL_EXPORT QGLPaintDevice : public QPaintDevice -{ -public: - QGLPaintDevice(); - virtual ~QGLPaintDevice(); - - int devType() const override {return QInternal::OpenGL;} - - virtual void beginPaint(); - virtual void ensureActiveTarget(); - virtual void endPaint(); - - virtual QGLContext* context() const = 0; - virtual QGLFormat format() const; - virtual QSize size() const = 0; - virtual bool alphaRequested() const; - virtual bool isFlipped() const; - - // returns the QGLPaintDevice for the given QPaintDevice - static QGLPaintDevice* getDevice(QPaintDevice*); - -protected: - int metric(QPaintDevice::PaintDeviceMetric metric) const override; - GLuint m_previousFBO; - GLuint m_thisFBO; -}; - - -// Wraps a QGLWidget -class QGLWidget; -class Q_OPENGL_EXPORT QGLWidgetGLPaintDevice : public QGLPaintDevice -{ -public: - QGLWidgetGLPaintDevice(); - - virtual QPaintEngine* paintEngine() const override; - - // QGLWidgets need to do swapBufers in endPaint: - virtual void beginPaint() override; - virtual void endPaint() override; - virtual QSize size() const override; - virtual QGLContext* context() const override; - - void setWidget(QGLWidget*); - -private: - friend class QGLWidget; - QGLWidget *glWidget; -}; - -QT_END_NAMESPACE - -#endif // QGLPAINTDEVICE_P_H diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp deleted file mode 100644 index e2f434ac3c..0000000000 --- a/src/opengl/qglpixelbuffer.cpp +++ /dev/null @@ -1,654 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QGLPixelBuffer - \inmodule QtOpenGL - \brief The QGLPixelBuffer class encapsulates an OpenGL pbuffer. - \since 4.1 - \obsolete - - \ingroup painting-3D - - Rendering into a pbuffer is normally done using full hardware - acceleration. This can be significantly faster than rendering - into a QPixmap. - - There are three approaches to using this class: - - \list 1 - \li \b{We can draw into the pbuffer and convert it to a QImage - using toImage().} This is normally much faster than calling - QGLWidget::renderPixmap(). - - \li \b{We can draw into the pbuffer and copy the contents into - an OpenGL texture using updateDynamicTexture().} This allows - us to create dynamic textures and works on all systems - with pbuffer support. - - \li \b{On systems that support it, we can bind the pbuffer to - an OpenGL texture.} The texture is then updated automatically - when the pbuffer contents change, eliminating the need for - additional copy operations. This is supported only on Windows - and \macos systems that provide the \c render_texture - extension. Note that under Windows, a multi-sampled pbuffer - can't be used in conjunction with the \c render_texture - extension. If a multi-sampled pbuffer is requested under - Windows, the \c render_texture extension is turned off for that - pbuffer. - - - \endlist - - \note This class has been deprecated, use QOpenGLFramebufferObject - for offscreen rendering. - - \section1 Threading - - As of Qt 4.8, it's possible to render into a QGLPixelBuffer using - a QPainter in a separate thread. Note that OpenGL 2.0 or OpenGL ES - 2.0 is required for this to work. - - Pbuffers are provided by the OpenGL \c pbuffer extension; call - hasOpenGLPbuffer() to find out if the system provides pbuffers. -*/ - -#include <private/qopenglextensions_p.h> - -#include <QtCore/qglobal.h> -#include <QtGui/qopenglframebufferobject.h> - -#include "gl2paintengineex/qpaintengineex_opengl2_p.h" - -#include <qglframebufferobject.h> -#include <qglpixelbuffer.h> -#include <private/qglpixelbuffer_p.h> -#include <private/qfont_p.h> -#include <qimage.h> - -QT_BEGIN_NAMESPACE - -extern QImage qt_gl_read_frame_buffer(const QSize&, bool, bool); - - -QGLContext* QGLPBufferGLPaintDevice::context() const -{ - return pbuf->d_func()->qctx; -} - -void QGLPBufferGLPaintDevice::beginPaint() -{ - pbuf->makeCurrent(); - QGLPaintDevice::beginPaint(); -} - -void QGLPBufferGLPaintDevice::endPaint() -{ - QOpenGLContext::currentContext()->functions()->glFlush(); - QGLPaintDevice::endPaint(); -} - -void QGLPBufferGLPaintDevice::setFbo(GLuint fbo) -{ - m_thisFBO = fbo; -} - -void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) -{ - pbuf = pb; -} - -void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) -{ - Q_Q(QGLPixelBuffer); - if(init(size, format, shareWidget)) { - req_size = size; - req_format = format; - req_shareWidget = shareWidget; - invalid = false; - glDevice.setPBuffer(q); - } -} - -/*! - Constructs an OpenGL pbuffer of the given \a size. If no \a - format is specified, the \l{QGLFormat::defaultFormat()}{default - format} is used. If the \a shareWidget parameter points to a - valid QGLWidget, the pbuffer will share its context with \a - shareWidget. - - If you intend to bind this pbuffer as a dynamic texture, the width - and height components of \c size must be powers of two (e.g., 512 - x 128). - - \sa size(), format() -*/ -QGLPixelBuffer::QGLPixelBuffer(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) - : d_ptr(new QGLPixelBufferPrivate(this)) -{ - Q_D(QGLPixelBuffer); - d->common_init(size, format, shareWidget); -} - - -/*! \overload - - Constructs an OpenGL pbuffer with the \a width and \a height. If - no \a format is specified, the - \l{QGLFormat::defaultFormat()}{default format} is used. If the \a - shareWidget parameter points to a valid QGLWidget, the pbuffer - will share its context with \a shareWidget. - - If you intend to bind this pbuffer as a dynamic texture, the width - and height components of \c size must be powers of two (e.g., 512 - x 128). - - \sa size(), format() -*/ -QGLPixelBuffer::QGLPixelBuffer(int width, int height, const QGLFormat &format, QGLWidget *shareWidget) - : d_ptr(new QGLPixelBufferPrivate(this)) -{ - Q_D(QGLPixelBuffer); - d->common_init(QSize(width, height), format, shareWidget); -} - - -/*! \fn QGLPixelBuffer::~QGLPixelBuffer() - - Destroys the pbuffer and frees any allocated resources. -*/ -QGLPixelBuffer::~QGLPixelBuffer() -{ - Q_D(QGLPixelBuffer); - - // defined in qpaintengine_opengl.cpp - QGLContext *current = const_cast<QGLContext *>(QGLContext::currentContext()); - if (current != d->qctx) - makeCurrent(); - d->cleanup(); - if (current && current != d->qctx) - current->makeCurrent(); -} - -/*! \fn bool QGLPixelBuffer::makeCurrent() - - Makes this pbuffer the current OpenGL rendering context. Returns - true on success; otherwise returns \c false. - - \sa QGLContext::makeCurrent(), doneCurrent() -*/ - -bool QGLPixelBuffer::makeCurrent() -{ - Q_D(QGLPixelBuffer); - if (d->invalid) - return false; - d->qctx->makeCurrent(); - if (!d->fbo) { - QOpenGLFramebufferObjectFormat format; - if (d->req_format.stencil()) - format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - else if (d->req_format.depth()) - format.setAttachment(QOpenGLFramebufferObject::Depth); - if (d->req_format.sampleBuffers()) - format.setSamples(d->req_format.samples()); - d->fbo = new QOpenGLFramebufferObject(d->req_size, format); - d->fbo->bind(); - d->glDevice.setFbo(d->fbo->handle()); - QOpenGLContext::currentContext()->functions()->glViewport(0, 0, d->req_size.width(), d->req_size.height()); - } - return true; -} - -/*! \fn bool QGLPixelBuffer::doneCurrent() - - Makes no context the current OpenGL context. Returns \c true on - success; otherwise returns \c false. -*/ - -bool QGLPixelBuffer::doneCurrent() -{ - Q_D(QGLPixelBuffer); - if (d->invalid) - return false; - d->qctx->doneCurrent(); - return true; -} - -/*! - Returns the context of this pixelbuffer. -*/ -QGLContext *QGLPixelBuffer::context() const -{ - Q_D(const QGLPixelBuffer); - return d->qctx; -} - -/*! - \fn GLuint QGLPixelBuffer::generateDynamicTexture() const - - Generates and binds a 2D GL texture that is the same size as the - pbuffer, and returns the texture's ID. This can be used in - conjunction with bindToDynamicTexture() and - updateDynamicTexture(). - - \sa size() -*/ - -/*! \fn bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id) - - Binds the texture specified by \a texture_id to this pbuffer. - Returns \c true on success; otherwise returns \c false. - - The texture must be of the same size and format as the pbuffer. - - To unbind the texture, call releaseFromDynamicTexture(). While - the texture is bound, it is updated automatically when the - pbuffer contents change, eliminating the need for additional copy - operations. - - Example: - - \snippet code/src_opengl_qglpixelbuffer.cpp 0 - - \warning This function uses the \c {render_texture} extension, - which is currently not supported under X11. An alternative that - works on all systems (including X11) is to manually copy the - pbuffer contents to a texture using updateDynamicTexture(). - - \warning For the bindToDynamicTexture() call to succeed on the - \macos, the pbuffer needs a shared context, i.e. the - QGLPixelBuffer must be created with a share widget. - - \sa generateDynamicTexture(), releaseFromDynamicTexture() -*/ - -/*! \fn void QGLPixelBuffer::releaseFromDynamicTexture() - - Releases the pbuffer from any previously bound texture. - - \sa bindToDynamicTexture() -*/ - -/*! \fn bool QGLPixelBuffer::hasOpenGLPbuffers() - - Returns \c true if the OpenGL \c pbuffer extension is present on - this system; otherwise returns \c false. -*/ - -/*! - Copies the pbuffer contents into the texture specified with \a - texture_id. - - The texture must be of the same size and format as the pbuffer. - - Example: - - \snippet code/src_opengl_qglpixelbuffer.cpp 1 - - An alternative on Windows and \macos systems that support the - \c render_texture extension is to use bindToDynamicTexture() to - get dynamic updates of the texture. - - \sa generateDynamicTexture(), bindToDynamicTexture() -*/ -void QGLPixelBuffer::updateDynamicTexture(GLuint texture_id) const -{ - Q_D(const QGLPixelBuffer); - if (d->invalid || !d->fbo) - return; - - const QGLContext *ctx = QGLContext::currentContext(); - if (!ctx) - return; - -#undef glBindFramebuffer - -#ifndef GL_READ_FRAMEBUFFER -#define GL_READ_FRAMEBUFFER 0x8CA8 -#endif - -#ifndef GL_DRAW_FRAMEBUFFER -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#endif - - QOpenGLExtensions extensions(ctx->contextHandle()); - - ctx->d_ptr->refreshCurrentFbo(); - - if (d->blit_fbo) { - QOpenGLFramebufferObject::blitFramebuffer(d->blit_fbo, d->fbo); - extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, d->blit_fbo->handle()); - } - - extensions.glBindTexture(GL_TEXTURE_2D, texture_id); -#ifndef QT_OPENGL_ES - GLenum format = ctx->contextHandle()->isOpenGLES() ? GL_RGBA : GL_RGBA8; - extensions.glCopyTexImage2D(GL_TEXTURE_2D, 0, format, 0, 0, d->req_size.width(), d->req_size.height(), 0); -#else - extensions.glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, d->req_size.width(), d->req_size.height(), 0); -#endif - - if (d->blit_fbo) - extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, ctx->d_func()->current_fbo); -} - -/*! - Returns the size of the pbuffer. -*/ -QSize QGLPixelBuffer::size() const -{ - Q_D(const QGLPixelBuffer); - return d->req_size; -} - -/*! - Returns the contents of the pbuffer as a QImage. -*/ -QImage QGLPixelBuffer::toImage() const -{ - Q_D(const QGLPixelBuffer); - if (d->invalid) - return QImage(); - - const_cast<QGLPixelBuffer *>(this)->makeCurrent(); - if (d->fbo) - d->fbo->bind(); - return qt_gl_read_frame_buffer(d->req_size, d->format.alpha(), true); -} - -/*! - Returns the native pbuffer handle. -*/ -Qt::HANDLE QGLPixelBuffer::handle() const -{ - Q_D(const QGLPixelBuffer); - if (d->invalid) - return 0; - return (Qt::HANDLE) d->pbuf; -} - -/*! - Returns \c true if this pbuffer is valid; otherwise returns \c false. -*/ -bool QGLPixelBuffer::isValid() const -{ - Q_D(const QGLPixelBuffer); - return !d->invalid; -} - -Q_GLOBAL_STATIC(QGLEngineThreadStorage<QGL2PaintEngineEx>, qt_buffer_2_engine) - -/*! \reimp */ -QPaintEngine *QGLPixelBuffer::paintEngine() const -{ - return qt_buffer_2_engine()->engine(); -} - -/*! \reimp */ -int QGLPixelBuffer::metric(PaintDeviceMetric metric) const -{ - Q_D(const QGLPixelBuffer); - - float dpmx = qt_defaultDpiX()*100./2.54; - float dpmy = qt_defaultDpiY()*100./2.54; - int w = d->req_size.width(); - int h = d->req_size.height(); - switch (metric) { - case PdmWidth: - return w; - - case PdmHeight: - return h; - - case PdmWidthMM: - return qRound(w * 1000 / dpmx); - - case PdmHeightMM: - return qRound(h * 1000 / dpmy); - - case PdmNumColors: - return 0; - - case PdmDepth: - return 32;//d->depth; - - case PdmDpiX: - return qRound(dpmx * 0.0254); - - case PdmDpiY: - return qRound(dpmy * 0.0254); - - case PdmPhysicalDpiX: - return qRound(dpmx * 0.0254); - - case PdmPhysicalDpiY: - return qRound(dpmy * 0.0254); - - case QPaintDevice::PdmDevicePixelRatio: - return 1; - - case QPaintDevice::PdmDevicePixelRatioScaled: - return QPaintDevice::devicePixelRatioFScale(); - - default: - qWarning("QGLPixelBuffer::metric(), Unhandled metric type: %d\n", metric); - break; - } - return 0; -} - -/*! - Generates and binds a 2D GL texture to the current context, based - on \a image. The generated texture id is returned and can be used - in later glBindTexture() calls. - - The \a target parameter specifies the texture target. - - Equivalent to calling QGLContext::bindTexture(). - - \sa deleteTexture() -*/ -GLuint QGLPixelBuffer::bindTexture(const QImage &image, GLenum target) -{ - Q_D(QGLPixelBuffer); -#ifndef QT_OPENGL_ES - GLenum format = QOpenGLContext::currentContext()->isOpenGLES() ? GL_RGBA : GL_RGBA8; - return d->qctx->bindTexture(image, target, GLint(format)); -#else - return d->qctx->bindTexture(image, target, GL_RGBA); -#endif -} - -/*! \overload - - Generates and binds a 2D GL texture based on \a pixmap. - - Equivalent to calling QGLContext::bindTexture(). - - \sa deleteTexture() -*/ -GLuint QGLPixelBuffer::bindTexture(const QPixmap &pixmap, GLenum target) -{ - Q_D(QGLPixelBuffer); -#ifndef QT_OPENGL_ES - GLenum format = QOpenGLContext::currentContext()->isOpenGLES() ? GL_RGBA : GL_RGBA8; - return d->qctx->bindTexture(pixmap, target, GLint(format)); -#else - return d->qctx->bindTexture(pixmap, target, GL_RGBA); -#endif -} - -/*! \overload - - Reads the DirectDrawSurface (DDS) compressed file \a fileName and - generates a 2D GL texture from it. - - Equivalent to calling QGLContext::bindTexture(). - - \sa deleteTexture() -*/ -GLuint QGLPixelBuffer::bindTexture(const QString &fileName) -{ - Q_D(QGLPixelBuffer); - return d->qctx->bindTexture(fileName); -} - -/*! - Removes the texture identified by \a texture_id from the texture cache. - - Equivalent to calling QGLContext::deleteTexture(). - */ -void QGLPixelBuffer::deleteTexture(GLuint texture_id) -{ - Q_D(QGLPixelBuffer); - d->qctx->deleteTexture(texture_id); -} - -/*! - \since 4.4 - - Draws the given texture, \a textureId, to the given target rectangle, - \a target, in OpenGL model space. The \a textureTarget should be a 2D - texture target. - - Equivalent to the corresponding QGLContext::drawTexture(). -*/ -void QGLPixelBuffer::drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget) -{ - Q_D(QGLPixelBuffer); - d->qctx->drawTexture(target, textureId, textureTarget); -} - -/*! - \since 4.4 - - Draws the given texture, \a textureId, at the given \a point in OpenGL model - space. The textureTarget parameter should be a 2D texture target. - - Equivalent to the corresponding QGLContext::drawTexture(). -*/ -void QGLPixelBuffer::drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) -{ - Q_D(QGLPixelBuffer); - d->qctx->drawTexture(point, textureId, textureTarget); -} - -/*! - Returns the format of the pbuffer. The format may be different - from the one that was requested. -*/ -QGLFormat QGLPixelBuffer::format() const -{ - Q_D(const QGLPixelBuffer); - return d->format; -} - -/*! \fn int QGLPixelBuffer::devType() const - \internal -*/ - -bool QGLPixelBufferPrivate::init(const QSize &, const QGLFormat &f, QGLWidget *shareWidget) -{ - widget = new QGLWidget(f, 0, shareWidget); - widget->resize(1, 1); - qctx = const_cast<QGLContext *>(widget->context()); - return widget->isValid(); -} - -bool QGLPixelBufferPrivate::cleanup() -{ - delete fbo; - fbo = 0; - delete blit_fbo; - blit_fbo = 0; - delete widget; - widget = 0; - return true; -} - -bool QGLPixelBuffer::bindToDynamicTexture(GLuint texture_id) -{ - Q_UNUSED(texture_id); - return false; -} - -void QGLPixelBuffer::releaseFromDynamicTexture() -{ -} - -GLuint QGLPixelBuffer::generateDynamicTexture() const -{ - Q_D(const QGLPixelBuffer); - if (!d->fbo) - return 0; - - if (d->fbo->format().samples() > 0 - && QOpenGLExtensions(QOpenGLContext::currentContext()) - .hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)) - { - if (!d->blit_fbo) - const_cast<QOpenGLFramebufferObject *&>(d->blit_fbo) = new QOpenGLFramebufferObject(d->req_size); - } else { - return d->fbo->texture(); - } - - GLuint texture; - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - - funcs->glGenTextures(1, &texture); - funcs->glBindTexture(GL_TEXTURE_2D, texture); - - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, d->req_size.width(), d->req_size.height(), 0, - GL_RGBA, GL_UNSIGNED_BYTE, 0); - - return texture; -} - -bool QGLPixelBuffer::hasOpenGLPbuffers() -{ - return QGLFramebufferObject::hasOpenGLFramebufferObjects(); -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h deleted file mode 100644 index f5d7929c35..0000000000 --- a/src/opengl/qglpixelbuffer.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLPIXELBUFFER_H -#define QGLPIXELBUFFER_H - -#include <QtOpenGL/qgl.h> -#include <QtGui/qpaintdevice.h> - -QT_BEGIN_NAMESPACE - - -class QGLPixelBufferPrivate; - -class Q_OPENGL_EXPORT QGLPixelBuffer : public QPaintDevice -{ - Q_DECLARE_PRIVATE(QGLPixelBuffer) -public: - QGLPixelBuffer(const QSize &size, const QGLFormat &format = QGLFormat::defaultFormat(), - QGLWidget *shareWidget = nullptr); - QGLPixelBuffer(int width, int height, const QGLFormat &format = QGLFormat::defaultFormat(), - QGLWidget *shareWidget = nullptr); - virtual ~QGLPixelBuffer(); - - bool isValid() const; - bool makeCurrent(); - bool doneCurrent(); - - QGLContext *context() const; - - GLuint generateDynamicTexture() const; - bool bindToDynamicTexture(GLuint texture); - void releaseFromDynamicTexture(); - void updateDynamicTexture(GLuint texture_id) const; - - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D); - GLuint bindTexture(const QString &fileName); - void deleteTexture(GLuint texture_id); - - void drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - void drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D); - - QSize size() const; - Qt::HANDLE handle() const; - QImage toImage() const; - - QPaintEngine *paintEngine() const override; - QGLFormat format() const; - - static bool hasOpenGLPbuffers(); - -protected: - int metric(PaintDeviceMetric metric) const override; - int devType() const override { return QInternal::Pbuffer; } - -private: - Q_DISABLE_COPY(QGLPixelBuffer) - QScopedPointer<QGLPixelBufferPrivate> d_ptr; - friend class QGLDrawable; - friend class QGLPaintDevice; - friend class QGLPBufferGLPaintDevice; - friend class QGLContextPrivate; -}; - -QT_END_NAMESPACE - -#endif // QGLPIXELBUFFER_H diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h deleted file mode 100644 index 2729ade2b6..0000000000 --- a/src/opengl/qglpixelbuffer_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLPIXELBUFFER_P_H -#define QGLPIXELBUFFER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtOpenGL/qglpixelbuffer.h" -#include <private/qgl_p.h> -#include <private/qglpaintdevice_p.h> - -QT_BEGIN_NAMESPACE - -class QEglContext; -class QOpenGLFramebufferObject; - -class QGLPBufferGLPaintDevice : public QGLPaintDevice -{ -public: - QPaintEngine* paintEngine() const override {return pbuf->paintEngine();} - QSize size() const override {return pbuf->size();} - QGLContext* context() const override; - void beginPaint() override; - void endPaint() override; - void setPBuffer(QGLPixelBuffer* pb); - void setFbo(GLuint fbo); -private: - QGLPixelBuffer* pbuf; -}; - -class QGLPixelBufferPrivate { - Q_DECLARE_PUBLIC(QGLPixelBuffer) -public: - QGLPixelBufferPrivate(QGLPixelBuffer *q) : q_ptr(q), invalid(true), qctx(nullptr), widget(nullptr), fbo(nullptr), blit_fbo(nullptr), pbuf(nullptr), ctx(nullptr) - { - } - bool init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget); - void common_init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget); - bool cleanup(); - - QGLPixelBuffer *q_ptr; - bool invalid; - QGLContext *qctx; - QGLPBufferGLPaintDevice glDevice; - QGLWidget *widget; - QOpenGLFramebufferObject *fbo; - QOpenGLFramebufferObject *blit_fbo; - QGLFormat format; - - QGLFormat req_format; - QPointer<QGLWidget> req_shareWidget; - QSize req_size; - - //stubs - void *pbuf; - void *ctx; -}; - -QT_END_NAMESPACE - -#endif // QGLPIXELBUFFER_P_H diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp deleted file mode 100644 index 35f60318be..0000000000 --- a/src/opengl/qglshaderprogram.cpp +++ /dev/null @@ -1,3237 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglshaderprogram.h" -#include <private/qopenglextensions_p.h> -#include "qgl_p.h" -#include <QtCore/private/qobject_p.h> -#include <QtCore/qdebug.h> -#include <QtCore/qfile.h> -#include <QtCore/qvarlengtharray.h> -#include <QtCore/qvector.h> -#include <QDebug> - -QT_BEGIN_NAMESPACE - -/*! - \class QGLShaderProgram - \inmodule QtOpenGL - \brief The QGLShaderProgram class allows OpenGL shader programs to be linked and used. - \since 4.6 - \obsolete - \ingroup painting-3D - - \section1 Introduction - - This class supports shader programs written in the OpenGL Shading - Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES). - - QGLShader and QGLShaderProgram shelter the programmer from the details of - compiling and linking vertex and fragment shaders. - - The following example creates a vertex shader program using the - supplied source \c{code}. Once compiled and linked, the shader - program is activated in the current QGLContext by calling - QGLShaderProgram::bind(): - - \snippet code/src_opengl_qglshaderprogram.cpp 0 - - \section1 Writing Portable Shaders - - Shader programs can be difficult to reuse across OpenGL implementations - because of varying levels of support for standard vertex attributes and - uniform variables. In particular, GLSL/ES lacks all of the - standard variables that are present on desktop OpenGL systems: - \c{gl_Vertex}, \c{gl_Normal}, \c{gl_Color}, and so on. Desktop OpenGL - lacks the variable qualifiers \c{highp}, \c{mediump}, and \c{lowp}. - - The QGLShaderProgram class makes the process of writing portable shaders - easier by prefixing all shader programs with the following lines on - desktop OpenGL: - - \code - #define highp - #define mediump - #define lowp - \endcode - - This makes it possible to run most GLSL/ES shader programs - on desktop systems. The programmer should restrict themselves - to just features that are present in GLSL/ES, and avoid - standard variable names that only work on the desktop. - - \section1 Simple Shader Example - - \snippet code/src_opengl_qglshaderprogram.cpp 1 - - With the above shader program active, we can draw a green triangle - as follows: - - \snippet code/src_opengl_qglshaderprogram.cpp 2 - - \section1 Binary Shaders and Programs - - Binary shaders may be specified using \c{glShaderBinary()} on - the return value from QGLShader::shaderId(). The QGLShader instance - containing the binary can then be added to the shader program with - addShader() and linked in the usual fashion with link(). - - Binary programs may be specified using \c{glProgramBinaryOES()} - on the return value from programId(). Then the application should - call link(), which will notice that the program has already been - specified and linked, allowing other operations to be performed - on the shader program. - - \note This class has been deprecated in favor of QOpenGLShaderProgram. - - \sa QGLShader -*/ - -/*! - \class QGLShader - \inmodule QtOpenGL - \brief The QGLShader class allows OpenGL shaders to be compiled. - \since 4.6 - \obsolete - \ingroup painting-3D - - This class supports shaders written in the OpenGL Shading Language (GLSL) - and in the OpenGL/ES Shading Language (GLSL/ES). - - QGLShader and QGLShaderProgram shelter the programmer from the details of - compiling and linking vertex and fragment shaders. - - \note This class has been deprecated in favor of QOpenGLShader. - - \sa QGLShaderProgram -*/ - -/*! - \enum QGLShader::ShaderTypeBit - This enum specifies the type of QGLShader that is being created. - - \value Vertex Vertex shader written in the OpenGL Shading Language (GLSL). - \value Fragment Fragment shader written in the OpenGL Shading Language (GLSL). - \value Geometry Geometry shaders written in the OpenGL Shading - Language (GLSL), based on the GL_EXT_geometry_shader4 extension. -*/ - -#ifndef GL_FRAGMENT_SHADER -#define GL_FRAGMENT_SHADER 0x8B30 -#endif -#ifndef GL_VERTEX_SHADER -#define GL_VERTEX_SHADER 0x8B31 -#endif -#ifndef GL_COMPILE_STATUS -#define GL_COMPILE_STATUS 0x8B81 -#endif -#ifndef GL_LINK_STATUS -#define GL_LINK_STATUS 0x8B82 -#endif -#ifndef GL_INFO_LOG_LENGTH -#define GL_INFO_LOG_LENGTH 0x8B84 -#endif -#ifndef GL_ACTIVE_UNIFORMS -#define GL_ACTIVE_UNIFORMS 0x8B86 -#endif -#ifndef GL_ACTIVE_UNIFORM_MAX_LENGTH -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#endif -#ifndef GL_ACTIVE_ATTRIBUTES -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#endif -#ifndef GL_ACTIVE_ATTRIBUTE_MAX_LENGTH -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#endif -#ifndef GL_CURRENT_VERTEX_ATTRIB -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#endif -#ifndef GL_SHADER_SOURCE_LENGTH -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#endif -#ifndef GL_SHADER_BINARY_FORMATS -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#endif -#ifndef GL_NUM_SHADER_BINARY_FORMATS -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#endif - -class QGLShaderPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QGLShader) -public: - QGLShaderPrivate(const QGLContext *ctx, QGLShader::ShaderType type) - : shaderGuard(0) - , shaderType(type) - , compiled(false) - , glfuncs(new QOpenGLFunctions(ctx->contextHandle())) - { - } - ~QGLShaderPrivate(); - - QGLSharedResourceGuardBase *shaderGuard; - QGLShader::ShaderType shaderType; - bool compiled; - QString log; - - QOpenGLFunctions *glfuncs; - - bool create(); - bool compile(QGLShader *q); - void deleteShader(); -}; - -namespace { - void freeShaderFunc(QGLContext *ctx, GLuint id) - { - Q_ASSERT(ctx); - ctx->contextHandle()->functions()->glDeleteShader(id); - } -} - -#define ctx QGLContext::currentContext() - -QGLShaderPrivate::~QGLShaderPrivate() -{ - delete glfuncs; - if (shaderGuard) - shaderGuard->free(); -} - -bool QGLShaderPrivate::create() -{ - QGLContext *context = const_cast<QGLContext *>(QGLContext::currentContext()); - if (!context) - return false; - - if (glfuncs->hasOpenGLFeature(QOpenGLFunctions::Shaders)) { - GLuint shader; - if (shaderType == QGLShader::Vertex) - shader = glfuncs->glCreateShader(GL_VERTEX_SHADER); -#if !defined(QT_OPENGL_ES_2) - else if (shaderType == QGLShader::Geometry - && !context->contextHandle()->isOpenGLES()) - shader = glfuncs->glCreateShader(GL_GEOMETRY_SHADER_EXT); -#endif - else - shader = glfuncs->glCreateShader(GL_FRAGMENT_SHADER); - if (!shader) { - qWarning("Could not create shader of type %d.", int(shaderType)); - return false; - } - shaderGuard = createSharedResourceGuard(context, shader, freeShaderFunc); - return true; - } else { - return false; - } -} - -bool QGLShaderPrivate::compile(QGLShader *q) -{ - GLuint shader = shaderGuard ? shaderGuard->id() : 0; - if (!shader) - return false; - glfuncs->glCompileShader(shader); - GLint value = 0; - glfuncs->glGetShaderiv(shader, GL_COMPILE_STATUS, &value); - compiled = (value != 0); - value = 0; - glfuncs->glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &value); - if (!compiled && value > 1) { - char *logbuf = new char [value]; - GLint len; - glfuncs->glGetShaderInfoLog(shader, value, &len, logbuf); - log = QString::fromLatin1(logbuf); - QString name = q->objectName(); - - const char *types[] = { - "Fragment", - "Vertex", - "Geometry", - "" - }; - - const char *type = types[3]; - if (shaderType == QGLShader::Fragment) - type = types[0]; - else if (shaderType == QGLShader::Vertex) - type = types[1]; - else if (shaderType == QGLShader::Geometry) - type = types[2]; - - if (name.isEmpty()) - qWarning("QGLShader::compile(%s): %s", type, qPrintable(log)); - else - qWarning("QGLShader::compile(%s)[%s]: %s", type, qPrintable(name), qPrintable(log)); - - delete [] logbuf; - } - return compiled; -} - -void QGLShaderPrivate::deleteShader() -{ - if (shaderGuard) { - shaderGuard->free(); - shaderGuard = 0; - } -} - -/*! - Constructs a new QGLShader object of the specified \a type - and attaches it to \a parent. If shader programs are not supported, - QGLShaderProgram::hasOpenGLShaderPrograms() will return false. - - This constructor is normally followed by a call to compileSourceCode() - or compileSourceFile(). - - The shader will be associated with the current QGLContext. - - \sa compileSourceCode(), compileSourceFile() -*/ -QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) - : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) -{ - Q_D(QGLShader); - d->create(); -} - -/*! - Constructs a new QGLShader object of the specified \a type - and attaches it to \a parent. If shader programs are not supported, - then QGLShaderProgram::hasOpenGLShaderPrograms() will return false. - - This constructor is normally followed by a call to compileSourceCode() - or compileSourceFile(). - - The shader will be associated with \a context. - - \sa compileSourceCode(), compileSourceFile() -*/ -QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(*new QGLShaderPrivate(context ? context : QGLContext::currentContext(), type), parent) -{ - Q_D(QGLShader); -#ifndef QT_NO_DEBUG - if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { - qWarning("QGLShader::QGLShader: \'context\' must be the current context or sharing with it."); - return; - } -#endif - d->create(); -} - -/*! - Deletes this shader. If the shader has been attached to a - QGLShaderProgram object, then the actual shader will stay around - until the QGLShaderProgram is destroyed. -*/ -QGLShader::~QGLShader() -{ -} - -/*! - Returns the type of this shader. -*/ -QGLShader::ShaderType QGLShader::shaderType() const -{ - Q_D(const QGLShader); - return d->shaderType; -} - -// The precision qualifiers are useful on OpenGL/ES systems, -// but usually not present on desktop systems. Define the -// keywords to empty strings on desktop systems. -#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_FORCE_SHADER_DEFINES) -#define QGL_DEFINE_QUALIFIERS 1 -static const char qualifierDefines[] = - "#define lowp\n" - "#define mediump\n" - "#define highp\n"; - -#else - -// The "highp" qualifier doesn't exist in fragment shaders -// on all ES platforms. When it doesn't exist, use "mediump". -#define QGL_REDEFINE_HIGHP 1 -static const char redefineHighp[] = - "#ifndef GL_FRAGMENT_PRECISION_HIGH\n" - "#define highp mediump\n" - "#endif\n"; -#endif - -/*! - Sets the \a source code for this shader and compiles it. - Returns \c true if the source was successfully compiled, false otherwise. - - \sa compileSourceFile() -*/ -bool QGLShader::compileSourceCode(const char *source) -{ - Q_D(QGLShader); - if (d->shaderGuard && d->shaderGuard->id()) { - QVarLengthArray<const char *, 4> src; - QVarLengthArray<GLint, 4> srclen; - int headerLen = 0; - while (source && source[headerLen] == '#') { - // Skip #version and #extension directives at the start of - // the shader code. We need to insert the qualifierDefines - // and redefineHighp just after them. - if (qstrncmp(source + headerLen, "#version", 8) != 0 && - qstrncmp(source + headerLen, "#extension", 10) != 0) { - break; - } - while (source[headerLen] != '\0' && source[headerLen] != '\n') - ++headerLen; - if (source[headerLen] == '\n') - ++headerLen; - } - if (headerLen > 0) { - src.append(source); - srclen.append(GLint(headerLen)); - } -#ifdef QGL_DEFINE_QUALIFIERS - if (!QOpenGLContext::currentContext()->isOpenGLES()) { - src.append(qualifierDefines); - srclen.append(GLint(sizeof(qualifierDefines) - 1)); - } -#endif -#ifdef QGL_REDEFINE_HIGHP - if (d->shaderType == Fragment - && QOpenGLContext::currentContext()->isOpenGLES()) { - src.append(redefineHighp); - srclen.append(GLint(sizeof(redefineHighp) - 1)); - } -#endif - src.append(source + headerLen); - srclen.append(GLint(qstrlen(source + headerLen))); - d->glfuncs->glShaderSource(d->shaderGuard->id(), src.size(), src.data(), srclen.data()); - return d->compile(this); - } else { - return false; - } -} - -/*! - \overload - - Sets the \a source code for this shader and compiles it. - Returns \c true if the source was successfully compiled, false otherwise. - - \sa compileSourceFile() -*/ -bool QGLShader::compileSourceCode(const QByteArray& source) -{ - return compileSourceCode(source.constData()); -} - -/*! - \overload - - Sets the \a source code for this shader and compiles it. - Returns \c true if the source was successfully compiled, false otherwise. - - \sa compileSourceFile() -*/ -bool QGLShader::compileSourceCode(const QString& source) -{ - return compileSourceCode(source.toLatin1().constData()); -} - -/*! - Sets the source code for this shader to the contents of \a fileName - and compiles it. Returns \c true if the file could be opened and the - source compiled, false otherwise. - - \sa compileSourceCode() -*/ -bool QGLShader::compileSourceFile(const QString& fileName) -{ - QFile file(fileName); - if (!file.open(QFile::ReadOnly)) { - qWarning() << "QGLShader: Unable to open file" << fileName; - return false; - } - - QByteArray contents = file.readAll(); - return compileSourceCode(contents.constData()); -} - -/*! - Returns the source code for this shader. - - \sa compileSourceCode() -*/ -QByteArray QGLShader::sourceCode() const -{ - Q_D(const QGLShader); - GLuint shader = d->shaderGuard ? d->shaderGuard->id() : 0; - if (!shader) - return QByteArray(); - GLint size = 0; - d->glfuncs->glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &size); - if (size <= 0) - return QByteArray(); - GLint len = 0; - char *source = new char [size]; - d->glfuncs->glGetShaderSource(shader, size, &len, source); - QByteArray src(source); - delete [] source; - return src; -} - -/*! - Returns \c true if this shader has been compiled; false otherwise. - - \sa compileSourceCode(), compileSourceFile() -*/ -bool QGLShader::isCompiled() const -{ - Q_D(const QGLShader); - return d->compiled; -} - -/*! - Returns the errors and warnings that occurred during the last compile. - - \sa compileSourceCode(), compileSourceFile() -*/ -QString QGLShader::log() const -{ - Q_D(const QGLShader); - return d->log; -} - -/*! - Returns the OpenGL identifier associated with this shader. - - \sa QGLShaderProgram::programId() -*/ -GLuint QGLShader::shaderId() const -{ - Q_D(const QGLShader); - return d->shaderGuard ? d->shaderGuard->id() : 0; -} - -#undef ctx - -class ShaderProgramOpenGLFunctions : public QOpenGLFunctions -{ -public: - ShaderProgramOpenGLFunctions() - : QOpenGLFunctions() - , glProgramParameteri(0) - { - } - - typedef void (QOPENGLF_APIENTRYP type_glProgramParameteri)(GLuint program, GLenum pname, GLint value); - - void initializeGeometryShaderFunctions() - { - QOpenGLContext *context = QOpenGLContext::currentContext(); - if (!context->isOpenGLES()) { - glProgramParameteri = (type_glProgramParameteri) - context->getProcAddress("glProgramParameteri"); - - if (!glProgramParameteri) { - glProgramParameteri = (type_glProgramParameteri) - context->getProcAddress("glProgramParameteriEXT"); - } - } - } - - type_glProgramParameteri glProgramParameteri; -}; - -class QGLShaderProgramPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QGLShaderProgram) -public: - QGLShaderProgramPrivate(const QGLContext *) - : programGuard(0) - , linked(false) - , inited(false) - , removingShaders(false) - , geometryVertexCount(64) - , geometryInputType(0) - , geometryOutputType(0) - , glfuncs(new ShaderProgramOpenGLFunctions) - { - } - ~QGLShaderProgramPrivate(); - - QGLSharedResourceGuardBase *programGuard; - bool linked; - bool inited; - bool removingShaders; - - int geometryVertexCount; - GLenum geometryInputType; - GLenum geometryOutputType; - - QString log; - QList<QGLShader *> shaders; - QList<QGLShader *> anonShaders; - - ShaderProgramOpenGLFunctions *glfuncs; - - bool hasShader(QGLShader::ShaderType type) const; -}; - -namespace { - void freeProgramFunc(QGLContext *ctx, GLuint id) - { - Q_ASSERT(ctx); - ctx->contextHandle()->functions()->glDeleteProgram(id); - } -} - - -QGLShaderProgramPrivate::~QGLShaderProgramPrivate() -{ - delete glfuncs; - if (programGuard) - programGuard->free(); -} - -bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const -{ - for (QGLShader *shader : shaders) { - if (shader->shaderType() == type) - return true; - } - return false; -} - -#define ctx QGLContext::currentContext() - -/*! - Constructs a new shader program and attaches it to \a parent. - The program will be invalid until addShader() is called. - - The shader program will be associated with the current QGLContext. - - \sa addShader() -*/ -QGLShaderProgram::QGLShaderProgram(QObject *parent) - : QObject(*new QGLShaderProgramPrivate(QGLContext::currentContext()), parent) -{ -} - -/*! - Constructs a new shader program and attaches it to \a parent. - The program will be invalid until addShader() is called. - - The shader program will be associated with \a context. - - \sa addShader() -*/ -QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) - : QObject(*new QGLShaderProgramPrivate(context), parent) -{ -} - -/*! - Deletes this shader program. -*/ -QGLShaderProgram::~QGLShaderProgram() -{ -} - -bool QGLShaderProgram::init() -{ - Q_D(QGLShaderProgram); - if ((d->programGuard && d->programGuard->id()) || d->inited) - return true; - d->inited = true; - QGLContext *context = const_cast<QGLContext *>(QGLContext::currentContext()); - if (!context) - return false; - d->glfuncs->initializeOpenGLFunctions(); - d->glfuncs->initializeGeometryShaderFunctions(); - if (d->glfuncs->hasOpenGLFeature(QOpenGLFunctions::Shaders)) { - GLuint program = d->glfuncs->glCreateProgram(); - if (!program) { - qWarning("QGLShaderProgram: could not create shader program"); - return false; - } - if (d->programGuard) - delete d->programGuard; - d->programGuard = createSharedResourceGuard(context, program, freeProgramFunc); - return true; - } else { - qWarning("QGLShaderProgram: shader programs are not supported"); - return false; - } -} - -/*! - Adds a compiled \a shader to this shader program. Returns \c true - if the shader could be added, or false otherwise. - - Ownership of the \a shader object remains with the caller. - It will not be deleted when this QGLShaderProgram instance - is deleted. This allows the caller to add the same shader - to multiple shader programs. - - \sa addShaderFromSourceCode(), addShaderFromSourceFile() - \sa removeShader(), link(), removeAllShaders() -*/ -bool QGLShaderProgram::addShader(QGLShader *shader) -{ - Q_D(QGLShaderProgram); - if (!init()) - return false; - if (d->shaders.contains(shader)) - return true; // Already added to this shader program. - if (d->programGuard && d->programGuard->id() && shader) { - if (!shader->d_func()->shaderGuard || !shader->d_func()->shaderGuard->id()) - return false; - if (d->programGuard->group() != shader->d_func()->shaderGuard->group()) { - qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); - return false; - } - d->glfuncs->glAttachShader(d->programGuard->id(), shader->d_func()->shaderGuard->id()); - d->linked = false; // Program needs to be relinked. - d->shaders.append(shader); - connect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); - return true; - } else { - return false; - } -} - -/*! - Compiles \a source as a shader of the specified \a type and - adds it to this shader program. Returns \c true if compilation - was successful, false otherwise. The compilation errors - and warnings will be made available via log(). - - This function is intended to be a short-cut for quickly - adding vertex and fragment shaders to a shader program without - creating an instance of QGLShader first. - - \sa addShader(), addShaderFromSourceFile() - \sa removeShader(), link(), log(), removeAllShaders() -*/ -bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const char *source) -{ - Q_D(QGLShaderProgram); - if (!init()) - return false; - QGLShader *shader = new QGLShader(type, this); - if (!shader->compileSourceCode(source)) { - d->log = shader->log(); - delete shader; - return false; - } - d->anonShaders.append(shader); - return addShader(shader); -} - -/*! - \overload - - Compiles \a source as a shader of the specified \a type and - adds it to this shader program. Returns \c true if compilation - was successful, false otherwise. The compilation errors - and warnings will be made available via log(). - - This function is intended to be a short-cut for quickly - adding vertex and fragment shaders to a shader program without - creating an instance of QGLShader first. - - \sa addShader(), addShaderFromSourceFile() - \sa removeShader(), link(), log(), removeAllShaders() -*/ -bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const QByteArray& source) -{ - return addShaderFromSourceCode(type, source.constData()); -} - -/*! - \overload - - Compiles \a source as a shader of the specified \a type and - adds it to this shader program. Returns \c true if compilation - was successful, false otherwise. The compilation errors - and warnings will be made available via log(). - - This function is intended to be a short-cut for quickly - adding vertex and fragment shaders to a shader program without - creating an instance of QGLShader first. - - \sa addShader(), addShaderFromSourceFile() - \sa removeShader(), link(), log(), removeAllShaders() -*/ -bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const QString& source) -{ - return addShaderFromSourceCode(type, source.toLatin1().constData()); -} - -/*! - Compiles the contents of \a fileName as a shader of the specified - \a type and adds it to this shader program. Returns \c true if - compilation was successful, false otherwise. The compilation errors - and warnings will be made available via log(). - - This function is intended to be a short-cut for quickly - adding vertex and fragment shaders to a shader program without - creating an instance of QGLShader first. - - \sa addShader(), addShaderFromSourceCode() -*/ -bool QGLShaderProgram::addShaderFromSourceFile - (QGLShader::ShaderType type, const QString& fileName) -{ - Q_D(QGLShaderProgram); - if (!init()) - return false; - QGLShader *shader = new QGLShader(type, this); - if (!shader->compileSourceFile(fileName)) { - d->log = shader->log(); - delete shader; - return false; - } - d->anonShaders.append(shader); - return addShader(shader); -} - -/*! - Removes \a shader from this shader program. The object is not deleted. - - The shader program must be valid in the current QGLContext. - - \sa addShader(), link(), removeAllShaders() -*/ -void QGLShaderProgram::removeShader(QGLShader *shader) -{ - Q_D(QGLShaderProgram); - if (d->programGuard && d->programGuard->id() - && shader && shader->d_func()->shaderGuard) - { - d->glfuncs->glDetachShader(d->programGuard->id(), shader->d_func()->shaderGuard->id()); - } - d->linked = false; // Program needs to be relinked. - if (shader) { - d->shaders.removeAll(shader); - d->anonShaders.removeAll(shader); - disconnect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); - } -} - -/*! - Returns a list of all shaders that have been added to this shader - program using addShader(). - - \sa addShader(), removeShader() -*/ -QList<QGLShader *> QGLShaderProgram::shaders() const -{ - Q_D(const QGLShaderProgram); - return d->shaders; -} - -/*! - Removes all of the shaders that were added to this program previously. - The QGLShader objects for the shaders will not be deleted if they - were constructed externally. QGLShader objects that are constructed - internally by QGLShaderProgram will be deleted. - - \sa addShader(), removeShader() -*/ -void QGLShaderProgram::removeAllShaders() -{ - Q_D(QGLShaderProgram); - d->removingShaders = true; - if (d->programGuard) { - if (const auto programGuardId = d->programGuard->id()) { - for (QGLShader *shader : qAsConst(d->shaders)) { - if (shader && shader->d_func()->shaderGuard) - d->glfuncs->glDetachShader(programGuardId, shader->d_func()->shaderGuard->id()); - } - } - } - // Delete shader objects that were created anonymously. - qDeleteAll(d->anonShaders); - d->shaders.clear(); - d->anonShaders.clear(); - d->linked = false; // Program needs to be relinked. - d->removingShaders = false; -} - -/*! - Links together the shaders that were added to this program with - addShader(). Returns \c true if the link was successful or - false otherwise. If the link failed, the error messages can - be retrieved with log(). - - Subclasses can override this function to initialize attributes - and uniform variables for use in specific shader programs. - - If the shader program was already linked, calling this - function again will force it to be re-linked. - - \sa addShader(), log() -*/ -bool QGLShaderProgram::link() -{ - Q_D(QGLShaderProgram); - GLuint program = d->programGuard ? d->programGuard->id() : 0; - if (!program) - return false; - - GLint value; - if (d->shaders.isEmpty()) { - // If there are no explicit shaders, then it is possible that the - // application added a program binary with glProgramBinaryOES(), - // or otherwise populated the shaders itself. Check to see if the - // program is already linked and bail out if so. - value = 0; - d->glfuncs->glGetProgramiv(program, GL_LINK_STATUS, &value); - d->linked = (value != 0); - if (d->linked) - return true; - } - -#if !defined(QT_OPENGL_ES_2) - // Set up the geometry shader parameters - if (!QOpenGLContext::currentContext()->isOpenGLES() - && d->glfuncs->glProgramParameteri) { - for (QGLShader *shader : qAsConst(d->shaders)) { - if (shader->shaderType() & QGLShader::Geometry) { - d->glfuncs->glProgramParameteri(program, GL_GEOMETRY_INPUT_TYPE_EXT, - d->geometryInputType); - d->glfuncs->glProgramParameteri(program, GL_GEOMETRY_OUTPUT_TYPE_EXT, - d->geometryOutputType); - d->glfuncs->glProgramParameteri(program, GL_GEOMETRY_VERTICES_OUT_EXT, - d->geometryVertexCount); - break; - } - } - } -#endif - - d->glfuncs->glLinkProgram(program); - value = 0; - d->glfuncs->glGetProgramiv(program, GL_LINK_STATUS, &value); - d->linked = (value != 0); - value = 0; - d->glfuncs->glGetProgramiv(program, GL_INFO_LOG_LENGTH, &value); - d->log = QString(); - if (value > 1) { - char *logbuf = new char [value]; - GLint len; - d->glfuncs->glGetProgramInfoLog(program, value, &len, logbuf); - d->log = QString::fromLatin1(logbuf); - QString name = objectName(); - if (!d->linked) { - if (name.isEmpty()) - qWarning() << "QGLShader::link:" << d->log; - else - qWarning() << "QGLShader::link[" << name << "]:" << d->log; - } - delete [] logbuf; - } - return d->linked; -} - -/*! - Returns \c true if this shader program has been linked; false otherwise. - - \sa link() -*/ -bool QGLShaderProgram::isLinked() const -{ - Q_D(const QGLShaderProgram); - return d->linked; -} - -/*! - Returns the errors and warnings that occurred during the last link() - or addShader() with explicitly specified source code. - - \sa link() -*/ -QString QGLShaderProgram::log() const -{ - Q_D(const QGLShaderProgram); - return d->log; -} - -/*! - Binds this shader program to the active QGLContext and makes - it the current shader program. Any previously bound shader program - is released. This is equivalent to calling \c{glUseProgram()} on - programId(). Returns \c true if the program was successfully bound; - false otherwise. If the shader program has not yet been linked, - or it needs to be re-linked, this function will call link(). - - \sa link(), release() -*/ -bool QGLShaderProgram::bind() -{ - Q_D(QGLShaderProgram); - GLuint program = d->programGuard ? d->programGuard->id() : 0; - if (!program) - return false; - if (!d->linked && !link()) - return false; -#ifndef QT_NO_DEBUG - if (d->programGuard->group() != QOpenGLContextGroup::currentContextGroup()) { - qWarning("QGLShaderProgram::bind: program is not valid in the current context."); - return false; - } -#endif - d->glfuncs->glUseProgram(program); - return true; -} - -#undef ctx -#define ctx QGLContext::currentContext() - -/*! - Releases the active shader program from the current QGLContext. - This is equivalent to calling \c{glUseProgram(0)}. - - \sa bind() -*/ -void QGLShaderProgram::release() -{ - Q_D(QGLShaderProgram); -#ifndef QT_NO_DEBUG - if (d->programGuard && d->programGuard->group() != QOpenGLContextGroup::currentContextGroup()) - qWarning("QGLShaderProgram::release: program is not valid in the current context."); -#endif - d->glfuncs->glUseProgram(0); -} - -/*! - Returns the OpenGL identifier associated with this shader program. - - \sa QGLShader::shaderId() -*/ -GLuint QGLShaderProgram::programId() const -{ - Q_D(const QGLShaderProgram); - GLuint id = d->programGuard ? d->programGuard->id() : 0; - if (id) - return id; - - // Create the identifier if we don't have one yet. This is for - // applications that want to create the attached shader configuration - // themselves, particularly those using program binaries. - if (!const_cast<QGLShaderProgram *>(this)->init()) - return 0; - return d->programGuard ? d->programGuard->id() : 0; -} - -/*! - Binds the attribute \a name to the specified \a location. This - function can be called before or after the program has been linked. - Any attributes that have not been explicitly bound when the program - is linked will be assigned locations automatically. - - When this function is called after the program has been linked, - the program will need to be relinked for the change to take effect. - - \sa attributeLocation() -*/ -void QGLShaderProgram::bindAttributeLocation(const char *name, int location) -{ - Q_D(QGLShaderProgram); - if (!init() || !d->programGuard || !d->programGuard->id()) - return; - d->glfuncs->glBindAttribLocation(d->programGuard->id(), location, name); - d->linked = false; // Program needs to be relinked. -} - -/*! - \overload - - Binds the attribute \a name to the specified \a location. This - function can be called before or after the program has been linked. - Any attributes that have not been explicitly bound when the program - is linked will be assigned locations automatically. - - When this function is called after the program has been linked, - the program will need to be relinked for the change to take effect. - - \sa attributeLocation() -*/ -void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location) -{ - bindAttributeLocation(name.constData(), location); -} - -/*! - \overload - - Binds the attribute \a name to the specified \a location. This - function can be called before or after the program has been linked. - Any attributes that have not been explicitly bound when the program - is linked will be assigned locations automatically. - - When this function is called after the program has been linked, - the program will need to be relinked for the change to take effect. - - \sa attributeLocation() -*/ -void QGLShaderProgram::bindAttributeLocation(const QString& name, int location) -{ - bindAttributeLocation(name.toLatin1().constData(), location); -} - -/*! - Returns the location of the attribute \a name within this shader - program's parameter list. Returns -1 if \a name is not a valid - attribute for this shader program. - - \sa uniformLocation(), bindAttributeLocation() -*/ -int QGLShaderProgram::attributeLocation(const char *name) const -{ - Q_D(const QGLShaderProgram); - if (d->linked && d->programGuard && d->programGuard->id()) { - return d->glfuncs->glGetAttribLocation(d->programGuard->id(), name); - } else { - qWarning() << "QGLShaderProgram::attributeLocation(" << name - << "): shader program is not linked"; - return -1; - } -} - -/*! - \overload - - Returns the location of the attribute \a name within this shader - program's parameter list. Returns -1 if \a name is not a valid - attribute for this shader program. - - \sa uniformLocation(), bindAttributeLocation() -*/ -int QGLShaderProgram::attributeLocation(const QByteArray& name) const -{ - return attributeLocation(name.constData()); -} - -/*! - \overload - - Returns the location of the attribute \a name within this shader - program's parameter list. Returns -1 if \a name is not a valid - attribute for this shader program. - - \sa uniformLocation(), bindAttributeLocation() -*/ -int QGLShaderProgram::attributeLocation(const QString& name) const -{ - return attributeLocation(name.toLatin1().constData()); -} - -/*! - Sets the attribute at \a location in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(int location, GLfloat value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glVertexAttrib1fv(location, &value); -} - -/*! - \overload - - Sets the attribute called \a name in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value) -{ - setAttributeValue(attributeLocation(name), value); -} - -/*! - Sets the attribute at \a location in the current context to - the 2D vector (\a x, \a y). - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[2] = {x, y}; - d->glfuncs->glVertexAttrib2fv(location, values); - } -} - -/*! - \overload - - Sets the attribute called \a name in the current context to - the 2D vector (\a x, \a y). - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y) -{ - setAttributeValue(attributeLocation(name), x, y); -} - -/*! - Sets the attribute at \a location in the current context to - the 3D vector (\a x, \a y, \a z). - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue - (int location, GLfloat x, GLfloat y, GLfloat z) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[3] = {x, y, z}; - d->glfuncs->glVertexAttrib3fv(location, values); - } -} - -/*! - \overload - - Sets the attribute called \a name in the current context to - the 3D vector (\a x, \a y, \a z). - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue - (const char *name, GLfloat x, GLfloat y, GLfloat z) -{ - setAttributeValue(attributeLocation(name), x, y, z); -} - -/*! - Sets the attribute at \a location in the current context to - the 4D vector (\a x, \a y, \a z, \a w). - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue - (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {x, y, z, w}; - d->glfuncs->glVertexAttrib4fv(location, values); - } -} - -/*! - \overload - - Sets the attribute called \a name in the current context to - the 4D vector (\a x, \a y, \a z, \a w). - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue - (const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - setAttributeValue(attributeLocation(name), x, y, z, w); -} - -/*! - Sets the attribute at \a location in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glVertexAttrib2fv(location, reinterpret_cast<const GLfloat *>(&value)); -} - -/*! - \overload - - Sets the attribute called \a name in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& value) -{ - setAttributeValue(attributeLocation(name), value); -} - -/*! - Sets the attribute at \a location in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glVertexAttrib3fv(location, reinterpret_cast<const GLfloat *>(&value)); -} - -/*! - \overload - - Sets the attribute called \a name in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& value) -{ - setAttributeValue(attributeLocation(name), value); -} - -/*! - Sets the attribute at \a location in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glVertexAttrib4fv(location, reinterpret_cast<const GLfloat *>(&value)); -} - -/*! - \overload - - Sets the attribute called \a name in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& value) -{ - setAttributeValue(attributeLocation(name), value); -} - -/*! - Sets the attribute at \a location in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(int location, const QColor& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {GLfloat(value.redF()), GLfloat(value.greenF()), - GLfloat(value.blueF()), GLfloat(value.alphaF())}; - d->glfuncs->glVertexAttrib4fv(location, values); - } -} - -/*! - \overload - - Sets the attribute called \a name in the current context to \a value. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue(const char *name, const QColor& value) -{ - setAttributeValue(attributeLocation(name), value); -} - -/*! - Sets the attribute at \a location in the current context to the - contents of \a values, which contains \a columns elements, each - consisting of \a rows elements. The \a rows value should be - 1, 2, 3, or 4. This function is typically used to set matrix - values and column vectors. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue - (int location, const GLfloat *values, int columns, int rows) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (rows < 1 || rows > 4) { - qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; - return; - } - if (location != -1) { - while (columns-- > 0) { - if (rows == 1) - d->glfuncs->glVertexAttrib1fv(location, values); - else if (rows == 2) - d->glfuncs->glVertexAttrib2fv(location, values); - else if (rows == 3) - d->glfuncs->glVertexAttrib3fv(location, values); - else - d->glfuncs->glVertexAttrib4fv(location, values); - values += rows; - ++location; - } - } -} - -/*! - \overload - - Sets the attribute called \a name in the current context to the - contents of \a values, which contains \a columns elements, each - consisting of \a rows elements. The \a rows value should be - 1, 2, 3, or 4. This function is typically used to set matrix - values and column vectors. - - \sa setUniformValue() -*/ -void QGLShaderProgram::setAttributeValue - (const char *name, const GLfloat *values, int columns, int rows) -{ - setAttributeValue(attributeLocation(name), values, columns, rows); -} - -/*! - Sets an array of vertex \a values on the attribute at \a location - in this shader program. The \a tupleSize indicates the number of - components per vertex (1, 2, 3, or 4), and the \a stride indicates - the number of bytes between vertices. A default \a stride value - of zero indicates that the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on the \a location. Otherwise the value specified with - setAttributeValue() for \a location will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (int location, const GLfloat *values, int tupleSize, int stride) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - d->glfuncs->glVertexAttribPointer(location, tupleSize, GL_FLOAT, GL_FALSE, - stride, values); - } -} - -/*! - Sets an array of 2D vertex \a values on the attribute at \a location - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on the \a location. Otherwise the value specified with - setAttributeValue() for \a location will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (int location, const QVector2D *values, int stride) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - d->glfuncs->glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, - stride, values); - } -} - -/*! - Sets an array of 3D vertex \a values on the attribute at \a location - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on the \a location. Otherwise the value specified with - setAttributeValue() for \a location will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (int location, const QVector3D *values, int stride) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - d->glfuncs->glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, - stride, values); - } -} - -/*! - Sets an array of 4D vertex \a values on the attribute at \a location - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on the \a location. Otherwise the value specified with - setAttributeValue() for \a location will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (int location, const QVector4D *values, int stride) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - d->glfuncs->glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, - stride, values); - } -} - -/*! - Sets an array of vertex \a values on the attribute at \a location - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The \a type indicates the type of elements in the \a values array, - usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a tupleSize - indicates the number of components per vertex: 1, 2, 3, or 4. - - The array will become active when enableAttributeArray() is called - on the \a location. Otherwise the value specified with - setAttributeValue() for \a location will be used. - - The setAttributeBuffer() function can be used to set the attribute - array to an offset within a vertex buffer. - - \note Normalization will be enabled. If this is not desired, call - glVertexAttribPointer directly through QGLFunctions. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray(), setAttributeBuffer() - \since 4.7 -*/ -void QGLShaderProgram::setAttributeArray - (int location, GLenum type, const void *values, int tupleSize, int stride) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - d->glfuncs->glVertexAttribPointer(location, tupleSize, type, GL_TRUE, - stride, values); - } -} - -/*! - \overload - - Sets an array of vertex \a values on the attribute called \a name - in this shader program. The \a tupleSize indicates the number of - components per vertex (1, 2, 3, or 4), and the \a stride indicates - the number of bytes between vertices. A default \a stride value - of zero indicates that the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on \a name. Otherwise the value specified with setAttributeValue() - for \a name will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (const char *name, const GLfloat *values, int tupleSize, int stride) -{ - setAttributeArray(attributeLocation(name), values, tupleSize, stride); -} - -/*! - \overload - - Sets an array of 2D vertex \a values on the attribute called \a name - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on \a name. Otherwise the value specified with setAttributeValue() - for \a name will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (const char *name, const QVector2D *values, int stride) -{ - setAttributeArray(attributeLocation(name), values, stride); -} - -/*! - \overload - - Sets an array of 3D vertex \a values on the attribute called \a name - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on \a name. Otherwise the value specified with setAttributeValue() - for \a name will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (const char *name, const QVector3D *values, int stride) -{ - setAttributeArray(attributeLocation(name), values, stride); -} - -/*! - \overload - - Sets an array of 4D vertex \a values on the attribute called \a name - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The array will become active when enableAttributeArray() is called - on \a name. Otherwise the value specified with setAttributeValue() - for \a name will be used. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray() -*/ -void QGLShaderProgram::setAttributeArray - (const char *name, const QVector4D *values, int stride) -{ - setAttributeArray(attributeLocation(name), values, stride); -} - -/*! - \overload - - Sets an array of vertex \a values on the attribute called \a name - in this shader program. The \a stride indicates the number of bytes - between vertices. A default \a stride value of zero indicates that - the vertices are densely packed in \a values. - - The \a type indicates the type of elements in the \a values array, - usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a tupleSize - indicates the number of components per vertex: 1, 2, 3, or 4. - - The array will become active when enableAttributeArray() is called - on the \a name. Otherwise the value specified with - setAttributeValue() for \a name will be used. - - The setAttributeBuffer() function can be used to set the attribute - array to an offset within a vertex buffer. - - \sa setAttributeValue(), setUniformValue(), enableAttributeArray() - \sa disableAttributeArray(), setAttributeBuffer() - \since 4.7 -*/ -void QGLShaderProgram::setAttributeArray - (const char *name, GLenum type, const void *values, int tupleSize, int stride) -{ - setAttributeArray(attributeLocation(name), type, values, tupleSize, stride); -} - -/*! - Sets an array of vertex values on the attribute at \a location in - this shader program, starting at a specific \a offset in the - currently bound vertex buffer. The \a stride indicates the number - of bytes between vertices. A default \a stride value of zero - indicates that the vertices are densely packed in the value array. - - The \a type indicates the type of elements in the vertex value - array, usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a - tupleSize indicates the number of components per vertex: 1, 2, 3, - or 4. - - The array will become active when enableAttributeArray() is called - on the \a location. Otherwise the value specified with - setAttributeValue() for \a location will be used. - - \note Normalization will be enabled. If this is not desired, call - glVertexAttribPointer directly though QGLFunctions. - - \sa setAttributeArray() - \since 4.7 -*/ -void QGLShaderProgram::setAttributeBuffer - (int location, GLenum type, int offset, int tupleSize, int stride) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - d->glfuncs->glVertexAttribPointer(location, tupleSize, type, GL_TRUE, stride, - reinterpret_cast<const void *>(qintptr(offset))); - } -} - -/*! - \overload - - Sets an array of vertex values on the attribute called \a name - in this shader program, starting at a specific \a offset in the - currently bound vertex buffer. The \a stride indicates the number - of bytes between vertices. A default \a stride value of zero - indicates that the vertices are densely packed in the value array. - - The \a type indicates the type of elements in the vertex value - array, usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a - tupleSize indicates the number of components per vertex: 1, 2, 3, - or 4. - - The array will become active when enableAttributeArray() is called - on the \a name. Otherwise the value specified with - setAttributeValue() for \a name will be used. - - \sa setAttributeArray() - \since 4.7 -*/ -void QGLShaderProgram::setAttributeBuffer - (const char *name, GLenum type, int offset, int tupleSize, int stride) -{ - setAttributeBuffer(attributeLocation(name), type, offset, tupleSize, stride); -} - -/*! - Enables the vertex array at \a location in this shader program - so that the value set by setAttributeArray() on \a location - will be used by the shader program. - - \sa disableAttributeArray(), setAttributeArray(), setAttributeValue() - \sa setUniformValue() -*/ -void QGLShaderProgram::enableAttributeArray(int location) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glEnableVertexAttribArray(location); -} - -/*! - \overload - - Enables the vertex array called \a name in this shader program - so that the value set by setAttributeArray() on \a name - will be used by the shader program. - - \sa disableAttributeArray(), setAttributeArray(), setAttributeValue() - \sa setUniformValue() -*/ -void QGLShaderProgram::enableAttributeArray(const char *name) -{ - enableAttributeArray(attributeLocation(name)); -} - -/*! - Disables the vertex array at \a location in this shader program - that was enabled by a previous call to enableAttributeArray(). - - \sa enableAttributeArray(), setAttributeArray(), setAttributeValue() - \sa setUniformValue() -*/ -void QGLShaderProgram::disableAttributeArray(int location) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glDisableVertexAttribArray(location); -} - -/*! - \overload - - Disables the vertex array called \a name in this shader program - that was enabled by a previous call to enableAttributeArray(). - - \sa enableAttributeArray(), setAttributeArray(), setAttributeValue() - \sa setUniformValue() -*/ -void QGLShaderProgram::disableAttributeArray(const char *name) -{ - disableAttributeArray(attributeLocation(name)); -} - -/*! - Returns the location of the uniform variable \a name within this shader - program's parameter list. Returns -1 if \a name is not a valid - uniform variable for this shader program. - - \sa attributeLocation() -*/ -int QGLShaderProgram::uniformLocation(const char *name) const -{ - Q_D(const QGLShaderProgram); - Q_UNUSED(d); - if (d->linked && d->programGuard && d->programGuard->id()) { - return d->glfuncs->glGetUniformLocation(d->programGuard->id(), name); - } else { - qWarning() << "QGLShaderProgram::uniformLocation(" << name - << "): shader program is not linked"; - return -1; - } -} - -/*! - \overload - - Returns the location of the uniform variable \a name within this shader - program's parameter list. Returns -1 if \a name is not a valid - uniform variable for this shader program. - - \sa attributeLocation() -*/ -int QGLShaderProgram::uniformLocation(const QByteArray& name) const -{ - return uniformLocation(name.constData()); -} - -/*! - \overload - - Returns the location of the uniform variable \a name within this shader - program's parameter list. Returns -1 if \a name is not a valid - uniform variable for this shader program. - - \sa attributeLocation() -*/ -int QGLShaderProgram::uniformLocation(const QString& name) const -{ - return uniformLocation(name.toLatin1().constData()); -} - -/*! - Sets the uniform variable at \a location in the current context to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, GLfloat value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform1fv(location, 1, &value); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, GLfloat value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, GLint value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform1i(location, value); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, GLint value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to \a value. - This function should be used when setting sampler values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, GLuint value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform1i(location, value); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to \a value. This function should be used when setting sampler values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, GLuint value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to - the 2D vector (\a x, \a y). - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[2] = {x, y}; - d->glfuncs->glUniform2fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context to - the 2D vector (\a x, \a y). - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y) -{ - setUniformValue(uniformLocation(name), x, y); -} - -/*! - Sets the uniform variable at \a location in the current context to - the 3D vector (\a x, \a y, \a z). - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue - (int location, GLfloat x, GLfloat y, GLfloat z) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[3] = {x, y, z}; - d->glfuncs->glUniform3fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context to - the 3D vector (\a x, \a y, \a z). - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue - (const char *name, GLfloat x, GLfloat y, GLfloat z) -{ - setUniformValue(uniformLocation(name), x, y, z); -} - -/*! - Sets the uniform variable at \a location in the current context to - the 4D vector (\a x, \a y, \a z, \a w). - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue - (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {x, y, z, w}; - d->glfuncs->glUniform4fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context to - the 4D vector (\a x, \a y, \a z, \a w). - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue - (const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) -{ - setUniformValue(uniformLocation(name), x, y, z, w); -} - -/*! - Sets the uniform variable at \a location in the current context to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QVector2D& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform2fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QVector3D& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform3fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QVector4D& value) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform4fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to - the red, green, blue, and alpha components of \a color. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QColor& color) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {GLfloat(color.redF()), GLfloat(color.greenF()), - GLfloat(color.blueF()), GLfloat(color.alphaF())}; - d->glfuncs->glUniform4fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context to - the red, green, blue, and alpha components of \a color. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QColor& color) -{ - setUniformValue(uniformLocation(name), color); -} - -/*! - Sets the uniform variable at \a location in the current context to - the x and y coordinates of \a point. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QPoint& point) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {GLfloat(point.x()), GLfloat(point.y())}; - d->glfuncs->glUniform2fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable associated with \a name in the current - context to the x and y coordinates of \a point. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point) -{ - setUniformValue(uniformLocation(name), point); -} - -/*! - Sets the uniform variable at \a location in the current context to - the x and y coordinates of \a point. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QPointF& point) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {GLfloat(point.x()), GLfloat(point.y())}; - d->glfuncs->glUniform2fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable associated with \a name in the current - context to the x and y coordinates of \a point. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point) -{ - setUniformValue(uniformLocation(name), point); -} - -/*! - Sets the uniform variable at \a location in the current context to - the width and height of the given \a size. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QSize& size) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())}; - d->glfuncs->glUniform2fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable associated with \a name in the current - context to the width and height of the given \a size. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QSize& size) -{ - setUniformValue(uniformLocation(name), size); -} - -/*! - Sets the uniform variable at \a location in the current context to - the width and height of the given \a size. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QSizeF& size) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) { - GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())}; - d->glfuncs->glUniform2fv(location, 1, values); - } -} - -/*! - \overload - - Sets the uniform variable associated with \a name in the current - context to the width and height of the given \a size. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size) -{ - setUniformValue(uniformLocation(name), size); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 2x2 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniformMatrix2fv(location, 1, GL_FALSE, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 2x2 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 2x3 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniform3fv(location, 2, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 2x3 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 2x4 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniform4fv(location, 2, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 2x4 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 3x2 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniform2fv(location, 3, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 3x2 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 3x3 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniformMatrix3fv(location, 1, GL_FALSE, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 3x3 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 3x4 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniform4fv(location, 3, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 3x4 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 4x2 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniform2fv(location, 4, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 4x2 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 4x3 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniform3fv(location, 4, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 4x3 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context - to a 4x4 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value) -{ - Q_D(QGLShaderProgram); - d->glfuncs->glUniformMatrix4fv(location, 1, GL_FALSE, value.constData()); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 4x4 matrix \a value. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - \overload - - Sets the uniform variable at \a location in the current context - to a 2x2 matrix \a value. The matrix elements must be specified - in column-major order. - - \sa setAttributeValue() - \since 4.7 -*/ -void QGLShaderProgram::setUniformValue(int location, const GLfloat value[2][2]) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniformMatrix2fv(location, 1, GL_FALSE, value[0]); -} - -/*! - \overload - - Sets the uniform variable at \a location in the current context - to a 3x3 matrix \a value. The matrix elements must be specified - in column-major order. - - \sa setAttributeValue() - \since 4.7 -*/ -void QGLShaderProgram::setUniformValue(int location, const GLfloat value[3][3]) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniformMatrix3fv(location, 1, GL_FALSE, value[0]); -} - -/*! - \overload - - Sets the uniform variable at \a location in the current context - to a 4x4 matrix \a value. The matrix elements must be specified - in column-major order. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4]) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniformMatrix4fv(location, 1, GL_FALSE, value[0]); -} - - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 2x2 matrix \a value. The matrix elements must be specified - in column-major order. - - \sa setAttributeValue() - \since 4.7 -*/ -void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[2][2]) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 3x3 matrix \a value. The matrix elements must be specified - in column-major order. - - \sa setAttributeValue() - \since 4.7 -*/ -void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[3][3]) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context - to a 4x4 matrix \a value. The matrix elements must be specified - in column-major order. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][4]) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable at \a location in the current context to a - 3x3 transformation matrix \a value that is specified as a QTransform value. - - To set a QTransform value as a 4x4 matrix in a shader, use - \c{setUniformValue(location, QMatrix4x4(value))}. -*/ -void QGLShaderProgram::setUniformValue(int location, const QTransform& value) -{ - Q_D(QGLShaderProgram); - if (location != -1) { - GLfloat mat[3][3] = { - {GLfloat(value.m11()), GLfloat(value.m12()), GLfloat(value.m13())}, - {GLfloat(value.m21()), GLfloat(value.m22()), GLfloat(value.m23())}, - {GLfloat(value.m31()), GLfloat(value.m32()), GLfloat(value.m33())} - }; - d->glfuncs->glUniformMatrix3fv(location, 1, GL_FALSE, mat[0]); - } -} - -/*! - \overload - - Sets the uniform variable called \a name in the current context to a - 3x3 transformation matrix \a value that is specified as a QTransform value. - - To set a QTransform value as a 4x4 matrix in a shader, use - \c{setUniformValue(name, QMatrix4x4(value))}. -*/ -void QGLShaderProgram::setUniformValue - (const char *name, const QTransform& value) -{ - setUniformValue(uniformLocation(name), value); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniform1iv(location, count, values); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray - (const char *name, const GLint *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count elements of \a values. This overload - should be used when setting an array of sampler values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniform1iv(location, count, reinterpret_cast<const GLint *>(values)); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count elements of \a values. This overload - should be used when setting an array of sampler values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray - (const char *name, const GLuint *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count elements of \a values. Each element - has \a tupleSize components. The \a tupleSize must be 1, 2, 3, or 4. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize) -{ - Q_D(QGLShaderProgram); - if (location != -1) { - if (tupleSize == 1) - d->glfuncs->glUniform1fv(location, count, values); - else if (tupleSize == 2) - d->glfuncs->glUniform2fv(location, count, values); - else if (tupleSize == 3) - d->glfuncs->glUniform3fv(location, count, values); - else if (tupleSize == 4) - d->glfuncs->glUniform4fv(location, count, values); - else - qWarning() << "QGLShaderProgram::setUniformValue: size" << tupleSize << "not supported"; - } -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count elements of \a values. Each element - has \a tupleSize components. The \a tupleSize must be 1, 2, 3, or 4. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray - (const char *name, const GLfloat *values, int count, int tupleSize) -{ - setUniformValueArray(uniformLocation(name), values, count, tupleSize); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 2D vector elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniform2fv(location, count, reinterpret_cast<const GLfloat *>(values)); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 2D vector elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 3D vector elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count) -{ - Q_D(QGLShaderProgram); - if (location != -1) - d->glfuncs->glUniform3fv(location, count, reinterpret_cast<const GLfloat *>(values)); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 3D vector elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 4D vector elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - if (location != -1) - d->glfuncs->glUniform4fv(location, count, reinterpret_cast<const GLfloat *>(values)); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 4D vector elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -// We have to repack matrix arrays from qreal to GLfloat. -#define setUniformMatrixArray(func,location,values,count,type,cols,rows) \ - if (location == -1 || count <= 0) \ - return; \ - if (sizeof(type) == sizeof(GLfloat) * cols * rows) { \ - func(location, count, GL_FALSE, \ - reinterpret_cast<const GLfloat *>(values[0].constData())); \ - } else { \ - QVarLengthArray<GLfloat> temp(cols * rows * count); \ - for (int index = 0; index < count; ++index) { \ - for (int index2 = 0; index2 < (cols * rows); ++index2) { \ - temp.data()[cols * rows * index + index2] = \ - values[index].constData()[index2]; \ - } \ - } \ - func(location, count, GL_FALSE, temp.constData()); \ - } -#define setUniformGenericMatrixArray(colfunc,location,values,count,type,cols,rows) \ - if (location == -1 || count <= 0) \ - return; \ - if (sizeof(type) == sizeof(GLfloat) * cols * rows) { \ - const GLfloat *data = reinterpret_cast<const GLfloat *> \ - (values[0].constData()); \ - colfunc(location, count * cols, data); \ - } else { \ - QVarLengthArray<GLfloat> temp(cols * rows * count); \ - for (int index = 0; index < count; ++index) { \ - for (int index2 = 0; index2 < (cols * rows); ++index2) { \ - temp.data()[cols * rows * index + index2] = \ - values[index].constData()[index2]; \ - } \ - } \ - colfunc(location, count * cols, temp.constData()); \ - } - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 2x2 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformMatrixArray - (d->glfuncs->glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 2x2 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 2x3 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformGenericMatrixArray - (d->glfuncs->glUniform3fv, location, values, count, - QMatrix2x3, 2, 3); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 2x3 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 2x4 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformGenericMatrixArray - (d->glfuncs->glUniform4fv, location, values, count, - QMatrix2x4, 2, 4); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 2x4 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 3x2 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformGenericMatrixArray - (d->glfuncs->glUniform2fv, location, values, count, - QMatrix3x2, 3, 2); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 3x2 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 3x3 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformMatrixArray - (d->glfuncs->glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 3x3 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 3x4 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformGenericMatrixArray - (d->glfuncs->glUniform4fv, location, values, count, - QMatrix3x4, 3, 4); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 3x4 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 4x2 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformGenericMatrixArray - (d->glfuncs->glUniform2fv, location, values, count, - QMatrix4x2, 4, 2); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 4x2 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 4x3 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformGenericMatrixArray - (d->glfuncs->glUniform3fv, location, values, count, - QMatrix4x3, 4, 3); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 4x3 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -/*! - Sets the uniform variable array at \a location in the current - context to the \a count 4x4 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count) -{ - Q_D(QGLShaderProgram); - Q_UNUSED(d); - setUniformMatrixArray - (d->glfuncs->glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4); -} - -/*! - \overload - - Sets the uniform variable array called \a name in the current - context to the \a count 4x4 matrix elements of \a values. - - \sa setAttributeValue() -*/ -void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x4 *values, int count) -{ - setUniformValueArray(uniformLocation(name), values, count); -} - -#undef ctx - -/*! - Returns the hardware limit for how many vertices a geometry shader - can output. - - \since 4.7 - - \sa setGeometryOutputVertexCount() -*/ -int QGLShaderProgram::maxGeometryOutputVertices() const -{ - GLint n = 0; -#if !defined(QT_OPENGL_ES_2) - Q_D(const QGLShaderProgram); - if (!QOpenGLContext::currentContext()->isOpenGLES()) - d->glfuncs->glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &n); -#endif - return n; -} - -/*! - Sets the maximum number of vertices the current geometry shader - program will produce, if active, to \a count. - - \since 4.7 - - This parameter takes effect the next time the program is linked. -*/ -void QGLShaderProgram::setGeometryOutputVertexCount(int count) -{ -#ifndef QT_NO_DEBUG - int max = maxGeometryOutputVertices(); - if (count > max) { - qWarning("QGLShaderProgram::setGeometryOutputVertexCount: count: %d higher than maximum: %d", - count, max); - } -#endif - d_func()->geometryVertexCount = count; -} - - -/*! - Returns the maximum number of vertices the current geometry shader - program will produce, if active. - - \since 4.7 - - This parameter takes effect the ntext time the program is linked. -*/ -int QGLShaderProgram::geometryOutputVertexCount() const -{ - return d_func()->geometryVertexCount; -} - - -/*! - Sets the input type from \a inputType. - - This parameter takes effect the next time the program is linked. -*/ -void QGLShaderProgram::setGeometryInputType(GLenum inputType) -{ - d_func()->geometryInputType = inputType; -} - - -/*! - Returns the geometry shader input type, if active. - - This parameter takes effect the next time the program is linked. - - \since 4.7 - */ - -GLenum QGLShaderProgram::geometryInputType() const -{ - return d_func()->geometryInputType; -} - - -/*! - Sets the output type from the geometry shader, if active, to - \a outputType. - - This parameter takes effect the next time the program is linked. - - \since 4.7 -*/ -void QGLShaderProgram::setGeometryOutputType(GLenum outputType) -{ - d_func()->geometryOutputType = outputType; -} - - -/*! - Returns the geometry shader output type, if active. - - This parameter takes effect the next time the program is linked. - - \since 4.7 - */ -GLenum QGLShaderProgram::geometryOutputType() const -{ - return d_func()->geometryOutputType; -} - - -/*! - Returns \c true if shader programs written in the OpenGL Shading - Language (GLSL) are supported on this system; false otherwise. - - The \a context is used to resolve the GLSL extensions. - If \a context is \nullptr, then QGLContext::currentContext() is - used. -*/ -bool QGLShaderProgram::hasOpenGLShaderPrograms(const QGLContext *context) -{ -#if !defined(QT_OPENGL_ES_2) - if (!context) - context = QGLContext::currentContext(); - if (!context) - return false; - - QOpenGLFunctions functions(context->contextHandle()); - return functions.hasOpenGLFeature(QOpenGLFunctions::Shaders); -#else - Q_UNUSED(context); - return true; -#endif -} - -/*! - \internal -*/ -void QGLShaderProgram::shaderDestroyed() -{ - Q_D(QGLShaderProgram); - QGLShader *shader = qobject_cast<QGLShader *>(sender()); - if (shader && !d->removingShaders) - removeShader(shader); -} - - -#undef ctx -#undef context - -/*! - Returns \c true if shader programs of type \a type are supported on - this system; false otherwise. - - The \a context is used to resolve the GLSL extensions. - If \a context is \nullptr, then QGLContext::currentContext() is - used. - - \since 4.7 -*/ -bool QGLShader::hasOpenGLShaders(ShaderType type, const QGLContext *context) -{ - if (!context) - context = QGLContext::currentContext(); - if (!context) - return false; - - if ((type & ~(Geometry | Vertex | Fragment)) || type == 0) - return false; - - QOpenGLFunctions functions(context->contextHandle()); - bool resolved = functions.hasOpenGLFeature(QOpenGLFunctions::Shaders); - if (!resolved) - return false; - - if ((type & Geometry) && !QByteArray((const char *) functions.glGetString(GL_EXTENSIONS)).contains("GL_EXT_geometry_shader4")) - return false; - - return true; -} - -QT_END_NAMESPACE diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h deleted file mode 100644 index 3ce88197d2..0000000000 --- a/src/opengl/qglshaderprogram.h +++ /dev/null @@ -1,303 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLSHADERPROGRAM_H -#define QGLSHADERPROGRAM_H - -#include <QtOpenGL/qgl.h> -#include <QtGui/qvector2d.h> -#include <QtGui/qvector3d.h> -#include <QtGui/qvector4d.h> -#include <QtGui/qmatrix4x4.h> - -QT_BEGIN_NAMESPACE - - -class QGLShaderProgram; -class QGLShaderPrivate; - -class Q_OPENGL_EXPORT QGLShader : public QObject -{ - Q_OBJECT -public: - enum ShaderTypeBit - { - Vertex = 0x0001, - Fragment = 0x0002, - Geometry = 0x0004 - }; - Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) - - explicit QGLShader(QGLShader::ShaderType type, QObject *parent = nullptr); - QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent = nullptr); - virtual ~QGLShader(); - - QGLShader::ShaderType shaderType() const; - - bool compileSourceCode(const char *source); - bool compileSourceCode(const QByteArray& source); - bool compileSourceCode(const QString& source); - bool compileSourceFile(const QString& fileName); - - QByteArray sourceCode() const; - - bool isCompiled() const; - QString log() const; - - GLuint shaderId() const; - - static bool hasOpenGLShaders(ShaderType type, const QGLContext *context = nullptr); - -private: - friend class QGLShaderProgram; - - Q_DISABLE_COPY(QGLShader) - Q_DECLARE_PRIVATE(QGLShader) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType) - - -class QGLShaderProgramPrivate; - -class Q_OPENGL_EXPORT QGLShaderProgram : public QObject -{ - Q_OBJECT -public: - explicit QGLShaderProgram(QObject *parent = nullptr); - explicit QGLShaderProgram(const QGLContext *context, QObject *parent = nullptr); - virtual ~QGLShaderProgram(); - - bool addShader(QGLShader *shader); - void removeShader(QGLShader *shader); - QList<QGLShader *> shaders() const; - - bool addShaderFromSourceCode(QGLShader::ShaderType type, const char *source); - bool addShaderFromSourceCode(QGLShader::ShaderType type, const QByteArray& source); - bool addShaderFromSourceCode(QGLShader::ShaderType type, const QString& source); - bool addShaderFromSourceFile(QGLShader::ShaderType type, const QString& fileName); - - void removeAllShaders(); - - virtual bool link(); - bool isLinked() const; - QString log() const; - - bool bind(); - void release(); - - GLuint programId() const; - - int maxGeometryOutputVertices() const; - - void setGeometryOutputVertexCount(int count); - int geometryOutputVertexCount() const; - - void setGeometryInputType(GLenum inputType); - GLenum geometryInputType() const; - - void setGeometryOutputType(GLenum outputType); - GLenum geometryOutputType() const; - - void bindAttributeLocation(const char *name, int location); - void bindAttributeLocation(const QByteArray& name, int location); - void bindAttributeLocation(const QString& name, int location); - - int attributeLocation(const char *name) const; - int attributeLocation(const QByteArray& name) const; - int attributeLocation(const QString& name) const; - - void setAttributeValue(int location, GLfloat value); - void setAttributeValue(int location, GLfloat x, GLfloat y); - void setAttributeValue(int location, GLfloat x, GLfloat y, GLfloat z); - void setAttributeValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void setAttributeValue(int location, const QVector2D& value); - void setAttributeValue(int location, const QVector3D& value); - void setAttributeValue(int location, const QVector4D& value); - void setAttributeValue(int location, const QColor& value); - void setAttributeValue(int location, const GLfloat *values, int columns, int rows); - - void setAttributeValue(const char *name, GLfloat value); - void setAttributeValue(const char *name, GLfloat x, GLfloat y); - void setAttributeValue(const char *name, GLfloat x, GLfloat y, GLfloat z); - void setAttributeValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void setAttributeValue(const char *name, const QVector2D& value); - void setAttributeValue(const char *name, const QVector3D& value); - void setAttributeValue(const char *name, const QVector4D& value); - void setAttributeValue(const char *name, const QColor& value); - void setAttributeValue(const char *name, const GLfloat *values, int columns, int rows); - - void setAttributeArray - (int location, const GLfloat *values, int tupleSize, int stride = 0); - void setAttributeArray - (int location, const QVector2D *values, int stride = 0); - void setAttributeArray - (int location, const QVector3D *values, int stride = 0); - void setAttributeArray - (int location, const QVector4D *values, int stride = 0); - void setAttributeArray - (int location, GLenum type, const void *values, int tupleSize, int stride = 0); - void setAttributeArray - (const char *name, const GLfloat *values, int tupleSize, int stride = 0); - void setAttributeArray - (const char *name, const QVector2D *values, int stride = 0); - void setAttributeArray - (const char *name, const QVector3D *values, int stride = 0); - void setAttributeArray - (const char *name, const QVector4D *values, int stride = 0); - void setAttributeArray - (const char *name, GLenum type, const void *values, int tupleSize, int stride = 0); - - void setAttributeBuffer - (int location, GLenum type, int offset, int tupleSize, int stride = 0); - void setAttributeBuffer - (const char *name, GLenum type, int offset, int tupleSize, int stride = 0); - - void enableAttributeArray(int location); - void enableAttributeArray(const char *name); - void disableAttributeArray(int location); - void disableAttributeArray(const char *name); - - int uniformLocation(const char *name) const; - int uniformLocation(const QByteArray& name) const; - int uniformLocation(const QString& name) const; - - void setUniformValue(int location, GLfloat value); - void setUniformValue(int location, GLint value); - void setUniformValue(int location, GLuint value); - void setUniformValue(int location, GLfloat x, GLfloat y); - void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z); - void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void setUniformValue(int location, const QVector2D& value); - void setUniformValue(int location, const QVector3D& value); - void setUniformValue(int location, const QVector4D& value); - void setUniformValue(int location, const QColor& color); - void setUniformValue(int location, const QPoint& point); - void setUniformValue(int location, const QPointF& point); - void setUniformValue(int location, const QSize& size); - void setUniformValue(int location, const QSizeF& size); - void setUniformValue(int location, const QMatrix2x2& value); - void setUniformValue(int location, const QMatrix2x3& value); - void setUniformValue(int location, const QMatrix2x4& value); - void setUniformValue(int location, const QMatrix3x2& value); - void setUniformValue(int location, const QMatrix3x3& value); - void setUniformValue(int location, const QMatrix3x4& value); - void setUniformValue(int location, const QMatrix4x2& value); - void setUniformValue(int location, const QMatrix4x3& value); - void setUniformValue(int location, const QMatrix4x4& value); - void setUniformValue(int location, const GLfloat value[2][2]); - void setUniformValue(int location, const GLfloat value[3][3]); - void setUniformValue(int location, const GLfloat value[4][4]); - void setUniformValue(int location, const QTransform& value); - - void setUniformValue(const char *name, GLfloat value); - void setUniformValue(const char *name, GLint value); - void setUniformValue(const char *name, GLuint value); - void setUniformValue(const char *name, GLfloat x, GLfloat y); - void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z); - void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); - void setUniformValue(const char *name, const QVector2D& value); - void setUniformValue(const char *name, const QVector3D& value); - void setUniformValue(const char *name, const QVector4D& value); - void setUniformValue(const char *name, const QColor& color); - void setUniformValue(const char *name, const QPoint& point); - void setUniformValue(const char *name, const QPointF& point); - void setUniformValue(const char *name, const QSize& size); - void setUniformValue(const char *name, const QSizeF& size); - void setUniformValue(const char *name, const QMatrix2x2& value); - void setUniformValue(const char *name, const QMatrix2x3& value); - void setUniformValue(const char *name, const QMatrix2x4& value); - void setUniformValue(const char *name, const QMatrix3x2& value); - void setUniformValue(const char *name, const QMatrix3x3& value); - void setUniformValue(const char *name, const QMatrix3x4& value); - void setUniformValue(const char *name, const QMatrix4x2& value); - void setUniformValue(const char *name, const QMatrix4x3& value); - void setUniformValue(const char *name, const QMatrix4x4& value); - void setUniformValue(const char *name, const GLfloat value[2][2]); - void setUniformValue(const char *name, const GLfloat value[3][3]); - void setUniformValue(const char *name, const GLfloat value[4][4]); - void setUniformValue(const char *name, const QTransform& value); - - void setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize); - void setUniformValueArray(int location, const GLint *values, int count); - void setUniformValueArray(int location, const GLuint *values, int count); - void setUniformValueArray(int location, const QVector2D *values, int count); - void setUniformValueArray(int location, const QVector3D *values, int count); - void setUniformValueArray(int location, const QVector4D *values, int count); - void setUniformValueArray(int location, const QMatrix2x2 *values, int count); - void setUniformValueArray(int location, const QMatrix2x3 *values, int count); - void setUniformValueArray(int location, const QMatrix2x4 *values, int count); - void setUniformValueArray(int location, const QMatrix3x2 *values, int count); - void setUniformValueArray(int location, const QMatrix3x3 *values, int count); - void setUniformValueArray(int location, const QMatrix3x4 *values, int count); - void setUniformValueArray(int location, const QMatrix4x2 *values, int count); - void setUniformValueArray(int location, const QMatrix4x3 *values, int count); - void setUniformValueArray(int location, const QMatrix4x4 *values, int count); - - void setUniformValueArray(const char *name, const GLfloat *values, int count, int tupleSize); - void setUniformValueArray(const char *name, const GLint *values, int count); - void setUniformValueArray(const char *name, const GLuint *values, int count); - void setUniformValueArray(const char *name, const QVector2D *values, int count); - void setUniformValueArray(const char *name, const QVector3D *values, int count); - void setUniformValueArray(const char *name, const QVector4D *values, int count); - void setUniformValueArray(const char *name, const QMatrix2x2 *values, int count); - void setUniformValueArray(const char *name, const QMatrix2x3 *values, int count); - void setUniformValueArray(const char *name, const QMatrix2x4 *values, int count); - void setUniformValueArray(const char *name, const QMatrix3x2 *values, int count); - void setUniformValueArray(const char *name, const QMatrix3x3 *values, int count); - void setUniformValueArray(const char *name, const QMatrix3x4 *values, int count); - void setUniformValueArray(const char *name, const QMatrix4x2 *values, int count); - void setUniformValueArray(const char *name, const QMatrix4x3 *values, int count); - void setUniformValueArray(const char *name, const QMatrix4x4 *values, int count); - - static bool hasOpenGLShaderPrograms(const QGLContext *context = nullptr); - -private Q_SLOTS: - void shaderDestroyed(); - -private: - Q_DISABLE_COPY(QGLShaderProgram) - Q_DECLARE_PRIVATE(QGLShaderProgram) - - bool init(); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp deleted file mode 100644 index 97b83a6b3d..0000000000 --- a/src/opengl/qgraphicsshadereffect.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgraphicsshadereffect_p.h" - -#include "qglshaderprogram.h" -#include "gl2paintengineex/qglcustomshaderstage_p.h" -#define QGL_HAVE_CUSTOM_SHADERS 1 -#include <QtGui/qpainter.h> -#include <QtWidgets/qgraphicsitem.h> -#include <private/qgraphicseffect_p.h> - -QT_BEGIN_NAMESPACE - -/*# - \class QGraphicsShaderEffect - \inmodule QtOpenGL - \brief The QGraphicsShaderEffect class is the base class for creating - custom GLSL shader effects in a QGraphicsScene. - \since 4.6 - \ingroup multimedia - \ingroup graphicsview-api - - The specific effect is defined by a fragment of GLSL source code - supplied to setPixelShaderFragment(). This source code must define a - function with the signature - \c{lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords)} - that returns the source pixel value - to use in the paint engine's shader program. The shader fragment - is linked with the regular shader code used by the GL2 paint engine - to construct a complete QGLShaderProgram. - - The following example shader converts the incoming pixmap to - grayscale and then applies a colorize operation using the - \c effectColor value: - - \snippet code/src_opengl_qgraphicsshadereffect.cpp 0 - - To use this shader code, it is necessary to define a subclass - of QGraphicsShaderEffect as follows: - - \snippet code/src_opengl_qgraphicsshadereffect.cpp 1 - - The setUniforms() function is called when the effect is about - to be used for drawing to give the subclass the opportunity to - set effect-specific uniform variables. - - QGraphicsShaderEffect is only supported when the GL2 paint engine - is in use. When any other paint engine is in use (GL1, raster, etc), - the drawItem() method will draw its item argument directly with - no effect applied. - - \sa QGraphicsEffect -*/ - -static const char qglslDefaultImageFragmentShader[] = "\ - lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) { \ - return texture2D(imageTexture, textureCoords); \ - }\n"; - -#ifdef QGL_HAVE_CUSTOM_SHADERS - -class QGLCustomShaderEffectStage : public QGLCustomShaderStage -{ -public: - QGLCustomShaderEffectStage - (QGraphicsShaderEffect *e, const QByteArray& source) - : QGLCustomShaderStage(), - effect(e) - { - setSource(source); - } - - void setUniforms(QGLShaderProgram *program) override; - - QGraphicsShaderEffect *effect; -}; - -void QGLCustomShaderEffectStage::setUniforms(QGLShaderProgram *program) -{ - effect->setUniforms(program); -} - -#endif - -class QGraphicsShaderEffectPrivate : public QGraphicsEffectPrivate -{ - Q_DECLARE_PUBLIC(QGraphicsShaderEffect) -public: - QGraphicsShaderEffectPrivate() - : pixelShaderFragment(qglslDefaultImageFragmentShader) -#ifdef QGL_HAVE_CUSTOM_SHADERS - , customShaderStage(0) -#endif - { - } - - QByteArray pixelShaderFragment; -#ifdef QGL_HAVE_CUSTOM_SHADERS - QGLCustomShaderEffectStage *customShaderStage; -#endif -}; - -/*# - Constructs a shader effect and attaches it to \a parent. -*/ -QGraphicsShaderEffect::QGraphicsShaderEffect(QObject *parent) - : QGraphicsEffect(*new QGraphicsShaderEffectPrivate(), parent) -{ -} - -/*# - Destroys this shader effect. -*/ -QGraphicsShaderEffect::~QGraphicsShaderEffect() -{ -#ifdef QGL_HAVE_CUSTOM_SHADERS - Q_D(QGraphicsShaderEffect); - delete d->customShaderStage; -#endif -} - -/*# - Returns the source code for the pixel shader fragment for - this shader effect. The default is a shader that copies - its incoming pixmap directly to the output with no effect - applied. - - \sa setPixelShaderFragment() -*/ -QByteArray QGraphicsShaderEffect::pixelShaderFragment() const -{ - Q_D(const QGraphicsShaderEffect); - return d->pixelShaderFragment; -} - -/*# - Sets the source code for the pixel shader fragment for - this shader effect to \a code. - - The \a code must define a GLSL function with the signature - \c{lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords)} - that returns the source pixel value to use in the paint engine's - shader program. The following is the default pixel shader fragment, - which draws a pixmap with no effect applied: - - \snippet code/src_opengl_qgraphicsshadereffect.cpp 2 - - \sa pixelShaderFragment(), setUniforms() -*/ -void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code) -{ - Q_D(QGraphicsShaderEffect); - if (d->pixelShaderFragment != code) { - d->pixelShaderFragment = code; -#ifdef QGL_HAVE_CUSTOM_SHADERS - delete d->customShaderStage; - d->customShaderStage = 0; -#endif - } -} - -/*# - \reimp -*/ -void QGraphicsShaderEffect::draw(QPainter *painter) -{ - Q_D(QGraphicsShaderEffect); - -#ifdef QGL_HAVE_CUSTOM_SHADERS - // Set the custom shader on the paint engine. The setOnPainter() - // call may fail if the paint engine is not GL2. In that case, - // we fall through to drawing the pixmap normally. - if (!d->customShaderStage) { - d->customShaderStage = new QGLCustomShaderEffectStage - (this, d->pixelShaderFragment); - } - bool usingShader = d->customShaderStage->setOnPainter(painter); - - QPoint offset; - if (sourceIsPixmap()) { - // No point in drawing in device coordinates (pixmap will be scaled anyways). - const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); - painter->drawPixmap(offset, pixmap); - } else { - // Draw pixmap in device coordinates to avoid pixmap scaling. - const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); - QTransform restoreTransform = painter->worldTransform(); - painter->setWorldTransform(QTransform()); - painter->drawPixmap(offset, pixmap); - painter->setWorldTransform(restoreTransform); - } - - // Remove the custom shader to return to normal painting operations. - if (usingShader) - d->customShaderStage->removeFromPainter(painter); -#else - drawSource(painter); -#endif -} - -/*# - Sets the custom uniform variables on this shader effect to - be dirty. The setUniforms() function will be called the next - time the shader program corresponding to this effect is used. - - This function is typically called by subclasses when an - effect-specific parameter is changed by the application. - - \sa setUniforms() -*/ -void QGraphicsShaderEffect::setUniformsDirty() -{ -#ifdef QGL_HAVE_CUSTOM_SHADERS - Q_D(QGraphicsShaderEffect); - if (d->customShaderStage) - d->customShaderStage->setUniformsDirty(); -#endif -} - -/*# - Sets custom uniform variables on the current GL context when - \a program is about to be used by the paint engine. - - This function should be overridden if the shader set with - setPixelShaderFragment() has additional parameters beyond - those that the paint engine normally sets itself. - - \sa setUniformsDirty() -*/ -void QGraphicsShaderEffect::setUniforms(QGLShaderProgram *program) -{ - Q_UNUSED(program); -} - -QT_END_NAMESPACE diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h deleted file mode 100644 index 218caa2936..0000000000 --- a/src/opengl/qgraphicsshadereffect_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGRAPHICSSHADEREFFECT_P_H -#define QGRAPHICSSHADEREFFECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtWidgets/qgraphicseffect.h> - -#include <QtOpenGL/qtopenglglobal.h> - -QT_REQUIRE_CONFIG(graphicseffect); - -QT_BEGIN_NAMESPACE - -class QGLShaderProgram; -class QGLCustomShaderEffectStage; -class QGraphicsShaderEffectPrivate; - -class Q_OPENGL_EXPORT QGraphicsShaderEffect : public QGraphicsEffect -{ - Q_OBJECT -public: - QGraphicsShaderEffect(QObject *parent = nullptr); - virtual ~QGraphicsShaderEffect(); - - QByteArray pixelShaderFragment() const; - void setPixelShaderFragment(const QByteArray& code); - -protected: - void draw(QPainter *painter) override; - void setUniformsDirty(); - virtual void setUniforms(QGLShaderProgram *program); - -private: - Q_DECLARE_PRIVATE(QGraphicsShaderEffect) - Q_DISABLE_COPY_MOVE(QGraphicsShaderEffect) - - friend class QGLCustomShaderEffectStage; -}; - -QT_END_NAMESPACE - -#endif // QGRAPHICSSHADEREFFECT_P_H -- cgit v1.2.3 From c3a66baff87e8d231aae06ccd1eb5d623587593d Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Tue, 10 Dec 2019 13:01:45 +0100 Subject: Move QOpenGLDebugLogger from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: Ida7a89b214cd5e1a3b6fdfa651299a9c5a654f5b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/opengl/opengl.pri | 2 - src/gui/opengl/qopengldebug.cpp | 1826 --------------------------------------- src/gui/opengl/qopengldebug.h | 221 ----- src/opengl/opengl.pro | 4 + src/opengl/qopengldebug.cpp | 1826 +++++++++++++++++++++++++++++++++++++++ src/opengl/qopengldebug.h | 221 +++++ 6 files changed, 2051 insertions(+), 2049 deletions(-) delete mode 100644 src/gui/opengl/qopengldebug.cpp delete mode 100644 src/gui/opengl/qopengldebug.h create mode 100644 src/opengl/qopengldebug.cpp create mode 100644 src/opengl/qopengldebug.h (limited to 'src') diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index 24758afdeb..9eab55f112 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -27,7 +27,6 @@ qtConfig(opengl) { opengl/qopenglversionfunctions.h \ opengl/qopenglversionfunctionsfactory_p.h \ opengl/qopenglvertexarrayobject.h \ - opengl/qopengldebug.h \ opengl/qopengltextureblitter.h \ opengl/qopengltexture.h \ opengl/qopengltexture_p.h \ @@ -53,7 +52,6 @@ qtConfig(opengl) { opengl/qopenglversionfunctions.cpp \ opengl/qopenglversionfunctionsfactory.cpp \ opengl/qopenglvertexarrayobject.cpp \ - opengl/qopengldebug.cpp \ opengl/qopengltextureblitter.cpp \ opengl/qopengltexture.cpp \ opengl/qopengltexturehelper.cpp \ diff --git a/src/gui/opengl/qopengldebug.cpp b/src/gui/opengl/qopengldebug.cpp deleted file mode 100644 index 310006feaf..0000000000 --- a/src/gui/opengl/qopengldebug.cpp +++ /dev/null @@ -1,1826 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/private/qobject_p.h> -#include <QtCore/qglobal.h> -#include <QtCore/qvarlengtharray.h> -#include <QtGui/qopengl.h> -#include <QtGui/qopenglfunctions.h> -#include <QtGui/qoffscreensurface.h> - -#include "qopengldebug.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QOpenGLDebugMessage - \brief The QOpenGLDebugMessage class wraps an OpenGL debug message. - \inmodule QtGui - \reentrant - \since 5.1 - \ingroup shared - \ingroup painting-3D - - Debug messages are usually created by the OpenGL server and then read by - OpenGL clients (either from the OpenGL internal debug log, or logged in real-time). - A debug message has a textual representation, a vendor-specific numeric id, - a source, a type and a severity. - - It's also possible for applications or third-party libraries and toolkits - to create and insert messages in the debug log. In order to do so, you can use - the createApplicationMessage() or the createThirdPartyMessage() static functions. - - \sa QOpenGLDebugLogger -*/ - -/*! - \class QOpenGLDebugLogger - \brief The QOpenGLDebugLogger enables logging of OpenGL debugging messages. - \inmodule QtGui - \since 5.1 - \ingroup painting-3D - - \tableofcontents - - \section1 Introduction - - OpenGL programming can be very error prone. Most of the time, a single - failing call to OpenGL can cause an entire portion of an application to - stop working, with nothing being drawn on the screen. - - The only way to be sure that no errors are being returned from the OpenGL - implementation is checking with \c{glGetError} after each and every API - call. Moreover, OpenGL errors stack up, therefore glGetError should always - be used in a loop like this: - - \snippet code/src_gui_opengl_qopengldebug.cpp 0 - - If you try to clear the error stack, make sure not just keep going until - GL_NO_ERROR is returned but also break on GL_CONTEXT_LOST as that error - value will keep repeating. - - There are also many other information we are interested in (as application - developers), for instance performance issues, or warnings about using - deprecated APIs. Those kind of messages are not reported through the - ordinary OpenGL error reporting mechanisms. - - QOpenGLDebugLogger aims at addressing these issues by providing access to - the \e{OpenGL debug log}. If your OpenGL implementation supports it (by - exposing the \c{GL_KHR_debug} extension), messages from the OpenGL server - will be either logged in an internal OpenGL log, or passed in "real-time" - to listeners as they're generated from OpenGL. - - QOpenGLDebugLogger supports both these modes of operation. Refer to the - following sections to find out the differences between them. - - \section1 Creating an OpenGL Debug Context - - For efficiency reasons, OpenGL implementations are allowed not to create - any debug output at all, unless the OpenGL context is a debug context. In order - to create a debug context from Qt, you must set the QSurfaceFormat::DebugContext - format option on the QSurfaceFormat used to create the QOpenGLContext object: - - \snippet code/src_gui_opengl_qopengldebug.cpp 1 - - Note that requesting a 3.2 OpenGL Core Profile is just for the example's - purposes; this class is not tied to any specific OpenGL or OpenGL ES - version, as it relies on the availability of the \c{GL_KHR_debug} extension - (see below). - - \section1 Creating and Initializing a QOpenGLDebugLogger - - QOpenGLDebugLogger is a simple QObject-derived class. Just like all QObject - subclasses, you create an instance (and optionally specify a parent - object), and like the other OpenGL functions in Qt you \e{must} initialize - it before usage by calling initialize() whilst there is a current OpenGL context: - - \snippet code/src_gui_opengl_qopengldebug.cpp 2 - - Note that the \c{GL_KHR_debug} extension \e{must} be available in the context - in order to access the messages logged by OpenGL. You can check the - presence of this extension by calling: - - \snippet code/src_gui_opengl_qopengldebug.cpp 3 - - where \c{ctx} is a valid QOpenGLContext. If the extension is not available, - initialize() will return false. - - \section1 Reading the Internal OpenGL Debug Log - - OpenGL implementations keep an internal log of debug messages. Messages - stored in this log can be retrieved by using the loggedMessages() function: - - \snippet code/src_gui_opengl_qopengldebug.cpp 4 - - The internal log has a limited size; when it fills up, older messages will - get discarded to make room for the new incoming messages. When you call - loggedMessages(), the internal log will be emptied as well. - - If you want to be sure not to lose any debug message, you must use real-time - logging instead of calling this function. However, debug messages might - still be generated in the timespan between context creation and activation - of real-time logging (or, in general, when the real-time logging is disabled). - - \section1 Real-time logging of messages - - It is also possible to receive a stream of debug messages from the OpenGL - server \e{as they are generated} by the implementation. In order to do so, - you need to connect a suitable slot to the messageLogged() signal, and - start logging by calling startLogging(): - - \snippet code/src_gui_opengl_qopengldebug.cpp 5 - - Similarly, logging can be disabled at any time by calling the stopLogging() - function. - - Real-time logging can be either asynchronous or synchronous, depending on - the parameter passed to startLogging(). When logging in asynchronous mode - (the default, as it has a very small overhead), the OpenGL implementation - can generate messages at any time, and/or in an order which is different from the - order of the OpenGL commands which caused those messages to be logged. - The messages could also be generated from a thread that it's different from - the thread the context is currently bound to. This is because OpenGL - implementations are usually highly threaded and asynchronous, and therefore - no warranties are made about the relative order and the timings of the - debug messages. - - On the other hand, logging in synchronous mode has a high overhead, but - the OpenGL implementation guarantees that all the messages caused by a - certain command are received in order, before the command returns, - and from the same thread the OpenGL context is bound to. - - This means that when logging in synchronous mode you will be able to run - your OpenGL application in a debugger, put a breakpoint on a slot connected - to the messageLogged() signal, and see in the backtrace the exact call - that caused the logged message. This can be extremely useful to debug - an OpenGL problem. Note that if OpenGL rendering is happening in another - thread, you must force the signal/slot connection type to Qt::DirectConnection - in order to be able to see the actual backtrace. - - Refer to the LoggingMode enum documentation for more information about - logging modes. - - \note When real-time logging is enabled, debug messages will \e{not} be - inserted in the internal OpenGL debug log any more; messages already - present in the internal log will not be deleted, nor they will be emitted - through the messageLogged() signal. Since some messages might be generated - before real-time logging is started (and therefore be kept in the internal - OpenGL log), it is important to always check if it contains any message - after calling startLogging(). - - \section1 Inserting Messages in the Debug Log - - It is possible for applications and libraries to insert custom messages in - the debug log, for instance for marking a group of related OpenGL commands - and therefore being then able to identify eventual messages coming from them. - - In order to do so, you can create a QOpenGLDebugMessage object by calling - \l{QOpenGLDebugMessage::}{createApplicationMessage()} or - \l{QOpenGLDebugMessage::}{createThirdPartyMessage()}, and then inserting it - into the log by calling logMessage(): - - \snippet code/src_gui_opengl_qopengldebug.cpp 6 - - Note that OpenGL implementations have a vendor-specific limit to the length - of the messages that can be inserted in the debug log. You can retrieve - this length by calling the maximumMessageLength() method; messages longer - than the limit will automatically get truncated. - - \section1 Controlling the Debug Output - - QOpenGLDebugMessage is also able to apply filters to the debug messages, and - therefore limit the amount of messages logged. You can enable or disable - logging of messages by calling enableMessages() and disableMessages() - respectively. By default, all messages are logged. - - It is possible to enable or disable messages by selecting them by: - - \list - \li source, type and severity (and including all ids in the selection); - \li id, source and type (and including all severities in the selection). - \endlist - - Note that the "enabled" status for a given message is a property of the - (id, source, type, severity) tuple; the message attributes \e{do not} form - a hierarchy of any kind. You should be careful about the order of the calls - to enableMessages() and disableMessages(), as it will change which - messages will are enabled / disabled. - - It's not possible to filter by the message text itself; applications - have to do that on their own (in slots connected to the messageLogged() - signal, or after fetching the messages in the internal debug log - through loggedMessages()). - - In order to simplify the management of the enabled / disabled statuses, - QOpenGLDebugMessage also supports the concept of \c{debug groups}. A debug - group contains the group of enabled / disabled configurations of debug - messages. Moreover, debug groups are organized in a stack: it is possible - to push and pop groups by calling pushGroup() and popGroup() respectively. - (When an OpenGL context is created, there is already a group in the stack). - - The enableMessages() and disableMessages() functions will modify the - configuration in the current debug group, that is, the one at the top of - the debug groups stack. - - When a new group is pushed onto the debug groups stack, it will inherit - the configuration of the group that was previously on the top of the stack. - Vice versa, popping a debug group will restore the configuration of - the debug group that becomes the new top. - - Pushing (respectively popping) debug groups will also automatically generate - a debug message of type QOpenGLDebugMessage::GroupPushType (respectively - \l{QOpenGLDebugMessage::}{GroupPopType}). - - \sa QOpenGLDebugMessage -*/ - -/*! - \enum QOpenGLDebugMessage::Source - - The Source enum defines the source of the debug message. - - \value InvalidSource - The source of the message is invalid; this is the source of a - default-constructed QOpenGLDebugMessage object. - - \value APISource - The message was generated in response to OpenGL API calls. - - \value WindowSystemSource - The message was generated by the window system. - - \value ShaderCompilerSource - The message was generated by the shader compiler. - - \value ThirdPartySource - The message was generated by a third party, for instance an OpenGL - framework a or debugging toolkit. - - \value ApplicationSource - The message was generated by the application itself. - - \value OtherSource - The message was generated by a source not included in this - enumeration. - - \omitvalue LastSource - - \value AnySource - This value corresponds to a mask of all possible message sources. -*/ - -/*! - \enum QOpenGLDebugMessage::Type - - The Type enum defines the type of the debug message. - - \value InvalidType - The type of the message is invalid; this is the type of a - default-constructed QOpenGLDebugMessage object. - - \value ErrorType - The message represents an error. - - \value DeprecatedBehaviorType - The message represents an usage of deprecated behavior. - - \value UndefinedBehaviorType - The message represents an usage of undefined behavior. - - \value PortabilityType - The message represents an usage of vendor-specific behavior, - that might pose portability concerns. - - \value PerformanceType - The message represents a performance issue. - - \value OtherType - The message represents a type not included in this - enumeration. - - \value MarkerType - The message represents a marker in the debug log. - - \value GroupPushType - The message represents a debug group push operation. - - \value GroupPopType - The message represents a debug group pop operation. - - \omitvalue LastType - - \value AnyType - This value corresponds to a mask of all possible message types. -*/ - -/*! - \enum QOpenGLDebugMessage::Severity - - The Severity enum defines the severity of the debug message. - - \value InvalidSeverity - The severity of the message is invalid; this is the severity of a - default-constructed QOpenGLDebugMessage object. - - \value HighSeverity - The message has a high severity. - - \value MediumSeverity - The message has a medium severity. - - \value LowSeverity - The message has a low severity. - - \value NotificationSeverity - The message is a notification. - - \omitvalue LastSeverity - - \value AnySeverity - This value corresponds to a mask of all possible message severities. -*/ - -/*! - \property QOpenGLDebugLogger::loggingMode - - \brief the logging mode passed to startLogging(). - - Note that logging must have been started or the value of this property - will be meaningless. - - \sa startLogging(), isLogging() -*/ -/*! - \enum QOpenGLDebugLogger::LoggingMode - - The LoggingMode enum defines the logging mode of the logger object. - - \value AsynchronousLogging - Messages from the OpenGL server are logged asynchronously. This means - that messages can be logged some time after the corresponding OpenGL - actions that caused them, and even be received in an out-of-order - fashion, depending on the OpenGL implementation. This mode has a very low - performance penalty, as OpenGL implementations are heavily threaded - and asynchronous by nature. - - \value SynchronousLogging - Messages from the OpenGL server are logged synchronously and - sequentially. This has a severe performance hit, as OpenGL - implementations are very asynchronous by nature; but it's very useful - to debug OpenGL problems, as OpenGL guarantees that the messages - generated by a OpenGL command will be logged before the corresponding - command execution has returned. Therefore, you can install a breakpoint - on the messageLogged() signal and see in the backtrace which OpenGL - command caused it; the only caveat is that if you are using OpenGL from - multiple threads you may need to force direct connection when - connecting to the messageLogged() signal. -*/ - -// When using OpenGL ES 2.0, all the necessary GL_KHR_debug constants are -// provided in qopengles2ext.h. Unfortunately, newer versions of that file -// suffix everything with _KHR which causes extra headache when the goal is -// to have a single piece of code that builds in all our target -// environments. Therefore, try to detect this and use our custom defines -// instead, which we anyway need for OS X. - -#if defined(GL_KHR_debug) && defined(GL_DEBUG_SOURCE_API_KHR) -#define USE_MANUAL_DEFS -#endif - -// Under OSX (at least up to 10.8) we cannot include our copy of glext.h, -// but we use the system-wide one, which unfortunately lacks all the needed -// defines/typedefs. In order to make the code compile, we just add here -// the GL_KHR_debug defines. - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#define USE_MANUAL_DEFS -#endif - -#ifdef USE_MANUAL_DEFS - -#ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#endif -#ifndef GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#endif -#ifndef GL_DEBUG_CALLBACK_FUNCTION -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#endif -#ifndef GL_DEBUG_CALLBACK_USER_PARAM -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#endif -#ifndef GL_DEBUG_SOURCE_API -#define GL_DEBUG_SOURCE_API 0x8246 -#endif -#ifndef GL_DEBUG_SOURCE_WINDOW_SYSTEM -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#endif -#ifndef GL_DEBUG_SOURCE_SHADER_COMPILER -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#endif -#ifndef GL_DEBUG_SOURCE_THIRD_PARTY -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#endif -#ifndef GL_DEBUG_SOURCE_APPLICATION -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#endif -#ifndef GL_DEBUG_SOURCE_OTHER -#define GL_DEBUG_SOURCE_OTHER 0x824B -#endif -#ifndef GL_DEBUG_TYPE_ERROR -#define GL_DEBUG_TYPE_ERROR 0x824C -#endif -#ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#endif -#ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#endif -#ifndef GL_DEBUG_TYPE_PORTABILITY -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#endif -#ifndef GL_DEBUG_TYPE_PERFORMANCE -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#endif -#ifndef GL_DEBUG_TYPE_OTHER -#define GL_DEBUG_TYPE_OTHER 0x8251 -#endif -#ifndef GL_DEBUG_TYPE_MARKER -#define GL_DEBUG_TYPE_MARKER 0x8268 -#endif -#ifndef GL_DEBUG_TYPE_PUSH_GROUP -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#endif -#ifndef GL_DEBUG_TYPE_POP_GROUP -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#endif -#ifndef GL_DEBUG_SEVERITY_NOTIFICATION -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#endif -#ifndef GL_MAX_DEBUG_GROUP_STACK_DEPTH -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#endif -#ifndef GL_DEBUG_GROUP_STACK_DEPTH -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#endif -#ifndef GL_BUFFER -#define GL_BUFFER 0x82E0 -#endif -#ifndef GL_SHADER -#define GL_SHADER 0x82E1 -#endif -#ifndef GL_PROGRAM -#define GL_PROGRAM 0x82E2 -#endif -#ifndef GL_QUERY -#define GL_QUERY 0x82E3 -#endif -#ifndef GL_PROGRAM_PIPELINE -#define GL_PROGRAM_PIPELINE 0x82E4 -#endif -#ifndef GL_SAMPLER -#define GL_SAMPLER 0x82E6 -#endif -#ifndef GL_DISPLAY_LIST -#define GL_DISPLAY_LIST 0x82E7 -#endif -#ifndef GL_MAX_LABEL_LENGTH -#define GL_MAX_LABEL_LENGTH 0x82E8 -#endif -#ifndef GL_MAX_DEBUG_MESSAGE_LENGTH -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#endif -#ifndef GL_MAX_DEBUG_LOGGED_MESSAGES -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#endif -#ifndef GL_DEBUG_LOGGED_MESSAGES -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#endif -#ifndef GL_DEBUG_SEVERITY_HIGH -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#endif -#ifndef GL_DEBUG_SEVERITY_MEDIUM -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#endif -#ifndef GL_DEBUG_SEVERITY_LOW -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#endif -#ifndef GL_DEBUG_OUTPUT -#define GL_DEBUG_OUTPUT 0x92E0 -#endif -#ifndef GL_CONTEXT_FLAG_DEBUG_BIT -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#endif -#ifndef GL_STACK_OVERFLOW -#define GL_STACK_OVERFLOW 0x0503 -#endif -#ifndef GL_STACK_UNDERFLOW -#define GL_STACK_UNDERFLOW 0x0504 -#endif - -typedef void (QOPENGLF_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); - -#endif /* USE_MANUAL_DEFS */ - - -/*! - \internal -*/ -static QOpenGLDebugMessage::Source qt_messageSourceFromGL(GLenum source) -{ - switch (source) { - case GL_DEBUG_SOURCE_API: - return QOpenGLDebugMessage::APISource; - case GL_DEBUG_SOURCE_WINDOW_SYSTEM: - return QOpenGLDebugMessage::WindowSystemSource; - case GL_DEBUG_SOURCE_SHADER_COMPILER: - return QOpenGLDebugMessage::ShaderCompilerSource; - case GL_DEBUG_SOURCE_THIRD_PARTY: - return QOpenGLDebugMessage::ThirdPartySource; - case GL_DEBUG_SOURCE_APPLICATION: - return QOpenGLDebugMessage::ApplicationSource; - case GL_DEBUG_SOURCE_OTHER: - return QOpenGLDebugMessage::OtherSource; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source from GL"); - return QOpenGLDebugMessage::OtherSource; -} - -/*! - \internal -*/ -static GLenum qt_messageSourceToGL(QOpenGLDebugMessage::Source source) -{ - switch (source) { - case QOpenGLDebugMessage::InvalidSource: - break; - case QOpenGLDebugMessage::APISource: - return GL_DEBUG_SOURCE_API; - case QOpenGLDebugMessage::WindowSystemSource: - return GL_DEBUG_SOURCE_WINDOW_SYSTEM; - case QOpenGLDebugMessage::ShaderCompilerSource: - return GL_DEBUG_SOURCE_SHADER_COMPILER; - case QOpenGLDebugMessage::ThirdPartySource: - return GL_DEBUG_SOURCE_THIRD_PARTY; - case QOpenGLDebugMessage::ApplicationSource: - return GL_DEBUG_SOURCE_APPLICATION; - case QOpenGLDebugMessage::OtherSource: - return GL_DEBUG_SOURCE_OTHER; - case QOpenGLDebugMessage::AnySource: - break; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message source"); - return GL_DEBUG_SOURCE_OTHER; -} - -/*! - \internal -*/ -static QString qt_messageSourceToString(QOpenGLDebugMessage::Source source) -{ - switch (source) { - case QOpenGLDebugMessage::InvalidSource: - return QStringLiteral("InvalidSource"); - case QOpenGLDebugMessage::APISource: - return QStringLiteral("APISource"); - case QOpenGLDebugMessage::WindowSystemSource: - return QStringLiteral("WindowSystemSource"); - case QOpenGLDebugMessage::ShaderCompilerSource: - return QStringLiteral("ShaderCompilerSource"); - case QOpenGLDebugMessage::ThirdPartySource: - return QStringLiteral("ThirdPartySource"); - case QOpenGLDebugMessage::ApplicationSource: - return QStringLiteral("ApplicationSource"); - case QOpenGLDebugMessage::OtherSource: - return QStringLiteral("OtherSource"); - case QOpenGLDebugMessage::AnySource: - return QStringLiteral("AnySource"); - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source"); - return QString(); -} - -/*! - \internal -*/ -static QOpenGLDebugMessage::Type qt_messageTypeFromGL(GLenum type) -{ - switch (type) { - case GL_DEBUG_TYPE_ERROR: - return QOpenGLDebugMessage::ErrorType; - case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: - return QOpenGLDebugMessage::DeprecatedBehaviorType; - case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: - return QOpenGLDebugMessage::UndefinedBehaviorType; - case GL_DEBUG_TYPE_PORTABILITY: - return QOpenGLDebugMessage::PortabilityType; - case GL_DEBUG_TYPE_PERFORMANCE: - return QOpenGLDebugMessage::PerformanceType; - case GL_DEBUG_TYPE_OTHER: - return QOpenGLDebugMessage::OtherType; - case GL_DEBUG_TYPE_MARKER: - return QOpenGLDebugMessage::MarkerType; - case GL_DEBUG_TYPE_PUSH_GROUP: - return QOpenGLDebugMessage::GroupPushType; - case GL_DEBUG_TYPE_POP_GROUP: - return QOpenGLDebugMessage::GroupPopType; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type from GL"); - return QOpenGLDebugMessage::OtherType; -} - -/*! - \internal -*/ -static GLenum qt_messageTypeToGL(QOpenGLDebugMessage::Type type) -{ - switch (type) { - case QOpenGLDebugMessage::InvalidType: - break; - case QOpenGLDebugMessage::ErrorType: - return GL_DEBUG_TYPE_ERROR; - case QOpenGLDebugMessage::DeprecatedBehaviorType: - return GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; - case QOpenGLDebugMessage::UndefinedBehaviorType: - return GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; - case QOpenGLDebugMessage::PortabilityType: - return GL_DEBUG_TYPE_PORTABILITY; - case QOpenGLDebugMessage::PerformanceType: - return GL_DEBUG_TYPE_PERFORMANCE; - case QOpenGLDebugMessage::OtherType: - return GL_DEBUG_TYPE_OTHER; - case QOpenGLDebugMessage::MarkerType: - return GL_DEBUG_TYPE_MARKER; - case QOpenGLDebugMessage::GroupPushType: - return GL_DEBUG_TYPE_PUSH_GROUP; - case QOpenGLDebugMessage::GroupPopType: - return GL_DEBUG_TYPE_POP_GROUP; - case QOpenGLDebugMessage::AnyType: - break; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type"); - return GL_DEBUG_TYPE_OTHER; -} - -/*! - \internal -*/ -static QString qt_messageTypeToString(QOpenGLDebugMessage::Type type) -{ - switch (type) { - case QOpenGLDebugMessage::InvalidType: - return QStringLiteral("InvalidType"); - case QOpenGLDebugMessage::ErrorType: - return QStringLiteral("ErrorType"); - case QOpenGLDebugMessage::DeprecatedBehaviorType: - return QStringLiteral("DeprecatedBehaviorType"); - case QOpenGLDebugMessage::UndefinedBehaviorType: - return QStringLiteral("UndefinedBehaviorType"); - case QOpenGLDebugMessage::PortabilityType: - return QStringLiteral("PortabilityType"); - case QOpenGLDebugMessage::PerformanceType: - return QStringLiteral("PerformanceType"); - case QOpenGLDebugMessage::OtherType: - return QStringLiteral("OtherType"); - case QOpenGLDebugMessage::MarkerType: - return QStringLiteral("MarkerType"); - case QOpenGLDebugMessage::GroupPushType: - return QStringLiteral("GroupPushType"); - case QOpenGLDebugMessage::GroupPopType: - return QStringLiteral("GroupPopType"); - case QOpenGLDebugMessage::AnyType: - return QStringLiteral("AnyType"); - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type"); - return QString(); -} - -/*! - \internal -*/ -static QOpenGLDebugMessage::Severity qt_messageSeverityFromGL(GLenum severity) -{ - switch (severity) { - case GL_DEBUG_SEVERITY_HIGH: - return QOpenGLDebugMessage::HighSeverity; - case GL_DEBUG_SEVERITY_MEDIUM: - return QOpenGLDebugMessage::MediumSeverity; - case GL_DEBUG_SEVERITY_LOW: - return QOpenGLDebugMessage::LowSeverity; - case GL_DEBUG_SEVERITY_NOTIFICATION: - return QOpenGLDebugMessage::NotificationSeverity; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity from GL"); - return QOpenGLDebugMessage::NotificationSeverity; -} - -/*! - \internal -*/ -static GLenum qt_messageSeverityToGL(QOpenGLDebugMessage::Severity severity) -{ - switch (severity) { - case QOpenGLDebugMessage::InvalidSeverity: - break; - case QOpenGLDebugMessage::HighSeverity: - return GL_DEBUG_SEVERITY_HIGH; - case QOpenGLDebugMessage::MediumSeverity: - return GL_DEBUG_SEVERITY_MEDIUM; - case QOpenGLDebugMessage::LowSeverity: - return GL_DEBUG_SEVERITY_LOW; - case QOpenGLDebugMessage::NotificationSeverity: - return GL_DEBUG_SEVERITY_NOTIFICATION; - case QOpenGLDebugMessage::AnySeverity: - break; - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message severity"); - return GL_DEBUG_SEVERITY_NOTIFICATION; -} - -/*! - \internal -*/ -static QString qt_messageSeverityToString(QOpenGLDebugMessage::Severity severity) -{ - switch (severity) { - case QOpenGLDebugMessage::InvalidSeverity: - return QStringLiteral("InvalidSeverity"); - case QOpenGLDebugMessage::HighSeverity: - return QStringLiteral("HighSeverity"); - case QOpenGLDebugMessage::MediumSeverity: - return QStringLiteral("MediumSeverity"); - case QOpenGLDebugMessage::LowSeverity: - return QStringLiteral("LowSeverity"); - case QOpenGLDebugMessage::NotificationSeverity: - return QStringLiteral("NotificationSeverity"); - case QOpenGLDebugMessage::AnySeverity: - return QStringLiteral("AnySeverity"); - } - - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity"); - return QString(); -} - -class QOpenGLDebugMessagePrivate : public QSharedData -{ -public: - QOpenGLDebugMessagePrivate(); - - QString message; - GLuint id; - QOpenGLDebugMessage::Source source; - QOpenGLDebugMessage::Type type; - QOpenGLDebugMessage::Severity severity; -}; - -/*! - \internal -*/ -QOpenGLDebugMessagePrivate::QOpenGLDebugMessagePrivate() - : message(), - id(0), - source(QOpenGLDebugMessage::InvalidSource), - type(QOpenGLDebugMessage::InvalidType), - severity(QOpenGLDebugMessage::InvalidSeverity) -{ -} - - -/*! - Constructs a debug message with an empty message string, id set to 0, - source set to InvalidSource, type set to InvalidType, and severity set to - InvalidSeverity. - - \note This constructor should not be used to create a debug message; - instead, use the createApplicationMessage() or the createThirdPartyMessage() - static functions. - - \sa createApplicationMessage(), createThirdPartyMessage() -*/ -QOpenGLDebugMessage::QOpenGLDebugMessage() - : d(new QOpenGLDebugMessagePrivate) -{ -} - -/*! - Constructs a debug message as a copy of \a debugMessage. - - \sa operator=() -*/ -QOpenGLDebugMessage::QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage) - : d(debugMessage.d) -{ -} - -/*! - Destroys this debug message. -*/ -QOpenGLDebugMessage::~QOpenGLDebugMessage() -{ -} - -/*! - Assigns the message \a debugMessage to this object, and returns a reference - to the copy. -*/ -QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(const QOpenGLDebugMessage &debugMessage) -{ - d = debugMessage.d; - return *this; -} - -/*! - \fn QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(QOpenGLDebugMessage &&debugMessage) - - Move-assigns \a debugMessage to this object. -*/ - -/*! - \fn void QOpenGLDebugMessage::swap(QOpenGLDebugMessage &debugMessage) - - Swaps the message \a debugMessage with this message. This operation is very - fast and never fails. -*/ - -/*! - Returns the source of the debug message. -*/ -QOpenGLDebugMessage::Source QOpenGLDebugMessage::source() const -{ - return d->source; -} - -/*! - Returns the type of the debug message. -*/ -QOpenGLDebugMessage::Type QOpenGLDebugMessage::type() const -{ - return d->type; -} - -/*! - Returns the severity of the debug message. -*/ -QOpenGLDebugMessage::Severity QOpenGLDebugMessage::severity() const -{ - return d->severity; -} - -/*! - Returns the id of the debug message. Ids are generally vendor-specific. -*/ -GLuint QOpenGLDebugMessage::id() const -{ - return d->id; -} - -/*! - Returns the textual message contained by this debug message. -*/ -QString QOpenGLDebugMessage::message() const -{ - return d->message; -} - -/*! - Constructs and returns a debug message with \a text as its text, \a id - as id, \a severity as severity, and \a type as type. The message source - will be set to ApplicationSource. - - \sa QOpenGLDebugLogger::logMessage(), createThirdPartyMessage() -*/ -QOpenGLDebugMessage QOpenGLDebugMessage::createApplicationMessage(const QString &text, - GLuint id, - QOpenGLDebugMessage::Severity severity, - QOpenGLDebugMessage::Type type) -{ - QOpenGLDebugMessage m; - m.d->message = text; - m.d->id = id; - m.d->severity = severity; - m.d->type = type; - m.d->source = ApplicationSource; - return m; -} - -/*! - Constructs and returns a debug message with \a text as its text, \a id - as id, \a severity as severity, and \a type as type. The message source - will be set to ThirdPartySource. - - \sa QOpenGLDebugLogger::logMessage(), createApplicationMessage() -*/ -QOpenGLDebugMessage QOpenGLDebugMessage::createThirdPartyMessage(const QString &text, - GLuint id, - QOpenGLDebugMessage::Severity severity, - QOpenGLDebugMessage::Type type) -{ - QOpenGLDebugMessage m; - m.d->message = text; - m.d->id = id; - m.d->severity = severity; - m.d->type = type; - m.d->source = ThirdPartySource; - return m; -} - -/*! - Returns \c true if this debug message is equal to \a debugMessage, or false - otherwise. Two debugging messages are equal if they have the same textual - message, the same id, the same source, the same type and the same severity. - - \sa operator!=() -*/ -bool QOpenGLDebugMessage::operator==(const QOpenGLDebugMessage &debugMessage) const -{ - return (d == debugMessage.d) - || (d->id == debugMessage.d->id - && d->source == debugMessage.d->source - && d->type == debugMessage.d->type - && d->severity == debugMessage.d->severity - && d->message == debugMessage.d->message); -} - -/*! - \fn bool QOpenGLDebugMessage::operator!=(const QOpenGLDebugMessage &debugMessage) const - - Returns \c true if this message is different from \a debugMessage, or false - otherwise. - - \sa operator==() -*/ - -#ifndef QT_NO_DEBUG_STREAM -/*! - \relates QOpenGLDebugMessage - - Writes the source \a source into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage::Source(" - << qt_messageSourceToString(source) - << ')'; - return debug; -} - -/*! - \relates QOpenGLDebugMessage - - Writes the type \a type into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage::Type(" - << qt_messageTypeToString(type) - << ')'; - return debug; -} - -/*! - \relates QOpenGLDebugMessage - - Writes the severity \a severity into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage::Severity(" - << qt_messageSeverityToString(severity) - << ')'; - return debug; -} - -/*! - \relates QOpenGLDebugMessage - - Writes the message \a message into the debug object \a debug for debugging - purposes. -*/ -QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QOpenGLDebugMessage(" - << qt_messageSourceToString(message.source()) << ", " - << message.id() << ", " - << message.message() << ", " - << qt_messageSeverityToString(message.severity()) << ", " - << qt_messageTypeToString(message.type()) << ')'; - return debug; - -} -#endif // QT_NO_DEBUG_STREAM - -typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageControl_t)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageInsert_t)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageCallback_t)(GLDEBUGPROC callback, const void *userParam); -typedef GLuint (QOPENGLF_APIENTRYP qt_glGetDebugMessageLog_t)(GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (QOPENGLF_APIENTRYP qt_glPushDebugGroup_t)(GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (QOPENGLF_APIENTRYP qt_glPopDebugGroup_t)(); -typedef void (QOPENGLF_APIENTRYP qt_glGetPointerv_t)(GLenum pname, GLvoid **params); - -class QOpenGLDebugLoggerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QOpenGLDebugLogger) -public: - QOpenGLDebugLoggerPrivate(); - - void handleMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *rawMessage); - void controlDebugMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities, - const QVector<GLuint> &ids, - const QByteArray &callerName, - bool enable); - void _q_contextAboutToBeDestroyed(); - - qt_glDebugMessageControl_t glDebugMessageControl; - qt_glDebugMessageInsert_t glDebugMessageInsert; - qt_glDebugMessageCallback_t glDebugMessageCallback; - qt_glGetDebugMessageLog_t glGetDebugMessageLog; - qt_glPushDebugGroup_t glPushDebugGroup; - qt_glPopDebugGroup_t glPopDebugGroup; - qt_glGetPointerv_t glGetPointerv; - - GLDEBUGPROC oldDebugCallbackFunction; - void *oldDebugCallbackParameter; - QOpenGLContext *context; - GLint maxMessageLength; - QOpenGLDebugLogger::LoggingMode loggingMode; - bool initialized : 1; - bool isLogging : 1; - bool debugWasEnabled : 1; - bool syncDebugWasEnabled : 1; -}; - -/*! - \internal -*/ -QOpenGLDebugLoggerPrivate::QOpenGLDebugLoggerPrivate() - : glDebugMessageControl(nullptr), - glDebugMessageInsert(nullptr), - glDebugMessageCallback(nullptr), - glGetDebugMessageLog(nullptr), - glPushDebugGroup(nullptr), - glPopDebugGroup(nullptr), - oldDebugCallbackFunction(nullptr), - context(nullptr), - maxMessageLength(0), - loggingMode(QOpenGLDebugLogger::AsynchronousLogging), - initialized(false), - isLogging(false), - debugWasEnabled(false), - syncDebugWasEnabled(false) -{ -} - -/*! - \internal -*/ -void QOpenGLDebugLoggerPrivate::handleMessage(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar *rawMessage) -{ - if (oldDebugCallbackFunction) - oldDebugCallbackFunction(source, type, id, severity, length, rawMessage, oldDebugCallbackParameter); - - QOpenGLDebugMessage message; - - QOpenGLDebugMessagePrivate *messagePrivate = message.d.data(); - messagePrivate->source = qt_messageSourceFromGL(source); - messagePrivate->type = qt_messageTypeFromGL(type); - messagePrivate->id = id; - messagePrivate->severity = qt_messageSeverityFromGL(severity); - // not passing the length to fromUtf8, as some bugged OpenGL drivers - // do not handle the length correctly. Just rely on the message to be NUL terminated. - messagePrivate->message = QString::fromUtf8(rawMessage); - - Q_Q(QOpenGLDebugLogger); - emit q->messageLogged(message); -} - -/*! - \internal -*/ -void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities, - const QVector<GLuint> &ids, - const QByteArray &callerName, - bool enable) -{ - if (!initialized) { - qWarning("QOpenGLDebugLogger::%s(): object must be initialized before enabling/disabling messages", callerName.constData()); - return; - } - if (sources == QOpenGLDebugMessage::InvalidSource) { - qWarning("QOpenGLDebugLogger::%s(): invalid source specified", callerName.constData()); - return; - } - if (types == QOpenGLDebugMessage::InvalidType) { - qWarning("QOpenGLDebugLogger::%s(): invalid type specified", callerName.constData()); - return; - } - if (severities == QOpenGLDebugMessage::InvalidSeverity) { - qWarning("QOpenGLDebugLogger::%s(): invalid severity specified", callerName.constData()); - return; - } - - QVarLengthArray<GLenum, 8> glSources; - QVarLengthArray<GLenum, 8> glTypes; - QVarLengthArray<GLenum, 8> glSeverities; - - if (ids.count() > 0) { - Q_ASSERT(severities == QOpenGLDebugMessage::AnySeverity); - - // The GL_KHR_debug extension says: - // - // - If <count> is greater than zero, then <ids> is an array of <count> - // message IDs for the specified combination of <source> and <type>. In - // this case, if <source> or <type> is DONT_CARE, or <severity> is not - // DONT_CARE, the error INVALID_OPERATION is generated. If <count> is - // zero, the value if <ids> is ignored. - // - // This means we can't convert AnySource or AnyType into DONT_CARE, but we have to roll - // them into individual sources/types. - - if (sources == QOpenGLDebugMessage::AnySource) { - sources = QOpenGLDebugMessage::InvalidSource; - for (uint i = 1; i <= QOpenGLDebugMessage::LastSource; i = i << 1) - sources |= QOpenGLDebugMessage::Source(i); - } - - if (types == QOpenGLDebugMessage::AnyType) { - types = QOpenGLDebugMessage::InvalidType; - for (uint i = 1; i <= QOpenGLDebugMessage::LastType; i = i << 1) - types |= QOpenGLDebugMessage::Type(i); - } - } - -#define CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(type, source, target) \ - if (source == QOpenGLDebugMessage::Any ## type) { \ - target << GL_DONT_CARE; \ - } else { \ - for (uint i = 1; i <= QOpenGLDebugMessage::Last ## type; i = i << 1) \ - if (source.testFlag(QOpenGLDebugMessage:: type (i))) \ - target << qt_message ## type ## ToGL (QOpenGLDebugMessage:: type (i)); \ - } - - CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Source, sources, glSources) - CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Type, types, glTypes) - CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Severity, severities, glSeverities) -#undef CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS - - const GLsizei idCount = ids.count(); - // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored. - // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case. - const GLuint * const idPtr = idCount ? ids.constData() : nullptr; - - for (GLenum source : glSources) - for (GLenum type : glTypes) - for (GLenum severity : glSeverities) - glDebugMessageControl(source, type, severity, idCount, idPtr, GLboolean(enable)); -} - -/*! - \internal -*/ -void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() -{ - Q_ASSERT(context); - - // Re-make our context current somehow, otherwise stopLogging will fail. - - // Save the current context and its surface in case we need to set them back - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - QSurface *currentSurface = nullptr; - - QScopedPointer<QOffscreenSurface> offscreenSurface; - - if (context != currentContext) { - // Make our old context current on a temporary surface - if (currentContext) - currentSurface = currentContext->surface(); - - offscreenSurface.reset(new QOffscreenSurface); - offscreenSurface->setFormat(context->format()); - offscreenSurface->create(); - if (!context->makeCurrent(offscreenSurface.data())) - qWarning("QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup"); - } - - Q_Q(QOpenGLDebugLogger); - q->stopLogging(); - - if (offscreenSurface) { - // We did change the current context: set it back - if (currentContext) - currentContext->makeCurrent(currentSurface); - else - context->doneCurrent(); - } - - QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); - context = nullptr; - initialized = false; -} - -extern "C" { -static void QOPENGLF_APIENTRY qt_opengl_debug_callback(GLenum source, - GLenum type, - GLuint id, - GLenum severity, - GLsizei length, - const GLchar *rawMessage, - const GLvoid *userParam) -{ - QOpenGLDebugLoggerPrivate *loggerPrivate = static_cast<QOpenGLDebugLoggerPrivate *>(const_cast<GLvoid *>(userParam)); - loggerPrivate->handleMessage(source, type, id, severity, length, rawMessage); -} -} - -/*! - Constructs a new logger object with the given \a parent. - - \note The object must be initialized before logging can happen. - - \sa initialize() -*/ -QOpenGLDebugLogger::QOpenGLDebugLogger(QObject *parent) - : QObject(*new QOpenGLDebugLoggerPrivate, parent) -{ - // QOpenGLDebugMessage is going to be mostly used as an argument - // of a cross thread connection, therefore let's ease the life for the users - // and register the type for them. - qRegisterMetaType<QOpenGLDebugMessage>(); -} - -/*! - Destroys the logger object. -*/ -QOpenGLDebugLogger::~QOpenGLDebugLogger() -{ - stopLogging(); -} - -/*! - Initializes the object in the current OpenGL context. The context must - support the \c{GL_KHR_debug} extension for the initialization to succeed. - The object must be initialized before any logging can happen. - - It is safe to call this function multiple times from the same context. - - This function can also be used to change the context of a previously - initialized object; note that in this case the object must not be logging - when you call this function. - - Returns \c true if the logger is successfully initialized; false otherwise. - - \sa QOpenGLContext -*/ -bool QOpenGLDebugLogger::initialize() -{ - QOpenGLContext *context = QOpenGLContext::currentContext(); - if (!context) { - qWarning("QOpenGLDebugLogger::initialize(): no current OpenGL context found."); - return false; - } - - Q_D(QOpenGLDebugLogger); - if (d->context == context) { - // context is non-NULL, d->context is non NULL only on successful initialization. - Q_ASSERT(d->initialized); - return true; - } - - if (d->isLogging) { - qWarning("QOpenGLDebugLogger::initialize(): cannot initialize the object while logging. Please stop the logging first."); - return false; - } - - if (d->context) - disconnect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); - - d->initialized = false; - d->context = nullptr; - - if (!context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) - return false; - - d->context = context; - connect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); - -#define GET_DEBUG_PROC_ADDRESS(procName) \ - d->procName = reinterpret_cast< qt_ ## procName ## _t >( \ - d->context->getProcAddress(d->context->isOpenGLES() ? (#procName "KHR") : (#procName)) \ - ); - - GET_DEBUG_PROC_ADDRESS(glDebugMessageControl); - GET_DEBUG_PROC_ADDRESS(glDebugMessageInsert); - GET_DEBUG_PROC_ADDRESS(glDebugMessageCallback); - GET_DEBUG_PROC_ADDRESS(glGetDebugMessageLog); - GET_DEBUG_PROC_ADDRESS(glPushDebugGroup); - GET_DEBUG_PROC_ADDRESS(glPopDebugGroup); - GET_DEBUG_PROC_ADDRESS(glGetPointerv) - -#undef GET_DEBUG_PROC_ADDRESS - - QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &d->maxMessageLength); - -#ifndef QT_NO_DEBUG - if (!d->context->format().testOption(QSurfaceFormat::DebugContext)) { - qWarning("QOpenGLDebugLogger::initialize(): the current context is not a debug context:\n" - " this means that the GL may not generate any debug output at all.\n" - " To avoid this warning, try creating the context with the\n" - " QSurfaceFormat::DebugContext surface format option."); - } -#endif // QT_NO_DEBUG - - d->initialized = true; - return true; -} - -/*! - Returns \c true if this object is currently logging, false otherwise. - - \sa startLogging() -*/ -bool QOpenGLDebugLogger::isLogging() const -{ - Q_D(const QOpenGLDebugLogger); - return d->isLogging; -} - -/*! - Starts logging messages coming from the OpenGL server. When a new message - is received, the signal messageLogged() is emitted, carrying the logged - message as argument. - - \a loggingMode specifies whether the logging must be asynchronous (the default) - or synchronous. - - QOpenGLDebugLogger will record the values of \c{GL_DEBUG_OUTPUT} and - \c{GL_DEBUG_OUTPUT_SYNCHRONOUS} when logging is started, and set them back - when logging is stopped. Moreover, any user-defined OpenGL debug callback - installed when this function is invoked will be restored when logging is - stopped; QOpenGLDebugLogger will ensure that the pre-existing callback will - still be invoked when logging. - - \note It's not possible to change the logging mode without stopping and - starting logging again. This might change in a future version of Qt. - - \note The object must be initialized before logging can happen. - - \sa stopLogging(), initialize() -*/ -void QOpenGLDebugLogger::startLogging(QOpenGLDebugLogger::LoggingMode loggingMode) -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::startLogging(): object must be initialized before logging can start"); - return; - } - if (d->isLogging) { - qWarning("QOpenGLDebugLogger::startLogging(): this object is already logging"); - return; - } - - d->isLogging = true; - d->loggingMode = loggingMode; - - d->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION, reinterpret_cast<void **>(&d->oldDebugCallbackFunction)); - d->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM, &d->oldDebugCallbackParameter); - - d->glDebugMessageCallback(&qt_opengl_debug_callback, d); - - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - d->debugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT); - d->syncDebugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT_SYNCHRONOUS); - - if (d->loggingMode == SynchronousLogging) - funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - else - funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - - funcs->glEnable(GL_DEBUG_OUTPUT); -} - -/*! - Returns the logging mode of the object. - - \sa startLogging() -*/ -QOpenGLDebugLogger::LoggingMode QOpenGLDebugLogger::loggingMode() const -{ - Q_D(const QOpenGLDebugLogger); - return d->loggingMode; -} - -/*! - Stops logging messages from the OpenGL server. - - \sa startLogging() -*/ -void QOpenGLDebugLogger::stopLogging() -{ - Q_D(QOpenGLDebugLogger); - if (!d->isLogging) - return; - - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - if (!currentContext || currentContext != d->context) { - qWarning("QOpenGLDebugLogger::stopLogging(): attempting to stop logging with the wrong OpenGL context current"); - return; - } - - d->isLogging = false; - - d->glDebugMessageCallback(d->oldDebugCallbackFunction, d->oldDebugCallbackParameter); - - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - if (!d->debugWasEnabled) - funcs->glDisable(GL_DEBUG_OUTPUT); - - if (d->syncDebugWasEnabled) - funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - else - funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); -} - -/*! - Inserts the message \a debugMessage into the OpenGL debug log. This provides - a way for applications or libraries to insert custom messages that can - ease the debugging of OpenGL applications. - - \note \a debugMessage must have QOpenGLDebugMessage::ApplicationSource or - QOpenGLDebugMessage::ThirdPartySource as its source, and a valid - type and severity, otherwise it will not be inserted into the log. - - \note The object must be initialized before logging can happen. - - \sa initialize() -*/ -void QOpenGLDebugLogger::logMessage(const QOpenGLDebugMessage &debugMessage) -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::logMessage(): object must be initialized before logging messages"); - return; - } - if (debugMessage.source() != QOpenGLDebugMessage::ApplicationSource - && debugMessage.source() != QOpenGLDebugMessage::ThirdPartySource) { - qWarning("QOpenGLDebugLogger::logMessage(): using a message source different from ApplicationSource\n" - " or ThirdPartySource is not supported by GL_KHR_debug. The message will not be logged."); - return; - } - if (debugMessage.type() == QOpenGLDebugMessage::InvalidType - || debugMessage.type() == QOpenGLDebugMessage::AnyType - || debugMessage.severity() == QOpenGLDebugMessage::InvalidSeverity - || debugMessage.severity() == QOpenGLDebugMessage::AnySeverity) { - qWarning("QOpenGLDebugLogger::logMessage(): the message has a non-valid type and/or severity. The message will not be logged."); - return; - } - - const GLenum source = qt_messageSourceToGL(debugMessage.source()); - const GLenum type = qt_messageTypeToGL(debugMessage.type()); - const GLenum severity = qt_messageSeverityToGL(debugMessage.severity()); - QByteArray rawMessage = debugMessage.message().toUtf8(); - rawMessage.append('\0'); - - if (rawMessage.length() > d->maxMessageLength) { - qWarning("QOpenGLDebugLogger::logMessage(): message too long, truncating it\n" - " (%d bytes long, but the GL accepts up to %d bytes)", rawMessage.length(), d->maxMessageLength); - rawMessage.resize(d->maxMessageLength - 1); - rawMessage.append('\0'); - } - - // Don't pass rawMessage.length(), as unfortunately bugged - // OpenGL drivers will eat the trailing NUL in the message. Just rely - // on the message being NUL terminated. - d->glDebugMessageInsert(source, - type, - debugMessage.id(), - severity, - -1, - rawMessage.constData()); -} - -/*! - Pushes a debug group with name \a name, id \a id, and source \a source onto - the debug groups stack. If the group is successfully pushed, OpenGL will - automatically log a message with message \a name, id \a id, source \a - source, type QOpenGLDebugMessage::GroupPushType and severity - QOpenGLDebugMessage::NotificationSeverity. - - The newly pushed group will inherit the same filtering settings of the - group that was on the top of the stack; that is, the filtering will not be - changed by pushing a new group. - - \note The \a source must either be QOpenGLDebugMessage::ApplicationSource or - QOpenGLDebugMessage::ThirdPartySource, otherwise the group will not be pushed. - - \note The object must be initialized before managing debug groups. - - \sa popGroup(), enableMessages(), disableMessages() -*/ -void QOpenGLDebugLogger::pushGroup(const QString &name, GLuint id, QOpenGLDebugMessage::Source source) -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before pushing a debug group"); - return; - } - if (source != QOpenGLDebugMessage::ApplicationSource - && source != QOpenGLDebugMessage::ThirdPartySource) { - qWarning("QOpenGLDebugLogger::pushGroup(): using a source different from ApplicationSource\n" - " or ThirdPartySource is not supported by GL_KHR_debug. The group will not be pushed."); - return; - } - - QByteArray rawName = name.toUtf8(); - rawName.append('\0'); - if (rawName.length() > d->maxMessageLength) { - qWarning("QOpenGLDebugLogger::pushGroup(): group name too long, truncating it\n" - " (%d bytes long, but the GL accepts up to %d bytes)", rawName.length(), d->maxMessageLength); - rawName.resize(d->maxMessageLength - 1); - rawName.append('\0'); - } - - // Don't pass rawMessage.length(), as unfortunately bugged - // OpenGL drivers will eat the trailing NUL in the name. Just rely - // on the name being NUL terminated. - d->glPushDebugGroup(qt_messageSourceToGL(source), id, -1, rawName.constData()); -} - -/*! - Pops the topmost debug group from the debug groups stack. If the group is - successfully popped, OpenGL will automatically log a message with message, - id and source matching those of the popped group, type - QOpenGLDebugMessage::GroupPopType and severity - QOpenGLDebugMessage::NotificationSeverity. - - Popping a debug group will restore the message filtering settings of the - group that becomes the top of the debug groups stack. - - \note The object must be initialized before managing debug groups. - - \sa pushGroup() -*/ -void QOpenGLDebugLogger::popGroup() -{ - Q_D(QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before popping a debug group"); - return; - } - - d->glPopDebugGroup(); -} - -/*! - Enables the logging of messages from the given \a sources, of the given \a - types and with the given \a severities and any message id. - - The logging will be enabled in the current control group. - - \sa disableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::enableMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - severities, - QVector<GLuint>(), - QByteArrayLiteral("enableMessages"), - true); -} - -/*! - Enables the logging of messages with the given \a ids, from the given \a - sources and of the given \a types and any severity. - - The logging will be enabled in the current control group. - - \sa disableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::enableMessages(const QVector<GLuint> &ids, - QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - QOpenGLDebugMessage::AnySeverity, - ids, - QByteArrayLiteral("enableMessages"), - true); -} - -/*! - Disables the logging of messages with the given \a sources, of the given \a - types and with the given \a severities and any message id. - - The logging will be disabled in the current control group. - - \sa enableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::disableMessages(QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types, - QOpenGLDebugMessage::Severities severities) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - severities, - QVector<GLuint>(), - QByteArrayLiteral("disableMessages"), - false); -} - -/*! - Disables the logging of messages with the given \a ids, from the given \a - sources and of the given \a types and any severity. - - The logging will be disabled in the current control group. - - \sa enableMessages(), pushGroup(), popGroup() -*/ -void QOpenGLDebugLogger::disableMessages(const QVector<GLuint> &ids, - QOpenGLDebugMessage::Sources sources, - QOpenGLDebugMessage::Types types) -{ - Q_D(QOpenGLDebugLogger); - d->controlDebugMessages(sources, - types, - QOpenGLDebugMessage::AnySeverity, - ids, - QByteArrayLiteral("disableMessages"), - false); -} - -/*! - Reads all the available messages in the OpenGL internal debug log and - returns them. Moreover, this function will clear the internal debug log, - so that subsequent invocations will not return messages that were - already returned. - - \sa startLogging() -*/ -QList<QOpenGLDebugMessage> QOpenGLDebugLogger::loggedMessages() const -{ - Q_D(const QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::loggedMessages(): object must be initialized before reading logged messages"); - return QList<QOpenGLDebugMessage>(); - } - - static const GLuint maxMessageCount = 128; - GLuint messagesRead; - GLenum messageSources[maxMessageCount]; - GLenum messageTypes[maxMessageCount]; - GLuint messageIds[maxMessageCount]; - GLenum messageSeverities[maxMessageCount]; - GLsizei messageLengths[maxMessageCount]; - - QByteArray messagesBuffer; - messagesBuffer.resize(maxMessageCount * d->maxMessageLength); - - QList<QOpenGLDebugMessage> messages; - do { - messagesRead = d->glGetDebugMessageLog(maxMessageCount, - GLsizei(messagesBuffer.size()), - messageSources, - messageTypes, - messageIds, - messageSeverities, - messageLengths, - messagesBuffer.data()); - - const char *messagesBufferPtr = messagesBuffer.constData(); - for (GLuint i = 0; i < messagesRead; ++i) { - QOpenGLDebugMessage message; - - QOpenGLDebugMessagePrivate *messagePrivate = message.d.data(); - messagePrivate->source = qt_messageSourceFromGL(messageSources[i]); - messagePrivate->type = qt_messageTypeFromGL(messageTypes[i]); - messagePrivate->id = messageIds[i]; - messagePrivate->severity = qt_messageSeverityFromGL(messageSeverities[i]); - messagePrivate->message = QString::fromUtf8(messagesBufferPtr, messageLengths[i] - 1); - - messagesBufferPtr += messageLengths[i]; - messages << message; - } - } while (messagesRead == maxMessageCount); - - return messages; -} - -/*! - \fn void QOpenGLDebugLogger::messageLogged(const QOpenGLDebugMessage &debugMessage) - - This signal is emitted when a debug message (wrapped by the \a debugMessage - argument) is logged from the OpenGL server. - - Depending on the OpenGL implementation, this signal can be emitted - from other threads than the one(s) the receiver(s) lives in, and even - different from the thread the QOpenGLContext in which this object has - been initialized lives in. Moreover, the signal could be emitted from - multiple threads at the same time. This is normally not a problem, - as Qt will utilize a queued connection for cross-thread signal emissions, - but if you force the connection type to Direct then you must be aware of - the potential races in the slots connected to this signal. - - If logging have been started in SynchronousLogging mode, OpenGL guarantees - that this signal will be emitted from the same thread the QOpenGLContext - has been bound to, and no concurrent invocations will ever happen. - - \note Logging must have been started, or this signal will not be emitted. - - \sa startLogging() -*/ - -/*! - Returns the maximum supported length, in bytes, for the text of the messages - passed to logMessage(). This is also the maximum length of a debug group - name, as pushing or popping groups will automatically log a message with - the debug group name as the message text. - - If a message text is too long, it will be automatically truncated by - QOpenGLDebugLogger. - - \note Message texts are encoded in UTF-8 when they get passed to OpenGL, so - their size in bytes does not usually match the amount of UTF-16 code units, - as returned, for instance, by QString::length(). (It does if the message contains - 7-bit ASCII only data, which is typical for debug messages.) -*/ -qint64 QOpenGLDebugLogger::maximumMessageLength() const -{ - Q_D(const QOpenGLDebugLogger); - if (!d->initialized) { - qWarning("QOpenGLDebugLogger::maximumMessageLength(): object must be initialized before reading the maximum message length"); - return -1; - } - return d->maxMessageLength; -} - - -QT_END_NAMESPACE - -#include "moc_qopengldebug.cpp" diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h deleted file mode 100644 index 7363985d60..0000000000 --- a/src/gui/opengl/qopengldebug.h +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLDEBUG_H -#define QOPENGLDEBUG_H - -#include <QtGui/qtguiglobal.h> - -#ifndef QT_NO_OPENGL - -#include <QtCore/qshareddata.h> -#include <QtCore/qflags.h> -#include <QtCore/qlist.h> -#include <QtCore/qvector.h> -#include <QtCore/qmetatype.h> -#include <QtCore/qdebug.h> -#include <QtGui/qopenglcontext.h> - -#if defined(Q_CLANG_QDOC) -#undef GLuint -typedef unsigned int GLuint; -#endif - -QT_BEGIN_NAMESPACE - -class QOpenGLDebugLogger; -class QOpenGLDebugLoggerPrivate; -class QOpenGLDebugMessagePrivate; - -class Q_GUI_EXPORT QOpenGLDebugMessage -{ -public: - enum Source { - InvalidSource = 0x00000000, - APISource = 0x00000001, - WindowSystemSource = 0x00000002, - ShaderCompilerSource = 0x00000004, - ThirdPartySource = 0x00000008, - ApplicationSource = 0x00000010, - OtherSource = 0x00000020, - LastSource = OtherSource, // private API - AnySource = 0xffffffff - }; - Q_DECLARE_FLAGS(Sources, Source) - - enum Type { - InvalidType = 0x00000000, - ErrorType = 0x00000001, - DeprecatedBehaviorType = 0x00000002, - UndefinedBehaviorType = 0x00000004, - PortabilityType = 0x00000008, - PerformanceType = 0x00000010, - OtherType = 0x00000020, - MarkerType = 0x00000040, - GroupPushType = 0x00000080, - GroupPopType = 0x00000100, - LastType = GroupPopType, // private API - AnyType = 0xffffffff - }; - Q_DECLARE_FLAGS(Types, Type) - - enum Severity { - InvalidSeverity = 0x00000000, - HighSeverity = 0x00000001, - MediumSeverity = 0x00000002, - LowSeverity = 0x00000004, - NotificationSeverity = 0x00000008, - LastSeverity = NotificationSeverity, // private API - AnySeverity = 0xffffffff - }; - Q_DECLARE_FLAGS(Severities, Severity) - - QOpenGLDebugMessage(); - QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage); - - QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage); - QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) noexcept { swap(other); return *this; } - ~QOpenGLDebugMessage(); - - void swap(QOpenGLDebugMessage &other) noexcept { qSwap(d, other.d); } - - Source source() const; - Type type() const; - Severity severity() const; - GLuint id() const; - QString message() const; - - static QOpenGLDebugMessage createApplicationMessage(const QString &text, - GLuint id = 0, - Severity severity = NotificationSeverity, - Type type = OtherType); - static QOpenGLDebugMessage createThirdPartyMessage(const QString &text, - GLuint id = 0, - Severity severity = NotificationSeverity, - Type type = OtherType); - - bool operator==(const QOpenGLDebugMessage &debugMessage) const; - inline bool operator!=(const QOpenGLDebugMessage &debugMessage) const { return !operator==(debugMessage); } - -private: - friend class QOpenGLDebugLogger; - friend class QOpenGLDebugLoggerPrivate; - QSharedDataPointer<QOpenGLDebugMessagePrivate> d; -}; - -Q_DECLARE_SHARED(QOpenGLDebugMessage) -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Sources) -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Types) -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Severities) - -#ifndef QT_NO_DEBUG_STREAM -Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message); -Q_GUI_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source); -Q_GUI_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type); -Q_GUI_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity); -#endif - -class QOpenGLDebugLoggerPrivate; - -class Q_GUI_EXPORT QOpenGLDebugLogger : public QObject -{ - Q_OBJECT - Q_PROPERTY(LoggingMode loggingMode READ loggingMode) - -public: - enum LoggingMode { - AsynchronousLogging, - SynchronousLogging - }; - Q_ENUM(LoggingMode) - - explicit QOpenGLDebugLogger(QObject *parent = nullptr); - ~QOpenGLDebugLogger(); - - bool initialize(); - - bool isLogging() const; - LoggingMode loggingMode() const; - - qint64 maximumMessageLength() const; - - void pushGroup(const QString &name, - GLuint id = 0, - QOpenGLDebugMessage::Source source = QOpenGLDebugMessage::ApplicationSource); - void popGroup(); - - void enableMessages(QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, - QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); - - void enableMessages(const QVector<GLuint> &ids, - QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); - - void disableMessages(QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, - QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); - - void disableMessages(const QVector<GLuint> &ids, - QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, - QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); - - QList<QOpenGLDebugMessage> loggedMessages() const; - -public Q_SLOTS: - void logMessage(const QOpenGLDebugMessage &debugMessage); - void startLogging(LoggingMode loggingMode = AsynchronousLogging); - void stopLogging(); - -Q_SIGNALS: - void messageLogged(const QOpenGLDebugMessage &debugMessage); - -private: - Q_DISABLE_COPY(QOpenGLDebugLogger) - Q_DECLARE_PRIVATE(QOpenGLDebugLogger) - Q_PRIVATE_SLOT(d_func(), void _q_contextAboutToBeDestroyed()) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QOpenGLDebugMessage) - -#endif // QT_NO_OPENGL - -#endif // QOPENGLDEBUG_H diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 811eecaeba..b9d0c6213d 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -9,6 +9,10 @@ qtConfig(opengl): CONFIG += opengl qtConfig(opengles2): CONFIG += opengles2 HEADERS += \ + qopengldebug.h \ qtopenglglobal.h +SOURCES += \ + qopengldebug.cpp + load(qt_module) diff --git a/src/opengl/qopengldebug.cpp b/src/opengl/qopengldebug.cpp new file mode 100644 index 0000000000..a69f6069dc --- /dev/null +++ b/src/opengl/qopengldebug.cpp @@ -0,0 +1,1826 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/private/qobject_p.h> +#include <QtCore/qglobal.h> +#include <QtCore/qvarlengtharray.h> +#include <QtGui/qopengl.h> +#include <QtGui/qopenglfunctions.h> +#include <QtGui/qoffscreensurface.h> + +#include "qopengldebug.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QOpenGLDebugMessage + \brief The QOpenGLDebugMessage class wraps an OpenGL debug message. + \inmodule QtOpenGL + \reentrant + \since 5.1 + \ingroup shared + \ingroup painting-3D + + Debug messages are usually created by the OpenGL server and then read by + OpenGL clients (either from the OpenGL internal debug log, or logged in real-time). + A debug message has a textual representation, a vendor-specific numeric id, + a source, a type and a severity. + + It's also possible for applications or third-party libraries and toolkits + to create and insert messages in the debug log. In order to do so, you can use + the createApplicationMessage() or the createThirdPartyMessage() static functions. + + \sa QOpenGLDebugLogger +*/ + +/*! + \class QOpenGLDebugLogger + \brief The QOpenGLDebugLogger enables logging of OpenGL debugging messages. + \inmodule QtOpenGL + \since 5.1 + \ingroup painting-3D + + \tableofcontents + + \section1 Introduction + + OpenGL programming can be very error prone. Most of the time, a single + failing call to OpenGL can cause an entire portion of an application to + stop working, with nothing being drawn on the screen. + + The only way to be sure that no errors are being returned from the OpenGL + implementation is checking with \c{glGetError} after each and every API + call. Moreover, OpenGL errors stack up, therefore glGetError should always + be used in a loop like this: + + \snippet code/src_gui_opengl_qopengldebug.cpp 0 + + If you try to clear the error stack, make sure not just keep going until + GL_NO_ERROR is returned but also break on GL_CONTEXT_LOST as that error + value will keep repeating. + + There are also many other information we are interested in (as application + developers), for instance performance issues, or warnings about using + deprecated APIs. Those kind of messages are not reported through the + ordinary OpenGL error reporting mechanisms. + + QOpenGLDebugLogger aims at addressing these issues by providing access to + the \e{OpenGL debug log}. If your OpenGL implementation supports it (by + exposing the \c{GL_KHR_debug} extension), messages from the OpenGL server + will be either logged in an internal OpenGL log, or passed in "real-time" + to listeners as they're generated from OpenGL. + + QOpenGLDebugLogger supports both these modes of operation. Refer to the + following sections to find out the differences between them. + + \section1 Creating an OpenGL Debug Context + + For efficiency reasons, OpenGL implementations are allowed not to create + any debug output at all, unless the OpenGL context is a debug context. In order + to create a debug context from Qt, you must set the QSurfaceFormat::DebugContext + format option on the QSurfaceFormat used to create the QOpenGLContext object: + + \snippet code/src_gui_opengl_qopengldebug.cpp 1 + + Note that requesting a 3.2 OpenGL Core Profile is just for the example's + purposes; this class is not tied to any specific OpenGL or OpenGL ES + version, as it relies on the availability of the \c{GL_KHR_debug} extension + (see below). + + \section1 Creating and Initializing a QOpenGLDebugLogger + + QOpenGLDebugLogger is a simple QObject-derived class. Just like all QObject + subclasses, you create an instance (and optionally specify a parent + object), and like the other OpenGL functions in Qt you \e{must} initialize + it before usage by calling initialize() whilst there is a current OpenGL context: + + \snippet code/src_gui_opengl_qopengldebug.cpp 2 + + Note that the \c{GL_KHR_debug} extension \e{must} be available in the context + in order to access the messages logged by OpenGL. You can check the + presence of this extension by calling: + + \snippet code/src_gui_opengl_qopengldebug.cpp 3 + + where \c{ctx} is a valid QOpenGLContext. If the extension is not available, + initialize() will return false. + + \section1 Reading the Internal OpenGL Debug Log + + OpenGL implementations keep an internal log of debug messages. Messages + stored in this log can be retrieved by using the loggedMessages() function: + + \snippet code/src_gui_opengl_qopengldebug.cpp 4 + + The internal log has a limited size; when it fills up, older messages will + get discarded to make room for the new incoming messages. When you call + loggedMessages(), the internal log will be emptied as well. + + If you want to be sure not to lose any debug message, you must use real-time + logging instead of calling this function. However, debug messages might + still be generated in the timespan between context creation and activation + of real-time logging (or, in general, when the real-time logging is disabled). + + \section1 Real-time logging of messages + + It is also possible to receive a stream of debug messages from the OpenGL + server \e{as they are generated} by the implementation. In order to do so, + you need to connect a suitable slot to the messageLogged() signal, and + start logging by calling startLogging(): + + \snippet code/src_gui_opengl_qopengldebug.cpp 5 + + Similarly, logging can be disabled at any time by calling the stopLogging() + function. + + Real-time logging can be either asynchronous or synchronous, depending on + the parameter passed to startLogging(). When logging in asynchronous mode + (the default, as it has a very small overhead), the OpenGL implementation + can generate messages at any time, and/or in an order which is different from the + order of the OpenGL commands which caused those messages to be logged. + The messages could also be generated from a thread that it's different from + the thread the context is currently bound to. This is because OpenGL + implementations are usually highly threaded and asynchronous, and therefore + no warranties are made about the relative order and the timings of the + debug messages. + + On the other hand, logging in synchronous mode has a high overhead, but + the OpenGL implementation guarantees that all the messages caused by a + certain command are received in order, before the command returns, + and from the same thread the OpenGL context is bound to. + + This means that when logging in synchronous mode you will be able to run + your OpenGL application in a debugger, put a breakpoint on a slot connected + to the messageLogged() signal, and see in the backtrace the exact call + that caused the logged message. This can be extremely useful to debug + an OpenGL problem. Note that if OpenGL rendering is happening in another + thread, you must force the signal/slot connection type to Qt::DirectConnection + in order to be able to see the actual backtrace. + + Refer to the LoggingMode enum documentation for more information about + logging modes. + + \note When real-time logging is enabled, debug messages will \e{not} be + inserted in the internal OpenGL debug log any more; messages already + present in the internal log will not be deleted, nor they will be emitted + through the messageLogged() signal. Since some messages might be generated + before real-time logging is started (and therefore be kept in the internal + OpenGL log), it is important to always check if it contains any message + after calling startLogging(). + + \section1 Inserting Messages in the Debug Log + + It is possible for applications and libraries to insert custom messages in + the debug log, for instance for marking a group of related OpenGL commands + and therefore being then able to identify eventual messages coming from them. + + In order to do so, you can create a QOpenGLDebugMessage object by calling + \l{QOpenGLDebugMessage::}{createApplicationMessage()} or + \l{QOpenGLDebugMessage::}{createThirdPartyMessage()}, and then inserting it + into the log by calling logMessage(): + + \snippet code/src_gui_opengl_qopengldebug.cpp 6 + + Note that OpenGL implementations have a vendor-specific limit to the length + of the messages that can be inserted in the debug log. You can retrieve + this length by calling the maximumMessageLength() method; messages longer + than the limit will automatically get truncated. + + \section1 Controlling the Debug Output + + QOpenGLDebugMessage is also able to apply filters to the debug messages, and + therefore limit the amount of messages logged. You can enable or disable + logging of messages by calling enableMessages() and disableMessages() + respectively. By default, all messages are logged. + + It is possible to enable or disable messages by selecting them by: + + \list + \li source, type and severity (and including all ids in the selection); + \li id, source and type (and including all severities in the selection). + \endlist + + Note that the "enabled" status for a given message is a property of the + (id, source, type, severity) tuple; the message attributes \e{do not} form + a hierarchy of any kind. You should be careful about the order of the calls + to enableMessages() and disableMessages(), as it will change which + messages will are enabled / disabled. + + It's not possible to filter by the message text itself; applications + have to do that on their own (in slots connected to the messageLogged() + signal, or after fetching the messages in the internal debug log + through loggedMessages()). + + In order to simplify the management of the enabled / disabled statuses, + QOpenGLDebugMessage also supports the concept of \c{debug groups}. A debug + group contains the group of enabled / disabled configurations of debug + messages. Moreover, debug groups are organized in a stack: it is possible + to push and pop groups by calling pushGroup() and popGroup() respectively. + (When an OpenGL context is created, there is already a group in the stack). + + The enableMessages() and disableMessages() functions will modify the + configuration in the current debug group, that is, the one at the top of + the debug groups stack. + + When a new group is pushed onto the debug groups stack, it will inherit + the configuration of the group that was previously on the top of the stack. + Vice versa, popping a debug group will restore the configuration of + the debug group that becomes the new top. + + Pushing (respectively popping) debug groups will also automatically generate + a debug message of type QOpenGLDebugMessage::GroupPushType (respectively + \l{QOpenGLDebugMessage::}{GroupPopType}). + + \sa QOpenGLDebugMessage +*/ + +/*! + \enum QOpenGLDebugMessage::Source + + The Source enum defines the source of the debug message. + + \value InvalidSource + The source of the message is invalid; this is the source of a + default-constructed QOpenGLDebugMessage object. + + \value APISource + The message was generated in response to OpenGL API calls. + + \value WindowSystemSource + The message was generated by the window system. + + \value ShaderCompilerSource + The message was generated by the shader compiler. + + \value ThirdPartySource + The message was generated by a third party, for instance an OpenGL + framework a or debugging toolkit. + + \value ApplicationSource + The message was generated by the application itself. + + \value OtherSource + The message was generated by a source not included in this + enumeration. + + \omitvalue LastSource + + \value AnySource + This value corresponds to a mask of all possible message sources. +*/ + +/*! + \enum QOpenGLDebugMessage::Type + + The Type enum defines the type of the debug message. + + \value InvalidType + The type of the message is invalid; this is the type of a + default-constructed QOpenGLDebugMessage object. + + \value ErrorType + The message represents an error. + + \value DeprecatedBehaviorType + The message represents an usage of deprecated behavior. + + \value UndefinedBehaviorType + The message represents an usage of undefined behavior. + + \value PortabilityType + The message represents an usage of vendor-specific behavior, + that might pose portability concerns. + + \value PerformanceType + The message represents a performance issue. + + \value OtherType + The message represents a type not included in this + enumeration. + + \value MarkerType + The message represents a marker in the debug log. + + \value GroupPushType + The message represents a debug group push operation. + + \value GroupPopType + The message represents a debug group pop operation. + + \omitvalue LastType + + \value AnyType + This value corresponds to a mask of all possible message types. +*/ + +/*! + \enum QOpenGLDebugMessage::Severity + + The Severity enum defines the severity of the debug message. + + \value InvalidSeverity + The severity of the message is invalid; this is the severity of a + default-constructed QOpenGLDebugMessage object. + + \value HighSeverity + The message has a high severity. + + \value MediumSeverity + The message has a medium severity. + + \value LowSeverity + The message has a low severity. + + \value NotificationSeverity + The message is a notification. + + \omitvalue LastSeverity + + \value AnySeverity + This value corresponds to a mask of all possible message severities. +*/ + +/*! + \property QOpenGLDebugLogger::loggingMode + + \brief the logging mode passed to startLogging(). + + Note that logging must have been started or the value of this property + will be meaningless. + + \sa startLogging(), isLogging() +*/ +/*! + \enum QOpenGLDebugLogger::LoggingMode + + The LoggingMode enum defines the logging mode of the logger object. + + \value AsynchronousLogging + Messages from the OpenGL server are logged asynchronously. This means + that messages can be logged some time after the corresponding OpenGL + actions that caused them, and even be received in an out-of-order + fashion, depending on the OpenGL implementation. This mode has a very low + performance penalty, as OpenGL implementations are heavily threaded + and asynchronous by nature. + + \value SynchronousLogging + Messages from the OpenGL server are logged synchronously and + sequentially. This has a severe performance hit, as OpenGL + implementations are very asynchronous by nature; but it's very useful + to debug OpenGL problems, as OpenGL guarantees that the messages + generated by a OpenGL command will be logged before the corresponding + command execution has returned. Therefore, you can install a breakpoint + on the messageLogged() signal and see in the backtrace which OpenGL + command caused it; the only caveat is that if you are using OpenGL from + multiple threads you may need to force direct connection when + connecting to the messageLogged() signal. +*/ + +// When using OpenGL ES 2.0, all the necessary GL_KHR_debug constants are +// provided in qopengles2ext.h. Unfortunately, newer versions of that file +// suffix everything with _KHR which causes extra headache when the goal is +// to have a single piece of code that builds in all our target +// environments. Therefore, try to detect this and use our custom defines +// instead, which we anyway need for OS X. + +#if defined(GL_KHR_debug) && defined(GL_DEBUG_SOURCE_API_KHR) +#define USE_MANUAL_DEFS +#endif + +// Under OSX (at least up to 10.8) we cannot include our copy of glext.h, +// but we use the system-wide one, which unfortunately lacks all the needed +// defines/typedefs. In order to make the code compile, we just add here +// the GL_KHR_debug defines. + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#define USE_MANUAL_DEFS +#endif + +#ifdef USE_MANUAL_DEFS + +#ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#endif +#ifndef GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#endif +#ifndef GL_DEBUG_CALLBACK_FUNCTION +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#endif +#ifndef GL_DEBUG_CALLBACK_USER_PARAM +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#endif +#ifndef GL_DEBUG_SOURCE_API +#define GL_DEBUG_SOURCE_API 0x8246 +#endif +#ifndef GL_DEBUG_SOURCE_WINDOW_SYSTEM +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#endif +#ifndef GL_DEBUG_SOURCE_SHADER_COMPILER +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#endif +#ifndef GL_DEBUG_SOURCE_THIRD_PARTY +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#endif +#ifndef GL_DEBUG_SOURCE_APPLICATION +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#endif +#ifndef GL_DEBUG_SOURCE_OTHER +#define GL_DEBUG_SOURCE_OTHER 0x824B +#endif +#ifndef GL_DEBUG_TYPE_ERROR +#define GL_DEBUG_TYPE_ERROR 0x824C +#endif +#ifndef GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#endif +#ifndef GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#endif +#ifndef GL_DEBUG_TYPE_PORTABILITY +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#endif +#ifndef GL_DEBUG_TYPE_PERFORMANCE +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#endif +#ifndef GL_DEBUG_TYPE_OTHER +#define GL_DEBUG_TYPE_OTHER 0x8251 +#endif +#ifndef GL_DEBUG_TYPE_MARKER +#define GL_DEBUG_TYPE_MARKER 0x8268 +#endif +#ifndef GL_DEBUG_TYPE_PUSH_GROUP +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#endif +#ifndef GL_DEBUG_TYPE_POP_GROUP +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#endif +#ifndef GL_DEBUG_SEVERITY_NOTIFICATION +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#endif +#ifndef GL_MAX_DEBUG_GROUP_STACK_DEPTH +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#endif +#ifndef GL_DEBUG_GROUP_STACK_DEPTH +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#endif +#ifndef GL_BUFFER +#define GL_BUFFER 0x82E0 +#endif +#ifndef GL_SHADER +#define GL_SHADER 0x82E1 +#endif +#ifndef GL_PROGRAM +#define GL_PROGRAM 0x82E2 +#endif +#ifndef GL_QUERY +#define GL_QUERY 0x82E3 +#endif +#ifndef GL_PROGRAM_PIPELINE +#define GL_PROGRAM_PIPELINE 0x82E4 +#endif +#ifndef GL_SAMPLER +#define GL_SAMPLER 0x82E6 +#endif +#ifndef GL_DISPLAY_LIST +#define GL_DISPLAY_LIST 0x82E7 +#endif +#ifndef GL_MAX_LABEL_LENGTH +#define GL_MAX_LABEL_LENGTH 0x82E8 +#endif +#ifndef GL_MAX_DEBUG_MESSAGE_LENGTH +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#endif +#ifndef GL_MAX_DEBUG_LOGGED_MESSAGES +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#endif +#ifndef GL_DEBUG_LOGGED_MESSAGES +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#endif +#ifndef GL_DEBUG_SEVERITY_HIGH +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#endif +#ifndef GL_DEBUG_SEVERITY_MEDIUM +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#endif +#ifndef GL_DEBUG_SEVERITY_LOW +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#endif +#ifndef GL_DEBUG_OUTPUT +#define GL_DEBUG_OUTPUT 0x92E0 +#endif +#ifndef GL_CONTEXT_FLAG_DEBUG_BIT +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#endif +#ifndef GL_STACK_OVERFLOW +#define GL_STACK_OVERFLOW 0x0503 +#endif +#ifndef GL_STACK_UNDERFLOW +#define GL_STACK_UNDERFLOW 0x0504 +#endif + +typedef void (QOPENGLF_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); + +#endif /* USE_MANUAL_DEFS */ + + +/*! + \internal +*/ +static QOpenGLDebugMessage::Source qt_messageSourceFromGL(GLenum source) +{ + switch (source) { + case GL_DEBUG_SOURCE_API: + return QOpenGLDebugMessage::APISource; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: + return QOpenGLDebugMessage::WindowSystemSource; + case GL_DEBUG_SOURCE_SHADER_COMPILER: + return QOpenGLDebugMessage::ShaderCompilerSource; + case GL_DEBUG_SOURCE_THIRD_PARTY: + return QOpenGLDebugMessage::ThirdPartySource; + case GL_DEBUG_SOURCE_APPLICATION: + return QOpenGLDebugMessage::ApplicationSource; + case GL_DEBUG_SOURCE_OTHER: + return QOpenGLDebugMessage::OtherSource; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source from GL"); + return QOpenGLDebugMessage::OtherSource; +} + +/*! + \internal +*/ +static GLenum qt_messageSourceToGL(QOpenGLDebugMessage::Source source) +{ + switch (source) { + case QOpenGLDebugMessage::InvalidSource: + break; + case QOpenGLDebugMessage::APISource: + return GL_DEBUG_SOURCE_API; + case QOpenGLDebugMessage::WindowSystemSource: + return GL_DEBUG_SOURCE_WINDOW_SYSTEM; + case QOpenGLDebugMessage::ShaderCompilerSource: + return GL_DEBUG_SOURCE_SHADER_COMPILER; + case QOpenGLDebugMessage::ThirdPartySource: + return GL_DEBUG_SOURCE_THIRD_PARTY; + case QOpenGLDebugMessage::ApplicationSource: + return GL_DEBUG_SOURCE_APPLICATION; + case QOpenGLDebugMessage::OtherSource: + return GL_DEBUG_SOURCE_OTHER; + case QOpenGLDebugMessage::AnySource: + break; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message source"); + return GL_DEBUG_SOURCE_OTHER; +} + +/*! + \internal +*/ +static QString qt_messageSourceToString(QOpenGLDebugMessage::Source source) +{ + switch (source) { + case QOpenGLDebugMessage::InvalidSource: + return QStringLiteral("InvalidSource"); + case QOpenGLDebugMessage::APISource: + return QStringLiteral("APISource"); + case QOpenGLDebugMessage::WindowSystemSource: + return QStringLiteral("WindowSystemSource"); + case QOpenGLDebugMessage::ShaderCompilerSource: + return QStringLiteral("ShaderCompilerSource"); + case QOpenGLDebugMessage::ThirdPartySource: + return QStringLiteral("ThirdPartySource"); + case QOpenGLDebugMessage::ApplicationSource: + return QStringLiteral("ApplicationSource"); + case QOpenGLDebugMessage::OtherSource: + return QStringLiteral("OtherSource"); + case QOpenGLDebugMessage::AnySource: + return QStringLiteral("AnySource"); + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message source"); + return QString(); +} + +/*! + \internal +*/ +static QOpenGLDebugMessage::Type qt_messageTypeFromGL(GLenum type) +{ + switch (type) { + case GL_DEBUG_TYPE_ERROR: + return QOpenGLDebugMessage::ErrorType; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: + return QOpenGLDebugMessage::DeprecatedBehaviorType; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: + return QOpenGLDebugMessage::UndefinedBehaviorType; + case GL_DEBUG_TYPE_PORTABILITY: + return QOpenGLDebugMessage::PortabilityType; + case GL_DEBUG_TYPE_PERFORMANCE: + return QOpenGLDebugMessage::PerformanceType; + case GL_DEBUG_TYPE_OTHER: + return QOpenGLDebugMessage::OtherType; + case GL_DEBUG_TYPE_MARKER: + return QOpenGLDebugMessage::MarkerType; + case GL_DEBUG_TYPE_PUSH_GROUP: + return QOpenGLDebugMessage::GroupPushType; + case GL_DEBUG_TYPE_POP_GROUP: + return QOpenGLDebugMessage::GroupPopType; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type from GL"); + return QOpenGLDebugMessage::OtherType; +} + +/*! + \internal +*/ +static GLenum qt_messageTypeToGL(QOpenGLDebugMessage::Type type) +{ + switch (type) { + case QOpenGLDebugMessage::InvalidType: + break; + case QOpenGLDebugMessage::ErrorType: + return GL_DEBUG_TYPE_ERROR; + case QOpenGLDebugMessage::DeprecatedBehaviorType: + return GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; + case QOpenGLDebugMessage::UndefinedBehaviorType: + return GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; + case QOpenGLDebugMessage::PortabilityType: + return GL_DEBUG_TYPE_PORTABILITY; + case QOpenGLDebugMessage::PerformanceType: + return GL_DEBUG_TYPE_PERFORMANCE; + case QOpenGLDebugMessage::OtherType: + return GL_DEBUG_TYPE_OTHER; + case QOpenGLDebugMessage::MarkerType: + return GL_DEBUG_TYPE_MARKER; + case QOpenGLDebugMessage::GroupPushType: + return GL_DEBUG_TYPE_PUSH_GROUP; + case QOpenGLDebugMessage::GroupPopType: + return GL_DEBUG_TYPE_POP_GROUP; + case QOpenGLDebugMessage::AnyType: + break; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message type"); + return GL_DEBUG_TYPE_OTHER; +} + +/*! + \internal +*/ +static QString qt_messageTypeToString(QOpenGLDebugMessage::Type type) +{ + switch (type) { + case QOpenGLDebugMessage::InvalidType: + return QStringLiteral("InvalidType"); + case QOpenGLDebugMessage::ErrorType: + return QStringLiteral("ErrorType"); + case QOpenGLDebugMessage::DeprecatedBehaviorType: + return QStringLiteral("DeprecatedBehaviorType"); + case QOpenGLDebugMessage::UndefinedBehaviorType: + return QStringLiteral("UndefinedBehaviorType"); + case QOpenGLDebugMessage::PortabilityType: + return QStringLiteral("PortabilityType"); + case QOpenGLDebugMessage::PerformanceType: + return QStringLiteral("PerformanceType"); + case QOpenGLDebugMessage::OtherType: + return QStringLiteral("OtherType"); + case QOpenGLDebugMessage::MarkerType: + return QStringLiteral("MarkerType"); + case QOpenGLDebugMessage::GroupPushType: + return QStringLiteral("GroupPushType"); + case QOpenGLDebugMessage::GroupPopType: + return QStringLiteral("GroupPopType"); + case QOpenGLDebugMessage::AnyType: + return QStringLiteral("AnyType"); + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message type"); + return QString(); +} + +/*! + \internal +*/ +static QOpenGLDebugMessage::Severity qt_messageSeverityFromGL(GLenum severity) +{ + switch (severity) { + case GL_DEBUG_SEVERITY_HIGH: + return QOpenGLDebugMessage::HighSeverity; + case GL_DEBUG_SEVERITY_MEDIUM: + return QOpenGLDebugMessage::MediumSeverity; + case GL_DEBUG_SEVERITY_LOW: + return QOpenGLDebugMessage::LowSeverity; + case GL_DEBUG_SEVERITY_NOTIFICATION: + return QOpenGLDebugMessage::NotificationSeverity; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity from GL"); + return QOpenGLDebugMessage::NotificationSeverity; +} + +/*! + \internal +*/ +static GLenum qt_messageSeverityToGL(QOpenGLDebugMessage::Severity severity) +{ + switch (severity) { + case QOpenGLDebugMessage::InvalidSeverity: + break; + case QOpenGLDebugMessage::HighSeverity: + return GL_DEBUG_SEVERITY_HIGH; + case QOpenGLDebugMessage::MediumSeverity: + return GL_DEBUG_SEVERITY_MEDIUM; + case QOpenGLDebugMessage::LowSeverity: + return GL_DEBUG_SEVERITY_LOW; + case QOpenGLDebugMessage::NotificationSeverity: + return GL_DEBUG_SEVERITY_NOTIFICATION; + case QOpenGLDebugMessage::AnySeverity: + break; + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid message severity"); + return GL_DEBUG_SEVERITY_NOTIFICATION; +} + +/*! + \internal +*/ +static QString qt_messageSeverityToString(QOpenGLDebugMessage::Severity severity) +{ + switch (severity) { + case QOpenGLDebugMessage::InvalidSeverity: + return QStringLiteral("InvalidSeverity"); + case QOpenGLDebugMessage::HighSeverity: + return QStringLiteral("HighSeverity"); + case QOpenGLDebugMessage::MediumSeverity: + return QStringLiteral("MediumSeverity"); + case QOpenGLDebugMessage::LowSeverity: + return QStringLiteral("LowSeverity"); + case QOpenGLDebugMessage::NotificationSeverity: + return QStringLiteral("NotificationSeverity"); + case QOpenGLDebugMessage::AnySeverity: + return QStringLiteral("AnySeverity"); + } + + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown message severity"); + return QString(); +} + +class QOpenGLDebugMessagePrivate : public QSharedData +{ +public: + QOpenGLDebugMessagePrivate(); + + QString message; + GLuint id; + QOpenGLDebugMessage::Source source; + QOpenGLDebugMessage::Type type; + QOpenGLDebugMessage::Severity severity; +}; + +/*! + \internal +*/ +QOpenGLDebugMessagePrivate::QOpenGLDebugMessagePrivate() + : message(), + id(0), + source(QOpenGLDebugMessage::InvalidSource), + type(QOpenGLDebugMessage::InvalidType), + severity(QOpenGLDebugMessage::InvalidSeverity) +{ +} + + +/*! + Constructs a debug message with an empty message string, id set to 0, + source set to InvalidSource, type set to InvalidType, and severity set to + InvalidSeverity. + + \note This constructor should not be used to create a debug message; + instead, use the createApplicationMessage() or the createThirdPartyMessage() + static functions. + + \sa createApplicationMessage(), createThirdPartyMessage() +*/ +QOpenGLDebugMessage::QOpenGLDebugMessage() + : d(new QOpenGLDebugMessagePrivate) +{ +} + +/*! + Constructs a debug message as a copy of \a debugMessage. + + \sa operator=() +*/ +QOpenGLDebugMessage::QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage) + : d(debugMessage.d) +{ +} + +/*! + Destroys this debug message. +*/ +QOpenGLDebugMessage::~QOpenGLDebugMessage() +{ +} + +/*! + Assigns the message \a debugMessage to this object, and returns a reference + to the copy. +*/ +QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(const QOpenGLDebugMessage &debugMessage) +{ + d = debugMessage.d; + return *this; +} + +/*! + \fn QOpenGLDebugMessage &QOpenGLDebugMessage::operator=(QOpenGLDebugMessage &&debugMessage) + + Move-assigns \a debugMessage to this object. +*/ + +/*! + \fn void QOpenGLDebugMessage::swap(QOpenGLDebugMessage &debugMessage) + + Swaps the message \a debugMessage with this message. This operation is very + fast and never fails. +*/ + +/*! + Returns the source of the debug message. +*/ +QOpenGLDebugMessage::Source QOpenGLDebugMessage::source() const +{ + return d->source; +} + +/*! + Returns the type of the debug message. +*/ +QOpenGLDebugMessage::Type QOpenGLDebugMessage::type() const +{ + return d->type; +} + +/*! + Returns the severity of the debug message. +*/ +QOpenGLDebugMessage::Severity QOpenGLDebugMessage::severity() const +{ + return d->severity; +} + +/*! + Returns the id of the debug message. Ids are generally vendor-specific. +*/ +GLuint QOpenGLDebugMessage::id() const +{ + return d->id; +} + +/*! + Returns the textual message contained by this debug message. +*/ +QString QOpenGLDebugMessage::message() const +{ + return d->message; +} + +/*! + Constructs and returns a debug message with \a text as its text, \a id + as id, \a severity as severity, and \a type as type. The message source + will be set to ApplicationSource. + + \sa QOpenGLDebugLogger::logMessage(), createThirdPartyMessage() +*/ +QOpenGLDebugMessage QOpenGLDebugMessage::createApplicationMessage(const QString &text, + GLuint id, + QOpenGLDebugMessage::Severity severity, + QOpenGLDebugMessage::Type type) +{ + QOpenGLDebugMessage m; + m.d->message = text; + m.d->id = id; + m.d->severity = severity; + m.d->type = type; + m.d->source = ApplicationSource; + return m; +} + +/*! + Constructs and returns a debug message with \a text as its text, \a id + as id, \a severity as severity, and \a type as type. The message source + will be set to ThirdPartySource. + + \sa QOpenGLDebugLogger::logMessage(), createApplicationMessage() +*/ +QOpenGLDebugMessage QOpenGLDebugMessage::createThirdPartyMessage(const QString &text, + GLuint id, + QOpenGLDebugMessage::Severity severity, + QOpenGLDebugMessage::Type type) +{ + QOpenGLDebugMessage m; + m.d->message = text; + m.d->id = id; + m.d->severity = severity; + m.d->type = type; + m.d->source = ThirdPartySource; + return m; +} + +/*! + Returns \c true if this debug message is equal to \a debugMessage, or false + otherwise. Two debugging messages are equal if they have the same textual + message, the same id, the same source, the same type and the same severity. + + \sa operator!=() +*/ +bool QOpenGLDebugMessage::operator==(const QOpenGLDebugMessage &debugMessage) const +{ + return (d == debugMessage.d) + || (d->id == debugMessage.d->id + && d->source == debugMessage.d->source + && d->type == debugMessage.d->type + && d->severity == debugMessage.d->severity + && d->message == debugMessage.d->message); +} + +/*! + \fn bool QOpenGLDebugMessage::operator!=(const QOpenGLDebugMessage &debugMessage) const + + Returns \c true if this message is different from \a debugMessage, or false + otherwise. + + \sa operator==() +*/ + +#ifndef QT_NO_DEBUG_STREAM +/*! + \relates QOpenGLDebugMessage + + Writes the source \a source into the debug object \a debug for debugging + purposes. +*/ +QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QOpenGLDebugMessage::Source(" + << qt_messageSourceToString(source) + << ')'; + return debug; +} + +/*! + \relates QOpenGLDebugMessage + + Writes the type \a type into the debug object \a debug for debugging + purposes. +*/ +QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QOpenGLDebugMessage::Type(" + << qt_messageTypeToString(type) + << ')'; + return debug; +} + +/*! + \relates QOpenGLDebugMessage + + Writes the severity \a severity into the debug object \a debug for debugging + purposes. +*/ +QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QOpenGLDebugMessage::Severity(" + << qt_messageSeverityToString(severity) + << ')'; + return debug; +} + +/*! + \relates QOpenGLDebugMessage + + Writes the message \a message into the debug object \a debug for debugging + purposes. +*/ +QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QOpenGLDebugMessage(" + << qt_messageSourceToString(message.source()) << ", " + << message.id() << ", " + << message.message() << ", " + << qt_messageSeverityToString(message.severity()) << ", " + << qt_messageTypeToString(message.type()) << ')'; + return debug; + +} +#endif // QT_NO_DEBUG_STREAM + +typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageControl_t)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageInsert_t)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (QOPENGLF_APIENTRYP qt_glDebugMessageCallback_t)(GLDEBUGPROC callback, const void *userParam); +typedef GLuint (QOPENGLF_APIENTRYP qt_glGetDebugMessageLog_t)(GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (QOPENGLF_APIENTRYP qt_glPushDebugGroup_t)(GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (QOPENGLF_APIENTRYP qt_glPopDebugGroup_t)(); +typedef void (QOPENGLF_APIENTRYP qt_glGetPointerv_t)(GLenum pname, GLvoid **params); + +class QOpenGLDebugLoggerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QOpenGLDebugLogger) +public: + QOpenGLDebugLoggerPrivate(); + + void handleMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *rawMessage); + void controlDebugMessages(QOpenGLDebugMessage::Sources sources, + QOpenGLDebugMessage::Types types, + QOpenGLDebugMessage::Severities severities, + const QVector<GLuint> &ids, + const QByteArray &callerName, + bool enable); + void _q_contextAboutToBeDestroyed(); + + qt_glDebugMessageControl_t glDebugMessageControl; + qt_glDebugMessageInsert_t glDebugMessageInsert; + qt_glDebugMessageCallback_t glDebugMessageCallback; + qt_glGetDebugMessageLog_t glGetDebugMessageLog; + qt_glPushDebugGroup_t glPushDebugGroup; + qt_glPopDebugGroup_t glPopDebugGroup; + qt_glGetPointerv_t glGetPointerv; + + GLDEBUGPROC oldDebugCallbackFunction; + void *oldDebugCallbackParameter; + QOpenGLContext *context; + GLint maxMessageLength; + QOpenGLDebugLogger::LoggingMode loggingMode; + bool initialized : 1; + bool isLogging : 1; + bool debugWasEnabled : 1; + bool syncDebugWasEnabled : 1; +}; + +/*! + \internal +*/ +QOpenGLDebugLoggerPrivate::QOpenGLDebugLoggerPrivate() + : glDebugMessageControl(nullptr), + glDebugMessageInsert(nullptr), + glDebugMessageCallback(nullptr), + glGetDebugMessageLog(nullptr), + glPushDebugGroup(nullptr), + glPopDebugGroup(nullptr), + oldDebugCallbackFunction(nullptr), + context(nullptr), + maxMessageLength(0), + loggingMode(QOpenGLDebugLogger::AsynchronousLogging), + initialized(false), + isLogging(false), + debugWasEnabled(false), + syncDebugWasEnabled(false) +{ +} + +/*! + \internal +*/ +void QOpenGLDebugLoggerPrivate::handleMessage(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar *rawMessage) +{ + if (oldDebugCallbackFunction) + oldDebugCallbackFunction(source, type, id, severity, length, rawMessage, oldDebugCallbackParameter); + + QOpenGLDebugMessage message; + + QOpenGLDebugMessagePrivate *messagePrivate = message.d.data(); + messagePrivate->source = qt_messageSourceFromGL(source); + messagePrivate->type = qt_messageTypeFromGL(type); + messagePrivate->id = id; + messagePrivate->severity = qt_messageSeverityFromGL(severity); + // not passing the length to fromUtf8, as some bugged OpenGL drivers + // do not handle the length correctly. Just rely on the message to be NUL terminated. + messagePrivate->message = QString::fromUtf8(rawMessage); + + Q_Q(QOpenGLDebugLogger); + emit q->messageLogged(message); +} + +/*! + \internal +*/ +void QOpenGLDebugLoggerPrivate::controlDebugMessages(QOpenGLDebugMessage::Sources sources, + QOpenGLDebugMessage::Types types, + QOpenGLDebugMessage::Severities severities, + const QVector<GLuint> &ids, + const QByteArray &callerName, + bool enable) +{ + if (!initialized) { + qWarning("QOpenGLDebugLogger::%s(): object must be initialized before enabling/disabling messages", callerName.constData()); + return; + } + if (sources == QOpenGLDebugMessage::InvalidSource) { + qWarning("QOpenGLDebugLogger::%s(): invalid source specified", callerName.constData()); + return; + } + if (types == QOpenGLDebugMessage::InvalidType) { + qWarning("QOpenGLDebugLogger::%s(): invalid type specified", callerName.constData()); + return; + } + if (severities == QOpenGLDebugMessage::InvalidSeverity) { + qWarning("QOpenGLDebugLogger::%s(): invalid severity specified", callerName.constData()); + return; + } + + QVarLengthArray<GLenum, 8> glSources; + QVarLengthArray<GLenum, 8> glTypes; + QVarLengthArray<GLenum, 8> glSeverities; + + if (ids.count() > 0) { + Q_ASSERT(severities == QOpenGLDebugMessage::AnySeverity); + + // The GL_KHR_debug extension says: + // + // - If <count> is greater than zero, then <ids> is an array of <count> + // message IDs for the specified combination of <source> and <type>. In + // this case, if <source> or <type> is DONT_CARE, or <severity> is not + // DONT_CARE, the error INVALID_OPERATION is generated. If <count> is + // zero, the value if <ids> is ignored. + // + // This means we can't convert AnySource or AnyType into DONT_CARE, but we have to roll + // them into individual sources/types. + + if (sources == QOpenGLDebugMessage::AnySource) { + sources = QOpenGLDebugMessage::InvalidSource; + for (uint i = 1; i <= QOpenGLDebugMessage::LastSource; i = i << 1) + sources |= QOpenGLDebugMessage::Source(i); + } + + if (types == QOpenGLDebugMessage::AnyType) { + types = QOpenGLDebugMessage::InvalidType; + for (uint i = 1; i <= QOpenGLDebugMessage::LastType; i = i << 1) + types |= QOpenGLDebugMessage::Type(i); + } + } + +#define CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(type, source, target) \ + if (source == QOpenGLDebugMessage::Any ## type) { \ + target << GL_DONT_CARE; \ + } else { \ + for (uint i = 1; i <= QOpenGLDebugMessage::Last ## type; i = i << 1) \ + if (source.testFlag(QOpenGLDebugMessage:: type (i))) \ + target << qt_message ## type ## ToGL (QOpenGLDebugMessage:: type (i)); \ + } + + CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Source, sources, glSources) + CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Type, types, glTypes) + CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS(Severity, severities, glSeverities) +#undef CONVERT_TO_GL_DEBUG_MESSAGE_CONTROL_PARAMETERS + + const GLsizei idCount = ids.count(); + // The GL_KHR_debug extension says that if idCount is 0, idPtr must be ignored. + // Unfortunately, some bugged drivers do NOT ignore it, so pass NULL in case. + const GLuint * const idPtr = idCount ? ids.constData() : nullptr; + + for (GLenum source : glSources) + for (GLenum type : glTypes) + for (GLenum severity : glSeverities) + glDebugMessageControl(source, type, severity, idCount, idPtr, GLboolean(enable)); +} + +/*! + \internal +*/ +void QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed() +{ + Q_ASSERT(context); + + // Re-make our context current somehow, otherwise stopLogging will fail. + + // Save the current context and its surface in case we need to set them back + QOpenGLContext *currentContext = QOpenGLContext::currentContext(); + QSurface *currentSurface = nullptr; + + QScopedPointer<QOffscreenSurface> offscreenSurface; + + if (context != currentContext) { + // Make our old context current on a temporary surface + if (currentContext) + currentSurface = currentContext->surface(); + + offscreenSurface.reset(new QOffscreenSurface); + offscreenSurface->setFormat(context->format()); + offscreenSurface->create(); + if (!context->makeCurrent(offscreenSurface.data())) + qWarning("QOpenGLDebugLoggerPrivate::_q_contextAboutToBeDestroyed(): could not make the owning GL context current for cleanup"); + } + + Q_Q(QOpenGLDebugLogger); + q->stopLogging(); + + if (offscreenSurface) { + // We did change the current context: set it back + if (currentContext) + currentContext->makeCurrent(currentSurface); + else + context->doneCurrent(); + } + + QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); + context = nullptr; + initialized = false; +} + +extern "C" { +static void QOPENGLF_APIENTRY qt_opengl_debug_callback(GLenum source, + GLenum type, + GLuint id, + GLenum severity, + GLsizei length, + const GLchar *rawMessage, + const GLvoid *userParam) +{ + QOpenGLDebugLoggerPrivate *loggerPrivate = static_cast<QOpenGLDebugLoggerPrivate *>(const_cast<GLvoid *>(userParam)); + loggerPrivate->handleMessage(source, type, id, severity, length, rawMessage); +} +} + +/*! + Constructs a new logger object with the given \a parent. + + \note The object must be initialized before logging can happen. + + \sa initialize() +*/ +QOpenGLDebugLogger::QOpenGLDebugLogger(QObject *parent) + : QObject(*new QOpenGLDebugLoggerPrivate, parent) +{ + // QOpenGLDebugMessage is going to be mostly used as an argument + // of a cross thread connection, therefore let's ease the life for the users + // and register the type for them. + qRegisterMetaType<QOpenGLDebugMessage>(); +} + +/*! + Destroys the logger object. +*/ +QOpenGLDebugLogger::~QOpenGLDebugLogger() +{ + stopLogging(); +} + +/*! + Initializes the object in the current OpenGL context. The context must + support the \c{GL_KHR_debug} extension for the initialization to succeed. + The object must be initialized before any logging can happen. + + It is safe to call this function multiple times from the same context. + + This function can also be used to change the context of a previously + initialized object; note that in this case the object must not be logging + when you call this function. + + Returns \c true if the logger is successfully initialized; false otherwise. + + \sa QOpenGLContext +*/ +bool QOpenGLDebugLogger::initialize() +{ + QOpenGLContext *context = QOpenGLContext::currentContext(); + if (!context) { + qWarning("QOpenGLDebugLogger::initialize(): no current OpenGL context found."); + return false; + } + + Q_D(QOpenGLDebugLogger); + if (d->context == context) { + // context is non-NULL, d->context is non NULL only on successful initialization. + Q_ASSERT(d->initialized); + return true; + } + + if (d->isLogging) { + qWarning("QOpenGLDebugLogger::initialize(): cannot initialize the object while logging. Please stop the logging first."); + return false; + } + + if (d->context) + disconnect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); + + d->initialized = false; + d->context = nullptr; + + if (!context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) + return false; + + d->context = context; + connect(d->context, SIGNAL(aboutToBeDestroyed()), this, SLOT(_q_contextAboutToBeDestroyed())); + +#define GET_DEBUG_PROC_ADDRESS(procName) \ + d->procName = reinterpret_cast< qt_ ## procName ## _t >( \ + d->context->getProcAddress(d->context->isOpenGLES() ? (#procName "KHR") : (#procName)) \ + ); + + GET_DEBUG_PROC_ADDRESS(glDebugMessageControl); + GET_DEBUG_PROC_ADDRESS(glDebugMessageInsert); + GET_DEBUG_PROC_ADDRESS(glDebugMessageCallback); + GET_DEBUG_PROC_ADDRESS(glGetDebugMessageLog); + GET_DEBUG_PROC_ADDRESS(glPushDebugGroup); + GET_DEBUG_PROC_ADDRESS(glPopDebugGroup); + GET_DEBUG_PROC_ADDRESS(glGetPointerv) + +#undef GET_DEBUG_PROC_ADDRESS + + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &d->maxMessageLength); + +#ifndef QT_NO_DEBUG + if (!d->context->format().testOption(QSurfaceFormat::DebugContext)) { + qWarning("QOpenGLDebugLogger::initialize(): the current context is not a debug context:\n" + " this means that the GL may not generate any debug output at all.\n" + " To avoid this warning, try creating the context with the\n" + " QSurfaceFormat::DebugContext surface format option."); + } +#endif // QT_NO_DEBUG + + d->initialized = true; + return true; +} + +/*! + Returns \c true if this object is currently logging, false otherwise. + + \sa startLogging() +*/ +bool QOpenGLDebugLogger::isLogging() const +{ + Q_D(const QOpenGLDebugLogger); + return d->isLogging; +} + +/*! + Starts logging messages coming from the OpenGL server. When a new message + is received, the signal messageLogged() is emitted, carrying the logged + message as argument. + + \a loggingMode specifies whether the logging must be asynchronous (the default) + or synchronous. + + QOpenGLDebugLogger will record the values of \c{GL_DEBUG_OUTPUT} and + \c{GL_DEBUG_OUTPUT_SYNCHRONOUS} when logging is started, and set them back + when logging is stopped. Moreover, any user-defined OpenGL debug callback + installed when this function is invoked will be restored when logging is + stopped; QOpenGLDebugLogger will ensure that the pre-existing callback will + still be invoked when logging. + + \note It's not possible to change the logging mode without stopping and + starting logging again. This might change in a future version of Qt. + + \note The object must be initialized before logging can happen. + + \sa stopLogging(), initialize() +*/ +void QOpenGLDebugLogger::startLogging(QOpenGLDebugLogger::LoggingMode loggingMode) +{ + Q_D(QOpenGLDebugLogger); + if (!d->initialized) { + qWarning("QOpenGLDebugLogger::startLogging(): object must be initialized before logging can start"); + return; + } + if (d->isLogging) { + qWarning("QOpenGLDebugLogger::startLogging(): this object is already logging"); + return; + } + + d->isLogging = true; + d->loggingMode = loggingMode; + + d->glGetPointerv(GL_DEBUG_CALLBACK_FUNCTION, reinterpret_cast<void **>(&d->oldDebugCallbackFunction)); + d->glGetPointerv(GL_DEBUG_CALLBACK_USER_PARAM, &d->oldDebugCallbackParameter); + + d->glDebugMessageCallback(&qt_opengl_debug_callback, d); + + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + d->debugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT); + d->syncDebugWasEnabled = funcs->glIsEnabled(GL_DEBUG_OUTPUT_SYNCHRONOUS); + + if (d->loggingMode == SynchronousLogging) + funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + else + funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + + funcs->glEnable(GL_DEBUG_OUTPUT); +} + +/*! + Returns the logging mode of the object. + + \sa startLogging() +*/ +QOpenGLDebugLogger::LoggingMode QOpenGLDebugLogger::loggingMode() const +{ + Q_D(const QOpenGLDebugLogger); + return d->loggingMode; +} + +/*! + Stops logging messages from the OpenGL server. + + \sa startLogging() +*/ +void QOpenGLDebugLogger::stopLogging() +{ + Q_D(QOpenGLDebugLogger); + if (!d->isLogging) + return; + + QOpenGLContext *currentContext = QOpenGLContext::currentContext(); + if (!currentContext || currentContext != d->context) { + qWarning("QOpenGLDebugLogger::stopLogging(): attempting to stop logging with the wrong OpenGL context current"); + return; + } + + d->isLogging = false; + + d->glDebugMessageCallback(d->oldDebugCallbackFunction, d->oldDebugCallbackParameter); + + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + if (!d->debugWasEnabled) + funcs->glDisable(GL_DEBUG_OUTPUT); + + if (d->syncDebugWasEnabled) + funcs->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + else + funcs->glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); +} + +/*! + Inserts the message \a debugMessage into the OpenGL debug log. This provides + a way for applications or libraries to insert custom messages that can + ease the debugging of OpenGL applications. + + \note \a debugMessage must have QOpenGLDebugMessage::ApplicationSource or + QOpenGLDebugMessage::ThirdPartySource as its source, and a valid + type and severity, otherwise it will not be inserted into the log. + + \note The object must be initialized before logging can happen. + + \sa initialize() +*/ +void QOpenGLDebugLogger::logMessage(const QOpenGLDebugMessage &debugMessage) +{ + Q_D(QOpenGLDebugLogger); + if (!d->initialized) { + qWarning("QOpenGLDebugLogger::logMessage(): object must be initialized before logging messages"); + return; + } + if (debugMessage.source() != QOpenGLDebugMessage::ApplicationSource + && debugMessage.source() != QOpenGLDebugMessage::ThirdPartySource) { + qWarning("QOpenGLDebugLogger::logMessage(): using a message source different from ApplicationSource\n" + " or ThirdPartySource is not supported by GL_KHR_debug. The message will not be logged."); + return; + } + if (debugMessage.type() == QOpenGLDebugMessage::InvalidType + || debugMessage.type() == QOpenGLDebugMessage::AnyType + || debugMessage.severity() == QOpenGLDebugMessage::InvalidSeverity + || debugMessage.severity() == QOpenGLDebugMessage::AnySeverity) { + qWarning("QOpenGLDebugLogger::logMessage(): the message has a non-valid type and/or severity. The message will not be logged."); + return; + } + + const GLenum source = qt_messageSourceToGL(debugMessage.source()); + const GLenum type = qt_messageTypeToGL(debugMessage.type()); + const GLenum severity = qt_messageSeverityToGL(debugMessage.severity()); + QByteArray rawMessage = debugMessage.message().toUtf8(); + rawMessage.append('\0'); + + if (rawMessage.length() > d->maxMessageLength) { + qWarning("QOpenGLDebugLogger::logMessage(): message too long, truncating it\n" + " (%d bytes long, but the GL accepts up to %d bytes)", rawMessage.length(), d->maxMessageLength); + rawMessage.resize(d->maxMessageLength - 1); + rawMessage.append('\0'); + } + + // Don't pass rawMessage.length(), as unfortunately bugged + // OpenGL drivers will eat the trailing NUL in the message. Just rely + // on the message being NUL terminated. + d->glDebugMessageInsert(source, + type, + debugMessage.id(), + severity, + -1, + rawMessage.constData()); +} + +/*! + Pushes a debug group with name \a name, id \a id, and source \a source onto + the debug groups stack. If the group is successfully pushed, OpenGL will + automatically log a message with message \a name, id \a id, source \a + source, type QOpenGLDebugMessage::GroupPushType and severity + QOpenGLDebugMessage::NotificationSeverity. + + The newly pushed group will inherit the same filtering settings of the + group that was on the top of the stack; that is, the filtering will not be + changed by pushing a new group. + + \note The \a source must either be QOpenGLDebugMessage::ApplicationSource or + QOpenGLDebugMessage::ThirdPartySource, otherwise the group will not be pushed. + + \note The object must be initialized before managing debug groups. + + \sa popGroup(), enableMessages(), disableMessages() +*/ +void QOpenGLDebugLogger::pushGroup(const QString &name, GLuint id, QOpenGLDebugMessage::Source source) +{ + Q_D(QOpenGLDebugLogger); + if (!d->initialized) { + qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before pushing a debug group"); + return; + } + if (source != QOpenGLDebugMessage::ApplicationSource + && source != QOpenGLDebugMessage::ThirdPartySource) { + qWarning("QOpenGLDebugLogger::pushGroup(): using a source different from ApplicationSource\n" + " or ThirdPartySource is not supported by GL_KHR_debug. The group will not be pushed."); + return; + } + + QByteArray rawName = name.toUtf8(); + rawName.append('\0'); + if (rawName.length() > d->maxMessageLength) { + qWarning("QOpenGLDebugLogger::pushGroup(): group name too long, truncating it\n" + " (%d bytes long, but the GL accepts up to %d bytes)", rawName.length(), d->maxMessageLength); + rawName.resize(d->maxMessageLength - 1); + rawName.append('\0'); + } + + // Don't pass rawMessage.length(), as unfortunately bugged + // OpenGL drivers will eat the trailing NUL in the name. Just rely + // on the name being NUL terminated. + d->glPushDebugGroup(qt_messageSourceToGL(source), id, -1, rawName.constData()); +} + +/*! + Pops the topmost debug group from the debug groups stack. If the group is + successfully popped, OpenGL will automatically log a message with message, + id and source matching those of the popped group, type + QOpenGLDebugMessage::GroupPopType and severity + QOpenGLDebugMessage::NotificationSeverity. + + Popping a debug group will restore the message filtering settings of the + group that becomes the top of the debug groups stack. + + \note The object must be initialized before managing debug groups. + + \sa pushGroup() +*/ +void QOpenGLDebugLogger::popGroup() +{ + Q_D(QOpenGLDebugLogger); + if (!d->initialized) { + qWarning("QOpenGLDebugLogger::pushGroup(): object must be initialized before popping a debug group"); + return; + } + + d->glPopDebugGroup(); +} + +/*! + Enables the logging of messages from the given \a sources, of the given \a + types and with the given \a severities and any message id. + + The logging will be enabled in the current control group. + + \sa disableMessages(), pushGroup(), popGroup() +*/ +void QOpenGLDebugLogger::enableMessages(QOpenGLDebugMessage::Sources sources, + QOpenGLDebugMessage::Types types, + QOpenGLDebugMessage::Severities severities) +{ + Q_D(QOpenGLDebugLogger); + d->controlDebugMessages(sources, + types, + severities, + QVector<GLuint>(), + QByteArrayLiteral("enableMessages"), + true); +} + +/*! + Enables the logging of messages with the given \a ids, from the given \a + sources and of the given \a types and any severity. + + The logging will be enabled in the current control group. + + \sa disableMessages(), pushGroup(), popGroup() +*/ +void QOpenGLDebugLogger::enableMessages(const QVector<GLuint> &ids, + QOpenGLDebugMessage::Sources sources, + QOpenGLDebugMessage::Types types) +{ + Q_D(QOpenGLDebugLogger); + d->controlDebugMessages(sources, + types, + QOpenGLDebugMessage::AnySeverity, + ids, + QByteArrayLiteral("enableMessages"), + true); +} + +/*! + Disables the logging of messages with the given \a sources, of the given \a + types and with the given \a severities and any message id. + + The logging will be disabled in the current control group. + + \sa enableMessages(), pushGroup(), popGroup() +*/ +void QOpenGLDebugLogger::disableMessages(QOpenGLDebugMessage::Sources sources, + QOpenGLDebugMessage::Types types, + QOpenGLDebugMessage::Severities severities) +{ + Q_D(QOpenGLDebugLogger); + d->controlDebugMessages(sources, + types, + severities, + QVector<GLuint>(), + QByteArrayLiteral("disableMessages"), + false); +} + +/*! + Disables the logging of messages with the given \a ids, from the given \a + sources and of the given \a types and any severity. + + The logging will be disabled in the current control group. + + \sa enableMessages(), pushGroup(), popGroup() +*/ +void QOpenGLDebugLogger::disableMessages(const QVector<GLuint> &ids, + QOpenGLDebugMessage::Sources sources, + QOpenGLDebugMessage::Types types) +{ + Q_D(QOpenGLDebugLogger); + d->controlDebugMessages(sources, + types, + QOpenGLDebugMessage::AnySeverity, + ids, + QByteArrayLiteral("disableMessages"), + false); +} + +/*! + Reads all the available messages in the OpenGL internal debug log and + returns them. Moreover, this function will clear the internal debug log, + so that subsequent invocations will not return messages that were + already returned. + + \sa startLogging() +*/ +QList<QOpenGLDebugMessage> QOpenGLDebugLogger::loggedMessages() const +{ + Q_D(const QOpenGLDebugLogger); + if (!d->initialized) { + qWarning("QOpenGLDebugLogger::loggedMessages(): object must be initialized before reading logged messages"); + return QList<QOpenGLDebugMessage>(); + } + + static const GLuint maxMessageCount = 128; + GLuint messagesRead; + GLenum messageSources[maxMessageCount]; + GLenum messageTypes[maxMessageCount]; + GLuint messageIds[maxMessageCount]; + GLenum messageSeverities[maxMessageCount]; + GLsizei messageLengths[maxMessageCount]; + + QByteArray messagesBuffer; + messagesBuffer.resize(maxMessageCount * d->maxMessageLength); + + QList<QOpenGLDebugMessage> messages; + do { + messagesRead = d->glGetDebugMessageLog(maxMessageCount, + GLsizei(messagesBuffer.size()), + messageSources, + messageTypes, + messageIds, + messageSeverities, + messageLengths, + messagesBuffer.data()); + + const char *messagesBufferPtr = messagesBuffer.constData(); + for (GLuint i = 0; i < messagesRead; ++i) { + QOpenGLDebugMessage message; + + QOpenGLDebugMessagePrivate *messagePrivate = message.d.data(); + messagePrivate->source = qt_messageSourceFromGL(messageSources[i]); + messagePrivate->type = qt_messageTypeFromGL(messageTypes[i]); + messagePrivate->id = messageIds[i]; + messagePrivate->severity = qt_messageSeverityFromGL(messageSeverities[i]); + messagePrivate->message = QString::fromUtf8(messagesBufferPtr, messageLengths[i] - 1); + + messagesBufferPtr += messageLengths[i]; + messages << message; + } + } while (messagesRead == maxMessageCount); + + return messages; +} + +/*! + \fn void QOpenGLDebugLogger::messageLogged(const QOpenGLDebugMessage &debugMessage) + + This signal is emitted when a debug message (wrapped by the \a debugMessage + argument) is logged from the OpenGL server. + + Depending on the OpenGL implementation, this signal can be emitted + from other threads than the one(s) the receiver(s) lives in, and even + different from the thread the QOpenGLContext in which this object has + been initialized lives in. Moreover, the signal could be emitted from + multiple threads at the same time. This is normally not a problem, + as Qt will utilize a queued connection for cross-thread signal emissions, + but if you force the connection type to Direct then you must be aware of + the potential races in the slots connected to this signal. + + If logging have been started in SynchronousLogging mode, OpenGL guarantees + that this signal will be emitted from the same thread the QOpenGLContext + has been bound to, and no concurrent invocations will ever happen. + + \note Logging must have been started, or this signal will not be emitted. + + \sa startLogging() +*/ + +/*! + Returns the maximum supported length, in bytes, for the text of the messages + passed to logMessage(). This is also the maximum length of a debug group + name, as pushing or popping groups will automatically log a message with + the debug group name as the message text. + + If a message text is too long, it will be automatically truncated by + QOpenGLDebugLogger. + + \note Message texts are encoded in UTF-8 when they get passed to OpenGL, so + their size in bytes does not usually match the amount of UTF-16 code units, + as returned, for instance, by QString::length(). (It does if the message contains + 7-bit ASCII only data, which is typical for debug messages.) +*/ +qint64 QOpenGLDebugLogger::maximumMessageLength() const +{ + Q_D(const QOpenGLDebugLogger); + if (!d->initialized) { + qWarning("QOpenGLDebugLogger::maximumMessageLength(): object must be initialized before reading the maximum message length"); + return -1; + } + return d->maxMessageLength; +} + + +QT_END_NAMESPACE + +#include "moc_qopengldebug.cpp" diff --git a/src/opengl/qopengldebug.h b/src/opengl/qopengldebug.h new file mode 100644 index 0000000000..fef2782302 --- /dev/null +++ b/src/opengl/qopengldebug.h @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGLDEBUG_H +#define QOPENGLDEBUG_H + +#include <QtOpenGL/qtopenglglobal.h> + +#ifndef QT_NO_OPENGL + +#include <QtCore/qshareddata.h> +#include <QtCore/qflags.h> +#include <QtCore/qlist.h> +#include <QtCore/qvector.h> +#include <QtCore/qmetatype.h> +#include <QtCore/qdebug.h> +#include <QtGui/qopenglcontext.h> + +#if defined(Q_CLANG_QDOC) +#undef GLuint +typedef unsigned int GLuint; +#endif + +QT_BEGIN_NAMESPACE + +class QOpenGLDebugLogger; +class QOpenGLDebugLoggerPrivate; +class QOpenGLDebugMessagePrivate; + +class Q_OPENGL_EXPORT QOpenGLDebugMessage +{ +public: + enum Source { + InvalidSource = 0x00000000, + APISource = 0x00000001, + WindowSystemSource = 0x00000002, + ShaderCompilerSource = 0x00000004, + ThirdPartySource = 0x00000008, + ApplicationSource = 0x00000010, + OtherSource = 0x00000020, + LastSource = OtherSource, // private API + AnySource = 0xffffffff + }; + Q_DECLARE_FLAGS(Sources, Source) + + enum Type { + InvalidType = 0x00000000, + ErrorType = 0x00000001, + DeprecatedBehaviorType = 0x00000002, + UndefinedBehaviorType = 0x00000004, + PortabilityType = 0x00000008, + PerformanceType = 0x00000010, + OtherType = 0x00000020, + MarkerType = 0x00000040, + GroupPushType = 0x00000080, + GroupPopType = 0x00000100, + LastType = GroupPopType, // private API + AnyType = 0xffffffff + }; + Q_DECLARE_FLAGS(Types, Type) + + enum Severity { + InvalidSeverity = 0x00000000, + HighSeverity = 0x00000001, + MediumSeverity = 0x00000002, + LowSeverity = 0x00000004, + NotificationSeverity = 0x00000008, + LastSeverity = NotificationSeverity, // private API + AnySeverity = 0xffffffff + }; + Q_DECLARE_FLAGS(Severities, Severity) + + QOpenGLDebugMessage(); + QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage); + + QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage); + QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) noexcept { swap(other); return *this; } + ~QOpenGLDebugMessage(); + + void swap(QOpenGLDebugMessage &other) noexcept { qSwap(d, other.d); } + + Source source() const; + Type type() const; + Severity severity() const; + GLuint id() const; + QString message() const; + + static QOpenGLDebugMessage createApplicationMessage(const QString &text, + GLuint id = 0, + Severity severity = NotificationSeverity, + Type type = OtherType); + static QOpenGLDebugMessage createThirdPartyMessage(const QString &text, + GLuint id = 0, + Severity severity = NotificationSeverity, + Type type = OtherType); + + bool operator==(const QOpenGLDebugMessage &debugMessage) const; + inline bool operator!=(const QOpenGLDebugMessage &debugMessage) const { return !operator==(debugMessage); } + +private: + friend class QOpenGLDebugLogger; + friend class QOpenGLDebugLoggerPrivate; + QSharedDataPointer<QOpenGLDebugMessagePrivate> d; +}; + +Q_DECLARE_SHARED(QOpenGLDebugMessage) +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Sources) +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Types) +Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLDebugMessage::Severities) + +#ifndef QT_NO_DEBUG_STREAM +Q_OPENGL_EXPORT QDebug operator<<(QDebug debug, const QOpenGLDebugMessage &message); +Q_OPENGL_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Source source); +Q_OPENGL_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Type type); +Q_OPENGL_EXPORT QDebug operator<<(QDebug debug, QOpenGLDebugMessage::Severity severity); +#endif + +class QOpenGLDebugLoggerPrivate; + +class Q_OPENGL_EXPORT QOpenGLDebugLogger : public QObject +{ + Q_OBJECT + Q_PROPERTY(LoggingMode loggingMode READ loggingMode) + +public: + enum LoggingMode { + AsynchronousLogging, + SynchronousLogging + }; + Q_ENUM(LoggingMode) + + explicit QOpenGLDebugLogger(QObject *parent = nullptr); + ~QOpenGLDebugLogger(); + + bool initialize(); + + bool isLogging() const; + LoggingMode loggingMode() const; + + qint64 maximumMessageLength() const; + + void pushGroup(const QString &name, + GLuint id = 0, + QOpenGLDebugMessage::Source source = QOpenGLDebugMessage::ApplicationSource); + void popGroup(); + + void enableMessages(QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, + QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, + QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); + + void enableMessages(const QVector<GLuint> &ids, + QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, + QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); + + void disableMessages(QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, + QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType, + QOpenGLDebugMessage::Severities severities = QOpenGLDebugMessage::AnySeverity); + + void disableMessages(const QVector<GLuint> &ids, + QOpenGLDebugMessage::Sources sources = QOpenGLDebugMessage::AnySource, + QOpenGLDebugMessage::Types types = QOpenGLDebugMessage::AnyType); + + QList<QOpenGLDebugMessage> loggedMessages() const; + +public Q_SLOTS: + void logMessage(const QOpenGLDebugMessage &debugMessage); + void startLogging(LoggingMode loggingMode = AsynchronousLogging); + void stopLogging(); + +Q_SIGNALS: + void messageLogged(const QOpenGLDebugMessage &debugMessage); + +private: + Q_DISABLE_COPY(QOpenGLDebugLogger) + Q_DECLARE_PRIVATE(QOpenGLDebugLogger) + Q_PRIVATE_SLOT(d_func(), void _q_contextAboutToBeDestroyed()) +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QOpenGLDebugMessage) + +#endif // QT_NO_OPENGL + +#endif // QOPENGLDEBUG_H -- cgit v1.2.3 From 3e9895f3de7f118beab3068b938ff6b9f2f5ef73 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Mon, 2 Dec 2019 18:54:14 +0100 Subject: Support checkable QComboBox items with styles using a popup dropdown The dropdown of a combobox is rendered using menu items when the style request it to do so via the SH_ComboBox_Popup style hint. In that case, checkable items were not supported; the QComboBox didn't pass the checked state correctly to the style, and the delegate used for rendering the items into the list view did not implement modifying the checked state of the item. However, the QStyleOptionMenuItem's checked state and checkType members were set anyway, as on e.g. macOS style we use a checkmark to show which item is currently selected in the combobox. The QStyle::State enum defines State_On and State_Off for toggleable things, so in addition to setting QStyleOptionMenuItem::checked, we are now also adding State_On or State_Off if the model provides a valid checked/unchecked state. Otherwise, we only set the checked state if the item is currently selected. In addition, we implement the delegate to support toggling of checkable model data with mouse and keyboard, using a simplified version of the QItemDelegate implementation. To avoid spurious item toggles when the popup is opened, we only handle mouse releases when the press was on the same row. In the fusion style, we ignore the workaround to let QtQuickControls render comboboxes if State_On or State_Off are set. [ChangeLog][QtWidgets][QComboBox] Support checkable items in styles that use a popup for the dropdown. Change-Id: Ia01519694b0419d777dc66b1ef683482fb01754c Fixes: QTBUG-60310 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/styles/qfusionstyle.cpp | 8 +++-- src/widgets/widgets/qcombobox.cpp | 59 ++++++++++++++++++++++++++++++++++++- src/widgets/widgets/qcombobox_p.h | 7 ++++- 3 files changed, 69 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 49b3703189..03d083bbf1 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1590,7 +1590,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio (option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool())) ignoreCheckMark = true; //ignore the checkmarks provided by the QComboMenuDelegate - if (!ignoreCheckMark) { + if (!ignoreCheckMark || menuItem->state & (State_On | State_Off)) { // Check, using qreal and QRectF to avoid error accumulation const qreal boxMargin = dpiScaled(3.5, option); const qreal boxWidth = checkcol - 2 * boxMargin; @@ -1601,7 +1601,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (checkable) { if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) { // Radio button - if (checked || sunken) { + if (menuItem->state & State_On || checked || sunken) { painter->setRenderHint(QPainter::Antialiasing); painter->setPen(Qt::NoPen); @@ -1617,8 +1617,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio QStyleOptionButton box; box.QStyleOption::operator=(*option); box.rect = checkRect; - if (checked) + if (checked || menuItem->state & State_On) box.state |= State_On; + else + box.state |= State_Off; proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); } } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 19b442f477..4cfa5554e4 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -129,7 +129,15 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt if (option.state & QStyle::State_Selected) menuOption.state |= QStyle::State_Selected; menuOption.checkType = QStyleOptionMenuItem::NonExclusive; - menuOption.checked = mCombo->currentIndex() == index.row(); + // a valid checkstate means that the model has checkable items + const QVariant checkState = index.data(Qt::CheckStateRole); + if (!checkState.isValid()) { + menuOption.checked = mCombo->currentIndex() == index.row(); + } else { + menuOption.checked = qvariant_cast<int>(checkState) == Qt::Checked; + menuOption.state |= qvariant_cast<int>(checkState) == Qt::Checked + ? QStyle::State_On : QStyle::State_Off; + } if (QComboBoxDelegate::isSeparator(index)) menuOption.menuItemType = QStyleOptionMenuItem::Separator; else @@ -179,6 +187,55 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt return menuOption; } +bool QComboMenuDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, + const QStyleOptionViewItem &option, const QModelIndex &index) +{ + Q_ASSERT(event); + Q_ASSERT(model); + + // make sure that the item is checkable + Qt::ItemFlags flags = model->flags(index); + if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled) + || !(flags & Qt::ItemIsEnabled)) + return false; + + // make sure that we have a check state + const QVariant checkState = index.data(Qt::CheckStateRole); + if (!checkState.isValid()) + return false; + + // make sure that we have the right event type + if ((event->type() == QEvent::MouseButtonRelease) + || (event->type() == QEvent::MouseButtonDblClick) + || (event->type() == QEvent::MouseButtonPress)) { + QMouseEvent *me = static_cast<QMouseEvent*>(event); + if (me->button() != Qt::LeftButton) + return false; + + if ((event->type() == QEvent::MouseButtonPress) + || (event->type() == QEvent::MouseButtonDblClick)) { + pressedIndex = index.row(); + return false; + } + + if (index.row() != pressedIndex) + return false; + pressedIndex = -1; + + } else if (event->type() == QEvent::KeyPress) { + if (static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space + && static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select) + return false; + } else { + return false; + } + + // we don't support user-tristate items in QComboBox (not implemented in any style) + Qt::CheckState newState = (static_cast<Qt::CheckState>(checkState.toInt()) == Qt::Checked) + ? Qt::Unchecked : Qt::Checked; + return model->setData(index, newState, Qt::CheckStateRole); +} + #if QT_CONFIG(completer) void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index) { diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index c79406eafd..7a3fcf6e0f 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -266,7 +266,9 @@ class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate { Q_OBJECT public: - QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {} + QComboMenuDelegate(QObject *parent, QComboBox *cmb) + : QAbstractItemDelegate(parent), mCombo(cmb), pressedIndex(-1) + {} protected: void paint(QPainter *painter, @@ -282,11 +284,14 @@ protected: return mCombo->style()->sizeFromContents( QStyle::CT_MenuItem, &opt, option.rect.size(), mCombo); } + bool editorEvent(QEvent *event, QAbstractItemModel *model, + const QStyleOptionViewItem &option, const QModelIndex &index) override; private: QStyleOptionMenuItem getStyleOption(const QStyleOptionViewItem &option, const QModelIndex &index) const; QComboBox *mCombo; + int pressedIndex; }; // ### Qt6: QStyledItemDelegate ? -- cgit v1.2.3 From b3c0e9afa0041d4d45e47880732deda1dd1013b9 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <aacid@kde.org> Date: Mon, 9 Dec 2019 23:51:46 +0100 Subject: Deprecate qrand/qsrand They have been marked as deprecated in the documentation for a while Change-Id: Ia2b0b6dbd4c525e3e9c4bc835eee2c9da5a938cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qglobal.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e335916eac..861f087c60 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1266,8 +1266,10 @@ inline int qIntCast(float f) { return int(f); } /* Reentrant versions of basic rand() functions for random number generation */ -Q_CORE_EXPORT void qsrand(uint seed); -Q_CORE_EXPORT int qrand(); +#if QT_DEPRECATED_SINCE(5, 15) +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X_5_15("use QRandomGenerator instead") void qsrand(uint seed); +Q_CORE_EXPORT QT_DEPRECATED_VERSION_X_5_15("use QRandomGenerator instead") int qrand(); +#endif #define QT_MODULE(x) -- cgit v1.2.3 From 07838840e86a5fb7f81520bb2a31d16f80e51e4c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sat, 30 Nov 2019 15:06:20 +0100 Subject: Doc/SQL: update sql driver creation instructions Update the instructions on how to build and distribute the mysql and postgresql drivers on windows. Change-Id: Ie4d50c1c34820680d7496b9544eb00fcee17f8e7 Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/plugins/sqldrivers/README | 4 +- src/sql/doc/snippets/code/doc_src_sql-driver.qdoc | 57 +++++++++++++++++++--- src/sql/doc/src/sql-driver.qdoc | 58 ++++++++++++++++------- 3 files changed, 95 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/README b/src/plugins/sqldrivers/README index 7000fb5613..26418c5e36 100644 --- a/src/plugins/sqldrivers/README +++ b/src/plugins/sqldrivers/README @@ -1,5 +1,5 @@ -Please note that the DB2, Oracle and TDS client drivers are not distributed -with the Qt Open Source Editions. +Please note that the DB2, MySQL, Oracle and TDS client drivers are not +distributed with the Qt Open Source Editions. This is because the client libraries are distributed under a license which is not compatible with the GPL license. diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc index 9709deeccb..12a39d80b2 100644 --- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc +++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc @@ -70,7 +70,6 @@ BEGIN END //! [1] - //! [3] cd $QTDIR/qtbase/src/plugins/sqldrivers qmake -- MYSQL_PREFIX=/usr/local @@ -86,14 +85,15 @@ make install //! [5] cd %QTDIR%\qtbase\src\plugins\sqldrivers -qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt" +qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib" nmake sub-mysql +nmake install //! [5] //! [6] cd $QTDIR/qtbase/src/plugins/sqldrivers -qmake -- "OCI_INCDIR=$ORACLE_HOME/rdbms/public" OCI_LIBDIR=$ORACLE_HOME/lib "OCI_LIBS=-lclntsh -lwtc9" +qmake -- OCI_INCDIR="$ORACLE_HOME/rdbms/public" OCI_LIBDIR="$ORACLE_HOME/lib" OCI_LIBS="-lclntsh -lwtc9" make sub-oci //! [6] @@ -142,6 +142,7 @@ make sub-psql cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- PSQL_INCDIR=C:/psql/include PSQL_LIBDIR=C:/psql/lib/ms nmake sub-psql +nmake install //! [15] @@ -156,6 +157,7 @@ make sub-tds cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake nmake sub-tds +nmake install //! [17] @@ -168,8 +170,9 @@ make sub-db2 //! [20] cd %QTDIR%\qtbase\src\plugins\sqldrivers -qmake -- "DB2_PREFIX=<DB2 home>/sqllib" +qmake -- DB2_PREFIX="<DB2 home>/sqllib" nmake sub-db2 +nmake install //! [20] @@ -184,6 +187,7 @@ make sub-sqlite cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- -system-sqlite SQLITE3_PREFIX=C:/SQLITE nmake sub-sqlite +nmake install //! [23] @@ -205,6 +209,7 @@ make sub-ibase cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- IBASE_INCDIR=C:/interbase/include nmake sub-ibase +nmake install //! [29] @@ -212,17 +217,18 @@ nmake sub-ibase cd %QTDIR%\qtbase\src\plugins\sqldrivers qmake -- IBASE_INCDIR=C:/interbase/include IBASE_LIBS=-lfbclient nmake sub-ibase +nmake install //! [30] //! [32] -configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib "OCI_LIBS=-lclntsh -lnnz10" +configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-lclntsh -lnnz10" make //! [32] //! [33] cd $QTDIR/qtbase/src/plugins/sqldrivers -qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib "OCI_LIBS=-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10" +qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10" make sub-oci //! [33] @@ -250,3 +256,42 @@ q.exec(QString("CREATE TABLE %1 (id INTEGER)").arg(tableString)); // Call toLower() on the string so that it can be matched QSqlRecord rec = database.record(tableString.toLower()); //! [40] + +//! [41] +C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version +QMake version 3.1 +Using Qt version 5.13.2 in C:/Qt5/5.13.2/mingw73_64/lib +C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib" +Info: creating stash file C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers\.qmake.stash + +Running configuration tests... +Checking for DB2 (IBM)... no +Checking for InterBase... no +Checking for MySQL... yes +Checking for OCI (Oracle)... no +Checking for ODBC... yes +Checking for PostgreSQL... no +Checking for SQLite (version 2)... no +Checking for TDS (Sybase)... no +Done running configuration tests. + +Configure summary: + +Qt Sql Drivers: + DB2 (IBM) .............................. no + InterBase .............................. no + MySql .................................. yes + OCI (Oracle) ........................... no + ODBC ................................... yes + PostgreSQL ............................. no + SQLite2 ................................ no + SQLite ................................. yes + Using system provided SQLite ......... no + TDS (Sybase) ........................... no + +Qt is now configured for building. Just run 'mingw32-make'. +Once everything is built, you must run 'mingw32-make install'. +Qt will be installed into 'C:\Qt5\5.13.2\mingw73_64'. + +Prior to reconfiguration, make sure you remove any leftovers from the previous build. +//! [41] diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index c6ac4d17ff..9c26c4089c 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -48,7 +48,7 @@ \header \li Driver name \li DBMS \row \li \l{#QDB2}{QDB2} \li IBM DB2 (version 7.1 and above) \row \li \l{#QIBASE}{QIBASE} \li Borland InterBase - \row \li \l{#QMYSQL}{QMYSQL} \li MySQL + \row \li \l{#QMYSQL}{QMYSQL} \li MySQL (version 5.0 and above) \row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver \row \li \l{#QODBC}{QODBC} \li Open Database Connectivity (ODBC) - Microsoft SQL Server and other @@ -70,7 +70,8 @@ access to the API exposed by the DBMS, and is typically shipped with it. Most installation programs also allow you to install "development libraries", and these are what you need. These libraries are responsible - for the low-level communication with the DBMS. + for the low-level communication with the DBMS. Also make sure to install + the correct database libraries for your Qt architecture (32 or 64 bit). \note When using Qt under Open Source terms but with a proprietary database, verify the client library's license compatibility with @@ -91,11 +92,21 @@ may be necessary to specify these paths using the \c *_INCDIR=, \c *_LIBDIR=, or \c *_PREFIX= command-line options. For example, if your MySQL files are installed in \c /usr/local/mysql (or in - \c{C:\mysql} on Windows), then pass the following parameter to - configure: \c MYSQL_PREFIX=/usr/local/mysql - (or \c{MYSQL_PREFIX=C:\mysql} for Windows). + \c{C:/Program Files/MySQL/MySQL Connector C 6.1} on Windows), then pass the + following parameter to configure: \c MYSQL_PREFIX=/usr/local/mysql + (or \c{MYSQL_PREFIX="C:/Program Files/MySQL/MySQL Connector C 6.1"} for Windows). The particulars for each driver are explained below. + If something goes wrong and you want qmake to recheck your + available drivers, you must remove \e{config.cache} in + \e{<QTDIR>/qtbase/src/plugins/sqldrivers} - otherwise qmake will not + search for the available drivers again. If you encounter an error during + the qmake stage, open \e{config.log} to see what went wrong. + + A typical qmake run (in this case to configure for MySQL) looks like this: + + \snippet code/doc_src_sql-driver.qdoc 41 + Due to the practicalities of dealing with external dependencies, only the SQLite3 plugin is shipped with binary builds of Qt. To be able to add additional drivers to the Qt installation @@ -112,11 +123,11 @@ \section1 Driver Specifics \target QMYSQL - \section2 QMYSQL for MySQL 4 and higher + \section2 QMYSQL for MySQL 5 and higher \section3 QMYSQL Stored Procedure Support - MySQL 5 introduces stored procedure support at the SQL level, but no + MySQL 5 has stored procedure support at the SQL level, but no API to control IN, OUT, and INOUT parameters. Therefore, parameters have to be set and read using SQL commands instead of QSqlQuery::bindValue(). @@ -159,16 +170,32 @@ \section3 How to Build the QMYSQL Plugin on Windows - You need to get the MySQL installation files. Run \c SETUP.EXE and - choose "Custom Install". Install the "Libs & Include Files" Module. - Build the plugin as follows (here it is assumed that MySQL is - installed in \c{C:\MySQL}): + You need to get the MySQL installation files (e.g. + \e{mysql-installer-web-community-8.0.18.0.msi}). Run the installer, + select custom installation and install the MySQL C Connector + which matches your Qt installation (x86 or x64). + After installation make sure that the needed files are there: + \list + \li \c {<MySQL dir>/lib/libmysql.lib} + \li \c {<MySQL dir>/lib/libmysql.dll} + \li \c {<MySQL dir>/include/mysql.h} + \endlist + + Build the plugin as follows (here it is assumed that the MySQL + C Connector is installed in + \c{C:/Program Files/MySQL/MySQL Connector C 6.1}): \snippet code/doc_src_sql-driver.qdoc 5 If you are not using a Microsoft compiler, replace \c nmake with \c mingw32-make in the line above. + When you distribute your application, remember to include libmysql.dll + in your installation package. It must be placed in the same folder + as the application executable. libmysql.dll additionally needs the + MSVC runtime libraries which can be installed with vcredist.exe + (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}(vcredist.exe) + \target QOCI \section2 QOCI for the Oracle Call Interface (OCI) @@ -398,11 +425,6 @@ \snippet code/doc_src_sql-driver.qdoc 40 - \section3 QPSQL BLOB Support - - Binary Large Objects are supported through the \c BYTEA field type in - PostgreSQL server versions >= 7.1. - \section3 QPSQL Forward-only query support To use forward-only queries, you must build the QPSQL plugin with @@ -463,6 +485,10 @@ Users of MinGW may wish to consult the following online document: \l{http://www.postgresql.org/docs/current/static/installation-platform-notes.html#INSTALLATION-NOTES-MINGW}{PostgreSQL MinGW/Native Windows}. + When you distribute your application, remember to include libpq.dll + in your installation package. It must be placed in the same folder + as the application executable. + \target QTDS \section2 QTDS for Sybase Adaptive Server -- cgit v1.2.3 From c15d6a155c6121bad68a3ec60be62181fb92d0f8 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale <fabian.kosmale@qt.io> Date: Tue, 10 Dec 2019 14:55:14 +0100 Subject: QVariant: introduce ShouldDeleteVariantData flag This flag is used in QSequentialIterable and QAssociativeIterable to indicate that the data pointer in VariantData should be deleted after the variant has been constructed. The use case for this is https://codereview.qt-project.org/c/qt/qtdeclarative/+/284151, where we have a proxy iterator and cannot easily return a pointer to already owned data, as it is hard to manage its lifetime in the iterator. In contrast, it is clear that we can release the memory in the QSequentialIterable functions, as it has already been copied into the QVariant there. Change-Id: I2b33497d991cd4f752153e0ebda767b82e4bb851 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> --- src/corelib/kernel/qvariant.cpp | 35 ++++++++++++++++------------------- src/corelib/kernel/qvariant_p.h | 5 +++++ 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 84ad555f34..a1e1c71d12 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -4520,15 +4520,24 @@ QSequentialIterable::const_iterator QSequentialIterable::end() const return it; } +static const QVariant variantFromVariantDataHelper(const QtMetaTypePrivate::VariantData &d) { + QVariant v; + if (d.metaTypeId == qMetaTypeId<QVariant>()) + v = *reinterpret_cast<const QVariant*>(d.data); + else + v = QVariant(d.metaTypeId, d.data, d.flags & ~QVariantConstructionFlags::ShouldDeleteVariantData); + if (d.flags & QVariantConstructionFlags::ShouldDeleteVariantData) + QMetaType::destroy(d.metaTypeId, const_cast<void *>(d.data)); + return v; +} + /*! Returns the element at position \a idx in the container. */ QVariant QSequentialIterable::at(int idx) const { const QtMetaTypePrivate::VariantData d = m_impl.at(idx); - if (d.metaTypeId == qMetaTypeId<QVariant>()) - return *reinterpret_cast<const QVariant*>(d.data); - return QVariant(d.metaTypeId, d.data, d.flags); + return variantFromVariantDataHelper(d); } /*! @@ -4605,9 +4614,7 @@ QSequentialIterable::const_iterator::operator=(const const_iterator &other) const QVariant QSequentialIterable::const_iterator::operator*() const { const QtMetaTypePrivate::VariantData d = m_impl.getCurrent(); - if (d.metaTypeId == qMetaTypeId<QVariant>()) - return *reinterpret_cast<const QVariant*>(d.data); - return QVariant(d.metaTypeId, d.data, d.flags); + return variantFromVariantDataHelper(d); } /*! @@ -4939,10 +4946,7 @@ QAssociativeIterable::const_iterator::operator=(const const_iterator &other) const QVariant QAssociativeIterable::const_iterator::operator*() const { const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); - QVariant v(d.metaTypeId, d.data, d.flags); - if (d.metaTypeId == qMetaTypeId<QVariant>()) - return *reinterpret_cast<const QVariant*>(d.data); - return v; + return variantFromVariantDataHelper(d); } /*! @@ -4951,10 +4955,7 @@ const QVariant QAssociativeIterable::const_iterator::operator*() const const QVariant QAssociativeIterable::const_iterator::key() const { const QtMetaTypePrivate::VariantData d = m_impl.getCurrentKey(); - QVariant v(d.metaTypeId, d.data, d.flags); - if (d.metaTypeId == qMetaTypeId<QVariant>()) - return *reinterpret_cast<const QVariant*>(d.data); - return v; + return variantFromVariantDataHelper(d); } /*! @@ -4962,11 +4963,7 @@ const QVariant QAssociativeIterable::const_iterator::key() const */ const QVariant QAssociativeIterable::const_iterator::value() const { - const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); - QVariant v(d.metaTypeId, d.data, d.flags); - if (d.metaTypeId == qMetaTypeId<QVariant>()) - return *reinterpret_cast<const QVariant*>(d.data); - return v; + return operator*(); } /*! diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 3d87beac83..b8b63b5e6f 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -105,6 +105,11 @@ inline T *v_cast(QVariant::Private *d, T * = nullptr) #endif +enum QVariantConstructionFlags : uint { + Default = 0x0, + PointerType = 0x1, + ShouldDeleteVariantData = 0x2 // only used in Q*Iterable +}; //a simple template that avoids to allocate 2 memory chunks when creating a QVariant template <class T> class QVariantPrivateSharedEx : public QVariant::PrivateShared -- cgit v1.2.3 From 3162345670ffe67a71a62abaeda0d8eb8ad0682e Mon Sep 17 00:00:00 2001 From: Michael Dippold <michael.dippold@us.thalesgroup.com> Date: Wed, 4 Dec 2019 14:48:00 -0800 Subject: Support both qrc and qml files for qmlimportscanner Some projects can be configured to have both qrcFiles and qml-root-path included in the deployment settings file. The addition to qrc scanning prevented the qml root directory from being scanned. Change-Id: Idadb62f5572be45d0083294440bdb29740c2c47e Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/tools/androiddeployqt/main.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 550ed0832f..6fd32c2d29 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -1717,17 +1717,18 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies) qmlImportScanner += QLatin1String(" -qrcFiles"); for (const QString &qrcFile : options->qrcFiles) qmlImportScanner += QLatin1Char(' ') + shellQuote(qrcFile); - } else { - if (rootPath.isEmpty()) - rootPath = QFileInfo(options->inputFileName).absolutePath(); - else - rootPath = QFileInfo(rootPath).absoluteFilePath(); - - if (!rootPath.endsWith(QLatin1Char('/'))) - rootPath += QLatin1Char('/'); - qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath)); } + if (rootPath.isEmpty()) + rootPath = QFileInfo(options->inputFileName).absolutePath(); + else + rootPath = QFileInfo(rootPath).absoluteFilePath(); + + if (!rootPath.endsWith(QLatin1Char('/'))) + rootPath += QLatin1Char('/'); + + qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath)); + QStringList importPaths; importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml")); if (!rootPath.isEmpty()) -- cgit v1.2.3 From b89f2ebd9543d4cf60821a9c3cc12547d7d2253e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 22 Nov 2019 23:19:34 +0100 Subject: QWaitCondition: un-deprecate wait() functions with ulong arg The wait() functions with the unsigned long arg were marked for removal for Qt6 but due to the high usage of this functions and the very small gain, revert the deprecation. Change-Id: I9c9b720d279a59d87730f51de0f321b3794aa88e Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/thread/qwaitcondition.h | 9 ++------- src/corelib/thread/qwaitcondition.qdoc | 6 ++---- src/corelib/thread/qwaitcondition_unix.cpp | 4 ---- 3 files changed, 4 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h index 079049af25..0a47ac3717 100644 --- a/src/corelib/thread/qwaitcondition.h +++ b/src/corelib/thread/qwaitcondition.h @@ -58,14 +58,11 @@ public: bool wait(QMutex *lockedMutex, QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever)); + bool wait(QMutex *lockedMutex, unsigned long time); + bool wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever)); -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_VERSION_X_5_15("Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead") - bool wait(QMutex *lockedMutex, unsigned long time); - QT_DEPRECATED_VERSION_X_5_15("Use wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) instead") bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time); -#endif void wakeOne(); void wakeAll(); @@ -94,10 +91,8 @@ public: { return true; } bool wait(QReadWriteLock *, QDeadlineTimer = QDeadlineTimer(QDeadlineTimer::Forever)) { return true; } -#if QT_DEPRECATED_SINCE(5, 15) bool wait(QMutex *, unsigned long) { return true; } bool wait(QReadWriteLock *, unsigned long) { return true; } -#endif void wakeOne() {} void wakeAll() {} diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc index 9da6f6f25c..014d549477 100644 --- a/src/corelib/thread/qwaitcondition.qdoc +++ b/src/corelib/thread/qwaitcondition.qdoc @@ -119,16 +119,14 @@ \sa wakeOne() */ -#if QT_DEPRECATED_SINCE(5, 15) /*! \fn bool QWaitCondition::wait(QMutex *lockedMutex, unsigned long time) - \obsolete use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead + \overload */ /*! \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, unsigned long time) - \obsolete use wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) instead + \overload */ -#endif /*! \fn bool QWaitCondition::wait(QMutex *lockedMutex, QDeadlineTimer deadline) diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index 80f9e780e7..88b058f410 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -202,14 +202,12 @@ void QWaitCondition::wakeAll() report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock"); } -#if QT_DEPRECATED_SINCE(5, 15) bool QWaitCondition::wait(QMutex *mutex, unsigned long time) { if (time == std::numeric_limits<unsigned long>::max()) return wait(mutex, QDeadlineTimer(QDeadlineTimer::Forever)); return wait(mutex, QDeadlineTimer(time)); } -#endif bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline) { @@ -231,14 +229,12 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline) return returnValue; } -#if QT_DEPRECATED_SINCE(5, 15) bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time) { if (time == std::numeric_limits<unsigned long>::max()) return wait(readWriteLock, QDeadlineTimer(QDeadlineTimer::Forever)); return wait(readWriteLock, QDeadlineTimer(time)); } -#endif bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline) { -- cgit v1.2.3 From 5a660353edde7b9f382ee41ecf278fc4537f38fa Mon Sep 17 00:00:00 2001 From: Nico Vertriest <nico.vertriest@qt.io> Date: Wed, 13 Nov 2019 10:20:09 +0100 Subject: Doc: Fix qdoc compilation errors qtbase Task-number: QTBUG-79824 Change-Id: I6557de598de1931fc30556951d35783d02b83abe Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/doc/src/qtcore-index.qdoc | 2 +- src/corelib/doc/src/resource-system.qdoc | 4 +- src/corelib/global/qendian.cpp | 6 +- src/corelib/io/qresource.cpp | 4 +- src/corelib/thread/qatomic.cpp | 204 ++++++++++++++++--------- src/corelib/thread/qatomic.h | 6 + src/gui/doc/src/qtgui.qdoc | 2 +- src/gui/kernel/qwindow.cpp | 2 +- src/network/ssl/qsslsocket.cpp | 2 +- src/testlib/doc/src/qttest-best-practices.qdoc | 4 +- src/widgets/styles/qstyleoption.cpp | 2 +- 11 files changed, 156 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc index 40a6584af0..29fc25f69d 100644 --- a/src/corelib/doc/src/qtcore-index.qdoc +++ b/src/corelib/doc/src/qtcore-index.qdoc @@ -56,7 +56,7 @@ \include module-use.qdocinc using qt module \quotefile overview/using-qt-core.cmake - See also the \l[QtDoc]{Building with CMake} overview. + See also the \l[QtDoc]{Build with CMake} overview. \section2 Building with qmake diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc index 69ec5e556b..f9ef317799 100644 --- a/src/corelib/doc/src/resource-system.qdoc +++ b/src/corelib/doc/src/resource-system.qdoc @@ -189,13 +189,13 @@ XML file to indicate a file should be most compressed, regardless of which algorithms \c rcc supports. - \li \c{zstd}: use the \l{Zstandard}{https://zstd.net} library to compress + \li \c{zstd}: use the \l{https://zstd.net}{Zstandard} library to compress contents. Valid compression levels range from 1 to 19, 1 is least compression (least CPU time) and 19 is the most compression (most CPU time). The default level is 14. A special value of 0 tells the \c{zstd} library to choose an implementation-defined default. - \li \c{zlib}: use the \l{zlib}{https://zlib.net} library to compress + \li \c{zlib}: use the \l{https://zlib.net}{zlib} library to compress contents. Valid compression levels range from 1 to 9, with 1the least compression (least CPU time) and 9 the most compression (most CPU time). The special value 0 means "no compression" and should not be used. The diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp index 7fd6e13d3b..98dc6a9a4b 100644 --- a/src/corelib/global/qendian.cpp +++ b/src/corelib/global/qendian.cpp @@ -137,7 +137,7 @@ QT_BEGIN_NAMESPACE \sa qToLittleEndian() */ /*! - \fn template <typename T> T qFromLittleEndian(const void *src) + \fn template <typename T> inline T qFromLittleEndian(const void *src) \since 4.3 \relates <QtEndian> @@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE \sa qToLittleEndian() */ /*! - \fn template <typename T> T qFromLittleEndian(T src) + \fn template <typename T> inline T qFromLittleEndian(T src) \since 4.3 \relates <QtEndian> \overload @@ -171,7 +171,7 @@ QT_BEGIN_NAMESPACE unmodified. */ /*! - \fn template <typename T> T qFromLittleEndian(const void *src, qsizetype count, void *dest) + \fn template <typename T> inline T qFromLittleEndian(const void *src, qsizetype count, void *dest) \since 5.12 \relates <QtEndian> diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 22c22ce711..5cbe49e2f7 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -280,9 +280,9 @@ static inline QStringList *resourceSearchPaths() RCC tool used to compress the payload. \value NoCompression Contents are not compressed - \value ZlibCompression Contents are compressed using \l{zlib}{https://zlib.net} and can + \value ZlibCompression Contents are compressed using \l{https://zlib.net}{zlib} and can be decompressed using the qUncompress() function. - \value ZstdCompression Contents are compressed using \l{zstd}{https://zstd.net}. To + \value ZstdCompression Contents are compressed using \l{https://zstd.net}{zstd}. To decompress, use the \c{ZSTD_decompress} function from the zstd library. diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index b1a7edad91..5c3ad9412f 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -234,22 +234,26 @@ \sa QAtomicPointer */ -/*! \fn QAtomicInt::QAtomicInt(int value) +/*! + \fn QAtomicInt::QAtomicInt(int value) Constructs a QAtomicInt with the given \a value. */ -/*! \fn QAtomicInteger<T>::QAtomicInteger(T value) +/*! + \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(T value) Constructs a QAtomicInteger with the given \a value. */ -/*! \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(const QAtomicInteger &other) +/*! + \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(const QAtomicInteger &other) Constructs a copy of \a other. */ -/*! \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(const QAtomicInteger &other) +/*! + \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(const QAtomicInteger &other) Assigns \a other to this QAtomicInteger and returns a reference to this QAtomicInteger. @@ -344,19 +348,22 @@ \sa storeRelaxed(), storeRelease() */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingNative() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingNative() Returns \c true if reference counting is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingWaitFree() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingWaitFree() Returns \c true if atomic reference counting is wait-free, false otherwise. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::ref() +/*! + \fn template <typename T> bool QAtomicInteger<T>::ref() Atomically increments the value of this QAtomicInteger. Returns \c true if the new value is non-zero, false otherwise. @@ -394,7 +401,8 @@ \sa ref(), operator++(), operator--(int) */ -/*! \fn template <typename T> bool QAtomicInteger<T>::deref() +/*! + \fn template <typename T> bool QAtomicInteger<T>::deref() Atomically decrements the value of this QAtomicInteger. Returns \c true if the new value is non-zero, false otherwise. @@ -432,18 +440,21 @@ \sa deref(), operator--(), operator++(int) */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetNative() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetNative() Returns \c true if test-and-set is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetWaitFree() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetWaitFree() Returns \c true if atomic test-and-set is wait-free, false otherwise. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelaxed(T expectedValue, T newValue) +/*! + \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelaxed(T expectedValue, T newValue) Atomic test-and-set. @@ -457,7 +468,8 @@ processor to freely reorder memory accesses. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetAcquire(T expectedValue, T newValue) +/*! + \fn template <typename T> bool QAtomicInteger<T>::testAndSetAcquire(T expectedValue, T newValue) Atomic test-and-set. @@ -472,7 +484,8 @@ be re-ordered before the atomic operation. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelease(T expectedValue, T newValue) +/*! + \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelease(T expectedValue, T newValue) Atomic test-and-set. @@ -487,7 +500,8 @@ re-ordered after the atomic operation. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetOrdered(T expectedValue, T newValue) +/*! + \fn template <typename T> bool QAtomicInteger<T>::testAndSetOrdered(T expectedValue, T newValue) Atomic test-and-set. @@ -502,19 +516,22 @@ may not be re-ordered. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreNative() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreNative() Returns \c true if fetch-and-store is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreWaitFree() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreWaitFree() Returns \c true if atomic fetch-and-store is wait-free, false otherwise. */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelaxed(T newValue) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelaxed(T newValue) Atomic fetch-and-store. @@ -526,7 +543,8 @@ processor to freely reorder memory accesses. */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreAcquire(T newValue) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreAcquire(T newValue) Atomic fetch-and-store. @@ -539,7 +557,8 @@ be re-ordered before the atomic operation. */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelease(T newValue) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelease(T newValue) Atomic fetch-and-store. @@ -552,7 +571,8 @@ re-ordered after the atomic operation. */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreOrdered(T newValue) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreOrdered(T newValue) Atomic fetch-and-store. @@ -565,19 +585,22 @@ may not be re-ordered. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddNative() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddNative() Returns \c true if fetch-and-add is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddWaitFree() +/*! + \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddWaitFree() Returns \c true if atomic fetch-and-add is wait-free, false otherwise. */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelaxed(T valueToAdd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelaxed(T valueToAdd) Atomic fetch-and-add. @@ -591,7 +614,8 @@ \sa operator+=(), fetchAndSubRelaxed() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddAcquire(T valueToAdd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAddAcquire(T valueToAdd) Atomic fetch-and-add. @@ -606,7 +630,8 @@ \sa operator+=(), fetchAndSubAcquire() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelease(T valueToAdd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelease(T valueToAdd) Atomic fetch-and-add. @@ -621,7 +646,8 @@ \sa operator+=(), fetchAndSubRelease() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddOrdered(T valueToAdd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAddOrdered(T valueToAdd) Atomic fetch-and-add. @@ -636,7 +662,8 @@ \sa operator+=(), fetchAndSubOrdered() */ -/*! \fn template <typename T> T QAtomicInteger<T>::operator+=(T value) +/*! + \fn template <typename T> T QAtomicInteger<T>::operator+=(T value) \since 5.3 Atomic add-and-fetch. @@ -650,7 +677,8 @@ \sa fetchAndAddOrdered(), operator-=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelaxed(T valueToSub) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelaxed(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -665,7 +693,8 @@ \sa operator-=(), fetchAndAddRelaxed() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubAcquire(T valueToSub) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndSubAcquire(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -681,7 +710,8 @@ \sa operator-=(), fetchAndAddAcquire() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelease(T valueToSub) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelease(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -697,7 +727,8 @@ \sa operator-=(), fetchAndAddRelease() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubOrdered(T valueToSub) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndSubOrdered(T valueToSub) \since 5.3 Atomic fetch-and-sub. @@ -713,7 +744,8 @@ \sa operator-=(), fetchAndAddOrdered() */ -/*! \fn template <typename T> T QAtomicInteger<T>::operator-=(T value) +/*! + \fn template <typename T> T QAtomicInteger<T>::operator-=(T value) \since 5.3 Atomic sub-and-fetch. @@ -727,7 +759,8 @@ \sa fetchAndSubOrdered(), operator+=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelaxed(T valueToOr) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelaxed(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -742,7 +775,8 @@ \sa operator|=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrAcquire(T valueToOr) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndOrAcquire(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -758,7 +792,8 @@ \sa operator|=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelease(T valueToOr) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelease(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -774,7 +809,8 @@ \sa operator|=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrOrdered(T valueToOr) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndOrOrdered(T valueToOr) \since 5.3 Atomic fetch-and-or. @@ -790,7 +826,8 @@ \sa operator|=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::operator|=(T value) +/*! + \fn template <typename T> T QAtomicInteger<T>::operator|=(T value) \since 5.3 Atomic or-and-fetch. @@ -804,7 +841,8 @@ \sa fetchAndOrOrdered() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelaxed(T valueToXor) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelaxed(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -819,7 +857,8 @@ \sa operator^=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorAcquire(T valueToXor) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndXorAcquire(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -835,7 +874,8 @@ \sa operator^=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelease(T valueToXor) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelease(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -851,7 +891,8 @@ \sa operator^=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorOrdered(T valueToXor) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndXorOrdered(T valueToXor) \since 5.3 Atomic fetch-and-xor. @@ -867,7 +908,8 @@ \sa operator^=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::operator^=(T value) +/*! + \fn template <typename T> T QAtomicInteger<T>::operator^=(T value) \since 5.3 Atomic xor-and-fetch. @@ -881,7 +923,8 @@ \sa fetchAndXorOrdered() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelaxed(T valueToAnd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelaxed(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -896,7 +939,8 @@ \sa operator&=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndAcquire(T valueToAnd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAndAcquire(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -912,7 +956,8 @@ \sa operator&=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelease(T valueToAnd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelease(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -928,7 +973,8 @@ \sa operator&=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndOrdered(T valueToAnd) +/*! + \fn template <typename T> T QAtomicInteger<T>::fetchAndAndOrdered(T valueToAnd) \since 5.3 Atomic fetch-and-and. @@ -944,7 +990,8 @@ \sa operator&=() */ -/*! \fn template <typename T> T QAtomicInteger<T>::operator&=(T value) +/*! + \fn template <typename T> T QAtomicInteger<T>::operator&=(T value) \since 5.3 Atomic add-and-fetch. @@ -1287,17 +1334,20 @@ \sa QAtomicInteger */ -/*! \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(T *value) +/*! + \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(T *value) Constructs a QAtomicPointer with the given \a value. */ -/*! \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(const QAtomicPointer<T> &other) +/*! + \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(const QAtomicPointer<T> &other) Constructs a copy of \a other. */ -/*! \fn template <typename T> QAtomicPointer &QAtomicPointer<T>::operator=(const QAtomicPointer &other) +/*! + \fn template <typename T> QAtomicPointer &QAtomicPointer<T>::operator=(const QAtomicPointer &other) Assigns \a other to this QAtomicPointer and returns a reference to this QAtomicPointer. @@ -1369,18 +1419,21 @@ \sa storeRelaxed(), loadRelaxed() */ -/*! \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetNative() +/*! + \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetNative() Returns \c true if test-and-set is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetWaitFree() +/*! + \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetWaitFree() Returns \c true if atomic test-and-set is wait-free, false otherwise. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue) +/*! + \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue) Atomic test-and-set. @@ -1394,7 +1447,8 @@ processor to freely reorder memory accesses. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue) +/*! + \fn template <typename T> bool QAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue) Atomic test-and-set. @@ -1409,7 +1463,8 @@ be re-ordered before the atomic operation. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue) +/*! + \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue) Atomic test-and-set. @@ -1424,7 +1479,8 @@ re-ordered after the atomic operation. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue) +/*! + \fn template <typename T> bool QAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue) Atomic test-and-set. @@ -1439,19 +1495,22 @@ may not be re-ordered. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreNative() +/*! + \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreNative() Returns \c true if fetch-and-store is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreWaitFree() +/*! + \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreWaitFree() Returns \c true if atomic fetch-and-store is wait-free, false otherwise. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) Atomic fetch-and-store. @@ -1463,7 +1522,8 @@ processor to freely reorder memory accesses. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreAcquire(T *newValue) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreAcquire(T *newValue) Atomic fetch-and-store. @@ -1476,7 +1536,8 @@ be re-ordered before the atomic operation. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelease(T *newValue) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelease(T *newValue) Atomic fetch-and-store. @@ -1489,7 +1550,8 @@ re-ordered after the atomic operation. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreOrdered(T *newValue) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreOrdered(T *newValue) Atomic fetch-and-store. @@ -1502,19 +1564,22 @@ may not be re-ordered. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddNative() +/*! + \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddNative() Returns \c true if fetch-and-add is implemented using atomic processor instructions, false otherwise. */ -/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddWaitFree() +/*! + \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddWaitFree() Returns \c true if atomic fetch-and-add is wait-free, false otherwise. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd) Atomic fetch-and-add. @@ -1526,7 +1591,8 @@ processor to freely reorder memory accesses. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd) Atomic fetch-and-add. @@ -1539,7 +1605,8 @@ be re-ordered before the atomic operation. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd) Atomic fetch-and-add. @@ -1552,7 +1619,8 @@ re-ordered after the atomic operation. */ -/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd) +/*! + \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd) Atomic fetch-and-add. diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index a3b9be0729..aa57ddc610 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -50,6 +50,10 @@ QT_BEGIN_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wextra") +#ifdef Q_CLANG_QDOC +# undef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS +#endif + // High-level atomic integer operations template <typename T> class QAtomicInteger : public QBasicAtomicInteger<T> @@ -194,7 +198,9 @@ public: #ifdef Q_QDOC T *load() const; T *loadAcquire() const; + T *loadRelaxed() const; void store(T *newValue); + void storeRelaxed(T *newValue); void storeRelease(T *newValue); static Q_DECL_CONSTEXPR bool isTestAndSetNative(); diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc index c4e7d32de1..392b6040cb 100644 --- a/src/gui/doc/src/qtgui.qdoc +++ b/src/gui/doc/src/qtgui.qdoc @@ -62,7 +62,7 @@ \include module-use.qdocinc using qt module \quotefile overview/using-qt-gui.cmake - See also the \l[QtDoc]{Building with CMake} overview. + See also the \l[QtDoc]{Build with CMake} overview. \section2 Building with qmake diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index b71a0c54aa..f701755500 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -1344,7 +1344,7 @@ Qt::WindowStates QWindow::windowStates() const This is a hint to the window manager that this window is a dialog or pop-up on behalf of the transient parent. - In order to cause the window to be centered above its transient parent by + In order to cause the window to be centered above its transient \a parent by default, depending on the window manager, it may also be necessary to call setFlags() with a suitable \l Qt::WindowType (such as \c Qt::Dialog). diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index e302aa1761..4e9e947263 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1512,7 +1512,7 @@ bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFor SSL socket's CA certificate database is initialized to the default CA certificate database. - \sa QSslConfiguration::caCertificates(), addCaCertificates() + \sa addCaCertificates() */ void QSslSocket::addDefaultCaCertificate(const QSslCertificate &certificate) { diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc index c7fee93c80..8ad67acce6 100644 --- a/src/testlib/doc/src/qttest-best-practices.qdoc +++ b/src/testlib/doc/src/qttest-best-practices.qdoc @@ -278,8 +278,8 @@ \section2 Avoid Fixed Timeouts Avoid using hard-coded timeouts, such as QTest::qWait() to wait for some - conditions to become true. Consider using the \l QtSignalSpy class, - the \l QTRY_VERIFY() or \l QTRY_COMPARE() macros, or the \c QtSignalSpy + conditions to become true. Consider using the \l QSignalSpy class, + the \l QTRY_VERIFY() or \l QTRY_COMPARE() macros, or the \c QSignalSpy class in conjunction with the \c QTRY_ macro variants. The \c qWait() function can be used to set a delay for a fixed period diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 01cadd9a86..237d496e0e 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1453,7 +1453,7 @@ QStyleOptionTab::QStyleOptionTab(int version) \value None A normal tab button. \value HasFrame The tab button is positioned on a tab frame - \sa features + \sa QStyleOptionToolBar::features */ /*! -- cgit v1.2.3 From c496fee2a5b65fd1b0672923293db058486e350e Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Fri, 11 Oct 2019 14:10:39 -0700 Subject: qSwap: suppress pedantic warning about noexcept being false This warning is not in -Wall or -Wextra, but it happens in a single place, so we can reasonably suppress it. Fixes: QTBUG-79138 Change-Id: Ib5d667bf77a740c28d2efffd15ccb3f62cf8f431 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/corelib/global/qglobal.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e335916eac..e636a7cf8f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -944,6 +944,10 @@ QT_WARNING_POP # define Q_DUMMY_COMPARISON_OPERATOR(C) #endif +QT_WARNING_PUSH +// warning: noexcept-expression evaluates to ‘false’ because of a call to ‘void swap(..., ...)' +QT_WARNING_DISABLE_GCC("-Wnoexcept") + namespace QtPrivate { namespace SwapExceptionTester { // insulate users from the "using std::swap" below @@ -963,6 +967,8 @@ inline void qSwap(T &value1, T &value2) swap(value1, value2); } +QT_WARNING_POP + #if QT_DEPRECATED_SINCE(5, 0) Q_CORE_EXPORT QT_DEPRECATED void *qMalloc(size_t size) Q_ALLOC_SIZE(1); Q_CORE_EXPORT QT_DEPRECATED void qFree(void *ptr); -- cgit v1.2.3 From 23d23125068f98f4e6bb1ed3bc9899cefd8cbbf4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@qt.io> Date: Tue, 29 Oct 2019 13:50:22 +0100 Subject: Split cborstream feature in two Reading of Cbor streams is substantially more complicated than writing as it requires float16 support. When writing Cbor, we can just choose to always write 32bit floats, even if we could compress the numbers into 16 bits. We need Cbor writing in the bootstrap library, but we cannot easily add float16 support. Furthermore, Cbor reading is required for plugin support, but not Cbor writing. It might make sense for some users to build a custom Qt with Cbor writing disabled. Therefore, provide two features, cborstreamreader and cborstreamwriter, split up the code in cborstream.{h|cpp} into several files, and enable Cbor writing in the bootstrap library. Change-Id: I15450afb0e328a84a22ebca9379cffc4f900a75a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/configure.json | 12 +- src/corelib/global/qconfig-bootstrapped.h | 3 +- src/corelib/serialization/qcborcommon.cpp | 328 +++ src/corelib/serialization/qcborcommon.h | 2 + src/corelib/serialization/qcborcommon_p.h | 84 + src/corelib/serialization/qcborstream.cpp | 2649 ----------------------- src/corelib/serialization/qcborstream.h | 226 +- src/corelib/serialization/qcborstreamreader.cpp | 1533 +++++++++++++ src/corelib/serialization/qcborstreamreader.h | 210 ++ src/corelib/serialization/qcborstreamwriter.cpp | 868 ++++++++ src/corelib/serialization/qcborstreamwriter.h | 130 ++ src/corelib/serialization/qcborvalue.cpp | 34 +- src/corelib/serialization/qcborvalue.h | 8 +- src/corelib/serialization/serialization.pri | 17 +- src/tools/bootstrap/bootstrap.pro | 6 + 15 files changed, 3223 insertions(+), 2887 deletions(-) create mode 100644 src/corelib/serialization/qcborcommon.cpp create mode 100644 src/corelib/serialization/qcborcommon_p.h delete mode 100644 src/corelib/serialization/qcborstream.cpp create mode 100644 src/corelib/serialization/qcborstreamreader.cpp create mode 100644 src/corelib/serialization/qcborstreamreader.h create mode 100644 src/corelib/serialization/qcborstreamwriter.cpp create mode 100644 src/corelib/serialization/qcborstreamwriter.h (limited to 'src') diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 04643aec33..eb60ad213c 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -1087,14 +1087,20 @@ Mozilla License) is included. The data is then also used in QNetworkCookieJar::v "label": "Windows System Libraries", "condition": "config.win32 && libs.advapi32 && libs.gdi32 && libs.kernel32 && libs.netapi32 && libs.ole32 && libs.shell32 && libs.uuid && libs.user32 && libs.winmm && libs.ws2_32" }, - "cborstream": { - "label": "CBOR stream I/O", - "purpose": "Provides support for reading and writing the CBOR binary format. + "cborstreamreader": { + "label": "CBOR stream reading", + "purpose": "Provides support for reading the CBOR binary format. Note that this is required for plugin loading. Qt GUI needs QPA plugins for basic operation.", "section": "Utilities", "output": [ "publicFeature" ] }, + "cborstreamwriter": { + "label": "CBOR stream writing", + "purpose": "Provides support for writing the CBOR binary format.", + "section": "Utilities", + "output": [ "publicFeature" ] + }, "binaryjson": { "label": "Binary JSON (deprecated)", "purpose": "Provides support for the deprecated binary JSON format.", diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index b62c1a4d35..b3daf43c04 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -75,7 +75,8 @@ # define QT_FEATURE_alloca_malloc_h -1 #endif #define QT_FEATURE_binaryjson -1 -#define QT_FEATURE_cborstream -1 +#define QT_FEATURE_cborstreamreader -1 +#define QT_FEATURE_cborstreamwriter 1 #define QT_CRYPTOGRAPHICHASH_ONLY_SHA1 #define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1) #define QT_NO_DATASTREAM diff --git a/src/corelib/serialization/qcborcommon.cpp b/src/corelib/serialization/qcborcommon.cpp new file mode 100644 index 0000000000..37fb198744 --- /dev/null +++ b/src/corelib/serialization/qcborcommon.cpp @@ -0,0 +1,328 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#define CBOR_NO_ENCODER_API +#define CBOR_NO_PARSER_API +#include "qcborcommon_p.h" + +#include <QtCore/qdatastream.h> + +QT_BEGIN_NAMESPACE + +#include <cborerrorstrings.c> + +/*! + \headerfile <QtCborCommon> + + \brief The <QtCborCommon> header contains definitions common to both the + streaming classes (QCborStreamReader and QCborStreamWriter) and to + QCborValue. + */ + +/*! + \enum QCborSimpleType + \relates <QtCborCommon> + + This enum contains the possible "Simple Types" for CBOR. Simple Types range + from 0 to 255 and are types that carry no further value. + + The following values are currently known: + + \value False A "false" boolean. + \value True A "true" boolean. + \value Null Absence of value (null). + \value Undefined Missing or deleted value, usually an error. + + Qt CBOR API supports encoding and decoding any Simple Type, whether one of + those above or any other value. + + Applications should only use further values if a corresponding specification + has been published, otherwise interpretation and validation by the remote + may fail. Values 24 to 31 are reserved and must not be used. + + The current authoritative list is maintained by IANA in the + \l{https://www.iana.org/assignments/cbor-simple-values/cbor-simple-values.xml}{Simple + Values registry}. + + \sa QCborStreamWriter::append(QCborSimpleType), QCborStreamReader::isSimpleType(), + QCborStreamReader::toSimpleType(), QCborValue::isSimpleType(), QCborValue::toSimpleType() + */ + +#if !defined(QT_NO_DATASTREAM) +QDataStream &operator<<(QDataStream &ds, QCborSimpleType st) +{ + return ds << quint8(st); +} + +QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st) +{ + quint8 v; + ds >> v; + st = QCborSimpleType(v); + return ds; +} +#endif + +/*! + \enum QCborTag + \relates <QtCborCommon> + + This enum contains no enumeration and is used only to provide type-safe + access to a CBOR tag. + + CBOR tags are 64-bit numbers that are attached to generic CBOR types to + provide further semantic meaning. QCborTag may be constructed from an + enumeration found in QCborKnownTags or directly by providing the numeric + representation. + + For example, the following creates a QCborValue containing a byte array + tagged with a tag 2. + + \snippet code/src_corelib_serialization_qcborstream.cpp 0 + + \sa QCborKnownTags, QCborStreamWriter::append(QCborTag), + QCborStreamReader::isTag(), QCborStreamReader::toTag(), + QCborValue::isTag(), QCborValue::tag() + */ + +/*! + \enum QCborKnownTags + \relates <QtCborCommon> + + This enum contains a list of CBOR tags, known at the time of the Qt + implementation. This list is not meant to be complete and contains only + tags that are either backed by an RFC or specifically used by the Qt + implementation. + + The authoritative list is maintained by IANA in the + \l{https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml}{CBOR tag + registry}. + + \value DateTimeString A date and time string, formatted according to RFC 3339, as refined + by RFC 4287. It is the same format as Qt::ISODate and + Qt::ISODateWithMs. + \value UnixTime_t A numerical representation of seconds elapsed since + 1970-01-01T00:00Z. + \value PositiveBignum A positive number of arbitrary length, encoded as a byte array in + network byte order. For example, the number 2\sup{64} is represented by + a byte array containing the byte value 0x01 followed by 8 zero bytes. + \value NegativeBignum A negative number of arbirary length, encoded as the absolute value + of that number, minus one. For example, a byte array containing + byte value 0x02 followed by 8 zero bytes represents the number + -2\sup{65} - 1. + \value Decimal A decimal fraction, encoded as an array of two integers: the first + is the exponent of the power of 10, the second the integral + mantissa. The value 273.15 would be encoded as array \c{[-2, 27315]}. + \value Bigfloat Similar to Decimal, but the exponent is a power of 2 instead. + \value COSE_Encrypt0 An \c Encrypt0 map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} + (CBOR Object Signing and Encryption). + \value COSE_Mac0 A \c Mac0 map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} + (CBOR Object Signing and Encryption). + \value COSE_Sign1 A \c Sign1 map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} + (CBOR Object Signing and Encryption). + \value ExpectedBase64url Indicates that the byte array should be encoded using Base64url + if the stream is converted to JSON. + \value ExpectedBase64 Indicates that the byte array should be encoded using Base64 + if the stream is converted to JSON. + \value ExpectedBase16 Indicates that the byte array should be encoded using Base16 (hex) + if the stream is converted to JSON. + \value EncodedCbor Indicates that the byte array contains a CBOR stream. + \value Url Indicates that the string contains a URL. + \value Base64url Indicates that the string contains data encoded using Base64url. + \value Base64 Indicates that the string contains data encoded using Base64. + \value RegularExpression Indicates that the string contains a Perl-Compatible Regular + Expression pattern. + \value MimeMessage Indicates that the string contains a MIME message (according to + \l{https://tools.ietf.org/html/rfc2045}){RFC 2045}. + \value Uuid Indicates that the byte array contains a UUID. + \value COSE_Encrypt An \c Encrypt map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} + (CBOR Object Signing and Encryption). + \value COSE_Mac A \c Mac map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} + (CBOR Object Signing and Encryption). + \value COSE_Sign A \c Sign map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} + (CBOR Object Signing and Encryption). + \value Signature No change in interpretation; this tag can be used as the outermost + tag in a CBOR stream as the file header. + + The following tags are interpreted by QCborValue during decoding and will + produce objects with extended Qt types, and it will use those tags when + encoding the same extended types. + + \value DateTimeString \l QDateTime + \value UnixTime_t \l QDateTime (only in decoding) + \value Url \l QUrl + \value Uuid \l QUuid + + Additionally, if a QCborValue containing a QByteArray is tagged using one of + \c ExpectedBase64url, \c ExpectedBase64 or \c ExpectedBase16, QCborValue + will use the expected encoding when converting to JSON (see + QCborValue::toJsonValue). + + \sa QCborTag, QCborStreamWriter::append(QCborTag), + QCborStreamReader::isTag(), QCborStreamReader::toTag(), + QCborValue::isTag(), QCborValue::tag() + */ + +/*! + \class QCborError + \inmodule QtCore + \relates <QtCborCommon> + \reentrant + \since 5.12 + + \brief The QCborError class holds the error condition found while parsing or + validating a CBOR stream. + + \sa QCborStreamReader, QCborValue, QCborParserError + */ + +/*! + \enum QCborError::Code + + This enum contains the possible error condition codes. + + \value NoError No error was detected. + \value UnknownError An unknown error occurred and no further details are available. + \value AdvancePastEnd QCborStreamReader::next() was called but there are no more elements in + the current context. + \value InputOutputError An I/O error with the QIODevice occurred. + \value GarbageAtEnd Data was found in the input stream after the last element. + \value EndOfFile The end of the input stream was unexpectedly reached while processing an + element. + \value UnexpectedBreak The CBOR stream contains a Break where it is not allowed (data is + corrupt and the error is not recoverable). + \value UnknownType The CBOR stream contains an unknown/unparseable Type (data is corrupt + and the and the error is not recoverable). + \value IllegalType The CBOR stream contains a known type in a position it is not allowed + to exist (data is corrupt and the error is not recoverable). + \value IllegalNumber The CBOR stream appears to be encoding a number larger than 64-bit + (data is corrupt and the error is not recoverable). + \value IllegalSimpleType The CBOR stream contains a Simple Type encoded incorrectly (data is + corrupt and the error is not recoverable). + \value InvalidUtf8String The CBOR stream contains a text string that does not decode properly + as UTF-8 (data is corrupt and the error is not recoverable). + \value DataTooLarge CBOR string, map or array is too big and cannot be parsed by Qt + (internal limitation, but the error is not recoverable). + \value NestingTooDeep Too many levels of arrays or maps encountered while processing the + input (internal limitation, but the error is not recoverable). + \value UnsupportedType The CBOR stream contains a known type that the implementation does not + support (internal limitation, but the error is not recoverable). + */ + +/*! + \variable QCborError::c + \internal + */ + +/*! + \fn QCborError::operator Code() const + + Returns the error code that this QCborError object stores. + */ + +/*! + Returns a text string that matches the error code in this QCborError object. + + Note: the string is not translated. Applications whose interface allow users + to parse CBOR streams need to provide their own, translated strings. + + \sa QCborError::Code + */ +QString QCborError::toString() const +{ + switch (c) { + case NoError: + Q_STATIC_ASSERT(int(NoError) == int(CborNoError)); + return QString(); + + case UnknownError: + Q_STATIC_ASSERT(int(UnknownError) == int(CborUnknownError)); + return QStringLiteral("Unknown error"); + case AdvancePastEnd: + Q_STATIC_ASSERT(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF)); + return QStringLiteral("Read past end of buffer (more bytes needed)"); + case InputOutputError: + Q_STATIC_ASSERT(int(InputOutputError) == int(CborErrorIO)); + return QStringLiteral("Input/Output error"); + case GarbageAtEnd: + Q_STATIC_ASSERT(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd)); + return QStringLiteral("Data found after the end of the stream"); + case EndOfFile: + Q_STATIC_ASSERT(int(EndOfFile) == int(CborErrorUnexpectedEOF)); + return QStringLiteral("Unexpected end of input data (more bytes needed)"); + case UnexpectedBreak: + Q_STATIC_ASSERT(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak)); + return QStringLiteral("Invalid CBOR stream: unexpected 'break' byte"); + case UnknownType: + Q_STATIC_ASSERT(int(UnknownType) == int(CborErrorUnknownType)); + return QStringLiteral("Invalid CBOR stream: unknown type"); + case IllegalType: + Q_STATIC_ASSERT(int(IllegalType) == int(CborErrorIllegalType)); + return QStringLiteral("Invalid CBOR stream: illegal type found"); + case IllegalNumber: + Q_STATIC_ASSERT(int(IllegalNumber) == int(CborErrorIllegalNumber)); + return QStringLiteral("Invalid CBOR stream: illegal number encoding (future extension)"); + case IllegalSimpleType: + Q_STATIC_ASSERT(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType)); + return QStringLiteral("Invalid CBOR stream: illegal simple type"); + case InvalidUtf8String: + Q_STATIC_ASSERT(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString)); + return QStringLiteral("Invalid CBOR stream: invalid UTF-8 text string"); + case DataTooLarge: + Q_STATIC_ASSERT(int(DataTooLarge) == int(CborErrorDataTooLarge)); + return QStringLiteral("Internal limitation: data set too large"); + case NestingTooDeep: + Q_STATIC_ASSERT(int(NestingTooDeep) == int(CborErrorNestingTooDeep)); + return QStringLiteral("Internal limitation: data nesting too deep"); + case UnsupportedType: + Q_STATIC_ASSERT(int(UnsupportedType) == int(CborErrorUnsupportedType)); + return QStringLiteral("Internal limitation: unsupported type"); + } + + // get the error string from TinyCBOR + CborError err = CborError(int(c)); + return QString::fromLatin1(cbor_error_string(err)); +} + +QT_END_NAMESPACE + +#ifndef QT_BOOTSTRAPPED +#include "moc_qcborcommon.cpp" +#endif diff --git a/src/corelib/serialization/qcborcommon.h b/src/corelib/serialization/qcborcommon.h index 3dfe50cd09..bec46399ce 100644 --- a/src/corelib/serialization/qcborcommon.h +++ b/src/corelib/serialization/qcborcommon.h @@ -148,6 +148,8 @@ inline uint qHash(QCborTag tag, uint seed = 0) return qHash(quint64(tag), seed); } +enum class QCborNegativeInteger : quint64 {}; + QT_END_NAMESPACE Q_DECLARE_METATYPE(QCborTag) diff --git a/src/corelib/serialization/qcborcommon_p.h b/src/corelib/serialization/qcborcommon_p.h new file mode 100644 index 0000000000..9b7f4b7099 --- /dev/null +++ b/src/corelib/serialization/qcborcommon_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCBORCOMMON_P_H +#define QCBORCOMMON_P_H + +#include "qcborcommon.h" + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +#ifdef QT_NO_DEBUG +# define NDEBUG 1 +#endif +#undef assert +#define assert Q_ASSERT + +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wunused-function") +QT_WARNING_DISABLE_CLANG("-Wunused-function") +QT_WARNING_DISABLE_CLANG("-Wundefined-internal") + +#define CBOR_NO_VALIDATION_API 1 +#define CBOR_NO_PRETTY_API 1 +#define CBOR_API static inline +#define CBOR_PRIVATE_API static inline +#define CBOR_INLINE_API static inline + +#include <cbor.h> + +QT_WARNING_POP + +Q_DECLARE_TYPEINFO(CborValue, Q_PRIMITIVE_TYPE); + +QT_END_NAMESPACE + +#endif // QCBORCOMMON_P_H diff --git a/src/corelib/serialization/qcborstream.cpp b/src/corelib/serialization/qcborstream.cpp deleted file mode 100644 index a232f7eef7..0000000000 --- a/src/corelib/serialization/qcborstream.cpp +++ /dev/null @@ -1,2649 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qcborstream.h" - -#include <private/qnumeric_p.h> -#include <private/qutfcodec_p.h> -#include <qbuffer.h> -#include <qdebug.h> -#include <qstack.h> -#include <qdatastream.h> - -QT_BEGIN_NAMESPACE - -#ifdef QT_NO_DEBUG -# define NDEBUG 1 -#endif -#undef assert -#define assert Q_ASSERT - -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wunused-function") -QT_WARNING_DISABLE_CLANG("-Wunused-function") -QT_WARNING_DISABLE_CLANG("-Wundefined-internal") -QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) - -#define CBOR_ENCODER_NO_CHECK_USER - -#define CBOR_NO_VALIDATION_API 1 -#define CBOR_NO_PRETTY_API 1 -#define CBOR_API static inline -#define CBOR_PRIVATE_API static inline -#define CBOR_INLINE_API static inline - -#include <cbor.h> - -static CborError qt_cbor_encoder_write_callback(void *token, const void *data, size_t len, CborEncoderAppendType); -static bool qt_cbor_decoder_can_read(void *token, size_t len); -static void qt_cbor_decoder_advance(void *token, size_t len); -static void *qt_cbor_decoder_read(void *token, void *userptr, size_t offset, size_t len); -static CborError qt_cbor_decoder_transfer_string(void *token, const void **userptr, size_t offset, size_t len); - -#define CBOR_ENCODER_WRITER_CONTROL 1 -#define CBOR_ENCODER_WRITE_FUNCTION qt_cbor_encoder_write_callback - -#define CBOR_PARSER_READER_CONTROL 1 -#define CBOR_PARSER_CAN_READ_BYTES_FUNCTION qt_cbor_decoder_can_read -#define CBOR_PARSER_ADVANCE_BYTES_FUNCTION qt_cbor_decoder_advance -#define CBOR_PARSER_TRANSFER_STRING_FUNCTION qt_cbor_decoder_transfer_string -#define CBOR_PARSER_READ_BYTES_FUNCTION qt_cbor_decoder_read - -#include "../3rdparty/tinycbor/src/cborencoder.c" -#include "../3rdparty/tinycbor/src/cborerrorstrings.c" -#include "../3rdparty/tinycbor/src/cborparser.c" - -// silence compilers that complain about this being a static function declared -// but never defined -static CborError cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*) -{ - Q_UNREACHABLE(); - return CborErrorInternalError; -} -static CborError _cbor_value_dup_string(const CborValue *, void **, size_t *, CborValue *) -{ - Q_UNREACHABLE(); - return CborErrorInternalError; -} -static CborError cbor_value_get_half_float_as_float(const CborValue *, float *) -{ - Q_UNREACHABLE(); - return CborErrorInternalError; -} -static CborError cbor_encode_float_as_half_float(CborEncoder *, float) -{ - Q_UNREACHABLE(); - return CborErrorInternalError; -} -QT_WARNING_POP - -Q_DECLARE_TYPEINFO(CborEncoder, Q_PRIMITIVE_TYPE); -Q_DECLARE_TYPEINFO(CborValue, Q_PRIMITIVE_TYPE); - -// confirm our constants match TinyCBOR's -Q_STATIC_ASSERT(int(QCborStreamReader::UnsignedInteger) == CborIntegerType); -Q_STATIC_ASSERT(int(QCborStreamReader::ByteString) == CborByteStringType); -Q_STATIC_ASSERT(int(QCborStreamReader::TextString) == CborTextStringType); -Q_STATIC_ASSERT(int(QCborStreamReader::Array) == CborArrayType); -Q_STATIC_ASSERT(int(QCborStreamReader::Map) == CborMapType); -Q_STATIC_ASSERT(int(QCborStreamReader::Tag) == CborTagType); -Q_STATIC_ASSERT(int(QCborStreamReader::SimpleType) == CborSimpleType); -Q_STATIC_ASSERT(int(QCborStreamReader::HalfFloat) == CborHalfFloatType); -Q_STATIC_ASSERT(int(QCborStreamReader::Float) == CborFloatType); -Q_STATIC_ASSERT(int(QCborStreamReader::Double) == CborDoubleType); -Q_STATIC_ASSERT(int(QCborStreamReader::Invalid) == CborInvalidType); - -/*! - \headerfile <QtCborCommon> - - \brief The <QtCborCommon> header contains definitions common to both the - streaming classes (QCborStreamReader and QCborStreamWriter) and to - QCborValue. - */ - -/*! - \enum QCborSimpleType - \relates <QtCborCommon> - - This enum contains the possible "Simple Types" for CBOR. Simple Types range - from 0 to 255 and are types that carry no further value. - - The following values are currently known: - - \value False A "false" boolean. - \value True A "true" boolean. - \value Null Absence of value (null). - \value Undefined Missing or deleted value, usually an error. - - Qt CBOR API supports encoding and decoding any Simple Type, whether one of - those above or any other value. - - Applications should only use further values if a corresponding specification - has been published, otherwise interpretation and validation by the remote - may fail. Values 24 to 31 are reserved and must not be used. - - The current authoritative list is maintained by IANA in the - \l{https://www.iana.org/assignments/cbor-simple-values/cbor-simple-values.xml}{Simple - Values registry}. - - \sa QCborStreamWriter::append(QCborSimpleType), QCborStreamReader::isSimpleType(), - QCborStreamReader::toSimpleType(), QCborValue::isSimpleType(), QCborValue::toSimpleType() - */ - -#if !defined(QT_NO_DATASTREAM) -QDataStream &operator<<(QDataStream &ds, QCborSimpleType st) -{ - return ds << quint8(st); -} - -QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st) -{ - quint8 v; - ds >> v; - st = QCborSimpleType(v); - return ds; -} -#endif - -/*! - \enum QCborTag - \relates <QtCborCommon> - - This enum contains no enumeration and is used only to provide type-safe - access to a CBOR tag. - - CBOR tags are 64-bit numbers that are attached to generic CBOR types to - provide further semantic meaning. QCborTag may be constructed from an - enumeration found in QCborKnownTags or directly by providing the numeric - representation. - - For example, the following creates a QCborValue containing a byte array - tagged with a tag 2. - - \snippet code/src_corelib_serialization_qcborstream.cpp 0 - - \sa QCborKnownTags, QCborStreamWriter::append(QCborTag), - QCborStreamReader::isTag(), QCborStreamReader::toTag(), - QCborValue::isTag(), QCborValue::tag() - */ - -/*! - \enum QCborKnownTags - \relates <QtCborCommon> - - This enum contains a list of CBOR tags, known at the time of the Qt - implementation. This list is not meant to be complete and contains only - tags that are either backed by an RFC or specifically used by the Qt - implementation. - - The authoritative list is maintained by IANA in the - \l{https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml}{CBOR tag - registry}. - - \value DateTimeString A date and time string, formatted according to RFC 3339, as refined - by RFC 4287. It is the same format as Qt::ISODate and - Qt::ISODateWithMs. - \value UnixTime_t A numerical representation of seconds elapsed since - 1970-01-01T00:00Z. - \value PositiveBignum A positive number of arbitrary length, encoded as a byte array in - network byte order. For example, the number 2\sup{64} is represented by - a byte array containing the byte value 0x01 followed by 8 zero bytes. - \value NegativeBignum A negative number of arbirary length, encoded as the absolute value - of that number, minus one. For example, a byte array containing - byte value 0x02 followed by 8 zero bytes represents the number - -2\sup{65} - 1. - \value Decimal A decimal fraction, encoded as an array of two integers: the first - is the exponent of the power of 10, the second the integral - mantissa. The value 273.15 would be encoded as array \c{[-2, 27315]}. - \value Bigfloat Similar to Decimal, but the exponent is a power of 2 instead. - \value COSE_Encrypt0 An \c Encrypt0 map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} - (CBOR Object Signing and Encryption). - \value COSE_Mac0 A \c Mac0 map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} - (CBOR Object Signing and Encryption). - \value COSE_Sign1 A \c Sign1 map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} - (CBOR Object Signing and Encryption). - \value ExpectedBase64url Indicates that the byte array should be encoded using Base64url - if the stream is converted to JSON. - \value ExpectedBase64 Indicates that the byte array should be encoded using Base64 - if the stream is converted to JSON. - \value ExpectedBase16 Indicates that the byte array should be encoded using Base16 (hex) - if the stream is converted to JSON. - \value EncodedCbor Indicates that the byte array contains a CBOR stream. - \value Url Indicates that the string contains a URL. - \value Base64url Indicates that the string contains data encoded using Base64url. - \value Base64 Indicates that the string contains data encoded using Base64. - \value RegularExpression Indicates that the string contains a Perl-Compatible Regular - Expression pattern. - \value MimeMessage Indicates that the string contains a MIME message (according to - \l{https://tools.ietf.org/html/rfc2045}){RFC 2045}. - \value Uuid Indicates that the byte array contains a UUID. - \value COSE_Encrypt An \c Encrypt map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} - (CBOR Object Signing and Encryption). - \value COSE_Mac A \c Mac map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} - (CBOR Object Signing and Encryption). - \value COSE_Sign A \c Sign map as specified by \l{https://tools.ietf.org/html/rfc8152}{RFC 8152} - (CBOR Object Signing and Encryption). - \value Signature No change in interpretation; this tag can be used as the outermost - tag in a CBOR stream as the file header. - - The following tags are interpreted by QCborValue during decoding and will - produce objects with extended Qt types, and it will use those tags when - encoding the same extended types. - - \value DateTimeString \l QDateTime - \value UnixTime_t \l QDateTime (only in decoding) - \value Url \l QUrl - \value Uuid \l QUuid - - Additionally, if a QCborValue containing a QByteArray is tagged using one of - \c ExpectedBase64url, \c ExpectedBase64 or \c ExpectedBase16, QCborValue - will use the expected encoding when converting to JSON (see - QCborValue::toJsonValue). - - \sa QCborTag, QCborStreamWriter::append(QCborTag), - QCborStreamReader::isTag(), QCborStreamReader::toTag(), - QCborValue::isTag(), QCborValue::tag() - */ - -/*! - \class QCborError - \inmodule QtCore - \relates <QtCborCommon> - \reentrant - \since 5.12 - - \brief The QCborError class holds the error condition found while parsing or - validating a CBOR stream. - - \sa QCborStreamReader, QCborValue, QCborParserError - */ - -/*! - \enum QCborError::Code - - This enum contains the possible error condition codes. - - \value NoError No error was detected. - \value UnknownError An unknown error occurred and no further details are available. - \value AdvancePastEnd QCborStreamReader::next() was called but there are no more elements in - the current context. - \value InputOutputError An I/O error with the QIODevice occurred. - \value GarbageAtEnd Data was found in the input stream after the last element. - \value EndOfFile The end of the input stream was unexpectedly reached while processing an - element. - \value UnexpectedBreak The CBOR stream contains a Break where it is not allowed (data is - corrupt and the error is not recoverable). - \value UnknownType The CBOR stream contains an unknown/unparseable Type (data is corrupt - and the and the error is not recoverable). - \value IllegalType The CBOR stream contains a known type in a position it is not allowed - to exist (data is corrupt and the error is not recoverable). - \value IllegalNumber The CBOR stream appears to be encoding a number larger than 64-bit - (data is corrupt and the error is not recoverable). - \value IllegalSimpleType The CBOR stream contains a Simple Type encoded incorrectly (data is - corrupt and the error is not recoverable). - \value InvalidUtf8String The CBOR stream contains a text string that does not decode properly - as UTF-8 (data is corrupt and the error is not recoverable). - \value DataTooLarge CBOR string, map or array is too big and cannot be parsed by Qt - (internal limitation, but the error is not recoverable). - \value NestingTooDeep Too many levels of arrays or maps encountered while processing the - input (internal limitation, but the error is not recoverable). - \value UnsupportedType The CBOR stream contains a known type that the implementation does not - support (internal limitation, but the error is not recoverable). - */ - -// Convert from CborError to QCborError. -// -// Centralized in a function in case we need to make more adjustments in the -// future. -static QCborError fromCborError(CborError err) -{ - return { QCborError::Code(int(err)) }; -} - -// Convert to CborError from QCborError. -// -// Centralized in a function in case we need to make more adjustments in the -// future. -static CborError toCborError(QCborError c) -{ - return CborError(int(c.c)); -} - -/*! - \variable QCborError::c - \internal - */ - -/*! - \fn QCborError::operator Code() const - - Returns the error code that this QCborError object stores. - */ - -/*! - Returns a text string that matches the error code in this QCborError object. - - Note: the string is not translated. Applications whose interface allow users - to parse CBOR streams need to provide their own, translated strings. - - \sa QCborError::Code - */ -QString QCborError::toString() const -{ - switch (c) { - case NoError: - Q_STATIC_ASSERT(int(NoError) == int(CborNoError)); - return QString(); - - case UnknownError: - Q_STATIC_ASSERT(int(UnknownError) == int(CborUnknownError)); - return QStringLiteral("Unknown error"); - case AdvancePastEnd: - Q_STATIC_ASSERT(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF)); - return QStringLiteral("Read past end of buffer (more bytes needed)"); - case InputOutputError: - Q_STATIC_ASSERT(int(InputOutputError) == int(CborErrorIO)); - return QStringLiteral("Input/Output error"); - case GarbageAtEnd: - Q_STATIC_ASSERT(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd)); - return QStringLiteral("Data found after the end of the stream"); - case EndOfFile: - Q_STATIC_ASSERT(int(EndOfFile) == int(CborErrorUnexpectedEOF)); - return QStringLiteral("Unexpected end of input data (more bytes needed)"); - case UnexpectedBreak: - Q_STATIC_ASSERT(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak)); - return QStringLiteral("Invalid CBOR stream: unexpected 'break' byte"); - case UnknownType: - Q_STATIC_ASSERT(int(UnknownType) == int(CborErrorUnknownType)); - return QStringLiteral("Invalid CBOR stream: unknown type"); - case IllegalType: - Q_STATIC_ASSERT(int(IllegalType) == int(CborErrorIllegalType)); - return QStringLiteral("Invalid CBOR stream: illegal type found"); - case IllegalNumber: - Q_STATIC_ASSERT(int(IllegalNumber) == int(CborErrorIllegalNumber)); - return QStringLiteral("Invalid CBOR stream: illegal number encoding (future extension)"); - case IllegalSimpleType: - Q_STATIC_ASSERT(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType)); - return QStringLiteral("Invalid CBOR stream: illegal simple type"); - case InvalidUtf8String: - Q_STATIC_ASSERT(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString)); - return QStringLiteral("Invalid CBOR stream: invalid UTF-8 text string"); - case DataTooLarge: - Q_STATIC_ASSERT(int(DataTooLarge) == int(CborErrorDataTooLarge)); - return QStringLiteral("Internal limitation: data set too large"); - case NestingTooDeep: - Q_STATIC_ASSERT(int(NestingTooDeep) == int(CborErrorNestingTooDeep)); - return QStringLiteral("Internal limitation: data nesting too deep"); - case UnsupportedType: - Q_STATIC_ASSERT(int(UnsupportedType) == int(CborErrorUnsupportedType)); - return QStringLiteral("Internal limitation: unsupported type"); - } - - // get the error string from TinyCBOR - CborError err = toCborError(*this); - return QString::fromLatin1(cbor_error_string(err)); -} - -/*! - \class QCborStreamWriter - \inmodule QtCore - \ingroup cbor - \reentrant - \since 5.12 - - \brief The QCborStreamWriter class is a simple CBOR encoder operating on a - one-way stream. - - This class can be used to quickly encode a stream of CBOR content directly - to either a QByteArray or QIODevice. CBOR is the Concise Binary Object - Representation, a very compact form of binary data encoding that is - compatible with JSON. It was created by the IETF Constrained RESTful - Environments (CoRE) WG, which has used it in many new RFCs. It is meant to - be used alongside the \l{https://tools.ietf.org/html/rfc7252}{CoAP - protocol}. - - QCborStreamWriter provides a StAX-like API, similar to that of - \l{QXmlStreamWriter}. It is rather low-level and requires a bit of knowledge - of CBOR encoding. For a simpler API, see \l{QCborValue} and especially the - encoding function QCborValue::toCbor(). - - The typical use of QCborStreamWriter is to create the object on the target - QByteArray or QIODevice, then call one of the append() overloads with the - desired type to be encoded. To create arrays and maps, QCborStreamWriter - provides startArray() and startMap() overloads, which must be terminated by - the corresponding endArray() and endMap() functions. - - The following example encodes the equivalent of this JSON content: - - \div{class="pre"} - { - "label": "journald", - "autoDetect": false, - "condition": "libs.journald", - "output": [ "privateFeature" ] - } - \enddiv - - \snippet code/src_corelib_serialization_qcborstream.cpp 1 - - \section1 CBOR support - - QCborStreamWriter supports all CBOR features required to create canonical - and strict streams. It implements almost all of the features specified in - \l {https://tools.ietf.org/html/rfc7049}{RFC 7049}. - - The following table lists the CBOR features that QCborStreamWriter supports. - - \table - \header \li Feature \li Support - \row \li Unsigned numbers \li Yes (full range) - \row \li Negative numbers \li Yes (full range) - \row \li Byte strings \li Yes - \row \li Text strings \li Yes - \row \li Chunked strings \li No - \row \li Tags \li Yes (arbitrary) - \row \li Booleans \li Yes - \row \li Null \li Yes - \row \li Undefined \li Yes - \row \li Arbitrary simple values \li Yes - \row \li Half-precision float (16-bit) \li Yes - \row \li Single-precision float (32-bit) \li Yes - \row \li Double-precision float (64-bit) \li Yes - \row \li Infinities and NaN floating point \li Yes - \row \li Determinate-length arrays and maps \li Yes - \row \li Indeterminate-length arrays and maps \li Yes - \row \li Map key types other than strings and integers \li Yes (arbitrary) - \endtable - - \section2 Canonical CBOR encoding - - Canonical CBOR encoding is defined by - \l{https://tools.ietf.org/html/rfc7049#section-3.9}{Section 3.9 of RFC - 7049}. Canonical encoding is not a requirement for Qt's CBOR decoding - functionality, but it may be required for some protocols. In particular, - protocols that require the ability to reproduce the same stream identically - may require this. - - In order to be considered "canonical", a CBOR stream must meet the - following requirements: - - \list - \li Integers must be as small as possible. QCborStreamWriter always - does this (no user action is required and it is not possible - to write overlong integers). - \li Array, map and string lengths must be as short as possible. As - above, QCborStreamWriter automatically does this. - \li Arrays, maps and strings must use explicit length. QCborStreamWriter - always does this for strings; for arrays and maps, be sure to call - startArray() and startMap() overloads with explicit length. - \li Keys in every map must be sorted in ascending order. QCborStreamWriter - offers no help in this item: the developer must ensure that before - calling append() for the map pairs. - \li Floating point values should be as small as possible. QCborStreamWriter - will not convert floating point values; it is up to the developer - to perform this check prior to calling append() (see those functions' - examples). - \endlist - - \section2 Strict CBOR mode - - Strict mode is defined by - \l{https://tools.ietf.org/html/rfc7049#section-3.10}{Section 3.10 of RFC - 7049}. As for Canonical encoding above, QCborStreamWriter makes it possible - to create strict CBOR streams, but does not require them or validate that - the output is so. - - \list - \li Keys in a map must be unique. QCborStreamWriter performs no validation - of map keys. - \li Tags may be required to be paired only with the correct types, - according to their specification. QCborStreamWriter performs no - validation of tag usage. - \li Text Strings must be properly-encoded UTF-8. QCborStreamWriter always - writes proper UTF-8 for strings added with append(), but performs no - validation for strings added with appendTextString(). - \endlist - - \section2 Invalid CBOR stream - - It is also possible to misuse QCborStreamWriter and produce invalid CBOR - streams that will fail to be decoded by a receiver. The following actions - will produce invalid streams: - - \list - \li Append a tag and not append the corresponding tagged value - (QCborStreamWriter produces no diagnostic). - \li Append too many or too few items to an array or map with explicit - length (endMap() and endArray() will return false and - QCborStreamWriter will log with qWarning()). - \endlist - - \sa QCborStreamReader, QCborValue, QXmlStreamWriter - */ - -class QCborStreamWriterPrivate -{ -public: - static Q_CONSTEXPR quint64 IndefiniteLength = (std::numeric_limits<quint64>::max)(); - - QIODevice *device; - CborEncoder encoder; - QStack<CborEncoder> containerStack; - bool deleteDevice = false; - - QCborStreamWriterPrivate(QIODevice *device) - : device(device) - { - cbor_encoder_init_writer(&encoder, qt_cbor_encoder_write_callback, this); - } - - ~QCborStreamWriterPrivate() - { - if (deleteDevice) - delete device; - } - - template <typename... Args> void executeAppend(CborError (*f)(CborEncoder *, Args...), Args... args) - { - f(&encoder, std::forward<Args>(args)...); - } - - void createContainer(CborError (*f)(CborEncoder *, CborEncoder *, size_t), quint64 len = IndefiniteLength) - { - Q_STATIC_ASSERT(size_t(IndefiniteLength) == CborIndefiniteLength); - if (sizeof(len) != sizeof(size_t) && len != IndefiniteLength) { - if (Q_UNLIKELY(len >= CborIndefiniteLength)) { - // TinyCBOR can't do this in 32-bit mode - qWarning("QCborStreamWriter: container of size %llu is too big for a 32-bit build; " - "will use indeterminate length instead", len); - len = CborIndefiniteLength; - } - } - - containerStack.push(encoder); - f(&containerStack.top(), &encoder, len); - } - - bool closeContainer() - { - if (containerStack.isEmpty()) { - qWarning("QCborStreamWriter: closing map or array that wasn't open"); - return false; - } - - CborEncoder container = containerStack.pop(); - CborError err = cbor_encoder_close_container(&container, &encoder); - encoder = container; - - if (Q_UNLIKELY(err)) { - if (err == CborErrorTooFewItems) - qWarning("QCborStreamWriter: not enough items added to array or map"); - else if (err == CborErrorTooManyItems) - qWarning("QCborStreamWriter: too many items added to array or map"); - return false; - } - - return true; - } -}; - -static CborError qt_cbor_encoder_write_callback(void *self, const void *data, size_t len, CborEncoderAppendType) -{ - auto that = static_cast<QCborStreamWriterPrivate *>(self); - if (!that->device) - return CborNoError; - qint64 written = that->device->write(static_cast<const char *>(data), len); - return (written == qsizetype(len) ? CborNoError : CborErrorIO); -} - -/*! - Creates a QCborStreamWriter object that will write the stream to \a device. - The device must be opened before the first append() call is made. This - constructor can be used with any class that derives from QIODevice, such as - QFile, QProcess or QTcpSocket. - - QCborStreamWriter has no buffering, so every append() call will result in - one or more calls to the device's \l {QIODevice::}{write()} method. - - The following example writes an empty map to a file: - - \snippet code/src_corelib_serialization_qcborstream.cpp 2 - - QCborStreamWriter does not take ownership of \a device. - - \sa device(), setDevice() - */ -QCborStreamWriter::QCborStreamWriter(QIODevice *device) - : d(new QCborStreamWriterPrivate(device)) -{ -} - -/*! - Creates a QCborStreamWriter object that will append the stream to \a data. - All streaming is done immediately to the byte array, without the need for - flushing any buffers. - - The following example writes a number to a byte array then returns - it. - - \snippet code/src_corelib_serialization_qcborstream.cpp 3 - - QCborStreamWriter does not take ownership of \a data. - */ -QCborStreamWriter::QCborStreamWriter(QByteArray *data) - : d(new QCborStreamWriterPrivate(new QBuffer(data))) -{ - d->deleteDevice = true; - d->device->open(QIODevice::WriteOnly | QIODevice::Unbuffered); -} - -/*! - Destroys this QCborStreamWriter object and frees any resources associated. - - QCborStreamWriter does not perform error checking to see if all required - items were written to the stream prior to the object being destroyed. It is - the programmer's responsibility to ensure that it was done. - */ -QCborStreamWriter::~QCborStreamWriter() -{ -} - -/*! - Replaces the device or byte array that this QCborStreamWriter object is - writing to with \a device. - - \sa device() - */ -void QCborStreamWriter::setDevice(QIODevice *device) -{ - if (d->deleteDevice) - delete d->device; - d->device = device; - d->deleteDevice = false; -} - -/*! - Returns the QIODevice that this QCborStreamWriter object is writing to. The - device must have previously been set with either the constructor or with - setDevice(). - - If this object was created by writing to a QByteArray, this function will - return an internal instance of QBuffer, which is owned by QCborStreamWriter. - - \sa setDevice() - */ -QIODevice *QCborStreamWriter::device() const -{ - return d->device; -} - -/*! - \overload - - Appends the 64-bit unsigned value \a u to the CBOR stream, creating a CBOR - Unsigned Integer value. In the following example, we write the values 0, - 2\sup{32} and \c UINT64_MAX: - - \snippet code/src_corelib_serialization_qcborstream.cpp 4 - - \sa QCborStreamReader::isUnsignedInteger(), QCborStreamReader::toUnsignedInteger() - */ -void QCborStreamWriter::append(quint64 u) -{ - d->executeAppend(cbor_encode_uint, uint64_t(u)); -} - -/*! - \overload - - Appends the 64-bit signed value \a i to the CBOR stream. This will create - either a CBOR Unsigned Integer or CBOR NegativeInteger value based on the - sign of the parameter. In the following example, we write the values 0, -1, - 2\sup{32} and \c INT64_MAX: - - \snippet code/src_corelib_serialization_qcborstream.cpp 5 - - \sa QCborStreamReader::isInteger(), QCborStreamReader::toInteger() - */ -void QCborStreamWriter::append(qint64 i) -{ - d->executeAppend(cbor_encode_int, int64_t(i)); -} - -/*! - \overload - - Appends the 64-bit negative value \a n to the CBOR stream. - QCborNegativeInteger is a 64-bit enum that holds the absolute value of the - negative number we want to write. If n is zero, the value written will be - equivalent to 2\sup{64} (that is, -18,446,744,073,709,551,616). - - In the following example, we write the values -1, -2\sup{32} and INT64_MIN: - \snippet code/src_corelib_serialization_qcborstream.cpp 6 - - Note how this function can be used to encode numbers that cannot fit a - standard computer's 64-bit signed integer like \l qint64. That is, if \a n - is larger than \c{std::numeric_limits<qint64>::max()} or is 0, this will - represent a negative number smaller than - \c{std::numeric_limits<qint64>::min()}. - - \sa QCborStreamReader::isNegativeInteger(), QCborStreamReader::toNegativeInteger() - */ -void QCborStreamWriter::append(QCborNegativeInteger n) -{ - d->executeAppend(cbor_encode_negative_int, uint64_t(n)); -} - -/*! - \fn void QCborStreamWriter::append(const QByteArray &ba) - \overload - - Appends the byte array \a ba to the stream, creating a CBOR Byte String - value. QCborStreamWriter will attempt to write the entire string in one - chunk. - - The following example will load and append the contents of a file to the - stream: - - \snippet code/src_corelib_serialization_qcborstream.cpp 7 - - As the example shows, unlike JSON, CBOR requires no escaping for binary - content. - - \sa appendByteString(), QCborStreamReader::isByteArray(), - QCborStreamReader::readByteArray() - */ - -/*! - \overload - - Appends the text string \a str to the stream, creating a CBOR Text String - value. QCborStreamWriter will attempt to write the entire string in one - chunk. - - The following example appends a simple string to the stream: - - \snippet code/src_corelib_serialization_qcborstream.cpp 8 - - \b{Performance note}: CBOR requires that all Text Strings be encoded in - UTF-8, so this function will iterate over the characters in the string to - determine whether the contents are US-ASCII or not. If the string is found - to contain characters outside of US-ASCII, it will allocate memory and - convert to UTF-8. If this check is unnecessary, use appendTextString() - instead. - - \sa QCborStreamReader::isString(), QCborStreamReader::readString() - */ -void QCborStreamWriter::append(QLatin1String str) -{ - // We've got Latin-1 but CBOR wants UTF-8, so check if the string is the - // common subset (US-ASCII). - if (QtPrivate::isAscii(str)) { - // it is plain US-ASCII - appendTextString(str.latin1(), str.size()); - } else { - // non-ASCII, so we need a pass-through UTF-16 - append(QString(str)); - } -} - -/*! - \overload - - Appends the text string \a str to the stream, creating a CBOR Text String - value. QCborStreamWriter will attempt to write the entire string in one - chunk. - - The following example writes an arbitrary QString to the stream: - - \snippet code/src_corelib_serialization_qcborstream.cpp 9 - - \sa QCborStreamReader::isString(), QCborStreamReader::readString() - */ -void QCborStreamWriter::append(QStringView str) -{ - QByteArray utf8 = str.toUtf8(); - appendTextString(utf8.constData(), utf8.size()); -} - -/*! - \overload - - Appends the CBOR tag \a tag to the stream, creating a CBOR Tag value. All - tags must be followed by another type which they provide meaning for. - - In the following example, we append a CBOR Tag 36 (Regular Expression) and a - QRegularExpression's pattern to the stream: - - \snippet code/src_corelib_serialization_qcborstream.cpp 10 - - \sa QCborStreamReader::isTag(), QCborStreamReader::toTag() - */ -void QCborStreamWriter::append(QCborTag tag) -{ - d->executeAppend(cbor_encode_tag, CborTag(tag)); -} - -/*! - \fn void QCborStreamWriter::append(QCborKnownTags tag) - \overload - - Appends the CBOR tag \a tag to the stream, creating a CBOR Tag value. All - tags must be followed by another type which they provide meaning for. - - In the following example, we append a CBOR Tag 1 (Unix \c time_t) and an - integer representing the current time to the stream, obtained using the \c - time() function: - - \snippet code/src_corelib_serialization_qcborstream.cpp 11 - - \sa QCborStreamReader::isTag(), QCborStreamReader::toTag() - */ - -/*! - \overload - - Appends the CBOR simple type \a st to the stream, creating a CBOR Simple - Type value. In the following example, we write the simple type for Null as - well as for type 32, which Qt has no support for. - - \snippet code/src_corelib_serialization_qcborstream.cpp 12 - - \note Using Simple Types for which there is no specification can lead to - validation errors by the remote receiver. In addition, simple type values 24 - through 31 (inclusive) are reserved and must not be used. - - \sa QCborStreamReader::isSimpleType(), QCborStreamReader::toSimpleType() - */ -void QCborStreamWriter::append(QCborSimpleType st) -{ - d->executeAppend(cbor_encode_simple_value, uint8_t(st)); -} - -/*! - \overload - - Appends the floating point number \a f to the stream, creating a CBOR 16-bit - Half-Precision Floating Point value. The following code can be used to convert - a C++ \tt float to \c qfloat16 if there's no loss of precision and append it, or - instead append the \tt float. - - \snippet code/src_corelib_serialization_qcborstream.cpp 13 - - \sa QCborStreamReader::isFloat16(), QCborStreamReader::toFloat16() - */ -void QCborStreamWriter::append(qfloat16 f) -{ - d->executeAppend(cbor_encode_half_float, static_cast<const void *>(&f)); -} - -/*! - \overload - - Appends the floating point number \a f to the stream, creating a CBOR 32-bit - Single-Precision Floating Point value. The following code can be used to convert - a C++ \tt double to \tt float if there's no loss of precision and append it, or - instead append the \tt double. - - \snippet code/src_corelib_serialization_qcborstream.cpp 14 - - \sa QCborStreamReader::isFloat(), QCborStreamReader::toFloat() - */ -void QCborStreamWriter::append(float f) -{ - d->executeAppend(cbor_encode_float, f); -} - -/*! - \overload - - Appends the floating point number \a d to the stream, creating a CBOR 64-bit - Double-Precision Floating Point value. QCborStreamWriter always appends the - number as-is, performing no check for whether the number is the canonical - form for NaN, an infinite, whether it is denormal or if it could be written - with a shorter format. - - The following code performs all those checks, except for the denormal one, - which is expected to be taken into account by the system FPU or floating - point emulation directly. - - \snippet code/src_corelib_serialization_qcborstream.cpp 15 - - Determining if a double can be converted to an integral with no loss of - precision is left as an exercise to the reader. - - \sa QCborStreamReader::isDouble(), QCborStreamReader::toDouble() - */ -void QCborStreamWriter::append(double d) -{ - this->d->executeAppend(cbor_encode_double, d); -} - -/*! - Appends \a len bytes of data starting from \a data to the stream, creating a - CBOR Byte String value. QCborStreamWriter will attempt to write the entire - string in one chunk. - - Unlike the QByteArray overload of append(), this function is not limited by - QByteArray's size limits. However, note that neither - QCborStreamReader::readByteArray() nor QCborValue support reading CBOR - streams with byte arrays larger than 2 GB. - - \sa append(), appendTextString(), - QCborStreamReader::isByteArray(), QCborStreamReader::readByteArray() - */ -void QCborStreamWriter::appendByteString(const char *data, qsizetype len) -{ - d->executeAppend(cbor_encode_byte_string, reinterpret_cast<const uint8_t *>(data), size_t(len)); -} - -/*! - Appends \a len bytes of text starting from \a utf8 to the stream, creating a - CBOR Text String value. QCborStreamWriter will attempt to write the entire - string in one chunk. - - The string pointed to by \a utf8 is expected to be properly encoded UTF-8. - QCborStreamWriter performs no validation that this is the case. - - Unlike the QLatin1String overload of append(), this function is not limited - to 2 GB. However, note that neither QCborStreamReader::readString() nor - QCborValue support reading CBOR streams with text strings larger than 2 GB. - - \sa append(QLatin1String), append(QStringView), - QCborStreamReader::isString(), QCborStreamReader::readString() - */ -void QCborStreamWriter::appendTextString(const char *utf8, qsizetype len) -{ - d->executeAppend(cbor_encode_text_string, utf8, size_t(len)); -} - -/*! - \fn void QCborStreamWriter::append(const char *str, qsizetype size) - \overload - - Appends \a size bytes of text starting from \a str to the stream, creating a - CBOR Text String value. QCborStreamWriter will attempt to write the entire - string in one chunk. If \a size is -1, this function will write \c strlen(\a - str) bytes. - - The string pointed to by \a str is expected to be properly encoded UTF-8. - QCborStreamWriter performs no validation that this is the case. - - Unlike the QLatin1String overload of append(), this function is not limited - to 2 GB. However, note that neither QCborStreamReader nor QCborValue support - reading CBOR streams with text strings larger than 2 GB. - - \sa append(QLatin1String), append(QStringView), - QCborStreamReader::isString(), QCborStreamReader::readString() - */ - -/*! - \fn void QCborStreamWriter::append(bool b) - \overload - - Appends the boolean value \a b to the stream, creating either a CBOR False - value or a CBOR True value. This function is equivalent to (and implemented - as): - - \snippet code/src_corelib_serialization_qcborstream.cpp 16 - - \sa appendNull(), appendUndefined(), - QCborStreamReader::isBool(), QCborStreamReader::toBool() - */ - -/*! - \fn void QCborStreamWriter::append(std::nullptr_t) - \overload - - Appends a CBOR Null value to the stream. This function is equivalent to (and - implemented as): The parameter is ignored. - - \snippet code/src_corelib_serialization_qcborstream.cpp 17 - - \sa appendNull(), append(QCborSimpleType), QCborStreamReader::isNull() - */ - -/*! - \fn void QCborStreamWriter::appendNull() - - Appends a CBOR Null value to the stream. This function is equivalent to (and - implemented as): - - \snippet code/src_corelib_serialization_qcborstream.cpp 18 - - \sa append(std::nullptr_t), append(QCborSimpleType), QCborStreamReader::isNull() - */ - -/*! - \fn void QCborStreamWriter::appendUndefined() - - Appends a CBOR Undefined value to the stream. This function is equivalent to (and - implemented as): - - \snippet code/src_corelib_serialization_qcborstream.cpp 19 - - \sa append(QCborSimpleType), QCborStreamReader::isUndefined() - */ - -/*! - Starts a CBOR Array with indeterminate length in the CBOR stream. Each - startArray() call must be paired with one endArray() call and the current - CBOR element extends until the end of the array. - - The array created by this function has no explicit length. Instead, its - length is implied by the elements contained in it. Note, however, that use - of indeterminate-length arrays is not compliant with canonical CBOR encoding. - - The following example appends elements from the linked list of strings - passed as input: - - \snippet code/src_corelib_serialization_qcborstream.cpp 20 - - \sa startArray(quint64), endArray(), startMap(), QCborStreamReader::isArray(), - QCborStreamReader::isLengthKnown() - */ -void QCborStreamWriter::startArray() -{ - d->createContainer(cbor_encoder_create_array); -} - -/*! - \overload - - Starts a CBOR Array with explicit length of \a count items in the CBOR - stream. Each startArray call must be paired with one endArray() call and the - current CBOR element extends until the end of the array. - - The array created by this function has an explicit length and therefore - exactly \a count items must be added to the CBOR stream. Adding fewer or - more items will result in failure during endArray() and the CBOR stream will - be corrupt. However, explicit-length arrays are required by canonical CBOR - encoding. - - The following example appends all strings found in the \l QStringList passed as input: - - \snippet code/src_corelib_serialization_qcborstream.cpp 21 - - \b{Size limitations}: The parameter to this function is quint64, which would - seem to allow up to 2\sup{64}-1 elements in the array. However, both - QCborStreamWriter and QCborStreamReader are currently limited to 2\sup{32}-2 - items on 32-bit systems and 2\sup{64}-2 items on 64-bit ones. Also note that - QCborArray is currently limited to 2\sup{27} elements in any platform. - - \sa startArray(), endArray(), startMap(), QCborStreamReader::isArray(), - QCborStreamReader::isLengthKnown() - */ -void QCborStreamWriter::startArray(quint64 count) -{ - d->createContainer(cbor_encoder_create_array, count); -} - -/*! - Terminates the array started by either overload of startArray() and returns - true if the correct number of elements was added to the array. This function - must be called for every startArray() used. - - A return of false indicates error in the application and an unrecoverable - error in this stream. QCborStreamWriter also writes a warning using - qWarning() if that happens. - - Calling this function when the current container is not an array is also an - error, though QCborStreamWriter cannot currently detect this condition. - - \sa startArray(), startArray(quint64), endMap() - */ -bool QCborStreamWriter::endArray() -{ - return d->closeContainer(); -} - -/*! - Starts a CBOR Map with indeterminate length in the CBOR stream. Each - startMap() call must be paired with one endMap() call and the current CBOR - element extends until the end of the map. - - The map created by this function has no explicit length. Instead, its length - is implied by the elements contained in it. Note, however, that use of - indeterminate-length maps is not compliant with canonical CBOR encoding - (canonical encoding also requires keys to be unique and in sorted order). - - The following example appends elements from the linked list of int and - string pairs passed as input: - - \snippet code/src_corelib_serialization_qcborstream.cpp 22 - - \sa startMap(quint64), endMap(), startArray(), QCborStreamReader::isMap(), - QCborStreamReader::isLengthKnown() - */ -void QCborStreamWriter::startMap() -{ - d->createContainer(cbor_encoder_create_map); -} - -/*! - \overload - - Starts a CBOR Map with explicit length of \a count items in the CBOR - stream. Each startMap call must be paired with one endMap() call and the - current CBOR element extends until the end of the map. - - The map created by this function has an explicit length and therefore - exactly \a count pairs of items must be added to the CBOR stream. Adding - fewer or more items will result in failure during endMap() and the CBOR - stream will be corrupt. However, explicit-length map are required by - canonical CBOR encoding. - - The following example appends all strings found in the \l QMap passed as input: - - \snippet code/src_corelib_serialization_qcborstream.cpp 23 - - \b{Size limitations}: The parameter to this function is quint64, which would - seem to allow up to 2\sup{64}-1 pairs in the map. However, both - QCborStreamWriter and QCborStreamReader are currently limited to 2\sup{31}-1 - items on 32-bit systems and 2\sup{63}-1 items on 64-bit ones. Also note that - QCborMap is currently limited to 2\sup{26} elements in any platform. - - \sa startMap(), endMap(), startArray(), QCborStreamReader::isMap(), - QCborStreamReader::isLengthKnown() - */ -void QCborStreamWriter::startMap(quint64 count) -{ - d->createContainer(cbor_encoder_create_map, count); -} - -/*! - Terminates the map started by either overload of startMap() and returns - true if the correct number of elements was added to the array. This function - must be called for every startMap() used. - - A return of false indicates error in the application and an unrecoverable - error in this stream. QCborStreamWriter also writes a warning using - qWarning() if that happens. - - Calling this function when the current container is not a map is also an - error, though QCborStreamWriter cannot currently detect this condition. - - \sa startMap(), startMap(quint64), endArray() - */ -bool QCborStreamWriter::endMap() -{ - return d->closeContainer(); -} - -/*! - \class QCborStreamReader - \inmodule QtCore - \ingroup cbor - \reentrant - \since 5.12 - - \brief The QCborStreamReader class is a simple CBOR stream decoder, operating - on either a QByteArray or QIODevice. - - This class can be used to decode a stream of CBOR content directly from - either a QByteArray or a QIODevice. CBOR is the Concise Binary Object - Representation, a very compact form of binary data encoding that is - compatible with JSON. It was created by the IETF Constrained RESTful - Environments (CoRE) WG, which has used it in many new RFCs. It is meant to - be used alongside the \l{https://tools.ietf.org/html/rfc7252}{CoAP - protocol}. - - QCborStreamReader provides a StAX-like API, similar to that of - \l{QXmlStreamReader}. Using it requires a bit of knowledge of CBOR encoding. - For a simpler API, see \l{QCborValue} and especially the decoding function - QCborValue::fromCbor(). - - Typically, one creates a QCborStreamReader by passing the source QByteArray - or QIODevice as a parameter to the constructor, then pop elements off the - stream if there were no errors in decoding. There are three kinds of CBOR - types: - - \table - \header \li Kind \li Types \li Behavior - \row \li Fixed-width \li Integers, Tags, Simple types, Floating point - \li Value is pre-parsed by QCborStreamReader, so accessor functions - are \c const. Must call next() to advance. - \row \li Strings \li Byte arrays, Text strings - \li Length (if known) is pre-parsed, but the string itself is not. - The accessor functions are not const and may allocate memory. - Once called, the accessor functions automatically advance to - the next element. - \row \li Containers \li Arrays, Maps - \li Length (if known) is pre-parsed. To access the elements, you - must call enterContainer(), read all elements, then call - leaveContainer(). That function advances to the next element. - \endtable - - So a processor function typically looks like this: - - \snippet code/src_corelib_serialization_qcborstream.cpp 24 - - \section1 CBOR support - - The following table lists the CBOR features that QCborStreamReader supports. - - \table - \header \li Feature \li Support - \row \li Unsigned numbers \li Yes (full range) - \row \li Negative numbers \li Yes (full range) - \row \li Byte strings \li Yes - \row \li Text strings \li Yes - \row \li Chunked strings \li Yes - \row \li Tags \li Yes (arbitrary) - \row \li Booleans \li Yes - \row \li Null \li Yes - \row \li Undefined \li Yes - \row \li Arbitrary simple values \li Yes - \row \li Half-precision float (16-bit) \li Yes - \row \li Single-precision float (32-bit) \li Yes - \row \li Double-precision float (64-bit) \li Yes - \row \li Infinities and NaN floating point \li Yes - \row \li Determinate-length arrays and maps \li Yes - \row \li Indeterminate-length arrays and maps \li Yes - \row \li Map key types other than strings and integers \li Yes (arbitrary) - \endtable - - \section1 Dealing with invalid or incomplete CBOR streams - - QCborStreamReader is capable of detecting corrupt input on its own. The - library it uses has been extensively tested against invalid input of any - kind and is quite able to report errors. If any is detected, - QCborStreamReader will set lastError() to a value besides - QCborError::NoError, indicating which situation was detected. - - Most errors detected by QCborStreamReader during normal item parsing are not - recoverable. The code using QCborStreamReader may opt to handle the data - that was properly decoded or it can opt to discard the entire data. - - The only recoverable error is QCborError::EndOfFile, which indicates that - more data is required in order to complete the parsing. This situation is - useful when data is being read from an asynchronous source, such as a pipe - (QProcess) or a socket (QTcpSocket, QUdpSocket, QNetworkReply, etc.). When - more data arrives, the surrounding code needs to call either addData(), if - parsing from a QByteArray, or reparse(), if it is instead reading directly - a the QIDOevice that now has more data available (see setDevice()). - - \sa QCborStreamWriter, QCborValue, QXmlStreamReader - */ - -/*! - \enum QCborStreamReader::Type - - This enumeration contains all possible CBOR types as decoded by - QCborStreamReader. CBOR has 7 major types, plus a number of simple types - carrying no value, and floating point values. - - \value UnsignedInteger (Major type 0) Ranges from 0 to 2\sup{64} - 1 - (18,446,744,073,709,551,616) - \value NegativeInteger (Major type 1) Ranges from -1 to -2\sup{64} - (-18,446,744,073,709,551,616) - \value ByteArray (Major type 2) Arbitrary binary data. - \value ByteString An alias to ByteArray. - \value String (Major type 3) Unicode text, possibly containing NULs. - \value TextString An alias to String - \value Array (Major type 4) Array of heterogeneous items. - \value Map (Major type 5) Map/dictionary of heterogeneous items. - \value Tag (Major type 6) Numbers giving further semantic value - to generic CBOR items. See \l QCborTag for more information. - \value SimpleType (Major type 7) Types carrying no further value. Includes - booleans (true and false), null, undefined. - \value Float16 IEEE 754 half-precision floating point (\c qfloat16). - \value HalfFloat An alias to Float16. - \value Float IEEE 754 single-precision floating point (\tt float). - \value Double IEEE 754 double-precision floating point (\tt double). - \value Invalid Not a valid type, either due to parsing error or due to - reaching the end of an array or map. - */ - -/*! - \enum QCborStreamReader::StringResultCode - - This enum is returned by readString() and readByteArray() and is used to - indicate what the status of the parsing is. - - \value EndOfString The parsing for the string is complete, with no error. - \value Ok The function returned data; there was no error. - \value Error Parsing failed with an error. - */ - -/*! - \class QCborStreamReader::StringResult - \inmodule QtCore - - This class is returned by readString() and readByteArray(), with either the - contents of the string that was read or an indication that the parsing is - done or found an error. - - The contents of \l data are valid only if \l status is - \l{StringResultCode}{Ok}. Otherwise, it should be null. - */ - -/*! - \variable QCborStreamReader::StringResult::data - - Contains the actual data from the string if \l status is \c Ok. - */ - -/*! - \variable QCborStreamReader::StringResult::status - - Contains the status of the attempt of reading the string from the stream. - */ - -/*! - \fn QCborStreamReader::Type QCborStreamReader::type() const - - Returns the type of the current element. It is one of the valid types or - Invalid. - - \sa isValid(), isUnsignedInteger(), isNegativeInteger(), isInteger(), - isByteArray(), isString(), isArray(), isMap(), isTag(), isSimpleType(), - isBool(), isFalse(), isTrue(), isNull(), isUndefined(), isFloat16(), - isFloat(), isDouble() - */ - -/*! - \fn bool QCborStreamReader::isValid() const - - Returns true if the current element is valid, false otherwise. The current - element may be invalid if there was a decoding error or we've just parsed - the last element in an array or map. - - \note This function is not the opposite of isNull(). Null is a normal CBOR - type that must be handled by the application. - - \sa type(), isInvalid() - */ - -/*! - \fn bool QCborStreamReader::isInvalid() const - - Returns true if the current element is invalid, false otherwise. The current - element may be invalid if there was a decoding error or we've just parsed - the last element in an array or map. - - \note This function is not to be confused with isNull(). Null is a normal - CBOR type that must be handled by the application. - - \sa type(), isValid() - */ - -/*! - \fn bool QCborStreamReader::isUnsignedInteger() const - - Returns true if the type of the current element is an unsigned integer (that - is if type() returns QCborStreamReader::UnsignedInteger). If this function - returns true, you may call toUnsignedInteger() or toInteger() to read that value. - - \sa type(), toUnsignedInteger(), toInteger(), isInteger(), isNegativeInteger() - */ - -/*! - \fn bool QCborStreamReader::isNegativeInteger() const - - Returns true if the type of the current element is a negative integer (that - is if type() returns QCborStreamReader::NegativeInteger). If this function - returns true, you may call toNegativeInteger() or toInteger() to read that value. - - \sa type(), toNegativeInteger(), toInteger(), isInteger(), isUnsignedInteger() - */ - -/*! - \fn bool QCborStreamReader::isInteger() const - - Returns true if the type of the current element is either an unsigned - integer or a negative one (that is, if type() returns - QCborStreamReader::UnsignedInteger or QCborStreamReader::NegativeInteger). - If this function returns true, you may call toInteger() to read that - value. - - \sa type(), toInteger(), toUnsignedInteger(), toNegativeInteger(), - isUnsignedInteger(), isNegativeInteger() - */ - -/*! - \fn bool QCborStreamReader::isByteArray() const - - Returns true if the type of the current element is a byte array (that is, - if type() returns QCborStreamReader::ByteArray). If this function returns - true, you may call readByteArray() to read that data. - - \sa type(), readByteArray(), isString() - */ - -/*! - \fn bool QCborStreamReader::isString() const - - Returns true if the type of the current element is a text string (that is, - if type() returns QCborStreamReader::String). If this function returns - true, you may call readString() to read that data. - - \sa type(), readString(), isByteArray() - */ - -/*! - \fn bool QCborStreamReader::isArray() const - - Returns true if the type of the current element is an array (that is, - if type() returns QCborStreamReader::Array). If this function returns - true, you may call enterContainer() to begin parsing that container. - - When the current element is an array, you may also call isLengthKnown() to - find out if the array's size is explicit in the CBOR stream. If it is, that - size can be obtained by calling length(). - - The following example pre-allocates a QVariantList given the array's size - for more efficient decoding: - - \snippet code/src_corelib_serialization_qcborstream.cpp 25 - - \note The code above does not validate that the length is a sensible value. - If the input stream reports that the length is 1 billion elements, the above - function will try to allocate some 16 GB or more of RAM, which can lead to a - crash. - - \sa type(), isMap(), isLengthKnown(), length(), enterContainer(), leaveContainer() - */ - -/*! - \fn bool QCborStreamReader::isMap() const - - Returns true if the type of the current element is a map (that is, if type() - returns QCborStreamReader::Map). If this function returns true, you may call - enterContainer() to begin parsing that container. - - When the current element is a map, you may also call isLengthKnown() to - find out if the map's size is explicit in the CBOR stream. If it is, that - size can be obtained by calling length(). - - The following example pre-allocates a QVariantMap given the map's size - for more efficient decoding: - - \snippet code/src_corelib_serialization_qcborstream.cpp 26 - - The example above uses a function called \c readElementAsString to read the - map's keys and obtain a string. That is because CBOR maps may contain any - type as keys, not just strings. User code needs to either perform this - conversion, reject non-string keys, or instead use a different container - besides \l QVariantMap and \l QVariantHash. For example, if the map is - expected to contain integer keys, which is recommended as it reduces stream - size and parsing, the correct container would be \c{\l{QMap}<int, QVariant>} - or \c{\l{QHash}<int, QVariant>}. - - \note The code above does not validate that the length is a sensible value. - If the input stream reports that the length is 1 billion elements, the above - function will try to allocate some 24 GB or more of RAM, which can lead to a - crash. - - \sa type(), isArray(), isLengthKnown(), length(), enterContainer(), leaveContainer() - */ - -/*! - \fn bool QCborStreamReader::isTag() const - - Returns true if the type of the current element is a CBOR tag (that is, - if type() returns QCborStreamReader::Tag). If this function returns - true, you may call toTag() to read that data. - - \sa type(), toTag() - */ - -/*! - \fn bool QCborStreamReader::isFloat16() const - - Returns true if the type of the current element is an IEEE 754 - half-precision floating point (that is, if type() returns - QCborStreamReader::Float16). If this function returns true, you may call - toFloat16() to read that data. - - \sa type(), toFloat16(), isFloat(), isDouble() - */ - -/*! - \fn bool QCborStreamReader::isFloat() const - - Returns true if the type of the current element is an IEEE 754 - single-precision floating point (that is, if type() returns - QCborStreamReader::Float). If this function returns true, you may call - toFloat() to read that data. - - \sa type(), toFloat(), isFloat16(), isDouble() - */ - -/*! - \fn bool QCborStreamReader::isDouble() const - - Returns true if the type of the current element is an IEEE 754 - double-precision floating point (that is, if type() returns - QCborStreamReader::Double). If this function returns true, you may call - toDouble() to read that data. - - \sa type(), toDouble(), isFloat16(), isFloat() - */ - -/*! - \fn bool QCborStreamReader::isSimpleType() const - - Returns true if the type of the current element is any CBOR simple type, - including a boolean value (true and false) as well as null and undefined. To - find out which simple type this is, call toSimpleType(). Alternatively, to - test for one specific simple type, call the overload that takes a - QCborSimpleType parameter. - - CBOR simple types are types that do not carry extra value. There are 255 - possibilities, but there are currently only four values that have defined - meaning. Code is not expected to cope with unknown simple types and may - simply discard the stream as invalid if it finds an unknown one. - - \sa QCborSimpleType, type(), isSimpleType(QCborSimpleType), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isSimpleType(QCborSimpleType st) const - - Returns true if the type of the current element is the simple type \a st, - false otherwise. If this function returns true, then toSimpleType() will - return \a st. - - CBOR simple types are types that do not carry extra value. There are 255 - possibilities, but there are currently only four values that have defined - meaning. Code is not expected to cope with unknown simple types and may - simply discard the stream as invalid if it finds an unknown one. - - \sa QCborSimpleType, type(), isSimpleType(), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isFalse() const - - Returns true if the current element is the \c false value, false if it is - anything else. - - \sa type(), isTrue(), isBool(), toBool(), isSimpleType(), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isTrue() const - - Returns true if the current element is the \c true value, false if it is - anything else. - - \sa type(), isFalse(), isBool(), toBool(), isSimpleType(), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isBool() const - - Returns true if the current element is a boolean value (\c true or \c - false), false if it is anything else. If this function returns true, you may - call toBool() to retrieve the value of the boolean. You may also call - toSimpleType() and compare to either QCborSimpleValue::True or - QCborSimpleValue::False. - - \sa type(), isFalse(), isTrue(), toBool(), isSimpleType(), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isNull() const - - Returns true if the current element is the \c null value, false if it is - anything else. Null values may be used to indicate the absence of some - optional data. - - \note This function is not the opposite of isValid(). A Null value is a - valid CBOR value. - - \sa type(), isSimpleType(), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isUndefined() const - - Returns true if the current element is the \c undefined value, false if it - is anything else. Undefined values may be encoded to indicate that some - conversion failed or was not possible when creating the stream. - QCborStreamReader never performs any replacement and this function will only - return true if the stream contains an explicit undefined value. - - \sa type(), isSimpleType(), toSimpleType() - */ - -/*! - \fn bool QCborStreamReader::isContainer() const - - Returns true if the current element is a container (that is, an array or a - map), false if it is anything else. If the current element is a container, - the isLengthKnown() function may be used to find out if the container's size - is explicit in the stream and, if so, length() can be used to get that size. - - More importantly, for a container, the enterContainer() function is - available to begin iterating through the elements contained therein. - - \sa type(), isArray(), isMap(), isLengthKnown(), length(), enterContainer(), - leaveContainer(), containerDepth() - */ - -class QCborStreamReaderPrivate -{ -public: - enum { - // 9 bytes is the maximum size for any integer, floating point or - // length in CBOR. - MaxCborIndividualSize = 9, - IdealIoBufferSize = 256 - }; - - QIODevice *device; - QByteArray buffer; - QStack<CborValue> containerStack; - - CborParser parser; - CborValue currentElement; - QCborError lastError = {}; - - QByteArray::size_type bufferStart; - bool corrupt = false; - - QCborStreamReaderPrivate(const QByteArray &data) - : device(nullptr), buffer(data) - { - initDecoder(); - } - - QCborStreamReaderPrivate(QIODevice *device) - { - setDevice(device); - } - - ~QCborStreamReaderPrivate() - { - } - - void setDevice(QIODevice *dev) - { - buffer.clear(); - device = dev; - initDecoder(); - } - - void initDecoder() - { - containerStack.clear(); - bufferStart = 0; - if (device) { - buffer.clear(); - buffer.reserve(IdealIoBufferSize); // sets the CapacityReserved flag - } - - preread(); - if (CborError err = cbor_parser_init_reader(nullptr, &parser, ¤tElement, this)) - handleError(err); - else - lastError = { QCborError::NoError }; - } - - char *bufferPtr() - { - Q_ASSERT(buffer.isDetached()); - return const_cast<char *>(buffer.constData()) + bufferStart; - } - - void preread() - { - if (device && buffer.size() - bufferStart < MaxCborIndividualSize) { - // load more, but only if there's more to be read - qint64 avail = device->bytesAvailable(); - Q_ASSERT(avail >= buffer.size()); - if (avail == buffer.size()) - return; - - if (bufferStart) - device->skip(bufferStart); // skip what we've already parsed - - if (buffer.size() != IdealIoBufferSize) - buffer.resize(IdealIoBufferSize); - - bufferStart = 0; - qint64 read = device->peek(bufferPtr(), IdealIoBufferSize); - if (read < 0) - buffer.clear(); - else if (read != IdealIoBufferSize) - buffer.truncate(read); - } - } - - void handleError(CborError err) noexcept - { - Q_ASSERT(err); - - // is the error fatal? - if (err != CborErrorUnexpectedEOF) - corrupt = true; - - lastError = fromCborError(err); - } - - void updateBufferAfterString(qsizetype offset, qsizetype size) - { - Q_ASSERT(device); - - bufferStart += offset; - qsizetype newStart = bufferStart + size; - qsizetype remainingInBuffer = buffer.size() - newStart; - - if (remainingInBuffer <= 0) { - // We've read from the QIODevice more than what was in the buffer. - buffer.truncate(0); - } else { - // There's still data buffered, but we need to move it around. - char *ptr = buffer.data(); - memmove(ptr, ptr + newStart, remainingInBuffer); - buffer.truncate(remainingInBuffer); - } - - bufferStart = 0; - } - - bool ensureStringIteration(); -}; - -void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error) -{ - d->handleError(CborError(error.c)); -} - -static inline bool qt_cbor_decoder_can_read(void *token, size_t len) -{ - Q_ASSERT(len <= QCborStreamReaderPrivate::MaxCborIndividualSize); - auto self = static_cast<QCborStreamReaderPrivate *>(token); - - qint64 avail = self->buffer.size() - self->bufferStart; - return len <= quint64(avail); -} - -static void qt_cbor_decoder_advance(void *token, size_t len) -{ - Q_ASSERT(len <= QCborStreamReaderPrivate::MaxCborIndividualSize); - auto self = static_cast<QCborStreamReaderPrivate *>(token); - Q_ASSERT(len <= size_t(self->buffer.size() - self->bufferStart)); - - self->bufferStart += int(len); - self->preread(); -} - -static void *qt_cbor_decoder_read(void *token, void *userptr, size_t offset, size_t len) -{ - Q_ASSERT(len == 1 || len == 2 || len == 4 || len == 8); - Q_ASSERT(offset == 0 || offset == 1); - auto self = static_cast<const QCborStreamReaderPrivate *>(token); - - // we must have pre-read the data - Q_ASSERT(len + offset <= size_t(self->buffer.size() - self->bufferStart)); - return memcpy(userptr, self->buffer.constData() + self->bufferStart + offset, len); -} - -static CborError qt_cbor_decoder_transfer_string(void *token, const void **userptr, size_t offset, size_t len) -{ - auto self = static_cast<QCborStreamReaderPrivate *>(token); - Q_ASSERT(offset <= size_t(self->buffer.size())); - Q_STATIC_ASSERT(sizeof(size_t) >= sizeof(QByteArray::size_type)); - Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); - - // check that we will have enough data from the QIODevice before we advance - // (otherwise, we'd lose the length information) - qsizetype total; - if (len > size_t(std::numeric_limits<QByteArray::size_type>::max()) - || add_overflow<qsizetype>(offset, len, &total)) - return CborErrorDataTooLarge; - - // our string transfer is just saving the offset to the userptr - *userptr = reinterpret_cast<void *>(offset); - - qint64 avail = (self->device ? self->device->bytesAvailable() : self->buffer.size()) - - self->bufferStart; - return total > avail ? CborErrorUnexpectedEOF : CborNoError; -} - -bool QCborStreamReaderPrivate::ensureStringIteration() -{ - if (currentElement.flags & CborIteratorFlag_IteratingStringChunks) - return true; - - CborError err = cbor_value_begin_string_iteration(¤tElement); - if (!err) - return true; - handleError(err); - return false; -} - -/*! - \internal - */ -inline void QCborStreamReader::preparse() -{ - if (lastError() == QCborError::NoError) { - type_ = cbor_value_get_type(&d->currentElement); - - if (type_ == CborInvalidType) { - // We may have reached the end. - if (d->device && d->containerStack.isEmpty()) { - d->buffer.clear(); - if (d->bufferStart) - d->device->skip(d->bufferStart); - d->bufferStart = 0; - } - } else { - d->lastError = {}; - // Undo the type mapping that TinyCBOR does (we have an explicit type - // for negative integer and we don't have separate types for Boolean, - // Null and Undefined). - if (type_ == CborBooleanType || type_ == CborNullType || type_ == CborUndefinedType) { - type_ = CborSimpleType; - value64 = quint8(d->buffer.at(d->bufferStart)) - CborSimpleType; - } else { - // Using internal TinyCBOR API! - value64 = _cbor_value_extract_int64_helper(&d->currentElement); - - if (cbor_value_is_negative_integer(&d->currentElement)) - type_ = quint8(QCborStreamReader::NegativeInteger); - } - } - } else { - type_ = Invalid; - } -} - -/*! - Creates a QCborStreamReader object with no source data. After construction, - QCborStreamReader will report an error parsing. - - You can add more data by calling addData() or by setting a different source - device using setDevice(). - - \sa addData(), isValid() - */ -QCborStreamReader::QCborStreamReader() - : QCborStreamReader(QByteArray()) -{ -} - -/*! - \overload - - Creates a QCborStreamReader object with \a len bytes of data starting at \a - data. The pointer must remain valid until QCborStreamReader is destroyed. - */ -QCborStreamReader::QCborStreamReader(const char *data, qsizetype len) - : QCborStreamReader(QByteArray::fromRawData(data, len)) -{ -} - -/*! - \overload - - Creates a QCborStreamReader object with \a len bytes of data starting at \a - data. The pointer must remain valid until QCborStreamReader is destroyed. - */ -QCborStreamReader::QCborStreamReader(const quint8 *data, qsizetype len) - : QCborStreamReader(QByteArray::fromRawData(reinterpret_cast<const char *>(data), len)) -{ -} - -/*! - \overload - - Creates a QCborStreamReader object that will parse the CBOR stream found in - \a data. - */ -QCborStreamReader::QCborStreamReader(const QByteArray &data) - : d(new QCborStreamReaderPrivate(data)) -{ - preparse(); -} - -/*! - \overload - - Creates a QCborStreamReader object that will parse the CBOR stream found by - reading from \a device. QCborStreamReader does not take ownership of \a - device, so it must remain valid until this oject is destroyed. - */ -QCborStreamReader::QCborStreamReader(QIODevice *device) - : d(new QCborStreamReaderPrivate(device)) -{ - preparse(); -} - -/*! - Destroys this QCborStreamReader object and frees any associated resources. - */ -QCborStreamReader::~QCborStreamReader() -{ -} - -/*! - Sets the source of data to \a device, resetting the decoder to its initial - state. - */ -void QCborStreamReader::setDevice(QIODevice *device) -{ - d->setDevice(device); - preparse(); -} - -/*! - Returns the QIODevice that was set with either setDevice() or the - QCborStreamReader constructor. If this object was reading from a QByteArray, - this function returns nullptr instead. - */ -QIODevice *QCborStreamReader::device() const -{ - return d->device; -} - -/*! - Adds \a data to the CBOR stream and reparses the current element. This - function is useful if the end of the data was previously reached while - processing the stream, but now more data is available. - */ -void QCborStreamReader::addData(const QByteArray &data) -{ - addData(data.constData(), data.size()); -} - -/*! - \fn void QCborStreamReader::addData(const quint8 *data, qsizetype len) - \overload - - Adds \a len bytes of data starting at \a data to the CBOR stream and - reparses the current element. This function is useful if the end of the data - was previously reached while processing the stream, but now more data is - available. - */ - -/*! - \overload - - Adds \a len bytes of data starting at \a data to the CBOR stream and - reparses the current element. This function is useful if the end of the data - was previously reached while processing the stream, but now more data is - available. - */ -void QCborStreamReader::addData(const char *data, qsizetype len) -{ - if (!d->device) { - if (len > 0) - d->buffer.append(data, len); - reparse(); - } else { - qWarning("QCborStreamReader: addData() with device()"); - } -} - -/*! - Reparses the current element. This function must be called when more data - becomes available in the source QIODevice after parsing failed due to - reaching the end of the input data before the end of the CBOR stream. - - When reading from QByteArray(), the addData() function automatically calls - this function. Calling it when the reading had not failed is a no-op. - */ -void QCborStreamReader::reparse() -{ - d->lastError = {}; - d->preread(); - if (CborError err = cbor_value_reparse(&d->currentElement)) - d->handleError(err); - else - preparse(); -} - -/*! - Clears the decoder state and resets the input source data to an empty byte - array. After this function is called, QCborStreamReader will be indicating - an error parsing. - - Call addData() to add more data to be parsed. - - \sa reset(), setDevice() - */ -void QCborStreamReader::clear() -{ - setDevice(nullptr); -} - -/*! - Resets the source back to the beginning and clears the decoder state. If the - source data was a QByteArray, QCborStreamReader will restart from the - beginning of the array. - - If the source data is a QIODevice, this function will call - QIODevice::reset(), which will seek to byte position 0. If the CBOR stream - is not found at the beginning of the device (e.g., beginning of a file), - then this function will likely do the wrong thing. Instead, position the - QIODevice to the right offset and call setDevice(). - - \sa clear(), setDevice() - */ -void QCborStreamReader::reset() -{ - if (d->device) - d->device->reset(); - d->lastError = {}; - d->initDecoder(); - preparse(); -} - -/*! - Returns the last error in decoding the stream, if any. If no error - was encountered, this returns an QCborError::NoError. - - \sa isValid() - */ -QCborError QCborStreamReader::lastError() -{ - return d->lastError; -} - -/*! - Returns the offset in the input stream of the item currently being decoded. - The current offset is the number of decoded bytes so far only if the source - data is a QByteArray or it is a QIODevice that was positioned at its - beginning when decoding started. - - \sa reset(), clear(), device() - */ -qint64 QCborStreamReader::currentOffset() const -{ - return (d->device ? d->device->pos() : 0) + d->bufferStart; -} - -/*! - Returns the number of containers that this stream has entered with - enterContainer() but not yet left. - - \sa enterContainer(), leaveContainer() - */ -int QCborStreamReader::containerDepth() const -{ - return d->containerStack.size(); -} - -/*! - Returns either QCborStreamReader::Array or QCborStreamReader::Map, - indicating whether the container that contains the current item was an array - or map, respectively. If we're currently parsing the root element, this - function returns QCborStreamReader::Invalid. - - \sa containerDepth(), enterContainer() - */ -QCborStreamReader::Type QCborStreamReader::parentContainerType() const -{ - if (d->containerStack.isEmpty()) - return Invalid; - return Type(cbor_value_get_type(&qAsConst(d->containerStack).top())); -} - -/*! - Returns true if there are more items to be decoded in the current container - or false of we've reached its end. If we're parsing the root element, - hasNext() returning false indicates the parsing is complete; otherwise, if - the container depth is non-zero, then the outer code needs to call - leaveContainer(). - - \sa parentContainerType(), containerDepth(), leaveContainer() - */ -bool QCborStreamReader::hasNext() const noexcept -{ - return cbor_value_is_valid(&d->currentElement) && - !cbor_value_at_end(&d->currentElement); -} - -/*! - Advance the CBOR stream decoding one element. You should usually call this - function when parsing fixed-width basic elements (that is, integers, simple - values, tags and floating point values). But this function can be called - when the current item is a string, array or map too and it will skip over - that entire element, including all contained elements. - - This function returns true if advancing was successful, false otherwise. It - may fail if the stream is corrupt, incomplete or if the nesting level of - arrays and maps exceeds \a maxRecursion. Calling this function when - hasNext() has returned false is also an error. If this function returns - false, lastError() will return the error code detailing what the failure - was. - - \sa lastError(), isValid(), hasNext() - */ -bool QCborStreamReader::next(int maxRecursion) -{ - if (lastError() != QCborError::NoError) - return false; - - if (!hasNext()) { - d->handleError(CborErrorAdvancePastEOF); - } else if (maxRecursion < 0) { - d->handleError(CborErrorNestingTooDeep); - } else if (isContainer()) { - // iterate over each element - enterContainer(); - while (lastError() == QCborError::NoError && hasNext()) - next(maxRecursion - 1); - if (lastError() == QCborError::NoError) - leaveContainer(); - } else if (isString() || isByteArray()) { - auto r = _readByteArray_helper(); - while (r.status == Ok) { - if (isString() && !QUtf8::isValidUtf8(r.data, r.data.size()).isValidUtf8) { - d->handleError(CborErrorInvalidUtf8TextString); - break; - } - r = _readByteArray_helper(); - } - } else { - // fixed types - CborError err = cbor_value_advance_fixed(&d->currentElement); - if (err) - d->handleError(err); - } - - preparse(); - return d->lastError == QCborError::NoError; -} - -/*! - Returns true if the length of the current array, map, byte array or string - is known (explicit in the CBOR stream), false otherwise. This function - should only be called if the element is one of those. - - If the length is known, it may be obtained by calling length(). - - If the length of a map or an array is not known, it is implied by the number - of elements present in the stream. QCborStreamReader has no API to calculate - the length in that condition. - - Strings and byte arrays may also have indeterminate length (that is, they - may be transmitted in multiple chunks). Those cannot currently be created - with QCborStreamWriter, but they could be with other encoders, so - QCborStreamReader supports them. - - \sa length(), QCborStreamWriter::startArray(), QCborStreamWriter::startMap() - */ -bool QCborStreamReader::isLengthKnown() const noexcept -{ - return cbor_value_is_length_known(&d->currentElement); -} - -/*! - Returns the length of the string or byte array, or the number of items in an - array or the number, of item pairs in a map, if known. This function must - not be called if the length is unknown (that is, if isLengthKnown() returned - false). It is an error to do that and it will cause QCborStreamReader to - stop parsing the input stream. - - \sa isLengthKnown(), QCborStreamWriter::startArray(), QCborStreamWriter::startMap() - */ -quint64 QCborStreamReader::length() const -{ - CborError err; - switch (type()) { - case String: - case ByteArray: - case Map: - case Array: - if (isLengthKnown()) - return value64; - err = CborErrorUnknownLength; - break; - - default: - err = CborErrorIllegalType; - break; - } - - d->handleError(err); - return quint64(-1); -} - -/*! - \fn bool QCborStreamReader::enterContainer() - - Enters the array or map that is the current item and prepares for iterating - the elements contained in the container. Returns true if entering the - container succeeded, false otherwise (usually, a parsing error). Each call - to enterContainer() must be paired with a call to leaveContainer(). - - This function may only be called if the current item is an array or a map - (that is, if isArray(), isMap() or isContainer() is true). Calling it in any - other condition is an error. - - \sa leaveContainer(), isContainer(), isArray(), isMap() - */ -bool QCborStreamReader::_enterContainer_helper() -{ - d->containerStack.push(d->currentElement); - CborError err = cbor_value_enter_container(&d->containerStack.top(), &d->currentElement); - if (!err) { - preparse(); - return true; - } - d->handleError(err); - return false; -} - -/*! - Leaves the array or map whose items were being processed and positions the - decoder at the next item after the end of the container. Returns true if - leaving the container succeeded, false otherwise (usually, a parsing error). - Each call to enterContainer() must be paired with a call to - leaveContainer(). - - This function may only be called if hasNext() has returned false and - containerDepth() is not zero. Calling it in any other condition is an error. - - \sa enterContainer(), parentContainerType(), containerDepth() - */ -bool QCborStreamReader::leaveContainer() -{ - if (d->containerStack.isEmpty()) { - qWarning("QCborStreamReader::leaveContainer: trying to leave top-level element"); - return false; - } - if (d->corrupt) - return false; - - CborValue container = d->containerStack.pop(); - CborError err = cbor_value_leave_container(&container, &d->currentElement); - d->currentElement = container; - if (err) { - d->handleError(err); - return false; - } - - preparse(); - return true; -} - -/*! - \fn bool QCborStreamReader::toBool() const - - Returns the boolean value of the current element. - - This function does not perform any type conversions, including from integer. - Therefore, it may only be called if isTrue(), isFalse() or isBool() returned - true; calling it in any other condition is an error. - - \sa isBool(), isTrue(), isFalse(), toInteger() - */ - -/*! - \fn QCborTag QCborStreamReader::toTag() const - - Returns the tag value of the current element. - - This function does not perform any type conversions, including from integer. - Therefore, it may only be called if isTag() is true; calling it in any other - condition is an error. - - Tags are 64-bit numbers attached to generic CBOR types that give them - further meaning. For a list of known tags, see the \l QCborKnownTags - enumeration. - - \sa isTag(), toInteger(), QCborKnownTags - */ - -/*! - \fn quint64 QCborStreamReader::toUnsignedInteger() const - - Returns the unsigned integer value of the current element. - - This function does not perform any type conversions, including from boolean - or CBOR tag. Therefore, it may only be called if isUnsignedInteger() is - true; calling it in any other condition is an error. - - This function may be used to obtain numbers beyond the range of the return - type of toInteger(). - - \sa type(), toInteger(), isUnsignedInteger(), isNegativeInteger() - */ - -/*! - \fn QCborNegativeValue QCborStreamReader::toNegativeInteger() const - - Returns the negative integer value of the current element. - QCborNegativeValue is a 64-bit unsigned integer containing the absolute - value of the negative number that was stored in the CBOR stream. - Additionally, QCborNegativeValue(0) represents the number -2\sup{64}. - - This function does not perform any type conversions, including from boolean - or CBOR tag. Therefore, it may only be called if isNegativeInteger() is - true; calling it in any other condition is an error. - - This function may be used to obtain numbers beyond the range of the return - type of toInteger(). However, use of negative numbers smaller than -2\sup{63} - is extremely discouraged. - - \sa type(), toInteger(), isNegativeInteger(), isUnsignedInteger() - */ - -/*! - \fn qint64 QCborStreamReader::toInteger() const - - Returns the integer value of the current element, be it negative, positive - or zero. If the value is larger than 2\sup{63} - 1 or smaller than - -2\sup{63}, the returned value will overflow and will have an incorrect - sign. If handling those values is required, use toUnsignedInteger() or - toNegativeInteger() instead. - - This function does not perform any type conversions, including from boolean - or CBOR tag. Therefore, it may only be called if isInteger() is true; - calling it in any other condition is an error. - - \sa isInteger(), toUnsignedInteger(), toNegativeInteger() - */ - -/*! - \fn QCborSimpleType QCborStreamReader::toSimpleType() const - - Returns value of the current simple type. - - This function does not perform any type conversions, including from integer. - Therefore, it may only be called if isSimpleType() is true; calling it in - any other condition is an error. - - \sa isSimpleType(), isTrue(), isFalse(), isBool(), isNull(), isUndefined() - */ - -/*! - \fn qfloat16 QCborStreamReader::toFloat16() const - - Returns the 16-bit half-precision floating point value of the current element. - - This function does not perform any type conversions, including from other - floating point types or from integer values. Therefore, it may only be - called if isFloat16() is true; calling it in any other condition is an - error. - - \sa isFloat16(), toFloat(), toDouble() - */ - -/*! - \fn float QCborStreamReader::toFloat() const - - Returns the 32-bit single-precision floating point value of the current - element. - - This function does not perform any type conversions, including from other - floating point types or from integer values. Therefore, it may only be - called if isFloat() is true; calling it in any other condition is an error. - - \sa isFloat(), toFloat16(), toDouble() - */ - -/*! - \fn double QCborStreamReader::toDouble() const - - Returns the 64-bit double-precision floating point value of the current - element. - - This function does not perform any type conversions, including from other - floating point types or from integer values. Therefore, it may only be - called if isDouble() is true; calling it in any other condition is an error. - - \sa isDouble(), toFloat16(), toFloat() - */ - -/*! - \fn QCborStreamReader::StringResult<QString> QCborStreamReader::readString() - - Decodes one string chunk from the CBOR string and returns it. This function - is used for both regular and chunked string contents, so the caller must - always loop around calling this function, even if isLengthKnown() has - is true. The typical use of this function is as follows: - - \snippet code/src_corelib_serialization_qcborstream.cpp 27 - - This function does not perform any type conversions, including from integers - or from byte arrays. Therefore, it may only be called if isString() returned - true; calling it in any other condition is an error. - - \sa readByteArray(), isString(), readStringChunk() - */ -QCborStreamReader::StringResult<QString> QCborStreamReader::_readString_helper() -{ - auto r = _readByteArray_helper(); - QCborStreamReader::StringResult<QString> result; - result.status = r.status; - - if (r.status == Ok) { - QTextCodec::ConverterState cs; - result.data = QUtf8::convertToUnicode(r.data, r.data.size(), &cs); - if (cs.invalidChars == 0 && cs.remainingChars == 0) - return result; - - d->handleError(CborErrorInvalidUtf8TextString); - result.data.clear(); - result.status = Error; - return result; - } - return result; -} - -/*! - \fn QCborStreamReader::StringResult<QString> QCborStreamReader::readByteArray() - - Decodes one byte array chunk from the CBOR string and returns it. This - function is used for both regular and chunked contents, so the caller must - always loop around calling this function, even if isLengthKnown() has - is true. The typical use of this function is as follows: - - \snippet code/src_corelib_serialization_qcborstream.cpp 28 - - This function does not perform any type conversions, including from integers - or from strings. Therefore, it may only be called if isByteArray() is true; - calling it in any other condition is an error. - - \sa readString(), isByteArray(), readStringChunk() - */ -QCborStreamReader::StringResult<QByteArray> QCborStreamReader::_readByteArray_helper() -{ - QCborStreamReader::StringResult<QByteArray> result; - result.status = Error; - qsizetype len = _currentStringChunkSize(); - if (len < 0) - return result; - - result.data.resize(len); - auto r = readStringChunk(result.data.data(), len); - Q_ASSERT(r.status != Ok || r.data == len); - result.status = r.status; - return result; -} - -/*! - \fn qsizetype QCborStreamReader::currentStringChunkSize() const - - Returns the size of the current text or byte string chunk. If the CBOR - stream contains a non-chunked string (that is, if isLengthKnown() returns - \c true), this function returns the size of the entire string, the same as - length(). - - This function is useful to pre-allocate the buffer whose pointer can be passed - to readStringChunk() later. - - \sa readString(), readByteArray(), readStringChunk() - */ -qsizetype QCborStreamReader::_currentStringChunkSize() const -{ - if (!d->ensureStringIteration()) - return -1; - - size_t len; - CborError err = cbor_value_get_string_chunk_size(&d->currentElement, &len); - if (err == CborErrorNoMoreStringChunks) - return 0; // not a real error - else if (err) - d->handleError(err); - else if (qsizetype(len) < 0) - d->handleError(CborErrorDataTooLarge); - else - return qsizetype(len); - return -1; -} - -/*! - Reads the current string chunk into the buffer pointed to by \a ptr, whose - size is \a maxlen. This function returns a \l StringResult object, with the - number of bytes copied into \a ptr saved in the \c \l StringResult::data - member. The \c \l StringResult::status member indicates whether there was - an error reading the string, whether data was copied or whether this was - the last chunk. - - This function can be called for both \l String and \l ByteArray types. - For the latter, this function will read the same data that readByteArray() - would have returned. For strings, it returns the UTF-8 equivalent of the \l - QString that would have been returned. - - This function is usually used alongside currentStringChunkSize() in a loop. - For example: - - \snippet code/src_corelib_serialization_qcborstream.cpp 29 - - Unlike readByteArray() and readString(), this function is not limited by - implementation limits of QByteArray and QString. - - \note This function does not perform verification that the UTF-8 contents - are properly formatted. That means this function does not produce the - QCborError::InvalidUtf8String error, even when readString() does. - - \sa currentStringChunkSize(), readString(), readByteArray(), - isString(), isByteArray() - */ -QCborStreamReader::StringResult<qsizetype> -QCborStreamReader::readStringChunk(char *ptr, qsizetype maxlen) -{ - CborError err; - size_t len; - const void *content = nullptr; - QCborStreamReader::StringResult<qsizetype> result; - result.data = 0; - result.status = Error; - - d->lastError = {}; - if (!d->ensureStringIteration()) - return result; - -#if 1 - // Using internal TinyCBOR API! - err = _cbor_value_get_string_chunk(&d->currentElement, &content, &len, &d->currentElement); -#else - // the above is effectively the same as: - if (cbor_value_is_byte_string(¤tElement)) - err = cbor_value_get_byte_string_chunk(&d->currentElement, reinterpret_cast<const uint8_t **>(&content), - &len, &d->currentElement); - else - err = cbor_value_get_text_string_chunk(&d->currentElement, reinterpret_cast<const char **>(&content), - &len, &d->currentElement); -#endif - - // Range check: using implementation-defined behavior in converting an - // unsigned value out of range of the destination signed type (same as - // "len > size_t(std::numeric_limits<qsizetype>::max())", but generates - // better code with ICC and MSVC). - if (!err && qsizetype(len) < 0) - err = CborErrorDataTooLarge; - - if (err) { - if (err == CborErrorNoMoreStringChunks) { - d->preread(); - err = cbor_value_finish_string_iteration(&d->currentElement); - result.status = EndOfString; - } - if (err) - d->handleError(err); - else - preparse(); - return result; - } - - // Read the chunk into the user's buffer. - qint64 actuallyRead; - qptrdiff offset = qptrdiff(content); - qsizetype toRead = qsizetype(len); - qsizetype left = toRead - maxlen; - if (left < 0) - left = 0; // buffer bigger than string - else - toRead = maxlen; // buffer smaller than string - - if (d->device) { - // This first skip can't fail because we've already read this many bytes. - d->device->skip(d->bufferStart + qptrdiff(content)); - actuallyRead = d->device->read(ptr, toRead); - - if (actuallyRead != toRead) { - actuallyRead = -1; - } else if (left) { - qint64 skipped = d->device->skip(left); - if (skipped != left) - actuallyRead = -1; - } - - if (actuallyRead < 0) { - d->handleError(CborErrorIO); - return result; - } - - d->updateBufferAfterString(offset, len); - } else { - actuallyRead = toRead; - memcpy(ptr, d->buffer.constData() + d->bufferStart + offset, toRead); - d->bufferStart += QByteArray::size_type(offset + len); - } - - d->preread(); - result.data = actuallyRead; - result.status = Ok; - return result; -} - -QT_END_NAMESPACE - -#include "moc_qcborcommon.cpp" -#include "moc_qcborstream.cpp" diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h index 08bf680cca..f2b88820cd 100644 --- a/src/corelib/serialization/qcborstream.h +++ b/src/corelib/serialization/qcborstream.h @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -40,230 +41,17 @@ #ifndef QCBORSTREAM_H #define QCBORSTREAM_H -#include <QtCore/qbytearray.h> -#include <QtCore/qcborcommon.h> -#include <QtCore/qfloat16.h> -#include <QtCore/qscopedpointer.h> -#include <QtCore/qstring.h> -#include <QtCore/qstringview.h> +#include <QtCore/qglobal.h> -QT_REQUIRE_CONFIG(cborstream); - -// See qcborcommon.h for why we check -#if defined(QT_X11_DEFINES_FOUND) -# undef True -# undef False +#if QT_CONFIG(cborstreamreader) +#include <QtCore/qcborstreamreader.h> #endif -QT_BEGIN_NAMESPACE - -class QIODevice; - -enum class QCborNegativeInteger : quint64 {}; - -class QCborStreamWriterPrivate; -class Q_CORE_EXPORT QCborStreamWriter -{ -public: - explicit QCborStreamWriter(QIODevice *device); - explicit QCborStreamWriter(QByteArray *data); - ~QCborStreamWriter(); - Q_DISABLE_COPY(QCborStreamWriter) - - void setDevice(QIODevice *device); - QIODevice *device() const; - - void append(quint64 u); - void append(qint64 i); - void append(QCborNegativeInteger n); - void append(const QByteArray &ba) { appendByteString(ba.constData(), ba.size()); } - void append(QLatin1String str); - void append(QStringView str); - void append(QCborTag tag); - void append(QCborKnownTags tag) { append(QCborTag(tag)); } - void append(QCborSimpleType st); - void append(std::nullptr_t) { append(QCborSimpleType::Null); } - void append(qfloat16 f); - void append(float f); - void append(double d); - - void appendByteString(const char *data, qsizetype len); - void appendTextString(const char *utf8, qsizetype len); - - // convenience - void append(bool b) { append(b ? QCborSimpleType::True : QCborSimpleType::False); } - void appendNull() { append(QCborSimpleType::Null); } - void appendUndefined() { append(QCborSimpleType::Undefined); } - -#ifndef Q_QDOC - // overloads to make normal code not complain - void append(int i) { append(qint64(i)); } - void append(uint u) { append(quint64(u)); } -#endif -#ifndef QT_NO_CAST_FROM_ASCII - void append(const char *str, qsizetype size = -1) - { appendTextString(str, (str && size == -1) ? int(strlen(str)) : size); } +#if QT_CONFIG(cborstreamwriter) +#include <QtCore/qcborstreamwriter.h> #endif - void startArray(); - void startArray(quint64 count); - bool endArray(); - void startMap(); - void startMap(quint64 count); - bool endMap(); - - // no API for encoding chunked strings - -private: - QScopedPointer<QCborStreamWriterPrivate> d; -}; - -class QCborStreamReaderPrivate; -class Q_CORE_EXPORT QCborStreamReader -{ - Q_GADGET -public: - enum Type : quint8 { - UnsignedInteger = 0x00, - NegativeInteger = 0x20, - ByteString = 0x40, - ByteArray = ByteString, - TextString = 0x60, - String = TextString, - Array = 0x80, - Map = 0xa0, - Tag = 0xc0, - SimpleType = 0xe0, - HalfFloat = 0xf9, - Float16 = HalfFloat, - Float = 0xfa, - Double = 0xfb, - - Invalid = 0xff - }; - Q_ENUM(Type) - - enum StringResultCode { - EndOfString = 0, - Ok = 1, - Error = -1 - }; - template <typename Container> struct StringResult { - Container data; - StringResultCode status = Error; - }; - Q_ENUM(StringResultCode) - - QCborStreamReader(); - QCborStreamReader(const char *data, qsizetype len); - QCborStreamReader(const quint8 *data, qsizetype len); - explicit QCborStreamReader(const QByteArray &data); - explicit QCborStreamReader(QIODevice *device); - ~QCborStreamReader(); - Q_DISABLE_COPY(QCborStreamReader) - - void setDevice(QIODevice *device); - QIODevice *device() const; - void addData(const QByteArray &data); - void addData(const char *data, qsizetype len); - void addData(const quint8 *data, qsizetype len) - { addData(reinterpret_cast<const char *>(data), len); } - void reparse(); - void clear(); - void reset(); - - QCborError lastError(); - - qint64 currentOffset() const; - - bool isValid() const { return !isInvalid(); } - - int containerDepth() const; - QCborStreamReader::Type parentContainerType() const; - bool hasNext() const noexcept Q_DECL_PURE_FUNCTION; - bool next(int maxRecursion = 10000); - - Type type() const { return QCborStreamReader::Type(type_); } - bool isUnsignedInteger() const { return type() == UnsignedInteger; } - bool isNegativeInteger() const { return type() == NegativeInteger; } - bool isInteger() const { return quint8(type()) <= quint8(NegativeInteger); } - bool isByteArray() const { return type() == ByteArray; } - bool isString() const { return type() == String; } - bool isArray() const { return type() == Array; } - bool isMap() const { return type() == Map; } - bool isTag() const { return type() == Tag; } - bool isSimpleType() const { return type() == SimpleType; } - bool isFloat16() const { return type() == Float16; } - bool isFloat() const { return type() == Float; } - bool isDouble() const { return type() == Double; } - bool isInvalid() const { return type() == Invalid; } - - bool isSimpleType(QCborSimpleType st) const { return isSimpleType() && toSimpleType() == st; } - bool isFalse() const { return isSimpleType(QCborSimpleType::False); } - bool isTrue() const { return isSimpleType(QCborSimpleType::True); } - bool isBool() const { return isFalse() || isTrue(); } - bool isNull() const { return isSimpleType(QCborSimpleType::Null); } - bool isUndefined() const { return isSimpleType(QCborSimpleType::Undefined); } - - bool isLengthKnown() const noexcept Q_DECL_PURE_FUNCTION; - quint64 length() const; - - bool isContainer() const { return isMap() || isArray(); } - bool enterContainer() { Q_ASSERT(isContainer()); return _enterContainer_helper(); } - bool leaveContainer(); - - StringResult<QString> readString() { Q_ASSERT(isString()); return _readString_helper(); } - StringResult<QByteArray> readByteArray(){ Q_ASSERT(isByteArray()); return _readByteArray_helper(); } - qsizetype currentStringChunkSize() const{ Q_ASSERT(isString() || isByteArray()); return _currentStringChunkSize(); } - StringResult<qsizetype> readStringChunk(char *ptr, qsizetype maxlen); - - bool toBool() const { Q_ASSERT(isBool()); return value64 - int(QCborSimpleType::False); } - QCborTag toTag() const { Q_ASSERT(isTag()); return QCborTag(value64); } - quint64 toUnsignedInteger() const { Q_ASSERT(isUnsignedInteger()); return value64; } - QCborNegativeInteger toNegativeInteger() const { Q_ASSERT(isNegativeInteger()); return QCborNegativeInteger(value64 + 1); } - QCborSimpleType toSimpleType() const{ Q_ASSERT(isSimpleType()); return QCborSimpleType(value64); } - qfloat16 toFloat16() const { Q_ASSERT(isFloat16()); return _toFloatingPoint<qfloat16>(); } - float toFloat() const { Q_ASSERT(isFloat()); return _toFloatingPoint<float>(); } - double toDouble() const { Q_ASSERT(isDouble()); return _toFloatingPoint<double>(); } - - qint64 toInteger() const - { - Q_ASSERT(isInteger()); - qint64 v = qint64(value64); - if (isNegativeInteger()) - return -v - 1; - return v; - } - -private: - void preparse(); - bool _enterContainer_helper(); - StringResult<QString> _readString_helper(); - StringResult<QByteArray> _readByteArray_helper(); - qsizetype _currentStringChunkSize() const; - - template <typename FP> FP _toFloatingPoint() const noexcept - { - using UIntFP = typename QIntegerForSizeof<FP>::Unsigned; - UIntFP u = UIntFP(value64); - FP f; - memcpy(static_cast<void *>(&f), &u, sizeof(f)); - return f; - } - - friend QCborStreamReaderPrivate; - friend class QCborContainerPrivate; - quint64 value64; - QScopedPointer<QCborStreamReaderPrivate> d; - quint8 type_; - quint8 reserved[3] = {}; -}; - +QT_BEGIN_NAMESPACE QT_END_NAMESPACE -#if defined(QT_X11_DEFINES_FOUND) -# define True 1 -# define False 0 -#endif - #endif // QCBORSTREAM_H diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp new file mode 100644 index 0000000000..112fc6e226 --- /dev/null +++ b/src/corelib/serialization/qcborstreamreader.cpp @@ -0,0 +1,1533 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcborstreamreader.h" + +#define CBOR_NO_ENCODER_API +#include <private/qcborcommon_p.h> + +#include <private/qnumeric_p.h> +#include <private/qutfcodec_p.h> +#include <qdebug.h> +#include <qstack.h> + +QT_BEGIN_NAMESPACE + +static bool qt_cbor_decoder_can_read(void *token, size_t len); +static void qt_cbor_decoder_advance(void *token, size_t len); +static void *qt_cbor_decoder_read(void *token, void *userptr, size_t offset, size_t len); +static CborError qt_cbor_decoder_transfer_string(void *token, const void **userptr, size_t offset, size_t len); + +#define CBOR_PARSER_READER_CONTROL 1 +#define CBOR_PARSER_CAN_READ_BYTES_FUNCTION qt_cbor_decoder_can_read +#define CBOR_PARSER_ADVANCE_BYTES_FUNCTION qt_cbor_decoder_advance +#define CBOR_PARSER_TRANSFER_STRING_FUNCTION qt_cbor_decoder_transfer_string +#define CBOR_PARSER_READ_BYTES_FUNCTION qt_cbor_decoder_read + +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) + +#include <cborparser.c> + +QT_WARNING_POP + +static CborError _cbor_value_dup_string(const CborValue *, void **, size_t *, CborValue *) +{ + Q_UNREACHABLE(); + return CborErrorInternalError; +} +static CborError cbor_value_get_half_float_as_float(const CborValue *, float *) +{ + Q_UNREACHABLE(); + return CborErrorInternalError; +} + +// confirm our constants match TinyCBOR's +Q_STATIC_ASSERT(int(QCborStreamReader::UnsignedInteger) == CborIntegerType); +Q_STATIC_ASSERT(int(QCborStreamReader::ByteString) == CborByteStringType); +Q_STATIC_ASSERT(int(QCborStreamReader::TextString) == CborTextStringType); +Q_STATIC_ASSERT(int(QCborStreamReader::Array) == CborArrayType); +Q_STATIC_ASSERT(int(QCborStreamReader::Map) == CborMapType); +Q_STATIC_ASSERT(int(QCborStreamReader::Tag) == CborTagType); +Q_STATIC_ASSERT(int(QCborStreamReader::SimpleType) == CborSimpleType); +Q_STATIC_ASSERT(int(QCborStreamReader::HalfFloat) == CborHalfFloatType); +Q_STATIC_ASSERT(int(QCborStreamReader::Float) == CborFloatType); +Q_STATIC_ASSERT(int(QCborStreamReader::Double) == CborDoubleType); +Q_STATIC_ASSERT(int(QCborStreamReader::Invalid) == CborInvalidType); + +/*! + \class QCborStreamReader + \inmodule QtCore + \ingroup cbor + \reentrant + \since 5.12 + + \brief The QCborStreamReader class is a simple CBOR stream decoder, operating + on either a QByteArray or QIODevice. + + This class can be used to decode a stream of CBOR content directly from + either a QByteArray or a QIODevice. CBOR is the Concise Binary Object + Representation, a very compact form of binary data encoding that is + compatible with JSON. It was created by the IETF Constrained RESTful + Environments (CoRE) WG, which has used it in many new RFCs. It is meant to + be used alongside the \l{https://tools.ietf.org/html/rfc7252}{CoAP + protocol}. + + QCborStreamReader provides a StAX-like API, similar to that of + \l{QXmlStreamReader}. Using it requires a bit of knowledge of CBOR encoding. + For a simpler API, see \l{QCborValue} and especially the decoding function + QCborValue::fromCbor(). + + Typically, one creates a QCborStreamReader by passing the source QByteArray + or QIODevice as a parameter to the constructor, then pop elements off the + stream if there were no errors in decoding. There are three kinds of CBOR + types: + + \table + \header \li Kind \li Types \li Behavior + \row \li Fixed-width \li Integers, Tags, Simple types, Floating point + \li Value is pre-parsed by QCborStreamReader, so accessor functions + are \c const. Must call next() to advance. + \row \li Strings \li Byte arrays, Text strings + \li Length (if known) is pre-parsed, but the string itself is not. + The accessor functions are not const and may allocate memory. + Once called, the accessor functions automatically advance to + the next element. + \row \li Containers \li Arrays, Maps + \li Length (if known) is pre-parsed. To access the elements, you + must call enterContainer(), read all elements, then call + leaveContainer(). That function advances to the next element. + \endtable + + So a processor function typically looks like this: + + \snippet code/src_corelib_serialization_qcborstream.cpp 24 + + \section1 CBOR support + + The following table lists the CBOR features that QCborStreamReader supports. + + \table + \header \li Feature \li Support + \row \li Unsigned numbers \li Yes (full range) + \row \li Negative numbers \li Yes (full range) + \row \li Byte strings \li Yes + \row \li Text strings \li Yes + \row \li Chunked strings \li Yes + \row \li Tags \li Yes (arbitrary) + \row \li Booleans \li Yes + \row \li Null \li Yes + \row \li Undefined \li Yes + \row \li Arbitrary simple values \li Yes + \row \li Half-precision float (16-bit) \li Yes + \row \li Single-precision float (32-bit) \li Yes + \row \li Double-precision float (64-bit) \li Yes + \row \li Infinities and NaN floating point \li Yes + \row \li Determinate-length arrays and maps \li Yes + \row \li Indeterminate-length arrays and maps \li Yes + \row \li Map key types other than strings and integers \li Yes (arbitrary) + \endtable + + \section1 Dealing with invalid or incomplete CBOR streams + + QCborStreamReader is capable of detecting corrupt input on its own. The + library it uses has been extensively tested against invalid input of any + kind and is quite able to report errors. If any is detected, + QCborStreamReader will set lastError() to a value besides + QCborError::NoError, indicating which situation was detected. + + Most errors detected by QCborStreamReader during normal item parsing are not + recoverable. The code using QCborStreamReader may opt to handle the data + that was properly decoded or it can opt to discard the entire data. + + The only recoverable error is QCborError::EndOfFile, which indicates that + more data is required in order to complete the parsing. This situation is + useful when data is being read from an asynchronous source, such as a pipe + (QProcess) or a socket (QTcpSocket, QUdpSocket, QNetworkReply, etc.). When + more data arrives, the surrounding code needs to call either addData(), if + parsing from a QByteArray, or reparse(), if it is instead reading directly + a the QIDOevice that now has more data available (see setDevice()). + + \sa QCborStreamWriter, QCborValue, QXmlStreamReader + */ + +/*! + \enum QCborStreamReader::Type + + This enumeration contains all possible CBOR types as decoded by + QCborStreamReader. CBOR has 7 major types, plus a number of simple types + carrying no value, and floating point values. + + \value UnsignedInteger (Major type 0) Ranges from 0 to 2\sup{64} - 1 + (18,446,744,073,709,551,616) + \value NegativeInteger (Major type 1) Ranges from -1 to -2\sup{64} + (-18,446,744,073,709,551,616) + \value ByteArray (Major type 2) Arbitrary binary data. + \value ByteString An alias to ByteArray. + \value String (Major type 3) Unicode text, possibly containing NULs. + \value TextString An alias to String + \value Array (Major type 4) Array of heterogeneous items. + \value Map (Major type 5) Map/dictionary of heterogeneous items. + \value Tag (Major type 6) Numbers giving further semantic value + to generic CBOR items. See \l QCborTag for more information. + \value SimpleType (Major type 7) Types carrying no further value. Includes + booleans (true and false), null, undefined. + \value Float16 IEEE 754 half-precision floating point (\c qfloat16). + \value HalfFloat An alias to Float16. + \value Float IEEE 754 single-precision floating point (\tt float). + \value Double IEEE 754 double-precision floating point (\tt double). + \value Invalid Not a valid type, either due to parsing error or due to + reaching the end of an array or map. + */ + +/*! + \enum QCborStreamReader::StringResultCode + + This enum is returned by readString() and readByteArray() and is used to + indicate what the status of the parsing is. + + \value EndOfString The parsing for the string is complete, with no error. + \value Ok The function returned data; there was no error. + \value Error Parsing failed with an error. + */ + +/*! + \class QCborStreamReader::StringResult + \inmodule QtCore + + This class is returned by readString() and readByteArray(), with either the + contents of the string that was read or an indication that the parsing is + done or found an error. + + The contents of \l data are valid only if \l status is + \l{StringResultCode}{Ok}. Otherwise, it should be null. + */ + +/*! + \variable QCborStreamReader::StringResult::data + + Contains the actual data from the string if \l status is \c Ok. + */ + +/*! + \variable QCborStreamReader::StringResult::status + + Contains the status of the attempt of reading the string from the stream. + */ + +/*! + \fn QCborStreamReader::Type QCborStreamReader::type() const + + Returns the type of the current element. It is one of the valid types or + Invalid. + + \sa isValid(), isUnsignedInteger(), isNegativeInteger(), isInteger(), + isByteArray(), isString(), isArray(), isMap(), isTag(), isSimpleType(), + isBool(), isFalse(), isTrue(), isNull(), isUndefined(), isFloat16(), + isFloat(), isDouble() + */ + +/*! + \fn bool QCborStreamReader::isValid() const + + Returns true if the current element is valid, false otherwise. The current + element may be invalid if there was a decoding error or we've just parsed + the last element in an array or map. + + \note This function is not the opposite of isNull(). Null is a normal CBOR + type that must be handled by the application. + + \sa type(), isInvalid() + */ + +/*! + \fn bool QCborStreamReader::isInvalid() const + + Returns true if the current element is invalid, false otherwise. The current + element may be invalid if there was a decoding error or we've just parsed + the last element in an array or map. + + \note This function is not to be confused with isNull(). Null is a normal + CBOR type that must be handled by the application. + + \sa type(), isValid() + */ + +/*! + \fn bool QCborStreamReader::isUnsignedInteger() const + + Returns true if the type of the current element is an unsigned integer (that + is if type() returns QCborStreamReader::UnsignedInteger). If this function + returns true, you may call toUnsignedInteger() or toInteger() to read that value. + + \sa type(), toUnsignedInteger(), toInteger(), isInteger(), isNegativeInteger() + */ + +/*! + \fn bool QCborStreamReader::isNegativeInteger() const + + Returns true if the type of the current element is a negative integer (that + is if type() returns QCborStreamReader::NegativeInteger). If this function + returns true, you may call toNegativeInteger() or toInteger() to read that value. + + \sa type(), toNegativeInteger(), toInteger(), isInteger(), isUnsignedInteger() + */ + +/*! + \fn bool QCborStreamReader::isInteger() const + + Returns true if the type of the current element is either an unsigned + integer or a negative one (that is, if type() returns + QCborStreamReader::UnsignedInteger or QCborStreamReader::NegativeInteger). + If this function returns true, you may call toInteger() to read that + value. + + \sa type(), toInteger(), toUnsignedInteger(), toNegativeInteger(), + isUnsignedInteger(), isNegativeInteger() + */ + +/*! + \fn bool QCborStreamReader::isByteArray() const + + Returns true if the type of the current element is a byte array (that is, + if type() returns QCborStreamReader::ByteArray). If this function returns + true, you may call readByteArray() to read that data. + + \sa type(), readByteArray(), isString() + */ + +/*! + \fn bool QCborStreamReader::isString() const + + Returns true if the type of the current element is a text string (that is, + if type() returns QCborStreamReader::String). If this function returns + true, you may call readString() to read that data. + + \sa type(), readString(), isByteArray() + */ + +/*! + \fn bool QCborStreamReader::isArray() const + + Returns true if the type of the current element is an array (that is, + if type() returns QCborStreamReader::Array). If this function returns + true, you may call enterContainer() to begin parsing that container. + + When the current element is an array, you may also call isLengthKnown() to + find out if the array's size is explicit in the CBOR stream. If it is, that + size can be obtained by calling length(). + + The following example pre-allocates a QVariantList given the array's size + for more efficient decoding: + + \snippet code/src_corelib_serialization_qcborstream.cpp 25 + + \note The code above does not validate that the length is a sensible value. + If the input stream reports that the length is 1 billion elements, the above + function will try to allocate some 16 GB or more of RAM, which can lead to a + crash. + + \sa type(), isMap(), isLengthKnown(), length(), enterContainer(), leaveContainer() + */ + +/*! + \fn bool QCborStreamReader::isMap() const + + Returns true if the type of the current element is a map (that is, if type() + returns QCborStreamReader::Map). If this function returns true, you may call + enterContainer() to begin parsing that container. + + When the current element is a map, you may also call isLengthKnown() to + find out if the map's size is explicit in the CBOR stream. If it is, that + size can be obtained by calling length(). + + The following example pre-allocates a QVariantMap given the map's size + for more efficient decoding: + + \snippet code/src_corelib_serialization_qcborstream.cpp 26 + + The example above uses a function called \c readElementAsString to read the + map's keys and obtain a string. That is because CBOR maps may contain any + type as keys, not just strings. User code needs to either perform this + conversion, reject non-string keys, or instead use a different container + besides \l QVariantMap and \l QVariantHash. For example, if the map is + expected to contain integer keys, which is recommended as it reduces stream + size and parsing, the correct container would be \c{\l{QMap}<int, QVariant>} + or \c{\l{QHash}<int, QVariant>}. + + \note The code above does not validate that the length is a sensible value. + If the input stream reports that the length is 1 billion elements, the above + function will try to allocate some 24 GB or more of RAM, which can lead to a + crash. + + \sa type(), isArray(), isLengthKnown(), length(), enterContainer(), leaveContainer() + */ + +/*! + \fn bool QCborStreamReader::isTag() const + + Returns true if the type of the current element is a CBOR tag (that is, + if type() returns QCborStreamReader::Tag). If this function returns + true, you may call toTag() to read that data. + + \sa type(), toTag() + */ + +/*! + \fn bool QCborStreamReader::isFloat16() const + + Returns true if the type of the current element is an IEEE 754 + half-precision floating point (that is, if type() returns + QCborStreamReader::Float16). If this function returns true, you may call + toFloat16() to read that data. + + \sa type(), toFloat16(), isFloat(), isDouble() + */ + +/*! + \fn bool QCborStreamReader::isFloat() const + + Returns true if the type of the current element is an IEEE 754 + single-precision floating point (that is, if type() returns + QCborStreamReader::Float). If this function returns true, you may call + toFloat() to read that data. + + \sa type(), toFloat(), isFloat16(), isDouble() + */ + +/*! + \fn bool QCborStreamReader::isDouble() const + + Returns true if the type of the current element is an IEEE 754 + double-precision floating point (that is, if type() returns + QCborStreamReader::Double). If this function returns true, you may call + toDouble() to read that data. + + \sa type(), toDouble(), isFloat16(), isFloat() + */ + +/*! + \fn bool QCborStreamReader::isSimpleType() const + + Returns true if the type of the current element is any CBOR simple type, + including a boolean value (true and false) as well as null and undefined. To + find out which simple type this is, call toSimpleType(). Alternatively, to + test for one specific simple type, call the overload that takes a + QCborSimpleType parameter. + + CBOR simple types are types that do not carry extra value. There are 255 + possibilities, but there are currently only four values that have defined + meaning. Code is not expected to cope with unknown simple types and may + simply discard the stream as invalid if it finds an unknown one. + + \sa QCborSimpleType, type(), isSimpleType(QCborSimpleType), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isSimpleType(QCborSimpleType st) const + + Returns true if the type of the current element is the simple type \a st, + false otherwise. If this function returns true, then toSimpleType() will + return \a st. + + CBOR simple types are types that do not carry extra value. There are 255 + possibilities, but there are currently only four values that have defined + meaning. Code is not expected to cope with unknown simple types and may + simply discard the stream as invalid if it finds an unknown one. + + \sa QCborSimpleType, type(), isSimpleType(), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isFalse() const + + Returns true if the current element is the \c false value, false if it is + anything else. + + \sa type(), isTrue(), isBool(), toBool(), isSimpleType(), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isTrue() const + + Returns true if the current element is the \c true value, false if it is + anything else. + + \sa type(), isFalse(), isBool(), toBool(), isSimpleType(), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isBool() const + + Returns true if the current element is a boolean value (\c true or \c + false), false if it is anything else. If this function returns true, you may + call toBool() to retrieve the value of the boolean. You may also call + toSimpleType() and compare to either QCborSimpleValue::True or + QCborSimpleValue::False. + + \sa type(), isFalse(), isTrue(), toBool(), isSimpleType(), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isNull() const + + Returns true if the current element is the \c null value, false if it is + anything else. Null values may be used to indicate the absence of some + optional data. + + \note This function is not the opposite of isValid(). A Null value is a + valid CBOR value. + + \sa type(), isSimpleType(), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isUndefined() const + + Returns true if the current element is the \c undefined value, false if it + is anything else. Undefined values may be encoded to indicate that some + conversion failed or was not possible when creating the stream. + QCborStreamReader never performs any replacement and this function will only + return true if the stream contains an explicit undefined value. + + \sa type(), isSimpleType(), toSimpleType() + */ + +/*! + \fn bool QCborStreamReader::isContainer() const + + Returns true if the current element is a container (that is, an array or a + map), false if it is anything else. If the current element is a container, + the isLengthKnown() function may be used to find out if the container's size + is explicit in the stream and, if so, length() can be used to get that size. + + More importantly, for a container, the enterContainer() function is + available to begin iterating through the elements contained therein. + + \sa type(), isArray(), isMap(), isLengthKnown(), length(), enterContainer(), + leaveContainer(), containerDepth() + */ + +class QCborStreamReaderPrivate +{ +public: + enum { + // 9 bytes is the maximum size for any integer, floating point or + // length in CBOR. + MaxCborIndividualSize = 9, + IdealIoBufferSize = 256 + }; + + QIODevice *device; + QByteArray buffer; + QStack<CborValue> containerStack; + + CborParser parser; + CborValue currentElement; + QCborError lastError = {}; + + QByteArray::size_type bufferStart; + bool corrupt = false; + + QCborStreamReaderPrivate(const QByteArray &data) + : device(nullptr), buffer(data) + { + initDecoder(); + } + + QCborStreamReaderPrivate(QIODevice *device) + { + setDevice(device); + } + + ~QCborStreamReaderPrivate() + { + } + + void setDevice(QIODevice *dev) + { + buffer.clear(); + device = dev; + initDecoder(); + } + + void initDecoder() + { + containerStack.clear(); + bufferStart = 0; + if (device) { + buffer.clear(); + buffer.reserve(IdealIoBufferSize); // sets the CapacityReserved flag + } + + preread(); + if (CborError err = cbor_parser_init_reader(nullptr, &parser, ¤tElement, this)) + handleError(err); + else + lastError = { QCborError::NoError }; + } + + char *bufferPtr() + { + Q_ASSERT(buffer.isDetached()); + return const_cast<char *>(buffer.constData()) + bufferStart; + } + + void preread() + { + if (device && buffer.size() - bufferStart < MaxCborIndividualSize) { + // load more, but only if there's more to be read + qint64 avail = device->bytesAvailable(); + Q_ASSERT(avail >= buffer.size()); + if (avail == buffer.size()) + return; + + if (bufferStart) + device->skip(bufferStart); // skip what we've already parsed + + if (buffer.size() != IdealIoBufferSize) + buffer.resize(IdealIoBufferSize); + + bufferStart = 0; + qint64 read = device->peek(bufferPtr(), IdealIoBufferSize); + if (read < 0) + buffer.clear(); + else if (read != IdealIoBufferSize) + buffer.truncate(read); + } + } + + void handleError(CborError err) noexcept + { + Q_ASSERT(err); + + // is the error fatal? + if (err != CborErrorUnexpectedEOF) + corrupt = true; + + lastError = QCborError { QCborError::Code(int(err)) }; + } + + void updateBufferAfterString(qsizetype offset, qsizetype size) + { + Q_ASSERT(device); + + bufferStart += offset; + qsizetype newStart = bufferStart + size; + qsizetype remainingInBuffer = buffer.size() - newStart; + + if (remainingInBuffer <= 0) { + // We've read from the QIODevice more than what was in the buffer. + buffer.truncate(0); + } else { + // There's still data buffered, but we need to move it around. + char *ptr = buffer.data(); + memmove(ptr, ptr + newStart, remainingInBuffer); + buffer.truncate(remainingInBuffer); + } + + bufferStart = 0; + } + + bool ensureStringIteration(); +}; + +void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error) +{ + d->handleError(CborError(error.c)); +} + +static inline bool qt_cbor_decoder_can_read(void *token, size_t len) +{ + Q_ASSERT(len <= QCborStreamReaderPrivate::MaxCborIndividualSize); + auto self = static_cast<QCborStreamReaderPrivate *>(token); + + qint64 avail = self->buffer.size() - self->bufferStart; + return len <= quint64(avail); +} + +static void qt_cbor_decoder_advance(void *token, size_t len) +{ + Q_ASSERT(len <= QCborStreamReaderPrivate::MaxCborIndividualSize); + auto self = static_cast<QCborStreamReaderPrivate *>(token); + Q_ASSERT(len <= size_t(self->buffer.size() - self->bufferStart)); + + self->bufferStart += int(len); + self->preread(); +} + +static void *qt_cbor_decoder_read(void *token, void *userptr, size_t offset, size_t len) +{ + Q_ASSERT(len == 1 || len == 2 || len == 4 || len == 8); + Q_ASSERT(offset == 0 || offset == 1); + auto self = static_cast<const QCborStreamReaderPrivate *>(token); + + // we must have pre-read the data + Q_ASSERT(len + offset <= size_t(self->buffer.size() - self->bufferStart)); + return memcpy(userptr, self->buffer.constData() + self->bufferStart + offset, len); +} + +static CborError qt_cbor_decoder_transfer_string(void *token, const void **userptr, size_t offset, size_t len) +{ + auto self = static_cast<QCborStreamReaderPrivate *>(token); + Q_ASSERT(offset <= size_t(self->buffer.size())); + Q_STATIC_ASSERT(sizeof(size_t) >= sizeof(QByteArray::size_type)); + Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); + + // check that we will have enough data from the QIODevice before we advance + // (otherwise, we'd lose the length information) + qsizetype total; + if (len > size_t(std::numeric_limits<QByteArray::size_type>::max()) + || add_overflow<qsizetype>(offset, len, &total)) + return CborErrorDataTooLarge; + + // our string transfer is just saving the offset to the userptr + *userptr = reinterpret_cast<void *>(offset); + + qint64 avail = (self->device ? self->device->bytesAvailable() : self->buffer.size()) - + self->bufferStart; + return total > avail ? CborErrorUnexpectedEOF : CborNoError; +} + +bool QCborStreamReaderPrivate::ensureStringIteration() +{ + if (currentElement.flags & CborIteratorFlag_IteratingStringChunks) + return true; + + CborError err = cbor_value_begin_string_iteration(¤tElement); + if (!err) + return true; + handleError(err); + return false; +} + +/*! + \internal + */ +inline void QCborStreamReader::preparse() +{ + if (lastError() == QCborError::NoError) { + type_ = cbor_value_get_type(&d->currentElement); + + if (type_ == CborInvalidType) { + // We may have reached the end. + if (d->device && d->containerStack.isEmpty()) { + d->buffer.clear(); + if (d->bufferStart) + d->device->skip(d->bufferStart); + d->bufferStart = 0; + } + } else { + d->lastError = {}; + // Undo the type mapping that TinyCBOR does (we have an explicit type + // for negative integer and we don't have separate types for Boolean, + // Null and Undefined). + if (type_ == CborBooleanType || type_ == CborNullType || type_ == CborUndefinedType) { + type_ = CborSimpleType; + value64 = quint8(d->buffer.at(d->bufferStart)) - CborSimpleType; + } else { + // Using internal TinyCBOR API! + value64 = _cbor_value_extract_int64_helper(&d->currentElement); + + if (cbor_value_is_negative_integer(&d->currentElement)) + type_ = quint8(QCborStreamReader::NegativeInteger); + } + } + } else { + type_ = Invalid; + } +} + +/*! + Creates a QCborStreamReader object with no source data. After construction, + QCborStreamReader will report an error parsing. + + You can add more data by calling addData() or by setting a different source + device using setDevice(). + + \sa addData(), isValid() + */ +QCborStreamReader::QCborStreamReader() + : QCborStreamReader(QByteArray()) +{ +} + +/*! + \overload + + Creates a QCborStreamReader object with \a len bytes of data starting at \a + data. The pointer must remain valid until QCborStreamReader is destroyed. + */ +QCborStreamReader::QCborStreamReader(const char *data, qsizetype len) + : QCborStreamReader(QByteArray::fromRawData(data, len)) +{ +} + +/*! + \overload + + Creates a QCborStreamReader object with \a len bytes of data starting at \a + data. The pointer must remain valid until QCborStreamReader is destroyed. + */ +QCborStreamReader::QCborStreamReader(const quint8 *data, qsizetype len) + : QCborStreamReader(QByteArray::fromRawData(reinterpret_cast<const char *>(data), len)) +{ +} + +/*! + \overload + + Creates a QCborStreamReader object that will parse the CBOR stream found in + \a data. + */ +QCborStreamReader::QCborStreamReader(const QByteArray &data) + : d(new QCborStreamReaderPrivate(data)) +{ + preparse(); +} + +/*! + \overload + + Creates a QCborStreamReader object that will parse the CBOR stream found by + reading from \a device. QCborStreamReader does not take ownership of \a + device, so it must remain valid until this oject is destroyed. + */ +QCborStreamReader::QCborStreamReader(QIODevice *device) + : d(new QCborStreamReaderPrivate(device)) +{ + preparse(); +} + +/*! + Destroys this QCborStreamReader object and frees any associated resources. + */ +QCborStreamReader::~QCborStreamReader() +{ +} + +/*! + Sets the source of data to \a device, resetting the decoder to its initial + state. + */ +void QCborStreamReader::setDevice(QIODevice *device) +{ + d->setDevice(device); + preparse(); +} + +/*! + Returns the QIODevice that was set with either setDevice() or the + QCborStreamReader constructor. If this object was reading from a QByteArray, + this function returns nullptr instead. + */ +QIODevice *QCborStreamReader::device() const +{ + return d->device; +} + +/*! + Adds \a data to the CBOR stream and reparses the current element. This + function is useful if the end of the data was previously reached while + processing the stream, but now more data is available. + */ +void QCborStreamReader::addData(const QByteArray &data) +{ + addData(data.constData(), data.size()); +} + +/*! + \fn void QCborStreamReader::addData(const quint8 *data, qsizetype len) + \overload + + Adds \a len bytes of data starting at \a data to the CBOR stream and + reparses the current element. This function is useful if the end of the data + was previously reached while processing the stream, but now more data is + available. + */ + +/*! + \overload + + Adds \a len bytes of data starting at \a data to the CBOR stream and + reparses the current element. This function is useful if the end of the data + was previously reached while processing the stream, but now more data is + available. + */ +void QCborStreamReader::addData(const char *data, qsizetype len) +{ + if (!d->device) { + if (len > 0) + d->buffer.append(data, len); + reparse(); + } else { + qWarning("QCborStreamReader: addData() with device()"); + } +} + +/*! + Reparses the current element. This function must be called when more data + becomes available in the source QIODevice after parsing failed due to + reaching the end of the input data before the end of the CBOR stream. + + When reading from QByteArray(), the addData() function automatically calls + this function. Calling it when the reading had not failed is a no-op. + */ +void QCborStreamReader::reparse() +{ + d->lastError = {}; + d->preread(); + if (CborError err = cbor_value_reparse(&d->currentElement)) + d->handleError(err); + else + preparse(); +} + +/*! + Clears the decoder state and resets the input source data to an empty byte + array. After this function is called, QCborStreamReader will be indicating + an error parsing. + + Call addData() to add more data to be parsed. + + \sa reset(), setDevice() + */ +void QCborStreamReader::clear() +{ + setDevice(nullptr); +} + +/*! + Resets the source back to the beginning and clears the decoder state. If the + source data was a QByteArray, QCborStreamReader will restart from the + beginning of the array. + + If the source data is a QIODevice, this function will call + QIODevice::reset(), which will seek to byte position 0. If the CBOR stream + is not found at the beginning of the device (e.g., beginning of a file), + then this function will likely do the wrong thing. Instead, position the + QIODevice to the right offset and call setDevice(). + + \sa clear(), setDevice() + */ +void QCborStreamReader::reset() +{ + if (d->device) + d->device->reset(); + d->lastError = {}; + d->initDecoder(); + preparse(); +} + +/*! + Returns the last error in decoding the stream, if any. If no error + was encountered, this returns an QCborError::NoError. + + \sa isValid() + */ +QCborError QCborStreamReader::lastError() +{ + return d->lastError; +} + +/*! + Returns the offset in the input stream of the item currently being decoded. + The current offset is the number of decoded bytes so far only if the source + data is a QByteArray or it is a QIODevice that was positioned at its + beginning when decoding started. + + \sa reset(), clear(), device() + */ +qint64 QCborStreamReader::currentOffset() const +{ + return (d->device ? d->device->pos() : 0) + d->bufferStart; +} + +/*! + Returns the number of containers that this stream has entered with + enterContainer() but not yet left. + + \sa enterContainer(), leaveContainer() + */ +int QCborStreamReader::containerDepth() const +{ + return d->containerStack.size(); +} + +/*! + Returns either QCborStreamReader::Array or QCborStreamReader::Map, + indicating whether the container that contains the current item was an array + or map, respectively. If we're currently parsing the root element, this + function returns QCborStreamReader::Invalid. + + \sa containerDepth(), enterContainer() + */ +QCborStreamReader::Type QCborStreamReader::parentContainerType() const +{ + if (d->containerStack.isEmpty()) + return Invalid; + return Type(cbor_value_get_type(&qAsConst(d->containerStack).top())); +} + +/*! + Returns true if there are more items to be decoded in the current container + or false of we've reached its end. If we're parsing the root element, + hasNext() returning false indicates the parsing is complete; otherwise, if + the container depth is non-zero, then the outer code needs to call + leaveContainer(). + + \sa parentContainerType(), containerDepth(), leaveContainer() + */ +bool QCborStreamReader::hasNext() const noexcept +{ + return cbor_value_is_valid(&d->currentElement) && + !cbor_value_at_end(&d->currentElement); +} + +/*! + Advance the CBOR stream decoding one element. You should usually call this + function when parsing fixed-width basic elements (that is, integers, simple + values, tags and floating point values). But this function can be called + when the current item is a string, array or map too and it will skip over + that entire element, including all contained elements. + + This function returns true if advancing was successful, false otherwise. It + may fail if the stream is corrupt, incomplete or if the nesting level of + arrays and maps exceeds \a maxRecursion. Calling this function when + hasNext() has returned false is also an error. If this function returns + false, lastError() will return the error code detailing what the failure + was. + + \sa lastError(), isValid(), hasNext() + */ +bool QCborStreamReader::next(int maxRecursion) +{ + if (lastError() != QCborError::NoError) + return false; + + if (!hasNext()) { + d->handleError(CborErrorAdvancePastEOF); + } else if (maxRecursion < 0) { + d->handleError(CborErrorNestingTooDeep); + } else if (isContainer()) { + // iterate over each element + enterContainer(); + while (lastError() == QCborError::NoError && hasNext()) + next(maxRecursion - 1); + if (lastError() == QCborError::NoError) + leaveContainer(); + } else if (isString() || isByteArray()) { + auto r = _readByteArray_helper(); + while (r.status == Ok) { + if (isString() && !QUtf8::isValidUtf8(r.data, r.data.size()).isValidUtf8) { + d->handleError(CborErrorInvalidUtf8TextString); + break; + } + r = _readByteArray_helper(); + } + } else { + // fixed types + CborError err = cbor_value_advance_fixed(&d->currentElement); + if (err) + d->handleError(err); + } + + preparse(); + return d->lastError == QCborError::NoError; +} + +/*! + Returns true if the length of the current array, map, byte array or string + is known (explicit in the CBOR stream), false otherwise. This function + should only be called if the element is one of those. + + If the length is known, it may be obtained by calling length(). + + If the length of a map or an array is not known, it is implied by the number + of elements present in the stream. QCborStreamReader has no API to calculate + the length in that condition. + + Strings and byte arrays may also have indeterminate length (that is, they + may be transmitted in multiple chunks). Those cannot currently be created + with QCborStreamWriter, but they could be with other encoders, so + QCborStreamReader supports them. + + \sa length(), QCborStreamWriter::startArray(), QCborStreamWriter::startMap() + */ +bool QCborStreamReader::isLengthKnown() const noexcept +{ + return cbor_value_is_length_known(&d->currentElement); +} + +/*! + Returns the length of the string or byte array, or the number of items in an + array or the number, of item pairs in a map, if known. This function must + not be called if the length is unknown (that is, if isLengthKnown() returned + false). It is an error to do that and it will cause QCborStreamReader to + stop parsing the input stream. + + \sa isLengthKnown(), QCborStreamWriter::startArray(), QCborStreamWriter::startMap() + */ +quint64 QCborStreamReader::length() const +{ + CborError err; + switch (type()) { + case String: + case ByteArray: + case Map: + case Array: + if (isLengthKnown()) + return value64; + err = CborErrorUnknownLength; + break; + + default: + err = CborErrorIllegalType; + break; + } + + d->handleError(err); + return quint64(-1); +} + +/*! + \fn bool QCborStreamReader::enterContainer() + + Enters the array or map that is the current item and prepares for iterating + the elements contained in the container. Returns true if entering the + container succeeded, false otherwise (usually, a parsing error). Each call + to enterContainer() must be paired with a call to leaveContainer(). + + This function may only be called if the current item is an array or a map + (that is, if isArray(), isMap() or isContainer() is true). Calling it in any + other condition is an error. + + \sa leaveContainer(), isContainer(), isArray(), isMap() + */ +bool QCborStreamReader::_enterContainer_helper() +{ + d->containerStack.push(d->currentElement); + CborError err = cbor_value_enter_container(&d->containerStack.top(), &d->currentElement); + if (!err) { + preparse(); + return true; + } + d->handleError(err); + return false; +} + +/*! + Leaves the array or map whose items were being processed and positions the + decoder at the next item after the end of the container. Returns true if + leaving the container succeeded, false otherwise (usually, a parsing error). + Each call to enterContainer() must be paired with a call to + leaveContainer(). + + This function may only be called if hasNext() has returned false and + containerDepth() is not zero. Calling it in any other condition is an error. + + \sa enterContainer(), parentContainerType(), containerDepth() + */ +bool QCborStreamReader::leaveContainer() +{ + if (d->containerStack.isEmpty()) { + qWarning("QCborStreamReader::leaveContainer: trying to leave top-level element"); + return false; + } + if (d->corrupt) + return false; + + CborValue container = d->containerStack.pop(); + CborError err = cbor_value_leave_container(&container, &d->currentElement); + d->currentElement = container; + if (err) { + d->handleError(err); + return false; + } + + preparse(); + return true; +} + +/*! + \fn bool QCborStreamReader::toBool() const + + Returns the boolean value of the current element. + + This function does not perform any type conversions, including from integer. + Therefore, it may only be called if isTrue(), isFalse() or isBool() returned + true; calling it in any other condition is an error. + + \sa isBool(), isTrue(), isFalse(), toInteger() + */ + +/*! + \fn QCborTag QCborStreamReader::toTag() const + + Returns the tag value of the current element. + + This function does not perform any type conversions, including from integer. + Therefore, it may only be called if isTag() is true; calling it in any other + condition is an error. + + Tags are 64-bit numbers attached to generic CBOR types that give them + further meaning. For a list of known tags, see the \l QCborKnownTags + enumeration. + + \sa isTag(), toInteger(), QCborKnownTags + */ + +/*! + \fn quint64 QCborStreamReader::toUnsignedInteger() const + + Returns the unsigned integer value of the current element. + + This function does not perform any type conversions, including from boolean + or CBOR tag. Therefore, it may only be called if isUnsignedInteger() is + true; calling it in any other condition is an error. + + This function may be used to obtain numbers beyond the range of the return + type of toInteger(). + + \sa type(), toInteger(), isUnsignedInteger(), isNegativeInteger() + */ + +/*! + \fn QCborNegativeValue QCborStreamReader::toNegativeInteger() const + + Returns the negative integer value of the current element. + QCborNegativeValue is a 64-bit unsigned integer containing the absolute + value of the negative number that was stored in the CBOR stream. + Additionally, QCborNegativeValue(0) represents the number -2\sup{64}. + + This function does not perform any type conversions, including from boolean + or CBOR tag. Therefore, it may only be called if isNegativeInteger() is + true; calling it in any other condition is an error. + + This function may be used to obtain numbers beyond the range of the return + type of toInteger(). However, use of negative numbers smaller than -2\sup{63} + is extremely discouraged. + + \sa type(), toInteger(), isNegativeInteger(), isUnsignedInteger() + */ + +/*! + \fn qint64 QCborStreamReader::toInteger() const + + Returns the integer value of the current element, be it negative, positive + or zero. If the value is larger than 2\sup{63} - 1 or smaller than + -2\sup{63}, the returned value will overflow and will have an incorrect + sign. If handling those values is required, use toUnsignedInteger() or + toNegativeInteger() instead. + + This function does not perform any type conversions, including from boolean + or CBOR tag. Therefore, it may only be called if isInteger() is true; + calling it in any other condition is an error. + + \sa isInteger(), toUnsignedInteger(), toNegativeInteger() + */ + +/*! + \fn QCborSimpleType QCborStreamReader::toSimpleType() const + + Returns value of the current simple type. + + This function does not perform any type conversions, including from integer. + Therefore, it may only be called if isSimpleType() is true; calling it in + any other condition is an error. + + \sa isSimpleType(), isTrue(), isFalse(), isBool(), isNull(), isUndefined() + */ + +/*! + \fn qfloat16 QCborStreamReader::toFloat16() const + + Returns the 16-bit half-precision floating point value of the current element. + + This function does not perform any type conversions, including from other + floating point types or from integer values. Therefore, it may only be + called if isFloat16() is true; calling it in any other condition is an + error. + + \sa isFloat16(), toFloat(), toDouble() + */ + +/*! + \fn float QCborStreamReader::toFloat() const + + Returns the 32-bit single-precision floating point value of the current + element. + + This function does not perform any type conversions, including from other + floating point types or from integer values. Therefore, it may only be + called if isFloat() is true; calling it in any other condition is an error. + + \sa isFloat(), toFloat16(), toDouble() + */ + +/*! + \fn double QCborStreamReader::toDouble() const + + Returns the 64-bit double-precision floating point value of the current + element. + + This function does not perform any type conversions, including from other + floating point types or from integer values. Therefore, it may only be + called if isDouble() is true; calling it in any other condition is an error. + + \sa isDouble(), toFloat16(), toFloat() + */ + +/*! + \fn QCborStreamReader::StringResult<QString> QCborStreamReader::readString() + + Decodes one string chunk from the CBOR string and returns it. This function + is used for both regular and chunked string contents, so the caller must + always loop around calling this function, even if isLengthKnown() has + is true. The typical use of this function is as follows: + + \snippet code/src_corelib_serialization_qcborstream.cpp 27 + + This function does not perform any type conversions, including from integers + or from byte arrays. Therefore, it may only be called if isString() returned + true; calling it in any other condition is an error. + + \sa readByteArray(), isString(), readStringChunk() + */ +QCborStreamReader::StringResult<QString> QCborStreamReader::_readString_helper() +{ + auto r = _readByteArray_helper(); + QCborStreamReader::StringResult<QString> result; + result.status = r.status; + + if (r.status == Ok) { + QTextCodec::ConverterState cs; + result.data = QUtf8::convertToUnicode(r.data, r.data.size(), &cs); + if (cs.invalidChars == 0 && cs.remainingChars == 0) + return result; + + d->handleError(CborErrorInvalidUtf8TextString); + result.data.clear(); + result.status = Error; + return result; + } + return result; +} + +/*! + \fn QCborStreamReader::StringResult<QString> QCborStreamReader::readByteArray() + + Decodes one byte array chunk from the CBOR string and returns it. This + function is used for both regular and chunked contents, so the caller must + always loop around calling this function, even if isLengthKnown() has + is true. The typical use of this function is as follows: + + \snippet code/src_corelib_serialization_qcborstream.cpp 28 + + This function does not perform any type conversions, including from integers + or from strings. Therefore, it may only be called if isByteArray() is true; + calling it in any other condition is an error. + + \sa readString(), isByteArray(), readStringChunk() + */ +QCborStreamReader::StringResult<QByteArray> QCborStreamReader::_readByteArray_helper() +{ + QCborStreamReader::StringResult<QByteArray> result; + result.status = Error; + qsizetype len = _currentStringChunkSize(); + if (len < 0) + return result; + + result.data.resize(len); + auto r = readStringChunk(result.data.data(), len); + Q_ASSERT(r.status != Ok || r.data == len); + result.status = r.status; + return result; +} + +/*! + \fn qsizetype QCborStreamReader::currentStringChunkSize() const + + Returns the size of the current text or byte string chunk. If the CBOR + stream contains a non-chunked string (that is, if isLengthKnown() returns + \c true), this function returns the size of the entire string, the same as + length(). + + This function is useful to pre-allocate the buffer whose pointer can be passed + to readStringChunk() later. + + \sa readString(), readByteArray(), readStringChunk() + */ +qsizetype QCborStreamReader::_currentStringChunkSize() const +{ + if (!d->ensureStringIteration()) + return -1; + + size_t len; + CborError err = cbor_value_get_string_chunk_size(&d->currentElement, &len); + if (err == CborErrorNoMoreStringChunks) + return 0; // not a real error + else if (err) + d->handleError(err); + else if (qsizetype(len) < 0) + d->handleError(CborErrorDataTooLarge); + else + return qsizetype(len); + return -1; +} + +/*! + Reads the current string chunk into the buffer pointed to by \a ptr, whose + size is \a maxlen. This function returns a \l StringResult object, with the + number of bytes copied into \a ptr saved in the \c \l StringResult::data + member. The \c \l StringResult::status member indicates whether there was + an error reading the string, whether data was copied or whether this was + the last chunk. + + This function can be called for both \l String and \l ByteArray types. + For the latter, this function will read the same data that readByteArray() + would have returned. For strings, it returns the UTF-8 equivalent of the \l + QString that would have been returned. + + This function is usually used alongside currentStringChunkSize() in a loop. + For example: + + \snippet code/src_corelib_serialization_qcborstream.cpp 29 + + Unlike readByteArray() and readString(), this function is not limited by + implementation limits of QByteArray and QString. + + \note This function does not perform verification that the UTF-8 contents + are properly formatted. That means this function does not produce the + QCborError::InvalidUtf8String error, even when readString() does. + + \sa currentStringChunkSize(), readString(), readByteArray(), + isString(), isByteArray() + */ +QCborStreamReader::StringResult<qsizetype> +QCborStreamReader::readStringChunk(char *ptr, qsizetype maxlen) +{ + CborError err; + size_t len; + const void *content = nullptr; + QCborStreamReader::StringResult<qsizetype> result; + result.data = 0; + result.status = Error; + + d->lastError = {}; + if (!d->ensureStringIteration()) + return result; + +#if 1 + // Using internal TinyCBOR API! + err = _cbor_value_get_string_chunk(&d->currentElement, &content, &len, &d->currentElement); +#else + // the above is effectively the same as: + if (cbor_value_is_byte_string(¤tElement)) + err = cbor_value_get_byte_string_chunk(&d->currentElement, reinterpret_cast<const uint8_t **>(&content), + &len, &d->currentElement); + else + err = cbor_value_get_text_string_chunk(&d->currentElement, reinterpret_cast<const char **>(&content), + &len, &d->currentElement); +#endif + + // Range check: using implementation-defined behavior in converting an + // unsigned value out of range of the destination signed type (same as + // "len > size_t(std::numeric_limits<qsizetype>::max())", but generates + // better code with ICC and MSVC). + if (!err && qsizetype(len) < 0) + err = CborErrorDataTooLarge; + + if (err) { + if (err == CborErrorNoMoreStringChunks) { + d->preread(); + err = cbor_value_finish_string_iteration(&d->currentElement); + result.status = EndOfString; + } + if (err) + d->handleError(err); + else + preparse(); + return result; + } + + // Read the chunk into the user's buffer. + qint64 actuallyRead; + qptrdiff offset = qptrdiff(content); + qsizetype toRead = qsizetype(len); + qsizetype left = toRead - maxlen; + if (left < 0) + left = 0; // buffer bigger than string + else + toRead = maxlen; // buffer smaller than string + + if (d->device) { + // This first skip can't fail because we've already read this many bytes. + d->device->skip(d->bufferStart + qptrdiff(content)); + actuallyRead = d->device->read(ptr, toRead); + + if (actuallyRead != toRead) { + actuallyRead = -1; + } else if (left) { + qint64 skipped = d->device->skip(left); + if (skipped != left) + actuallyRead = -1; + } + + if (actuallyRead < 0) { + d->handleError(CborErrorIO); + return result; + } + + d->updateBufferAfterString(offset, len); + } else { + actuallyRead = toRead; + memcpy(ptr, d->buffer.constData() + d->bufferStart + offset, toRead); + d->bufferStart += QByteArray::size_type(offset + len); + } + + d->preread(); + result.data = actuallyRead; + result.status = Ok; + return result; +} + +QT_END_NAMESPACE + +#include "moc_qcborstreamreader.cpp" diff --git a/src/corelib/serialization/qcborstreamreader.h b/src/corelib/serialization/qcborstreamreader.h new file mode 100644 index 0000000000..6d5feccfcf --- /dev/null +++ b/src/corelib/serialization/qcborstreamreader.h @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCBORSTREAMREADER_H +#define QCBORSTREAMREADER_H + +#include <QtCore/qbytearray.h> +#include <QtCore/qcborcommon.h> +#include <QtCore/qfloat16.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringview.h> + +QT_REQUIRE_CONFIG(cborstreamreader); + +// See qcborcommon.h for why we check +#if defined(QT_X11_DEFINES_FOUND) +# undef True +# undef False +#endif + +QT_BEGIN_NAMESPACE + +class QIODevice; + +class QCborStreamReaderPrivate; +class Q_CORE_EXPORT QCborStreamReader +{ + Q_GADGET +public: + enum Type : quint8 { + UnsignedInteger = 0x00, + NegativeInteger = 0x20, + ByteString = 0x40, + ByteArray = ByteString, + TextString = 0x60, + String = TextString, + Array = 0x80, + Map = 0xa0, + Tag = 0xc0, + SimpleType = 0xe0, + HalfFloat = 0xf9, + Float16 = HalfFloat, + Float = 0xfa, + Double = 0xfb, + + Invalid = 0xff + }; + Q_ENUM(Type) + + enum StringResultCode { + EndOfString = 0, + Ok = 1, + Error = -1 + }; + template <typename Container> struct StringResult { + Container data; + StringResultCode status = Error; + }; + Q_ENUM(StringResultCode) + + QCborStreamReader(); + QCborStreamReader(const char *data, qsizetype len); + QCborStreamReader(const quint8 *data, qsizetype len); + explicit QCborStreamReader(const QByteArray &data); + explicit QCborStreamReader(QIODevice *device); + ~QCborStreamReader(); + Q_DISABLE_COPY(QCborStreamReader) + + void setDevice(QIODevice *device); + QIODevice *device() const; + void addData(const QByteArray &data); + void addData(const char *data, qsizetype len); + void addData(const quint8 *data, qsizetype len) + { addData(reinterpret_cast<const char *>(data), len); } + void reparse(); + void clear(); + void reset(); + + QCborError lastError(); + + qint64 currentOffset() const; + + bool isValid() const { return !isInvalid(); } + + int containerDepth() const; + QCborStreamReader::Type parentContainerType() const; + bool hasNext() const noexcept Q_DECL_PURE_FUNCTION; + bool next(int maxRecursion = 10000); + + Type type() const { return QCborStreamReader::Type(type_); } + bool isUnsignedInteger() const { return type() == UnsignedInteger; } + bool isNegativeInteger() const { return type() == NegativeInteger; } + bool isInteger() const { return quint8(type()) <= quint8(NegativeInteger); } + bool isByteArray() const { return type() == ByteArray; } + bool isString() const { return type() == String; } + bool isArray() const { return type() == Array; } + bool isMap() const { return type() == Map; } + bool isTag() const { return type() == Tag; } + bool isSimpleType() const { return type() == SimpleType; } + bool isFloat16() const { return type() == Float16; } + bool isFloat() const { return type() == Float; } + bool isDouble() const { return type() == Double; } + bool isInvalid() const { return type() == Invalid; } + + bool isSimpleType(QCborSimpleType st) const { return isSimpleType() && toSimpleType() == st; } + bool isFalse() const { return isSimpleType(QCborSimpleType::False); } + bool isTrue() const { return isSimpleType(QCborSimpleType::True); } + bool isBool() const { return isFalse() || isTrue(); } + bool isNull() const { return isSimpleType(QCborSimpleType::Null); } + bool isUndefined() const { return isSimpleType(QCborSimpleType::Undefined); } + + bool isLengthKnown() const noexcept Q_DECL_PURE_FUNCTION; + quint64 length() const; + + bool isContainer() const { return isMap() || isArray(); } + bool enterContainer() { Q_ASSERT(isContainer()); return _enterContainer_helper(); } + bool leaveContainer(); + + StringResult<QString> readString() { Q_ASSERT(isString()); return _readString_helper(); } + StringResult<QByteArray> readByteArray(){ Q_ASSERT(isByteArray()); return _readByteArray_helper(); } + qsizetype currentStringChunkSize() const{ Q_ASSERT(isString() || isByteArray()); return _currentStringChunkSize(); } + StringResult<qsizetype> readStringChunk(char *ptr, qsizetype maxlen); + + bool toBool() const { Q_ASSERT(isBool()); return value64 - int(QCborSimpleType::False); } + QCborTag toTag() const { Q_ASSERT(isTag()); return QCborTag(value64); } + quint64 toUnsignedInteger() const { Q_ASSERT(isUnsignedInteger()); return value64; } + QCborNegativeInteger toNegativeInteger() const { Q_ASSERT(isNegativeInteger()); return QCborNegativeInteger(value64 + 1); } + QCborSimpleType toSimpleType() const{ Q_ASSERT(isSimpleType()); return QCborSimpleType(value64); } + qfloat16 toFloat16() const { Q_ASSERT(isFloat16()); return _toFloatingPoint<qfloat16>(); } + float toFloat() const { Q_ASSERT(isFloat()); return _toFloatingPoint<float>(); } + double toDouble() const { Q_ASSERT(isDouble()); return _toFloatingPoint<double>(); } + + qint64 toInteger() const + { + Q_ASSERT(isInteger()); + qint64 v = qint64(value64); + if (isNegativeInteger()) + return -v - 1; + return v; + } + +private: + void preparse(); + bool _enterContainer_helper(); + StringResult<QString> _readString_helper(); + StringResult<QByteArray> _readByteArray_helper(); + qsizetype _currentStringChunkSize() const; + + template <typename FP> FP _toFloatingPoint() const noexcept + { + using UIntFP = typename QIntegerForSizeof<FP>::Unsigned; + UIntFP u = UIntFP(value64); + FP f; + memcpy(static_cast<void *>(&f), &u, sizeof(f)); + return f; + } + + friend QCborStreamReaderPrivate; + friend class QCborContainerPrivate; + quint64 value64; + QScopedPointer<QCborStreamReaderPrivate> d; + quint8 type_; + quint8 reserved[3] = {}; +}; + +QT_END_NAMESPACE + +#if defined(QT_X11_DEFINES_FOUND) +# define True 1 +# define False 0 +#endif + +#endif // QCBORSTREAMREADER_H diff --git a/src/corelib/serialization/qcborstreamwriter.cpp b/src/corelib/serialization/qcborstreamwriter.cpp new file mode 100644 index 0000000000..d7f750b05e --- /dev/null +++ b/src/corelib/serialization/qcborstreamwriter.cpp @@ -0,0 +1,868 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcborstreamwriter.h" + +#define CBOR_NO_PARSER_API +#include <private/qcborcommon_p.h> + +#include <private/qnumeric_p.h> +#include <qbuffer.h> +#include <qdebug.h> +#include <qstack.h> + +QT_BEGIN_NAMESPACE + +static CborError qt_cbor_encoder_write_callback(void *token, const void *data, size_t len, CborEncoderAppendType); +#define CBOR_ENCODER_WRITER_CONTROL 1 +#define CBOR_ENCODER_WRITE_FUNCTION qt_cbor_encoder_write_callback +#define CBOR_ENCODER_NO_CHECK_USER + +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4334) // '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) + +#include <cborencoder.c> + +QT_WARNING_POP + +// silence compilers that complain about this being a static function declared +// but never defined +static CborError cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*) +{ + Q_UNREACHABLE(); + return CborErrorInternalError; +} + +static CborError cbor_encode_float_as_half_float(CborEncoder *, float) +{ + Q_UNREACHABLE(); + return CborErrorInternalError; +} + +Q_DECLARE_TYPEINFO(CborEncoder, Q_PRIMITIVE_TYPE); + +/*! + \class QCborStreamWriter + \inmodule QtCore + \ingroup cbor + \reentrant + \since 5.12 + + \brief The QCborStreamWriter class is a simple CBOR encoder operating on a + one-way stream. + + This class can be used to quickly encode a stream of CBOR content directly + to either a QByteArray or QIODevice. CBOR is the Concise Binary Object + Representation, a very compact form of binary data encoding that is + compatible with JSON. It was created by the IETF Constrained RESTful + Environments (CoRE) WG, which has used it in many new RFCs. It is meant to + be used alongside the \l{https://tools.ietf.org/html/rfc7252}{CoAP + protocol}. + + QCborStreamWriter provides a StAX-like API, similar to that of + \l{QXmlStreamWriter}. It is rather low-level and requires a bit of knowledge + of CBOR encoding. For a simpler API, see \l{QCborValue} and especially the + encoding function QCborValue::toCbor(). + + The typical use of QCborStreamWriter is to create the object on the target + QByteArray or QIODevice, then call one of the append() overloads with the + desired type to be encoded. To create arrays and maps, QCborStreamWriter + provides startArray() and startMap() overloads, which must be terminated by + the corresponding endArray() and endMap() functions. + + The following example encodes the equivalent of this JSON content: + + \div{class="pre"} + { + "label": "journald", + "autoDetect": false, + "condition": "libs.journald", + "output": [ "privateFeature" ] + } + \enddiv + + \snippet code/src_corelib_serialization_qcborstream.cpp 1 + + \section1 CBOR support + + QCborStreamWriter supports all CBOR features required to create canonical + and strict streams. It implements almost all of the features specified in + \l {https://tools.ietf.org/html/rfc7049}{RFC 7049}. + + The following table lists the CBOR features that QCborStreamWriter supports. + + \table + \header \li Feature \li Support + \row \li Unsigned numbers \li Yes (full range) + \row \li Negative numbers \li Yes (full range) + \row \li Byte strings \li Yes + \row \li Text strings \li Yes + \row \li Chunked strings \li No + \row \li Tags \li Yes (arbitrary) + \row \li Booleans \li Yes + \row \li Null \li Yes + \row \li Undefined \li Yes + \row \li Arbitrary simple values \li Yes + \row \li Half-precision float (16-bit) \li Yes + \row \li Single-precision float (32-bit) \li Yes + \row \li Double-precision float (64-bit) \li Yes + \row \li Infinities and NaN floating point \li Yes + \row \li Determinate-length arrays and maps \li Yes + \row \li Indeterminate-length arrays and maps \li Yes + \row \li Map key types other than strings and integers \li Yes (arbitrary) + \endtable + + \section2 Canonical CBOR encoding + + Canonical CBOR encoding is defined by + \l{https://tools.ietf.org/html/rfc7049#section-3.9}{Section 3.9 of RFC + 7049}. Canonical encoding is not a requirement for Qt's CBOR decoding + functionality, but it may be required for some protocols. In particular, + protocols that require the ability to reproduce the same stream identically + may require this. + + In order to be considered "canonical", a CBOR stream must meet the + following requirements: + + \list + \li Integers must be as small as possible. QCborStreamWriter always + does this (no user action is required and it is not possible + to write overlong integers). + \li Array, map and string lengths must be as short as possible. As + above, QCborStreamWriter automatically does this. + \li Arrays, maps and strings must use explicit length. QCborStreamWriter + always does this for strings; for arrays and maps, be sure to call + startArray() and startMap() overloads with explicit length. + \li Keys in every map must be sorted in ascending order. QCborStreamWriter + offers no help in this item: the developer must ensure that before + calling append() for the map pairs. + \li Floating point values should be as small as possible. QCborStreamWriter + will not convert floating point values; it is up to the developer + to perform this check prior to calling append() (see those functions' + examples). + \endlist + + \section2 Strict CBOR mode + + Strict mode is defined by + \l{https://tools.ietf.org/html/rfc7049#section-3.10}{Section 3.10 of RFC + 7049}. As for Canonical encoding above, QCborStreamWriter makes it possible + to create strict CBOR streams, but does not require them or validate that + the output is so. + + \list + \li Keys in a map must be unique. QCborStreamWriter performs no validation + of map keys. + \li Tags may be required to be paired only with the correct types, + according to their specification. QCborStreamWriter performs no + validation of tag usage. + \li Text Strings must be properly-encoded UTF-8. QCborStreamWriter always + writes proper UTF-8 for strings added with append(), but performs no + validation for strings added with appendTextString(). + \endlist + + \section2 Invalid CBOR stream + + It is also possible to misuse QCborStreamWriter and produce invalid CBOR + streams that will fail to be decoded by a receiver. The following actions + will produce invalid streams: + + \list + \li Append a tag and not append the corresponding tagged value + (QCborStreamWriter produces no diagnostic). + \li Append too many or too few items to an array or map with explicit + length (endMap() and endArray() will return false and + QCborStreamWriter will log with qWarning()). + \endlist + + \sa QCborStreamReader, QCborValue, QXmlStreamWriter + */ + +class QCborStreamWriterPrivate +{ +public: + static Q_CONSTEXPR quint64 IndefiniteLength = (std::numeric_limits<quint64>::max)(); + + QIODevice *device; + CborEncoder encoder; + QStack<CborEncoder> containerStack; + bool deleteDevice = false; + + QCborStreamWriterPrivate(QIODevice *device) + : device(device) + { + cbor_encoder_init_writer(&encoder, qt_cbor_encoder_write_callback, this); + } + + ~QCborStreamWriterPrivate() + { + if (deleteDevice) + delete device; + } + + template <typename... Args> void executeAppend(CborError (*f)(CborEncoder *, Args...), Args... args) + { + f(&encoder, std::forward<Args>(args)...); + } + + void createContainer(CborError (*f)(CborEncoder *, CborEncoder *, size_t), quint64 len = IndefiniteLength) + { + Q_STATIC_ASSERT(size_t(IndefiniteLength) == CborIndefiniteLength); + if (sizeof(len) != sizeof(size_t) && len != IndefiniteLength) { + if (Q_UNLIKELY(len >= CborIndefiniteLength)) { + // TinyCBOR can't do this in 32-bit mode + qWarning("QCborStreamWriter: container of size %llu is too big for a 32-bit build; " + "will use indeterminate length instead", len); + len = CborIndefiniteLength; + } + } + + containerStack.push(encoder); + f(&containerStack.top(), &encoder, len); + } + + bool closeContainer() + { + if (containerStack.isEmpty()) { + qWarning("QCborStreamWriter: closing map or array that wasn't open"); + return false; + } + + CborEncoder container = containerStack.pop(); + CborError err = cbor_encoder_close_container(&container, &encoder); + encoder = container; + + if (Q_UNLIKELY(err)) { + if (err == CborErrorTooFewItems) + qWarning("QCborStreamWriter: not enough items added to array or map"); + else if (err == CborErrorTooManyItems) + qWarning("QCborStreamWriter: too many items added to array or map"); + return false; + } + + return true; + } +}; + +static CborError qt_cbor_encoder_write_callback(void *self, const void *data, size_t len, CborEncoderAppendType) +{ + auto that = static_cast<QCborStreamWriterPrivate *>(self); + if (!that->device) + return CborNoError; + qint64 written = that->device->write(static_cast<const char *>(data), len); + return (written == qsizetype(len) ? CborNoError : CborErrorIO); +} + +/*! + Creates a QCborStreamWriter object that will write the stream to \a device. + The device must be opened before the first append() call is made. This + constructor can be used with any class that derives from QIODevice, such as + QFile, QProcess or QTcpSocket. + + QCborStreamWriter has no buffering, so every append() call will result in + one or more calls to the device's \l {QIODevice::}{write()} method. + + The following example writes an empty map to a file: + + \snippet code/src_corelib_serialization_qcborstream.cpp 2 + + QCborStreamWriter does not take ownership of \a device. + + \sa device(), setDevice() + */ +QCborStreamWriter::QCborStreamWriter(QIODevice *device) + : d(new QCborStreamWriterPrivate(device)) +{ +} + +/*! + Creates a QCborStreamWriter object that will append the stream to \a data. + All streaming is done immediately to the byte array, without the need for + flushing any buffers. + + The following example writes a number to a byte array then returns + it. + + \snippet code/src_corelib_serialization_qcborstream.cpp 3 + + QCborStreamWriter does not take ownership of \a data. + */ +QCborStreamWriter::QCborStreamWriter(QByteArray *data) + : d(new QCborStreamWriterPrivate(new QBuffer(data))) +{ + d->deleteDevice = true; + d->device->open(QIODevice::WriteOnly | QIODevice::Unbuffered); +} + +/*! + Destroys this QCborStreamWriter object and frees any resources associated. + + QCborStreamWriter does not perform error checking to see if all required + items were written to the stream prior to the object being destroyed. It is + the programmer's responsibility to ensure that it was done. + */ +QCborStreamWriter::~QCborStreamWriter() +{ +} + +/*! + Replaces the device or byte array that this QCborStreamWriter object is + writing to with \a device. + + \sa device() + */ +void QCborStreamWriter::setDevice(QIODevice *device) +{ + if (d->deleteDevice) + delete d->device; + d->device = device; + d->deleteDevice = false; +} + +/*! + Returns the QIODevice that this QCborStreamWriter object is writing to. The + device must have previously been set with either the constructor or with + setDevice(). + + If this object was created by writing to a QByteArray, this function will + return an internal instance of QBuffer, which is owned by QCborStreamWriter. + + \sa setDevice() + */ +QIODevice *QCborStreamWriter::device() const +{ + return d->device; +} + +/*! + \overload + + Appends the 64-bit unsigned value \a u to the CBOR stream, creating a CBOR + Unsigned Integer value. In the following example, we write the values 0, + 2\sup{32} and \c UINT64_MAX: + + \snippet code/src_corelib_serialization_qcborstream.cpp 4 + + \sa QCborStreamReader::isUnsignedInteger(), QCborStreamReader::toUnsignedInteger() + */ +void QCborStreamWriter::append(quint64 u) +{ + d->executeAppend(cbor_encode_uint, uint64_t(u)); +} + +/*! + \overload + + Appends the 64-bit signed value \a i to the CBOR stream. This will create + either a CBOR Unsigned Integer or CBOR NegativeInteger value based on the + sign of the parameter. In the following example, we write the values 0, -1, + 2\sup{32} and \c INT64_MAX: + + \snippet code/src_corelib_serialization_qcborstream.cpp 5 + + \sa QCborStreamReader::isInteger(), QCborStreamReader::toInteger() + */ +void QCborStreamWriter::append(qint64 i) +{ + d->executeAppend(cbor_encode_int, int64_t(i)); +} + +/*! + \overload + + Appends the 64-bit negative value \a n to the CBOR stream. + QCborNegativeInteger is a 64-bit enum that holds the absolute value of the + negative number we want to write. If n is zero, the value written will be + equivalent to 2\sup{64} (that is, -18,446,744,073,709,551,616). + + In the following example, we write the values -1, -2\sup{32} and INT64_MIN: + \snippet code/src_corelib_serialization_qcborstream.cpp 6 + + Note how this function can be used to encode numbers that cannot fit a + standard computer's 64-bit signed integer like \l qint64. That is, if \a n + is larger than \c{std::numeric_limits<qint64>::max()} or is 0, this will + represent a negative number smaller than + \c{std::numeric_limits<qint64>::min()}. + + \sa QCborStreamReader::isNegativeInteger(), QCborStreamReader::toNegativeInteger() + */ +void QCborStreamWriter::append(QCborNegativeInteger n) +{ + d->executeAppend(cbor_encode_negative_int, uint64_t(n)); +} + +/*! + \fn void QCborStreamWriter::append(const QByteArray &ba) + \overload + + Appends the byte array \a ba to the stream, creating a CBOR Byte String + value. QCborStreamWriter will attempt to write the entire string in one + chunk. + + The following example will load and append the contents of a file to the + stream: + + \snippet code/src_corelib_serialization_qcborstream.cpp 7 + + As the example shows, unlike JSON, CBOR requires no escaping for binary + content. + + \sa appendByteString(), QCborStreamReader::isByteArray(), + QCborStreamReader::readByteArray() + */ + +/*! + \overload + + Appends the text string \a str to the stream, creating a CBOR Text String + value. QCborStreamWriter will attempt to write the entire string in one + chunk. + + The following example appends a simple string to the stream: + + \snippet code/src_corelib_serialization_qcborstream.cpp 8 + + \b{Performance note}: CBOR requires that all Text Strings be encoded in + UTF-8, so this function will iterate over the characters in the string to + determine whether the contents are US-ASCII or not. If the string is found + to contain characters outside of US-ASCII, it will allocate memory and + convert to UTF-8. If this check is unnecessary, use appendTextString() + instead. + + \sa QCborStreamReader::isString(), QCborStreamReader::readString() + */ +void QCborStreamWriter::append(QLatin1String str) +{ + // We've got Latin-1 but CBOR wants UTF-8, so check if the string is the + // common subset (US-ASCII). + if (QtPrivate::isAscii(str)) { + // it is plain US-ASCII + appendTextString(str.latin1(), str.size()); + } else { + // non-ASCII, so we need a pass-through UTF-16 + append(QString(str)); + } +} + +/*! + \overload + + Appends the text string \a str to the stream, creating a CBOR Text String + value. QCborStreamWriter will attempt to write the entire string in one + chunk. + + The following example writes an arbitrary QString to the stream: + + \snippet code/src_corelib_serialization_qcborstream.cpp 9 + + \sa QCborStreamReader::isString(), QCborStreamReader::readString() + */ +void QCborStreamWriter::append(QStringView str) +{ + QByteArray utf8 = str.toUtf8(); + appendTextString(utf8.constData(), utf8.size()); +} + +/*! + \overload + + Appends the CBOR tag \a tag to the stream, creating a CBOR Tag value. All + tags must be followed by another type which they provide meaning for. + + In the following example, we append a CBOR Tag 36 (Regular Expression) and a + QRegularExpression's pattern to the stream: + + \snippet code/src_corelib_serialization_qcborstream.cpp 10 + + \sa QCborStreamReader::isTag(), QCborStreamReader::toTag() + */ +void QCborStreamWriter::append(QCborTag tag) +{ + d->executeAppend(cbor_encode_tag, CborTag(tag)); +} + +/*! + \fn void QCborStreamWriter::append(QCborKnownTags tag) + \overload + + Appends the CBOR tag \a tag to the stream, creating a CBOR Tag value. All + tags must be followed by another type which they provide meaning for. + + In the following example, we append a CBOR Tag 1 (Unix \c time_t) and an + integer representing the current time to the stream, obtained using the \c + time() function: + + \snippet code/src_corelib_serialization_qcborstream.cpp 11 + + \sa QCborStreamReader::isTag(), QCborStreamReader::toTag() + */ + +/*! + \overload + + Appends the CBOR simple type \a st to the stream, creating a CBOR Simple + Type value. In the following example, we write the simple type for Null as + well as for type 32, which Qt has no support for. + + \snippet code/src_corelib_serialization_qcborstream.cpp 12 + + \note Using Simple Types for which there is no specification can lead to + validation errors by the remote receiver. In addition, simple type values 24 + through 31 (inclusive) are reserved and must not be used. + + \sa QCborStreamReader::isSimpleType(), QCborStreamReader::toSimpleType() + */ +void QCborStreamWriter::append(QCborSimpleType st) +{ + d->executeAppend(cbor_encode_simple_value, uint8_t(st)); +} + +#ifndef QT_BOOTSTRAPPED +/*! + \overload + + Appends the floating point number \a f to the stream, creating a CBOR 16-bit + Half-Precision Floating Point value. The following code can be used to convert + a C++ \tt float to \c qfloat16 if there's no loss of precision and append it, or + instead append the \tt float. + + \snippet code/src_corelib_serialization_qcborstream.cpp 13 + + \sa QCborStreamReader::isFloat16(), QCborStreamReader::toFloat16() + */ +void QCborStreamWriter::append(qfloat16 f) +{ + d->executeAppend(cbor_encode_half_float, static_cast<const void *>(&f)); +} +#endif // QT_BOOTSTRAPPED + +/*! + \overload + + Appends the floating point number \a f to the stream, creating a CBOR 32-bit + Single-Precision Floating Point value. The following code can be used to convert + a C++ \tt double to \tt float if there's no loss of precision and append it, or + instead append the \tt double. + + \snippet code/src_corelib_serialization_qcborstream.cpp 14 + + \sa QCborStreamReader::isFloat(), QCborStreamReader::toFloat() + */ +void QCborStreamWriter::append(float f) +{ + d->executeAppend(cbor_encode_float, f); +} + +/*! + \overload + + Appends the floating point number \a d to the stream, creating a CBOR 64-bit + Double-Precision Floating Point value. QCborStreamWriter always appends the + number as-is, performing no check for whether the number is the canonical + form for NaN, an infinite, whether it is denormal or if it could be written + with a shorter format. + + The following code performs all those checks, except for the denormal one, + which is expected to be taken into account by the system FPU or floating + point emulation directly. + + \snippet code/src_corelib_serialization_qcborstream.cpp 15 + + Determining if a double can be converted to an integral with no loss of + precision is left as an exercise to the reader. + + \sa QCborStreamReader::isDouble(), QCborStreamReader::toDouble() + */ +void QCborStreamWriter::append(double d) +{ + this->d->executeAppend(cbor_encode_double, d); +} + +/*! + Appends \a len bytes of data starting from \a data to the stream, creating a + CBOR Byte String value. QCborStreamWriter will attempt to write the entire + string in one chunk. + + Unlike the QByteArray overload of append(), this function is not limited by + QByteArray's size limits. However, note that neither + QCborStreamReader::readByteArray() nor QCborValue support reading CBOR + streams with byte arrays larger than 2 GB. + + \sa append(), appendTextString(), + QCborStreamReader::isByteArray(), QCborStreamReader::readByteArray() + */ +void QCborStreamWriter::appendByteString(const char *data, qsizetype len) +{ + d->executeAppend(cbor_encode_byte_string, reinterpret_cast<const uint8_t *>(data), size_t(len)); +} + +/*! + Appends \a len bytes of text starting from \a utf8 to the stream, creating a + CBOR Text String value. QCborStreamWriter will attempt to write the entire + string in one chunk. + + The string pointed to by \a utf8 is expected to be properly encoded UTF-8. + QCborStreamWriter performs no validation that this is the case. + + Unlike the QLatin1String overload of append(), this function is not limited + to 2 GB. However, note that neither QCborStreamReader::readString() nor + QCborValue support reading CBOR streams with text strings larger than 2 GB. + + \sa append(QLatin1String), append(QStringView), + QCborStreamReader::isString(), QCborStreamReader::readString() + */ +void QCborStreamWriter::appendTextString(const char *utf8, qsizetype len) +{ + d->executeAppend(cbor_encode_text_string, utf8, size_t(len)); +} + +/*! + \fn void QCborStreamWriter::append(const char *str, qsizetype size) + \overload + + Appends \a size bytes of text starting from \a str to the stream, creating a + CBOR Text String value. QCborStreamWriter will attempt to write the entire + string in one chunk. If \a size is -1, this function will write \c strlen(\a + str) bytes. + + The string pointed to by \a str is expected to be properly encoded UTF-8. + QCborStreamWriter performs no validation that this is the case. + + Unlike the QLatin1String overload of append(), this function is not limited + to 2 GB. However, note that neither QCborStreamReader nor QCborValue support + reading CBOR streams with text strings larger than 2 GB. + + \sa append(QLatin1String), append(QStringView), + QCborStreamReader::isString(), QCborStreamReader::readString() + */ + +/*! + \fn void QCborStreamWriter::append(bool b) + \overload + + Appends the boolean value \a b to the stream, creating either a CBOR False + value or a CBOR True value. This function is equivalent to (and implemented + as): + + \snippet code/src_corelib_serialization_qcborstream.cpp 16 + + \sa appendNull(), appendUndefined(), + QCborStreamReader::isBool(), QCborStreamReader::toBool() + */ + +/*! + \fn void QCborStreamWriter::append(std::nullptr_t) + \overload + + Appends a CBOR Null value to the stream. This function is equivalent to (and + implemented as): The parameter is ignored. + + \snippet code/src_corelib_serialization_qcborstream.cpp 17 + + \sa appendNull(), append(QCborSimpleType), QCborStreamReader::isNull() + */ + +/*! + \fn void QCborStreamWriter::appendNull() + + Appends a CBOR Null value to the stream. This function is equivalent to (and + implemented as): + + \snippet code/src_corelib_serialization_qcborstream.cpp 18 + + \sa append(std::nullptr_t), append(QCborSimpleType), QCborStreamReader::isNull() + */ + +/*! + \fn void QCborStreamWriter::appendUndefined() + + Appends a CBOR Undefined value to the stream. This function is equivalent to (and + implemented as): + + \snippet code/src_corelib_serialization_qcborstream.cpp 19 + + \sa append(QCborSimpleType), QCborStreamReader::isUndefined() + */ + +/*! + Starts a CBOR Array with indeterminate length in the CBOR stream. Each + startArray() call must be paired with one endArray() call and the current + CBOR element extends until the end of the array. + + The array created by this function has no explicit length. Instead, its + length is implied by the elements contained in it. Note, however, that use + of indeterminate-length arrays is not compliant with canonical CBOR encoding. + + The following example appends elements from the linked list of strings + passed as input: + + \snippet code/src_corelib_serialization_qcborstream.cpp 20 + + \sa startArray(quint64), endArray(), startMap(), QCborStreamReader::isArray(), + QCborStreamReader::isLengthKnown() + */ +void QCborStreamWriter::startArray() +{ + d->createContainer(cbor_encoder_create_array); +} + +/*! + \overload + + Starts a CBOR Array with explicit length of \a count items in the CBOR + stream. Each startArray call must be paired with one endArray() call and the + current CBOR element extends until the end of the array. + + The array created by this function has an explicit length and therefore + exactly \a count items must be added to the CBOR stream. Adding fewer or + more items will result in failure during endArray() and the CBOR stream will + be corrupt. However, explicit-length arrays are required by canonical CBOR + encoding. + + The following example appends all strings found in the \l QStringList passed as input: + + \snippet code/src_corelib_serialization_qcborstream.cpp 21 + + \b{Size limitations}: The parameter to this function is quint64, which would + seem to allow up to 2\sup{64}-1 elements in the array. However, both + QCborStreamWriter and QCborStreamReader are currently limited to 2\sup{32}-2 + items on 32-bit systems and 2\sup{64}-2 items on 64-bit ones. Also note that + QCborArray is currently limited to 2\sup{27} elements in any platform. + + \sa startArray(), endArray(), startMap(), QCborStreamReader::isArray(), + QCborStreamReader::isLengthKnown() + */ +void QCborStreamWriter::startArray(quint64 count) +{ + d->createContainer(cbor_encoder_create_array, count); +} + +/*! + Terminates the array started by either overload of startArray() and returns + true if the correct number of elements was added to the array. This function + must be called for every startArray() used. + + A return of false indicates error in the application and an unrecoverable + error in this stream. QCborStreamWriter also writes a warning using + qWarning() if that happens. + + Calling this function when the current container is not an array is also an + error, though QCborStreamWriter cannot currently detect this condition. + + \sa startArray(), startArray(quint64), endMap() + */ +bool QCborStreamWriter::endArray() +{ + return d->closeContainer(); +} + +/*! + Starts a CBOR Map with indeterminate length in the CBOR stream. Each + startMap() call must be paired with one endMap() call and the current CBOR + element extends until the end of the map. + + The map created by this function has no explicit length. Instead, its length + is implied by the elements contained in it. Note, however, that use of + indeterminate-length maps is not compliant with canonical CBOR encoding + (canonical encoding also requires keys to be unique and in sorted order). + + The following example appends elements from the linked list of int and + string pairs passed as input: + + \snippet code/src_corelib_serialization_qcborstream.cpp 22 + + \sa startMap(quint64), endMap(), startArray(), QCborStreamReader::isMap(), + QCborStreamReader::isLengthKnown() + */ +void QCborStreamWriter::startMap() +{ + d->createContainer(cbor_encoder_create_map); +} + +/*! + \overload + + Starts a CBOR Map with explicit length of \a count items in the CBOR + stream. Each startMap call must be paired with one endMap() call and the + current CBOR element extends until the end of the map. + + The map created by this function has an explicit length and therefore + exactly \a count pairs of items must be added to the CBOR stream. Adding + fewer or more items will result in failure during endMap() and the CBOR + stream will be corrupt. However, explicit-length map are required by + canonical CBOR encoding. + + The following example appends all strings found in the \l QMap passed as input: + + \snippet code/src_corelib_serialization_qcborstream.cpp 23 + + \b{Size limitations}: The parameter to this function is quint64, which would + seem to allow up to 2\sup{64}-1 pairs in the map. However, both + QCborStreamWriter and QCborStreamReader are currently limited to 2\sup{31}-1 + items on 32-bit systems and 2\sup{63}-1 items on 64-bit ones. Also note that + QCborMap is currently limited to 2\sup{26} elements in any platform. + + \sa startMap(), endMap(), startArray(), QCborStreamReader::isMap(), + QCborStreamReader::isLengthKnown() + */ +void QCborStreamWriter::startMap(quint64 count) +{ + d->createContainer(cbor_encoder_create_map, count); +} + +/*! + Terminates the map started by either overload of startMap() and returns + true if the correct number of elements was added to the array. This function + must be called for every startMap() used. + + A return of false indicates error in the application and an unrecoverable + error in this stream. QCborStreamWriter also writes a warning using + qWarning() if that happens. + + Calling this function when the current container is not a map is also an + error, though QCborStreamWriter cannot currently detect this condition. + + \sa startMap(), startMap(quint64), endArray() + */ +bool QCborStreamWriter::endMap() +{ + return d->closeContainer(); +} + +QT_END_NAMESPACE diff --git a/src/corelib/serialization/qcborstreamwriter.h b/src/corelib/serialization/qcborstreamwriter.h new file mode 100644 index 0000000000..f8c94ceb93 --- /dev/null +++ b/src/corelib/serialization/qcborstreamwriter.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCBORSTREAMWRITER_H +#define QCBORSTREAMWRITER_H + +#include <QtCore/qbytearray.h> +#include <QtCore/qcborcommon.h> +#include <QtCore/qscopedpointer.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringview.h> +#ifndef QT_BOOTSTRAPPED +#include <QtCore/qfloat16.h> +#endif + +QT_REQUIRE_CONFIG(cborstreamwriter); + +// See qcborcommon.h for why we check +#if defined(QT_X11_DEFINES_FOUND) +# undef True +# undef False +#endif + +QT_BEGIN_NAMESPACE + +class QIODevice; + +class QCborStreamWriterPrivate; +class Q_CORE_EXPORT QCborStreamWriter +{ +public: + explicit QCborStreamWriter(QIODevice *device); + explicit QCborStreamWriter(QByteArray *data); + ~QCborStreamWriter(); + Q_DISABLE_COPY(QCborStreamWriter) + + void setDevice(QIODevice *device); + QIODevice *device() const; + + void append(quint64 u); + void append(qint64 i); + void append(QCborNegativeInteger n); + void append(const QByteArray &ba) { appendByteString(ba.constData(), ba.size()); } + void append(QLatin1String str); + void append(QStringView str); + void append(QCborTag tag); + void append(QCborKnownTags tag) { append(QCborTag(tag)); } + void append(QCborSimpleType st); + void append(std::nullptr_t) { append(QCborSimpleType::Null); } +#ifndef QT_BOOTSTRAPPED + void append(qfloat16 f); +#endif + void append(float f); + void append(double d); + + void appendByteString(const char *data, qsizetype len); + void appendTextString(const char *utf8, qsizetype len); + + // convenience + void append(bool b) { append(b ? QCborSimpleType::True : QCborSimpleType::False); } + void appendNull() { append(QCborSimpleType::Null); } + void appendUndefined() { append(QCborSimpleType::Undefined); } + +#ifndef Q_QDOC + // overloads to make normal code not complain + void append(int i) { append(qint64(i)); } + void append(uint u) { append(quint64(u)); } +#endif +#ifndef QT_NO_CAST_FROM_ASCII + void append(const char *str, qsizetype size = -1) + { appendTextString(str, (str && size == -1) ? int(strlen(str)) : size); } +#endif + + void startArray(); + void startArray(quint64 count); + bool endArray(); + void startMap(); + void startMap(quint64 count); + bool endMap(); + + // no API for encoding chunked strings + +private: + QScopedPointer<QCborStreamWriterPrivate> d; +}; + +QT_END_NAMESPACE + +#if defined(QT_X11_DEFINES_FOUND) +# define True 1 +# define False 0 +#endif + +#endif // QCBORSTREAMWRITER_H diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index 61d61dd9ae..db2840704c 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -43,8 +43,12 @@ #include "qcborarray.h" #include "qcbormap.h" -#if QT_CONFIG(cborstream) -#include "qcborstream.h" +#if QT_CONFIG(cborstreamreader) +#include "qcborstreamreader.h" +#endif + +#if QT_CONFIG(cborstreamwriter) +#include "qcborstreamwriter.h" #endif #include <qendian.h> @@ -840,16 +844,20 @@ static QCborValue::Type convertToExtendedType(QCborContainerPrivate *d) return QCborValue::Tag; } -#if QT_CONFIG(cborstream) +#if QT_CONFIG(cborstreamreader) // in qcborstream.cpp extern void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error); +#endif +#if QT_CONFIG(cborstreamwriter) static void writeDoubleToCbor(QCborStreamWriter &writer, double d, QCborValue::EncodingOptions opt) { if (qt_is_nan(d)) { - if (opt & QCborValue::UseFloat16) { + if (opt & QCborValue::UseFloat) { +#ifndef QT_BOOTSTRAPPED if ((opt & QCborValue::UseFloat16) == QCborValue::UseFloat16) return writer.append(std::numeric_limits<qfloat16>::quiet_NaN()); +#endif return writer.append(std::numeric_limits<float>::quiet_NaN()); } return writer.append(qt_qnan()); @@ -866,15 +874,17 @@ static void writeDoubleToCbor(QCborStreamWriter &writer, double d, QCborValue::E } } - if (opt & QCborValue::UseFloat16) { + if (opt & QCborValue::UseFloat) { float f = float(d); if (f == d) { // no data loss, we could use float +#ifndef QT_BOOTSTRAPPED if ((opt & QCborValue::UseFloat16) == QCborValue::UseFloat16) { qfloat16 f16 = f; if (f16 == f) return writer.append(f16); } +#endif return writer.append(f); } @@ -882,7 +892,7 @@ static void writeDoubleToCbor(QCborStreamWriter &writer, double d, QCborValue::E writer.append(d); } -#endif // QT_CONFIG(cborstream) +#endif // QT_CONFIG(cborstreamwriter) static inline int typeOrder(Element e1, Element e2) { @@ -1305,7 +1315,7 @@ int QCborMap::compare(const QCborMap &other) const noexcept return compareContainer(d.data(), other.d.data()); } -#if QT_CONFIG(cborstream) +#if QT_CONFIG(cborstreamwriter) static void encodeToCbor(QCborStreamWriter &writer, const QCborContainerPrivate *d, qsizetype idx, QCborValue::EncodingOptions opt) { @@ -1393,7 +1403,9 @@ static void encodeToCbor(QCborStreamWriter &writer, const QCborContainerPrivate qWarning("QCborValue: found unknown type 0x%x", e.type); } } +#endif // QT_CONFIG(cborstreamwriter) +#if QT_CONFIG(cborstreamreader) static inline double integerOutOfRange(const QCborStreamReader &reader) { Q_ASSERT(reader.isInteger()); @@ -1650,7 +1662,7 @@ void QCborContainerPrivate::decodeFromCbor(QCborStreamReader &reader) if (reader.lastError() == QCborError::NoError) reader.leaveContainer(); } -#endif // QT_CONFIG(cborstream) +#endif // QT_CONFIG(cborstreamreader) /*! Creates a QCborValue with byte array value \a ba. The value can later be @@ -2350,7 +2362,7 @@ QCborValueRef QCborValue::operator[](qint64 key) return { container, index }; } -#if QT_CONFIG(cborstream) +#if QT_CONFIG(cborstreamreader) /*! Decodes one item from the CBOR stream found in \a reader and returns the equivalent representation. This function is recursive: if the item is a map @@ -2465,7 +2477,9 @@ QCborValue QCborValue::fromCbor(const QByteArray &ba, QCborParserError *error) overload of this function that accepts a QByteArray, also passing \a error, if provided. */ +#endif // QT_CONFIG(cborstreamreader) +#if QT_CONFIG(cborstreamwriter) /*! Encodes this QCborValue object to its CBOR representation, using the options specified in \a opt, and return the byte array containing that @@ -2588,7 +2602,7 @@ void QCborValueRef::toCbor(QCborStreamWriter &writer, QCborValue::EncodingOption { concrete().toCbor(writer, opt); } -#endif // QT_CONFIG(cborstream) +#endif // QT_CONFIG(cborstreamwriter) void QCborValueRef::assign(QCborValueRef that, const QCborValue &other) { diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index 071213e83a..1df8425d45 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -90,7 +90,9 @@ public: enum EncodingOption { SortKeysInMaps = 0x01, UseFloat = 0x02, +#ifndef QT_BOOTSTRAPPED UseFloat16 = UseFloat | 0x04, +#endif UseIntegers = 0x08, NoTransformation = 0 @@ -287,13 +289,15 @@ public: static QCborValue fromJsonValue(const QJsonValue &v); QJsonValue toJsonValue() const; -#if QT_CONFIG(cborstream) +#if QT_CONFIG(cborstreamreader) static QCborValue fromCbor(QCborStreamReader &reader); static QCborValue fromCbor(const QByteArray &ba, QCborParserError *error = nullptr); static QCborValue fromCbor(const char *data, qsizetype len, QCborParserError *error = nullptr) { return fromCbor(QByteArray(data, int(len)), error); } static QCborValue fromCbor(const quint8 *data, qsizetype len, QCborParserError *error = nullptr) { return fromCbor(QByteArray(reinterpret_cast<const char *>(data), int(len)), error); } +#endif // QT_CONFIG(cborstreamreader) +#if QT_CONFIG(cborstreamwriter) QByteArray toCbor(EncodingOptions opt = NoTransformation); void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation); #endif @@ -441,7 +445,7 @@ public: QVariant toVariant() const { return concrete().toVariant(); } QJsonValue toJsonValue() const; -#if QT_CONFIG(cborstream) +#if QT_CONFIG(cborstreamwriter) QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation) { return concrete().toCbor(opt); } void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation); diff --git a/src/corelib/serialization/serialization.pri b/src/corelib/serialization/serialization.pri index 7407e20d9e..ff653ca8f3 100644 --- a/src/corelib/serialization/serialization.pri +++ b/src/corelib/serialization/serialization.pri @@ -3,7 +3,9 @@ HEADERS += \ serialization/qcborarray.h \ serialization/qcborcommon.h \ + serialization/qcborcommon_p.h \ serialization/qcbormap.h \ + serialization/qcborstream.h \ serialization/qcborvalue.h \ serialization/qcborvalue_p.h \ serialization/qdatastream.h \ @@ -22,6 +24,7 @@ HEADERS += \ serialization/qxmlutils_p.h SOURCES += \ + serialization/qcborcommon.cpp \ serialization/qcbordiagnostic.cpp \ serialization/qcborvalue.cpp \ serialization/qdatastream.cpp \ @@ -36,12 +39,20 @@ SOURCES += \ serialization/qxmlstream.cpp \ serialization/qxmlutils.cpp -qtConfig(cborstream): { +qtConfig(cborstreamreader): { SOURCES += \ - serialization/qcborstream.cpp + serialization/qcborstreamreader.cpp HEADERS += \ - serialization/qcborstream.h + serialization/qcborstreamreader.h +} + +qtConfig(cborstreamwriter): { + SOURCES += \ + serialization/qcborstreamwriter.cpp + + HEADERS += \ + serialization/qcborstreamwriter.h } qtConfig(binaryjson): { diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 6230cc081d..bfd199a8ba 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -19,6 +19,10 @@ DEFINES += \ QT_NO_FOREACH \ QT_NO_CAST_FROM_ASCII +INCLUDEPATH += \ + $$PWD/.. \ + $$PWD/../../3rdparty/tinycbor/src + SOURCES += \ ../../corelib/codecs/qlatincodec.cpp \ ../../corelib/codecs/qtextcodec.cpp \ @@ -63,6 +67,8 @@ SOURCES += \ ../../corelib/kernel/qsharedmemory.cpp \ ../../corelib/kernel/qsystemsemaphore.cpp \ ../../corelib/plugin/quuid.cpp \ + ../../corelib/serialization/qcborcommon.cpp \ + ../../corelib/serialization/qcborstreamwriter.cpp \ ../../corelib/serialization/qcborvalue.cpp \ ../../corelib/serialization/qdatastream.cpp \ ../../corelib/serialization/qjsoncbor.cpp \ -- cgit v1.2.3 From 2a653fde48f7312ccd2f792d72d305061b410ae3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Thu, 28 Nov 2019 14:22:09 +0100 Subject: Convert date-time faithfully in QDateTimeEdit::setDateTime() Previously, setDateTime() was documented to ignore the new date-time's time-spec. It used the date and time (determined using that timespec) with the QDateTimeEdit's configured spec. It is debatable whether that really counts as ignoring its time-spec. All the same, that's what it did. Fixing it is a behavior change. Added tests. [ChangeLog][QtWidgets][QDateTimeEdit] QDateTimeEdit::setDateTime() now converts the new datetime to the QDateTimeEdit's time-spec, rather than combining its date and time (determined using the time spec it came with) with the QDateTimeEdit's date and time. Fixes: QTBUG-71181 Change-Id: Ibf0bd87723c3957ca00a2199d51d992032ef57ee Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> --- src/widgets/widgets/qdatetimeedit.cpp | 33 +++++++++++++++++++++++++++++---- src/widgets/widgets/qdatetimeedit_p.h | 1 + 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 3d6716666d..33300b542a 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -53,6 +53,9 @@ #include <qlayout.h> #include <qset.h> #include <qstyle.h> +#if QT_CONFIG(timezone) +#include <QTimeZone> +#endif #include <algorithm> @@ -218,8 +221,8 @@ QDateTimeEdit::~QDateTimeEdit() \property QDateTimeEdit::dateTime \brief the QDateTime that is set in the QDateTimeEdit - When setting this property the timespec of the QDateTimeEdit remains the same - and the timespec of the new QDateTime is ignored. + When setting this property, the new QDateTime is converted to the timespec of + the QDateTimeEdit, which thus remains unchanged. By default, this property is set to the start of 2000 CE. It can only be set to a valid QDateTime value. If any operation causes this property to have an @@ -243,11 +246,14 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime) { Q_D(QDateTimeEdit); if (datetime.isValid()) { + QDateTime when = d->convertTimeSpec(datetime); + Q_ASSERT(when.timeSpec() == d->spec); + d->clearCache(); - const QDate date = datetime.date(); + const QDate date = when.date(); if (!(d->sections & DateSections_Mask)) setDateRange(date, date); - d->setValue(QDateTime(date, datetime.time(), d->spec), EmitIfChanged); + d->setValue(when, EmitIfChanged); } } @@ -1706,6 +1712,25 @@ QDateTimeEditPrivate::QDateTimeEditPrivate() #endif } +QDateTime QDateTimeEditPrivate::convertTimeSpec(const QDateTime &datetime) +{ + Q_ASSERT(value.toDateTime().timeSpec() == spec); + switch (spec) { + case Qt::UTC: + return datetime.toUTC(); + case Qt::LocalTime: + return datetime.toLocalTime(); + case Qt::OffsetFromUTC: + return datetime.toOffsetFromUtc(value.toDateTime().offsetFromUtc()); +#if QT_CONFIG(timezone) + case Qt::TimeZone: + return datetime.toTimeZone(value.toDateTime().timeZone()); +#endif + } + Q_UNREACHABLE(); +} + +// FIXME: architecturaly incompatible with OffsetFromUTC or TimeZone as spec (QTBUG-80417). void QDateTimeEditPrivate::updateTimeSpec() { minimum = minimum.toDateTime().toTimeSpec(spec); diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 392bb0c778..0a4433846f 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -109,6 +109,7 @@ public: void updateCache(const QVariant &val, const QString &str) const; + QDateTime convertTimeSpec(const QDateTime &datetime); void updateTimeSpec(); QString valueToText(const QVariant &var) const { return textFromValue(var); } -- cgit v1.2.3 From 4639660dedceba7c16e1a8110bba16eff30be312 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Wed, 11 Dec 2019 13:27:49 +0100 Subject: rhi: metal: Skip inactive resources The Quick3D-on-RHI PoC demonstrates a case which the Metal backend fails to handle correctly: have an object with a lighting-enabled material, but remove all lights from the scene. Under the hood this means having a uniform block in the shader, but without referencing it in any way in the actual shader code. This leads to the resource being present (as far as shader reflection is concerned), but with no native binding point available, meaning the attempt to retrieve the Metal binding point for it returns -1, and that is what the QShader carries in the nativeResourceBindingMap. The backend should be prepared to silently skip the resource, whereas currently we end up in an assertion due to attempting to batch the (native) binding "-1", which is invalid. Correct this. Change-Id: I85ee58145f589aca45d46c23e0cdce837d598850 Fixes: QTBUG-80668 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhimetal.mm | 104 +++++++++++++++++++++++++++++++++-------------- src/gui/rhi/qshader.cpp | 7 ++++ 2 files changed, 81 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 3aa68db585..b6ca40e08b 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -673,12 +673,17 @@ static inline int mapBinding(int binding, BindingType type) { const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex]; - if (map) { - auto it = map->constFind(binding); - if (it != map->cend()) - return type == BindingType::Sampler ? it->second : it->first; - } - return binding; + if (!map) + return binding; // old QShader versions do not have this map, assume 1:1 mapping then + + auto it = map->constFind(binding); + if (it != map->cend()) + return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive + + // Hitting this path is normal too, is not given that the resource (e.g. a + // uniform block) is really present in the shaders for all the stages + // specified by the visibility mask in the QRhiShaderResourceBinding. + return -1; } void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD, @@ -712,16 +717,25 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } } if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - res[VERTEX].buffers.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[VERTEX].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[VERTEX].buffers.feed(nativeBinding, mtlbuf); + res[VERTEX].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - res[FRAGMENT].buffers.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[FRAGMENT].buffers.feed(nativeBinding, mtlbuf); + res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - res[COMPUTE].buffers.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[COMPUTE].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[COMPUTE].buffers.feed(nativeBinding, mtlbuf); + res[COMPUTE].bufferOffsets.feed(b->binding, offset); + } } } break; @@ -730,16 +744,28 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.stex.tex); QMetalSampler *samplerD = QRHI_RES(QMetalSampler, b->u.stex.sampler); if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - res[VERTEX].textures.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture), texD->d->tex); - res[VERTEX].samplers.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Sampler), samplerD->d->samplerState); + const int nativeBindingTexture = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[VERTEX].textures.feed(nativeBindingTexture, texD->d->tex); + res[VERTEX].samplers.feed(nativeBindingSampler, samplerD->d->samplerState); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - res[FRAGMENT].textures.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture), texD->d->tex); - res[FRAGMENT].samplers.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Sampler), samplerD->d->samplerState); + const int nativeBindingTexture = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[FRAGMENT].textures.feed(nativeBindingTexture, texD->d->tex); + res[FRAGMENT].samplers.feed(nativeBindingSampler, samplerD->d->samplerState); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - res[COMPUTE].textures.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture), texD->d->tex); - res[COMPUTE].samplers.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Sampler), samplerD->d->samplerState); + const int nativeBindingTexture = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture); + const int nativeBindingSampler = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Sampler); + if (nativeBindingTexture >= 0 && nativeBindingSampler >= 0) { + res[COMPUTE].textures.feed(nativeBindingTexture, texD->d->tex); + res[COMPUTE].samplers.feed(nativeBindingSampler, samplerD->d->samplerState); + } } } break; @@ -751,12 +777,21 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); id<MTLTexture> t = texD->d->viewForLevel(b->u.simage.level); - if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) - res[VERTEX].textures.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture), t); - if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) - res[FRAGMENT].textures.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture), t); - if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) - res[COMPUTE].textures.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture), t); + if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { + const int nativeBinding = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Texture); + if (nativeBinding >= 0) + res[VERTEX].textures.feed(nativeBinding, t); + } + if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { + const int nativeBinding = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Texture); + if (nativeBinding >= 0) + res[FRAGMENT].textures.feed(nativeBinding, t); + } + if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { + const int nativeBinding = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Texture); + if (nativeBinding >= 0) + res[COMPUTE].textures.feed(nativeBinding, t); + } } break; case QRhiShaderResourceBinding::BufferLoad: @@ -769,16 +804,25 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD id<MTLBuffer> mtlbuf = bufD->d->buf[0]; uint offset = uint(b->u.sbuf.offset); if (b->stage.testFlag(QRhiShaderResourceBinding::VertexStage)) { - res[VERTEX].buffers.feed(mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[VERTEX].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, VERTEX, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[VERTEX].buffers.feed(nativeBinding, mtlbuf); + res[VERTEX].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::FragmentStage)) { - res[FRAGMENT].buffers.feed(mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, FRAGMENT, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[FRAGMENT].buffers.feed(nativeBinding, mtlbuf); + res[FRAGMENT].bufferOffsets.feed(b->binding, offset); + } } if (b->stage.testFlag(QRhiShaderResourceBinding::ComputeStage)) { - res[COMPUTE].buffers.feed(mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer), mtlbuf); - res[COMPUTE].bufferOffsets.feed(b->binding, offset); + const int nativeBinding = mapBinding(b->binding, COMPUTE, nativeResourceBindingMaps, BindingType::Buffer); + if (nativeBinding >= 0) { + res[COMPUTE].buffers.feed(nativeBinding, mtlbuf); + res[COMPUTE].bufferOffsets.feed(b->binding, offset); + } } } break; diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index dc6060f882..0b99281f08 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -660,6 +660,13 @@ QDebug operator<<(QDebug dbg, const QShaderVersion &v) pair, because combined image samplers may map to two native resources (a texture and a sampler) in some shading languages. In that case the second value refers to the sampler. + + \note The native binding may be -1, in case there is no active binding for + the resource in the shader. (for example, there is a uniform block + declared, but it is not used in the shader code) The map is always + complete, meaning there is an entry for all declared uniform blocks, + storage blocks, image objects, and combined samplers, but the value will be + -1 for those that are not actually referenced in the shader functions. */ /*! -- cgit v1.2.3 From 83818431e15e36ad9c8484cee33475ba00731d6f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Wed, 11 Dec 2019 14:13:03 +0100 Subject: rhi: gl: Add support for arrays of float, vec2, vec3 and vec4 This is a thing in Qt Quick: there are some types of image particles that use uniforms like "float opacitytable[64]". This should make all views work correctly in the Image Particles example when running on the OpenGL backend of QRhi. (other backends should work as expected already) Change-Id: I64a04fbb98b97d81d257b00b428582e751d46b8e Fixes: QTBUG-80667 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhigles2.cpp | 79 +++++++++++++++++++++++++++++++++++++++------ src/gui/rhi/qrhigles2_p_p.h | 1 + 2 files changed, 70 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 3fb2ec38a7..ffaccbad71 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2378,12 +2378,23 @@ void QRhiGles2::executeBindGraphicsPipeline(QRhiGraphicsPipeline *ps) f->glUseProgram(psD->program); } +static inline void qrhi_std140_to_packed(float *dst, int vecSize, int elemCount, const void *src) +{ + const float *p = reinterpret_cast<const float *>(src); + for (int i = 0; i < elemCount; ++i) { + for (int j = 0; j < vecSize; ++j) + dst[vecSize * i + j] = *p++; + p += 4 - vecSize; + } +} + void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiComputePipeline *maybeComputePs, QRhiShaderResourceBindings *srb, const uint *dynOfsPairs, int dynOfsCount) { QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, srb); int texUnit = 0; + QVarLengthArray<float, 256> packedFloatArray; for (int i = 0, ie = srbD->m_bindings.count(); i != ie; ++i) { const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); @@ -2411,18 +2422,64 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC // so this should not cause unaligned reads const void *src = bufView.constData() + uniform.offset; + if (uniform.arrayDim > 0 + && uniform.type != QShaderDescription::Float + && uniform.type != QShaderDescription::Vec2 + && uniform.type != QShaderDescription::Vec3 + && uniform.type != QShaderDescription::Vec4) + { + qWarning("Uniform with buffer binding %d, buffer offset %d, type %d is an array, " + "but arrays are only supported for float, vec2, vec3, and vec4. " + "Only the first element will be set.", + uniform.binding, uniform.offset, uniform.type); + } + + // Our input is an std140 layout uniform block. See + // "Standard Uniform Block Layout" in section 7.6.2.2 of + // the OpenGL spec. This has some peculiar alignment + // requirements, which is not what glUniform* wants. Hence + // the unpacking/repacking for arrays and certain types. + switch (uniform.type) { case QShaderDescription::Float: - f->glUniform1f(uniform.glslLocation, *reinterpret_cast<const float *>(src)); + { + const int elemCount = uniform.arrayDim; + if (elemCount < 1) { + f->glUniform1f(uniform.glslLocation, *reinterpret_cast<const float *>(src)); + } else { + // input is 16 bytes per element as per std140, have to convert to packed + packedFloatArray.resize(elemCount); + qrhi_std140_to_packed(packedFloatArray.data(), 1, elemCount, src); + f->glUniform1fv(uniform.glslLocation, elemCount, packedFloatArray.constData()); + } + } break; case QShaderDescription::Vec2: - f->glUniform2fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(src)); + { + const int elemCount = uniform.arrayDim; + if (elemCount < 1) { + f->glUniform2fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(src)); + } else { + packedFloatArray.resize(elemCount * 2); + qrhi_std140_to_packed(packedFloatArray.data(), 2, elemCount, src); + f->glUniform2fv(uniform.glslLocation, elemCount, packedFloatArray.constData()); + } + } break; case QShaderDescription::Vec3: - f->glUniform3fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(src)); + { + const int elemCount = uniform.arrayDim; + if (elemCount < 1) { + f->glUniform3fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(src)); + } else { + packedFloatArray.resize(elemCount * 3); + qrhi_std140_to_packed(packedFloatArray.data(), 3, elemCount, src); + f->glUniform3fv(uniform.glslLocation, elemCount, packedFloatArray.constData()); + } + } break; case QShaderDescription::Vec4: - f->glUniform4fv(uniform.glslLocation, 1, reinterpret_cast<const float *>(src)); + f->glUniform4fv(uniform.glslLocation, qMax(1, uniform.arrayDim), reinterpret_cast<const float *>(src)); break; case QShaderDescription::Mat2: f->glUniformMatrix2fv(uniform.glslLocation, 1, GL_FALSE, reinterpret_cast<const float *>(src)); @@ -2477,8 +2534,9 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC case QShaderDescription::Bool4: f->glUniform4iv(uniform.glslLocation, 1, reinterpret_cast<const qint32 *>(src)); break; - // ### more types default: + qWarning("Uniform with buffer binding %d, buffer offset %d has unsupported type %d", + uniform.binding, uniform.offset, uniform.type); break; } } @@ -2944,9 +3002,15 @@ void QRhiGles2::registerUniformIfActive(const QShaderDescription::BlockVariable const QByteArray name = namePrefix + var.name.toUtf8(); uniform.glslLocation = f->glGetUniformLocation(program, name.constData()); if (uniform.glslLocation >= 0) { + if (var.arrayDims.count() > 1) { + qWarning("Array '%s' has more than one dimension. This is not supported.", + qPrintable(var.name)); + return; + } uniform.binding = binding; uniform.offset = uint(baseOffset + var.offset); uniform.size = var.size; + uniform.arrayDim = var.arrayDims.isEmpty() ? 0 : var.arrayDims.first(); dst->append(uniform); } } @@ -2979,11 +3043,6 @@ void QRhiGles2::gatherUniforms(GLuint program, } } } else { - if (!blockMember.arrayDims.isEmpty()) { - qWarning("Arrays are only supported for structs at the moment. '%s' ignored.", - qPrintable(blockMember.name)); - continue; - } registerUniformIfActive(blockMember, prefix, ub.binding, 0, program, dst); } } diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index 4a98011d3d..d4f1336c3e 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -252,6 +252,7 @@ struct QGles2UniformDescription int binding; uint offset; int size; + int arrayDim; }; Q_DECLARE_TYPEINFO(QGles2UniformDescription, Q_MOVABLE_TYPE); -- cgit v1.2.3 From 656d6f2a9b221dbd5adfc46262cb243e696d8d62 Mon Sep 17 00:00:00 2001 From: Milian Wolff <milian.wolff@kdab.com> Date: Fri, 12 Apr 2019 13:21:44 +0200 Subject: Support Q_GADGET QMetaObject super class hierarchies across templates This patch fixes the QMetaObject::superClass hierarchy for Q_GADGETs that inherit from a template which in turn inherits another Q_GADGET. One common scenario where this is applied is for the CRTP. Without this patch, moc would stop at the template and then sets the superClass QMetaObject to a nullptr. For QObjects this works, since there moc knows that every child must by definition inherit QObject. In order to support this for Q_GADGETs too, we defer the judgment about the availability of a staticMetaObject in the base class to compile time through the existing QtPrivate::MetaObjectForType<Base>::value() helper. [ChangeLog][QtCore][moc] Moc now correctly sets a non-null QMetaObject::superClass for Q_GADGETs that inherit from a template which inherits another Q_GADGET. Change-Id: I103b5efd74ed24172dffce477ca2ed6d0f374d44 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> --- src/tools/moc/generator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 553e16d472..9029bf9008 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -541,8 +541,10 @@ void Generator::generateCode() if (isQObject) fprintf(out, " nullptr,\n"); - else if (cdef->superclassList.size() && (!cdef->hasQGadget || knownGadgets.contains(purestSuperClass))) + else if (cdef->superclassList.size() && !cdef->hasQGadget) // for qobject, we know the super class must have a static metaobject fprintf(out, " QMetaObject::SuperData::link<%s::staticMetaObject>(),\n", purestSuperClass.constData()); + else if (cdef->superclassList.size()) // for gadgets we need to query at compile time for it + fprintf(out, " QtPrivate::MetaObjectForType<%s>::value(),\n", purestSuperClass.constData()); else fprintf(out, " nullptr,\n"); fprintf(out, " qt_meta_stringdata_%s.data,\n" -- cgit v1.2.3 From 026a8ec802361de4080b738db2bf6db85e047f76 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Tue, 10 Dec 2019 13:18:21 +0100 Subject: Move QOpenGLTimerQuery to from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: Ic8ef0a814700b2ed76b661d560907ad498334231 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/opengl/opengl.pri | 7 +- src/gui/opengl/qopenglqueryhelper_p.h | 186 ------- src/gui/opengl/qopengltimerquery.cpp | 880 ---------------------------------- src/gui/opengl/qopengltimerquery.h | 116 ----- src/opengl/opengl.pro | 8 + src/opengl/qopenglqueryhelper_p.h | 186 +++++++ src/opengl/qopengltimerquery.cpp | 880 ++++++++++++++++++++++++++++++++++ src/opengl/qopengltimerquery.h | 116 +++++ 8 files changed, 1192 insertions(+), 1187 deletions(-) delete mode 100644 src/gui/opengl/qopenglqueryhelper_p.h delete mode 100644 src/gui/opengl/qopengltimerquery.cpp delete mode 100644 src/gui/opengl/qopengltimerquery.h create mode 100644 src/opengl/qopenglqueryhelper_p.h create mode 100644 src/opengl/qopengltimerquery.cpp create mode 100644 src/opengl/qopengltimerquery.h (limited to 'src') diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index 9eab55f112..26060ea5df 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -85,9 +85,7 @@ qtConfig(opengl) { opengl/qopenglfunctions_4_2_compatibility.h \ opengl/qopenglfunctions_4_3_compatibility.h \ opengl/qopenglfunctions_4_4_compatibility.h \ - opengl/qopenglfunctions_4_5_compatibility.h \ - opengl/qopenglqueryhelper_p.h \ - opengl/qopengltimerquery.h + opengl/qopenglfunctions_4_5_compatibility.h SOURCES += opengl/qopenglfunctions_1_0.cpp \ opengl/qopenglfunctions_1_1.cpp \ @@ -114,8 +112,7 @@ qtConfig(opengl) { opengl/qopenglfunctions_4_2_compatibility.cpp \ opengl/qopenglfunctions_4_3_compatibility.cpp \ opengl/qopenglfunctions_4_4_compatibility.cpp \ - opengl/qopenglfunctions_4_5_compatibility.cpp \ - opengl/qopengltimerquery.cpp + opengl/qopenglfunctions_4_5_compatibility.cpp } qtConfig(opengles2) { diff --git a/src/gui/opengl/qopenglqueryhelper_p.h b/src/gui/opengl/qopenglqueryhelper_p.h deleted file mode 100644 index ad91ca9f96..0000000000 --- a/src/gui/opengl/qopenglqueryhelper_p.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLQUERYHELPER_P_H -#define QOPENGLQUERYHELPER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtGui/private/qtguiglobal_p.h> - -#if !defined(QT_OPENGL_ES_2) - -#include <QtGui/QOpenGLContext> - -QT_BEGIN_NAMESPACE - -// Helper class used by QOpenGLTimerQuery and later will be used by -// QOpenGLOcclusionQuery -class QOpenGLQueryHelper -{ -public: - QOpenGLQueryHelper(QOpenGLContext *context) - : GetQueryObjectuiv(nullptr), - GetQueryObjectiv(nullptr), - GetQueryiv(nullptr), - EndQuery(nullptr), - BeginQuery(nullptr), - IsQuery(nullptr), - DeleteQueries(nullptr), - GenQueries(nullptr), - GetInteger64v(nullptr), - GetQueryObjectui64v(nullptr), - GetQueryObjecti64v(nullptr), - QueryCounter(nullptr) - { - Q_ASSERT(context); - - // Core in OpenGL >=1.5 - GetQueryObjectuiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint *)>(context->getProcAddress("glGetQueryObjectuiv")); - GetQueryObjectiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint *)>(context->getProcAddress("glGetQueryObjectiv")); - GetQueryiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint *)>(context->getProcAddress("glGetQueryiv")); - EndQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum )>(context->getProcAddress("glEndQuery")); - BeginQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLuint )>(context->getProcAddress("glBeginQuery")); - IsQuery = reinterpret_cast<GLboolean (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress("glIsQuery")); - DeleteQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress("glDeleteQueries")); - GenQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress("glGenQueries")); - - // Core in OpenGL >=3.2 - GetInteger64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint64 *)>(context->getProcAddress("glGetInteger64v")); - - // Core in OpenGL >=3.3 / ARB_timer_query - GetQueryObjectui64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint64 *)>(context->getProcAddress("glGetQueryObjectui64v")); - GetQueryObjecti64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint64 *)>(context->getProcAddress("glGetQueryObjecti64v")); - QueryCounter = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum )>(context->getProcAddress("glQueryCounter")); - } - - inline void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) - { - GetQueryObjectuiv(id, pname, params); - } - - inline void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) - { - GetQueryObjectiv(id, pname, params); - } - - inline void glGetQueryiv(GLenum target, GLenum pname, GLint *params) - { - GetQueryiv(target, pname, params); - } - - inline void glEndQuery(GLenum target) - { - EndQuery(target); - } - - inline void glBeginQuery(GLenum target, GLuint id) - { - BeginQuery(target, id); - } - - inline GLboolean glIsQuery(GLuint id) - { - return IsQuery(id); - } - - inline void glDeleteQueries(GLsizei n, const GLuint *ids) - { - DeleteQueries(n, ids); - } - - inline void glGenQueries(GLsizei n, GLuint *ids) - { - GenQueries(n, ids); - } - - inline void glGetInteger64v(GLenum pname, GLint64 *params) - { - GetInteger64v(pname, params); - } - - inline void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) - { - GetQueryObjectui64v(id, pname, params); - } - - inline void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) - { - GetQueryObjecti64v(id, pname, params); - } - - inline void glQueryCounter(GLuint id, GLenum target) - { - QueryCounter(id, target); - } - -private: - // Core in OpenGL >=1.5 - void (QOPENGLF_APIENTRYP GetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params); - void (QOPENGLF_APIENTRYP GetQueryObjectiv)(GLuint id, GLenum pname, GLint *params); - void (QOPENGLF_APIENTRYP GetQueryiv)(GLenum target, GLenum pname, GLint *params); - void (QOPENGLF_APIENTRYP EndQuery)(GLenum target); - void (QOPENGLF_APIENTRYP BeginQuery)(GLenum target, GLuint id); - GLboolean (QOPENGLF_APIENTRYP IsQuery)(GLuint id); - void (QOPENGLF_APIENTRYP DeleteQueries)(GLsizei n, const GLuint *ids); - void (QOPENGLF_APIENTRYP GenQueries)(GLsizei n, GLuint *ids); - - // Core in OpenGL >=3.2 - void (QOPENGLF_APIENTRYP GetInteger64v)(GLenum pname, GLint64 *params); - - // Core in OpenGL >=3.3 and provided by ARB_timer_query - void (QOPENGLF_APIENTRYP GetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 *params); - void (QOPENGLF_APIENTRYP GetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 *params); - void (QOPENGLF_APIENTRYP QueryCounter)(GLuint id, GLenum target); -}; - -QT_END_NAMESPACE - -#endif - -#endif // QOPENGLQUERYHELPER_P_H diff --git a/src/gui/opengl/qopengltimerquery.cpp b/src/gui/opengl/qopengltimerquery.cpp deleted file mode 100644 index a4e10b42f7..0000000000 --- a/src/gui/opengl/qopengltimerquery.cpp +++ /dev/null @@ -1,880 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopengltimerquery.h" - -#include "qopenglqueryhelper_p.h" -#include <QtCore/private/qobject_p.h> -#include <QtGui/QOpenGLContext> -#include <QtGui/QOpenGLFunctions> - -QT_BEGIN_NAMESPACE - -// Helper class used as fallback if OpenGL <3.3 is being used with EXT_timer_query -class QExtTimerQueryHelper -{ -public: - QExtTimerQueryHelper(QOpenGLContext *context) - { - Q_ASSERT(context); - GetQueryObjectui64vEXT = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint64EXT *)>(context->getProcAddress("glGetQueryObjectui64vEXT")); - GetQueryObjecti64vEXT = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint64EXT *)>(context->getProcAddress("glGetQueryObjecti64vEXT")); - } - - inline void glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) - { - GetQueryObjectui64vEXT(id, pname, params); - } - - inline void glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) - { - GetQueryObjecti64vEXT(id, pname, params); - } - -private: - void (QOPENGLF_APIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT *params); - void (QOPENGLF_APIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT *params); -}; - -class QOpenGLTimerQueryPrivate : public QObjectPrivate -{ -public: - QOpenGLTimerQueryPrivate() - : QObjectPrivate(), - context(nullptr), - ext(nullptr), - timeInterval(0), - timer(0) - { - } - - ~QOpenGLTimerQueryPrivate() - { - delete core; - delete ext; - } - - bool create(); - void destroy(); - void begin(); - void end(); - GLuint64 waitForTimeStamp() const; - void recordTimestamp(); - bool isResultAvailable() const; - GLuint64 result() const; - - // There are several cases we must handle: - // OpenGL >=3.3 includes timer queries as a core feature - // ARB_timer_query has same functionality as above. Requires OpenGL 3.2 - // EXT_timer_query offers limited support. Can be used with OpenGL >=1.5 - // - // Note that some implementations (OS X) provide OpenGL 3.2 but do not expose the - // ARB_timer_query extension. In such situations we must also be able to handle - // using the EXT_timer_query extension with any version of OpenGL. - // - // OpenGL 1.5 or above contains the generic query API and OpenGL 3.3 and - // ARB_timer_query provide the 64-bit query API. These are wrapped by - // QOpenGLQueryHelper. All we need to handle in addition is the EXT_timer_query - // case and to take care not to call the Core/ARB functions when we only - // have EXT_timer_query available. - QOpenGLContext *context; - QOpenGLQueryHelper *core; - QExtTimerQueryHelper *ext; - mutable GLuint64 timeInterval; - GLuint timer; -}; - -bool QOpenGLTimerQueryPrivate::create() -{ - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - - if (timer && context == ctx) - return true; - - context = ctx; - if (!context) { - qWarning("A current OpenGL context is required to create timer query objects"); - return false; - } - - if (context->isOpenGLES()) { - qWarning("QOpenGLTimerQuery: Not supported on OpenGL ES"); - return false; - } - - // Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query - core = new QOpenGLQueryHelper(context); - - // Check to see if we also need to resolve the functions for EXT_timer_query - QSurfaceFormat f = context->format(); - if (f.version() <= qMakePair<int, int>(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - ext = new QExtTimerQueryHelper(context); - } else if (f.version() <= qMakePair<int, int>(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && !context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - qWarning("QOpenGLTimerQuery requires one of:\n" - " OpenGL 3.3 or newer,\n" - " OpenGL 3.2 and the ARB_timer_query extension\n" - " or the EXT_timer query extension"); - return false; - } - - core->glGenQueries(1, &timer); - return (timer != 0); -} - -void QOpenGLTimerQueryPrivate::destroy() -{ - if (!timer) - return; - - core->glDeleteQueries(1, &timer); - timer = 0; - context = nullptr; -} - -// GL_TIME_ELAPSED_EXT is not defined on OS X 10.6 -#if !defined(GL_TIME_ELAPSED_EXT) -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -// GL_TIME_ELAPSED is not defined on OS X 10.7 or 10.8 yet -#if !defined(GL_TIME_ELAPSED) -#define GL_TIME_ELAPSED GL_TIME_ELAPSED_EXT -#endif - -void QOpenGLTimerQueryPrivate::begin() -{ - core->glBeginQuery(GL_TIME_ELAPSED, timer); -} - -void QOpenGLTimerQueryPrivate::end() -{ - core->glEndQuery(GL_TIME_ELAPSED); -} - -void QOpenGLTimerQueryPrivate::recordTimestamp() -{ - // Don't call glQueryCounter if we only have EXT_timer_query -#if defined(GL_TIMESTAMP) - if (!ext) - core->glQueryCounter(timer, GL_TIMESTAMP); - else - qWarning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#else - qWarning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#endif -} - -GLuint64 QOpenGLTimerQueryPrivate::waitForTimeStamp() const -{ - GLint64 tmp = 0; -#if defined(GL_TIMESTAMP) - if (!ext) - core->glGetInteger64v(GL_TIMESTAMP, &tmp); - else - qWarning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#else - qWarning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); -#endif - GLuint64 timestamp(tmp); - return timestamp; -} - -bool QOpenGLTimerQueryPrivate::isResultAvailable() const -{ - GLuint available = GL_FALSE; - core->glGetQueryObjectuiv(timer, GL_QUERY_RESULT_AVAILABLE, &available); - return available; -} - -GLuint64 QOpenGLTimerQueryPrivate::result() const -{ - if (!ext) - core->glGetQueryObjectui64v(timer, GL_QUERY_RESULT, &timeInterval); - else - ext->glGetQueryObjectui64vEXT(timer, GL_QUERY_RESULT, &timeInterval); - return timeInterval; -} - -/*! - \class QOpenGLTimerQuery - \brief The QOpenGLTimerQuery class wraps an OpenGL timer query object. - \inmodule QtGui - \since 5.1 - \ingroup painting-3D - - OpenGL timer query objects are OpenGL managed resources to measure the - execution times of sequences of OpenGL commands on the GPU. - - OpenGL offers various levels of support for timer queries, depending on - the version of OpenGL you have and the presence of the ARB_timer_query or - EXT_timer_query extensions. The support can be summarized as: - - \list - \li OpenGL >=3.3 offers full support for all timer query functionality. - \li OpenGL 3.2 with the ARB_timer_query extension offers full support - for all timer query functionality. - \li OpenGL <=3.2 with the EXT_timer_query extension offers limited support - in that the timestamp of the GPU cannot be queried. Places where this - impacts functions provided by Qt classes will be highlighted in the - function documentation. - \li OpenGL ES 2 (and OpenGL ES 3) do not provide any support for OpenGL - timer queries. - \endlist - - OpenGL represents time with a granularity of 1 nanosecond (1e-9 seconds). As a - consequence of this, 32-bit integers would only give a total possible duration - of approximately 4 seconds, which would not be difficult to exceed in poorly - performing or lengthy operations. OpenGL therefore uses 64 bit integer types - to represent times. A GLuint64 variable has enough width to contain a duration - of hundreds of years, which is plenty for real-time rendering needs. - - As with the other Qt OpenGL classes, QOpenGLTimerQuery has a create() - function to create the underlying OpenGL object. This is to allow the developer to - ensure that there is a valid current OpenGL context at the time. - - Once created, timer queries can be issued in one of several ways. The simplest - method is to delimit a block of commands with calls to begin() and end(). This - instructs OpenGL to measure the time taken from completing all commands issued - prior to begin() until the completion of all commands issued prior to end(). - - At the end of a frame we can retrieve the results by calling waitForResult(). - As this function's name implies, it blocks CPU execution until OpenGL notifies - that the timer query result is available. To avoid blocking, you can check - if the query result is available by calling isResultAvailable(). Note that - modern GPUs are deeply pipelined and query results may not become available for - between 1-5 frames after they were issued. - - Note that OpenGL does not permit nesting or interleaving of multiple timer queries - using begin() and end(). Using multiple timer queries and recordTimestamp() avoids - this limitation. When using recordTimestamp() the result can be obtained at - some later time using isResultAvailable() and waitForResult(). Qt provides the - convenience class QOpenGLTimeMonitor that helps with using multiple query objects. - - \sa QOpenGLTimeMonitor -*/ - -/*! - Creates a QOpenGLTimerQuery instance with the given \a parent. You must call create() - with a valid OpenGL context before using. -*/ -QOpenGLTimerQuery::QOpenGLTimerQuery(QObject *parent) - : QObject(*new QOpenGLTimerQueryPrivate, parent) -{ -} - -/*! - Destroys the QOpenGLTimerQuery and the underlying OpenGL resource. -*/ -QOpenGLTimerQuery::~QOpenGLTimerQuery() -{ - QOpenGLContext* ctx = QOpenGLContext::currentContext(); - - Q_D(QOpenGLTimerQuery); - QOpenGLContext *oldContext = nullptr; - if (d->context != ctx) { - oldContext = ctx; - if (d->context->makeCurrent(oldContext->surface())) { - ctx = d->context; - } else { - qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current"); - ctx = nullptr; - } - } - - if (ctx) - destroy(); - - if (oldContext) { - if (!oldContext->makeCurrent(oldContext->surface())) - qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to restore current context"); - } -} - -/*! - Creates the underlying OpenGL timer query object. There must be a valid OpenGL context - that supports query objects current for this function to succeed. - - Returns \c true if the OpenGL timer query object was successfully created. -*/ -bool QOpenGLTimerQuery::create() -{ - Q_D(QOpenGLTimerQuery); - return d->create(); -} - -/*! - Destroys the underlying OpenGL timer query object. The context that was current when - create() was called must be current when calling this function. -*/ -void QOpenGLTimerQuery::destroy() -{ - Q_D(QOpenGLTimerQuery); - d->destroy(); -} - -/*! - Returns \c true if the underlying OpenGL query object has been created. If this - returns \c true and the associated OpenGL context is current, then you are able to issue - queries with this object. -*/ -bool QOpenGLTimerQuery::isCreated() const -{ - Q_D(const QOpenGLTimerQuery); - return (d->timer != 0); -} - -/*! - Returns the id of the underlying OpenGL query object. -*/ -GLuint QOpenGLTimerQuery::objectId() const -{ - Q_D(const QOpenGLTimerQuery); - return d->timer; -} - -/*! - Marks the start point in the OpenGL command queue for a sequence of commands to - be timed by this query object. - - This is useful for simple use-cases. Usually it is better to use recordTimestamp(). - - \sa end(), isResultAvailable(), waitForResult(), recordTimestamp() -*/ -void QOpenGLTimerQuery::begin() -{ - Q_D(QOpenGLTimerQuery); - d->begin(); -} - -/*! - Marks the end point in the OpenGL command queue for a sequence of commands to - be timed by this query object. - - This is useful for simple use-cases. Usually it is better to use recordTimestamp(). - - \sa begin(), isResultAvailable(), waitForResult(), recordTimestamp() -*/ -void QOpenGLTimerQuery::end() -{ - Q_D(QOpenGLTimerQuery); - d->end(); -} - -/*! - Places a marker in the OpenGL command queue for the GPU to record the timestamp - when this marker is reached by the GPU. This function is non-blocking and the - result will become available at some later time. - - The availability of the result can be checked with isResultAvailable(). The result - can be fetched with waitForResult() which will block if the result is not yet - available. - - \sa waitForResult(), isResultAvailable(), begin(), end() -*/ -void QOpenGLTimerQuery::recordTimestamp() -{ - Q_D(QOpenGLTimerQuery); - return d->recordTimestamp(); -} - -/*! - Returns the current timestamp of the GPU when all previously issued OpenGL - commands have been received but not necessarily executed by the GPU. - - This function blocks until the result is returned. - - \sa recordTimestamp() -*/ -GLuint64 QOpenGLTimerQuery::waitForTimestamp() const -{ - Q_D(const QOpenGLTimerQuery); - return d->waitForTimeStamp(); -} - -/*! - Returns \c true if the OpenGL timer query result is available. - - This function is non-blocking and ideally should be used to check for the - availability of the query result before calling waitForResult(). - - \sa waitForResult() -*/ -bool QOpenGLTimerQuery::isResultAvailable() const -{ - Q_D(const QOpenGLTimerQuery); - return d->isResultAvailable(); -} - -/*! - Returns the result of the OpenGL timer query. - - This function will block until the result is made available by OpenGL. It is - recommended to call isResultAvailable() to ensure that the result is available - to avoid unnecessary blocking and stalling. - - \sa isResultAvailable() -*/ -GLuint64 QOpenGLTimerQuery::waitForResult() const -{ - Q_D(const QOpenGLTimerQuery); - return d->result(); -} - - -class QOpenGLTimeMonitorPrivate : public QObjectPrivate -{ -public: - QOpenGLTimeMonitorPrivate() - : QObjectPrivate(), - timers(), - timeSamples(), - context(nullptr), - core(nullptr), - ext(nullptr), - requestedSampleCount(2), - currentSample(-1), - timerQueryActive(false) - { - } - - ~QOpenGLTimeMonitorPrivate() - { - delete core; - delete ext; - } - - bool create(); - void destroy(); - void recordSample(); - bool isResultAvailable() const; - QVector<GLuint64> samples() const; - QVector<GLuint64> intervals() const; - void reset(); - - QVector<GLuint> timers; - mutable QVector<GLuint64> timeSamples; - - QOpenGLContext *context; - QOpenGLQueryHelper *core; - QExtTimerQueryHelper *ext; - - int requestedSampleCount; - int currentSample; - mutable bool timerQueryActive; -}; - -bool QOpenGLTimeMonitorPrivate::create() -{ - if (!timers.isEmpty() && timers.at(0) != 0 && timers.size() == requestedSampleCount) - return true; - - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - if (context && context != ctx) { - qWarning("QTimeMonitor: Attempting to use different OpenGL context to recreate timers.\n" - "Please call destroy() first or use the same context to previously create"); - return false; - } - - context = ctx; - if (!context) { - qWarning("A current OpenGL context is required to create timer query objects"); - return false; - } - - // Resize the vectors that hold the timers and the recorded samples - timers.resize(requestedSampleCount); - timeSamples.resize(requestedSampleCount); - - // Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query - core = new QOpenGLQueryHelper(context); - - // Check to see if we also need to resolve the functions for EXT_timer_query - QSurfaceFormat f = context->format(); - if (f.version() <= qMakePair<int, int>(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - ext = new QExtTimerQueryHelper(context); - } else if (f.version() <= qMakePair<int, int>(3, 2) - && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) - && !context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { - qWarning("QOpenGLTimeMonitor requires one of:\n" - " OpenGL 3.3 or newer,\n" - " OpenGL 3.2 and the ARB_timer_query extension\n" - " or the EXT_timer query extension"); - return false; - } - - core->glGenQueries(requestedSampleCount, timers.data()); - return (timers.at(0) != 0); -} - -void QOpenGLTimeMonitorPrivate::destroy() -{ - if (timers.isEmpty() || timers.at(0) == 0) - return; - - core->glDeleteQueries(timers.size(), timers.data()); - timers.clear(); - delete core; - core = nullptr; - delete ext; - ext = nullptr; - context = nullptr; -} - -void QOpenGLTimeMonitorPrivate::recordSample() -{ - // Use glQueryCounter() and GL_TIMESTAMP where available. - // Otherwise, simulate it with glBeginQuery()/glEndQuery() - if (!ext) { -#if defined(GL_TIMESTAMP) - core->glQueryCounter(timers.at(++currentSample), GL_TIMESTAMP); -#endif - } else { - if (currentSample == -1) { - core->glBeginQuery(GL_TIME_ELAPSED_EXT, timers.at(++currentSample)); - timerQueryActive = true; - } else if (currentSample < timers.size() - 1) { - core->glEndQuery(GL_TIME_ELAPSED_EXT); - core->glBeginQuery(GL_TIME_ELAPSED_EXT, timers.at(++currentSample)); - } else { - if (timerQueryActive) { - core->glEndQuery(GL_TIME_ELAPSED_EXT); - timerQueryActive = false; - } - } - } -} - -bool QOpenGLTimeMonitorPrivate::isResultAvailable() const -{ - // The OpenGL spec says that if a query result is ready then the results of all queries - // of the same type issued before it must also be ready. Therefore we only need to check - // the availability of the result for the last issued query - GLuint available = GL_FALSE; - core->glGetQueryObjectuiv(timers.at(currentSample), GL_QUERY_RESULT_AVAILABLE, &available); - return available; -} - -QVector<GLuint64> QOpenGLTimeMonitorPrivate::samples() const -{ - // For the Core and ARB options just ask for the timestamp for each timer query. - // For the EXT implementation we cannot obtain timestamps so we defer any result - // collection to the intervals() function - if (!ext) { - for (int i = 0; i <= currentSample; ++i) - core->glGetQueryObjectui64v(timers.at(i), GL_QUERY_RESULT, &timeSamples[i]); - } else { - qWarning("QOpenGLTimeMonitor::samples() requires OpenGL >=3.3\n" - "or OpenGL 3.2 and GL_ARB_timer_query"); - } - return timeSamples; -} - -QVector<GLuint64> QOpenGLTimeMonitorPrivate::intervals() const -{ - QVector<GLuint64> intervals(timers.size() - 1); - if (!ext) { - // Obtain the timestamp samples and calculate the interval durations - const QVector<GLuint64> timeStamps = samples(); - for (int i = 0; i < intervals.size(); ++i) - intervals[i] = timeStamps[i+1] - timeStamps[i]; - } else { - // Stop the last timer if needed - if (timerQueryActive) { - core->glEndQuery(GL_TIME_ELAPSED_EXT); - timerQueryActive = false; - } - - // Obtain the results from all timers apart from the redundant last one. In this - // case the results actually are the intervals not timestamps - for (int i = 0; i < currentSample; ++i) - ext->glGetQueryObjectui64vEXT(timers.at(i), GL_QUERY_RESULT, &intervals[i]); - } - - return intervals; -} - -void QOpenGLTimeMonitorPrivate::reset() -{ - currentSample = -1; - timeSamples.fill(0); -} - - -/*! - \class QOpenGLTimeMonitor - \brief The QOpenGLTimeMonitor class wraps a sequence of OpenGL timer query objects. - \inmodule QtGui - \since 5.1 - \ingroup painting-3D - - The QOpenGLTimeMonitor class is a convenience wrapper around a collection of OpenGL - timer query objects used to measure intervals of time on the GPU to the level of - granularity required by your rendering application. - - The OpenGL timer queries objects are queried in sequence to record the GPU - timestamps at positions of interest in your rendering code. Once the results for - all issues timer queries become available, the results can be fetched and - QOpenGLTimerMonitor will calculate the recorded time intervals for you. - - The typical use case of this class is to either profile your application's rendering - algorithms or to adjust those algorithms in real-time for dynamic performance/quality - balancing. - - Prior to using QOpenGLTimeMonitor in your rendering function you should set the - required number of sample points that you wish to record by calling setSamples(). Note - that measuring N sample points will produce N-1 time intervals. Once you have set the - number of sample points, call the create() function with a valid current OpenGL context - to create the necessary query timer objects. These steps are usually performed just - once in an initialization function. - - Use the recordSample() function to delimit blocks of code containing OpenGL commands - that you wish to time. You can check availability of the resulting time - samples and time intervals with isResultAvailable(). The calculated time intervals and - the raw timestamp samples can be retrieved with the blocking waitForIntervals() and - waitForSamples() functions respectively. - - After retrieving the results and before starting a new round of taking samples - (for example, in the next frame) be sure to call the reset() function which will clear - the cached results and reset the timer index back to the first timer object. - - \sa QOpenGLTimerQuery -*/ - -/*! - Creates a QOpenGLTimeMonitor instance with the given \a parent. You must call create() - with a valid OpenGL context before using. - - \sa setSampleCount(), create() -*/ -QOpenGLTimeMonitor::QOpenGLTimeMonitor(QObject *parent) - : QObject(*new QOpenGLTimeMonitorPrivate, parent) -{ -} - -/*! - Destroys the QOpenGLTimeMonitor and any underlying OpenGL resources. -*/ -QOpenGLTimeMonitor::~QOpenGLTimeMonitor() -{ - QOpenGLContext* ctx = QOpenGLContext::currentContext(); - - Q_D(QOpenGLTimeMonitor); - QOpenGLContext *oldContext = nullptr; - if (d->context != ctx) { - oldContext = ctx; - if (d->context->makeCurrent(oldContext->surface())) { - ctx = d->context; - } else { - qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current"); - ctx = nullptr; - } - } - - if (ctx) - destroy(); - - if (oldContext) { - if (!oldContext->makeCurrent(oldContext->surface())) - qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to restore current context"); - } -} - -/*! - Sets the number of sample points to \a sampleCount. After setting the number - of samples with this function, you must call create() to instantiate the underlying - OpenGL timer query objects. - - The new \a sampleCount must be at least 2. - - \sa sampleCount(), create(), recordSample() -*/ -void QOpenGLTimeMonitor::setSampleCount(int sampleCount) -{ - // We need at least 2 samples to get an interval - if (sampleCount < 2) - return; - Q_D(QOpenGLTimeMonitor); - d->requestedSampleCount = sampleCount; -} - -/*! - Returns the number of sample points that have been requested with - setSampleCount(). If create was successfully called following setSampleCount(), - then the value returned will be the actual number of sample points - that can be used. - - The default value for sample count is 2, leading to the measurement of a - single interval. - - \sa setSampleCount() -*/ -int QOpenGLTimeMonitor::sampleCount() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->requestedSampleCount; -} - -/*! - Instantiate sampleCount() OpenGL timer query objects that will be used - to track the amount of time taken to execute OpenGL commands between - successive calls to recordSample(). - - Returns \c true if the OpenGL timer query objects could be created. - - \sa destroy(), setSampleCount(), recordSample() -*/ -bool QOpenGLTimeMonitor::create() -{ - Q_D(QOpenGLTimeMonitor); - return d->create(); -} - -/*! - Destroys any OpenGL timer query objects used within this instance. - - \sa create() -*/ -void QOpenGLTimeMonitor::destroy() -{ - Q_D(QOpenGLTimeMonitor); - d->destroy(); -} - -/*! - Returns \c true if the underlying OpenGL query objects have been created. If this - returns \c true and the associated OpenGL context is current, then you are able to record - time samples with this object. -*/ -bool QOpenGLTimeMonitor::isCreated() const -{ - Q_D(const QOpenGLTimeMonitor); - return (!d->timers.isEmpty() && d->timers.at(0) != 0); -} - -/*! - Returns a QVector containing the object Ids of the OpenGL timer query objects. -*/ -QVector<GLuint> QOpenGLTimeMonitor::objectIds() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->timers; -} - -/*! - Issues an OpenGL timer query at this point in the OpenGL command queue. Calling this - function in a sequence in your application's rendering function, will build up - details of the GPU time taken to execute the OpenGL commands between successive - calls to this function. - - \sa setSampleCount(), isResultAvailable(), waitForSamples(), waitForIntervals() -*/ -int QOpenGLTimeMonitor::recordSample() -{ - Q_D(QOpenGLTimeMonitor); - d->recordSample(); - return d->currentSample; -} - -/*! - Returns \c true if the OpenGL timer query results are available. - - \sa waitForSamples(), waitForIntervals() -*/ -bool QOpenGLTimeMonitor::isResultAvailable() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->isResultAvailable(); -} - -/*! - Returns a QVector containing the GPU timestamps taken with recordSample(). - - This function will block until OpenGL indicates the results are available. It - is recommended to check the availability of the result prior to calling this - function with isResultAvailable(). - - \note This function only works on systems that have OpenGL >=3.3 or the - ARB_timer_query extension. See QOpenGLTimerQuery for more details. - - \sa waitForIntervals(), isResultAvailable() -*/ -QVector<GLuint64> QOpenGLTimeMonitor::waitForSamples() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->samples(); -} - -/*! - Returns a QVector containing the time intervals delimited by the calls to - recordSample(). The resulting vector will contain one fewer element as - this represents the intervening intervals rather than the actual timestamp - samples. - - This function will block until OpenGL indicates the results are available. It - is recommended to check the availability of the result prior to calling this - function with isResultAvailable(). - - \sa waitForSamples(), isResultAvailable() -*/ -QVector<GLuint64> QOpenGLTimeMonitor::waitForIntervals() const -{ - Q_D(const QOpenGLTimeMonitor); - return d->intervals(); -} - -/*! - Resets the time monitor ready for use in another frame of rendering. Call - this once you have obtained the previous results and before calling - recordSample() for the first time on the next frame. - - \sa recordSample() -*/ -void QOpenGLTimeMonitor::reset() -{ - Q_D(QOpenGLTimeMonitor); - d->reset(); -} - -QT_END_NAMESPACE diff --git a/src/gui/opengl/qopengltimerquery.h b/src/gui/opengl/qopengltimerquery.h deleted file mode 100644 index 27da74a3fb..0000000000 --- a/src/gui/opengl/qopengltimerquery.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLTIMERQUERY_H -#define QOPENGLTIMERQUERY_H - -#include <QtGui/qtguiglobal.h> - -#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) - -#include <QtCore/QObject> -#include <QtGui/qopengl.h> - -QT_BEGIN_NAMESPACE - -class QOpenGLTimerQueryPrivate; - -class Q_GUI_EXPORT QOpenGLTimerQuery : public QObject -{ - Q_OBJECT - -public: - explicit QOpenGLTimerQuery(QObject *parent = nullptr); - ~QOpenGLTimerQuery(); - - bool create(); - void destroy(); - bool isCreated() const; - GLuint objectId() const; - - void begin(); - void end(); - GLuint64 waitForTimestamp() const; - void recordTimestamp(); - bool isResultAvailable() const; - GLuint64 waitForResult() const; - -private: - Q_DECLARE_PRIVATE(QOpenGLTimerQuery) - Q_DISABLE_COPY(QOpenGLTimerQuery) -}; - - -class QOpenGLTimeMonitorPrivate; - -class Q_GUI_EXPORT QOpenGLTimeMonitor : public QObject -{ - Q_OBJECT - -public: - explicit QOpenGLTimeMonitor(QObject *parent = nullptr); - ~QOpenGLTimeMonitor(); - - void setSampleCount(int sampleCount); - int sampleCount() const; - - bool create(); - void destroy(); - bool isCreated() const; - QVector<GLuint> objectIds() const; - - int recordSample(); - - bool isResultAvailable() const; - - QVector<GLuint64> waitForSamples() const; - QVector<GLuint64> waitForIntervals() const; - - void reset(); - -private: - Q_DECLARE_PRIVATE(QOpenGLTimeMonitor) - Q_DISABLE_COPY(QOpenGLTimeMonitor) -}; - -QT_END_NAMESPACE - -#endif // QT_NO_OPENGL - -#endif // QOPENGLTIMERQUERY_H diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index b9d0c6213d..820e46ed79 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -15,4 +15,12 @@ HEADERS += \ SOURCES += \ qopengldebug.cpp +!qtConfig(opengles2) { + HEADERS += \ + qopenglqueryhelper_p.h \ + qopengltimerquery.h + + SOURCES += qopengltimerquery.cpp +} + load(qt_module) diff --git a/src/opengl/qopenglqueryhelper_p.h b/src/opengl/qopenglqueryhelper_p.h new file mode 100644 index 0000000000..f3ed997f98 --- /dev/null +++ b/src/opengl/qopenglqueryhelper_p.h @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGLQUERYHELPER_P_H +#define QOPENGLQUERYHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qtguiglobal_p.h> + +#if !defined(QT_OPENGL_ES_2) + +#include <QtGui/QOpenGLContext> + +QT_BEGIN_NAMESPACE + +// Helper class used by QOpenGLTimerQuery and later will be used by +// QOpenGLOcclusionQuery +class QOpenGLQueryHelper +{ +public: + QOpenGLQueryHelper(QOpenGLContext *context) + : GetQueryObjectuiv(nullptr), + GetQueryObjectiv(nullptr), + GetQueryiv(nullptr), + EndQuery(nullptr), + BeginQuery(nullptr), + IsQuery(nullptr), + DeleteQueries(nullptr), + GenQueries(nullptr), + GetInteger64v(nullptr), + GetQueryObjectui64v(nullptr), + GetQueryObjecti64v(nullptr), + QueryCounter(nullptr) + { + Q_ASSERT(context); + + // Core in OpenGL >=1.5 + GetQueryObjectuiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint *)>(context->getProcAddress("glGetQueryObjectuiv")); + GetQueryObjectiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint *)>(context->getProcAddress("glGetQueryObjectiv")); + GetQueryiv = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLenum , GLint *)>(context->getProcAddress("glGetQueryiv")); + EndQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum )>(context->getProcAddress("glEndQuery")); + BeginQuery = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLuint )>(context->getProcAddress("glBeginQuery")); + IsQuery = reinterpret_cast<GLboolean (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress("glIsQuery")); + DeleteQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress("glDeleteQueries")); + GenQueries = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress("glGenQueries")); + + // Core in OpenGL >=3.2 + GetInteger64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint64 *)>(context->getProcAddress("glGetInteger64v")); + + // Core in OpenGL >=3.3 / ARB_timer_query + GetQueryObjectui64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint64 *)>(context->getProcAddress("glGetQueryObjectui64v")); + GetQueryObjecti64v = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint64 *)>(context->getProcAddress("glGetQueryObjecti64v")); + QueryCounter = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum )>(context->getProcAddress("glQueryCounter")); + } + + inline void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) + { + GetQueryObjectuiv(id, pname, params); + } + + inline void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) + { + GetQueryObjectiv(id, pname, params); + } + + inline void glGetQueryiv(GLenum target, GLenum pname, GLint *params) + { + GetQueryiv(target, pname, params); + } + + inline void glEndQuery(GLenum target) + { + EndQuery(target); + } + + inline void glBeginQuery(GLenum target, GLuint id) + { + BeginQuery(target, id); + } + + inline GLboolean glIsQuery(GLuint id) + { + return IsQuery(id); + } + + inline void glDeleteQueries(GLsizei n, const GLuint *ids) + { + DeleteQueries(n, ids); + } + + inline void glGenQueries(GLsizei n, GLuint *ids) + { + GenQueries(n, ids); + } + + inline void glGetInteger64v(GLenum pname, GLint64 *params) + { + GetInteger64v(pname, params); + } + + inline void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) + { + GetQueryObjectui64v(id, pname, params); + } + + inline void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) + { + GetQueryObjecti64v(id, pname, params); + } + + inline void glQueryCounter(GLuint id, GLenum target) + { + QueryCounter(id, target); + } + +private: + // Core in OpenGL >=1.5 + void (QOPENGLF_APIENTRYP GetQueryObjectuiv)(GLuint id, GLenum pname, GLuint *params); + void (QOPENGLF_APIENTRYP GetQueryObjectiv)(GLuint id, GLenum pname, GLint *params); + void (QOPENGLF_APIENTRYP GetQueryiv)(GLenum target, GLenum pname, GLint *params); + void (QOPENGLF_APIENTRYP EndQuery)(GLenum target); + void (QOPENGLF_APIENTRYP BeginQuery)(GLenum target, GLuint id); + GLboolean (QOPENGLF_APIENTRYP IsQuery)(GLuint id); + void (QOPENGLF_APIENTRYP DeleteQueries)(GLsizei n, const GLuint *ids); + void (QOPENGLF_APIENTRYP GenQueries)(GLsizei n, GLuint *ids); + + // Core in OpenGL >=3.2 + void (QOPENGLF_APIENTRYP GetInteger64v)(GLenum pname, GLint64 *params); + + // Core in OpenGL >=3.3 and provided by ARB_timer_query + void (QOPENGLF_APIENTRYP GetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 *params); + void (QOPENGLF_APIENTRYP GetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 *params); + void (QOPENGLF_APIENTRYP QueryCounter)(GLuint id, GLenum target); +}; + +QT_END_NAMESPACE + +#endif + +#endif // QOPENGLQUERYHELPER_P_H diff --git a/src/opengl/qopengltimerquery.cpp b/src/opengl/qopengltimerquery.cpp new file mode 100644 index 0000000000..44955d48fc --- /dev/null +++ b/src/opengl/qopengltimerquery.cpp @@ -0,0 +1,880 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qopengltimerquery.h" + +#include "qopenglqueryhelper_p.h" +#include <QtCore/private/qobject_p.h> +#include <QtGui/QOpenGLContext> +#include <QtGui/QOpenGLFunctions> + +QT_BEGIN_NAMESPACE + +// Helper class used as fallback if OpenGL <3.3 is being used with EXT_timer_query +class QExtTimerQueryHelper +{ +public: + QExtTimerQueryHelper(QOpenGLContext *context) + { + Q_ASSERT(context); + GetQueryObjectui64vEXT = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLuint64EXT *)>(context->getProcAddress("glGetQueryObjectui64vEXT")); + GetQueryObjecti64vEXT = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLint64EXT *)>(context->getProcAddress("glGetQueryObjecti64vEXT")); + } + + inline void glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params) + { + GetQueryObjectui64vEXT(id, pname, params); + } + + inline void glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params) + { + GetQueryObjecti64vEXT(id, pname, params); + } + +private: + void (QOPENGLF_APIENTRYP GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT *params); + void (QOPENGLF_APIENTRYP GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT *params); +}; + +class QOpenGLTimerQueryPrivate : public QObjectPrivate +{ +public: + QOpenGLTimerQueryPrivate() + : QObjectPrivate(), + context(nullptr), + ext(nullptr), + timeInterval(0), + timer(0) + { + } + + ~QOpenGLTimerQueryPrivate() + { + delete core; + delete ext; + } + + bool create(); + void destroy(); + void begin(); + void end(); + GLuint64 waitForTimeStamp() const; + void recordTimestamp(); + bool isResultAvailable() const; + GLuint64 result() const; + + // There are several cases we must handle: + // OpenGL >=3.3 includes timer queries as a core feature + // ARB_timer_query has same functionality as above. Requires OpenGL 3.2 + // EXT_timer_query offers limited support. Can be used with OpenGL >=1.5 + // + // Note that some implementations (OS X) provide OpenGL 3.2 but do not expose the + // ARB_timer_query extension. In such situations we must also be able to handle + // using the EXT_timer_query extension with any version of OpenGL. + // + // OpenGL 1.5 or above contains the generic query API and OpenGL 3.3 and + // ARB_timer_query provide the 64-bit query API. These are wrapped by + // QOpenGLQueryHelper. All we need to handle in addition is the EXT_timer_query + // case and to take care not to call the Core/ARB functions when we only + // have EXT_timer_query available. + QOpenGLContext *context; + QOpenGLQueryHelper *core; + QExtTimerQueryHelper *ext; + mutable GLuint64 timeInterval; + GLuint timer; +}; + +bool QOpenGLTimerQueryPrivate::create() +{ + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + + if (timer && context == ctx) + return true; + + context = ctx; + if (!context) { + qWarning("A current OpenGL context is required to create timer query objects"); + return false; + } + + if (context->isOpenGLES()) { + qWarning("QOpenGLTimerQuery: Not supported on OpenGL ES"); + return false; + } + + // Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query + core = new QOpenGLQueryHelper(context); + + // Check to see if we also need to resolve the functions for EXT_timer_query + QSurfaceFormat f = context->format(); + if (f.version() <= qMakePair<int, int>(3, 2) + && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) + && context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { + ext = new QExtTimerQueryHelper(context); + } else if (f.version() <= qMakePair<int, int>(3, 2) + && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) + && !context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { + qWarning("QOpenGLTimerQuery requires one of:\n" + " OpenGL 3.3 or newer,\n" + " OpenGL 3.2 and the ARB_timer_query extension\n" + " or the EXT_timer query extension"); + return false; + } + + core->glGenQueries(1, &timer); + return (timer != 0); +} + +void QOpenGLTimerQueryPrivate::destroy() +{ + if (!timer) + return; + + core->glDeleteQueries(1, &timer); + timer = 0; + context = nullptr; +} + +// GL_TIME_ELAPSED_EXT is not defined on OS X 10.6 +#if !defined(GL_TIME_ELAPSED_EXT) +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +// GL_TIME_ELAPSED is not defined on OS X 10.7 or 10.8 yet +#if !defined(GL_TIME_ELAPSED) +#define GL_TIME_ELAPSED GL_TIME_ELAPSED_EXT +#endif + +void QOpenGLTimerQueryPrivate::begin() +{ + core->glBeginQuery(GL_TIME_ELAPSED, timer); +} + +void QOpenGLTimerQueryPrivate::end() +{ + core->glEndQuery(GL_TIME_ELAPSED); +} + +void QOpenGLTimerQueryPrivate::recordTimestamp() +{ + // Don't call glQueryCounter if we only have EXT_timer_query +#if defined(GL_TIMESTAMP) + if (!ext) + core->glQueryCounter(timer, GL_TIMESTAMP); + else + qWarning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); +#else + qWarning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); +#endif +} + +GLuint64 QOpenGLTimerQueryPrivate::waitForTimeStamp() const +{ + GLint64 tmp = 0; +#if defined(GL_TIMESTAMP) + if (!ext) + core->glGetInteger64v(GL_TIMESTAMP, &tmp); + else + qWarning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); +#else + qWarning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query"); +#endif + GLuint64 timestamp(tmp); + return timestamp; +} + +bool QOpenGLTimerQueryPrivate::isResultAvailable() const +{ + GLuint available = GL_FALSE; + core->glGetQueryObjectuiv(timer, GL_QUERY_RESULT_AVAILABLE, &available); + return available; +} + +GLuint64 QOpenGLTimerQueryPrivate::result() const +{ + if (!ext) + core->glGetQueryObjectui64v(timer, GL_QUERY_RESULT, &timeInterval); + else + ext->glGetQueryObjectui64vEXT(timer, GL_QUERY_RESULT, &timeInterval); + return timeInterval; +} + +/*! + \class QOpenGLTimerQuery + \brief The QOpenGLTimerQuery class wraps an OpenGL timer query object. + \inmodule QtOpenGL + \since 5.1 + \ingroup painting-3D + + OpenGL timer query objects are OpenGL managed resources to measure the + execution times of sequences of OpenGL commands on the GPU. + + OpenGL offers various levels of support for timer queries, depending on + the version of OpenGL you have and the presence of the ARB_timer_query or + EXT_timer_query extensions. The support can be summarized as: + + \list + \li OpenGL >=3.3 offers full support for all timer query functionality. + \li OpenGL 3.2 with the ARB_timer_query extension offers full support + for all timer query functionality. + \li OpenGL <=3.2 with the EXT_timer_query extension offers limited support + in that the timestamp of the GPU cannot be queried. Places where this + impacts functions provided by Qt classes will be highlighted in the + function documentation. + \li OpenGL ES 2 (and OpenGL ES 3) do not provide any support for OpenGL + timer queries. + \endlist + + OpenGL represents time with a granularity of 1 nanosecond (1e-9 seconds). As a + consequence of this, 32-bit integers would only give a total possible duration + of approximately 4 seconds, which would not be difficult to exceed in poorly + performing or lengthy operations. OpenGL therefore uses 64 bit integer types + to represent times. A GLuint64 variable has enough width to contain a duration + of hundreds of years, which is plenty for real-time rendering needs. + + As with the other Qt OpenGL classes, QOpenGLTimerQuery has a create() + function to create the underlying OpenGL object. This is to allow the developer to + ensure that there is a valid current OpenGL context at the time. + + Once created, timer queries can be issued in one of several ways. The simplest + method is to delimit a block of commands with calls to begin() and end(). This + instructs OpenGL to measure the time taken from completing all commands issued + prior to begin() until the completion of all commands issued prior to end(). + + At the end of a frame we can retrieve the results by calling waitForResult(). + As this function's name implies, it blocks CPU execution until OpenGL notifies + that the timer query result is available. To avoid blocking, you can check + if the query result is available by calling isResultAvailable(). Note that + modern GPUs are deeply pipelined and query results may not become available for + between 1-5 frames after they were issued. + + Note that OpenGL does not permit nesting or interleaving of multiple timer queries + using begin() and end(). Using multiple timer queries and recordTimestamp() avoids + this limitation. When using recordTimestamp() the result can be obtained at + some later time using isResultAvailable() and waitForResult(). Qt provides the + convenience class QOpenGLTimeMonitor that helps with using multiple query objects. + + \sa QOpenGLTimeMonitor +*/ + +/*! + Creates a QOpenGLTimerQuery instance with the given \a parent. You must call create() + with a valid OpenGL context before using. +*/ +QOpenGLTimerQuery::QOpenGLTimerQuery(QObject *parent) + : QObject(*new QOpenGLTimerQueryPrivate, parent) +{ +} + +/*! + Destroys the QOpenGLTimerQuery and the underlying OpenGL resource. +*/ +QOpenGLTimerQuery::~QOpenGLTimerQuery() +{ + QOpenGLContext* ctx = QOpenGLContext::currentContext(); + + Q_D(QOpenGLTimerQuery); + QOpenGLContext *oldContext = nullptr; + if (d->context != ctx) { + oldContext = ctx; + if (d->context->makeCurrent(oldContext->surface())) { + ctx = d->context; + } else { + qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current"); + ctx = nullptr; + } + } + + if (ctx) + destroy(); + + if (oldContext) { + if (!oldContext->makeCurrent(oldContext->surface())) + qWarning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to restore current context"); + } +} + +/*! + Creates the underlying OpenGL timer query object. There must be a valid OpenGL context + that supports query objects current for this function to succeed. + + Returns \c true if the OpenGL timer query object was successfully created. +*/ +bool QOpenGLTimerQuery::create() +{ + Q_D(QOpenGLTimerQuery); + return d->create(); +} + +/*! + Destroys the underlying OpenGL timer query object. The context that was current when + create() was called must be current when calling this function. +*/ +void QOpenGLTimerQuery::destroy() +{ + Q_D(QOpenGLTimerQuery); + d->destroy(); +} + +/*! + Returns \c true if the underlying OpenGL query object has been created. If this + returns \c true and the associated OpenGL context is current, then you are able to issue + queries with this object. +*/ +bool QOpenGLTimerQuery::isCreated() const +{ + Q_D(const QOpenGLTimerQuery); + return (d->timer != 0); +} + +/*! + Returns the id of the underlying OpenGL query object. +*/ +GLuint QOpenGLTimerQuery::objectId() const +{ + Q_D(const QOpenGLTimerQuery); + return d->timer; +} + +/*! + Marks the start point in the OpenGL command queue for a sequence of commands to + be timed by this query object. + + This is useful for simple use-cases. Usually it is better to use recordTimestamp(). + + \sa end(), isResultAvailable(), waitForResult(), recordTimestamp() +*/ +void QOpenGLTimerQuery::begin() +{ + Q_D(QOpenGLTimerQuery); + d->begin(); +} + +/*! + Marks the end point in the OpenGL command queue for a sequence of commands to + be timed by this query object. + + This is useful for simple use-cases. Usually it is better to use recordTimestamp(). + + \sa begin(), isResultAvailable(), waitForResult(), recordTimestamp() +*/ +void QOpenGLTimerQuery::end() +{ + Q_D(QOpenGLTimerQuery); + d->end(); +} + +/*! + Places a marker in the OpenGL command queue for the GPU to record the timestamp + when this marker is reached by the GPU. This function is non-blocking and the + result will become available at some later time. + + The availability of the result can be checked with isResultAvailable(). The result + can be fetched with waitForResult() which will block if the result is not yet + available. + + \sa waitForResult(), isResultAvailable(), begin(), end() +*/ +void QOpenGLTimerQuery::recordTimestamp() +{ + Q_D(QOpenGLTimerQuery); + return d->recordTimestamp(); +} + +/*! + Returns the current timestamp of the GPU when all previously issued OpenGL + commands have been received but not necessarily executed by the GPU. + + This function blocks until the result is returned. + + \sa recordTimestamp() +*/ +GLuint64 QOpenGLTimerQuery::waitForTimestamp() const +{ + Q_D(const QOpenGLTimerQuery); + return d->waitForTimeStamp(); +} + +/*! + Returns \c true if the OpenGL timer query result is available. + + This function is non-blocking and ideally should be used to check for the + availability of the query result before calling waitForResult(). + + \sa waitForResult() +*/ +bool QOpenGLTimerQuery::isResultAvailable() const +{ + Q_D(const QOpenGLTimerQuery); + return d->isResultAvailable(); +} + +/*! + Returns the result of the OpenGL timer query. + + This function will block until the result is made available by OpenGL. It is + recommended to call isResultAvailable() to ensure that the result is available + to avoid unnecessary blocking and stalling. + + \sa isResultAvailable() +*/ +GLuint64 QOpenGLTimerQuery::waitForResult() const +{ + Q_D(const QOpenGLTimerQuery); + return d->result(); +} + + +class QOpenGLTimeMonitorPrivate : public QObjectPrivate +{ +public: + QOpenGLTimeMonitorPrivate() + : QObjectPrivate(), + timers(), + timeSamples(), + context(nullptr), + core(nullptr), + ext(nullptr), + requestedSampleCount(2), + currentSample(-1), + timerQueryActive(false) + { + } + + ~QOpenGLTimeMonitorPrivate() + { + delete core; + delete ext; + } + + bool create(); + void destroy(); + void recordSample(); + bool isResultAvailable() const; + QVector<GLuint64> samples() const; + QVector<GLuint64> intervals() const; + void reset(); + + QVector<GLuint> timers; + mutable QVector<GLuint64> timeSamples; + + QOpenGLContext *context; + QOpenGLQueryHelper *core; + QExtTimerQueryHelper *ext; + + int requestedSampleCount; + int currentSample; + mutable bool timerQueryActive; +}; + +bool QOpenGLTimeMonitorPrivate::create() +{ + if (!timers.isEmpty() && timers.at(0) != 0 && timers.size() == requestedSampleCount) + return true; + + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (context && context != ctx) { + qWarning("QTimeMonitor: Attempting to use different OpenGL context to recreate timers.\n" + "Please call destroy() first or use the same context to previously create"); + return false; + } + + context = ctx; + if (!context) { + qWarning("A current OpenGL context is required to create timer query objects"); + return false; + } + + // Resize the vectors that hold the timers and the recorded samples + timers.resize(requestedSampleCount); + timeSamples.resize(requestedSampleCount); + + // Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query + core = new QOpenGLQueryHelper(context); + + // Check to see if we also need to resolve the functions for EXT_timer_query + QSurfaceFormat f = context->format(); + if (f.version() <= qMakePair<int, int>(3, 2) + && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) + && context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { + ext = new QExtTimerQueryHelper(context); + } else if (f.version() <= qMakePair<int, int>(3, 2) + && !context->hasExtension(QByteArrayLiteral("GL_ARB_timer_query")) + && !context->hasExtension(QByteArrayLiteral("GL_EXT_timer_query"))) { + qWarning("QOpenGLTimeMonitor requires one of:\n" + " OpenGL 3.3 or newer,\n" + " OpenGL 3.2 and the ARB_timer_query extension\n" + " or the EXT_timer query extension"); + return false; + } + + core->glGenQueries(requestedSampleCount, timers.data()); + return (timers.at(0) != 0); +} + +void QOpenGLTimeMonitorPrivate::destroy() +{ + if (timers.isEmpty() || timers.at(0) == 0) + return; + + core->glDeleteQueries(timers.size(), timers.data()); + timers.clear(); + delete core; + core = nullptr; + delete ext; + ext = nullptr; + context = nullptr; +} + +void QOpenGLTimeMonitorPrivate::recordSample() +{ + // Use glQueryCounter() and GL_TIMESTAMP where available. + // Otherwise, simulate it with glBeginQuery()/glEndQuery() + if (!ext) { +#if defined(GL_TIMESTAMP) + core->glQueryCounter(timers.at(++currentSample), GL_TIMESTAMP); +#endif + } else { + if (currentSample == -1) { + core->glBeginQuery(GL_TIME_ELAPSED_EXT, timers.at(++currentSample)); + timerQueryActive = true; + } else if (currentSample < timers.size() - 1) { + core->glEndQuery(GL_TIME_ELAPSED_EXT); + core->glBeginQuery(GL_TIME_ELAPSED_EXT, timers.at(++currentSample)); + } else { + if (timerQueryActive) { + core->glEndQuery(GL_TIME_ELAPSED_EXT); + timerQueryActive = false; + } + } + } +} + +bool QOpenGLTimeMonitorPrivate::isResultAvailable() const +{ + // The OpenGL spec says that if a query result is ready then the results of all queries + // of the same type issued before it must also be ready. Therefore we only need to check + // the availability of the result for the last issued query + GLuint available = GL_FALSE; + core->glGetQueryObjectuiv(timers.at(currentSample), GL_QUERY_RESULT_AVAILABLE, &available); + return available; +} + +QVector<GLuint64> QOpenGLTimeMonitorPrivate::samples() const +{ + // For the Core and ARB options just ask for the timestamp for each timer query. + // For the EXT implementation we cannot obtain timestamps so we defer any result + // collection to the intervals() function + if (!ext) { + for (int i = 0; i <= currentSample; ++i) + core->glGetQueryObjectui64v(timers.at(i), GL_QUERY_RESULT, &timeSamples[i]); + } else { + qWarning("QOpenGLTimeMonitor::samples() requires OpenGL >=3.3\n" + "or OpenGL 3.2 and GL_ARB_timer_query"); + } + return timeSamples; +} + +QVector<GLuint64> QOpenGLTimeMonitorPrivate::intervals() const +{ + QVector<GLuint64> intervals(timers.size() - 1); + if (!ext) { + // Obtain the timestamp samples and calculate the interval durations + const QVector<GLuint64> timeStamps = samples(); + for (int i = 0; i < intervals.size(); ++i) + intervals[i] = timeStamps[i+1] - timeStamps[i]; + } else { + // Stop the last timer if needed + if (timerQueryActive) { + core->glEndQuery(GL_TIME_ELAPSED_EXT); + timerQueryActive = false; + } + + // Obtain the results from all timers apart from the redundant last one. In this + // case the results actually are the intervals not timestamps + for (int i = 0; i < currentSample; ++i) + ext->glGetQueryObjectui64vEXT(timers.at(i), GL_QUERY_RESULT, &intervals[i]); + } + + return intervals; +} + +void QOpenGLTimeMonitorPrivate::reset() +{ + currentSample = -1; + timeSamples.fill(0); +} + + +/*! + \class QOpenGLTimeMonitor + \brief The QOpenGLTimeMonitor class wraps a sequence of OpenGL timer query objects. + \inmodule QtOpenGL + \since 5.1 + \ingroup painting-3D + + The QOpenGLTimeMonitor class is a convenience wrapper around a collection of OpenGL + timer query objects used to measure intervals of time on the GPU to the level of + granularity required by your rendering application. + + The OpenGL timer queries objects are queried in sequence to record the GPU + timestamps at positions of interest in your rendering code. Once the results for + all issues timer queries become available, the results can be fetched and + QOpenGLTimerMonitor will calculate the recorded time intervals for you. + + The typical use case of this class is to either profile your application's rendering + algorithms or to adjust those algorithms in real-time for dynamic performance/quality + balancing. + + Prior to using QOpenGLTimeMonitor in your rendering function you should set the + required number of sample points that you wish to record by calling setSamples(). Note + that measuring N sample points will produce N-1 time intervals. Once you have set the + number of sample points, call the create() function with a valid current OpenGL context + to create the necessary query timer objects. These steps are usually performed just + once in an initialization function. + + Use the recordSample() function to delimit blocks of code containing OpenGL commands + that you wish to time. You can check availability of the resulting time + samples and time intervals with isResultAvailable(). The calculated time intervals and + the raw timestamp samples can be retrieved with the blocking waitForIntervals() and + waitForSamples() functions respectively. + + After retrieving the results and before starting a new round of taking samples + (for example, in the next frame) be sure to call the reset() function which will clear + the cached results and reset the timer index back to the first timer object. + + \sa QOpenGLTimerQuery +*/ + +/*! + Creates a QOpenGLTimeMonitor instance with the given \a parent. You must call create() + with a valid OpenGL context before using. + + \sa setSampleCount(), create() +*/ +QOpenGLTimeMonitor::QOpenGLTimeMonitor(QObject *parent) + : QObject(*new QOpenGLTimeMonitorPrivate, parent) +{ +} + +/*! + Destroys the QOpenGLTimeMonitor and any underlying OpenGL resources. +*/ +QOpenGLTimeMonitor::~QOpenGLTimeMonitor() +{ + QOpenGLContext* ctx = QOpenGLContext::currentContext(); + + Q_D(QOpenGLTimeMonitor); + QOpenGLContext *oldContext = nullptr; + if (d->context != ctx) { + oldContext = ctx; + if (d->context->makeCurrent(oldContext->surface())) { + ctx = d->context; + } else { + qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current"); + ctx = nullptr; + } + } + + if (ctx) + destroy(); + + if (oldContext) { + if (!oldContext->makeCurrent(oldContext->surface())) + qWarning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to restore current context"); + } +} + +/*! + Sets the number of sample points to \a sampleCount. After setting the number + of samples with this function, you must call create() to instantiate the underlying + OpenGL timer query objects. + + The new \a sampleCount must be at least 2. + + \sa sampleCount(), create(), recordSample() +*/ +void QOpenGLTimeMonitor::setSampleCount(int sampleCount) +{ + // We need at least 2 samples to get an interval + if (sampleCount < 2) + return; + Q_D(QOpenGLTimeMonitor); + d->requestedSampleCount = sampleCount; +} + +/*! + Returns the number of sample points that have been requested with + setSampleCount(). If create was successfully called following setSampleCount(), + then the value returned will be the actual number of sample points + that can be used. + + The default value for sample count is 2, leading to the measurement of a + single interval. + + \sa setSampleCount() +*/ +int QOpenGLTimeMonitor::sampleCount() const +{ + Q_D(const QOpenGLTimeMonitor); + return d->requestedSampleCount; +} + +/*! + Instantiate sampleCount() OpenGL timer query objects that will be used + to track the amount of time taken to execute OpenGL commands between + successive calls to recordSample(). + + Returns \c true if the OpenGL timer query objects could be created. + + \sa destroy(), setSampleCount(), recordSample() +*/ +bool QOpenGLTimeMonitor::create() +{ + Q_D(QOpenGLTimeMonitor); + return d->create(); +} + +/*! + Destroys any OpenGL timer query objects used within this instance. + + \sa create() +*/ +void QOpenGLTimeMonitor::destroy() +{ + Q_D(QOpenGLTimeMonitor); + d->destroy(); +} + +/*! + Returns \c true if the underlying OpenGL query objects have been created. If this + returns \c true and the associated OpenGL context is current, then you are able to record + time samples with this object. +*/ +bool QOpenGLTimeMonitor::isCreated() const +{ + Q_D(const QOpenGLTimeMonitor); + return (!d->timers.isEmpty() && d->timers.at(0) != 0); +} + +/*! + Returns a QVector containing the object Ids of the OpenGL timer query objects. +*/ +QVector<GLuint> QOpenGLTimeMonitor::objectIds() const +{ + Q_D(const QOpenGLTimeMonitor); + return d->timers; +} + +/*! + Issues an OpenGL timer query at this point in the OpenGL command queue. Calling this + function in a sequence in your application's rendering function, will build up + details of the GPU time taken to execute the OpenGL commands between successive + calls to this function. + + \sa setSampleCount(), isResultAvailable(), waitForSamples(), waitForIntervals() +*/ +int QOpenGLTimeMonitor::recordSample() +{ + Q_D(QOpenGLTimeMonitor); + d->recordSample(); + return d->currentSample; +} + +/*! + Returns \c true if the OpenGL timer query results are available. + + \sa waitForSamples(), waitForIntervals() +*/ +bool QOpenGLTimeMonitor::isResultAvailable() const +{ + Q_D(const QOpenGLTimeMonitor); + return d->isResultAvailable(); +} + +/*! + Returns a QVector containing the GPU timestamps taken with recordSample(). + + This function will block until OpenGL indicates the results are available. It + is recommended to check the availability of the result prior to calling this + function with isResultAvailable(). + + \note This function only works on systems that have OpenGL >=3.3 or the + ARB_timer_query extension. See QOpenGLTimerQuery for more details. + + \sa waitForIntervals(), isResultAvailable() +*/ +QVector<GLuint64> QOpenGLTimeMonitor::waitForSamples() const +{ + Q_D(const QOpenGLTimeMonitor); + return d->samples(); +} + +/*! + Returns a QVector containing the time intervals delimited by the calls to + recordSample(). The resulting vector will contain one fewer element as + this represents the intervening intervals rather than the actual timestamp + samples. + + This function will block until OpenGL indicates the results are available. It + is recommended to check the availability of the result prior to calling this + function with isResultAvailable(). + + \sa waitForSamples(), isResultAvailable() +*/ +QVector<GLuint64> QOpenGLTimeMonitor::waitForIntervals() const +{ + Q_D(const QOpenGLTimeMonitor); + return d->intervals(); +} + +/*! + Resets the time monitor ready for use in another frame of rendering. Call + this once you have obtained the previous results and before calling + recordSample() for the first time on the next frame. + + \sa recordSample() +*/ +void QOpenGLTimeMonitor::reset() +{ + Q_D(QOpenGLTimeMonitor); + d->reset(); +} + +QT_END_NAMESPACE diff --git a/src/opengl/qopengltimerquery.h b/src/opengl/qopengltimerquery.h new file mode 100644 index 0000000000..a779240108 --- /dev/null +++ b/src/opengl/qopengltimerquery.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGLTIMERQUERY_H +#define QOPENGLTIMERQUERY_H + +#include <QtOpenGL/qtopenglglobal.h> + +#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) + +#include <QtCore/QObject> +#include <QtGui/qopengl.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLTimerQueryPrivate; + +class Q_OPENGL_EXPORT QOpenGLTimerQuery : public QObject +{ + Q_OBJECT + +public: + explicit QOpenGLTimerQuery(QObject *parent = nullptr); + ~QOpenGLTimerQuery(); + + bool create(); + void destroy(); + bool isCreated() const; + GLuint objectId() const; + + void begin(); + void end(); + GLuint64 waitForTimestamp() const; + void recordTimestamp(); + bool isResultAvailable() const; + GLuint64 waitForResult() const; + +private: + Q_DECLARE_PRIVATE(QOpenGLTimerQuery) + Q_DISABLE_COPY(QOpenGLTimerQuery) +}; + + +class QOpenGLTimeMonitorPrivate; + +class Q_OPENGL_EXPORT QOpenGLTimeMonitor : public QObject +{ + Q_OBJECT + +public: + explicit QOpenGLTimeMonitor(QObject *parent = nullptr); + ~QOpenGLTimeMonitor(); + + void setSampleCount(int sampleCount); + int sampleCount() const; + + bool create(); + void destroy(); + bool isCreated() const; + QVector<GLuint> objectIds() const; + + int recordSample(); + + bool isResultAvailable() const; + + QVector<GLuint64> waitForSamples() const; + QVector<GLuint64> waitForIntervals() const; + + void reset(); + +private: + Q_DECLARE_PRIVATE(QOpenGLTimeMonitor) + Q_DISABLE_COPY(QOpenGLTimeMonitor) +}; + +QT_END_NAMESPACE + +#endif // QT_NO_OPENGL + +#endif // QOPENGLTIMERQUERY_H -- cgit v1.2.3 From c7e35ffe69a73bb144618714313673f0d0c28394 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 26 Nov 2018 09:55:00 +0100 Subject: Use a QMultiHash explicitly if insertMulti() is being used This is a step towards deprecating QHash::insertMulti() and clearly separating QHash and QMultiHash. Change-Id: Ic2c7665673ff00d4f2186e94850710b70330f8ba Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/tools/moc/generator.cpp | 2 +- src/tools/rcc/rcc.cpp | 6 +++--- src/xml/dom/qdom.cpp | 24 ++++++++++++------------ src/xml/dom/qdom_p.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 9029bf9008..034e846918 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -462,7 +462,7 @@ void Generator::generateCode() // Build extra array // QVector<QByteArray> extraList; - QHash<QByteArray, QByteArray> knownExtraMetaObject = knownGadgets; + QMultiHash<QByteArray, QByteArray> knownExtraMetaObject = knownGadgets; knownExtraMetaObject.unite(knownQObjectClasses); for (int i = 0; i < cdef->propertyList.count(); ++i) { diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 7185219d34..7188c81300 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -129,7 +129,7 @@ public: QLocale::Country m_country; QFileInfo m_fileInfo; RCCFileInfo *m_parent; - QHash<QString, RCCFileInfo*> m_children; + QMultiHash<QString, RCCFileInfo *> m_children; RCCResourceLibrary::CompressionAlgorithm m_compressAlgo; int m_compressLevel; int m_compressThreshold; @@ -737,7 +737,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) parent->m_children.insert(node, s); parent = s; } else { - parent = parent->m_children[node]; + parent = *parent->m_children.constFind(node); } } @@ -757,7 +757,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) break; } } - parent->m_children.insertMulti(filename, s); + parent->m_children.insert(filename, s); return true; } diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 81f33b0693..cb753ed573 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -2573,8 +2573,8 @@ void QDomNamedNodeMapPrivate::clearMap() QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(const QString& name) const { - QDomNodePrivate* p = map[name]; - return p; + auto it = map.constFind(name); + return it == map.cend() ? nullptr : *it; } QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, const QString& localName) const @@ -2603,7 +2603,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg) QDomNodePrivate *n = map.value(arg->nodeName()); // We take a reference arg->ref.ref(); - map.insertMulti(arg->nodeName(), arg); + map.insert(arg->nodeName(), arg); return n; } @@ -2620,7 +2620,7 @@ QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg) QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name); // We take a reference arg->ref.ref(); - map.insertMulti(arg->nodeName(), arg); + map.insert(arg->nodeName(), arg); return n; } else { // ### check the following code if it is ok @@ -2963,10 +2963,10 @@ QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, boo while (p) { if (p->isEntity()) // Don't use normal insert function since we would create infinite recursion - entities->map.insertMulti(p->nodeName(), p); + entities->map.insert(p->nodeName(), p); if (p->isNotation()) // Don't use normal insert function since we would create infinite recursion - notations->map.insertMulti(p->nodeName(), p); + notations->map.insert(p->nodeName(), p); p = p->next; } } @@ -3010,9 +3010,9 @@ QDomNodePrivate* QDomDocumentTypePrivate::insertBefore(QDomNodePrivate* newChild QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild); // Update the maps if (p && p->isEntity()) - entities->map.insertMulti(p->nodeName(), p); + entities->map.insert(p->nodeName(), p); else if (p && p->isNotation()) - notations->map.insertMulti(p->nodeName(), p); + notations->map.insert(p->nodeName(), p); return p; } @@ -3023,9 +3023,9 @@ QDomNodePrivate* QDomDocumentTypePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild); // Update the maps if (p && p->isEntity()) - entities->map.insertMulti(p->nodeName(), p); + entities->map.insert(p->nodeName(), p); else if (p && p->isNotation()) - notations->map.insertMulti(p->nodeName(), p); + notations->map.insert(p->nodeName(), p); return p; } @@ -3042,9 +3042,9 @@ QDomNodePrivate* QDomDocumentTypePrivate::replaceChild(QDomNodePrivate* newChild notations->map.remove(oldChild->nodeName()); if (p->isEntity()) - entities->map.insertMulti(p->nodeName(), p); + entities->map.insert(p->nodeName(), p); else if (p->isNotation()) - notations->map.insertMulti(p->nodeName(), p); + notations->map.insert(p->nodeName(), p); } return p; diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h index d197e999f1..b66c756af0 100644 --- a/src/xml/dom/qdom_p.h +++ b/src/xml/dom/qdom_p.h @@ -235,7 +235,7 @@ public: // Variables QAtomicInt ref; - QHash<QString, QDomNodePrivate *> map; + QMultiHash<QString, QDomNodePrivate *> map; QDomNodePrivate *parent; bool readonly; bool appendToParent; -- cgit v1.2.3 From 9c124b1b0a3730978699b8a6420308b5e5ab4e4e Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 26 Nov 2018 10:37:10 +0100 Subject: Qt 6: Deprecate QHash::insertMulti [ChangeLog][QtCore][QHash] insertMulti(), unite() and values(const Key &key) are now deprecated. Please use QMultiHash instead. Change-Id: Ic14907fd5fd38d585708e2dcf2c0200d221ebb25 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- .../doc/snippets/code/src_corelib_tools_qhash.cpp | 16 -- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/kernel/qvariant.h | 2 +- src/corelib/serialization/qdatastream.h | 3 + src/corelib/tools/qhash.cpp | 102 +++++---- src/corelib/tools/qhash.h | 250 +++++++++++++-------- src/dbus/qdbusargument.h | 2 +- 7 files changed, 217 insertions(+), 160 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp index 9813cc98d5..a140175956 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp @@ -119,22 +119,6 @@ hash.insert("plenty", 2000); //! [9] -//! [10] -QList<int> values = hash.values("plenty"); -for (int i = 0; i < values.size(); ++i) - cout << values.at(i) << Qt::endl; -//! [10] - - -//! [11] -QHash<QString, int>::iterator i = hash.find("plenty"); -while (i != hash.end() && i.key() == "plenty") { - cout << i.value() << Qt::endl; - ++i; -} -//! [11] - - //! [12] QHash<QString, int> hash; ... diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 40a401361d..5e27119729 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -972,7 +972,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) const QVariantMap *map = v_cast<QVariantMap>(d); const auto end = map->end(); for (auto it = map->begin(); it != end; ++it) - hash->insertMulti(it.key(), it.value()); + static_cast<QMultiHash<QString, QVariant> *>(hash)->insert(it.key(), it.value()); #ifndef QT_BOOTSTRAPPED } else if (d->type == QMetaType::QCborValue) { if (!v_cast<QCborValue>(d)->isMap()) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index f48419c934..6739643f89 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -825,7 +825,7 @@ namespace QtPrivate { QVariantHash l; l.reserve(iter.size()); for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) - l.insertMulti(it.key().toString(), it.value()); + static_cast<QMultiHash<QString, QVariant> &>(l).insert(it.key().toString(), it.value()); return l; } return QVariantValueHelper<QVariantHash>::invoke(v); diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h index d9d4a4fcd3..4d827772c8 100644 --- a/src/corelib/serialization/qdatastream.h +++ b/src/corelib/serialization/qdatastream.h @@ -301,7 +301,10 @@ QDataStream &readAssociativeContainer(QDataStream &s, Container &c) c.clear(); break; } +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED c.insertMulti(k, t); +QT_WARNING_POP } return s; diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index dcac91778f..3ff8f886f1 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -1120,21 +1120,6 @@ uint qHash(long double key, uint seed) noexcept \snippet code/src_corelib_tools_qhash.cpp 9 - However, you can store multiple values per key by using - insertMulti() instead of insert() (or using the convenience - subclass QMultiHash). If you want to retrieve all - the values for a single key, you can use values(const Key &key), - which returns a QList<T>: - - \snippet code/src_corelib_tools_qhash.cpp 10 - - The items that share the same key are available from most - recently to least recently inserted. A more efficient approach is - to call find() to get the iterator for the first item with a key - and iterate from there: - - \snippet code/src_corelib_tools_qhash.cpp 11 - If you only need to extract the values from a hash (not the keys), you can also use \l{foreach}: @@ -1435,9 +1420,8 @@ uint qHash(long double key, uint seed) noexcept /*! \fn template <class Key, class T> int QHash<Key, T>::remove(const Key &key) Removes all the items that have the \a key from the hash. - Returns the number of items removed which is usually 1 but will - be 0 if the key isn't in the hash, or greater than 1 if - insertMulti() has been used with the \a key. + Returns the number of items removed which is 1 if the key exists in the hash, + and 0 otherwise. \sa clear(), take(), QMultiHash::remove() */ @@ -1507,27 +1491,25 @@ uint qHash(long double key, uint seed) noexcept /*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::uniqueKeys() const \since 4.2 + \obsolete Returns a list containing all the keys in the map. Keys that occur multiple times in the map (because items were inserted with insertMulti(), or unite() was used) occur only once in the returned list. - \sa keys(), values() + \sa QMultiHash::uniqueKeys() */ /*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::keys() const Returns a list containing all the keys in the hash, in an arbitrary order. Keys that occur multiple times in the hash - (because items were inserted with insertMulti(), or unite() was - used) also occur multiple times in the list. - - To obtain a list of unique keys, where each key from the map only - occurs once, use uniqueKeys(). + (because the method is operating on a QMultiHash) also occur + multiple times in the list. The order is guaranteed to be the same as that used by values(). - \sa uniqueKeys(), values(), key() + \sa QMultiMap::uniqueKeys(), values(), key() */ /*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::keys(const T &value) const @@ -1555,7 +1537,7 @@ uint qHash(long double key, uint seed) noexcept */ /*! \fn template <class Key, class T> QList<T> QHash<Key, T>::values(const Key &key) const - + \obsolete \overload Returns a list of all the values associated with the \a key, @@ -1592,6 +1574,7 @@ uint qHash(long double key, uint seed) noexcept */ /*! \fn template <class Key, class T> int QHash<Key, T>::count(const Key &key) const + \obsolete Returns the number of items associated with the \a key. @@ -1803,8 +1786,6 @@ uint qHash(long double key, uint seed) noexcept If there are multiple items with the \a key, the most recently inserted item's value is replaced with \a value. - - \sa insertMulti() */ /*! \fn template <class Key, class T> void QHash<Key, T>::insert(const QHash &other) @@ -1820,6 +1801,7 @@ uint qHash(long double key, uint seed) noexcept */ /*! \fn template <class Key, class T> QHash<Key, T>::iterator QHash<Key, T>::insertMulti(const Key &key, const T &value) + \obsolete Inserts a new item with the \a key and a value of \a value. @@ -1828,16 +1810,17 @@ uint qHash(long double key, uint seed) noexcept different from insert(), which overwrites the value of an existing item.) + This function is obsolete. Use QMultiHash or QMultiMap instead. + \sa insert(), values() */ /*! \fn template <class Key, class T> QHash &QHash<Key, T>::unite(const QHash &other) + \obsolete Inserts all the items in the \a other hash into this hash. If a key is common to both hashes, the resulting hash will contain the key multiple times. - - \sa insertMulti() */ /*! \fn template <class Key, class T> bool QHash<Key, T>::empty() const @@ -1978,10 +1961,7 @@ uint qHash(long double key, uint seed) noexcept \snippet code/src_corelib_tools_qhash.cpp 17 Unlike QMap, which orders its items by key, QHash stores its - items in an arbitrary order. The only guarantee is that items that - share the same key (because they were inserted using - QHash::insertMulti()) will appear consecutively, from the most - recently to the least recently inserted value. + items in an arbitrary order. Let's see a few examples of things we can do with a QHash::iterator that we cannot do with a QHash::const_iterator. @@ -2048,7 +2028,7 @@ uint qHash(long double key, uint seed) noexcept There is no direct way of changing an item's key through an iterator, although it can be done by calling QHash::erase() - followed by QHash::insert() or QHash::insertMulti(). + followed by QHash::insert(). \sa value() */ @@ -2210,7 +2190,7 @@ uint qHash(long double key, uint seed) noexcept Unlike QMap, which orders its items by key, QHash stores its items in an arbitrary order. The only guarantee is that items that share the same key (because they were inserted using - QHash::insertMulti()) will appear consecutively, from the most + a QMultiHash) will appear consecutively, from the most recently to the least recently inserted value. Multiple iterators can be used on the same hash. However, be aware @@ -2543,18 +2523,22 @@ uint qHash(long double key, uint seed) noexcept It inherits QHash and extends it with a few convenience functions that make it more suitable than QHash for storing multi-valued hashes. A multi-valued hash is a hash that allows multiple values - with the same key; QHash normally doesn't allow that, unless you - call QHash::insertMulti(). + with the same key. Because QMultiHash inherits QHash, all of QHash's functionality also applies to QMultiHash. For example, you can use isEmpty() to test whether the hash is empty, and you can traverse a QMultiHash using - QHash's iterator classes (for example, QHashIterator). But in - addition, it provides an insert() function that corresponds to - QHash::insertMulti(), and a replace() function that corresponds to + QHash's iterator classes (for example, QHashIterator). But opposed to + QHash, it provides an insert() function will allow the insertion of + multiple items with the same key. The replace() function corresponds to QHash::insert(). It also provides convenient operator+() and operator+=(). + Unlike QMultiMap, QMultiHash does not provide and ordering of the + inserted items. The only guarantee is that items that + share the same key will appear consecutively, from the most + recently to the least recently inserted value. + Example: \snippet code/src_corelib_tools_qhash.cpp 24 @@ -2645,7 +2629,8 @@ uint qHash(long double key, uint seed) noexcept \sa replace() */ -/*! \fn template <class Key, class T> QMultiHash &QMultiHash<Key, T>::operator+=(const QMultiHash &other) +/*! \fn template <class Key, class T> QMultiHash &QMultiHash<Key, T>::unite(const QMultiHash &other) + \since 5.13 Inserts all the items in the \a other hash into this hash and returns a reference to this hash. @@ -2653,6 +2638,32 @@ uint qHash(long double key, uint seed) noexcept \sa insert() */ +/*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::uniqueKeys() const + \since 5.13 + + Returns a list containing all the keys in the map. Keys that occur multiple + times in the map occur only once in the returned list. + + \sa keys(), values() +*/ + +/*! \fn template <class Key, class T> QList<T> QMultiHash<Key, T>::values(const Key &key) const + \overload + + Returns a list of all the values associated with the \a key, + from the most recently inserted to the least recently inserted. + + \sa count(), insert() +*/ + +/*! \fn template <class Key, class T> QMultiHash &QMultiHash<Key, T>::operator+=(const QMultiHash &other) + + Inserts all the items in the \a other hash into this hash + and returns a reference to this hash. + + \sa unit(), insert() +*/ + /*! \fn template <class Key, class T> QMultiHash QMultiHash<Key, T>::operator+(const QMultiHash &other) const Returns a hash that contains all the items in this hash in @@ -2682,6 +2693,13 @@ uint qHash(long double key, uint seed) noexcept \sa QHash::remove() */ +/*! \fn template <class Key, class T> int QMultiHash<Key, T>::count(const Key &key) const + + Returns the number of items associated with the \a key. + + \sa contains(), insert() +*/ + /*! \fn template <class Key, class T> int QMultiHash<Key, T>::count(const Key &key, const T &value) const \since 4.3 diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 89697b1fd1..0b8a0b283d 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -308,12 +308,14 @@ public: T &operator[](const Key &key); const T operator[](const Key &key) const; - QList<Key> uniqueKeys() const; QList<Key> keys() const; QList<Key> keys(const T &value) const; QList<T> values() const; - QList<T> values(const Key &key) const; - int count(const Key &key) const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") QList<Key> uniqueKeys() const; + QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") QList<T> values(const Key &key) const; + QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") int count(const Key &key) const; +#endif class const_iterator; @@ -388,6 +390,7 @@ public: { friend class iterator; friend class QHash<Key, T>; + friend class QMultiHash<Key, T>; friend class QSet<Key>; QHashData::Node *i; @@ -527,8 +530,10 @@ public: const_iterator constFind(const Key &key) const; iterator insert(const Key &key, const T &value); void insert(const QHash &hash); - iterator insertMulti(const Key &key, const T &value); - QHash &unite(const QHash &other); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") iterator insertMulti(const Key &key, const T &value); + QT_DEPRECATED_X("Use QMultiHash for hashes storing multiple values with the same key.") QHash &unite(const QHash &other); +#endif // STL compatibility typedef T mapped_type; @@ -570,6 +575,7 @@ private: #endif } friend class QSet<Key>; + friend class QMultiHash<Key, T>; }; @@ -607,38 +613,6 @@ QHash<Key, T>::createNode(uint ah, const Key &akey, const T &avalue, Node **anex return node; } -template <class Key, class T> -Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::unite(const QHash &other) -{ - if (d == &QHashData::shared_null) { - *this = other; - } else { -#if QT_DEPRECATED_SINCE(5, 15) - QHash copy(other); - const_iterator it = copy.constEnd(); - while (it != copy.constBegin()) { - it.i = QHashData::previousNode(it.i); - insertMulti(it.key(), it.value()); - } -#else - QHash copy(other); - const_iterator it = copy.cbegin(); - const const_iterator end = copy.cend(); - while (it != end) { - const auto rangeStart = it++; - while (it != end && rangeStart.key() == it.key()) - ++it; - const qint64 last = std::distance(rangeStart, it) - 1; - for (qint64 i = last; i >= 0; --i) { - auto next = std::next(rangeStart, i); - insertMulti(next.key(), next.value()); - } - } -#endif - } - return *this; -} - template <class Key, class T> Q_OUTOFLINE_TEMPLATE void QHash<Key, T>::freeData(QHashData *x) { @@ -697,26 +671,6 @@ Q_INLINE_TEMPLATE const T QHash<Key, T>::value(const Key &akey, const T &adefaul } } -template <class Key, class T> -Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const -{ - QList<Key> res; - res.reserve(size()); // May be too much, but assume short lifetime - const_iterator i = begin(); - if (i != end()) { - for (;;) { - const Key &aKey = i.key(); - res.append(aKey); - do { - if (++i == end()) - goto break_out_of_outer_loop; - } while (aKey == i.key()); - } - } -break_out_of_outer_loop: - return res; -} - template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::keys() const { @@ -775,32 +729,6 @@ Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values() const return res; } -template <class Key, class T> -Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values(const Key &akey) const -{ - QList<T> res; - Node *node = *findNode(akey); - if (node != e) { - do { - res.append(node->value); - } while ((node = node->next) != e && node->key == akey); - } - return res; -} - -template <class Key, class T> -Q_OUTOFLINE_TEMPLATE int QHash<Key, T>::count(const Key &akey) const -{ - int cnt = 0; - Node *node = *findNode(akey); - if (node != e) { - do { - ++cnt; - } while ((node = node->next) != e && node->key == akey); - } - return cnt; -} - template <class Key, class T> Q_INLINE_TEMPLATE const T QHash<Key, T>::operator[](const Key &akey) const { @@ -866,18 +794,6 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::insert(const QHash &hash) } } -template <class Key, class T> -Q_INLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::insertMulti(const Key &akey, - const T &avalue) -{ - detach(); - d->willGrow(); - - uint h; - Node **nextNode = findNode(akey, &h); - return iterator(createNode(h, akey, avalue, nextNode)); -} - template <class Key, class T> Q_OUTOFLINE_TEMPLATE int QHash<Key, T>::remove(const Key &akey) { @@ -1128,11 +1044,12 @@ public: inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value) { return QHash<Key, T>::insert(key, value); } - inline typename QHash<Key, T>::iterator insert(const Key &key, const T &value) - { return QHash<Key, T>::insertMulti(key, value); } + typename QHash<Key, T>::iterator insert(const Key &key, const T &value); + + inline QMultiHash &unite(const QMultiHash &other); inline QMultiHash &operator+=(const QMultiHash &other) - { this->unite(other); return *this; } + { return unite(other); } inline QMultiHash operator+(const QMultiHash &other) const { QMultiHash result = *this; result += other; return result; } @@ -1141,13 +1058,27 @@ public: using QHash<Key, T>::count; using QHash<Key, T>::find; using QHash<Key, T>::constFind; + using QHash<Key, T>::values; + using QHash<Key, T>::findNode; + using QHash<Key, T>::createNode; + using QHash<Key, T>::concrete; + using QHash<Key, T>::detach; + + using typename QHash<Key, T>::Node; + using typename QHash<Key, T>::iterator; + using typename QHash<Key, T>::const_iterator; bool contains(const Key &key, const T &value) const; int remove(const Key &key, const T &value); + int count(const Key &key) const; int count(const Key &key, const T &value) const; + QList<Key> uniqueKeys() const; + + QList<T> values(const Key &akey) const; + typename QHash<Key, T>::iterator find(const Key &key, const T &value) { typename QHash<Key, T>::iterator i(find(key)); typename QHash<Key, T>::iterator end(this->end()); @@ -1175,6 +1106,50 @@ private: const T operator[](const Key &key) const; }; +template <class Key, class T> +Q_INLINE_TEMPLATE typename QHash<Key, T>::iterator QMultiHash<Key, T>::insert(const Key &akey, const T &avalue) +{ + detach(); + this->d->willGrow(); + + uint h; + Node **nextNode = findNode(akey, &h); + return iterator(createNode(h, akey, avalue, nextNode)); +} + +template <class Key, class T> +Q_INLINE_TEMPLATE QMultiHash<Key, T> &QMultiHash<Key, T>::unite(const QMultiHash &other) +{ + if (this->d == &QHashData::shared_null) { + *this = other; + } else { +#if QT_DEPRECATED_SINCE(5, 15) + QMultiHash copy(other); + const_iterator it = copy.constEnd(); + while (it != copy.constBegin()) { + it.i = QHashData::previousNode(it.i); + insert(it.key(), it.value()); + } +#else + const QMultiHash copy(other); + const_iterator it = copy.cbegin(); + const const_iterator end = copy.cend(); + while (it != end) { + const auto rangeStart = it++; + while (it != end && rangeStart.key() == it.key()) + ++it; + const qint64 last = std::distance(rangeStart, it) - 1; + for (qint64 i = last; i >= 0; --i) { + auto next = std::next(rangeStart, i); + insert(next.key(), next.value()); + } + } +#endif + } + return *this; +} + + template <class Key, class T> Q_INLINE_TEMPLATE bool QMultiHash<Key, T>::contains(const Key &key, const T &value) const { @@ -1212,7 +1187,84 @@ Q_INLINE_TEMPLATE int QMultiHash<Key, T>::count(const Key &key, const T &value) return n; } -template<class Key, class T> +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QList<Key> QMultiHash<Key, T>::uniqueKeys() const +{ + QList<Key> res; + res.reserve(QHash<Key, T>::size()); // May be too much, but assume short lifetime + typename QHash<Key, T>::const_iterator i = QHash<Key, T>::begin(); + if (i != QHash<Key, T>::end()) { + for (;;) { + const Key &aKey = i.key(); + res.append(aKey); + do { + if (++i == QHash<Key, T>::end()) + goto break_out_of_outer_loop; + } while (aKey == i.key()); + } + } +break_out_of_outer_loop: + return res; +} + +#if QT_DEPRECATED_SINCE(5, 15) + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::insertMulti(const Key &key, const T &value) { + return static_cast<QMultiHash<Key, T> *>(this)->insert(key, value); +} + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::unite(const QHash &other) { + return static_cast<QMultiHash<Key, T> *>(this)->unite(other); +} + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QList<T> QHash<Key, T>::values(const Key &akey) const +{ + return static_cast<const QMultiHash<Key, T> *>(this)->values(akey); +} + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE int QHash<Key, T>::count(const Key &akey) const +{ + return static_cast<const QMultiHash<Key, T> *>(this)->count(akey); +} + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QList<Key> QHash<Key, T>::uniqueKeys() const +{ + return static_cast<const QMultiHash<Key, T> *>(this)->uniqueKeys(); +} +#endif + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QList<T> QMultiHash<Key, T>::values(const Key &akey) const +{ + QList<T> res; + Node *node = *findNode(akey); + if (node != this->e) { + do { + res.append(node->value); + } while ((node = node->next) != this->e && node->key == akey); + } + return res; +} + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE int QMultiHash<Key, T>::count(const Key &akey) const +{ + int cnt = 0; + Node *node = *findNode(akey); + if (node != this->e) { + do { + ++cnt; + } while ((node = node->next) != this->e && node->key == akey); + } + return cnt; +} + +template <class Key, class T> class QHashIterator { typedef typename QHash<Key, T>::const_iterator const_iterator; diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index b7cd4c8989..340f11bf5d 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -370,7 +370,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, QHash<Key, T> & T value; arg.beginMapEntry(); arg >> key >> value; - map.insertMulti(key, value); + static_cast<QMultiHash<Key, T> &>(map).insert(key, value); arg.endMapEntry(); } arg.endMap(); -- cgit v1.2.3 From d98a1ef902527ca2351ec6bf18872a4226953487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Wed, 6 Nov 2019 18:04:45 +0100 Subject: Add QMap::insert(const QMap &map) As opposed to unite(), this inserts one map into the other without duplicating elements. Task-number: QTBUG-35544 Change-Id: Ie8ab350b29148851a3176cef1007e8a4ca82c273 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/tools/qmap.cpp | 14 ++++++++++++++ src/corelib/tools/qmap.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index a0ec372f9a..970373101f 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -1150,6 +1150,20 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa insertMulti() */ +/*! \fn template <class Key, class T> void QMap<Key, T>::insert(const QMap<Key, T> &map) + \since 5.15 + + Inserts all the items in \a map into this map. + + If a key is common to both maps, its value will be replaced with + the value stored in \a map. + + \note If \a map contains multiple entries with the same key then the + final value of the key is undefined. + + \sa insertMulti() +*/ + /*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &key, const T &value) Inserts a new item with the key \a key and a value of \a value. diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 18c681581f..fa736e8413 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -578,6 +578,7 @@ public: const_iterator upperBound(const Key &key) const; iterator insert(const Key &key, const T &value); iterator insert(const_iterator pos, const Key &key, const T &value); + void insert(const QMap<Key, T> &map); iterator insertMulti(const Key &key, const T &value); iterator insertMulti(const_iterator pos, const Key &akey, const T &avalue); QMap<Key, T> &unite(const QMap<Key, T> &other); @@ -788,6 +789,49 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const K } } +template <class Key, class T> +Q_INLINE_TEMPLATE void QMap<Key, T>::insert(const QMap<Key, T> &map) +{ + if (d == map.d) + return; + + detach(); + + Node *n = d->root(); + auto it = map.cbegin(); + const auto e = map.cend(); + while (it != e) { + // Insertion here is based on insert(Key, T) + auto parent = d->end(); + bool left = true; + Node *lastNode = nullptr; + while (n) { + parent = n; + if (!qMapLessThanKey(n->key, it.key())) { + lastNode = n; + n = n->leftNode(); + left = true; + } else { + n = n->rightNode(); + left = false; + } + } + if (lastNode && !qMapLessThanKey(it.key(), lastNode->key)) { + lastNode->value = it.value(); + n = lastNode; + } else { + n = d->createNode(it.key(), it.value(), parent, left); + } + ++it; + if (it != e) { + // Move back up the tree until we find the next branch or node which is + // relevant for the next key. + while (n != d->root() && qMapLessThanKey(n->key, it.key())) + n = static_cast<Node *>(n->parent()); + } + } +} + template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &akey, const T &avalue) -- cgit v1.2.3 From 1c98479aa2d39d099b548e1161e402ad8f05d6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Thu, 7 Nov 2019 17:15:50 +0100 Subject: QRegExp: change QMap::unite to QMap::insert Change-Id: I4c682b31da8bfa56c6858a1878f12118568f28bf Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/text/qregexp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qregexp.cpp b/src/corelib/text/qregexp.cpp index ac4d9bbc36..9301a7e573 100644 --- a/src/corelib/text/qregexp.cpp +++ b/src/corelib/text/qregexp.cpp @@ -2528,7 +2528,7 @@ void QRegExpEngine::Box::cat(const Box &b) eng->addCatTransitions(rs, b.ls); addAnchorsToEngine(b); if (minl == 0) { - lanchors.unite(b.lanchors); + lanchors.insert(b.lanchors); if (skipanchors != 0) { for (int i = 0; i < b.ls.size(); i++) { int a = eng->anchorConcatenation(lanchors.value(b.ls.at(i), 0), skipanchors); @@ -2538,7 +2538,7 @@ void QRegExpEngine::Box::cat(const Box &b) mergeInto(&ls, b.ls); } if (b.minl == 0) { - ranchors.unite(b.ranchors); + ranchors.insert(b.ranchors); if (b.skipanchors != 0) { for (int i = 0; i < rs.size(); i++) { int a = eng->anchorConcatenation(ranchors.value(rs.at(i), 0), b.skipanchors); @@ -2596,9 +2596,9 @@ void QRegExpEngine::Box::cat(const Box &b) void QRegExpEngine::Box::orx(const Box &b) { mergeInto(&ls, b.ls); - lanchors.unite(b.lanchors); + lanchors.insert(b.lanchors); mergeInto(&rs, b.rs); - ranchors.unite(b.ranchors); + ranchors.insert(b.ranchors); if (b.minl == 0) { if (minl == 0) -- cgit v1.2.3 From b79d74e96f078580adfd403c8118f1e5429bfb8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Thu, 7 Nov 2019 17:16:21 +0100 Subject: moc: change QMap::unite to QMap::insert Which is the intended behavior. Change-Id: I0cffc623fc09284f3d95850f840564dca20ed0d4 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> --- src/tools/moc/moc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 8cc605fd8a..58c9f88328 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -930,9 +930,9 @@ void Moc::parse() if (it != classList.end()) { it->classInfoList += def.classInfoList; - it->enumDeclarations.unite(def.enumDeclarations); + it->enumDeclarations.insert(def.enumDeclarations); it->enumList += def.enumList; - it->flagAliases.unite(def.flagAliases); + it->flagAliases.insert(def.flagAliases); } else { knownGadgets.insert(def.classname, def.qualified); knownGadgets.insert(def.qualified, def.qualified); -- cgit v1.2.3 From 43837f38b23e46b2b26599b30724902ce6eddabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Wed, 27 Nov 2019 17:13:13 +0100 Subject: Change some uses of QMap::insertMulti to QMultiMap::insert By casting it, these are situations where we cannot change the type itself to QMultiMap. For QVariant it's a public define and for dbus it's the type of an argument to the function. Change-Id: I0f385dc857fce5de3e8254d18268fd84a6d7707c Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/kernel/qvariant.h | 2 +- src/dbus/qdbusargument.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 5e27119729..c00efc0afe 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -944,7 +944,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) const QVariantHash *hash = v_cast<QVariantHash>(d); const auto end = hash->end(); for (auto it = hash->begin(); it != end; ++it) - map->insertMulti(it.key(), it.value()); + static_cast<QMultiMap<QString, QVariant> *>(map)->insert(it.key(), it.value()); #ifndef QT_BOOTSTRAPPED } else if (d->type == QMetaType::QCborValue) { if (!v_cast<QCborValue>(d)->isMap()) diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 6739643f89..0dddfc59b3 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -841,7 +841,7 @@ namespace QtPrivate { QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) - l.insertMulti(it.key().toString(), it.value()); + static_cast<QMultiMap<QString, QVariant> &>(l).insert(it.key().toString(), it.value()); return l; } return QVariantValueHelper<QVariantMap>::invoke(v); diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index 340f11bf5d..477bd1e8fd 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -321,7 +321,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, QMap<Key, T> &m T value; arg.beginMapEntry(); arg >> key >> value; - map.insertMulti(key, value); + static_cast<QMultiMap<Key, T> &>(map).insert(key, value); arg.endMapEntry(); } arg.endMap(); -- cgit v1.2.3 From 6f5556e7b4d5d388805d06d852b5cdb7c52e80dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Wed, 27 Nov 2019 17:16:50 +0100 Subject: QTextDocument: Change use of QMap::unite to QMap::insert None of the code I could see handles the map like a multimap. Change-Id: I9d51da6dafed4317e801703599e83fb038c22a1d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/gui/text/qtextdocument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 1d27cc30eb..f2caedc25f 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -3085,7 +3085,7 @@ void QTextDocumentPrivate::mergeCachedResources(const QTextDocumentPrivate *priv if (!priv) return; - cachedResources.unite(priv->cachedResources); + cachedResources.insert(priv->cachedResources); } void QTextHtmlExporter::emitBackgroundAttribute(const QTextFormat &format) -- cgit v1.2.3 From 40f28b1a8afbe15da369db53cda3dadd8d11ee43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Fri, 29 Nov 2019 12:13:49 +0100 Subject: Don't use QMap::unite for merging maps Other code using these maps are not treating them like multi-maps Change-Id: I3381fde3b3612a29110cfe890f20f96f3c0bd3a2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/dbus/qdbusmetaobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 74e17ced77..3c529ab755 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -631,10 +631,10 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con QDBusIntrospection::Interface merged = *it.value().constData(); for (++it; it != end; ++it) { - merged.annotations.unite(it.value()->annotations); + merged.annotations.insert(it.value()->annotations); merged.methods.unite(it.value()->methods); merged.signals_.unite(it.value()->signals_); - merged.properties.unite(it.value()->properties); + merged.properties.insert(it.value()->properties); } merged.name = QLatin1String("local.Merged"); -- cgit v1.2.3 From d107706ab9a482fb5dbce1c48a9bab7ea176d90e Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Wed, 11 Dec 2019 10:52:31 +0100 Subject: Move QOpenGLWidget from QtWidgets to QtOpenGL Task-number: QTBUG-74409 Change-Id: I98a4f8a9e1d439bfdc24eb2910385273cedecd29 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/opengl/opengl.pro | 6 + src/opengl/qopenglwidget.cpp | 1471 ++++++++++++++++++++++++++++++++++ src/opengl/qopenglwidget.h | 115 +++ src/widgets/kernel/kernel.pri | 5 - src/widgets/kernel/qopenglwidget.cpp | 1471 ---------------------------------- src/widgets/kernel/qopenglwidget.h | 115 --- 6 files changed, 1592 insertions(+), 1591 deletions(-) create mode 100644 src/opengl/qopenglwidget.cpp create mode 100644 src/opengl/qopenglwidget.h delete mode 100644 src/widgets/kernel/qopenglwidget.cpp delete mode 100644 src/widgets/kernel/qopenglwidget.h (limited to 'src') diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 820e46ed79..eaa10de22a 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -1,5 +1,6 @@ TARGET = QtOpenGL QT = core-private gui-private +qtConfig(widgets): QT += widgets widgets-private DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH @@ -23,4 +24,9 @@ SOURCES += \ SOURCES += qopengltimerquery.cpp } +qtConfig(widgets) { + HEADERS += qopenglwidget.h + SOURCES += qopenglwidget.cpp +} + load(qt_module) diff --git a/src/opengl/qopenglwidget.cpp b/src/opengl/qopenglwidget.cpp new file mode 100644 index 0000000000..a6c63ae034 --- /dev/null +++ b/src/opengl/qopenglwidget.cpp @@ -0,0 +1,1471 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qopenglwidget.h" +#include <QtGui/QOpenGLContext> +#include <QtGui/QOpenGLFramebufferObject> +#include <QtGui/QOffscreenSurface> +#include <QtGui/QOpenGLFunctions> +#include <QtGui/QWindow> +#include <QtGui/QGuiApplication> +#include <QtGui/QScreen> +#include <QtGui/QOpenGLPaintDevice> +#include <QtGui/qpa/qplatformwindow.h> +#include <QtGui/qpa/qplatformintegration.h> +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qopenglextensions_p.h> +#include <QtGui/private/qfont_p.h> +#include <QtGui/private/qopenglpaintdevice_p.h> +#include <QtGui/private/qopenglcontext_p.h> +#include <QtWidgets/private/qwidget_p.h> + +QT_BEGIN_NAMESPACE + +/*! + \class QOpenGLWidget + \inmodule QtOpenGL + \since 5.4 + + \brief The QOpenGLWidget class is a widget for rendering OpenGL graphics. + + QOpenGLWidget provides functionality for displaying OpenGL graphics + integrated into a Qt application. It is very simple to use: Make + your class inherit from it and use the subclass like any other + QWidget, except that you have the choice between using QPainter and + standard OpenGL rendering commands. + + QOpenGLWidget provides three convenient virtual functions that you + can reimplement in your subclass to perform the typical OpenGL + tasks: + + \list + \li paintGL() - Renders the OpenGL scene. Gets called whenever the widget + needs to be updated. + \li resizeGL() - Sets up the OpenGL viewport, projection, etc. Gets + called whenever the widget has been resized (and also when it + is shown for the first time because all newly created widgets get a + resize event automatically). + \li initializeGL() - Sets up the OpenGL resources and state. Gets called + once before the first time resizeGL() or paintGL() is called. + \endlist + + If you need to trigger a repaint from places other than paintGL() (a + typical example is when using \l{QTimer}{timers} to animate scenes), + you should call the widget's update() function to schedule an update. + + Your widget's OpenGL rendering context is made current when + paintGL(), resizeGL(), or initializeGL() is called. If you need to + call the standard OpenGL API functions from other places (e.g. in + your widget's constructor or in your own paint functions), you + must call makeCurrent() first. + + All rendering happens into an OpenGL framebuffer + object. makeCurrent() ensure that it is bound in the context. Keep + this in mind when creating and binding additional framebuffer + objects in the rendering code in paintGL(). Never re-bind the + framebuffer with ID 0. Instead, call defaultFramebufferObject() to + get the ID that should be bound. + + QOpenGLWidget allows using different OpenGL versions and profiles + when the platform supports it. Just set the requested format via + setFormat(). Keep in mind however that having multiple QOpenGLWidget + instances in the same window requires that they all use the same + format, or at least formats that do not make the contexts + non-sharable. To overcome this issue, prefer using + QSurfaceFormat::setDefaultFormat() instead of setFormat(). + + \note Calling QSurfaceFormat::setDefaultFormat() before constructing + the QApplication instance is mandatory on some platforms (for example, + \macos) when an OpenGL core profile context is requested. This is to + ensure that resource sharing between contexts stays functional as all + internal contexts are created using the correct version and profile. + + \section1 Painting Techniques + + As described above, subclass QOpenGLWidget to render pure 3D content in the + following way: + + \list + + \li Reimplement the initializeGL() and resizeGL() functions to + set up the OpenGL state and provide a perspective transformation. + + \li Reimplement paintGL() to paint the 3D scene, calling only + OpenGL functions. + + \endlist + + It is also possible to draw 2D graphics onto a QOpenGLWidget subclass using QPainter: + + \list + + \li In paintGL(), instead of issuing OpenGL commands, construct a QPainter + object for use on the widget. + + \li Draw primitives using QPainter's member functions. + + \li Direct OpenGL commands can still be issued. However, you must make sure + these are enclosed by a call to the painter's beginNativePainting() and + endNativePainting(). + + \endlist + + When performing drawing using QPainter only, it is also possible to perform + the painting like it is done for ordinary widgets: by reimplementing paintEvent(). + + \list + + \li Reimplement the paintEvent() function. + + \li Construct a QPainter object targeting the widget. Either pass the widget to the + constructor or the QPainter::begin() function. + + \li Draw primitives using QPainter's member functions. + + \li Painting finishes then the QPainter instance is destroyed. Alternatively, + call QPainter::end() explicitly. + + \endlist + + \section1 OpenGL Function Calls, Headers and QOpenGLFunctions + + When making OpenGL function calls, it is strongly recommended to avoid calling + the functions directly. Instead, prefer using QOpenGLFunctions (when making + portable applications) or the versioned variants (for example, + QOpenGLFunctions_3_2_Core and similar, when targeting modern, desktop-only + OpenGL). This way the application will work correctly in all Qt build + configurations, including the ones that perform dynamic OpenGL implementation + loading which means applications are not directly linking to an GL + implementation and thus direct function calls are not feasible. + + In paintGL() the current context is always accessible by caling + QOpenGLContext::currentContext(). From this context an already initialized, + ready-to-be-used QOpenGLFunctions instance is retrievable by calling + QOpenGLContext::functions(). An alternative to prefixing every GL call is to + inherit from QOpenGLFunctions and call + QOpenGLFunctions::initializeOpenGLFunctions() in initializeGL(). + + As for the OpenGL headers, note that in most cases there will be no need to + directly include any headers like GL.h. The OpenGL-related Qt headers will + include qopengl.h which will in turn include an appropriate header for the + system. This might be an OpenGL ES 3.x or 2.0 header, the highest version that + is available, or a system-provided gl.h. In addition, a copy of the extension + headers (called glext.h on some systems) is provided as part of Qt both for + OpenGL and OpenGL ES. These will get included automatically on platforms where + feasible. This means that constants and function pointer typedefs from ARB, + EXT, OES extensions are automatically available. + + \section1 Code Examples + + To get started, the simplest QOpenGLWidget subclass could like like the following: + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 0 + + Alternatively, the prefixing of each and every OpenGL call can be avoided by deriving + from QOpenGLFunctions instead: + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 1 + + To get a context compatible with a given OpenGL version or profile, or to + request depth and stencil buffers, call setFormat(): + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 2 + + With OpenGL 3.0+ contexts, when portability is not important, the versioned + QOpenGLFunctions variants give easy access to all the modern OpenGL functions + available in a given version: + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 3 + + As described above, it is simpler and more robust to set the requested format + globally so that it applies to all windows and contexts during the lifetime of + the application. Below is an example of this: + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 6 + + \section1 Relation to QGLWidget + + The legacy QtOpenGL module (classes prefixed with QGL) provides a widget + called QGLWidget. QOpenGLWidget is intended to be a modern replacement for + it. Therefore, especially in new applications, the general recommendation is + to use QOpenGLWidget. + + While the API is very similar, there is an important difference between the + two: QOpenGLWidget always renders offscreen, using framebuffer + objects. QGLWidget on the other hand uses a native window and surface. The + latter causes issues when using it in complex user interfaces since, depending + on the platform, such native child widgets may have various limitations, + regarding stacking orders for example. QOpenGLWidget avoids this by not + creating a separate native window. + + Due to being backed by a framebuffer object, the behavior of QOpenGLWidget is + very similar to QOpenGLWindow with the update behavior set to \c + PartialUpdateBlit or \c PartialUpdateBlend. This means that the contents are + preserved between paintGL() calls so that incremental rendering is + possible. With QGLWidget (and naturally QOpenGLWindow with the default update + behavior) this is usually not the case because swapping the buffers leaves the + back buffer with undefined contents. + + \note Most applications do not need incremental rendering because they will + render everything in the view on every paint call. In this case it is + important to call glClear() as early as possible in paintGL(). This helps + mobile GPUs that use a tile-based architecture to recognize that the tile + buffer does not need to be reloaded with the framebuffer's previous + contents. Omitting the clear call can lead to significant performance drops on + such systems. + + \note Avoid calling winId() on a QOpenGLWidget. This function triggers the creation of + a native window, resulting in reduced performance and possibly rendering glitches. + + \section1 Differences to QGLWidget + + Besides the main conceptual difference of being backed by a framebuffer object, there + are a number of smaller, internal differences between QOpenGLWidget and the older + QGLWidget: + + \list + + \li OpenGL state when invoking paintGL(). QOpenGLWidget sets up the viewport via + glViewport(). It does not perform any clearing. + + \li Clearing when starting to paint via QPainter. Unlike regular widgets, QGLWidget + defaulted to a value of \c true for + \l{QWidget::autoFillBackground()}{autoFillBackground}. It then performed clearing to the + palette's background color every time QPainter::begin() was used. QOpenGLWidget does not + follow this: \l{QWidget::autoFillBackground()}{autoFillBackground} defaults to false, + like for any other widget. The only exception is when being used as a viewport for other + widgets like QGraphicsView. In such a case autoFillBackground will be automatically set + to true to ensure compatibility with QGLWidget-based viewports. + + \endlist + + \section1 Multisampling + + To enable multisampling, set the number of requested samples on the + QSurfaceFormat that is passed to setFormat(). On systems that do not support + it the request may get ignored. + + Multisampling support requires support for multisampled renderbuffers and + framebuffer blits. On OpenGL ES 2.0 implementations it is likely that these + will not be present. This means that multisampling will not be available. With + modern OpenGL versions and OpenGL ES 3.0 and up this is usually not a problem + anymore. + + \section1 Threading + + Performing offscreen rendering on worker threads, for example to generate + textures that are then used in the GUI/main thread in paintGL(), are supported + by exposing the widget's QOpenGLContext so that additional contexts sharing + with it can be created on each thread. + + Drawing directly to the QOpenGLWidget's framebuffer outside the GUI/main + thread is possible by reimplementing paintEvent() to do nothing. The context's + thread affinity has to be changed via QObject::moveToThread(). After that, + makeCurrent() and doneCurrent() are usable on the worker thread. Be careful to + move the context back to the GUI/main thread afterwards. + + Unlike QGLWidget, triggering a buffer swap just for the QOpenGLWidget is not + possible since there is no real, onscreen native surface for it. Instead, it + is up to the widget stack to manage composition and buffer swaps on the gui + thread. When a thread is done updating the framebuffer, call update() \b{on + the GUI/main thread} to schedule composition. + + Extra care has to be taken to avoid using the framebuffer when the GUI/main + thread is performing compositing. The signals aboutToCompose() and + frameSwapped() will be emitted when the composition is starting and + ending. They are emitted on the GUI/main thread. This means that by using a + direct connection aboutToCompose() can block the GUI/main thread until the + worker thread has finished its rendering. After that, the worker thread must + perform no further rendering until the frameSwapped() signal is emitted. If + this is not acceptable, the worker thread has to implement a double buffering + mechanism. This involves drawing using an alternative render target, that is + fully controlled by the thread, e.g. an additional framebuffer object, and + blitting to the QOpenGLWidget's framebuffer at a suitable time. + + \section1 Context Sharing + + When multiple QOpenGLWidgets are added as children to the same top-level + widget, their contexts will share with each other. This does not apply for + QOpenGLWidget instances that belong to different windows. + + This means that all QOpenGLWidgets in the same window can access each other's + sharable resources, like textures, and there is no need for an extra "global + share" context, as was the case with QGLWidget. + + To set up sharing between QOpenGLWidget instances belonging to different + windows, set the Qt::AA_ShareOpenGLContexts application attribute before + instantiating QApplication. This will trigger sharing between all + QOpenGLWidget instances without any further steps. + + Creating extra QOpenGLContext instances that share resources like textures + with the QOpenGLWidget's context is also possible. Simply pass the pointer + returned from context() to QOpenGLContext::setShareContext() before calling + QOpenGLContext::create(). The resulting context can also be used on a + different thread, allowing threaded generation of textures and asynchronous + texture uploads. + + Note that QOpenGLWidget expects a standard conformant implementation of + resource sharing when it comes to the underlying graphics drivers. For + example, some drivers, in particular for mobile and embedded hardware, have + issues with setting up sharing between an existing context and others that are + created later. Some other drivers may behave in unexpected ways when trying to + utilize shared resources between different threads. + + \section1 Resource Initialization and Cleanup + + The QOpenGLWidget's associated OpenGL context is guaranteed to be current + whenever initializeGL() and paintGL() are invoked. Do not attempt to create + OpenGL resources before initializeGL() is called. For example, attempting to + compile shaders, initialize vertex buffer objects or upload texture data will + fail when done in a subclass's constructor. These operations must be deferred + to initializeGL(). Some of Qt's OpenGL helper classes, like QOpenGLBuffer or + QOpenGLVertexArrayObject, have a matching deferred behavior: they can be + instantiated without a context, but all initialization is deferred until a + create(), or similar, call. This means that they can be used as normal + (non-pointer) member variables in a QOpenGLWidget subclass, but the create() + or similar function can only be called from initializeGL(). Be aware however + that not all classes are designed like this. When in doubt, make the member + variable a pointer and create and destroy the instance dynamically in + initializeGL() and the destructor, respectively. + + Releasing the resources also needs the context to be current. Therefore + destructors that perform such cleanup are expected to call makeCurrent() + before moving on to destroy any OpenGL resources or wrappers. Avoid deferred + deletion via \l{QObject::deleteLater()}{deleteLater()} or the parenting + mechanism of QObject. There is no guarantee the correct context will be + current at the time the instance in question is really destroyed. + + A typical subclass will therefore often look like the following when it comes + to resource initialization and destruction: + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 4 + + This is naturally not the only possible solution. One alternative is to use + the \l{QOpenGLContext::aboutToBeDestroyed()}{aboutToBeDestroyed()} signal of + QOpenGLContext. By connecting a slot, using direct connection, to this signal, + it is possible to perform cleanup whenever the the underlying native context + handle, or the entire QOpenGLContext instance, is going to be released. The + following snippet is in principle equivalent to the previous one: + + \snippet code/doc_gui_widgets_qopenglwidget.cpp 5 + + \note For widgets that change their associated top-level window multiple times + during their lifetime, a combined approach is essential. Whenever the widget + or a parent of it gets reparented so that the top-level window becomes + different, the widget's associated context is destroyed and a new one is + created. This is then followed by a call to initializeGL() where all OpenGL + resources must get reinitialized. Due to this the only option to perform + proper cleanup is to connect to the context's aboutToBeDestroyed() + signal. Note that the context in question may not be the current one when the + signal gets emitted. Therefore it is good practice to call makeCurrent() in + the connected slot. Additionally, the same cleanup steps must be performed + from the derived class' destructor, since the slot connected to the signal + will not get invoked when the widget is being destroyed. + + \note When Qt::AA_ShareOpenGLContexts is set, the widget's context never + changes, not even when reparenting because the widget's associated texture is + guaranteed to be accessible also from the new top-level's context. + + Proper cleanup is especially important due to context sharing. Even though + each QOpenGLWidget's associated context is destroyed together with the + QOpenGLWidget, the sharable resources in that context, like textures, will + stay valid until the top-level window, in which the QOpenGLWidget lived, is + destroyed. Additionally, settings like Qt::AA_ShareOpenGLContexts and some Qt + modules may trigger an even wider scope for sharing contexts, potentially + leading to keeping the resources in question alive for the entire lifetime of + the application. Therefore the safest and most robust is always to perform + explicit cleanup for all resources and resource wrappers used in the + QOpenGLWidget. + + \section1 Limitations + + Putting other widgets underneath and making the QOpenGLWidget transparent will + not lead to the expected results: The widgets underneath will not be + visible. This is because in practice the QOpenGLWidget is drawn before all + other regular, non-OpenGL widgets, and so see-through type of solutions are + not feasible. Other type of layouts, like having widgets on top of the + QOpenGLWidget, will function as expected. + + When absolutely necessary, this limitation can be overcome by setting the + Qt::WA_AlwaysStackOnTop attribute on the QOpenGLWidget. Be aware however that + this breaks stacking order, for example it will not be possible to have other + widgets on top of the QOpenGLWidget, so it should only be used in situations + where a semi-transparent QOpenGLWidget with other widgets visible underneath + is required. + + Note that this does not apply when there are no other widgets underneath and + the intention is to have a semi-transparent window. In that case the + traditional approach of setting Qt::WA_TranslucentBackground + on the top-level window is sufficient. Note that if the transparent areas are + only desired in the QOpenGLWidget, then Qt::WA_NoSystemBackground will need + to be turned back to \c false after enabling Qt::WA_TranslucentBackground. + Additionally, requesting an alpha channel for the QOpenGLWidget's context via + setFormat() may be necessary too, depending on the system. + + QOpenGLWidget supports multiple update behaviors, just like QOpenGLWindow. In + preserved mode the rendered content from the previous paintGL() call is + available in the next one, allowing incremental rendering. In non-preserved + mode the content is lost and paintGL() implementations are expected to redraw + everything in the view. + + Before Qt 5.5 the default behavior of QOpenGLWidget was to preserve the + rendered contents between paintGL() calls. Since Qt 5.5 the default behavior + is non-preserved because this provides better performance and the majority of + applications have no need for the previous content. This also resembles the + semantics of an OpenGL-based QWindow and matches the default behavior of + QOpenGLWindow in that the color and ancillary buffers are invalidated for + each frame. To restore the preserved behavior, call setUpdateBehavior() with + \c PartialUpdate. + + \section1 Alternatives + + Adding a QOpenGLWidget into a window turns on OpenGL-based + compositing for the entire window. In some special cases this may + not be ideal, and the old QGLWidget-style behavior with a separate, + native child window is desired. Desktop applications that understand + the limitations of this approach (for example when it comes to + overlaps, transparency, scroll views and MDI areas), can use + QOpenGLWindow with QWidget::createWindowContainer(). This is a + modern alternative to QGLWidget and is faster than QOpenGLWidget due + to the lack of the additional composition step. It is strongly + recommended to limit the usage of this approach to cases where there + is no other choice. Note that this option is not suitable for most + embedded and mobile platforms, and it is known to have issues on + certain desktop platforms (e.g. \macos) too. The stable, + cross-platform solution is always QOpenGLWidget. + + \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other + countries.} + + \sa QOpenGLFunctions, QOpenGLWindow, Qt::AA_ShareOpenGLContexts, UpdateBehavior +*/ + +/*! + \fn void QOpenGLWidget::aboutToCompose() + + This signal is emitted when the widget's top-level window is about to begin + composing the textures of its QOpenGLWidget children and the other widgets. +*/ + +/*! + \fn void QOpenGLWidget::frameSwapped() + + This signal is emitted after the widget's top-level window has finished + composition and returned from its potentially blocking + QOpenGLContext::swapBuffers() call. +*/ + +/*! + \fn void QOpenGLWidget::aboutToResize() + + This signal is emitted when the widget's size is changed and therefore the + framebuffer object is going to be recreated. +*/ + +/*! + \fn void QOpenGLWidget::resized() + + This signal is emitted right after the framebuffer object has been recreated + due to resizing the widget. +*/ + +/*! + \enum QOpenGLWidget::UpdateBehavior + \since 5.5 + + This enum describes the update semantics of QOpenGLWidget. + + \value NoPartialUpdate QOpenGLWidget will discard the + contents of the color buffer and the ancillary buffers after the + QOpenGLWidget is rendered to screen. This is the same behavior that can be + expected by calling QOpenGLContext::swapBuffers with a default opengl + enabled QWindow as the argument. NoPartialUpdate can have some performance + benefits on certain hardware architectures common in the mobile and + embedded space when a framebuffer object is used as the rendering target. + The framebuffer object is invalidated between frames with + glDiscardFramebufferEXT if supported or a glClear. Please see the + documentation of EXT_discard_framebuffer for more information: + https://www.khronos.org/registry/gles/extensions/EXT/EXT_discard_framebuffer.txt + + \value PartialUpdate The framebuffer objects color buffer and ancillary + buffers are not invalidated between frames. + + \sa updateBehavior(), setUpdateBehavior() +*/ + +class QOpenGLWidgetPaintDevicePrivate : public QOpenGLPaintDevicePrivate +{ +public: + QOpenGLWidgetPaintDevicePrivate(QOpenGLWidget *widget) + : QOpenGLPaintDevicePrivate(QSize()), + w(widget) { } + + void beginPaint() override; + void endPaint() override; + + QOpenGLWidget *w; +}; + +class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice +{ +public: + QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) + : QOpenGLPaintDevice(*new QOpenGLWidgetPaintDevicePrivate(widget)) { } + void ensureActiveTarget() override; +}; + +class QOpenGLWidgetPrivate : public QWidgetPrivate +{ + Q_DECLARE_PUBLIC(QOpenGLWidget) +public: + QOpenGLWidgetPrivate() + : context(nullptr), + fbo(nullptr), + resolvedFbo(nullptr), + surface(nullptr), + initialized(false), + fakeHidden(false), + inBackingStorePaint(false), + hasBeenComposed(false), + flushPending(false), + paintDevice(nullptr), + updateBehavior(QOpenGLWidget::NoPartialUpdate), + requestedSamples(0), + inPaintGL(false), + textureFormat(0) + { + requestedFormat = QSurfaceFormat::defaultFormat(); + } + + void reset(); + void recreateFbo(); + + GLuint textureId() const override; + QPlatformTextureList::Flags textureListFlags() override; + + void initialize(); + void invokeUserPaint(); + void render(); + + void invalidateFbo(); + + QImage grabFramebuffer() override; + void beginBackingStorePainting() override { inBackingStorePaint = true; } + void endBackingStorePainting() override { inBackingStorePaint = false; } + void beginCompose() override; + void endCompose() override; + void initializeViewportFramebuffer() override; + void resizeViewportFramebuffer() override; + void resolveSamples() override; + + QOpenGLContext *context; + QOpenGLFramebufferObject *fbo; + QOpenGLFramebufferObject *resolvedFbo; + QOffscreenSurface *surface; + bool initialized; + bool fakeHidden; + bool inBackingStorePaint; + bool hasBeenComposed; + bool flushPending; + QOpenGLPaintDevice *paintDevice; + QSurfaceFormat requestedFormat; + QOpenGLWidget::UpdateBehavior updateBehavior; + int requestedSamples; + bool inPaintGL; + GLenum textureFormat; +}; + +void QOpenGLWidgetPaintDevicePrivate::beginPaint() +{ + // NB! autoFillBackground is and must be false by default. Otherwise we would clear on + // every QPainter begin() which is not desirable. This is only for legacy use cases, + // like using QOpenGLWidget as the viewport of a graphics view, that expect clearing + // with the palette's background color. + if (w->autoFillBackground()) { + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + if (w->format().hasAlpha()) { + f->glClearColor(0, 0, 0, 0); + } else { + QColor c = w->palette().brush(w->backgroundRole()).color(); + float alpha = c.alphaF(); + f->glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + } + f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } +} + +void QOpenGLWidgetPaintDevicePrivate::endPaint() +{ + QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(w)); + if (!wd->initialized) + return; + + if (!wd->inPaintGL) + QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = 0; +} + +void QOpenGLWidgetPaintDevice::ensureActiveTarget() +{ + QOpenGLWidgetPaintDevicePrivate *d = static_cast<QOpenGLWidgetPaintDevicePrivate *>(d_ptr.data()); + QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(d->w)); + if (!wd->initialized) + return; + + if (QOpenGLContext::currentContext() != wd->context) + d->w->makeCurrent(); + else + wd->fbo->bind(); + + if (!wd->inPaintGL) + QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = wd->fbo->handle(); + + // When used as a viewport, drawing is done via opening a QPainter on the widget + // without going through paintEvent(). We will have to make sure a glFlush() is done + // before the texture is accessed also in this case. + wd->flushPending = true; +} + +GLuint QOpenGLWidgetPrivate::textureId() const +{ + return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); +} + +#ifndef GL_SRGB +#define GL_SRGB 0x8C40 +#endif +#ifndef GL_SRGB8 +#define GL_SRGB8 0x8C41 +#endif +#ifndef GL_SRGB_ALPHA +#define GL_SRGB_ALPHA 0x8C42 +#endif +#ifndef GL_SRGB8_ALPHA8 +#define GL_SRGB8_ALPHA8 0x8C43 +#endif + +QPlatformTextureList::Flags QOpenGLWidgetPrivate::textureListFlags() +{ + QPlatformTextureList::Flags flags = QWidgetPrivate::textureListFlags(); + switch (textureFormat) { + case GL_SRGB: + case GL_SRGB8: + case GL_SRGB_ALPHA: + case GL_SRGB8_ALPHA8: + flags |= QPlatformTextureList::TextureIsSrgb; + break; + default: + break; + } + return flags; +} + +void QOpenGLWidgetPrivate::reset() +{ + Q_Q(QOpenGLWidget); + + // Destroy the OpenGL resources first. These need the context to be current. + if (initialized) + q->makeCurrent(); + + delete paintDevice; + paintDevice = nullptr; + delete fbo; + fbo = nullptr; + delete resolvedFbo; + resolvedFbo = nullptr; + + if (initialized) + q->doneCurrent(); + + // Delete the context first, then the surface. Slots connected to + // the context's aboutToBeDestroyed() may still call makeCurrent() + // to perform some cleanup. + delete context; + context = nullptr; + delete surface; + surface = nullptr; + initialized = fakeHidden = inBackingStorePaint = false; +} + +void QOpenGLWidgetPrivate::recreateFbo() +{ + Q_Q(QOpenGLWidget); + + emit q->aboutToResize(); + + context->makeCurrent(surface); + + delete fbo; + fbo = nullptr; + delete resolvedFbo; + resolvedFbo = nullptr; + + int samples = requestedSamples; + QOpenGLExtensions *extfuncs = static_cast<QOpenGLExtensions *>(context->functions()); + if (!extfuncs->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) + samples = 0; + + QOpenGLFramebufferObjectFormat format; + format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + format.setSamples(samples); + if (textureFormat) + format.setInternalTextureFormat(textureFormat); + + const QSize deviceSize = q->size() * q->devicePixelRatioF(); + fbo = new QOpenGLFramebufferObject(deviceSize, format); + if (samples > 0) + resolvedFbo = new QOpenGLFramebufferObject(deviceSize); + + textureFormat = fbo->format().internalTextureFormat(); + + fbo->bind(); + context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + flushPending = true; // Make sure the FBO is initialized before use + + paintDevice->setSize(deviceSize); + paintDevice->setDevicePixelRatio(q->devicePixelRatioF()); + + emit q->resized(); +} + +void QOpenGLWidgetPrivate::beginCompose() +{ + Q_Q(QOpenGLWidget); + if (flushPending) { + flushPending = false; + q->makeCurrent(); + static_cast<QOpenGLExtensions *>(context->functions())->flushShared(); + } + hasBeenComposed = true; + emit q->aboutToCompose(); +} + +void QOpenGLWidgetPrivate::endCompose() +{ + Q_Q(QOpenGLWidget); + emit q->frameSwapped(); +} + +void QOpenGLWidgetPrivate::initialize() +{ + Q_Q(QOpenGLWidget); + if (initialized) + return; + + // If no global shared context get our toplevel's context with which we + // will share in order to make the texture usable by the underlying window's backingstore. + QWidget *tlw = q->window(); + QOpenGLContext *shareContext = qt_gl_global_share_context(); + if (!shareContext) + shareContext = get(tlw)->shareContext(); + // If shareContext is null, showing content on-screen will not work. + // However, offscreen rendering and grabFramebuffer() will stay fully functional. + + // Do not include the sample count. Requesting a multisampled context is not necessary + // since we render into an FBO, never to an actual surface. What's more, attempting to + // create a pbuffer with a multisampled config crashes certain implementations. Just + // avoid the entire hassle, the result is the same. + requestedSamples = requestedFormat.samples(); + requestedFormat.setSamples(0); + + QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext); + ctx->setFormat(requestedFormat); + if (shareContext) { + ctx->setShareContext(shareContext); + ctx->setScreen(shareContext->screen()); + } + if (Q_UNLIKELY(!ctx->create())) { + qWarning("QOpenGLWidget: Failed to create context"); + return; + } + + // Propagate settings that make sense only for the tlw. Note that this only + // makes sense for properties that get picked up even after the native + // window is created. + if (tlw->windowHandle()) { + QSurfaceFormat tlwFormat = tlw->windowHandle()->format(); + if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) { + // Most platforms will pick up the changed swap interval on the next + // makeCurrent or swapBuffers. + tlwFormat.setSwapInterval(requestedFormat.swapInterval()); + tlw->windowHandle()->setFormat(tlwFormat); + } + if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) { + tlwFormat.setSwapBehavior(requestedFormat.swapBehavior()); + tlw->windowHandle()->setFormat(tlwFormat); + } + } + + // The top-level window's surface is not good enough since it causes way too + // much trouble with regards to the QSurfaceFormat for example. So just like + // in QQuickWidget, use a dedicated QOffscreenSurface. + surface = new QOffscreenSurface; + surface->setFormat(ctx->format()); + surface->setScreen(ctx->screen()); + surface->create(); + + if (Q_UNLIKELY(!ctx->makeCurrent(surface))) { + qWarning("QOpenGLWidget: Failed to make context current"); + return; + } + + paintDevice = new QOpenGLWidgetPaintDevice(q); + paintDevice->setSize(q->size() * q->devicePixelRatioF()); + paintDevice->setDevicePixelRatio(q->devicePixelRatioF()); + + context = ctx.take(); + initialized = true; + + q->initializeGL(); +} + +void QOpenGLWidgetPrivate::resolveSamples() +{ + Q_Q(QOpenGLWidget); + if (resolvedFbo) { + q->makeCurrent(); + QRect rect(QPoint(0, 0), fbo->size()); + QOpenGLFramebufferObject::blitFramebuffer(resolvedFbo, rect, fbo, rect); + flushPending = true; + } +} + +void QOpenGLWidgetPrivate::invokeUserPaint() +{ + Q_Q(QOpenGLWidget); + + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + Q_ASSERT(ctx && fbo); + + QOpenGLFunctions *f = ctx->functions(); + QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle(); + + f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF()); + inPaintGL = true; + q->paintGL(); + inPaintGL = false; + flushPending = true; + + QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0; +} + +void QOpenGLWidgetPrivate::render() +{ + Q_Q(QOpenGLWidget); + + if (fakeHidden || !initialized) + return; + + q->makeCurrent(); + + if (updateBehavior == QOpenGLWidget::NoPartialUpdate && hasBeenComposed) { + invalidateFbo(); + hasBeenComposed = false; + } + + invokeUserPaint(); +} + +void QOpenGLWidgetPrivate::invalidateFbo() +{ + QOpenGLExtensions *f = static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions()); + if (f->hasOpenGLExtension(QOpenGLExtensions::DiscardFramebuffer)) { + const int gl_color_attachment0 = 0x8CE0; // GL_COLOR_ATTACHMENT0 + const int gl_depth_attachment = 0x8D00; // GL_DEPTH_ATTACHMENT + const int gl_stencil_attachment = 0x8D20; // GL_STENCIL_ATTACHMENT +#ifdef Q_OS_WASM + // webgl does not allow separate depth and stencil attachments + // QTBUG-69913 + const int gl_depth_stencil_attachment = 0x821A; // GL_DEPTH_STENCIL_ATTACHMENT + + const GLenum attachments[] = { + gl_color_attachment0, gl_depth_attachment, gl_stencil_attachment, gl_depth_stencil_attachment + }; +#else + const GLenum attachments[] = { + gl_color_attachment0, gl_depth_attachment, gl_stencil_attachment + }; +#endif + f->glDiscardFramebufferEXT(GL_FRAMEBUFFER, sizeof attachments / sizeof *attachments, attachments); + } else { + f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } +} + +extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); + +QImage QOpenGLWidgetPrivate::grabFramebuffer() +{ + Q_Q(QOpenGLWidget); + + initialize(); + if (!initialized) + return QImage(); + + if (!fbo) // could be completely offscreen, without ever getting a resize event + recreateFbo(); + + if (!inPaintGL) + render(); + + if (resolvedFbo) { + resolveSamples(); + resolvedFbo->bind(); + } else { + q->makeCurrent(); + } + + const bool hasAlpha = q->format().hasAlpha(); + QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), hasAlpha, hasAlpha); + res.setDevicePixelRatio(q->devicePixelRatioF()); + + // While we give no guarantees of what is going to be left bound, prefer the + // multisample fbo instead of the resolved one. Clients may continue to + // render straight after calling this function. + if (resolvedFbo) + q->makeCurrent(); + + return res; +} + +void QOpenGLWidgetPrivate::initializeViewportFramebuffer() +{ + Q_Q(QOpenGLWidget); + // Legacy behavior for compatibility with QGLWidget when used as a graphics view + // viewport: enable clearing on each painter begin. + q->setAutoFillBackground(true); +} + +void QOpenGLWidgetPrivate::resizeViewportFramebuffer() +{ + Q_Q(QOpenGLWidget); + if (!initialized) + return; + + if (!fbo || q->size() * q->devicePixelRatioF() != fbo->size()) { + recreateFbo(); + q->update(); + } +} + +/*! + Constructs a widget which is a child of \a parent, with widget flags set to \a f. + */ +QOpenGLWidget::QOpenGLWidget(QWidget *parent, Qt::WindowFlags f) + : QWidget(*(new QOpenGLWidgetPrivate), parent, f) +{ + Q_D(QOpenGLWidget); + if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface))) + qWarning("QOpenGLWidget is not supported on this platform."); + else + d->setRenderToTexture(); +} + +/*! + Destroys the QOpenGLWidget instance, freeing its resources. + + The QOpenGLWidget's context is made current in the destructor, allowing for + safe destruction of any child object that may need to release OpenGL + resources belonging to the context provided by this widget. + + \warning if you have objects wrapping OpenGL resources (such as + QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a OpenGLWidget + subclass, you may need to add a call to makeCurrent() in that subclass' + destructor as well. Due to the rules of C++ object destruction, those objects + will be destroyed \e{before} calling this function (but after that the + destructor of the subclass has run), therefore making the OpenGL context + current in this function happens too late for their safe disposal. + + \sa makeCurrent +*/ +QOpenGLWidget::~QOpenGLWidget() +{ + Q_D(QOpenGLWidget); + d->reset(); +} + +/*! + Sets this widget's update behavior to \a updateBehavior. + \since 5.5 +*/ +void QOpenGLWidget::setUpdateBehavior(UpdateBehavior updateBehavior) +{ + Q_D(QOpenGLWidget); + d->updateBehavior = updateBehavior; +} + +/*! + \return the update behavior of the widget. + \since 5.5 +*/ +QOpenGLWidget::UpdateBehavior QOpenGLWidget::updateBehavior() const +{ + Q_D(const QOpenGLWidget); + return d->updateBehavior; +} + +/*! + Sets the requested surface \a format. + + When the format is not explicitly set via this function, the format returned by + QSurfaceFormat::defaultFormat() will be used. This means that when having multiple + OpenGL widgets, individual calls to this function can be replaced by one single call to + QSurfaceFormat::setDefaultFormat() before creating the first widget. + + \note Requesting an alpha buffer via this function will not lead to the + desired results when the intention is to make other widgets beneath visible. + Instead, use Qt::WA_AlwaysStackOnTop to enable semi-transparent QOpenGLWidget + instances with other widgets visible underneath. Keep in mind however that + this breaks the stacking order, so it will no longer be possible to have + other widgets on top of the QOpenGLWidget. + + \sa format(), Qt::WA_AlwaysStackOnTop, QSurfaceFormat::setDefaultFormat() + */ +void QOpenGLWidget::setFormat(const QSurfaceFormat &format) +{ + Q_D(QOpenGLWidget); + if (Q_UNLIKELY(d->initialized)) { + qWarning("QOpenGLWidget: Already initialized, setting the format has no effect"); + return; + } + + d->requestedFormat = format; +} + +/*! + Returns the context and surface format used by this widget and its toplevel + window. + + After the widget and its toplevel have both been created, resized and shown, + this function will return the actual format of the context. This may differ + from the requested format if the request could not be fulfilled by the + platform. It is also possible to get larger color buffer sizes than + requested. + + When the widget's window and the related OpenGL resources are not yet + initialized, the return value is the format that has been set via + setFormat(). + + \sa setFormat(), context() + */ +QSurfaceFormat QOpenGLWidget::format() const +{ + Q_D(const QOpenGLWidget); + return d->initialized ? d->context->format() : d->requestedFormat; +} + +/*! + Sets a custom internal texture format of \a texFormat. + + When working with sRGB framebuffers, it will be necessary to specify a + format like \c{GL_SRGB8_ALPHA8}. This can be achieved by calling this + function. + + \note This function has no effect if called after the widget has already + been shown and thus it performed initialization. + + \note This function will typically have to be used in combination with a + QSurfaceFormat::setDefaultFormat() call that sets the color space to + QSurfaceFormat::sRGBColorSpace. + + \since 5.10 + */ +void QOpenGLWidget::setTextureFormat(GLenum texFormat) +{ + Q_D(QOpenGLWidget); + if (Q_UNLIKELY(d->initialized)) { + qWarning("QOpenGLWidget: Already initialized, setting the internal texture format has no effect"); + return; + } + + d->textureFormat = texFormat; +} + +/*! + \return the active internal texture format if the widget has already + initialized, the requested format if one was set but the widget has not yet + been made visible, or \nullptr if setTextureFormat() was not called and the + widget has not yet been made visible. + + \since 5.10 + */ +GLenum QOpenGLWidget::textureFormat() const +{ + Q_D(const QOpenGLWidget); + return d->textureFormat; +} + +/*! + \return \e true if the widget and OpenGL resources, like the context, have + been successfully initialized. Note that the return value is always false + until the widget is shown. +*/ +bool QOpenGLWidget::isValid() const +{ + Q_D(const QOpenGLWidget); + return d->initialized && d->context->isValid(); +} + +/*! + Prepares for rendering OpenGL content for this widget by making the + corresponding context current and binding the framebuffer object in that + context. + + It is not necessary to call this function in most cases, because it + is called automatically before invoking paintGL(). + + \sa context(), paintGL(), doneCurrent() + */ +void QOpenGLWidget::makeCurrent() +{ + Q_D(QOpenGLWidget); + if (!d->initialized) + return; + + d->context->makeCurrent(d->surface); + + if (d->fbo) // there may not be one if we are in reset() + d->fbo->bind(); +} + +/*! + Releases the context. + + It is not necessary to call this function in most cases, since the + widget will make sure the context is bound and released properly + when invoking paintGL(). + */ +void QOpenGLWidget::doneCurrent() +{ + Q_D(QOpenGLWidget); + if (!d->initialized) + return; + + d->context->doneCurrent(); +} + +/*! + \return The QOpenGLContext used by this widget or \c 0 if not yet initialized. + + \note The context and the framebuffer object used by the widget changes when + reparenting the widget via setParent(). + + \sa QOpenGLContext::setShareContext(), defaultFramebufferObject() + */ +QOpenGLContext *QOpenGLWidget::context() const +{ + Q_D(const QOpenGLWidget); + return d->context; +} + +/*! + \return The framebuffer object handle or \c 0 if not yet initialized. + + \note The framebuffer object belongs to the context returned by context() + and may not be accessible from other contexts. + + \note The context and the framebuffer object used by the widget changes when + reparenting the widget via setParent(). In addition, the framebuffer object + changes on each resize. + + \sa context() + */ +GLuint QOpenGLWidget::defaultFramebufferObject() const +{ + Q_D(const QOpenGLWidget); + return d->fbo ? d->fbo->handle() : 0; +} + +/*! + This virtual function is called once before the first call to + paintGL() or resizeGL(). Reimplement it in a subclass. + + This function should set up any required OpenGL resources and state. + + There is no need to call makeCurrent() because this has already been + done when this function is called. Note however that the framebuffer + is not yet available at this stage, so avoid issuing draw calls from + here. Defer such calls to paintGL() instead. + + \sa paintGL(), resizeGL() +*/ +void QOpenGLWidget::initializeGL() +{ +} + +/*! + This virtual function is called whenever the widget has been + resized. Reimplement it in a subclass. The new size is passed in + \a w and \a h. + + There is no need to call makeCurrent() because this has already been + done when this function is called. Additionally, the framebuffer is + also bound. + + \sa initializeGL(), paintGL() +*/ +void QOpenGLWidget::resizeGL(int w, int h) +{ + Q_UNUSED(w); + Q_UNUSED(h); +} + +/*! + This virtual function is called whenever the widget needs to be + painted. Reimplement it in a subclass. + + There is no need to call makeCurrent() because this has already + been done when this function is called. + + Before invoking this function, the context and the framebuffer are + bound, and the viewport is set up by a call to glViewport(). No + other state is set and no clearing or drawing is performed by the + framework. + + \sa initializeGL(), resizeGL() +*/ +void QOpenGLWidget::paintGL() +{ +} + +/*! + Handles resize events that are passed in the \a e event parameter. + Calls the virtual function resizeGL(). + + \note Avoid overriding this function in derived classes. If that is not + feasible, make sure that QOpenGLWidget's implementation is invoked + too. Otherwise the underlying framebuffer object and related resources will + not get resized properly and will lead to incorrect rendering. +*/ +void QOpenGLWidget::resizeEvent(QResizeEvent *e) +{ + Q_D(QOpenGLWidget); + + if (e->size().isEmpty()) { + d->fakeHidden = true; + return; + } + d->fakeHidden = false; + + d->initialize(); + if (!d->initialized) + return; + + d->recreateFbo(); + resizeGL(width(), height()); + d->sendPaintEvent(QRect(QPoint(0, 0), size())); +} + +/*! + Handles paint events. + + Calling QWidget::update() will lead to sending a paint event \a e, + and thus invoking this function. (NB this is asynchronous and will + happen at some point after returning from update()). This function + will then, after some preparation, call the virtual paintGL() to + update the contents of the QOpenGLWidget's framebuffer. The widget's + top-level window will then composite the framebuffer's texture with + the rest of the window. +*/ +void QOpenGLWidget::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + Q_D(QOpenGLWidget); + if (!d->initialized) + return; + + if (updatesEnabled()) + d->render(); +} + +/*! + Renders and returns a 32-bit RGB image of the framebuffer. + + \note This is a potentially expensive operation because it relies on glReadPixels() + to read back the pixels. This may be slow and can stall the GPU pipeline. +*/ +QImage QOpenGLWidget::grabFramebuffer() +{ + Q_D(QOpenGLWidget); + return d->grabFramebuffer(); +} + +/*! + \internal +*/ +int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const +{ + Q_D(const QOpenGLWidget); + if (d->inBackingStorePaint) + return QWidget::metric(metric); + + auto window = d->windowHandle(QWidgetPrivate::WindowHandleMode::TopLevel); + QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen(); + + const float dpmx = qt_defaultDpiX() * 100. / 2.54; + const float dpmy = qt_defaultDpiY() * 100. / 2.54; + + switch (metric) { + case PdmWidth: + return width(); + case PdmHeight: + return height(); + case PdmDepth: + return 32; + case PdmWidthMM: + if (screen) + return width() * screen->physicalSize().width() / screen->geometry().width(); + else + return width() * 1000 / dpmx; + case PdmHeightMM: + if (screen) + return height() * screen->physicalSize().height() / screen->geometry().height(); + else + return height() * 1000 / dpmy; + case PdmNumColors: + return 0; + case PdmDpiX: + if (screen) + return qRound(screen->logicalDotsPerInchX()); + else + return qRound(dpmx * 0.0254); + case PdmDpiY: + if (screen) + return qRound(screen->logicalDotsPerInchY()); + else + return qRound(dpmy * 0.0254); + case PdmPhysicalDpiX: + if (screen) + return qRound(screen->physicalDotsPerInchX()); + else + return qRound(dpmx * 0.0254); + case PdmPhysicalDpiY: + if (screen) + return qRound(screen->physicalDotsPerInchY()); + else + return qRound(dpmy * 0.0254); + case PdmDevicePixelRatio: + if (window) + return int(window->devicePixelRatio()); + else + return 1.0; + case PdmDevicePixelRatioScaled: + if (window) + return int(window->devicePixelRatio() * devicePixelRatioFScale()); + else + return int(devicePixelRatioFScale()); + default: + qWarning("QOpenGLWidget::metric(): unknown metric %d", metric); + return 0; + } +} + +/*! + \internal +*/ +QPaintDevice *QOpenGLWidget::redirected(QPoint *p) const +{ + Q_D(const QOpenGLWidget); + if (d->inBackingStorePaint) + return QWidget::redirected(p); + + return d->paintDevice; +} + +/*! + \internal +*/ +QPaintEngine *QOpenGLWidget::paintEngine() const +{ + Q_D(const QOpenGLWidget); + // QWidget needs to "punch a hole" into the backingstore. This needs the + // normal paint engine and device, not the GL one. So in this mode, behave + // like a normal widget. + if (d->inBackingStorePaint) + return QWidget::paintEngine(); + + if (!d->initialized) + return nullptr; + + return d->paintDevice->paintEngine(); +} + +/*! + \internal +*/ +bool QOpenGLWidget::event(QEvent *e) +{ + Q_D(QOpenGLWidget); + switch (e->type()) { + case QEvent::WindowChangeInternal: + if (QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) + break; + if (d->initialized) + d->reset(); + if (isHidden()) + break; + Q_FALLTHROUGH(); + case QEvent::Show: // reparenting may not lead to a resize so reinitalize on Show too + if (d->initialized && window()->windowHandle() + && d->context->shareContext() != QWidgetPrivate::get(window())->shareContext()) + { + // Special case: did grabFramebuffer() for a hidden widget that then became visible. + // Recreate all resources since the context now needs to share with the TLW's. + if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) + d->reset(); + } + if (!d->initialized && !size().isEmpty() && window()->windowHandle()) { + d->initialize(); + if (d->initialized) + d->recreateFbo(); + } + break; + case QEvent::ScreenChangeInternal: + if (d->initialized && d->paintDevice->devicePixelRatioF() != devicePixelRatioF()) + d->recreateFbo(); + break; + default: + break; + } + return QWidget::event(e); +} + +QT_END_NAMESPACE + +#include "moc_qopenglwidget.cpp" diff --git a/src/opengl/qopenglwidget.h b/src/opengl/qopenglwidget.h new file mode 100644 index 0000000000..b331880b5d --- /dev/null +++ b/src/opengl/qopenglwidget.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGLWIDGET_H +#define QOPENGLWIDGET_H + +#include <QtOpenGL/qtopenglglobal.h> + +#ifndef QT_NO_OPENGL + +#include <QtWidgets/QWidget> +#include <QtGui/QSurfaceFormat> +#include <QtGui/qopengl.h> + +QT_BEGIN_NAMESPACE + +class QOpenGLWidgetPrivate; + +class Q_OPENGL_EXPORT QOpenGLWidget : public QWidget +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QOpenGLWidget) + +public: + enum UpdateBehavior { + NoPartialUpdate, + PartialUpdate + }; + + explicit QOpenGLWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + ~QOpenGLWidget(); + + void setUpdateBehavior(UpdateBehavior updateBehavior); + UpdateBehavior updateBehavior() const; + + void setFormat(const QSurfaceFormat &format); + QSurfaceFormat format() const; + + GLenum textureFormat() const; + void setTextureFormat(GLenum texFormat); + + bool isValid() const; + + void makeCurrent(); + void doneCurrent(); + + QOpenGLContext *context() const; + GLuint defaultFramebufferObject() const; + + QImage grabFramebuffer(); + +Q_SIGNALS: + void aboutToCompose(); + void frameSwapped(); + void aboutToResize(); + void resized(); + +protected: + virtual void initializeGL(); + virtual void resizeGL(int w, int h); + virtual void paintGL(); + + void paintEvent(QPaintEvent *e) override; + void resizeEvent(QResizeEvent *e) override; + bool event(QEvent *e) override; + + int metric(QPaintDevice::PaintDeviceMetric metric) const override; + QPaintDevice *redirected(QPoint *p) const override; + QPaintEngine *paintEngine() const override; + +private: + Q_DISABLE_COPY(QOpenGLWidget) +}; + +QT_END_NAMESPACE + +#endif // QT_NO_OPENGL + +#endif // QOPENGLWIDGET_H diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index 58107973d8..a960280959 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -68,11 +68,6 @@ qtConfig(action) { kernel/qwidgetaction.cpp } -qtConfig(opengl) { - HEADERS += kernel/qopenglwidget.h - SOURCES += kernel/qopenglwidget.cpp -} - qtConfig(formlayout) { HEADERS += kernel/qformlayout.h SOURCES += kernel/qformlayout.cpp diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp deleted file mode 100644 index 90622fd21e..0000000000 --- a/src/widgets/kernel/qopenglwidget.cpp +++ /dev/null @@ -1,1471 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopenglwidget.h" -#include <QtGui/QOpenGLContext> -#include <QtGui/QOpenGLFramebufferObject> -#include <QtGui/QOffscreenSurface> -#include <QtGui/QOpenGLFunctions> -#include <QtGui/QWindow> -#include <QtGui/QGuiApplication> -#include <QtGui/QScreen> -#include <QtGui/QOpenGLPaintDevice> -#include <QtGui/qpa/qplatformwindow.h> -#include <QtGui/qpa/qplatformintegration.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtGui/private/qopenglextensions_p.h> -#include <QtGui/private/qfont_p.h> -#include <QtGui/private/qopenglpaintdevice_p.h> -#include <QtGui/private/qopenglcontext_p.h> -#include <QtWidgets/private/qwidget_p.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QOpenGLWidget - \inmodule QtWidgets - \since 5.4 - - \brief The QOpenGLWidget class is a widget for rendering OpenGL graphics. - - QOpenGLWidget provides functionality for displaying OpenGL graphics - integrated into a Qt application. It is very simple to use: Make - your class inherit from it and use the subclass like any other - QWidget, except that you have the choice between using QPainter and - standard OpenGL rendering commands. - - QOpenGLWidget provides three convenient virtual functions that you - can reimplement in your subclass to perform the typical OpenGL - tasks: - - \list - \li paintGL() - Renders the OpenGL scene. Gets called whenever the widget - needs to be updated. - \li resizeGL() - Sets up the OpenGL viewport, projection, etc. Gets - called whenever the widget has been resized (and also when it - is shown for the first time because all newly created widgets get a - resize event automatically). - \li initializeGL() - Sets up the OpenGL resources and state. Gets called - once before the first time resizeGL() or paintGL() is called. - \endlist - - If you need to trigger a repaint from places other than paintGL() (a - typical example is when using \l{QTimer}{timers} to animate scenes), - you should call the widget's update() function to schedule an update. - - Your widget's OpenGL rendering context is made current when - paintGL(), resizeGL(), or initializeGL() is called. If you need to - call the standard OpenGL API functions from other places (e.g. in - your widget's constructor or in your own paint functions), you - must call makeCurrent() first. - - All rendering happens into an OpenGL framebuffer - object. makeCurrent() ensure that it is bound in the context. Keep - this in mind when creating and binding additional framebuffer - objects in the rendering code in paintGL(). Never re-bind the - framebuffer with ID 0. Instead, call defaultFramebufferObject() to - get the ID that should be bound. - - QOpenGLWidget allows using different OpenGL versions and profiles - when the platform supports it. Just set the requested format via - setFormat(). Keep in mind however that having multiple QOpenGLWidget - instances in the same window requires that they all use the same - format, or at least formats that do not make the contexts - non-sharable. To overcome this issue, prefer using - QSurfaceFormat::setDefaultFormat() instead of setFormat(). - - \note Calling QSurfaceFormat::setDefaultFormat() before constructing - the QApplication instance is mandatory on some platforms (for example, - \macos) when an OpenGL core profile context is requested. This is to - ensure that resource sharing between contexts stays functional as all - internal contexts are created using the correct version and profile. - - \section1 Painting Techniques - - As described above, subclass QOpenGLWidget to render pure 3D content in the - following way: - - \list - - \li Reimplement the initializeGL() and resizeGL() functions to - set up the OpenGL state and provide a perspective transformation. - - \li Reimplement paintGL() to paint the 3D scene, calling only - OpenGL functions. - - \endlist - - It is also possible to draw 2D graphics onto a QOpenGLWidget subclass using QPainter: - - \list - - \li In paintGL(), instead of issuing OpenGL commands, construct a QPainter - object for use on the widget. - - \li Draw primitives using QPainter's member functions. - - \li Direct OpenGL commands can still be issued. However, you must make sure - these are enclosed by a call to the painter's beginNativePainting() and - endNativePainting(). - - \endlist - - When performing drawing using QPainter only, it is also possible to perform - the painting like it is done for ordinary widgets: by reimplementing paintEvent(). - - \list - - \li Reimplement the paintEvent() function. - - \li Construct a QPainter object targeting the widget. Either pass the widget to the - constructor or the QPainter::begin() function. - - \li Draw primitives using QPainter's member functions. - - \li Painting finishes then the QPainter instance is destroyed. Alternatively, - call QPainter::end() explicitly. - - \endlist - - \section1 OpenGL Function Calls, Headers and QOpenGLFunctions - - When making OpenGL function calls, it is strongly recommended to avoid calling - the functions directly. Instead, prefer using QOpenGLFunctions (when making - portable applications) or the versioned variants (for example, - QOpenGLFunctions_3_2_Core and similar, when targeting modern, desktop-only - OpenGL). This way the application will work correctly in all Qt build - configurations, including the ones that perform dynamic OpenGL implementation - loading which means applications are not directly linking to an GL - implementation and thus direct function calls are not feasible. - - In paintGL() the current context is always accessible by caling - QOpenGLContext::currentContext(). From this context an already initialized, - ready-to-be-used QOpenGLFunctions instance is retrievable by calling - QOpenGLContext::functions(). An alternative to prefixing every GL call is to - inherit from QOpenGLFunctions and call - QOpenGLFunctions::initializeOpenGLFunctions() in initializeGL(). - - As for the OpenGL headers, note that in most cases there will be no need to - directly include any headers like GL.h. The OpenGL-related Qt headers will - include qopengl.h which will in turn include an appropriate header for the - system. This might be an OpenGL ES 3.x or 2.0 header, the highest version that - is available, or a system-provided gl.h. In addition, a copy of the extension - headers (called glext.h on some systems) is provided as part of Qt both for - OpenGL and OpenGL ES. These will get included automatically on platforms where - feasible. This means that constants and function pointer typedefs from ARB, - EXT, OES extensions are automatically available. - - \section1 Code Examples - - To get started, the simplest QOpenGLWidget subclass could like like the following: - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 0 - - Alternatively, the prefixing of each and every OpenGL call can be avoided by deriving - from QOpenGLFunctions instead: - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 1 - - To get a context compatible with a given OpenGL version or profile, or to - request depth and stencil buffers, call setFormat(): - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 2 - - With OpenGL 3.0+ contexts, when portability is not important, the versioned - QOpenGLFunctions variants give easy access to all the modern OpenGL functions - available in a given version: - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 3 - - As described above, it is simpler and more robust to set the requested format - globally so that it applies to all windows and contexts during the lifetime of - the application. Below is an example of this: - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 6 - - \section1 Relation to QGLWidget - - The legacy QtOpenGL module (classes prefixed with QGL) provides a widget - called QGLWidget. QOpenGLWidget is intended to be a modern replacement for - it. Therefore, especially in new applications, the general recommendation is - to use QOpenGLWidget. - - While the API is very similar, there is an important difference between the - two: QOpenGLWidget always renders offscreen, using framebuffer - objects. QGLWidget on the other hand uses a native window and surface. The - latter causes issues when using it in complex user interfaces since, depending - on the platform, such native child widgets may have various limitations, - regarding stacking orders for example. QOpenGLWidget avoids this by not - creating a separate native window. - - Due to being backed by a framebuffer object, the behavior of QOpenGLWidget is - very similar to QOpenGLWindow with the update behavior set to \c - PartialUpdateBlit or \c PartialUpdateBlend. This means that the contents are - preserved between paintGL() calls so that incremental rendering is - possible. With QGLWidget (and naturally QOpenGLWindow with the default update - behavior) this is usually not the case because swapping the buffers leaves the - back buffer with undefined contents. - - \note Most applications do not need incremental rendering because they will - render everything in the view on every paint call. In this case it is - important to call glClear() as early as possible in paintGL(). This helps - mobile GPUs that use a tile-based architecture to recognize that the tile - buffer does not need to be reloaded with the framebuffer's previous - contents. Omitting the clear call can lead to significant performance drops on - such systems. - - \note Avoid calling winId() on a QOpenGLWidget. This function triggers the creation of - a native window, resulting in reduced performance and possibly rendering glitches. - - \section1 Differences to QGLWidget - - Besides the main conceptual difference of being backed by a framebuffer object, there - are a number of smaller, internal differences between QOpenGLWidget and the older - QGLWidget: - - \list - - \li OpenGL state when invoking paintGL(). QOpenGLWidget sets up the viewport via - glViewport(). It does not perform any clearing. - - \li Clearing when starting to paint via QPainter. Unlike regular widgets, QGLWidget - defaulted to a value of \c true for - \l{QWidget::autoFillBackground()}{autoFillBackground}. It then performed clearing to the - palette's background color every time QPainter::begin() was used. QOpenGLWidget does not - follow this: \l{QWidget::autoFillBackground()}{autoFillBackground} defaults to false, - like for any other widget. The only exception is when being used as a viewport for other - widgets like QGraphicsView. In such a case autoFillBackground will be automatically set - to true to ensure compatibility with QGLWidget-based viewports. - - \endlist - - \section1 Multisampling - - To enable multisampling, set the number of requested samples on the - QSurfaceFormat that is passed to setFormat(). On systems that do not support - it the request may get ignored. - - Multisampling support requires support for multisampled renderbuffers and - framebuffer blits. On OpenGL ES 2.0 implementations it is likely that these - will not be present. This means that multisampling will not be available. With - modern OpenGL versions and OpenGL ES 3.0 and up this is usually not a problem - anymore. - - \section1 Threading - - Performing offscreen rendering on worker threads, for example to generate - textures that are then used in the GUI/main thread in paintGL(), are supported - by exposing the widget's QOpenGLContext so that additional contexts sharing - with it can be created on each thread. - - Drawing directly to the QOpenGLWidget's framebuffer outside the GUI/main - thread is possible by reimplementing paintEvent() to do nothing. The context's - thread affinity has to be changed via QObject::moveToThread(). After that, - makeCurrent() and doneCurrent() are usable on the worker thread. Be careful to - move the context back to the GUI/main thread afterwards. - - Unlike QGLWidget, triggering a buffer swap just for the QOpenGLWidget is not - possible since there is no real, onscreen native surface for it. Instead, it - is up to the widget stack to manage composition and buffer swaps on the gui - thread. When a thread is done updating the framebuffer, call update() \b{on - the GUI/main thread} to schedule composition. - - Extra care has to be taken to avoid using the framebuffer when the GUI/main - thread is performing compositing. The signals aboutToCompose() and - frameSwapped() will be emitted when the composition is starting and - ending. They are emitted on the GUI/main thread. This means that by using a - direct connection aboutToCompose() can block the GUI/main thread until the - worker thread has finished its rendering. After that, the worker thread must - perform no further rendering until the frameSwapped() signal is emitted. If - this is not acceptable, the worker thread has to implement a double buffering - mechanism. This involves drawing using an alternative render target, that is - fully controlled by the thread, e.g. an additional framebuffer object, and - blitting to the QOpenGLWidget's framebuffer at a suitable time. - - \section1 Context Sharing - - When multiple QOpenGLWidgets are added as children to the same top-level - widget, their contexts will share with each other. This does not apply for - QOpenGLWidget instances that belong to different windows. - - This means that all QOpenGLWidgets in the same window can access each other's - sharable resources, like textures, and there is no need for an extra "global - share" context, as was the case with QGLWidget. - - To set up sharing between QOpenGLWidget instances belonging to different - windows, set the Qt::AA_ShareOpenGLContexts application attribute before - instantiating QApplication. This will trigger sharing between all - QOpenGLWidget instances without any further steps. - - Creating extra QOpenGLContext instances that share resources like textures - with the QOpenGLWidget's context is also possible. Simply pass the pointer - returned from context() to QOpenGLContext::setShareContext() before calling - QOpenGLContext::create(). The resulting context can also be used on a - different thread, allowing threaded generation of textures and asynchronous - texture uploads. - - Note that QOpenGLWidget expects a standard conformant implementation of - resource sharing when it comes to the underlying graphics drivers. For - example, some drivers, in particular for mobile and embedded hardware, have - issues with setting up sharing between an existing context and others that are - created later. Some other drivers may behave in unexpected ways when trying to - utilize shared resources between different threads. - - \section1 Resource Initialization and Cleanup - - The QOpenGLWidget's associated OpenGL context is guaranteed to be current - whenever initializeGL() and paintGL() are invoked. Do not attempt to create - OpenGL resources before initializeGL() is called. For example, attempting to - compile shaders, initialize vertex buffer objects or upload texture data will - fail when done in a subclass's constructor. These operations must be deferred - to initializeGL(). Some of Qt's OpenGL helper classes, like QOpenGLBuffer or - QOpenGLVertexArrayObject, have a matching deferred behavior: they can be - instantiated without a context, but all initialization is deferred until a - create(), or similar, call. This means that they can be used as normal - (non-pointer) member variables in a QOpenGLWidget subclass, but the create() - or similar function can only be called from initializeGL(). Be aware however - that not all classes are designed like this. When in doubt, make the member - variable a pointer and create and destroy the instance dynamically in - initializeGL() and the destructor, respectively. - - Releasing the resources also needs the context to be current. Therefore - destructors that perform such cleanup are expected to call makeCurrent() - before moving on to destroy any OpenGL resources or wrappers. Avoid deferred - deletion via \l{QObject::deleteLater()}{deleteLater()} or the parenting - mechanism of QObject. There is no guarantee the correct context will be - current at the time the instance in question is really destroyed. - - A typical subclass will therefore often look like the following when it comes - to resource initialization and destruction: - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 4 - - This is naturally not the only possible solution. One alternative is to use - the \l{QOpenGLContext::aboutToBeDestroyed()}{aboutToBeDestroyed()} signal of - QOpenGLContext. By connecting a slot, using direct connection, to this signal, - it is possible to perform cleanup whenever the the underlying native context - handle, or the entire QOpenGLContext instance, is going to be released. The - following snippet is in principle equivalent to the previous one: - - \snippet code/doc_gui_widgets_qopenglwidget.cpp 5 - - \note For widgets that change their associated top-level window multiple times - during their lifetime, a combined approach is essential. Whenever the widget - or a parent of it gets reparented so that the top-level window becomes - different, the widget's associated context is destroyed and a new one is - created. This is then followed by a call to initializeGL() where all OpenGL - resources must get reinitialized. Due to this the only option to perform - proper cleanup is to connect to the context's aboutToBeDestroyed() - signal. Note that the context in question may not be the current one when the - signal gets emitted. Therefore it is good practice to call makeCurrent() in - the connected slot. Additionally, the same cleanup steps must be performed - from the derived class' destructor, since the slot connected to the signal - will not get invoked when the widget is being destroyed. - - \note When Qt::AA_ShareOpenGLContexts is set, the widget's context never - changes, not even when reparenting because the widget's associated texture is - guaranteed to be accessible also from the new top-level's context. - - Proper cleanup is especially important due to context sharing. Even though - each QOpenGLWidget's associated context is destroyed together with the - QOpenGLWidget, the sharable resources in that context, like textures, will - stay valid until the top-level window, in which the QOpenGLWidget lived, is - destroyed. Additionally, settings like Qt::AA_ShareOpenGLContexts and some Qt - modules may trigger an even wider scope for sharing contexts, potentially - leading to keeping the resources in question alive for the entire lifetime of - the application. Therefore the safest and most robust is always to perform - explicit cleanup for all resources and resource wrappers used in the - QOpenGLWidget. - - \section1 Limitations - - Putting other widgets underneath and making the QOpenGLWidget transparent will - not lead to the expected results: The widgets underneath will not be - visible. This is because in practice the QOpenGLWidget is drawn before all - other regular, non-OpenGL widgets, and so see-through type of solutions are - not feasible. Other type of layouts, like having widgets on top of the - QOpenGLWidget, will function as expected. - - When absolutely necessary, this limitation can be overcome by setting the - Qt::WA_AlwaysStackOnTop attribute on the QOpenGLWidget. Be aware however that - this breaks stacking order, for example it will not be possible to have other - widgets on top of the QOpenGLWidget, so it should only be used in situations - where a semi-transparent QOpenGLWidget with other widgets visible underneath - is required. - - Note that this does not apply when there are no other widgets underneath and - the intention is to have a semi-transparent window. In that case the - traditional approach of setting Qt::WA_TranslucentBackground - on the top-level window is sufficient. Note that if the transparent areas are - only desired in the QOpenGLWidget, then Qt::WA_NoSystemBackground will need - to be turned back to \c false after enabling Qt::WA_TranslucentBackground. - Additionally, requesting an alpha channel for the QOpenGLWidget's context via - setFormat() may be necessary too, depending on the system. - - QOpenGLWidget supports multiple update behaviors, just like QOpenGLWindow. In - preserved mode the rendered content from the previous paintGL() call is - available in the next one, allowing incremental rendering. In non-preserved - mode the content is lost and paintGL() implementations are expected to redraw - everything in the view. - - Before Qt 5.5 the default behavior of QOpenGLWidget was to preserve the - rendered contents between paintGL() calls. Since Qt 5.5 the default behavior - is non-preserved because this provides better performance and the majority of - applications have no need for the previous content. This also resembles the - semantics of an OpenGL-based QWindow and matches the default behavior of - QOpenGLWindow in that the color and ancillary buffers are invalidated for - each frame. To restore the preserved behavior, call setUpdateBehavior() with - \c PartialUpdate. - - \section1 Alternatives - - Adding a QOpenGLWidget into a window turns on OpenGL-based - compositing for the entire window. In some special cases this may - not be ideal, and the old QGLWidget-style behavior with a separate, - native child window is desired. Desktop applications that understand - the limitations of this approach (for example when it comes to - overlaps, transparency, scroll views and MDI areas), can use - QOpenGLWindow with QWidget::createWindowContainer(). This is a - modern alternative to QGLWidget and is faster than QOpenGLWidget due - to the lack of the additional composition step. It is strongly - recommended to limit the usage of this approach to cases where there - is no other choice. Note that this option is not suitable for most - embedded and mobile platforms, and it is known to have issues on - certain desktop platforms (e.g. \macos) too. The stable, - cross-platform solution is always QOpenGLWidget. - - \e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other - countries.} - - \sa QOpenGLFunctions, QOpenGLWindow, Qt::AA_ShareOpenGLContexts, UpdateBehavior -*/ - -/*! - \fn void QOpenGLWidget::aboutToCompose() - - This signal is emitted when the widget's top-level window is about to begin - composing the textures of its QOpenGLWidget children and the other widgets. -*/ - -/*! - \fn void QOpenGLWidget::frameSwapped() - - This signal is emitted after the widget's top-level window has finished - composition and returned from its potentially blocking - QOpenGLContext::swapBuffers() call. -*/ - -/*! - \fn void QOpenGLWidget::aboutToResize() - - This signal is emitted when the widget's size is changed and therefore the - framebuffer object is going to be recreated. -*/ - -/*! - \fn void QOpenGLWidget::resized() - - This signal is emitted right after the framebuffer object has been recreated - due to resizing the widget. -*/ - -/*! - \enum QOpenGLWidget::UpdateBehavior - \since 5.5 - - This enum describes the update semantics of QOpenGLWidget. - - \value NoPartialUpdate QOpenGLWidget will discard the - contents of the color buffer and the ancillary buffers after the - QOpenGLWidget is rendered to screen. This is the same behavior that can be - expected by calling QOpenGLContext::swapBuffers with a default opengl - enabled QWindow as the argument. NoPartialUpdate can have some performance - benefits on certain hardware architectures common in the mobile and - embedded space when a framebuffer object is used as the rendering target. - The framebuffer object is invalidated between frames with - glDiscardFramebufferEXT if supported or a glClear. Please see the - documentation of EXT_discard_framebuffer for more information: - https://www.khronos.org/registry/gles/extensions/EXT/EXT_discard_framebuffer.txt - - \value PartialUpdate The framebuffer objects color buffer and ancillary - buffers are not invalidated between frames. - - \sa updateBehavior(), setUpdateBehavior() -*/ - -class QOpenGLWidgetPaintDevicePrivate : public QOpenGLPaintDevicePrivate -{ -public: - QOpenGLWidgetPaintDevicePrivate(QOpenGLWidget *widget) - : QOpenGLPaintDevicePrivate(QSize()), - w(widget) { } - - void beginPaint() override; - void endPaint() override; - - QOpenGLWidget *w; -}; - -class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice -{ -public: - QOpenGLWidgetPaintDevice(QOpenGLWidget *widget) - : QOpenGLPaintDevice(*new QOpenGLWidgetPaintDevicePrivate(widget)) { } - void ensureActiveTarget() override; -}; - -class QOpenGLWidgetPrivate : public QWidgetPrivate -{ - Q_DECLARE_PUBLIC(QOpenGLWidget) -public: - QOpenGLWidgetPrivate() - : context(nullptr), - fbo(nullptr), - resolvedFbo(nullptr), - surface(nullptr), - initialized(false), - fakeHidden(false), - inBackingStorePaint(false), - hasBeenComposed(false), - flushPending(false), - paintDevice(nullptr), - updateBehavior(QOpenGLWidget::NoPartialUpdate), - requestedSamples(0), - inPaintGL(false), - textureFormat(0) - { - requestedFormat = QSurfaceFormat::defaultFormat(); - } - - void reset(); - void recreateFbo(); - - GLuint textureId() const override; - QPlatformTextureList::Flags textureListFlags() override; - - void initialize(); - void invokeUserPaint(); - void render(); - - void invalidateFbo(); - - QImage grabFramebuffer() override; - void beginBackingStorePainting() override { inBackingStorePaint = true; } - void endBackingStorePainting() override { inBackingStorePaint = false; } - void beginCompose() override; - void endCompose() override; - void initializeViewportFramebuffer() override; - void resizeViewportFramebuffer() override; - void resolveSamples() override; - - QOpenGLContext *context; - QOpenGLFramebufferObject *fbo; - QOpenGLFramebufferObject *resolvedFbo; - QOffscreenSurface *surface; - bool initialized; - bool fakeHidden; - bool inBackingStorePaint; - bool hasBeenComposed; - bool flushPending; - QOpenGLPaintDevice *paintDevice; - QSurfaceFormat requestedFormat; - QOpenGLWidget::UpdateBehavior updateBehavior; - int requestedSamples; - bool inPaintGL; - GLenum textureFormat; -}; - -void QOpenGLWidgetPaintDevicePrivate::beginPaint() -{ - // NB! autoFillBackground is and must be false by default. Otherwise we would clear on - // every QPainter begin() which is not desirable. This is only for legacy use cases, - // like using QOpenGLWidget as the viewport of a graphics view, that expect clearing - // with the palette's background color. - if (w->autoFillBackground()) { - QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - if (w->format().hasAlpha()) { - f->glClearColor(0, 0, 0, 0); - } else { - QColor c = w->palette().brush(w->backgroundRole()).color(); - float alpha = c.alphaF(); - f->glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); - } - f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - } -} - -void QOpenGLWidgetPaintDevicePrivate::endPaint() -{ - QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(w)); - if (!wd->initialized) - return; - - if (!wd->inPaintGL) - QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = 0; -} - -void QOpenGLWidgetPaintDevice::ensureActiveTarget() -{ - QOpenGLWidgetPaintDevicePrivate *d = static_cast<QOpenGLWidgetPaintDevicePrivate *>(d_ptr.data()); - QOpenGLWidgetPrivate *wd = static_cast<QOpenGLWidgetPrivate *>(QWidgetPrivate::get(d->w)); - if (!wd->initialized) - return; - - if (QOpenGLContext::currentContext() != wd->context) - d->w->makeCurrent(); - else - wd->fbo->bind(); - - if (!wd->inPaintGL) - QOpenGLContextPrivate::get(wd->context)->defaultFboRedirect = wd->fbo->handle(); - - // When used as a viewport, drawing is done via opening a QPainter on the widget - // without going through paintEvent(). We will have to make sure a glFlush() is done - // before the texture is accessed also in this case. - wd->flushPending = true; -} - -GLuint QOpenGLWidgetPrivate::textureId() const -{ - return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); -} - -#ifndef GL_SRGB -#define GL_SRGB 0x8C40 -#endif -#ifndef GL_SRGB8 -#define GL_SRGB8 0x8C41 -#endif -#ifndef GL_SRGB_ALPHA -#define GL_SRGB_ALPHA 0x8C42 -#endif -#ifndef GL_SRGB8_ALPHA8 -#define GL_SRGB8_ALPHA8 0x8C43 -#endif - -QPlatformTextureList::Flags QOpenGLWidgetPrivate::textureListFlags() -{ - QPlatformTextureList::Flags flags = QWidgetPrivate::textureListFlags(); - switch (textureFormat) { - case GL_SRGB: - case GL_SRGB8: - case GL_SRGB_ALPHA: - case GL_SRGB8_ALPHA8: - flags |= QPlatformTextureList::TextureIsSrgb; - break; - default: - break; - } - return flags; -} - -void QOpenGLWidgetPrivate::reset() -{ - Q_Q(QOpenGLWidget); - - // Destroy the OpenGL resources first. These need the context to be current. - if (initialized) - q->makeCurrent(); - - delete paintDevice; - paintDevice = nullptr; - delete fbo; - fbo = nullptr; - delete resolvedFbo; - resolvedFbo = nullptr; - - if (initialized) - q->doneCurrent(); - - // Delete the context first, then the surface. Slots connected to - // the context's aboutToBeDestroyed() may still call makeCurrent() - // to perform some cleanup. - delete context; - context = nullptr; - delete surface; - surface = nullptr; - initialized = fakeHidden = inBackingStorePaint = false; -} - -void QOpenGLWidgetPrivate::recreateFbo() -{ - Q_Q(QOpenGLWidget); - - emit q->aboutToResize(); - - context->makeCurrent(surface); - - delete fbo; - fbo = nullptr; - delete resolvedFbo; - resolvedFbo = nullptr; - - int samples = requestedSamples; - QOpenGLExtensions *extfuncs = static_cast<QOpenGLExtensions *>(context->functions()); - if (!extfuncs->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) - samples = 0; - - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - format.setSamples(samples); - if (textureFormat) - format.setInternalTextureFormat(textureFormat); - - const QSize deviceSize = q->size() * q->devicePixelRatioF(); - fbo = new QOpenGLFramebufferObject(deviceSize, format); - if (samples > 0) - resolvedFbo = new QOpenGLFramebufferObject(deviceSize); - - textureFormat = fbo->format().internalTextureFormat(); - - fbo->bind(); - context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - flushPending = true; // Make sure the FBO is initialized before use - - paintDevice->setSize(deviceSize); - paintDevice->setDevicePixelRatio(q->devicePixelRatioF()); - - emit q->resized(); -} - -void QOpenGLWidgetPrivate::beginCompose() -{ - Q_Q(QOpenGLWidget); - if (flushPending) { - flushPending = false; - q->makeCurrent(); - static_cast<QOpenGLExtensions *>(context->functions())->flushShared(); - } - hasBeenComposed = true; - emit q->aboutToCompose(); -} - -void QOpenGLWidgetPrivate::endCompose() -{ - Q_Q(QOpenGLWidget); - emit q->frameSwapped(); -} - -void QOpenGLWidgetPrivate::initialize() -{ - Q_Q(QOpenGLWidget); - if (initialized) - return; - - // If no global shared context get our toplevel's context with which we - // will share in order to make the texture usable by the underlying window's backingstore. - QWidget *tlw = q->window(); - QOpenGLContext *shareContext = qt_gl_global_share_context(); - if (!shareContext) - shareContext = get(tlw)->shareContext(); - // If shareContext is null, showing content on-screen will not work. - // However, offscreen rendering and grabFramebuffer() will stay fully functional. - - // Do not include the sample count. Requesting a multisampled context is not necessary - // since we render into an FBO, never to an actual surface. What's more, attempting to - // create a pbuffer with a multisampled config crashes certain implementations. Just - // avoid the entire hassle, the result is the same. - requestedSamples = requestedFormat.samples(); - requestedFormat.setSamples(0); - - QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext); - ctx->setFormat(requestedFormat); - if (shareContext) { - ctx->setShareContext(shareContext); - ctx->setScreen(shareContext->screen()); - } - if (Q_UNLIKELY(!ctx->create())) { - qWarning("QOpenGLWidget: Failed to create context"); - return; - } - - // Propagate settings that make sense only for the tlw. Note that this only - // makes sense for properties that get picked up even after the native - // window is created. - if (tlw->windowHandle()) { - QSurfaceFormat tlwFormat = tlw->windowHandle()->format(); - if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) { - // Most platforms will pick up the changed swap interval on the next - // makeCurrent or swapBuffers. - tlwFormat.setSwapInterval(requestedFormat.swapInterval()); - tlw->windowHandle()->setFormat(tlwFormat); - } - if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) { - tlwFormat.setSwapBehavior(requestedFormat.swapBehavior()); - tlw->windowHandle()->setFormat(tlwFormat); - } - } - - // The top-level window's surface is not good enough since it causes way too - // much trouble with regards to the QSurfaceFormat for example. So just like - // in QQuickWidget, use a dedicated QOffscreenSurface. - surface = new QOffscreenSurface; - surface->setFormat(ctx->format()); - surface->setScreen(ctx->screen()); - surface->create(); - - if (Q_UNLIKELY(!ctx->makeCurrent(surface))) { - qWarning("QOpenGLWidget: Failed to make context current"); - return; - } - - paintDevice = new QOpenGLWidgetPaintDevice(q); - paintDevice->setSize(q->size() * q->devicePixelRatioF()); - paintDevice->setDevicePixelRatio(q->devicePixelRatioF()); - - context = ctx.take(); - initialized = true; - - q->initializeGL(); -} - -void QOpenGLWidgetPrivate::resolveSamples() -{ - Q_Q(QOpenGLWidget); - if (resolvedFbo) { - q->makeCurrent(); - QRect rect(QPoint(0, 0), fbo->size()); - QOpenGLFramebufferObject::blitFramebuffer(resolvedFbo, rect, fbo, rect); - flushPending = true; - } -} - -void QOpenGLWidgetPrivate::invokeUserPaint() -{ - Q_Q(QOpenGLWidget); - - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - Q_ASSERT(ctx && fbo); - - QOpenGLFunctions *f = ctx->functions(); - QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle(); - - f->glViewport(0, 0, q->width() * q->devicePixelRatioF(), q->height() * q->devicePixelRatioF()); - inPaintGL = true; - q->paintGL(); - inPaintGL = false; - flushPending = true; - - QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0; -} - -void QOpenGLWidgetPrivate::render() -{ - Q_Q(QOpenGLWidget); - - if (fakeHidden || !initialized) - return; - - q->makeCurrent(); - - if (updateBehavior == QOpenGLWidget::NoPartialUpdate && hasBeenComposed) { - invalidateFbo(); - hasBeenComposed = false; - } - - invokeUserPaint(); -} - -void QOpenGLWidgetPrivate::invalidateFbo() -{ - QOpenGLExtensions *f = static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions()); - if (f->hasOpenGLExtension(QOpenGLExtensions::DiscardFramebuffer)) { - const int gl_color_attachment0 = 0x8CE0; // GL_COLOR_ATTACHMENT0 - const int gl_depth_attachment = 0x8D00; // GL_DEPTH_ATTACHMENT - const int gl_stencil_attachment = 0x8D20; // GL_STENCIL_ATTACHMENT -#ifdef Q_OS_WASM - // webgl does not allow separate depth and stencil attachments - // QTBUG-69913 - const int gl_depth_stencil_attachment = 0x821A; // GL_DEPTH_STENCIL_ATTACHMENT - - const GLenum attachments[] = { - gl_color_attachment0, gl_depth_attachment, gl_stencil_attachment, gl_depth_stencil_attachment - }; -#else - const GLenum attachments[] = { - gl_color_attachment0, gl_depth_attachment, gl_stencil_attachment - }; -#endif - f->glDiscardFramebufferEXT(GL_FRAMEBUFFER, sizeof attachments / sizeof *attachments, attachments); - } else { - f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - } -} - -extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); - -QImage QOpenGLWidgetPrivate::grabFramebuffer() -{ - Q_Q(QOpenGLWidget); - - initialize(); - if (!initialized) - return QImage(); - - if (!fbo) // could be completely offscreen, without ever getting a resize event - recreateFbo(); - - if (!inPaintGL) - render(); - - if (resolvedFbo) { - resolveSamples(); - resolvedFbo->bind(); - } else { - q->makeCurrent(); - } - - const bool hasAlpha = q->format().hasAlpha(); - QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), hasAlpha, hasAlpha); - res.setDevicePixelRatio(q->devicePixelRatioF()); - - // While we give no guarantees of what is going to be left bound, prefer the - // multisample fbo instead of the resolved one. Clients may continue to - // render straight after calling this function. - if (resolvedFbo) - q->makeCurrent(); - - return res; -} - -void QOpenGLWidgetPrivate::initializeViewportFramebuffer() -{ - Q_Q(QOpenGLWidget); - // Legacy behavior for compatibility with QGLWidget when used as a graphics view - // viewport: enable clearing on each painter begin. - q->setAutoFillBackground(true); -} - -void QOpenGLWidgetPrivate::resizeViewportFramebuffer() -{ - Q_Q(QOpenGLWidget); - if (!initialized) - return; - - if (!fbo || q->size() * q->devicePixelRatioF() != fbo->size()) { - recreateFbo(); - q->update(); - } -} - -/*! - Constructs a widget which is a child of \a parent, with widget flags set to \a f. - */ -QOpenGLWidget::QOpenGLWidget(QWidget *parent, Qt::WindowFlags f) - : QWidget(*(new QOpenGLWidgetPrivate), parent, f) -{ - Q_D(QOpenGLWidget); - if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface))) - qWarning("QOpenGLWidget is not supported on this platform."); - else - d->setRenderToTexture(); -} - -/*! - Destroys the QOpenGLWidget instance, freeing its resources. - - The QOpenGLWidget's context is made current in the destructor, allowing for - safe destruction of any child object that may need to release OpenGL - resources belonging to the context provided by this widget. - - \warning if you have objects wrapping OpenGL resources (such as - QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a OpenGLWidget - subclass, you may need to add a call to makeCurrent() in that subclass' - destructor as well. Due to the rules of C++ object destruction, those objects - will be destroyed \e{before} calling this function (but after that the - destructor of the subclass has run), therefore making the OpenGL context - current in this function happens too late for their safe disposal. - - \sa makeCurrent -*/ -QOpenGLWidget::~QOpenGLWidget() -{ - Q_D(QOpenGLWidget); - d->reset(); -} - -/*! - Sets this widget's update behavior to \a updateBehavior. - \since 5.5 -*/ -void QOpenGLWidget::setUpdateBehavior(UpdateBehavior updateBehavior) -{ - Q_D(QOpenGLWidget); - d->updateBehavior = updateBehavior; -} - -/*! - \return the update behavior of the widget. - \since 5.5 -*/ -QOpenGLWidget::UpdateBehavior QOpenGLWidget::updateBehavior() const -{ - Q_D(const QOpenGLWidget); - return d->updateBehavior; -} - -/*! - Sets the requested surface \a format. - - When the format is not explicitly set via this function, the format returned by - QSurfaceFormat::defaultFormat() will be used. This means that when having multiple - OpenGL widgets, individual calls to this function can be replaced by one single call to - QSurfaceFormat::setDefaultFormat() before creating the first widget. - - \note Requesting an alpha buffer via this function will not lead to the - desired results when the intention is to make other widgets beneath visible. - Instead, use Qt::WA_AlwaysStackOnTop to enable semi-transparent QOpenGLWidget - instances with other widgets visible underneath. Keep in mind however that - this breaks the stacking order, so it will no longer be possible to have - other widgets on top of the QOpenGLWidget. - - \sa format(), Qt::WA_AlwaysStackOnTop, QSurfaceFormat::setDefaultFormat() - */ -void QOpenGLWidget::setFormat(const QSurfaceFormat &format) -{ - Q_D(QOpenGLWidget); - if (Q_UNLIKELY(d->initialized)) { - qWarning("QOpenGLWidget: Already initialized, setting the format has no effect"); - return; - } - - d->requestedFormat = format; -} - -/*! - Returns the context and surface format used by this widget and its toplevel - window. - - After the widget and its toplevel have both been created, resized and shown, - this function will return the actual format of the context. This may differ - from the requested format if the request could not be fulfilled by the - platform. It is also possible to get larger color buffer sizes than - requested. - - When the widget's window and the related OpenGL resources are not yet - initialized, the return value is the format that has been set via - setFormat(). - - \sa setFormat(), context() - */ -QSurfaceFormat QOpenGLWidget::format() const -{ - Q_D(const QOpenGLWidget); - return d->initialized ? d->context->format() : d->requestedFormat; -} - -/*! - Sets a custom internal texture format of \a texFormat. - - When working with sRGB framebuffers, it will be necessary to specify a - format like \c{GL_SRGB8_ALPHA8}. This can be achieved by calling this - function. - - \note This function has no effect if called after the widget has already - been shown and thus it performed initialization. - - \note This function will typically have to be used in combination with a - QSurfaceFormat::setDefaultFormat() call that sets the color space to - QSurfaceFormat::sRGBColorSpace. - - \since 5.10 - */ -void QOpenGLWidget::setTextureFormat(GLenum texFormat) -{ - Q_D(QOpenGLWidget); - if (Q_UNLIKELY(d->initialized)) { - qWarning("QOpenGLWidget: Already initialized, setting the internal texture format has no effect"); - return; - } - - d->textureFormat = texFormat; -} - -/*! - \return the active internal texture format if the widget has already - initialized, the requested format if one was set but the widget has not yet - been made visible, or \nullptr if setTextureFormat() was not called and the - widget has not yet been made visible. - - \since 5.10 - */ -GLenum QOpenGLWidget::textureFormat() const -{ - Q_D(const QOpenGLWidget); - return d->textureFormat; -} - -/*! - \return \e true if the widget and OpenGL resources, like the context, have - been successfully initialized. Note that the return value is always false - until the widget is shown. -*/ -bool QOpenGLWidget::isValid() const -{ - Q_D(const QOpenGLWidget); - return d->initialized && d->context->isValid(); -} - -/*! - Prepares for rendering OpenGL content for this widget by making the - corresponding context current and binding the framebuffer object in that - context. - - It is not necessary to call this function in most cases, because it - is called automatically before invoking paintGL(). - - \sa context(), paintGL(), doneCurrent() - */ -void QOpenGLWidget::makeCurrent() -{ - Q_D(QOpenGLWidget); - if (!d->initialized) - return; - - d->context->makeCurrent(d->surface); - - if (d->fbo) // there may not be one if we are in reset() - d->fbo->bind(); -} - -/*! - Releases the context. - - It is not necessary to call this function in most cases, since the - widget will make sure the context is bound and released properly - when invoking paintGL(). - */ -void QOpenGLWidget::doneCurrent() -{ - Q_D(QOpenGLWidget); - if (!d->initialized) - return; - - d->context->doneCurrent(); -} - -/*! - \return The QOpenGLContext used by this widget or \c 0 if not yet initialized. - - \note The context and the framebuffer object used by the widget changes when - reparenting the widget via setParent(). - - \sa QOpenGLContext::setShareContext(), defaultFramebufferObject() - */ -QOpenGLContext *QOpenGLWidget::context() const -{ - Q_D(const QOpenGLWidget); - return d->context; -} - -/*! - \return The framebuffer object handle or \c 0 if not yet initialized. - - \note The framebuffer object belongs to the context returned by context() - and may not be accessible from other contexts. - - \note The context and the framebuffer object used by the widget changes when - reparenting the widget via setParent(). In addition, the framebuffer object - changes on each resize. - - \sa context() - */ -GLuint QOpenGLWidget::defaultFramebufferObject() const -{ - Q_D(const QOpenGLWidget); - return d->fbo ? d->fbo->handle() : 0; -} - -/*! - This virtual function is called once before the first call to - paintGL() or resizeGL(). Reimplement it in a subclass. - - This function should set up any required OpenGL resources and state. - - There is no need to call makeCurrent() because this has already been - done when this function is called. Note however that the framebuffer - is not yet available at this stage, so avoid issuing draw calls from - here. Defer such calls to paintGL() instead. - - \sa paintGL(), resizeGL() -*/ -void QOpenGLWidget::initializeGL() -{ -} - -/*! - This virtual function is called whenever the widget has been - resized. Reimplement it in a subclass. The new size is passed in - \a w and \a h. - - There is no need to call makeCurrent() because this has already been - done when this function is called. Additionally, the framebuffer is - also bound. - - \sa initializeGL(), paintGL() -*/ -void QOpenGLWidget::resizeGL(int w, int h) -{ - Q_UNUSED(w); - Q_UNUSED(h); -} - -/*! - This virtual function is called whenever the widget needs to be - painted. Reimplement it in a subclass. - - There is no need to call makeCurrent() because this has already - been done when this function is called. - - Before invoking this function, the context and the framebuffer are - bound, and the viewport is set up by a call to glViewport(). No - other state is set and no clearing or drawing is performed by the - framework. - - \sa initializeGL(), resizeGL() -*/ -void QOpenGLWidget::paintGL() -{ -} - -/*! - Handles resize events that are passed in the \a e event parameter. - Calls the virtual function resizeGL(). - - \note Avoid overriding this function in derived classes. If that is not - feasible, make sure that QOpenGLWidget's implementation is invoked - too. Otherwise the underlying framebuffer object and related resources will - not get resized properly and will lead to incorrect rendering. -*/ -void QOpenGLWidget::resizeEvent(QResizeEvent *e) -{ - Q_D(QOpenGLWidget); - - if (e->size().isEmpty()) { - d->fakeHidden = true; - return; - } - d->fakeHidden = false; - - d->initialize(); - if (!d->initialized) - return; - - d->recreateFbo(); - resizeGL(width(), height()); - d->sendPaintEvent(QRect(QPoint(0, 0), size())); -} - -/*! - Handles paint events. - - Calling QWidget::update() will lead to sending a paint event \a e, - and thus invoking this function. (NB this is asynchronous and will - happen at some point after returning from update()). This function - will then, after some preparation, call the virtual paintGL() to - update the contents of the QOpenGLWidget's framebuffer. The widget's - top-level window will then composite the framebuffer's texture with - the rest of the window. -*/ -void QOpenGLWidget::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - Q_D(QOpenGLWidget); - if (!d->initialized) - return; - - if (updatesEnabled()) - d->render(); -} - -/*! - Renders and returns a 32-bit RGB image of the framebuffer. - - \note This is a potentially expensive operation because it relies on glReadPixels() - to read back the pixels. This may be slow and can stall the GPU pipeline. -*/ -QImage QOpenGLWidget::grabFramebuffer() -{ - Q_D(QOpenGLWidget); - return d->grabFramebuffer(); -} - -/*! - \internal -*/ -int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const -{ - Q_D(const QOpenGLWidget); - if (d->inBackingStorePaint) - return QWidget::metric(metric); - - auto window = d->windowHandle(QWidgetPrivate::WindowHandleMode::TopLevel); - QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen(); - - const float dpmx = qt_defaultDpiX() * 100. / 2.54; - const float dpmy = qt_defaultDpiY() * 100. / 2.54; - - switch (metric) { - case PdmWidth: - return width(); - case PdmHeight: - return height(); - case PdmDepth: - return 32; - case PdmWidthMM: - if (screen) - return width() * screen->physicalSize().width() / screen->geometry().width(); - else - return width() * 1000 / dpmx; - case PdmHeightMM: - if (screen) - return height() * screen->physicalSize().height() / screen->geometry().height(); - else - return height() * 1000 / dpmy; - case PdmNumColors: - return 0; - case PdmDpiX: - if (screen) - return qRound(screen->logicalDotsPerInchX()); - else - return qRound(dpmx * 0.0254); - case PdmDpiY: - if (screen) - return qRound(screen->logicalDotsPerInchY()); - else - return qRound(dpmy * 0.0254); - case PdmPhysicalDpiX: - if (screen) - return qRound(screen->physicalDotsPerInchX()); - else - return qRound(dpmx * 0.0254); - case PdmPhysicalDpiY: - if (screen) - return qRound(screen->physicalDotsPerInchY()); - else - return qRound(dpmy * 0.0254); - case PdmDevicePixelRatio: - if (window) - return int(window->devicePixelRatio()); - else - return 1.0; - case PdmDevicePixelRatioScaled: - if (window) - return int(window->devicePixelRatio() * devicePixelRatioFScale()); - else - return int(devicePixelRatioFScale()); - default: - qWarning("QOpenGLWidget::metric(): unknown metric %d", metric); - return 0; - } -} - -/*! - \internal -*/ -QPaintDevice *QOpenGLWidget::redirected(QPoint *p) const -{ - Q_D(const QOpenGLWidget); - if (d->inBackingStorePaint) - return QWidget::redirected(p); - - return d->paintDevice; -} - -/*! - \internal -*/ -QPaintEngine *QOpenGLWidget::paintEngine() const -{ - Q_D(const QOpenGLWidget); - // QWidget needs to "punch a hole" into the backingstore. This needs the - // normal paint engine and device, not the GL one. So in this mode, behave - // like a normal widget. - if (d->inBackingStorePaint) - return QWidget::paintEngine(); - - if (!d->initialized) - return nullptr; - - return d->paintDevice->paintEngine(); -} - -/*! - \internal -*/ -bool QOpenGLWidget::event(QEvent *e) -{ - Q_D(QOpenGLWidget); - switch (e->type()) { - case QEvent::WindowChangeInternal: - if (QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) - break; - if (d->initialized) - d->reset(); - if (isHidden()) - break; - Q_FALLTHROUGH(); - case QEvent::Show: // reparenting may not lead to a resize so reinitalize on Show too - if (d->initialized && window()->windowHandle() - && d->context->shareContext() != QWidgetPrivate::get(window())->shareContext()) - { - // Special case: did grabFramebuffer() for a hidden widget that then became visible. - // Recreate all resources since the context now needs to share with the TLW's. - if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts)) - d->reset(); - } - if (!d->initialized && !size().isEmpty() && window()->windowHandle()) { - d->initialize(); - if (d->initialized) - d->recreateFbo(); - } - break; - case QEvent::ScreenChangeInternal: - if (d->initialized && d->paintDevice->devicePixelRatioF() != devicePixelRatioF()) - d->recreateFbo(); - break; - default: - break; - } - return QWidget::event(e); -} - -QT_END_NAMESPACE - -#include "moc_qopenglwidget.cpp" diff --git a/src/widgets/kernel/qopenglwidget.h b/src/widgets/kernel/qopenglwidget.h deleted file mode 100644 index 9eb4a9ba5a..0000000000 --- a/src/widgets/kernel/qopenglwidget.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLWIDGET_H -#define QOPENGLWIDGET_H - -#include <QtWidgets/qtwidgetsglobal.h> - -#ifndef QT_NO_OPENGL - -#include <QtWidgets/QWidget> -#include <QtGui/QSurfaceFormat> -#include <QtGui/qopengl.h> - -QT_BEGIN_NAMESPACE - -class QOpenGLWidgetPrivate; - -class Q_WIDGETS_EXPORT QOpenGLWidget : public QWidget -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QOpenGLWidget) - -public: - enum UpdateBehavior { - NoPartialUpdate, - PartialUpdate - }; - - explicit QOpenGLWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); - ~QOpenGLWidget(); - - void setUpdateBehavior(UpdateBehavior updateBehavior); - UpdateBehavior updateBehavior() const; - - void setFormat(const QSurfaceFormat &format); - QSurfaceFormat format() const; - - GLenum textureFormat() const; - void setTextureFormat(GLenum texFormat); - - bool isValid() const; - - void makeCurrent(); - void doneCurrent(); - - QOpenGLContext *context() const; - GLuint defaultFramebufferObject() const; - - QImage grabFramebuffer(); - -Q_SIGNALS: - void aboutToCompose(); - void frameSwapped(); - void aboutToResize(); - void resized(); - -protected: - virtual void initializeGL(); - virtual void resizeGL(int w, int h); - virtual void paintGL(); - - void paintEvent(QPaintEvent *e) override; - void resizeEvent(QResizeEvent *e) override; - bool event(QEvent *e) override; - - int metric(QPaintDevice::PaintDeviceMetric metric) const override; - QPaintDevice *redirected(QPoint *p) const override; - QPaintEngine *paintEngine() const override; - -private: - Q_DISABLE_COPY(QOpenGLWidget) -}; - -QT_END_NAMESPACE - -#endif // QT_NO_OPENGL - -#endif // QOPENGLWIDGET_H -- cgit v1.2.3 From 14071b5a8e15b1f9ce0bf601a96ae365fa8983aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 21 Jun 2019 13:40:50 +0200 Subject: Clarify call to initializeWidgetFontHash in QApplication::setStyle The call was added in c49c96fbb13912, "Reinitialize system palette when setting a new style", but adding it along with the palette code seems like a mistake. The potentially dirty widget font hash needs to be reset for all style changes. Change-Id: I411f56bb833819213c5485d7585fc5e3e9bd8983 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index dfa1bc23b1..b3938df78a 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1133,12 +1133,18 @@ void QApplication::setStyle(QStyle *style) } else if (QApplicationPrivate::sys_pal) { clearSystemPalette(); initSystemPalette(); - QApplicationPrivate::initializeWidgetFontHash(); } else if (!QApplicationPrivate::sys_pal) { // Initialize the sys_pal if it hasn't happened yet... QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); } + // The default widget font hash is based on the platform theme, + // not the style, but the widget fonts could in theory have been + // affected by polish of the previous style, without a proper + // cleanup in unpolish, so reset it now before polishing the + // new style. + QApplicationPrivate::initializeWidgetFontHash(); + // initialize the application with the new style QApplicationPrivate::app_style->polish(qApp); -- cgit v1.2.3 From 6b06f12da6d5171d02764e9d6636c59731e2289f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 21 Jun 2019 13:45:39 +0200 Subject: Unify system palette initialization during style change We let initSystemPalette() do all the work, instead of leaving the first time initialization of the system palette to the caller, which makes the logic harder to follow. This also means first time initialization of the system palette will pick up a platform theme if available and resolve the palette using that, which was missing from the original logic. Change-Id: I84da557caf8ecedf6d96d87ebee93168ea9d73ba Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b3938df78a..37948ecd8c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -142,16 +142,19 @@ QApplicationPrivate *QApplicationPrivate::self = 0; static void initSystemPalette() { - if (!QApplicationPrivate::sys_pal) { - QPalette defaultPlatte; - if (QApplicationPrivate::app_style) - defaultPlatte = QApplicationPrivate::app_style->standardPalette(); - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) { - QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte)); - QApplicationPrivate::initializeWidgetPaletteHash(); - } else { - QApplicationPrivate::setSystemPalette(defaultPlatte); - } + if (QApplicationPrivate::sys_pal) + return; // Already initialized + + QPalette defaultPalette; + if (QApplicationPrivate::app_style) + defaultPalette = QApplicationPrivate::app_style->standardPalette(); + + auto *platformTheme = QGuiApplicationPrivate::platformTheme(); + if (const QPalette *themePalette = platformTheme ? platformTheme->palette() : nullptr) { + QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPalette)); + QApplicationPrivate::initializeWidgetPaletteHash(); + } else { + QApplicationPrivate::setSystemPalette(defaultPalette); } } @@ -1130,12 +1133,10 @@ void QApplication::setStyle(QStyle *style) // might call QApplication::setPalette() itself if (QApplicationPrivate::set_pal) { QApplication::setPalette(*QApplicationPrivate::set_pal); - } else if (QApplicationPrivate::sys_pal) { - clearSystemPalette(); + } else { + if (QApplicationPrivate::sys_pal) + clearSystemPalette(); initSystemPalette(); - } else if (!QApplicationPrivate::sys_pal) { - // Initialize the sys_pal if it hasn't happened yet... - QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); } // The default widget font hash is based on the platform theme, -- cgit v1.2.3 From f6a2b81eabae81110f678263be8558c24072c458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 21 Jun 2019 14:04:46 +0200 Subject: Update system palette on application init if needed A style may have been set before the application was created, which would have resulted in setting the system palette based on the style's palette. Once the application is initialized and we have a platform theme we need to reset the system palette. Change-Id: Ia48f57d3983535c8633741d8027f75bc0c214018 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 37948ecd8c..f546ec9187 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -555,6 +555,12 @@ void QApplicationPrivate::init() // Must be called before initialize() QColormap::initialize(); + if (sys_pal) { + // Now that we have a platform theme we need to reset + // the system palette to pick up the theme colors. + clearSystemPalette(); + initSystemPalette(); + } qt_init_tooltip_palette(); QApplicationPrivate::initializeWidgetFontHash(); -- cgit v1.2.3 From a9e628e7ec6b9d5bb38e64b7129c68320322033b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 21 Jun 2019 14:17:50 +0200 Subject: Ensure override style properly clears out previous style if set QApplication::setStyle has quite a bit of logic to clean up from the old style before setting a new one. If a style has been set before the application is created, it's not enough to just delete the existing style, we need to treat it like a normal style switch. Change-Id: I2bcc2eb75567bf1bc8a32ac31467b22315a70a0b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f546ec9187..fc3b73924e 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -434,13 +434,6 @@ void QApplicationPrivate::process_cmdline() if (styleOverride.isEmpty() && qEnvironmentVariableIsSet("QT_STYLE_OVERRIDE")) styleOverride = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE")); - if (!styleOverride.isEmpty()) { - if (app_style) { - delete app_style; - app_style = 0; - } - } - // process platform-indep command line if (!qt_is_gui_used || !argc) return; @@ -606,8 +599,20 @@ void QApplicationPrivate::initialize() // needed for widgets in QML QAbstractDeclarativeData::setWidgetParent = QWidgetPrivate::setWidgetParentHelper; - if (application_type != QApplicationPrivate::Tty) - (void) QApplication::style(); // trigger creation of application style + if (application_type != QApplicationPrivate::Tty) { + if (!styleOverride.isEmpty()) { + if (auto *style = QStyleFactory::create(styleOverride.toLower())) { + QApplication::setStyle(style); + } else { + qWarning("QApplication: invalid style override '%s' passed, ignoring it.\n" + "\tAvailable styles: %s", qPrintable(styleOverride), + qPrintable(QStyleFactory::keys().join(QLatin1String(", ")))); + } + } + + // Trigger default style if none was set already + Q_UNUSED(QApplication::style()); + } #if QT_CONFIG(statemachine) // trigger registering of QStateMachine's GUI types qRegisterGuiStateMachine(); @@ -1036,15 +1041,6 @@ QStyle *QApplication::style() // Compile-time search for default style // QStyle *&app_style = QApplicationPrivate::app_style; - - if (!QApplicationPrivate::styleOverride.isEmpty()) { - const QString style = QApplicationPrivate::styleOverride.toLower(); - app_style = QStyleFactory::create(style); - if (Q_UNLIKELY(!app_style)) { - qWarning("QApplication: invalid style override passed, ignoring it.\n" - " Available styles: %s", qPrintable(QStyleFactory::keys().join(QLatin1String(", ")))); - } - } if (!app_style) app_style = QStyleFactory::create(QApplicationPrivate::desktopStyleKey()); -- cgit v1.2.3 From 96d1d44279dc582355c21956fee99d945888fb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 25 Jun 2019 16:02:17 +0200 Subject: Clean up QApplication::style default style construction Change-Id: I9f01e7cc5fa90fd9b1f5d12c7ce694c231158c32 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index fc3b73924e..1f26e6e41c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1030,46 +1030,45 @@ void QApplication::setStyleSheet(const QString& styleSheet) */ QStyle *QApplication::style() { - if (QApplicationPrivate::app_style) - return QApplicationPrivate::app_style; - if (!qobject_cast<QApplication *>(QCoreApplication::instance())) { - Q_ASSERT(!"No style available without QApplication!"); - return 0; - } - if (!QApplicationPrivate::app_style) { - // Compile-time search for default style - // - QStyle *&app_style = QApplicationPrivate::app_style; - if (!app_style) - app_style = QStyleFactory::create(QApplicationPrivate::desktopStyleKey()); + // Create default style + if (!qobject_cast<QApplication *>(QCoreApplication::instance())) { + Q_ASSERT(!"No style available without QApplication!"); + return nullptr; + } + + auto &defaultStyle = QApplicationPrivate::app_style; - if (!app_style) { + defaultStyle = QStyleFactory::create(QApplicationPrivate::desktopStyleKey()); + if (!defaultStyle) { const QStringList styles = QStyleFactory::keys(); for (const auto &style : styles) { - if ((app_style = QStyleFactory::create(style))) + if ((defaultStyle = QStyleFactory::create(style))) break; } } - if (!app_style) { + if (!defaultStyle) { Q_ASSERT(!"No styles available!"); return 0; } - } - // take ownership of the style - QApplicationPrivate::app_style->setParent(qApp); - initSystemPalette(); + // Take ownership of the style + defaultStyle->setParent(qApp); - if (QApplicationPrivate::set_pal) // repolish set palette with the new style - QApplication::setPalette(*QApplicationPrivate::set_pal); + initSystemPalette(); + + if (QApplicationPrivate::set_pal) // Re-polish set palette with the new style + QApplication::setPalette(*QApplicationPrivate::set_pal); #ifndef QT_NO_STYLE_STYLESHEET - if (!QApplicationPrivate::styleSheet.isEmpty()) { - qApp->setStyleSheet(QApplicationPrivate::styleSheet); - } else + if (!QApplicationPrivate::styleSheet.isEmpty()) { + qApp->setStyleSheet(QApplicationPrivate::styleSheet); + } else #endif - QApplicationPrivate::app_style->polish(qApp); + { + defaultStyle->polish(qApp); + } + } return QApplicationPrivate::app_style; } -- cgit v1.2.3 From da0e7457523a5c6867c2d9b9f0346167738f0323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 25 Jun 2019 16:24:33 +0200 Subject: Explicitly polish palette instead of relying on QApplication::setPalette The only effect calling QApplication::setPalette will have is the polish, so opt for doing it explicitly instead of the weirdly looking no-op assignment. Change-Id: Ia80b3f60e3e513b68c2993ea8417966f9ab6721e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 1f26e6e41c..2a1a21596c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1057,8 +1057,8 @@ QStyle *QApplication::style() initSystemPalette(); - if (QApplicationPrivate::set_pal) // Re-polish set palette with the new style - QApplication::setPalette(*QApplicationPrivate::set_pal); + if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) + defaultStyle->polish(*explicitlySetPalette); #ifndef QT_NO_STYLE_STYLESHEET if (!QApplicationPrivate::styleSheet.isEmpty()) { @@ -1132,8 +1132,8 @@ void QApplication::setStyle(QStyle *style) // take care of possible palette requirements of certain gui // styles. Do it before polishing the application since the style // might call QApplication::setPalette() itself - if (QApplicationPrivate::set_pal) { - QApplication::setPalette(*QApplicationPrivate::set_pal); + if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) { + QApplicationPrivate::app_style->polish(*explicitlySetPalette); } else { if (QApplicationPrivate::sys_pal) clearSystemPalette(); -- cgit v1.2.3 From 1e27db6c20913bf1c8b607f1eb5e899fc8f4112e Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Fri, 6 Dec 2019 22:03:35 +0100 Subject: Avoid using a QRegExp for trivial replacements It's slow and we want to get rid of it. In this case, it's just as easy to do the replacing manually using a small loop. Task-number: QTBUG-72587 Change-Id: I32e1cc89642bc0e5b6f500d072960cd8871e0684 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/corelib/io/qprocess_win.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 05af5a5aee..1527cf93ed 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -49,7 +49,6 @@ #include <qelapsedtimer.h> #include <qfileinfo.h> #include <qrandom.h> -#include <qregexp.h> #include <qwineventnotifier.h> #include <private/qsystemlibrary_p.h> #include <private/qthread_p.h> @@ -398,7 +397,17 @@ static QString qt_create_commandline(const QString &program, const QStringList & for (int i=0; i<arguments.size(); ++i) { QString tmp = arguments.at(i); // Quotes are escaped and their preceding backslashes are doubled. - tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\"")); + int index = tmp.indexOf(QLatin1Char('"')); + while (index >= 0) { + // Escape quote + tmp.insert(index++, QLatin1Char('\\')); + // Double preceding backslashes (ignoring the one we just inserted) + for (int i = index - 2 ; i >= 0 && tmp.at(i) == QLatin1Char('\\') ; --i) { + tmp.insert(i, QLatin1Char('\\')); + index++; + } + index = tmp.indexOf(QLatin1Char('"'), index + 1); + } if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) { // The argument must not end with a \ since this would be interpreted // as escaping the quote -- rather put the \ behind the quote: e.g. -- cgit v1.2.3 From df69364469c6816dab0f364f0687946a8d566679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 25 Jun 2019 16:53:37 +0200 Subject: Remove QApplicationPrivate::set_pal Its purpose was to track the default palette set by the programmer, but after 8fb881900c this is tracked by the Qt::AA_SetPalette attribute. The palette itself is always reflected 1:1 in the palette tracked by QGuiApplicationPrivate::app_pal. Change-Id: If3e84c8b3ae6070b6c50be7a33adb38799b3f3a5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 18 ++++++------------ src/widgets/kernel/qapplication_p.h | 1 - 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 2a1a21596c..5a21a3a15c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -382,7 +382,6 @@ QString QApplicationPrivate::styleSheet; // default application styles QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0; QPalette *QApplicationPrivate::sys_pal = 0; // default system palette -QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer QFont *QApplicationPrivate::sys_font = 0; // default system font QFont *QApplicationPrivate::set_font = 0; // default font set by programmer @@ -803,8 +802,6 @@ QApplication::~QApplication() delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; clearSystemPalette(); - delete QApplicationPrivate::set_pal; - QApplicationPrivate::set_pal = 0; app_palettes()->clear(); delete QApplicationPrivate::sys_font; @@ -1057,8 +1054,8 @@ QStyle *QApplication::style() initSystemPalette(); - if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) - defaultStyle->polish(*explicitlySetPalette); + if (testAttribute(Qt::AA_SetPalette)) + defaultStyle->polish(*QGuiApplicationPrivate::app_pal); #ifndef QT_NO_STYLE_STYLESHEET if (!QApplicationPrivate::styleSheet.isEmpty()) { @@ -1132,8 +1129,8 @@ void QApplication::setStyle(QStyle *style) // take care of possible palette requirements of certain gui // styles. Do it before polishing the application since the style // might call QApplication::setPalette() itself - if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) { - QApplicationPrivate::app_style->polish(*explicitlySetPalette); + if (testAttribute(Qt::AA_SetPalette)) { + QApplicationPrivate::app_style->polish(*QGuiApplicationPrivate::app_pal); } else { if (QApplicationPrivate::sys_pal) clearSystemPalette(); @@ -1397,11 +1394,8 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* // Send ApplicationPaletteChange to qApp itself, and to the widgets. qApp->d_func()->sendApplicationPaletteChange(all, className); } + if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { - if (!QApplicationPrivate::set_pal) - QApplicationPrivate::set_pal = new QPalette(palette); - else - *QApplicationPrivate::set_pal = palette; QCoreApplication::setAttribute(Qt::AA_SetPalette); emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } @@ -1444,7 +1438,7 @@ void QApplicationPrivate::setSystemPalette(const QPalette &pal) else *sys_pal = pal; - if (!QApplicationPrivate::set_pal) + if (!testAttribute(Qt::AA_SetPalette)) QApplication::setPalette(*sys_pal); } diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 3167bd423f..79d06ed98c 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -162,7 +162,6 @@ public: static QWidgetList *popupWidgets; static QStyle *app_style; static QPalette *sys_pal; - static QPalette *set_pal; protected: void notifyThemeChanged() override; -- cgit v1.2.3 From 318a991907b6c08f52786160bafea1e30d3ad9bd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Tue, 10 Dec 2019 13:57:24 +0100 Subject: Windows: Fix offset of glyphs with DirectWrite font engine When fetching the bounding box of the alphamap for the glyph cache, we would include the margins in the size, but we would not account for it in the origin. We would therefore get a mismatch when copying the alpha map into the cache. [ChangeLog][Windows] Fixed a 2 pixel offset on glyphs when using color fonts or any hinting preference other than the default (full) hinting. Fixes: QTBUG-71928 Change-Id: I9287df02de4f6e79c3b6c5ce92b73c284261ef5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index 3415002ffc..98246de0a5 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -1012,8 +1012,8 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph int margin = glyphMargin(QFontEngine::Format_A32); - return glyph_metrics_t(rect.left, - rect.top, + return glyph_metrics_t(rect.left - margin, + rect.top - margin, rect.right - rect.left + margin * 2, rect.bottom - rect.top + margin * 2, bbox.xoff, bbox.yoff); -- cgit v1.2.3 From a3a6f28427de260ab827fc405b53b6f162f1ec90 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor <alexandru.croitor@qt.io> Date: Fri, 13 Dec 2019 12:04:14 +0100 Subject: OpenGL: Fix signature of GLDEBUGPROC in qopenglextrafunctions.h The typedef "QOPENGLF_APIENTRYP" was incompatible to the one in "src/opengl/qopengldebug.cpp" which used "QOPENGLF_APIENTRY". Note the misisng "P " ending. The type is meant to be a function pointer, not a pointer to a function pointer, so remove the extra P. Change-Id: I229b73ca8e7367f88a2b48e2728e615605f02da3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/opengl/qopenglextrafunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h index a68e269065..faac2dce4e 100644 --- a/src/gui/opengl/qopenglextrafunctions.h +++ b/src/gui/opengl/qopenglextrafunctions.h @@ -54,7 +54,7 @@ // GLES build without having included gl32.h -> GLDEBUGPROC is still need for the protos, define it here #if defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_ES_3_2) -typedef void (QOPENGLF_APIENTRYP *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +typedef void (QOPENGLF_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); #endif QT_BEGIN_NAMESPACE -- cgit v1.2.3 From e076965542148b8c2341fd4418733febbf9ae1ec Mon Sep 17 00:00:00 2001 From: James McDonnell <jmcdonnell@blackberry.com> Date: Fri, 16 Aug 2019 15:38:54 -0400 Subject: Move QQnxGLContext::ms_eglDisplay to the integration object In part, this is a continuation of https://codereview.qt-project.org/c/qt/qtbase/+/227953. It also paves the way toward implementing the EglDisplay integration resource needed by QtWayland. For the code that's being moved around and modified, switch from !QT_NO_OPENGL to QT_CONFIG(opengl). Change-Id: I5046e8caf5df7cf326f8e697d7d41cf802250414 Reviewed-by: Dan Cape <dcape@qnx.com> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io> --- src/plugins/platforms/qnx/qqnxglcontext.cpp | 27 ++----------------- src/plugins/platforms/qnx/qqnxglcontext.h | 7 ----- src/plugins/platforms/qnx/qqnxintegration.cpp | 37 ++++++++++++++++++++++----- src/plugins/platforms/qnx/qqnxintegration.h | 13 +++++++++- 4 files changed, 45 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index 1d030ba1aa..69391c4fec 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE -EGLDisplay QQnxGLContext::ms_eglDisplay = EGL_NO_DISPLAY; - static QEGLPlatformContext::Flags makeFlags() { QEGLPlatformContext::Flags result = 0; @@ -71,7 +69,8 @@ static QEGLPlatformContext::Flags makeFlags() } QQnxGLContext::QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share) - : QEGLPlatformContext(format, share, ms_eglDisplay, 0, QVariant(), makeFlags()) + : QEGLPlatformContext(format, share, QQnxIntegration::instance()->eglDisplay(), 0, QVariant(), + makeFlags()) { } @@ -79,28 +78,6 @@ QQnxGLContext::~QQnxGLContext() { } -void QQnxGLContext::initializeContext() -{ - qGLContextDebug(); - - // Initialize connection to EGL - ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (Q_UNLIKELY(ms_eglDisplay == EGL_NO_DISPLAY)) - qFatal("QQnxGLContext: failed to obtain EGL display: %x", eglGetError()); - - EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0); - if (Q_UNLIKELY(eglResult != EGL_TRUE)) - qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError()); -} - -void QQnxGLContext::shutdownContext() -{ - qGLContextDebug(); - - // Close connection to EGL - eglTerminate(ms_eglDisplay); -} - EGLSurface QQnxGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) { QQnxEglWindow *window = static_cast<QQnxEglWindow *>(surface); diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h index 19179a80e2..5d807ee9e4 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.h +++ b/src/plugins/platforms/qnx/qqnxglcontext.h @@ -58,19 +58,12 @@ public: QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share); virtual ~QQnxGLContext(); - static void initializeContext(); - static void shutdownContext(); - bool makeCurrent(QPlatformSurface *surface) override; void swapBuffers(QPlatformSurface *surface) override; void doneCurrent() override; protected: EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; - -private: - //Can be static because different displays returne the same handle - static EGLDisplay ms_eglDisplay; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index f479e94988..84baa6ec44 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -170,6 +170,9 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) #if QT_CONFIG(draganddrop) , m_drag(new QSimpleDrag()) #endif +#if QT_CONFIG(opengl) + , m_eglDisplay(EGL_NO_DISPLAY) +#endif { ms_instance = this; m_options = parseOptions(paramList); @@ -195,9 +198,8 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) QMetaObject::invokeMethod(m_navigatorEventNotifier, "start", Qt::QueuedConnection); #endif -#if !defined(QT_NO_OPENGL) - // Initialize global OpenGL resources - QQnxGLContext::initializeContext(); +#if QT_CONFIG(opengl) + createEglDisplay(); #endif // Create/start event thread @@ -284,9 +286,8 @@ QQnxIntegration::~QQnxIntegration() // Close connection to QNX composition manager screen_destroy_context(m_screenContext); -#if !defined(QT_NO_OPENGL) - // Cleanup global OpenGL resources - QQnxGLContext::shutdownContext(); +#if QT_CONFIG(opengl) + destroyEglDisplay(); #endif #if QT_CONFIG(qqnx_pps) @@ -741,4 +742,28 @@ bool QQnxIntegration::supportsNavigatorEvents() const return m_navigator != 0; } +#if QT_CONFIG(opengl) +void QQnxIntegration::createEglDisplay() +{ + qIntegrationDebug(); + + // Initialize connection to EGL + m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY)) + qFatal("QQnxiIntegration: failed to obtain EGL display: %x", eglGetError()); + + EGLBoolean eglResult = eglInitialize(m_eglDisplay, 0, 0); + if (Q_UNLIKELY(eglResult != EGL_TRUE)) + qFatal("QQnxIntegration: failed to initialize EGL display, err=%d", eglGetError()); +} + +void QQnxIntegration::destroyEglDisplay() +{ + qIntegrationDebug(); + + // Close connection to EGL + eglTerminate(m_eglDisplay); +} +#endif + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 0bf37880d1..2596af3c45 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -46,6 +46,10 @@ #include <screen/screen.h> +#if QT_CONFIG(opengl) +#include <EGL/egl.h> +#endif + QT_BEGIN_NAMESPACE class QQnxScreenEventThread; @@ -96,7 +100,8 @@ public: QPlatformWindow *createPlatformWindow(QWindow *window) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; -#if !defined(QT_NO_OPENGL) +#if QT_CONFIG(opengl) + EGLDisplay eglDisplay() const { return m_eglDisplay; } QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; #endif @@ -175,6 +180,12 @@ private: Options m_options; +#if QT_CONFIG(opengl) + EGLDisplay m_eglDisplay; + void createEglDisplay(); + void destroyEglDisplay(); +#endif + static QQnxIntegration *ms_instance; friend class QQnxWindow; -- cgit v1.2.3 From 4522b17159a29ffd12c4d93be8a6e8e1a05dccd0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 6 Dec 2019 21:56:41 +0100 Subject: QStandardItemModel: do not reset persisten index in setItem() When an existing item is replaced with a new one in QStandardItemModel::setItem() then the persitent index is invalidated which leads to some unexpected behaviors (like e.g the header size and resize mode are reset). Therefore we have to make sure that the invalidation does not happen. This can be achieved by delaying the call to QStandardItem::setModel() for the old item until the new is properly added. After this, the old item no longer gets a valid QModelIndex from the model and therefore can't invalidate the persistent index anymore. Fixes: QTBUG-13605 Fixes: QTBUG-73000 Fixes: QTBUG-80586 Change-Id: I4e45e6feb81b7287c0859f638d7ab1a576fc2f0f Reviewed-by: David Faure <david.faure@kdab.com> --- src/gui/itemmodels/qstandarditemmodel.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 2998808b54..9bdc22b49e 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -138,10 +138,19 @@ void QStandardItemPrivate::setChild(int row, int column, QStandardItem *item, return; } } + + // setting the model to nullptr invalidates the persistent index which we want to avoid + if (!item && oldItem) + oldItem->d_func()->setModel(nullptr); + + children.replace(index, item); + + // since now indexFromItem() does no longer return a valid index, the persistent index + // will not be invalidated anymore if (oldItem) oldItem->d_func()->setModel(nullptr); delete oldItem; - children.replace(index, item); + if (item) item->d_func()->lastKnownIndex = index; -- cgit v1.2.3 From 4689e198e76e054ef51254c0724064ba61408625 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 13 Dec 2019 15:13:39 +0100 Subject: Doc/SQL: update sql driver creation instructions Fix the links, remove section about Q_ODBC_VERSION_2 - it wasn't there since Qt5.0. Change-Id: I571f5c2cf0f0e2df38638299c26814b510d1a8af Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/sql/doc/src/sql-driver.qdoc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 9c26c4089c..3a0fcfa1e7 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -171,7 +171,8 @@ \section3 How to Build the QMYSQL Plugin on Windows You need to get the MySQL installation files (e.g. - \e{mysql-installer-web-community-8.0.18.0.msi}). Run the installer, + \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}). + Run the installer, select custom installation and install the MySQL C Connector which matches your Qt installation (x86 or x64). After installation make sure that the needed files are there: @@ -192,9 +193,9 @@ When you distribute your application, remember to include libmysql.dll in your installation package. It must be placed in the same folder - as the application executable. libmysql.dll additionally needs the + as the application executable. \e libmysql.dll additionally needs the MSVC runtime libraries which can be installed with vcredist.exe - (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}(vcredist.exe) + (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}{vcredist.exe} \target QOCI \section2 QOCI for the Oracle Call Interface (OCI) @@ -356,10 +357,6 @@ Windows NT based systems, this is the default. Note that the ODBC driver and the DBMS must also support Unicode. - Some driver managers and drivers do not support UNICODE. To use the - QODBC plugin with such drivers, it has to be compiled with - Q_ODBC_VERSION_2 defined. - For the Oracle 9 ODBC driver (Windows), it is necessary to check "SQL_WCHAR support" in the ODBC driver manager otherwise Oracle will convert all Unicode strings to local 8-bit. -- cgit v1.2.3 From 0edd2e39ad7f959c3d0c56e79abd3c60d9950538 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 11 Dec 2019 19:48:53 +0100 Subject: Let QItemSelectionModel::columnIntersectsSelection honor the parent QItemSelectionModel::columnIntersectsSelection() should honor the parent according to the docs. For rowIntersectsSelection() this was fixed a long time ago but columnIntersectsSelection() was forgotten. Sync the both functions and use range-based for loops as a drive-by. Fixes: QTBUG-80644 Change-Id: Iaf08f85e2225204d1e6564fa4bb0bc826352ed53 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/corelib/itemmodels/qitemselectionmodel.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp index c93a4d15b9..ebcc3b10ca 100644 --- a/src/corelib/itemmodels/qitemselectionmodel.cpp +++ b/src/corelib/itemmodels/qitemselectionmodel.cpp @@ -1627,10 +1627,9 @@ bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &par QItemSelection sel = d->ranges; sel.merge(d->currentSelection, d->currentCommand); - for (int i = 0; i < sel.count(); ++i) { - QItemSelectionRange range = sel.at(i); + for (const QItemSelectionRange &range : qAsConst(sel)) { if (range.parent() != parent) - return false; + return false; int top = range.top(); int bottom = range.bottom(); int left = range.left(); @@ -1661,11 +1660,13 @@ bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelInde QItemSelection sel = d->ranges; sel.merge(d->currentSelection, d->currentCommand); - for (int i = 0; i < sel.count(); ++i) { - int left = sel.at(i).left(); - int right = sel.at(i).right(); - int top = sel.at(i).top(); - int bottom = sel.at(i).bottom(); + for (const QItemSelectionRange &range : qAsConst(sel)) { + if (range.parent() != parent) + return false; + int top = range.top(); + int bottom = range.bottom(); + int left = range.left(); + int right = range.right(); if (left <= column && right >= column) { for (int j = top; j <= bottom; j++) { const Qt::ItemFlags flags = d->model->index(j, column, parent).flags(); -- cgit v1.2.3 From 0915a08b335650793cc024da906d745dc804debe Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Fri, 13 Dec 2019 12:06:24 +0100 Subject: Remove a bunch of code maked for removal Change-Id: I1bda415433b748a1b8408ef3b890a6de3e51b3ba Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/kernel/qmetatype.cpp | 5 ++--- src/corelib/kernel/qmetatype.h | 9 --------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 89765fb11a..79d6d0aa93 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -539,13 +539,12 @@ struct DefinedTypesFilter { #define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, MetaTypeId, AliasingName, RealNameStr) \ { RealNameStr, sizeof(RealNameStr) - 1, QMetaType::MetaTypeName }, -#define QT_ADD_STATIC_METATYPE_HACKS_ITER(MetaTypeName, TypeId, Name) \ - QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeName, Name) + static const struct { const char * typeName; int typeNameLength; int type; } types[] = { QT_FOR_EACH_STATIC_TYPE(QT_ADD_STATIC_METATYPE) QT_FOR_EACH_STATIC_ALIAS_TYPE(QT_ADD_STATIC_METATYPE_ALIASES_ITER) - QT_FOR_EACH_STATIC_HACKS_TYPE(QT_ADD_STATIC_METATYPE_HACKS_ITER) + QT_ADD_STATIC_METATYPE(_, QMetaTypeId2<qreal>::MetaType, qreal) {nullptr, 0, QMetaType::UnknownType} }; diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index ee7c0fa4a4..7628f5f6b3 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -187,10 +187,6 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); #define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\ F(QSizePolicy, 121, QSizePolicy) \ -// ### FIXME kill that set -#define QT_FOR_EACH_STATIC_HACKS_TYPE(F)\ - F(QMetaTypeId2<qreal>::MetaType, -1, qreal) - // F is a tuple: (QMetaType::TypeName, QMetaType::TypeNameID, AliasingType, "RealType") #define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)\ F(ULong, -1, ulong, "unsigned long") \ @@ -755,8 +751,6 @@ private: static bool registerDebugStreamOperatorFunction(const QtPrivate::AbstractDebugStreamFunction *f, int type); #endif -// ### Qt6: FIXME: Remove the special Q_CC_MSVC handling, it was introduced to maintain BC. -#if !defined(Q_NO_TEMPLATE_FRIENDS) && !defined(Q_CC_MSVC) #ifndef Q_CLANG_QDOC template<typename, bool> friend struct QtPrivate::ValueTypeIsMetaType; template<typename, typename> friend struct QtPrivate::ConverterMemberFunction; @@ -765,9 +759,6 @@ private: template<typename, bool> friend struct QtPrivate::AssociativeValueTypeIsMetaType; template<typename, bool> friend struct QtPrivate::IsMetaTypePair; template<typename, typename> friend struct QtPrivate::MetaTypeSmartPointerHelper; -#endif -#else -public: #endif static bool registerConverterFunction(const QtPrivate::AbstractConverterFunction *f, int from, int to); static void unregisterConverterFunction(int from, int to); -- cgit v1.2.3 From 5b4b437b30b320e2cd7c9a566999a39772e5d431 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Mon, 10 Jun 2019 15:57:52 +0200 Subject: WebGradients: redo implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation was *extremely* expensive. It relied on loading a binary JSON file from resources (which involved decompressing it), then extracting information out of it to build a gradient. Already-loaded gradients were kept in a local cache, which had to be mutex protected. Instead, this patch extends the gradient generator to build static arrays filled with the web gradient data, sitting in .rodata. These arrays are used when building QGradient objects with a web gradient. No explicit mutex protection is necessary, since accesses will just read from the arrays. As benefits, this patch removes: * the binary json representation from QtGui's resources (~4KB compressed, ~50KB uncompressed) * the overhead of reading from the JSON for each used web gradient; * the startup costs of registering the webgradients in the resources; * all the overhead of mutex locking when building such gradients; * all the runtime memory allocations to load, parse and cache the web gradients (including the memory + CPU spike on first load due to the uncompression of the JSON data, as well as a couple of deep copies). Change-Id: If5c3d704430df76ce8faf55ee75ebd4639ba09c4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/gui/painting/WEBGRADIENTS_LICENSE.txt | 21 - src/gui/painting/painting.pri | 5 - src/gui/painting/qbrush.cpp | 55 +- src/gui/painting/qbrush.h | 24 +- src/gui/painting/qt_attribution.json | 14 - src/gui/painting/webgradients.binaryjson | Bin 50792 -> 0 bytes src/gui/painting/webgradients.cpp | 578 +++++++++++++++++++ src/gui/painting/webgradients.css | 909 ------------------------------ 8 files changed, 600 insertions(+), 1006 deletions(-) delete mode 100644 src/gui/painting/WEBGRADIENTS_LICENSE.txt delete mode 100644 src/gui/painting/webgradients.binaryjson create mode 100644 src/gui/painting/webgradients.cpp delete mode 100644 src/gui/painting/webgradients.css (limited to 'src') diff --git a/src/gui/painting/WEBGRADIENTS_LICENSE.txt b/src/gui/painting/WEBGRADIENTS_LICENSE.txt deleted file mode 100644 index 1a4d527a4d..0000000000 --- a/src/gui/painting/WEBGRADIENTS_LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 itmeo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index fcf6488edd..1a0f4f11e4 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -111,13 +111,8 @@ SOURCES += \ painting/qplatformbackingstore.cpp \ painting/qpathsimplifier.cpp -webgradients.files = painting/webgradients.binaryjson -webgradients.prefix = qgradient -webgradients.base = painting - RESOURCES += \ painting/qpdf.qrc \ - webgradients darwin { HEADERS += painting/qcoregraphics_p.h diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index b23fb45952..83032bdc4f 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -1347,6 +1348,8 @@ QGradient::QGradient() based on the gradients from https://webgradients.com/. */ +#include "webgradients.cpp" + /*! \fn QGradient::QGradient(QGradient::Preset preset) \since 5.12 @@ -1358,47 +1361,12 @@ QGradient::QGradient() to be applied to arbitrary object sizes. */ QGradient::QGradient(Preset preset) - : QGradient() -{ - static QHash<int, QGradient> cachedPresets; - static QMutex cacheMutex; - QMutexLocker locker(&cacheMutex); - if (cachedPresets.contains(preset)) { - const QGradient &cachedPreset = cachedPresets.value(preset); - m_type = cachedPreset.m_type; - m_data = cachedPreset.m_data; - m_stops = cachedPreset.m_stops; - m_spread = cachedPreset.m_spread; - dummy = cachedPreset.dummy; - } else { - static QJsonDocument jsonPresets = []() { - QFile webGradients(QLatin1String(":/qgradient/webgradients.binaryjson")); - webGradients.open(QFile::ReadOnly); - return QJsonDocument::fromBinaryData(webGradients.readAll()); - }(); - - const QJsonValue presetData = jsonPresets[preset - 1]; - if (!presetData.isObject()) - return; - - m_type = LinearGradient; - setCoordinateMode(ObjectMode); - setSpread(PadSpread); - - const QJsonValue start = presetData[QLatin1String("start")]; - const QJsonValue end = presetData[QLatin1String("end")]; - m_data.linear.x1 = start[QLatin1String("x")].toDouble(); - m_data.linear.y1 = start[QLatin1String("y")].toDouble(); - m_data.linear.x2 = end[QLatin1String("x")].toDouble(); - m_data.linear.y2 = end[QLatin1String("y")].toDouble(); - - for (const QJsonValue &stop : presetData[QLatin1String("stops")].toArray()) { - setColorAt(stop[QLatin1String("position")].toDouble(), - QColor(QRgb(stop[QLatin1String("color")].toInt()))); - } - - cachedPresets.insert(preset, *this); - } + : m_type(LinearGradient) + , m_spread(PadSpread) + , m_stops(qt_preset_gradient_stops(preset)) + , m_data(qt_preset_gradient_data[preset - 1]) + , dummy(qt_preset_gradient_dummy()) +{ } /*! @@ -1408,11 +1376,6 @@ QGradient::~QGradient() { } -QT_END_NAMESPACE -static void initGradientPresets() { Q_INIT_RESOURCE(qmake_webgradients); } -Q_CONSTRUCTOR_FUNCTION(initGradientPresets); -QT_BEGIN_NAMESPACE - /*! \enum QGradient::Type diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 6a4ffab1c5..1d7199782f 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -400,16 +400,7 @@ public: inline bool operator!=(const QGradient &other) const { return !operator==(other); } -private: - friend class QLinearGradient; - friend class QRadialGradient; - friend class QConicalGradient; - friend class QBrush; - - Type m_type; - Spread m_spread; - QGradientStops m_stops; - union { + union QGradientData { struct { qreal x1, y1, x2, y2; } linear; @@ -419,7 +410,18 @@ private: struct { qreal cx, cy, angle; } conical; - } m_data; + }; + +private: + friend class QLinearGradient; + friend class QRadialGradient; + friend class QConicalGradient; + friend class QBrush; + + Type m_type; + Spread m_spread; + QGradientStops m_stops; + QGradientData m_data; void *dummy; // ### Qt 6: replace with actual content (CoordinateMode, InterpolationMode, ...) }; diff --git a/src/gui/painting/qt_attribution.json b/src/gui/painting/qt_attribution.json index 7b16e8c211..e2326a56c1 100644 --- a/src/gui/painting/qt_attribution.json +++ b/src/gui/painting/qt_attribution.json @@ -28,20 +28,6 @@ (C) Carsten Haitzler and various contributors. (C) Willem Monsuwe <willem@stack.nl>" }, - { - "Id": "webgradients", - "Name": "WebGradients", - "QDocModule": "qtgui", - "QtUsage": "Used in Qt GUI to provide presets for QGradient.", - "Files": "webgradients.css", - - "Description": "WebGradients is a free collection of 180 linear gradients.", - "Homepage": "https://webgradients.com/", - "License": "MIT License", - "LicenseId": "MIT", - "LicenseFile": "WEBGRADIENTS_LICENSE.txt", - "Copyright": "Copyright (c) 2017 itmeo" - }, { "Id": "xserverhelper", "Name": "X Server helper", diff --git a/src/gui/painting/webgradients.binaryjson b/src/gui/painting/webgradients.binaryjson deleted file mode 100644 index 75edd487be..0000000000 Binary files a/src/gui/painting/webgradients.binaryjson and /dev/null differ diff --git a/src/gui/painting/webgradients.cpp b/src/gui/painting/webgradients.cpp new file mode 100644 index 0000000000..b4d297450b --- /dev/null +++ b/src/gui/painting/webgradients.cpp @@ -0,0 +1,578 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file is auto-generated by gradientgen. DO NOT EDIT! + +static QArrayDataPointerRef<QGradientStop> qt_preset_gradient_stops(QGradient::Preset preset) +{ + Q_ASSERT(preset < QGradient::NumPresets); + switch (preset) { + case QGradient::WarmFlame: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 154, 158, 255)), QGradientStop(0.99, QColor(250, 208, 196, 255)), QGradientStop(1, QColor(250, 208, 196, 255))); + case QGradient::NightFade: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(161, 140, 209, 255)), QGradientStop(1, QColor(251, 194, 235, 255))); + case QGradient::SpringWarmth: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(250, 208, 196, 255)), QGradientStop(0.01, QColor(250, 208, 196, 255)), QGradientStop(1, QColor(255, 209, 255, 255))); + case QGradient::JuicyPeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 236, 210, 255)), QGradientStop(1, QColor(252, 182, 159, 255))); + case QGradient::YoungPassion: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 129, 119, 255)), QGradientStop(0, QColor(255, 134, 122, 255)), QGradientStop(0.21, QColor(255, 140, 127, 255)), QGradientStop(0.52, QColor(249, 145, 133, 255)), QGradientStop(0.78, QColor(207, 85, 108, 255)), QGradientStop(1, QColor(177, 42, 91, 255))); + case QGradient::LadyLips: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 154, 158, 255)), QGradientStop(0.99, QColor(254, 207, 239, 255)), QGradientStop(1, QColor(254, 207, 239, 255))); + case QGradient::SunnyMorning: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(246, 211, 101, 255)), QGradientStop(1, QColor(253, 160, 133, 255))); + case QGradient::RainyAshville: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(251, 194, 235, 255)), QGradientStop(1, QColor(166, 193, 238, 255))); + case QGradient::FrozenDreams: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 203, 241, 255)), QGradientStop(0.01, QColor(253, 203, 241, 255)), QGradientStop(1, QColor(230, 222, 233, 255))); + case QGradient::WinterNeva: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(161, 196, 253, 255)), QGradientStop(1, QColor(194, 233, 251, 255))); + case QGradient::DustyGrass: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(212, 252, 121, 255)), QGradientStop(1, QColor(150, 230, 161, 255))); + case QGradient::TemptingAzure: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(132, 250, 176, 255)), QGradientStop(1, QColor(143, 211, 244, 255))); + case QGradient::HeavyRain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(207, 217, 223, 255)), QGradientStop(1, QColor(226, 235, 240, 255))); + case QGradient::AmyCrisp: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(166, 192, 254, 255)), QGradientStop(1, QColor(246, 128, 132, 255))); + case QGradient::MeanFruit: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(252, 203, 144, 255)), QGradientStop(1, QColor(213, 126, 235, 255))); + case QGradient::DeepBlue: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(224, 195, 252, 255)), QGradientStop(1, QColor(142, 197, 252, 255))); + case QGradient::RipeMalinka: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(240, 147, 251, 255)), QGradientStop(1, QColor(245, 87, 108, 255))); + case QGradient::CloudyKnoxville: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 251, 251, 255)), QGradientStop(1, QColor(235, 237, 238, 255))); + case QGradient::MalibuBeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(79, 172, 254, 255)), QGradientStop(1, QColor(0, 242, 254, 255))); + case QGradient::NewLife: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(67, 233, 123, 255)), QGradientStop(1, QColor(56, 249, 215, 255))); + case QGradient::TrueSunset: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(250, 112, 154, 255)), QGradientStop(1, QColor(254, 225, 64, 255))); + case QGradient::MorpheusDen: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(48, 207, 208, 255)), QGradientStop(1, QColor(51, 8, 103, 255))); + case QGradient::RareWind: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(168, 237, 234, 255)), QGradientStop(1, QColor(254, 214, 227, 255))); + case QGradient::NearMoon: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(94, 231, 223, 255)), QGradientStop(1, QColor(180, 144, 202, 255))); + case QGradient::WildApple: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(210, 153, 194, 255)), QGradientStop(1, QColor(254, 249, 215, 255))); + case QGradient::SaintPetersburg: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(245, 247, 250, 255)), QGradientStop(1, QColor(195, 207, 226, 255))); + case QGradient::PlumPlate: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(102, 126, 234, 255)), QGradientStop(1, QColor(118, 75, 162, 255))); + case QGradient::EverlastingSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 252, 251, 255)), QGradientStop(1, QColor(226, 209, 195, 255))); + case QGradient::HappyFisher: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(137, 247, 254, 255)), QGradientStop(1, QColor(102, 166, 255, 255))); + case QGradient::Blessing: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(253, 219, 146, 255)), QGradientStop(1, QColor(209, 253, 255, 255))); + case QGradient::SharpeyeEagle: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(152, 144, 227, 255)), QGradientStop(1, QColor(177, 244, 207, 255))); + case QGradient::LadogaBottom: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(235, 192, 253, 255)), QGradientStop(1, QColor(217, 222, 216, 255))); + case QGradient::LemonGate: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(150, 251, 196, 255)), QGradientStop(1, QColor(249, 245, 134, 255))); + case QGradient::ItmeoBranding: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(42, 245, 152, 255)), QGradientStop(1, QColor(0, 158, 253, 255))); + case QGradient::ZeusMiracle: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(205, 156, 242, 255)), QGradientStop(1, QColor(246, 243, 255, 255))); + case QGradient::OldHat: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(228, 175, 203, 255)), QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0.3, QColor(226, 197, 139, 255)), QGradientStop(0.64, QColor(194, 206, 156, 255)), QGradientStop(1, QColor(126, 219, 220, 255))); + case QGradient::StarWine: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0, QColor(184, 203, 184, 255)), QGradientStop(0, QColor(180, 101, 218, 255)), QGradientStop(0.33, QColor(207, 108, 201, 255)), QGradientStop(0.66, QColor(238, 96, 156, 255)), QGradientStop(1, QColor(238, 96, 156, 255))); + case QGradient::HappyAcid: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(55, 236, 186, 255)), QGradientStop(1, QColor(114, 175, 211, 255))); + case QGradient::AwesomePine: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(235, 187, 167, 255)), QGradientStop(1, QColor(207, 199, 248, 255))); + case QGradient::NewYork: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 241, 235, 255)), QGradientStop(1, QColor(172, 224, 249, 255))); + case QGradient::ShyRainbow: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(238, 162, 162, 255)), QGradientStop(0.19, QColor(187, 193, 191, 255)), QGradientStop(0.42, QColor(87, 198, 225, 255)), QGradientStop(0.79, QColor(180, 159, 218, 255)), QGradientStop(1, QColor(122, 197, 216, 255))); + case QGradient::MixedHopes: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(196, 113, 245, 255)), QGradientStop(1, QColor(250, 113, 205, 255))); + case QGradient::FlyHigh: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(72, 198, 239, 255)), QGradientStop(1, QColor(111, 134, 214, 255))); + case QGradient::StrongBliss: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(247, 140, 160, 255)), QGradientStop(0.19, QColor(249, 116, 143, 255)), QGradientStop(0.6, QColor(253, 134, 140, 255)), QGradientStop(1, QColor(254, 154, 139, 255))); + case QGradient::FreshMilk: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(254, 173, 166, 255)), QGradientStop(1, QColor(245, 239, 239, 255))); + case QGradient::SnowAgain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(230, 233, 240, 255)), QGradientStop(1, QColor(238, 241, 245, 255))); + case QGradient::FebruaryInk: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(172, 203, 238, 255)), QGradientStop(1, QColor(231, 240, 253, 255))); + case QGradient::KindSteel: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(233, 222, 250, 255)), QGradientStop(1, QColor(251, 252, 219, 255))); + case QGradient::SoftGrass: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(193, 223, 196, 255)), QGradientStop(1, QColor(222, 236, 221, 255))); + case QGradient::GrownEarly: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(11, 163, 96, 255)), QGradientStop(1, QColor(60, 186, 146, 255))); + case QGradient::SharpBlues: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 198, 251, 255)), QGradientStop(1, QColor(0, 91, 234, 255))); + case QGradient::ShadyWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(116, 235, 213, 255)), QGradientStop(1, QColor(159, 172, 230, 255))); + case QGradient::DirtyBeauty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(106, 133, 182, 255)), QGradientStop(1, QColor(186, 200, 224, 255))); + case QGradient::GreatWhale: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(163, 189, 237, 255)), QGradientStop(1, QColor(105, 145, 199, 255))); + case QGradient::TeenNotebook: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(151, 149, 240, 255)), QGradientStop(1, QColor(251, 200, 212, 255))); + case QGradient::PoliteRumors: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(167, 166, 203, 255)), QGradientStop(0.52, QColor(137, 137, 186, 255)), QGradientStop(1, QColor(137, 137, 186, 255))); + case QGradient::SweetPeriod: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(63, 81, 177, 255)), QGradientStop(0.13, QColor(90, 85, 174, 255)), QGradientStop(0.25, QColor(123, 95, 172, 255)), QGradientStop(0.38, QColor(143, 106, 174, 255)), QGradientStop(0.5, QColor(168, 106, 164, 255)), QGradientStop(0.62, QColor(204, 107, 142, 255)), QGradientStop(0.75, QColor(241, 130, 113, 255)), QGradientStop(0.87, QColor(243, 164, 105, 255)), QGradientStop(1, QColor(247, 201, 120, 255))); + case QGradient::WideMatrix: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(252, 197, 228, 255)), QGradientStop(0.15, QColor(253, 163, 75, 255)), QGradientStop(0.35, QColor(255, 120, 130, 255)), QGradientStop(0.52, QColor(200, 105, 158, 255)), QGradientStop(0.71, QColor(112, 70, 170, 255)), QGradientStop(0.87, QColor(12, 29, 184, 255)), QGradientStop(1, QColor(2, 15, 117, 255))); + case QGradient::SoftCherish: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(219, 220, 215, 255)), QGradientStop(0.24, QColor(221, 220, 215, 255)), QGradientStop(0.3, QColor(226, 201, 204, 255)), QGradientStop(0.46, QColor(231, 98, 125, 255)), QGradientStop(0.59, QColor(184, 35, 90, 255)), QGradientStop(0.71, QColor(128, 19, 87, 255)), QGradientStop(0.84, QColor(61, 22, 53, 255)), QGradientStop(1, QColor(28, 26, 39, 255))); + case QGradient::RedSalvation: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(244, 59, 71, 255)), QGradientStop(1, QColor(69, 58, 148, 255))); + case QGradient::BurningSpring: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(79, 181, 118, 255)), QGradientStop(0.3, QColor(68, 196, 137, 255)), QGradientStop(0.46, QColor(40, 169, 174, 255)), QGradientStop(0.59, QColor(40, 162, 183, 255)), QGradientStop(0.71, QColor(76, 119, 136, 255)), QGradientStop(0.86, QColor(108, 79, 99, 255)), QGradientStop(1, QColor(67, 44, 57, 255))); + case QGradient::NightParty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(2, 80, 197, 255)), QGradientStop(1, QColor(212, 63, 141, 255))); + case QGradient::SkyGlider: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(136, 211, 206, 255)), QGradientStop(1, QColor(110, 69, 226, 255))); + case QGradient::HeavenPeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(217, 175, 217, 255)), QGradientStop(1, QColor(151, 217, 225, 255))); + case QGradient::PurpleDivision: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(112, 40, 228, 255)), QGradientStop(1, QColor(229, 178, 202, 255))); + case QGradient::AquaSplash: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(19, 84, 122, 255)), QGradientStop(1, QColor(128, 208, 199, 255))); + case QGradient::SpikyNaga: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(80, 82, 133, 255)), QGradientStop(0.12, QColor(88, 94, 146, 255)), QGradientStop(0.25, QColor(101, 104, 159, 255)), QGradientStop(0.37, QColor(116, 116, 176, 255)), QGradientStop(0.5, QColor(126, 126, 187, 255)), QGradientStop(0.62, QColor(131, 137, 199, 255)), QGradientStop(0.75, QColor(151, 149, 212, 255)), QGradientStop(0.87, QColor(162, 161, 220, 255)), QGradientStop(1, QColor(181, 174, 228, 255))); + case QGradient::LoveKiss: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 8, 68, 255)), QGradientStop(1, QColor(255, 177, 153, 255))); + case QGradient::CleanMirror: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(147, 165, 207, 255)), QGradientStop(1, QColor(228, 239, 233, 255))); + case QGradient::PremiumDark: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(67, 67, 67, 255)), QGradientStop(1, QColor(0, 0, 0, 255))); + case QGradient::ColdEvening: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(12, 52, 131, 255)), QGradientStop(1, QColor(162, 182, 223, 255)), QGradientStop(1, QColor(107, 140, 206, 255)), QGradientStop(1, QColor(162, 182, 223, 255))); + case QGradient::CochitiLake: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(147, 165, 207, 255)), QGradientStop(1, QColor(228, 239, 233, 255))); + case QGradient::SummerGames: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(146, 254, 157, 255)), QGradientStop(1, QColor(0, 201, 255, 255))); + case QGradient::PassionateBed: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 117, 140, 255)), QGradientStop(1, QColor(255, 126, 179, 255))); + case QGradient::MountainRock: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(134, 143, 150, 255)), QGradientStop(1, QColor(89, 97, 100, 255))); + case QGradient::DesertHump: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(199, 144, 129, 255)), QGradientStop(1, QColor(223, 165, 121, 255))); + case QGradient::JungleDay: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(139, 170, 170, 255)), QGradientStop(1, QColor(174, 139, 156, 255))); + case QGradient::PhoenixStart: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(248, 54, 0, 255)), QGradientStop(1, QColor(249, 212, 35, 255))); + case QGradient::OctoberSilence: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(183, 33, 255, 255)), QGradientStop(1, QColor(33, 212, 253, 255))); + case QGradient::FarawayRiver: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(110, 69, 226, 255)), QGradientStop(1, QColor(136, 211, 206, 255))); + case QGradient::AlchemistLab: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(213, 88, 200, 255)), QGradientStop(1, QColor(36, 210, 146, 255))); + case QGradient::OverSun: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(171, 236, 214, 255)), QGradientStop(1, QColor(251, 237, 150, 255))); + case QGradient::PremiumWhite: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(213, 212, 208, 255)), QGradientStop(0.01, QColor(213, 212, 208, 255)), QGradientStop(0.31, QColor(238, 238, 236, 255)), QGradientStop(0.75, QColor(239, 238, 236, 255)), QGradientStop(1, QColor(233, 233, 231, 255))); + case QGradient::MarsParty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(95, 114, 189, 255)), QGradientStop(1, QColor(155, 35, 234, 255))); + case QGradient::EternalConstance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(9, 32, 63, 255)), QGradientStop(1, QColor(83, 120, 149, 255))); + case QGradient::JapanBlush: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(221, 214, 243, 255)), QGradientStop(1, QColor(250, 172, 168, 255)), QGradientStop(1, QColor(250, 172, 168, 255))); + case QGradient::SmilingRain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(220, 176, 237, 255)), QGradientStop(1, QColor(153, 201, 156, 255))); + case QGradient::CloudyApple: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(243, 231, 233, 255)), QGradientStop(0.99, QColor(227, 238, 255, 255)), QGradientStop(1, QColor(227, 238, 255, 255))); + case QGradient::BigMango: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(199, 29, 111, 255)), QGradientStop(1, QColor(208, 150, 147, 255))); + case QGradient::HealthyWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(150, 222, 218, 255)), QGradientStop(1, QColor(80, 201, 195, 255))); + case QGradient::AmourAmour: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(247, 112, 98, 255)), QGradientStop(1, QColor(254, 81, 150, 255))); + case QGradient::RiskyConcrete: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(196, 197, 199, 255)), QGradientStop(0.52, QColor(220, 221, 223, 255)), QGradientStop(1, QColor(235, 235, 235, 255))); + case QGradient::StrongStick: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(168, 202, 186, 255)), QGradientStop(1, QColor(93, 65, 87, 255))); + case QGradient::ViciousStance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(41, 50, 60, 255)), QGradientStop(1, QColor(72, 85, 99, 255))); + case QGradient::PaloAlto: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(22, 160, 133, 255)), QGradientStop(1, QColor(244, 208, 63, 255))); + case QGradient::HappyMemories: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 88, 88, 255)), QGradientStop(1, QColor(240, 152, 25, 255))); + case QGradient::MidnightBloom: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(43, 88, 118, 255)), QGradientStop(1, QColor(78, 67, 118, 255))); + case QGradient::Crystalline: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 205, 172, 255)), QGradientStop(1, QColor(141, 218, 213, 255))); + case QGradient::PartyBliss: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(68, 129, 235, 255)), QGradientStop(1, QColor(4, 190, 254, 255))); + case QGradient::ConfidentCloud: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(218, 212, 236, 255)), QGradientStop(0.01, QColor(218, 212, 236, 255)), QGradientStop(1, QColor(243, 231, 233, 255))); + case QGradient::LeCocktail: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(135, 77, 162, 255)), QGradientStop(1, QColor(196, 58, 48, 255))); + case QGradient::RiverCity: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(68, 129, 235, 255)), QGradientStop(1, QColor(4, 190, 254, 255))); + case QGradient::FrozenBerry: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(232, 25, 139, 255)), QGradientStop(1, QColor(199, 234, 253, 255))); + case QGradient::ChildCare: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(247, 148, 164, 255)), QGradientStop(1, QColor(253, 214, 189, 255))); + case QGradient::FlyingLemon: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(100, 179, 244, 255)), QGradientStop(1, QColor(194, 229, 156, 255))); + case QGradient::NewRetrowave: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(59, 65, 197, 255)), QGradientStop(0.49, QColor(169, 129, 187, 255)), QGradientStop(1, QColor(255, 200, 169, 255))); + case QGradient::HiddenJaguar: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(15, 216, 80, 255)), QGradientStop(1, QColor(249, 240, 71, 255))); + case QGradient::AboveTheSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(211, 211, 211, 255)), QGradientStop(0.01, QColor(211, 211, 211, 255)), QGradientStop(0.26, QColor(224, 224, 224, 255)), QGradientStop(0.48, QColor(239, 239, 239, 255)), QGradientStop(0.75, QColor(217, 217, 217, 255)), QGradientStop(1, QColor(188, 188, 188, 255))); + case QGradient::Nega: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(238, 156, 167, 255)), QGradientStop(1, QColor(255, 221, 225, 255))); + case QGradient::DenseWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(58, 181, 176, 255)), QGradientStop(0.31, QColor(61, 153, 190, 255)), QGradientStop(1, QColor(86, 49, 122, 255))); + case QGradient::Seashore: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(32, 156, 255, 255)), QGradientStop(1, QColor(104, 224, 207, 255))); + case QGradient::MarbleWall: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(189, 194, 232, 255)), QGradientStop(0.01, QColor(189, 194, 232, 255)), QGradientStop(1, QColor(230, 222, 233, 255))); + case QGradient::CheerfulCaramel: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(230, 185, 128, 255)), QGradientStop(1, QColor(234, 205, 163, 255))); + case QGradient::NightSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(30, 60, 114, 255)), QGradientStop(0.01, QColor(30, 60, 114, 255)), QGradientStop(1, QColor(42, 82, 152, 255))); + case QGradient::MagicLake: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(213, 222, 231, 255)), QGradientStop(0, QColor(255, 175, 189, 255)), QGradientStop(1, QColor(201, 255, 191, 255))); + case QGradient::YoungGrass: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(155, 225, 93, 255)), QGradientStop(1, QColor(0, 227, 174, 255))); + case QGradient::ColorfulPeach: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(237, 110, 160, 255)), QGradientStop(1, QColor(236, 140, 105, 255))); + case QGradient::GentleCare: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 195, 160, 255)), QGradientStop(1, QColor(255, 175, 189, 255))); + case QGradient::PlumBath: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(204, 32, 142, 255)), QGradientStop(1, QColor(103, 19, 210, 255))); + case QGradient::HappyUnicorn: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(179, 255, 171, 255)), QGradientStop(1, QColor(18, 255, 247, 255))); + case QGradient::AfricanField: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(101, 189, 96, 255)), QGradientStop(0.25, QColor(90, 193, 168, 255)), QGradientStop(0.5, QColor(62, 198, 237, 255)), QGradientStop(0.75, QColor(183, 221, 183, 255)), QGradientStop(1, QColor(254, 243, 129, 255))); + case QGradient::SolidStone: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(36, 57, 73, 255)), QGradientStop(1, QColor(81, 127, 164, 255))); + case QGradient::OrangeJuice: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(252, 96, 118, 255)), QGradientStop(1, QColor(255, 154, 68, 255))); + case QGradient::GlassWater: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(223, 233, 243, 255)), QGradientStop(1, QColor(255, 255, 255, 255))); + case QGradient::NorthMiracle: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 219, 222, 255)), QGradientStop(1, QColor(252, 0, 255, 255))); + case QGradient::FruitBlend: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(249, 212, 35, 255)), QGradientStop(1, QColor(255, 78, 80, 255))); + case QGradient::MillenniumPine: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(80, 204, 127, 255)), QGradientStop(1, QColor(245, 209, 0, 255))); + case QGradient::HighFlight: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(10, 207, 254, 255)), QGradientStop(1, QColor(73, 90, 255, 255))); + case QGradient::MoleHall: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(97, 97, 97, 255)), QGradientStop(1, QColor(155, 197, 195, 255))); + case QGradient::SpaceShift: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(61, 51, 147, 255)), QGradientStop(0.37, QColor(43, 118, 185, 255)), QGradientStop(0.65, QColor(44, 172, 209, 255)), QGradientStop(1, QColor(53, 235, 147, 255))); + case QGradient::ForestInei: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(223, 137, 181, 255)), QGradientStop(1, QColor(191, 217, 254, 255))); + case QGradient::RoyalGarden: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(237, 110, 160, 255)), QGradientStop(1, QColor(236, 140, 105, 255))); + case QGradient::RichMetal: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(215, 210, 204, 255)), QGradientStop(1, QColor(48, 67, 82, 255))); + case QGradient::JuicyCake: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(225, 79, 173, 255)), QGradientStop(1, QColor(249, 212, 35, 255))); + case QGradient::SmartIndigo: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(178, 36, 239, 255)), QGradientStop(1, QColor(117, 121, 255, 255))); + case QGradient::SandStrike: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(193, 193, 97, 255)), QGradientStop(0, QColor(193, 193, 97, 255)), QGradientStop(1, QColor(212, 212, 177, 255))); + case QGradient::NorseBeauty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(236, 119, 171, 255)), QGradientStop(1, QColor(120, 115, 245, 255))); + case QGradient::AquaGuidance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(0, 122, 223, 255)), QGradientStop(1, QColor(0, 236, 188, 255))); + case QGradient::SunVeggie: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(32, 226, 215, 255)), QGradientStop(1, QColor(249, 254, 165, 255))); + case QGradient::SeaLord: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(44, 216, 213, 255)), QGradientStop(0.56, QColor(197, 193, 255, 255)), QGradientStop(1, QColor(255, 186, 195, 255))); + case QGradient::BlackSea: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(44, 216, 213, 255)), QGradientStop(0.48, QColor(107, 141, 214, 255)), QGradientStop(1, QColor(142, 55, 215, 255))); + case QGradient::GrassShampoo: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(223, 255, 205, 255)), QGradientStop(0.48, QColor(144, 249, 196, 255)), QGradientStop(1, QColor(57, 243, 187, 255))); + case QGradient::LandingAircraft: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(93, 159, 255, 255)), QGradientStop(0.48, QColor(184, 220, 255, 255)), QGradientStop(1, QColor(107, 187, 255, 255))); + case QGradient::WitchDance: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(168, 191, 255, 255)), QGradientStop(1, QColor(136, 77, 128, 255))); + case QGradient::SleeplessNight: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(82, 113, 196, 255)), QGradientStop(0.48, QColor(177, 159, 255, 255)), QGradientStop(1, QColor(236, 161, 254, 255))); + case QGradient::AngelCare: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 226, 159, 255)), QGradientStop(0.48, QColor(255, 169, 159, 255)), QGradientStop(1, QColor(255, 113, 154, 255))); + case QGradient::CrystalRiver: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(34, 225, 255, 255)), QGradientStop(0.48, QColor(29, 143, 225, 255)), QGradientStop(1, QColor(98, 94, 177, 255))); + case QGradient::SoftLipstick: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(182, 206, 232, 255)), QGradientStop(1, QColor(245, 120, 220, 255))); + case QGradient::SaltMountain: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 254, 255, 255)), QGradientStop(1, QColor(215, 255, 254, 255))); + case QGradient::PerfectWhite: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(227, 253, 245, 255)), QGradientStop(1, QColor(255, 230, 250, 255))); + case QGradient::FreshOasis: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(125, 226, 252, 255)), QGradientStop(1, QColor(185, 182, 229, 255))); + case QGradient::StrictNovember: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(203, 186, 204, 255)), QGradientStop(1, QColor(37, 128, 179, 255))); + case QGradient::MorningSalad: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(183, 248, 219, 255)), QGradientStop(1, QColor(80, 167, 194, 255))); + case QGradient::DeepRelief: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(112, 133, 182, 255)), QGradientStop(0.5, QColor(135, 167, 217, 255)), QGradientStop(1, QColor(222, 243, 248, 255))); + case QGradient::SeaStrike: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(119, 255, 210, 255)), QGradientStop(0.48, QColor(98, 151, 219, 255)), QGradientStop(1, QColor(30, 236, 255, 255))); + case QGradient::NightCall: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(172, 50, 228, 255)), QGradientStop(0.48, QColor(121, 24, 242, 255)), QGradientStop(1, QColor(72, 1, 255, 255))); + case QGradient::SupremeSky: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(212, 255, 236, 255)), QGradientStop(0.48, QColor(87, 242, 204, 255)), QGradientStop(1, QColor(69, 150, 251, 255))); + case QGradient::LightBlue: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(158, 251, 211, 255)), QGradientStop(0.48, QColor(87, 233, 242, 255)), QGradientStop(1, QColor(69, 212, 251, 255))); + case QGradient::MindCrawl: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(71, 59, 123, 255)), QGradientStop(0.51, QColor(53, 132, 167, 255)), QGradientStop(1, QColor(48, 210, 190, 255))); + case QGradient::LilyMeadow: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(101, 55, 155, 255)), QGradientStop(0.53, QColor(136, 106, 234, 255)), QGradientStop(1, QColor(100, 87, 198, 255))); + case QGradient::SugarLollipop: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(164, 69, 178, 255)), QGradientStop(0.52, QColor(212, 24, 114, 255)), QGradientStop(1, QColor(255, 0, 102, 255))); + case QGradient::SweetDessert: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(119, 66, 178, 255)), QGradientStop(0.52, QColor(241, 128, 255, 255)), QGradientStop(1, QColor(253, 139, 217, 255))); + case QGradient::MagicRay: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 60, 172, 255)), QGradientStop(0.52, QColor(86, 43, 124, 255)), QGradientStop(1, QColor(43, 134, 197, 255))); + case QGradient::TeenParty: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 5, 124, 255)), QGradientStop(0.5, QColor(141, 11, 147, 255)), QGradientStop(1, QColor(50, 21, 117, 255))); + case QGradient::FrozenHeat: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(255, 5, 124, 255)), QGradientStop(0.48, QColor(124, 100, 213, 255)), QGradientStop(1, QColor(76, 195, 255, 255))); + case QGradient::GagarinView: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(105, 234, 203, 255)), QGradientStop(0.48, QColor(234, 204, 248, 255)), QGradientStop(1, QColor(102, 84, 241, 255))); + case QGradient::FabledSunset: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(35, 21, 87, 255)), QGradientStop(0.29, QColor(68, 16, 122, 255)), QGradientStop(0.67, QColor(255, 19, 97, 255)), QGradientStop(1, QColor(255, 248, 0, 255))); + case QGradient::PerfectBlue: + return Q_ARRAY_LITERAL(QGradientStop, QGradientStop(0, QColor(61, 78, 129, 255)), QGradientStop(0.48, QColor(87, 83, 201, 255)), QGradientStop(1, QColor(110, 127, 243, 255))); + case QGradient::NumPresets: + Q_UNREACHABLE(); + } + Q_UNREACHABLE(); + return {}; +} + +static Q_CONSTEXPR QGradient::QGradientData qt_preset_gradient_data[] = { + { { 0, 1, 1, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 0, 0 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { -0.0915064, 0.158494, 1.09151, 0.841506 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 0, 0.5, 1 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0, 0, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.341506, 1.09151, 0.658494, -0.0915064 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 1.09151, 0.841506, -0.0915064, 0.158494 } }, + { { 1.09151, 0.841506, -0.0915064, 0.158494 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 1, 1, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 0, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.719186, 1.10221, 0.280814, -0.102208 } }, + { { 0, 0, 0, 0 } }, + { { -0.0915064, 0.841506, 1.09151, 0.158494 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0, 0.5, 1, 0.5 } }, + { { 0.5, 1, 0.5, 0 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, + { { 0, 0, 1, 1 } }, +}; + +static void *qt_preset_gradient_dummy() +{ + union {void *p; uint i;}; + p = 0; + i |= uint(QGradient::ObjectMode); + return p; +} diff --git a/src/gui/painting/webgradients.css b/src/gui/painting/webgradients.css deleted file mode 100644 index 870866bb46..0000000000 --- a/src/gui/painting/webgradients.css +++ /dev/null @@ -1,909 +0,0 @@ -/*001 Warm Flame*/ -.warm_flame{ - background-image: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%); -} - -/*002 Night Fade*/ -.night_fade{ - background-image: linear-gradient(to top, #a18cd1 0%, #fbc2eb 100%); -} - -/*003 Spring Warmth*/ -.spring_warmth{ - background-image: linear-gradient(to top, #fad0c4 0%, #fad0c4 1%, #ffd1ff 100%); -} - -/*004 Juicy Peach*/ -.juicy_peach{ - background-image: linear-gradient(to right, #ffecd2 0%, #fcb69f 100%); -} - -/*005 Young Passion*/ -.young_passion{ - background-image: linear-gradient(to right, #ff8177 0%, #ff867a 0%, #ff8c7f 21%, #f99185 52%, #cf556c 78%, #b12a5b 100%); -} - -/*006 Lady Lips*/ -.lady_lips{ - background-image: linear-gradient(to top, #ff9a9e 0%, #fecfef 99%, #fecfef 100%); -} - -/*007 Sunny Morning*/ -.sunny_morning{ - background-image: linear-gradient(120deg, #f6d365 0%, #fda085 100%); -} - -/*008 Rainy Ashville*/ -.rainy_ashville{ - background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%); -} - -/*009 Frozen Dreams*/ -.frozen_dreams{ - background-image: linear-gradient(to top, #fdcbf1 0%, #fdcbf1 1%, #e6dee9 100%); -} - -/*010 Winter Neva*/ -.winter_neva{ - background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%); -} - -/*011 Dusty Grass*/ -.dusty_grass{ - background-image: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%); -} - -/*012 Tempting Azure*/ -.tempting_azure{ - background-image: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%); -} - -/*013 Heavy Rain*/ -.heavy_rain{ - background-image: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%); -} - -/*014 Amy Crisp*/ -.amy_crisp{ - background-image: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%); -} - -/*015 Mean Fruit*/ -.mean_fruit{ - background-image: linear-gradient(120deg, #fccb90 0%, #d57eeb 100%); -} - -/*016 Deep Blue*/ -.deep_blue{ - background-image: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%); -} - -/*017 Ripe Malinka*/ -.ripe_malinka{ - background-image: linear-gradient(120deg, #f093fb 0%, #f5576c 100%); -} - -/*018 Cloudy Knoxville*/ -.cloudy_knoxville{ - background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%); -} - -/*019 Malibu Beach*/ -.malibu_beach{ - background-image: linear-gradient(to right, #4facfe 0%, #00f2fe 100%); -} - -/*020 New Life*/ -.new_life{ - background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%); -} - -/*021 True Sunset*/ -.true_sunset{ - background-image: linear-gradient(to right, #fa709a 0%, #fee140 100%); -} - -/*022 Morpheus Den*/ -.morpheus_den{ - background-image: linear-gradient(to top, #30cfd0 0%, #330867 100%); -} - -/*023 Rare Wind*/ -.rare_wind{ - background-image: linear-gradient(to top, #a8edea 0%, #fed6e3 100%); -} - -/*024 Near Moon*/ -.near_moon{ - background-image: linear-gradient(to top, #5ee7df 0%, #b490ca 100%); -} - -/*025 Wild Apple*/ -.wild_apple{ - background-image: linear-gradient(to top, #d299c2 0%, #fef9d7 100%); -} - -/*026 Saint Petersburg*/ -.saint_petersburg{ - background-image: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); -} - -/*027 Arielle's Smile*/ -.arielles_smile{ - background-image: radial-gradient(circle 248px at center, #16d9e3 0%, #30c7ec 47%, #46aef7 100%); -} - -/*028 Plum Plate*/ -.plum_plate{ - background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%); -} - -/*029 Everlasting Sky*/ -.everlasting_sky{ - background-image: linear-gradient(135deg, #fdfcfb 0%, #e2d1c3 100%); -} - -/*030 Happy Fisher*/ -.happy_fisher{ - background-image: linear-gradient(120deg, #89f7fe 0%, #66a6ff 100%); -} - -/*031 Blessing*/ -.blessing{ - background-image: linear-gradient(to top, #fddb92 0%, #d1fdff 100%); -} - -/*032 Sharpeye Eagle*/ -.sharpeye_eagle{ - background-image: linear-gradient(to top, #9890e3 0%, #b1f4cf 100%); -} - -/*033 Ladoga Bottom*/ -.ladoga_bottom{ - background-image: linear-gradient(to top, #ebc0fd 0%, #d9ded8 100%); -} - -/*034 Lemon Gate*/ -.lemon_gate{ - background-image: linear-gradient(to top, #96fbc4 0%, #f9f586 100%); -} - -/*035 Itmeo Branding*/ -.itmeo_branding{ - background-image: linear-gradient(180deg, #2af598 0%, #009efd 100%); -} - -/*036 Zeus Miracle*/ -.zeus_miracle{ - background-image: linear-gradient(to top, #cd9cf2 0%, #f6f3ff 100%); -} - -/*037 Old Hat*/ -.old_hat{ - background-image: linear-gradient(to right, #e4afcb 0%, #b8cbb8 0%, #b8cbb8 0%, #e2c58b 30%, #c2ce9c 64%, #7edbdc 100%); -} - -/*038 Star Wine*/ -.star_wine{ - background-image: linear-gradient(to right, #b8cbb8 0%, #b8cbb8 0%, #b465da 0%, #cf6cc9 33%, #ee609c 66%, #ee609c 100%); -} - -/*039 Deep Blue*/ -.deep_blue{ - background-image: linear-gradient(to right, #6a11cb 0%, #2575fc 100%); -} - -/*040 Coup de Grace*/ -.coup_de_grace{ - background: #DCD9D4 linear-gradient(to bottom, rgba(255, 255, 255, 0.50) 0%, rgba(0, 0, 0, 0.50) 100%), radial-gradient(at 50% 0%, rgba(255, 255, 255, 0.10) 0%, rgba(0, 0, 0, 0.50) 50%); - background-blend-mode: soft-light,screen; -} - -/*041 Happy Acid*/ -.happy_acid{ - background-image: linear-gradient(to top, #37ecba 0%, #72afd3 100%); -} - -/*042 Awesome Pine*/ -.awesome_pine{ - background-image: linear-gradient(to top, #ebbba7 0%, #cfc7f8 100%); -} - -/*043 New York*/ -.new_york{ - background-image: linear-gradient(to top, #fff1eb 0%, #ace0f9 100%); -} - -/*044 Shy Rainbow*/ -.shy_rainbow{ - background-image: linear-gradient(to right, #eea2a2 0%, #bbc1bf 19%, #57c6e1 42%, #b49fda 79%, #7ac5d8 100%); -} - -/*045 Loon Crest*/ -.loon_crest{ - background: linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.15) 100%), radial-gradient(at top center, rgba(255,255,255,0.40) 0%, rgba(0,0,0,0.40) 120%) #989898; - background-blend-mode: multiply,multiply; -} - -/*046 Mixed Hopes*/ -.mixed_hopes{ - background-image: linear-gradient(to top, #c471f5 0%, #fa71cd 100%); -} - -/*047 Fly High*/ -.fly_high{ - background-image: linear-gradient(to top, #48c6ef 0%, #6f86d6 100%); -} - -/*048 Strong Bliss*/ -.strong_bliss{ - background-image: linear-gradient(to right, #f78ca0 0%, #f9748f 19%, #fd868c 60%, #fe9a8b 100%); -} - -/*049 Fresh Milk*/ -.fresh_milk{ - background-image: linear-gradient(to top, #feada6 0%, #f5efef 100%); -} - -/*050 Snow Again*/ -.snow_again{ - background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%); -} - -/*051 February Ink*/ -.february_ink{ - background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%); -} - -/*052 Kind Steel*/ -.kind_steel{ - background-image: linear-gradient(-20deg, #e9defa 0%, #fbfcdb 100%); -} - -/*053 Soft Grass*/ -.soft_grass{ - background-image: linear-gradient(to top, #c1dfc4 0%, #deecdd 100%); -} - -/*054 Grown Early*/ -.grown_early{ - background-image: linear-gradient(to top, #0ba360 0%, #3cba92 100%); -} - -/*055 Sharp Blues*/ -.sharp_blues{ - background-image: linear-gradient(to top, #00c6fb 0%, #005bea 100%); -} - -/*056 Shady Water*/ -.shady_water{ - background-image: linear-gradient(to right, #74ebd5 0%, #9face6 100%); -} - -/*057 Dirty Beauty*/ -.dirty_beauty{ - background-image: linear-gradient(to top, #6a85b6 0%, #bac8e0 100%); -} - -/*058 Great Whale*/ -.great_whale{ - background-image: linear-gradient(to top, #a3bded 0%, #6991c7 100%); -} - -/*059 Teen Notebook*/ -.teen_notebook{ - background-image: linear-gradient(to top, #9795f0 0%, #fbc8d4 100%); -} - -/*060 Polite Rumors*/ -.polite_rumors{ - background-image: linear-gradient(to top, #a7a6cb 0%, #8989ba 52%, #8989ba 100%); -} - -/*061 Sweet Period*/ -.sweet_period{ - background-image: linear-gradient(to top, #3f51b1 0%, #5a55ae 13%, #7b5fac 25%, #8f6aae 38%, #a86aa4 50%, #cc6b8e 62%, #f18271 75%, #f3a469 87%, #f7c978 100%); -} - -/*062 Wide Matrix*/ -.wide_matrix{ - background-image: linear-gradient(to top, #fcc5e4 0%, #fda34b 15%, #ff7882 35%, #c8699e 52%, #7046aa 71%, #0c1db8 87%, #020f75 100%); -} - -/*063 Soft Cherish*/ -.soft_cherish{ - background-image: linear-gradient(to top, #dbdcd7 0%, #dddcd7 24%, #e2c9cc 30%, #e7627d 46%, #b8235a 59%, #801357 71%, #3d1635 84%, #1c1a27 100%); -} - -/*064 Red Salvation*/ -.red_salvation{ - background-image: linear-gradient(to top, #f43b47 0%, #453a94 100%); -} - -/*065 Burning Spring*/ -.burning_spring{ - background-image: linear-gradient(to top, #4fb576 0%, #44c489 30%, #28a9ae 46%, #28a2b7 59%, #4c7788 71%, #6c4f63 86%, #432c39 100%); -} - -/*066 Night Party*/ -.night_party{ - background-image: linear-gradient(to top, #0250c5 0%, #d43f8d 100%); -} - -/*067 Sky Glider*/ -.sky_glider{ - background-image: linear-gradient(to top, #88d3ce 0%, #6e45e2 100%); -} - -/*068 Heaven Peach*/ -.heaven_peach{ - background-image: linear-gradient(to top, #d9afd9 0%, #97d9e1 100%); -} - -/*069 Purple Division*/ -.purple_division{ - background-image: linear-gradient(to top, #7028e4 0%, #e5b2ca 100%); -} - -/*070 Aqua Splash*/ -.aqua_splash{ - background-image: linear-gradient(15deg, #13547a 0%, #80d0c7 100%); -} - -/*071 Above Clouds*/ -.above_clouds{ - background-image: linear-gradient(to left, #BDBBBE 0%, #9D9EA3 100%), radial-gradient(88% 271%, rgba(255, 255, 255, 0.25) 0%, rgba(254, 254, 254, 0.25) 1%, rgba(0, 0, 0, 0.25) 100%), radial-gradient(50% 100%, rgba(255, 255, 255, 0.30) 0%, rgba(0, 0, 0, 0.30) 100%); - background-blend-mode: normal, lighten, soft-light; -} - -/*072 Spiky Naga*/ -.spiky_naga{ - background-image: linear-gradient(to top, #505285 0%, #585e92 12%, #65689f 25%, #7474b0 37%, #7e7ebb 50%, #8389c7 62%, #9795d4 75%, #a2a1dc 87%, #b5aee4 100%); -} - -/*073 Love Kiss*/ -.love_kiss{ - background-image: linear-gradient(to top, #ff0844 0%, #ffb199 100%); -} - -/*074 Sharp Glass*/ -.sharp_glass{ - background: #C9CCD3 linear-gradient(-180deg, rgba(255, 255, 255, 0.50) 0%, rgba(0, 0, 0, 0.50) 100%); - background-blend-mode: lighten; -} - -/*075 Clean Mirror*/ -.clean_mirror{ - background-image: linear-gradient(45deg, #93a5cf 0%, #e4efe9 100%); -} - -/*076 Premium Dark*/ -.premium_dark{ - background-image: linear-gradient(to right, #434343 0%, black 100%); -} - -/*077 Cold Evening*/ -.cold_evening{ - background-image: linear-gradient(to top, #0c3483 0%, #a2b6df 100%, #6b8cce 100%, #a2b6df 100%); -} - -/*078 Cochiti Lake*/ -.cochiti_lake{ - background-image: linear-gradient(45deg, #93a5cf 0%, #e4efe9 100%); -} - -/*079 Summer Games*/ -.summer_games{ - background-image: linear-gradient(to right, #92fe9d 0%, #00c9ff 100%); -} - -/*080 Passionate Bed*/ -.passionate_bed{ - background-image: linear-gradient(to right, #ff758c 0%, #ff7eb3 100%); -} - -/*081 Mountain Rock*/ -.mountain_rock{ - background-image: linear-gradient(to right, #868f96 0%, #596164 100%); -} - -/*082 Desert Hump*/ -.desert_hump{ - background-image: linear-gradient(to top, #c79081 0%, #dfa579 100%); -} - -/*083 Jungle Day*/ -.jungle_day{ - background-image: linear-gradient(45deg, #8baaaa 0%, #ae8b9c 100%); -} - -/*084 Phoenix Start*/ -.phoenix_start{ - background-image: linear-gradient(to right, #f83600 0%, #f9d423 100%); -} - -/*085 October Silence*/ -.october_silence{ - background-image: linear-gradient(-20deg, #b721ff 0%, #21d4fd 100%); -} - -/*086 Faraway River*/ -.faraway_river{ - background-image: linear-gradient(-20deg, #6e45e2 0%, #88d3ce 100%); -} - -/*087 Alchemist Lab*/ -.alchemist_lab{ - background-image: linear-gradient(-20deg, #d558c8 0%, #24d292 100%); -} - -/*088 Over Sun*/ -.over_sun{ - background-image: linear-gradient(60deg, #abecd6 0%, #fbed96 100%); -} - -/*089 Premium White*/ -.premium_white{ - background-image: linear-gradient(to top, #d5d4d0 0%, #d5d4d0 1%, #eeeeec 31%, #efeeec 75%, #e9e9e7 100%); -} - -/*090 Mars Party*/ -.mars_party{ - background-image: linear-gradient(to top, #5f72bd 0%, #9b23ea 100%); -} - -/*091 Eternal Constance*/ -.eternal_constance{ - background-image: linear-gradient(to top, #09203f 0%, #537895 100%); -} - -/*092 Japan Blush*/ -.japan_blush{ - background-image: linear-gradient(-20deg, #ddd6f3 0%, #faaca8 100%, #faaca8 100%); -} - -/*093 Smiling Rain*/ -.smiling_rain{ - background-image: linear-gradient(-20deg, #dcb0ed 0%, #99c99c 100%); -} - -/*094 Cloudy Apple*/ -.cloudy_apple{ - background-image: linear-gradient(to top, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%); -} - -/*095 Big Mango*/ -.big_mango{ - background-image: linear-gradient(to top, #c71d6f 0%, #d09693 100%); -} - -/*096 Healthy Water*/ -.healthy_water{ - background-image: linear-gradient(60deg, #96deda 0%, #50c9c3 100%); -} - -/*097 Amour Amour*/ -.amour_amour{ - background-image: linear-gradient(to top, #f77062 0%, #fe5196 100%); -} - -/*098 Risky Concrete*/ -.risky_concrete{ - background-image: linear-gradient(to top, #c4c5c7 0%, #dcdddf 52%, #ebebeb 100%); -} - -/*099 Strong Stick*/ -.strong_stick{ - background-image: linear-gradient(to right, #a8caba 0%, #5d4157 100%); -} - -/*100 Vicious Stance*/ -.vicious_stance{ - background-image: linear-gradient(60deg, #29323c 0%, #485563 100%); -} - -/*101 Palo Alto*/ -.palo_alto{ - background-image: linear-gradient(-60deg, #16a085 0%, #f4d03f 100%); -} - -/*102 Happy Memories*/ -.happy_memories{ - background-image: linear-gradient(-60deg, #ff5858 0%, #f09819 100%); -} - -/*103 Midnight Bloom*/ -.midnight_bloom{ - background-image: linear-gradient(-20deg, #2b5876 0%, #4e4376 100%); -} - -/*104 Crystalline*/ -.crystalline{ - background-image: linear-gradient(-20deg, #00cdac 0%, #8ddad5 100%); -} - -/*105 Raccoon Back*/ -.raccoon_back{ - background: linear-gradient(-180deg, #BCC5CE 0%, #929EAD 98%), radial-gradient(at top left, rgba(255,255,255,0.30) 0%, rgba(0,0,0,0.30) 100%); - background-blend-mode: screen; -} - -/*106 Party Bliss*/ -.party_bliss{ - background-image: linear-gradient(to top, #4481eb 0%, #04befe 100%); -} - -/*107 Confident Cloud*/ -.confident_cloud{ - background-image: linear-gradient(to top, #dad4ec 0%, #dad4ec 1%, #f3e7e9 100%); -} - -/*108 Le Cocktail*/ -.le_cocktail{ - background-image: linear-gradient(45deg, #874da2 0%, #c43a30 100%); -} - -/*109 River City*/ -.river_city{ - background-image: linear-gradient(to top, #4481eb 0%, #04befe 100%); -} - -/*110 Frozen Berry*/ -.frozen_berry{ - background-image: linear-gradient(to top, #e8198b 0%, #c7eafd 100%); -} - -/*111 Elegance*/ -.elegance{ - background-image: radial-gradient(73% 147%, #EADFDF 59%, #ECE2DF 100%), radial-gradient(91% 146%, rgba(255,255,255,0.50) 47%, rgba(0,0,0,0.50) 100%); - background-blend-mode: screen; -} - -/*112 Child Care*/ -.child_care{ - background-image: linear-gradient(-20deg, #f794a4 0%, #fdd6bd 100%); -} - -/*113 Flying Lemon*/ -.flying_lemon{ - background-image: linear-gradient(60deg, #64b3f4 0%, #c2e59c 100%); -} - -/*114 New Retrowave*/ -.new_retrowave{ - background-image: linear-gradient(to top, #3b41c5 0%, #a981bb 49%, #ffc8a9 100%); -} - -/*115 Hidden Jaguar*/ -.hidden_jaguar{ - background-image: linear-gradient(to top, #0fd850 0%, #f9f047 100%); -} - -/*116 Above The Sky*/ -.above_the_sky{ - background-image: linear-gradient(to top, lightgrey 0%, lightgrey 1%, #e0e0e0 26%, #efefef 48%, #d9d9d9 75%, #bcbcbc 100%); -} - -/*117 Nega*/ -.nega{ - background-image: linear-gradient(45deg, #ee9ca7 0%, #ffdde1 100%); -} - -/*118 Dense Water*/ -.dense_water{ - background-image: linear-gradient(to right, #3ab5b0 0%, #3d99be 31%, #56317a 100%); -} - -/*119 Chemic Aqua*/ -.chemic_aqua{ - background: #CDDCDC radial-gradient(at 50% 100%, rgba(255, 255, 255, 0.50) 0%, rgba(0, 0, 0, 0.50) 100%), linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 0%, rgba(0, 0, 0, 0.25) 100%); - background-blend-mode: screen, overlay; -} - -/*120 Seashore*/ -.seashore{ - background-image: linear-gradient(to top, #209cff 0%, #68e0cf 100%); -} - -/*121 Marble Wall*/ -.marble_wall{ - background-image: linear-gradient(to top, #bdc2e8 0%, #bdc2e8 1%, #e6dee9 100%); -} - -/*122 Cheerful Caramel*/ -.cheerful_caramel{ - background-image: linear-gradient(to top, #e6b980 0%, #eacda3 100%); -} - -/*123 Night Sky*/ -.night_sky{ - background-image: linear-gradient(to top, #1e3c72 0%, #1e3c72 1%, #2a5298 100%); -} - -/*124 Magic Lake*/ -.magic_lake{ - background-image: linear-gradient(to top, #d5dee7 0%, #ffafbd 0%, #c9ffbf 100%); -} - -/*125 Young Grass*/ -.young_grass{ - background-image: linear-gradient(to top, #9be15d 0%, #00e3ae 100%); -} - -/*126 Colorful Peach*/ -.colorful_peach{ - background-image: linear-gradient(to right, #ed6ea0 0%, #ec8c69 100%); -} - -/*127 Gentle Care*/ -.gentle_care{ - background-image: linear-gradient(to right, #ffc3a0 0%, #ffafbd 100%); -} - -/*128 Plum Bath*/ -.plum_bath{ - background-image: linear-gradient(to top, #cc208e 0%, #6713d2 100%); -} - -/*129 Happy Unicorn*/ -.happy_unicorn{ - background-image: linear-gradient(to top, #b3ffab 0%, #12fff7 100%); -} - -/*130 Full Metal*/ -.full_metal{ - background: linear-gradient(to bottom, #D5DEE7 0%, #E8EBF2 50%, #E2E7ED 100%), linear-gradient(to bottom, rgba(0,0,0,0.02) 50%, rgba(255,255,255,0.02) 61%, rgba(0,0,0,0.02) 73%), linear-gradient(33deg, rgba(255,255,255,0.20) 0%, rgba(0,0,0,0.20) 100%); - background-blend-mode: normal,color-burn; -} - -/*131 African Field*/ -.african_field{ - background-image: linear-gradient(to top, #65bd60 0%, #5ac1a8 25%, #3ec6ed 50%, #b7ddb7 75%, #fef381 100%); -} - -/*132 Solid Stone*/ -.solid_stone{ - background-image: linear-gradient(to right, #243949 0%, #517fa4 100%); -} - -/*133 Orange Juice*/ -.orange_juice{ - background-image: linear-gradient(-20deg, #fc6076 0%, #ff9a44 100%); -} - -/*134 Glass Water*/ -.glass_water{ - background-image: linear-gradient(to top, #dfe9f3 0%, white 100%); -} - -/*135 Slick Carbon*/ -.slick_carbon{ - background: linear-gradient(to bottom, #323232 0%, #3F3F3F 40%, #1C1C1C 150%), linear-gradient(to top, rgba(255,255,255,0.40) 0%, rgba(0,0,0,0.25) 200%); - background-blend-mode: multiply; -} - -/*136 North Miracle*/ -.north_miracle{ - background-image: linear-gradient(to right, #00dbde 0%, #fc00ff 100%); -} - -/*137 Fruit Blend*/ -.fruit_blend{ - background-image: linear-gradient(to right, #f9d423 0%, #ff4e50 100%); -} - -/*138 Millennium Pine*/ -.millennium_pine{ - background-image: linear-gradient(to top, #50cc7f 0%, #f5d100 100%); -} - -/*139 High Flight*/ -.high_flight{ - background-image: linear-gradient(to right, #0acffe 0%, #495aff 100%); -} - -/*140 Mole Hall*/ -.mole_hall{ - background-image: linear-gradient(-20deg, #616161 0%, #9bc5c3 100%); -} - -/*141 Earl Gray*/ -.earl_gray{ - background: #E4E4E1 radial-gradient(at top center, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.03) 100%), linear-gradient(to top, rgba(255, 255, 255, 0.1) 0%, rgba(143, 152, 157, 0.60) 100%); - background-blend-mode: normal, multiply; -} - -/*142 Space Shift*/ -.space_shift{ - background-image: linear-gradient(60deg, #3d3393 0%, #2b76b9 37%, #2cacd1 65%, #35eb93 100%); -} - -/*143 Forest Inei*/ -.forest_inei{ - background-image: linear-gradient(to top, #df89b5 0%, #bfd9fe 100%); -} - -/*144 Royal Garden*/ -.royal_garden{ - background-image: linear-gradient(to right, #ed6ea0 0%, #ec8c69 100%); -} - -/*145 Rich Metal*/ -.rich_metal{ - background-image: linear-gradient(to right, #d7d2cc 0%, #304352 100%); -} - -/*146 Juicy Cake*/ -.juicy_cake{ - background-image: linear-gradient(to top, #e14fad 0%, #f9d423 100%); -} - -/*147 Smart Indigo*/ -.smart_indigo{ - background-image: linear-gradient(to top, #b224ef 0%, #7579ff 100%); -} - -/*148 Sand Strike*/ -.sand_strike{ - background-image: linear-gradient(to right, #c1c161 0%, #c1c161 0%, #d4d4b1 100%); -} - -/*149 Norse Beauty*/ -.norse_beauty{ - background-image: linear-gradient(to right, #ec77ab 0%, #7873f5 100%); -} - -/*150 Aqua Guidance*/ -.aqua_guidance{ - background-image: linear-gradient(to top, #007adf 0%, #00ecbc 100%); -} - -/*151 Sun Veggie*/ -.sun_veggie{ - background-image: linear-gradient(-225deg, #20E2D7 0%, #F9FEA5 100%); -} - -/*152 Sea Lord*/ -.sea_lord{ - background-image: linear-gradient(-225deg, #2CD8D5 0%, #C5C1FF 56%, #FFBAC3 100%); -} - -/*153 Black Sea*/ -.black_sea{ - background-image: linear-gradient(-225deg, #2CD8D5 0%, #6B8DD6 48%, #8E37D7 100%); -} - -/*154 Grass Shampoo*/ -.grass_shampoo{ - background-image: linear-gradient(-225deg, #DFFFCD 0%, #90F9C4 48%, #39F3BB 100%); -} - -/*155 Landing Aircraft*/ -.landing_aircraft{ - background-image: linear-gradient(-225deg, #5D9FFF 0%, #B8DCFF 48%, #6BBBFF 100%); -} - -/*156 Witch Dance*/ -.witch_dance{ - background-image: linear-gradient(-225deg, #A8BFFF 0%, #884D80 100%); -} - -/*157 Sleepless Night*/ -.sleepless_night{ - background-image: linear-gradient(-225deg, #5271C4 0%, #B19FFF 48%, #ECA1FE 100%); -} - -/*158 Angel Care*/ -.angel_care{ - background-image: linear-gradient(-225deg, #FFE29F 0%, #FFA99F 48%, #FF719A 100%); -} - -/*159 Crystal River*/ -.crystal_river{ - background-image: linear-gradient(-225deg, #22E1FF 0%, #1D8FE1 48%, #625EB1 100%); -} - -/*160 Soft Lipstick*/ -.soft_lipstick{ - background-image: linear-gradient(-225deg, #B6CEE8 0%, #F578DC 100%); -} - -/*161 Salt Mountain*/ -.salt_mountain{ - background-image: linear-gradient(-225deg, #FFFEFF 0%, #D7FFFE 100%); -} - -/*162 Perfect White*/ -.perfect_white{ - background-image: linear-gradient(-225deg, #E3FDF5 0%, #FFE6FA 100%); -} - -/*163 Fresh Oasis*/ -.fresh_oasis{ - background-image: linear-gradient(-225deg, #7DE2FC 0%, #B9B6E5 100%); -} - -/*164 Strict November*/ -.strict_november{ - background-image: linear-gradient(-225deg, #CBBACC 0%, #2580B3 100%); -} - -/*165 Morning Salad*/ -.morning_salad{ - background-image: linear-gradient(-225deg, #B7F8DB 0%, #50A7C2 100%); -} - -/*166 Deep Relief*/ -.deep_relief{ - background-image: linear-gradient(-225deg, #7085B6 0%, #87A7D9 50%, #DEF3F8 100%); -} - -/*167 Sea Strike*/ -.sea_strike{ - background-image: linear-gradient(-225deg, #77FFD2 0%, #6297DB 48%, #1EECFF 100%); -} - -/*168 Night Call*/ -.night_call{ - background-image: linear-gradient(-225deg, #AC32E4 0%, #7918F2 48%, #4801FF 100%); -} - -/*169 Supreme Sky*/ -.supreme_sky{ - background-image: linear-gradient(-225deg, #D4FFEC 0%, #57F2CC 48%, #4596FB 100%); -} - -/*170 Light Blue*/ -.light_blue{ - background-image: linear-gradient(-225deg, #9EFBD3 0%, #57E9F2 48%, #45D4FB 100%); -} - -/*171 Mind Crawl*/ -.mind_crawl{ - background-image: linear-gradient(-225deg, #473B7B 0%, #3584A7 51%, #30D2BE 100%); -} - -/*172 Lily Meadow*/ -.lily_meadow{ - background-image: linear-gradient(-225deg, #65379B 0%, #886AEA 53%, #6457C6 100%); -} - -/*173 Sugar Lollipop*/ -.sugar_lollipop{ - background-image: linear-gradient(-225deg, #A445B2 0%, #D41872 52%, #FF0066 100%); -} - -/*174 Sweet Dessert*/ -.sweet_dessert{ - background-image: linear-gradient(-225deg, #7742B2 0%, #F180FF 52%, #FD8BD9 100%); -} - -/*175 Magic Ray*/ -.magic_ray{ - background-image: linear-gradient(-225deg, #FF3CAC 0%, #562B7C 52%, #2B86C5 100%); -} - -/*176 Teen Party*/ -.teen_party{ - background-image: linear-gradient(-225deg, #FF057C 0%, #8D0B93 50%, #321575 100%); -} - -/*177 Frozen Heat*/ -.frozen_heat{ - background-image: linear-gradient(-225deg, #FF057C 0%, #7C64D5 48%, #4CC3FF 100%); -} - -/*178 Gagarin View*/ -.gagarin_view{ - background-image: linear-gradient(-225deg, #69EACB 0%, #EACCF8 48%, #6654F1 100%); -} - -/*179 Fabled Sunset*/ -.fabled_sunset{ - background-image: linear-gradient(-225deg, #231557 0%, #44107A 29%, #FF1361 67%, #FFF800 100%); -} - -/*180 Perfect Blue*/ -.perfect_blue{ - background-image: linear-gradient(-225deg, #3D4E81 0%, #5753C9 48%, #6E7FF3 100%); -} -- cgit v1.2.3 From 127533637e4ff4d3301fe02c88a2a506dd24c199 Mon Sep 17 00:00:00 2001 From: James McDonnell <jmcdonnell@blackberry.com> Date: Wed, 30 Oct 2019 10:22:07 -0400 Subject: Provide repeat parameter to handleExtendedKeyEvent QtWayland uses this to discard key repeats. Modifier key repeats confuse xkbcommon. Change-Id: I3ea384aa7b750ff83520bfb2440e61b91bb6e354 Reviewed-by: Dan Cape <dcape@qnx.com> Reviewed-by: Johan Helsing <johan.helsing@qt.io> --- src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index a9b5860187..e3a6aea99f 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -257,7 +257,7 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie capKeyString(cap, modifiers, key); QWindowSystemInterface::handleExtendedKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod, - scan, virtualKey, modifiers, keyStr); + scan, virtualKey, modifiers, keyStr, flags & KEY_REPEAT); qScreenEventDebug() << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr; } -- cgit v1.2.3 From d6266c757d2f2ea4ff1e71dc8545f9bf97aa3bb1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Fri, 6 Dec 2019 13:19:37 +0100 Subject: Replace usages of QVariant::value by qvariant_cast This is done automatically with a clazy check Change-Id: I3b59511d3d36d416c8eda74858ead611d327b116 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/kernel/qvariant.h | 6 +++--- src/corelib/serialization/qjsoncbor.cpp | 8 ++++---- src/corelib/serialization/qjsonvalue.cpp | 6 +++--- src/corelib/text/qlocale.cpp | 2 +- src/corelib/text/qlocale_unix.cpp | 4 ++-- src/dbus/qdbusinterface.cpp | 14 +++++++------- src/gui/image/qimagereader.cpp | 2 +- src/gui/image/qimagewriter.cpp | 2 +- src/gui/text/qfontengine_qpf2.cpp | 16 ++++++++-------- src/gui/text/qsyntaxhighlighter.cpp | 2 +- src/gui/util/qshadergenerator.cpp | 4 ++-- src/network/access/qnetworkreplyhttpimpl.cpp | 2 +- .../eglconvenience/qeglplatformcontext.cpp | 2 +- .../linuxaccessibility/atspiadaptor.cpp | 2 +- .../themes/genericunix/dbusmenu/qdbusmenutypes.cpp | 2 +- .../bearer/networkmanager/qnetworkmanagerengine.cpp | 2 +- .../bearer/networkmanager/qnetworkmanagerservice.cpp | 16 ++++++++-------- .../ibus/qibusplatforminputcontext.cpp | 4 ++-- src/plugins/platforminputcontexts/ibus/qibusproxy.cpp | 4 ++-- src/plugins/platforminputcontexts/ibus/qibustypes.cpp | 6 +++--- .../xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- src/plugins/printsupport/cups/qcupsprintengine.cpp | 4 ++-- src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 14 +++++++------- src/printsupport/dialogs/qprintdialog_unix.cpp | 18 +++++++++--------- src/printsupport/kernel/qcups.cpp | 2 +- src/printsupport/kernel/qprintengine_pdf.cpp | 6 +++--- src/printsupport/kernel/qprinter.cpp | 2 +- src/printsupport/widgets/qcupsjobwidget.cpp | 6 +++--- src/testlib/qabstractitemmodeltester.cpp | 2 +- src/widgets/dialogs/qdialog.cpp | 2 +- src/widgets/styles/qfusionstyle.cpp | 2 +- src/widgets/util/qscrollerproperties.cpp | 6 +++--- src/widgets/widgets/qcombobox.cpp | 2 +- 35 files changed, 89 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index c00efc0afe..f3ac3fcdba 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1544,7 +1544,7 @@ static void customStreamDebug(QDebug dbg, const QVariant &variant) { #ifndef QT_BOOTSTRAPPED QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType()); if (flags & QMetaType::PointerToQObject) - dbg.nospace() << variant.value<QObject*>(); + dbg.nospace() << qvariant_cast<QObject*>(variant); #else Q_UNUSED(dbg); Q_UNUSED(variant); diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 0dddfc59b3..0ffac5ad54 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -779,7 +779,7 @@ namespace QtPrivate { return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QByteArrayList*>(v.constData()))); } #endif - return QSequentialIterable(v.value<QtMetaTypePrivate::QSequentialIterableImpl>()); + return QSequentialIterable(qvariant_cast<QtMetaTypePrivate::QSequentialIterableImpl>(v)); } }; template<> @@ -794,7 +794,7 @@ namespace QtPrivate { if (typeId == qMetaTypeId<QVariantHash>()) { return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantHash*>(v.constData()))); } - return QAssociativeIterable(v.value<QtMetaTypePrivate::QAssociativeIterableImpl>()); + return QAssociativeIterable(qvariant_cast<QtMetaTypePrivate::QAssociativeIterableImpl>(v)); } }; template<> @@ -857,7 +857,7 @@ namespace QtPrivate { return QVariantValueHelper<QPair<QVariant, QVariant> >::invoke(v); if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) { - QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value<QtMetaTypePrivate::QPairVariantInterfaceImpl>(); + QtMetaTypePrivate::QPairVariantInterfaceImpl pi = qvariant_cast<QtMetaTypePrivate::QPairVariantInterfaceImpl>(v); const QtMetaTypePrivate::VariantData d1 = pi.first(); QVariant v1(d1.metaTypeId, d1.data, d1.flags); diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp index 7136a163ee..5097f4eb81 100644 --- a/src/corelib/serialization/qjsoncbor.cpp +++ b/src/corelib/serialization/qjsoncbor.cpp @@ -757,13 +757,13 @@ QCborValue QCborValue::fromVariant(const QVariant &variant) return QCborMap::fromJsonObject(doc.object()); } case QMetaType::QCborValue: - return variant.value<QCborValue>(); + return qvariant_cast<QCborValue>(variant); case QMetaType::QCborArray: - return variant.value<QCborArray>(); + return qvariant_cast<QCborArray>(variant); case QMetaType::QCborMap: - return variant.value<QCborMap>(); + return qvariant_cast<QCborMap>(variant); case QMetaType::QCborSimpleType: - return variant.value<QCborSimpleType>(); + return qvariant_cast<QCborSimpleType>(variant); #endif default: break; diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index 033e438580..6cf4c7fdf9 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -482,11 +482,11 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant) return doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object()); } case QMetaType::QCborValue: - return variant.value<QCborValue>().toJsonValue(); + return qvariant_cast<QCborValue>(variant).toJsonValue(); case QMetaType::QCborArray: - return variant.value<QCborArray>().toJsonArray(); + return qvariant_cast<QCborArray>(variant).toJsonArray(); case QMetaType::QCborMap: - return variant.value<QCborMap>().toJsonObject(); + return qvariant_cast<QCborMap>(variant).toJsonObject(); #endif default: break; diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 694d491273..bc38437f8e 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3065,7 +3065,7 @@ QList<Qt::DayOfWeek> QLocale::weekdays() const if (d->m_data == systemData()) { QVariant res = systemLocale()->query(QSystemLocale::Weekdays, QVariant()); if (!res.isNull()) - return static_cast<QList<Qt::DayOfWeek> >(res.value<QList<Qt::DayOfWeek> >()); + return static_cast<QList<Qt::DayOfWeek> >(qvariant_cast<QList<Qt::DayOfWeek> >(res)); } #endif QList<Qt::DayOfWeek> weekdays; diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index ff4274d932..5e1e47eae7 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -283,9 +283,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages); } case StringToStandardQuotation: - return lc_messages.quoteString(in.value<QStringRef>()); + return lc_messages.quoteString(qvariant_cast<QStringRef>(in)); case StringToAlternateQuotation: - return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation); + return lc_messages.quoteString(qvariant_cast<QStringRef>(in), QLocale::AlternateQuotation); case ListToSeparatedString: return lc_messages.createSeparatedList(in.toStringList()); case LocaleChanged: diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index 72b9d42247..fb958a8954 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -60,15 +60,15 @@ static void copyArgument(void *to, int id, const QVariant &arg) return; case QMetaType::UChar: - *reinterpret_cast<uchar *>(to) = arg.value<uchar>(); + *reinterpret_cast<uchar *>(to) = qvariant_cast<uchar>(arg); return; case QMetaType::Short: - *reinterpret_cast<short *>(to) = arg.value<short>(); + *reinterpret_cast<short *>(to) = qvariant_cast<short>(arg); return; case QMetaType::UShort: - *reinterpret_cast<ushort *>(to) = arg.value<ushort>(); + *reinterpret_cast<ushort *>(to) = qvariant_cast<ushort>(arg); return; case QVariant::Int: @@ -105,13 +105,13 @@ static void copyArgument(void *to, int id, const QVariant &arg) } if (id == QDBusMetaTypeId::variant()) { - *reinterpret_cast<QDBusVariant *>(to) = arg.value<QDBusVariant>(); + *reinterpret_cast<QDBusVariant *>(to) = qvariant_cast<QDBusVariant>(arg); return; } else if (id == QDBusMetaTypeId::objectpath()) { - *reinterpret_cast<QDBusObjectPath *>(to) = arg.value<QDBusObjectPath>(); + *reinterpret_cast<QDBusObjectPath *>(to) = qvariant_cast<QDBusObjectPath>(arg); return; } else if (id == QDBusMetaTypeId::signature()) { - *reinterpret_cast<QDBusSignature *>(to) = arg.value<QDBusSignature>(); + *reinterpret_cast<QDBusSignature *>(to) = qvariant_cast<QDBusSignature>(arg); return; } @@ -136,7 +136,7 @@ static void copyArgument(void *to, int id, const QVariant &arg) } // is it the same signature? - QDBusArgument dbarg = arg.value<QDBusArgument>(); + QDBusArgument dbarg = qvariant_cast<QDBusArgument>(arg); if (dbarg.currentSignature() != QLatin1String(userSignature)) { // not the same signature, another mismatch //qWarning? diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 5e3b608d20..6139cf99c9 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1089,7 +1089,7 @@ QList<QByteArray> QImageReader::supportedSubTypes() const return QList<QByteArray>(); if (d->handler->supportsOption(QImageIOHandler::SupportedSubTypes)) - return d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList<QByteArray> >(); + return qvariant_cast<QList<QByteArray> >(d->handler->option(QImageIOHandler::SupportedSubTypes)); return QList<QByteArray>(); } diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 9dcc955fe2..512da5c432 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -561,7 +561,7 @@ QList<QByteArray> QImageWriter::supportedSubTypes() const { if (!supportsOption(QImageIOHandler::SupportedSubTypes)) return QList<QByteArray>(); - return d->handler->option(QImageIOHandler::SupportedSubTypes).value< QList<QByteArray> >(); + return qvariant_cast<QList<QByteArray> >(d->handler->option(QImageIOHandler::SupportedSubTypes)); } /*! diff --git a/src/gui/text/qfontengine_qpf2.cpp b/src/gui/text/qfontengine_qpf2.cpp index d22239c040..e00f9d058c 100644 --- a/src/gui/text/qfontengine_qpf2.cpp +++ b/src/gui/text/qfontengine_qpf2.cpp @@ -456,7 +456,7 @@ glyph_metrics_t QFontEngineQPF2::boundingBox(glyph_t glyph) QFixed QFontEngineQPF2::ascent() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_Ascent).value<qreal>()); + return QFixed::fromReal(qvariant_cast<qreal>(extractHeaderField(fontData, Tag_Ascent))); } QFixed QFontEngineQPF2::capHeight() const @@ -466,37 +466,37 @@ QFixed QFontEngineQPF2::capHeight() const QFixed QFontEngineQPF2::descent() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_Descent).value<qreal>()); + return QFixed::fromReal(qvariant_cast<qreal>(extractHeaderField(fontData, Tag_Descent))); } QFixed QFontEngineQPF2::leading() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_Leading).value<qreal>()); + return QFixed::fromReal(qvariant_cast<qreal>(extractHeaderField(fontData, Tag_Leading))); } qreal QFontEngineQPF2::maxCharWidth() const { - return extractHeaderField(fontData, Tag_MaxCharWidth).value<qreal>(); + return qvariant_cast<qreal>(extractHeaderField(fontData, Tag_MaxCharWidth)); } qreal QFontEngineQPF2::minLeftBearing() const { - return extractHeaderField(fontData, Tag_MinLeftBearing).value<qreal>(); + return qvariant_cast<qreal>(extractHeaderField(fontData, Tag_MinLeftBearing)); } qreal QFontEngineQPF2::minRightBearing() const { - return extractHeaderField(fontData, Tag_MinRightBearing).value<qreal>(); + return qvariant_cast<qreal>(extractHeaderField(fontData, Tag_MinRightBearing)); } QFixed QFontEngineQPF2::underlinePosition() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_UnderlinePosition).value<qreal>()); + return QFixed::fromReal(qvariant_cast<qreal>(extractHeaderField(fontData, Tag_UnderlinePosition))); } QFixed QFontEngineQPF2::lineThickness() const { - return QFixed::fromReal(extractHeaderField(fontData, Tag_LineThickness).value<qreal>()); + return QFixed::fromReal(qvariant_cast<qreal>(extractHeaderField(fontData, Tag_LineThickness))); } bool QFontEngineQPF2::isValid() const diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index c345e89a21..b50957d63d 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -299,7 +299,7 @@ QSyntaxHighlighter::QSyntaxHighlighter(QObject *parent) : QObject(*new QSyntaxHighlighterPrivate, parent) { if (parent && parent->inherits("QTextEdit")) { - QTextDocument *doc = parent->property("document").value<QTextDocument *>(); + QTextDocument *doc = qvariant_cast<QTextDocument *>(parent->property("document")); if (doc) setDocument(doc); } diff --git a/src/gui/util/qshadergenerator.cpp b/src/gui/util/qshadergenerator.cpp index bcb985de54..4beed8ed25 100644 --- a/src/gui/util/qshadergenerator.cpp +++ b/src/gui/util/qshadergenerator.cpp @@ -273,11 +273,11 @@ namespace const QByteArray placeholder = QByteArray(QByteArrayLiteral("$") + parameterName.toUtf8()); const QVariant parameter = node.parameter(parameterName); if (parameter.userType() == qMetaTypeId<QShaderLanguage::StorageQualifier>()) { - const QShaderLanguage::StorageQualifier qualifier = parameter.value<QShaderLanguage::StorageQualifier>(); + const QShaderLanguage::StorageQualifier qualifier = qvariant_cast<QShaderLanguage::StorageQualifier>(parameter); const QByteArray value = toGlsl(qualifier, format); result.replace(placeholder, value); } else if (parameter.userType() == qMetaTypeId<QShaderLanguage::VariableType>()) { - const QShaderLanguage::VariableType type = parameter.value<QShaderLanguage::VariableType>(); + const QShaderLanguage::VariableType type = qvariant_cast<QShaderLanguage::VariableType>(parameter); const QByteArray value = toGlsl(type); result.replace(placeholder, value); } else { diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index ba9d0a76d5..5a775142b0 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -693,7 +693,7 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq auto redirectPolicy = QNetworkRequest::ManualRedirectPolicy; const QVariant value = newHttpRequest.attribute(QNetworkRequest::RedirectPolicyAttribute); if (value.isValid()) - redirectPolicy = value.value<QNetworkRequest::RedirectPolicy>(); + redirectPolicy = qvariant_cast<QNetworkRequest::RedirectPolicy>(value); else if (newHttpRequest.attribute(QNetworkRequest::FollowRedirectsAttribute).toBool()) redirectPolicy = QNetworkRequest::NoLessSafeRedirectPolicy; diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index aa87a620d8..63cf771f32 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -218,7 +218,7 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon qWarning("QEGLPlatformContext: Requires a QEGLNativeContext"); return; } - QEGLNativeContext handle = nativeHandle.value<QEGLNativeContext>(); + QEGLNativeContext handle = qvariant_cast<QEGLNativeContext>(nativeHandle); EGLContext context = handle.context(); if (!context) { qWarning("QEGLPlatformContext: No EGLContext given"); diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 4a83c6eb80..0f34e1a4ca 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -2230,7 +2230,7 @@ bool AtSpiAdaptor::valueInterface(QAccessibleInterface *interface, const QString return false; if (function == QLatin1String("SetCurrentValue")) { - QDBusVariant v = message.arguments().at(2).value<QDBusVariant>(); + QDBusVariant v = qvariant_cast<QDBusVariant>(message.arguments().at(2)); double value = v.variant().toDouble(); //Temporary fix //See https://bugzilla.gnome.org/show_bug.cgi?id=652596 diff --git a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp index 82a13d2fa0..ccf2180dc5 100644 --- a/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp +++ b/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenutypes.cpp @@ -152,7 +152,7 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, QDBusMenuLayoutItem &i while (!arg.atEnd()) { QDBusVariant dbusVariant; arg >> dbusVariant; - QDBusArgument childArgument = dbusVariant.variant().value<QDBusArgument>(); + QDBusArgument childArgument = qvariant_cast<QDBusArgument>(dbusVariant.variant()); QDBusMenuLayoutItem child; childArgument >> child; diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index e74b1cf744..85a9f9b9e0 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -250,7 +250,7 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVari if (i.key() == QLatin1String("ActiveConnections")) { // Active connections changed, update configurations. - const auto activeConnections = qdbus_cast<QList<QDBusObjectPath> >(i.value().value<QDBusArgument>()); + const auto activeConnections = qdbus_cast<QList<QDBusObjectPath> >(qvariant_cast<QDBusArgument>(i.value())); QStringList identifiers = accessPointConfigurations.keys(); QStringList priorActiveConnections = activeConnectionsList.keys(); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 35199eb7a2..2d6cba1791 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -193,7 +193,7 @@ QList <QDBusObjectPath> QNetworkManagerInterface::activeConnections() const { if (propertyMap.contains("ActiveConnections")) { - const QDBusArgument &dbusArgs = propertyMap.value("ActiveConnections").value<QDBusArgument>(); + const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(propertyMap.value("ActiveConnections")); QDBusObjectPath path; QList <QDBusObjectPath> list; @@ -403,7 +403,7 @@ quint32 QNetworkManagerInterfaceDevice::deviceType() const QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const { if (propertyMap.contains("Ip4Config")) - return propertyMap.value("Ip4Config").value<QDBusObjectPath>(); + return qvariant_cast<QDBusObjectPath>(propertyMap.value("Ip4Config")); return QDBusObjectPath(); } @@ -411,7 +411,7 @@ void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map) { for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) { if (i.key() == QLatin1String("AvailableConnections")) { //Device - const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>(); + const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(i.value()); QDBusObjectPath path; QStringList paths; dbusArgs.beginArray(); @@ -489,7 +489,7 @@ QStringList QNetworkManagerInterfaceDeviceWired::availableConnections() { QStringList list; if (propertyMap.contains("AvailableConnections")) { - const QDBusArgument &dbusArgs = propertyMap.value("Carrier").value<QDBusArgument>(); + const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(propertyMap.value("Carrier")); QDBusObjectPath path; dbusArgs.beginArray(); while (!dbusArgs.atEnd()) { @@ -598,7 +598,7 @@ quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const { if (propertyMap.contains("ActiveAccessPoint")) - return propertyMap.value("ActiveAccessPoint").value<QDBusObjectPath>(); + return qvariant_cast<QDBusObjectPath>(propertyMap.value("ActiveAccessPoint")); return QDBusObjectPath(); } @@ -931,14 +931,14 @@ QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() QDBusObjectPath QNetworkManagerConnectionActive::connection() const { if (propertyMap.contains("Connection")) - return propertyMap.value("Connection").value<QDBusObjectPath>(); + return qvariant_cast<QDBusObjectPath>(propertyMap.value("Connection")); return QDBusObjectPath(); } QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const { if (propertyMap.contains("SpecificObject")) - return propertyMap.value("SpecificObject").value<QDBusObjectPath>(); + return qvariant_cast<QDBusObjectPath>(propertyMap.value("SpecificObject")); return QDBusObjectPath(); } @@ -946,7 +946,7 @@ QStringList QNetworkManagerConnectionActive::devices() const { QStringList list; if (propertyMap.contains("Devices")) { - const QDBusArgument &dbusArgs = propertyMap.value("Devices").value<QDBusArgument>(); + const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(propertyMap.value("Devices")); QDBusObjectPath path; dbusArgs.beginArray(); diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index f2429f24ff..47ac54927b 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -285,7 +285,7 @@ void QIBusPlatformInputContext::commitText(const QDBusVariant &text) if (!input) return; - const QDBusArgument arg = text.variant().value<QDBusArgument>(); + const QDBusArgument arg = qvariant_cast<QDBusArgument>(text.variant()); QIBusText t; if (debug) @@ -311,7 +311,7 @@ void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint if (!input) return; - const QDBusArgument arg = text.variant().value<QDBusArgument>(); + const QDBusArgument arg = qvariant_cast<QDBusArgument>(text.variant()); QIBusText t; arg >> t; diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp index 156e9b7c90..6b46e106ab 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp @@ -83,10 +83,10 @@ QIBusEngineDesc QIBusProxy::getGlobalEngine() QVariant variant = reply.value().variant(); if (!variant.isValid()) return desc; - QVariant child = variant.value<QDBusVariant>().variant(); + QVariant child = qvariant_cast<QDBusVariant>(variant).variant(); if (!child.isValid()) return desc; - const QDBusArgument argument = child.value<QDBusArgument>(); + const QDBusArgument argument = qvariant_cast<QDBusArgument>(child); argument >> desc; return desc; } diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp index a2551f1320..443df271a8 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp @@ -62,7 +62,7 @@ void QIBusSerializable::deserializeFrom(const QDBusArgument &argument) argument >> key; argument >> value; argument.endMapEntry(); - attachments[key] = value.variant().value<QDBusArgument>(); + attachments[key] = qvariant_cast<QDBusArgument>(value.variant()); } argument.endMap(); } @@ -201,7 +201,7 @@ void QIBusAttributeList::deserializeFrom(const QDBusArgument &arg) arg >> var; QIBusAttribute attr; - var.variant().value<QDBusArgument>() >> attr; + qvariant_cast<QDBusArgument>(var.variant()) >> attr; attributes.append(std::move(attr)); } arg.endArray(); @@ -268,7 +268,7 @@ void QIBusText::deserializeFrom(const QDBusArgument &argument) argument >> text; QDBusVariant variant; argument >> variant; - variant.variant().value<QDBusArgument>() >> attributes; + qvariant_cast<QDBusArgument>(variant.variant()) >> attributes; argument.endStructure(); } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 57805d5571..75189a9c80 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -429,7 +429,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const qWarning("QGLXContext: Requires a QGLXNativeContext"); return; } - QGLXNativeContext handle = nativeHandle.value<QGLXNativeContext>(); + QGLXNativeContext handle = qvariant_cast<QGLXNativeContext>(nativeHandle); GLXContext context = handle.context(); if (!context) { qWarning("QGLXContext: No GLXContext given"); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 66030b9ad4..23ed80ab5a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -930,7 +930,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) QXcbWindowFunctions::WmWindowTypes wmWindowTypes; if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) { wmWindowTypes = static_cast<QXcbWindowFunctions::WmWindowTypes>( - window()->property(wm_window_type_property_id).value<int>()); + qvariant_cast<int>(window()->property(wm_window_type_property_id))); } setWmWindowType(wmWindowTypes, flags); diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp index c9683eb99d..43d5e119ad 100644 --- a/src/plugins/printsupport/cups/qcupsprintengine.cpp +++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp @@ -100,10 +100,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v d->cupsOptions = value.toStringList(); break; case PPK_QPageSize: - d->setPageSize(value.value<QPageSize>()); + d->setPageSize(qvariant_cast<QPageSize>(value)); break; case PPK_QPageLayout: { - QPageLayout pageLayout = value.value<QPageLayout>(); + QPageLayout pageLayout = qvariant_cast<QPageLayout>(value); if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution) || d->m_printDevice.supportsCustomPageSizes() || d->m_printDevice.supportedPageSizes().isEmpty())) { diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index ab7a2edb67..78e5b8d1ef 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -533,10 +533,10 @@ void QPageSetupWidget::setupPrinter() const { m_printer->setPageLayout(m_pageLayout); #if QT_CONFIG(cups) - QCUPSSupport::PagesPerSheet pagesPerSheet = m_ui.pagesPerSheetCombo->currentData() - .value<QCUPSSupport::PagesPerSheet>(); - QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = m_ui.pagesPerSheetLayoutCombo->currentData() - .value<QCUPSSupport::PagesPerSheetLayout>(); + QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData() +); + QCUPSSupport::PagesPerSheetLayout pagesPerSheetLayout = qvariant_cast<QCUPSSupport::PagesPerSheetLayout>(m_ui.pagesPerSheetLayoutCombo->currentData() +); QCUPSSupport::setPagesPerSheetLayout(m_printer, pagesPerSheet, pagesPerSheetLayout); #endif #ifdef PSD_ENABLE_PAPERSOURCE @@ -587,11 +587,11 @@ void QPageSetupWidget::pageSizeChanged() { QPageSize pageSize; if (m_ui.pageSizeCombo->currentIndex() != m_realCustomPageSizeIndex) { - pageSize = m_ui.pageSizeCombo->currentData().value<QPageSize>(); + pageSize = qvariant_cast<QPageSize>(m_ui.pageSizeCombo->currentData()); #if QT_CONFIG(cups) if (m_pageSizePpdOption) { - ppd_file_t *ppd = m_printDevice->property(PDPK_PpdFile).value<ppd_file_t*>(); + ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_printDevice->property(PDPK_PpdFile)); QTextCodec *cupsCodec = QTextCodec::codecForName(ppd->lang_encoding); for (int i = 0; i < m_pageSizePpdOption->num_choices; ++i) { const ppd_choice_t *choice = &m_pageSizePpdOption->choices[i]; @@ -676,7 +676,7 @@ void QPageSetupWidget::unitChanged() { if (m_blockSignals) return; - m_units = m_ui.unitCombo->currentData().value<QPageLayout::Unit>(); + m_units = qvariant_cast<QPageLayout::Unit>(m_ui.unitCombo->currentData()); m_pageLayout.setUnits(m_units); updateWidget(); } diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index d929367557..bf1633930c 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -426,7 +426,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget() { bool anyWidgetCreated = false; - ppd_file_t *ppd = m_currentPrintDevice->property(PDPK_PpdFile).value<ppd_file_t*>(); + ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(m_currentPrintDevice->property(PDPK_PpdFile)); if (ppd) { m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding); @@ -532,7 +532,7 @@ bool QPrintPropertiesDialog::createAdvancedOptionsWidget() void QPrintPropertiesDialog::setPrinterAdvancedCupsOptions() const { for (const QComboBox *choicesCb : m_advancedOptionsCombos) { - const ppd_option_t *option = choicesCb->property(ppdOptionProperty).value<const ppd_option_t *>(); + const ppd_option_t *option = qvariant_cast<const ppd_option_t *>(choicesCb->property(ppdOptionProperty)); // We can't use choicesCb->currentIndex() to know the index of the option in the choices[] array // because some of them may not be present in the list because they conflict with the @@ -551,7 +551,7 @@ void QPrintPropertiesDialog::setPrinterAdvancedCupsOptions() const void QPrintPropertiesDialog::revertAdvancedOptionsToSavedValues() const { for (QComboBox *choicesCb : m_advancedOptionsCombos) { - const int originallySelectedChoice = choicesCb->property(ppdOriginallySelectedChoiceProperty).value<int>(); + const int originallySelectedChoice = qvariant_cast<int>(choicesCb->property(ppdOriginallySelectedChoiceProperty)); const int newComboIndexToSelect = choicesCb->findData(originallySelectedChoice); choicesCb->setCurrentIndex(newComboIndexToSelect); // The currentIndexChanged lambda takes care of resetting the ppd option @@ -580,8 +580,8 @@ bool QPrintPropertiesDialog::anyAdvancedOptionConflict() const bool anyConflicted = false; for (const QComboBox *choicesCb : m_advancedOptionsCombos) { - const ppd_option_t *option = choicesCb->property(ppdOptionProperty).value<const ppd_option_t *>(); - QLabel *warningLabel = choicesCb->property(warningLabelProperty).value<QLabel *>(); + const ppd_option_t *option = qvariant_cast<const ppd_option_t *>(choicesCb->property(ppdOptionProperty)); + QLabel *warningLabel = qvariant_cast<QLabel *>(choicesCb->property(warningLabelProperty)); if (option->conflicted) { anyConflicted = true; const int pixmap_size = choicesCb->sizeHint().height() * .75; @@ -900,7 +900,7 @@ void QPrintDialogPrivate::setupPrinter() // page set if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) { //If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly - QCUPSSupport::PageSet pageSet = options.pageSetCombo->itemData(options.pageSetCombo->currentIndex()).value<QCUPSSupport::PageSet>(); + QCUPSSupport::PageSet pageSet = qvariant_cast<QCUPSSupport::PageSet>(options.pageSetCombo->itemData(options.pageSetCombo->currentIndex())); if (q->isOptionEnabled(QPrintDialog::PrintPageRange) && p->printRange() == QPrinter::PageRange && (q->fromPage() % 2 == 0)) { @@ -1323,10 +1323,10 @@ bool QUnixPrintWidgetPrivate::checkFields() #if QT_CONFIG(cups) if (propertiesDialog) { - QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo - ->currentData().value<QCUPSSupport::PagesPerSheet>(); + QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo + ->currentData()); - QCUPSSupport::PageSet pageSet = optionsPane->options.pageSetCombo->currentData().value<QCUPSSupport::PageSet>(); + QCUPSSupport::PageSet pageSet = qvariant_cast<QCUPSSupport::PageSet>(optionsPane->options.pageSetCombo->currentData()); if (pagesPerSheet != QCUPSSupport::OnePagePerSheet diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 2fc4621960..0fc8cdd1b7 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -149,7 +149,7 @@ QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString ppd_option_t *QCUPSSupport::findPpdOption(const char *optionName, QPrintDevice *printDevice) { - ppd_file_t *ppd = printDevice->property(PDPK_PpdFile).value<ppd_file_t*>(); + ppd_file_t *ppd = qvariant_cast<ppd_file_t*>(printDevice->property(PDPK_PpdFile)); if (ppd) { for (int i = 0; i < ppd->num_groups; ++i) { diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp index 3c24e5ac69..7f1c20916b 100644 --- a/src/printsupport/kernel/qprintengine_pdf.cpp +++ b/src/printsupport/kernel/qprintengine_pdf.cpp @@ -217,19 +217,19 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va break; } case PPK_QPageSize: { - QPageSize pageSize = value.value<QPageSize>(); + QPageSize pageSize = qvariant_cast<QPageSize>(value); if (pageSize.isValid()) d->m_pageLayout.setPageSize(pageSize); break; } case PPK_QPageMargins: { - QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >(); + QPair<QMarginsF, QPageLayout::Unit> pair = qvariant_cast<QPair<QMarginsF, QPageLayout::Unit> >(value); d->m_pageLayout.setUnits(pair.second); d->m_pageLayout.setMargins(pair.first); break; } case PPK_QPageLayout: { - QPageLayout pageLayout = value.value<QPageLayout>(); + QPageLayout pageLayout = qvariant_cast<QPageLayout>(value); if (pageLayout.isValid()) d->m_pageLayout = pageLayout; break; diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index ddcd8c4702..fbf5e5c2ba 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -294,7 +294,7 @@ public: { QPrinterPrivate *pd = QPrinterPrivate::get(m_printer); - return pd->printEngine->property(QPrintEngine::PPK_QPageLayout).value<QPageLayout>(); + return qvariant_cast<QPageLayout>(pd->printEngine->property(QPrintEngine::PPK_QPageLayout)); } QPrinter *m_printer; diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp index dcdb933f73..456ed9db19 100644 --- a/src/printsupport/widgets/qcupsjobwidget.cpp +++ b/src/printsupport/widgets/qcupsjobwidget.cpp @@ -150,7 +150,7 @@ void QCupsJobWidget::setJobHold(QCUPSSupport::JobHoldUntil jobHold, const QTime QCUPSSupport::JobHoldUntil QCupsJobWidget::jobHold() const { - return m_ui.jobHoldComboBox->itemData(m_ui.jobHoldComboBox->currentIndex()).value<QCUPSSupport::JobHoldUntil>(); + return qvariant_cast<QCUPSSupport::JobHoldUntil>(m_ui.jobHoldComboBox->itemData(m_ui.jobHoldComboBox->currentIndex())); } void QCupsJobWidget::toggleJobHoldTime() @@ -247,7 +247,7 @@ void QCupsJobWidget::setStartBannerPage(const QCUPSSupport::BannerPage bannerPag QCUPSSupport::BannerPage QCupsJobWidget::startBannerPage() const { - return m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>(); + return qvariant_cast<QCUPSSupport::BannerPage>(m_ui.startBannerPageCombo->itemData(m_ui.startBannerPageCombo->currentIndex())); } void QCupsJobWidget::setEndBannerPage(const QCUPSSupport::BannerPage bannerPage) @@ -257,7 +257,7 @@ void QCupsJobWidget::setEndBannerPage(const QCUPSSupport::BannerPage bannerPage) QCUPSSupport::BannerPage QCupsJobWidget::endBannerPage() const { - return m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex()).value<QCUPSSupport::BannerPage>(); + return qvariant_cast<QCUPSSupport::BannerPage>(m_ui.endBannerPageCombo->itemData(m_ui.endBannerPageCombo->currentIndex())); } QT_END_NAMESPACE diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp index 859966c0e3..2e05097122 100644 --- a/src/testlib/qabstractitemmodeltester.cpp +++ b/src/testlib/qabstractitemmodeltester.cpp @@ -605,7 +605,7 @@ void QAbstractItemModelTesterPrivate::data() // Check that the alignment is one we know about QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlignmentRole); if (textAlignmentVariant.isValid()) { - Qt::Alignment alignment = textAlignmentVariant.value<Qt::Alignment>(); + Qt::Alignment alignment = qvariant_cast<Qt::Alignment>(textAlignmentVariant); MODELTESTER_COMPARE(alignment, (alignment & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask))); } diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 362200a4fd..906022a185 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -920,7 +920,7 @@ void QDialog::adjustPosition(QWidget* w) if (w) { // Use pos() if the widget is embedded into a native window QPoint pp; - if (w->windowHandle() && w->windowHandle()->property("_q_embedded_native_parent_handle").value<WId>()) + if (w->windowHandle() && qvariant_cast<WId>(w->windowHandle()->property("_q_embedded_native_parent_handle"))) pp = w->pos(); else pp = w->mapToGlobal(QPoint(0,0)); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 03d083bbf1..8da21a2e11 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2413,7 +2413,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption int oldMin = styleObject->property("_q_stylemin").toInt(); int oldMax = styleObject->property("_q_stylemax").toInt(); QRect oldRect = styleObject->property("_q_stylerect").toRect(); - QStyle::State oldState = static_cast<QStyle::State>(styleObject->property("_q_stylestate").value<QStyle::State::Int>()); + QStyle::State oldState = static_cast<QStyle::State>(qvariant_cast<QStyle::State::Int>(styleObject->property("_q_stylestate"))); uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt(); // a scrollbar is transient when the the scrollbar itself and diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp index 0306f54faa..be763f182e 100644 --- a/src/widgets/util/qscrollerproperties.cpp +++ b/src/widgets/util/qscrollerproperties.cpp @@ -261,9 +261,9 @@ void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &v case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break; - case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break; - case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break; - case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break; + case HorizontalOvershootPolicy: d->hOvershootPolicy = qvariant_cast<QScrollerProperties::OvershootPolicy>(value); break; + case VerticalOvershootPolicy: d->vOvershootPolicy = qvariant_cast<QScrollerProperties::OvershootPolicy>(value); break; + case FrameRate: d->frameRate = qvariant_cast<QScrollerProperties::FrameRates>(value); break; case ScrollMetricCount: break; } } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 4cfa5554e4..d786c7ff83 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -172,7 +172,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt // that order, also override the font for the popup menu. QVariant fontRoleData = index.data(Qt::FontRole); if (fontRoleData.isValid()) { - menuOption.font = fontRoleData.value<QFont>(); + menuOption.font = qvariant_cast<QFont>(fontRoleData); } else if (mCombo->testAttribute(Qt::WA_SetFont) || mCombo->testAttribute(Qt::WA_MacSmallSize) || mCombo->testAttribute(Qt::WA_MacMiniSize) -- cgit v1.2.3 From 98f19f00361bf25097281cae5dfa833ba7db8a2f Mon Sep 17 00:00:00 2001 From: Marius Kittler <mariuskittler@gmx.de> Date: Sat, 7 Sep 2019 20:05:42 +0200 Subject: Use pkg-config to find libjpeg Change-Id: I42d877fbca5d746114cc28f8ee4db3e54754cd24 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/gui/configure.json | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/configure.json b/src/gui/configure.json index 19312d245d..0202f17b21 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -374,6 +374,7 @@ }, "headers": "jpeglib.h", "sources": [ + { "type": "pkgConfig", "args": "libjpeg" }, { "libs": "-llibjpeg", "condition": "config.msvc" }, "-ljpeg" ] -- cgit v1.2.3 From deeaa500ad8c591b3142eb53a57e79b6b4ae1ca6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Thu, 5 Dec 2019 10:44:37 +0100 Subject: Mark the old style unprefixed stream functions deprecated Requires a third definition for the source-compatible but deprecated version. Change-Id: I260ae79f4547f99eed701b10e0b25222f81cd5ff Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/serialization/qtextstream.cpp | 52 +++++++++++++++++++++++++------ src/corelib/serialization/qtextstream.h | 42 ++++++++++++++++++------- src/tools/tracegen/etw.cpp | 2 +- 3 files changed, 73 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index cf59cc54c7..4d92b1e0da 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -2689,11 +2689,8 @@ QTextStream &QTextStream::operator<<(const void *ptr) d->params.numberFlags = oldFlags; return *this; } -#if defined(Q_QDOC) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + namespace Qt { -#else -namespace QTextStreamFunctions { -#endif /*! \relates QTextStream @@ -3020,7 +3017,7 @@ QTextStream &ws(QTextStream &stream) return stream; } -} // namespace QTextStreamFunctions +} // namespace Qt /*! \fn QTextStreamManipulator qSetFieldWidth(int width) @@ -3045,11 +3042,7 @@ QTextStream &ws(QTextStream &stream) #if QT_CONFIG(textcodec) -#if defined(Q_QDOC) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) namespace Qt { -#else -namespace QTextStreamFunctions { -#endif /*! \relates QTextStream @@ -3064,7 +3057,7 @@ QTextStream &bom(QTextStream &stream) return stream; } -} // namespace QTextStreamFunctions +} // namespace Qt /*! Sets the codec for this stream to \a codec. The codec is used for @@ -3215,6 +3208,45 @@ QLocale QTextStream::locale() const return d->locale; } +#if QT_DEPRECATED_SINCE(5, 15) && !defined(Q_QDOC) +// Deprecated source compatible migration versions: +namespace QTextStreamFunctions { +QTextStream &bin(QTextStream &s) { return Qt::bin(s); } +QTextStream &oct(QTextStream &s) { return Qt::oct(s); } +QTextStream &dec(QTextStream &s) { return Qt::dec(s); } +QTextStream &hex(QTextStream &s) { return Qt::hex(s); } + +QTextStream &showbase(QTextStream &s) { return Qt::showbase(s); } +QTextStream &forcesign(QTextStream &s) { return Qt::forcesign(s); } +QTextStream &forcepoint(QTextStream &s) { return Qt::forcepoint(s); } +QTextStream &noshowbase(QTextStream &s) { return Qt::noshowbase(s); } +QTextStream &noforcesign(QTextStream &s) { return Qt::noforcesign(s); } +QTextStream &noforcepoint(QTextStream &s) { return Qt::noforcepoint(s); } + +QTextStream &uppercasebase(QTextStream &s) { return Qt::uppercasebase(s); } +QTextStream &uppercasedigits(QTextStream &s) { return Qt::uppercasedigits(s); } +QTextStream &lowercasebase(QTextStream &s) { return Qt::lowercasebase(s); } +QTextStream &lowercasedigits(QTextStream &s) { return Qt::lowercasedigits(s); } + +QTextStream &fixed(QTextStream &s) { return Qt::fixed(s); } +QTextStream &scientific(QTextStream &s) { return Qt::scientific(s); } + +QTextStream &left(QTextStream &s) { return Qt::left(s); } +QTextStream &right(QTextStream &s) { return Qt::right(s); } +QTextStream ¢er(QTextStream &s) { return Qt::center(s); } + +QTextStream &endl(QTextStream &s) { return Qt::endl(s); } +QTextStream &flush(QTextStream &s) { return Qt::flush(s); } +QTextStream &reset(QTextStream &s) { return Qt::reset(s); } + +QTextStream &ws(QTextStream &s) { return Qt::ws(s); } + +#if QT_CONFIG(textcodec) +QTextStream &bom(QTextStream &s) { return Qt::bom(s); } +#endif +} // namespace QTextStreamFunctions +#endif + #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_QDOC) // Binary compatible definitions for Qt<5.14 Q_CORE_EXPORT QTextStream &bin(QTextStream &s) { return Qt::bin(s); } diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index 935ec16536..6f93826d8a 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -233,13 +233,7 @@ inline QTextStream &operator<<(QTextStream &s, QTextStreamFunction f) inline QTextStream &operator<<(QTextStream &s, QTextStreamManipulator m) { m.exec(s); return s; } -#if defined(Q_QDOC) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) namespace Qt { -#else -// This namespace only exists for 'using namespace' declarations. -namespace QTextStreamFunctions { -#endif - Q_CORE_EXPORT QTextStream &bin(QTextStream &s); Q_CORE_EXPORT QTextStream &oct(QTextStream &s); Q_CORE_EXPORT QTextStream &dec(QTextStream &s); @@ -272,12 +266,36 @@ Q_CORE_EXPORT QTextStream &bom(QTextStream &s); Q_CORE_EXPORT QTextStream &ws(QTextStream &s); -} // namespace QTextStreamFunctions +} // namespace Qt -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_QDOC) -namespace Qt { -using namespace QTextStreamFunctions; -} +#if QT_DEPRECATED_SINCE(5, 15) && !defined(Q_QDOC) +// This namespace only exists for 'using namespace' declarations. +namespace QTextStreamFunctions { +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::bin") QTextStream &bin(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::oct") QTextStream &oct(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::dec") QTextStream &dec(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::hex") QTextStream &hex(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::showbase") QTextStream &showbase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::forcesign") QTextStream &forcesign(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::forcepoint") QTextStream &forcepoint(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::noshowbase") QTextStream &noshowbase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::noforcesign") QTextStream &noforcesign(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::noforcepoint") QTextStream &noforcepoint(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::uppercasebase") QTextStream &uppercasebase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::uppercasedigits") QTextStream &uppercasedigits(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::lowercasebase") QTextStream &lowercasebase(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::lowercasedigits") QTextStream &lowercasedigits(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::fixed") QTextStream &fixed(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::scientific") QTextStream &scientific(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::left") QTextStream &left(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::right") QTextStream &right(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::center") QTextStream ¢er(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::endl") QTextStream &endl(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::flush") QTextStream &flush(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::reset") QTextStream &reset(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::bom") QTextStream &bom(QTextStream &s); +Q_CORE_EXPORT QT_DEPRECATED_X("Use Qt::ws") QTextStream &ws(QTextStream &s); +} // namespace QTextStreamFunctions QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wheader-hygiene") @@ -285,7 +303,7 @@ QT_WARNING_DISABLE_CLANG("-Wheader-hygiene") // conflicting definitions compiler errors. using namespace QTextStreamFunctions; QT_WARNING_POP -#endif // QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_QDOC) +#endif // QT_DEPRECATED_SINCE(5, 15) && !defined(Q_QDOC) inline QTextStreamManipulator qSetFieldWidth(int width) { diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp index acd81bd5c1..eac518dbab 100644 --- a/src/tools/tracegen/etw.cpp +++ b/src/tools/tracegen/etw.cpp @@ -90,7 +90,7 @@ static QString createGuid(const QUuid &uuid) QTextStream stream(&guid); - hex(stream); + Qt::hex(stream); stream << "(" << "0x" << uuid.data1 << ", " -- cgit v1.2.3 From a1a3a7cd8abbfcc778c3b57953fd931c87a49278 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Thu, 12 Dec 2019 11:36:47 +0100 Subject: Avoid crashing when constructing color-space from invalid enum This is not to be taken as supported and is still undefined behavior, but I prefer we do not crash. Change-Id: Icf4f3398bfd57fcbdc611a5a821a1f2de0838330 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/painting/qcolorspace.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 9631fdb416..0fb0e9ee33 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -422,6 +422,10 @@ QColorSpace::QColorSpace() */ QColorSpace::QColorSpace(NamedColorSpace namedColorSpace) { + if (namedColorSpace < QColorSpace::SRgb || namedColorSpace > QColorSpace::ProPhotoRgb) { + qWarning() << "QColorSpace attempted constructed from invalid QColorSpace::NamedColorSpace: " << int(namedColorSpace); + return; + } static QColorSpacePrivate *predefinedColorspacePrivates[QColorSpace::ProPhotoRgb + 1]; if (!predefinedColorspacePrivates[namedColorSpace]) { predefinedColorspacePrivates[namedColorSpace] = new QColorSpacePrivate(namedColorSpace); -- cgit v1.2.3 From 313c2b46fe2830de981c94d07c5ef5ced9cb3257 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Wed, 27 Nov 2019 15:00:50 +0100 Subject: Windows QPA: Use UTF-16 literals where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should minimize diffs to Qt 6. Change-Id: Id74c0b4085085984bd51251765420718d16e9fc7 Reviewed-by: André de la Rocha <andre.rocha@qt.io> --- .../platforms/windows/qwindowsclipboard.cpp | 4 +- .../platforms/windows/qwindowsdialoghelpers.cpp | 60 +++++++++++----------- .../platforms/windows/qwindowseglcontext.cpp | 2 +- .../platforms/windows/qwindowsintegration.cpp | 32 ++++++------ src/plugins/platforms/windows/qwindowsmenu.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 44 ++++++++-------- .../platforms/windows/qwindowsopengltester.cpp | 4 +- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 +- src/plugins/platforms/windows/qwindowsservices.cpp | 6 +-- .../platforms/windows/qwindowssystemtrayicon.cpp | 2 +- src/plugins/platforms/windows/qwindowstheme.cpp | 14 ++--- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- .../uiautomation/qwindowsuiamainprovider.cpp | 2 +- 13 files changed, 89 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 4e6d3306e1..ccd4e50a8b 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -82,7 +82,7 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData) d << "QMimeData("; if (mimeData) { const QStringList formats = mimeData->formats(); - d << "formats=" << formats.join(QLatin1String(", ")); + d << "formats=" << formats.join(u", "); if (mimeData->hasText()) d << ", text=" << mimeData->text(); if (mimeData->hasHtml()) @@ -339,7 +339,7 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) if (src != S_OK) { QString mimeDataFormats = mimeData ? - mimeData->formats().join(QLatin1String(", ")) : QString(QStringLiteral("NULL")); + mimeData->formats().join(u", ") : QString(QStringLiteral("NULL")); qErrnoWarning("OleSetClipboard: Failed to set mime data (%s) on clipboard: %s", qPrintable(mimeDataFormats), QWindowsContext::comErrorString(src).constData()); diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index cdb4e407d1..b038e19689 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -91,7 +91,7 @@ static inline QString guidToString(const GUID &g) str << '{' << g.Data1 << ", " << g.Data2 << ", " << g.Data3; str.setFieldWidth(2); str.setFieldAlignment(QTextStream::AlignRight); - str.setPadChar(QLatin1Char('0')); + str.setPadChar(u'0'); str << ",{" << g.Data4[0] << ", " << g.Data4[1] << ", " << g.Data4[2] << ", " << g.Data4[3] << ", " << g.Data4[4] << ", " << g.Data4[5] << ", " << g.Data4[6] << ", " << g.Data4[7] << "}};"; @@ -915,7 +915,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url) return nullptr; } return result; - } else if (url.scheme() == QLatin1String("clsid")) { + } else if (url.scheme() == u"clsid") { // Support for virtual folders via GUID // (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx) // specified as "clsid:<GUID>" (without '{', '}'). @@ -1040,20 +1040,20 @@ static QList<FilterSpec> filterSpecs(const QStringList &filters, // Split filter specification as 'Texts (*.txt[;] *.doc)', '*.txt[;] *.doc' // into description and filters specification as '*.txt;*.doc' for (const QString &filterString : filters) { - const int openingParenPos = filterString.lastIndexOf(QLatin1Char('(')); + const int openingParenPos = filterString.lastIndexOf(u'('); const int closingParenPos = openingParenPos != -1 ? - filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1; + filterString.indexOf(u')', openingParenPos + 1) : -1; FilterSpec filterSpec; filterSpec.filter = closingParenPos == -1 ? filterString : filterString.mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).trimmed(); if (filterSpec.filter.isEmpty()) - filterSpec.filter += QLatin1Char('*'); + filterSpec.filter += u'*'; filterSpec.filter.replace(filterSeparatorRE, separator); filterSpec.description = filterString; if (hideFilterDetails && openingParenPos != -1) { // Do not show pattern in description filterSpec.description.truncate(openingParenPos); - while (filterSpec.description.endsWith(QLatin1Char(' '))) + while (filterSpec.description.endsWith(u' ')) filterSpec.description.truncate(filterSpec.description.size() - 1); } *totalStringLength += filterSpec.filter.size() + filterSpec.description.size(); @@ -1084,8 +1084,8 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters) // 'AAA files (a.*) (a.*)' QString description = specs[i].description; const QString &filter = specs[i].filter; - if (!m_hideFiltersDetails && !filter.startsWith(QLatin1String("*."))) { - const int pos = description.lastIndexOf(QLatin1Char('(')); + if (!m_hideFiltersDetails && !filter.startsWith(u"*.")) { + const int pos = description.lastIndexOf(u'('); if (pos > 0) description.truncate(pos); } @@ -1151,8 +1151,8 @@ static bool isHexRange(const QString& s, int start, int end) for (;start < end; ++start) { QChar ch = s.at(start); if (!(ch.isDigit() - || (ch >= QLatin1Char('a') && ch <= QLatin1Char('f')) - || (ch >= QLatin1Char('A') && ch <= QLatin1Char('F')))) + || (ch >= u'a' && ch <= u'f') + || (ch >= u'A' && ch <= u'F'))) return false; } return true; @@ -1161,7 +1161,7 @@ static bool isHexRange(const QString& s, int start, int end) static inline bool isClsid(const QString &s) { // detect "374DE290-123F-4565-9164-39C4925E467B". - const QChar dash(QLatin1Char('-')); + const QChar dash(u'-'); return s.size() == 36 && isHexRange(s, 0, 8) && s.at(8) == dash @@ -1204,7 +1204,7 @@ void QWindowsNativeFileDialogBase::selectNameFilter(const QString &filter) if (index < 0) { qWarning("%s: Invalid parameter '%s' not found in '%s'.", __FUNCTION__, qPrintable(filter), - qPrintable(m_nameFilters.join(QLatin1String(", ")))); + qPrintable(m_nameFilters.join(u", "))); return; } m_fileDialog->SetFileTypeIndex(index + 1); // one-based. @@ -1313,15 +1313,15 @@ public: // Also handles the simple name filter case "*.txt" -> "txt" static inline QString suffixFromFilter(const QString &filter) { - int suffixPos = filter.indexOf(QLatin1String("*.")); + int suffixPos = filter.indexOf(u"*."); if (suffixPos < 0) return QString(); suffixPos += 2; - int endPos = filter.indexOf(QLatin1Char(' '), suffixPos + 1); + int endPos = filter.indexOf(u' ', suffixPos + 1); if (endPos < 0) - endPos = filter.indexOf(QLatin1Char(';'), suffixPos + 1); + endPos = filter.indexOf(u';', suffixPos + 1); if (endPos < 0) - endPos = filter.indexOf(QLatin1Char(')'), suffixPos + 1); + endPos = filter.indexOf(u')', suffixPos + 1); if (endPos < 0) endPos = filter.size(); return filter.mid(suffixPos, endPos - suffixPos); @@ -1406,27 +1406,27 @@ static void cleanupTemporaryItemCopies() static bool validFileNameCharacter(QChar c) { - return c.isLetterOrNumber() || c == QLatin1Char('_') || c == QLatin1Char('-'); + return c.isLetterOrNumber() || c == u'_' || c == u'-'; } QString tempFilePattern(QString name) { - const int lastSlash = qMax(name.lastIndexOf(QLatin1Char('/')), - name.lastIndexOf(QLatin1Char('\\'))); + const int lastSlash = qMax(name.lastIndexOf(u'/'), + name.lastIndexOf(u'\\')); if (lastSlash != -1) name.remove(0, lastSlash + 1); - int lastDot = name.lastIndexOf(QLatin1Char('.')); + int lastDot = name.lastIndexOf(u'.'); if (lastDot < 0) lastDot = name.size(); name.insert(lastDot, QStringLiteral("_XXXXXX")); for (int i = lastDot - 1; i >= 0; --i) { if (!validFileNameCharacter(name.at(i))) - name[i] = QLatin1Char('_'); + name[i] = u'_'; } - name.prepend(QDir::tempPath() + QLatin1Char('/')); + name.prepend(QDir::tempPath() + u'/'); return name; } @@ -1456,7 +1456,7 @@ static QString createTemporaryItemCopy(QWindowsShellItem &qItem, QString *errorM static QUrl itemToDialogUrl(QWindowsShellItem &qItem, QString *errorMessage) { QUrl url = qItem.url(); - if (url.isLocalFile() || url.scheme().startsWith(QLatin1String("http"))) + if (url.isLocalFile() || url.scheme().startsWith(u"http")) return url; const QString path = qItem.path(); if (path.isEmpty() && !qItem.isDir() && qItem.canStream()) { @@ -1859,10 +1859,12 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow // for the target. If it contains any invalid character, the dialog // will not show. ofn->nMaxFile = 65535; - const QString initiallySelectedFile = - QDir::toNativeSeparators(m_data.selectedFile()).remove(QLatin1Char('<')). - remove(QLatin1Char('>')).remove(QLatin1Char('"')).remove(QLatin1Char('|')); - ofn->lpstrFile = qStringToWCharArray(initiallySelectedFile, ofn->nMaxFile); + QString initiallySelectedFile = m_data.selectedFile(); + initiallySelectedFile.remove(u'<'); + initiallySelectedFile.remove(u'>'); + initiallySelectedFile.remove(u'"'); + initiallySelectedFile.remove(u'|'); + ofn->lpstrFile = qStringToWCharArray(QDir::toNativeSeparators(initiallySelectedFile), ofn->nMaxFile); ofn->lpstrInitialDir = qStringToWCharArray(QDir::toNativeSeparators(m_data.directory().toLocalFile())); ofn->lpstrTitle = (wchar_t*)m_title.utf16(); // Determine lpstrDefExt. Note that the current MSDN docs document this @@ -1872,7 +1874,7 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow // the extension of the current filter". if (m_options->acceptMode() == QFileDialogOptions::AcceptSave) { QString defaultSuffix = m_options->defaultSuffix(); - if (defaultSuffix.startsWith(QLatin1Char('.'))) + if (defaultSuffix.startsWith(u'.')) defaultSuffix.remove(0, 1); // QTBUG-33156, also create empty strings to trigger the appending mechanism. ofn->lpstrDefExt = qStringToWCharArray(defaultSuffix); @@ -1905,7 +1907,7 @@ QList<QUrl> QWindowsXpNativeFileDialog::execFileNames(HWND owner, int *selectedF wchar_t *ptr = ofn.lpstrFile + dir.size() + 1; if (*ptr) { result.pop_front(); - const QString path = dir + QLatin1Char('/'); + const QString path = dir + u'/'; while (*ptr) { const QString fileName = QString::fromWCharArray(ptr); result.push_back(QUrl::fromLocalFile(path + fileName)); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index e9f3dc5189..76baa93d98 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -88,7 +88,7 @@ static void *resolveFunc(HMODULE lib, const char *name) while (!proc && argSize <= 64) { nameStr = baseNameStr; if (argSize >= 0) - nameStr += QLatin1Char('@') + QString::number(argSize); + nameStr += u'@' + QString::number(argSize); argSize = argSize < 0 ? 0 : argSize + 4; proc = (void *) ::GetProcAddress(lib, nameStr.toLatin1().constData()); } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 09117f663d..32bd29a842 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -162,7 +162,7 @@ bool parseIntOption(const QString ¶meter,const QLatin1String &option, IntType minimumValue, IntType maximumValue, IntType *target) { const int valueLength = parameter.size() - option.size() - 1; - if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != QLatin1Char('=')) + if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != u'=') return false; bool ok; const QStringRef valueRef = parameter.rightRef(valueLength); @@ -186,38 +186,38 @@ static inline unsigned parseOptions(const QStringList ¶mList, { unsigned options = 0; for (const QString ¶m : paramList) { - if (param.startsWith(QLatin1String("fontengine="))) { - if (param.endsWith(QLatin1String("freetype"))) { + if (param.startsWith(u"fontengine=")) { + if (param.endsWith(u"freetype")) { options |= QWindowsIntegration::FontDatabaseFreeType; - } else if (param.endsWith(QLatin1String("native"))) { + } else if (param.endsWith(u"native")) { options |= QWindowsIntegration::FontDatabaseNative; } - } else if (param.startsWith(QLatin1String("dialogs="))) { - if (param.endsWith(QLatin1String("xp"))) { + } else if (param.startsWith(u"dialogs=")) { + if (param.endsWith(u"xp")) { options |= QWindowsIntegration::XpNativeDialogs; - } else if (param.endsWith(QLatin1String("none"))) { + } else if (param.endsWith(u"none")) { options |= QWindowsIntegration::NoNativeDialogs; } - } else if (param == QLatin1String("altgr")) { + } else if (param == u"altgr") { options |= QWindowsIntegration::DetectAltGrModifier; - } else if (param == QLatin1String("gl=gdi")) { + } else if (param == u"gl=gdi") { options |= QWindowsIntegration::DisableArb; - } else if (param == QLatin1String("nodirectwrite")) { + } else if (param == u"nodirectwrite") { options |= QWindowsIntegration::DontUseDirectWriteFonts; - } else if (param == QLatin1String("nocolorfonts")) { + } else if (param == u"nocolorfonts") { options |= QWindowsIntegration::DontUseColorFonts; - } else if (param == QLatin1String("nomousefromtouch")) { + } else if (param == u"nomousefromtouch") { options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch; } else if (parseIntOption(param, QLatin1String("verbose"), 0, INT_MAX, &QWindowsContext::verbose) || parseIntOption(param, QLatin1String("tabletabsoluterange"), 0, INT_MAX, tabletAbsoluteRange) || parseIntOption(param, QLatin1String("dpiawareness"), QtWindows::ProcessDpiUnaware, QtWindows::ProcessPerMonitorDpiAware, dpiAwareness)) { - } else if (param == QLatin1String("menus=native")) { + } else if (param == u"menus=native") { options |= QWindowsIntegration::AlwaysUseNativeMenus; - } else if (param == QLatin1String("menus=none")) { + } else if (param == u"menus=none") { options |= QWindowsIntegration::NoNativeMenus; - } else if (param == QLatin1String("nowmpointer")) { + } else if (param == u"nowmpointer") { options |= QWindowsIntegration::DontUseWMPointer; - } else if (param == QLatin1String("reverse")) { + } else if (param == u"reverse") { options |= QWindowsIntegration::RtlEnabled; } else { qWarning() << "Unknown option" << param; diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index d20edd685e..7c3e87eec1 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -445,7 +445,7 @@ QString QWindowsMenuItem::nativeText() const QString result = m_text; #if QT_CONFIG(shortcut) if (!m_shortcut.isEmpty()) { - result += QLatin1Char('\t'); + result += u'\t'; result += m_shortcut.toString(QKeySequence::NativeText); } #endif diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 1c6c999f05..fe9e1fe31f 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -635,11 +635,11 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa int ri = 0; bool cr = false; for (int i=0; i < s; ++i) { - if (*u == QLatin1Char('\r')) + if (*u == u'\r') cr = true; else { - if (*u == QLatin1Char('\n') && !cr) - res[ri++] = QLatin1Char('\r'); + if (*u == u'\n' && !cr) + res[ri++] = u'\r'; cr = false; } res[ri++] = *u; @@ -663,7 +663,7 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa bool QWindowsMimeText::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType.startsWith(QLatin1String("text/plain")) + return mimeType.startsWith(u"text/plain") && (canGetData(CF_UNICODETEXT, pDataObj) || canGetData(CF_TEXT, pDataObj)); } @@ -680,7 +680,7 @@ QString QWindowsMimeText::mimeForFormat(const FORMATETC &formatetc) const QVector<FORMATETC> QWindowsMimeText::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector<FORMATETC> formatics; - if (mimeType.startsWith(QLatin1String("text/plain")) && mimeData->hasText()) { + if (mimeType.startsWith(u"text/plain") && mimeData->hasText()) { formatics += setCf(CF_UNICODETEXT); formatics += setCf(CF_TEXT); } @@ -816,7 +816,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat bool QWindowsMimeURI::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType == QLatin1String("text/uri-list") + return mimeType == u"text/uri-list" && (canGetData(CF_HDROP, pDataObj) || canGetData(CF_INETURL_W, pDataObj) || canGetData(CF_INETURL, pDataObj)); } @@ -831,7 +831,7 @@ QString QWindowsMimeURI::mimeForFormat(const FORMATETC &formatetc) const QVector<FORMATETC> QWindowsMimeURI::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector<FORMATETC> formatics; - if (mimeType == QLatin1String("text/uri-list")) { + if (mimeType == u"text/uri-list") { if (canConvertFromMime(setCf(CF_HDROP), mimeData)) formatics += setCf(CF_HDROP); if (canConvertFromMime(setCf(CF_INETURL_W), mimeData)) @@ -844,7 +844,7 @@ QVector<FORMATETC> QWindowsMimeURI::formatsForMime(const QString &mimeType, cons QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const { - if (mimeType == QLatin1String("text/uri-list")) { + if (mimeType == u"text/uri-list") { if (canGetData(CF_HDROP, pDataObj)) { QList<QVariant> urls; @@ -916,7 +916,7 @@ QWindowsMimeHtml::QWindowsMimeHtml() QVector<FORMATETC> QWindowsMimeHtml::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector<FORMATETC> formatetcs; - if (mimeType == QLatin1String("text/html") && (!mimeData->html().isEmpty())) + if (mimeType == u"text/html" && (!mimeData->html().isEmpty())) formatetcs += setCf(CF_HTML); return formatetcs; } @@ -930,7 +930,7 @@ QString QWindowsMimeHtml::mimeForFormat(const FORMATETC &formatetc) const bool QWindowsMimeHtml::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType == QLatin1String("text/html") && canGetData(CF_HTML, pDataObj); + return mimeType == u"text/html" && canGetData(CF_HTML, pDataObj); } @@ -1053,7 +1053,7 @@ QWindowsMimeImage::QWindowsMimeImage() QVector<FORMATETC> QWindowsMimeImage::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector<FORMATETC> formatetcs; - if (mimeData->hasImage() && mimeType == QLatin1String("application/x-qt-image")) { + if (mimeData->hasImage() && mimeType == u"application/x-qt-image") { //add DIBV5 if image has alpha channel. Do not add CF_PNG here as it will confuse MS Office (QTBUG47656). auto image = qvariant_cast<QImage>(mimeData->imageData()); if (!image.isNull() && image.hasAlphaChannel()) @@ -1075,7 +1075,7 @@ QString QWindowsMimeImage::mimeForFormat(const FORMATETC &formatetc) const bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType == QLatin1String("application/x-qt-image") + return mimeType == u"application/x-qt-image" && (canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj)); } @@ -1149,7 +1149,7 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject * { Q_UNUSED(preferredType); QVariant result; - if (mimeType != QLatin1String("application/x-qt-image")) + if (mimeType != u"application/x-qt-image") return result; //Try to convert from a format which has more data //DIBV5, use only if its is not synthesized @@ -1220,7 +1220,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData { if (canConvertFromMime(formatetc, mimeData)) { QByteArray data; - if (outFormats.value(getCf(formatetc)) == QLatin1String("text/html")) { + if (outFormats.value(getCf(formatetc)) == u"text/html") { // text/html is in wide chars on windows (compatible with mozillia) QString html = mimeData->html(); // same code as in the text converter up above @@ -1232,11 +1232,11 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData int ri = 0; bool cr = false; for (int i=0; i < s; ++i) { - if (*u == QLatin1Char('\r')) + if (*u == u'\r') cr = true; else { - if (*u == QLatin1Char('\n') && !cr) - res[ri++] = QLatin1Char('\r'); + if (*u == u'\n' && !cr) + res[ri++] = u'\r'; cr = false; } res[ri++] = *u; @@ -1285,7 +1285,7 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat QByteArray data = getData(inFormats.key(mimeType), pDataObj); if (!data.isEmpty()) { qCDebug(lcQpaMime) << __FUNCTION__; - if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) { + if (mimeType == u"text/html" && preferredType == QVariant::String) { // text/html is in wide chars on windows (compatible with Mozilla) val = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData())); } else { @@ -1404,12 +1404,12 @@ static bool isCustomMimeType(const QString &mimeType) static QString customMimeType(const QString &mimeType, int *lindex = nullptr) { int len = sizeof(x_qt_windows_mime) - 1; - int n = mimeType.lastIndexOf(QLatin1Char('\"')) - len; + int n = mimeType.lastIndexOf(u'\"') - len; QString ret = mimeType.mid(len, n); - const int beginPos = mimeType.indexOf(QLatin1String(";index=")); + const int beginPos = mimeType.indexOf(u";index="); if (beginPos > -1) { - const int endPos = mimeType.indexOf(QLatin1Char(';'), beginPos + 1); + const int endPos = mimeType.indexOf(u';', beginPos + 1); const int indexStartPos = beginPos + 7; if (lindex) *lindex = mimeType.midRef(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt(); @@ -1480,7 +1480,7 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const } } if (!ianaType) - format = QLatin1String(x_qt_windows_mime) + clipFormat + QLatin1Char('\"'); + format = QLatin1String(x_qt_windows_mime) + clipFormat + u'"'; else format = clipFormat; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index afc1991e2c..72092a4481 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -206,7 +206,7 @@ QString GpuDescription::toString() const str << " Card name : " << description << "\n Driver Name : " << driverName << "\n Driver Version : " << driverVersion.toString() - << "\n Vendor ID : 0x" << qSetPadChar(QLatin1Char('0')) + << "\n Vendor ID : 0x" << qSetPadChar(u'0') << Qt::uppercasedigits << Qt::hex << qSetFieldWidth(4) << vendorId << "\n Device ID : 0x" << qSetFieldWidth(4) << deviceId << "\n SubSys ID : 0x" << qSetFieldWidth(8) << subSysId @@ -285,7 +285,7 @@ static inline QString resolveBugListFile(const QString &fileName) // then resolve via QStandardPaths::ConfigLocation. const QString settingsPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); if (!settingsPath.isEmpty()) { // SettingsPath is empty unless specified in qt.conf. - const QFileInfo fi(settingsPath + QLatin1Char('/') + fileName); + const QFileInfo fi(settingsPath + u'/' + fileName); if (fi.isFile()) return fi.absoluteFilePath(); } diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 4f76a82544..c7a0c2e62e 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -87,7 +87,7 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) data->geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1)); data->availableGeometry = QRect(QPoint(info.rcWork.left, info.rcWork.top), QPoint(info.rcWork.right - 1, info.rcWork.bottom - 1)); data->name = QString::fromWCharArray(info.szDevice); - if (data->name == QLatin1String("WinDisc")) { + if (data->name == u"WinDisc") { data->flags |= QWindowsScreenData::LockScreen; } else { if (const HDC hdc = CreateDC(info.szDevice, nullptr, nullptr, nullptr)) { diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 83b052bb49..6a2708ee26 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -92,7 +92,7 @@ static inline QString mailCommand() // "rundll32.exe .. url.dll,MailToProtocolHandler %l" is returned. Launching it // silently fails or brings up a broken dialog after a long time, so exclude it and // fall back to ShellExecute() which brings up the URL assocation dialog. - if (command.isEmpty() || command.contains(QLatin1String(",MailToProtocolHandler"))) + if (command.isEmpty() || command.contains(u",MailToProtocolHandler")) return QString(); wchar_t expandedCommand[MAX_PATH] = {0}; return ExpandEnvironmentStrings(reinterpret_cast<const wchar_t *>(command.utf16()), @@ -108,7 +108,7 @@ static inline bool launchMail(const QUrl &url) return false; } //Make sure the path for the process is in quotes - const QChar doubleQuote = QLatin1Char('"'); + const QChar doubleQuote = u'"'; if (!command.startsWith(doubleQuote)) { const int exeIndex = command.indexOf(QStringLiteral(".exe "), 0, Qt::CaseInsensitive); if (exeIndex != -1) { @@ -140,7 +140,7 @@ static inline bool launchMail(const QUrl &url) bool QWindowsServices::openUrl(const QUrl &url) { const QString scheme = url.scheme(); - if (scheme == QLatin1String("mailto") && launchMail(url)) + if (scheme == u"mailto" && launchMail(url)) return true; return shellExecute(url); } diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index ab830e1461..66c558df1e 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -261,7 +261,7 @@ void QWindowsSystemTrayIcon::showMessage(const QString &title, const QString &me // For empty messages, ensures that they show when only title is set QString message = messageIn; if (message.isEmpty() && !title.isEmpty()) - message.append(QLatin1Char(' ')); + message.append(u' '); NOTIFYICONDATA tnd; initNotifyIconData(tnd); diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 32a65109af..010aea2068 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -96,7 +96,7 @@ static inline QTextStream& operator<<(QTextStream &str, const QColor &c) { str.setIntegerBase(16); str.setFieldWidth(2); - str.setPadChar(QLatin1Char('0')); + str.setPadChar(u'0'); str << " rgb: #" << c.red() << c.green() << c.blue(); str.setIntegerBase(10); str.setFieldWidth(0); @@ -731,13 +731,13 @@ static QString dirIconPixmapCacheKey(int iIcon, int iconSize, int imageListSize) { QString key = QLatin1String("qt_dir_") + QString::number(iIcon); if (iconSize == SHGFI_LARGEICON) - key += QLatin1Char('l'); + key += u'l'; switch (imageListSize) { case sHIL_EXTRALARGE: - key += QLatin1Char('e'); + key += u'e'; break; case sHIL_JUMBO: - key += QLatin1Char('j'); + key += u'j'; break; } return key; @@ -815,9 +815,9 @@ QString QWindowsFileIconEngine::cacheKey() const // It is faster to just look at the file extensions; // avoiding slow QFileInfo::isExecutable() (QTBUG-13182) QString suffix = fileInfo().suffix(); - if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive) - || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive) - || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) { + if (!suffix.compare(u"exe", Qt::CaseInsensitive) + || !suffix.compare(u"lnk", Qt::CaseInsensitive) + || !suffix.compare(u"ico", Qt::CaseInsensitive)) { return QString(); } return QLatin1String("qt_.") diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 5a4f879d0f..a7aad15749 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -253,7 +253,7 @@ QDebug operator<<(QDebug d, const GUID &guid) { QDebugStateSaver saver(d); d.nospace(); - d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(QLatin1Char('0')) + d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(u'0') << qSetFieldWidth(8) << guid.Data1 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4) << guid.Data2 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index cc293b777c..a0a976545f 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -473,7 +473,7 @@ QString QWindowsUiaMainProvider::automationIdForAccessible(const QAccessibleInte if (name.isEmpty()) return QString(); if (!result.isEmpty()) - result.prepend(QLatin1Char('.')); + result.prepend(u'.'); result.prepend(name); obj = obj->parent(); } -- cgit v1.2.3 From 287ace562ee5ddff22f7dbf4e49ae5f0520f2308 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Thu, 14 Nov 2019 13:46:12 +0100 Subject: Convert QString to use QArrayDataPointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're now using the same infrastructure for QVector, QString and QByteArray. This should also make it easier to remove the shared null in a follow-up change. Change-Id: I3aae9cf7912845cfca8e8150e9e82aa3673e3756 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> --- src/corelib/serialization/qbinaryjsonvalue.cpp | 16 +- src/corelib/serialization/qbinaryjsonvalue_p.h | 7 +- src/corelib/text/qstring.cpp | 263 ++++++++++--------------- src/corelib/text/qstring.h | 71 ++++--- src/corelib/text/qstringliteral.h | 10 +- src/corelib/tools/qarraydatapointer.h | 2 + 6 files changed, 149 insertions(+), 220 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qbinaryjsonvalue.cpp b/src/corelib/serialization/qbinaryjsonvalue.cpp index b24bd0fc89..7d0bc3d366 100644 --- a/src/corelib/serialization/qbinaryjsonvalue.cpp +++ b/src/corelib/serialization/qbinaryjsonvalue.cpp @@ -63,12 +63,9 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, case QJsonValue::Double: dbl = v.toDouble(parent); break; - case QJsonValue::String: { - QString s = v.toString(parent); - stringData = s.data_ptr(); - stringData.d->ref(); + case QJsonValue::String: + stringData = v.toString(parent); break; - } case QJsonValue::Array: case QJsonValue::Object: d = data; @@ -82,8 +79,7 @@ QBinaryJsonValue::QBinaryJsonValue(QBinaryJsonPrivate::MutableData *data, QBinaryJsonValue::QBinaryJsonValue(QString string) : d(nullptr), t(QJsonValue::String) { - stringData = string.data_ptr(); - stringData.d->ref(); + stringData = std::move(string); } QBinaryJsonValue::QBinaryJsonValue(const QBinaryJsonArray &a) @@ -102,9 +98,6 @@ QBinaryJsonValue::QBinaryJsonValue(const QBinaryJsonObject &o) QBinaryJsonValue::~QBinaryJsonValue() { - if (t == QJsonValue::String && !stringData.d->deref()) - QTypedArrayData<ushort>::deallocate(stringData.d); - if (d && !d->ref.deref()) delete d; } @@ -135,8 +128,7 @@ QString QBinaryJsonValue::toString() const { if (t != QJsonValue::String) return QString(); - stringData.d->ref(); // the constructor below doesn't add a ref. - return QString(stringData); + return stringData; } void QBinaryJsonValue::detach() diff --git a/src/corelib/serialization/qbinaryjsonvalue_p.h b/src/corelib/serialization/qbinaryjsonvalue_p.h index 4b39b05316..c3b943250c 100644 --- a/src/corelib/serialization/qbinaryjsonvalue_p.h +++ b/src/corelib/serialization/qbinaryjsonvalue_p.h @@ -85,10 +85,12 @@ public: ~QBinaryJsonValue(); QBinaryJsonValue(QBinaryJsonValue &&other) noexcept - : stringData(other.stringData), + : ui(other.ui), + stringData(std::move(other.stringData)), d(other.d), t(other.t) { + other.ui = 0; other.d = nullptr; other.t = QJsonValue::Null; } @@ -96,6 +98,7 @@ public: QBinaryJsonValue &operator =(QBinaryJsonValue &&other) noexcept { qSwap(stringData, other.stringData); + qSwap(ui, other.ui); qSwap(d, other.d); qSwap(t, other.t); return *this; @@ -121,9 +124,9 @@ private: quint64 ui; bool b; double dbl; - QString::DataPointer stringData; const QBinaryJsonPrivate::Base *base; }; + QString stringData; QBinaryJsonPrivate::MutableData *d = nullptr; // needed for Objects and Arrays QJsonValue::Type t = QJsonValue::Null; }; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index e8ce637453..e61228c4a4 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2082,9 +2082,7 @@ int QString::toUcs4_helper(const ushort *uc, int length, uint *out) QString::QString(const QChar *unicode, int size) { if (!unicode) { - d.d = Data::sharedNull(); - d.b = Data::sharedNullData(); - d.size = 0; + d.clear(); } else { if (size < 0) { size = 0; @@ -2092,18 +2090,11 @@ QString::QString(const QChar *unicode, int size) ++size; } if (!size) { - QPair<Data *, ushort *> pair = Data::allocate(0); - d.d = pair.first; - d.b = pair.second; - d.size = 0; + d = DataPointer(Data::allocate(0), 0); } else { - QPair<Data *, ushort *> pair = Data::allocate(size + 1); - d.d = pair.first; - d.b = pair.second; - d.size = size; - Q_CHECK_PTR(d.d); - memcpy(d.b, unicode, size * sizeof(QChar)); - d.b[size] = '\0'; + d = DataPointer(Data::allocate(size + 1), size); + memcpy(d.data(), unicode, size * sizeof(QChar)); + d.data()[size] = '\0'; } } } @@ -2117,19 +2108,12 @@ QString::QString(const QChar *unicode, int size) QString::QString(int size, QChar ch) { if (size <= 0) { - QPair<Data *, ushort *> pair = Data::allocate(0); - d.d = pair.first; - d.b = pair.second; - d.size = 0; + d = DataPointer(Data::allocate(0), 0); } else { - QPair<Data *, ushort *> pair = Data::allocate(size + 1); - d.d = pair.first; - d.b = pair.second; - d.size = size; - Q_CHECK_PTR(d.d); - d.b[size] = '\0'; - ushort *i = d.b + size; - ushort *b = d.b; + d = DataPointer(Data::allocate(size + 1), size); + d.data()[size] = '\0'; + ushort *i = d.data() + size; + ushort *b = d.data(); const ushort value = ch.unicode(); while (i != b) *--i = value; @@ -2144,12 +2128,8 @@ QString::QString(int size, QChar ch) */ QString::QString(int size, Qt::Initialization) { - QPair<Data *, ushort *> pair = Data::allocate(size + 1); - d.d = pair.first; - d.b = pair.second; - d.size = size; - Q_CHECK_PTR(d.d); - d.b[size] = '\0'; + d = DataPointer(Data::allocate(size + 1), size); + d.data()[size] = '\0'; } /*! \fn QString::QString(QLatin1String str) @@ -2164,13 +2144,9 @@ QString::QString(int size, Qt::Initialization) */ QString::QString(QChar ch) { - QPair<Data *, ushort *> pair = Data::allocate(2); - d.d = pair.first; - d.b = pair.second; - d.size = 1; - Q_CHECK_PTR(d.d); - d.b[0] = ch.unicode(); - d.b[1] = '\0'; + d = DataPointer(Data::allocate(2), 1); + d.data()[0] = ch.unicode(); + d.data()[1] = '\0'; } /*! \fn QString::QString(const QByteArray &ba) @@ -2262,16 +2238,16 @@ void QString::resize(int size) if (size < 0) size = 0; - if (!d.d->isShared() && !d.d->isMutable() && size < int(d.size)) { + if (!d->isShared() && !d->isMutable() && size < int(d.size)) { d.size = size; return; } - if (d.d->needsDetach() || size > capacity()) + if (d->needsDetach() || size > capacity()) reallocData(uint(size) + 1u, true); d.size = size; - if (d.d->isMutable()) { - d.b[size] = '\0'; + if (d->isMutable()) { + d.data()[size] = '\0'; } } @@ -2291,7 +2267,7 @@ void QString::resize(int size, QChar fillChar) resize(size); const int difference = length() - oldSize; if (difference > 0) - std::fill_n(d.b + oldSize, difference, fillChar.unicode()); + std::fill_n(d.data() + oldSize, difference, fillChar.unicode()); } /*! \fn int QString::capacity() const @@ -2346,26 +2322,17 @@ void QString::resize(int size, QChar fillChar) void QString::reallocData(uint alloc, bool grow) { - auto allocOptions = d.d->detachFlags(); + auto allocOptions = d->detachFlags(); if (grow) allocOptions |= QArrayData::GrowsForward; - if (d.d->needsDetach()) { - QPair<Data *, ushort *> pair = Data::allocate(alloc, allocOptions); - Q_CHECK_PTR(pair.first); - d.size = qMin(alloc - 1, d.size); - ::memcpy(pair.second, d.b, d.size * sizeof(QChar)); - pair.second[d.size] = 0; - if (!d.d->deref()) - Data::deallocate(d.d); - d.d = pair.first; - d.b = pair.second; + if (d->needsDetach()) { + DataPointer dd(Data::allocate(alloc, allocOptions), qMin(int(alloc) - 1, d.size)); + ::memcpy(dd.data(), d.data(), dd.size * sizeof(QChar)); + dd.data()[dd.size] = 0; + d = dd; } else { - QPair<Data *, ushort *> pair = - Data::reallocateUnaligned(static_cast<Data *>(d.d), d.b, alloc, allocOptions); - Q_CHECK_PTR(pair.first); - d.d = pair.first; - d.b = pair.second; + d.reallocate(alloc, allocOptions); } } @@ -2391,9 +2358,6 @@ void QString::expand(int i) QString &QString::operator=(const QString &other) noexcept { - other.d.d->ref(); - if (!d.d->deref()) - Data::deallocate(d.d); d = other.d; return *this; } @@ -2416,8 +2380,8 @@ QString &QString::operator=(QLatin1String other) { if (isDetached() && other.size() <= capacity()) { // assumes d->alloc == 0 -> !isDetached() (sharedNull) d.size = other.size(); - d.b[other.size()] = 0; - qt_from_latin1(d.b, other.latin1(), other.size()); + d.data()[other.size()] = 0; + qt_from_latin1(d.data(), other.latin1(), other.size()); } else { *this = fromLatin1(other.latin1(), other.size()); } @@ -2480,8 +2444,8 @@ QString &QString::operator=(QChar ch) { if (isDetached() && capacity() >= 1) { // assumes d->alloc == 0 -> !isDetached() (sharedNull) // re-use existing capacity: - d.b[0] = ch.unicode(); - d.b[1] = 0; + d.data()[0] = ch.unicode(); + d.data()[1] = 0; d.size = 1; } else { operator=(QString(ch)); @@ -2573,8 +2537,8 @@ QString &QString::insert(int i, QLatin1String str) else resize(size() + len); - ::memmove(d.b + i + len, d.b + i, (d.size - i - len) * sizeof(QChar)); - qt_from_latin1(d.b + i, s, uint(len)); + ::memmove(d.data() + i + len, d.data() + i, (d.size - i - len) * sizeof(QChar)); + qt_from_latin1(d.data() + i, s, uint(len)); return *this; } @@ -2591,7 +2555,7 @@ QString& QString::insert(int i, const QChar *unicode, int size) return *this; const ushort *s = (const ushort *)unicode; - if (s >= d.b && s < d.b + d.size) { + if (s >= d.data() && s < d.data() + d.size) { // Part of me - take a copy ushort *tmp = static_cast<ushort *>(::malloc(size * sizeof(QChar))); Q_CHECK_PTR(tmp); @@ -2606,8 +2570,8 @@ QString& QString::insert(int i, const QChar *unicode, int size) else resize(d.size + size); - ::memmove(d.b + i + size, d.b + i, (d.size - i - size) * sizeof(QChar)); - memcpy(d.b + i, s, size * sizeof(QChar)); + ::memmove(d.data() + i + size, d.data() + i, (d.size - i - size) * sizeof(QChar)); + memcpy(d.data() + i, s, size * sizeof(QChar)); return *this; } @@ -2628,8 +2592,8 @@ QString& QString::insert(int i, QChar ch) resize(i + 1, QLatin1Char(' ')); else resize(d.size + 1); - ::memmove(d.b + i + 1, d.b + i, (d.size - i - 1) * sizeof(QChar)); - d.b[i] = ch.unicode(); + ::memmove(d.data() + i + 1, d.data() + i, (d.size - i - 1) * sizeof(QChar)); + d.data()[i] = ch.unicode(); return *this; } @@ -2657,11 +2621,11 @@ QString &QString::append(const QString &str) if (isNull()) { operator=(str); } else { - if (d.d->needsDetach() || size() + str.size() > capacity()) + if (d->needsDetach() || size() + str.size() > capacity()) reallocData(uint(size() + str.size()) + 1u, true); - memcpy(d.b + d.size, str.d.b, str.d.size * sizeof(QChar)); + memcpy(d.data() + d.size, str.d.data(), str.d.size * sizeof(QChar)); d.size += str.d.size; - d.b[d.size] = '\0'; + d.data()[d.size] = '\0'; } } return *this; @@ -2676,11 +2640,11 @@ QString &QString::append(const QString &str) QString &QString::append(const QChar *str, int len) { if (str && len > 0) { - if (d.d->needsDetach() || size() + len > capacity()) + if (d->needsDetach() || size() + len > capacity()) reallocData(uint(size() + len) + 1u, true); - memcpy(d.b + d.size, str, len * sizeof(QChar)); + memcpy(d.data() + d.size, str, len * sizeof(QChar)); d.size += len; - d.b[d.size] = '\0'; + d.data()[d.size] = '\0'; } return *this; } @@ -2695,9 +2659,9 @@ QString &QString::append(QLatin1String str) const char *s = str.latin1(); if (s) { int len = str.size(); - if (d.d->needsDetach() || size() + len > capacity()) + if (d->needsDetach() || size() + len > capacity()) reallocData(uint(size() + len) + 1u, true); - ushort *i = d.b + d.size; + ushort *i = d.data() + d.size; qt_from_latin1(i, s, uint(len)); i[len] = '\0'; d.size += len; @@ -2742,10 +2706,10 @@ QString &QString::append(QLatin1String str) */ QString &QString::append(QChar ch) { - if (d.d->needsDetach() || size() + 1 > capacity()) + if (d->needsDetach() || size() + 1 > capacity()) reallocData(uint(d.size) + 2u, true); - d.b[d.size++] = ch.unicode(); - d.b[d.size] = '\0'; + d.data()[d.size++] = ch.unicode(); + d.data()[d.size] = '\0'; return *this; } @@ -2845,7 +2809,7 @@ QString &QString::remove(int pos, int len) resize(pos); // truncate } else if (len > 0) { detach(); - memmove(d.b + pos, d.b + pos + len, + memmove(d.data() + pos, d.data() + pos + len, (d.size - pos - len + 1) * sizeof(ushort)); d.size -= len; } @@ -3062,7 +3026,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar // Copy after if it lies inside our own d.b area (which we could // possibly invalidate via a realloc or modify by replacement). QChar *afterBuffer = nullptr; - if (pointsIntoRange(after, d.b, d.size)) // Use copy in place of vulnerable original: + if (pointsIntoRange(after, d.data(), d.size)) // Use copy in place of vulnerable original: after = afterBuffer = textCopy(after, alen); QT_TRY { @@ -3070,30 +3034,30 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar // replace in place detach(); for (int i = 0; i < nIndices; ++i) - memcpy(d.b + indices[i], after, alen * sizeof(QChar)); + memcpy(d.data() + indices[i], after, alen * sizeof(QChar)); } else if (alen < blen) { // replace from front detach(); uint to = indices[0]; if (alen) - memcpy(d.b+to, after, alen*sizeof(QChar)); + memcpy(d.data()+to, after, alen*sizeof(QChar)); to += alen; uint movestart = indices[0] + blen; for (int i = 1; i < nIndices; ++i) { int msize = indices[i] - movestart; if (msize > 0) { - memmove(d.b + to, d.b + movestart, msize * sizeof(QChar)); + memmove(d.data() + to, d.data() + movestart, msize * sizeof(QChar)); to += msize; } if (alen) { - memcpy(d.b + to, after, alen * sizeof(QChar)); + memcpy(d.data() + to, after, alen * sizeof(QChar)); to += alen; } movestart = indices[i] + blen; } int msize = d.size - movestart; if (msize > 0) - memmove(d.b + to, d.b + movestart, msize * sizeof(QChar)); + memmove(d.data() + to, d.data() + movestart, msize * sizeof(QChar)); resize(d.size - nIndices*(blen-alen)); } else { // replace from back @@ -3107,9 +3071,9 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar int movestart = indices[nIndices] + blen; int insertstart = indices[nIndices] + nIndices*(alen-blen); int moveto = insertstart + alen; - memmove(d.b + moveto, d.b + movestart, + memmove(d.data() + moveto, d.data() + movestart, (moveend - movestart)*sizeof(QChar)); - memcpy(d.b + insertstart, after, alen * sizeof(QChar)); + memcpy(d.data() + insertstart, after, alen * sizeof(QChar)); moveend = movestart-blen; } } @@ -3170,10 +3134,10 @@ QString &QString::replace(const QChar *before, int blen, We're about to change data, that before and after might point into, and we'll need that data for our next batch of indices. */ - if (!afterBuffer && pointsIntoRange(after, d.b, d.size)) + if (!afterBuffer && pointsIntoRange(after, d.data(), d.size)) after = afterBuffer = textCopy(after, alen); - if (!beforeBuffer && pointsIntoRange(before, d.b, d.size)) { + if (!beforeBuffer && pointsIntoRange(before, d.data(), d.size)) { beforeBuffer = textCopy(before, blen); matcher = QStringMatcher(beforeBuffer, blen, cs); } @@ -3219,13 +3183,13 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs uint pos = 0; if (cs == Qt::CaseSensitive) { while (pos < 1024 && index < size()) { - if (d.b[index] == cc) + if (d.data()[index] == cc) indices[pos++] = index; index++; } } else { while (pos < 1024 && index < size()) { - if (QChar::toCaseFolded(d.b[index]) == cc) + if (QChar::toCaseFolded(d.data()[index]) == cc) indices[pos++] = index; index++; } @@ -3258,7 +3222,7 @@ QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs) if (idx != -1) { detach(); const ushort a = after.unicode(); - ushort *i = d.b; + ushort *i = d.data(); ushort *const e = i + d.size; i += idx; *i = a; @@ -4050,14 +4014,14 @@ QString& QString::replace(const QRegExp &rx, const QString &after) while (i < pos) { int copyend = replacements[i].pos; int size = copyend - copystart; - memcpy(static_cast<void*>(uc), static_cast<const void *>(d.b + copystart), size * sizeof(QChar)); + memcpy(static_cast<void*>(uc), static_cast<const void *>(d.data() + copystart), size * sizeof(QChar)); uc += size; - memcpy(static_cast<void *>(uc), static_cast<const void *>(after.d.b), al * sizeof(QChar)); + memcpy(static_cast<void *>(uc), static_cast<const void *>(after.d.data()), al * sizeof(QChar)); uc += al; copystart = copyend + replacements[i].length; i++; } - memcpy(static_cast<void *>(uc), static_cast<const void *>(d.b + copystart), (d.size - copystart) * sizeof(QChar)); + memcpy(static_cast<void *>(uc), static_cast<const void *>(d.data() + copystart), (d.size - copystart) * sizeof(QChar)); newstring.resize(newlen); *this = newstring; caretMode = QRegExp::CaretWontMatch; @@ -4851,7 +4815,7 @@ QString QString::left(int n) const { if (uint(n) >= uint(size())) return *this; - return QString((const QChar*) d.b, n); + return QString((const QChar*) d.data(), n); } /*! @@ -5146,22 +5110,22 @@ QByteArray QString::toLatin1_helper_inplace(QString &s) // We can return our own buffer to the caller. // Conversion to Latin-1 always shrinks the buffer by half. - const ushort *data = reinterpret_cast<const ushort *>(s.constData()); - uint length = s.size(); + const ushort *data = s.d.data(); + int length = s.d.size; - // Swap the d pointers. + // Move the d pointer over to the bytearray. // Kids, avert your eyes. Don't try this at home. - auto *dd = static_cast<QTypedArrayData<char> *>(s.d.d); - char *ddata = reinterpret_cast<char *>(s.d.b); + // this relies on the fact that we use QArrayData for everything behind the scenes which has the same layout + static_assert(sizeof(QByteArray::DataPointer) == sizeof(QString::DataPointer), "sizes have to be equal"); + QByteArray::DataPointer ba_d(reinterpret_cast<QByteArray::Data *>(s.d.d_ptr()), reinterpret_cast<char *>(s.d.data()), length); + ba_d.ref(); + s.clear(); - QByteArray::DataPointer ba_d = { dd, ddata, length }; + char *ddata = ba_d.data(); // multiply the allocated capacity by sizeof(ushort) - dd->alloc *= sizeof(ushort); - - // reset ourselves to QString() - s.d = QString().d; + ba_d.d_ptr()->alloc *= sizeof(ushort); // do the in-place conversion qt_to_latin1(reinterpret_cast<uchar *>(ddata), data, length); @@ -5352,37 +5316,21 @@ QString::DataPointer QString::fromLatin1_helper(const char *str, int size) { DataPointer d; if (!str) { - d.d = Data::sharedNull(); - d.b = Data::sharedNullData(); - d.size = 0; + // nothing to do } else if (size == 0 || (!*str && size < 0)) { - QPair<Data *, ushort *> pair = Data::allocate(0); - d.d = pair.first; - d.b = pair.second; - d.size = 0; + d = DataPointer(Data::allocate(0), 0); } else { if (size < 0) size = qstrlen(str); - QPair<Data *, ushort *> pair = Data::allocate(size + 1); - d.d = pair.first; - d.b = pair.second; - d.size = size; - Q_CHECK_PTR(d.d); - d.b[size] = '\0'; - ushort *dst = d.b; + d = DataPointer(Data::allocate(size + 1), size); + d.data()[size] = '\0'; + ushort *dst = d.data(); qt_from_latin1(dst, str, uint(size)); } return d; } -QString::DataPointer QString::fromAscii_helper(const char *str, int size) -{ - QString s = fromUtf8(str, size); - s.d.d->ref(); - return s.d; -} - /*! \fn QString QString::fromLatin1(const char *str, int size) Returns a QString initialized with the first \a size characters of the Latin-1 string \a str. @@ -5596,7 +5544,7 @@ QString& QString::setUnicode(const QChar *unicode, int size) { resize(size); if (unicode && size) - memcpy(d.b, unicode, size * sizeof(QChar)); + memcpy(d.data(), unicode, size * sizeof(QChar)); return *this; } @@ -5856,8 +5804,8 @@ QString& QString::fill(QChar ch, int size) { resize(size < 0 ? d.size : size); if (d.size) { - QChar *i = (QChar*)d.b + d.size; - QChar *b = (QChar*)d.b; + QChar *i = (QChar*)d.data() + d.size; + QChar *b = (QChar*)d.data(); while (i != b) *--i = ch; } @@ -6438,11 +6386,11 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, const ushort *QString::utf16() const { - if (!d.d->isMutable()) { + if (!d->isMutable()) { // ensure '\0'-termination for ::fromRawData strings const_cast<QString*>(this)->reallocData(uint(d.size) + 1u); } - return d.b; + return d.data(); } /*! @@ -6471,8 +6419,8 @@ QString QString::leftJustified(int width, QChar fill, bool truncate) const if (padlen > 0) { result.resize(len+padlen); if (len) - memcpy(result.d.b, d.b, sizeof(QChar)*len); - QChar *uc = (QChar*)result.d.b + len; + memcpy(result.d.data(), d.data(), sizeof(QChar)*len); + QChar *uc = (QChar*)result.d.data() + len; while (padlen--) * uc++ = fill; } else { @@ -6509,11 +6457,11 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const int padlen = width - len; if (padlen > 0) { result.resize(len+padlen); - QChar *uc = (QChar*)result.d.b; + QChar *uc = (QChar*)result.d.data(); while (padlen--) * uc++ = fill; if (len) - memcpy(static_cast<void *>(uc), static_cast<const void *>(d.b), sizeof(QChar)*len); + memcpy(static_cast<void *>(uc), static_cast<const void *>(d.data()), sizeof(QChar)*len); } else { if (truncate) result = left(width); @@ -7938,19 +7886,19 @@ QString QString::repeated(int times) const if (result.capacity() != resultSize) return QString(); // not enough memory - memcpy(result.d.b, d.b, d.size * sizeof(ushort)); + memcpy(result.d.data(), d.data(), d.size * sizeof(ushort)); int sizeSoFar = d.size; - ushort *end = result.d.b + sizeSoFar; + ushort *end = result.d.data() + sizeSoFar; const int halfResultSize = resultSize >> 1; while (sizeSoFar <= halfResultSize) { - memcpy(end, result.d.b, sizeSoFar * sizeof(ushort)); + memcpy(end, result.d.data(), sizeSoFar * sizeof(ushort)); end += sizeSoFar; sizeSoFar <<= 1; } - memcpy(end, result.d.b, (resultSize - sizeSoFar) * sizeof(ushort)); - result.d.b[resultSize] = '\0'; + memcpy(end, result.d.data(), (resultSize - sizeSoFar) * sizeof(ushort)); + result.d.data()[resultSize] = '\0'; result.d.size = resultSize; return result; } @@ -8951,7 +8899,7 @@ QString QtPrivate::argToQString(QLatin1String pattern, size_t n, const ArgBase * */ bool QString::isSimpleText() const { - const ushort *p = d.b; + const ushort *p = d.data(); const ushort * const end = p + d.size; while (p < end) { ushort uc = *p; @@ -9102,18 +9050,11 @@ bool QString::isRightToLeft() const QString QString::fromRawData(const QChar *unicode, int size) { QString::DataPointer x; - x.size = size; if (!unicode) { - x.d = Data::sharedNull(); - x.b = Data::sharedNullData(); } else if (!size) { - QPair<Data *, ushort *> pair = Data::allocate(0); - x.d = pair.first; - x.b = pair.second; + x = DataPointer(Data::allocate(0), 0); } else { - x.b = const_cast<ushort *>(reinterpret_cast<const ushort *>(unicode)); - x.d = Data::fromRawData(x.b, size).ptr; - Q_CHECK_PTR(x.d); + x = Data::fromRawData(reinterpret_cast<const ushort *>(unicode), size); } return QString(x); } @@ -9136,12 +9077,8 @@ QString &QString::setRawData(const QChar *unicode, int size) { if (!unicode || !size) { clear(); - } else if (d.d->isShared() || !IS_RAW_DATA(d)) { - *this = fromRawData(unicode, size); - } else { - d.size = size; - d.b = const_cast<ushort *>(reinterpret_cast<const ushort *>(unicode)); } + *this = fromRawData(unicode, size); return *this; } diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 391e4788f2..a611410fac 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -259,8 +259,8 @@ public: QString &operator=(QChar c); QString &operator=(const QString &) noexcept; QString &operator=(QLatin1String latin1); - inline QString(QString &&other) noexcept : d(std::move(other.d)) - { other.d.d = Data::sharedNull(); other.d.b = Data::sharedNullData(); other.d.size = 0; } + inline QString(QString &&other) noexcept + { qSwap(d, other.d); } inline QString &operator=(QString &&other) noexcept { qSwap(d, other.d); return *this; } inline void swap(QString &other) noexcept { qSwap(d, other.d); } @@ -286,7 +286,7 @@ public: inline void detach(); inline bool isDetached() const; - inline bool isSharedWith(const QString &other) const { return d.d == other.d.d; } + inline bool isSharedWith(const QString &other) const { return d.isSharedWith(other.d); } void clear(); inline const QChar at(int i) const; @@ -541,10 +541,10 @@ public: inline QString &prepend(QLatin1String s) { return insert(0, s); } inline QString &operator+=(QChar c) { - if (d.d->needsDetach() || int(d.size + 1) > capacity()) + if (d->needsDetach() || int(d.size + 1) > capacity()) reallocData(uint(d.size) + 2u, true); - d.b[d.size++] = c.unicode(); - d.b[d.size] = '\0'; + d->data()[d.size++] = c.unicode(); + d->data()[d.size] = '\0'; return *this; } @@ -789,10 +789,10 @@ public: #endif #if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) inline QT_ASCII_CAST_WARN QString(const char *ch) - : d(fromAscii_helper(ch, ch ? int(strlen(ch)) : -1)) + : QString(fromUtf8(ch)) {} inline QT_ASCII_CAST_WARN QString(const QByteArray &a) - : d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size()))) + : QString(fromUtf8(a)) {} inline QT_ASCII_CAST_WARN QString &operator=(const char *ch) { return (*this = fromUtf8(ch)); } @@ -908,10 +908,10 @@ public: struct Null { }; QT_DEPRECATED_X("use QString()") static const Null null; - inline QString(const Null &) { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } + inline QString(const Null &) {} inline QString &operator=(const Null &) { *this = QString(); return *this; } #endif - inline bool isNull() const { return d.d == Data::sharedNull(); } + inline bool isNull() const { return d->isNull(); } bool isSimpleText() const; @@ -969,7 +969,6 @@ private: static QString simplified_helper(const QString &str); static QString simplified_helper(QString &str); static DataPointer fromLatin1_helper(const char *str, int size = -1); - static DataPointer fromAscii_helper(const char *str, int size = -1); static QString fromUtf8_helper(const char *str, int size); static QString fromLocal8Bit_helper(const char *, int size); static QByteArray toLatin1_helper(const QString &); @@ -1021,29 +1020,29 @@ inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1.lat inline int QString::length() const { return int(d.size); } inline const QChar QString::at(int i) const -{ Q_ASSERT(uint(i) < uint(size())); return QChar(d.b[i]); } +{ Q_ASSERT(uint(i) < uint(size())); return QChar(d.data()[i]); } inline const QChar QString::operator[](int i) const -{ Q_ASSERT(uint(i) < uint(size())); return QChar(d.b[i]); } +{ Q_ASSERT(uint(i) < uint(size())); return QChar(d.data()[i]); } inline bool QString::isEmpty() const { return d.size == 0; } inline const QChar *QString::unicode() const -{ return reinterpret_cast<const QChar*>(d.b); } +{ return reinterpret_cast<const QChar*>(d.data()); } inline const QChar *QString::data() const -{ return reinterpret_cast<const QChar*>(d.b); } +{ return reinterpret_cast<const QChar*>(d.data()); } inline QChar *QString::data() -{ detach(); return reinterpret_cast<QChar*>(d.b); } +{ detach(); return reinterpret_cast<QChar*>(d.data()); } inline const QChar *QString::constData() const -{ return reinterpret_cast<const QChar*>(d.b); } +{ return reinterpret_cast<const QChar*>(d.data()); } inline void QString::detach() -{ if (d.d->needsDetach()) reallocData(d.size + 1u); } +{ if (d->needsDetach()) reallocData(d.size + 1u); } inline bool QString::isDetached() const -{ return !d.d->isShared(); } +{ return !d->isShared(); } inline void QString::clear() { if (!isNull()) *this = QString(); } inline QString::QString(const QString &other) noexcept : d(other.d) -{ Q_ASSERT(&other != this); d.d->ref(); } +{ } inline int QString::capacity() const -{ int realCapacity = d.d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } +{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } inline QString &QString::setNum(short n, int base) { return setNum(qlonglong(n), base); } inline QString &QString::setNum(ushort n, int base) @@ -1130,27 +1129,27 @@ inline QString QString::fromWCharArray(const wchar_t *string, int size) : fromUcs4(reinterpret_cast<const uint *>(string), size); } -inline QString::QString() noexcept { d.d = Data::sharedNull(); d.b = Data::sharedNullData(); d.size = 0; } -inline QString::~QString() { if (!d.d->deref()) Data::deallocate(d.d); } +inline QString::QString() noexcept {} +inline QString::~QString() {} inline void QString::reserve(int asize) { - if (d.d->needsDetach() || asize >= capacity()) + if (d->needsDetach() || asize >= capacity()) reallocData(uint(qMax(asize, size())) + 1u); // we're not shared anymore, for sure - d.d->flags |= Data::CapacityReserved; + d->flags() |= Data::CapacityReserved; } inline void QString::squeeze() { - if ((d.d->flags & Data::CapacityReserved) == 0) + if ((d->flags() & Data::CapacityReserved) == 0) return; - if (d.d->needsDetach() || int(d.size) < capacity()) + if (d->needsDetach() || int(d.size) < capacity()) reallocData(uint(d.size) + 1u); // we're not shared anymore, for sure - d.d->flags &= uint(~Data::CapacityReserved); + d->flags() &= uint(~Data::CapacityReserved); } inline QString &QString::setUtf16(const ushort *autf16, int asize) @@ -1160,21 +1159,21 @@ inline QChar &QString::operator[](int i) inline QChar &QString::front() { return operator[](0); } inline QChar &QString::back() { return operator[](size() - 1); } inline QString::iterator QString::begin() -{ detach(); return reinterpret_cast<QChar*>(d.b); } +{ detach(); return reinterpret_cast<QChar*>(d.data()); } inline QString::const_iterator QString::begin() const -{ return reinterpret_cast<const QChar*>(d.b); } +{ return reinterpret_cast<const QChar*>(d.data()); } inline QString::const_iterator QString::cbegin() const -{ return reinterpret_cast<const QChar*>(d.b); } +{ return reinterpret_cast<const QChar*>(d.data()); } inline QString::const_iterator QString::constBegin() const -{ return reinterpret_cast<const QChar*>(d.b); } +{ return reinterpret_cast<const QChar*>(d.data()); } inline QString::iterator QString::end() -{ detach(); return reinterpret_cast<QChar*>(d.b + d.size); } +{ detach(); return reinterpret_cast<QChar*>(d.data() + d.size); } inline QString::const_iterator QString::end() const -{ return reinterpret_cast<const QChar*>(d.b + d.size); } +{ return reinterpret_cast<const QChar*>(d.data() + d.size); } inline QString::const_iterator QString::cend() const -{ return reinterpret_cast<const QChar*>(d.b + d.size); } +{ return reinterpret_cast<const QChar*>(d.data() + d.size); } inline QString::const_iterator QString::constEnd() const -{ return reinterpret_cast<const QChar*>(d.b + d.size); } +{ return reinterpret_cast<const QChar*>(d.data() + d.size); } #if QT_STRINGVIEW_LEVEL < 2 inline bool QString::contains(const QString &s, Qt::CaseSensitivity cs) const { return indexOf(s, 0, cs) != -1; } diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 61570fe042..742d38de7d 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -42,6 +42,7 @@ #define QSTRINGLITERAL_H #include <QtCore/qarraydata.h> +#include <QtCore/qarraydatapointer.h> #if 0 #pragma qt_class(QStringLiteral) @@ -67,7 +68,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, Q_BASIC_ATOMIC_INITIALIZER(-1), QArrayData::StaticDataFlags, 0 \ }; \ QStringPrivate holder = { \ - const_cast<QArrayData *>(&qstring_literal), \ + static_cast<QTypedArrayData<ushort> *>(const_cast<QArrayData *>(&qstring_literal)), \ reinterpret_cast<ushort *>(const_cast<qunicodechar *>(QT_UNICODE_LITERAL(str))), \ Size \ }; \ @@ -79,12 +80,7 @@ Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, # define QStringViewLiteral(str) QStringView(QT_UNICODE_LITERAL(str), QtPrivate::Deprecated) #endif -struct QStringPrivate -{ - QArrayData *d; - ushort *b; - uint size; -}; +using QStringPrivate = QArrayDataPointer<ushort>; QT_END_NAMESPACE diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 1d13344991..7bba7241e9 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -191,6 +191,7 @@ public: bool isMutable() const noexcept { return d->isMutable(); } bool isStatic() const noexcept { return d->isStatic(); } bool isShared() const noexcept { return d->isShared(); } + bool isSharedWith(const QArrayDataPointer &other) const noexcept { return d && d == other.d; } bool needsDetach() const noexcept { return d->needsDetach(); } size_t detachCapacity(size_t newSize) const noexcept { return d->detachCapacity(newSize); } typename Data::ArrayOptions &flags() noexcept { return reinterpret_cast<typename Data::ArrayOptions &>(d->flags); } @@ -204,6 +205,7 @@ public: d = pair.first; ptr = pair.second; } + Data *d_ptr() { return d; } private: Q_REQUIRED_RESULT QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const -- cgit v1.2.3 From c69b218197e97f09bf69f8f7fa3b4677c0f17455 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Thu, 14 Nov 2019 15:43:01 +0100 Subject: Avoid asan errors The SSE code can read slightly outside the bounds of the string. This is ok, as it's limited to 16 byte boundaries and thus can't cause a segfault. But it does cause a crash with asan. Change-Id: Id6e4a550579dc6228f365357773b392ecfd41471 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/corelib/text/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index e61228c4a4..4234b3c402 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -163,7 +163,7 @@ qsizetype QtPrivate::qustrlen(const ushort *str) noexcept { qsizetype result = 0; -#ifdef __SSE2__ +#if defined(__SSE2__) && !(defined(__SANITIZE_ADDRESS__) || QT_HAS_FEATURE(address_sanitizer)) // find the 16-byte alignment immediately prior or equal to str quintptr misalignment = quintptr(str) & 0xf; Q_ASSERT((misalignment & 1) == 0); -- cgit v1.2.3 From be9398c8d4ab0b7eba74b607d82dc43cd40443b8 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 2 Dec 2019 21:07:44 +0100 Subject: QListModel: fix moveRows() QListModel::moveRows() had an issue when the destination was before the source row. Change-Id: I4ce8b425451f2f53c7eb3b211e9590753dec618a Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: David Faure <david.faure@kdab.com> --- src/widgets/itemviews/qlistwidget.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index f71e0f2822..c9379f9a8a 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -301,16 +301,23 @@ bool QListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int co { if (sourceRow < 0 || sourceRow + count - 1 >= rowCount(sourceParent) - || destinationChild <= 0 + || destinationChild < 0 || destinationChild > rowCount(destinationParent) + || sourceRow == destinationChild || sourceRow == destinationChild - 1 - || count <= 0) { + || count <= 0 + || sourceParent.isValid() + || destinationParent.isValid()) { return false; } if (!beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(), destinationChild)) return false; - destinationChild--; - const int fromRow = destinationChild < sourceRow ? (sourceRow + count - 1) : sourceRow; + + int fromRow = sourceRow; + if (destinationChild < sourceRow) + fromRow += count - 1; + else + destinationChild--; while (count--) items.move(fromRow, destinationChild); endMoveRows(); -- cgit v1.2.3 From 8d2a6b422f9180ba053f22d7f8583ad559b3e9ca Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 18 Feb 2019 21:46:33 +0100 Subject: QTextDocument: compile with QT_NO_PRINTER The implementation of QTextDocument::print() is not available when QT_NO_PRINTER is defined but the declaration was so when someone is using this function (and QT_NO_PRINTER) a linker error will occur. Fixes: QTBUG-56916 Change-Id: I49aaaa643c4d8587a66fc95733060cea11994872 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- src/gui/text/qtextdocument.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 7d46238257..2459c78768 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -221,7 +221,9 @@ public: bool isModified() const; +#ifndef QT_NO_PRINTER void print(QPagedPaintDevice *printer) const; +#endif enum ResourceType { UnknownResource = 0, -- cgit v1.2.3 From 4e04132264a1259d28dc55e1ad01f848562c4c6d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 2 Dec 2019 21:04:09 +0100 Subject: QStringListModel: fix moveRows() QStringListMode::moveRows() had an issue when the destination was before the source row. Change-Id: Icf64e5b4cdd6a39faf3ba4ccc3883196b247ccbd Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: David Faure <david.faure@kdab.com> --- src/corelib/itemmodels/qstringlistmodel.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index a248cdcd38..9c87ff853a 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -301,24 +301,23 @@ bool QStringListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, { if (sourceRow < 0 || sourceRow + count - 1 >= rowCount(sourceParent) - || destinationChild <= 0 + || destinationChild < 0 || destinationChild > rowCount(destinationParent) + || sourceRow == destinationChild || sourceRow == destinationChild - 1 - || count <= 0) { + || count <= 0 + || sourceParent.isValid() + || destinationParent.isValid()) { return false; } if (!beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(), destinationChild)) return false; - /* - QList::move assumes that the second argument is the index where the item will end up to - i.e. the valid range for that argument is from 0 to QList::size()-1 - QAbstractItemModel::moveRows when source and destinations have the same parent assumes that - the item will end up being in the row BEFORE the one indicated by destinationChild - i.e. the valid range for that argument is from 1 to QList::size() - For this reason we remove 1 from destinationChild when using it inside QList - */ - destinationChild--; - const int fromRow = destinationChild < sourceRow ? (sourceRow + count - 1) : sourceRow; + + int fromRow = sourceRow; + if (destinationChild < sourceRow) + fromRow += count - 1; + else + destinationChild--; while (count--) lst.move(fromRow, destinationChild); endMoveRows(); -- cgit v1.2.3 From bda2169d965a40b3229421154979526448a1f745 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 25 Nov 2019 20:31:38 +0100 Subject: Doc: remove documented macros which were removed in Qt5 Remove documentation about QMIN, QMAX and QABS - they were removed during Qt4 -> 5 porting. Change-Id: I24e12e4f2bba635ff412e73dd1d0134bbab5247a Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/global/qglobal.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index b662233d4e..c145c46f78 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -4134,36 +4134,6 @@ bool qunsetenv(const char *varName) directive. */ -/*! - \macro QABS(n) - \relates <QtGlobal> - \obsolete - - Use qAbs(\a n) instead. - - \sa QMIN(), QMAX() -*/ - -/*! - \macro QMIN(x, y) - \relates <QtGlobal> - \obsolete - - Use qMin(\a x, \a y) instead. - - \sa QMAX(), QABS() -*/ - -/*! - \macro QMAX(x, y) - \relates <QtGlobal> - \obsolete - - Use qMax(\a x, \a y) instead. - - \sa QMIN(), QABS() -*/ - /*! \macro const char *qPrintable(const QString &str) \relates <QtGlobal> -- cgit v1.2.3 From abbdd634cd545b8d5ec34a615538f9d4ff2baec3 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Fri, 18 Oct 2019 14:15:40 +0200 Subject: Get rid of the getter for QObjectPrivate::threadData The dependent changes have now landed. Change-Id: I502377ab5603d67ada9e5577de1abfccdfa0fa09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/kernel/qobject_p.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 1ebf8e7a07..838a9aa8c5 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -374,7 +374,6 @@ public: } public: ExtraData *extraData; // extra data set by the user - QThreadData *getThreadData() const { return threadData.loadAcquire(); } // This atomic requires acquire/release semantics in a few places, // e.g. QObject::moveToThread must synchronize with QCoreApplication::postEvent, // because postEvent is thread-safe. -- cgit v1.2.3 From 05d52685028a46e340d610093c7e7c98479ac18b Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland <eirik.aavitsland@qt.io> Date: Tue, 17 Dec 2019 13:13:16 +0100 Subject: Fix QPainter::drawLines() with cosmetic pen Even though each line in the array passed to drawLines() should be rendered as an independent line, some state was kept in the cosmetic stroker from one line to the next. This could result in visible rendering errors. Fixes: QTBUG-80834 Change-Id: Ief7bf78eab83ae34459802bff5a57d6beec4a5e5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/gui/painting/qcosmeticstroker.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 0fb89a75b5..fa34c5598e 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -375,6 +375,7 @@ void QCosmeticStroker::drawLine(const QPointF &p1, const QPointF &p2) patternOffset = state->lastPen.dashOffset()*64; lastPixel.x = INT_MIN; + lastPixel.y = INT_MIN; stroke(this, start.x(), start.y(), end.x(), end.y(), drawCaps ? CapBegin|CapEnd : 0); -- cgit v1.2.3 From 18f22fea7c89da59b040da6361026593c8557a74 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha <andre.rocha@qt.io> Date: Wed, 13 Nov 2019 16:39:52 +0100 Subject: Windows QPA: Allow the native Windows virtual keyboard to be disabled This change provides a way to disable the automatic showing of the native Windows on-screen virtual keyboard when a text editing widget is selected on a system without a physical keyboard, by enabling the new AA_MSWindowsDisableVirtualKeyboard application attribute, allowing applications to use a custom virtual keyboard implementation. Fixes: QTBUG-76088 Change-Id: Id76f9673a2e4081e5325662f3e3b4b102d133b9a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 6 ++++++ src/plugins/platforms/windows/qwindowsinputcontext.cpp | 3 ++- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 6 ++++-- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 047ed8e7b3..5b63daec69 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -523,6 +523,7 @@ public: AA_DontUseNativeMenuBar = 6, AA_MacDontSwapCtrlAndMeta = 7, AA_Use96Dpi = 8, + AA_MSWindowsDisableVirtualKeyboard = 9, #if QT_DEPRECATED_SINCE(5, 14) AA_X11InitThreads Q_DECL_ENUMERATOR_DEPRECATED = 10, #endif diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index ef5f345e9c..6149281904 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -293,6 +293,12 @@ This attribute must be set before QGuiApplication is constructed. This value was added in 5.13 + \value AA_MSWindowsDisableVirtualKeyboard When this attribute is set, + Windows' native on-screen virtual keyboard will not be shown + automatically when a text input widget gains focus on a system + without a physical keyboard. + This value was added in 5.15 + The following values are deprecated or obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 19d632dc10..f1f5d3a96e 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -285,7 +285,8 @@ void QWindowsInputContext::showInputPanel() // the Surface seems unnecessary there anyway. But leave it hidden for IME. // Only trigger the native OSK if the Qt OSK is not in use. static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); - if (imModuleEmpty + bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard); + if ((imModuleEmpty && !nativeVKDisabled) && QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index a0a976545f..5f564f81c2 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -393,12 +393,14 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR // Control type converted from role. auto controlType = roleToControlTypeId(accessible->role()); - // The native OSK should be disbled if the Qt OSK is in use. + // The native OSK should be disbled if the Qt OSK is in use, + // or if disabled via application attribute. static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); + bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard); // If we want to disable the native OSK auto-showing // we have to report text fields as non-editable. - if (controlType == UIA_EditControlTypeId && !imModuleEmpty) + if (controlType == UIA_EditControlTypeId && (!imModuleEmpty || nativeVKDisabled)) controlType = UIA_TextControlTypeId; setVariantI4(controlType, pRetVal); -- cgit v1.2.3 From 87cedab94e4ca17e8c77602c0d1d285e3c68cb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 13 Dec 2019 11:47:42 +0100 Subject: Remove ApplicationResourceFlags::ApplicationPaletteExplicitlySet After 8fb881900c7b it's tracked by AA_SetPalette. Since the latter is publicly observable we remove the internal flag instead. Change-Id: Ie69799f1b45d68017cb9eaab2a9986cc9ac9ca38 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/gui/kernel/qguiapplication.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 54f3996b6e..e534ba377f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -166,7 +166,6 @@ bool QGuiApplicationPrivate::is_fallback_session_management_enabled = true; enum ApplicationResourceFlags { - ApplicationPaletteExplicitlySet = 0x1, ApplicationFontExplicitlySet = 0x2 }; @@ -3297,7 +3296,6 @@ void QGuiApplication::setPalette(const QPalette &pal) else *QGuiApplicationPrivate::app_pal = pal; - applicationResourceFlags |= ApplicationPaletteExplicitlySet; QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qGuiApp) @@ -4100,8 +4098,7 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) && - !QCoreApplication::testAttribute(Qt::AA_SetPalette)) { + if (!testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); emit qGuiApp->paletteChanged(*app_pal); -- cgit v1.2.3 From 04f5008f51dee9feec68afcee8cd8314b8e5ac62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 25 Jun 2019 18:42:59 +0200 Subject: Let sendApplicationPaletteChange() decide when it needs to exit early Change-Id: I7a8e6c0b54d2a16a17b292a4102e05f743bcbe29 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/gui/kernel/qguiapplication.cpp | 6 ++++-- src/widgets/kernel/qapplication.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e534ba377f..bab525f809 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -4102,8 +4102,7 @@ void QGuiApplicationPrivate::notifyThemeChanged() clearPalette(); initPalette(); emit qGuiApp->paletteChanged(*app_pal); - if (is_app_running && !is_app_closing) - sendApplicationPaletteChange(); + sendApplicationPaletteChange(); } if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { const auto locker = qt_scoped_lock(applicationFontMutex); @@ -4118,6 +4117,9 @@ void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, con Q_UNUSED(toAllWidgets) Q_UNUSED(className) + if (!is_app_running || is_app_closing) + return; + QEvent event(QEvent::ApplicationPaletteChange); QGuiApplication::sendEvent(QGuiApplication::instance(), &event); } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 5a21a3a15c..6120e0e164 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1390,10 +1390,9 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* hash->insert(className, pal); } - if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { - // Send ApplicationPaletteChange to qApp itself, and to the widgets. + + if (qApp) qApp->d_func()->sendApplicationPaletteChange(all, className); - } if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { QCoreApplication::setAttribute(Qt::AA_SetPalette); @@ -4431,6 +4430,9 @@ void QApplicationPrivate::notifyThemeChanged() void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) { + if (!is_app_running || is_app_closing) + return; + QGuiApplicationPrivate::sendApplicationPaletteChange(); QEvent event(QEvent::ApplicationPaletteChange); -- cgit v1.2.3 From 0a09a6341ddff4397461deb98b8d7a28ca3c9dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 25 Jun 2019 18:36:04 +0200 Subject: Sync implementation of QGuiApplication and QApplication setPalette The two static setPalette methods in QApplication and QGuiApplication should have the same behavior in terms of what signals and events they emit. Change-Id: I54579d490e31f3783e2d4fea689ca799a070ff1d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/gui/kernel/qguiapplication.cpp | 7 ++++--- src/widgets/kernel/qapplication.cpp | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bab525f809..7adba40fbd 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3299,7 +3299,7 @@ void QGuiApplication::setPalette(const QPalette &pal) QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qGuiApp) - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + qGuiApp->d_func()->sendApplicationPaletteChange(); } void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) @@ -4101,7 +4101,6 @@ void QGuiApplicationPrivate::notifyThemeChanged() if (!testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); - emit qGuiApp->paletteChanged(*app_pal); sendApplicationPaletteChange(); } if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { @@ -4115,7 +4114,9 @@ void QGuiApplicationPrivate::notifyThemeChanged() void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) { Q_UNUSED(toAllWidgets) - Q_UNUSED(className) + + if (!className) + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); if (!is_app_running || is_app_closing) return; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6120e0e164..9b1202c491 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1390,14 +1390,11 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* hash->insert(className, pal); } + if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) + QCoreApplication::setAttribute(Qt::AA_SetPalette); if (qApp) qApp->d_func()->sendApplicationPaletteChange(all, className); - - if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { - QCoreApplication::setAttribute(Qt::AA_SetPalette); - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); - } } /*! @@ -4433,7 +4430,7 @@ void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const if (!is_app_running || is_app_closing) return; - QGuiApplicationPrivate::sendApplicationPaletteChange(); + QGuiApplicationPrivate::sendApplicationPaletteChange(toAllWidgets, className); QEvent event(QEvent::ApplicationPaletteChange); const QWidgetList widgets = QApplication::allWidgets(); -- cgit v1.2.3 From cf3d4cf3c3755faa5474267bf5097e87b9f8152b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor <alexandru.croitor@qt.io> Date: Tue, 10 Dec 2019 15:01:11 +0100 Subject: Teach moc to output a Make-style depfile If moc is invoked with the --output-dep-file option, it will generate a "moc_<source_file_name>.d" dep file which contains dependency entries that can be consumed by a Makefile / Ninja build system. This is useful for build tools (like CMake) to know when moc should be re-ran. In the future, it might also be useful for ccache (teach ccache not to re-run moc when not necessary). The dependency list contains: the original source file, the passed --include files (like moc_predefs.h), the include files that were discovered while preprocessing the source file, and the plugin metadata json files listed in Q_PLUGIN_METADATA macros. The file paths are encoded using QFile::encodeName, so using the local 8-bit encoding. The paths are also escaped (so ' ' replaced by '\ ', '$' by '$$', etc) according to the Make-style rules as described in clang's dep file generator https://github.com/llvm/llvm-project/blob/release/9.x/clang/lib/Frontend/DependencyFile.cpp#L233 For reference, the equivalent Ninja depfile parser source code can be found at https://github.com/ninja-build/ninja/blob/v1.9.0/src/depfile_parser.in.cc#L37 Additional options that can be passed: --dep-file-path - to change the location where the dep file should be generated. --dep-file-rule-name - to change the rule name (first line) of the dep file (useful when no -o option is specified, so output goes to stdout). Encoding story. Note that moc doesn't handle non-local-8-bit characters properly when processing include directives at the preprocessor step. Specifically the content of the main input file is read as a raw byte array (which can be UTF-8 encoded) and then each include directive is resolved via Preprocessor::resolveInclude(), which calls QString::fromLocal8Bit(). Because moc uses the QtBootstrap library, only a limited set of codecs are available: various UTF 8 / 16 / 32 codecs and QLatin1Codec (ISO-8859-15). This means that on Windows, if the source input file is UTF-8 encoded, and contains include names with UTF-8 characters (like an emoji or any character >= 127 that is not in the QLatin1 codec), moc will fail to resolve and process that include, and thus no dep file entry will be created either. On macOS / QNX / WASM the main locale is UTF-8, so file content and paths will be processed correctly (hardcoded via QT_LOCALE_IS_UTF8 in src/corelib/codecs/qtextcodec_p.h). On Linux it will depend on the current locale / encoding set, and if that encoding is one of the ones supported above. UTF-8 should work fine. [ChangeLog][QtCore][moc] moc can now output a ".d" dep file that can be consumed by other build systems. Task-number: QTBUG-74521 Task-number: QTBUG-76598 Change-Id: I5585631ff1bbbae4e2875cade9cb6c20ed018c0a Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> --- src/tools/moc/main.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++++++++ src/tools/moc/moc.cpp | 1 + src/tools/moc/moc.h | 1 + 3 files changed, 133 insertions(+) (limited to 'src') diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 4aa040a9bb..b8c2d7f594 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -175,6 +175,49 @@ static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments) return allArguments; } +// Escape characters in given path. Dependency paths are Make-style, not NMake/Jom style. +// The paths can also be consumed by Ninja. +// "$" replaced by "$$" +// "#" replaced by "\#" +// " " replaced by "\ " +// "\#" replaced by "\\#" +// "\ " replaced by "\\\ " +// +// The escape rules are according to what clang / llvm escapes when generating a Make-style +// dependency file. +// Is a template function, because input param can be either a QString or a QByteArray. +template <typename T> struct CharType; +template <> struct CharType<QString> { using type = QLatin1Char; }; +template <> struct CharType<QByteArray> { using type = char; }; +template <typename StringType> +StringType escapeDependencyPath(const StringType &path) +{ + using CT = typename CharType<StringType>::type; + StringType escapedPath; + int size = path.size(); + escapedPath.reserve(size); + for (int i = 0; i < size; ++i) { + if (path[i] == CT('$')) { + escapedPath.append(CT('$')); + } else if (path[i] == CT('#')) { + escapedPath.append(CT('\\')); + } else if (path[i] == CT(' ')) { + escapedPath.append(CT('\\')); + int backwards_it = i - 1; + while (backwards_it > 0 && path[backwards_it] == CT('\\')) { + escapedPath.append(CT('\\')); + --backwards_it; + } + } + escapedPath.append(path[i]); + } + return escapedPath; +} + +QByteArray escapeAndEncodeDependencyPath(const QString &path) +{ + return QFile::encodeName(escapeDependencyPath(path)); +} int runMoc(int argc, char **argv) { @@ -308,6 +351,22 @@ int runMoc(int argc, char **argv) collectOption.setDescription(QStringLiteral("Instead of processing C++ code, collect previously generated JSON output into a single file.")); parser.addOption(collectOption); + QCommandLineOption depFileOption(QStringLiteral("output-dep-file")); + depFileOption.setDescription( + QStringLiteral("Output a Make-style dep file for build system consumption.")); + parser.addOption(depFileOption); + + QCommandLineOption depFilePathOption(QStringLiteral("dep-file-path")); + depFilePathOption.setDescription(QStringLiteral("Path where to write the dep file.")); + depFilePathOption.setValueName(QStringLiteral("file")); + parser.addOption(depFilePathOption); + + QCommandLineOption depFileRuleNameOption(QStringLiteral("dep-file-rule-name")); + depFileRuleNameOption.setDescription( + QStringLiteral("The rule name (first line) of the dep file.")); + depFileRuleNameOption.setValueName(QStringLiteral("rule name")); + parser.addOption(depFileRuleNameOption); + parser.addPositionalArgument(QStringLiteral("[header-file]"), QStringLiteral("Header file to read from, otherwise stdin.")); parser.addPositionalArgument(QStringLiteral("[@option-file]"), @@ -476,6 +535,7 @@ int runMoc(int argc, char **argv) // 1. preprocess const auto includeFiles = parser.values(includeOption); + QStringList validIncludesFiles; for (const QString &includeName : includeFiles) { QByteArray rawName = pp.resolveInclude(QFile::encodeName(includeName), moc.filename); if (rawName.isEmpty()) { @@ -488,6 +548,7 @@ int runMoc(int argc, char **argv) moc.symbols += Symbol(0, MOC_INCLUDE_BEGIN, rawName); moc.symbols += pp.preprocessed(rawName, &f); moc.symbols += Symbol(0, MOC_INCLUDE_END, rawName); + validIncludesFiles.append(includeName); } else { fprintf(stderr, "Warning: Cannot open %s included by moc file %s: %s\n", rawName.constData(), @@ -507,6 +568,7 @@ int runMoc(int argc, char **argv) QScopedPointer<FILE, ScopedPointerFileCloser> jsonOutput; + bool outputToFile = true; if (output.size()) { // output file specified #if defined(_MSC_VER) if (_wfopen_s(&out, reinterpret_cast<const wchar_t *>(output.utf16()), L"w") != 0) @@ -535,6 +597,7 @@ int runMoc(int argc, char **argv) } } else { // use stdout out = stdout; + outputToFile = false; } if (pp.preprocessOnly) { @@ -549,6 +612,74 @@ int runMoc(int argc, char **argv) if (output.size()) fclose(out); + if (parser.isSet(depFileOption)) { + // 4. write a Make-style dependency file (can also be consumed by Ninja). + QString depOutputFileName; + QString depRuleName = output; + + if (parser.isSet(depFileRuleNameOption)) + depRuleName = parser.value(depFileRuleNameOption); + + if (parser.isSet(depFilePathOption)) { + depOutputFileName = parser.value(depFilePathOption); + } else if (outputToFile) { + depOutputFileName = output + QLatin1String(".d"); + } else { + fprintf(stderr, "moc: Writing to stdout, but no depfile path specified.\n"); + } + + QScopedPointer<FILE, ScopedPointerFileCloser> depFileHandle; + FILE *depFileHandleRaw; +#if defined(_MSC_VER) + if (_wfopen_s(&depFileHandleRaw, + reinterpret_cast<const wchar_t *>(depOutputFileName.utf16()), L"w") != 0) +#else + depFileHandleRaw = fopen(QFile::encodeName(depOutputFileName).constData(), "w"); + if (!depFileHandleRaw) +#endif + fprintf(stderr, "moc: Cannot create dep output file '%s'. %s\n", + QFile::encodeName(depOutputFileName).constData(), + strerror(errno)); + depFileHandle.reset(depFileHandleRaw); + + if (!depFileHandle.isNull()) { + // First line is the path to the generated file. + fprintf(depFileHandle.data(), "%s: ", + escapeAndEncodeDependencyPath(depRuleName).constData()); + + QByteArrayList dependencies; + + // If there's an input file, it's the first dependency. + if (!filename.isEmpty()) { + dependencies.append(escapeAndEncodeDependencyPath(filename).constData()); + } + + // Additional passed-in includes are dependencies (like moc_predefs.h). + for (const QString &includeName : validIncludesFiles) { + dependencies.append(escapeAndEncodeDependencyPath(includeName).constData()); + } + + // Plugin metadata json files discovered via Q_PLUGIN_METADATA macros are also + // dependencies. + for (const QString &pluginMetadataFile : moc.parsedPluginMetadataFiles) { + dependencies.append(escapeAndEncodeDependencyPath(pluginMetadataFile).constData()); + } + + // All pre-processed includes are dependnecies. + // Sort the entries for easier human consumption. + auto includeList = pp.preprocessedIncludes.values(); + std::sort(includeList.begin(), includeList.end()); + + for (QByteArray &includeName : includeList) { + dependencies.append(escapeDependencyPath(includeName)); + } + + // Join dependencies, output them, and output a final new line. + const auto dependenciesJoined = dependencies.join(QByteArrayLiteral(" \\\n ")); + fprintf(depFileHandle.data(), "%s\n", dependenciesJoined.constData()); + } + } + return 0; } diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 58c9f88328..d7a1af0a18 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1382,6 +1382,7 @@ void Moc::parsePluginData(ClassDef *def) error(msg.constData()); return; } + parsedPluginMetadataFiles.append(fi.canonicalFilePath()); metaData = file.readAll(); } } diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 687ea2552f..5d1ae0ad6d 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -223,6 +223,7 @@ public: QHash<QByteArray, QByteArray> knownQObjectClasses; QHash<QByteArray, QByteArray> knownGadgets; QMap<QString, QJsonArray> metaArgs; + QVector<QString> parsedPluginMetadataFiles; void parse(); void generate(FILE *out, FILE *jsonOutput); -- cgit v1.2.3 From b2e3a5502afc0398cb8a732c366253e72a64b744 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Fri, 6 Dec 2019 13:30:40 +0100 Subject: Parse Xft.dpi with fraction Some versions of GNOME 3 would set Xft.dpi with fraction though that is technically not valid. Change-Id: Ib1027283cc78fd5d9869cd337864a92e28cd7e88 Fixes: QTBUG-64738 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> --- src/plugins/platforms/xcb/qxcbscreen.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 7c60ca06f9..44d0bb3f55 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -320,12 +320,22 @@ bool QXcbVirtualDesktop::xResource(const QByteArray &identifier, static bool parseXftInt(const QByteArray& stringValue, int *value) { - Q_ASSERT(value != 0); + Q_ASSERT(value); bool ok; *value = stringValue.toInt(&ok); return ok; } +static bool parseXftDpi(const QByteArray& stringValue, int *value) +{ + Q_ASSERT(value); + bool ok = parseXftInt(stringValue, value); + // Support GNOME 3 bug that wrote DPI with fraction: + if (!ok) + *value = qRound(stringValue.toDouble(&ok)); + return ok; +} + static QFontEngine::HintStyle parseXftHintStyle(const QByteArray& stringValue) { if (stringValue == "hintfull") @@ -391,7 +401,7 @@ void QXcbVirtualDesktop::readXResources() int value; QByteArray stringValue; if (xResource(r, "Xft.dpi:\t", stringValue)) { - if (parseXftInt(stringValue, &value)) + if (parseXftDpi(stringValue, &value)) m_forcedDpi = value; } else if (xResource(r, "Xft.hintstyle:\t", stringValue)) { m_hintStyle = parseXftHintStyle(stringValue); -- cgit v1.2.3 From 52876e0a821126ea07cb1c5db8f064c3585b6d96 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Tue, 17 Dec 2019 17:20:44 +0100 Subject: Basic QImage cleanup Remove deprecated methods and do marked TODOs for Qt6. Change-Id: I905743cf909776c6433616b3a7c3b544d75f2afe Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/doc/src/dontdocument.qdoc | 2 +- src/gui/image/qimage.cpp | 155 -------------------------------------- src/gui/image/qimage.h | 146 ----------------------------------- src/tools/uic/qclass_lib_map.h | 1 - 4 files changed, 1 insertion(+), 303 deletions(-) (limited to 'src') diff --git a/src/gui/doc/src/dontdocument.qdoc b/src/gui/doc/src/dontdocument.qdoc index b360acefc1..6b50daba88 100644 --- a/src/gui/doc/src/dontdocument.qdoc +++ b/src/gui/doc/src/dontdocument.qdoc @@ -27,7 +27,7 @@ /*! \dontdocument (QTypeInfo QScreenOrientationChangeEvent QApplicationStateChangeEvent - QImageTextKeyLang QMetaTypeId QAbstractUndoItem + QMetaTypeId QAbstractUndoItem QOpenGLVersionStatus QOpenGLVersionFunctionsBackend QOpenGLVersionFunctionsStorage diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 99d64737c5..1c8c6262ce 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1381,11 +1381,7 @@ int QImage::colorCount() const \sa colorTable(), setColor(), {QImage#Image Transformations}{Image Transformations} */ -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) void QImage::setColorTable(const QVector<QRgb> &colors) -#else -void QImage::setColorTable(const QVector<QRgb> colors) -#endif { if (!d) return; @@ -1395,11 +1391,7 @@ void QImage::setColorTable(const QVector<QRgb> colors) if (!d) return; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) d->colortable = colors; -#else - d->colortable = std::move(const_cast<QVector<QRgb>&>(colors)); -#endif d->has_alpha_clut = false; for (int i = 0; i < d->colortable.size(); ++i) { if (qAlpha(d->colortable.at(i)) != 255) { @@ -1472,25 +1464,6 @@ void QImage::setDevicePixelRatio(qreal scaleFactor) d->devicePixelRatio = scaleFactor; } -#if QT_DEPRECATED_SINCE(5, 10) -/*! - \since 4.6 - \obsolete - Returns the number of bytes occupied by the image data. - - Note this method should never be called on an image larger than 2 gigabytes. - Instead use sizeInBytes(). - - \sa sizeInBytes(), bytesPerLine(), bits(), {QImage#Image Information}{Image - Information} -*/ -int QImage::byteCount() const -{ - Q_ASSERT(!d || d->nbytes < std::numeric_limits<int>::max()); - return d ? int(d->nbytes) : 0; -} -#endif - /*! \since 5.10 Returns the image data size in bytes. @@ -1510,17 +1483,10 @@ qsizetype QImage::sizeInBytes() const \sa scanLine() */ -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) qsizetype QImage::bytesPerLine() const { return d ? d->bytes_per_line : 0; } -#else -int QImage::bytesPerLine() const -{ - return d ? d->bytes_per_line : 0; -} -#endif /*! @@ -4053,72 +4019,11 @@ void QImage::setText(const QString &key, const QString &value) d->text.insert(key, value); } -/*! - \fn QString QImage::text(const char* key, const char* language) const - \obsolete - - Returns the text recorded for the given \a key in the given \a - language, or in a default language if \a language is 0. - - Use text() instead. - - The language the text is recorded in is no longer relevant since - the text is always set using QString and UTF-8 representation. -*/ - -/*! - \fn QString QImage::text(const QImageTextKeyLang& keywordAndLanguage) const - \overload - \obsolete - - Returns the text recorded for the given \a keywordAndLanguage. - - Use text() instead. - - The language the text is recorded in is no longer relevant since - the text is always set using QString and UTF-8 representation. -*/ - -/*! - \fn void QImage::setText(const char* key, const char* language, const QString& text) - \obsolete - - Sets the image text to the given \a text and associate it with the - given \a key. The text is recorded in the specified \a language, - or in a default language if \a language is 0. - - Use setText() instead. - - The language the text is recorded in is no longer relevant since - the text is always set using QString and UTF-8 representation. - - \omit - Records string \a for the keyword \a key. The \a key should be - a portable keyword recognizable by other software - some suggested - values can be found in - \l{http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.Anc-text} - {the PNG specification}. \a s can be any text. \a lang should - specify the language code (see - \l{http://www.rfc-editor.org/rfc/rfc1766.txt}{RFC 1766}) or 0. - \endomit -*/ - -/* - Sets the image bits to the \a pixmap contents and returns a - reference to the image. - - If the image shares data with other images, it will first - dereference the shared data. - - Makes a call to QPixmap::convertToImage(). -*/ - /*! \internal Used by QPainter to retrieve a paint engine for the image. */ - QPaintEngine *QImage::paintEngine() const { if (!d) @@ -4364,22 +4269,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth #undef IWX_LSB #undef IWX_PIX -/*! \fn int QImage::serialNumber() const - \obsolete - Returns a number that identifies the contents of this - QImage object. Distinct QImage objects can only have the same - serial number if they refer to the same contents (but they don't - have to). - - Use cacheKey() instead. - - \warning The serial number doesn't necessarily change when the - image is altered. This means that it may be dangerous to use - it as a cache key. - - \sa operator==() -*/ - /*! Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same key if they @@ -5122,50 +5011,6 @@ QDebug operator<<(QDebug dbg, const QImage &i) } #endif -/*! - \fn void QImage::setNumColors(int n) - \obsolete - - Resizes the color table to contain \a n entries. - - \sa setColorCount() - */ - -/*! - \fn int QImage::numBytes() const - \obsolete - - Returns the number of bytes occupied by the image data. - - \sa sizeInBytes() - */ - -/*! - \fn QStringList QImage::textLanguages() const - \obsolete - - Returns the language identifiers for which some texts are recorded. - Note that if you want to iterate over the list, you should iterate over a copy. - - The language the text is recorded in is no longer relevant since the text is - always set using QString and UTF-8 representation. - - \sa textKeys() - */ - -/*! - \fn QList<QImageTextKeyLang> QImage::textList() const - \obsolete - - Returns a list of QImageTextKeyLang objects that enumerate all the texts - key/language pairs set for this image. - - The language the text is recorded in is no longer relevant since the text - is always set using QString and UTF-8 representation. - - \sa textKeys() - */ - static Q_CONSTEXPR QPixelFormat pixelformats[] = { //QImage::Format_Invalid: QPixelFormat(), diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 73c960f13f..1e462fc2e6 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -50,10 +50,6 @@ #include <QtCore/qrect.h> #include <QtCore/qstring.h> -#if QT_DEPRECATED_SINCE(5, 0) -#include <QtCore/qstringlist.h> -#endif - #if defined(Q_OS_DARWIN) || defined(Q_QDOC) Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage); #endif @@ -71,27 +67,6 @@ class QVariant; template <class T> class QVector; struct QImageData; -class QImageDataMisc; // internal -#if QT_DEPRECATED_SINCE(5, 0) -class QImageTextKeyLang { -public: - QT_DEPRECATED QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } - QT_DEPRECATED QImageTextKeyLang() { } - - QByteArray key; - QByteArray lang; - - bool operator< (const QImageTextKeyLang& other) const - { return key < other.key || (key==other.key && lang < other.lang); } - bool operator== (const QImageTextKeyLang& other) const - { return key==other.key && lang==other.lang; } - inline bool operator!= (const QImageTextKeyLang &other) const - { return !operator==(other); } -private: - friend class QImage; - QImageTextKeyLang(bool /*dummy*/) {} -}; -#endif typedef void (*QImageCleanupFunction)(void*); @@ -212,19 +187,12 @@ public: const uchar *bits() const; const uchar *constBits() const; -#if QT_DEPRECATED_SINCE(5, 10) - QT_DEPRECATED_X("Use sizeInBytes") int byteCount() const; -#endif qsizetype sizeInBytes() const; uchar *scanLine(int); const uchar *scanLine(int) const; const uchar *constScanLine(int) const; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) qsizetype bytesPerLine() const; -#else - int bytesPerLine() const; -#endif bool valid(int x, int y) const; bool valid(const QPoint &pt) const; @@ -245,11 +213,7 @@ public: void setPixelColor(const QPoint &pt, const QColor &c); QVector<QRgb> colorTable() const; -#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) void setColorTable(const QVector<QRgb> &colors); -#else - void setColorTable(const QVector<QRgb> colors); -#endif qreal devicePixelRatio() const; void setDevicePixelRatio(qreal scaleFactor); @@ -309,9 +273,6 @@ public: inline static QImage fromData(const QByteArray &data, const char *format = nullptr) { return fromData(reinterpret_cast<const uchar *>(data.constData()), data.size(), format); } -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } -#endif qint64 cacheKey() const; QPaintEngine *paintEngine() const override; @@ -337,20 +298,6 @@ public: CGImageRef toCGImage() const Q_DECL_CF_RETURNS_RETAINED; #endif -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline QString text(const char *key, const char *lang = nullptr) const; - QT_DEPRECATED inline QList<QImageTextKeyLang> textList() const; - QT_DEPRECATED inline QStringList textLanguages() const; - QT_DEPRECATED inline QString text(const QImageTextKeyLang&) const; - QT_DEPRECATED inline void setText(const char* key, const char* lang, const QString&); -#endif - -#if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED inline int numColors() const; - QT_DEPRECATED inline void setNumColors(int); - QT_DEPRECATED inline int numBytes() const; -#endif - protected: virtual int metric(PaintDeviceMetric metric) const override; QImage mirrored_helper(bool horizontal, bool vertical) const; @@ -385,99 +332,6 @@ inline void QImage::setPixel(const QPoint &pt, uint index_or_rgb) { setPixel(pt. inline QColor QImage::pixelColor(const QPoint &pt) const { return pixelColor(pt.x(), pt.y()); } inline void QImage::setPixelColor(const QPoint &pt, const QColor &c) { setPixelColor(pt.x(), pt.y(), c); } -#if QT_DEPRECATED_SINCE(5, 0) - -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - -inline QString QImage::text(const char* key, const char* lang) const -{ - if (!d) - return QString(); - QString k = QString::fromLatin1(key); - if (lang && *lang) - k += QLatin1Char('/') + QString::fromLatin1(lang); - return text(k); -} - -inline QList<QImageTextKeyLang> QImage::textList() const -{ - QList<QImageTextKeyLang> imageTextKeys; - if (!d) - return imageTextKeys; - QStringList keys = textKeys(); - for (int i = 0; i < keys.size(); ++i) { - int index = keys.at(i).indexOf(QLatin1Char('/')); - if (index > 0) { - QImageTextKeyLang tkl(true); - tkl.key = keys.at(i).left(index).toLatin1(); - tkl.lang = keys.at(i).mid(index+1).toLatin1(); - imageTextKeys += tkl; - } - } - - return imageTextKeys; -} - -inline QStringList QImage::textLanguages() const -{ - if (!d) - return QStringList(); - QStringList keys = textKeys(); - QStringList languages; - for (int i = 0; i < keys.size(); ++i) { - int index = keys.at(i).indexOf(QLatin1Char('/')); - if (index > 0) - languages += keys.at(i).mid(index+1); - } - - return languages; -} - -inline QString QImage::text(const QImageTextKeyLang&kl) const -{ - if (!d) - return QString(); - QString k = QString::fromLatin1(kl.key.constData()); - if (!kl.lang.isEmpty()) - k += QLatin1Char('/') + QString::fromLatin1(kl.lang.constData()); - return text(k); -} - -inline void QImage::setText(const char* key, const char* lang, const QString &s) -{ - if (!d) - return; - detach(); - - // In case detach() ran out of memory - if (!d) - return; - - QString k = QString::fromLatin1(key); - if (lang && *lang) - k += QLatin1Char('/') + QString::fromLatin1(lang); - setText(k, s); -} - -QT_WARNING_POP - -inline int QImage::numColors() const -{ - return colorCount(); -} - -inline void QImage::setNumColors(int n) -{ - setColorCount(n); -} - -inline int QImage::numBytes() const -{ - return int(sizeInBytes()); -} -#endif - // QImage stream functions #if !defined(QT_NO_DATASTREAM) diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index bf3882edd1..841144133f 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -635,7 +635,6 @@ QT_CLASS_LIB(QIconEngineFactoryInterface, QtGui, qiconengineplugin.h) QT_CLASS_LIB(QIconEnginePlugin, QtGui, qiconengineplugin.h) QT_CLASS_LIB(QIconEngineFactoryInterfaceV2, QtGui, qiconengineplugin.h) QT_CLASS_LIB(QIconEnginePluginV2, QtGui, qiconengineplugin.h) -QT_CLASS_LIB(QImageTextKeyLang, QtGui, qimage.h) QT_CLASS_LIB(QImage, QtGui, qimage.h) QT_CLASS_LIB(QImageIOHandler, QtGui, qimageiohandler.h) QT_CLASS_LIB(QImageIOHandlerFactoryInterface, QtGui, qimageiohandler.h) -- cgit v1.2.3 From 48704c3f5c18c126fc777e5669ccca0d37f9663e Mon Sep 17 00:00:00 2001 From: Leena Miettinen <riitta-leena.miettinen@qt.io> Date: Wed, 18 Dec 2019 10:22:59 +0100 Subject: Doc: Add since Qt 5.8 info for QResource::lastModified() Fixes: QTBUG-80856 Change-Id: I2f2b562ad2b262c6dfa236a43589129186589ed7 Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/io/qresource.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 5cbe49e2f7..a494daa29f 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -629,6 +629,8 @@ const uchar *QResource::data() const } /*! + \since 5.8 + Returns the date and time when the file was last modified before packaging into a resource. */ -- cgit v1.2.3 From f2d752c59f5a1d2e815394d718350d0fcaf43ef6 Mon Sep 17 00:00:00 2001 From: Marc Mutz <marc.mutz@kdab.com> Date: Fri, 6 Dec 2019 14:16:31 +0100 Subject: QWindowSystemInterface: use QBasicMutex and qt_scoped_lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no reason to use a class-static mutex object here. Use a namespace-static QBasicMutex, port to qt_scoped_lock. Change-Id: Ia9bd3c2fadbf1da25ef79bb393c899b678cbc182 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/kernel/qwindowsysteminterface.cpp | 10 ++++++---- src/gui/kernel/qwindowsysteminterface_p.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index c9a70897d6..31765cf54c 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -46,7 +46,9 @@ #include <qpa/qplatformintegration.h> #include <qdebug.h> #include "qhighdpiscaling_p.h" + #include <QtCore/qscopedvaluerollback.h> +#include <QtCore/private/qlocking_p.h> #if QT_CONFIG(draganddrop) #include <qpa/qplatformdrag.h> @@ -623,7 +625,7 @@ bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device) static int g_nextPointId = 1; // map from device-independent point id (arbitrary) to "Qt point" ids -QMutex QWindowSystemInterfacePrivate::pointIdMapMutex; +static QBasicMutex pointIdMapMutex; typedef QMap<quint64, int> PointIdMap; Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap) @@ -641,7 +643,7 @@ Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap) */ static int acquireCombinedPointId(quint8 deviceId, int pointId) { - QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + const auto locker = qt_scoped_lock(pointIdMapMutex); quint64 combinedId64 = (quint64(deviceId) << 32) + pointId; auto it = g_pointIdMap->constFind(combinedId64); @@ -702,7 +704,7 @@ QList<QTouchEvent::TouchPoint> } if (states == Qt::TouchPointReleased) { - QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + const auto locker = qt_scoped_lock(pointIdMapMutex); // All points on deviceId have been released. // Remove all points associated with that device from g_pointIdMap. @@ -723,7 +725,7 @@ QList<QTouchEvent::TouchPoint> void QWindowSystemInterfacePrivate::clearPointIdMap() { - QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex); + const auto locker = qt_scoped_lock(pointIdMapMutex); g_pointIdMap->clear(); g_nextPointId = 1; } diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 6e4bce607e..dd6f29b41f 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -529,7 +529,6 @@ public: static QWaitCondition eventsFlushed; static QMutex flushEventMutex; - static QMutex pointIdMapMutex; static QAtomicInt eventAccepted; static QList<QTouchEvent::TouchPoint> -- cgit v1.2.3 From 2614347ab8aa0ec0b1ea8f383ae795cfdb6ae2ac Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Tue, 17 Dec 2019 19:58:58 +0100 Subject: Fix QSpinbox default width After aa8d3f90a440575deef914916299b792105d7209 the default width of the spinbox buttons is calculated from the spinbox width. This is wrong because the initial width (e.g. when the spinbox is not yet shown) is 640 pixels which results in a too long width. Therefore fall back to the old hard-coded value version but instead using 20 pixels, use 16 to be in sync with the stylesheet style value and honor the dpi of the screen by using QStyleHelper::dpiScaled(). Fixes: QTBUG-79806 Fixes: QTBUG-80814 Change-Id: I45786684575273f940e498df3b7639e626f00a7e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/widgets/styles/qcommonstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 03081658bb..49b92a69f8 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5027,8 +5027,9 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_SpinBox: if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { // Add button + frame widths + const qreal dpi = QStyleHelper::dpi(opt); const bool hasButtons = (vopt->buttonSymbols != QAbstractSpinBox::NoButtons); - const int buttonWidth = hasButtons ? proxy()->subControlRect(CC_SpinBox, vopt, SC_SpinBoxUp, widget).width() : 0; + const int buttonWidth = hasButtons ? qRound(QStyleHelper::dpiScaled(16, dpi)) : 0; const int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget) : 0; sz += QSize(buttonWidth + 2*fw, 2*fw); } -- cgit v1.2.3 From 62c3dd5632b04a7ee2410cc2233c0d0605ad5bd6 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Date: Fri, 22 Nov 2019 13:04:36 +0100 Subject: QPalette::setBrush: remove a workaround for PlaceholderText This partially reverts ebd3a13b807c6af2684b42d3912549caf7ef82aa removing the part that was intended to be removed in Qt 6. Task-number: QTBUG-78544 Change-Id: I4b7eb922c46e44411717f80234fad8ad7dd09aef Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/kernel/qpalette.cpp | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index fc063bc72c..fdcdef4345 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -321,11 +321,8 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) Returns the placeholder text brush of the current color group. - \note Before Qt 5.12, the placeholder text color was hard-coded in the code as - QPalette::text().color() where an alpha of 128 was applied. - We continue to support this behavior by default, unless you set your own brush. - One can get back the original placeholder color setting the special QBrush default - constructor as placeholder brush. + \note Before Qt 5.12, the placeholder text color was hard-coded as QPalette::text().color() + with an alpha of 128 applied. In Qt 6, it is an independent color. \sa ColorRole, brush() */ @@ -783,32 +780,11 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) cg = Active; } - // For placeholder we want to continue to respect the original behavior, which is - // derivating the text color, but only if user has not yet set his own brush. - // We then use Qt::NoBrush as an inernal way to know if the brush is customized or not. - - // ### Qt 6 - remove this special case - // Part 1 - Restore initial color to the given color group - if (cr == PlaceholderText && b == QBrush()) { - QColor col = brush(Text).color(); - col.setAlpha(128); - setBrush(cg, PlaceholderText, QBrush(col, Qt::NoBrush)); - return; - } - if (d->br[cg][cr] != b) { detach(); d->br[cg][cr] = b; } data.resolve_mask |= (1<<cr); - - // ### Qt 6 - remove this special case - // Part 2 - Update initial color to the given color group - if (cr == Text && d->br[cg][PlaceholderText].style() == Qt::NoBrush) { - QColor col = brush(Text).color(); - col.setAlpha(128); - setBrush(cg, PlaceholderText, QBrush(col, Qt::NoBrush)); - } } /*! @@ -1177,6 +1153,8 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() QColor button = backGround; QColor shadow = dark.darker(135); QColor disabledShadow = shadow.lighter(150); + QColor placeholder = text; + placeholder.setAlpha(128); QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base); fusionPalette.setBrush(QPalette::Midlight, midLight); @@ -1194,6 +1172,9 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198)); fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145)); + + fusionPalette.setBrush(QPalette::PlaceholderText, placeholder); + return fusionPalette; } -- cgit v1.2.3 From 322e5b7f5e35db73f7d7730a6fff558e153ad356 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 18 Dec 2019 16:05:52 +0100 Subject: QtWidget docs: small fixes Apply some minor fixes to the widget docs - use nullptr - use c++11 initializer list - properly delete widget when cleaning the layout (QTBUG-29471) - rework CardLayout example to make it work with Qt5 Fixes: QTBUG-29471 Change-Id: Ie2ee9f75eb8faf97d2bbd2c25e7013d4f30d8dd0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/widgets/doc/snippets/code/doc_src_layout.cpp | 53 +++++++++++----------- .../snippets/code/src_gui_dialogs_qfiledialog.cpp | 17 ++++--- .../code/src_gui_itemviews_qtreewidget.cpp | 2 +- .../snippets/code/src_gui_kernel_qapplication.cpp | 7 +-- .../doc/snippets/code/src_gui_kernel_qlayout.cpp | 5 +- .../snippets/code/src_gui_kernel_qlayoutitem.cpp | 3 +- .../doc/snippets/code/src_gui_qproxystyle.cpp | 8 ++-- .../doc/snippets/code/src_gui_widgets_qmenubar.cpp | 2 +- .../code/src_gui_widgets_qsplashscreen.cpp | 4 +- .../doc/src/widgets-and-layouts/layout.qdoc | 2 +- 10 files changed, 52 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/widgets/doc/snippets/code/doc_src_layout.cpp b/src/widgets/doc/snippets/code/doc_src_layout.cpp index 5e9a740244..7bbd781bb2 100644 --- a/src/widgets/doc/snippets/code/doc_src_layout.cpp +++ b/src/widgets/doc/snippets/code/doc_src_layout.cpp @@ -53,14 +53,15 @@ #define CARD_H #include <QtWidgets> -#include <QList> +#include <QVector> class CardLayout : public QLayout { public: - CardLayout(QWidget *parent, int dist): QLayout(parent, 0, dist) {} - CardLayout(QLayout *parent, int dist): QLayout(parent, dist) {} - CardLayout(int dist): QLayout(dist) {} + CardLayout(int spacing): QLayout() + { setSpacing(spacing); } + CardLayout(int spacing, QWidget *parent): QLayout(parent) + { setSpacing(spacing); } ~CardLayout(); void addItem(QLayoutItem *item) override; @@ -72,7 +73,7 @@ public: void setGeometry(const QRect &rect) override; private: - QList<QLayoutItem*> list; + QVector<QLayoutItem*> m_items; }; #endif //! [0] @@ -85,23 +86,23 @@ private: //! [2] int CardLayout::count() const { - // QList::size() returns the number of QLayoutItems in the list - return list.size(); + // QVector::size() returns the number of QLayoutItems in m_items + return m_items.size(); } //! [2] //! [3] QLayoutItem *CardLayout::itemAt(int idx) const { - // QList::value() performs index checking, and returns 0 if we are + // QVector::value() performs index checking, and returns nullptr if we are // outside the valid range - return list.value(idx); + return m_items.value(idx); } QLayoutItem *CardLayout::takeAt(int idx) { - // QList::take does not do index checking - return idx >= 0 && idx < list.size() ? list.takeAt(idx) : 0; + // QVector::take does not do index checking + return idx >= 0 && idx < m_items.size() ? m_items.takeAt(idx) : 0; } //! [3] @@ -109,7 +110,7 @@ QLayoutItem *CardLayout::takeAt(int idx) //! [4] void CardLayout::addItem(QLayoutItem *item) { - list.append(item); + m_items.append(item); } //! [4] @@ -129,14 +130,14 @@ void CardLayout::setGeometry(const QRect &r) { QLayout::setGeometry(r); - if (list.size() == 0) + if (m_items.size() == 0) return; - int w = r.width() - (list.count() - 1) * spacing(); - int h = r.height() - (list.count() - 1) * spacing(); + int w = r.width() - (m_items.count() - 1) * spacing(); + int h = r.height() - (m_items.count() - 1) * spacing(); int i = 0; - while (i < list.size()) { - QLayoutItem *o = list.at(i); + while (i < m_items.size()) { + QLayoutItem *o = m_items.at(i); QRect geom(r.x() + i * spacing(), r.y() + i * spacing(), w, h); o->setGeometry(geom); ++i; @@ -148,29 +149,29 @@ void CardLayout::setGeometry(const QRect &r) //! [7] QSize CardLayout::sizeHint() const { - QSize s(0,0); - int n = list.count(); + QSize s(0, 0); + int n = m_items.count(); if (n > 0) - s = QSize(100,70); //start with a nice default size + s = QSize(100, 70); //start with a nice default size int i = 0; while (i < n) { - QLayoutItem *o = list.at(i); + QLayoutItem *o = m_items.at(i); s = s.expandedTo(o->sizeHint()); ++i; } - return s + n*QSize(spacing(), spacing()); + return s + n * QSize(spacing(), spacing()); } QSize CardLayout::minimumSize() const { - QSize s(0,0); - int n = list.count(); + QSize s(0, 0); + int n = m_items.count(); int i = 0; while (i < n) { - QLayoutItem *o = list.at(i); + QLayoutItem *o = m_items.at(i); s = s.expandedTo(o->minimumSize()); ++i; } - return s + n*QSize(spacing(), spacing()); + return s + n * QSize(spacing(), spacing()); } //! [7] diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp index 4b4fb869f9..ed6043564b 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp @@ -89,11 +89,10 @@ dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++"); //! [7] -QStringList filters; -filters << "Image files (*.png *.xpm *.jpg)" - << "Text files (*.txt)" - << "Any files (*)"; - +const QStringList filters({"Image files (*.png *.xpm *.jpg)", + "Text files (*.txt)", + "Any files (*)" + }); QFileDialog dialog(this); dialog.setNameFilters(filters); dialog.exec(); @@ -131,10 +130,10 @@ QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), //! [12] //! [13] -QStringList mimeTypeFilters; -mimeTypeFilters << "image/jpeg" // will show "JPEG image (*.jpeg *.jpg *.jpe) - << "image/png" // will show "PNG image (*.png)" - << "application/octet-stream"; // will show "All files (*)" +QStringList mimeTypeFilters({"image/jpeg", // will show "JPEG image (*.jpeg *.jpg *.jpe) + "image/png", // will show "PNG image (*.png)" + "application/octet-stream" // will show "All files (*)" + }); QFileDialog dialog(this); dialog.setMimeTypeFilters(mimeTypeFilters); diff --git a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp index 792cc48ca7..f1e3b6ea45 100644 --- a/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp +++ b/src/widgets/doc/snippets/code/src_gui_itemviews_qtreewidget.cpp @@ -53,6 +53,6 @@ QTreeWidget *treeWidget = new QTreeWidget(); treeWidget->setColumnCount(1); QList<QTreeWidgetItem *> items; for (int i = 0; i < 10; ++i) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i)))); + items.append(new QTreeWidgetItem(static_cast<QTreeWidget *>(nullptr), QStringList(QString("item: %1").arg(i)))); treeWidget->insertTopLevelItems(0, items); //! [0] diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp index 0a70c1d32a..5e1f0883e7 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -51,9 +51,10 @@ //! [0] QCoreApplication* createApplication(int &argc, char *argv[]) { - for (int i = 1; i < argc; ++i) + for (int i = 1; i < argc; ++i) { if (!qstrcmp(argv[i], "-no-gui")) return new QCoreApplication(argc, argv); + } return new QApplication(argc, argv); } @@ -187,14 +188,14 @@ for (const QString &command : commands) //! [12] -QWidget *widget = qApp->widgetAt(x, y); +QWidget *widget = QApplication::widgetAt(x, y); if (widget) widget = widget->window(); //! [12] //! [13] -QWidget *widget = qApp->widgetAt(point); +QWidget *widget = QApplication::widgetAt(point); if (widget) widget = widget->window(); //! [13] diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp index 1a716029a9..c55834ebfb 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayout.cpp @@ -70,8 +70,9 @@ void MyWidget::paintEvent(QPaintEvent *) //! [1] QLayoutItem *child; -while ((child = layout->takeAt(0)) != 0) { +while ((child = layout->takeAt(0)) != nullptr) { ... - delete child; + delete child->widget(); // delete the widget + delete child; // delete the layout item } //! [1] diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp index d9f70b91ed..dd0f860c01 100644 --- a/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp +++ b/src/widgets/doc/snippets/code/src_gui_kernel_qlayoutitem.cpp @@ -52,8 +52,7 @@ int MyLayout::heightForWidth(int w) const { if (cache_dirty || cached_width != w) { - // not all C++ compilers support "mutable" - MyLayout *that = (MyLayout*)this; + MyLayout *that = const_cast<MyLayout *>(this); int h = calculateHeightForWidth(w); that->cached_hfw = h; return h; diff --git a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp index 3169d1c193..98dc0ff55b 100644 --- a/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp +++ b/src/widgets/doc/snippets/code/src_gui_qproxystyle.cpp @@ -53,8 +53,8 @@ class MyProxyStyle : public QProxyStyle { public: - int styleHint(StyleHint hint, const QStyleOption *option = 0, - const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override + int styleHint(StyleHint hint, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override { if (hint == QStyle::SH_UnderlineShortcut) return 1; @@ -72,8 +72,8 @@ public: class MyProxyStyle : public QProxyStyle { public: - int styleHint(StyleHint hint, const QStyleOption *option = 0, - const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override + int styleHint(StyleHint hint, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override { if (hint == QStyle::SH_UnderlineShortcut) return 0; diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp index b82c67b379..b52b0064ad 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qmenubar.cpp @@ -54,5 +54,5 @@ menubar->addMenu(fileMenu); //! [1] -QMenuBar *menuBar = new QMenuBar(0); +QMenuBar *menuBar = new QMenuBar(nullptr); //! [1] diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp index b9c0b1a38b..91aa8a9c4e 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qsplashscreen.cpp @@ -56,10 +56,10 @@ splash->show(); ... // Loading some items splash->showMessage("Loaded modules"); -qApp->processEvents(); +QCoreApplication::processEvents(); ... // Establishing connections splash->showMessage("Established connections"); -qApp->processEvents(); +QCoreApplication::processEvents(); //! [0] diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc index 65569a9cd2..e42e6d42ec 100644 --- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc @@ -300,7 +300,7 @@ \list \li A data structure to store the items handled by the layout. Each item is a \l{QLayoutItem}{QLayoutItem}. We will use a - QList in this example. + QVector in this example. \li \l{QLayout::}{addItem()}, how to add items to the layout. \li \l{QLayout::}{setGeometry()}, how to perform the layout. \li \l{QLayout::}{sizeHint()}, the preferred size of the layout. -- cgit v1.2.3 From caa82e1fc24907af0a81e31cf9b77ae8e82e44cc Mon Sep 17 00:00:00 2001 From: Paul Wicking <paul.wicking@qt.io> Date: Wed, 18 Dec 2019 15:27:06 +0100 Subject: Doc: Add since version for QCursor::swap and QOperatingSystemVersion::currentType. Fixes: QTBUG-80854 Fixes: QTBUG-80891 Change-Id: Ia256fa0d3ad4665f44b933f5a4a8d4ee87e9fc13 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> --- src/corelib/global/qoperatingsystemversion.cpp | 2 ++ src/gui/kernel/qcursor.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index 33793ca168..261f5c8795 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -299,6 +299,8 @@ int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1, Returns the current OS type without constructing a QOperatingSystemVersion instance. + \since 5.10 + \sa current() */ diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 1ba8760a9d..fd912362bf 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -175,6 +175,8 @@ QT_BEGIN_NAMESPACE \fn void QCursor::swap(QCursor &other) Swaps this cursor with the \a other cursor. + + \since 5.7 */ /*! -- cgit v1.2.3 From a132e0254005b2954b11705b32650c9018049187 Mon Sep 17 00:00:00 2001 From: Peter Varga <pvarga@inf.u-szeged.hu> Date: Mon, 18 Nov 2019 15:00:58 +0100 Subject: Fix QAccessibleWidget::focusChild() to return focused descendant This method should not ignore accessibility objects without corresponding widget. The widget may have parts with their own QAccessibilityInterface and these can be also focused. VoiceOver ignores them if they are not returned by focusChild(). QAccessibleTabBar::focusChild() has been implemented to demonstrate the concept and make tab titles of QTabBar readable by VoiceOver. Task-number: QTBUG-78284 Change-Id: Id7c62d86154bbd5d47d6bbee8cb7d05268c2e151 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/widgets/accessible/complexwidgets.cpp | 15 ++++++++++++++- src/widgets/accessible/complexwidgets_p.h | 1 + src/widgets/accessible/qaccessiblewidget.cpp | 12 ++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 63c6fbb9bb..5c993262bf 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -108,7 +108,10 @@ public: s.invalid = true; return s; } - return parent()->state(); + + QAccessible::State s = parent()->state(); + s.focused = (m_index == m_parent->currentIndex()); + return s; } QRect rect() const override { if (!isValid()) @@ -216,6 +219,16 @@ QTabBar *QAccessibleTabBar::tabBar() const return qobject_cast<QTabBar*>(object()); } +QAccessibleInterface* QAccessibleTabBar::focusChild() const +{ + for (int i = 0; i < childCount(); ++i) { + if (child(i)->state().focused) + return child(i); + } + + return nullptr; +} + QAccessibleInterface* QAccessibleTabBar::child(int index) const { if (QAccessible::Id id = m_childInterfaces.value(index)) diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h index e7a32c7264..335e257476 100644 --- a/src/widgets/accessible/complexwidgets_p.h +++ b/src/widgets/accessible/complexwidgets_p.h @@ -112,6 +112,7 @@ public: explicit QAccessibleTabBar(QWidget *w); ~QAccessibleTabBar(); + QAccessibleInterface *focusChild() const override; int childCount() const override; QString text(QAccessible::Text t) const override; diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 27e6b09dc7..3ab66c4ce4 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -374,11 +374,15 @@ QAccessibleInterface *QAccessibleWidget::focusChild() const QWidget *fw = widget()->focusWidget(); if (!fw) - return 0; + return nullptr; - if (isAncestor(widget(), fw) || fw == widget()) - return QAccessible::queryAccessibleInterface(fw); - return 0; + if (isAncestor(widget(), fw)) { + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(fw); + if (!iface || iface == this || !iface->focusChild()) + return iface; + return iface->focusChild(); + } + return nullptr; } /*! \reimp */ -- cgit v1.2.3 From 512b87bc28fc70058e240cf720fdfc9c9da98afb Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <albert.astals.cid@kdab.com> Date: Wed, 18 Dec 2019 09:32:31 +0100 Subject: Don't have a "see also qrand" from qrand I guess what we wanted there was qsrand Change-Id: I8e18e76ae65abf9de231d51faa61cc9142ea2b98 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qrandom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 3cbd40b772..10672c1f92 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -1295,7 +1295,7 @@ void qsrand(uint seed) \note This function is deprecated. In new applications, use QRandomGenerator instead. - \sa qrand(), QRandomGenerator + \sa qsrand(), QRandomGenerator */ int qrand() { -- cgit v1.2.3 From e2f4c5f4a115d1b7431d7d5781e9e1886b9b2450 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 19 Dec 2019 10:24:55 +0100 Subject: double-conversion.cc: Fix developer build with clang-cl clang-cl errors out with an unknown #pragma on the scope turning off optimization for MSVC2012. Remove it since MSVC2012 is no longer supported. Change-Id: I46610885e10158bc5b3666b7698dc1162dbac8a7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/3rdparty/double-conversion/double-conversion.cc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'src') diff --git a/src/3rdparty/double-conversion/double-conversion.cc b/src/3rdparty/double-conversion/double-conversion.cc index 8c52755cfb..148193b72a 100644 --- a/src/3rdparty/double-conversion/double-conversion.cc +++ b/src/3rdparty/double-conversion/double-conversion.cc @@ -535,22 +535,10 @@ static double SignedZero(bool sign) { // Returns true if 'c' is a decimal digit that is valid for the given radix. -// -// The function is small and could be inlined, but VS2012 emitted a warning -// because it constant-propagated the radix and concluded that the last -// condition was always true. By moving it into a separate function the -// compiler wouldn't warn anymore. -#ifdef _MSC_VER -#pragma optimize("",off) -static bool IsDecimalDigitForRadix(int c, int radix) { - return '0' <= c && c <= '9' && (c - '0') < radix; -} -#pragma optimize("",on) -#else static bool inline IsDecimalDigitForRadix(int c, int radix) { return '0' <= c && c <= '9' && (c - '0') < radix; } -#endif + // Returns true if 'c' is a character digit that is valid for the given radix. // The 'a_character' should be 'a' or 'A'. // -- cgit v1.2.3 From 09f19e48ac2a34ea2df9d19267599e05d64d45c6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Wed, 18 Dec 2019 13:16:20 +0100 Subject: Fix unneeded use of QImage invertPixels and createAlphaMask The result of createAlphaMask was mostly overwritten and then inverted, we can write the right values directly instead. Change-Id: I3cdddcc74218a4058bddd20178733688607c8a01 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/plugins/imageformats/ico/qicohandler.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index c8e31dceac..6515748bf5 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -615,13 +615,7 @@ bool ICOReader::write(QIODevice *device, const QVector<QImage> &images) } QImage maskImage(image.width(), image.height(), QImage::Format_Mono); image = image.convertToFormat(QImage::Format_ARGB32); - - if (image.hasAlphaChannel()) { - maskImage = image.createAlphaMask(); - } else { - maskImage.fill(0xff); - } - maskImage = maskImage.convertToFormat(QImage::Format_Mono); + maskImage.fill(Qt::color1); int nbits = 32; int bpl_bmp = ((image.width()*nbits+31)/32)*4; @@ -671,7 +665,7 @@ bool ICOReader::write(QIODevice *device, const QVector<QImage> &images) *b++ = qRed(*p); *b++ = qAlpha(*p); if (qAlpha(*p) > 0) // Even mostly transparent pixels must not be masked away - maskImage.setPixel(x, y, Qt::color1); // (i.e. createAlphaMask() takes away too much) + maskImage.setPixel(x, y, 0); p++; x++; } @@ -679,7 +673,6 @@ bool ICOReader::write(QIODevice *device, const QVector<QImage> &images) } delete[] buf; - maskImage.invertPixels(); // seems as though it needs this // NOTE! !! The mask is only flipped vertically - not horizontally !! for (y = maskImage.height() - 1; y >= 0; y--) buffer.write((char*)maskImage.scanLine(y), maskImage.bytesPerLine()); -- cgit v1.2.3 From 9a77beaea36bf6c8b44086a15bed0e9903a06944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <torarnv@gmail.com> Date: Wed, 18 Dec 2019 18:01:27 +0100 Subject: macOS: Deliver theme changes synchronously Otherwise the expose event that AppKit triggers will be delivered before we've propagated the theme change, and we fail to draw the UI using the new theme. Change-Id: I502122a2bf02a866d136106d831f0c2a0dfe26f2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/gui/kernel/qwindowsysteminterface.cpp | 4 ++-- src/gui/kernel/qwindowsysteminterface.h | 1 + src/plugins/platforms/cocoa/qcocoatheme.mm | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index ba04f8701d..8457282bed 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -880,10 +880,10 @@ void QWindowSystemInterface::handleScreenRefreshRateChange(QScreen *screen, qrea QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::handleThemeChange(QWindow *window) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleThemeChange, QWindow *window) { QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(window); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } #if QT_CONFIG(draganddrop) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index d5a4ad30d8..95e20f0f8b 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -249,6 +249,7 @@ public: static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY); static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleThemeChange(QWindow *window); static void handleFileOpenEvent(const QString& fileName); diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 7c10456824..387df65721 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -129,7 +129,7 @@ void QCocoaTheme::handleSystemThemeChange() QFontCache::instance()->clear(); } - QWindowSystemInterface::handleThemeChange(nullptr); + QWindowSystemInterface::handleThemeChange<QWindowSystemInterface::SynchronousDelivery>(nullptr); } bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const -- cgit v1.2.3 From b31aef2900478ef463c65dff5a3ea92b8fc047d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= <cristian.maureira-fredes@qt.io> Date: Fri, 13 Dec 2019 16:03:50 +0100 Subject: uic: Rename raise() to raise_() for Python Fixes: QTBUG-80791 Change-Id: Ia6339b8c683147456cdffa7f2d45972e8eacd92c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/tools/uic/cpp/cppwriteinitialization.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 0349061089..570a61a1f1 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -824,8 +824,8 @@ void WriteInitialization::acceptWidget(DomWidget *node) qPrintable(m_option.messagePrefix()), name.toLatin1().data()); } else { - m_output << m_indent << varName << language::derefPointer << "raise()" - << language::eol; + m_output << m_indent << varName << language::derefPointer + << (language::language() != Language::Python ? "raise()" : "raise_()") << language::eol; } } } -- cgit v1.2.3 From 0f0d26418c185fe9e4c01049d165ac5548305354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> Date: Thu, 19 Dec 2019 13:51:56 +0100 Subject: High-DPI: restore rounding behavior on Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt 5.14 introduced QApplication::scaleFactorRoundingPolicy, where the default policy rounds the scale factor to an integer, which matches Qt's behavior on Windows and X11. However, Qt has never rounded scale factors on Android. Restore the historical behavior and document the platform difference. Change-Id: I0f8e8fb65e3874338ea290bbb12da350da22f099 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/kernel/qguiapplication.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 7adba40fbd..6678b5f0ce 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -148,7 +148,13 @@ QString QGuiApplicationPrivate::styleOverride; Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = +#ifdef Q_OS_ANDROID + // On Android, Qt has newer rounded the scale factor. Preserve + // that behavior by disabling rounding by default. + Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; +#else Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; +#endif bool QGuiApplicationPrivate::highDpiScalingUpdated = false; QPointer<QWindow> QGuiApplicationPrivate::currentDragWindow; @@ -3551,6 +3557,8 @@ Qt::ApplicationState QGuiApplication::applicationState() accessor will reflect the environment, if set. The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor. + On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough, + which preserves historical behavior from earlier Qt versions. */ void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy) { -- cgit v1.2.3 From 43792c50d4c8de1c30456666cc9ee1c945d67991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> Date: Thu, 19 Dec 2019 14:05:30 +0100 Subject: =?UTF-8?q?Don=E2=80=99t=20reset=20highDpicaleFactorRoundingPolicy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t reset highDpicaleFactorRoundingPolicy in the QGuiApplication destructior. This is a static property, independent of the application object lifetime. Change-Id: Ibf55e2a6ea1ae6429fce3f0e9d58323111aac374 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/kernel/qguiapplication.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 6678b5f0ce..d49f349e7a 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -695,8 +695,6 @@ QGuiApplication::~QGuiApplication() QGuiApplicationPrivate::lastCursorPosition = {qInf(), qInf()}; QGuiApplicationPrivate::currentMousePressWindow = QGuiApplicationPrivate::currentMouseWindow = nullptr; QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; - QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = - Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; QGuiApplicationPrivate::highDpiScalingUpdated = false; QGuiApplicationPrivate::currentDragWindow = nullptr; QGuiApplicationPrivate::tabletDevicePoints.clear(); -- cgit v1.2.3 From 9d6b4d11424cdcd6c572cdcc50b3b790b6e673c0 Mon Sep 17 00:00:00 2001 From: Jordi Pujol Foyo <jordi@vikingsoftware.com> Date: Fri, 13 Dec 2019 14:27:11 +0100 Subject: New features for QPdfWriter Added new API setDocumentXmpMetadata/documentXmpMetadata and addFileAttachment [ChangeLog][QtGui][QPdfWriter] New API to provide external document XMP metadata and attach files to PDF. Fixes: QTBUG-78651 Fixes: QTBUG-78764 Change-Id: Ic0b37e8d12899f907001db469080594c14c87655 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/painting/qpdf.cpp | 159 ++++++++++++++++++++++++++++++++-------- src/gui/painting/qpdf_p.h | 21 +++++- src/gui/painting/qpdfwriter.cpp | 44 +++++++++++ src/gui/painting/qpdfwriter.h | 5 ++ 4 files changed, 196 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 932c3e6f5a..de9fc13331 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1390,6 +1390,18 @@ void QPdfEngine::setPdfVersion(PdfVersion version) d->pdfVersion = version; } +void QPdfEngine::setDocumentXmpMetadata(const QByteArray &xmpMetadata) +{ + Q_D(QPdfEngine); + d->xmpDocumentMetadata = xmpMetadata; +} + +QByteArray QPdfEngine::documentXmpMetadata() const +{ + Q_D(const QPdfEngine); + return d->xmpDocumentMetadata; +} + void QPdfEngine::setPageLayout(const QPageLayout &pageLayout) { Q_D(QPdfEngine); @@ -1520,6 +1532,8 @@ bool QPdfEngine::begin(QPaintDevice *pdev) d->xrefPositions.clear(); d->pageRoot = 0; + d->embeddedfilesRoot = 0; + d->namesRoot = 0; d->catalog = 0; d->info = 0; d->graphicsState = 0; @@ -1555,10 +1569,18 @@ bool QPdfEngine::end() d->outDevice = nullptr; } + d->fileCache.clear(); + setActive(false); return true; } +void QPdfEngine::addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType) +{ + Q_D(QPdfEngine); + d->fileCache.push_back({fileName, data, mimeType}); +} + QPdfEnginePrivate::~QPdfEnginePrivate() { qDeleteAll(fonts); @@ -1586,13 +1608,19 @@ void QPdfEnginePrivate::writeHeader() int metaDataObj = -1; int outputIntentObj = -1; + if (pdfVersion == QPdfEngine::Version_A1b || !xmpDocumentMetadata.isEmpty()) { + metaDataObj = writeXmpDcumentMetaData(); + } if (pdfVersion == QPdfEngine::Version_A1b) { - metaDataObj = writeXmpMetaData(); outputIntentObj = writeOutputIntent(); } catalog = addXrefEntry(-1); pageRoot = requestObject(); + if (!fileCache.isEmpty()) { + namesRoot = requestObject(); + embeddedfilesRoot = requestObject(); + } // catalog { @@ -1602,10 +1630,15 @@ void QPdfEnginePrivate::writeHeader() << "/Type /Catalog\n" << "/Pages " << pageRoot << "0 R\n"; - if (pdfVersion == QPdfEngine::Version_A1b) { - s << "/OutputIntents [" << outputIntentObj << "0 R]\n"; + // Embedded files, if any + if (!fileCache.isEmpty()) + s << "/Names " << embeddedfilesRoot << "0 R\n"; + + if (pdfVersion == QPdfEngine::Version_A1b || !xmpDocumentMetadata.isEmpty()) s << "/Metadata " << metaDataObj << "0 R\n"; - } + + if (pdfVersion == QPdfEngine::Version_A1b) + s << "/OutputIntents [" << outputIntentObj << "0 R]\n"; s << ">>\n" << "endobj\n"; @@ -1613,6 +1646,12 @@ void QPdfEnginePrivate::writeHeader() write(catalog); } + if (!fileCache.isEmpty()) { + addXrefEntry(embeddedfilesRoot); + xprintf("<</EmbeddedFiles %d 0 R>>\n" + "endobj\n", namesRoot); + } + // graphics state graphicsState = addXrefEntry(-1); xprintf("<<\n" @@ -1664,39 +1703,45 @@ void QPdfEnginePrivate::writeInfo() "endobj\n"); } -int QPdfEnginePrivate::writeXmpMetaData() +int QPdfEnginePrivate::writeXmpDcumentMetaData() { const int metaDataObj = addXrefEntry(-1); + QByteArray metaDataContent; + + if (xmpDocumentMetadata.isEmpty()) { + const QString producer(QString::fromLatin1("Qt " QT_VERSION_STR)); + + const QDateTime now = QDateTime::currentDateTime(); + const QDate date = now.date(); + const QTime time = now.time(); + const QString timeStr = + QString::asprintf("%d-%02d-%02dT%02d:%02d:%02d", + date.year(), date.month(), date.day(), + time.hour(), time.minute(), time.second()); + + const int offset = now.offsetFromUtc(); + const int hours = (offset / 60) / 60; + const int mins = (offset / 60) % 60; + QString tzStr; + if (offset < 0) + tzStr = QString::asprintf("-%02d:%02d", -hours, -mins); + else if (offset > 0) + tzStr = QString::asprintf("+%02d:%02d", hours , mins); + else + tzStr = QLatin1String("Z"); - const QString producer(QString::fromLatin1("Qt " QT_VERSION_STR)); - - const QDateTime now = QDateTime::currentDateTime(); - const QDate date = now.date(); - const QTime time = now.time(); - const QString timeStr = - QString::asprintf("%d-%02d-%02dT%02d:%02d:%02d", - date.year(), date.month(), date.day(), - time.hour(), time.minute(), time.second()); + const QString metaDataDate = timeStr + tzStr; - const int offset = now.offsetFromUtc(); - const int hours = (offset / 60) / 60; - const int mins = (offset / 60) % 60; - QString tzStr; - if (offset < 0) - tzStr = QString::asprintf("-%02d:%02d", -hours, -mins); - else if (offset > 0) - tzStr = QString::asprintf("+%02d:%02d", hours , mins); + QFile metaDataFile(QLatin1String(":/qpdf/qpdfa_metadata.xml")); + metaDataFile.open(QIODevice::ReadOnly); + metaDataContent = QString::fromUtf8(metaDataFile.readAll()).arg(producer.toHtmlEscaped(), + title.toHtmlEscaped(), + creator.toHtmlEscaped(), + metaDataDate).toUtf8(); + } else - tzStr = QLatin1String("Z"); + metaDataContent = xmpDocumentMetadata; - const QString metaDataDate = timeStr + tzStr; - - QFile metaDataFile(QLatin1String(":/qpdf/qpdfa_metadata.xml")); - metaDataFile.open(QIODevice::ReadOnly); - const QByteArray metaDataContent = QString::fromUtf8(metaDataFile.readAll()).arg(producer.toHtmlEscaped(), - title.toHtmlEscaped(), - creator.toHtmlEscaped(), - metaDataDate).toUtf8(); xprintf("<<\n" "/Type /Metadata /Subtype /XML\n" "/Length %d\n" @@ -1774,6 +1819,56 @@ void QPdfEnginePrivate::writePageRoot() "endobj\n"); } +void QPdfEnginePrivate::writeAttachmentRoot() +{ + if (fileCache.isEmpty()) + return; + + QVector<int> attachments; + const int size = fileCache.size(); + for (int i = 0; i < size; ++i) { + auto attachment = fileCache.at(i); + const int attachmentID = addXrefEntry(-1); + xprintf("<<\n"); + if (do_compress) + xprintf("/Filter /FlateDecode\n"); + + const int lenobj = requestObject(); + xprintf("/Length %d 0 R\n", lenobj); + int len = 0; + xprintf(">>\nstream\n"); + len = writeCompressed(attachment.data); + xprintf("\nendstream\n" + "endobj\n"); + addXrefEntry(lenobj); + xprintf("%d\n" + "endobj\n", len); + + attachments.push_back(addXrefEntry(-1)); + xprintf("<<\n" + "/F (%s)", attachment.fileName.toLatin1().constData()); + + xprintf("\n/EF <</F %d 0 R>>\n" + "/Type/Filespec\n" + , attachmentID); + if (!attachment.mimeType.isEmpty()) + xprintf("/Subtype/%s\n", + attachment.mimeType.replace(QLatin1String("/"), + QLatin1String("#2F")).toLatin1().constData()); + xprintf(">>\nendobj\n"); + } + + // names + addXrefEntry(namesRoot); + xprintf("<</Names["); + for (int i = 0; i < size; ++i) { + auto attachment = fileCache.at(i); + printString(attachment.fileName); + xprintf("%d 0 R\n", attachments.at(i)); + } + xprintf("]>>\n" + "endobj\n"); +} void QPdfEnginePrivate::embedFont(QFontSubset *font) { @@ -2031,6 +2126,8 @@ void QPdfEnginePrivate::writeTail() writePage(); writeFonts(); writePageRoot(); + writeAttachmentRoot(); + addXrefEntry(xrefPositions.size(),false); xprintf("xref\n" "0 %d\n" diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 89e549614a..57d70db442 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -187,6 +187,11 @@ public: void setPdfVersion(PdfVersion version); + void setDocumentXmpMetadata(const QByteArray &xmpMetadata); + QByteArray documentXmpMetadata() const; + + void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType); + // reimplementations QPaintEngine bool begin(QPaintDevice *pdev) override; bool end() override; @@ -297,9 +302,10 @@ private: int createShadingFunction(const QGradient *gradient, int from, int to, bool reflect, bool alpha); void writeInfo(); - int writeXmpMetaData(); + int writeXmpDcumentMetaData(); int writeOutputIntent(); void writePageRoot(); + void writeAttachmentRoot(); void writeFonts(); void embedFont(QFontSubset *font); qreal calcUserUnit() const; @@ -324,11 +330,22 @@ private: inline int writeCompressed(const QByteArray &data) { return writeCompressed(data.constData(), data.length()); } int writeCompressed(QIODevice *dev); + struct AttachmentInfo + { + AttachmentInfo (const QString &fileName, const QByteArray &data, const QString &mimeType) + : fileName(fileName), data(data), mimeType(mimeType) {} + QString fileName; + QByteArray data; + QString mimeType; + }; + // various PDF objects - int pageRoot, catalog, info, graphicsState, patternColorSpace; + int pageRoot, embeddedfilesRoot, namesRoot, catalog, info, graphicsState, patternColorSpace; QVector<uint> pages; QHash<qint64, uint> imageCache; QHash<QPair<uint, uint>, uint > alphaCache; + QVector<AttachmentInfo> fileCache; + QByteArray xmpDocumentMetadata; }; QT_END_NAMESPACE diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 35814d146c..4f70fe6ad2 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -266,6 +266,50 @@ int QPdfWriter::resolution() const return d->engine->resolution(); } +/*! + \since 5.15 + + Sets the document metadata. This metadata is not influenced by the setTitle / setCreator methods, + so is up to the user to keep it consistent. + \a xmpMetadata contains XML formatted metadata to embed into the PDF file. + + \sa documentXmpMetadata() +*/ + +void QPdfWriter::setDocumentXmpMetadata(const QByteArray &xmpMetadata) +{ + Q_D(const QPdfWriter); + d->engine->setDocumentXmpMetadata(xmpMetadata); +} + +/*! + \since 5.15 + + Gets the document metadata, as it was provided with a call to setDocumentXmpMetadata. It will not + return the default metadata. + + \sa setDocumentXmpMetadata() +*/ + +QByteArray QPdfWriter::documentXmpMetadata() const +{ + Q_D(const QPdfWriter); + return d->engine->documentXmpMetadata(); +} + +/*! + \since 5.15 + + Adds \a fileName attachment to the PDF with (optional) \a mimeType + \a data contains the raw file data to embed into the PDF file. +*/ + +void QPdfWriter::addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType) +{ + Q_D(QPdfWriter); + d->engine->addFileAttachment(fileName, data, mimeType); +} + // Defined in QPagedPaintDevice but non-virtual, add QPdfWriter specific doc here #ifdef Q_QDOC /*! diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index 668081e008..04039a0104 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -75,6 +75,11 @@ public: void setResolution(int resolution); int resolution() const; + void setDocumentXmpMetadata(const QByteArray &xmpMetadata); + QByteArray documentXmpMetadata() const; + + void addFileAttachment(const QString &fileName, const QByteArray &data, const QString &mimeType = QString()); + #ifdef Q_QDOC bool setPageLayout(const QPageLayout &pageLayout); bool setPageSize(const QPageSize &pageSize); -- cgit v1.2.3 From 23d4c0c34b37d9d6d94fedd2fc7316c34a66f10d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Wed, 18 Dec 2019 11:25:44 +0100 Subject: Remove some uses of QImage::setAlphaChannel Remove once where it did nothing, and once where using composition mode masking avoids first creating a masking image. Change-Id: Ia4c93eac6ebb11fcdab34d306d943a7f87906b7e Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/widgets/dialogs/qfilesystemmodel.cpp | 5 ++--- src/widgets/effects/qpixmapfilter.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 914c845565..d658f7fe0c 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -948,9 +948,8 @@ QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation, if (section == 0) { // ### TODO oh man this is ugly and doesn't even work all the way! // it is still 2 pixels off - QImage pixmap(16, 1, QImage::Format_Mono); - pixmap.fill(0); - pixmap.setAlphaChannel(pixmap.createAlphaMask()); + QImage pixmap(16, 1, QImage::Format_ARGB32_Premultiplied); + pixmap.fill(Qt::transparent); return pixmap; } break; diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index 637c9c6aba..1f899c2660 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -1135,8 +1135,12 @@ void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const Q destImage = std::move(buffer); } - if (srcImage.hasAlphaChannel()) - destImage.setAlphaChannel(srcImage.alphaChannel()); + if (srcImage.hasAlphaChannel()) { + Q_ASSERT(destImage.format() == QImage::Format_ARGB32_Premultiplied); + QPainter maskPainter(&destImage); + maskPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + maskPainter.drawImage(0, 0, srcImage); + } painter->drawImage(dest, destImage); } -- cgit v1.2.3 From 5034f8d8d5e05dc1a477d5fabe486a0997679b97 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Thu, 19 Dec 2019 09:33:19 -0800 Subject: forkfd: fix build with GCC 4.8 & 4.9 Prior to GCC 5.x, std::atomic_int was a typedef to __atomic_base<int>, which meant we couldn't use it in atomic_compare_exchange that requires pointers to std::atomic<int>. That changed in 5.x (r219790) in response to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940. Easy fix, though. Fixes: QTBUG-80896 Change-Id: I46bf1f65e8db46afbde5fffd15e1d625154f8d59 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> --- src/3rdparty/forkfd/forkfd_c11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty/forkfd/forkfd_c11.h b/src/3rdparty/forkfd/forkfd_c11.h index f3dc2b5357..2b1d3f181e 100644 --- a/src/3rdparty/forkfd/forkfd_c11.h +++ b/src/3rdparty/forkfd/forkfd_c11.h @@ -36,7 +36,7 @@ # define FFD_ATOMIC_ACQUIRE std::memory_order_acquire # define FFD_ATOMIC_RELEASE std::memory_order_release // acq_rel & cst not necessary -typedef std::atomic_int ffd_atomic_int; +typedef std::atomic<int> ffd_atomic_int; #else # include <stdatomic.h> # define ffd_atomic_pointer(type) _Atomic(type*) -- cgit v1.2.3 From a0eb51c3870d90c06966dbfbe26b114f39103b60 Mon Sep 17 00:00:00 2001 From: Federico Guerinoni <guerinoni@micro-systems.it> Date: Fri, 6 Dec 2019 22:41:36 +0100 Subject: QBitArray: Add method to get int value It is useful to use an array of bit as an integer value. I add also a prarameter to set endianness when converting value to UInt32. [ChangeLog][QtCore][QBitArray] Added toUInt32() to return the bit array's value as a uint32_t. Change-Id: I9d8c7a33f11e7ce94cb67aa9a50b11fa42d56168 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/tools/qbitarray.cpp | 34 ++++++++++++++++++++++++++++++++++ src/corelib/tools/qbitarray.h | 2 ++ 2 files changed, 36 insertions(+) (limited to 'src') diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index f0b81cce66..4db0f61599 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -342,6 +342,40 @@ QBitArray QBitArray::fromBits(const char *data, qsizetype size) return result; } +/*! + \since 5.13 + + Returns the array of bit converted to an int. The conversion is based of endianness value. + Converts up to the first 32 bits of the array to \c uint32_t and returns it, + obeying \a endianness. If the array has more than 32 bits, \a ok is set to false + and this function returns zero; otherwise, it's set to true. +*/ +quint32 QBitArray::toUInt32(QSysInfo::Endian endianness, bool *ok) const noexcept +{ + if (size() > 32) { + if (ok != nullptr) { + *ok = false; + } + + return 0; + } + + if (ok != nullptr) { + *ok = true; + } + + auto factor = 1; + quint32 total = 0; + for (auto i = 0; i < size(); ++i, factor *= 2) { + const auto index = endianness == QSysInfo::Endian::LittleEndian ? i : (size() - i - 1); + if (testBit(index)) { + total += factor; + } + } + + return total; +} + /*! \fn bool QBitArray::isDetached() const \internal diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h index 4ea613a442..ac3a8771d9 100644 --- a/src/corelib/tools/qbitarray.h +++ b/src/corelib/tools/qbitarray.h @@ -105,6 +105,8 @@ public: const char *bits() const { return isEmpty() ? nullptr : d.constData() + 1; } static QBitArray fromBits(const char *data, qsizetype len); + quint32 toUInt32(QSysInfo::Endian endianness, bool *ok = nullptr) const noexcept; + public: typedef QByteArray::DataPointer DataPtr; inline DataPtr &data_ptr() { return d.data_ptr(); } -- cgit v1.2.3 From c24404dbda48bd4f9d6ceb4777fced7b164345fd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 19 Dec 2019 10:10:43 +0100 Subject: Unbreak developer build with clang-cl Move the macro definitions for Q_DECL_UNUSED_MEMBER along with a definition for Q_DECL_UNUSED from the scope excluding icc and cl into a separate one for plain clang and cl since the attributes work with clang-cl as well. Remove the check introduced in 9782938045c33b37fe0bbb6cdf00e406cd3d837e since it is assumed that all clang versions have the attribute now. Fixes: include\QtCore/../../src/corelib/io/qloggingcategory.h(87,32): error: private field 'd' is not used [-Werror,-Wunused-private-field] Q_DECL_UNUSED_MEMBER void *d; // reserved for future use ^ include\QtCore/../../src/corelib/io/qloggingcategory.h(108,31): error: private field 'placeholder' is not used [-Werror,-Wunused-private-field] Q_DECL_UNUSED_MEMBER bool placeholder[4]; // reserved for future use Task-number: QTBUG-63512 Change-Id: I651771b085408443bb02e96698a980170fcaeb6d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qcompilerdetection.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 60dc7ce688..0091cfcb60 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -828,13 +828,14 @@ # endif # endif -# if defined(__has_warning) -# if __has_warning("-Wunused-private-field") -# define Q_DECL_UNUSED_MEMBER Q_DECL_UNUSED -# endif -# endif +#endif // Q_CC_CLANG && !Q_CC_INTEL && !Q_CC_MSVC -#endif // Q_CC_CLANG +#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) +# ifndef Q_DECL_UNUSED +# define Q_DECL_UNUSED __attribute__((__unused__)) +# endif +# define Q_DECL_UNUSED_MEMBER Q_DECL_UNUSED +#endif #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) # define Q_COMPILER_RESTRICTED_VLA -- cgit v1.2.3 From 556712f511a02ff8101e648d2e6f0090231d4f3d Mon Sep 17 00:00:00 2001 From: Jordi Pujol Foyo <jordi@vikingsoftware.com> Date: Wed, 6 Mar 2019 16:46:21 +0100 Subject: Allow hiding tabs in QTabWidget / QTabBar Add 2 methods to set/ask if a tab is hidden. [ChangeLog][QtWidgets][QTabWidget/QTabBar] Tabs can now be hidden with setTabVisible Fixes: QTBUG-63038 Change-Id: I7b07ecdb485e1f6c085d03515ef2b73baae889de Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/widgets/qtabbar.cpp | 172 ++++++++++++++++++++++++++++++++----- src/widgets/widgets/qtabbar.h | 3 + src/widgets/widgets/qtabbar_p.h | 9 +- src/widgets/widgets/qtabwidget.cpp | 50 ++++++++++- src/widgets/widgets/qtabwidget.h | 3 + 5 files changed, 212 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 4e75cca704..aff95b0931 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -207,8 +207,8 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) else option->selectedPosition = QStyleOptionTab::NotAdjacent; - const bool paintBeginning = (tabIndex == 0) || (dragInProgress && tabIndex == pressedIndex + 1); - const bool paintEnd = (tabIndex == totalTabs - 1) || (dragInProgress && tabIndex == pressedIndex - 1); + const bool paintBeginning = (tabIndex == firstVisible) || (dragInProgress && tabIndex == pressedIndex + 1); + const bool paintEnd = (tabIndex == lastVisible - 1) || (dragInProgress && tabIndex == pressedIndex - 1); if (paintBeginning) { if (paintEnd) option->position = QStyleOptionTab::OnlyOneTab; @@ -459,6 +459,7 @@ void QTabBarPrivate::layoutTabs() int i; bool vertTabs = verticalTabs(shape); int tabChainIndex = 0; + int hiddenTabs = 0; Qt::Alignment tabAlignment = Qt::Alignment(q->style()->styleHint(QStyle::SH_TabBar_Alignment, nullptr, q)); QVector<QLayoutStruct> tabChain(tabList.count() + 2); @@ -484,7 +485,11 @@ void QTabBarPrivate::layoutTabs() int minx = 0; int x = 0; int maxHeight = 0; - for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) { + for (i = 0; i < tabList.count(); ++i) { + if (!tabList.at(i).visible) { + ++hiddenTabs; + continue; + } QSize sz = q->tabSizeHint(i); tabList[i].maxRect = QRect(x, 0, sz.width(), sz.height()); x += sz.width(); @@ -500,6 +505,7 @@ void QTabBarPrivate::layoutTabs() if (!expanding) tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint; + ++tabChainIndex; } last = minx; @@ -509,7 +515,11 @@ void QTabBarPrivate::layoutTabs() int miny = 0; int y = 0; int maxWidth = 0; - for (i = 0; i < tabList.count(); ++i, ++tabChainIndex) { + for (i = 0; i < tabList.count(); ++i) { + if (!tabList.at(i).visible) { + ++hiddenTabs; + continue; + } QSize sz = q->tabSizeHint(i); tabList[i].maxRect = QRect(0, y, sz.width(), sz.height()); y += sz.height(); @@ -525,6 +535,7 @@ void QTabBarPrivate::layoutTabs() if (!expanding) tabChain[tabChainIndex].maximumSize = tabChain[tabChainIndex].sizeHint; + ++tabChainIndex; } last = miny; @@ -538,14 +549,20 @@ void QTabBarPrivate::layoutTabs() && (tabAlignment != Qt::AlignRight) && (tabAlignment != Qt::AlignJustify); tabChain[tabChainIndex].empty = true; - Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure. + Q_ASSERT(tabChainIndex == tabChain.count() - 1 - hiddenTabs); // add an assert just to make sure. // Do the calculation qGeomCalc(tabChain, 0, tabChain.count(), 0, qMax(available, last), 0); // Use the results + hiddenTabs = 0; for (i = 0; i < tabList.count(); ++i) { - const QLayoutStruct &lstruct = tabChain.at(i + 1); + if (!tabList.at(i).visible) { + tabList[i].rect = QRect(); + ++hiddenTabs; + continue; + } + const QLayoutStruct &lstruct = tabChain.at(i + 1 - hiddenTabs); if (!vertTabs) tabList[i].rect.setRect(lstruct.pos, 0, lstruct.size, maxExtent); else @@ -975,11 +992,15 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) #ifndef QT_NO_SHORTCUT d->tabList[index].shortcutId = grabShortcut(QKeySequence::mnemonic(text)); #endif + d->firstVisible = qMax(qMin(index, d->firstVisible), 0); + d->lastVisible = qMax(index, d->lastVisible); d->refresh(); if (d->tabList.count() == 1) setCurrentIndex(index); - else if (index <= d->currentIndex) + else if (index <= d->currentIndex) { ++d->currentIndex; + ++d->lastVisible; + } if (d->closeButtonOnTabs) { QStyleOptionTab opt; @@ -1035,6 +1056,9 @@ void QTabBar::removeTab(int index) if (d->tabList[i].lastTab > index) --d->tabList[i].lastTab; } + + d->calculateFirstLastVisible(index, false, true); + if (index == d->currentIndex) { // The current tab is going away, in order to make sure // we emit that "current has changed", we need to reset this @@ -1045,16 +1069,14 @@ void QTabBar::removeTab(int index) case SelectPreviousTab: if (newIndex > index) newIndex--; - if (d->validIndex(newIndex)) + if (d->validIndex(newIndex) && d->tabList.at(newIndex).visible) break; Q_FALLTHROUGH(); case SelectRightTab: - newIndex = index; - if (newIndex >= d->tabList.size()) - newIndex = d->tabList.size() - 1; + newIndex = qBound(d->firstVisible, index, d->lastVisible); break; case SelectLeftTab: - newIndex = index - 1; + newIndex = qBound(d->firstVisible, index-1, d->lastVisible); if (newIndex < 0) newIndex = 0; break; @@ -1118,9 +1140,52 @@ void QTabBar::setTabEnabled(int index, bool enabled) #endif update(); if (!enabled && index == d->currentIndex) - setCurrentIndex(d->validIndex(index+1)?index+1:0); - else if (enabled && !d->validIndex(d->currentIndex)) - setCurrentIndex(index); + setCurrentIndex(d->selectNewCurrentIndexFrom(index+1)); + else if (enabled && !isTabVisible(d->currentIndex)) + setCurrentIndex(d->selectNewCurrentIndexFrom(index)); + } +} + + +/*! + Returns true if the tab at position \a index is visible; otherwise + returns false. + \since 5.15 +*/ +bool QTabBar::isTabVisible(int index) const +{ + Q_D(const QTabBar); + if (d->validIndex(index)) + return d->tabList.at(index).visible; + return false; +} + +/*! + If \a visible is true, make the tab at position \a index visible, + otherwise make it hidden. + \since 5.15 +*/ +void QTabBar::setTabVisible(int index, bool visible) +{ + Q_D(QTabBar); + if (QTabBarPrivate::Tab *tab = d->at(index)) { + d->layoutDirty = (visible != tab->visible); + if (!d->layoutDirty) + return; + tab->visible = visible; + if (tab->leftWidget) + tab->leftWidget->setVisible(visible); + if (tab->rightWidget) + tab->rightWidget->setVisible(visible); +#ifndef QT_NO_SHORTCUT + setShortcutEnabled(tab->shortcutId, visible); +#endif + d->calculateFirstLastVisible(index, visible, false); + if (!visible && index == d->currentIndex) { + const int newindex = d->selectNewCurrentIndexFrom(index+1); + setCurrentIndex(newindex); + } + update(); } } @@ -1291,7 +1356,7 @@ QVariant QTabBar::tabData(int index) const /*! Returns the visual rectangle of the tab at position \a - index, or a null rectangle if \a index is out of range. + index, or a null rectangle if \a index is hidden, or out of range. */ QRect QTabBar::tabRect(int index) const { @@ -1299,6 +1364,8 @@ QRect QTabBar::tabRect(int index) const if (const QTabBarPrivate::Tab *tab = d->at(index)) { if (d->layoutDirty) const_cast<QTabBarPrivate*>(d)->layoutTabs(); + if (!tab->visible) + return QRect(); QRect r = tab->rect; if (verticalTabs(d->shape)) r.translate(0, -d->scrollOffset); @@ -1429,8 +1496,10 @@ QSize QTabBar::sizeHint() const if (d->layoutDirty) const_cast<QTabBarPrivate*>(d)->layoutTabs(); QRect r; - for (int i = 0; i < d->tabList.count(); ++i) - r = r.united(d->tabList.at(i).maxRect); + for (int i = 0; i < d->tabList.count(); ++i) { + if (d->tabList.at(i).visible) + r = r.united(d->tabList.at(i).maxRect); + } QSize sz = QApplication::globalStrut(); return r.size().expandedTo(sz); } @@ -1444,8 +1513,10 @@ QSize QTabBar::minimumSizeHint() const const_cast<QTabBarPrivate*>(d)->layoutTabs(); if (!d->useScrollButtons) { QRect r; - for (int i = 0; i < d->tabList.count(); ++i) - r = r.united(d->tabList.at(i).minRect); + for (int i = 0; i < d->tabList.count(); ++i) { + if (d->tabList.at(i).visible) + r = r.united(d->tabList.at(i).minRect); + } return r.size().expandedTo(QApplication::globalStrut()); } if (verticalTabs(d->shape)) @@ -1746,6 +1817,8 @@ void QTabBar::paintEvent(QPaintEvent *) p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase); for (int i = 0; i < d->tabList.count(); ++i) { + if (!d->at(i)->visible) + continue; QStyleOptionTab tab; initStyleOption(&tab, i); if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) { @@ -1819,6 +1892,65 @@ void QTabBar::paintEvent(QPaintEvent *) } } +/* + When index changes visibility, we have to find first & last visible indexes. + If remove is set, we force both + */ +void QTabBarPrivate::calculateFirstLastVisible(int index, bool visible, bool remove) +{ + if (visible) { + firstVisible = qMin(index, firstVisible); + lastVisible = qMax(index, lastVisible); + } else { + if (remove || (index == firstVisible)) { + firstVisible = -1; + for (int i = 0; i < tabList.count(); ++i) { + if (tabList.at(i).visible) { + firstVisible = i; + break; + } + } + if (firstVisible < 0) + firstVisible = 0; + } + if (remove || (index == lastVisible)) { + lastVisible = -1; + for (int i = tabList.count() - 1; i >= 0; --i) { + if (tabList.at(i).visible) { + lastVisible = i; + break; + } + } + } + } +} + +/* + Selects the new current index starting at "fromIndex". If "fromIndex" is visible we're done. + Else it tries any index AFTER fromIndex, then any BEFORE fromIndex and, if everything fails, + it returns -1 indicating that no index is available + */ +int QTabBarPrivate::selectNewCurrentIndexFrom(int fromIndex) +{ + int newindex = -1; + for (int i = fromIndex; i < tabList.count(); ++i) { + if (at(i)->visible && at(i)->enabled) { + newindex = i; + break; + } + } + if (newindex < 0) { + for (int i = fromIndex-1; i > -1; --i) { + if (at(i)->visible && at(i)->enabled) { + newindex = i; + break; + } + } + } + + return newindex; +} + /* Given that index at position from moved to position to where return where index goes. */ diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h index fc619355f0..c49c12f38c 100644 --- a/src/widgets/widgets/qtabbar.h +++ b/src/widgets/widgets/qtabbar.h @@ -105,6 +105,9 @@ public: bool isTabEnabled(int index) const; void setTabEnabled(int index, bool); + bool isTabVisible(int index) const; + void setTabVisible(int index, bool); + QString tabText(int index) const; void setTabText(int index, const QString &text); diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 6f77579108..ac4cbd32a8 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -88,7 +88,7 @@ class Q_WIDGETS_EXPORT QTabBarPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QTabBar) public: QTabBarPrivate() - :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), + :currentIndex(-1), pressedIndex(-1), firstVisible(0), lastVisible(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), drawBase(true), scrollOffset(0), hoverIndex(-1), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false), @@ -97,6 +97,8 @@ public: int currentIndex; int pressedIndex; + int firstVisible; + int lastVisible; QTabBar::Shape shape; bool layoutDirty; bool drawBase; @@ -104,7 +106,7 @@ public: struct Tab { inline Tab(const QIcon &ico, const QString &txt) - : enabled(true) , shortcutId(0), text(txt), icon(ico), + : enabled(true) , visible(true), shortcutId(0), text(txt), icon(ico), leftWidget(nullptr), rightWidget(nullptr), lastTab(-1), dragOffset(0) #if QT_CONFIG(animation) , animation(nullptr) @@ -112,6 +114,7 @@ public: {} bool operator==(const Tab &other) const { return &other == this; } bool enabled; + bool visible; int shortcutId; QString text; #ifndef QT_NO_TOOLTIP @@ -170,6 +173,8 @@ public: QList<Tab> tabList; mutable QHash<QString, QSize> textSizes; + void calculateFirstLastVisible(int index, bool visible, bool remove); + int selectNewCurrentIndexFrom(int currentIndex); int calculateNewPosition(int from, int to, int index) const; void slide(int from, int to); void init(); diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index 28c91a89e7..5b3dcfa45b 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -544,8 +544,8 @@ bool QTabWidget::isTabEnabled(int index) const } /*! - If \a enable is true, the page at position \a index is enabled; otherwise the page at position \a index is - disabled. The page's tab is redrawn appropriately. + If \a enable is true, the page at position \a index is enabled; otherwise the page at + position \a index is disabled. The page's tab is redrawn appropriately. QTabWidget uses QWidget::setEnabled() internally, rather than keeping a separate flag. @@ -565,6 +565,44 @@ void QTabWidget::setTabEnabled(int index, bool enable) widget->setEnabled(enable); } +/*! + Returns true if the page at position \a index is visible; otherwise returns false. + + \sa setTabVisible() + \since 5.15 +*/ + +bool QTabWidget::isTabVisible(int index) const +{ + Q_D(const QTabWidget); + return d->tabs->isTabVisible(index); +} + +/*! + If \a enable is true, the page at position \a index is visible; otherwise the page at + position \a index is hidden. The page's tab is redrawn appropriately. + + \sa isTabVisible() + \since 5.15 +*/ + +void QTabWidget::setTabVisible(int index, bool visible) +{ + Q_D(QTabWidget); + QWidget *widget = d->stack->widget(index); + bool currentVisible = d->tabs->isTabVisible(d->tabs->currentIndex()); + d->tabs->setTabVisible(index, visible); + if (!visible) { + if (widget) + widget->setVisible(false); + } else if (!currentVisible) { + setCurrentIndex(index); + if (widget) + widget->setVisible(true); + } + setUpLayout(); +} + /*! \fn void QTabWidget::setCornerWidget(QWidget *widget, Qt::Corner corner) @@ -848,7 +886,13 @@ QSize QTabWidget::sizeHint() const QTabWidget *that = const_cast<QTabWidget*>(this); that->setUpLayout(true); } - QSize s(d->stack->sizeHint()); + QSize s; + for (int i=0; i< d->stack->count(); ++i) { + if (const QWidget* w = d->stack->widget(i)) { + if (d->tabs->isTabVisible(i)) + s = s.expandedTo(w->sizeHint()); + } + } QSize t; if (!d->isAutoHidden()) { t = d->tabs->sizeHint(); diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h index f55e71488b..e6b3f93303 100644 --- a/src/widgets/widgets/qtabwidget.h +++ b/src/widgets/widgets/qtabwidget.h @@ -82,6 +82,9 @@ public: bool isTabEnabled(int index) const; void setTabEnabled(int index, bool); + bool isTabVisible(int index) const; + void setTabVisible(int index, bool); + QString tabText(int index) const; void setTabText(int index, const QString &); -- cgit v1.2.3 From a2ddd96ac8b7657c2ef64f2a8f51db5cd8a8d96a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Wed, 18 Dec 2019 20:23:11 +0100 Subject: Introduce QString(View)::isValidUtf16 QString(View)s can be built or manipulated in ways that make them contain/refer to improperly encoded UTF-16 data. Problem is, we don't have public APIs to check whether a string contains valid UTF-16. This knowledge is precious if the string is to be fed in algorithms, regular expressions, etc. that expect validated input (e.g. QRegularExpression can be faster if it can assume valid UTF-16, otherwise it has to employ extra checks). Add a function that does the validation. [ChangeLog][QtCore][QStringView] Added QStringView::isValidUtf16. [ChangeLog][QtCore][QString] Added QString::isValidUtf16. Change-Id: Idd699183f6ec08013046c76c6a5a7c524b6c6fbc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qstring.cpp | 29 +++++++++++++++++++++++++++++ src/corelib/text/qstring.h | 2 ++ src/corelib/text/qstringalgorithms.h | 1 + src/corelib/text/qstringview.cpp | 15 +++++++++++++++ src/corelib/text/qstringview.h | 2 ++ 5 files changed, 49 insertions(+) (limited to 'src') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 4d83f19db7..82b2c10a93 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -591,6 +591,20 @@ bool QtPrivate::isLatin1(QStringView s) noexcept return true; } +bool QtPrivate::isValidUtf16(QStringView s) noexcept +{ + Q_CONSTEXPR uint InvalidCodePoint = UINT_MAX; + + QStringIterator i(s); + while (i.hasNext()) { + uint c = i.next(InvalidCodePoint); + if (c == InvalidCodePoint) + return false; + } + + return true; +} + // conversion between Latin 1 and UTF-16 void qt_from_latin1(ushort *dst, const char *str, size_t size) noexcept { @@ -9046,6 +9060,21 @@ bool QString::isRightToLeft() const return QtPrivate::isRightToLeft(QStringView(*this)); } +/*! + \fn bool QString::isValidUtf16() const noexcept + \since 5.15 + + Returns \c true if the string contains valid UTF-16 encoded data, + or \c false otherwise. + + Note that this function does not perform any special validation of the + data; it merely checks if it can be successfully decoded from UTF-16. + The data is assumed to be in host byte order; the presence of a BOM + is meaningless. + + \sa QStringView::isValidUtf16() +*/ + /*! \fn QChar *QString::data() Returns a pointer to the data stored in the QString. The pointer diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 1669d7c94a..1f4e856660 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -919,6 +919,8 @@ public: bool isSimpleText() const; bool isRightToLeft() const; + Q_REQUIRED_RESULT bool isValidUtf16() const noexcept + { return QStringView(*this).isValidUtf16(); } QString(int size, Qt::Initialization); Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {} diff --git a/src/corelib/text/qstringalgorithms.h b/src/corelib/text/qstringalgorithms.h index d54e376aa9..0b7774b4f3 100644 --- a/src/corelib/text/qstringalgorithms.h +++ b/src/corelib/text/qstringalgorithms.h @@ -99,6 +99,7 @@ Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QStringView s) noexcept; Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline bool isLatin1(QLatin1String s) noexcept; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLatin1(QStringView s) noexcept; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept; } // namespace QtPRivate diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index 75de827583..c4ddb06ea4 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -864,6 +864,21 @@ QT_BEGIN_NAMESPACE \sa QString::isRightToLeft() */ +/*! + \fn bool QStringView::isValidUtf16() const + \since 5.15 + + Returns \c true if the string contains valid UTF-16 encoded data, + or \c false otherwise. + + Note that this function does not perform any special validation of the + data; it merely checks if it can be successfully decoded from UTF-16. + The data is assumed to be in host byte order; the presence of a BOM + is meaningless. + + \sa QString::isValidUtf16() +*/ + /*! \fn QStringView::toWCharArray(wchar_t *array) const \since 5.14 diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 4ab4d2570f..06391ffef4 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -294,6 +294,8 @@ public: Q_REQUIRED_RESULT bool isRightToLeft() const noexcept { return QtPrivate::isRightToLeft(*this); } + Q_REQUIRED_RESULT bool isValidUtf16() const noexcept + { return QtPrivate::isValidUtf16(*this); } Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h -- cgit v1.2.3 From c7ecff04609dd7d9282fa5de3d5d1e1fd189b4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <torarnv@gmail.com> Date: Thu, 19 Dec 2019 12:28:33 +0100 Subject: Simplify QApplication::palette Change-Id: I1f1be554a72a385985eeee0b79b49acdfcf40d8e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 9b1202c491..a74b45f377 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1354,15 +1354,14 @@ QPalette QApplication::palette(const QWidget* w) */ QPalette QApplication::palette(const char *className) { - if (!QApplicationPrivate::app_pal) - palette(); PaletteHash *hash = app_palettes(); if (className && hash && hash->size()) { QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className); if (it != hash->constEnd()) return *it; } - return *QApplicationPrivate::app_pal; + + return QGuiApplication::palette(); } void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash) -- cgit v1.2.3 From 761025d08c32f3dddbd2d32f00b71f6411dd40ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <torarnv@gmail.com> Date: Thu, 19 Dec 2019 12:28:46 +0100 Subject: Contain Qt::AA_SetPalette logic in QApplicationPrivate::setPalette_helper Change-Id: I88b36e800139389895ecb1a15553207a24b3e3a4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index a74b45f377..bf3cf090ba 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1380,6 +1380,10 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* QApplicationPrivate::app_pal = new QPalette(pal); else *QApplicationPrivate::app_pal = pal; + + if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal)) + QCoreApplication::setAttribute(Qt::AA_SetPalette); + if (hash && hash->size()) { all = true; if (clearWidgetPaletteHash) @@ -1389,9 +1393,6 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* hash->insert(className, pal); } - if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) - QCoreApplication::setAttribute(Qt::AA_SetPalette); - if (qApp) qApp->d_func()->sendApplicationPaletteChange(all, className); } -- cgit v1.2.3 From 7e7f76bc553fc29858262ec1946ef413adfad718 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Fri, 20 Dec 2019 13:39:24 +0100 Subject: QMacStyle: fix tab widget's tab bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alas, this thing strikes back: I have to use clip to remove the part of NSBox coming through the transparent buttons, but this works (as I've noticed recently) only for 'North' and 'West' tab positions. For 'South' and 'East' different geomety adjustments are required. Change-Id: Id1f77bc1869e82e710132a2f4402cc3c8be3ab01 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/styles/mac/qmacstyle_mac.mm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 93d2681fd8..5aa7befb84 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -236,6 +236,18 @@ static QLinearGradient titlebarGradientInactive() } #if QT_CONFIG(tabwidget) +/* + Since macOS 10.14 AppKit is using transparency more extensively, especially for the + dark theme. Inactive buttons, for example, are semi-transparent. And we use them to + draw tab widget's tab bar. The combination of NSBox (also a part of tab widget) + and these transparent buttons gives us an undesired side-effect: an outline of + NSBox is visible through transparent buttons. To avoid this, we have this hack below: + we clip the area where the line would be visible through the buttons. The area we + want to clip away can be described as an intersection of the option's rect and + the tab widget's tab bar rect. But some adjustments are required, since those rects + are anyway adjusted during the rendering and they are not exactly what you'll see on + the screen. Thus this switch-statement inside. +*/ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextRef ctx) { Q_ASSERT(option); @@ -246,7 +258,19 @@ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, QTabWidget *tabWidget = qobject_cast<QTabWidget *>(option->styleObject); Q_ASSERT(tabWidget); - const QRect tabBarRect = style->subElementRect(QStyle::SE_TabWidgetTabBar, option, tabWidget).adjusted(2, 2, -3, -2); + QRect tabBarRect = style->subElementRect(QStyle::SE_TabWidgetTabBar, option, tabWidget).adjusted(2, 0, -3, 0); + switch (tabWidget->tabPosition()) { + case QTabWidget::South: + tabBarRect.setY(tabBarRect.y() + tabBarRect.height() / 2); + break; + case QTabWidget::North: + case QTabWidget::West: + tabBarRect = tabBarRect.adjusted(0, 2, 0, -2); + break; + case QTabWidget::East: + tabBarRect = tabBarRect.adjusted(tabBarRect.width() / 2, 2, tabBarRect.width() / 2, -2); + } + const QRegion clipPath = QRegion(option->rect) - tabBarRect; QVarLengthArray<CGRect, 3> cgRects; for (const QRect &qtRect : clipPath) -- cgit v1.2.3 From 7ac4e55cb979dff890f1575e771e5f2def9e3131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 20 Dec 2019 16:46:24 +0100 Subject: macOS Don't throw away backingstore buffers when backing properties change Clients such as QtWidgets that do their own dirty tracking will assume they can just flush in response to the expose event, without repainting anything. Since we have no way at the moment to inform these clients that the backingstore content might be invalid we can't just throw it away. It turns out that to pick up changes in color spaces we can just tag the existing buffers with the new color space, so we don't need to throw it away. And for the older surface-backed mode we tag the color space on flush, so we didn't need to invalidate anything in the first place. Fixes: QTBUG-80844 Task-number: QTBUG-77749 Change-Id: Icb1ceb178894bb43887cdf03fb855d2d614b5ab0 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qcocoabackingstore.h | 6 ++-- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 36 ++++++++++------------ src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 ++ .../platforms/cocoa/qiosurfacegraphicsbuffer.h | 4 ++- .../platforms/cocoa/qiosurfacegraphicsbuffer.mm | 14 +++++---- 5 files changed, 32 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index a874936ce6..b57deacb57 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -54,8 +54,6 @@ class QCocoaBackingStore : public QRasterBackingStore protected: QCocoaBackingStore(QWindow *window); QCFType<CGColorSpaceRef> colorSpace() const; - QMacNotificationObserver m_backingPropertiesObserver; - virtual void backingPropertiesChanged() = 0; }; class QNSWindowBackingStore : public QCocoaBackingStore @@ -71,7 +69,6 @@ private: bool windowHasUnifiedToolbar() const; QImage::Format format() const override; void redrawRoundedBottomCorners(CGRect) const; - void backingPropertiesChanged() override; }; class QCALayerBackingStore : public QCocoaBackingStore @@ -118,7 +115,8 @@ private: bool recreateBackBufferIfNeeded(); bool prepareForFlush(); - void backingPropertiesChanged() override; + void backingPropertiesChanged(); + QMacNotificationObserver m_backingPropertiesObserver; std::list<std::unique_ptr<GraphicsBuffer>> m_buffers; }; diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index b17302a640..8a815a7665 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -51,17 +51,6 @@ QT_BEGIN_NAMESPACE QCocoaBackingStore::QCocoaBackingStore(QWindow *window) : QRasterBackingStore(window) { - // Ideally this would be plumbed from the platform layer to QtGui, and - // the QBackingStore would be recreated, but we don't have that code yet, - // so at least make sure we invalidate our backingstore when the backing - // properties (color space e.g.) are changed. - NSView *view = static_cast<QCocoaWindow *>(window->handle())->view(); - m_backingPropertiesObserver = QMacNotificationObserver(view.window, - NSWindowDidChangeBackingPropertiesNotification, [this]() { - qCDebug(lcQpaBackingStore) << "Backing properties for" - << this->window() << "did change"; - backingPropertiesChanged(); - }); } QCFType<CGColorSpaceRef> QCocoaBackingStore::colorSpace() const @@ -341,11 +330,6 @@ void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const #endif } -void QNSWindowBackingStore::backingPropertiesChanged() -{ - m_image = QImage(); -} - // ---------------------------------------------------------------------------- QCALayerBackingStore::QCALayerBackingStore(QWindow *window) @@ -353,6 +337,18 @@ QCALayerBackingStore::QCALayerBackingStore(QWindow *window) { qCDebug(lcQpaBackingStore) << "Creating QCALayerBackingStore for" << window; m_buffers.resize(1); + + // Ideally this would be plumbed from the platform layer to QtGui, and + // the QBackingStore would be recreated, but we don't have that code yet, + // so at least make sure we update our backingstore when the backing + // properties (color space e.g.) are changed. + NSView *view = static_cast<QCocoaWindow *>(window->handle())->view(); + m_backingPropertiesObserver = QMacNotificationObserver(view.window, + NSWindowDidChangeBackingPropertiesNotification, [this]() { + qCDebug(lcQpaBackingStore) << "Backing properties for" + << this->window() << "did change"; + backingPropertiesChanged(); + }); } QCALayerBackingStore::~QCALayerBackingStore() @@ -620,8 +616,9 @@ QImage QCALayerBackingStore::toImage() const void QCALayerBackingStore::backingPropertiesChanged() { - m_buffers.clear(); - m_buffers.resize(1); + qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers"; + for (auto &buffer : m_buffers) + buffer->setColorSpace(colorSpace()); } QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const @@ -698,10 +695,11 @@ bool QCALayerBackingStore::prepareForFlush() QCALayerBackingStore::GraphicsBuffer::GraphicsBuffer(const QSize &size, qreal devicePixelRatio, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace) - : QIOSurfaceGraphicsBuffer(size, format, colorSpace) + : QIOSurfaceGraphicsBuffer(size, format) , dirtyRegion(0, 0, size.width() / devicePixelRatio, size.height() / devicePixelRatio) , m_devicePixelRatio(devicePixelRatio) { + setColorSpace(colorSpace); } QImage *QCALayerBackingStore::GraphicsBuffer::asImage() diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index b7f15a2bf1..d8c931e9a1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -396,6 +396,8 @@ QVariant QCocoaIntegration::styleHint(StyleHint hint) const return QCoreTextFontEngine::fontSmoothingGamma(); case ShowShortcutsInContextMenus: return QVariant(false); + // case CursorFlashTime: + // return 50000; default: break; } diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h index 872773cb7a..e070ba977d 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h @@ -48,9 +48,11 @@ QT_BEGIN_NAMESPACE class QIOSurfaceGraphicsBuffer : public QPlatformGraphicsBuffer { public: - QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace); + QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format); ~QIOSurfaceGraphicsBuffer(); + void setColorSpace(QCFType<CGColorSpaceRef> colorSpace); + const uchar *data() const override; uchar *data() override; int bytesPerLine() const override; diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm index a367487e85..285e316d4a 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaIOSurface, "qt.qpa.backingstore.iosurface"); -QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType<CGColorSpaceRef> colorSpace) +QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format) : QPlatformGraphicsBuffer(size, format) { const size_t width = size.width(); @@ -81,17 +81,19 @@ QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPix Q_ASSERT(size_t(bytesPerLine()) == bytesPerRow); Q_ASSERT(size_t(byteCount()) == totalBytes); - - if (colorSpace) { - IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), - QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace))); - } } QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer() { } +void QIOSurfaceGraphicsBuffer::setColorSpace(QCFType<CGColorSpaceRef> colorSpace) +{ + Q_ASSERT(colorSpace); + IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), + QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace))); +} + const uchar *QIOSurfaceGraphicsBuffer::data() const { return (const uchar *)IOSurfaceGetBaseAddress(m_surface); -- cgit v1.2.3 From e0b9beb63dead017b6849ebcaa91c04a57f955c6 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 23 Dec 2019 14:41:50 +0100 Subject: QFileInfoGatherer: don't pass empty list to QFileSystemWatcher When an empty list is passed to QFileSystemWatcher::unwatchPaths() a warning is printed out. To avoid this, check if the container is not empty before calling unwatchPaths() Fixes: QTBUG-80965 Change-Id: I23a7946e1e16a8d899abf6cce6b75a6f3662ca0f Reviewed-by: David Faure <david.faure@kdab.com> --- src/widgets/dialogs/qfileinfogatherer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 0beca82f28..7342efbd0d 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -232,7 +232,7 @@ void QFileInfoGatherer::watchPaths(const QStringList &paths) void QFileInfoGatherer::unwatchPaths(const QStringList &paths) { #if QT_CONFIG(filesystemwatcher) - if (m_watcher) + if (m_watcher && !paths.isEmpty()) m_watcher->removePaths(paths); #else Q_UNUSED(paths); -- cgit v1.2.3 From 2ad3348031d8a622374920eac5bdd8fb9ecefcd7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sat, 21 Dec 2019 19:57:45 +0100 Subject: QPrintDialog: don't access dangling pointer when cups is disabled When no cups support is available, ui.pagesRadioButton is destroyed in QPrintDialogPrivate::init() but was accessed later on. Fix it by moving the cups check one line above. Fixes: QTBUG-80945 Change-Id: Ieb062b39e1461f39665ef612dfea1d7757274b7e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/printsupport/dialogs/qprintdialog_unix.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index c7328d9732..7bbf137977 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -637,8 +637,10 @@ void QPrintDialogPrivate::init() options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages)); options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages)); #else - for (int i = options.pagesLayout->count() - 1; i >= 0; --i) - delete options.pagesLayout->itemAt(i)->widget(); + delete options.pagesRadioButton; + delete options.pagesLineEdit; + options.pagesRadioButton = nullptr; + options.pagesLineEdit = nullptr; #endif top->d->setOptionsPane(this); @@ -727,12 +729,12 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma else options.pageSetCombo->setEnabled(true); +#if QT_CONFIG(cups) // Disable complex page ranges widget when printing to pdf // It doesn't work since it relies on cups to do the heavy lifting and cups // is not used when printing to PDF options.pagesRadioButton->setEnabled(outputFormat != QPrinter::PdfFormat); -#if QT_CONFIG(cups) // Disable color options on main dialog if not printing to file, it will be handled by CUPS advanced dialog options.colorMode->setVisible(outputFormat == QPrinter::PdfFormat); #endif -- cgit v1.2.3 From d24a1d4323e73400ef4ecca99e03ff0f41c60389 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Tue, 24 Dec 2019 12:29:53 +0100 Subject: QRegularExpression: improve docs about porting from QRegExp Change-Id: Ie5d737188977b0e4dc1070c2d7329d0ecb6a9308 Reviewed-by: David Faure <david.faure@kdab.com> --- src/corelib/text/qregularexpression.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 8d2187eb28..a02d471134 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -443,6 +443,38 @@ QT_BEGIN_NAMESPACE Other differences are outlined below. + \section2 Different pattern syntax + + Porting a regular expression from QRegExp to QRegularExpression may require + changes to the pattern itself. + + In certain scenarios, QRegExp was too lenient and accepted patterns that + are simply invalid when using QRegularExpression. These are somehow easy + to detect, because the QRegularExpression objects built with these patterns + are not valid (cf. isValid()). + + In other cases, a pattern ported from QRegExp to QRegularExpression may + silently change semantics. Therefore, it is necessary to review the + patterns used. The most notable cases of silent incompatibility are: + + \list + + \li Curly braces are needed in order to use a hexadecimal escape like + \c{\xHHHH} with more than 2 digits. A pattern like \c{\x2022} neeeds to + be ported to \c{\x{2022}}, or it will match a space (\c{0x20}) followed + by the string \c{"22"}. In general, it is highly recommended to always use + curly braces with the \c{\\x} escape, no matter the amount of digits + specified. + + \li A 0-to-n quantification like \c{{,n}} needs to be ported to c{{0,n}} to + preserve semantics. Otherwise, a pattern such as \c{\d{,3}} would + actually match a digit followed by the exact string \c{"{,3}"}. + + \li QRegExp by default does Unicode-aware matching, while + QRegularExpression requires a separate option; see below for more details. + + \endlist + \section2 Porting from QRegExp::exactMatch() QRegExp::exactMatch() in Qt 4 served two purposes: it exactly matched -- cgit v1.2.3 From 25101f0984e86aa30f34773eb5b2025f58086b71 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Sat, 23 Nov 2019 15:04:47 +0100 Subject: Update PCRE2 to 10.34 Also adjust the import script to handle new files. The RTEMS patch is not upstreamed and had to be-reapplied. Change-Id: Ie3102d56a25674b50c67edd3cce25ffe7040a215 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/3rdparty/pcre2/import_from_pcre2_tarball.sh | 2 + src/3rdparty/pcre2/qt_attribution.json | 8 +- src/3rdparty/pcre2/src/pcre2.h | 19 +- src/3rdparty/pcre2/src/pcre2_auto_possess.c | 7 + src/3rdparty/pcre2/src/pcre2_compile.c | 535 +- src/3rdparty/pcre2/src/pcre2_context.c | 2 +- src/3rdparty/pcre2/src/pcre2_dfa_match.c | 129 +- src/3rdparty/pcre2/src/pcre2_error.c | 3 + src/3rdparty/pcre2/src/pcre2_internal.h | 105 +- src/3rdparty/pcre2/src/pcre2_intmodedep.h | 10 +- src/3rdparty/pcre2/src/pcre2_jit_compile.c | 2015 +++---- src/3rdparty/pcre2/src/pcre2_jit_match.c | 1 - src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h | 321 ++ src/3rdparty/pcre2/src/pcre2_jit_simd_inc.h | 993 ++++ src/3rdparty/pcre2/src/pcre2_maketables.c | 11 + src/3rdparty/pcre2/src/pcre2_match.c | 603 ++- src/3rdparty/pcre2/src/pcre2_match_data.c | 15 +- src/3rdparty/pcre2/src/pcre2_study.c | 306 +- src/3rdparty/pcre2/src/pcre2_tables.c | 316 +- src/3rdparty/pcre2/src/pcre2_ucd.c | 5623 ++++++++++---------- src/3rdparty/pcre2/src/pcre2_ucp.h | 7 +- src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h | 4 + src/3rdparty/pcre2/src/sljit/sljitExecAllocator.c | 28 +- src/3rdparty/pcre2/src/sljit/sljitLir.c | 69 +- src/3rdparty/pcre2/src/sljit/sljitLir.h | 22 +- src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c | 126 +- src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c | 111 +- .../pcre2/src/sljit/sljitNativeARM_T2_32.c | 76 +- src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_32.c | 2 + .../pcre2/src/sljit/sljitNativeMIPS_common.c | 155 +- src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c | 2 + src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c | 3 - .../pcre2/src/sljit/sljitNativePPC_common.c | 214 +- src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_32.c | 2 + .../pcre2/src/sljit/sljitNativeSPARC_common.c | 102 +- src/3rdparty/pcre2/src/sljit/sljitNativeX86_32.c | 4 +- src/3rdparty/pcre2/src/sljit/sljitNativeX86_64.c | 54 +- .../pcre2/src/sljit/sljitNativeX86_common.c | 125 +- src/3rdparty/pcre2/src/sljit/sljitUtils.c | 6 + 39 files changed, 7425 insertions(+), 4711 deletions(-) create mode 100644 src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h create mode 100644 src/3rdparty/pcre2/src/pcre2_jit_simd_inc.h (limited to 'src') diff --git a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh index 438efe9535..3ff1335cc6 100755 --- a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh +++ b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh @@ -103,6 +103,8 @@ FILES=" src/pcre2_pattern_info.c src/pcre2_script_run.c src/pcre2_serialize.c + src/pcre2_jit_neon_inc.h + src/pcre2_jit_simd_inc.h src/pcre2_string_utils.c src/pcre2_study.c src/pcre2_substitute.c diff --git a/src/3rdparty/pcre2/qt_attribution.json b/src/3rdparty/pcre2/qt_attribution.json index a22136c06c..12213ba5a7 100644 --- a/src/3rdparty/pcre2/qt_attribution.json +++ b/src/3rdparty/pcre2/qt_attribution.json @@ -7,8 +7,8 @@ "Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.", "Homepage": "http://www.pcre.org/", - "Version": "10.33", - "DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.33.tar.bz2", + "Version": "10.34", + "DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.34.tar.bz2", "License": "BSD 3-clause \"New\" or \"Revised\" License", "LicenseId": "BSD-3-Clause", "LicenseFile": "LICENCE", @@ -24,8 +24,8 @@ Copyright (c) 2010-2019 Zoltan Herczeg" "Path": "src/sljit", "Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.", "Homepage": "http://www.pcre.org/", - "Version": "10.33", - "DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.33.tar.bz2", + "Version": "10.34", + "DownloadLocation": "https://ftp.pcre.org/pub/pcre/pcre2-10.34.tar.bz2", "License": "BSD 2-clause \"Simplified\" License", "LicenseId": "BSD-2-Clause", "LicenseFile": "LICENCE", diff --git a/src/3rdparty/pcre2/src/pcre2.h b/src/3rdparty/pcre2/src/pcre2.h index 102b5d91f1..cb9d61a35b 100644 --- a/src/3rdparty/pcre2/src/pcre2.h +++ b/src/3rdparty/pcre2/src/pcre2.h @@ -5,7 +5,7 @@ /* This is the public header file for the PCRE library, second API, to be #included by applications that call PCRE2 functions. - Copyright (c) 2016-2018 University of Cambridge + Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -42,9 +42,9 @@ POSSIBILITY OF SUCH DAMAGE. /* The current PCRE version information. */ #define PCRE2_MAJOR 10 -#define PCRE2_MINOR 33 +#define PCRE2_MINOR 34 #define PCRE2_PRERELEASE -#define PCRE2_DATE 2019-04-16 +#define PCRE2_DATE 2019-11-21 /* When an application links to a PCRE DLL in Windows, the symbols that are imported have to be identified as such. When building PCRE2, the appropriate @@ -142,6 +142,7 @@ D is inspected during pcre2_dfa_match() execution #define PCRE2_USE_OFFSET_LIMIT 0x00800000u /* J M D */ #define PCRE2_EXTENDED_MORE 0x01000000u /* C */ #define PCRE2_LITERAL 0x02000000u /* C */ +#define PCRE2_MATCH_INVALID_UTF 0x04000000u /* J M D */ /* An additional compile options word is available in the compile context. */ @@ -305,6 +306,8 @@ pcre2_pattern_convert(). */ #define PCRE2_ERROR_INVALID_HYPHEN_IN_OPTIONS 194 #define PCRE2_ERROR_ALPHA_ASSERTION_UNKNOWN 195 #define PCRE2_ERROR_SCRIPT_RUN_NOT_AVAILABLE 196 +#define PCRE2_ERROR_TOO_MANY_CAPTURES 197 +#define PCRE2_ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED 198 /* "Expected" matching error codes: no match and partial match. */ @@ -390,6 +393,7 @@ released, the numbers must not be changed. */ #define PCRE2_ERROR_HEAPLIMIT (-63) #define PCRE2_ERROR_CONVERT_SYNTAX (-64) #define PCRE2_ERROR_INTERNAL_DUPMATCH (-65) +#define PCRE2_ERROR_DFA_UINVALID_UTF (-66) /* Request types for pcre2_pattern_info() */ @@ -580,7 +584,7 @@ PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ pcre2_set_bsr(pcre2_compile_context *, uint32_t); \ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ - pcre2_set_character_tables(pcre2_compile_context *, const unsigned char *); \ + pcre2_set_character_tables(pcre2_compile_context *, const uint8_t *); \ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ pcre2_set_compile_extra_options(pcre2_compile_context *, uint32_t); \ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ @@ -675,6 +679,8 @@ PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ pcre2_match_data_free(pcre2_match_data *); \ PCRE2_EXP_DECL PCRE2_SPTR PCRE2_CALL_CONVENTION \ pcre2_get_mark(pcre2_match_data *); \ +PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \ + pcre2_get_match_data_size(pcre2_match_data *); \ PCRE2_EXP_DECL uint32_t PCRE2_CALL_CONVENTION \ pcre2_get_ovector_count(pcre2_match_data *); \ PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \ @@ -773,7 +779,8 @@ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \ pcre2_get_error_message(int, PCRE2_UCHAR *, PCRE2_SIZE); \ PCRE2_EXP_DECL const uint8_t PCRE2_CALL_CONVENTION \ *pcre2_maketables(pcre2_general_context *); \ - +PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \ + pcre2_maketables_free(pcre2_general_context *, const uint8_t *); /* Define macros that generate width-specific names from generic versions. The three-level macro scheme is necessary to get the macros expanded when we want @@ -838,6 +845,7 @@ pcre2_compile are called by application code. */ #define pcre2_general_context_free PCRE2_SUFFIX(pcre2_general_context_free_) #define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_) #define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_) +#define pcre2_get_match_data_size PCRE2_SUFFIX(pcre2_get_match_data_size_) #define pcre2_get_ovector_pointer PCRE2_SUFFIX(pcre2_get_ovector_pointer_) #define pcre2_get_ovector_count PCRE2_SUFFIX(pcre2_get_ovector_count_) #define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_) @@ -848,6 +856,7 @@ pcre2_compile are called by application code. */ #define pcre2_jit_stack_create PCRE2_SUFFIX(pcre2_jit_stack_create_) #define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_) #define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_) +#define pcre2_maketables_free PCRE2_SUFFIX(pcre2_maketables_free_) #define pcre2_match PCRE2_SUFFIX(pcre2_match_) #define pcre2_match_context_copy PCRE2_SUFFIX(pcre2_match_context_copy_) #define pcre2_match_context_create PCRE2_SUFFIX(pcre2_match_context_create_) diff --git a/src/3rdparty/pcre2/src/pcre2_auto_possess.c b/src/3rdparty/pcre2/src/pcre2_auto_possess.c index 6d7b7c4a4d..5b95b9b8a8 100644 --- a/src/3rdparty/pcre2/src/pcre2_auto_possess.c +++ b/src/3rdparty/pcre2/src/pcre2_auto_possess.c @@ -624,6 +624,13 @@ for(;;) case OP_ASSERTBACK_NOT: case OP_ONCE: return !entered_a_group; + + /* Non-atomic assertions - don't possessify last iterator. This needs + more thought. */ + + case OP_ASSERT_NA: + case OP_ASSERTBACK_NA: + return FALSE; } /* Skip over the bracket and inspect what comes next. */ diff --git a/src/3rdparty/pcre2/src/pcre2_compile.c b/src/3rdparty/pcre2/src/pcre2_compile.c index 068735ae8e..f2e6b6b5bd 100644 --- a/src/3rdparty/pcre2/src/pcre2_compile.c +++ b/src/3rdparty/pcre2/src/pcre2_compile.c @@ -135,6 +135,9 @@ static BOOL set_lookbehind_lengths(uint32_t **, int *, int *, parsed_recurse_check *, compile_block *); +static int + check_lookbehinds(uint32_t *, uint32_t **, parsed_recurse_check *, + compile_block *); /************************************************* @@ -250,36 +253,41 @@ is present where expected in a conditional group. */ #define META_LOOKBEHIND 0x80250000u /* (?<= */ #define META_LOOKBEHINDNOT 0x80260000u /* (?<! */ +/* These cannot be conditions */ + +#define META_LOOKAHEAD_NA 0x80270000u /* (*napla: */ +#define META_LOOKBEHIND_NA 0x80280000u /* (*naplb: */ + /* These must be kept in this order, with consecutive values, and the _ARG versions of COMMIT, PRUNE, SKIP, and THEN immediately after their non-argument versions. */ -#define META_MARK 0x80270000u /* (*MARK) */ -#define META_ACCEPT 0x80280000u /* (*ACCEPT) */ -#define META_FAIL 0x80290000u /* (*FAIL) */ -#define META_COMMIT 0x802a0000u /* These */ -#define META_COMMIT_ARG 0x802b0000u /* pairs */ -#define META_PRUNE 0x802c0000u /* must */ -#define META_PRUNE_ARG 0x802d0000u /* be */ -#define META_SKIP 0x802e0000u /* kept */ -#define META_SKIP_ARG 0x802f0000u /* in */ -#define META_THEN 0x80300000u /* this */ -#define META_THEN_ARG 0x80310000u /* order */ +#define META_MARK 0x80290000u /* (*MARK) */ +#define META_ACCEPT 0x802a0000u /* (*ACCEPT) */ +#define META_FAIL 0x802b0000u /* (*FAIL) */ +#define META_COMMIT 0x802c0000u /* These */ +#define META_COMMIT_ARG 0x802d0000u /* pairs */ +#define META_PRUNE 0x802e0000u /* must */ +#define META_PRUNE_ARG 0x802f0000u /* be */ +#define META_SKIP 0x80300000u /* kept */ +#define META_SKIP_ARG 0x80310000u /* in */ +#define META_THEN 0x80320000u /* this */ +#define META_THEN_ARG 0x80330000u /* order */ /* These must be kept in groups of adjacent 3 values, and all together. */ -#define META_ASTERISK 0x80320000u /* * */ -#define META_ASTERISK_PLUS 0x80330000u /* *+ */ -#define META_ASTERISK_QUERY 0x80340000u /* *? */ -#define META_PLUS 0x80350000u /* + */ -#define META_PLUS_PLUS 0x80360000u /* ++ */ -#define META_PLUS_QUERY 0x80370000u /* +? */ -#define META_QUERY 0x80380000u /* ? */ -#define META_QUERY_PLUS 0x80390000u /* ?+ */ -#define META_QUERY_QUERY 0x803a0000u /* ?? */ -#define META_MINMAX 0x803b0000u /* {n,m} repeat */ -#define META_MINMAX_PLUS 0x803c0000u /* {n,m}+ repeat */ -#define META_MINMAX_QUERY 0x803d0000u /* {n,m}? repeat */ +#define META_ASTERISK 0x80340000u /* * */ +#define META_ASTERISK_PLUS 0x80350000u /* *+ */ +#define META_ASTERISK_QUERY 0x80360000u /* *? */ +#define META_PLUS 0x80370000u /* + */ +#define META_PLUS_PLUS 0x80380000u /* ++ */ +#define META_PLUS_QUERY 0x80390000u /* +? */ +#define META_QUERY 0x803a0000u /* ? */ +#define META_QUERY_PLUS 0x803b0000u /* ?+ */ +#define META_QUERY_QUERY 0x803c0000u /* ?? */ +#define META_MINMAX 0x803d0000u /* {n,m} repeat */ +#define META_MINMAX_PLUS 0x803e0000u /* {n,m}+ repeat */ +#define META_MINMAX_QUERY 0x803f0000u /* {n,m}? repeat */ #define META_FIRST_QUANTIFIER META_ASTERISK #define META_LAST_QUANTIFIER META_MINMAX_QUERY @@ -335,6 +343,8 @@ static unsigned char meta_extra_lengths[] = { 0, /* META_LOOKAHEADNOT */ SIZEOFFSET, /* META_LOOKBEHIND */ SIZEOFFSET, /* META_LOOKBEHINDNOT */ + 0, /* META_LOOKAHEAD_NA */ + SIZEOFFSET, /* META_LOOKBEHIND_NA */ 1, /* META_MARK - plus the string length */ 0, /* META_ACCEPT */ 0, /* META_FAIL */ @@ -634,10 +644,14 @@ typedef struct alasitem { static const char alasnames[] = STRING_pla0 STRING_plb0 + STRING_napla0 + STRING_naplb0 STRING_nla0 STRING_nlb0 STRING_positive_lookahead0 STRING_positive_lookbehind0 + STRING_non_atomic_positive_lookahead0 + STRING_non_atomic_positive_lookbehind0 STRING_negative_lookahead0 STRING_negative_lookbehind0 STRING_atomic0 @@ -649,10 +663,14 @@ static const char alasnames[] = static const alasitem alasmeta[] = { { 3, META_LOOKAHEAD }, { 3, META_LOOKBEHIND }, + { 5, META_LOOKAHEAD_NA }, + { 5, META_LOOKBEHIND_NA }, { 3, META_LOOKAHEADNOT }, { 3, META_LOOKBEHINDNOT }, { 18, META_LOOKAHEAD }, { 19, META_LOOKBEHIND }, + { 29, META_LOOKAHEAD_NA }, + { 30, META_LOOKBEHIND_NA }, { 18, META_LOOKAHEADNOT }, { 19, META_LOOKBEHINDNOT }, { 6, META_ATOMIC }, @@ -746,8 +764,8 @@ are allowed. */ #define PUBLIC_LITERAL_COMPILE_OPTIONS \ (PCRE2_ANCHORED|PCRE2_AUTO_CALLOUT|PCRE2_CASELESS|PCRE2_ENDANCHORED| \ - PCRE2_FIRSTLINE|PCRE2_LITERAL|PCRE2_NO_START_OPTIMIZE| \ - PCRE2_NO_UTF_CHECK|PCRE2_USE_OFFSET_LIMIT|PCRE2_UTF) + PCRE2_FIRSTLINE|PCRE2_LITERAL|PCRE2_MATCH_INVALID_UTF| \ + PCRE2_NO_START_OPTIMIZE|PCRE2_NO_UTF_CHECK|PCRE2_USE_OFFSET_LIMIT|PCRE2_UTF) #define PUBLIC_COMPILE_OPTIONS \ (PUBLIC_LITERAL_COMPILE_OPTIONS| \ @@ -781,7 +799,7 @@ enum { ERR0 = COMPILE_ERROR_BASE, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERR87, ERR88, ERR89, ERR90, - ERR91, ERR92, ERR93, ERR94, ERR95, ERR96 }; + ERR91, ERR92, ERR93, ERR94, ERR95, ERR96, ERR97, ERR98 }; /* This is a table of start-of-pattern options such as (*UTF) and settings such as (*LIMIT_MATCH=nnnn) and (*CRLF). For completeness and backward @@ -1012,6 +1030,7 @@ for (;;) case META_NOCAPTURE: fprintf(stderr, "META (?:"); break; case META_LOOKAHEAD: fprintf(stderr, "META (?="); break; case META_LOOKAHEADNOT: fprintf(stderr, "META (?!"); break; + case META_LOOKAHEAD_NA: fprintf(stderr, "META (*napla:"); break; case META_SCRIPT_RUN: fprintf(stderr, "META (*sr:"); break; case META_KET: fprintf(stderr, "META )"); break; case META_ALT: fprintf(stderr, "META | %d", meta_arg); break; @@ -1043,6 +1062,12 @@ for (;;) fprintf(stderr, "%zd", offset); break; + case META_LOOKBEHIND_NA: + fprintf(stderr, "META (*naplb: %d offset=", meta_arg); + GETOFFSET(offset, pptr); + fprintf(stderr, "%zd", offset); + break; + case META_LOOKBEHINDNOT: fprintf(stderr, "META (?<! %d offset=", meta_arg); GETOFFSET(offset, pptr); @@ -1419,9 +1444,6 @@ the result is "not a repeat quantifier". */ EXIT: if (yield || *errorcodeptr != 0) *ptrptr = p; return yield; - - - } @@ -2450,8 +2472,9 @@ must be last. */ enum { RANGE_NO, RANGE_STARTED, RANGE_OK_ESCAPED, RANGE_OK_LITERAL }; -/* Only in 32-bit mode can there be literals > META_END. A macros encapsulates -the storing of literal values in the parsed pattern. */ +/* Only in 32-bit mode can there be literals > META_END. A macro encapsulates +the storing of literal values in the main parsed pattern, where they can always +be quantified. */ #if PCRE2_CODE_UNIT_WIDTH == 32 #define PARSED_LITERAL(c, p) \ @@ -2474,6 +2497,7 @@ uint32_t delimiter; uint32_t namelen; uint32_t class_range_state; uint32_t *verblengthptr = NULL; /* Value avoids compiler warning */ +uint32_t *verbstartptr = NULL; uint32_t *previous_callout = NULL; uint32_t *parsed_pattern = cb->parsed_pattern; uint32_t *parsed_pattern_end = cb->parsed_pattern_end; @@ -2600,10 +2624,20 @@ while (ptr < ptrend) errorcode = ERR28; goto FAILED; } - if (!inverbname && after_manual_callout-- <= 0) - parsed_pattern = manage_callouts(thisptr, &previous_callout, - auto_callout, parsed_pattern, cb); - PARSED_LITERAL(c, parsed_pattern); + if (inverbname) + { /* Don't use PARSED_LITERAL() because it */ +#if PCRE2_CODE_UNIT_WIDTH == 32 /* sets okquantifier. */ + if (c >= META_END) *parsed_pattern++ = META_BIGVALUE; +#endif + *parsed_pattern++ = c; + } + else + { + if (after_manual_callout-- <= 0) + parsed_pattern = manage_callouts(thisptr, &previous_callout, + auto_callout, parsed_pattern, cb); + PARSED_LITERAL(c, parsed_pattern); + } meta_quantifier = 0; } continue; /* Next character */ @@ -2640,13 +2674,15 @@ while (ptr < ptrend) switch(c) { - default: - PARSED_LITERAL(c, parsed_pattern); + default: /* Don't use PARSED_LITERAL() because it */ +#if PCRE2_CODE_UNIT_WIDTH == 32 /* sets okquantifier. */ + if (c >= META_END) *parsed_pattern++ = META_BIGVALUE; +#endif + *parsed_pattern++ = c; break; case CHAR_RIGHT_PARENTHESIS: inverbname = FALSE; - okquantifier = FALSE; /* Was probably set by literals */ /* This is the length in characters */ verbnamelength = (PCRE2_SIZE)(parsed_pattern - verblengthptr - 1); /* But the limit on the length is in code units */ @@ -2680,8 +2716,11 @@ while (ptr < ptrend) switch(escape) { - case 0: - PARSED_LITERAL(c, parsed_pattern); + case 0: /* Don't use PARSED_LITERAL() because it */ +#if PCRE2_CODE_UNIT_WIDTH == 32 /* sets okquantifier. */ + if (c >= META_END) *parsed_pattern++ = META_BIGVALUE; +#endif + *parsed_pattern++ = c; break; case ESC_Q: @@ -3135,6 +3174,21 @@ while (ptr < ptrend) goto FAILED_BACK; } + /* Most (*VERB)s are not allowed to be quantified, but an ungreedy + quantifier can be useful for (*ACCEPT) - meaning "succeed on backtrack", a + sort of negated (*COMMIT). We therefore allow (*ACCEPT) to be quantified by + wrapping it in non-capturing brackets, but we have to allow for a preceding + (*MARK) for when (*ACCEPT) has an argument. */ + + if (parsed_pattern[-1] == META_ACCEPT) + { + uint32_t *p; + for (p = parsed_pattern - 1; p >= verbstartptr; p--) p[1] = p[0]; + *verbstartptr = META_NOCAPTURE; + parsed_pattern[1] = META_KET; + parsed_pattern += 2; + } + /* Now we can put the quantifier into the parsed pattern vector. At this stage, we have only the basic quantifier. The check for a following + or ? modifier happens at the top of the loop, after any intervening comments @@ -3581,6 +3635,8 @@ while (ptr < ptrend) if (c == CHAR_RIGHT_SQUARE_BRACKET && !inescq) break; } /* End of class-processing loop */ + /* -] at the end of a class is a literal '-' */ + if (class_range_state == RANGE_STARTED) { parsed_pattern[-1] = CHAR_MINUS; @@ -3611,6 +3667,11 @@ while (ptr < ptrend) nest_depth++; if ((options & PCRE2_NO_AUTO_CAPTURE) == 0) { + if (cb->bracount >= MAX_GROUP_NUMBER) + { + errorcode = ERR97; + goto FAILED; + } cb->bracount++; *parsed_pattern++ = META_CAPTURE | cb->bracount; } @@ -3658,19 +3719,20 @@ while (ptr < ptrend) goto FAILED; } - /* Check for expecting an assertion condition. If so, only lookaround - assertions are valid. */ + /* Check for expecting an assertion condition. If so, only atomic + lookaround assertions are valid. */ meta = alasmeta[i].meta; if (prev_expect_cond_assert > 0 && (meta < META_LOOKAHEAD || meta > META_LOOKBEHINDNOT)) { - errorcode = ERR28; /* Assertion expected */ + errorcode = (meta == META_LOOKAHEAD_NA || meta == META_LOOKBEHIND_NA)? + ERR98 : ERR28; /* (Atomic) assertion expected */ goto FAILED; } - /* The lookaround alphabetic synonyms can be almost entirely handled by - jumping to the code that handles the traditional symbolic forms. */ + /* The lookaround alphabetic synonyms can mostly be handled by jumping + to the code that handles the traditional symbolic forms. */ switch(meta) { @@ -3684,11 +3746,17 @@ while (ptr < ptrend) case META_LOOKAHEAD: goto POSITIVE_LOOK_AHEAD; + case META_LOOKAHEAD_NA: + *parsed_pattern++ = meta; + ptr++; + goto POST_ASSERTION; + case META_LOOKAHEADNOT: goto NEGATIVE_LOOK_AHEAD; case META_LOOKBEHIND: case META_LOOKBEHINDNOT: + case META_LOOKBEHIND_NA: *parsed_pattern++ = meta; ptr--; goto POST_LOOKBEHIND; @@ -3770,6 +3838,12 @@ while (ptr < ptrend) goto FAILED; } + /* Remember where this verb, possibly with a preceding (*MARK), starts, + for handling quantified (*ACCEPT). */ + + verbstartptr = parsed_pattern; + okquantifier = (verbs[i].meta == META_ACCEPT); + /* It appears that Perl allows any characters whatsoever, other than a closing parenthesis, to appear in arguments ("names"), so we no longer insist on letters, digits, and underscores. Perl does not, however, do @@ -4386,7 +4460,7 @@ while (ptr < ptrend) *parsed_pattern++ = (ptr[1] == CHAR_EQUALS_SIGN)? META_LOOKBEHIND : META_LOOKBEHINDNOT; - POST_LOOKBEHIND: /* Come from (*plb: and (*nlb: */ + POST_LOOKBEHIND: /* Come from (*plb: (*naplb: and (*nlb: */ *has_lookbehind = TRUE; offset = (PCRE2_SIZE)(ptr - cb->start_pattern - 2); PUTOFFSET(offset, parsed_pattern); @@ -4435,6 +4509,11 @@ while (ptr < ptrend) /* We have a name for this capturing group. It is also assigned a number, which is its primary means of identification. */ + if (cb->bracount >= MAX_GROUP_NUMBER) + { + errorcode = ERR97; + goto FAILED; + } cb->bracount++; *parsed_pattern++ = META_CAPTURE | cb->bracount; nest_depth++; @@ -4661,6 +4740,7 @@ for (;;) case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: + case OP_ASSERTBACK_NA: if (!skipassert) return code; do code += GET(code, 1); while (*code == OP_ALT); code += PRIV(OP_lengths)[*code]; @@ -5221,8 +5301,10 @@ PCRE2_UCHAR *tempcode; PCRE2_UCHAR *previous = NULL; PCRE2_UCHAR op_previous; BOOL groupsetfirstcu = FALSE; +BOOL had_accept = FALSE; BOOL matched_char = FALSE; BOOL previous_matched_char = FALSE; +BOOL reset_caseful = FALSE; const uint8_t *cbits = cb->cbits; uint8_t classbits[32]; @@ -5355,7 +5437,7 @@ for (;; pptr++) if (meta < META_ASTERISK || meta > META_MINMAX_QUERY) { previous = code; - if (matched_char) okreturn = 1; + if (matched_char && !had_accept) okreturn = 1; } previous_matched_char = matched_char; @@ -5499,7 +5581,45 @@ for (;; pptr++) } /* End of 1-char optimization */ /* Handle character classes that contain more than just one literal - character. */ + character. If there are exactly two characters in a positive class, see if + they are case partners. This can be optimized to generate a caseless single + character match (which also sets first/required code units if relevant). */ + + if (meta == META_CLASS && pptr[1] < META_END && pptr[2] < META_END && + pptr[3] == META_CLASS_END) + { + uint32_t c = pptr[1]; + +#ifdef SUPPORT_UNICODE + if (UCD_CASESET(c) == 0) +#endif + { + uint32_t d; + +#ifdef SUPPORT_UNICODE + if (utf && c > 127) d = UCD_OTHERCASE(c); else +#endif + { +#if PCRE2_CODE_UNIT_WIDTH != 8 + if (c > 255) d = c; else +#endif + d = TABLE_GET(c, cb->fcc, c); + } + + if (c != d && pptr[2] == d) + { + pptr += 3; /* Move on to class end */ + meta = c; + if ((options & PCRE2_CASELESS) == 0) + { + reset_caseful = TRUE; + options |= PCRE2_CASELESS; + req_caseopt = REQ_CASELESS; + } + goto CLASS_CASELESS_CHAR; + } + } + } /* If a non-extended class contains a negative special such as \S, we need to flip the negation flag at the end, so that support for characters > 255 @@ -5994,7 +6114,7 @@ for (;; pptr++) workspace overflow. Do not set firstcu after *ACCEPT. */ case META_ACCEPT: - cb->had_accept = TRUE; + cb->had_accept = had_accept = TRUE; for (oc = cb->open_caps; oc != NULL && oc->assert_depth >= cb->assert_depth; oc = oc->next) @@ -6252,6 +6372,11 @@ for (;; pptr++) cb->assert_depth += 1; goto GROUP_PROCESS; + case META_LOOKAHEAD_NA: + bravalue = OP_ASSERT_NA; + cb->assert_depth += 1; + goto GROUP_PROCESS; + /* Optimize (?!) to (*FAIL) unless it is quantified - which is a weird thing to do, but Perl allows all assertions to be quantified, and when they contain capturing parentheses there may be a potential use for @@ -6283,6 +6408,11 @@ for (;; pptr++) cb->assert_depth += 1; goto GROUP_PROCESS; + case META_LOOKBEHIND_NA: + bravalue = OP_ASSERTBACK_NA; + cb->assert_depth += 1; + goto GROUP_PROCESS; + case META_ATOMIC: bravalue = OP_ONCE; goto GROUP_PROCESS_NOTE_EMPTY; @@ -6341,7 +6471,7 @@ for (;; pptr++) /* If we've just compiled an assertion, pop the assert depth. */ - if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT) + if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NA) cb->assert_depth -= 1; /* At the end of compiling, code is still pointing to the start of the @@ -6491,8 +6621,8 @@ for (;; pptr++) we must only take the reqcu when the group also set a firstcu. Otherwise, in that example, 'X' ends up set for both. */ - else if (bravalue == OP_ASSERT && subreqcuflags >= 0 && - subfirstcuflags >= 0) + else if ((bravalue == OP_ASSERT || bravalue == OP_ASSERT_NA) && + subreqcuflags >= 0 && subfirstcuflags >= 0) { reqcu = subreqcu; reqcuflags = subreqcuflags; @@ -6713,10 +6843,6 @@ for (;; pptr++) reqvary = (repeat_min == repeat_max)? 0 : REQ_VARY; op_type = 0; - /* If the repeat is {1} we can ignore it. */ - - if (repeat_max == 1 && repeat_min == 1) goto END_REPEAT; - /* Adjust first and required code units for a zero repeat. */ if (repeat_min == 0) @@ -6759,7 +6885,10 @@ for (;; pptr++) tempcode = previous; op_previous = *previous; - /* Now handle repetition for the different types of item. */ + /* Now handle repetition for the different types of item. If the repeat + minimum and the repeat maximum are both 1, we can ignore the quantifier for + non-parenthesized items, as they have only one alternative. For anything in + parentheses, we must not ignore if {1} is possessive. */ switch (op_previous) { @@ -6773,6 +6902,7 @@ for (;; pptr++) case OP_CHARI: case OP_NOT: case OP_NOTI: + if (repeat_max == 1 && repeat_min == 1) goto END_REPEAT; op_type = chartypeoffset[op_previous - OP_CHAR]; /* Deal with UTF characters that take up more than one code unit. */ @@ -6819,6 +6949,7 @@ for (;; pptr++) code = previous; goto END_REPEAT; } + if (repeat_max == 1 && repeat_min == 1) goto END_REPEAT; if (repeat_min == 0 && repeat_max == REPEAT_UNLIMITED) *code++ = OP_CRSTAR + repeat_type; @@ -6853,6 +6984,8 @@ for (;; pptr++) repetition. */ case OP_RECURSE: + if (repeat_max == 1 && repeat_min == 1 && !possessive_quantifier) + goto END_REPEAT; /* Generate unwrapped repeats for a non-zero minimum, except when the minimum is 1 and the maximum unlimited, because that can be handled with @@ -6923,8 +7056,10 @@ for (;; pptr++) case OP_ASSERT: case OP_ASSERT_NOT: + case OP_ASSERT_NA: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: + case OP_ASSERTBACK_NA: case OP_ONCE: case OP_SCRIPT_RUN: case OP_BRA: @@ -6935,6 +7070,9 @@ for (;; pptr++) PCRE2_UCHAR *bralink = NULL; PCRE2_UCHAR *brazeroptr = NULL; + if (repeat_max == 1 && repeat_min == 1 && !possessive_quantifier) + goto END_REPEAT; + /* Repeating a DEFINE group (or any group where the condition is always FALSE and there is only one branch) is pointless, but Perl allows the syntax, so we just ignore the repeat. */ @@ -7151,11 +7289,12 @@ for (;; pptr++) and SCRIPT_RUN groups at runtime, but in a different way.] Then, if the quantifier was possessive and the bracket is not a - conditional, we convert the BRA code to the POS form, and the KET code to - KETRPOS. (It turns out to be convenient at runtime to detect this kind of - subpattern at both the start and at the end.) The use of special opcodes - makes it possible to reduce greatly the stack usage in pcre2_match(). If - the group is preceded by OP_BRAZERO, convert this to OP_BRAPOSZERO. + conditional, we convert the BRA code to the POS form, and the KET code + to KETRPOS. (It turns out to be convenient at runtime to detect this + kind of subpattern at both the start and at the end.) The use of + special opcodes makes it possible to reduce greatly the stack usage in + pcre2_match(). If the group is preceded by OP_BRAZERO, convert this to + OP_BRAPOSZERO. Then, if the minimum number of matches is 1 or 0, cancel the possessive flag so that the default action below, of wrapping everything inside @@ -7256,6 +7395,8 @@ for (;; pptr++) int prop_type, prop_value; PCRE2_UCHAR *oldcode; + if (repeat_max == 1 && repeat_min == 1) goto END_REPEAT; + op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */ mclength = 0; /* Not a character */ @@ -7718,9 +7859,15 @@ for (;; pptr++) } #endif - /* Caseful matches, or not one of the multicase characters. Get the - character's code units into mcbuffer, with the length in mclength. When not - in UTF mode, the length is always 1. */ + /* Caseful matches, or caseless and not one of the multicase characters. We + come here by goto in the case of a positive class that contains only + case-partners of a character with just two cases; matched_char has already + been set TRUE and options fudged if necessary. */ + + CLASS_CASELESS_CHAR: + + /* Get the character's code units into mcbuffer, with the length in + mclength. When not in UTF mode, the length is always 1. */ #ifdef SUPPORT_UNICODE if (utf) mclength = PRIV(ord2utf)(meta, mcbuffer); else @@ -7752,8 +7899,9 @@ for (;; pptr++) zeroreqcu = reqcu; zeroreqcuflags = reqcuflags; - /* If the character is more than one code unit long, we can set firstcu - only if it is not to be matched caselessly. */ + /* If the character is more than one code unit long, we can set a single + firstcu only if it is not to be matched caselessly. Multiple possible + starting code units may be picked up later in the studying code. */ if (mclength == 1 || req_caseopt == 0) { @@ -7783,7 +7931,17 @@ for (;; pptr++) reqcuflags = req_caseopt | cb->req_varyopt; } } - break; /* End default meta handling */ + + /* If caselessness was temporarily instated, reset it. */ + + if (reset_caseful) + { + options &= ~PCRE2_CASELESS; + req_caseopt = 0; + reset_caseful = FALSE; + } + + break; /* End literal character handling */ } /* End of big switch */ } /* End of big loop */ @@ -7874,7 +8032,10 @@ length = 2 + 2*LINK_SIZE + skipunits; /* Remember if this is a lookbehind assertion, and if it is, save its length and skip over the pattern offset. */ -lookbehind = *code == OP_ASSERTBACK || *code == OP_ASSERTBACK_NOT; +lookbehind = *code == OP_ASSERTBACK || + *code == OP_ASSERTBACK_NOT || + *code == OP_ASSERTBACK_NA; + if (lookbehind) { lookbehindlength = META_DATA(pptr[-1]); @@ -7948,7 +8109,7 @@ for (;;) /* If this is not the first branch, the first char and reqcu have to match the values from all the previous branches, except that if the previous value for reqcu didn't have REQ_VARY set, it can still match, - and we set REQ_VARY for the regex. */ + and we set REQ_VARY for the group from this branch's value. */ else { @@ -7987,7 +8148,7 @@ for (;;) else { reqcu = branchreqcu; - reqcuflags |= branchreqcuflags; /* To "or" REQ_VARY */ + reqcuflags |= branchreqcuflags; /* To "or" REQ_VARY if present */ } } } @@ -8167,7 +8328,7 @@ do { /* Positive forward assertion */ - else if (op == OP_ASSERT) + else if (op == OP_ASSERT || op == OP_ASSERT_NA) { if (!is_anchored(scode, bracket_map, cb, atomcount, TRUE)) return FALSE; } @@ -8305,7 +8466,7 @@ do { /* Positive forward assertions */ - else if (op == OP_ASSERT) + else if (op == OP_ASSERT || op == OP_ASSERT_NA) { if (!is_startline(scode, bracket_map, cb, atomcount, TRUE)) return FALSE; @@ -8547,9 +8708,11 @@ do { case OP_CBRAPOS: case OP_SCBRAPOS: case OP_ASSERT: + case OP_ASSERT_NA: case OP_ONCE: case OP_SCRIPT_RUN: - d = find_firstassertedcu(scode, &dflags, inassert + ((op==OP_ASSERT)?1:0)); + d = find_firstassertedcu(scode, &dflags, inassert + + ((op == OP_ASSERT || op == OP_ASSERT_NA)?1:0)); if (dflags < 0) return 0; if (cflags < 0) { c = d; cflags = dflags; } @@ -8578,6 +8741,19 @@ do { case OP_MINPLUSI: case OP_POSPLUSI: if (inassert == 0) return 0; + + /* If the character is more than one code unit long, we cannot set its + first code unit when matching caselessly. Later scanning may pick up + multiple code units. */ + +#ifdef SUPPORT_UNICODE +#if PCRE2_CODE_UNIT_WIDTH == 8 + if (scode[1] >= 0x80) return 0; +#elif PCRE2_CODE_UNIT_WIDTH == 16 + if (scode[1] >= 0xd800 && scode[1] <= 0xdfff) return 0; +#endif +#endif + if (cflags < 0) { c = scode[1]; cflags = REQ_CASELESS; } else if (c != scode[1]) return 0; break; @@ -8745,8 +8921,10 @@ for (;; pptr++) case META_COND_VERSION: case META_LOOKAHEAD: case META_LOOKAHEADNOT: + case META_LOOKAHEAD_NA: case META_LOOKBEHIND: case META_LOOKBEHINDNOT: + case META_LOOKBEHIND_NA: case META_NOCAPTURE: case META_SCRIPT_RUN: nestlevel++; @@ -8798,7 +8976,7 @@ Returns: the group length or a negative number static int get_grouplength(uint32_t **pptrptr, BOOL isinline, int *errcodeptr, int *lcptr, - int group, parsed_recurse_check *recurses, compile_block *cb) + int group, parsed_recurse_check *recurses, compile_block *cb) { int branchlength; int grouplength = -1; @@ -8847,8 +9025,7 @@ return -1; *************************************************/ /* Return a fixed length for a branch in a lookbehind, giving an error if the -length is not fixed. If any lookbehinds are encountered on the way, they get -their length set. On entry, *pptrptr points to the first element inside the +length is not fixed. On entry, *pptrptr points to the first element inside the branch. On exit it is set to point to the ALT or KET. Arguments: @@ -8978,15 +9155,16 @@ for (;; pptr++) } break; - /* Lookaheads can be ignored, but we must start the skip inside the group - so that it isn't treated as a group within the branch. */ + /* Lookaheads do not contribute to the length of this branch, but they may + contain lookbehinds within them whose lengths need to be set. */ case META_LOOKAHEAD: case META_LOOKAHEADNOT: - pptr = parsed_skip(pptr + 1, PSKIP_KET); - if (pptr == NULL) goto PARSED_SKIP_FAILED; + case META_LOOKAHEAD_NA: + *errcodeptr = check_lookbehinds(pptr + 1, &pptr, recurses, cb); + if (*errcodeptr != 0) return -1; - /* Also ignore any qualifiers that follow a lookahead assertion. */ + /* Ignore any qualifiers that follow a lookahead assertion. */ switch (pptr[1]) { @@ -9013,10 +9191,12 @@ for (;; pptr++) } break; - /* Lookbehinds can be ignored, but must themselves be checked. */ + /* A nested lookbehind does not contribute any length to this lookbehind, + but must itself be checked and have its lengths set. */ case META_LOOKBEHIND: case META_LOOKBEHINDNOT: + case META_LOOKBEHIND_NA: if (!set_lookbehind_lengths(&pptr, errcodeptr, lcptr, recurses, cb)) return -1; break; @@ -9178,8 +9358,26 @@ for (;; pptr++) case META_MINMAX_QUERY: if (pptr[1] == pptr[2]) { - if (pptr[1] == 0) branchlength -= lastitemlength; - else itemlength = (pptr[1] - 1) * lastitemlength; + switch(pptr[1]) + { + case 0: + branchlength -= lastitemlength; + break; + + case 1: + itemlength = 0; + break; + + default: /* Check for integer overflow */ + if (lastitemlength != 0 && /* Should not occur, but just in case */ + INT_MAX/lastitemlength < pptr[1] - 1) + { + *errcodeptr = ERR87; /* Integer overflow; lookbehind too big */ + return -1; + } + itemlength = (pptr[1] - 1) * lastitemlength; + break; + } pptr += 2; break; } @@ -9193,24 +9391,23 @@ for (;; pptr++) return -1; } - /* Add the item length to the branchlength, and save it for use if the next - thing is a quantifier. */ - - branchlength += itemlength; - lastitemlength = itemlength; - - /* Ensure that the length does not overflow the limit. */ + /* Add the item length to the branchlength, checking for integer overflow and + for the branch length exceeding the limit. */ - if (branchlength > LOOKBEHIND_MAX) + if (INT_MAX - branchlength < (int)itemlength || + (branchlength += itemlength) > LOOKBEHIND_MAX) { *errcodeptr = ERR87; return -1; } + + /* Save this item length for use if the next item is a quantifier. */ + + lastitemlength = itemlength; } EXIT: *pptrptr = pptr; -if (branchlength > cb->max_lookbehind) cb->max_lookbehind = branchlength; return branchlength; PARSED_SKIP_FAILED: @@ -9229,6 +9426,11 @@ branches. An error occurs if any branch does not have a fixed length that is less than the maximum (65535). On exit, the pointer must be left on the final ket. +The function also maintains the max_lookbehind value. Any lookbehind branch +that contains a nested lookbehind may actually look further back than the +length of the branch. The additional amount is passed back from +get_branchlength() as an "extra" value. + Arguments: pptrptr pointer to pointer in the parsed pattern errcodeptr pointer to error code @@ -9262,6 +9464,7 @@ do if (cb->erroroffset == PCRE2_UNSET) cb->erroroffset = offset; return FALSE; } + if (branchlength > cb->max_lookbehind) cb->max_lookbehind = branchlength; *bptr |= branchlength; /* branchlength never more than 65535 */ bptr = *pptrptr; } @@ -9282,20 +9485,30 @@ set_lookbehind_lengths() for each one. At the start, the errorcode is zero and the error offset is marked unset. The enables the functions above not to override settings from deeper nestings. -Arguments cb points to the compile block -Returns: 0 on success, or an errorcode (cb->erroroffset will be set) +This function is called recursively from get_branchlength() for lookaheads in +order to process any lookbehinds that they may contain. It stops when it hits a +non-nested closing parenthesis in this case, returning a pointer to it. + +Arguments + pptr points to where to start (start of pattern or start of lookahead) + retptr if not NULL, return the ket pointer here + recurses chain of recurse_check to catch mutual recursion + cb points to the compile block + +Returns: 0 on success, or an errorcode (cb->erroroffset will be set) */ static int -check_lookbehinds(compile_block *cb) +check_lookbehinds(uint32_t *pptr, uint32_t **retptr, + parsed_recurse_check *recurses, compile_block *cb) { -uint32_t *pptr; int errorcode = 0; int loopcount = 0; +int nestlevel = 0; cb->erroroffset = PCRE2_UNSET; -for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) +for (; *pptr != META_END; pptr++) { if (*pptr < META_END) continue; /* Literal */ @@ -9309,14 +9522,31 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) pptr += 1; break; + case META_KET: + if (--nestlevel < 0) + { + if (retptr != NULL) *retptr = pptr; + return 0; + } + break; + + case META_ATOMIC: + case META_CAPTURE: + case META_COND_ASSERT: + case META_LOOKAHEAD: + case META_LOOKAHEADNOT: + case META_LOOKAHEAD_NA: + case META_NOCAPTURE: + case META_SCRIPT_RUN: + nestlevel++; + break; + case META_ACCEPT: case META_ALT: case META_ASTERISK: case META_ASTERISK_PLUS: case META_ASTERISK_QUERY: - case META_ATOMIC: case META_BACKREF: - case META_CAPTURE: case META_CIRCUMFLEX: case META_CLASS: case META_CLASS_EMPTY: @@ -9324,14 +9554,9 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) case META_CLASS_END: case META_CLASS_NOT: case META_COMMIT: - case META_COND_ASSERT: case META_DOLLAR: case META_DOT: case META_FAIL: - case META_KET: - case META_LOOKAHEAD: - case META_LOOKAHEADNOT: - case META_NOCAPTURE: case META_PLUS: case META_PLUS_PLUS: case META_PLUS_QUERY: @@ -9341,7 +9566,6 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) case META_QUERY_QUERY: case META_RANGE_ESCAPED: case META_RANGE_LITERAL: - case META_SCRIPT_RUN: case META_SKIP: case META_THEN: break; @@ -9351,13 +9575,22 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) break; case META_BACKREF_BYNAME: + case META_RECURSE_BYNAME: + pptr += 1 + SIZEOFFSET; + break; + case META_COND_DEFINE: case META_COND_NAME: case META_COND_NUMBER: case META_COND_RNAME: case META_COND_RNUMBER: - case META_RECURSE_BYNAME: pptr += 1 + SIZEOFFSET; + nestlevel++; + break; + + case META_COND_VERSION: + pptr += 3; + nestlevel++; break; case META_CALLOUT_STRING: @@ -9378,7 +9611,6 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) break; case META_CALLOUT_NUMBER: - case META_COND_VERSION: pptr += 3; break; @@ -9392,7 +9624,8 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) case META_LOOKBEHIND: case META_LOOKBEHINDNOT: - if (!set_lookbehind_lengths(&pptr, &errorcode, &loopcount, NULL, cb)) + case META_LOOKBEHIND_NA: + if (!set_lookbehind_lengths(&pptr, &errorcode, &loopcount, recurses, cb)) return errorcode; break; } @@ -9494,6 +9727,10 @@ if (pattern == NULL) if (ccontext == NULL) ccontext = (pcre2_compile_context *)(&PRIV(default_compile_context)); +/* PCRE2_MATCH_INVALID_UTF implies UTF */ + +if ((options & PCRE2_MATCH_INVALID_UTF) != 0) options |= PCRE2_UTF; + /* Check that all undefined public option bits are zero. */ if ((options & ~PUBLIC_COMPILE_OPTIONS) != 0 || @@ -9672,7 +9909,7 @@ if ((options & PCRE2_LITERAL) == 0) ptr += skipatstart; -/* Can't support UTF or UCP unless PCRE2 has been compiled with UTF support. */ +/* Can't support UTF or UCP if PCRE2 was built without Unicode support. */ #ifndef SUPPORT_UNICODE if ((cb.external_options & (PCRE2_UTF|PCRE2_UCP)) != 0) @@ -9842,7 +10079,7 @@ lengths. */ if (has_lookbehind) { - errorcode = check_lookbehinds(&cb); + errorcode = check_lookbehinds(cb.parsed_pattern, NULL, NULL, &cb); if (errorcode != 0) goto HAD_CB_ERROR; } @@ -9990,8 +10227,9 @@ re->max_lookbehind = cb.max_lookbehind; if (cb.had_accept) { - reqcu = 0; /* Must disable after (*ACCEPT) */ + reqcu = 0; /* Must disable after (*ACCEPT) */ reqcuflags = REQ_NONE; + re->flags |= PCRE2_HASACCEPT; /* Disables minimum length */ } /* Fill in the final opcode and check for disastrous overflow. If no overflow, @@ -10112,6 +10350,8 @@ unit. */ if ((re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0) { + int minminlength = 0; /* For minimal minlength from first/required CU */ + /* If we do not have a first code unit, see if there is one that is asserted (these are not saved during the compile because they can cause conflicts with actual literals that follow). */ @@ -10119,12 +10359,14 @@ if ((re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0) if (firstcuflags < 0) firstcu = find_firstassertedcu(codestart, &firstcuflags, 0); - /* Save the data for a first code unit. */ + /* Save the data for a first code unit. The existence of one means the + minimum length must be at least 1. */ if (firstcuflags >= 0) { re->first_codeunit = firstcu; re->flags |= PCRE2_FIRSTSET; + minminlength++; /* Handle caseless first code units. */ @@ -10158,39 +10400,72 @@ if ((re->overall_options & PCRE2_NO_START_OPTIMIZE) == 0) is_startline(codestart, 0, &cb, 0, FALSE)) re->flags |= PCRE2_STARTLINE; - /* Handle the "required code unit", if one is set. In the case of an anchored - pattern, do this only if it follows a variable length item in the pattern. */ + /* Handle the "required code unit", if one is set. In the UTF case we can + increment the minimum minimum length only if we are sure this really is a + different character and not a non-starting code unit of the first character, + because the minimum length count is in characters, not code units. */ - if (reqcuflags >= 0 && - ((re->overall_options & PCRE2_ANCHORED) == 0 || - (reqcuflags & REQ_VARY) != 0)) + if (reqcuflags >= 0) { - re->last_codeunit = reqcu; - re->flags |= PCRE2_LASTSET; +#if PCRE2_CODE_UNIT_WIDTH == 16 + if ((re->overall_options & PCRE2_UTF) == 0 || /* Not UTF */ + firstcuflags < 0 || /* First not set */ + (firstcu & 0xf800) != 0xd800 || /* First not surrogate */ + (reqcu & 0xfc00) != 0xdc00) /* Req not low surrogate */ +#elif PCRE2_CODE_UNIT_WIDTH == 8 + if ((re->overall_options & PCRE2_UTF) == 0 || /* Not UTF */ + firstcuflags < 0 || /* First not set */ + (firstcu & 0x80) == 0 || /* First is ASCII */ + (reqcu & 0x80) == 0) /* Req is ASCII */ +#endif + { + minminlength++; + } - /* Handle caseless required code units as for first code units (above). */ + /* In the case of an anchored pattern, set up the value only if it follows + a variable length item in the pattern. */ - if ((reqcuflags & REQ_CASELESS) != 0) + if ((re->overall_options & PCRE2_ANCHORED) == 0 || + (reqcuflags & REQ_VARY) != 0) { - if (reqcu < 128 || (!utf && reqcu < 255)) + re->last_codeunit = reqcu; + re->flags |= PCRE2_LASTSET; + + /* Handle caseless required code units as for first code units (above). */ + + if ((reqcuflags & REQ_CASELESS) != 0) { - if (cb.fcc[reqcu] != reqcu) re->flags |= PCRE2_LASTCASELESS; - } + if (reqcu < 128 || (!utf && reqcu < 255)) + { + if (cb.fcc[reqcu] != reqcu) re->flags |= PCRE2_LASTCASELESS; + } #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 8 - else if (reqcu <= MAX_UTF_CODE_POINT && UCD_OTHERCASE(reqcu) != reqcu) - re->flags |= PCRE2_LASTCASELESS; + else if (reqcu <= MAX_UTF_CODE_POINT && UCD_OTHERCASE(reqcu) != reqcu) + re->flags |= PCRE2_LASTCASELESS; #endif + } } } - /* Finally, study the compiled pattern to set up information such as a bitmap - of starting code units and a minimum matching length. */ + /* Study the compiled pattern to set up information such as a bitmap of + starting code units and a minimum matching length. */ if (PRIV(study)(re) != 0) { errorcode = ERR31; goto HAD_CB_ERROR; } + + /* If study() set a bitmap of starting code units, it implies a minimum + length of at least one. */ + + if ((re->flags & PCRE2_FIRSTMAPSET) != 0 && minminlength == 0) + minminlength = 1; + + /* If the minimum length set (or not set) by study() is less than the minimum + implied by required code units, override it. */ + + if (re->minlength < minminlength) re->minlength = minminlength; } /* End of start-of-match optimizations. */ /* Control ends up here in all cases. When running under valgrind, make a diff --git a/src/3rdparty/pcre2/src/pcre2_context.c b/src/3rdparty/pcre2/src/pcre2_context.c index 9c2886a6d0..f904a494a0 100644 --- a/src/3rdparty/pcre2/src/pcre2_context.c +++ b/src/3rdparty/pcre2/src/pcre2_context.c @@ -323,7 +323,7 @@ data. */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_set_character_tables(pcre2_compile_context *ccontext, - const unsigned char *tables) + const uint8_t *tables) { ccontext->tables = tables; return 0; diff --git a/src/3rdparty/pcre2/src/pcre2_dfa_match.c b/src/3rdparty/pcre2/src/pcre2_dfa_match.c index bbf3e21064..7d8ffe8a3e 100644 --- a/src/3rdparty/pcre2/src/pcre2_dfa_match.c +++ b/src/3rdparty/pcre2/src/pcre2_dfa_match.c @@ -173,6 +173,8 @@ static const uint8_t coptable[] = { 0, /* Assert not */ 0, /* Assert behind */ 0, /* Assert behind not */ + 0, /* NA assert */ + 0, /* NA assert behind */ 0, /* ONCE */ 0, /* SCRIPT_RUN */ 0, 0, 0, 0, 0, /* BRA, BRAPOS, CBRA, CBRAPOS, COND */ @@ -248,6 +250,8 @@ static const uint8_t poptable[] = { 0, /* Assert not */ 0, /* Assert behind */ 0, /* Assert behind not */ + 0, /* NA assert */ + 0, /* NA assert behind */ 0, /* ONCE */ 0, /* SCRIPT_RUN */ 0, 0, 0, 0, 0, /* BRA, BRAPOS, CBRA, CBRAPOS, COND */ @@ -962,7 +966,7 @@ for (;;) if (ptr >= end_subject) { if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) - could_continue = TRUE; + return PCRE2_ERROR_PARTIAL; else { ADD_ACTIVE(state_offset + 1, 0); } } break; @@ -1011,10 +1015,12 @@ for (;;) /*-----------------------------------------------------------------*/ case OP_EODN: - if (clen == 0 && (mb->moptions & PCRE2_PARTIAL_HARD) != 0) - could_continue = TRUE; - else if (clen == 0 || (IS_NEWLINE(ptr) && ptr == end_subject - mb->nllen)) - { ADD_ACTIVE(state_offset + 1, 0); } + if (clen == 0 || (IS_NEWLINE(ptr) && ptr == end_subject - mb->nllen)) + { + if ((mb->moptions & PCRE2_PARTIAL_HARD) != 0) + return PCRE2_ERROR_PARTIAL; + ADD_ACTIVE(state_offset + 1, 0); + } break; /*-----------------------------------------------------------------*/ @@ -3152,8 +3158,8 @@ for (;;) /* We have finished the processing at the current subject character. If no new states have been set for the next character, we have found all the - matches that we are going to find. If we are at the top level and partial - matching has been requested, check for appropriate conditions. + matches that we are going to find. If partial matching has been requested, + check for appropriate conditions. The "forced_ fail" variable counts the number of (*F) encountered for the character. If it is equal to the original active_count (saved in @@ -3165,22 +3171,24 @@ for (;;) if (new_count <= 0) { - if (rlevel == 1 && /* Top level, and */ - could_continue && /* Some could go on, and */ + if (could_continue && /* Some could go on, and */ forced_fail != workspace[1] && /* Not all forced fail & */ ( /* either... */ (mb->moptions & PCRE2_PARTIAL_HARD) != 0 /* Hard partial */ || /* or... */ ((mb->moptions & PCRE2_PARTIAL_SOFT) != 0 && /* Soft partial and */ - match_count < 0) /* no matches */ + match_count < 0) /* no matches */ ) && /* And... */ ( - partial_newline || /* Either partial NL */ - ( /* or ... */ - ptr >= end_subject && /* End of subject and */ - ptr > mb->start_used_ptr) /* Inspected non-empty string */ + partial_newline || /* Either partial NL */ + ( /* or ... */ + ptr >= end_subject && /* End of subject and */ + ( /* either */ + ptr > mb->start_used_ptr || /* Inspected non-empty string */ + mb->allowemptypartial /* or pattern has lookbehind */ + ) /* or could match empty */ ) - ) + )) match_count = PCRE2_ERROR_PARTIAL; break; /* Exit from loop along the subject string */ } @@ -3246,6 +3254,11 @@ BOOL utf, anchored, startline, firstline; BOOL has_first_cu = FALSE; BOOL has_req_cu = FALSE; +#if PCRE2_CODE_UNIT_WIDTH == 8 +BOOL memchr_not_found_first_cu = FALSE; +BOOL memchr_not_found_first_cu2 = FALSE; +#endif + PCRE2_UCHAR first_cu = 0; PCRE2_UCHAR first_cu2 = 0; PCRE2_UCHAR req_cu = 0; @@ -3295,6 +3308,11 @@ if ((options & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) != 0 && ((re->overall_options | options) & PCRE2_ENDANCHORED) != 0) return PCRE2_ERROR_BADOPTION; +/* Invalid UTF support is not available for DFA matching. */ + +if ((re->overall_options & PCRE2_MATCH_INVALID_UTF) != 0) + return PCRE2_ERROR_DFA_UINVALID_UTF; + /* Check that the first field in the block is the magic number. If it is not, return with PCRE2_ERROR_BADMAGIC. */ @@ -3404,6 +3422,8 @@ mb->tables = re->tables; mb->start_subject = subject; mb->end_subject = end_subject; mb->start_offset = start_offset; +mb->allowemptypartial = (re->max_lookbehind > 0) || + (re->flags & PCRE2_MATCH_EMPTY) != 0; mb->moptions = options; mb->poptions = re->overall_options; mb->match_call_count = 0; @@ -3619,7 +3639,10 @@ for (;;) /* Not anchored. Advance to a unique first code unit if there is one. In 8-bit mode, the use of memchr() gives a big speed up, even though we have to call it twice in caseless mode, in order to find the earliest occurrence - of the character in either of its cases. */ + of the character in either of its cases. If a call to memchr() that + searches the rest of the subject fails to find one case, remember that in + order not to keep on repeating the search. This can make a huge difference + when the strings are very long and only one case is present. */ else { @@ -3633,11 +3656,29 @@ for (;;) (smc = UCHAR21TEST(start_match)) != first_cu && smc != first_cu2) start_match++; + #else /* 8-bit code units */ - PCRE2_SPTR pp1 = - memchr(start_match, first_cu, end_subject-start_match); - PCRE2_SPTR pp2 = - memchr(start_match, first_cu2, end_subject-start_match); + PCRE2_SPTR pp1 = NULL; + PCRE2_SPTR pp2 = NULL; + PCRE2_SIZE cu2size = end_subject - start_match; + + if (!memchr_not_found_first_cu) + { + pp1 = memchr(start_match, first_cu, end_subject - start_match); + if (pp1 == NULL) memchr_not_found_first_cu = TRUE; + else cu2size = pp1 - start_match; + } + + /* If pp1 is not NULL, we have arranged to search only as far as pp1, + to see if the other case is earlier, so we can set "not found" only + when both searches have returned NULL. */ + + if (!memchr_not_found_first_cu2) + { + pp2 = memchr(start_match, first_cu2, cu2size); + memchr_not_found_first_cu2 = (pp2 == NULL && pp1 == NULL); + } + if (pp1 == NULL) start_match = (pp2 == NULL)? end_subject : pp2; else @@ -3653,7 +3694,7 @@ for (;;) while (start_match < end_subject && UCHAR21TEST(start_match) != first_cu) start_match++; -#else +#else /* 8-bit code units */ start_match = memchr(start_match, first_cu, end_subject - start_match); if (start_match == NULL) start_match = end_subject; #endif @@ -3740,6 +3781,8 @@ for (;;) if ((mb->moptions & (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT)) == 0) { + PCRE2_SPTR p; + /* The minimum matching length is a lower bound; no actual string of that length may actually match the pattern. Although the value is, strictly, in characters, we treat it as code units to avoid spending too much time @@ -3753,37 +3796,63 @@ for (;;) point. This optimization can save a huge amount of backtracking in patterns with nested unlimited repeats that aren't going to match. Writing separate code for cased/caseless versions makes it go faster, as - does using an autoincrement and backing off on a match. + does using an autoincrement and backing off on a match. As in the case of + the first code unit, using memchr() in the 8-bit library gives a big + speed up. Unlike the first_cu check above, we do not need to call + memchr() twice in the caseless case because we only need to check for the + presence of the character in either case, not find the first occurrence. + + The search can be skipped if the code unit was found later than the + current starting point in a previous iteration of the bumpalong loop. HOWEVER: when the subject string is very, very long, searching to its end can take a long time, and give bad performance on quite ordinary patterns. This showed up when somebody was matching something like /^\d+C/ on a 32-megabyte string... so we don't do this when the string is - sufficiently long. */ + sufficiently long, but it's worth searching a lot more for unanchored + patterns. */ - if (has_req_cu && end_subject - start_match < REQ_CU_MAX) + p = start_match + (has_first_cu? 1:0); + if (has_req_cu && p > req_cu_ptr) { - PCRE2_SPTR p = start_match + (has_first_cu? 1:0); - - /* We don't need to repeat the search if we haven't yet reached the - place we found it at last time. */ + PCRE2_SIZE check_length = end_subject - start_match; - if (p > req_cu_ptr) + if (check_length < REQ_CU_MAX || + (!anchored && check_length < REQ_CU_MAX * 1000)) { - if (req_cu != req_cu2) + if (req_cu != req_cu2) /* Caseless */ { +#if PCRE2_CODE_UNIT_WIDTH != 8 while (p < end_subject) { uint32_t pp = UCHAR21INCTEST(p); if (pp == req_cu || pp == req_cu2) { p--; break; } } +#else /* 8-bit code units */ + PCRE2_SPTR pp = p; + p = memchr(pp, req_cu, end_subject - pp); + if (p == NULL) + { + p = memchr(pp, req_cu2, end_subject - pp); + if (p == NULL) p = end_subject; + } +#endif /* PCRE2_CODE_UNIT_WIDTH != 8 */ } + + /* The caseful case */ + else { +#if PCRE2_CODE_UNIT_WIDTH != 8 while (p < end_subject) { if (UCHAR21INCTEST(p) == req_cu) { p--; break; } } + +#else /* 8-bit code units */ + p = memchr(p, req_cu, end_subject - p); + if (p == NULL) p = end_subject; +#endif } /* If we can't find the required code unit, break the matching loop, diff --git a/src/3rdparty/pcre2/src/pcre2_error.c b/src/3rdparty/pcre2/src/pcre2_error.c index 1d02cf14a3..c61648cb7f 100644 --- a/src/3rdparty/pcre2/src/pcre2_error.c +++ b/src/3rdparty/pcre2/src/pcre2_error.c @@ -184,6 +184,8 @@ static const unsigned char compile_error_texts[] = /* 95 */ "(*alpha_assertion) not recognized\0" "script runs require Unicode support, which this version of PCRE2 does not have\0" + "too many capturing groups (maximum 65535)\0" + "atomic assertion expected after (?( or (?(?C)\0" ; /* Match-time and UTF error texts are in the same format. */ @@ -268,6 +270,7 @@ static const unsigned char match_error_texts[] = "invalid syntax\0" /* 65 */ "internal error - duplicate substitution match\0" + "PCRE2_MATCH_INVALID_UTF is not supported for DFA matching\0" ; diff --git a/src/3rdparty/pcre2/src/pcre2_internal.h b/src/3rdparty/pcre2/src/pcre2_internal.h index 814d91bddb..fe8ffe5c80 100644 --- a/src/3rdparty/pcre2/src/pcre2_internal.h +++ b/src/3rdparty/pcre2/src/pcre2_internal.h @@ -517,6 +517,7 @@ bytes in a code unit in that mode. */ #define PCRE2_HASBKPORX 0x00100000 /* contains \P, \p, or \X */ #define PCRE2_DUPCAPUSED 0x00200000 /* contains (?| */ #define PCRE2_HASBKC 0x00400000 /* contains \C */ +#define PCRE2_HASACCEPT 0x00800000 /* contains (*ACCEPT) */ #define PCRE2_MODE_MASK (PCRE2_MODE8 | PCRE2_MODE16 | PCRE2_MODE32) @@ -535,13 +536,14 @@ enum { PCRE2_MATCHEDBY_INTERPRETER, /* pcre2_match() */ #define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */ /* The maximum remaining length of subject we are prepared to search for a -req_unit match. In 8-bit mode, memchr() is used and is much faster than the -search loop that has to be used in 16-bit and 32-bit modes. */ +req_unit match from an anchored pattern. In 8-bit mode, memchr() is used and is +much faster than the search loop that has to be used in 16-bit and 32-bit +modes. */ #if PCRE2_CODE_UNIT_WIDTH == 8 -#define REQ_CU_MAX 2000 +#define REQ_CU_MAX 5000 #else -#define REQ_CU_MAX 1000 +#define REQ_CU_MAX 2000 #endif /* Offsets for the bitmap tables in the cbits set of tables. Each table @@ -881,12 +883,16 @@ a positive value. */ #define STRING_atomic0 "atomic\0" #define STRING_pla0 "pla\0" #define STRING_plb0 "plb\0" +#define STRING_napla0 "napla\0" +#define STRING_naplb0 "naplb\0" #define STRING_nla0 "nla\0" #define STRING_nlb0 "nlb\0" #define STRING_sr0 "sr\0" #define STRING_asr0 "asr\0" #define STRING_positive_lookahead0 "positive_lookahead\0" #define STRING_positive_lookbehind0 "positive_lookbehind\0" +#define STRING_non_atomic_positive_lookahead0 "non_atomic_positive_lookahead\0" +#define STRING_non_atomic_positive_lookbehind0 "non_atomic_positive_lookbehind\0" #define STRING_negative_lookahead0 "negative_lookahead\0" #define STRING_negative_lookbehind0 "negative_lookbehind\0" #define STRING_script_run0 "script_run\0" @@ -1171,12 +1177,16 @@ only. */ #define STRING_atomic0 STR_a STR_t STR_o STR_m STR_i STR_c "\0" #define STRING_pla0 STR_p STR_l STR_a "\0" #define STRING_plb0 STR_p STR_l STR_b "\0" +#define STRING_napla0 STR_n STR_a STR_p STR_l STR_a "\0" +#define STRING_naplb0 STR_n STR_a STR_p STR_l STR_b "\0" #define STRING_nla0 STR_n STR_l STR_a "\0" #define STRING_nlb0 STR_n STR_l STR_b "\0" #define STRING_sr0 STR_s STR_r "\0" #define STRING_asr0 STR_a STR_s STR_r "\0" #define STRING_positive_lookahead0 STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_a STR_h STR_e STR_a STR_d "\0" #define STRING_positive_lookbehind0 STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_b STR_e STR_h STR_i STR_n STR_d "\0" +#define STRING_non_atomic_positive_lookahead0 STR_n STR_o STR_n STR_UNDERSCORE STR_a STR_t STR_o STR_m STR_i STR_c STR_UNDERSCORE STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_a STR_h STR_e STR_a STR_d "\0" +#define STRING_non_atomic_positive_lookbehind0 STR_n STR_o STR_n STR_UNDERSCORE STR_a STR_t STR_o STR_m STR_i STR_c STR_UNDERSCORE STR_p STR_o STR_s STR_i STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_b STR_e STR_h STR_i STR_n STR_d "\0" #define STRING_negative_lookahead0 STR_n STR_e STR_g STR_a STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_a STR_h STR_e STR_a STR_d "\0" #define STRING_negative_lookbehind0 STR_n STR_e STR_g STR_a STR_t STR_i STR_v STR_e STR_UNDERSCORE STR_l STR_o STR_o STR_k STR_b STR_e STR_h STR_i STR_n STR_d "\0" #define STRING_script_run0 STR_s STR_c STR_r STR_i STR_p STR_t STR_UNDERSCORE STR_r STR_u STR_n "\0" @@ -1301,7 +1311,7 @@ enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s, Starting from 1 (i.e. after OP_END), the values up to OP_EOD must correspond in order to the list of escapes immediately above. Furthermore, values up to OP_DOLLM must not be changed without adjusting the table called autoposstab in -pcre2_auto_possess.c +pcre2_auto_possess.c. Whenever this list is updated, the two macro definitions that follow must be updated to match. The possessification table called "opcode_possessify" in @@ -1499,80 +1509,81 @@ enum { OP_KETRMIN, /* 123 order. They are for groups the repeat for ever. */ OP_KETRPOS, /* 124 Possessive unlimited repeat. */ - /* The assertions must come before BRA, CBRA, ONCE, and COND, and the four - asserts must remain in order. */ + /* The assertions must come before BRA, CBRA, ONCE, and COND. */ OP_REVERSE, /* 125 Move pointer back - used in lookbehind assertions */ OP_ASSERT, /* 126 Positive lookahead */ OP_ASSERT_NOT, /* 127 Negative lookahead */ OP_ASSERTBACK, /* 128 Positive lookbehind */ OP_ASSERTBACK_NOT, /* 129 Negative lookbehind */ + OP_ASSERT_NA, /* 130 Positive non-atomic lookahead */ + OP_ASSERTBACK_NA, /* 131 Positive non-atomic lookbehind */ /* ONCE, SCRIPT_RUN, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come immediately after the assertions, with ONCE first, as there's a test for >= ONCE for a subpattern that isn't an assertion. The POS versions must immediately follow the non-POS versions in each case. */ - OP_ONCE, /* 130 Atomic group, contains captures */ - OP_SCRIPT_RUN, /* 131 Non-capture, but check characters' scripts */ - OP_BRA, /* 132 Start of non-capturing bracket */ - OP_BRAPOS, /* 133 Ditto, with unlimited, possessive repeat */ - OP_CBRA, /* 134 Start of capturing bracket */ - OP_CBRAPOS, /* 135 Ditto, with unlimited, possessive repeat */ - OP_COND, /* 136 Conditional group */ + OP_ONCE, /* 132 Atomic group, contains captures */ + OP_SCRIPT_RUN, /* 133 Non-capture, but check characters' scripts */ + OP_BRA, /* 134 Start of non-capturing bracket */ + OP_BRAPOS, /* 135 Ditto, with unlimited, possessive repeat */ + OP_CBRA, /* 136 Start of capturing bracket */ + OP_CBRAPOS, /* 137 Ditto, with unlimited, possessive repeat */ + OP_COND, /* 138 Conditional group */ /* These five must follow the previous five, in the same order. There's a check for >= SBRA to distinguish the two sets. */ - OP_SBRA, /* 137 Start of non-capturing bracket, check empty */ - OP_SBRAPOS, /* 138 Ditto, with unlimited, possessive repeat */ - OP_SCBRA, /* 139 Start of capturing bracket, check empty */ - OP_SCBRAPOS, /* 140 Ditto, with unlimited, possessive repeat */ - OP_SCOND, /* 141 Conditional group, check empty */ + OP_SBRA, /* 139 Start of non-capturing bracket, check empty */ + OP_SBRAPOS, /* 149 Ditto, with unlimited, possessive repeat */ + OP_SCBRA, /* 141 Start of capturing bracket, check empty */ + OP_SCBRAPOS, /* 142 Ditto, with unlimited, possessive repeat */ + OP_SCOND, /* 143 Conditional group, check empty */ /* The next two pairs must (respectively) be kept together. */ - OP_CREF, /* 142 Used to hold a capture number as condition */ - OP_DNCREF, /* 143 Used to point to duplicate names as a condition */ - OP_RREF, /* 144 Used to hold a recursion number as condition */ - OP_DNRREF, /* 145 Used to point to duplicate names as a condition */ - OP_FALSE, /* 146 Always false (used by DEFINE and VERSION) */ - OP_TRUE, /* 147 Always true (used by VERSION) */ + OP_CREF, /* 144 Used to hold a capture number as condition */ + OP_DNCREF, /* 145 Used to point to duplicate names as a condition */ + OP_RREF, /* 146 Used to hold a recursion number as condition */ + OP_DNRREF, /* 147 Used to point to duplicate names as a condition */ + OP_FALSE, /* 148 Always false (used by DEFINE and VERSION) */ + OP_TRUE, /* 149 Always true (used by VERSION) */ - OP_BRAZERO, /* 148 These two must remain together and in this */ - OP_BRAMINZERO, /* 149 order. */ - OP_BRAPOSZERO, /* 150 */ + OP_BRAZERO, /* 150 These two must remain together and in this */ + OP_BRAMINZERO, /* 151 order. */ + OP_BRAPOSZERO, /* 152 */ /* These are backtracking control verbs */ - OP_MARK, /* 151 always has an argument */ - OP_PRUNE, /* 152 */ - OP_PRUNE_ARG, /* 153 same, but with argument */ - OP_SKIP, /* 154 */ - OP_SKIP_ARG, /* 155 same, but with argument */ - OP_THEN, /* 156 */ - OP_THEN_ARG, /* 157 same, but with argument */ - OP_COMMIT, /* 158 */ - OP_COMMIT_ARG, /* 159 same, but with argument */ + OP_MARK, /* 153 always has an argument */ + OP_PRUNE, /* 154 */ + OP_PRUNE_ARG, /* 155 same, but with argument */ + OP_SKIP, /* 156 */ + OP_SKIP_ARG, /* 157 same, but with argument */ + OP_THEN, /* 158 */ + OP_THEN_ARG, /* 159 same, but with argument */ + OP_COMMIT, /* 160 */ + OP_COMMIT_ARG, /* 161 same, but with argument */ /* These are forced failure and success verbs. FAIL and ACCEPT do accept an argument, but these cases can be compiled as, for example, (*MARK:X)(*FAIL) without the need for a special opcode. */ - OP_FAIL, /* 160 */ - OP_ACCEPT, /* 161 */ - OP_ASSERT_ACCEPT, /* 162 Used inside assertions */ - OP_CLOSE, /* 163 Used before OP_ACCEPT to close open captures */ + OP_FAIL, /* 162 */ + OP_ACCEPT, /* 163 */ + OP_ASSERT_ACCEPT, /* 164 Used inside assertions */ + OP_CLOSE, /* 165 Used before OP_ACCEPT to close open captures */ /* This is used to skip a subpattern with a {0} quantifier */ - OP_SKIPZERO, /* 164 */ + OP_SKIPZERO, /* 166 */ /* This is used to identify a DEFINE group during compilation so that it can be checked for having only one branch. It is changed to OP_FALSE before compilation finishes. */ - OP_DEFINE, /* 165 */ + OP_DEFINE, /* 167 */ /* This is not an opcode, but is used to check that tables indexed by opcode are the correct length, in order to catch updating errors - there have been @@ -1585,7 +1596,7 @@ enum { /* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro definitions that follow must also be updated to match. There are also tables called "opcode_possessify" in pcre2_compile.c and "coptable" and "poptable" in -pcre2_dfa_exec.c that must be updated. */ +pcre2_dfa_match.c that must be updated. */ /* This macro defines textual names for all the opcodes. These are used only @@ -1618,7 +1629,9 @@ some cases doesn't actually use these names at all). */ "class", "nclass", "xclass", "Ref", "Refi", "DnRef", "DnRefi", \ "Recurse", "Callout", "CalloutStr", \ "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos", \ - "Reverse", "Assert", "Assert not", "AssertB", "AssertB not", \ + "Reverse", "Assert", "Assert not", \ + "Assert back", "Assert back not", \ + "Non-atomic assert", "Non-atomic assert back", \ "Once", \ "Script run", \ "Bra", "BraPos", "CBra", "CBraPos", \ @@ -1703,6 +1716,8 @@ in UTF-8 mode. The code that uses this table must know about such things. */ 1+LINK_SIZE, /* Assert not */ \ 1+LINK_SIZE, /* Assert behind */ \ 1+LINK_SIZE, /* Assert behind not */ \ + 1+LINK_SIZE, /* NA Assert */ \ + 1+LINK_SIZE, /* NA Assert behind */ \ 1+LINK_SIZE, /* ONCE */ \ 1+LINK_SIZE, /* SCRIPT_RUN */ \ 1+LINK_SIZE, /* BRA */ \ diff --git a/src/3rdparty/pcre2/src/pcre2_intmodedep.h b/src/3rdparty/pcre2/src/pcre2_intmodedep.h index bf3a235984..ea3b3ec698 100644 --- a/src/3rdparty/pcre2/src/pcre2_intmodedep.h +++ b/src/3rdparty/pcre2/src/pcre2_intmodedep.h @@ -205,19 +205,19 @@ whether its argument, which is assumed to be one code unit, is less than 256. The CHMAX_255 macro does not assume one code unit. The maximum length of a MARK name must fit in one code unit; currently it is set to 255 or 65535. The TABLE_GET macro is used to access elements of tables containing exactly 256 -items. When code points can be greater than 255, a check is needed before -accessing these tables. */ +items. Its argument is a code unit. When code points can be greater than 255, a +check is needed before accessing these tables. */ #if PCRE2_CODE_UNIT_WIDTH == 8 #define MAX_255(c) TRUE #define MAX_MARK ((1u << 8) - 1) +#define TABLE_GET(c, table, default) ((table)[c]) #ifdef SUPPORT_UNICODE #define SUPPORT_WIDE_CHARS #define CHMAX_255(c) ((c) <= 255u) #else #define CHMAX_255(c) TRUE #endif /* SUPPORT_UNICODE */ -#define TABLE_GET(c, table, default) ((table)[c]) #else /* Code units are 16 or 32 bits */ #define CHMAX_255(c) ((c) <= 255u) @@ -228,7 +228,6 @@ accessing these tables. */ #endif - /* ----------------- Character-handling macros ----------------- */ /* There is a proposed future special "UTF-21" mode, in which only the lowest @@ -854,6 +853,7 @@ typedef struct match_block { uint32_t match_call_count; /* Number of times a new frame is created */ BOOL hitend; /* Hit the end of the subject at some point */ BOOL hasthen; /* Pattern contains (*THEN) */ + BOOL allowemptypartial; /* Allow empty hard partial */ const uint8_t *lcc; /* Points to lower casing table */ const uint8_t *fcc; /* Points to case-flipping table */ const uint8_t *ctypes; /* Points to table of type maps */ @@ -866,6 +866,7 @@ typedef struct match_block { PCRE2_SPTR name_table; /* Table of group names */ PCRE2_SPTR start_code; /* For use when recursing */ PCRE2_SPTR start_subject; /* Start of the subject string */ + PCRE2_SPTR check_subject; /* Where UTF-checked from */ PCRE2_SPTR end_subject; /* End of the subject string */ PCRE2_SPTR end_match_ptr; /* Subject position at end match */ PCRE2_SPTR start_used_ptr; /* Earliest consulted character */ @@ -908,6 +909,7 @@ typedef struct dfa_match_block { uint32_t poptions; /* Pattern options */ uint32_t nltype; /* Newline type */ uint32_t nllen; /* Newline string length */ + BOOL allowemptypartial; /* Allow empty hard partial */ PCRE2_UCHAR nl[4]; /* Newline string when fixed */ uint16_t bsr_convention; /* \R interpretation */ pcre2_callout_block *cb; /* Points to a callout block */ diff --git a/src/3rdparty/pcre2/src/pcre2_jit_compile.c b/src/3rdparty/pcre2/src/pcre2_jit_compile.c index 1f21bfb6ad..f564127c2a 100644 --- a/src/3rdparty/pcre2/src/pcre2_jit_compile.c +++ b/src/3rdparty/pcre2/src/pcre2_jit_compile.c @@ -6,8 +6,9 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel + This module by Zoltan Herczeg Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -212,12 +213,6 @@ typedef struct stub_list { struct stub_list *next; } stub_list; -typedef struct label_addr_list { - struct sljit_label *label; - sljit_uw *update_addr; - struct label_addr_list *next; -} label_addr_list; - enum frame_types { no_frame = -1, no_stack = -2 @@ -271,6 +266,8 @@ typedef struct bracket_backtrack { assert_backtrack *assert; /* For OP_ONCE. Less than 0 if not needed. */ int framesize; + /* For brackets with >3 alternatives. */ + struct sljit_put_label *matching_put_label; } u; /* Points to our private memory word on the stack. */ int private_data_ptr; @@ -416,6 +413,8 @@ typedef struct compiler_common { sljit_sw lcc; /* Mode can be PCRE2_JIT_COMPLETE and others. */ int mode; + /* TRUE, when empty match is accepted for partial matching. */ + BOOL allow_empty_partial; /* TRUE, when minlength is greater than 0. */ BOOL might_be_empty; /* \K is found in the pattern. */ @@ -454,7 +453,6 @@ typedef struct compiler_common { struct sljit_label *accept_label; struct sljit_label *ff_newline_shortcut; stub_list *stubs; - label_addr_list *label_addrs; recurse_entry *entries; recurse_entry *currententry; jump_list *partialmatch; @@ -563,6 +561,12 @@ typedef struct compare_context { #define ARGUMENTS SLJIT_S4 #define RETURN_ADDR SLJIT_R4 +#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) +#define HAS_VIRTUAL_REGISTERS 1 +#else +#define HAS_VIRTUAL_REGISTERS 0 +#endif + /* Local space layout. */ /* These two locals can be used by the current opcode. */ #define LOCALS0 (0 * sizeof(sljit_sw)) @@ -696,11 +700,12 @@ the start pointers when the end of the capturing group has not yet reached. */ #define GETCHARBACK_INVALID(c, ptr, start, invalid_action) \ { \ - if (ptr[-1] <= 0x7f) \ - c = *ptr--; \ + c = ptr[-1]; \ + if (c <= 0x7f) \ + ptr--; \ else if (ptr - 1 > start && ptr[-1] >= 0x80 && ptr[-1] < 0xc0) \ { \ - c = ptr[-1] - 0x80; \ + c -= 0x80; \ \ if (ptr[-2] >= 0xc2 && ptr[-2] <= 0xdf) \ { \ @@ -775,11 +780,12 @@ the start pointers when the end of the capturing group has not yet reached. */ #define GETCHARBACK_INVALID(c, ptr, start, invalid_action) \ { \ - if (ptr[-1] < 0xd800 || ptr[-1] >= 0xe000) \ - c = *ptr--; \ - else if (ptr[-1] >= 0xdc00 && ptr - 1 > start && ptr[-2] >= 0xd800 && ptr[-2] < 0xdc00) \ + c = ptr[-1]; \ + if (c < 0xd800 || c >= 0xe000) \ + ptr--; \ + else if (c >= 0xdc00 && ptr - 1 > start && ptr[-2] >= 0xd800 && ptr[-2] < 0xdc00) \ { \ - c = (((ptr[-2] - 0xd800) << 10) | (ptr[-1] - 0xdc00)) + 0x10000; \ + c = (((ptr[-2] - 0xd800) << 10) | (c - 0xdc00)) + 0x10000; \ ptr -= 2; \ } \ else \ @@ -793,7 +799,7 @@ the start pointers when the end of the capturing group has not yet reached. */ #define GETCHARINC_INVALID(c, ptr, end, invalid_action) \ { \ - if (ptr[0] < 0x110000) \ + if (ptr[0] < 0xd800 || (ptr[0] >= 0xe000 && ptr[0] < 0x110000)) \ c = *ptr++; \ else \ { \ @@ -801,6 +807,17 @@ the start pointers when the end of the capturing group has not yet reached. */ } \ } +#define GETCHARBACK_INVALID(c, ptr, start, invalid_action) \ + { \ + c = ptr[-1]; \ + if (ptr[-1] < 0xd800 || (ptr[-1] >= 0xe000 && ptr[-1] < 0x110000)) \ + ptr--; \ + else \ + { \ + invalid_action; \ + } \ + } + #endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */ #endif /* SUPPORT_UNICODE */ @@ -1033,8 +1050,8 @@ switch(*cc) return cc + 1 + 2 + cc[1]; default: - /* All opcodes are supported now! */ - SLJIT_UNREACHABLE(); + /* Unsupported opcodes: OP_ASSERT_NA and OP_ASSERTBACK_NA */ + /* SLJIT_UNREACHABLE(); */ return NULL; } } @@ -2371,14 +2388,14 @@ if (base_reg != TMP2) else { status.saved_tmp_regs[1] = RETURN_ADDR; - if (sljit_get_register_index(RETURN_ADDR) == -1) + if (HAS_VIRTUAL_REGISTERS) status.tmp_regs[1] = STR_PTR; else status.tmp_regs[1] = RETURN_ADDR; } status.saved_tmp_regs[2] = TMP3; -if (sljit_get_register_index(TMP3) == -1) +if (HAS_VIRTUAL_REGISTERS) status.tmp_regs[2] = STR_END; else status.tmp_regs[2] = TMP3; @@ -2829,20 +2846,6 @@ while (list_item) common->stubs = NULL; } -static void add_label_addr(compiler_common *common, sljit_uw *update_addr) -{ -DEFINE_COMPILER; -label_addr_list *label_addr; - -label_addr = sljit_alloc_memory(compiler, sizeof(label_addr_list)); -if (label_addr == NULL) - return; -label_addr->label = LABEL(); -label_addr->update_addr = update_addr; -label_addr->next = common->label_addrs; -common->label_addrs = label_addr; -} - static SLJIT_INLINE void count_match(compiler_common *common) { DEFINE_COMPILER; @@ -2985,12 +2988,18 @@ else } } -OP1(SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0); +if (!HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, stack)); +else + OP1(SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0); + if (common->mark_ptr != 0) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, SLJIT_IMM, 0); if (common->control_head_ptr != 0) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0); -OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack)); +if (HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack)); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr); OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(struct sljit_stack, end)); } @@ -3029,21 +3038,36 @@ BOOL has_pre; OP1(SLJIT_MOV, SLJIT_S2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(1), STR_PTR, 0); -OP1(SLJIT_MOV, SLJIT_R0, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr); -if (common->mark_ptr != 0) - OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr); -OP1(SLJIT_MOV_U32, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, oveccount)); -OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, startchar_ptr), SLJIT_S0, 0); -if (common->mark_ptr != 0) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_R2, 0); -OP2(SLJIT_ADD, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, match_data), - SLJIT_IMM, SLJIT_OFFSETOF(pcre2_match_data, ovector) - sizeof(PCRE2_SIZE)); +if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, SLJIT_R0, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr); + if (common->mark_ptr != 0) + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr); + OP1(SLJIT_MOV_U32, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, oveccount)); + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, startchar_ptr), SLJIT_S0, 0); + if (common->mark_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_R2, 0); + OP2(SLJIT_ADD, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, match_data), + SLJIT_IMM, SLJIT_OFFSETOF(pcre2_match_data, ovector) - sizeof(PCRE2_SIZE)); + } +else + { + OP1(SLJIT_MOV, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr); + OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, match_data)); + if (common->mark_ptr != 0) + OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr); + OP1(SLJIT_MOV_U32, SLJIT_R1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, oveccount)); + OP1(SLJIT_MOV, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, startchar_ptr), SLJIT_S0, 0); + if (common->mark_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_R0, 0); + OP2(SLJIT_ADD, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, SLJIT_OFFSETOF(pcre2_match_data, ovector) - sizeof(PCRE2_SIZE)); + } has_pre = sljit_emit_mem(compiler, SLJIT_MOV | SLJIT_MEM_SUPP | SLJIT_MEM_PRE, SLJIT_S1, SLJIT_MEM1(SLJIT_S0), sizeof(sljit_sw)) == SLJIT_SUCCESS; GET_LOCAL_BASE(SLJIT_S0, 0, OVECTOR_START - (has_pre ? sizeof(sljit_sw) : 0)); -OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, begin)); +OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(HAS_VIRTUAL_REGISTERS ? SLJIT_R0 : ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); loop = LABEL(); @@ -3105,20 +3129,22 @@ static SLJIT_INLINE void return_with_partial_match(compiler_common *common, stru { DEFINE_COMPILER; sljit_s32 mov_opcode; +sljit_s32 arguments_reg = !HAS_VIRTUAL_REGISTERS ? ARGUMENTS : SLJIT_R1; SLJIT_COMPILE_ASSERT(STR_END == SLJIT_S0, str_end_must_be_saved_reg0); SLJIT_ASSERT(common->start_used_ptr != 0 && common->start_ptr != 0 && (common->mode == PCRE2_JIT_PARTIAL_SOFT ? common->hit_start != 0 : common->hit_start == 0)); -OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0); +if (arguments_reg != ARGUMENTS) + OP1(SLJIT_MOV, arguments_reg, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == PCRE2_JIT_PARTIAL_SOFT ? common->hit_start : common->start_ptr); OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE2_ERROR_PARTIAL); /* Store match begin and end. */ -OP1(SLJIT_MOV, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, begin)); -OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, startchar_ptr), SLJIT_R2, 0); -OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, match_data)); +OP1(SLJIT_MOV, SLJIT_S1, 0, SLJIT_MEM1(arguments_reg), SLJIT_OFFSETOF(jit_arguments, begin)); +OP1(SLJIT_MOV, SLJIT_MEM1(arguments_reg), SLJIT_OFFSETOF(jit_arguments, startchar_ptr), SLJIT_R2, 0); +OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_MEM1(arguments_reg), SLJIT_OFFSETOF(jit_arguments, match_data)); mov_opcode = (sizeof(PCRE2_SIZE) == 4) ? SLJIT_MOV_U32 : SLJIT_MOV; @@ -3279,7 +3305,7 @@ SLJIT_ASSERT(!force || common->mode != PCRE2_JIT_COMPLETE); if (common->mode == PCRE2_JIT_COMPLETE) return; -if (!force) +if (!force && !common->allow_empty_partial) jump = CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0); else if (common->mode == PCRE2_JIT_PARTIAL_SOFT) jump = CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1); @@ -3341,7 +3367,11 @@ if (common->mode == PCRE2_JIT_COMPLETE) /* Partial matching mode. */ jump = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); -add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0)); +if (!common->allow_empty_partial) + add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0)); +else if (common->mode == PCRE2_JIT_PARTIAL_SOFT) + add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1)); + if (common->mode == PCRE2_JIT_PARTIAL_SOFT) { OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0); @@ -3357,6 +3387,35 @@ else JUMPHERE(jump); } +static void process_partial_match(compiler_common *common) +{ +DEFINE_COMPILER; +struct sljit_jump *jump; + +/* Partial matching mode. */ +if (common->mode == PCRE2_JIT_PARTIAL_SOFT) + { + jump = CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0); + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0); + JUMPHERE(jump); + } +else if (common->mode == PCRE2_JIT_PARTIAL_HARD) + { + if (common->partialmatchlabel != NULL) + CMPTO(SLJIT_LESS, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0, common->partialmatchlabel); + else + add_jump(compiler, &common->partialmatch, CMP(SLJIT_LESS, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0)); + } +} + +static void detect_partial_match_to(compiler_common *common, struct sljit_label *label) +{ +DEFINE_COMPILER; + +CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, label); +process_partial_match(common); +} + static void peek_char(compiler_common *common, sljit_u32 max, sljit_s32 dst, sljit_sw dstw, jump_list **backtracks) { /* Reads the character into TMP1, keeps STR_PTR. @@ -3420,12 +3479,21 @@ if (common->utf) #elif PCRE2_CODE_UNIT_WIDTH == 32 if (common->invalid_utf) { + if (max < 0xd800) return; + if (backtracks != NULL) + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x110000)); + add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800)); + } else { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); OP2(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x110000); CMOV(SLJIT_GREATER_EQUAL, TMP1, SLJIT_IMM, INVALID_UTF_CHAR); + OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800); + CMOV(SLJIT_LESS, TMP1, SLJIT_IMM, INVALID_UTF_CHAR); } } #endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */ @@ -3490,8 +3558,12 @@ if (common->utf) JUMPHERE(jump); } #elif PCRE2_CODE_UNIT_WIDTH == 32 - if (common->invalid_utf) - add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x110000)); +if (common->invalid_utf) + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); + add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x110000)); + add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800)); + } #endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */ #endif /* SUPPORT_UNICODE */ } @@ -3653,7 +3725,7 @@ if (common->utf) /* Skip low surrogate if necessary. */ OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); - if (sljit_has_cpu_feature(SLJIT_HAS_CMOV) && sljit_get_register_index(RETURN_ADDR) >= 0) + if (sljit_has_cpu_feature(SLJIT_HAS_CMOV) && !HAS_VIRTUAL_REGISTERS) { if (options & READ_CHAR_UPDATE_STR_PTR) OP2(SLJIT_ADD, RETURN_ADDR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); @@ -3677,11 +3749,18 @@ if (common->utf) if (common->invalid_utf) { if (backtracks != NULL) + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x110000)); + add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800)); + } else { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); OP2(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x110000); CMOV(SLJIT_GREATER_EQUAL, TMP1, SLJIT_IMM, INVALID_UTF_CHAR); + OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xe000 - 0xd800); + CMOV(SLJIT_LESS, TMP1, SLJIT_IMM, INVALID_UTF_CHAR); } } #endif /* PCRE2_CODE_UNIT_WIDTH == [8|16|32] */ @@ -3832,7 +3911,7 @@ if (common->utf && negated) { OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800); - if (sljit_has_cpu_feature(SLJIT_HAS_CMOV) && sljit_get_register_index(RETURN_ADDR) >= 0) + if (sljit_has_cpu_feature(SLJIT_HAS_CMOV) && !HAS_VIRTUAL_REGISTERS) { OP2(SLJIT_ADD, RETURN_ADDR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0x400); @@ -3865,9 +3944,9 @@ if (common->utf && negated) static void move_back(compiler_common *common, jump_list **backtracks, BOOL must_be_valid) { -/* Goes one character back. TMP2 must contain the start of -the subject buffer. Affects STR_PTR and TMP1. Does not modify -STR_PTR for invalid character sequences. */ +/* Goes one character back. Affects STR_PTR and TMP1. If must_be_valid is TRUE, +TMP2 is not used. Otherwise TMP2 must contain the start of the subject buffer, +and it is destroyed. Does not modify STR_PTR for invalid character sequences. */ DEFINE_COMPILER; SLJIT_UNUSED_ARG(backtracks); @@ -4407,7 +4486,7 @@ sljit_emit_fast_return(compiler, RETURN_ADDR, 0); static void do_utfpeakcharback(compiler_common *common) { -/* Peak a character back. */ +/* Peak a character back. Does not modify STR_PTR. */ DEFINE_COMPILER; struct sljit_jump *jump[2]; @@ -4444,7 +4523,7 @@ sljit_emit_fast_return(compiler, RETURN_ADDR, 0); static void do_utfpeakcharback_invalid(compiler_common *common) { -/* Peak a character back. */ +/* Peak a character back. Does not modify STR_PTR. */ DEFINE_COMPILER; sljit_s32 i; sljit_s32 has_cmov = sljit_has_cpu_feature(SLJIT_HAS_CMOV); @@ -4672,7 +4751,7 @@ sljit_emit_fast_return(compiler, RETURN_ADDR, 0); static void do_utfpeakcharback_invalid(compiler_common *common) { -/* Peak a character back. */ +/* Peak a character back. Does not modify STR_PTR. */ DEFINE_COMPILER; struct sljit_jump *jump; struct sljit_jump *exit_invalid[3]; @@ -4786,18 +4865,12 @@ OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2)); OP1(SLJIT_MOV_U16, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1); -// PH hacking -//fprintf(stderr, "~~A\n"); - OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2); - OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3); - OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype)); - +/* TMP2 is multiplied by 12. Same as (TMP2 << 2) + ((TMP2 << 2) << 1). */ OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype)); +OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2); +OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); +OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 1); - OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 0); - -// OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); } @@ -4866,15 +4939,27 @@ else if ((overall_options & PCRE2_USE_OFFSET_LIMIT) != 0) /* Check whether offset limit is set and valid. */ SLJIT_ASSERT(common->match_end_ptr != 0); - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, offset_limit)); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, offset_limit)); + } + else + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, offset_limit)); + OP1(SLJIT_MOV, TMP2, 0, STR_END, 0); end = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw) PCRE2_UNSET); - OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + if (HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + else + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); + #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif /* PCRE2_CODE_UNIT_WIDTH == [16|32] */ - OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); + if (HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); + OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); end2 = CMP(SLJIT_LESS_EQUAL, TMP2, 0, STR_END, 0); OP1(SLJIT_MOV, TMP2, 0, STR_END, 0); @@ -5434,802 +5519,157 @@ CMPTO(SLJIT_EQUAL, reg, 0, SLJIT_IMM, 0xdc00, label); } #endif -#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) && !(defined SUPPORT_VALGRIND) - -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -static struct sljit_jump *jump_if_utf_char_start(struct sljit_compiler *compiler, sljit_s32 reg) -{ -#if PCRE2_CODE_UNIT_WIDTH == 8 -OP2(SLJIT_AND, reg, 0, reg, 0, SLJIT_IMM, 0xc0); -return CMP(SLJIT_NOT_EQUAL, reg, 0, SLJIT_IMM, 0x80); -#elif PCRE2_CODE_UNIT_WIDTH == 16 -OP2(SLJIT_AND, reg, 0, reg, 0, SLJIT_IMM, 0xfc00); -return CMP(SLJIT_NOT_EQUAL, reg, 0, SLJIT_IMM, 0xdc00); -#else -#error "Unknown code width" -#endif -} -#endif +#include "pcre2_jit_simd_inc.h" -static sljit_s32 character_to_int32(PCRE2_UCHAR chr) -{ -sljit_u32 value = chr; -#if PCRE2_CODE_UNIT_WIDTH == 8 -#define SSE2_COMPARE_TYPE_INDEX 0 -return (sljit_s32)((value << 24) | (value << 16) | (value << 8) | value); -#elif PCRE2_CODE_UNIT_WIDTH == 16 -#define SSE2_COMPARE_TYPE_INDEX 1 -return (sljit_s32)((value << 16) | value); -#elif PCRE2_CODE_UNIT_WIDTH == 32 -#define SSE2_COMPARE_TYPE_INDEX 2 -return (sljit_s32)(value); -#else -#error "Unsupported unit width" -#endif -} +#ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD -static void load_from_mem_sse2(struct sljit_compiler *compiler, sljit_s32 dst_xmm_reg, sljit_s32 src_general_reg) +static BOOL check_fast_forward_char_pair_simd(compiler_common *common, fast_forward_char_data *chars, int max) { -#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) -sljit_u8 instruction[5]; -#else -sljit_u8 instruction[4]; -#endif + sljit_s32 i, j, max_i = 0, max_j = 0; + sljit_u32 max_pri = 0; + PCRE2_UCHAR a1, a2, a_pri, b1, b2, b_pri; -SLJIT_ASSERT(dst_xmm_reg < 8); + for (i = max - 1; i >= 1; i--) + { + if (chars[i].last_count > 2) + { + a1 = chars[i].chars[0]; + a2 = chars[i].chars[1]; + a_pri = chars[i].last_count; -/* MOVDQA xmm1, xmm2/m128 */ -#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) -if (src_general_reg < 8) - { - instruction[0] = 0x66; - instruction[1] = 0x0f; - instruction[2] = 0x6f; - instruction[3] = (dst_xmm_reg << 3) | src_general_reg; - sljit_emit_op_custom(compiler, instruction, 4); - } -else - { - instruction[0] = 0x66; - instruction[1] = 0x41; - instruction[2] = 0x0f; - instruction[3] = 0x6f; - instruction[4] = (dst_xmm_reg << 3) | (src_general_reg & 0x7); - sljit_emit_op_custom(compiler, instruction, 4); - } -#else -instruction[0] = 0x66; -instruction[1] = 0x0f; -instruction[2] = 0x6f; -instruction[3] = (dst_xmm_reg << 3) | src_general_reg; -sljit_emit_op_custom(compiler, instruction, 4); -#endif -} + j = i - max_fast_forward_char_pair_offset(); + if (j < 0) + j = 0; -static void fast_forward_char_pair_sse2_compare(struct sljit_compiler *compiler, PCRE2_UCHAR char1, PCRE2_UCHAR char2, - sljit_u32 bit, sljit_s32 dst_ind, sljit_s32 cmp1_ind, sljit_s32 cmp2_ind, sljit_s32 tmp_ind) -{ -sljit_u8 instruction[4]; -instruction[0] = 0x66; -instruction[1] = 0x0f; + while (j < i) + { + b_pri = chars[j].last_count; + if (b_pri > 2 && a_pri + b_pri >= max_pri) + { + b1 = chars[j].chars[0]; + b2 = chars[j].chars[1]; -if (char1 == char2 || bit != 0) - { - if (bit != 0) - { - /* POR xmm1, xmm2/m128 */ - /* instruction[0] = 0x66; */ - /* instruction[1] = 0x0f; */ - instruction[2] = 0xeb; - instruction[3] = 0xc0 | (dst_ind << 3) | cmp2_ind; - sljit_emit_op_custom(compiler, instruction, 4); + if (a1 != b1 && a1 != b2 && a2 != b1 && a2 != b2) + { + max_pri = a_pri + b_pri; + max_i = i; + max_j = j; + } + } + j++; + } + } } - /* PCMPEQB/W/D xmm1, xmm2/m128 */ - /* instruction[0] = 0x66; */ - /* instruction[1] = 0x0f; */ - instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; - instruction[3] = 0xc0 | (dst_ind << 3) | cmp1_ind; - sljit_emit_op_custom(compiler, instruction, 4); - } -else - { - /* MOVDQA xmm1, xmm2/m128 */ - /* instruction[0] = 0x66; */ - /* instruction[1] = 0x0f; */ - instruction[2] = 0x6f; - instruction[3] = 0xc0 | (tmp_ind << 3) | dst_ind; - sljit_emit_op_custom(compiler, instruction, 4); - - /* PCMPEQB/W/D xmm1, xmm2/m128 */ - /* instruction[0] = 0x66; */ - /* instruction[1] = 0x0f; */ - instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; - instruction[3] = 0xc0 | (dst_ind << 3) | cmp1_ind; - sljit_emit_op_custom(compiler, instruction, 4); - - instruction[3] = 0xc0 | (tmp_ind << 3) | cmp2_ind; - sljit_emit_op_custom(compiler, instruction, 4); +if (max_pri == 0) + return FALSE; - /* POR xmm1, xmm2/m128 */ - /* instruction[0] = 0x66; */ - /* instruction[1] = 0x0f; */ - instruction[2] = 0xeb; - instruction[3] = 0xc0 | (dst_ind << 3) | tmp_ind; - sljit_emit_op_custom(compiler, instruction, 4); - } +fast_forward_char_pair_simd(common, max_i, chars[max_i].chars[0], chars[max_i].chars[1], max_j, chars[max_j].chars[0], chars[max_j].chars[1]); +return TRUE; } -static void fast_forward_first_char2_sse2(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) +#endif /* JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD */ + +static void fast_forward_first_char2(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) { DEFINE_COMPILER; struct sljit_label *start; -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -struct sljit_label *restart; -#endif -struct sljit_jump *quit; -struct sljit_jump *partial_quit[2]; -sljit_u8 instruction[8]; -sljit_s32 tmp1_ind = sljit_get_register_index(TMP1); -sljit_s32 str_ptr_ind = sljit_get_register_index(STR_PTR); -sljit_s32 data_ind = 0; -sljit_s32 tmp_ind = 1; -sljit_s32 cmp1_ind = 2; -sljit_s32 cmp2_ind = 3; -sljit_u32 bit = 0; - -SLJIT_UNUSED_ARG(offset); - -if (char1 != char2) - { - bit = char1 ^ char2; - if (!is_powerof2(bit)) - bit = 0; - } - -partial_quit[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); -if (common->mode == PCRE2_JIT_COMPLETE) - add_jump(compiler, &common->failed_match, partial_quit[0]); - -/* First part (unaligned start) */ +struct sljit_jump *match; +struct sljit_jump *partial_quit; +PCRE2_UCHAR mask; +BOOL has_match_end = (common->match_end_ptr != 0); -OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1 | bit)); +SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE || offset == 0); -SLJIT_ASSERT(tmp1_ind < 8); +if (has_match_end) + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); -/* MOVD xmm, r/m32 */ -instruction[0] = 0x66; -instruction[1] = 0x0f; -instruction[2] = 0x6e; -instruction[3] = 0xc0 | (cmp1_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 4); +if (offset > 0) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); -if (char1 != char2) +if (has_match_end) { - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(bit != 0 ? bit : char2)); + OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - /* MOVD xmm, r/m32 */ - instruction[3] = 0xc0 | (cmp2_ind << 3) | tmp1_ind; - sljit_emit_op_custom(compiler, instruction, 4); + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(offset + 1)); + OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_END, 0, TMP1, 0); + CMOV(SLJIT_GREATER, STR_END, TMP1, 0); } -OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); - -/* PSHUFD xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x70; -instruction[3] = 0xc0 | (cmp1_ind << 3) | 2; -instruction[4] = 0; -sljit_emit_op_custom(compiler, instruction, 5); +#ifdef JIT_HAS_FAST_FORWARD_CHAR_SIMD -if (char1 != char2) +if (JIT_HAS_FAST_FORWARD_CHAR_SIMD) { - /* PSHUFD xmm1, xmm2/m128, imm8 */ - instruction[3] = 0xc0 | (cmp2_ind << 3) | 3; - sljit_emit_op_custom(compiler, instruction, 5); - } - -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -restart = LABEL(); -#endif -OP2(SLJIT_AND, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, ~0xf); -OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xf); - -load_from_mem_sse2(compiler, data_ind, str_ptr_ind); -fast_forward_char_pair_sse2_compare(compiler, char1, char2, bit, data_ind, cmp1_ind, cmp2_ind, tmp_ind); - -/* PMOVMSKB reg, xmm */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xd7; -instruction[3] = 0xc0 | (tmp1_ind << 3) | 0; -sljit_emit_op_custom(compiler, instruction, 4); - -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); -OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, TMP2, 0); + fast_forward_char_simd(common, char1, char2, offset); -/* BSF r32, r/m32 */ -instruction[0] = 0x0f; -instruction[1] = 0xbc; -instruction[2] = 0xc0 | (tmp1_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 3); -sljit_set_current_flags(compiler, SLJIT_SET_Z); + if (offset > 0) + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); -quit = JUMP(SLJIT_NOT_ZERO); + if (has_match_end) + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); + return; + } -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); +#endif start = LABEL(); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); -partial_quit[1] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); +partial_quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); if (common->mode == PCRE2_JIT_COMPLETE) - add_jump(compiler, &common->failed_match, partial_quit[1]); - -/* Second part (aligned) */ - -load_from_mem_sse2(compiler, 0, str_ptr_ind); -fast_forward_char_pair_sse2_compare(compiler, char1, char2, bit, data_ind, cmp1_ind, cmp2_ind, tmp_ind); - -/* PMOVMSKB reg, xmm */ -instruction[0] = 0x66; -instruction[1] = 0x0f; -instruction[2] = 0xd7; -instruction[3] = 0xc0 | (tmp1_ind << 3) | 0; -sljit_emit_op_custom(compiler, instruction, 4); - -/* BSF r32, r/m32 */ -instruction[0] = 0x0f; -instruction[1] = 0xbc; -instruction[2] = 0xc0 | (tmp1_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 3); -sljit_set_current_flags(compiler, SLJIT_SET_Z); - -JUMPTO(SLJIT_ZERO, start); + add_jump(compiler, &common->failed_match, partial_quit); -JUMPHERE(quit); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); +OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -if (common->mode != PCRE2_JIT_COMPLETE) +if (char1 == char2) + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, char1, start); +else { - JUMPHERE(partial_quit[0]); - JUMPHERE(partial_quit[1]); - OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0); - CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0); + mask = char1 ^ char2; + if (is_powerof2(mask)) + { + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, mask); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, char1 | mask, start); + } + else + { + match = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, char1); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, char2, start); + JUMPHERE(match); + } } -else - add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 if (common->utf && offset > 0) { - SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE); - - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offset)); - - quit = jump_if_utf_char_start(compiler, TMP1); - - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); - JUMPTO(SLJIT_JUMP, restart); - - JUMPHERE(quit); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-(offset + 1))); + jumpto_if_not_utf_char_start(compiler, TMP1, start); } #endif -} -#ifndef _WIN64 +OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset + 1)); -static SLJIT_INLINE sljit_u32 max_fast_forward_char_pair_sse2_offset(void) -{ -#if PCRE2_CODE_UNIT_WIDTH == 8 -return 15; -#elif PCRE2_CODE_UNIT_WIDTH == 16 -return 7; -#elif PCRE2_CODE_UNIT_WIDTH == 32 -return 3; -#else -#error "Unsupported unit width" -#endif +if (common->mode != PCRE2_JIT_COMPLETE) + JUMPHERE(partial_quit); + +if (has_match_end) + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); } -static void fast_forward_char_pair_sse2(compiler_common *common, sljit_s32 offs1, - PCRE2_UCHAR char1a, PCRE2_UCHAR char1b, sljit_s32 offs2, PCRE2_UCHAR char2a, PCRE2_UCHAR char2b) +static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common) { DEFINE_COMPILER; -sljit_u32 bit1 = 0; -sljit_u32 bit2 = 0; -sljit_u32 diff = IN_UCHARS(offs1 - offs2); -sljit_s32 tmp1_ind = sljit_get_register_index(TMP1); -sljit_s32 tmp2_ind = sljit_get_register_index(TMP2); -sljit_s32 str_ptr_ind = sljit_get_register_index(STR_PTR); -sljit_s32 data1_ind = 0; -sljit_s32 data2_ind = 1; -sljit_s32 tmp_ind = 2; -sljit_s32 cmp1a_ind = 3; -sljit_s32 cmp1b_ind = 4; -sljit_s32 cmp2a_ind = 5; -sljit_s32 cmp2b_ind = 6; struct sljit_label *start; -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -struct sljit_label *restart; -#endif -struct sljit_jump *jump[2]; - -sljit_u8 instruction[8]; - -SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE && offs1 > offs2); -SLJIT_ASSERT(diff <= IN_UCHARS(max_fast_forward_char_pair_sse2_offset())); -SLJIT_ASSERT(tmp1_ind < 8 && tmp2_ind == 1); - -/* Initialize. */ -if (common->match_end_ptr != 0) - { - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); - OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(offs1 + 1)); - - OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0); - CMOV(SLJIT_LESS, STR_END, TMP1, 0); - } - -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1)); -add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - -/* MOVD xmm, r/m32 */ -instruction[0] = 0x66; -instruction[1] = 0x0f; -instruction[2] = 0x6e; - -if (char1a == char1b) - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a)); -else - { - bit1 = char1a ^ char1b; - if (is_powerof2(bit1)) - { - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a | bit1)); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(bit1)); - } - else - { - bit1 = 0; - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a)); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(char1b)); - } - } - -instruction[3] = 0xc0 | (cmp1a_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -if (char1a != char1b) - { - instruction[3] = 0xc0 | (cmp1b_ind << 3) | tmp2_ind; - sljit_emit_op_custom(compiler, instruction, 4); - } - -if (char2a == char2b) - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a)); -else - { - bit2 = char2a ^ char2b; - if (is_powerof2(bit2)) - { - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a | bit2)); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(bit2)); - } - else - { - bit2 = 0; - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a)); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(char2b)); - } - } - -instruction[3] = 0xc0 | (cmp2a_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -if (char2a != char2b) - { - instruction[3] = 0xc0 | (cmp2b_ind << 3) | tmp2_ind; - sljit_emit_op_custom(compiler, instruction, 4); - } - -/* PSHUFD xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x70; -instruction[4] = 0; - -instruction[3] = 0xc0 | (cmp1a_ind << 3) | cmp1a_ind; -sljit_emit_op_custom(compiler, instruction, 5); - -if (char1a != char1b) - { - instruction[3] = 0xc0 | (cmp1b_ind << 3) | cmp1b_ind; - sljit_emit_op_custom(compiler, instruction, 5); - } - -instruction[3] = 0xc0 | (cmp2a_ind << 3) | cmp2a_ind; -sljit_emit_op_custom(compiler, instruction, 5); - -if (char2a != char2b) - { - instruction[3] = 0xc0 | (cmp2b_ind << 3) | cmp2b_ind; - sljit_emit_op_custom(compiler, instruction, 5); - } - -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -restart = LABEL(); -#endif - -OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1 - offs2)); -OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); -OP2(SLJIT_AND, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, ~0xf); -OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, ~0xf); - -load_from_mem_sse2(compiler, data1_ind, str_ptr_ind); - -jump[0] = CMP(SLJIT_EQUAL, STR_PTR, 0, TMP1, 0); - -load_from_mem_sse2(compiler, data2_ind, tmp1_ind); - -/* MOVDQA xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x6f; -instruction[3] = 0xc0 | (tmp_ind << 3) | data1_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -/* PSLLDQ xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x73; -instruction[3] = 0xc0 | (7 << 3) | tmp_ind; -instruction[4] = diff; -sljit_emit_op_custom(compiler, instruction, 5); - -/* PSRLDQ xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -/* instruction[2] = 0x73; */ -instruction[3] = 0xc0 | (3 << 3) | data2_ind; -instruction[4] = 16 - diff; -sljit_emit_op_custom(compiler, instruction, 5); - -/* POR xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xeb; -instruction[3] = 0xc0 | (data2_ind << 3) | tmp_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -jump[1] = JUMP(SLJIT_JUMP); - -JUMPHERE(jump[0]); - -/* MOVDQA xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x6f; -instruction[3] = 0xc0 | (data2_ind << 3) | data1_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -/* PSLLDQ xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x73; -instruction[3] = 0xc0 | (7 << 3) | data2_ind; -instruction[4] = diff; -sljit_emit_op_custom(compiler, instruction, 5); - -JUMPHERE(jump[1]); - -OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xf); - -fast_forward_char_pair_sse2_compare(compiler, char2a, char2b, bit2, data2_ind, cmp2a_ind, cmp2b_ind, tmp_ind); -fast_forward_char_pair_sse2_compare(compiler, char1a, char1b, bit1, data1_ind, cmp1a_ind, cmp1b_ind, tmp_ind); - -/* PAND xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xdb; -instruction[3] = 0xc0 | (data1_ind << 3) | data2_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -/* PMOVMSKB reg, xmm */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xd7; -instruction[3] = 0xc0 | (tmp1_ind << 3) | 0; -sljit_emit_op_custom(compiler, instruction, 4); - -/* Ignore matches before the first STR_PTR. */ -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); -OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, TMP2, 0); - -/* BSF r32, r/m32 */ -instruction[0] = 0x0f; -instruction[1] = 0xbc; -instruction[2] = 0xc0 | (tmp1_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 3); -sljit_set_current_flags(compiler, SLJIT_SET_Z); - -jump[0] = JUMP(SLJIT_NOT_ZERO); - -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); - -/* Main loop. */ -instruction[0] = 0x66; -instruction[1] = 0x0f; - -start = LABEL(); - -load_from_mem_sse2(compiler, data2_ind, str_ptr_ind); - -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); -add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - -load_from_mem_sse2(compiler, data1_ind, str_ptr_ind); - -/* PSRLDQ xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x73; -instruction[3] = 0xc0 | (3 << 3) | data2_ind; -instruction[4] = 16 - diff; -sljit_emit_op_custom(compiler, instruction, 5); - -/* MOVDQA xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x6f; -instruction[3] = 0xc0 | (tmp_ind << 3) | data1_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -/* PSLLDQ xmm1, xmm2/m128, imm8 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0x73; -instruction[3] = 0xc0 | (7 << 3) | tmp_ind; -instruction[4] = diff; -sljit_emit_op_custom(compiler, instruction, 5); - -/* POR xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xeb; -instruction[3] = 0xc0 | (data2_ind << 3) | tmp_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -fast_forward_char_pair_sse2_compare(compiler, char1a, char1b, bit1, data1_ind, cmp1a_ind, cmp1b_ind, tmp_ind); -fast_forward_char_pair_sse2_compare(compiler, char2a, char2b, bit2, data2_ind, cmp2a_ind, cmp2b_ind, tmp_ind); - -/* PAND xmm1, xmm2/m128 */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xdb; -instruction[3] = 0xc0 | (data1_ind << 3) | data2_ind; -sljit_emit_op_custom(compiler, instruction, 4); - -/* PMOVMSKB reg, xmm */ -/* instruction[0] = 0x66; */ -/* instruction[1] = 0x0f; */ -instruction[2] = 0xd7; -instruction[3] = 0xc0 | (tmp1_ind << 3) | 0; -sljit_emit_op_custom(compiler, instruction, 4); - -/* BSF r32, r/m32 */ -instruction[0] = 0x0f; -instruction[1] = 0xbc; -instruction[2] = 0xc0 | (tmp1_ind << 3) | tmp1_ind; -sljit_emit_op_custom(compiler, instruction, 3); -sljit_set_current_flags(compiler, SLJIT_SET_Z); - -JUMPTO(SLJIT_ZERO, start); - -JUMPHERE(jump[0]); - -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); - -add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); - -if (common->match_end_ptr != 0) - OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); - -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -if (common->utf) - { - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offs1)); - - jump[0] = jump_if_utf_char_start(compiler, TMP1); - - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, restart); - - add_jump(compiler, &common->failed_match, JUMP(SLJIT_JUMP)); - - JUMPHERE(jump[0]); - } -#endif - -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1)); - -if (common->match_end_ptr != 0) - OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); -} - -static BOOL check_fast_forward_char_pair_sse2(compiler_common *common, fast_forward_char_data *chars, int max) -{ -sljit_s32 i, j, priority, count; -sljit_u32 priorities; -PCRE2_UCHAR a1, a2, b1, b2; - -priorities = 0; - -count = 0; -for (i = 0; i < max; i++) - { - if (chars[i].last_count > 2) - { - SLJIT_ASSERT(chars[i].last_count <= 7); - - priorities |= (1 << chars[i].last_count); - count++; - } - } - -if (count < 2) - return FALSE; - -for (priority = 7; priority > 2; priority--) - { - if ((priorities & (1 << priority)) == 0) - continue; - - for (i = max - 1; i >= 1; i--) - if (chars[i].last_count >= priority) - { - SLJIT_ASSERT(chars[i].count <= 2 && chars[i].count >= 1); - - a1 = chars[i].chars[0]; - a2 = chars[i].chars[1]; - - j = i - max_fast_forward_char_pair_sse2_offset(); - if (j < 0) - j = 0; - - while (j < i) - { - if (chars[j].last_count >= priority) - { - b1 = chars[j].chars[0]; - b2 = chars[j].chars[1]; - - if (a1 != b1 && a1 != b2 && a2 != b1 && a2 != b2) - { - fast_forward_char_pair_sse2(common, i, a1, a2, j, b1, b2); - return TRUE; - } - } - j++; - } - } - } - -return FALSE; -} - -#endif - -#undef SSE2_COMPARE_TYPE_INDEX - -#endif - -static void fast_forward_first_char2(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) -{ -DEFINE_COMPILER; -struct sljit_label *start; -struct sljit_jump *match; -struct sljit_jump *partial_quit; -PCRE2_UCHAR mask; -BOOL has_match_end = (common->match_end_ptr != 0); - -SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE || offset == 0); - -if (has_match_end) - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); - -if (offset > 0) - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); - -if (has_match_end) - { - OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - - OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(offset + 1)); - OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_END, 0, TMP1, 0); - CMOV(SLJIT_GREATER, STR_END, TMP1, 0); - } - -#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) && !(defined SUPPORT_VALGRIND) - -/* SSE2 accelerated first character search. */ - -if (sljit_has_cpu_feature(SLJIT_HAS_SSE2)) - { - fast_forward_first_char2_sse2(common, char1, char2, offset); - - if (offset > 0) - OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset)); - - if (has_match_end) - OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); - return; - } - -#endif - -start = LABEL(); - -partial_quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); -if (common->mode == PCRE2_JIT_COMPLETE) - add_jump(compiler, &common->failed_match, partial_quit); - -OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - -if (char1 == char2) - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, char1, start); -else - { - mask = char1 ^ char2; - if (is_powerof2(mask)) - { - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, mask); - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, char1 | mask, start); - } - else - { - match = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, char1); - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, char2, start); - JUMPHERE(match); - } - } - -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 -if (common->utf && offset > 0) - { - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-(offset + 1))); - jumpto_if_not_utf_char_start(compiler, TMP1, start); - } -#endif - -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset + 1)); - -if (common->mode != PCRE2_JIT_COMPLETE) - JUMPHERE(partial_quit); - -if (has_match_end) - OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); -} - -static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common) -{ -DEFINE_COMPILER; -struct sljit_label *start; -struct sljit_jump *match; -fast_forward_char_data chars[MAX_N_CHARS]; -sljit_s32 offset; -PCRE2_UCHAR mask; -PCRE2_UCHAR *char_set, *char_set_end; -int i, max, from; -int range_right = -1, range_len; -sljit_u8 *update_table = NULL; -BOOL in_range; -sljit_u32 rec_count; +struct sljit_jump *match; +fast_forward_char_data chars[MAX_N_CHARS]; +sljit_s32 offset; +PCRE2_UCHAR mask; +PCRE2_UCHAR *char_set, *char_set_end; +int i, max, from; +int range_right = -1, range_len; +sljit_u8 *update_table = NULL; +BOOL in_range; +sljit_u32 rec_count; for (i = 0; i < MAX_N_CHARS; i++) { @@ -6267,8 +5707,8 @@ for (i = 0; i < max; i++) chars[i].last_count = (chars[i].count == 255) ? 0 : 1; } -#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) && !(defined SUPPORT_VALGRIND) && !(defined _WIN64) -if (sljit_has_cpu_feature(SLJIT_HAS_SSE2) && check_fast_forward_char_pair_sse2(common, chars, max)) +#ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD +if (JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD && check_fast_forward_char_pair_simd(common, chars, max)) return TRUE; #endif @@ -6353,18 +5793,21 @@ if (common->match_end_ptr != 0) { OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); + OP2(SLJIT_SUB | SLJIT_SET_LESS, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); + add_jump(compiler, &common->failed_match, JUMP(SLJIT_LESS)); OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_END, 0, TMP1, 0); CMOV(SLJIT_GREATER, STR_END, TMP1, 0); } else - OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); + { + OP2(SLJIT_SUB | SLJIT_SET_LESS, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); + add_jump(compiler, &common->failed_match, JUMP(SLJIT_LESS)); + } SLJIT_ASSERT(range_right >= 0); -#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) -OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table); -#endif +if (!HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table); start = LABEL(); add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0)); @@ -6375,11 +5818,11 @@ OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right)); OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right + 1) - 1); #endif -#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) -OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0); -#else -OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table); -#endif +if (!HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0); +else + OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, start); @@ -6473,9 +5916,17 @@ if (common->match_end_ptr != 0) if (common->nltype == NLTYPE_FIXED && common->newline > 255) { lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + } + else + { + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, str)); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); + } firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(2)); @@ -6503,9 +5954,15 @@ if (common->nltype == NLTYPE_FIXED && common->newline > 255) return; } -OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); +if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); + } +else + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, str)); + /* Example: match /^/ to \r\n from offset 1. */ -OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0); move_back(common, NULL, FALSE); @@ -6586,7 +6043,7 @@ if (!optimize_class(common, start_bits, (start_bits[31] & 0x80) != 0, FALSE, &ma OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits); - if (sljit_get_register_index(TMP3) >= 0) + if (!HAS_VIRTUAL_REGISTERS) { OP2(SLJIT_SHL, TMP3, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP1, 0, TMP3, 0); @@ -6693,7 +6150,7 @@ OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), -sizeof(sljit_sw)); jump = CMP(SLJIT_SIG_LESS_EQUAL, TMP2, 0, SLJIT_IMM, 0); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); -if (sljit_get_register_index(TMP3) < 0) +if (HAS_VIRTUAL_REGISTERS) { OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(STACK_TOP), -(2 * sizeof(sljit_sw))); OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), sizeof(sljit_sw), SLJIT_MEM1(STACK_TOP), -(3 * sizeof(sljit_sw))); @@ -6718,7 +6175,7 @@ sljit_emit_fast_return(compiler, RETURN_ADDR, 0); JUMPHERE(jump); OP1(SLJIT_NEG, TMP2, 0, TMP2, 0); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); -if (sljit_get_register_index(TMP3) < 0) +if (HAS_VIRTUAL_REGISTERS) { OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(STACK_TOP), -(2 * sizeof(sljit_sw))); OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2 * sizeof(sljit_sw)); @@ -6737,7 +6194,11 @@ static void check_wordboundary(compiler_common *common) DEFINE_COMPILER; struct sljit_jump *skipread; jump_list *skipread_list = NULL; -jump_list *invalid_utf = NULL; +#ifdef SUPPORT_UNICODE +struct sljit_label *valid_utf; +jump_list *invalid_utf1 = NULL; +#endif /* SUPPORT_UNICODE */ +jump_list *invalid_utf2 = NULL; #if PCRE2_CODE_UNIT_WIDTH != 8 || defined SUPPORT_UNICODE struct sljit_jump *jump; #endif /* PCRE2_CODE_UNIT_WIDTH != 8 || SUPPORT_UNICODE */ @@ -6751,14 +6212,30 @@ OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0); skipread = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0); -if (common->mode == PCRE2_JIT_COMPLETE) - peek_char_back(common, READ_CHAR_MAX, &invalid_utf); +#ifdef SUPPORT_UNICODE +if (common->invalid_utf) + { + peek_char_back(common, READ_CHAR_MAX, &invalid_utf1); + + if (common->mode != PCRE2_JIT_COMPLETE) + { + OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); + move_back(common, NULL, TRUE); + check_start_used_ptr(common); + OP1(SLJIT_MOV, STR_PTR, 0, TMP2, 0); + } + } else +#endif /* SUPPORT_UNICODE */ { - move_back(common, &invalid_utf, FALSE); - check_start_used_ptr(common); - /* No need precise read since match fails anyway. */ - read_char(common, 0, READ_CHAR_MAX, &invalid_utf, READ_CHAR_UPDATE_STR_PTR); + if (common->mode == PCRE2_JIT_COMPLETE) + peek_char_back(common, READ_CHAR_MAX, NULL); + else + { + move_back(common, NULL, TRUE); + check_start_used_ptr(common); + read_char(common, 0, READ_CHAR_MAX, NULL, READ_CHAR_UPDATE_STR_PTR); + } } /* Testing char type. */ @@ -6802,10 +6279,13 @@ JUMPHERE(skipread); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0); check_str_end(common, &skipread_list); -peek_char(common, READ_CHAR_MAX, SLJIT_MEM1(SLJIT_SP), LOCALS1, &invalid_utf); +peek_char(common, READ_CHAR_MAX, SLJIT_MEM1(SLJIT_SP), LOCALS1, &invalid_utf2); /* Testing char type. This is a code duplication. */ #ifdef SUPPORT_UNICODE + +valid_utf = LABEL(); + if (common->use_ucp) { OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 1); @@ -6851,13 +6331,19 @@ sljit_emit_fast_return(compiler, TMP1, 0); #ifdef SUPPORT_UNICODE if (common->invalid_utf) { - SLJIT_ASSERT(invalid_utf != NULL); + set_jumps(invalid_utf1, LABEL()); + + peek_char(common, READ_CHAR_MAX, SLJIT_MEM1(SLJIT_SP), LOCALS1, NULL); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR, valid_utf); - set_jumps(invalid_utf, LABEL()); OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, -1); sljit_emit_fast_return(compiler, TMP1, 0); - return; + + set_jumps(invalid_utf2, LABEL()); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + OP1(SLJIT_MOV, TMP2, 0, TMP3, 0); + sljit_emit_fast_return(compiler, TMP1, 0); } #endif /* SUPPORT_UNICODE */ } @@ -7225,7 +6711,7 @@ struct sljit_label *label; int char1_reg; int char2_reg; -if (sljit_get_register_index(TMP3) < 0) +if (HAS_VIRTUAL_REGISTERS) { char1_reg = STR_END; char2_reg = STACK_TOP; @@ -7307,7 +6793,7 @@ int char2_reg; int lcc_table; int opt_type = 0; -if (sljit_get_register_index(TMP3) < 0) +if (HAS_VIRTUAL_REGISTERS) { char2_reg = STACK_TOP; lcc_table = STACK_LIMIT; @@ -7790,8 +7276,6 @@ if (needstype || needsscript) if (needsscript) { // PH hacking -//fprintf(stderr, "~~B\n"); - OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); @@ -7845,7 +7329,6 @@ if (needstype || needsscript) if (!needschar) { // PH hacking -//fprintf(stderr, "~~C\n"); OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0); @@ -7860,7 +7343,6 @@ if (needstype || needsscript) else { // PH hacking -//fprintf(stderr, "~~D\n"); OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3); @@ -8174,14 +7656,24 @@ struct sljit_label *label; switch(type) { case OP_SOD: - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + } + else + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, TMP1, 0)); return cc; case OP_SOM: - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); + } + else + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, str)); add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, TMP1, 0)); return cc; @@ -8191,9 +7683,7 @@ switch(type) #ifdef SUPPORT_UNICODE if (common->invalid_utf) { - OP2(SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_SIG_LESS, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0); - add_jump(compiler, backtracks, JUMP(SLJIT_SIG_LESS)); - add_jump(compiler, backtracks, JUMP(type == OP_NOT_WORD_BOUNDARY ? SLJIT_NOT_ZERO : SLJIT_ZERO)); + add_jump(compiler, backtracks, CMP((type == OP_NOT_WORD_BOUNDARY) ? SLJIT_NOT_EQUAL : SLJIT_SIG_LESS_EQUAL, TMP2, 0, SLJIT_IMM, 0)); return cc; } #endif /* SUPPORT_UNICODE */ @@ -8267,17 +7757,24 @@ switch(type) JUMPHERE(jump[3]); } JUMPHERE(jump[0]); - check_partial(common, FALSE); + if (common->mode != PCRE2_JIT_COMPLETE) + check_partial(common, TRUE); return cc; case OP_EOD: add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0)); - check_partial(common, FALSE); + if (common->mode != PCRE2_JIT_COMPLETE) + check_partial(common, TRUE); return cc; case OP_DOLL: - OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); + } + else + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); if (!common->endonly) @@ -8291,8 +7788,13 @@ switch(type) case OP_DOLLM: jump[1] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); - OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); + } + else + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL); add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); check_partial(common, FALSE); jump[0] = JUMP(SLJIT_JUMP); @@ -8327,18 +7829,38 @@ switch(type) return cc; case OP_CIRC: - OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); - add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); - OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); - add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); + add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + } + else + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); + add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); + add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); + } return cc; case OP_CIRCM: - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); - OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); - jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP2, 0); - OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); + /* TMP2 might be used by peek_char_back. */ + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP2, 0); + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); + } + else + { + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); + jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP2, 0); + OP2(SLJIT_AND32 | SLJIT_SET_Z, SLJIT_UNUSED, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL); + } add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO32)); jump[0] = JUMP(SLJIT_JUMP); JUMPHERE(jump[1]); @@ -8367,11 +7889,16 @@ switch(type) length = GET(cc, 0); if (length == 0) return cc + LINK_SIZE; - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); + } + else + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, begin)); #ifdef SUPPORT_UNICODE if (common->utf) { - OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, length); label = LABEL(); add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0)); @@ -8382,9 +7909,8 @@ switch(type) else #endif { - OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin)); OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length)); - add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, TMP1, 0)); + add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, TMP2, 0)); } check_start_used_ptr(common); return cc + LINK_SIZE; @@ -8402,12 +7928,12 @@ static PCRE2_SPTR SLJIT_FUNC do_extuni_utf(jit_arguments *args, PCRE2_SPTR cc) PCRE2_SPTR start_subject = args->begin; PCRE2_SPTR end_subject = args->end; int lgb, rgb, ricount; -PCRE2_SPTR prevcc, startcc, bptr; +PCRE2_SPTR prevcc, endcc, bptr; BOOL first = TRUE; uint32_t c; prevcc = cc; -startcc = NULL; +endcc = NULL; do { GETCHARINC(c, cc); @@ -8416,7 +7942,7 @@ do if (first) { lgb = rgb; - startcc = cc; + endcc = cc; first = FALSE; continue; } @@ -8455,25 +7981,27 @@ do lgb != ucp_gbExtended_Pictographic) lgb = rgb; - prevcc = startcc; - startcc = cc; + prevcc = endcc; + endcc = cc; } while (cc < end_subject); -return startcc; +return endcc; } +#endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ + static PCRE2_SPTR SLJIT_FUNC do_extuni_utf_invalid(jit_arguments *args, PCRE2_SPTR cc) { PCRE2_SPTR start_subject = args->begin; PCRE2_SPTR end_subject = args->end; int lgb, rgb, ricount; -PCRE2_SPTR prevcc, startcc, bptr; +PCRE2_SPTR prevcc, endcc, bptr; BOOL first = TRUE; uint32_t c; prevcc = cc; -startcc = NULL; +endcc = NULL; do { GETCHARINC_INVALID(c, cc, end_subject, break); @@ -8482,7 +8010,7 @@ do if (first) { lgb = rgb; - startcc = cc; + endcc = cc; first = FALSE; continue; } @@ -8520,16 +8048,14 @@ do lgb != ucp_gbExtended_Pictographic) lgb = rgb; - prevcc = startcc; - startcc = cc; + prevcc = endcc; + endcc = cc; } while (cc < end_subject); -return startcc; +return endcc; } -#endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ - static PCRE2_SPTR SLJIT_FUNC do_extuni_no_utf(jit_arguments *args, PCRE2_SPTR cc) { PCRE2_SPTR start_subject = args->begin; @@ -8538,7 +8064,10 @@ int lgb, rgb, ricount; PCRE2_SPTR bptr; uint32_t c; -GETCHARINC(c, cc); +/* Patch by PH */ +/* GETCHARINC(c, cc); */ +c = *cc++; + #if PCRE2_CODE_UNIT_WIDTH == 32 if (c >= 0x110000) return NULL; @@ -8800,8 +8329,10 @@ switch(type) if (common->invalid_utf) add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0)); #else - sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW), SLJIT_IMM, SLJIT_FUNC_OFFSET(do_extuni_no_utf)); - add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0)); + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW), SLJIT_IMM, + common->invalid_utf ? SLJIT_FUNC_OFFSET(do_extuni_utf_invalid) : SLJIT_FUNC_OFFSET(do_extuni_no_utf)); + if (!common->utf || common->invalid_utf) + add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0)); #endif OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0); @@ -9198,8 +8729,6 @@ if (common->utf && *cc == OP_REFI) CMPTO(SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop); // PH hacking -//fprintf(stderr, "~~E\n"); - OP1(SLJIT_MOV, TMP3, 0, TMP1, 0); add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL)); @@ -10759,10 +10288,23 @@ if (ket != OP_KET || bra != OP_BRA) if (offset != 0) stacksize = match_capture_common(common, stacksize, offset, private_data_ptr); +/* Skip and count the other alternatives. */ +i = 1; +while (*cc == OP_ALT) + { + cc += GET(cc, 1); + i++; + } + if (has_alternatives) { if (opcode != OP_ONCE) - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0); + { + if (i <= 3) + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0); + else + BACKTRACK_AS(bracket_backtrack)->u.matching_put_label = sljit_emit_put_label(compiler, SLJIT_MEM1(STACK_TOP), STACK(stacksize)); + } if (ket != OP_KETRMAX) BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath = LABEL(); } @@ -10851,9 +10393,6 @@ if (bra == OP_BRAMINZERO) if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO) count_match(common); -/* Skip the other alternatives. */ -while (*cc == OP_ALT) - cc += GET(cc, 1); cc += 1 + LINK_SIZE; if (opcode == OP_ONCE) @@ -11412,174 +10951,232 @@ switch(opcode) JUMPTO(SLJIT_JUMP, label); if (jump != NULL) JUMPHERE(jump); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); + break; } - else +#ifdef SUPPORT_UNICODE + else if (type == OP_ALLANY && !common->invalid_utf) +#else + else if (type == OP_ALLANY) +#endif { - charpos_enabled = FALSE; - charpos_char = 0; - charpos_othercasebit = 0; + if (opcode == OP_STAR) + { + if (private_data_ptr == 0) + allocate_stack(common, 2); + + OP1(SLJIT_MOV, base, offset0, STR_END, 0); + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + + OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0); + process_partial_match(common); - if ((type != OP_CHAR && type != OP_CHARI) && (*end == OP_CHAR || *end == OP_CHARI)) + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_END, 0); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); + break; + } +#ifdef SUPPORT_UNICODE + else if (!common->utf) +#else + else +#endif { - charpos_enabled = TRUE; + if (private_data_ptr == 0) + allocate_stack(common, 2); + + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(max)); + + if (common->mode == PCRE2_JIT_COMPLETE) + { + OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0); + CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0); + } + else + { + jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, STR_END, 0); + process_partial_match(common); + JUMPHERE(jump); + } + + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); + break; + } + } + + charpos_enabled = FALSE; + charpos_char = 0; + charpos_othercasebit = 0; + + if ((type != OP_CHAR && type != OP_CHARI) && (*end == OP_CHAR || *end == OP_CHARI)) + { #ifdef SUPPORT_UNICODE - charpos_enabled = !common->utf || !HAS_EXTRALEN(end[1]); + charpos_enabled = !common->utf || !HAS_EXTRALEN(end[1]); +#else + charpos_enabled = TRUE; #endif - if (charpos_enabled && *end == OP_CHARI && char_has_othercase(common, end + 1)) - { - charpos_othercasebit = char_get_othercase_bit(common, end + 1); - if (charpos_othercasebit == 0) - charpos_enabled = FALSE; - } + if (charpos_enabled && *end == OP_CHARI && char_has_othercase(common, end + 1)) + { + charpos_othercasebit = char_get_othercase_bit(common, end + 1); + if (charpos_othercasebit == 0) + charpos_enabled = FALSE; + } - if (charpos_enabled) - { - charpos_char = end[1]; - /* Consumpe the OP_CHAR opcode. */ - end += 2; + if (charpos_enabled) + { + charpos_char = end[1]; + /* Consumpe the OP_CHAR opcode. */ + end += 2; #if PCRE2_CODE_UNIT_WIDTH == 8 - SLJIT_ASSERT((charpos_othercasebit >> 8) == 0); + SLJIT_ASSERT((charpos_othercasebit >> 8) == 0); #elif PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 - SLJIT_ASSERT((charpos_othercasebit >> 9) == 0); - if ((charpos_othercasebit & 0x100) != 0) - charpos_othercasebit = (charpos_othercasebit & 0xff) << 8; + SLJIT_ASSERT((charpos_othercasebit >> 9) == 0); + if ((charpos_othercasebit & 0x100) != 0) + charpos_othercasebit = (charpos_othercasebit & 0xff) << 8; #endif - if (charpos_othercasebit != 0) - charpos_char |= charpos_othercasebit; + if (charpos_othercasebit != 0) + charpos_char |= charpos_othercasebit; - BACKTRACK_AS(char_iterator_backtrack)->u.charpos.enabled = TRUE; - BACKTRACK_AS(char_iterator_backtrack)->u.charpos.chr = charpos_char; - BACKTRACK_AS(char_iterator_backtrack)->u.charpos.othercasebit = charpos_othercasebit; - } + BACKTRACK_AS(char_iterator_backtrack)->u.charpos.enabled = TRUE; + BACKTRACK_AS(char_iterator_backtrack)->u.charpos.chr = charpos_char; + BACKTRACK_AS(char_iterator_backtrack)->u.charpos.othercasebit = charpos_othercasebit; } + } - if (charpos_enabled) + if (charpos_enabled) + { + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max + 1); + + /* Search the first instance of charpos_char. */ + jump = JUMP(SLJIT_JUMP); + label = LABEL(); + if (opcode == OP_UPTO) { - if (opcode == OP_UPTO) - OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max + 1); + OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_ZERO)); + } + compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, FALSE); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + JUMPHERE(jump); - /* Search the first instance of charpos_char. */ - jump = JUMP(SLJIT_JUMP); - label = LABEL(); - if (opcode == OP_UPTO) - { - OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_ZERO)); - } - compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks, FALSE); - if (fast_str_ptr != 0) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); - JUMPHERE(jump); + detect_partial_match(common, &backtrack->topbacktracks); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + if (charpos_othercasebit != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit); + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label); - detect_partial_match(common, &backtrack->topbacktracks); - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); - if (charpos_othercasebit != 0) - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit); - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label); + if (private_data_ptr == 0) + allocate_stack(common, 2); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); + } - if (private_data_ptr == 0) - allocate_stack(common, 2); + /* Search the last instance of charpos_char. */ + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_match, FALSE); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + detect_partial_match(common, &no_match); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + if (charpos_othercasebit != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit); + if (opcode == OP_STAR) + { + CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label); OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); - if (opcode == OP_UPTO) - { - OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); - } - - /* Search the last instance of charpos_char. */ - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &no_match, FALSE); - if (fast_str_ptr != 0) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); - detect_partial_match(common, &no_match); - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); - if (charpos_othercasebit != 0) - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, charpos_othercasebit); - if (opcode == OP_STAR) - { - CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char, label); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - } - else - { - jump = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - JUMPHERE(jump); - } - - if (opcode == OP_UPTO) - { - OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); - } - else - JUMPTO(SLJIT_JUMP, label); - - set_jumps(no_match, LABEL()); - OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + } + else + { + jump = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, charpos_char); OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + JUMPHERE(jump); } -#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 - else if (common->utf) + + if (opcode == OP_UPTO) { - if (private_data_ptr == 0) - allocate_stack(common, 2); + OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + JUMPTO(SLJIT_NOT_ZERO, label); + } + else + JUMPTO(SLJIT_JUMP, label); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + } +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + else if (common->utf) + { + if (private_data_ptr == 0) + allocate_stack(common, 2); - if (opcode == OP_UPTO) - OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); - label = LABEL(); - compile_char1_matchingpath(common, type, cc, &no_match, TRUE); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); - if (opcode == OP_UPTO) - { - OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); - } - else - JUMPTO(SLJIT_JUMP, label); + detect_partial_match(common, &no_match); + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_match, FALSE); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - set_jumps(no_match, LABEL()); - OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); - if (fast_str_ptr != 0) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); - } -#endif - else + if (opcode == OP_UPTO) { - if (private_data_ptr == 0) - allocate_stack(common, 2); + OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); + } - OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); - if (opcode == OP_UPTO) - OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + detect_partial_match_to(common, label); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - label = LABEL(); - detect_partial_match(common, &no_match); - compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); - if (opcode == OP_UPTO) - { - OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - } - else - JUMPTO(SLJIT_JUMP, label); + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, STR_PTR, 0, base, offset0); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + } +#endif + else + { + if (private_data_ptr == 0) + allocate_stack(common, 2); - set_jumps(no_char1_match, LABEL()); - OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); - set_jumps(no_match, LABEL()); - OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); - if (fast_str_ptr != 0) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + OP1(SLJIT_MOV, base, offset1, STR_PTR, 0); + if (opcode == OP_UPTO) + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + + detect_partial_match(common, &no_match); + label = LABEL(); + compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); + if (opcode == OP_UPTO) + { + OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); + add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); } + + detect_partial_match_to(common, label); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + + set_jumps(no_char1_match, LABEL()); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_match, LABEL()); + OP1(SLJIT_MOV, base, offset0, STR_PTR, 0); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); } + BACKTRACK_AS(char_iterator_backtrack)->matchingpath = LABEL(); break; @@ -11616,25 +11213,47 @@ switch(opcode) break; case OP_POSSTAR: +#if defined SUPPORT_UNICODE + if (type == OP_ALLANY && !common->invalid_utf) +#else + if (type == OP_ALLANY) +#endif + { + OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0); + process_partial_match(common); + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_END, 0); + break; + } + #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 if (common->utf) { OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); + detect_partial_match(common, &no_match); label = LABEL(); - compile_char1_matchingpath(common, type, cc, &no_match, TRUE); + compile_char1_matchingpath(common, type, cc, &no_match, FALSE); OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0); - JUMPTO(SLJIT_JUMP, label); + detect_partial_match_to(common, label); + set_jumps(no_match, LABEL()); OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset); if (fast_str_ptr != 0) - OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + { + if (tmp_base == TMP3) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, TMP3, 0); + else + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + } break; } #endif - label = LABEL(); detect_partial_match(common, &no_match); + label = LABEL(); compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); - JUMPTO(SLJIT_JUMP, label); + detect_partial_match_to(common, label); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_char1_match, LABEL()); OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); set_jumps(no_match, LABEL()); @@ -11649,23 +11268,52 @@ switch(opcode) { OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, STR_PTR, 0); OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); + + detect_partial_match(common, &no_match); label = LABEL(); - compile_char1_matchingpath(common, type, cc, &no_match, TRUE); + compile_char1_matchingpath(common, type, cc, &no_match, FALSE); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, STR_PTR, 0); OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); + add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); + detect_partial_match_to(common, label); + set_jumps(no_match, LABEL()); OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1); break; } #endif + + if (type == OP_ALLANY) + { + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(max)); + + if (common->mode == PCRE2_JIT_COMPLETE) + { + OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0); + CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0); + } + else + { + jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, STR_END, 0); + process_partial_match(common); + JUMPHERE(jump); + } + + if (fast_str_ptr != 0) + OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), fast_str_ptr, STR_PTR, 0); + break; + } + OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max); - label = LABEL(); + detect_partial_match(common, &no_match); + label = LABEL(); compile_char1_matchingpath(common, type, cc, &no_char1_match, FALSE); OP2(SLJIT_SUB | SLJIT_SET_Z, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1); - JUMPTO(SLJIT_NOT_ZERO, label); + add_jump(compiler, &no_match, JUMP(SLJIT_ZERO)); + detect_partial_match_to(common, label); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + set_jumps(no_char1_match, LABEL()); OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); set_jumps(no_match, LABEL()); @@ -11719,8 +11367,15 @@ if (common->accept_label == NULL) add_jump(compiler, &common->accept, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0))); else CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), common->accept_label); -OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV_U32, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options)); + +if (HAS_VIRTUAL_REGISTERS) + { + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV_U32, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options)); + } +else + OP1(SLJIT_MOV_U32, TMP2, 0, SLJIT_MEM1(ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, options)); + OP2(SLJIT_AND | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, PCRE2_NOTEMPTY); add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_NOT_ZERO)); OP2(SLJIT_AND | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, PCRE2_NOTEMPTY_ATSTART); @@ -11728,7 +11383,8 @@ if (common->accept_label == NULL) add_jump(compiler, &common->accept, JUMP(SLJIT_ZERO)); else JUMPTO(SLJIT_ZERO, common->accept_label); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); + +OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(HAS_VIRTUAL_REGISTERS ? TMP1 : ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, str)); if (common->accept_label == NULL) add_jump(compiler, &common->accept, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0)); else @@ -11778,10 +11434,11 @@ if (opcode == OP_SKIP) if (opcode == OP_COMMIT_ARG || opcode == OP_PRUNE_ARG || opcode == OP_THEN_ARG) { - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + if (HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2)); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP2, 0); - OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0); + OP1(SLJIT_MOV, SLJIT_MEM1(HAS_VIRTUAL_REGISTERS ? TMP1 : ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0); } return ccend; @@ -12072,11 +11729,12 @@ while (cc < ccend) SLJIT_ASSERT(common->mark_ptr != 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr); allocate_stack(common, common->has_skip_arg ? 5 : 1); - OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + if (HAS_VIRTUAL_REGISTERS) + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(common->has_skip_arg ? 4 : 0), TMP2, 0); OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2)); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP2, 0); - OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0); + OP1(SLJIT_MOV, SLJIT_MEM1(HAS_VIRTUAL_REGISTERS ? TMP1 : ARGUMENTS), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0); if (common->has_skip_arg) { OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr); @@ -12403,16 +12061,15 @@ PCRE2_SPTR ccprev; PCRE2_UCHAR bra = OP_BRA; PCRE2_UCHAR ket; assert_backtrack *assert; -sljit_uw *next_update_addr = NULL; BOOL has_alternatives; BOOL needs_control_head = FALSE; struct sljit_jump *brazero = NULL; -struct sljit_jump *alt1 = NULL; -struct sljit_jump *alt2 = NULL; +struct sljit_jump *next_alt = NULL; struct sljit_jump *once = NULL; struct sljit_jump *cond = NULL; struct sljit_label *rmin_label = NULL; struct sljit_label *exact_label = NULL; +struct sljit_put_label *put_label = NULL; if (*cc == OP_BRAZERO || *cc == OP_BRAMINZERO) { @@ -12561,7 +12218,7 @@ else if (SLJIT_UNLIKELY(opcode == OP_COND) || SLJIT_UNLIKELY(opcode == OP_SCOND) free_stack(common, 1); alt_max = 2; - alt1 = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw)); + next_alt = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0); } } else if (has_alternatives) @@ -12569,21 +12226,15 @@ else if (has_alternatives) OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); free_stack(common, 1); - if (alt_max > 4) + if (alt_max > 3) { - /* Table jump if alt_max is greater than 4. */ - next_update_addr = allocate_read_only_data(common, alt_max * sizeof(sljit_uw)); - if (SLJIT_UNLIKELY(next_update_addr == NULL)) - return; - sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)next_update_addr); - add_label_addr(common, next_update_addr++); + sljit_emit_ijump(compiler, SLJIT_JUMP, TMP1, 0); + + SLJIT_ASSERT(CURRENT_AS(bracket_backtrack)->u.matching_put_label); + sljit_set_put_label(CURRENT_AS(bracket_backtrack)->u.matching_put_label, LABEL()); } else - { - if (alt_max == 4) - alt2 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw)); - alt1 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw)); - } + next_alt = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0); } COMPILE_BACKTRACKINGPATH(current->top); @@ -12620,7 +12271,7 @@ if (SLJIT_UNLIKELY(opcode == OP_COND) || SLJIT_UNLIKELY(opcode == OP_SCOND)) if (has_alternatives) { - alt_count = sizeof(sljit_uw); + alt_count = 1; do { current->top = NULL; @@ -12699,7 +12350,12 @@ if (has_alternatives) stacksize = match_capture_common(common, stacksize, offset, private_data_ptr); if (opcode != OP_ONCE) - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, alt_count); + { + if (alt_max <= 3) + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, alt_count); + else + put_label = sljit_emit_put_label(compiler, SLJIT_MEM1(STACK_TOP), STACK(stacksize)); + } if (offset != 0 && ket == OP_KETRMAX && common->optimized_cbracket[offset >> 1] != 0) { @@ -12712,24 +12368,18 @@ if (has_alternatives) if (opcode != OP_ONCE) { - if (alt_max > 4) - add_label_addr(common, next_update_addr++); - else + if (alt_max <= 3) { - if (alt_count != 2 * sizeof(sljit_uw)) - { - JUMPHERE(alt1); - if (alt_max == 3 && alt_count == sizeof(sljit_uw)) - alt2 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw)); - } - else + JUMPHERE(next_alt); + alt_count++; + if (alt_count < alt_max) { - JUMPHERE(alt2); - if (alt_max == 4) - alt1 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_uw)); + SLJIT_ASSERT(alt_count == 2 && alt_max == 3); + next_alt = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 1); } } - alt_count += sizeof(sljit_uw); + else + sljit_set_put_label(put_label, LABEL()); } COMPILE_BACKTRACKINGPATH(current->top); @@ -13219,11 +12869,10 @@ int private_data_size = get_recurse_data_length(common, ccbegin, ccend, &needs_c int alt_count, alt_max, local_size; backtrack_common altbacktrack; jump_list *match = NULL; -sljit_uw *next_update_addr = NULL; -struct sljit_jump *alt1 = NULL; -struct sljit_jump *alt2 = NULL; +struct sljit_jump *next_alt = NULL; struct sljit_jump *accept_exit = NULL; struct sljit_label *quit; +struct sljit_put_label *put_label; /* Recurse captures then. */ common->then_trap = NULL; @@ -13284,7 +12933,12 @@ while (1) OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->recursive_head_ptr); if (alt_max > 1 || has_accept) - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, alt_count); + { + if (alt_max > 3) + put_label = sljit_emit_put_label(compiler, SLJIT_MEM1(STACK_TOP), STACK(1)); + else + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, alt_count); + } add_jump(compiler, &match, JUMP(SLJIT_JUMP)); @@ -13298,7 +12952,7 @@ while (1) sljit_emit_fast_enter(compiler, TMP1, 0); if (has_accept) - accept_exit = CMP(SLJIT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, alt_max * sizeof (sljit_sw)); + accept_exit = CMP(SLJIT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, -1); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); /* Save return address. */ @@ -13311,44 +12965,30 @@ while (1) OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1)); free_stack(common, 2); - if (alt_max > 4) + if (alt_max > 3) { - /* Table jump if alt_max is greater than 4. */ - next_update_addr = allocate_read_only_data(common, alt_max * sizeof(sljit_uw)); - if (SLJIT_UNLIKELY(next_update_addr == NULL)) - return; - sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)next_update_addr); - add_label_addr(common, next_update_addr++); + sljit_emit_ijump(compiler, SLJIT_JUMP, TMP1, 0); + sljit_set_put_label(put_label, LABEL()); } else - { - if (alt_max == 4) - alt2 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw)); - alt1 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw)); - } + next_alt = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0); } else free_stack(common, has_accept ? 2 : 1); } - else if (alt_max > 4) - add_label_addr(common, next_update_addr++); + else if (alt_max > 3) + sljit_set_put_label(put_label, LABEL()); else { - if (alt_count != 2 * sizeof(sljit_uw)) + JUMPHERE(next_alt); + if (alt_count + 1 < alt_max) { - JUMPHERE(alt1); - if (alt_max == 3 && alt_count == sizeof(sljit_uw)) - alt2 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw)); - } - else - { - JUMPHERE(alt2); - if (alt_max == 4) - alt1 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_uw)); + SLJIT_ASSERT(alt_count == 1 && alt_max == 3); + next_alt = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 1); } } - alt_count += sizeof(sljit_uw); + alt_count++; compile_backtrackingpath(common, altbacktrack.top); if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) @@ -13409,7 +13049,7 @@ if (common->accept != NULL) OP1(SLJIT_MOV, TMP2, 0, STACK_TOP, 0); allocate_stack(common, 2); - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, alt_count); + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, -1); } set_jumps(match, LABEL()); @@ -13444,7 +13084,6 @@ executable_functions *functions; void *executable_func; sljit_uw executable_size; sljit_uw total_length; -label_addr_list *label_addr; struct sljit_label *mainloop_label = NULL; struct sljit_label *continue_match_label; struct sljit_label *empty_match_found_label = NULL; @@ -13459,6 +13098,14 @@ struct sljit_jump *end_anchor_failed = NULL; SLJIT_ASSERT(tables); +#if HAS_VIRTUAL_REGISTERS == 1 +SLJIT_ASSERT(sljit_get_register_index(TMP3) < 0 && sljit_get_register_index(ARGUMENTS) < 0 && sljit_get_register_index(RETURN_ADDR) < 0); +#elif HAS_VIRTUAL_REGISTERS == 0 +SLJIT_ASSERT(sljit_get_register_index(TMP3) >= 0 && sljit_get_register_index(ARGUMENTS) >= 0 && sljit_get_register_index(RETURN_ADDR) >= 0); +#else +#error "Invalid value for HAS_VIRTUAL_REGISTERS" +#endif + memset(&rootbacktrack, 0, sizeof(backtrack_common)); memset(common, 0, sizeof(compiler_common)); common->re = re; @@ -13476,6 +13123,7 @@ common->fcc = tables + fcc_offset; common->lcc = (sljit_sw)(tables + lcc_offset); common->mode = mode; common->might_be_empty = re->minlength == 0; +common->allow_empty_partial = (re->max_lookbehind > 0) || (re->flags & PCRE2_MATCH_EMPTY) != 0; common->nltype = NLTYPE_FIXED; switch(re->newline_convention) { @@ -13742,7 +13390,7 @@ if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) sljit_free_compiler(compiler); SLJIT_FREE(common->optimized_cbracket, allocator_data); SLJIT_FREE(common->private_data_ptrs, allocator_data); - PRIV(jit_free_rodata)(common->read_only_data_head, compiler->allocator_data); + PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data); return PCRE2_ERROR_NOMEMORY; } @@ -13796,7 +13444,7 @@ if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) sljit_free_compiler(compiler); SLJIT_FREE(common->optimized_cbracket, allocator_data); SLJIT_FREE(common->private_data_ptrs, allocator_data); - PRIV(jit_free_rodata)(common->read_only_data_head, compiler->allocator_data); + PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data); return PCRE2_ERROR_NOMEMORY; } @@ -13885,7 +13533,7 @@ while (common->currententry != NULL) sljit_free_compiler(compiler); SLJIT_FREE(common->optimized_cbracket, allocator_data); SLJIT_FREE(common->private_data_ptrs, allocator_data); - PRIV(jit_free_rodata)(common->read_only_data_head, compiler->allocator_data); + PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data); return PCRE2_ERROR_NOMEMORY; } flush_stubs(common); @@ -14028,16 +13676,11 @@ SLJIT_FREE(common->private_data_ptrs, allocator_data); executable_func = sljit_generate_code(compiler); executable_size = sljit_get_generated_code_size(compiler); -label_addr = common->label_addrs; -while (label_addr != NULL) - { - *label_addr->update_addr = sljit_get_label_addr(label_addr->label); - label_addr = label_addr->next; - } sljit_free_compiler(compiler); + if (executable_func == NULL) { - PRIV(jit_free_rodata)(common->read_only_data_head, compiler->allocator_data); + PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data); return PCRE2_ERROR_NOMEMORY; } @@ -14052,7 +13695,7 @@ else /* This case is highly unlikely since we just recently freed a lot of memory. Not impossible though. */ sljit_free_code(executable_func); - PRIV(jit_free_rodata)(common->read_only_data_head, compiler->allocator_data); + PRIV(jit_free_rodata)(common->read_only_data_head, allocator_data); return PCRE2_ERROR_NOMEMORY; } memset(functions, 0, sizeof(executable_functions)); @@ -14097,18 +13740,12 @@ Returns: 0: success or (*NOJIT) was used PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_jit_compile(pcre2_code *code, uint32_t options) { -#ifndef SUPPORT_JIT - -(void)code; -(void)options; -return PCRE2_ERROR_JIT_BADOPTION; - -#else /* SUPPORT_JIT */ - pcre2_real_code *re = (pcre2_real_code *)code; -executable_functions *functions; -uint32_t excluded_options; -int result; + +#ifdef SUPPORT_JIT +executable_functions *functions = (executable_functions *)re->executable_jit; +static int executable_allocator_is_working = 0; +#endif if (code == NULL) return PCRE2_ERROR_NULL; @@ -14116,30 +13753,98 @@ if (code == NULL) if ((options & ~PUBLIC_JIT_COMPILE_OPTIONS) != 0) return PCRE2_ERROR_JIT_BADOPTION; +/* Support for invalid UTF was first introduced in JIT, with the option +PCRE2_JIT_INVALID_UTF. Later, support was added to the interpreter, and the +compile-time option PCRE2_MATCH_INVALID_UTF was created. This is now the +preferred feature, with the earlier option deprecated. However, for backward +compatibility, if the earlier option is set, it forces the new option so that +if JIT matching falls back to the interpreter, there is still support for +invalid UTF. However, if this function has already been successfully called +without PCRE2_JIT_INVALID_UTF and without PCRE2_MATCH_INVALID_UTF (meaning that +non-invalid-supporting JIT code was compiled), give an error. + +If in the future support for PCRE2_JIT_INVALID_UTF is withdrawn, the following +actions are needed: + + 1. Remove the definition from pcre2.h.in and from the list in + PUBLIC_JIT_COMPILE_OPTIONS above. + + 2. Replace PCRE2_JIT_INVALID_UTF with a local flag in this module. + + 3. Replace PCRE2_JIT_INVALID_UTF in pcre2_jit_test.c. + + 4. Delete the following short block of code. The setting of "re" and + "functions" can be moved into the JIT-only block below, but if that is + done, (void)re and (void)functions will be needed in the non-JIT case, to + avoid compiler warnings. +*/ + +if ((options & PCRE2_JIT_INVALID_UTF) != 0) + { + if ((re->overall_options & PCRE2_MATCH_INVALID_UTF) == 0) + { +#ifdef SUPPORT_JIT + if (functions != NULL) return PCRE2_ERROR_JIT_BADOPTION; +#endif + re->overall_options |= PCRE2_MATCH_INVALID_UTF; + } + } + +/* The above tests are run with and without JIT support. This means that +PCRE2_JIT_INVALID_UTF propagates back into the regex options (ensuring +interpreter support) even in the absence of JIT. But now, if there is no JIT +support, give an error return. */ + +#ifndef SUPPORT_JIT +return PCRE2_ERROR_JIT_BADOPTION; +#else /* SUPPORT_JIT */ + +/* There is JIT support. Do the necessary. */ + if ((re->flags & PCRE2_NOJIT) != 0) return 0; -functions = (executable_functions *)re->executable_jit; +if (executable_allocator_is_working == 0) + { + /* Checks whether the executable allocator is working. This check + might run multiple times in multi-threaded environments, but the + result should not be affected by it. */ + void *ptr = SLJIT_MALLOC_EXEC(32); + + executable_allocator_is_working = -1; + + if (ptr != NULL) + { + SLJIT_FREE_EXEC(((sljit_u8*)(ptr)) + SLJIT_EXEC_OFFSET(ptr)); + executable_allocator_is_working = 1; + } + } + +if (executable_allocator_is_working < 0) + return PCRE2_ERROR_NOMEMORY; + +if ((re->overall_options & PCRE2_MATCH_INVALID_UTF) != 0) + options |= PCRE2_JIT_INVALID_UTF; if ((options & PCRE2_JIT_COMPLETE) != 0 && (functions == NULL || functions->executable_funcs[0] == NULL)) { - excluded_options = (PCRE2_JIT_PARTIAL_SOFT | PCRE2_JIT_PARTIAL_HARD); - result = jit_compile(code, options & ~excluded_options); + uint32_t excluded_options = (PCRE2_JIT_PARTIAL_SOFT | PCRE2_JIT_PARTIAL_HARD); + int result = jit_compile(code, options & ~excluded_options); if (result != 0) return result; } if ((options & PCRE2_JIT_PARTIAL_SOFT) != 0 && (functions == NULL || functions->executable_funcs[1] == NULL)) { - excluded_options = (PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_HARD); - result = jit_compile(code, options & ~excluded_options); + uint32_t excluded_options = (PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_HARD); + int result = jit_compile(code, options & ~excluded_options); if (result != 0) return result; } if ((options & PCRE2_JIT_PARTIAL_HARD) != 0 && (functions == NULL || functions->executable_funcs[2] == NULL)) { - excluded_options = (PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_SOFT); - result = jit_compile(code, options & ~excluded_options); + uint32_t excluded_options = (PCRE2_JIT_COMPLETE | PCRE2_JIT_PARTIAL_SOFT); + int result = jit_compile(code, options & ~excluded_options); if (result != 0) return result; } diff --git a/src/3rdparty/pcre2/src/pcre2_jit_match.c b/src/3rdparty/pcre2/src/pcre2_jit_match.c index eee038644d..7e13b8cfee 100644 --- a/src/3rdparty/pcre2/src/pcre2_jit_match.c +++ b/src/3rdparty/pcre2/src/pcre2_jit_match.c @@ -74,7 +74,6 @@ Arguments: options option bits match_data points to a match_data block mcontext points to a match context - jit_stack points to a JIT stack Returns: > 0 => success; value is the number of ovector pairs filled = 0 => success, but ovector is not big enough diff --git a/src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h b/src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h new file mode 100644 index 0000000000..55b1f32ac9 --- /dev/null +++ b/src/3rdparty/pcre2/src/pcre2_jit_neon_inc.h @@ -0,0 +1,321 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + + Written by Philip Hazel + This module by Zoltan Herczeg and Sebastian Pop + Original API code Copyright (c) 1997-2012 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +# if defined(FFCS) +# if defined(FF_UTF) +# define FF_FUN ffcs_utf +# else +# define FF_FUN ffcs +# endif + +# elif defined(FFCS_2) +# if defined(FF_UTF) +# define FF_FUN ffcs_2_utf +# else +# define FF_FUN ffcs_2 +# endif + +# elif defined(FFCS_MASK) +# if defined(FF_UTF) +# define FF_FUN ffcs_mask_utf +# else +# define FF_FUN ffcs_mask +# endif + +# elif defined(FFCPS_0) +# if defined (FF_UTF) +# define FF_FUN ffcps_0_utf +# else +# define FF_FUN ffcps_0 +# endif + +# elif defined (FFCPS_1) +# if defined (FF_UTF) +# define FF_FUN ffcps_1_utf +# else +# define FF_FUN ffcps_1 +# endif + +# elif defined (FFCPS_DEFAULT) +# if defined (FF_UTF) +# define FF_FUN ffcps_default_utf +# else +# define FF_FUN ffcps_default +# endif +# endif + +static sljit_u8* SLJIT_FUNC FF_FUN(sljit_u8 *str_end, sljit_u8 *str_ptr, sljit_uw offs1, sljit_uw offs2, sljit_uw chars) +#undef FF_FUN +{ +quad_word qw; +int_char ic; +ic.x = chars; + +#if defined(FFCS) +sljit_u8 c1 = ic.c.c1; +vect_t vc1 = VDUPQ(c1); + +#elif defined(FFCS_2) +sljit_u8 c1 = ic.c.c1; +vect_t vc1 = VDUPQ(c1); +sljit_u8 c2 = ic.c.c2; +vect_t vc2 = VDUPQ(c2); + +#elif defined(FFCS_MASK) +sljit_u8 c1 = ic.c.c1; +vect_t vc1 = VDUPQ(c1); +sljit_u8 mask = ic.c.c2; +vect_t vmask = VDUPQ(mask); +#endif + +#if defined(FFCPS) +compare_type compare1_type = compare_match1; +compare_type compare2_type = compare_match1; +vect_t cmp1a, cmp1b, cmp2a, cmp2b; +const sljit_u32 diff = IN_UCHARS(offs1 - offs2); +PCRE2_UCHAR char1a = ic.c.c1; +PCRE2_UCHAR char2a = ic.c.c3; + +# ifdef FFCPS_CHAR1A2A +cmp1a = VDUPQ(char1a); +cmp2a = VDUPQ(char2a); +# else +PCRE2_UCHAR char1b = ic.c.c2; +PCRE2_UCHAR char2b = ic.c.c4; +if (char1a == char1b) + cmp1a = VDUPQ(char1a); +else + { + sljit_u32 bit1 = char1a ^ char1b; + if (is_powerof2(bit1)) + { + compare1_type = compare_match1i; + cmp1a = VDUPQ(char1a | bit1); + cmp1b = VDUPQ(bit1); + } + else + { + compare1_type = compare_match2; + cmp1a = VDUPQ(char1a); + cmp1b = VDUPQ(char1b); + } + } + +if (char2a == char2b) + cmp2a = VDUPQ(char2a); +else + { + sljit_u32 bit2 = char2a ^ char2b; + if (is_powerof2(bit2)) + { + compare2_type = compare_match1i; + cmp2a = VDUPQ(char2a | bit2); + cmp2b = VDUPQ(bit2); + } + else + { + compare2_type = compare_match2; + cmp2a = VDUPQ(char2a); + cmp2b = VDUPQ(char2b); + } + } +# endif + +str_ptr += IN_UCHARS(offs1); +#endif + +#if PCRE2_CODE_UNIT_WIDTH != 8 +vect_t char_mask = VDUPQ(0xff); +#endif + +#if defined(FF_UTF) +restart:; +#endif + +#if defined(FFCPS) +sljit_u8 *p1 = str_ptr - diff; +#endif +sljit_s32 align_offset = ((uint64_t)str_ptr & 0xf); +str_ptr = (sljit_u8 *) ((uint64_t)str_ptr & ~0xf); +vect_t data = VLD1Q(str_ptr); +#if PCRE2_CODE_UNIT_WIDTH != 8 +data = VANDQ(data, char_mask); +#endif + +#if defined(FFCS) +vect_t eq = VCEQQ(data, vc1); + +#elif defined(FFCS_2) +vect_t eq1 = VCEQQ(data, vc1); +vect_t eq2 = VCEQQ(data, vc2); +vect_t eq = VORRQ(eq1, eq2); + +#elif defined(FFCS_MASK) +vect_t eq = VORRQ(data, vmask); +eq = VCEQQ(eq, vc1); + +#elif defined(FFCPS) +# if defined(FFCPS_DIFF1) +vect_t prev_data = data; +# endif + +vect_t data2; +if (p1 < str_ptr) + { + data2 = VLD1Q(str_ptr - diff); +#if PCRE2_CODE_UNIT_WIDTH != 8 + data2 = VANDQ(data2, char_mask); +#endif + } +else + data2 = shift_left_n_lanes(data, offs1 - offs2); + +data = fast_forward_char_pair_compare(compare1_type, data, cmp1a, cmp1b); +data2 = fast_forward_char_pair_compare(compare2_type, data2, cmp2a, cmp2b); +vect_t eq = VANDQ(data, data2); +#endif + +VST1Q(qw.mem, eq); +/* Ignore matches before the first STR_PTR. */ +if (align_offset < 8) + { + qw.dw[0] >>= align_offset * 8; + if (qw.dw[0]) + { + str_ptr += align_offset + __builtin_ctzll(qw.dw[0]) / 8; + goto match; + } + if (qw.dw[1]) + { + str_ptr += 8 + __builtin_ctzll(qw.dw[1]) / 8; + goto match; + } + } +else + { + qw.dw[1] >>= (align_offset - 8) * 8; + if (qw.dw[1]) + { + str_ptr += align_offset + __builtin_ctzll(qw.dw[1]) / 8; + goto match; + } + } +str_ptr += 16; + +while (str_ptr < str_end) + { + vect_t orig_data = VLD1Q(str_ptr); +#if PCRE2_CODE_UNIT_WIDTH != 8 + orig_data = VANDQ(orig_data, char_mask); +#endif + data = orig_data; + +#if defined(FFCS) + eq = VCEQQ(data, vc1); + +#elif defined(FFCS_2) + eq1 = VCEQQ(data, vc1); + eq2 = VCEQQ(data, vc2); + eq = VORRQ(eq1, eq2); + +#elif defined(FFCS_MASK) + eq = VORRQ(data, vmask); + eq = VCEQQ(eq, vc1); +#endif + +#if defined(FFCPS) +# if defined (FFCPS_DIFF1) + data2 = VEXTQ(prev_data, data, VECTOR_FACTOR - 1); +# else + data2 = VLD1Q(str_ptr - diff); +# if PCRE2_CODE_UNIT_WIDTH != 8 + data2 = VANDQ(data2, char_mask); +# endif +# endif + +# ifdef FFCPS_CHAR1A2A + data = VCEQQ(data, cmp1a); + data2 = VCEQQ(data2, cmp2a); +# else + data = fast_forward_char_pair_compare(compare1_type, data, cmp1a, cmp1b); + data2 = fast_forward_char_pair_compare(compare2_type, data2, cmp2a, cmp2b); +# endif + + eq = VANDQ(data, data2); +#endif + + VST1Q(qw.mem, eq); + if (qw.dw[0]) + str_ptr += __builtin_ctzll(qw.dw[0]) / 8; + else if (qw.dw[1]) + str_ptr += 8 + __builtin_ctzll(qw.dw[1]) / 8; + else { + str_ptr += 16; +#if defined (FFCPS_DIFF1) + prev_data = orig_data; +#endif + continue; + } + +match:; + if (str_ptr >= str_end) + /* Failed match. */ + return NULL; + +#if defined(FF_UTF) + if (utf_continue(str_ptr + IN_UCHARS(-offs1))) + { + /* Not a match. */ + str_ptr += IN_UCHARS(1); + goto restart; + } +#endif + + /* Match. */ +#if defined (FFCPS) + str_ptr -= IN_UCHARS(offs1); +#endif + return str_ptr; + } + +/* Failed match. */ +return NULL; +} diff --git a/src/3rdparty/pcre2/src/pcre2_jit_simd_inc.h b/src/3rdparty/pcre2/src/pcre2_jit_simd_inc.h new file mode 100644 index 0000000000..f7d56b29f8 --- /dev/null +++ b/src/3rdparty/pcre2/src/pcre2_jit_simd_inc.h @@ -0,0 +1,993 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* PCRE is a library of functions to support regular expressions whose syntax +and semantics are as close as possible to those of the Perl 5 language. + + Written by Philip Hazel + This module by Zoltan Herczeg + Original API code Copyright (c) 1997-2012 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge + +----------------------------------------------------------------------------- +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of the University of Cambridge nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +----------------------------------------------------------------------------- +*/ + +#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) && !(defined SUPPORT_VALGRIND) + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +static struct sljit_jump *jump_if_utf_char_start(struct sljit_compiler *compiler, sljit_s32 reg) +{ +#if PCRE2_CODE_UNIT_WIDTH == 8 +OP2(SLJIT_AND, reg, 0, reg, 0, SLJIT_IMM, 0xc0); +return CMP(SLJIT_NOT_EQUAL, reg, 0, SLJIT_IMM, 0x80); +#elif PCRE2_CODE_UNIT_WIDTH == 16 +OP2(SLJIT_AND, reg, 0, reg, 0, SLJIT_IMM, 0xfc00); +return CMP(SLJIT_NOT_EQUAL, reg, 0, SLJIT_IMM, 0xdc00); +#else +#error "Unknown code width" +#endif +} +#endif + +static sljit_s32 character_to_int32(PCRE2_UCHAR chr) +{ +sljit_u32 value = chr; +#if PCRE2_CODE_UNIT_WIDTH == 8 +#define SSE2_COMPARE_TYPE_INDEX 0 +return (sljit_s32)((value << 24) | (value << 16) | (value << 8) | value); +#elif PCRE2_CODE_UNIT_WIDTH == 16 +#define SSE2_COMPARE_TYPE_INDEX 1 +return (sljit_s32)((value << 16) | value); +#elif PCRE2_CODE_UNIT_WIDTH == 32 +#define SSE2_COMPARE_TYPE_INDEX 2 +return (sljit_s32)(value); +#else +#error "Unsupported unit width" +#endif +} + +static void load_from_mem_sse2(struct sljit_compiler *compiler, sljit_s32 dst_xmm_reg, sljit_s32 src_general_reg, sljit_s8 offset) +{ +sljit_u8 instruction[5]; + +SLJIT_ASSERT(dst_xmm_reg < 8); +SLJIT_ASSERT(src_general_reg < 8); + +/* MOVDQA xmm1, xmm2/m128 */ +instruction[0] = ((sljit_u8)offset & 0xf) == 0 ? 0x66 : 0xf3; +instruction[1] = 0x0f; +instruction[2] = 0x6f; + +if (offset == 0) + { + instruction[3] = (dst_xmm_reg << 3) | src_general_reg; + sljit_emit_op_custom(compiler, instruction, 4); + return; + } + +instruction[3] = 0x40 | (dst_xmm_reg << 3) | src_general_reg; +instruction[4] = (sljit_u8)offset; +sljit_emit_op_custom(compiler, instruction, 5); +} + +typedef enum { + sse2_compare_match1, + sse2_compare_match1i, + sse2_compare_match2, +} sse2_compare_type; + +static void fast_forward_char_pair_sse2_compare(struct sljit_compiler *compiler, sse2_compare_type compare_type, + int step, sljit_s32 dst_ind, sljit_s32 cmp1_ind, sljit_s32 cmp2_ind, sljit_s32 tmp_ind) +{ +sljit_u8 instruction[4]; +instruction[0] = 0x66; +instruction[1] = 0x0f; + +SLJIT_ASSERT(step >= 0 && step <= 3); + +if (compare_type != sse2_compare_match2) + { + if (step == 0) + { + if (compare_type == sse2_compare_match1i) + { + /* POR xmm1, xmm2/m128 */ + /* instruction[0] = 0x66; */ + /* instruction[1] = 0x0f; */ + instruction[2] = 0xeb; + instruction[3] = 0xc0 | (dst_ind << 3) | cmp2_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + return; + } + + if (step != 2) + return; + + /* PCMPEQB/W/D xmm1, xmm2/m128 */ + /* instruction[0] = 0x66; */ + /* instruction[1] = 0x0f; */ + instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; + instruction[3] = 0xc0 | (dst_ind << 3) | cmp1_ind; + sljit_emit_op_custom(compiler, instruction, 4); + return; + } + +switch (step) + { + case 0: + /* MOVDQA xmm1, xmm2/m128 */ + /* instruction[0] = 0x66; */ + /* instruction[1] = 0x0f; */ + instruction[2] = 0x6f; + instruction[3] = 0xc0 | (tmp_ind << 3) | dst_ind; + sljit_emit_op_custom(compiler, instruction, 4); + return; + + case 1: + /* PCMPEQB/W/D xmm1, xmm2/m128 */ + /* instruction[0] = 0x66; */ + /* instruction[1] = 0x0f; */ + instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; + instruction[3] = 0xc0 | (dst_ind << 3) | cmp1_ind; + sljit_emit_op_custom(compiler, instruction, 4); + return; + + case 2: + /* PCMPEQB/W/D xmm1, xmm2/m128 */ + /* instruction[0] = 0x66; */ + /* instruction[1] = 0x0f; */ + instruction[2] = 0x74 + SSE2_COMPARE_TYPE_INDEX; + instruction[3] = 0xc0 | (tmp_ind << 3) | cmp2_ind; + sljit_emit_op_custom(compiler, instruction, 4); + return; + + case 3: + /* POR xmm1, xmm2/m128 */ + /* instruction[0] = 0x66; */ + /* instruction[1] = 0x0f; */ + instruction[2] = 0xeb; + instruction[3] = 0xc0 | (dst_ind << 3) | tmp_ind; + sljit_emit_op_custom(compiler, instruction, 4); + return; + } +} + +#define JIT_HAS_FAST_FORWARD_CHAR_SIMD (sljit_has_cpu_feature(SLJIT_HAS_SSE2)) + +static void fast_forward_char_simd(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) +{ +DEFINE_COMPILER; +struct sljit_label *start; +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +struct sljit_label *restart; +#endif +struct sljit_jump *quit; +struct sljit_jump *partial_quit[2]; +sse2_compare_type compare_type = sse2_compare_match1; +sljit_u8 instruction[8]; +sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); +sljit_s32 str_ptr_reg_ind = sljit_get_register_index(STR_PTR); +sljit_s32 data_ind = 0; +sljit_s32 tmp_ind = 1; +sljit_s32 cmp1_ind = 2; +sljit_s32 cmp2_ind = 3; +sljit_u32 bit = 0; +int i; + +SLJIT_UNUSED_ARG(offset); + +if (char1 != char2) + { + bit = char1 ^ char2; + compare_type = sse2_compare_match1i; + + if (!is_powerof2(bit)) + { + bit = 0; + compare_type = sse2_compare_match2; + } + } + +partial_quit[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); +if (common->mode == PCRE2_JIT_COMPLETE) + add_jump(compiler, &common->failed_match, partial_quit[0]); + +/* First part (unaligned start) */ + +OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1 | bit)); + +SLJIT_ASSERT(tmp1_reg_ind < 8); + +/* MOVD xmm, r/m32 */ +instruction[0] = 0x66; +instruction[1] = 0x0f; +instruction[2] = 0x6e; +instruction[3] = 0xc0 | (cmp1_ind << 3) | tmp1_reg_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +if (char1 != char2) + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(bit != 0 ? bit : char2)); + + /* MOVD xmm, r/m32 */ + instruction[3] = 0xc0 | (cmp2_ind << 3) | tmp1_reg_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + +OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); + +/* PSHUFD xmm1, xmm2/m128, imm8 */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0x70; +instruction[3] = 0xc0 | (cmp1_ind << 3) | cmp1_ind; +instruction[4] = 0; +sljit_emit_op_custom(compiler, instruction, 5); + +if (char1 != char2) + { + /* PSHUFD xmm1, xmm2/m128, imm8 */ + instruction[3] = 0xc0 | (cmp2_ind << 3) | cmp2_ind; + sljit_emit_op_custom(compiler, instruction, 5); + } + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +restart = LABEL(); +#endif +OP2(SLJIT_AND, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, ~0xf); +OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xf); + +load_from_mem_sse2(compiler, data_ind, str_ptr_reg_ind, 0); +for (i = 0; i < 4; i++) + fast_forward_char_pair_sse2_compare(compiler, compare_type, i, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + +/* PMOVMSKB reg, xmm */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0xd7; +instruction[3] = 0xc0 | (tmp1_reg_ind << 3) | data_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); +OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, TMP2, 0); + +quit = CMP(SLJIT_NOT_ZERO, TMP1, 0, SLJIT_IMM, 0); + +OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); + +/* Second part (aligned) */ +start = LABEL(); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); + +partial_quit[1] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); +if (common->mode == PCRE2_JIT_COMPLETE) + add_jump(compiler, &common->failed_match, partial_quit[1]); + +load_from_mem_sse2(compiler, data_ind, str_ptr_reg_ind, 0); +for (i = 0; i < 4; i++) + fast_forward_char_pair_sse2_compare(compiler, compare_type, i, data_ind, cmp1_ind, cmp2_ind, tmp_ind); + +/* PMOVMSKB reg, xmm */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0xd7; +instruction[3] = 0xc0 | (tmp1_reg_ind << 3) | data_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +CMPTO(SLJIT_ZERO, TMP1, 0, SLJIT_IMM, 0, start); + +JUMPHERE(quit); + +/* BSF r32, r/m32 */ +instruction[0] = 0x0f; +instruction[1] = 0xbc; +instruction[2] = 0xc0 | (tmp1_reg_ind << 3) | tmp1_reg_ind; +sljit_emit_op_custom(compiler, instruction, 3); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); + +if (common->mode != PCRE2_JIT_COMPLETE) + { + JUMPHERE(partial_quit[0]); + JUMPHERE(partial_quit[1]); + OP2(SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0); + CMOV(SLJIT_GREATER, STR_PTR, STR_END, 0); + } +else + add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +if (common->utf && offset > 0) + { + SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE); + + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offset)); + + quit = jump_if_utf_char_start(compiler, TMP1); + + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); + JUMPTO(SLJIT_JUMP, restart); + + JUMPHERE(quit); + } +#endif +} + +#ifndef _WIN64 + +static SLJIT_INLINE sljit_u32 max_fast_forward_char_pair_offset(void) +{ +#if PCRE2_CODE_UNIT_WIDTH == 8 +return 15; +#elif PCRE2_CODE_UNIT_WIDTH == 16 +return 7; +#elif PCRE2_CODE_UNIT_WIDTH == 32 +return 3; +#else +#error "Unsupported unit width" +#endif +} + +#define JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD (sljit_has_cpu_feature(SLJIT_HAS_SSE2)) + +static void fast_forward_char_pair_simd(compiler_common *common, sljit_s32 offs1, + PCRE2_UCHAR char1a, PCRE2_UCHAR char1b, sljit_s32 offs2, PCRE2_UCHAR char2a, PCRE2_UCHAR char2b) +{ +DEFINE_COMPILER; +sse2_compare_type compare1_type = sse2_compare_match1; +sse2_compare_type compare2_type = sse2_compare_match1; +sljit_u32 bit1 = 0; +sljit_u32 bit2 = 0; +sljit_u32 diff = IN_UCHARS(offs1 - offs2); +sljit_s32 tmp1_reg_ind = sljit_get_register_index(TMP1); +sljit_s32 tmp2_reg_ind = sljit_get_register_index(TMP2); +sljit_s32 str_ptr_reg_ind = sljit_get_register_index(STR_PTR); +sljit_s32 data1_ind = 0; +sljit_s32 data2_ind = 1; +sljit_s32 tmp1_ind = 2; +sljit_s32 tmp2_ind = 3; +sljit_s32 cmp1a_ind = 4; +sljit_s32 cmp1b_ind = 5; +sljit_s32 cmp2a_ind = 6; +sljit_s32 cmp2b_ind = 7; +struct sljit_label *start; +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +struct sljit_label *restart; +#endif +struct sljit_jump *jump[2]; +sljit_u8 instruction[8]; +int i; + +SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE && offs1 > offs2); +SLJIT_ASSERT(diff <= IN_UCHARS(max_fast_forward_char_pair_offset())); +SLJIT_ASSERT(tmp1_reg_ind < 8 && tmp2_reg_ind == 1); + +/* Initialize. */ +if (common->match_end_ptr != 0) + { + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); + OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(offs1 + 1)); + + OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0); + CMOV(SLJIT_LESS, STR_END, TMP1, 0); + } + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1)); +add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +/* MOVD xmm, r/m32 */ +instruction[0] = 0x66; +instruction[1] = 0x0f; +instruction[2] = 0x6e; + +if (char1a == char1b) + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a)); +else + { + bit1 = char1a ^ char1b; + if (is_powerof2(bit1)) + { + compare1_type = sse2_compare_match1i; + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a | bit1)); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(bit1)); + } + else + { + compare1_type = sse2_compare_match2; + bit1 = 0; + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char1a)); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(char1b)); + } + } + +instruction[3] = 0xc0 | (cmp1a_ind << 3) | tmp1_reg_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +if (char1a != char1b) + { + instruction[3] = 0xc0 | (cmp1b_ind << 3) | tmp2_reg_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + +if (char2a == char2b) + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a)); +else + { + bit2 = char2a ^ char2b; + if (is_powerof2(bit2)) + { + compare2_type = sse2_compare_match1i; + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a | bit2)); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(bit2)); + } + else + { + compare2_type = sse2_compare_match2; + bit2 = 0; + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, character_to_int32(char2a)); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, character_to_int32(char2b)); + } + } + +instruction[3] = 0xc0 | (cmp2a_ind << 3) | tmp1_reg_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +if (char2a != char2b) + { + instruction[3] = 0xc0 | (cmp2b_ind << 3) | tmp2_reg_ind; + sljit_emit_op_custom(compiler, instruction, 4); + } + +/* PSHUFD xmm1, xmm2/m128, imm8 */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0x70; +instruction[4] = 0; + +instruction[3] = 0xc0 | (cmp1a_ind << 3) | cmp1a_ind; +sljit_emit_op_custom(compiler, instruction, 5); + +if (char1a != char1b) + { + instruction[3] = 0xc0 | (cmp1b_ind << 3) | cmp1b_ind; + sljit_emit_op_custom(compiler, instruction, 5); + } + +instruction[3] = 0xc0 | (cmp2a_ind << 3) | cmp2a_ind; +sljit_emit_op_custom(compiler, instruction, 5); + +if (char2a != char2b) + { + instruction[3] = 0xc0 | (cmp2b_ind << 3) | cmp2b_ind; + sljit_emit_op_custom(compiler, instruction, 5); + } + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +restart = LABEL(); +#endif + +OP2(SLJIT_SUB, TMP1, 0, STR_PTR, 0, SLJIT_IMM, diff); +OP1(SLJIT_MOV, TMP2, 0, STR_PTR, 0); +OP2(SLJIT_AND, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, ~0xf); + +load_from_mem_sse2(compiler, data1_ind, str_ptr_reg_ind, 0); + +jump[0] = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, STR_PTR, 0); + +load_from_mem_sse2(compiler, data2_ind, str_ptr_reg_ind, -(sljit_s8)diff); +jump[1] = JUMP(SLJIT_JUMP); + +JUMPHERE(jump[0]); + +/* MOVDQA xmm1, xmm2/m128 */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0x6f; +instruction[3] = 0xc0 | (data2_ind << 3) | data1_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +/* PSLLDQ xmm1, imm8 */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0x73; +instruction[3] = 0xc0 | (7 << 3) | data2_ind; +instruction[4] = diff; +sljit_emit_op_custom(compiler, instruction, 5); + +JUMPHERE(jump[1]); + +OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xf); + +for (i = 0; i < 4; i++) + { + fast_forward_char_pair_sse2_compare(compiler, compare2_type, i, data2_ind, cmp2a_ind, cmp2b_ind, tmp2_ind); + fast_forward_char_pair_sse2_compare(compiler, compare1_type, i, data1_ind, cmp1a_ind, cmp1b_ind, tmp1_ind); + } + +/* PAND xmm1, xmm2/m128 */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0xdb; +instruction[3] = 0xc0 | (data1_ind << 3) | data2_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +/* PMOVMSKB reg, xmm */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0xd7; +instruction[3] = 0xc0 | (tmp1_reg_ind << 3) | 0; +sljit_emit_op_custom(compiler, instruction, 4); + +/* Ignore matches before the first STR_PTR. */ +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); +OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, TMP2, 0); + +jump[0] = CMP(SLJIT_NOT_ZERO, TMP1, 0, SLJIT_IMM, 0); + +OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); + +/* Main loop. */ +start = LABEL(); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 16); +add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +load_from_mem_sse2(compiler, data1_ind, str_ptr_reg_ind, 0); +load_from_mem_sse2(compiler, data2_ind, str_ptr_reg_ind, -(sljit_s8)diff); + +for (i = 0; i < 4; i++) + { + fast_forward_char_pair_sse2_compare(compiler, compare1_type, i, data1_ind, cmp1a_ind, cmp1b_ind, tmp2_ind); + fast_forward_char_pair_sse2_compare(compiler, compare2_type, i, data2_ind, cmp2a_ind, cmp2b_ind, tmp1_ind); + } + +/* PAND xmm1, xmm2/m128 */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0xdb; +instruction[3] = 0xc0 | (data1_ind << 3) | data2_ind; +sljit_emit_op_custom(compiler, instruction, 4); + +/* PMOVMSKB reg, xmm */ +/* instruction[0] = 0x66; */ +/* instruction[1] = 0x0f; */ +instruction[2] = 0xd7; +instruction[3] = 0xc0 | (tmp1_reg_ind << 3) | 0; +sljit_emit_op_custom(compiler, instruction, 4); + +CMPTO(SLJIT_ZERO, TMP1, 0, SLJIT_IMM, 0, start); + +JUMPHERE(jump[0]); + +/* BSF r32, r/m32 */ +instruction[0] = 0x0f; +instruction[1] = 0xbc; +instruction[2] = 0xc0 | (tmp1_reg_ind << 3) | tmp1_reg_ind; +sljit_emit_op_custom(compiler, instruction, 3); + +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); + +add_jump(compiler, &common->failed_match, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); + +if (common->match_end_ptr != 0) + OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +if (common->utf) + { + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-offs1)); + + jump[0] = jump_if_utf_char_start(compiler, TMP1); + + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, restart); + + add_jump(compiler, &common->failed_match, JUMP(SLJIT_JUMP)); + + JUMPHERE(jump[0]); + } +#endif + +OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offs1)); + +if (common->match_end_ptr != 0) + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); +} + +#endif /* !_WIN64 */ + +#undef SSE2_COMPARE_TYPE_INDEX + +#endif /* SLJIT_CONFIG_X86 && !SUPPORT_VALGRIND */ + +#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64 && (defined __ARM_NEON || defined __ARM_NEON__)) + +#include <arm_neon.h> + +typedef union { + unsigned int x; + struct { unsigned char c1, c2, c3, c4; } c; +} int_char; + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +static SLJIT_INLINE int utf_continue(sljit_u8 *s) +{ +#if PCRE2_CODE_UNIT_WIDTH == 8 +return (*s & 0xc0) == 0x80; +#elif PCRE2_CODE_UNIT_WIDTH == 16 +return (*s & 0xfc00) == 0xdc00; +#else +#error "Unknown code width" +#endif +} +#endif /* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 */ + +#if PCRE2_CODE_UNIT_WIDTH == 8 +# define VECTOR_FACTOR 16 +# define vect_t uint8x16_t +# define VLD1Q(X) vld1q_u8((sljit_u8 *)(X)) +# define VCEQQ vceqq_u8 +# define VORRQ vorrq_u8 +# define VST1Q vst1q_u8 +# define VDUPQ vdupq_n_u8 +# define VEXTQ vextq_u8 +# define VANDQ vandq_u8 +typedef union { + uint8_t mem[16]; + uint64_t dw[2]; +} quad_word; +#elif PCRE2_CODE_UNIT_WIDTH == 16 +# define VECTOR_FACTOR 8 +# define vect_t uint16x8_t +# define VLD1Q(X) vld1q_u16((sljit_u16 *)(X)) +# define VCEQQ vceqq_u16 +# define VORRQ vorrq_u16 +# define VST1Q vst1q_u16 +# define VDUPQ vdupq_n_u16 +# define VEXTQ vextq_u16 +# define VANDQ vandq_u16 +typedef union { + uint16_t mem[8]; + uint64_t dw[2]; +} quad_word; +#else +# define VECTOR_FACTOR 4 +# define vect_t uint32x4_t +# define VLD1Q(X) vld1q_u32((sljit_u32 *)(X)) +# define VCEQQ vceqq_u32 +# define VORRQ vorrq_u32 +# define VST1Q vst1q_u32 +# define VDUPQ vdupq_n_u32 +# define VEXTQ vextq_u32 +# define VANDQ vandq_u32 +typedef union { + uint32_t mem[4]; + uint64_t dw[2]; +} quad_word; +#endif + +#define FFCS +#include "pcre2_jit_neon_inc.h" +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +# define FF_UTF +# include "pcre2_jit_neon_inc.h" +# undef FF_UTF +#endif +#undef FFCS + +#define FFCS_2 +#include "pcre2_jit_neon_inc.h" +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +# define FF_UTF +# include "pcre2_jit_neon_inc.h" +# undef FF_UTF +#endif +#undef FFCS_2 + +#define FFCS_MASK +#include "pcre2_jit_neon_inc.h" +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +# define FF_UTF +# include "pcre2_jit_neon_inc.h" +# undef FF_UTF +#endif +#undef FFCS_MASK + +#define JIT_HAS_FAST_FORWARD_CHAR_SIMD 1 + +static void fast_forward_char_simd(compiler_common *common, PCRE2_UCHAR char1, PCRE2_UCHAR char2, sljit_s32 offset) +{ +DEFINE_COMPILER; +int_char ic; +struct sljit_jump *partial_quit; +/* Save temporary registers. */ +OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STR_PTR, 0); +OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP3, 0); + +/* Prepare function arguments */ +OP1(SLJIT_MOV, SLJIT_R0, 0, STR_END, 0); +OP1(SLJIT_MOV, SLJIT_R1, 0, STR_PTR, 0); +OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, offset); + +if (char1 == char2) + { + ic.c.c1 = char1; + ic.c.c2 = char2; + OP1(SLJIT_MOV, SLJIT_R4, 0, SLJIT_IMM, ic.x); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + if (common->utf && offset > 0) + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_utf)); + else + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs)); +#else + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs)); +#endif + } +else + { + PCRE2_UCHAR mask = char1 ^ char2; + if (is_powerof2(mask)) + { + ic.c.c1 = char1 | mask; + ic.c.c2 = mask; + OP1(SLJIT_MOV, SLJIT_R4, 0, SLJIT_IMM, ic.x); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + if (common->utf && offset > 0) + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_mask_utf)); + else + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_mask)); +#else + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_mask)); +#endif + } + else + { + ic.c.c1 = char1; + ic.c.c2 = char2; + OP1(SLJIT_MOV, SLJIT_R4, 0, SLJIT_IMM, ic.x); + +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + if (common->utf && offset > 0) + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_2_utf)); + else + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_2)); +#else + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(UW) | SLJIT_ARG3(UW) | SLJIT_ARG4(UW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcs_2)); +#endif + } + } +/* Restore registers. */ +OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); +OP1(SLJIT_MOV, TMP3, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1); + +/* Check return value. */ +partial_quit = CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); +if (common->mode == PCRE2_JIT_COMPLETE) + add_jump(compiler, &common->failed_match, partial_quit); + +/* Fast forward STR_PTR to the result of memchr. */ +OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0); + +if (common->mode != PCRE2_JIT_COMPLETE) + JUMPHERE(partial_quit); +} + +typedef enum { + compare_match1, + compare_match1i, + compare_match2, +} compare_type; + +static inline vect_t fast_forward_char_pair_compare(compare_type ctype, vect_t dst, vect_t cmp1, vect_t cmp2) +{ +if (ctype == compare_match2) + { + vect_t tmp = dst; + dst = VCEQQ(dst, cmp1); + tmp = VCEQQ(tmp, cmp2); + dst = VORRQ(dst, tmp); + return dst; + } + +if (ctype == compare_match1i) + dst = VORRQ(dst, cmp2); +dst = VCEQQ(dst, cmp1); +return dst; +} + +static SLJIT_INLINE sljit_u32 max_fast_forward_char_pair_offset(void) +{ +#if PCRE2_CODE_UNIT_WIDTH == 8 +return 15; +#elif PCRE2_CODE_UNIT_WIDTH == 16 +return 7; +#elif PCRE2_CODE_UNIT_WIDTH == 32 +return 3; +#else +#error "Unsupported unit width" +#endif +} + +/* ARM doesn't have a shift left across lanes. */ +static SLJIT_INLINE vect_t shift_left_n_lanes(vect_t a, sljit_u8 n) +{ +vect_t zero = VDUPQ(0); +SLJIT_ASSERT(0 < n && n < VECTOR_FACTOR); +/* VEXTQ takes an immediate as last argument. */ +#define C(X) case X: return VEXTQ(zero, a, VECTOR_FACTOR - X); +switch (n) + { + C(1); C(2); C(3); +#if PCRE2_CODE_UNIT_WIDTH != 32 + C(4); C(5); C(6); C(7); +# if PCRE2_CODE_UNIT_WIDTH != 16 + C(8); C(9); C(10); C(11); C(12); C(13); C(14); C(15); +# endif +#endif + default: + /* Based on the ASSERT(0 < n && n < VECTOR_FACTOR) above, this won't + happen. The return is still here for compilers to not warn. */ + return a; + } +} + +#define FFCPS +#define FFCPS_DIFF1 +#define FFCPS_CHAR1A2A + +#define FFCPS_0 +#include "pcre2_jit_neon_inc.h" +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +# define FF_UTF +# include "pcre2_jit_neon_inc.h" +# undef FF_UTF +#endif +#undef FFCPS_0 + +#undef FFCPS_CHAR1A2A + +#define FFCPS_1 +#include "pcre2_jit_neon_inc.h" +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +# define FF_UTF +# include "pcre2_jit_neon_inc.h" +# undef FF_UTF +#endif +#undef FFCPS_1 + +#undef FFCPS_DIFF1 + +#define FFCPS_DEFAULT +#include "pcre2_jit_neon_inc.h" +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 +# define FF_UTF +# include "pcre2_jit_neon_inc.h" +# undef FF_UTF +#endif +#undef FFCPS + +#define JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD 1 + +static void fast_forward_char_pair_simd(compiler_common *common, sljit_s32 offs1, + PCRE2_UCHAR char1a, PCRE2_UCHAR char1b, sljit_s32 offs2, PCRE2_UCHAR char2a, PCRE2_UCHAR char2b) +{ +DEFINE_COMPILER; +sljit_u32 diff = IN_UCHARS(offs1 - offs2); +struct sljit_jump *partial_quit; +int_char ic; +SLJIT_ASSERT(common->mode == PCRE2_JIT_COMPLETE && offs1 > offs2); +SLJIT_ASSERT(diff <= IN_UCHARS(max_fast_forward_char_pair_offset())); +SLJIT_ASSERT(compiler->scratches == 5); + +/* Save temporary register STR_PTR. */ +OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STR_PTR, 0); + +/* Prepare arguments for the function call. */ +if (common->match_end_ptr == 0) + OP1(SLJIT_MOV, SLJIT_R0, 0, STR_END, 0); +else + { + OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); + OP2(SLJIT_ADD, SLJIT_R0, 0, SLJIT_R0, 0, SLJIT_IMM, IN_UCHARS(offs1 + 1)); + + OP2(SLJIT_SUB | SLJIT_SET_LESS, SLJIT_UNUSED, 0, STR_END, 0, SLJIT_R0, 0); + CMOV(SLJIT_LESS, SLJIT_R0, STR_END, 0); + } + +OP1(SLJIT_MOV, SLJIT_R1, 0, STR_PTR, 0); +OP1(SLJIT_MOV_S32, SLJIT_R2, 0, SLJIT_IMM, offs1); +OP1(SLJIT_MOV_S32, SLJIT_R3, 0, SLJIT_IMM, offs2); +ic.c.c1 = char1a; +ic.c.c2 = char1b; +ic.c.c3 = char2a; +ic.c.c4 = char2b; +OP1(SLJIT_MOV_U32, SLJIT_R4, 0, SLJIT_IMM, ic.x); + +if (diff == 1) { + if (char1a == char1b && char2a == char2b) { +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + if (common->utf) + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcps_0_utf)); + else +#endif + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcps_0)); + } else { +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + if (common->utf) + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcps_1_utf)); + else +#endif + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcps_1)); + } +} else { +#if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 + if (common->utf) + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcps_default_utf)); + else +#endif + sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_RET(SW) | SLJIT_ARG1(SW) | SLJIT_ARG2(SW) | SLJIT_ARG3(SW) | SLJIT_ARG4(SW), + SLJIT_IMM, SLJIT_FUNC_OFFSET(ffcps_default)); +} + +/* Restore STR_PTR register. */ +OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0); + +/* Check return value. */ +partial_quit = CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0); +add_jump(compiler, &common->failed_match, partial_quit); + +/* Fast forward STR_PTR to the result of memchr. */ +OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0); + +JUMPHERE(partial_quit); +} + +#endif /* SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64 */ diff --git a/src/3rdparty/pcre2/src/pcre2_maketables.c b/src/3rdparty/pcre2/src/pcre2_maketables.c index 5921e90793..8c93b4b573 100644 --- a/src/3rdparty/pcre2/src/pcre2_maketables.c +++ b/src/3rdparty/pcre2/src/pcre2_maketables.c @@ -147,4 +147,15 @@ for (i = 0; i < 256; i++) return yield; } +#ifndef DFTABLES +PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION +pcre2_maketables_free(pcre2_general_context *gcontext, const uint8_t *tables) +{ + if (gcontext) + gcontext->memctl.free((void *)tables, gcontext->memctl.memory_data); + else + free((void *)tables); +} +#endif + /* End of pcre2_maketables.c */ diff --git a/src/3rdparty/pcre2/src/pcre2_match.c b/src/3rdparty/pcre2/src/pcre2_match.c index 419561fd64..48e7b9dbb2 100644 --- a/src/3rdparty/pcre2/src/pcre2_match.c +++ b/src/3rdparty/pcre2/src/pcre2_match.c @@ -415,8 +415,7 @@ if (caseless) else #endif - /* Not in UTF mode */ - + /* Not in UTF mode */ { for (; length > 0; length--) { @@ -491,27 +490,32 @@ heap is used for a larger vector. *************************************************/ /* These macros pack up tests that are used for partial matching several times -in the code. We set the "hit end" flag if the pointer is at the end of the -subject and also past the earliest inspected character (i.e. something has been -matched, even if not part of the actual matched string). For hard partial -matching, we then return immediately. The second one is used when we already -know we are past the end of the subject. */ +in the code. The second one is used when we already know we are past the end of +the subject. We set the "hit end" flag if the pointer is at the end of the +subject and either (a) the pointer is past the earliest inspected character +(i.e. something has been matched, even if not part of the actual matched +string), or (b) the pattern contains a lookbehind. These are the conditions for +which adding more characters may allow the current match to continue. + +For hard partial matching, we immediately return a partial match. Otherwise, +carrying on means that a complete match on the current subject will be sought. +A partial match is returned only if no complete match can be found. */ #define CHECK_PARTIAL()\ - if (mb->partial != 0 && Feptr >= mb->end_subject && \ - Feptr > mb->start_used_ptr) \ + if (Feptr >= mb->end_subject) \ { \ - mb->hitend = TRUE; \ - if (mb->partial > 1) return PCRE2_ERROR_PARTIAL; \ + SCHECK_PARTIAL(); \ } #define SCHECK_PARTIAL()\ - if (mb->partial != 0 && Feptr > mb->start_used_ptr) \ + if (mb->partial != 0 && \ + (Feptr > mb->start_used_ptr || mb->allowemptypartial)) \ { \ mb->hitend = TRUE; \ if (mb->partial > 1) return PCRE2_ERROR_PARTIAL; \ } + /* These macros are used to implement backtracking. They simulate a recursive call to the match() function by means of a local vector of frames which remember the backtracking points. */ @@ -5127,6 +5131,8 @@ fprintf(stderr, "++ op=%d\n", *Fecode); case OP_ASSERT: case OP_ASSERTBACK: + case OP_ASSERT_NA: + case OP_ASSERTBACK_NA: Lframe_type = GF_NOCAPTURE | Fop; for (;;) { @@ -5412,7 +5418,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); { while (number-- > 0) { - if (Feptr <= mb->start_subject) RRETURN(MATCH_NOMATCH); + if (Feptr <= mb->check_subject) RRETURN(MATCH_NOMATCH); Feptr--; BACKCHAR(Feptr); } @@ -5420,7 +5426,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); else #endif - /* No UTF-8 support, or not in UTF-8 mode: count is byte count */ + /* No UTF-8 support, or not in UTF-8 mode: count is code unit count */ { if ((ptrdiff_t)number > Feptr - mb->start_subject) RRETURN(MATCH_NOMATCH); @@ -5472,15 +5478,16 @@ fprintf(stderr, "++ op=%d\n", *Fecode); /* If we are at the end of an assertion that is a condition, return a match, discarding any intermediate backtracking points. Copy back the - captures into the frame before N so that they are set on return. Doing - this for all assertions, both positive and negative, seems to match what - Perl does. */ + mark setting and the captures into the frame before N so that they are + set on return. Doing this for all assertions, both positive and negative, + seems to match what Perl does. */ if (GF_IDMASK(N->group_frame_type) == GF_CONDASSERT) { memcpy((char *)P + offsetof(heapframe, ovector), Fovector, Foffset_top * sizeof(PCRE2_SIZE)); P->offset_top = Foffset_top; + P->mark = Fmark; Fback_frame = (char *)F - (char *)P; RRETURN(MATCH_MATCH); } @@ -5496,10 +5503,20 @@ fprintf(stderr, "++ op=%d\n", *Fecode); case OP_SCOND: break; - /* Positive assertions are like OP_ONCE, except that in addition the + /* Non-atomic positive assertions are like OP_BRA, except that the subject pointer must be put back to where it was at the start of the assertion. */ + case OP_ASSERT_NA: + case OP_ASSERTBACK_NA: + if (Feptr > mb->last_used_ptr) mb->last_used_ptr = Feptr; + Feptr = P->eptr; + break; + + /* Atomic positive assertions are like OP_ONCE, except that in addition + the subject pointer must be put back to where it was at the start of the + assertion. */ + case OP_ASSERT: case OP_ASSERTBACK: if (Feptr > mb->last_used_ptr) mb->last_used_ptr = Feptr; @@ -5640,7 +5657,11 @@ fprintf(stderr, "++ op=%d\n", *Fecode); case OP_EOD: if (Feptr < mb->end_subject) RRETURN(MATCH_NOMATCH); - SCHECK_PARTIAL(); + if (mb->partial != 0) + { + mb->hitend = TRUE; + if (mb->partial > 1) return PCRE2_ERROR_PARTIAL; + } Fecode++; break; @@ -5665,7 +5686,11 @@ fprintf(stderr, "++ op=%d\n", *Fecode); /* Either at end of string or \n before end. */ - SCHECK_PARTIAL(); + if (mb->partial != 0) + { + mb->hitend = TRUE; + if (mb->partial > 1) return PCRE2_ERROR_PARTIAL; + } Fecode++; break; @@ -5743,7 +5768,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); case OP_NOT_WORD_BOUNDARY: case OP_WORD_BOUNDARY: - if (Feptr == mb->start_subject) prev_is_word = FALSE; else + if (Feptr == mb->check_subject) prev_is_word = FALSE; else { PCRE2_SPTR lastptr = Feptr - 1; #ifdef SUPPORT_UNICODE @@ -5946,6 +5971,7 @@ in rrc. */ #define LBL(val) case val: goto L_RM##val; RETURN_SWITCH: +if (Feptr > mb->last_used_ptr) mb->last_used_ptr = Feptr; if (Frdepth == 0) return rrc; /* Exit from the top level */ F = (heapframe *)((char *)F - Fback_frame); /* Backtrack */ mb->cb->callout_flags |= PCRE2_CALLOUT_BACKTRACK; /* Note for callouts */ @@ -5999,9 +6025,9 @@ Arguments: Returns: > 0 => success; value is the number of ovector pairs filled = 0 => success, but ovector is not big enough - -1 => failed to match (PCRE2_ERROR_NOMATCH) - -2 => partial match (PCRE2_ERROR_PARTIAL) - < -2 => some kind of unexpected problem + = -1 => failed to match (PCRE2_ERROR_NOMATCH) + = -2 => partial match (PCRE2_ERROR_PARTIAL) + < -2 => some kind of unexpected problem */ PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION @@ -6014,7 +6040,6 @@ int was_zero_terminated = 0; const uint8_t *start_bits = NULL; const pcre2_real_code *re = (const pcre2_real_code *)code; - BOOL anchored; BOOL firstline; BOOL has_first_cu = FALSE; @@ -6022,6 +6047,11 @@ BOOL has_req_cu = FALSE; BOOL startline; BOOL utf; +#if PCRE2_CODE_UNIT_WIDTH == 8 +BOOL memchr_not_found_first_cu = FALSE; +BOOL memchr_not_found_first_cu2 = FALSE; +#endif + PCRE2_UCHAR first_cu = 0; PCRE2_UCHAR first_cu2 = 0; PCRE2_UCHAR req_cu = 0; @@ -6029,10 +6059,23 @@ PCRE2_UCHAR req_cu2 = 0; PCRE2_SPTR bumpalong_limit; PCRE2_SPTR end_subject; +PCRE2_SPTR true_end_subject; PCRE2_SPTR start_match = subject + start_offset; PCRE2_SPTR req_cu_ptr = start_match - 1; -PCRE2_SPTR start_partial = NULL; -PCRE2_SPTR match_partial = NULL; +PCRE2_SPTR start_partial; +PCRE2_SPTR match_partial; + +#ifdef SUPPORT_JIT +BOOL use_jit; +#endif + +#ifdef SUPPORT_UNICODE +BOOL allow_invalid; +uint32_t fragment_options = 0; +#ifdef SUPPORT_JIT +BOOL jit_checked_utf = FALSE; +#endif +#endif PCRE2_SIZE frame_size; @@ -6059,7 +6102,7 @@ if (length == PCRE2_ZERO_TERMINATED) length = PRIV(strlen)(subject); was_zero_terminated = 1; } -end_subject = subject + length; +true_end_subject = end_subject = subject + length; /* Plausibility checks */ @@ -6095,12 +6138,24 @@ options |= (re->flags & FF) / ((FF & (~FF+1)) / (OO & (~OO+1))); #undef FF #undef OO -/* These two settings are used in the code for checking a UTF string that -follows immediately afterwards. Other values in the mb block are used only -during interpretive processing, not when the JIT support is in use, so they are -set up later. */ +/* If the pattern was successfully studied with JIT support, we will run the +JIT executable instead of the rest of this function. Most options must be set +at compile time for the JIT code to be usable. */ + +#ifdef SUPPORT_JIT +use_jit = (re->executable_jit != NULL && + (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0); +#endif + +/* Initialize UTF parameters. */ utf = (re->overall_options & PCRE2_UTF) != 0; +#ifdef SUPPORT_UNICODE +allow_invalid = (re->overall_options & PCRE2_MATCH_INVALID_UTF) != 0; +#endif + +/* Convert the partial matching flags into an integer. */ + mb->partial = ((options & PCRE2_PARTIAL_HARD) != 0)? 2 : ((options & PCRE2_PARTIAL_SOFT) != 0)? 1 : 0; @@ -6111,88 +6166,107 @@ if (mb->partial != 0 && ((re->overall_options | options) & PCRE2_ENDANCHORED) != 0) return PCRE2_ERROR_BADOPTION; -/* Check a UTF string for validity if required. For 8-bit and 16-bit strings, -we must also check that a starting offset does not point into the middle of a -multiunit character. We check only the portion of the subject that is going to -be inspected during matching - from the offset minus the maximum back reference -to the given length. This saves time when a small part of a large subject is -being matched by the use of a starting offset. Note that the maximum lookbehind -is a number of characters, not code units. */ +/* It is an error to set an offset limit without setting the flag at compile +time. */ -#ifdef SUPPORT_UNICODE -if (utf && (options & PCRE2_NO_UTF_CHECK) == 0) +if (mcontext != NULL && mcontext->offset_limit != PCRE2_UNSET && + (re->overall_options & PCRE2_USE_OFFSET_LIMIT) == 0) + return PCRE2_ERROR_BADOFFSETLIMIT; + +/* If the match data block was previously used with PCRE2_COPY_MATCHED_SUBJECT, +free the memory that was obtained. Set the field to NULL for no match cases. */ + +if ((match_data->flags & PCRE2_MD_COPIED_SUBJECT) != 0) { - PCRE2_SPTR check_subject = start_match; /* start_match includes offset */ + match_data->memctl.free((void *)match_data->subject, + match_data->memctl.memory_data); + match_data->flags &= ~PCRE2_MD_COPIED_SUBJECT; + } +match_data->subject = NULL; + +/* Zero the error offset in case the first code unit is invalid UTF. */ + +match_data->startchar = 0; + + +/* ============================= JIT matching ============================== */ + +/* Prepare for JIT matching. Check a UTF string for validity unless no check is +requested or invalid UTF can be handled. We check only the portion of the +subject that might be be inspected during matching - from the offset minus the +maximum lookbehind to the given length. This saves time when a small part of a +large subject is being matched by the use of a starting offset. Note that the +maximum lookbehind is a number of characters, not code units. */ - if (start_offset > 0) +#ifdef SUPPORT_JIT +if (use_jit) + { +#ifdef SUPPORT_UNICODE + if (utf && (options & PCRE2_NO_UTF_CHECK) == 0 && !allow_invalid) { #if PCRE2_CODE_UNIT_WIDTH != 32 unsigned int i; +#endif + + /* For 8-bit and 16-bit UTF, check that the first code unit is a valid + character start. */ + +#if PCRE2_CODE_UNIT_WIDTH != 32 if (start_match < end_subject && NOT_FIRSTCU(*start_match)) - return PCRE2_ERROR_BADUTFOFFSET; - for (i = re->max_lookbehind; i > 0 && check_subject > subject; i--) { - check_subject--; - while (check_subject > subject && + if (start_offset > 0) return PCRE2_ERROR_BADUTFOFFSET; +#if PCRE2_CODE_UNIT_WIDTH == 8 + return PCRE2_ERROR_UTF8_ERR20; /* Isolated 0x80 byte */ +#else + return PCRE2_ERROR_UTF16_ERR3; /* Isolated low surrogate */ +#endif + } +#endif /* WIDTH != 32 */ + + /* Move back by the maximum lookbehind, just in case it happens at the very + start of matching. */ + +#if PCRE2_CODE_UNIT_WIDTH != 32 + for (i = re->max_lookbehind; i > 0 && start_match > subject; i--) + { + start_match--; + while (start_match > subject && #if PCRE2_CODE_UNIT_WIDTH == 8 - (*check_subject & 0xc0) == 0x80) + (*start_match & 0xc0) == 0x80) #else /* 16-bit */ - (*check_subject & 0xfc00) == 0xdc00) -#endif /* PCRE2_CODE_UNIT_WIDTH == 8 */ - check_subject--; + (*start_match & 0xfc00) == 0xdc00) +#endif + start_match--; } -#else +#else /* PCRE2_CODE_UNIT_WIDTH != 32 */ + /* In the 32-bit library, one code unit equals one character. However, we cannot just subtract the lookbehind and then compare pointers, because a very large lookbehind could create an invalid pointer. */ if (start_offset >= re->max_lookbehind) - check_subject -= re->max_lookbehind; + start_match -= re->max_lookbehind; else - check_subject = subject; + start_match = subject; #endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ - } - /* Validate the relevant portion of the subject. After an error, adjust the - offset to be an absolute offset in the whole string. */ + /* Validate the relevant portion of the subject. Adjust the offset of an + invalid code point to be an absolute offset in the whole string. */ - match_data->rc = PRIV(valid_utf)(check_subject, - length - (check_subject - subject), &(match_data->startchar)); - if (match_data->rc != 0) - { - match_data->startchar += check_subject - subject; - return match_data->rc; + match_data->rc = PRIV(valid_utf)(start_match, + length - (start_match - subject), &(match_data->startchar)); + if (match_data->rc != 0) + { + match_data->startchar += start_match - subject; + return match_data->rc; + } + jit_checked_utf = TRUE; } - } #endif /* SUPPORT_UNICODE */ -/* It is an error to set an offset limit without setting the flag at compile -time. */ - -if (mcontext != NULL && mcontext->offset_limit != PCRE2_UNSET && - (re->overall_options & PCRE2_USE_OFFSET_LIMIT) == 0) - return PCRE2_ERROR_BADOFFSETLIMIT; - -/* If the match data block was previously used with PCRE2_COPY_MATCHED_SUBJECT, -free the memory that was obtained. Set the field to NULL for no match cases. */ + /* If JIT returns BADOPTION, which means that the selected complete or + partial matching mode was not compiled, fall through to the interpreter. */ -if ((match_data->flags & PCRE2_MD_COPIED_SUBJECT) != 0) - { - match_data->memctl.free((void *)match_data->subject, - match_data->memctl.memory_data); - match_data->flags &= ~PCRE2_MD_COPIED_SUBJECT; - } -match_data->subject = NULL; - -/* If the pattern was successfully studied with JIT support, run the JIT -executable instead of the rest of this function. Most options must be set at -compile time for the JIT code to be usable. Fallback to the normal code path if -an unsupported option is set or if JIT returns BADOPTION (which means that the -selected normal or partial matching mode was not compiled). */ - -#ifdef SUPPORT_JIT -if (re->executable_jit != NULL && (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0) - { rc = pcre2_jit_match(code, subject, length, start_offset, options, match_data, mcontext); if (rc != PCRE2_ERROR_JIT_BADOPTION) @@ -6209,10 +6283,152 @@ if (re->executable_jit != NULL && (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0) return rc; } } +#endif /* SUPPORT_JIT */ + +/* ========================= End of JIT matching ========================== */ + + +/* Proceed with non-JIT matching. The default is to allow lookbehinds to the +start of the subject. A UTF check when there is a non-zero offset may change +this. */ + +mb->check_subject = subject; + +/* If a UTF subject string was not checked for validity in the JIT code above, +check it here, and handle support for invalid UTF strings. The check above +happens only when invalid UTF is not supported and PCRE2_NO_CHECK_UTF is unset. +If we get here in those circumstances, it means the subject string is valid, +but for some reason JIT matching was not successful. There is no need to check +the subject again. + +We check only the portion of the subject that might be be inspected during +matching - from the offset minus the maximum lookbehind to the given length. +This saves time when a small part of a large subject is being matched by the +use of a starting offset. Note that the maximum lookbehind is a number of +characters, not code units. + +Note also that support for invalid UTF forces a check, overriding the setting +of PCRE2_NO_CHECK_UTF. */ + +#ifdef SUPPORT_UNICODE +if (utf && +#ifdef SUPPORT_JIT + !jit_checked_utf && +#endif + ((options & PCRE2_NO_UTF_CHECK) == 0 || allow_invalid)) + { +#if PCRE2_CODE_UNIT_WIDTH != 32 + BOOL skipped_bad_start = FALSE; +#endif + + /* For 8-bit and 16-bit UTF, check that the first code unit is a valid + character start. If we are handling invalid UTF, just skip over such code + units. Otherwise, give an appropriate error. */ + +#if PCRE2_CODE_UNIT_WIDTH != 32 + if (allow_invalid) + { + while (start_match < end_subject && NOT_FIRSTCU(*start_match)) + { + start_match++; + skipped_bad_start = TRUE; + } + } + else if (start_match < end_subject && NOT_FIRSTCU(*start_match)) + { + if (start_offset > 0) return PCRE2_ERROR_BADUTFOFFSET; +#if PCRE2_CODE_UNIT_WIDTH == 8 + return PCRE2_ERROR_UTF8_ERR20; /* Isolated 0x80 byte */ +#else + return PCRE2_ERROR_UTF16_ERR3; /* Isolated low surrogate */ +#endif + } +#endif /* WIDTH != 32 */ + + /* The mb->check_subject field points to the start of UTF checking; + lookbehinds can go back no further than this. */ + + mb->check_subject = start_match; + + /* Move back by the maximum lookbehind, just in case it happens at the very + start of matching, but don't do this if we skipped bad 8-bit or 16-bit code + units above. */ + +#if PCRE2_CODE_UNIT_WIDTH != 32 + if (!skipped_bad_start) + { + unsigned int i; + for (i = re->max_lookbehind; i > 0 && mb->check_subject > subject; i--) + { + mb->check_subject--; + while (mb->check_subject > subject && +#if PCRE2_CODE_UNIT_WIDTH == 8 + (*mb->check_subject & 0xc0) == 0x80) +#else /* 16-bit */ + (*mb->check_subject & 0xfc00) == 0xdc00) +#endif + mb->check_subject--; + } + } +#else /* PCRE2_CODE_UNIT_WIDTH != 32 */ + + /* In the 32-bit library, one code unit equals one character. However, + we cannot just subtract the lookbehind and then compare pointers, because + a very large lookbehind could create an invalid pointer. */ + + if (start_offset >= re->max_lookbehind) + mb->check_subject -= re->max_lookbehind; + else + mb->check_subject = subject; +#endif /* PCRE2_CODE_UNIT_WIDTH != 32 */ + + /* Validate the relevant portion of the subject. There's a loop in case we + encounter bad UTF in the characters preceding start_match which we are + scanning because of a lookbehind. */ + + for (;;) + { + match_data->rc = PRIV(valid_utf)(mb->check_subject, + length - (mb->check_subject - subject), &(match_data->startchar)); + + if (match_data->rc == 0) break; /* Valid UTF string */ + + /* Invalid UTF string. Adjust the offset to be an absolute offset in the + whole string. If we are handling invalid UTF strings, set end_subject to + stop before the bad code unit, and set the options to "not end of line". + Otherwise return the error. */ + + match_data->startchar += mb->check_subject - subject; + if (!allow_invalid || match_data->rc > 0) return match_data->rc; + end_subject = subject + match_data->startchar; + + /* If the end precedes start_match, it means there is invalid UTF in the + extra code units we reversed over because of a lookbehind. Advance past the + first bad code unit, and then skip invalid character starting code units in + 8-bit and 16-bit modes, and try again. */ + + if (end_subject < start_match) + { + mb->check_subject = end_subject + 1; +#if PCRE2_CODE_UNIT_WIDTH != 32 + while (mb->check_subject < start_match && NOT_FIRSTCU(*mb->check_subject)) + mb->check_subject++; #endif + } + + /* Otherwise, set the not end of line option, and do the match. */ + + else + { + fragment_options = PCRE2_NOTEOL; + break; + } + } + } +#endif /* SUPPORT_UNICODE */ -/* Carry on with non-JIT matching. A NULL match context means "use a default -context", but we take the memory control functions from the pattern. */ +/* A NULL match context means "use a default context", but we take the memory +control functions from the pattern. */ if (mcontext == NULL) { @@ -6224,8 +6440,8 @@ else mb->memctl = mcontext->memctl; anchored = ((re->overall_options | options) & PCRE2_ANCHORED) != 0; firstline = (re->overall_options & PCRE2_FIRSTLINE) != 0; startline = (re->flags & PCRE2_STARTLINE) != 0; -bumpalong_limit = (mcontext->offset_limit == PCRE2_UNSET)? - end_subject : subject + mcontext->offset_limit; +bumpalong_limit = (mcontext->offset_limit == PCRE2_UNSET)? + true_end_subject : subject + mcontext->offset_limit; /* Initialize and set up the fixed fields in the callout block, with a pointer in the match block. */ @@ -6236,7 +6452,8 @@ cb.subject = subject; cb.subject_length = (PCRE2_SIZE)(end_subject - subject); cb.callout_flags = 0; -/* Fill in the remaining fields in the match block. */ +/* Fill in the remaining fields in the match block, except for moptions, which +gets set later. */ mb->callout = mcontext->callout; mb->callout_data = mcontext->callout_data; @@ -6245,13 +6462,11 @@ mb->start_subject = subject; mb->start_offset = start_offset; mb->end_subject = end_subject; mb->hasthen = (re->flags & PCRE2_HASTHEN) != 0; - -mb->moptions = options; /* Match options */ -mb->poptions = re->overall_options; /* Pattern options */ - +mb->allowemptypartial = (re->max_lookbehind > 0) || + (re->flags & PCRE2_MATCH_EMPTY) != 0; +mb->poptions = re->overall_options; /* Pattern options */ mb->ignore_skip_arg = 0; -mb->mark = mb->nomatch_mark = NULL; /* In case never set */ -mb->hitend = FALSE; +mb->mark = mb->nomatch_mark = NULL; /* In case never set */ /* The name table is needed for finding all the numbers associated with a given name, for condition testing. The code follows the name table. */ @@ -6404,6 +6619,13 @@ if ((re->flags & PCRE2_LASTSET) != 0) /* Loop for handling unanchored repeated matching attempts; for anchored regexs the loop runs just once. */ +#ifdef SUPPORT_UNICODE +FRAGMENT_RESTART: +#endif + +start_partial = match_partial = NULL; +mb->hitend = FALSE; + for(;;) { PCRE2_SPTR new_start_match; @@ -6473,7 +6695,10 @@ for(;;) /* Not anchored. Advance to a unique first code unit if there is one. In 8-bit mode, the use of memchr() gives a big speed up, even though we have to call it twice in caseless mode, in order to find the earliest occurrence - of the character in either of its cases. */ + of the character in either of its cases. If a call to memchr() that + searches the rest of the subject fails to find one case, remember that in + order not to keep on repeating the search. This can make a huge difference + when the strings are very long and only one case is present. */ else { @@ -6487,11 +6712,29 @@ for(;;) (smc = UCHAR21TEST(start_match)) != first_cu && smc != first_cu2) start_match++; + #else /* 8-bit code units */ - PCRE2_SPTR pp1 = - memchr(start_match, first_cu, end_subject-start_match); - PCRE2_SPTR pp2 = - memchr(start_match, first_cu2, end_subject-start_match); + PCRE2_SPTR pp1 = NULL; + PCRE2_SPTR pp2 = NULL; + PCRE2_SIZE cu2size = end_subject - start_match; + + if (!memchr_not_found_first_cu) + { + pp1 = memchr(start_match, first_cu, end_subject - start_match); + if (pp1 == NULL) memchr_not_found_first_cu = TRUE; + else cu2size = pp1 - start_match; + } + + /* If pp1 is not NULL, we have arranged to search only as far as pp1, + to see if the other case is earlier, so we can set "not found" only + when both searches have returned NULL. */ + + if (!memchr_not_found_first_cu2) + { + pp2 = memchr(start_match, first_cu2, cu2size); + memchr_not_found_first_cu2 = (pp2 == NULL && pp1 == NULL); + } + if (pp1 == NULL) start_match = (pp2 == NULL)? end_subject : pp2; else @@ -6523,7 +6766,7 @@ for(;;) we also let the cycle run, because the matching string is legitimately allowed to start with the first code unit of a newline. */ - if (!mb->partial && start_match >= mb->end_subject) + if (mb->partial == 0 && start_match >= mb->end_subject) { rc = MATCH_NOMATCH; break; @@ -6582,7 +6825,7 @@ for(;;) /* See comment above in first_cu checking about the next few lines. */ - if (!mb->partial && start_match >= mb->end_subject) + if (mb->partial == 0 && start_match >= mb->end_subject) { rc = MATCH_NOMATCH; break; @@ -6596,8 +6839,10 @@ for(;;) /* The following two optimizations must be disabled for partial matching. */ - if (!mb->partial) + if (mb->partial == 0) { + PCRE2_SPTR p; + /* The minimum matching length is a lower bound; no string of that length may actually match the pattern. Although the value is, strictly, in characters, we treat it as code units to avoid spending too much time in @@ -6621,60 +6866,57 @@ for(;;) memchr() twice in the caseless case because we only need to check for the presence of the character in either case, not find the first occurrence. + The search can be skipped if the code unit was found later than the + current starting point in a previous iteration of the bumpalong loop. + HOWEVER: when the subject string is very, very long, searching to its end can take a long time, and give bad performance on quite ordinary - patterns. This showed up when somebody was matching something like - /^\d+C/ on a 32-megabyte string... so we don't do this when the string is - sufficiently long. */ + anchored patterns. This showed up when somebody was matching something + like /^\d+C/ on a 32-megabyte string... so we don't do this when the + string is sufficiently long, but it's worth searching a lot more for + unanchored patterns. */ - if (has_req_cu && end_subject - start_match < REQ_CU_MAX) + p = start_match + (has_first_cu? 1:0); + if (has_req_cu && p > req_cu_ptr) { - PCRE2_SPTR p = start_match + (has_first_cu? 1:0); - - /* We don't need to repeat the search if we haven't yet reached the - place we found it last time round the bumpalong loop. */ + PCRE2_SIZE check_length = end_subject - start_match; - if (p > req_cu_ptr) + if (check_length < REQ_CU_MAX || + (!anchored && check_length < REQ_CU_MAX * 1000)) { - if (p < end_subject) + if (req_cu != req_cu2) /* Caseless */ { - if (req_cu != req_cu2) /* Caseless */ - { #if PCRE2_CODE_UNIT_WIDTH != 8 - do - { - uint32_t pp = UCHAR21INCTEST(p); - if (pp == req_cu || pp == req_cu2) { p--; break; } - } - while (p < end_subject); - + while (p < end_subject) + { + uint32_t pp = UCHAR21INCTEST(p); + if (pp == req_cu || pp == req_cu2) { p--; break; } + } #else /* 8-bit code units */ - PCRE2_SPTR pp = p; - p = memchr(pp, req_cu, end_subject - pp); - if (p == NULL) - { - p = memchr(pp, req_cu2, end_subject - pp); - if (p == NULL) p = end_subject; - } -#endif /* PCRE2_CODE_UNIT_WIDTH != 8 */ + PCRE2_SPTR pp = p; + p = memchr(pp, req_cu, end_subject - pp); + if (p == NULL) + { + p = memchr(pp, req_cu2, end_subject - pp); + if (p == NULL) p = end_subject; } +#endif /* PCRE2_CODE_UNIT_WIDTH != 8 */ + } - /* The caseful case */ + /* The caseful case */ - else - { + else + { #if PCRE2_CODE_UNIT_WIDTH != 8 - do - { - if (UCHAR21INCTEST(p) == req_cu) { p--; break; } - } - while (p < end_subject); + while (p < end_subject) + { + if (UCHAR21INCTEST(p) == req_cu) { p--; break; } + } #else /* 8-bit code units */ - p = memchr(p, req_cu, end_subject - p); - if (p == NULL) p = end_subject; + p = memchr(p, req_cu, end_subject - p); + if (p == NULL) p = end_subject; #endif - } } /* If we can't find the required code unit, break the bumpalong loop, @@ -6714,6 +6956,11 @@ for(;;) mb->start_used_ptr = start_match; mb->last_used_ptr = start_match; +#ifdef SUPPORT_UNICODE + mb->moptions = options | fragment_options; +#else + mb->moptions = options; +#endif mb->match_call_count = 0; mb->end_offset_top = 0; mb->skip_arg_count = 0; @@ -6839,6 +7086,68 @@ for(;;) ENDLOOP: +/* If end_subject != true_end_subject, it means we are handling invalid UTF, +and have just processed a non-terminal fragment. If this resulted in no match +or a partial match we must carry on to the next fragment (a partial match is +returned to the caller only at the very end of the subject). A loop is used to +avoid trying to match against empty fragments; if the pattern can match an +empty string it would have done so already. */ + +#ifdef SUPPORT_UNICODE +if (utf && end_subject != true_end_subject && + (rc == MATCH_NOMATCH || rc == PCRE2_ERROR_PARTIAL)) + { + for (;;) + { + /* Advance past the first bad code unit, and then skip invalid character + starting code units in 8-bit and 16-bit modes. */ + + start_match = end_subject + 1; +#if PCRE2_CODE_UNIT_WIDTH != 32 + while (start_match < true_end_subject && NOT_FIRSTCU(*start_match)) + start_match++; +#endif + + /* If we have hit the end of the subject, there isn't another non-empty + fragment, so give up. */ + + if (start_match >= true_end_subject) + { + rc = MATCH_NOMATCH; /* In case it was partial */ + break; + } + + /* Check the rest of the subject */ + + mb->check_subject = start_match; + rc = PRIV(valid_utf)(start_match, length - (start_match - subject), + &(match_data->startchar)); + + /* The rest of the subject is valid UTF. */ + + if (rc == 0) + { + mb->end_subject = end_subject = true_end_subject; + fragment_options = PCRE2_NOTBOL; + goto FRAGMENT_RESTART; + } + + /* A subsequent UTF error has been found; if the next fragment is + non-empty, set up to process it. Otherwise, let the loop advance. */ + + else if (rc < 0) + { + mb->end_subject = end_subject = start_match + match_data->startchar; + if (end_subject > start_match) + { + fragment_options = PCRE2_NOTBOL|PCRE2_NOTEOL; + goto FRAGMENT_RESTART; + } + } + } + } +#endif /* SUPPORT_UNICODE */ + /* Release an enlarged frame vector that is on the heap. */ if (mb->match_frames != mb->stack_frames) diff --git a/src/3rdparty/pcre2/src/pcre2_match_data.c b/src/3rdparty/pcre2/src/pcre2_match_data.c index ccc5f6740e..53e4698707 100644 --- a/src/3rdparty/pcre2/src/pcre2_match_data.c +++ b/src/3rdparty/pcre2/src/pcre2_match_data.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -150,4 +150,17 @@ pcre2_get_startchar(pcre2_match_data *match_data) return match_data->startchar; } + + +/************************************************* +* Get size of match data block * +*************************************************/ + +PCRE2_EXP_DEFN PCRE2_SIZE PCRE2_CALL_CONVENTION +pcre2_get_match_data_size(pcre2_match_data *match_data) +{ +return offsetof(pcre2_match_data, ovector) + + 2 * (match_data->oveccount) * sizeof(PCRE2_SIZE); +} + /* End of pcre2_match_data.c */ diff --git a/src/3rdparty/pcre2/src/pcre2_study.c b/src/3rdparty/pcre2/src/pcre2_study.c index e883c2eb4c..2883868618 100644 --- a/src/3rdparty/pcre2/src/pcre2_study.c +++ b/src/3rdparty/pcre2/src/pcre2_study.c @@ -88,11 +88,13 @@ Arguments: countptr pointer to call count (to catch over complexity) backref_cache vector for caching back references. +This function is no longer called when the pattern contains (*ACCEPT); however, +the old code for returning -1 is retained, just in case. + Returns: the minimum length -1 \C in UTF-8 mode or (*ACCEPT) or pattern too complicated - or back reference to duplicate name/number -2 internal error (missing capturing bracket) -3 internal error (opcode not listed) */ @@ -103,6 +105,7 @@ find_minlength(const pcre2_real_code *re, PCRE2_SPTR code, int *backref_cache) { int length = -1; +int branchlength = 0; int prev_cap_recno = -1; int prev_cap_d = 0; int prev_recurse_recno = -1; @@ -110,9 +113,9 @@ int prev_recurse_d = 0; uint32_t once_fudge = 0; BOOL had_recurse = FALSE; BOOL dupcapused = (re->flags & PCRE2_DUPCAPUSED) != 0; -recurse_check this_recurse; -int branchlength = 0; +PCRE2_SPTR nextbranch = code + GET(code, 1); PCRE2_UCHAR *cc = (PCRE2_UCHAR *)code + 1 + LINK_SIZE; +recurse_check this_recurse; /* If this is a "could be empty" group, its minimum length is 0. */ @@ -128,16 +131,20 @@ if ((*countptr)++ > 1000) return -1; /* Scan along the opcodes for this branch. If we get to the end of the branch, check the length against that of the other branches. If the accumulated length -passes 16-bits, stop. */ +passes 16-bits, reset to that value and skip the rest of the branch. */ for (;;) { int d, min, recno; - PCRE2_UCHAR *cs, *ce; - PCRE2_UCHAR op = *cc; + PCRE2_UCHAR op, *cs, *ce; - if (branchlength >= UINT16_MAX) return UINT16_MAX; + if (branchlength >= UINT16_MAX) + { + branchlength = UINT16_MAX; + cc = (PCRE2_UCHAR *)nextbranch; + } + op = *cc; switch (op) { case OP_COND: @@ -206,7 +213,9 @@ for (;;) cc += 1 + LINK_SIZE; break; - /* ACCEPT makes things far too complicated; we have to give up. */ + /* ACCEPT makes things far too complicated; we have to give up. In fact, + from 10.34 onwards, if a pattern contains (*ACCEPT), this function is not + used. However, leave the code in place, just in case. */ case OP_ACCEPT: case OP_ASSERT_ACCEPT: @@ -214,9 +223,9 @@ for (;;) /* Reached end of a branch; if it's a ket it is the end of a nested call. If it's ALT it is an alternation in a nested call. If it is END it's - the end of the outer call. All can be handled by the same code. If an - ACCEPT was previously encountered, use the length that was in force at that - time, and pass back the shortest ACCEPT length. */ + the end of the outer call. All can be handled by the same code. If the + length of any branch is zero, there is no need to scan any subsequent + branches. */ case OP_ALT: case OP_KET: @@ -226,7 +235,8 @@ for (;;) case OP_END: if (length < 0 || (!had_recurse && branchlength < length)) length = branchlength; - if (op != OP_ALT) return length; + if (op != OP_ALT || length == 0) return length; + nextbranch = cc + GET(cc, 1); cc += 1 + LINK_SIZE; branchlength = 0; had_recurse = FALSE; @@ -238,6 +248,8 @@ for (;;) case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: + case OP_ASSERT_NA: + case OP_ASSERTBACK_NA: do cc += GET(cc, 1); while (*cc == OP_ALT); /* Fall through */ @@ -451,15 +463,17 @@ for (;;) If PCRE2_MATCH_UNSET_BACKREF is set, a backreference to an unset bracket matches an empty string (by default it causes a matching failure), so in - that case we must set the minimum length to zero. */ + that case we must set the minimum length to zero. + + For backreferenes, if duplicate numbers are present in the pattern we check + for a reference to a duplicate. If it is, we don't know which version will + be referenced, so we have to set the minimum length to zero. */ - /* Duplicate named pattern back reference. We cannot reliably find a length - for this if duplicate numbers are present in the pattern. */ + /* Duplicate named pattern back reference. */ case OP_DNREF: case OP_DNREFI: - if (dupcapused) return -1; - if ((re->overall_options & PCRE2_MATCH_UNSET_BACKREF) == 0) + if (!dupcapused && (re->overall_options & PCRE2_MATCH_UNSET_BACKREF) == 0) { int count = GET2(cc, 1+IMM2_SIZE); PCRE2_UCHAR *slot = @@ -482,28 +496,32 @@ for (;;) ce = cs = (PCRE2_UCHAR *)PRIV(find_bracket)(startcode, utf, recno); if (cs == NULL) return -2; do ce += GET(ce, 1); while (*ce == OP_ALT); - if (cc > cs && cc < ce) /* Simple recursion */ - { - dd = 0; - had_recurse = TRUE; - } - else + + dd = 0; + if (!dupcapused || + (PCRE2_UCHAR *)PRIV(find_bracket)(ce, utf, recno) == NULL) { - recurse_check *r = recurses; - for (r = recurses; r != NULL; r = r->prev) - if (r->group == cs) break; - if (r != NULL) /* Mutual recursion */ + if (cc > cs && cc < ce) /* Simple recursion */ { - dd = 0; had_recurse = TRUE; } else { - this_recurse.prev = recurses; - this_recurse.group = cs; - dd = find_minlength(re, cs, startcode, utf, &this_recurse, - countptr, backref_cache); - if (dd < 0) return dd; + recurse_check *r = recurses; + for (r = recurses; r != NULL; r = r->prev) + if (r->group == cs) break; + if (r != NULL) /* Mutual recursion */ + { + had_recurse = TRUE; + } + else + { + this_recurse.prev = recurses; /* No recursion */ + this_recurse.group = cs; + dd = find_minlength(re, cs, startcode, utf, &this_recurse, + countptr, backref_cache); + if (dd < 0) return dd; + } } } @@ -521,48 +539,51 @@ for (;;) cc += 1 + 2*IMM2_SIZE; goto REPEAT_BACK_REFERENCE; - /* Single back reference. We cannot find a length for this if duplicate - numbers are present in the pattern. */ + /* Single back reference by number. References by name are converted to by + number when there is no duplication. */ case OP_REF: case OP_REFI: - if (dupcapused) return -1; recno = GET2(cc, 1); if (recno <= backref_cache[0] && backref_cache[recno] >= 0) d = backref_cache[recno]; else { int i; + d = 0; + if ((re->overall_options & PCRE2_MATCH_UNSET_BACKREF) == 0) { ce = cs = (PCRE2_UCHAR *)PRIV(find_bracket)(startcode, utf, recno); if (cs == NULL) return -2; do ce += GET(ce, 1); while (*ce == OP_ALT); - if (cc > cs && cc < ce) /* Simple recursion */ - { - d = 0; - had_recurse = TRUE; - } - else + + if (!dupcapused || + (PCRE2_UCHAR *)PRIV(find_bracket)(ce, utf, recno) == NULL) { - recurse_check *r = recurses; - for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break; - if (r != NULL) /* Mutual recursion */ + if (cc > cs && cc < ce) /* Simple recursion */ { - d = 0; had_recurse = TRUE; } else { - this_recurse.prev = recurses; - this_recurse.group = cs; - d = find_minlength(re, cs, startcode, utf, &this_recurse, countptr, - backref_cache); - if (d < 0) return d; + recurse_check *r = recurses; + for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break; + if (r != NULL) /* Mutual recursion */ + { + had_recurse = TRUE; + } + else /* No recursion */ + { + this_recurse.prev = recurses; + this_recurse.group = cs; + d = find_minlength(re, cs, startcode, utf, &this_recurse, countptr, + backref_cache); + if (d < 0) return d; + } } } } - else d = 0; backref_cache[recno] = d; for (i = backref_cache[0] + 1; i < recno; i++) backref_cache[i] = -1; @@ -888,7 +909,7 @@ if (table_limit != 32) for (c = 24; c < 32; c++) re->start_bitmap[c] = 0xff; /************************************************* -* Create bitmap of starting bytes * +* Create bitmap of starting code units * *************************************************/ /* This function scans a compiled unanchored expression recursively and @@ -938,6 +959,9 @@ do { int rc; uint8_t *classmap = NULL; +#ifdef SUPPORT_WIDE_CHARS + PCRE2_UCHAR xclassflags; +#endif switch(*tcode) { @@ -1078,6 +1102,7 @@ do case OP_ONCE: case OP_SCRIPT_RUN: case OP_ASSERT: + case OP_ASSERT_NA: rc = set_start_bits(re, tcode, utf); if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc; if (rc == SSB_DONE) try_next = FALSE; else @@ -1120,6 +1145,7 @@ do case OP_ASSERT_NOT: case OP_ASSERTBACK: case OP_ASSERTBACK_NOT: + case OP_ASSERTBACK_NA: do tcode += GET(tcode, 1); while (*tcode == OP_ALT); tcode += 1 + LINK_SIZE; break; @@ -1444,20 +1470,59 @@ do negative XCLASS without a map, give up. If there are no property checks, there must be wide characters on the XCLASS list, because otherwise an XCLASS would not have been created. This means that code points >= 255 - are always potential starters. */ + are potential starters. In the UTF-8 case we can scan them and set bits + for the relevant leading bytes. */ #ifdef SUPPORT_WIDE_CHARS case OP_XCLASS: - if ((tcode[1 + LINK_SIZE] & XCL_HASPROP) != 0 || - (tcode[1 + LINK_SIZE] & (XCL_MAP|XCL_NOT)) == XCL_NOT) + xclassflags = tcode[1 + LINK_SIZE]; + if ((xclassflags & XCL_HASPROP) != 0 || + (xclassflags & (XCL_MAP|XCL_NOT)) == XCL_NOT) return SSB_FAIL; /* We have a positive XCLASS or a negative one without a map. Set up the map pointer if there is one, and fall through. */ - classmap = ((tcode[1 + LINK_SIZE] & XCL_MAP) == 0)? NULL : + classmap = ((xclassflags & XCL_MAP) == 0)? NULL : (uint8_t *)(tcode + 1 + LINK_SIZE + 1); -#endif + + /* In UTF-8 mode, scan the character list and set bits for leading bytes, + then jump to handle the map. */ + +#if PCRE2_CODE_UNIT_WIDTH == 8 + if (utf && (xclassflags & XCL_NOT) == 0) + { + PCRE2_UCHAR b, e; + PCRE2_SPTR p = tcode + 1 + LINK_SIZE + 1 + ((classmap == NULL)? 0:32); + tcode += GET(tcode, 1); + + for (;;) switch (*p++) + { + case XCL_SINGLE: + b = *p++; + while ((*p & 0xc0) == 0x80) p++; + re->start_bitmap[b/8] |= (1u << (b&7)); + break; + + case XCL_RANGE: + b = *p++; + while ((*p & 0xc0) == 0x80) p++; + e = *p++; + while ((*p & 0xc0) == 0x80) p++; + for (; b <= e; b++) + re->start_bitmap[b/8] |= (1u << (b&7)); + break; + + case XCL_END: + goto HANDLE_CLASSMAP; + + default: + return SSB_UNKNOWN; /* Internal error, should not occur */ + } + } +#endif /* SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 */ +#endif /* SUPPORT_WIDE_CHARS */ + /* It seems that the fall through comment must be outside the #ifdef if it is to avoid the gcc compiler warning. */ @@ -1499,6 +1564,9 @@ do greater than 127. In fact, there are only two possible starting bytes for characters in the range 128 - 255. */ +#if defined SUPPORT_WIDE_CHARS && PCRE2_CODE_UNIT_WIDTH == 8 + HANDLE_CLASSMAP: +#endif if (classmap != NULL) { #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 @@ -1569,7 +1637,9 @@ return yield; /* This function is handed a compiled expression that it must study to produce information that will speed up the matching. -Argument: points to the compiled expression +Argument: + re points to the compiled expression + Returns: 0 normally; non-zero should never normally occur 1 unknown opcode in set_start_bits 2 missing capturing bracket @@ -1579,7 +1649,6 @@ Returns: 0 normally; non-zero should never normally occur int PRIV(study)(pcre2_real_code *re) { -int min; int count = 0; PCRE2_UCHAR *code; BOOL utf = (re->overall_options & PCRE2_UTF) != 0; @@ -1597,25 +1666,121 @@ if ((re->flags & (PCRE2_FIRSTSET|PCRE2_STARTLINE)) == 0) { int rc = set_start_bits(re, code, utf); if (rc == SSB_UNKNOWN) return 1; - if (rc == SSB_DONE) re->flags |= PCRE2_FIRSTMAPSET; + + /* If a list of starting code units was set up, scan the list to see if only + one or two were listed. Having only one listed is rare because usually a + single starting code unit will have been recognized and PCRE2_FIRSTSET set. + If two are listed, see if they are caseless versions of the same character; + if so we can replace the list with a caseless first code unit. This gives + better performance and is plausibly worth doing for patterns such as [Ww]ord + or (word|WORD). */ + + if (rc == SSB_DONE) + { + int i; + int a = -1; + int b = -1; + uint8_t *p = re->start_bitmap; + uint32_t flags = PCRE2_FIRSTMAPSET; + + for (i = 0; i < 256; p++, i += 8) + { + uint8_t x = *p; + if (x != 0) + { + int c; + uint8_t y = x & (~x + 1); /* Least significant bit */ + if (y != x) goto DONE; /* More than one bit set */ + + /* In the 16-bit and 32-bit libraries, the bit for 0xff means "0xff and + all wide characters", so we cannot use it here. */ + +#if PCRE2_CODE_UNIT_WIDTH != 8 + if (i == 248 && x == 0x80) goto DONE; +#endif + + /* Compute the character value */ + + c = i; + switch (x) + { + case 1: break; + case 2: c += 1; break; case 4: c += 2; break; + case 8: c += 3; break; case 16: c += 4; break; + case 32: c += 5; break; case 64: c += 6; break; + case 128: c += 7; break; + } + + /* c contains the code unit value, in the range 0-255. In 8-bit UTF + mode, only values < 128 can be used. */ + +#if PCRE2_CODE_UNIT_WIDTH == 8 + if (c > 127) goto DONE; +#endif + if (a < 0) a = c; /* First one found */ + else if (b < 0) /* Second one found */ + { + int d = TABLE_GET((unsigned int)c, re->tables + fcc_offset, c); + +#ifdef SUPPORT_UNICODE +#if PCRE2_CODE_UNIT_WIDTH == 8 + if (utf && UCD_CASESET(c) != 0) goto DONE; /* Multiple case set */ +#else /* 16-bit or 32-bit */ + if (UCD_CASESET(c) != 0) goto DONE; /* Multiple case set */ + if (utf && c > 127) d = UCD_OTHERCASE(c); +#endif /* Code width */ +#endif /* SUPPORT_UNICODE */ + + if (d != a) goto DONE; /* Not other case of a */ + b = c; + } + else goto DONE; /* More than two characters found */ + } + } + + /* Replace the start code unit bits with a first code unit, but only if it + is not the same as a required later code unit. This is because a search for + a required code unit starts after an explicit first code unit, but at a + code unit found from the bitmap. Patterns such as /a*a/ don't work + if both the start unit and required unit are the same. */ + + if (a >= 0 && + ( + (re->flags & PCRE2_LASTSET) == 0 || + ( + re->last_codeunit != (uint32_t)a && + (b < 0 || re->last_codeunit != (uint32_t)b) + ) + )) + { + re->first_codeunit = a; + flags = PCRE2_FIRSTSET; + if (b >= 0) flags |= PCRE2_FIRSTCASELESS; + } + + DONE: + re->flags |= flags; + } } /* Find the minimum length of subject string. If the pattern can match an empty -string, the minimum length is already known. If there are more back references -than the size of the vector we are going to cache them in, do nothing. A -pattern that complicated will probably take a long time to analyze and may in -any case turn out to be too complicated. Note that back reference minima are -held as 16-bit numbers. */ - -if ((re->flags & PCRE2_MATCH_EMPTY) == 0 && +string, the minimum length is already known. If the pattern contains (*ACCEPT) +all bets are off, and we don't even try to find a minimum length. If there are +more back references than the size of the vector we are going to cache them in, +do nothing. A pattern that complicated will probably take a long time to +analyze and may in any case turn out to be too complicated. Note that back +reference minima are held as 16-bit numbers. */ + +if ((re->flags & (PCRE2_MATCH_EMPTY|PCRE2_HASACCEPT)) == 0 && re->top_backref <= MAX_CACHE_BACKREF) { + int min; int backref_cache[MAX_CACHE_BACKREF+1]; backref_cache[0] = 0; /* Highest one that is set */ min = find_minlength(re, code, code, utf, NULL, &count, backref_cache); switch(min) { - case -1: /* \C in UTF mode or (*ACCEPT) or over-complex regex */ + case -1: /* \C in UTF mode or over-complex regex */ break; /* Leave minlength unchanged (will be zero) */ case -2: @@ -1625,8 +1790,7 @@ if ((re->flags & PCRE2_MATCH_EMPTY) == 0 && return 3; /* unrecognized opcode */ default: - if (min > UINT16_MAX) min = UINT16_MAX; - re->minlength = min; + re->minlength = (min > UINT16_MAX)? UINT16_MAX : min; break; } } diff --git a/src/3rdparty/pcre2/src/pcre2_tables.c b/src/3rdparty/pcre2/src/pcre2_tables.c index 84019361fc..25531d98c6 100644 --- a/src/3rdparty/pcre2/src/pcre2_tables.c +++ b/src/3rdparty/pcre2/src/pcre2_tables.c @@ -279,6 +279,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Duployan0 STR_D STR_u STR_p STR_l STR_o STR_y STR_a STR_n "\0" #define STRING_Egyptian_Hieroglyphs0 STR_E STR_g STR_y STR_p STR_t STR_i STR_a STR_n STR_UNDERSCORE STR_H STR_i STR_e STR_r STR_o STR_g STR_l STR_y STR_p STR_h STR_s "\0" #define STRING_Elbasan0 STR_E STR_l STR_b STR_a STR_s STR_a STR_n "\0" +#define STRING_Elymaic0 STR_E STR_l STR_y STR_m STR_a STR_i STR_c "\0" #define STRING_Ethiopic0 STR_E STR_t STR_h STR_i STR_o STR_p STR_i STR_c "\0" #define STRING_Georgian0 STR_G STR_e STR_o STR_r STR_g STR_i STR_a STR_n "\0" #define STRING_Glagolitic0 STR_G STR_l STR_a STR_g STR_o STR_l STR_i STR_t STR_i STR_c "\0" @@ -348,6 +349,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Myanmar0 STR_M STR_y STR_a STR_n STR_m STR_a STR_r "\0" #define STRING_N0 STR_N "\0" #define STRING_Nabataean0 STR_N STR_a STR_b STR_a STR_t STR_a STR_e STR_a STR_n "\0" +#define STRING_Nandinagari0 STR_N STR_a STR_n STR_d STR_i STR_n STR_a STR_g STR_a STR_r STR_i "\0" #define STRING_Nd0 STR_N STR_d "\0" #define STRING_New_Tai_Lue0 STR_N STR_e STR_w STR_UNDERSCORE STR_T STR_a STR_i STR_UNDERSCORE STR_L STR_u STR_e "\0" #define STRING_Newa0 STR_N STR_e STR_w STR_a "\0" @@ -355,6 +357,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Nl0 STR_N STR_l "\0" #define STRING_No0 STR_N STR_o "\0" #define STRING_Nushu0 STR_N STR_u STR_s STR_h STR_u "\0" +#define STRING_Nyiakeng_Puachue_Hmong0 STR_N STR_y STR_i STR_a STR_k STR_e STR_n STR_g STR_UNDERSCORE STR_P STR_u STR_a STR_c STR_h STR_u STR_e STR_UNDERSCORE STR_H STR_m STR_o STR_n STR_g "\0" #define STRING_Ogham0 STR_O STR_g STR_h STR_a STR_m "\0" #define STRING_Ol_Chiki0 STR_O STR_l STR_UNDERSCORE STR_C STR_h STR_i STR_k STR_i "\0" #define STRING_Old_Hungarian0 STR_O STR_l STR_d STR_UNDERSCORE STR_H STR_u STR_n STR_g STR_a STR_r STR_i STR_a STR_n "\0" @@ -419,6 +422,7 @@ strings to make sure that UTF-8 support works on EBCDIC platforms. */ #define STRING_Ugaritic0 STR_U STR_g STR_a STR_r STR_i STR_t STR_i STR_c "\0" #define STRING_Unknown0 STR_U STR_n STR_k STR_n STR_o STR_w STR_n "\0" #define STRING_Vai0 STR_V STR_a STR_i "\0" +#define STRING_Wancho0 STR_W STR_a STR_n STR_c STR_h STR_o "\0" #define STRING_Warang_Citi0 STR_W STR_a STR_r STR_a STR_n STR_g STR_UNDERSCORE STR_C STR_i STR_t STR_i "\0" #define STRING_Xan0 STR_X STR_a STR_n "\0" #define STRING_Xps0 STR_X STR_p STR_s "\0" @@ -474,6 +478,7 @@ const char PRIV(utt_names)[] = STRING_Duployan0 STRING_Egyptian_Hieroglyphs0 STRING_Elbasan0 + STRING_Elymaic0 STRING_Ethiopic0 STRING_Georgian0 STRING_Glagolitic0 @@ -543,6 +548,7 @@ const char PRIV(utt_names)[] = STRING_Myanmar0 STRING_N0 STRING_Nabataean0 + STRING_Nandinagari0 STRING_Nd0 STRING_New_Tai_Lue0 STRING_Newa0 @@ -550,6 +556,7 @@ const char PRIV(utt_names)[] = STRING_Nl0 STRING_No0 STRING_Nushu0 + STRING_Nyiakeng_Puachue_Hmong0 STRING_Ogham0 STRING_Ol_Chiki0 STRING_Old_Hungarian0 @@ -614,6 +621,7 @@ const char PRIV(utt_names)[] = STRING_Ugaritic0 STRING_Unknown0 STRING_Vai0 + STRING_Wancho0 STRING_Warang_Citi0 STRING_Xan0 STRING_Xps0 @@ -669,158 +677,162 @@ const ucp_type_table PRIV(utt)[] = { { 299, PT_SC, ucp_Duployan }, { 308, PT_SC, ucp_Egyptian_Hieroglyphs }, { 329, PT_SC, ucp_Elbasan }, - { 337, PT_SC, ucp_Ethiopic }, - { 346, PT_SC, ucp_Georgian }, - { 355, PT_SC, ucp_Glagolitic }, - { 366, PT_SC, ucp_Gothic }, - { 373, PT_SC, ucp_Grantha }, - { 381, PT_SC, ucp_Greek }, - { 387, PT_SC, ucp_Gujarati }, - { 396, PT_SC, ucp_Gunjala_Gondi }, - { 410, PT_SC, ucp_Gurmukhi }, - { 419, PT_SC, ucp_Han }, - { 423, PT_SC, ucp_Hangul }, - { 430, PT_SC, ucp_Hanifi_Rohingya }, - { 446, PT_SC, ucp_Hanunoo }, - { 454, PT_SC, ucp_Hatran }, - { 461, PT_SC, ucp_Hebrew }, - { 468, PT_SC, ucp_Hiragana }, - { 477, PT_SC, ucp_Imperial_Aramaic }, - { 494, PT_SC, ucp_Inherited }, - { 504, PT_SC, ucp_Inscriptional_Pahlavi }, - { 526, PT_SC, ucp_Inscriptional_Parthian }, - { 549, PT_SC, ucp_Javanese }, - { 558, PT_SC, ucp_Kaithi }, - { 565, PT_SC, ucp_Kannada }, - { 573, PT_SC, ucp_Katakana }, - { 582, PT_SC, ucp_Kayah_Li }, - { 591, PT_SC, ucp_Kharoshthi }, - { 602, PT_SC, ucp_Khmer }, - { 608, PT_SC, ucp_Khojki }, - { 615, PT_SC, ucp_Khudawadi }, - { 625, PT_GC, ucp_L }, - { 627, PT_LAMP, 0 }, - { 630, PT_SC, ucp_Lao }, - { 634, PT_SC, ucp_Latin }, - { 640, PT_SC, ucp_Lepcha }, - { 647, PT_SC, ucp_Limbu }, - { 653, PT_SC, ucp_Linear_A }, - { 662, PT_SC, ucp_Linear_B }, - { 671, PT_SC, ucp_Lisu }, - { 676, PT_PC, ucp_Ll }, - { 679, PT_PC, ucp_Lm }, - { 682, PT_PC, ucp_Lo }, - { 685, PT_PC, ucp_Lt }, - { 688, PT_PC, ucp_Lu }, - { 691, PT_SC, ucp_Lycian }, - { 698, PT_SC, ucp_Lydian }, - { 705, PT_GC, ucp_M }, - { 707, PT_SC, ucp_Mahajani }, - { 716, PT_SC, ucp_Makasar }, - { 724, PT_SC, ucp_Malayalam }, - { 734, PT_SC, ucp_Mandaic }, - { 742, PT_SC, ucp_Manichaean }, - { 753, PT_SC, ucp_Marchen }, - { 761, PT_SC, ucp_Masaram_Gondi }, - { 775, PT_PC, ucp_Mc }, - { 778, PT_PC, ucp_Me }, - { 781, PT_SC, ucp_Medefaidrin }, - { 793, PT_SC, ucp_Meetei_Mayek }, - { 806, PT_SC, ucp_Mende_Kikakui }, - { 820, PT_SC, ucp_Meroitic_Cursive }, - { 837, PT_SC, ucp_Meroitic_Hieroglyphs }, - { 858, PT_SC, ucp_Miao }, - { 863, PT_PC, ucp_Mn }, - { 866, PT_SC, ucp_Modi }, - { 871, PT_SC, ucp_Mongolian }, - { 881, PT_SC, ucp_Mro }, - { 885, PT_SC, ucp_Multani }, - { 893, PT_SC, ucp_Myanmar }, - { 901, PT_GC, ucp_N }, - { 903, PT_SC, ucp_Nabataean }, - { 913, PT_PC, ucp_Nd }, - { 916, PT_SC, ucp_New_Tai_Lue }, - { 928, PT_SC, ucp_Newa }, - { 933, PT_SC, ucp_Nko }, - { 937, PT_PC, ucp_Nl }, - { 940, PT_PC, ucp_No }, - { 943, PT_SC, ucp_Nushu }, - { 949, PT_SC, ucp_Ogham }, - { 955, PT_SC, ucp_Ol_Chiki }, - { 964, PT_SC, ucp_Old_Hungarian }, - { 978, PT_SC, ucp_Old_Italic }, - { 989, PT_SC, ucp_Old_North_Arabian }, - { 1007, PT_SC, ucp_Old_Permic }, - { 1018, PT_SC, ucp_Old_Persian }, - { 1030, PT_SC, ucp_Old_Sogdian }, - { 1042, PT_SC, ucp_Old_South_Arabian }, - { 1060, PT_SC, ucp_Old_Turkic }, - { 1071, PT_SC, ucp_Oriya }, - { 1077, PT_SC, ucp_Osage }, - { 1083, PT_SC, ucp_Osmanya }, - { 1091, PT_GC, ucp_P }, - { 1093, PT_SC, ucp_Pahawh_Hmong }, - { 1106, PT_SC, ucp_Palmyrene }, - { 1116, PT_SC, ucp_Pau_Cin_Hau }, - { 1128, PT_PC, ucp_Pc }, - { 1131, PT_PC, ucp_Pd }, - { 1134, PT_PC, ucp_Pe }, - { 1137, PT_PC, ucp_Pf }, - { 1140, PT_SC, ucp_Phags_Pa }, - { 1149, PT_SC, ucp_Phoenician }, - { 1160, PT_PC, ucp_Pi }, - { 1163, PT_PC, ucp_Po }, - { 1166, PT_PC, ucp_Ps }, - { 1169, PT_SC, ucp_Psalter_Pahlavi }, - { 1185, PT_SC, ucp_Rejang }, - { 1192, PT_SC, ucp_Runic }, - { 1198, PT_GC, ucp_S }, - { 1200, PT_SC, ucp_Samaritan }, - { 1210, PT_SC, ucp_Saurashtra }, - { 1221, PT_PC, ucp_Sc }, - { 1224, PT_SC, ucp_Sharada }, - { 1232, PT_SC, ucp_Shavian }, - { 1240, PT_SC, ucp_Siddham }, - { 1248, PT_SC, ucp_SignWriting }, - { 1260, PT_SC, ucp_Sinhala }, - { 1268, PT_PC, ucp_Sk }, - { 1271, PT_PC, ucp_Sm }, - { 1274, PT_PC, ucp_So }, - { 1277, PT_SC, ucp_Sogdian }, - { 1285, PT_SC, ucp_Sora_Sompeng }, - { 1298, PT_SC, ucp_Soyombo }, - { 1306, PT_SC, ucp_Sundanese }, - { 1316, PT_SC, ucp_Syloti_Nagri }, - { 1329, PT_SC, ucp_Syriac }, - { 1336, PT_SC, ucp_Tagalog }, - { 1344, PT_SC, ucp_Tagbanwa }, - { 1353, PT_SC, ucp_Tai_Le }, - { 1360, PT_SC, ucp_Tai_Tham }, - { 1369, PT_SC, ucp_Tai_Viet }, - { 1378, PT_SC, ucp_Takri }, - { 1384, PT_SC, ucp_Tamil }, - { 1390, PT_SC, ucp_Tangut }, - { 1397, PT_SC, ucp_Telugu }, - { 1404, PT_SC, ucp_Thaana }, - { 1411, PT_SC, ucp_Thai }, - { 1416, PT_SC, ucp_Tibetan }, - { 1424, PT_SC, ucp_Tifinagh }, - { 1433, PT_SC, ucp_Tirhuta }, - { 1441, PT_SC, ucp_Ugaritic }, - { 1450, PT_SC, ucp_Unknown }, - { 1458, PT_SC, ucp_Vai }, - { 1462, PT_SC, ucp_Warang_Citi }, - { 1474, PT_ALNUM, 0 }, - { 1478, PT_PXSPACE, 0 }, - { 1482, PT_SPACE, 0 }, - { 1486, PT_UCNC, 0 }, - { 1490, PT_WORD, 0 }, - { 1494, PT_SC, ucp_Yi }, - { 1497, PT_GC, ucp_Z }, - { 1499, PT_SC, ucp_Zanabazar_Square }, - { 1516, PT_PC, ucp_Zl }, - { 1519, PT_PC, ucp_Zp }, - { 1522, PT_PC, ucp_Zs } + { 337, PT_SC, ucp_Elymaic }, + { 345, PT_SC, ucp_Ethiopic }, + { 354, PT_SC, ucp_Georgian }, + { 363, PT_SC, ucp_Glagolitic }, + { 374, PT_SC, ucp_Gothic }, + { 381, PT_SC, ucp_Grantha }, + { 389, PT_SC, ucp_Greek }, + { 395, PT_SC, ucp_Gujarati }, + { 404, PT_SC, ucp_Gunjala_Gondi }, + { 418, PT_SC, ucp_Gurmukhi }, + { 427, PT_SC, ucp_Han }, + { 431, PT_SC, ucp_Hangul }, + { 438, PT_SC, ucp_Hanifi_Rohingya }, + { 454, PT_SC, ucp_Hanunoo }, + { 462, PT_SC, ucp_Hatran }, + { 469, PT_SC, ucp_Hebrew }, + { 476, PT_SC, ucp_Hiragana }, + { 485, PT_SC, ucp_Imperial_Aramaic }, + { 502, PT_SC, ucp_Inherited }, + { 512, PT_SC, ucp_Inscriptional_Pahlavi }, + { 534, PT_SC, ucp_Inscriptional_Parthian }, + { 557, PT_SC, ucp_Javanese }, + { 566, PT_SC, ucp_Kaithi }, + { 573, PT_SC, ucp_Kannada }, + { 581, PT_SC, ucp_Katakana }, + { 590, PT_SC, ucp_Kayah_Li }, + { 599, PT_SC, ucp_Kharoshthi }, + { 610, PT_SC, ucp_Khmer }, + { 616, PT_SC, ucp_Khojki }, + { 623, PT_SC, ucp_Khudawadi }, + { 633, PT_GC, ucp_L }, + { 635, PT_LAMP, 0 }, + { 638, PT_SC, ucp_Lao }, + { 642, PT_SC, ucp_Latin }, + { 648, PT_SC, ucp_Lepcha }, + { 655, PT_SC, ucp_Limbu }, + { 661, PT_SC, ucp_Linear_A }, + { 670, PT_SC, ucp_Linear_B }, + { 679, PT_SC, ucp_Lisu }, + { 684, PT_PC, ucp_Ll }, + { 687, PT_PC, ucp_Lm }, + { 690, PT_PC, ucp_Lo }, + { 693, PT_PC, ucp_Lt }, + { 696, PT_PC, ucp_Lu }, + { 699, PT_SC, ucp_Lycian }, + { 706, PT_SC, ucp_Lydian }, + { 713, PT_GC, ucp_M }, + { 715, PT_SC, ucp_Mahajani }, + { 724, PT_SC, ucp_Makasar }, + { 732, PT_SC, ucp_Malayalam }, + { 742, PT_SC, ucp_Mandaic }, + { 750, PT_SC, ucp_Manichaean }, + { 761, PT_SC, ucp_Marchen }, + { 769, PT_SC, ucp_Masaram_Gondi }, + { 783, PT_PC, ucp_Mc }, + { 786, PT_PC, ucp_Me }, + { 789, PT_SC, ucp_Medefaidrin }, + { 801, PT_SC, ucp_Meetei_Mayek }, + { 814, PT_SC, ucp_Mende_Kikakui }, + { 828, PT_SC, ucp_Meroitic_Cursive }, + { 845, PT_SC, ucp_Meroitic_Hieroglyphs }, + { 866, PT_SC, ucp_Miao }, + { 871, PT_PC, ucp_Mn }, + { 874, PT_SC, ucp_Modi }, + { 879, PT_SC, ucp_Mongolian }, + { 889, PT_SC, ucp_Mro }, + { 893, PT_SC, ucp_Multani }, + { 901, PT_SC, ucp_Myanmar }, + { 909, PT_GC, ucp_N }, + { 911, PT_SC, ucp_Nabataean }, + { 921, PT_SC, ucp_Nandinagari }, + { 933, PT_PC, ucp_Nd }, + { 936, PT_SC, ucp_New_Tai_Lue }, + { 948, PT_SC, ucp_Newa }, + { 953, PT_SC, ucp_Nko }, + { 957, PT_PC, ucp_Nl }, + { 960, PT_PC, ucp_No }, + { 963, PT_SC, ucp_Nushu }, + { 969, PT_SC, ucp_Nyiakeng_Puachue_Hmong }, + { 992, PT_SC, ucp_Ogham }, + { 998, PT_SC, ucp_Ol_Chiki }, + { 1007, PT_SC, ucp_Old_Hungarian }, + { 1021, PT_SC, ucp_Old_Italic }, + { 1032, PT_SC, ucp_Old_North_Arabian }, + { 1050, PT_SC, ucp_Old_Permic }, + { 1061, PT_SC, ucp_Old_Persian }, + { 1073, PT_SC, ucp_Old_Sogdian }, + { 1085, PT_SC, ucp_Old_South_Arabian }, + { 1103, PT_SC, ucp_Old_Turkic }, + { 1114, PT_SC, ucp_Oriya }, + { 1120, PT_SC, ucp_Osage }, + { 1126, PT_SC, ucp_Osmanya }, + { 1134, PT_GC, ucp_P }, + { 1136, PT_SC, ucp_Pahawh_Hmong }, + { 1149, PT_SC, ucp_Palmyrene }, + { 1159, PT_SC, ucp_Pau_Cin_Hau }, + { 1171, PT_PC, ucp_Pc }, + { 1174, PT_PC, ucp_Pd }, + { 1177, PT_PC, ucp_Pe }, + { 1180, PT_PC, ucp_Pf }, + { 1183, PT_SC, ucp_Phags_Pa }, + { 1192, PT_SC, ucp_Phoenician }, + { 1203, PT_PC, ucp_Pi }, + { 1206, PT_PC, ucp_Po }, + { 1209, PT_PC, ucp_Ps }, + { 1212, PT_SC, ucp_Psalter_Pahlavi }, + { 1228, PT_SC, ucp_Rejang }, + { 1235, PT_SC, ucp_Runic }, + { 1241, PT_GC, ucp_S }, + { 1243, PT_SC, ucp_Samaritan }, + { 1253, PT_SC, ucp_Saurashtra }, + { 1264, PT_PC, ucp_Sc }, + { 1267, PT_SC, ucp_Sharada }, + { 1275, PT_SC, ucp_Shavian }, + { 1283, PT_SC, ucp_Siddham }, + { 1291, PT_SC, ucp_SignWriting }, + { 1303, PT_SC, ucp_Sinhala }, + { 1311, PT_PC, ucp_Sk }, + { 1314, PT_PC, ucp_Sm }, + { 1317, PT_PC, ucp_So }, + { 1320, PT_SC, ucp_Sogdian }, + { 1328, PT_SC, ucp_Sora_Sompeng }, + { 1341, PT_SC, ucp_Soyombo }, + { 1349, PT_SC, ucp_Sundanese }, + { 1359, PT_SC, ucp_Syloti_Nagri }, + { 1372, PT_SC, ucp_Syriac }, + { 1379, PT_SC, ucp_Tagalog }, + { 1387, PT_SC, ucp_Tagbanwa }, + { 1396, PT_SC, ucp_Tai_Le }, + { 1403, PT_SC, ucp_Tai_Tham }, + { 1412, PT_SC, ucp_Tai_Viet }, + { 1421, PT_SC, ucp_Takri }, + { 1427, PT_SC, ucp_Tamil }, + { 1433, PT_SC, ucp_Tangut }, + { 1440, PT_SC, ucp_Telugu }, + { 1447, PT_SC, ucp_Thaana }, + { 1454, PT_SC, ucp_Thai }, + { 1459, PT_SC, ucp_Tibetan }, + { 1467, PT_SC, ucp_Tifinagh }, + { 1476, PT_SC, ucp_Tirhuta }, + { 1484, PT_SC, ucp_Ugaritic }, + { 1493, PT_SC, ucp_Unknown }, + { 1501, PT_SC, ucp_Vai }, + { 1505, PT_SC, ucp_Wancho }, + { 1512, PT_SC, ucp_Warang_Citi }, + { 1524, PT_ALNUM, 0 }, + { 1528, PT_PXSPACE, 0 }, + { 1532, PT_SPACE, 0 }, + { 1536, PT_UCNC, 0 }, + { 1540, PT_WORD, 0 }, + { 1544, PT_SC, ucp_Yi }, + { 1547, PT_GC, ucp_Z }, + { 1549, PT_SC, ucp_Zanabazar_Square }, + { 1566, PT_PC, ucp_Zl }, + { 1569, PT_PC, ucp_Zp }, + { 1572, PT_PC, ucp_Zs } }; const size_t PRIV(utt_size) = sizeof(PRIV(utt)) / sizeof(ucp_type_table); diff --git a/src/3rdparty/pcre2/src/pcre2_ucd.c b/src/3rdparty/pcre2/src/pcre2_ucd.c index cc53c24001..55ba03bd43 100644 --- a/src/3rdparty/pcre2/src/pcre2_ucd.c +++ b/src/3rdparty/pcre2/src/pcre2_ucd.c @@ -20,7 +20,7 @@ needed. */ /* Unicode character database. */ /* This file was autogenerated by the MultiStage2.py script. */ -/* Total size: 97152 bytes, block size: 128. */ +/* Total size: 99316 bytes, block size: 128. */ /* The tables herein are needed only when UCP support is built, and in PCRE2 that happens automatically with UTF support. @@ -39,7 +39,7 @@ const uint16_t PRIV(ucd_stage2)[] = {0}; const uint32_t PRIV(ucd_caseless_sets)[] = {0}; #else -const char *PRIV(unicode_version) = "11.0.0"; +const char *PRIV(unicode_version) = "12.1.0"; /* If the 32-bit library is run in non-32-bit mode, character values greater than 0x10ffff may be encountered. For these we set up a @@ -116,7 +116,7 @@ set of decimal digits. It is used to ensure that all the digits in a script run come from the same set. */ const uint32_t PRIV(ucd_digit_sets)[] = { - 61, /* Number of subsequent values */ + 63, /* Number of subsequent values */ 0x00039, 0x00669, 0x006f9, 0x007c9, 0x0096f, 0x009ef, 0x00a6f, 0x00aef, 0x00b6f, 0x00bef, 0x00c6f, 0x00cef, 0x00d6f, 0x00def, 0x00e59, 0x00ed9, 0x00f29, 0x01049, 0x01099, 0x017e9, 0x01819, 0x0194f, 0x019d9, 0x01a89, @@ -124,7 +124,7 @@ const uint32_t PRIV(ucd_digit_sets)[] = { 0x0a9d9, 0x0a9f9, 0x0aa59, 0x0abf9, 0x0ff19, 0x104a9, 0x10d39, 0x1106f, 0x110f9, 0x1113f, 0x111d9, 0x112f9, 0x11459, 0x114d9, 0x11659, 0x116c9, 0x11739, 0x118e9, 0x11c59, 0x11d59, 0x11da9, 0x16a69, 0x16b59, 0x1d7d7, - 0x1d7e1, 0x1d7eb, 0x1d7f5, 0x1d7ff, 0x1e959, + 0x1d7e1, 0x1d7eb, 0x1d7f5, 0x1d7ff, 0x1e149, 0x1e2f9, 0x1e959, }; /* This vector is a list of lists of scripts for the Script Extension @@ -145,38 +145,42 @@ const uint8_t PRIV(ucd_script_sets)[] = { /* 31 */ 13, 34, 0, /* 34 */ 13, 118, 0, /* 37 */ 15, 107, 0, - /* 40 */ 15, 100, 0, - /* 43 */ 15, 54, 0, - /* 46 */ 17, 34, 0, - /* 49 */ 107, 54, 0, - /* 52 */ 21, 108, 0, - /* 55 */ 22, 129, 0, - /* 58 */ 27, 30, 0, - /* 61 */ 38, 65, 0, - /* 64 */ 1, 50, 56, 0, - /* 68 */ 3, 96, 49, 0, - /* 72 */ 96, 39, 53, 0, - /* 76 */ 12, 110, 36, 0, - /* 80 */ 15, 107, 29, 0, - /* 84 */ 15, 107, 34, 0, - /* 88 */ 23, 27, 30, 0, - /* 92 */ 69, 34, 39, 0, - /* 96 */ 1, 144, 50, 56, 0, - /* 101 */ 3, 15, 107, 29, 0, - /* 106 */ 7, 25, 52, 51, 0, - /* 111 */ 15, 142, 85, 111, 0, - /* 116 */ 4, 24, 23, 27, 30, 0, - /* 122 */ 4, 24, 23, 27, 30, 61, 0, - /* 129 */ 15, 29, 37, 44, 54, 55, 0, - /* 136 */ 132, 1, 95, 112, 121, 144, 148, 50, 0, - /* 145 */ 15, 142, 21, 22, 108, 85, 111, 114, 109, 102, 124, 0, - /* 157 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 54, 55, 124, 0, - /* 170 */ 15, 142, 21, 22, 108, 29, 85, 111, 114, 109, 102, 124, 0, - /* 183 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 100, 54, 55, 124, 0, - /* 197 */ 15, 142, 21, 22, 108, 29, 85, 111, 37, 114, 109, 102, 124, 0, - /* 211 */ 3, 15, 142, 143, 107, 21, 22, 29, 111, 37, 44, 109, 48, 49, 102, 54, 55, 124, 0, - /* 230 */ 3, 15, 142, 143, 107, 21, 22, 29, 35, 111, 37, 44, 109, 48, 49, 102, 54, 55, 124, 0, - /* 250 */ + /* 40 */ 15, 150, 0, + /* 43 */ 15, 100, 0, + /* 46 */ 15, 54, 0, + /* 49 */ 17, 34, 0, + /* 52 */ 107, 54, 0, + /* 55 */ 21, 108, 0, + /* 58 */ 22, 129, 0, + /* 61 */ 27, 30, 0, + /* 64 */ 29, 150, 0, + /* 67 */ 34, 38, 0, + /* 70 */ 38, 65, 0, + /* 73 */ 1, 50, 56, 0, + /* 77 */ 3, 96, 49, 0, + /* 81 */ 96, 39, 53, 0, + /* 85 */ 12, 110, 36, 0, + /* 89 */ 15, 107, 29, 0, + /* 93 */ 15, 107, 34, 0, + /* 97 */ 23, 27, 30, 0, + /* 101 */ 69, 34, 39, 0, + /* 105 */ 1, 144, 50, 56, 0, + /* 110 */ 3, 15, 107, 29, 0, + /* 115 */ 7, 25, 52, 51, 0, + /* 120 */ 15, 142, 85, 111, 0, + /* 125 */ 4, 24, 23, 27, 30, 0, + /* 131 */ 4, 24, 23, 27, 30, 61, 0, + /* 138 */ 15, 29, 37, 44, 54, 55, 0, + /* 145 */ 132, 1, 95, 112, 121, 144, 148, 50, 0, + /* 154 */ 3, 15, 107, 29, 150, 44, 55, 124, 0, + /* 163 */ 15, 142, 21, 22, 108, 85, 111, 114, 109, 102, 124, 0, + /* 175 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 54, 55, 124, 0, + /* 188 */ 3, 15, 107, 21, 22, 29, 34, 37, 44, 100, 54, 55, 124, 0, + /* 202 */ 15, 142, 21, 22, 108, 29, 85, 111, 114, 150, 109, 102, 124, 0, + /* 216 */ 15, 142, 21, 22, 108, 29, 85, 111, 37, 114, 150, 109, 102, 124, 0, + /* 231 */ 3, 15, 142, 143, 138, 107, 21, 22, 29, 111, 37, 150, 44, 109, 48, 49, 102, 54, 55, 124, 0, + /* 252 */ 3, 15, 142, 143, 138, 107, 21, 22, 29, 35, 111, 37, 150, 44, 109, 48, 49, 102, 54, 55, 124, 0, + /* 274 */ }; /* These are the main two-stage UCD tables. The fields in each record are: @@ -185,7 +189,7 @@ offset to multichar other cases or zero (8 bits), offset to other case or zero (32 bits, signed), script extension (16 bits, signed), and a dummy 16-bit field to make the whole thing a multiple of 4 bytes. */ -const ucd_record PRIV(ucd_records)[] = { /* 11136 bytes, record size 12 */ +const ucd_record PRIV(ucd_records)[] = { /* 11508 bytes, record size 12 */ { 10, 0, 2, 0, 0, 10, 256, }, /* 0 */ { 10, 0, 2, 0, 0, 10, 0, }, /* 1 */ { 10, 0, 1, 0, 0, 10, 0, }, /* 2 */ @@ -288,832 +292,863 @@ const ucd_record PRIV(ucd_records)[] = { /* 11136 bytes, record size 12 */ { 34, 5, 12, 0, -214, 34, 0, }, /* 99 */ { 34, 5, 12, 0, 10727, 34, 0, }, /* 100 */ { 34, 5, 12, 0, -218, 34, 0, }, /* 101 */ - { 34, 5, 12, 0, 42282, 34, 0, }, /* 102 */ - { 34, 5, 12, 0, -69, 34, 0, }, /* 103 */ - { 34, 5, 12, 0, -217, 34, 0, }, /* 104 */ - { 34, 5, 12, 0, -71, 34, 0, }, /* 105 */ - { 34, 5, 12, 0, -219, 34, 0, }, /* 106 */ - { 34, 5, 12, 0, 42261, 34, 0, }, /* 107 */ - { 34, 5, 12, 0, 42258, 34, 0, }, /* 108 */ - { 34, 6, 12, 0, 0, 34, 0, }, /* 109 */ - { 10, 6, 12, 0, 0, 10, 0, }, /* 110 */ - { 4, 24, 12, 0, 0, 4, 0, }, /* 111 */ - { 28, 12, 3, 0, 0, 28, 0, }, /* 112 */ - { 28, 12, 3, 0, 0, 20, 0, }, /* 113 */ - { 28, 12, 3, 21, 116, 20, 0, }, /* 114 */ - { 28, 12, 3, 0, 0, 34, 0, }, /* 115 */ - { 20, 9, 12, 0, 1, 20, 0, }, /* 116 */ - { 20, 5, 12, 0, -1, 20, 0, }, /* 117 */ - { 20, 24, 12, 0, 0, 20, 0, }, /* 118 */ - { 0, 2, 12, 0, 0, 0, 0, }, /* 119 */ - { 20, 6, 12, 0, 0, 20, 0, }, /* 120 */ - { 20, 5, 12, 0, 130, 20, 0, }, /* 121 */ - { 20, 9, 12, 0, 116, 20, 0, }, /* 122 */ - { 20, 9, 12, 0, 38, 20, 0, }, /* 123 */ - { 20, 9, 12, 0, 37, 20, 0, }, /* 124 */ - { 20, 9, 12, 0, 64, 20, 0, }, /* 125 */ - { 20, 9, 12, 0, 63, 20, 0, }, /* 126 */ - { 20, 5, 12, 0, 0, 20, 0, }, /* 127 */ - { 20, 9, 12, 0, 32, 20, 0, }, /* 128 */ - { 20, 9, 12, 34, 32, 20, 0, }, /* 129 */ - { 20, 9, 12, 59, 32, 20, 0, }, /* 130 */ - { 20, 9, 12, 38, 32, 20, 0, }, /* 131 */ - { 20, 9, 12, 21, 32, 20, 0, }, /* 132 */ - { 20, 9, 12, 51, 32, 20, 0, }, /* 133 */ - { 20, 9, 12, 26, 32, 20, 0, }, /* 134 */ - { 20, 9, 12, 47, 32, 20, 0, }, /* 135 */ - { 20, 9, 12, 55, 32, 20, 0, }, /* 136 */ - { 20, 9, 12, 30, 32, 20, 0, }, /* 137 */ - { 20, 9, 12, 43, 32, 20, 0, }, /* 138 */ - { 20, 9, 12, 96, 32, 20, 0, }, /* 139 */ - { 20, 5, 12, 0, -38, 20, 0, }, /* 140 */ - { 20, 5, 12, 0, -37, 20, 0, }, /* 141 */ - { 20, 5, 12, 0, -32, 20, 0, }, /* 142 */ - { 20, 5, 12, 34, -32, 20, 0, }, /* 143 */ - { 20, 5, 12, 59, -32, 20, 0, }, /* 144 */ - { 20, 5, 12, 38, -32, 20, 0, }, /* 145 */ - { 20, 5, 12, 21, -116, 20, 0, }, /* 146 */ - { 20, 5, 12, 51, -32, 20, 0, }, /* 147 */ - { 20, 5, 12, 26, -775, 20, 0, }, /* 148 */ - { 20, 5, 12, 47, -32, 20, 0, }, /* 149 */ - { 20, 5, 12, 55, -32, 20, 0, }, /* 150 */ - { 20, 5, 12, 30, 1, 20, 0, }, /* 151 */ - { 20, 5, 12, 30, -32, 20, 0, }, /* 152 */ - { 20, 5, 12, 43, -32, 20, 0, }, /* 153 */ - { 20, 5, 12, 96, -32, 20, 0, }, /* 154 */ - { 20, 5, 12, 0, -64, 20, 0, }, /* 155 */ - { 20, 5, 12, 0, -63, 20, 0, }, /* 156 */ - { 20, 9, 12, 0, 8, 20, 0, }, /* 157 */ - { 20, 5, 12, 34, -30, 20, 0, }, /* 158 */ - { 20, 5, 12, 38, -25, 20, 0, }, /* 159 */ - { 20, 9, 12, 0, 0, 20, 0, }, /* 160 */ - { 20, 5, 12, 43, -15, 20, 0, }, /* 161 */ - { 20, 5, 12, 47, -22, 20, 0, }, /* 162 */ - { 20, 5, 12, 0, -8, 20, 0, }, /* 163 */ - { 11, 9, 12, 0, 1, 11, 0, }, /* 164 */ - { 11, 5, 12, 0, -1, 11, 0, }, /* 165 */ - { 20, 5, 12, 51, -54, 20, 0, }, /* 166 */ - { 20, 5, 12, 55, -48, 20, 0, }, /* 167 */ - { 20, 5, 12, 0, 7, 20, 0, }, /* 168 */ - { 20, 5, 12, 0, -116, 20, 0, }, /* 169 */ - { 20, 9, 12, 38, -60, 20, 0, }, /* 170 */ - { 20, 5, 12, 59, -64, 20, 0, }, /* 171 */ - { 20, 25, 12, 0, 0, 20, 0, }, /* 172 */ - { 20, 9, 12, 0, -7, 20, 0, }, /* 173 */ - { 20, 9, 12, 0, -130, 20, 0, }, /* 174 */ - { 13, 9, 12, 0, 80, 13, 0, }, /* 175 */ - { 13, 9, 12, 0, 32, 13, 0, }, /* 176 */ - { 13, 9, 12, 63, 32, 13, 0, }, /* 177 */ - { 13, 9, 12, 67, 32, 13, 0, }, /* 178 */ - { 13, 9, 12, 71, 32, 13, 0, }, /* 179 */ - { 13, 9, 12, 75, 32, 13, 0, }, /* 180 */ - { 13, 9, 12, 79, 32, 13, 0, }, /* 181 */ - { 13, 9, 12, 84, 32, 13, 0, }, /* 182 */ - { 13, 5, 12, 0, -32, 13, 0, }, /* 183 */ - { 13, 5, 12, 63, -32, 13, 0, }, /* 184 */ - { 13, 5, 12, 67, -32, 13, 0, }, /* 185 */ - { 13, 5, 12, 71, -32, 13, 0, }, /* 186 */ - { 13, 5, 12, 75, -32, 13, 0, }, /* 187 */ - { 13, 5, 12, 79, -32, 13, 0, }, /* 188 */ - { 13, 5, 12, 84, -32, 13, 0, }, /* 189 */ - { 13, 5, 12, 0, -80, 13, 0, }, /* 190 */ - { 13, 9, 12, 0, 1, 13, 0, }, /* 191 */ - { 13, 5, 12, 0, -1, 13, 0, }, /* 192 */ - { 13, 9, 12, 88, 1, 13, 0, }, /* 193 */ - { 13, 5, 12, 88, -1, 13, 0, }, /* 194 */ - { 13, 26, 12, 0, 0, 13, 0, }, /* 195 */ - { 13, 12, 3, 0, 0, -34, 0, }, /* 196 */ - { 13, 12, 3, 0, 0, -28, 0, }, /* 197 */ - { 28, 12, 3, 0, 0, -31, 0, }, /* 198 */ - { 13, 11, 3, 0, 0, 13, 0, }, /* 199 */ - { 13, 9, 12, 0, 15, 13, 0, }, /* 200 */ - { 13, 5, 12, 0, -15, 13, 0, }, /* 201 */ - { 2, 9, 12, 0, 48, 2, 0, }, /* 202 */ - { 2, 6, 12, 0, 0, 2, 0, }, /* 203 */ - { 2, 21, 12, 0, 0, 2, 0, }, /* 204 */ - { 2, 5, 12, 0, 0, 2, 0, }, /* 205 */ - { 2, 5, 12, 0, -48, 2, 0, }, /* 206 */ - { 10, 21, 12, 0, 0, -13, 0, }, /* 207 */ - { 2, 17, 12, 0, 0, 2, 0, }, /* 208 */ - { 2, 26, 12, 0, 0, 2, 0, }, /* 209 */ - { 2, 23, 12, 0, 0, 2, 0, }, /* 210 */ - { 26, 12, 3, 0, 0, 26, 0, }, /* 211 */ - { 26, 17, 12, 0, 0, 26, 0, }, /* 212 */ - { 26, 21, 12, 0, 0, 26, 0, }, /* 213 */ - { 26, 7, 12, 0, 0, 26, 0, }, /* 214 */ - { 1, 1, 4, 0, 0, 1, 0, }, /* 215 */ - { 10, 1, 4, 0, 0, 10, 0, }, /* 216 */ - { 1, 25, 12, 0, 0, 1, 0, }, /* 217 */ - { 1, 21, 12, 0, 0, 1, 0, }, /* 218 */ - { 1, 23, 12, 0, 0, 1, 0, }, /* 219 */ - { 10, 21, 12, 0, 0, -96, 0, }, /* 220 */ - { 1, 26, 12, 0, 0, 1, 0, }, /* 221 */ - { 1, 12, 3, 0, 0, 1, 0, }, /* 222 */ - { 1, 1, 2, 0, 0, -64, 0, }, /* 223 */ - { 1, 7, 12, 0, 0, 1, 0, }, /* 224 */ - { 10, 6, 12, 0, 0, -136, 0, }, /* 225 */ - { 28, 12, 3, 0, 0, -7, 0, }, /* 226 */ - { 1, 13, 12, 0, 0, -10, 0, }, /* 227 */ - { 1, 21, 12, 0, 0, -4, 0, }, /* 228 */ - { 1, 6, 12, 0, 0, 1, 0, }, /* 229 */ - { 1, 13, 12, 0, 0, 1, 0, }, /* 230 */ - { 50, 21, 12, 0, 0, 50, 0, }, /* 231 */ - { 50, 1, 4, 0, 0, 50, 0, }, /* 232 */ - { 50, 7, 12, 0, 0, 50, 0, }, /* 233 */ - { 50, 12, 3, 0, 0, 50, 0, }, /* 234 */ - { 56, 7, 12, 0, 0, 56, 0, }, /* 235 */ - { 56, 12, 3, 0, 0, 56, 0, }, /* 236 */ - { 64, 13, 12, 0, 0, 64, 0, }, /* 237 */ - { 64, 7, 12, 0, 0, 64, 0, }, /* 238 */ - { 64, 12, 3, 0, 0, 64, 0, }, /* 239 */ - { 64, 6, 12, 0, 0, 64, 0, }, /* 240 */ - { 64, 26, 12, 0, 0, 64, 0, }, /* 241 */ - { 64, 21, 12, 0, 0, 64, 0, }, /* 242 */ - { 64, 23, 12, 0, 0, 64, 0, }, /* 243 */ - { 90, 7, 12, 0, 0, 90, 0, }, /* 244 */ - { 90, 12, 3, 0, 0, 90, 0, }, /* 245 */ - { 90, 6, 12, 0, 0, 90, 0, }, /* 246 */ - { 90, 21, 12, 0, 0, 90, 0, }, /* 247 */ - { 95, 7, 12, 0, 0, 95, 0, }, /* 248 */ - { 95, 12, 3, 0, 0, 95, 0, }, /* 249 */ - { 95, 21, 12, 0, 0, 95, 0, }, /* 250 */ - { 15, 12, 3, 0, 0, 15, 0, }, /* 251 */ - { 15, 10, 5, 0, 0, 15, 0, }, /* 252 */ - { 15, 7, 12, 0, 0, 15, 0, }, /* 253 */ - { 28, 12, 3, 0, 0, -183, 0, }, /* 254 */ - { 28, 12, 3, 0, 0, -157, 0, }, /* 255 */ - { 10, 21, 12, 0, 0, -211, 0, }, /* 256 */ - { 10, 21, 12, 0, 0, -230, 0, }, /* 257 */ - { 15, 13, 12, 0, 0, -111, 0, }, /* 258 */ - { 15, 21, 12, 0, 0, 15, 0, }, /* 259 */ - { 15, 6, 12, 0, 0, 15, 0, }, /* 260 */ - { 3, 7, 12, 0, 0, 3, 0, }, /* 261 */ - { 3, 12, 3, 0, 0, 3, 0, }, /* 262 */ - { 3, 10, 5, 0, 0, 3, 0, }, /* 263 */ - { 3, 10, 3, 0, 0, 3, 0, }, /* 264 */ - { 3, 13, 12, 0, 0, -68, 0, }, /* 265 */ - { 3, 23, 12, 0, 0, 3, 0, }, /* 266 */ - { 3, 15, 12, 0, 0, 3, 0, }, /* 267 */ - { 3, 26, 12, 0, 0, 3, 0, }, /* 268 */ - { 3, 21, 12, 0, 0, 3, 0, }, /* 269 */ - { 22, 12, 3, 0, 0, 22, 0, }, /* 270 */ - { 22, 10, 5, 0, 0, 22, 0, }, /* 271 */ - { 22, 7, 12, 0, 0, 22, 0, }, /* 272 */ - { 22, 13, 12, 0, 0, -55, 0, }, /* 273 */ - { 22, 21, 12, 0, 0, 22, 0, }, /* 274 */ - { 21, 12, 3, 0, 0, 21, 0, }, /* 275 */ - { 21, 10, 5, 0, 0, 21, 0, }, /* 276 */ - { 21, 7, 12, 0, 0, 21, 0, }, /* 277 */ - { 21, 13, 12, 0, 0, -52, 0, }, /* 278 */ - { 21, 21, 12, 0, 0, 21, 0, }, /* 279 */ - { 21, 23, 12, 0, 0, 21, 0, }, /* 280 */ - { 44, 12, 3, 0, 0, 44, 0, }, /* 281 */ - { 44, 10, 5, 0, 0, 44, 0, }, /* 282 */ - { 44, 7, 12, 0, 0, 44, 0, }, /* 283 */ - { 44, 10, 3, 0, 0, 44, 0, }, /* 284 */ - { 44, 13, 12, 0, 0, 44, 0, }, /* 285 */ - { 44, 26, 12, 0, 0, 44, 0, }, /* 286 */ - { 44, 15, 12, 0, 0, 44, 0, }, /* 287 */ - { 54, 12, 3, 0, 0, 54, 0, }, /* 288 */ - { 54, 7, 12, 0, 0, 54, 0, }, /* 289 */ - { 54, 10, 3, 0, 0, 54, 0, }, /* 290 */ - { 54, 10, 5, 0, 0, 54, 0, }, /* 291 */ - { 54, 13, 12, 0, 0, -49, 0, }, /* 292 */ - { 54, 15, 12, 0, 0, -49, 0, }, /* 293 */ - { 54, 26, 12, 0, 0, -49, 0, }, /* 294 */ - { 54, 26, 12, 0, 0, 54, 0, }, /* 295 */ - { 54, 23, 12, 0, 0, 54, 0, }, /* 296 */ - { 55, 12, 3, 0, 0, 55, 0, }, /* 297 */ - { 55, 10, 5, 0, 0, 55, 0, }, /* 298 */ - { 55, 7, 12, 0, 0, 55, 0, }, /* 299 */ - { 55, 13, 12, 0, 0, 55, 0, }, /* 300 */ - { 55, 15, 12, 0, 0, 55, 0, }, /* 301 */ - { 55, 26, 12, 0, 0, 55, 0, }, /* 302 */ - { 29, 7, 12, 0, 0, 29, 0, }, /* 303 */ - { 29, 12, 3, 0, 0, 29, 0, }, /* 304 */ - { 29, 10, 5, 0, 0, 29, 0, }, /* 305 */ - { 29, 21, 12, 0, 0, 29, 0, }, /* 306 */ - { 29, 10, 3, 0, 0, 29, 0, }, /* 307 */ - { 29, 13, 12, 0, 0, 29, 0, }, /* 308 */ - { 37, 12, 3, 0, 0, 37, 0, }, /* 309 */ - { 37, 10, 5, 0, 0, 37, 0, }, /* 310 */ - { 37, 7, 12, 0, 0, 37, 0, }, /* 311 */ - { 37, 10, 3, 0, 0, 37, 0, }, /* 312 */ - { 37, 7, 4, 0, 0, 37, 0, }, /* 313 */ - { 37, 26, 12, 0, 0, 37, 0, }, /* 314 */ - { 37, 15, 12, 0, 0, 37, 0, }, /* 315 */ - { 37, 13, 12, 0, 0, 37, 0, }, /* 316 */ - { 48, 10, 5, 0, 0, 48, 0, }, /* 317 */ - { 48, 7, 12, 0, 0, 48, 0, }, /* 318 */ - { 48, 12, 3, 0, 0, 48, 0, }, /* 319 */ - { 48, 10, 3, 0, 0, 48, 0, }, /* 320 */ - { 48, 13, 12, 0, 0, 48, 0, }, /* 321 */ - { 48, 21, 12, 0, 0, 48, 0, }, /* 322 */ - { 57, 7, 12, 0, 0, 57, 0, }, /* 323 */ - { 57, 12, 3, 0, 0, 57, 0, }, /* 324 */ - { 57, 7, 5, 0, 0, 57, 0, }, /* 325 */ - { 57, 6, 12, 0, 0, 57, 0, }, /* 326 */ - { 57, 21, 12, 0, 0, 57, 0, }, /* 327 */ - { 57, 13, 12, 0, 0, 57, 0, }, /* 328 */ - { 33, 7, 12, 0, 0, 33, 0, }, /* 329 */ - { 33, 12, 3, 0, 0, 33, 0, }, /* 330 */ - { 33, 7, 5, 0, 0, 33, 0, }, /* 331 */ - { 33, 6, 12, 0, 0, 33, 0, }, /* 332 */ - { 33, 13, 12, 0, 0, 33, 0, }, /* 333 */ - { 58, 7, 12, 0, 0, 58, 0, }, /* 334 */ - { 58, 26, 12, 0, 0, 58, 0, }, /* 335 */ - { 58, 21, 12, 0, 0, 58, 0, }, /* 336 */ - { 58, 12, 3, 0, 0, 58, 0, }, /* 337 */ - { 58, 13, 12, 0, 0, 58, 0, }, /* 338 */ - { 58, 15, 12, 0, 0, 58, 0, }, /* 339 */ - { 58, 22, 12, 0, 0, 58, 0, }, /* 340 */ - { 58, 18, 12, 0, 0, 58, 0, }, /* 341 */ - { 58, 10, 5, 0, 0, 58, 0, }, /* 342 */ - { 39, 7, 12, 0, 0, 39, 0, }, /* 343 */ - { 39, 10, 12, 0, 0, 39, 0, }, /* 344 */ - { 39, 12, 3, 0, 0, 39, 0, }, /* 345 */ - { 39, 10, 5, 0, 0, 39, 0, }, /* 346 */ - { 39, 13, 12, 0, 0, -72, 0, }, /* 347 */ - { 39, 21, 12, 0, 0, 39, 0, }, /* 348 */ - { 39, 13, 12, 0, 0, 39, 0, }, /* 349 */ - { 39, 26, 12, 0, 0, 39, 0, }, /* 350 */ - { 17, 9, 12, 0, 7264, 17, 0, }, /* 351 */ - { 17, 5, 12, 0, 3008, 17, 0, }, /* 352 */ - { 10, 21, 12, 0, 0, -46, 0, }, /* 353 */ - { 17, 6, 12, 0, 0, 17, 0, }, /* 354 */ - { 24, 7, 6, 0, 0, 24, 0, }, /* 355 */ - { 24, 7, 7, 0, 0, 24, 0, }, /* 356 */ - { 24, 7, 8, 0, 0, 24, 0, }, /* 357 */ - { 16, 7, 12, 0, 0, 16, 0, }, /* 358 */ - { 16, 12, 3, 0, 0, 16, 0, }, /* 359 */ - { 16, 21, 12, 0, 0, 16, 0, }, /* 360 */ - { 16, 15, 12, 0, 0, 16, 0, }, /* 361 */ - { 16, 26, 12, 0, 0, 16, 0, }, /* 362 */ - { 9, 9, 12, 0, 38864, 9, 0, }, /* 363 */ - { 9, 9, 12, 0, 8, 9, 0, }, /* 364 */ - { 9, 5, 12, 0, -8, 9, 0, }, /* 365 */ - { 8, 17, 12, 0, 0, 8, 0, }, /* 366 */ - { 8, 7, 12, 0, 0, 8, 0, }, /* 367 */ - { 8, 21, 12, 0, 0, 8, 0, }, /* 368 */ - { 41, 29, 12, 0, 0, 41, 0, }, /* 369 */ - { 41, 7, 12, 0, 0, 41, 0, }, /* 370 */ - { 41, 22, 12, 0, 0, 41, 0, }, /* 371 */ - { 41, 18, 12, 0, 0, 41, 0, }, /* 372 */ - { 46, 7, 12, 0, 0, 46, 0, }, /* 373 */ - { 46, 14, 12, 0, 0, 46, 0, }, /* 374 */ - { 51, 7, 12, 0, 0, 51, 0, }, /* 375 */ - { 51, 12, 3, 0, 0, 51, 0, }, /* 376 */ - { 25, 7, 12, 0, 0, 25, 0, }, /* 377 */ - { 25, 12, 3, 0, 0, 25, 0, }, /* 378 */ - { 10, 21, 12, 0, 0, -106, 0, }, /* 379 */ - { 7, 7, 12, 0, 0, 7, 0, }, /* 380 */ - { 7, 12, 3, 0, 0, 7, 0, }, /* 381 */ - { 52, 7, 12, 0, 0, 52, 0, }, /* 382 */ - { 52, 12, 3, 0, 0, 52, 0, }, /* 383 */ - { 32, 7, 12, 0, 0, 32, 0, }, /* 384 */ - { 32, 12, 3, 0, 0, 32, 0, }, /* 385 */ - { 32, 10, 5, 0, 0, 32, 0, }, /* 386 */ - { 32, 21, 12, 0, 0, 32, 0, }, /* 387 */ - { 32, 6, 12, 0, 0, 32, 0, }, /* 388 */ - { 32, 23, 12, 0, 0, 32, 0, }, /* 389 */ - { 32, 13, 12, 0, 0, 32, 0, }, /* 390 */ - { 32, 15, 12, 0, 0, 32, 0, }, /* 391 */ - { 38, 21, 12, 0, 0, 38, 0, }, /* 392 */ - { 10, 21, 12, 0, 0, -61, 0, }, /* 393 */ - { 38, 17, 12, 0, 0, 38, 0, }, /* 394 */ - { 38, 12, 3, 0, 0, 38, 0, }, /* 395 */ - { 38, 1, 2, 0, 0, 38, 0, }, /* 396 */ - { 38, 13, 12, 0, 0, 38, 0, }, /* 397 */ - { 38, 7, 12, 0, 0, 38, 0, }, /* 398 */ - { 38, 6, 12, 0, 0, 38, 0, }, /* 399 */ - { 35, 7, 12, 0, 0, 35, 0, }, /* 400 */ - { 35, 12, 3, 0, 0, 35, 0, }, /* 401 */ - { 35, 10, 5, 0, 0, 35, 0, }, /* 402 */ - { 35, 26, 12, 0, 0, 35, 0, }, /* 403 */ - { 35, 21, 12, 0, 0, 35, 0, }, /* 404 */ - { 35, 13, 12, 0, 0, 35, 0, }, /* 405 */ - { 53, 7, 12, 0, 0, 53, 0, }, /* 406 */ - { 40, 7, 12, 0, 0, 40, 0, }, /* 407 */ - { 40, 13, 12, 0, 0, 40, 0, }, /* 408 */ - { 40, 15, 12, 0, 0, 40, 0, }, /* 409 */ - { 40, 26, 12, 0, 0, 40, 0, }, /* 410 */ - { 32, 26, 12, 0, 0, 32, 0, }, /* 411 */ - { 6, 7, 12, 0, 0, 6, 0, }, /* 412 */ - { 6, 12, 3, 0, 0, 6, 0, }, /* 413 */ - { 6, 10, 5, 0, 0, 6, 0, }, /* 414 */ - { 6, 21, 12, 0, 0, 6, 0, }, /* 415 */ - { 91, 7, 12, 0, 0, 91, 0, }, /* 416 */ - { 91, 10, 5, 0, 0, 91, 0, }, /* 417 */ - { 91, 12, 3, 0, 0, 91, 0, }, /* 418 */ - { 91, 10, 12, 0, 0, 91, 0, }, /* 419 */ - { 91, 13, 12, 0, 0, 91, 0, }, /* 420 */ - { 91, 21, 12, 0, 0, 91, 0, }, /* 421 */ - { 91, 6, 12, 0, 0, 91, 0, }, /* 422 */ - { 28, 11, 3, 0, 0, 28, 0, }, /* 423 */ - { 62, 12, 3, 0, 0, 62, 0, }, /* 424 */ - { 62, 10, 5, 0, 0, 62, 0, }, /* 425 */ - { 62, 7, 12, 0, 0, 62, 0, }, /* 426 */ - { 62, 13, 12, 0, 0, 62, 0, }, /* 427 */ - { 62, 21, 12, 0, 0, 62, 0, }, /* 428 */ - { 62, 26, 12, 0, 0, 62, 0, }, /* 429 */ - { 76, 12, 3, 0, 0, 76, 0, }, /* 430 */ - { 76, 10, 5, 0, 0, 76, 0, }, /* 431 */ - { 76, 7, 12, 0, 0, 76, 0, }, /* 432 */ - { 76, 13, 12, 0, 0, 76, 0, }, /* 433 */ - { 93, 7, 12, 0, 0, 93, 0, }, /* 434 */ - { 93, 12, 3, 0, 0, 93, 0, }, /* 435 */ - { 93, 10, 5, 0, 0, 93, 0, }, /* 436 */ - { 93, 21, 12, 0, 0, 93, 0, }, /* 437 */ - { 70, 7, 12, 0, 0, 70, 0, }, /* 438 */ - { 70, 10, 5, 0, 0, 70, 0, }, /* 439 */ - { 70, 12, 3, 0, 0, 70, 0, }, /* 440 */ - { 70, 21, 12, 0, 0, 70, 0, }, /* 441 */ - { 70, 13, 12, 0, 0, 70, 0, }, /* 442 */ - { 73, 13, 12, 0, 0, 73, 0, }, /* 443 */ - { 73, 7, 12, 0, 0, 73, 0, }, /* 444 */ - { 73, 6, 12, 0, 0, 73, 0, }, /* 445 */ - { 73, 21, 12, 0, 0, 73, 0, }, /* 446 */ - { 13, 5, 12, 63, -6222, 13, 0, }, /* 447 */ - { 13, 5, 12, 67, -6221, 13, 0, }, /* 448 */ - { 13, 5, 12, 71, -6212, 13, 0, }, /* 449 */ - { 13, 5, 12, 75, -6210, 13, 0, }, /* 450 */ - { 13, 5, 12, 79, -6210, 13, 0, }, /* 451 */ - { 13, 5, 12, 79, -6211, 13, 0, }, /* 452 */ - { 13, 5, 12, 84, -6204, 13, 0, }, /* 453 */ - { 13, 5, 12, 88, -6180, 13, 0, }, /* 454 */ - { 13, 5, 12, 108, 35267, 13, 0, }, /* 455 */ - { 17, 9, 12, 0, -3008, 17, 0, }, /* 456 */ - { 76, 21, 12, 0, 0, 76, 0, }, /* 457 */ - { 28, 12, 3, 0, 0, -101, 0, }, /* 458 */ - { 28, 12, 3, 0, 0, 15, 0, }, /* 459 */ - { 10, 21, 12, 0, 0, -37, 0, }, /* 460 */ - { 28, 12, 3, 0, 0, -16, 0, }, /* 461 */ - { 28, 12, 3, 0, 0, -40, 0, }, /* 462 */ - { 28, 12, 3, 0, 0, -129, 0, }, /* 463 */ - { 10, 10, 5, 0, 0, -16, 0, }, /* 464 */ - { 10, 7, 12, 0, 0, 15, 0, }, /* 465 */ - { 10, 7, 12, 0, 0, -16, 0, }, /* 466 */ - { 10, 10, 5, 0, 0, -37, 0, }, /* 467 */ - { 28, 12, 3, 0, 0, -80, 0, }, /* 468 */ - { 10, 10, 5, 0, 0, 3, 0, }, /* 469 */ - { 28, 12, 3, 0, 0, -37, 0, }, /* 470 */ - { 13, 5, 12, 0, 0, 13, 0, }, /* 471 */ - { 13, 6, 12, 0, 0, 13, 0, }, /* 472 */ - { 34, 5, 12, 0, 35332, 34, 0, }, /* 473 */ - { 34, 5, 12, 0, 3814, 34, 0, }, /* 474 */ - { 34, 9, 12, 92, 1, 34, 0, }, /* 475 */ - { 34, 5, 12, 92, -1, 34, 0, }, /* 476 */ - { 34, 5, 12, 92, -58, 34, 0, }, /* 477 */ - { 34, 9, 12, 0, -7615, 34, 0, }, /* 478 */ - { 20, 5, 12, 0, 8, 20, 0, }, /* 479 */ - { 20, 9, 12, 0, -8, 20, 0, }, /* 480 */ - { 20, 5, 12, 0, 74, 20, 0, }, /* 481 */ - { 20, 5, 12, 0, 86, 20, 0, }, /* 482 */ - { 20, 5, 12, 0, 100, 20, 0, }, /* 483 */ - { 20, 5, 12, 0, 128, 20, 0, }, /* 484 */ - { 20, 5, 12, 0, 112, 20, 0, }, /* 485 */ - { 20, 5, 12, 0, 126, 20, 0, }, /* 486 */ - { 20, 8, 12, 0, -8, 20, 0, }, /* 487 */ - { 20, 5, 12, 0, 9, 20, 0, }, /* 488 */ - { 20, 9, 12, 0, -74, 20, 0, }, /* 489 */ - { 20, 8, 12, 0, -9, 20, 0, }, /* 490 */ - { 20, 5, 12, 21, -7173, 20, 0, }, /* 491 */ - { 20, 9, 12, 0, -86, 20, 0, }, /* 492 */ - { 20, 9, 12, 0, -100, 20, 0, }, /* 493 */ - { 20, 9, 12, 0, -112, 20, 0, }, /* 494 */ - { 20, 9, 12, 0, -128, 20, 0, }, /* 495 */ - { 20, 9, 12, 0, -126, 20, 0, }, /* 496 */ - { 28, 1, 3, 0, 0, 28, 0, }, /* 497 */ - { 28, 1, 13, 0, 0, 28, 0, }, /* 498 */ - { 10, 27, 2, 0, 0, 10, 0, }, /* 499 */ - { 10, 28, 2, 0, 0, 10, 0, }, /* 500 */ - { 10, 21, 14, 0, 0, 10, 0, }, /* 501 */ - { 0, 2, 2, 0, 0, 0, 0, }, /* 502 */ - { 28, 12, 3, 0, 0, -84, 0, }, /* 503 */ - { 10, 9, 12, 0, 0, 10, 0, }, /* 504 */ - { 10, 5, 12, 0, 0, 10, 0, }, /* 505 */ - { 20, 9, 12, 96, -7517, 20, 0, }, /* 506 */ - { 34, 9, 12, 100, -8383, 34, 0, }, /* 507 */ - { 34, 9, 12, 104, -8262, 34, 0, }, /* 508 */ - { 34, 9, 12, 0, 28, 34, 0, }, /* 509 */ - { 10, 7, 12, 0, 0, 10, 0, }, /* 510 */ - { 10, 5, 14, 0, 0, 10, 0, }, /* 511 */ - { 34, 5, 12, 0, -28, 34, 0, }, /* 512 */ - { 34, 14, 12, 0, 16, 34, 0, }, /* 513 */ - { 34, 14, 12, 0, -16, 34, 0, }, /* 514 */ - { 34, 14, 12, 0, 0, 34, 0, }, /* 515 */ - { 10, 25, 14, 0, 0, 10, 0, }, /* 516 */ - { 10, 26, 12, 0, 26, 10, 0, }, /* 517 */ - { 10, 26, 14, 0, 26, 10, 0, }, /* 518 */ - { 10, 26, 12, 0, -26, 10, 0, }, /* 519 */ - { 5, 26, 12, 0, 0, 5, 0, }, /* 520 */ - { 18, 9, 12, 0, 48, 18, 0, }, /* 521 */ - { 18, 5, 12, 0, -48, 18, 0, }, /* 522 */ - { 34, 9, 12, 0, -10743, 34, 0, }, /* 523 */ - { 34, 9, 12, 0, -3814, 34, 0, }, /* 524 */ - { 34, 9, 12, 0, -10727, 34, 0, }, /* 525 */ - { 34, 5, 12, 0, -10795, 34, 0, }, /* 526 */ - { 34, 5, 12, 0, -10792, 34, 0, }, /* 527 */ - { 34, 9, 12, 0, -10780, 34, 0, }, /* 528 */ - { 34, 9, 12, 0, -10749, 34, 0, }, /* 529 */ - { 34, 9, 12, 0, -10783, 34, 0, }, /* 530 */ - { 34, 9, 12, 0, -10782, 34, 0, }, /* 531 */ - { 34, 9, 12, 0, -10815, 34, 0, }, /* 532 */ - { 11, 5, 12, 0, 0, 11, 0, }, /* 533 */ - { 11, 26, 12, 0, 0, 11, 0, }, /* 534 */ - { 11, 12, 3, 0, 0, 11, 0, }, /* 535 */ - { 11, 21, 12, 0, 0, 11, 0, }, /* 536 */ - { 11, 15, 12, 0, 0, 11, 0, }, /* 537 */ - { 17, 5, 12, 0, -7264, 17, 0, }, /* 538 */ - { 59, 7, 12, 0, 0, 59, 0, }, /* 539 */ - { 59, 6, 12, 0, 0, 59, 0, }, /* 540 */ - { 59, 21, 12, 0, 0, 59, 0, }, /* 541 */ - { 59, 12, 3, 0, 0, 59, 0, }, /* 542 */ - { 13, 12, 3, 0, 0, 13, 0, }, /* 543 */ - { 10, 21, 12, 0, 0, -28, 0, }, /* 544 */ - { 23, 26, 12, 0, 0, 23, 0, }, /* 545 */ - { 10, 21, 12, 0, 0, -122, 0, }, /* 546 */ - { 10, 21, 12, 0, 0, -116, 0, }, /* 547 */ - { 23, 6, 12, 0, 0, 23, 0, }, /* 548 */ - { 10, 7, 12, 0, 0, 23, 0, }, /* 549 */ - { 23, 14, 12, 0, 0, 23, 0, }, /* 550 */ - { 10, 22, 12, 0, 0, -122, 0, }, /* 551 */ - { 10, 18, 12, 0, 0, -122, 0, }, /* 552 */ - { 10, 26, 12, 0, 0, -116, 0, }, /* 553 */ - { 10, 17, 12, 0, 0, -116, 0, }, /* 554 */ - { 10, 22, 12, 0, 0, -116, 0, }, /* 555 */ - { 10, 18, 12, 0, 0, -116, 0, }, /* 556 */ - { 28, 12, 3, 0, 0, -19, 0, }, /* 557 */ - { 24, 10, 3, 0, 0, 24, 0, }, /* 558 */ - { 10, 17, 14, 0, 0, -116, 0, }, /* 559 */ - { 10, 6, 12, 0, 0, -58, 0, }, /* 560 */ - { 10, 7, 12, 0, 0, -88, 0, }, /* 561 */ - { 10, 21, 14, 0, 0, -88, 0, }, /* 562 */ - { 10, 26, 12, 0, 0, 23, 0, }, /* 563 */ - { 27, 7, 12, 0, 0, 27, 0, }, /* 564 */ - { 28, 12, 3, 0, 0, -58, 0, }, /* 565 */ - { 10, 24, 12, 0, 0, -58, 0, }, /* 566 */ - { 27, 6, 12, 0, 0, 27, 0, }, /* 567 */ - { 10, 17, 12, 0, 0, -58, 0, }, /* 568 */ - { 30, 7, 12, 0, 0, 30, 0, }, /* 569 */ - { 30, 6, 12, 0, 0, 30, 0, }, /* 570 */ - { 4, 7, 12, 0, 0, 4, 0, }, /* 571 */ - { 24, 7, 12, 0, 0, 24, 0, }, /* 572 */ - { 10, 15, 12, 0, 0, 23, 0, }, /* 573 */ - { 24, 26, 12, 0, 0, 24, 0, }, /* 574 */ - { 10, 26, 14, 0, 0, 23, 0, }, /* 575 */ - { 30, 26, 12, 0, 0, 30, 0, }, /* 576 */ - { 23, 7, 12, 0, 0, 23, 0, }, /* 577 */ - { 61, 7, 12, 0, 0, 61, 0, }, /* 578 */ - { 61, 6, 12, 0, 0, 61, 0, }, /* 579 */ - { 61, 26, 12, 0, 0, 61, 0, }, /* 580 */ - { 86, 7, 12, 0, 0, 86, 0, }, /* 581 */ - { 86, 6, 12, 0, 0, 86, 0, }, /* 582 */ - { 86, 21, 12, 0, 0, 86, 0, }, /* 583 */ - { 77, 7, 12, 0, 0, 77, 0, }, /* 584 */ - { 77, 6, 12, 0, 0, 77, 0, }, /* 585 */ - { 77, 21, 12, 0, 0, 77, 0, }, /* 586 */ - { 77, 13, 12, 0, 0, 77, 0, }, /* 587 */ - { 13, 9, 12, 108, 1, 13, 0, }, /* 588 */ - { 13, 5, 12, 108, -35267, 13, 0, }, /* 589 */ - { 13, 7, 12, 0, 0, 13, 0, }, /* 590 */ - { 13, 21, 12, 0, 0, 13, 0, }, /* 591 */ - { 79, 7, 12, 0, 0, 79, 0, }, /* 592 */ - { 79, 14, 12, 0, 0, 79, 0, }, /* 593 */ - { 79, 12, 3, 0, 0, 79, 0, }, /* 594 */ - { 79, 21, 12, 0, 0, 79, 0, }, /* 595 */ - { 34, 9, 12, 0, -35332, 34, 0, }, /* 596 */ - { 34, 9, 12, 0, -42280, 34, 0, }, /* 597 */ - { 34, 9, 12, 0, -42308, 34, 0, }, /* 598 */ - { 34, 9, 12, 0, -42319, 34, 0, }, /* 599 */ - { 34, 9, 12, 0, -42315, 34, 0, }, /* 600 */ - { 34, 9, 12, 0, -42305, 34, 0, }, /* 601 */ - { 34, 9, 12, 0, -42258, 34, 0, }, /* 602 */ - { 34, 9, 12, 0, -42282, 34, 0, }, /* 603 */ - { 34, 9, 12, 0, -42261, 34, 0, }, /* 604 */ - { 34, 9, 12, 0, 928, 34, 0, }, /* 605 */ - { 49, 7, 12, 0, 0, 49, 0, }, /* 606 */ - { 49, 12, 3, 0, 0, 49, 0, }, /* 607 */ - { 49, 10, 5, 0, 0, 49, 0, }, /* 608 */ - { 49, 26, 12, 0, 0, 49, 0, }, /* 609 */ - { 10, 15, 12, 0, 0, -197, 0, }, /* 610 */ - { 10, 15, 12, 0, 0, -170, 0, }, /* 611 */ - { 10, 26, 12, 0, 0, -145, 0, }, /* 612 */ - { 10, 23, 12, 0, 0, -145, 0, }, /* 613 */ - { 65, 7, 12, 0, 0, 65, 0, }, /* 614 */ - { 65, 21, 12, 0, 0, 65, 0, }, /* 615 */ - { 75, 10, 5, 0, 0, 75, 0, }, /* 616 */ - { 75, 7, 12, 0, 0, 75, 0, }, /* 617 */ - { 75, 12, 3, 0, 0, 75, 0, }, /* 618 */ - { 75, 21, 12, 0, 0, 75, 0, }, /* 619 */ - { 75, 13, 12, 0, 0, 75, 0, }, /* 620 */ - { 15, 12, 3, 0, 0, -16, 0, }, /* 621 */ - { 15, 7, 12, 0, 0, -43, 0, }, /* 622 */ - { 69, 13, 12, 0, 0, 69, 0, }, /* 623 */ - { 69, 7, 12, 0, 0, 69, 0, }, /* 624 */ - { 69, 12, 3, 0, 0, 69, 0, }, /* 625 */ - { 10, 21, 12, 0, 0, -92, 0, }, /* 626 */ - { 69, 21, 12, 0, 0, 69, 0, }, /* 627 */ - { 74, 7, 12, 0, 0, 74, 0, }, /* 628 */ - { 74, 12, 3, 0, 0, 74, 0, }, /* 629 */ - { 74, 10, 5, 0, 0, 74, 0, }, /* 630 */ - { 74, 21, 12, 0, 0, 74, 0, }, /* 631 */ - { 84, 12, 3, 0, 0, 84, 0, }, /* 632 */ - { 84, 10, 5, 0, 0, 84, 0, }, /* 633 */ - { 84, 7, 12, 0, 0, 84, 0, }, /* 634 */ - { 84, 21, 12, 0, 0, 84, 0, }, /* 635 */ - { 10, 6, 12, 0, 0, -22, 0, }, /* 636 */ - { 84, 13, 12, 0, 0, 84, 0, }, /* 637 */ - { 39, 6, 12, 0, 0, 39, 0, }, /* 638 */ - { 68, 7, 12, 0, 0, 68, 0, }, /* 639 */ - { 68, 12, 3, 0, 0, 68, 0, }, /* 640 */ - { 68, 10, 5, 0, 0, 68, 0, }, /* 641 */ - { 68, 13, 12, 0, 0, 68, 0, }, /* 642 */ - { 68, 21, 12, 0, 0, 68, 0, }, /* 643 */ - { 92, 7, 12, 0, 0, 92, 0, }, /* 644 */ - { 92, 12, 3, 0, 0, 92, 0, }, /* 645 */ - { 92, 6, 12, 0, 0, 92, 0, }, /* 646 */ - { 92, 21, 12, 0, 0, 92, 0, }, /* 647 */ - { 87, 7, 12, 0, 0, 87, 0, }, /* 648 */ - { 87, 10, 5, 0, 0, 87, 0, }, /* 649 */ - { 87, 12, 3, 0, 0, 87, 0, }, /* 650 */ - { 87, 21, 12, 0, 0, 87, 0, }, /* 651 */ - { 87, 6, 12, 0, 0, 87, 0, }, /* 652 */ - { 34, 5, 12, 0, -928, 34, 0, }, /* 653 */ - { 9, 5, 12, 0, -38864, 9, 0, }, /* 654 */ - { 87, 13, 12, 0, 0, 87, 0, }, /* 655 */ - { 24, 7, 9, 0, 0, 24, 0, }, /* 656 */ - { 24, 7, 10, 0, 0, 24, 0, }, /* 657 */ - { 0, 4, 2, 0, 0, 0, 0, }, /* 658 */ - { 0, 3, 12, 0, 0, 0, 0, }, /* 659 */ - { 26, 25, 12, 0, 0, 26, 0, }, /* 660 */ - { 1, 24, 12, 0, 0, 1, 0, }, /* 661 */ - { 1, 7, 12, 0, 0, -10, 0, }, /* 662 */ - { 1, 26, 12, 0, 0, -10, 0, }, /* 663 */ - { 10, 6, 3, 0, 0, -58, 0, }, /* 664 */ - { 36, 7, 12, 0, 0, 36, 0, }, /* 665 */ - { 10, 21, 12, 0, 0, -25, 0, }, /* 666 */ - { 10, 15, 12, 0, 0, -76, 0, }, /* 667 */ - { 10, 26, 12, 0, 0, -25, 0, }, /* 668 */ - { 20, 14, 12, 0, 0, 20, 0, }, /* 669 */ - { 20, 15, 12, 0, 0, 20, 0, }, /* 670 */ - { 20, 26, 12, 0, 0, 20, 0, }, /* 671 */ - { 71, 7, 12, 0, 0, 71, 0, }, /* 672 */ - { 67, 7, 12, 0, 0, 67, 0, }, /* 673 */ - { 28, 12, 3, 0, 0, -1, 0, }, /* 674 */ - { 10, 15, 12, 0, 0, -1, 0, }, /* 675 */ - { 42, 7, 12, 0, 0, 42, 0, }, /* 676 */ - { 42, 15, 12, 0, 0, 42, 0, }, /* 677 */ - { 19, 7, 12, 0, 0, 19, 0, }, /* 678 */ - { 19, 14, 12, 0, 0, 19, 0, }, /* 679 */ - { 118, 7, 12, 0, 0, 118, 0, }, /* 680 */ - { 118, 12, 3, 0, 0, 118, 0, }, /* 681 */ - { 60, 7, 12, 0, 0, 60, 0, }, /* 682 */ - { 60, 21, 12, 0, 0, 60, 0, }, /* 683 */ - { 43, 7, 12, 0, 0, 43, 0, }, /* 684 */ - { 43, 21, 12, 0, 0, 43, 0, }, /* 685 */ - { 43, 14, 12, 0, 0, 43, 0, }, /* 686 */ - { 14, 9, 12, 0, 40, 14, 0, }, /* 687 */ - { 14, 5, 12, 0, -40, 14, 0, }, /* 688 */ - { 47, 7, 12, 0, 0, 47, 0, }, /* 689 */ - { 45, 7, 12, 0, 0, 45, 0, }, /* 690 */ - { 45, 13, 12, 0, 0, 45, 0, }, /* 691 */ - { 136, 9, 12, 0, 40, 136, 0, }, /* 692 */ - { 136, 5, 12, 0, -40, 136, 0, }, /* 693 */ - { 106, 7, 12, 0, 0, 106, 0, }, /* 694 */ - { 104, 7, 12, 0, 0, 104, 0, }, /* 695 */ - { 104, 21, 12, 0, 0, 104, 0, }, /* 696 */ - { 110, 7, 12, 0, 0, 110, 0, }, /* 697 */ - { 12, 7, 12, 0, 0, 12, 0, }, /* 698 */ - { 81, 7, 12, 0, 0, 81, 0, }, /* 699 */ - { 81, 21, 12, 0, 0, 81, 0, }, /* 700 */ - { 81, 15, 12, 0, 0, 81, 0, }, /* 701 */ - { 120, 7, 12, 0, 0, 120, 0, }, /* 702 */ - { 120, 26, 12, 0, 0, 120, 0, }, /* 703 */ - { 120, 15, 12, 0, 0, 120, 0, }, /* 704 */ - { 116, 7, 12, 0, 0, 116, 0, }, /* 705 */ - { 116, 15, 12, 0, 0, 116, 0, }, /* 706 */ - { 128, 7, 12, 0, 0, 128, 0, }, /* 707 */ - { 128, 15, 12, 0, 0, 128, 0, }, /* 708 */ - { 66, 7, 12, 0, 0, 66, 0, }, /* 709 */ - { 66, 15, 12, 0, 0, 66, 0, }, /* 710 */ - { 66, 21, 12, 0, 0, 66, 0, }, /* 711 */ - { 72, 7, 12, 0, 0, 72, 0, }, /* 712 */ - { 72, 21, 12, 0, 0, 72, 0, }, /* 713 */ - { 98, 7, 12, 0, 0, 98, 0, }, /* 714 */ - { 97, 7, 12, 0, 0, 97, 0, }, /* 715 */ - { 97, 15, 12, 0, 0, 97, 0, }, /* 716 */ - { 31, 7, 12, 0, 0, 31, 0, }, /* 717 */ - { 31, 12, 3, 0, 0, 31, 0, }, /* 718 */ - { 31, 15, 12, 0, 0, 31, 0, }, /* 719 */ - { 31, 21, 12, 0, 0, 31, 0, }, /* 720 */ - { 88, 7, 12, 0, 0, 88, 0, }, /* 721 */ - { 88, 15, 12, 0, 0, 88, 0, }, /* 722 */ - { 88, 21, 12, 0, 0, 88, 0, }, /* 723 */ - { 117, 7, 12, 0, 0, 117, 0, }, /* 724 */ - { 117, 15, 12, 0, 0, 117, 0, }, /* 725 */ - { 112, 7, 12, 0, 0, 112, 0, }, /* 726 */ - { 112, 26, 12, 0, 0, 112, 0, }, /* 727 */ - { 112, 12, 3, 0, 0, 112, 0, }, /* 728 */ - { 112, 15, 12, 0, 0, 112, 0, }, /* 729 */ - { 112, 21, 12, 0, 0, 112, 0, }, /* 730 */ - { 78, 7, 12, 0, 0, 78, 0, }, /* 731 */ - { 78, 21, 12, 0, 0, 78, 0, }, /* 732 */ - { 83, 7, 12, 0, 0, 83, 0, }, /* 733 */ - { 83, 15, 12, 0, 0, 83, 0, }, /* 734 */ - { 82, 7, 12, 0, 0, 82, 0, }, /* 735 */ - { 82, 15, 12, 0, 0, 82, 0, }, /* 736 */ - { 121, 7, 12, 0, 0, 121, 0, }, /* 737 */ - { 121, 21, 12, 0, 0, 121, 0, }, /* 738 */ - { 121, 15, 12, 0, 0, 121, 0, }, /* 739 */ - { 89, 7, 12, 0, 0, 89, 0, }, /* 740 */ - { 130, 9, 12, 0, 64, 130, 0, }, /* 741 */ - { 130, 5, 12, 0, -64, 130, 0, }, /* 742 */ - { 130, 15, 12, 0, 0, 130, 0, }, /* 743 */ - { 144, 7, 12, 0, 0, 144, 0, }, /* 744 */ - { 144, 12, 3, 0, 0, 144, 0, }, /* 745 */ - { 144, 13, 12, 0, 0, 144, 0, }, /* 746 */ - { 1, 15, 12, 0, 0, 1, 0, }, /* 747 */ - { 147, 7, 12, 0, 0, 147, 0, }, /* 748 */ - { 147, 15, 12, 0, 0, 147, 0, }, /* 749 */ - { 148, 7, 12, 0, 0, 148, 0, }, /* 750 */ - { 148, 12, 3, 0, 0, 148, 0, }, /* 751 */ - { 148, 15, 12, 0, 0, 148, 0, }, /* 752 */ - { 148, 21, 12, 0, 0, 148, 0, }, /* 753 */ - { 94, 10, 5, 0, 0, 94, 0, }, /* 754 */ - { 94, 12, 3, 0, 0, 94, 0, }, /* 755 */ - { 94, 7, 12, 0, 0, 94, 0, }, /* 756 */ - { 94, 21, 12, 0, 0, 94, 0, }, /* 757 */ - { 94, 15, 12, 0, 0, 94, 0, }, /* 758 */ - { 94, 13, 12, 0, 0, 94, 0, }, /* 759 */ - { 85, 12, 3, 0, 0, 85, 0, }, /* 760 */ - { 85, 10, 5, 0, 0, 85, 0, }, /* 761 */ - { 85, 7, 12, 0, 0, 85, 0, }, /* 762 */ - { 85, 21, 12, 0, 0, 85, 0, }, /* 763 */ - { 85, 1, 4, 0, 0, 85, 0, }, /* 764 */ - { 101, 7, 12, 0, 0, 101, 0, }, /* 765 */ - { 101, 13, 12, 0, 0, 101, 0, }, /* 766 */ - { 96, 12, 3, 0, 0, 96, 0, }, /* 767 */ - { 96, 7, 12, 0, 0, 96, 0, }, /* 768 */ - { 96, 10, 5, 0, 0, 96, 0, }, /* 769 */ - { 96, 13, 12, 0, 0, 96, 0, }, /* 770 */ - { 96, 21, 12, 0, 0, 96, 0, }, /* 771 */ - { 111, 7, 12, 0, 0, 111, 0, }, /* 772 */ - { 111, 12, 3, 0, 0, 111, 0, }, /* 773 */ - { 111, 21, 12, 0, 0, 111, 0, }, /* 774 */ - { 100, 12, 3, 0, 0, 100, 0, }, /* 775 */ - { 100, 10, 5, 0, 0, 100, 0, }, /* 776 */ - { 100, 7, 12, 0, 0, 100, 0, }, /* 777 */ - { 100, 7, 4, 0, 0, 100, 0, }, /* 778 */ - { 100, 21, 12, 0, 0, 100, 0, }, /* 779 */ - { 100, 13, 12, 0, 0, 100, 0, }, /* 780 */ - { 48, 15, 12, 0, 0, 48, 0, }, /* 781 */ - { 108, 7, 12, 0, 0, 108, 0, }, /* 782 */ - { 108, 10, 5, 0, 0, 108, 0, }, /* 783 */ - { 108, 12, 3, 0, 0, 108, 0, }, /* 784 */ - { 108, 21, 12, 0, 0, 108, 0, }, /* 785 */ - { 129, 7, 12, 0, 0, 129, 0, }, /* 786 */ - { 129, 21, 12, 0, 0, 129, 0, }, /* 787 */ - { 109, 7, 12, 0, 0, 109, 0, }, /* 788 */ - { 109, 12, 3, 0, 0, 109, 0, }, /* 789 */ - { 109, 10, 5, 0, 0, 109, 0, }, /* 790 */ - { 109, 13, 12, 0, 0, 109, 0, }, /* 791 */ - { 107, 12, 3, 0, 0, 107, 0, }, /* 792 */ - { 107, 12, 3, 0, 0, -49, 0, }, /* 793 */ - { 107, 10, 5, 0, 0, 107, 0, }, /* 794 */ - { 107, 10, 5, 0, 0, -49, 0, }, /* 795 */ - { 107, 7, 12, 0, 0, 107, 0, }, /* 796 */ - { 28, 12, 3, 0, 0, -49, 0, }, /* 797 */ - { 107, 10, 3, 0, 0, 107, 0, }, /* 798 */ - { 135, 7, 12, 0, 0, 135, 0, }, /* 799 */ - { 135, 10, 5, 0, 0, 135, 0, }, /* 800 */ - { 135, 12, 3, 0, 0, 135, 0, }, /* 801 */ - { 135, 21, 12, 0, 0, 135, 0, }, /* 802 */ - { 135, 13, 12, 0, 0, 135, 0, }, /* 803 */ - { 124, 7, 12, 0, 0, 124, 0, }, /* 804 */ - { 124, 10, 3, 0, 0, 124, 0, }, /* 805 */ - { 124, 10, 5, 0, 0, 124, 0, }, /* 806 */ - { 124, 12, 3, 0, 0, 124, 0, }, /* 807 */ - { 124, 21, 12, 0, 0, 124, 0, }, /* 808 */ - { 124, 13, 12, 0, 0, 124, 0, }, /* 809 */ - { 123, 7, 12, 0, 0, 123, 0, }, /* 810 */ - { 123, 10, 3, 0, 0, 123, 0, }, /* 811 */ - { 123, 10, 5, 0, 0, 123, 0, }, /* 812 */ - { 123, 12, 3, 0, 0, 123, 0, }, /* 813 */ - { 123, 21, 12, 0, 0, 123, 0, }, /* 814 */ - { 114, 7, 12, 0, 0, 114, 0, }, /* 815 */ - { 114, 10, 5, 0, 0, 114, 0, }, /* 816 */ - { 114, 12, 3, 0, 0, 114, 0, }, /* 817 */ - { 114, 21, 12, 0, 0, 114, 0, }, /* 818 */ - { 114, 13, 12, 0, 0, 114, 0, }, /* 819 */ - { 102, 7, 12, 0, 0, 102, 0, }, /* 820 */ - { 102, 12, 3, 0, 0, 102, 0, }, /* 821 */ - { 102, 10, 5, 0, 0, 102, 0, }, /* 822 */ - { 102, 13, 12, 0, 0, 102, 0, }, /* 823 */ - { 126, 7, 12, 0, 0, 126, 0, }, /* 824 */ - { 126, 12, 3, 0, 0, 126, 0, }, /* 825 */ - { 126, 10, 5, 0, 0, 126, 0, }, /* 826 */ - { 126, 13, 12, 0, 0, 126, 0, }, /* 827 */ - { 126, 15, 12, 0, 0, 126, 0, }, /* 828 */ - { 126, 21, 12, 0, 0, 126, 0, }, /* 829 */ - { 126, 26, 12, 0, 0, 126, 0, }, /* 830 */ - { 142, 7, 12, 0, 0, 142, 0, }, /* 831 */ - { 142, 10, 5, 0, 0, 142, 0, }, /* 832 */ - { 142, 12, 3, 0, 0, 142, 0, }, /* 833 */ - { 142, 21, 12, 0, 0, 142, 0, }, /* 834 */ - { 125, 9, 12, 0, 32, 125, 0, }, /* 835 */ - { 125, 5, 12, 0, -32, 125, 0, }, /* 836 */ - { 125, 13, 12, 0, 0, 125, 0, }, /* 837 */ - { 125, 15, 12, 0, 0, 125, 0, }, /* 838 */ - { 125, 7, 12, 0, 0, 125, 0, }, /* 839 */ - { 141, 7, 12, 0, 0, 141, 0, }, /* 840 */ - { 141, 12, 3, 0, 0, 141, 0, }, /* 841 */ - { 141, 10, 5, 0, 0, 141, 0, }, /* 842 */ - { 141, 7, 4, 0, 0, 141, 0, }, /* 843 */ - { 141, 21, 12, 0, 0, 141, 0, }, /* 844 */ - { 140, 7, 12, 0, 0, 140, 0, }, /* 845 */ - { 140, 12, 3, 0, 0, 140, 0, }, /* 846 */ - { 140, 10, 5, 0, 0, 140, 0, }, /* 847 */ - { 140, 7, 4, 0, 0, 140, 0, }, /* 848 */ - { 140, 21, 12, 0, 0, 140, 0, }, /* 849 */ - { 122, 7, 12, 0, 0, 122, 0, }, /* 850 */ - { 133, 7, 12, 0, 0, 133, 0, }, /* 851 */ - { 133, 10, 5, 0, 0, 133, 0, }, /* 852 */ - { 133, 12, 3, 0, 0, 133, 0, }, /* 853 */ - { 133, 21, 12, 0, 0, 133, 0, }, /* 854 */ - { 133, 13, 12, 0, 0, 133, 0, }, /* 855 */ - { 133, 15, 12, 0, 0, 133, 0, }, /* 856 */ - { 134, 21, 12, 0, 0, 134, 0, }, /* 857 */ - { 134, 7, 12, 0, 0, 134, 0, }, /* 858 */ - { 134, 12, 3, 0, 0, 134, 0, }, /* 859 */ - { 134, 10, 5, 0, 0, 134, 0, }, /* 860 */ - { 138, 7, 12, 0, 0, 138, 0, }, /* 861 */ - { 138, 12, 3, 0, 0, 138, 0, }, /* 862 */ - { 138, 7, 4, 0, 0, 138, 0, }, /* 863 */ - { 138, 13, 12, 0, 0, 138, 0, }, /* 864 */ - { 143, 7, 12, 0, 0, 143, 0, }, /* 865 */ - { 143, 10, 5, 0, 0, 143, 0, }, /* 866 */ - { 143, 12, 3, 0, 0, 143, 0, }, /* 867 */ - { 143, 13, 12, 0, 0, 143, 0, }, /* 868 */ - { 145, 7, 12, 0, 0, 145, 0, }, /* 869 */ - { 145, 12, 3, 0, 0, 145, 0, }, /* 870 */ - { 145, 10, 5, 0, 0, 145, 0, }, /* 871 */ - { 145, 21, 12, 0, 0, 145, 0, }, /* 872 */ - { 63, 7, 12, 0, 0, 63, 0, }, /* 873 */ - { 63, 14, 12, 0, 0, 63, 0, }, /* 874 */ - { 63, 21, 12, 0, 0, 63, 0, }, /* 875 */ - { 80, 7, 12, 0, 0, 80, 0, }, /* 876 */ - { 127, 7, 12, 0, 0, 127, 0, }, /* 877 */ - { 115, 7, 12, 0, 0, 115, 0, }, /* 878 */ - { 115, 13, 12, 0, 0, 115, 0, }, /* 879 */ - { 115, 21, 12, 0, 0, 115, 0, }, /* 880 */ - { 103, 7, 12, 0, 0, 103, 0, }, /* 881 */ - { 103, 12, 3, 0, 0, 103, 0, }, /* 882 */ - { 103, 21, 12, 0, 0, 103, 0, }, /* 883 */ - { 119, 7, 12, 0, 0, 119, 0, }, /* 884 */ - { 119, 12, 3, 0, 0, 119, 0, }, /* 885 */ - { 119, 21, 12, 0, 0, 119, 0, }, /* 886 */ - { 119, 26, 12, 0, 0, 119, 0, }, /* 887 */ - { 119, 6, 12, 0, 0, 119, 0, }, /* 888 */ - { 119, 13, 12, 0, 0, 119, 0, }, /* 889 */ - { 119, 15, 12, 0, 0, 119, 0, }, /* 890 */ - { 146, 9, 12, 0, 32, 146, 0, }, /* 891 */ - { 146, 5, 12, 0, -32, 146, 0, }, /* 892 */ - { 146, 15, 12, 0, 0, 146, 0, }, /* 893 */ - { 146, 21, 12, 0, 0, 146, 0, }, /* 894 */ - { 99, 7, 12, 0, 0, 99, 0, }, /* 895 */ - { 99, 10, 5, 0, 0, 99, 0, }, /* 896 */ - { 99, 12, 3, 0, 0, 99, 0, }, /* 897 */ - { 99, 6, 12, 0, 0, 99, 0, }, /* 898 */ - { 137, 6, 12, 0, 0, 137, 0, }, /* 899 */ - { 139, 6, 12, 0, 0, 139, 0, }, /* 900 */ - { 137, 7, 12, 0, 0, 137, 0, }, /* 901 */ - { 139, 7, 12, 0, 0, 139, 0, }, /* 902 */ - { 105, 7, 12, 0, 0, 105, 0, }, /* 903 */ - { 105, 26, 12, 0, 0, 105, 0, }, /* 904 */ - { 105, 12, 3, 0, 0, 105, 0, }, /* 905 */ - { 105, 21, 12, 0, 0, 105, 0, }, /* 906 */ - { 10, 1, 2, 0, 0, 105, 0, }, /* 907 */ - { 10, 10, 3, 0, 0, 10, 0, }, /* 908 */ - { 10, 10, 5, 0, 0, 10, 0, }, /* 909 */ - { 20, 12, 3, 0, 0, 20, 0, }, /* 910 */ - { 131, 26, 12, 0, 0, 131, 0, }, /* 911 */ - { 131, 12, 3, 0, 0, 131, 0, }, /* 912 */ - { 131, 21, 12, 0, 0, 131, 0, }, /* 913 */ - { 18, 12, 3, 0, 0, 18, 0, }, /* 914 */ - { 113, 7, 12, 0, 0, 113, 0, }, /* 915 */ - { 113, 15, 12, 0, 0, 113, 0, }, /* 916 */ - { 113, 12, 3, 0, 0, 113, 0, }, /* 917 */ - { 132, 9, 12, 0, 34, 132, 0, }, /* 918 */ - { 132, 5, 12, 0, -34, 132, 0, }, /* 919 */ - { 132, 12, 3, 0, 0, 132, 0, }, /* 920 */ - { 132, 13, 12, 0, 0, 132, 0, }, /* 921 */ - { 132, 21, 12, 0, 0, 132, 0, }, /* 922 */ - { 0, 2, 14, 0, 0, 0, 0, }, /* 923 */ - { 10, 26, 11, 0, 0, 10, 0, }, /* 924 */ - { 27, 26, 12, 0, 0, 27, 0, }, /* 925 */ - { 10, 24, 3, 0, 0, 10, 0, }, /* 926 */ - { 10, 1, 3, 0, 0, 10, 0, }, /* 927 */ + { 34, 5, 12, 0, 42307, 34, 0, }, /* 102 */ + { 34, 5, 12, 0, 42282, 34, 0, }, /* 103 */ + { 34, 5, 12, 0, -69, 34, 0, }, /* 104 */ + { 34, 5, 12, 0, -217, 34, 0, }, /* 105 */ + { 34, 5, 12, 0, -71, 34, 0, }, /* 106 */ + { 34, 5, 12, 0, -219, 34, 0, }, /* 107 */ + { 34, 5, 12, 0, 42261, 34, 0, }, /* 108 */ + { 34, 5, 12, 0, 42258, 34, 0, }, /* 109 */ + { 34, 6, 12, 0, 0, 34, 0, }, /* 110 */ + { 10, 6, 12, 0, 0, 10, 0, }, /* 111 */ + { 4, 24, 12, 0, 0, 4, 0, }, /* 112 */ + { 28, 12, 3, 0, 0, 28, 0, }, /* 113 */ + { 28, 12, 3, 0, 0, 20, 0, }, /* 114 */ + { 28, 12, 3, 21, 116, 20, 0, }, /* 115 */ + { 28, 12, 3, 0, 0, 34, 0, }, /* 116 */ + { 20, 9, 12, 0, 1, 20, 0, }, /* 117 */ + { 20, 5, 12, 0, -1, 20, 0, }, /* 118 */ + { 20, 24, 12, 0, 0, 20, 0, }, /* 119 */ + { 0, 2, 12, 0, 0, 0, 0, }, /* 120 */ + { 20, 6, 12, 0, 0, 20, 0, }, /* 121 */ + { 20, 5, 12, 0, 130, 20, 0, }, /* 122 */ + { 20, 9, 12, 0, 116, 20, 0, }, /* 123 */ + { 20, 9, 12, 0, 38, 20, 0, }, /* 124 */ + { 20, 9, 12, 0, 37, 20, 0, }, /* 125 */ + { 20, 9, 12, 0, 64, 20, 0, }, /* 126 */ + { 20, 9, 12, 0, 63, 20, 0, }, /* 127 */ + { 20, 5, 12, 0, 0, 20, 0, }, /* 128 */ + { 20, 9, 12, 0, 32, 20, 0, }, /* 129 */ + { 20, 9, 12, 34, 32, 20, 0, }, /* 130 */ + { 20, 9, 12, 59, 32, 20, 0, }, /* 131 */ + { 20, 9, 12, 38, 32, 20, 0, }, /* 132 */ + { 20, 9, 12, 21, 32, 20, 0, }, /* 133 */ + { 20, 9, 12, 51, 32, 20, 0, }, /* 134 */ + { 20, 9, 12, 26, 32, 20, 0, }, /* 135 */ + { 20, 9, 12, 47, 32, 20, 0, }, /* 136 */ + { 20, 9, 12, 55, 32, 20, 0, }, /* 137 */ + { 20, 9, 12, 30, 32, 20, 0, }, /* 138 */ + { 20, 9, 12, 43, 32, 20, 0, }, /* 139 */ + { 20, 9, 12, 96, 32, 20, 0, }, /* 140 */ + { 20, 5, 12, 0, -38, 20, 0, }, /* 141 */ + { 20, 5, 12, 0, -37, 20, 0, }, /* 142 */ + { 20, 5, 12, 0, -32, 20, 0, }, /* 143 */ + { 20, 5, 12, 34, -32, 20, 0, }, /* 144 */ + { 20, 5, 12, 59, -32, 20, 0, }, /* 145 */ + { 20, 5, 12, 38, -32, 20, 0, }, /* 146 */ + { 20, 5, 12, 21, -116, 20, 0, }, /* 147 */ + { 20, 5, 12, 51, -32, 20, 0, }, /* 148 */ + { 20, 5, 12, 26, -775, 20, 0, }, /* 149 */ + { 20, 5, 12, 47, -32, 20, 0, }, /* 150 */ + { 20, 5, 12, 55, -32, 20, 0, }, /* 151 */ + { 20, 5, 12, 30, 1, 20, 0, }, /* 152 */ + { 20, 5, 12, 30, -32, 20, 0, }, /* 153 */ + { 20, 5, 12, 43, -32, 20, 0, }, /* 154 */ + { 20, 5, 12, 96, -32, 20, 0, }, /* 155 */ + { 20, 5, 12, 0, -64, 20, 0, }, /* 156 */ + { 20, 5, 12, 0, -63, 20, 0, }, /* 157 */ + { 20, 9, 12, 0, 8, 20, 0, }, /* 158 */ + { 20, 5, 12, 34, -30, 20, 0, }, /* 159 */ + { 20, 5, 12, 38, -25, 20, 0, }, /* 160 */ + { 20, 9, 12, 0, 0, 20, 0, }, /* 161 */ + { 20, 5, 12, 43, -15, 20, 0, }, /* 162 */ + { 20, 5, 12, 47, -22, 20, 0, }, /* 163 */ + { 20, 5, 12, 0, -8, 20, 0, }, /* 164 */ + { 11, 9, 12, 0, 1, 11, 0, }, /* 165 */ + { 11, 5, 12, 0, -1, 11, 0, }, /* 166 */ + { 20, 5, 12, 51, -54, 20, 0, }, /* 167 */ + { 20, 5, 12, 55, -48, 20, 0, }, /* 168 */ + { 20, 5, 12, 0, 7, 20, 0, }, /* 169 */ + { 20, 5, 12, 0, -116, 20, 0, }, /* 170 */ + { 20, 9, 12, 38, -60, 20, 0, }, /* 171 */ + { 20, 5, 12, 59, -64, 20, 0, }, /* 172 */ + { 20, 25, 12, 0, 0, 20, 0, }, /* 173 */ + { 20, 9, 12, 0, -7, 20, 0, }, /* 174 */ + { 20, 9, 12, 0, -130, 20, 0, }, /* 175 */ + { 13, 9, 12, 0, 80, 13, 0, }, /* 176 */ + { 13, 9, 12, 0, 32, 13, 0, }, /* 177 */ + { 13, 9, 12, 63, 32, 13, 0, }, /* 178 */ + { 13, 9, 12, 67, 32, 13, 0, }, /* 179 */ + { 13, 9, 12, 71, 32, 13, 0, }, /* 180 */ + { 13, 9, 12, 75, 32, 13, 0, }, /* 181 */ + { 13, 9, 12, 79, 32, 13, 0, }, /* 182 */ + { 13, 9, 12, 84, 32, 13, 0, }, /* 183 */ + { 13, 5, 12, 0, -32, 13, 0, }, /* 184 */ + { 13, 5, 12, 63, -32, 13, 0, }, /* 185 */ + { 13, 5, 12, 67, -32, 13, 0, }, /* 186 */ + { 13, 5, 12, 71, -32, 13, 0, }, /* 187 */ + { 13, 5, 12, 75, -32, 13, 0, }, /* 188 */ + { 13, 5, 12, 79, -32, 13, 0, }, /* 189 */ + { 13, 5, 12, 84, -32, 13, 0, }, /* 190 */ + { 13, 5, 12, 0, -80, 13, 0, }, /* 191 */ + { 13, 9, 12, 0, 1, 13, 0, }, /* 192 */ + { 13, 5, 12, 0, -1, 13, 0, }, /* 193 */ + { 13, 9, 12, 88, 1, 13, 0, }, /* 194 */ + { 13, 5, 12, 88, -1, 13, 0, }, /* 195 */ + { 13, 26, 12, 0, 0, 13, 0, }, /* 196 */ + { 13, 12, 3, 0, 0, -34, 0, }, /* 197 */ + { 13, 12, 3, 0, 0, -28, 0, }, /* 198 */ + { 28, 12, 3, 0, 0, -31, 0, }, /* 199 */ + { 13, 11, 3, 0, 0, 13, 0, }, /* 200 */ + { 13, 9, 12, 0, 15, 13, 0, }, /* 201 */ + { 13, 5, 12, 0, -15, 13, 0, }, /* 202 */ + { 2, 9, 12, 0, 48, 2, 0, }, /* 203 */ + { 2, 6, 12, 0, 0, 2, 0, }, /* 204 */ + { 2, 21, 12, 0, 0, 2, 0, }, /* 205 */ + { 2, 5, 12, 0, 0, 2, 0, }, /* 206 */ + { 2, 5, 12, 0, -48, 2, 0, }, /* 207 */ + { 10, 21, 12, 0, 0, -13, 0, }, /* 208 */ + { 2, 17, 12, 0, 0, 2, 0, }, /* 209 */ + { 2, 26, 12, 0, 0, 2, 0, }, /* 210 */ + { 2, 23, 12, 0, 0, 2, 0, }, /* 211 */ + { 26, 12, 3, 0, 0, 26, 0, }, /* 212 */ + { 26, 17, 12, 0, 0, 26, 0, }, /* 213 */ + { 26, 21, 12, 0, 0, 26, 0, }, /* 214 */ + { 26, 7, 12, 0, 0, 26, 0, }, /* 215 */ + { 1, 1, 4, 0, 0, 1, 0, }, /* 216 */ + { 10, 1, 4, 0, 0, 10, 0, }, /* 217 */ + { 1, 25, 12, 0, 0, 1, 0, }, /* 218 */ + { 1, 21, 12, 0, 0, 1, 0, }, /* 219 */ + { 1, 23, 12, 0, 0, 1, 0, }, /* 220 */ + { 10, 21, 12, 0, 0, -105, 0, }, /* 221 */ + { 1, 26, 12, 0, 0, 1, 0, }, /* 222 */ + { 1, 12, 3, 0, 0, 1, 0, }, /* 223 */ + { 1, 1, 2, 0, 0, -73, 0, }, /* 224 */ + { 1, 7, 12, 0, 0, 1, 0, }, /* 225 */ + { 10, 6, 12, 0, 0, -145, 0, }, /* 226 */ + { 28, 12, 3, 0, 0, -7, 0, }, /* 227 */ + { 1, 13, 12, 0, 0, -10, 0, }, /* 228 */ + { 1, 21, 12, 0, 0, -4, 0, }, /* 229 */ + { 1, 6, 12, 0, 0, 1, 0, }, /* 230 */ + { 1, 13, 12, 0, 0, 1, 0, }, /* 231 */ + { 50, 21, 12, 0, 0, 50, 0, }, /* 232 */ + { 50, 1, 4, 0, 0, 50, 0, }, /* 233 */ + { 50, 7, 12, 0, 0, 50, 0, }, /* 234 */ + { 50, 12, 3, 0, 0, 50, 0, }, /* 235 */ + { 56, 7, 12, 0, 0, 56, 0, }, /* 236 */ + { 56, 12, 3, 0, 0, 56, 0, }, /* 237 */ + { 64, 13, 12, 0, 0, 64, 0, }, /* 238 */ + { 64, 7, 12, 0, 0, 64, 0, }, /* 239 */ + { 64, 12, 3, 0, 0, 64, 0, }, /* 240 */ + { 64, 6, 12, 0, 0, 64, 0, }, /* 241 */ + { 64, 26, 12, 0, 0, 64, 0, }, /* 242 */ + { 64, 21, 12, 0, 0, 64, 0, }, /* 243 */ + { 64, 23, 12, 0, 0, 64, 0, }, /* 244 */ + { 90, 7, 12, 0, 0, 90, 0, }, /* 245 */ + { 90, 12, 3, 0, 0, 90, 0, }, /* 246 */ + { 90, 6, 12, 0, 0, 90, 0, }, /* 247 */ + { 90, 21, 12, 0, 0, 90, 0, }, /* 248 */ + { 95, 7, 12, 0, 0, 95, 0, }, /* 249 */ + { 95, 12, 3, 0, 0, 95, 0, }, /* 250 */ + { 95, 21, 12, 0, 0, 95, 0, }, /* 251 */ + { 15, 12, 3, 0, 0, 15, 0, }, /* 252 */ + { 15, 10, 5, 0, 0, 15, 0, }, /* 253 */ + { 15, 7, 12, 0, 0, 15, 0, }, /* 254 */ + { 28, 12, 3, 0, 0, -188, 0, }, /* 255 */ + { 28, 12, 3, 0, 0, -175, 0, }, /* 256 */ + { 10, 21, 12, 0, 0, -231, 0, }, /* 257 */ + { 10, 21, 12, 0, 0, -252, 0, }, /* 258 */ + { 15, 13, 12, 0, 0, -120, 0, }, /* 259 */ + { 15, 21, 12, 0, 0, 15, 0, }, /* 260 */ + { 15, 6, 12, 0, 0, 15, 0, }, /* 261 */ + { 3, 7, 12, 0, 0, 3, 0, }, /* 262 */ + { 3, 12, 3, 0, 0, 3, 0, }, /* 263 */ + { 3, 10, 5, 0, 0, 3, 0, }, /* 264 */ + { 3, 10, 3, 0, 0, 3, 0, }, /* 265 */ + { 3, 13, 12, 0, 0, -77, 0, }, /* 266 */ + { 3, 23, 12, 0, 0, 3, 0, }, /* 267 */ + { 3, 15, 12, 0, 0, 3, 0, }, /* 268 */ + { 3, 26, 12, 0, 0, 3, 0, }, /* 269 */ + { 3, 21, 12, 0, 0, 3, 0, }, /* 270 */ + { 22, 12, 3, 0, 0, 22, 0, }, /* 271 */ + { 22, 10, 5, 0, 0, 22, 0, }, /* 272 */ + { 22, 7, 12, 0, 0, 22, 0, }, /* 273 */ + { 22, 13, 12, 0, 0, -58, 0, }, /* 274 */ + { 22, 21, 12, 0, 0, 22, 0, }, /* 275 */ + { 21, 12, 3, 0, 0, 21, 0, }, /* 276 */ + { 21, 10, 5, 0, 0, 21, 0, }, /* 277 */ + { 21, 7, 12, 0, 0, 21, 0, }, /* 278 */ + { 21, 13, 12, 0, 0, -55, 0, }, /* 279 */ + { 21, 21, 12, 0, 0, 21, 0, }, /* 280 */ + { 21, 23, 12, 0, 0, 21, 0, }, /* 281 */ + { 44, 12, 3, 0, 0, 44, 0, }, /* 282 */ + { 44, 10, 5, 0, 0, 44, 0, }, /* 283 */ + { 44, 7, 12, 0, 0, 44, 0, }, /* 284 */ + { 44, 10, 3, 0, 0, 44, 0, }, /* 285 */ + { 44, 13, 12, 0, 0, 44, 0, }, /* 286 */ + { 44, 26, 12, 0, 0, 44, 0, }, /* 287 */ + { 44, 15, 12, 0, 0, 44, 0, }, /* 288 */ + { 54, 12, 3, 0, 0, 54, 0, }, /* 289 */ + { 54, 7, 12, 0, 0, 54, 0, }, /* 290 */ + { 54, 10, 3, 0, 0, 54, 0, }, /* 291 */ + { 54, 10, 5, 0, 0, 54, 0, }, /* 292 */ + { 54, 13, 12, 0, 0, -52, 0, }, /* 293 */ + { 54, 15, 12, 0, 0, -52, 0, }, /* 294 */ + { 54, 26, 12, 0, 0, -52, 0, }, /* 295 */ + { 54, 26, 12, 0, 0, 54, 0, }, /* 296 */ + { 54, 23, 12, 0, 0, 54, 0, }, /* 297 */ + { 55, 12, 3, 0, 0, 55, 0, }, /* 298 */ + { 55, 10, 5, 0, 0, 55, 0, }, /* 299 */ + { 55, 7, 12, 0, 0, 55, 0, }, /* 300 */ + { 55, 13, 12, 0, 0, 55, 0, }, /* 301 */ + { 55, 21, 12, 0, 0, 55, 0, }, /* 302 */ + { 55, 15, 12, 0, 0, 55, 0, }, /* 303 */ + { 55, 26, 12, 0, 0, 55, 0, }, /* 304 */ + { 29, 7, 12, 0, 0, 29, 0, }, /* 305 */ + { 29, 12, 3, 0, 0, 29, 0, }, /* 306 */ + { 29, 10, 5, 0, 0, 29, 0, }, /* 307 */ + { 29, 21, 12, 0, 0, 29, 0, }, /* 308 */ + { 29, 10, 3, 0, 0, 29, 0, }, /* 309 */ + { 29, 13, 12, 0, 0, -64, 0, }, /* 310 */ + { 37, 12, 3, 0, 0, 37, 0, }, /* 311 */ + { 37, 10, 5, 0, 0, 37, 0, }, /* 312 */ + { 37, 7, 12, 0, 0, 37, 0, }, /* 313 */ + { 37, 10, 3, 0, 0, 37, 0, }, /* 314 */ + { 37, 7, 4, 0, 0, 37, 0, }, /* 315 */ + { 37, 26, 12, 0, 0, 37, 0, }, /* 316 */ + { 37, 15, 12, 0, 0, 37, 0, }, /* 317 */ + { 37, 13, 12, 0, 0, 37, 0, }, /* 318 */ + { 48, 10, 5, 0, 0, 48, 0, }, /* 319 */ + { 48, 7, 12, 0, 0, 48, 0, }, /* 320 */ + { 48, 12, 3, 0, 0, 48, 0, }, /* 321 */ + { 48, 10, 3, 0, 0, 48, 0, }, /* 322 */ + { 48, 13, 12, 0, 0, 48, 0, }, /* 323 */ + { 48, 21, 12, 0, 0, 48, 0, }, /* 324 */ + { 57, 7, 12, 0, 0, 57, 0, }, /* 325 */ + { 57, 12, 3, 0, 0, 57, 0, }, /* 326 */ + { 57, 7, 5, 0, 0, 57, 0, }, /* 327 */ + { 57, 6, 12, 0, 0, 57, 0, }, /* 328 */ + { 57, 21, 12, 0, 0, 57, 0, }, /* 329 */ + { 57, 13, 12, 0, 0, 57, 0, }, /* 330 */ + { 33, 7, 12, 0, 0, 33, 0, }, /* 331 */ + { 33, 12, 3, 0, 0, 33, 0, }, /* 332 */ + { 33, 7, 5, 0, 0, 33, 0, }, /* 333 */ + { 33, 6, 12, 0, 0, 33, 0, }, /* 334 */ + { 33, 13, 12, 0, 0, 33, 0, }, /* 335 */ + { 58, 7, 12, 0, 0, 58, 0, }, /* 336 */ + { 58, 26, 12, 0, 0, 58, 0, }, /* 337 */ + { 58, 21, 12, 0, 0, 58, 0, }, /* 338 */ + { 58, 12, 3, 0, 0, 58, 0, }, /* 339 */ + { 58, 13, 12, 0, 0, 58, 0, }, /* 340 */ + { 58, 15, 12, 0, 0, 58, 0, }, /* 341 */ + { 58, 22, 12, 0, 0, 58, 0, }, /* 342 */ + { 58, 18, 12, 0, 0, 58, 0, }, /* 343 */ + { 58, 10, 5, 0, 0, 58, 0, }, /* 344 */ + { 39, 7, 12, 0, 0, 39, 0, }, /* 345 */ + { 39, 10, 12, 0, 0, 39, 0, }, /* 346 */ + { 39, 12, 3, 0, 0, 39, 0, }, /* 347 */ + { 39, 10, 5, 0, 0, 39, 0, }, /* 348 */ + { 39, 13, 12, 0, 0, -81, 0, }, /* 349 */ + { 39, 21, 12, 0, 0, 39, 0, }, /* 350 */ + { 39, 13, 12, 0, 0, 39, 0, }, /* 351 */ + { 39, 26, 12, 0, 0, 39, 0, }, /* 352 */ + { 17, 9, 12, 0, 7264, 17, 0, }, /* 353 */ + { 17, 5, 12, 0, 3008, 17, 0, }, /* 354 */ + { 10, 21, 12, 0, 0, -49, 0, }, /* 355 */ + { 17, 6, 12, 0, 0, 17, 0, }, /* 356 */ + { 24, 7, 6, 0, 0, 24, 0, }, /* 357 */ + { 24, 7, 7, 0, 0, 24, 0, }, /* 358 */ + { 24, 7, 8, 0, 0, 24, 0, }, /* 359 */ + { 16, 7, 12, 0, 0, 16, 0, }, /* 360 */ + { 16, 12, 3, 0, 0, 16, 0, }, /* 361 */ + { 16, 21, 12, 0, 0, 16, 0, }, /* 362 */ + { 16, 15, 12, 0, 0, 16, 0, }, /* 363 */ + { 16, 26, 12, 0, 0, 16, 0, }, /* 364 */ + { 9, 9, 12, 0, 38864, 9, 0, }, /* 365 */ + { 9, 9, 12, 0, 8, 9, 0, }, /* 366 */ + { 9, 5, 12, 0, -8, 9, 0, }, /* 367 */ + { 8, 17, 12, 0, 0, 8, 0, }, /* 368 */ + { 8, 7, 12, 0, 0, 8, 0, }, /* 369 */ + { 8, 26, 12, 0, 0, 8, 0, }, /* 370 */ + { 8, 21, 12, 0, 0, 8, 0, }, /* 371 */ + { 41, 29, 12, 0, 0, 41, 0, }, /* 372 */ + { 41, 7, 12, 0, 0, 41, 0, }, /* 373 */ + { 41, 22, 12, 0, 0, 41, 0, }, /* 374 */ + { 41, 18, 12, 0, 0, 41, 0, }, /* 375 */ + { 46, 7, 12, 0, 0, 46, 0, }, /* 376 */ + { 46, 14, 12, 0, 0, 46, 0, }, /* 377 */ + { 51, 7, 12, 0, 0, 51, 0, }, /* 378 */ + { 51, 12, 3, 0, 0, 51, 0, }, /* 379 */ + { 25, 7, 12, 0, 0, 25, 0, }, /* 380 */ + { 25, 12, 3, 0, 0, 25, 0, }, /* 381 */ + { 10, 21, 12, 0, 0, -115, 0, }, /* 382 */ + { 7, 7, 12, 0, 0, 7, 0, }, /* 383 */ + { 7, 12, 3, 0, 0, 7, 0, }, /* 384 */ + { 52, 7, 12, 0, 0, 52, 0, }, /* 385 */ + { 52, 12, 3, 0, 0, 52, 0, }, /* 386 */ + { 32, 7, 12, 0, 0, 32, 0, }, /* 387 */ + { 32, 12, 3, 0, 0, 32, 0, }, /* 388 */ + { 32, 10, 5, 0, 0, 32, 0, }, /* 389 */ + { 32, 21, 12, 0, 0, 32, 0, }, /* 390 */ + { 32, 6, 12, 0, 0, 32, 0, }, /* 391 */ + { 32, 23, 12, 0, 0, 32, 0, }, /* 392 */ + { 32, 13, 12, 0, 0, 32, 0, }, /* 393 */ + { 32, 15, 12, 0, 0, 32, 0, }, /* 394 */ + { 38, 21, 12, 0, 0, 38, 0, }, /* 395 */ + { 10, 21, 12, 0, 0, -70, 0, }, /* 396 */ + { 38, 17, 12, 0, 0, 38, 0, }, /* 397 */ + { 38, 12, 3, 0, 0, 38, 0, }, /* 398 */ + { 38, 1, 2, 0, 0, 38, 0, }, /* 399 */ + { 38, 13, 12, 0, 0, 38, 0, }, /* 400 */ + { 38, 7, 12, 0, 0, 38, 0, }, /* 401 */ + { 38, 6, 12, 0, 0, 38, 0, }, /* 402 */ + { 35, 7, 12, 0, 0, 35, 0, }, /* 403 */ + { 35, 12, 3, 0, 0, 35, 0, }, /* 404 */ + { 35, 10, 5, 0, 0, 35, 0, }, /* 405 */ + { 35, 26, 12, 0, 0, 35, 0, }, /* 406 */ + { 35, 21, 12, 0, 0, 35, 0, }, /* 407 */ + { 35, 13, 12, 0, 0, 35, 0, }, /* 408 */ + { 53, 7, 12, 0, 0, 53, 0, }, /* 409 */ + { 40, 7, 12, 0, 0, 40, 0, }, /* 410 */ + { 40, 13, 12, 0, 0, 40, 0, }, /* 411 */ + { 40, 15, 12, 0, 0, 40, 0, }, /* 412 */ + { 40, 26, 12, 0, 0, 40, 0, }, /* 413 */ + { 32, 26, 12, 0, 0, 32, 0, }, /* 414 */ + { 6, 7, 12, 0, 0, 6, 0, }, /* 415 */ + { 6, 12, 3, 0, 0, 6, 0, }, /* 416 */ + { 6, 10, 5, 0, 0, 6, 0, }, /* 417 */ + { 6, 21, 12, 0, 0, 6, 0, }, /* 418 */ + { 91, 7, 12, 0, 0, 91, 0, }, /* 419 */ + { 91, 10, 5, 0, 0, 91, 0, }, /* 420 */ + { 91, 12, 3, 0, 0, 91, 0, }, /* 421 */ + { 91, 10, 12, 0, 0, 91, 0, }, /* 422 */ + { 91, 13, 12, 0, 0, 91, 0, }, /* 423 */ + { 91, 21, 12, 0, 0, 91, 0, }, /* 424 */ + { 91, 6, 12, 0, 0, 91, 0, }, /* 425 */ + { 28, 11, 3, 0, 0, 28, 0, }, /* 426 */ + { 62, 12, 3, 0, 0, 62, 0, }, /* 427 */ + { 62, 10, 5, 0, 0, 62, 0, }, /* 428 */ + { 62, 7, 12, 0, 0, 62, 0, }, /* 429 */ + { 62, 10, 3, 0, 0, 62, 0, }, /* 430 */ + { 62, 13, 12, 0, 0, 62, 0, }, /* 431 */ + { 62, 21, 12, 0, 0, 62, 0, }, /* 432 */ + { 62, 26, 12, 0, 0, 62, 0, }, /* 433 */ + { 76, 12, 3, 0, 0, 76, 0, }, /* 434 */ + { 76, 10, 5, 0, 0, 76, 0, }, /* 435 */ + { 76, 7, 12, 0, 0, 76, 0, }, /* 436 */ + { 76, 13, 12, 0, 0, 76, 0, }, /* 437 */ + { 93, 7, 12, 0, 0, 93, 0, }, /* 438 */ + { 93, 12, 3, 0, 0, 93, 0, }, /* 439 */ + { 93, 10, 5, 0, 0, 93, 0, }, /* 440 */ + { 93, 21, 12, 0, 0, 93, 0, }, /* 441 */ + { 70, 7, 12, 0, 0, 70, 0, }, /* 442 */ + { 70, 10, 5, 0, 0, 70, 0, }, /* 443 */ + { 70, 12, 3, 0, 0, 70, 0, }, /* 444 */ + { 70, 21, 12, 0, 0, 70, 0, }, /* 445 */ + { 70, 13, 12, 0, 0, 70, 0, }, /* 446 */ + { 73, 13, 12, 0, 0, 73, 0, }, /* 447 */ + { 73, 7, 12, 0, 0, 73, 0, }, /* 448 */ + { 73, 6, 12, 0, 0, 73, 0, }, /* 449 */ + { 73, 21, 12, 0, 0, 73, 0, }, /* 450 */ + { 13, 5, 12, 63, -6222, 13, 0, }, /* 451 */ + { 13, 5, 12, 67, -6221, 13, 0, }, /* 452 */ + { 13, 5, 12, 71, -6212, 13, 0, }, /* 453 */ + { 13, 5, 12, 75, -6210, 13, 0, }, /* 454 */ + { 13, 5, 12, 79, -6210, 13, 0, }, /* 455 */ + { 13, 5, 12, 79, -6211, 13, 0, }, /* 456 */ + { 13, 5, 12, 84, -6204, 13, 0, }, /* 457 */ + { 13, 5, 12, 88, -6180, 13, 0, }, /* 458 */ + { 13, 5, 12, 108, 35267, 13, 0, }, /* 459 */ + { 17, 9, 12, 0, -3008, 17, 0, }, /* 460 */ + { 76, 21, 12, 0, 0, 76, 0, }, /* 461 */ + { 28, 12, 3, 0, 0, -110, 0, }, /* 462 */ + { 28, 12, 3, 0, 0, 15, 0, }, /* 463 */ + { 10, 21, 12, 0, 0, -37, 0, }, /* 464 */ + { 28, 12, 3, 0, 0, -16, 0, }, /* 465 */ + { 28, 12, 3, 0, 0, -43, 0, }, /* 466 */ + { 28, 12, 3, 0, 0, -138, 0, }, /* 467 */ + { 10, 10, 5, 0, 0, -16, 0, }, /* 468 */ + { 10, 7, 12, 0, 0, -40, 0, }, /* 469 */ + { 10, 7, 12, 0, 0, -16, 0, }, /* 470 */ + { 10, 7, 12, 0, 0, 15, 0, }, /* 471 */ + { 10, 7, 12, 0, 0, -154, 0, }, /* 472 */ + { 10, 7, 12, 0, 0, -37, 0, }, /* 473 */ + { 28, 12, 3, 0, 0, -89, 0, }, /* 474 */ + { 10, 10, 5, 0, 0, 3, 0, }, /* 475 */ + { 28, 12, 3, 0, 0, -37, 0, }, /* 476 */ + { 10, 7, 12, 0, 0, 150, 0, }, /* 477 */ + { 13, 5, 12, 0, 0, 13, 0, }, /* 478 */ + { 13, 6, 12, 0, 0, 13, 0, }, /* 479 */ + { 34, 5, 12, 0, 35332, 34, 0, }, /* 480 */ + { 34, 5, 12, 0, 3814, 34, 0, }, /* 481 */ + { 34, 5, 12, 0, 35384, 34, 0, }, /* 482 */ + { 34, 9, 12, 92, 1, 34, 0, }, /* 483 */ + { 34, 5, 12, 92, -1, 34, 0, }, /* 484 */ + { 34, 5, 12, 92, -58, 34, 0, }, /* 485 */ + { 34, 9, 12, 0, -7615, 34, 0, }, /* 486 */ + { 20, 5, 12, 0, 8, 20, 0, }, /* 487 */ + { 20, 9, 12, 0, -8, 20, 0, }, /* 488 */ + { 20, 5, 12, 0, 74, 20, 0, }, /* 489 */ + { 20, 5, 12, 0, 86, 20, 0, }, /* 490 */ + { 20, 5, 12, 0, 100, 20, 0, }, /* 491 */ + { 20, 5, 12, 0, 128, 20, 0, }, /* 492 */ + { 20, 5, 12, 0, 112, 20, 0, }, /* 493 */ + { 20, 5, 12, 0, 126, 20, 0, }, /* 494 */ + { 20, 8, 12, 0, -8, 20, 0, }, /* 495 */ + { 20, 5, 12, 0, 9, 20, 0, }, /* 496 */ + { 20, 9, 12, 0, -74, 20, 0, }, /* 497 */ + { 20, 8, 12, 0, -9, 20, 0, }, /* 498 */ + { 20, 5, 12, 21, -7173, 20, 0, }, /* 499 */ + { 20, 9, 12, 0, -86, 20, 0, }, /* 500 */ + { 20, 9, 12, 0, -100, 20, 0, }, /* 501 */ + { 20, 9, 12, 0, -112, 20, 0, }, /* 502 */ + { 20, 9, 12, 0, -128, 20, 0, }, /* 503 */ + { 20, 9, 12, 0, -126, 20, 0, }, /* 504 */ + { 28, 1, 3, 0, 0, 28, 0, }, /* 505 */ + { 28, 1, 13, 0, 0, 28, 0, }, /* 506 */ + { 10, 27, 2, 0, 0, 10, 0, }, /* 507 */ + { 10, 28, 2, 0, 0, 10, 0, }, /* 508 */ + { 10, 29, 12, 0, 0, -67, 0, }, /* 509 */ + { 10, 21, 14, 0, 0, 10, 0, }, /* 510 */ + { 0, 2, 2, 0, 0, 0, 0, }, /* 511 */ + { 28, 12, 3, 0, 0, -93, 0, }, /* 512 */ + { 10, 9, 12, 0, 0, 10, 0, }, /* 513 */ + { 10, 5, 12, 0, 0, 10, 0, }, /* 514 */ + { 20, 9, 12, 96, -7517, 20, 0, }, /* 515 */ + { 34, 9, 12, 100, -8383, 34, 0, }, /* 516 */ + { 34, 9, 12, 104, -8262, 34, 0, }, /* 517 */ + { 34, 9, 12, 0, 28, 34, 0, }, /* 518 */ + { 10, 7, 12, 0, 0, 10, 0, }, /* 519 */ + { 10, 5, 14, 0, 0, 10, 0, }, /* 520 */ + { 34, 5, 12, 0, -28, 34, 0, }, /* 521 */ + { 34, 14, 12, 0, 16, 34, 0, }, /* 522 */ + { 34, 14, 12, 0, -16, 34, 0, }, /* 523 */ + { 34, 14, 12, 0, 0, 34, 0, }, /* 524 */ + { 10, 25, 14, 0, 0, 10, 0, }, /* 525 */ + { 10, 26, 12, 0, 26, 10, 0, }, /* 526 */ + { 10, 26, 14, 0, 26, 10, 0, }, /* 527 */ + { 10, 26, 12, 0, -26, 10, 0, }, /* 528 */ + { 5, 26, 12, 0, 0, 5, 0, }, /* 529 */ + { 18, 9, 12, 0, 48, 18, 0, }, /* 530 */ + { 18, 5, 12, 0, -48, 18, 0, }, /* 531 */ + { 34, 9, 12, 0, -10743, 34, 0, }, /* 532 */ + { 34, 9, 12, 0, -3814, 34, 0, }, /* 533 */ + { 34, 9, 12, 0, -10727, 34, 0, }, /* 534 */ + { 34, 5, 12, 0, -10795, 34, 0, }, /* 535 */ + { 34, 5, 12, 0, -10792, 34, 0, }, /* 536 */ + { 34, 9, 12, 0, -10780, 34, 0, }, /* 537 */ + { 34, 9, 12, 0, -10749, 34, 0, }, /* 538 */ + { 34, 9, 12, 0, -10783, 34, 0, }, /* 539 */ + { 34, 9, 12, 0, -10782, 34, 0, }, /* 540 */ + { 34, 9, 12, 0, -10815, 34, 0, }, /* 541 */ + { 11, 5, 12, 0, 0, 11, 0, }, /* 542 */ + { 11, 26, 12, 0, 0, 11, 0, }, /* 543 */ + { 11, 12, 3, 0, 0, 11, 0, }, /* 544 */ + { 11, 21, 12, 0, 0, 11, 0, }, /* 545 */ + { 11, 15, 12, 0, 0, 11, 0, }, /* 546 */ + { 17, 5, 12, 0, -7264, 17, 0, }, /* 547 */ + { 59, 7, 12, 0, 0, 59, 0, }, /* 548 */ + { 59, 6, 12, 0, 0, 59, 0, }, /* 549 */ + { 59, 21, 12, 0, 0, 59, 0, }, /* 550 */ + { 59, 12, 3, 0, 0, 59, 0, }, /* 551 */ + { 13, 12, 3, 0, 0, 13, 0, }, /* 552 */ + { 10, 21, 12, 0, 0, -28, 0, }, /* 553 */ + { 23, 26, 12, 0, 0, 23, 0, }, /* 554 */ + { 10, 21, 12, 0, 0, -131, 0, }, /* 555 */ + { 10, 21, 12, 0, 0, -125, 0, }, /* 556 */ + { 23, 6, 12, 0, 0, 23, 0, }, /* 557 */ + { 10, 7, 12, 0, 0, 23, 0, }, /* 558 */ + { 23, 14, 12, 0, 0, 23, 0, }, /* 559 */ + { 10, 22, 12, 0, 0, -131, 0, }, /* 560 */ + { 10, 18, 12, 0, 0, -131, 0, }, /* 561 */ + { 10, 26, 12, 0, 0, -125, 0, }, /* 562 */ + { 10, 17, 12, 0, 0, -125, 0, }, /* 563 */ + { 10, 22, 12, 0, 0, -125, 0, }, /* 564 */ + { 10, 18, 12, 0, 0, -125, 0, }, /* 565 */ + { 28, 12, 3, 0, 0, -19, 0, }, /* 566 */ + { 24, 10, 3, 0, 0, 24, 0, }, /* 567 */ + { 10, 17, 14, 0, 0, -125, 0, }, /* 568 */ + { 10, 6, 12, 0, 0, -61, 0, }, /* 569 */ + { 10, 7, 12, 0, 0, -97, 0, }, /* 570 */ + { 10, 21, 14, 0, 0, -97, 0, }, /* 571 */ + { 10, 26, 12, 0, 0, 23, 0, }, /* 572 */ + { 27, 7, 12, 0, 0, 27, 0, }, /* 573 */ + { 28, 12, 3, 0, 0, -61, 0, }, /* 574 */ + { 10, 24, 12, 0, 0, -61, 0, }, /* 575 */ + { 27, 6, 12, 0, 0, 27, 0, }, /* 576 */ + { 10, 17, 12, 0, 0, -61, 0, }, /* 577 */ + { 30, 7, 12, 0, 0, 30, 0, }, /* 578 */ + { 30, 6, 12, 0, 0, 30, 0, }, /* 579 */ + { 4, 7, 12, 0, 0, 4, 0, }, /* 580 */ + { 24, 7, 12, 0, 0, 24, 0, }, /* 581 */ + { 10, 15, 12, 0, 0, 23, 0, }, /* 582 */ + { 24, 26, 12, 0, 0, 24, 0, }, /* 583 */ + { 10, 26, 14, 0, 0, 23, 0, }, /* 584 */ + { 30, 26, 12, 0, 0, 30, 0, }, /* 585 */ + { 23, 7, 12, 0, 0, 23, 0, }, /* 586 */ + { 61, 7, 12, 0, 0, 61, 0, }, /* 587 */ + { 61, 6, 12, 0, 0, 61, 0, }, /* 588 */ + { 61, 26, 12, 0, 0, 61, 0, }, /* 589 */ + { 86, 7, 12, 0, 0, 86, 0, }, /* 590 */ + { 86, 6, 12, 0, 0, 86, 0, }, /* 591 */ + { 86, 21, 12, 0, 0, 86, 0, }, /* 592 */ + { 77, 7, 12, 0, 0, 77, 0, }, /* 593 */ + { 77, 6, 12, 0, 0, 77, 0, }, /* 594 */ + { 77, 21, 12, 0, 0, 77, 0, }, /* 595 */ + { 77, 13, 12, 0, 0, 77, 0, }, /* 596 */ + { 13, 9, 12, 108, 1, 13, 0, }, /* 597 */ + { 13, 5, 12, 108, -35267, 13, 0, }, /* 598 */ + { 13, 7, 12, 0, 0, 13, 0, }, /* 599 */ + { 13, 21, 12, 0, 0, 13, 0, }, /* 600 */ + { 79, 7, 12, 0, 0, 79, 0, }, /* 601 */ + { 79, 14, 12, 0, 0, 79, 0, }, /* 602 */ + { 79, 12, 3, 0, 0, 79, 0, }, /* 603 */ + { 79, 21, 12, 0, 0, 79, 0, }, /* 604 */ + { 34, 9, 12, 0, -35332, 34, 0, }, /* 605 */ + { 34, 9, 12, 0, -42280, 34, 0, }, /* 606 */ + { 34, 5, 12, 0, 48, 34, 0, }, /* 607 */ + { 34, 9, 12, 0, -42308, 34, 0, }, /* 608 */ + { 34, 9, 12, 0, -42319, 34, 0, }, /* 609 */ + { 34, 9, 12, 0, -42315, 34, 0, }, /* 610 */ + { 34, 9, 12, 0, -42305, 34, 0, }, /* 611 */ + { 34, 9, 12, 0, -42258, 34, 0, }, /* 612 */ + { 34, 9, 12, 0, -42282, 34, 0, }, /* 613 */ + { 34, 9, 12, 0, -42261, 34, 0, }, /* 614 */ + { 34, 9, 12, 0, 928, 34, 0, }, /* 615 */ + { 34, 9, 12, 0, -48, 34, 0, }, /* 616 */ + { 34, 9, 12, 0, -42307, 34, 0, }, /* 617 */ + { 34, 9, 12, 0, -35384, 34, 0, }, /* 618 */ + { 49, 7, 12, 0, 0, 49, 0, }, /* 619 */ + { 49, 12, 3, 0, 0, 49, 0, }, /* 620 */ + { 49, 10, 5, 0, 0, 49, 0, }, /* 621 */ + { 49, 26, 12, 0, 0, 49, 0, }, /* 622 */ + { 10, 15, 12, 0, 0, -216, 0, }, /* 623 */ + { 10, 15, 12, 0, 0, -202, 0, }, /* 624 */ + { 10, 26, 12, 0, 0, -163, 0, }, /* 625 */ + { 10, 23, 12, 0, 0, -163, 0, }, /* 626 */ + { 65, 7, 12, 0, 0, 65, 0, }, /* 627 */ + { 65, 21, 12, 0, 0, 65, 0, }, /* 628 */ + { 75, 10, 5, 0, 0, 75, 0, }, /* 629 */ + { 75, 7, 12, 0, 0, 75, 0, }, /* 630 */ + { 75, 12, 3, 0, 0, 75, 0, }, /* 631 */ + { 75, 21, 12, 0, 0, 75, 0, }, /* 632 */ + { 75, 13, 12, 0, 0, 75, 0, }, /* 633 */ + { 15, 12, 3, 0, 0, -16, 0, }, /* 634 */ + { 15, 7, 12, 0, 0, -46, 0, }, /* 635 */ + { 69, 13, 12, 0, 0, 69, 0, }, /* 636 */ + { 69, 7, 12, 0, 0, 69, 0, }, /* 637 */ + { 69, 12, 3, 0, 0, 69, 0, }, /* 638 */ + { 10, 21, 12, 0, 0, -101, 0, }, /* 639 */ + { 69, 21, 12, 0, 0, 69, 0, }, /* 640 */ + { 74, 7, 12, 0, 0, 74, 0, }, /* 641 */ + { 74, 12, 3, 0, 0, 74, 0, }, /* 642 */ + { 74, 10, 5, 0, 0, 74, 0, }, /* 643 */ + { 74, 21, 12, 0, 0, 74, 0, }, /* 644 */ + { 84, 12, 3, 0, 0, 84, 0, }, /* 645 */ + { 84, 10, 5, 0, 0, 84, 0, }, /* 646 */ + { 84, 7, 12, 0, 0, 84, 0, }, /* 647 */ + { 84, 21, 12, 0, 0, 84, 0, }, /* 648 */ + { 10, 6, 12, 0, 0, -22, 0, }, /* 649 */ + { 84, 13, 12, 0, 0, 84, 0, }, /* 650 */ + { 39, 6, 12, 0, 0, 39, 0, }, /* 651 */ + { 68, 7, 12, 0, 0, 68, 0, }, /* 652 */ + { 68, 12, 3, 0, 0, 68, 0, }, /* 653 */ + { 68, 10, 5, 0, 0, 68, 0, }, /* 654 */ + { 68, 13, 12, 0, 0, 68, 0, }, /* 655 */ + { 68, 21, 12, 0, 0, 68, 0, }, /* 656 */ + { 92, 7, 12, 0, 0, 92, 0, }, /* 657 */ + { 92, 12, 3, 0, 0, 92, 0, }, /* 658 */ + { 92, 6, 12, 0, 0, 92, 0, }, /* 659 */ + { 92, 21, 12, 0, 0, 92, 0, }, /* 660 */ + { 87, 7, 12, 0, 0, 87, 0, }, /* 661 */ + { 87, 10, 5, 0, 0, 87, 0, }, /* 662 */ + { 87, 12, 3, 0, 0, 87, 0, }, /* 663 */ + { 87, 21, 12, 0, 0, 87, 0, }, /* 664 */ + { 87, 6, 12, 0, 0, 87, 0, }, /* 665 */ + { 34, 5, 12, 0, -928, 34, 0, }, /* 666 */ + { 9, 5, 12, 0, -38864, 9, 0, }, /* 667 */ + { 87, 13, 12, 0, 0, 87, 0, }, /* 668 */ + { 24, 7, 9, 0, 0, 24, 0, }, /* 669 */ + { 24, 7, 10, 0, 0, 24, 0, }, /* 670 */ + { 0, 4, 12, 0, 0, 0, 0, }, /* 671 */ + { 0, 3, 12, 0, 0, 0, 0, }, /* 672 */ + { 26, 25, 12, 0, 0, 26, 0, }, /* 673 */ + { 1, 24, 12, 0, 0, 1, 0, }, /* 674 */ + { 1, 7, 12, 0, 0, -10, 0, }, /* 675 */ + { 1, 26, 12, 0, 0, -10, 0, }, /* 676 */ + { 10, 6, 3, 0, 0, -61, 0, }, /* 677 */ + { 36, 7, 12, 0, 0, 36, 0, }, /* 678 */ + { 10, 21, 12, 0, 0, -25, 0, }, /* 679 */ + { 10, 15, 12, 0, 0, -85, 0, }, /* 680 */ + { 10, 26, 12, 0, 0, -25, 0, }, /* 681 */ + { 20, 14, 12, 0, 0, 20, 0, }, /* 682 */ + { 20, 15, 12, 0, 0, 20, 0, }, /* 683 */ + { 20, 26, 12, 0, 0, 20, 0, }, /* 684 */ + { 71, 7, 12, 0, 0, 71, 0, }, /* 685 */ + { 67, 7, 12, 0, 0, 67, 0, }, /* 686 */ + { 28, 12, 3, 0, 0, -1, 0, }, /* 687 */ + { 10, 15, 12, 0, 0, -1, 0, }, /* 688 */ + { 42, 7, 12, 0, 0, 42, 0, }, /* 689 */ + { 42, 15, 12, 0, 0, 42, 0, }, /* 690 */ + { 19, 7, 12, 0, 0, 19, 0, }, /* 691 */ + { 19, 14, 12, 0, 0, 19, 0, }, /* 692 */ + { 118, 7, 12, 0, 0, 118, 0, }, /* 693 */ + { 118, 12, 3, 0, 0, 118, 0, }, /* 694 */ + { 60, 7, 12, 0, 0, 60, 0, }, /* 695 */ + { 60, 21, 12, 0, 0, 60, 0, }, /* 696 */ + { 43, 7, 12, 0, 0, 43, 0, }, /* 697 */ + { 43, 21, 12, 0, 0, 43, 0, }, /* 698 */ + { 43, 14, 12, 0, 0, 43, 0, }, /* 699 */ + { 14, 9, 12, 0, 40, 14, 0, }, /* 700 */ + { 14, 5, 12, 0, -40, 14, 0, }, /* 701 */ + { 47, 7, 12, 0, 0, 47, 0, }, /* 702 */ + { 45, 7, 12, 0, 0, 45, 0, }, /* 703 */ + { 45, 13, 12, 0, 0, 45, 0, }, /* 704 */ + { 136, 9, 12, 0, 40, 136, 0, }, /* 705 */ + { 136, 5, 12, 0, -40, 136, 0, }, /* 706 */ + { 106, 7, 12, 0, 0, 106, 0, }, /* 707 */ + { 104, 7, 12, 0, 0, 104, 0, }, /* 708 */ + { 104, 21, 12, 0, 0, 104, 0, }, /* 709 */ + { 110, 7, 12, 0, 0, 110, 0, }, /* 710 */ + { 12, 7, 12, 0, 0, 12, 0, }, /* 711 */ + { 81, 7, 12, 0, 0, 81, 0, }, /* 712 */ + { 81, 21, 12, 0, 0, 81, 0, }, /* 713 */ + { 81, 15, 12, 0, 0, 81, 0, }, /* 714 */ + { 120, 7, 12, 0, 0, 120, 0, }, /* 715 */ + { 120, 26, 12, 0, 0, 120, 0, }, /* 716 */ + { 120, 15, 12, 0, 0, 120, 0, }, /* 717 */ + { 116, 7, 12, 0, 0, 116, 0, }, /* 718 */ + { 116, 15, 12, 0, 0, 116, 0, }, /* 719 */ + { 128, 7, 12, 0, 0, 128, 0, }, /* 720 */ + { 128, 15, 12, 0, 0, 128, 0, }, /* 721 */ + { 66, 7, 12, 0, 0, 66, 0, }, /* 722 */ + { 66, 15, 12, 0, 0, 66, 0, }, /* 723 */ + { 66, 21, 12, 0, 0, 66, 0, }, /* 724 */ + { 72, 7, 12, 0, 0, 72, 0, }, /* 725 */ + { 72, 21, 12, 0, 0, 72, 0, }, /* 726 */ + { 98, 7, 12, 0, 0, 98, 0, }, /* 727 */ + { 97, 7, 12, 0, 0, 97, 0, }, /* 728 */ + { 97, 15, 12, 0, 0, 97, 0, }, /* 729 */ + { 31, 7, 12, 0, 0, 31, 0, }, /* 730 */ + { 31, 12, 3, 0, 0, 31, 0, }, /* 731 */ + { 31, 15, 12, 0, 0, 31, 0, }, /* 732 */ + { 31, 21, 12, 0, 0, 31, 0, }, /* 733 */ + { 88, 7, 12, 0, 0, 88, 0, }, /* 734 */ + { 88, 15, 12, 0, 0, 88, 0, }, /* 735 */ + { 88, 21, 12, 0, 0, 88, 0, }, /* 736 */ + { 117, 7, 12, 0, 0, 117, 0, }, /* 737 */ + { 117, 15, 12, 0, 0, 117, 0, }, /* 738 */ + { 112, 7, 12, 0, 0, 112, 0, }, /* 739 */ + { 112, 26, 12, 0, 0, 112, 0, }, /* 740 */ + { 112, 12, 3, 0, 0, 112, 0, }, /* 741 */ + { 112, 15, 12, 0, 0, 112, 0, }, /* 742 */ + { 112, 21, 12, 0, 0, 112, 0, }, /* 743 */ + { 78, 7, 12, 0, 0, 78, 0, }, /* 744 */ + { 78, 21, 12, 0, 0, 78, 0, }, /* 745 */ + { 83, 7, 12, 0, 0, 83, 0, }, /* 746 */ + { 83, 15, 12, 0, 0, 83, 0, }, /* 747 */ + { 82, 7, 12, 0, 0, 82, 0, }, /* 748 */ + { 82, 15, 12, 0, 0, 82, 0, }, /* 749 */ + { 121, 7, 12, 0, 0, 121, 0, }, /* 750 */ + { 121, 21, 12, 0, 0, 121, 0, }, /* 751 */ + { 121, 15, 12, 0, 0, 121, 0, }, /* 752 */ + { 89, 7, 12, 0, 0, 89, 0, }, /* 753 */ + { 130, 9, 12, 0, 64, 130, 0, }, /* 754 */ + { 130, 5, 12, 0, -64, 130, 0, }, /* 755 */ + { 130, 15, 12, 0, 0, 130, 0, }, /* 756 */ + { 144, 7, 12, 0, 0, 144, 0, }, /* 757 */ + { 144, 12, 3, 0, 0, 144, 0, }, /* 758 */ + { 144, 13, 12, 0, 0, 144, 0, }, /* 759 */ + { 1, 15, 12, 0, 0, 1, 0, }, /* 760 */ + { 147, 7, 12, 0, 0, 147, 0, }, /* 761 */ + { 147, 15, 12, 0, 0, 147, 0, }, /* 762 */ + { 148, 7, 12, 0, 0, 148, 0, }, /* 763 */ + { 148, 12, 3, 0, 0, 148, 0, }, /* 764 */ + { 148, 15, 12, 0, 0, 148, 0, }, /* 765 */ + { 148, 21, 12, 0, 0, 148, 0, }, /* 766 */ + { 149, 7, 12, 0, 0, 149, 0, }, /* 767 */ + { 94, 10, 5, 0, 0, 94, 0, }, /* 768 */ + { 94, 12, 3, 0, 0, 94, 0, }, /* 769 */ + { 94, 7, 12, 0, 0, 94, 0, }, /* 770 */ + { 94, 21, 12, 0, 0, 94, 0, }, /* 771 */ + { 94, 15, 12, 0, 0, 94, 0, }, /* 772 */ + { 94, 13, 12, 0, 0, 94, 0, }, /* 773 */ + { 85, 12, 3, 0, 0, 85, 0, }, /* 774 */ + { 85, 10, 5, 0, 0, 85, 0, }, /* 775 */ + { 85, 7, 12, 0, 0, 85, 0, }, /* 776 */ + { 85, 21, 12, 0, 0, 85, 0, }, /* 777 */ + { 85, 1, 4, 0, 0, 85, 0, }, /* 778 */ + { 101, 7, 12, 0, 0, 101, 0, }, /* 779 */ + { 101, 13, 12, 0, 0, 101, 0, }, /* 780 */ + { 96, 12, 3, 0, 0, 96, 0, }, /* 781 */ + { 96, 7, 12, 0, 0, 96, 0, }, /* 782 */ + { 96, 10, 5, 0, 0, 96, 0, }, /* 783 */ + { 96, 13, 12, 0, 0, 96, 0, }, /* 784 */ + { 96, 21, 12, 0, 0, 96, 0, }, /* 785 */ + { 111, 7, 12, 0, 0, 111, 0, }, /* 786 */ + { 111, 12, 3, 0, 0, 111, 0, }, /* 787 */ + { 111, 21, 12, 0, 0, 111, 0, }, /* 788 */ + { 100, 12, 3, 0, 0, 100, 0, }, /* 789 */ + { 100, 10, 5, 0, 0, 100, 0, }, /* 790 */ + { 100, 7, 12, 0, 0, 100, 0, }, /* 791 */ + { 100, 7, 4, 0, 0, 100, 0, }, /* 792 */ + { 100, 21, 12, 0, 0, 100, 0, }, /* 793 */ + { 100, 13, 12, 0, 0, 100, 0, }, /* 794 */ + { 48, 15, 12, 0, 0, 48, 0, }, /* 795 */ + { 108, 7, 12, 0, 0, 108, 0, }, /* 796 */ + { 108, 10, 5, 0, 0, 108, 0, }, /* 797 */ + { 108, 12, 3, 0, 0, 108, 0, }, /* 798 */ + { 108, 21, 12, 0, 0, 108, 0, }, /* 799 */ + { 129, 7, 12, 0, 0, 129, 0, }, /* 800 */ + { 129, 21, 12, 0, 0, 129, 0, }, /* 801 */ + { 109, 7, 12, 0, 0, 109, 0, }, /* 802 */ + { 109, 12, 3, 0, 0, 109, 0, }, /* 803 */ + { 109, 10, 5, 0, 0, 109, 0, }, /* 804 */ + { 109, 13, 12, 0, 0, 109, 0, }, /* 805 */ + { 107, 12, 3, 0, 0, 107, 0, }, /* 806 */ + { 107, 12, 3, 0, 0, -52, 0, }, /* 807 */ + { 107, 10, 5, 0, 0, 107, 0, }, /* 808 */ + { 107, 10, 5, 0, 0, -52, 0, }, /* 809 */ + { 107, 7, 12, 0, 0, 107, 0, }, /* 810 */ + { 28, 12, 3, 0, 0, -52, 0, }, /* 811 */ + { 107, 10, 3, 0, 0, 107, 0, }, /* 812 */ + { 135, 7, 12, 0, 0, 135, 0, }, /* 813 */ + { 135, 10, 5, 0, 0, 135, 0, }, /* 814 */ + { 135, 12, 3, 0, 0, 135, 0, }, /* 815 */ + { 135, 21, 12, 0, 0, 135, 0, }, /* 816 */ + { 135, 13, 12, 0, 0, 135, 0, }, /* 817 */ + { 124, 7, 12, 0, 0, 124, 0, }, /* 818 */ + { 124, 10, 3, 0, 0, 124, 0, }, /* 819 */ + { 124, 10, 5, 0, 0, 124, 0, }, /* 820 */ + { 124, 12, 3, 0, 0, 124, 0, }, /* 821 */ + { 124, 21, 12, 0, 0, 124, 0, }, /* 822 */ + { 124, 13, 12, 0, 0, 124, 0, }, /* 823 */ + { 123, 7, 12, 0, 0, 123, 0, }, /* 824 */ + { 123, 10, 3, 0, 0, 123, 0, }, /* 825 */ + { 123, 10, 5, 0, 0, 123, 0, }, /* 826 */ + { 123, 12, 3, 0, 0, 123, 0, }, /* 827 */ + { 123, 21, 12, 0, 0, 123, 0, }, /* 828 */ + { 114, 7, 12, 0, 0, 114, 0, }, /* 829 */ + { 114, 10, 5, 0, 0, 114, 0, }, /* 830 */ + { 114, 12, 3, 0, 0, 114, 0, }, /* 831 */ + { 114, 21, 12, 0, 0, 114, 0, }, /* 832 */ + { 114, 13, 12, 0, 0, 114, 0, }, /* 833 */ + { 102, 7, 12, 0, 0, 102, 0, }, /* 834 */ + { 102, 12, 3, 0, 0, 102, 0, }, /* 835 */ + { 102, 10, 5, 0, 0, 102, 0, }, /* 836 */ + { 102, 13, 12, 0, 0, 102, 0, }, /* 837 */ + { 126, 7, 12, 0, 0, 126, 0, }, /* 838 */ + { 126, 12, 3, 0, 0, 126, 0, }, /* 839 */ + { 126, 10, 5, 0, 0, 126, 0, }, /* 840 */ + { 126, 13, 12, 0, 0, 126, 0, }, /* 841 */ + { 126, 15, 12, 0, 0, 126, 0, }, /* 842 */ + { 126, 21, 12, 0, 0, 126, 0, }, /* 843 */ + { 126, 26, 12, 0, 0, 126, 0, }, /* 844 */ + { 142, 7, 12, 0, 0, 142, 0, }, /* 845 */ + { 142, 10, 5, 0, 0, 142, 0, }, /* 846 */ + { 142, 12, 3, 0, 0, 142, 0, }, /* 847 */ + { 142, 21, 12, 0, 0, 142, 0, }, /* 848 */ + { 125, 9, 12, 0, 32, 125, 0, }, /* 849 */ + { 125, 5, 12, 0, -32, 125, 0, }, /* 850 */ + { 125, 13, 12, 0, 0, 125, 0, }, /* 851 */ + { 125, 15, 12, 0, 0, 125, 0, }, /* 852 */ + { 125, 7, 12, 0, 0, 125, 0, }, /* 853 */ + { 150, 7, 12, 0, 0, 150, 0, }, /* 854 */ + { 150, 10, 5, 0, 0, 150, 0, }, /* 855 */ + { 150, 12, 3, 0, 0, 150, 0, }, /* 856 */ + { 150, 21, 12, 0, 0, 150, 0, }, /* 857 */ + { 141, 7, 12, 0, 0, 141, 0, }, /* 858 */ + { 141, 12, 3, 0, 0, 141, 0, }, /* 859 */ + { 141, 10, 5, 0, 0, 141, 0, }, /* 860 */ + { 141, 7, 4, 0, 0, 141, 0, }, /* 861 */ + { 141, 21, 12, 0, 0, 141, 0, }, /* 862 */ + { 140, 7, 12, 0, 0, 140, 0, }, /* 863 */ + { 140, 12, 3, 0, 0, 140, 0, }, /* 864 */ + { 140, 10, 5, 0, 0, 140, 0, }, /* 865 */ + { 140, 7, 4, 0, 0, 140, 0, }, /* 866 */ + { 140, 21, 12, 0, 0, 140, 0, }, /* 867 */ + { 122, 7, 12, 0, 0, 122, 0, }, /* 868 */ + { 133, 7, 12, 0, 0, 133, 0, }, /* 869 */ + { 133, 10, 5, 0, 0, 133, 0, }, /* 870 */ + { 133, 12, 3, 0, 0, 133, 0, }, /* 871 */ + { 133, 21, 12, 0, 0, 133, 0, }, /* 872 */ + { 133, 13, 12, 0, 0, 133, 0, }, /* 873 */ + { 133, 15, 12, 0, 0, 133, 0, }, /* 874 */ + { 134, 21, 12, 0, 0, 134, 0, }, /* 875 */ + { 134, 7, 12, 0, 0, 134, 0, }, /* 876 */ + { 134, 12, 3, 0, 0, 134, 0, }, /* 877 */ + { 134, 10, 5, 0, 0, 134, 0, }, /* 878 */ + { 138, 7, 12, 0, 0, 138, 0, }, /* 879 */ + { 138, 12, 3, 0, 0, 138, 0, }, /* 880 */ + { 138, 7, 4, 0, 0, 138, 0, }, /* 881 */ + { 138, 13, 12, 0, 0, 138, 0, }, /* 882 */ + { 143, 7, 12, 0, 0, 143, 0, }, /* 883 */ + { 143, 10, 5, 0, 0, 143, 0, }, /* 884 */ + { 143, 12, 3, 0, 0, 143, 0, }, /* 885 */ + { 143, 13, 12, 0, 0, 143, 0, }, /* 886 */ + { 145, 7, 12, 0, 0, 145, 0, }, /* 887 */ + { 145, 12, 3, 0, 0, 145, 0, }, /* 888 */ + { 145, 10, 5, 0, 0, 145, 0, }, /* 889 */ + { 145, 21, 12, 0, 0, 145, 0, }, /* 890 */ + { 54, 15, 12, 0, 0, 54, 0, }, /* 891 */ + { 54, 21, 12, 0, 0, 54, 0, }, /* 892 */ + { 63, 7, 12, 0, 0, 63, 0, }, /* 893 */ + { 63, 14, 12, 0, 0, 63, 0, }, /* 894 */ + { 63, 21, 12, 0, 0, 63, 0, }, /* 895 */ + { 80, 7, 12, 0, 0, 80, 0, }, /* 896 */ + { 80, 1, 2, 0, 0, 80, 0, }, /* 897 */ + { 127, 7, 12, 0, 0, 127, 0, }, /* 898 */ + { 115, 7, 12, 0, 0, 115, 0, }, /* 899 */ + { 115, 13, 12, 0, 0, 115, 0, }, /* 900 */ + { 115, 21, 12, 0, 0, 115, 0, }, /* 901 */ + { 103, 7, 12, 0, 0, 103, 0, }, /* 902 */ + { 103, 12, 3, 0, 0, 103, 0, }, /* 903 */ + { 103, 21, 12, 0, 0, 103, 0, }, /* 904 */ + { 119, 7, 12, 0, 0, 119, 0, }, /* 905 */ + { 119, 12, 3, 0, 0, 119, 0, }, /* 906 */ + { 119, 21, 12, 0, 0, 119, 0, }, /* 907 */ + { 119, 26, 12, 0, 0, 119, 0, }, /* 908 */ + { 119, 6, 12, 0, 0, 119, 0, }, /* 909 */ + { 119, 13, 12, 0, 0, 119, 0, }, /* 910 */ + { 119, 15, 12, 0, 0, 119, 0, }, /* 911 */ + { 146, 9, 12, 0, 32, 146, 0, }, /* 912 */ + { 146, 5, 12, 0, -32, 146, 0, }, /* 913 */ + { 146, 15, 12, 0, 0, 146, 0, }, /* 914 */ + { 146, 21, 12, 0, 0, 146, 0, }, /* 915 */ + { 99, 7, 12, 0, 0, 99, 0, }, /* 916 */ + { 99, 12, 3, 0, 0, 99, 0, }, /* 917 */ + { 99, 10, 5, 0, 0, 99, 0, }, /* 918 */ + { 99, 6, 12, 0, 0, 99, 0, }, /* 919 */ + { 137, 6, 12, 0, 0, 137, 0, }, /* 920 */ + { 139, 6, 12, 0, 0, 139, 0, }, /* 921 */ + { 137, 7, 12, 0, 0, 137, 0, }, /* 922 */ + { 139, 7, 12, 0, 0, 139, 0, }, /* 923 */ + { 105, 7, 12, 0, 0, 105, 0, }, /* 924 */ + { 105, 26, 12, 0, 0, 105, 0, }, /* 925 */ + { 105, 12, 3, 0, 0, 105, 0, }, /* 926 */ + { 105, 21, 12, 0, 0, 105, 0, }, /* 927 */ + { 10, 1, 2, 0, 0, 105, 0, }, /* 928 */ + { 10, 10, 3, 0, 0, 10, 0, }, /* 929 */ + { 10, 10, 5, 0, 0, 10, 0, }, /* 930 */ + { 20, 12, 3, 0, 0, 20, 0, }, /* 931 */ + { 131, 26, 12, 0, 0, 131, 0, }, /* 932 */ + { 131, 12, 3, 0, 0, 131, 0, }, /* 933 */ + { 131, 21, 12, 0, 0, 131, 0, }, /* 934 */ + { 18, 12, 3, 0, 0, 18, 0, }, /* 935 */ + { 151, 7, 12, 0, 0, 151, 0, }, /* 936 */ + { 151, 12, 3, 0, 0, 151, 0, }, /* 937 */ + { 151, 6, 12, 0, 0, 151, 0, }, /* 938 */ + { 151, 13, 12, 0, 0, 151, 0, }, /* 939 */ + { 151, 26, 12, 0, 0, 151, 0, }, /* 940 */ + { 152, 7, 12, 0, 0, 152, 0, }, /* 941 */ + { 152, 12, 3, 0, 0, 152, 0, }, /* 942 */ + { 152, 13, 12, 0, 0, 152, 0, }, /* 943 */ + { 152, 23, 12, 0, 0, 152, 0, }, /* 944 */ + { 113, 7, 12, 0, 0, 113, 0, }, /* 945 */ + { 113, 15, 12, 0, 0, 113, 0, }, /* 946 */ + { 113, 12, 3, 0, 0, 113, 0, }, /* 947 */ + { 132, 9, 12, 0, 34, 132, 0, }, /* 948 */ + { 132, 5, 12, 0, -34, 132, 0, }, /* 949 */ + { 132, 12, 3, 0, 0, 132, 0, }, /* 950 */ + { 132, 6, 12, 0, 0, 132, 0, }, /* 951 */ + { 132, 13, 12, 0, 0, 132, 0, }, /* 952 */ + { 132, 21, 12, 0, 0, 132, 0, }, /* 953 */ + { 0, 2, 14, 0, 0, 0, 0, }, /* 954 */ + { 10, 26, 11, 0, 0, 10, 0, }, /* 955 */ + { 27, 26, 12, 0, 0, 27, 0, }, /* 956 */ + { 10, 24, 3, 0, 0, 10, 0, }, /* 957 */ + { 10, 1, 3, 0, 0, 10, 0, }, /* 958 */ }; const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ @@ -1150,37 +1185,37 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+F000 */ 126,126, 98, 98,127,128,129,130,131,131,132,133,134,135,136,137, /* U+F800 */ 138,139,140,141,142,143,144,145,146,147,148,142,149,149,150,142, /* U+10000 */ -151,152,153,154,155,156,157,158,159,160,161,142,162,142,163,142, /* U+10800 */ -164,165,166,167,168,169,170,142,171,172,142,173,174,175,176,142, /* U+11000 */ -177,178,142,142,179,180,142,142,181,182,183,184,142,185,142,142, /* U+11800 */ -186,186,186,186,186,186,186,187,188,186,189,142,142,142,142,142, /* U+12000 */ +151,152,153,154,155,156,157,158,159,160,161,142,162,142,163,164, /* U+10800 */ +165,166,167,168,169,170,171,142,172,173,142,174,175,176,177,142, /* U+11000 */ +178,179,142,180,181,182,142,142,183,184,185,186,142,187,142,188, /* U+11800 */ +189,189,189,189,189,189,189,190,191,189,192,142,142,142,142,142, /* U+12000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+12800 */ -190,190,190,190,190,190,190,190,191,142,142,142,142,142,142,142, /* U+13000 */ +193,193,193,193,193,193,193,193,194,142,142,142,142,142,142,142, /* U+13000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+13800 */ -142,142,142,142,142,142,142,142,192,192,192,192,193,142,142,142, /* U+14000 */ +142,142,142,142,142,142,142,142,195,195,195,195,196,142,142,142, /* U+14000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+14800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+15000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+15800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+16000 */ -194,194,194,194,195,196,197,198,142,142,142,142,199,200,201,202, /* U+16800 */ -203,203,203,203,203,203,203,203,203,203,203,203,203,203,203,203, /* U+17000 */ -203,203,203,203,203,203,203,203,203,203,203,203,203,203,203,203, /* U+17800 */ -203,203,203,203,203,203,203,203,203,203,203,203,203,203,203,204, /* U+18000 */ -203,203,203,203,203,205,142,142,142,142,142,142,142,142,142,142, /* U+18800 */ +197,197,197,197,198,199,200,201,142,142,142,142,202,203,204,205, /* U+16800 */ +206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206, /* U+17000 */ +206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206, /* U+17800 */ +206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,207, /* U+18000 */ +206,206,206,206,206,208,142,142,142,142,142,142,142,142,142,142, /* U+18800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+19000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+19800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1A000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1A800 */ -206,207,208,209,209,210,142,142,142,142,142,142,142,142,142,142, /* U+1B000 */ -142,142,142,142,142,142,142,142,211,212,142,142,142,142,142,142, /* U+1B800 */ +209,210,211,212,212,213,142,142,142,142,142,142,142,142,142,142, /* U+1B000 */ +142,142,142,142,142,142,142,142,214,215,142,142,142,142,142,142, /* U+1B800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1C000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1C800 */ - 71,213,214,215,216,217,218,142,219,220,221,222,223,224,225,226, /* U+1D000 */ -227,227,227,227,228,229,142,142,142,142,142,142,142,142,142,142, /* U+1D800 */ -230,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+1E000 */ -231,232,233,142,142,142,142,142,234,235,142,142,236,237,142,142, /* U+1E800 */ -238,239,240,241,242,243,244,245,244,244,246,244,247,248,249,250, /* U+1F000 */ -251,252,253,254,255,243,243,243,243,243,243,243,243,243,243,256, /* U+1F800 */ + 71,216,217,218,219,220,221,142,222,223,224,225,226,227,228,229, /* U+1D000 */ +230,230,230,230,231,232,142,142,142,142,142,142,142,142,142,142, /* U+1D800 */ +233,142,234,142,142,235,142,142,142,142,142,142,142,142,142,142, /* U+1E000 */ +236,237,238,142,142,142,142,142,239,240,241,142,242,243,142,142, /* U+1E800 */ +244,245,246,247,248,249,250,251,250,250,252,250,253,254,255,256, /* U+1F000 */ +257,258,259,260,261,262,249,249,249,249,249,249,249,249,249,263, /* U+1F800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+20000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+20800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+21000 */ @@ -1201,18 +1236,18 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+28800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+29000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+29800 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,257, 98, 98, /* U+2A000 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,264, 98, 98, /* U+2A000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2A800 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,258, 98, /* U+2B000 */ -259, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2B800 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,265, 98, /* U+2B000 */ +266, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2B800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2C000 */ - 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,260, 98, 98, /* U+2C800 */ + 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,267, 98, 98, /* U+2C800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2D000 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2D800 */ 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, /* U+2E000 */ - 98, 98, 98, 98, 98, 98, 98,261,142,142,142,142,142,142,142,142, /* U+2E800 */ + 98, 98, 98, 98, 98, 98, 98,268,142,142,142,142,142,142,142,142, /* U+2E800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+2F000 */ - 98, 98, 98, 98,262,142,142,142,142,142,142,142,142,142,142,142, /* U+2F800 */ + 98, 98, 98, 98,269,142,142,142,142,142,142,142,142,142,142,142, /* U+2F800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+30000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+30800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+31000 */ @@ -1565,8 +1600,8 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DE800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DF000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+DF800 */ -263,264,265,266,264,264,264,264,264,264,264,264,264,264,264,264, /* U+E0000 */ -264,264,264,264,264,264,264,264,264,264,264,264,264,264,264,264, /* U+E0800 */ +270,271,272,273,271,271,271,271,271,271,271,271,271,271,271,271, /* U+E0000 */ +271,271,271,271,271,271,271,271,271,271,271,271,271,271,271,271, /* U+E0800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E1000 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E1800 */ 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, /* U+E2000 */ @@ -1628,7 +1663,7 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FE000 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FE800 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+FF000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,267, /* U+FF800 */ +126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,274, /* U+FF800 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+100000 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+100800 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+101000 */ @@ -1660,10 +1695,10 @@ const uint16_t PRIV(ucd_stage1)[] = { /* 17408 bytes */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10E000 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10E800 */ 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, /* U+10F000 */ -126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,267, /* U+10F800 */ +126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,274, /* U+10F800 */ }; -const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ +const uint16_t PRIV(ucd_stage2)[] = { /* 70400 bytes, block = 128 */ /* block 0 */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1715,534 +1750,534 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 35, 97, 98, 35, 35, 99, 35, 35, 35, 35, 35, 35, 35,100, 35, 35, /* block 5 */ -101, 35, 35,101, 35, 35, 35,102,101,103,104,104,105, 35, 35, 35, - 35, 35,106, 35, 22, 35, 35, 35, 35, 35, 35, 35, 35,107,108, 35, +101, 35,102,101, 35, 35, 35,103,101,104,105,105,106, 35, 35, 35, + 35, 35,107, 35, 22, 35, 35, 35, 35, 35, 35, 35, 35,108,109, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, -109,109,109,109,109,109,109,109,109,110,110,110,110,110,110,110, -110,110, 15, 15, 15, 15,110,110,110,110,110,110,110,110,110,110, -110,110, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -109,109,109,109,109, 15, 15, 15, 15, 15,111,111,110, 15,110, 15, +110,110,110,110,110,110,110,110,110,111,111,111,111,111,111,111, +111,111, 15, 15, 15, 15,111,111,111,111,111,111,111,111,111,111, +111,111, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +110,110,110,110,110, 15, 15, 15, 15, 15,112,112,111, 15,111, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, /* block 6 */ -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,113,112,112,114,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,115,115,115,115,115,115,115,115,115,115,115,115,115, -116,117,116,117,110,118,116,117,119,119,120,121,121,121, 5,122, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,114,113,113,115,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,116,116,116,116,116,116,116,116,116,116,116,116,116, +117,118,117,118,111,119,117,118,120,120,121,122,122,122, 5,123, /* block 7 */ -119,119,119,119,118, 15,123, 5,124,124,124,119,125,119,126,126, -127,128,129,128,128,130,128,128,131,132,133,128,134,128,128,128, -135,136,119,137,128,128,138,128,128,139,128,128,140,141,141,141, -127,142,143,142,142,144,142,142,145,146,147,142,148,142,142,142, -149,150,151,152,142,142,153,142,142,154,142,142,155,156,156,157, -158,159,160,160,160,161,162,163,116,117,116,117,116,117,116,117, -116,117,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -166,167,168,169,170,171,172,116,117,173,116,117,127,174,174,174, +120,120,120,120,119, 15,124, 5,125,125,125,120,126,120,127,127, +128,129,130,129,129,131,129,129,132,133,134,129,135,129,129,129, +136,137,120,138,129,129,139,129,129,140,129,129,141,142,142,142, +128,143,144,143,143,145,143,143,146,147,148,143,149,143,143,143, +150,151,152,153,143,143,154,143,143,155,143,143,156,157,157,158, +159,160,161,161,161,162,163,164,117,118,117,118,117,118,117,118, +117,118,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +167,168,169,170,171,172,173,117,118,174,117,118,128,175,175,175, /* block 8 */ -175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175, -176,176,177,176,178,176,176,176,176,176,176,176,176,176,179,176, -176,180,181,176,176,176,176,176,176,176,182,176,176,176,176,176, -183,183,184,183,185,183,183,183,183,183,183,183,183,183,186,183, -183,187,188,183,183,183,183,183,183,183,189,183,183,183,183,183, -190,190,190,190,190,190,190,190,190,190,190,190,190,190,190,190, -191,192,193,194,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, +176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176, +177,177,178,177,179,177,177,177,177,177,177,177,177,177,180,177, +177,181,182,177,177,177,177,177,177,177,183,177,177,177,177,177, +184,184,185,184,186,184,184,184,184,184,184,184,184,184,187,184, +184,188,189,184,184,184,184,184,184,184,190,184,184,184,184,184, +191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, +192,193,194,195,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, /* block 9 */ -191,192,195,196,197,198,198,197,199,199,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -200,191,192,191,192,191,192,191,192,191,192,191,192,191,192,201, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, +192,193,196,197,198,199,199,198,200,200,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +201,192,193,192,193,192,193,192,193,192,193,192,193,192,193,202, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, /* block 10 */ -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -119,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202, -202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202, -202,202,202,202,202,202,202,119,119,203,204,204,204,204,204,204, -205,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206, -206,206,206,206,206,206,206,206,206,206,206,206,206,206,206,206, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +120,203,203,203,203,203,203,203,203,203,203,203,203,203,203,203, +203,203,203,203,203,203,203,203,203,203,203,203,203,203,203,203, +203,203,203,203,203,203,203,120,120,204,205,205,205,205,205,205, +206,207,207,207,207,207,207,207,207,207,207,207,207,207,207,207, +207,207,207,207,207,207,207,207,207,207,207,207,207,207,207,207, /* block 11 */ -206,206,206,206,206,206,206,205,205,207,208,119,119,209,209,210, -119,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211, -211,211,211,211,211,211,211,211,211,211,211,211,211,211,211,211, -211,211,211,211,211,211,211,211,211,211,211,211,211,211,212,211, -213,211,211,213,211,211,213,211,119,119,119,119,119,119,119,119, -214,214,214,214,214,214,214,214,214,214,214,214,214,214,214,214, -214,214,214,214,214,214,214,214,214,214,214,119,119,119,119,214, -214,214,214,213,213,119,119,119,119,119,119,119,119,119,119,119, +207,207,207,207,207,207,207,206,206,208,209,120,120,210,210,211, +120,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212, +212,212,212,212,212,212,212,212,212,212,212,212,212,212,212,212, +212,212,212,212,212,212,212,212,212,212,212,212,212,212,213,212, +214,212,212,214,212,212,214,212,120,120,120,120,120,120,120,120, +215,215,215,215,215,215,215,215,215,215,215,215,215,215,215,215, +215,215,215,215,215,215,215,215,215,215,215,120,120,120,120,215, +215,215,215,214,214,120,120,120,120,120,120,120,120,120,120,120, /* block 12 */ -215,215,215,215,215,216,217,217,217,218,218,219,220,218,221,221, -222,222,222,222,222,222,222,222,222,222,222,220,223,119,218,220, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -225,224,224,224,224,224,224,224,224,224,224,226,226,226,226,226, -226,226,226,226,226,226,222,222,222,222,222,222,222,222,222,222, -227,227,227,227,227,227,227,227,227,227,218,218,218,218,224,224, -226,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +216,216,216,216,216,217,218,218,218,219,219,220,221,219,222,222, +223,223,223,223,223,223,223,223,223,223,223,221,224,120,219,221, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +226,225,225,225,225,225,225,225,225,225,225,227,227,227,227,227, +227,227,227,227,227,227,223,223,223,223,223,223,223,223,223,223, +228,228,228,228,228,228,228,228,228,228,219,219,219,219,225,225, +227,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 13 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,228,224,222,222,222,222,222,222,222,216,221,222, -222,222,222,222,222,229,229,222,222,221,222,222,222,222,224,224, -230,230,230,230,230,230,230,230,230,230,224,224,224,221,221,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,229,225,223,223,223,223,223,223,223,217,222,223, +223,223,223,223,223,230,230,223,223,222,223,223,223,223,225,225, +231,231,231,231,231,231,231,231,231,231,225,225,225,222,222,225, /* block 14 */ -231,231,231,231,231,231,231,231,231,231,231,231,231,231,119,232, -233,234,233,233,233,233,233,233,233,233,233,233,233,233,233,233, -233,233,233,233,233,233,233,233,233,233,233,233,233,233,233,233, +232,232,232,232,232,232,232,232,232,232,232,232,232,232,120,233, +234,235,234,234,234,234,234,234,234,234,234,234,234,234,234,234, 234,234,234,234,234,234,234,234,234,234,234,234,234,234,234,234, -234,234,234,234,234,234,234,234,234,234,234,119,119,233,233,233, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235, +235,235,235,235,235,235,235,235,235,235,235,120,120,234,234,234, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 15 */ -235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235, -235,235,235,235,235,235,235,235,235,235,235,235,235,235,235,235, -235,235,235,235,235,235,236,236,236,236,236,236,236,236,236,236, -236,235,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -237,237,237,237,237,237,237,237,237,237,238,238,238,238,238,238, -238,238,238,238,238,238,238,238,238,238,238,238,238,238,238,238, -238,238,238,238,238,238,238,238,238,238,238,239,239,239,239,239, -239,239,239,239,240,240,241,242,242,242,240,119,119,239,243,243, +236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236, +236,236,236,236,236,236,236,236,236,236,236,236,236,236,236,236, +236,236,236,236,236,236,237,237,237,237,237,237,237,237,237,237, +237,236,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +238,238,238,238,238,238,238,238,238,238,239,239,239,239,239,239, +239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239, +239,239,239,239,239,239,239,239,239,239,239,240,240,240,240,240, +240,240,240,240,241,241,242,243,243,243,241,120,120,240,244,244, /* block 16 */ -244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244, -244,244,244,244,244,244,245,245,245,245,246,245,245,245,245,245, -245,245,245,245,246,245,245,245,246,245,245,245,245,245,119,119, -247,247,247,247,247,247,247,247,247,247,247,247,247,247,247,119, -248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,248, -248,248,248,248,248,248,248,248,248,249,249,249,119,119,250,119, -233,233,233,233,233,233,233,233,233,233,233,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +245,245,245,245,245,245,245,245,245,245,245,245,245,245,245,245, +245,245,245,245,245,245,246,246,246,246,247,246,246,246,246,246, +246,246,246,246,247,246,246,246,247,246,246,246,246,246,120,120, +248,248,248,248,248,248,248,248,248,248,248,248,248,248,248,120, +249,249,249,249,249,249,249,249,249,249,249,249,249,249,249,249, +249,249,249,249,249,249,249,249,249,250,250,250,120,120,251,120, +234,234,234,234,234,234,234,234,234,234,234,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 17 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,119,224,224,224,224,224,224,224,224,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,222,222,222,222,222,222,222,222,222,222,222,222,222, -222,222,216,222,222,222,222,222,222,222,222,222,222,222,222,222, -222,222,222,222,222,222,222,222,222,222,222,222,222,222,222,222, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,120,225,225,225,225,225,225,225,225,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,223,223,223,223,223,223,223,223,223,223,223,223,223, +223,223,217,223,223,223,223,223,223,223,223,223,223,223,223,223, +223,223,223,223,223,223,223,223,223,223,223,223,223,223,223,223, /* block 18 */ -251,251,251,252,253,253,253,253,253,253,253,253,253,253,253,253, -253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, -253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, -253,253,253,253,253,253,253,253,253,253,251,252,251,253,252,252, -252,251,251,251,251,251,251,251,251,252,252,252,252,251,252,252, -253,254,255,251,251,251,251,251,253,253,253,253,253,253,253,253, -253,253,251,251,256,257,258,258,258,258,258,258,258,258,258,258, -259,260,253,253,253,253,253,253,253,253,253,253,253,253,253,253, +252,252,252,253,254,254,254,254,254,254,254,254,254,254,254,254, +254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254, +254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254, +254,254,254,254,254,254,254,254,254,254,252,253,252,254,253,253, +253,252,252,252,252,252,252,252,252,253,253,253,253,252,253,253, +254,255,256,113,113,252,252,252,254,254,254,254,254,254,254,254, +254,254,252,252,257,258,259,259,259,259,259,259,259,259,259,259, +260,261,254,254,254,254,254,254,254,254,254,254,254,254,254,254, /* block 19 */ -261,262,263,263,119,261,261,261,261,261,261,261,261,119,119,261, -261,119,119,261,261,261,261,261,261,261,261,261,261,261,261,261, -261,261,261,261,261,261,261,261,261,119,261,261,261,261,261,261, -261,119,261,119,119,119,261,261,261,261,119,119,262,261,264,263, -263,262,262,262,262,119,119,263,263,119,119,263,263,262,261,119, -119,119,119,119,119,119,119,264,119,119,119,119,261,261,119,261, -261,261,262,262,119,119,265,265,265,265,265,265,265,265,265,265, -261,261,266,266,267,267,267,267,267,267,268,266,261,269,262,119, +262,263,264,264,120,262,262,262,262,262,262,262,262,120,120,262, +262,120,120,262,262,262,262,262,262,262,262,262,262,262,262,262, +262,262,262,262,262,262,262,262,262,120,262,262,262,262,262,262, +262,120,262,120,120,120,262,262,262,262,120,120,263,262,265,264, +264,263,263,263,263,120,120,264,264,120,120,264,264,263,262,120, +120,120,120,120,120,120,120,265,120,120,120,120,262,262,120,262, +262,262,263,263,120,120,266,266,266,266,266,266,266,266,266,266, +262,262,267,267,268,268,268,268,268,268,269,267,262,270,263,120, /* block 20 */ -119,270,270,271,119,272,272,272,272,272,272,119,119,119,119,272, -272,119,119,272,272,272,272,272,272,272,272,272,272,272,272,272, -272,272,272,272,272,272,272,272,272,119,272,272,272,272,272,272, -272,119,272,272,119,272,272,119,272,272,119,119,270,119,271,271, -271,270,270,119,119,119,119,270,270,119,119,270,270,270,119,119, -119,270,119,119,119,119,119,119,119,272,272,272,272,119,272,119, -119,119,119,119,119,119,273,273,273,273,273,273,273,273,273,273, -270,270,272,272,272,270,274,119,119,119,119,119,119,119,119,119, +120,271,271,272,120,273,273,273,273,273,273,120,120,120,120,273, +273,120,120,273,273,273,273,273,273,273,273,273,273,273,273,273, +273,273,273,273,273,273,273,273,273,120,273,273,273,273,273,273, +273,120,273,273,120,273,273,120,273,273,120,120,271,120,272,272, +272,271,271,120,120,120,120,271,271,120,120,271,271,271,120,120, +120,271,120,120,120,120,120,120,120,273,273,273,273,120,273,120, +120,120,120,120,120,120,274,274,274,274,274,274,274,274,274,274, +271,271,273,273,273,271,275,120,120,120,120,120,120,120,120,120, /* block 21 */ -119,275,275,276,119,277,277,277,277,277,277,277,277,277,119,277, -277,277,119,277,277,277,277,277,277,277,277,277,277,277,277,277, -277,277,277,277,277,277,277,277,277,119,277,277,277,277,277,277, -277,119,277,277,119,277,277,277,277,277,119,119,275,277,276,276, -276,275,275,275,275,275,119,275,275,276,119,276,276,275,119,119, -277,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -277,277,275,275,119,119,278,278,278,278,278,278,278,278,278,278, -279,280,119,119,119,119,119,119,119,277,275,275,275,275,275,275, +120,276,276,277,120,278,278,278,278,278,278,278,278,278,120,278, +278,278,120,278,278,278,278,278,278,278,278,278,278,278,278,278, +278,278,278,278,278,278,278,278,278,120,278,278,278,278,278,278, +278,120,278,278,120,278,278,278,278,278,120,120,276,278,277,277, +277,276,276,276,276,276,120,276,276,277,120,277,277,276,120,120, +278,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +278,278,276,276,120,120,279,279,279,279,279,279,279,279,279,279, +280,281,120,120,120,120,120,120,120,278,276,276,276,276,276,276, /* block 22 */ -119,281,282,282,119,283,283,283,283,283,283,283,283,119,119,283, -283,119,119,283,283,283,283,283,283,283,283,283,283,283,283,283, -283,283,283,283,283,283,283,283,283,119,283,283,283,283,283,283, -283,119,283,283,119,283,283,283,283,283,119,119,281,283,284,281, -282,281,281,281,281,119,119,282,282,119,119,282,282,281,119,119, -119,119,119,119,119,119,281,284,119,119,119,119,283,283,119,283, -283,283,281,281,119,119,285,285,285,285,285,285,285,285,285,285, -286,283,287,287,287,287,287,287,119,119,119,119,119,119,119,119, +120,282,283,283,120,284,284,284,284,284,284,284,284,120,120,284, +284,120,120,284,284,284,284,284,284,284,284,284,284,284,284,284, +284,284,284,284,284,284,284,284,284,120,284,284,284,284,284,284, +284,120,284,284,120,284,284,284,284,284,120,120,282,284,285,282, +283,282,282,282,282,120,120,283,283,120,120,283,283,282,120,120, +120,120,120,120,120,120,282,285,120,120,120,120,284,284,120,284, +284,284,282,282,120,120,286,286,286,286,286,286,286,286,286,286, +287,284,288,288,288,288,288,288,120,120,120,120,120,120,120,120, /* block 23 */ -119,119,288,289,119,289,289,289,289,289,289,119,119,119,289,289, -289,119,289,289,289,289,119,119,119,289,289,119,289,119,289,289, -119,119,119,289,289,119,119,119,289,289,289,119,119,119,289,289, -289,289,289,289,289,289,289,289,289,289,119,119,119,119,290,291, -288,291,291,119,119,119,291,291,291,119,291,291,291,288,119,119, -289,119,119,119,119,119,119,290,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,292,292,292,292,292,292,292,292,292,292, -293,293,293,294,295,295,295,295,295,296,295,119,119,119,119,119, +120,120,289,290,120,290,290,290,290,290,290,120,120,120,290,290, +290,120,290,290,290,290,120,120,120,290,290,120,290,120,290,290, +120,120,120,290,290,120,120,120,290,290,290,120,120,120,290,290, +290,290,290,290,290,290,290,290,290,290,120,120,120,120,291,292, +289,292,292,120,120,120,292,292,292,120,292,292,292,289,120,120, +290,120,120,120,120,120,120,291,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,293,293,293,293,293,293,293,293,293,293, +294,294,294,295,296,296,296,296,296,297,296,120,120,120,120,120, /* block 24 */ -297,298,298,298,297,299,299,299,299,299,299,299,299,119,299,299, -299,119,299,299,299,299,299,299,299,299,299,299,299,299,299,299, -299,299,299,299,299,299,299,299,299,119,299,299,299,299,299,299, -299,299,299,299,299,299,299,299,299,299,119,119,119,299,297,297, -297,298,298,298,298,119,297,297,297,119,297,297,297,297,119,119, -119,119,119,119,119,297,297,119,299,299,299,119,119,119,119,119, -299,299,297,297,119,119,300,300,300,300,300,300,300,300,300,300, -119,119,119,119,119,119,119,119,301,301,301,301,301,301,301,302, +298,299,299,299,298,300,300,300,300,300,300,300,300,120,300,300, +300,120,300,300,300,300,300,300,300,300,300,300,300,300,300,300, +300,300,300,300,300,300,300,300,300,120,300,300,300,300,300,300, +300,300,300,300,300,300,300,300,300,300,120,120,120,300,298,298, +298,299,299,299,299,120,298,298,298,120,298,298,298,298,120,120, +120,120,120,120,120,298,298,120,300,300,300,120,120,120,120,120, +300,300,298,298,120,120,301,301,301,301,301,301,301,301,301,301, +120,120,120,120,120,120,120,302,303,303,303,303,303,303,303,304, /* block 25 */ -303,304,305,305,306,303,303,303,303,303,303,303,303,119,303,303, -303,119,303,303,303,303,303,303,303,303,303,303,303,303,303,303, -303,303,303,303,303,303,303,303,303,119,303,303,303,303,303,303, -303,303,303,303,119,303,303,303,303,303,119,119,304,303,305,304, -305,305,307,305,305,119,304,305,305,119,305,305,304,304,119,119, -119,119,119,119,119,307,307,119,119,119,119,119,119,119,303,119, -303,303,304,304,119,119,308,308,308,308,308,308,308,308,308,308, -119,303,303,119,119,119,119,119,119,119,119,119,119,119,119,119, +305,306,307,307,308,305,305,305,305,305,305,305,305,120,305,305, +305,120,305,305,305,305,305,305,305,305,305,305,305,305,305,305, +305,305,305,305,305,305,305,305,305,120,305,305,305,305,305,305, +305,305,305,305,120,305,305,305,305,305,120,120,306,305,307,306, +307,307,309,307,307,120,306,307,307,120,307,307,306,306,120,120, +120,120,120,120,120,309,309,120,120,120,120,120,120,120,305,120, +305,305,306,306,120,120,310,310,310,310,310,310,310,310,310,310, +120,305,305,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 26 */ -309,309,310,310,119,311,311,311,311,311,311,311,311,119,311,311, -311,119,311,311,311,311,311,311,311,311,311,311,311,311,311,311, -311,311,311,311,311,311,311,311,311,311,311,311,311,311,311,311, -311,311,311,311,311,311,311,311,311,311,311,309,309,311,312,310, -310,309,309,309,309,119,310,310,310,119,310,310,310,309,313,314, -119,119,119,119,311,311,311,312,315,315,315,315,315,315,315,311, -311,311,309,309,119,119,316,316,316,316,316,316,316,316,316,316, -315,315,315,315,315,315,315,315,315,314,311,311,311,311,311,311, +311,311,312,312,120,313,313,313,313,313,313,313,313,120,313,313, +313,120,313,313,313,313,313,313,313,313,313,313,313,313,313,313, +313,313,313,313,313,313,313,313,313,313,313,313,313,313,313,313, +313,313,313,313,313,313,313,313,313,313,313,311,311,313,314,312, +312,311,311,311,311,120,312,312,312,120,312,312,312,311,315,316, +120,120,120,120,313,313,313,314,317,317,317,317,317,317,317,313, +313,313,311,311,120,120,318,318,318,318,318,318,318,318,318,318, +317,317,317,317,317,317,317,317,317,316,313,313,313,313,313,313, /* block 27 */ -119,119,317,317,119,318,318,318,318,318,318,318,318,318,318,318, -318,318,318,318,318,318,318,119,119,119,318,318,318,318,318,318, -318,318,318,318,318,318,318,318,318,318,318,318,318,318,318,318, -318,318,119,318,318,318,318,318,318,318,318,318,119,318,119,119, -318,318,318,318,318,318,318,119,119,119,319,119,119,119,119,320, -317,317,319,319,319,119,319,119,317,317,317,317,317,317,317,320, -119,119,119,119,119,119,321,321,321,321,321,321,321,321,321,321, -119,119,317,317,322,119,119,119,119,119,119,119,119,119,119,119, +120,120,319,319,120,320,320,320,320,320,320,320,320,320,320,320, +320,320,320,320,320,320,320,120,120,120,320,320,320,320,320,320, +320,320,320,320,320,320,320,320,320,320,320,320,320,320,320,320, +320,320,120,320,320,320,320,320,320,320,320,320,120,320,120,120, +320,320,320,320,320,320,320,120,120,120,321,120,120,120,120,322, +319,319,321,321,321,120,321,120,319,319,319,319,319,319,319,322, +120,120,120,120,120,120,323,323,323,323,323,323,323,323,323,323, +120,120,319,319,324,120,120,120,120,120,120,120,120,120,120,120, /* block 28 */ -119,323,323,323,323,323,323,323,323,323,323,323,323,323,323,323, -323,323,323,323,323,323,323,323,323,323,323,323,323,323,323,323, -323,323,323,323,323,323,323,323,323,323,323,323,323,323,323,323, -323,324,323,325,324,324,324,324,324,324,324,119,119,119,119, 6, -323,323,323,323,323,323,326,324,324,324,324,324,324,324,324,327, -328,328,328,328,328,328,328,328,328,328,327,327,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,325,325,325,325,325,325,325,325,325,325,325,325,325,325,325, +325,325,325,325,325,325,325,325,325,325,325,325,325,325,325,325, +325,325,325,325,325,325,325,325,325,325,325,325,325,325,325,325, +325,326,325,327,326,326,326,326,326,326,326,120,120,120,120, 6, +325,325,325,325,325,325,328,326,326,326,326,326,326,326,326,329, +330,330,330,330,330,330,330,330,330,330,329,329,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 29 */ -119,329,329,119,329,119,119,329,329,119,329,119,119,329,119,119, -119,119,119,119,329,329,329,329,119,329,329,329,329,329,329,329, -119,329,329,329,119,329,119,329,119,119,329,329,119,329,329,329, -329,330,329,331,330,330,330,330,330,330,119,330,330,329,119,119, -329,329,329,329,329,119,332,119,330,330,330,330,330,330,119,119, -333,333,333,333,333,333,333,333,333,333,119,119,329,329,329,329, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,331,331,120,331,120,331,331,331,331,331,120,331,331,331,331, +331,331,331,331,331,331,331,331,331,331,331,331,331,331,331,331, +331,331,331,331,120,331,120,331,331,331,331,331,331,331,331,331, +331,332,331,333,332,332,332,332,332,332,332,332,332,331,120,120, +331,331,331,331,331,120,334,120,332,332,332,332,332,332,120,120, +335,335,335,335,335,335,335,335,335,335,120,120,331,331,331,331, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 30 */ -334,335,335,335,336,336,336,336,336,336,336,336,336,336,336,336, -336,336,336,335,336,335,335,335,337,337,335,335,335,335,335,335, -338,338,338,338,338,338,338,338,338,338,339,339,339,339,339,339, -339,339,339,339,335,337,335,337,335,337,340,341,340,341,342,342, -334,334,334,334,334,334,334,334,119,334,334,334,334,334,334,334, -334,334,334,334,334,334,334,334,334,334,334,334,334,334,334,334, -334,334,334,334,334,334,334,334,334,334,334,334,334,119,119,119, -119,337,337,337,337,337,337,337,337,337,337,337,337,337,337,342, +336,337,337,337,338,338,338,338,338,338,338,338,338,338,338,338, +338,338,338,337,338,337,337,337,339,339,337,337,337,337,337,337, +340,340,340,340,340,340,340,340,340,340,341,341,341,341,341,341, +341,341,341,341,337,339,337,339,337,339,342,343,342,343,344,344, +336,336,336,336,336,336,336,336,120,336,336,336,336,336,336,336, +336,336,336,336,336,336,336,336,336,336,336,336,336,336,336,336, +336,336,336,336,336,336,336,336,336,336,336,336,336,120,120,120, +120,339,339,339,339,339,339,339,339,339,339,339,339,339,339,344, /* block 31 */ -337,337,337,337,337,336,337,337,334,334,334,334,334,337,337,337, -337,337,337,337,337,337,337,337,119,337,337,337,337,337,337,337, -337,337,337,337,337,337,337,337,337,337,337,337,337,337,337,337, -337,337,337,337,337,337,337,337,337,337,337,337,337,119,335,335, -335,335,335,335,335,335,337,335,335,335,335,335,335,119,335,335, -336,336,336,336,336, 20, 20, 20, 20,336,336,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +339,339,339,339,339,338,339,339,336,336,336,336,336,339,339,339, +339,339,339,339,339,339,339,339,120,339,339,339,339,339,339,339, +339,339,339,339,339,339,339,339,339,339,339,339,339,339,339,339, +339,339,339,339,339,339,339,339,339,339,339,339,339,120,337,337, +337,337,337,337,337,337,339,337,337,337,337,337,337,120,337,337, +338,338,338,338,338, 20, 20, 20, 20,338,338,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 32 */ -343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343, -343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343, -343,343,343,343,343,343,343,343,343,343,343,344,344,345,345,345, -345,346,345,345,345,345,345,345,344,345,345,346,346,345,345,343, -347,347,347,347,347,347,347,347,347,347,348,348,348,348,348,348, -343,343,343,343,343,343,346,346,345,345,343,343,343,343,345,345, -345,343,344,344,344,343,343,344,344,344,344,344,344,344,343,343, -343,345,345,345,345,343,343,343,343,343,343,343,343,343,343,343, +345,345,345,345,345,345,345,345,345,345,345,345,345,345,345,345, +345,345,345,345,345,345,345,345,345,345,345,345,345,345,345,345, +345,345,345,345,345,345,345,345,345,345,345,346,346,347,347,347, +347,348,347,347,347,347,347,347,346,347,347,348,348,347,347,345, +349,349,349,349,349,349,349,349,349,349,350,350,350,350,350,350, +345,345,345,345,345,345,348,348,347,347,345,345,345,345,347,347, +347,345,346,346,346,345,345,346,346,346,346,346,346,346,345,345, +345,347,347,347,347,345,345,345,345,345,345,345,345,345,345,345, /* block 33 */ -343,343,345,344,346,345,345,344,344,344,344,344,344,345,343,344, -349,349,349,349,349,349,349,349,349,349,344,344,344,345,350,350, -351,351,351,351,351,351,351,351,351,351,351,351,351,351,351,351, -351,351,351,351,351,351,351,351,351,351,351,351,351,351,351,351, -351,351,351,351,351,351,119,351,119,119,119,119,119,351,119,119, -352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352, -352,352,352,352,352,352,352,352,352,352,352,352,352,352,352,352, -352,352,352,352,352,352,352,352,352,352,352,353,354,352,352,352, +345,345,347,346,348,347,347,346,346,346,346,346,346,347,345,346, +351,351,351,351,351,351,351,351,351,351,346,346,346,347,352,352, +353,353,353,353,353,353,353,353,353,353,353,353,353,353,353,353, +353,353,353,353,353,353,353,353,353,353,353,353,353,353,353,353, +353,353,353,353,353,353,120,353,120,120,120,120,120,353,120,120, +354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354, +354,354,354,354,354,354,354,354,354,354,354,354,354,354,354,354, +354,354,354,354,354,354,354,354,354,354,354,355,356,354,354,354, /* block 34 */ -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, - -/* block 35 */ -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,356,357,357,357,357,357,357,357,357, 357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, 357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, 357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, 357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, 357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, - -/* block 36 */ -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, +357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,119,358,358,358,358,119,119, -358,358,358,358,358,358,358,119,358,119,358,358,358,358,119,119, + +/* block 35 */ 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, 358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, +358,358,358,358,358,358,358,358,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, + +/* block 36 */ +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,120,360,360,360,360,120,120, +360,360,360,360,360,360,360,120,360,120,360,360,360,360,120,120, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, /* block 37 */ -358,358,358,358,358,358,358,358,358,119,358,358,358,358,119,119, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,119,358,358,358,358,119,119,358,358,358,358,358,358,358,119, -358,119,358,358,358,358,119,119,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,119,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, +360,360,360,360,360,360,360,360,360,120,360,360,360,360,120,120, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,120,360,360,360,360,120,120,360,360,360,360,360,360,360,120, +360,120,360,360,360,360,120,120,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,120,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, /* block 38 */ -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,119,358,358,358,358,119,119,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,358,358,358,358,119,119,359,359,359, -360,360,360,360,360,360,360,360,360,361,361,361,361,361,361,361, -361,361,361,361,361,361,361,361,361,361,361,361,361,119,119,119, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,120,360,360,360,360,120,120,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,360,360,360,360,120,120,361,361,361, +362,362,362,362,362,362,362,362,362,363,363,363,363,363,363,363, +363,363,363,363,363,363,363,363,363,363,363,363,363,120,120,120, /* block 39 */ -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -362,362,362,362,362,362,362,362,362,362,119,119,119,119,119,119, -363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363, -363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363, -363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363, -363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363, -363,363,363,363,363,363,363,363,363,363,363,363,363,363,363,363, -364,364,364,364,364,364,119,119,365,365,365,365,365,365,119,119, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +364,364,364,364,364,364,364,364,364,364,120,120,120,120,120,120, +365,365,365,365,365,365,365,365,365,365,365,365,365,365,365,365, +365,365,365,365,365,365,365,365,365,365,365,365,365,365,365,365, +365,365,365,365,365,365,365,365,365,365,365,365,365,365,365,365, +365,365,365,365,365,365,365,365,365,365,365,365,365,365,365,365, +365,365,365,365,365,365,365,365,365,365,365,365,365,365,365,365, +366,366,366,366,366,366,120,120,367,367,367,367,367,367,120,120, /* block 40 */ -366,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, +368,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, /* block 41 */ -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, /* block 42 */ -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,368,368,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,370,371,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, /* block 43 */ -369,370,370,370,370,370,370,370,370,370,370,370,370,370,370,370, -370,370,370,370,370,370,370,370,370,370,370,371,372,119,119,119, -373,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373, -373,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373, -373,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373, -373,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373, -373,373,373,373,373,373,373,373,373,373,373, 5, 5, 5,374,374, -374,373,373,373,373,373,373,373,373,119,119,119,119,119,119,119, +372,373,373,373,373,373,373,373,373,373,373,373,373,373,373,373, +373,373,373,373,373,373,373,373,373,373,373,374,375,120,120,120, +376,376,376,376,376,376,376,376,376,376,376,376,376,376,376,376, +376,376,376,376,376,376,376,376,376,376,376,376,376,376,376,376, +376,376,376,376,376,376,376,376,376,376,376,376,376,376,376,376, +376,376,376,376,376,376,376,376,376,376,376,376,376,376,376,376, +376,376,376,376,376,376,376,376,376,376,376, 5, 5, 5,377,377, +377,376,376,376,376,376,376,376,376,120,120,120,120,120,120,120, /* block 44 */ -375,375,375,375,375,375,375,375,375,375,375,375,375,119,375,375, -375,375,376,376,376,119,119,119,119,119,119,119,119,119,119,119, -377,377,377,377,377,377,377,377,377,377,377,377,377,377,377,377, -377,377,378,378,378,379,379,119,119,119,119,119,119,119,119,119, +378,378,378,378,378,378,378,378,378,378,378,378,378,120,378,378, +378,378,379,379,379,120,120,120,120,120,120,120,120,120,120,120, 380,380,380,380,380,380,380,380,380,380,380,380,380,380,380,380, -380,380,381,381,119,119,119,119,119,119,119,119,119,119,119,119, -382,382,382,382,382,382,382,382,382,382,382,382,382,119,382,382, -382,119,383,383,119,119,119,119,119,119,119,119,119,119,119,119, +380,380,381,381,381,382,382,120,120,120,120,120,120,120,120,120, +383,383,383,383,383,383,383,383,383,383,383,383,383,383,383,383, +383,383,384,384,120,120,120,120,120,120,120,120,120,120,120,120, +385,385,385,385,385,385,385,385,385,385,385,385,385,120,385,385, +385,120,386,386,120,120,120,120,120,120,120,120,120,120,120,120, /* block 45 */ -384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384, -384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384, -384,384,384,384,384,384,384,384,384,384,384,384,384,384,384,384, -384,384,384,384,385,385,386,385,385,385,385,385,385,385,386,386, -386,386,386,386,386,386,385,386,386,385,385,385,385,385,385,385, -385,385,385,385,387,387,387,388,387,387,387,389,384,385,119,119, -390,390,390,390,390,390,390,390,390,390,119,119,119,119,119,119, -391,391,391,391,391,391,391,391,391,391,119,119,119,119,119,119, +387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,387, +387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,387, +387,387,387,387,387,387,387,387,387,387,387,387,387,387,387,387, +387,387,387,387,388,388,389,388,388,388,388,388,388,388,389,389, +389,389,389,389,389,389,388,389,389,388,388,388,388,388,388,388, +388,388,388,388,390,390,390,391,390,390,390,392,387,388,120,120, +393,393,393,393,393,393,393,393,393,393,120,120,120,120,120,120, +394,394,394,394,394,394,394,394,394,394,120,120,120,120,120,120, /* block 46 */ -392,392,393,393,392,393,394,392,392,392,392,395,395,395,396,119, -397,397,397,397,397,397,397,397,397,397,119,119,119,119,119,119, -398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398, -398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398, -398,398,398,399,398,398,398,398,398,398,398,398,398,398,398,398, -398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398, -398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398, -398,398,398,398,398,398,398,398,398,119,119,119,119,119,119,119, +395,395,396,396,395,396,397,395,395,395,395,398,398,398,399,120, +400,400,400,400,400,400,400,400,400,400,120,120,120,120,120,120, +401,401,401,401,401,401,401,401,401,401,401,401,401,401,401,401, +401,401,401,401,401,401,401,401,401,401,401,401,401,401,401,401, +401,401,401,402,401,401,401,401,401,401,401,401,401,401,401,401, +401,401,401,401,401,401,401,401,401,401,401,401,401,401,401,401, +401,401,401,401,401,401,401,401,401,401,401,401,401,401,401,401, +401,401,401,401,401,401,401,401,401,120,120,120,120,120,120,120, /* block 47 */ -398,398,398,398,398,395,395,398,398,398,398,398,398,398,398,398, -398,398,398,398,398,398,398,398,398,398,398,398,398,398,398,398, -398,398,398,398,398,398,398,398,398,395,398,119,119,119,119,119, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,367,367,367,367,367,367,367,367,367,367, -367,367,367,367,367,367,119,119,119,119,119,119,119,119,119,119, +401,401,401,401,401,398,398,401,401,401,401,401,401,401,401,401, +401,401,401,401,401,401,401,401,401,401,401,401,401,401,401,401, +401,401,401,401,401,401,401,401,401,398,401,120,120,120,120,120, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,369,369,369,369,369,369,369,369,369,369, +369,369,369,369,369,369,120,120,120,120,120,120,120,120,120,120, /* block 48 */ -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,400, -400,400,400,400,400,400,400,400,400,400,400,400,400,400,400,119, -401,401,401,402,402,402,402,401,401,402,402,402,119,119,119,119, -402,402,401,402,402,402,402,402,402,401,401,401,119,119,119,119, -403,119,119,119,404,404,405,405,405,405,405,405,405,405,405,405, -406,406,406,406,406,406,406,406,406,406,406,406,406,406,406,406, -406,406,406,406,406,406,406,406,406,406,406,406,406,406,119,119, -406,406,406,406,406,119,119,119,119,119,119,119,119,119,119,119, +403,403,403,403,403,403,403,403,403,403,403,403,403,403,403,403, +403,403,403,403,403,403,403,403,403,403,403,403,403,403,403,120, +404,404,404,405,405,405,405,404,404,405,405,405,120,120,120,120, +405,405,404,405,405,405,405,405,405,404,404,404,120,120,120,120, +406,120,120,120,407,407,408,408,408,408,408,408,408,408,408,408, +409,409,409,409,409,409,409,409,409,409,409,409,409,409,409,409, +409,409,409,409,409,409,409,409,409,409,409,409,409,409,120,120, +409,409,409,409,409,120,120,120,120,120,120,120,120,120,120,120, /* block 49 */ -407,407,407,407,407,407,407,407,407,407,407,407,407,407,407,407, -407,407,407,407,407,407,407,407,407,407,407,407,407,407,407,407, -407,407,407,407,407,407,407,407,407,407,407,407,119,119,119,119, -407,407,407,407,407,407,407,407,407,407,407,407,407,407,407,407, -407,407,407,407,407,407,407,407,407,407,119,119,119,119,119,119, -408,408,408,408,408,408,408,408,408,408,409,119,119,119,410,410, -411,411,411,411,411,411,411,411,411,411,411,411,411,411,411,411, -411,411,411,411,411,411,411,411,411,411,411,411,411,411,411,411, +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410, +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410, +410,410,410,410,410,410,410,410,410,410,410,410,120,120,120,120, +410,410,410,410,410,410,410,410,410,410,410,410,410,410,410,410, +410,410,410,410,410,410,410,410,410,410,120,120,120,120,120,120, +411,411,411,411,411,411,411,411,411,411,412,120,120,120,413,413, +414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414, +414,414,414,414,414,414,414,414,414,414,414,414,414,414,414,414, /* block 50 */ -412,412,412,412,412,412,412,412,412,412,412,412,412,412,412,412, -412,412,412,412,412,412,412,413,413,414,414,413,119,119,415,415, -416,416,416,416,416,416,416,416,416,416,416,416,416,416,416,416, -416,416,416,416,416,416,416,416,416,416,416,416,416,416,416,416, -416,416,416,416,416,416,416,416,416,416,416,416,416,416,416,416, -416,416,416,416,416,417,418,417,418,418,418,418,418,418,418,119, -418,419,418,419,419,418,418,418,418,418,418,418,418,417,417,417, -417,417,417,418,418,418,418,418,418,418,418,418,418,119,119,418, +415,415,415,415,415,415,415,415,415,415,415,415,415,415,415,415, +415,415,415,415,415,415,415,416,416,417,417,416,120,120,418,418, +419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419, +419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419, +419,419,419,419,419,419,419,419,419,419,419,419,419,419,419,419, +419,419,419,419,419,420,421,420,421,421,421,421,421,421,421,120, +421,422,421,422,422,421,421,421,421,421,421,421,421,420,420,420, +420,420,420,421,421,421,421,421,421,421,421,421,421,120,120,421, /* block 51 */ -420,420,420,420,420,420,420,420,420,420,119,119,119,119,119,119, -420,420,420,420,420,420,420,420,420,420,119,119,119,119,119,119, -421,421,421,421,421,421,421,422,421,421,421,421,421,421,119,119, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,423,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +423,423,423,423,423,423,423,423,423,423,120,120,120,120,120,120, +423,423,423,423,423,423,423,423,423,423,120,120,120,120,120,120, +424,424,424,424,424,424,424,425,424,424,424,424,424,424,120,120, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,426,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 52 */ -424,424,424,424,425,426,426,426,426,426,426,426,426,426,426,426, -426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426, -426,426,426,426,426,426,426,426,426,426,426,426,426,426,426,426, -426,426,426,426,424,425,424,424,424,424,424,425,424,425,425,425, -425,425,424,425,425,426,426,426,426,426,426,426,119,119,119,119, -427,427,427,427,427,427,427,427,427,427,428,428,428,428,428,428, -428,429,429,429,429,429,429,429,429,429,429,424,424,424,424,424, -424,424,424,424,429,429,429,429,429,429,429,429,429,119,119,119, +427,427,427,427,428,429,429,429,429,429,429,429,429,429,429,429, +429,429,429,429,429,429,429,429,429,429,429,429,429,429,429,429, +429,429,429,429,429,429,429,429,429,429,429,429,429,429,429,429, +429,429,429,429,427,430,427,427,427,427,427,428,427,428,428,428, +428,428,427,428,428,429,429,429,429,429,429,429,120,120,120,120, +431,431,431,431,431,431,431,431,431,431,432,432,432,432,432,432, +432,433,433,433,433,433,433,433,433,433,433,427,427,427,427,427, +427,427,427,427,433,433,433,433,433,433,433,433,433,120,120,120, /* block 53 */ -430,430,431,432,432,432,432,432,432,432,432,432,432,432,432,432, -432,432,432,432,432,432,432,432,432,432,432,432,432,432,432,432, -432,431,430,430,430,430,431,431,430,430,431,430,430,430,432,432, -433,433,433,433,433,433,433,433,433,433,432,432,432,432,432,432, -434,434,434,434,434,434,434,434,434,434,434,434,434,434,434,434, -434,434,434,434,434,434,434,434,434,434,434,434,434,434,434,434, -434,434,434,434,434,434,435,436,435,435,436,436,436,435,436,435, -435,435,436,436,119,119,119,119,119,119,119,119,437,437,437,437, - -/* block 54 */ +434,434,435,436,436,436,436,436,436,436,436,436,436,436,436,436, +436,436,436,436,436,436,436,436,436,436,436,436,436,436,436,436, +436,435,434,434,434,434,435,435,434,434,435,434,434,434,436,436, +437,437,437,437,437,437,437,437,437,437,436,436,436,436,436,436, 438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,438, 438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,438, -438,438,438,438,439,439,439,439,439,439,439,439,440,440,440,440, -440,440,440,440,439,439,440,440,119,119,119,441,441,441,441,441, -442,442,442,442,442,442,442,442,442,442,119,119,119,438,438,438, -443,443,443,443,443,443,443,443,443,443,444,444,444,444,444,444, -444,444,444,444,444,444,444,444,444,444,444,444,444,444,444,444, -444,444,444,444,444,444,444,444,445,445,445,445,445,445,446,446, +438,438,438,438,438,438,439,440,439,439,440,440,440,439,440,439, +439,439,440,440,120,120,120,120,120,120,120,120,441,441,441,441, + +/* block 54 */ +442,442,442,442,442,442,442,442,442,442,442,442,442,442,442,442, +442,442,442,442,442,442,442,442,442,442,442,442,442,442,442,442, +442,442,442,442,443,443,443,443,443,443,443,443,444,444,444,444, +444,444,444,444,443,443,444,444,120,120,120,445,445,445,445,445, +446,446,446,446,446,446,446,446,446,446,120,120,120,442,442,442, +447,447,447,447,447,447,447,447,447,447,448,448,448,448,448,448, +448,448,448,448,448,448,448,448,448,448,448,448,448,448,448,448, +448,448,448,448,448,448,448,448,449,449,449,449,449,449,450,450, /* block 55 */ -447,448,449,450,451,452,453,454,455,119,119,119,119,119,119,119, -456,456,456,456,456,456,456,456,456,456,456,456,456,456,456,456, -456,456,456,456,456,456,456,456,456,456,456,456,456,456,456,456, -456,456,456,456,456,456,456,456,456,456,456,119,119,456,456,456, -457,457,457,457,457,457,457,457,119,119,119,119,119,119,119,119, -458,459,458,460,459,461,461,462,461,462,463,459,462,462,459,459, -462,464,459,459,459,459,459,459,459,465,466,465,465,461,465,465, -465,465,467,467,468,466,466,469,470,470,119,119,119,119,119,119, +451,452,453,454,455,456,457,458,459,120,120,120,120,120,120,120, +460,460,460,460,460,460,460,460,460,460,460,460,460,460,460,460, +460,460,460,460,460,460,460,460,460,460,460,460,460,460,460,460, +460,460,460,460,460,460,460,460,460,460,460,120,120,460,460,460, +461,461,461,461,461,461,461,461,120,120,120,120,120,120,120,120, +462,463,462,464,463,465,465,466,465,466,467,463,466,466,463,463, +466,468,463,463,463,463,463,463,463,469,470,471,471,465,471,471, +471,471,472,473,474,470,470,475,476,476,477,120,120,120,120,120, /* block 56 */ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35,127,127,127,127,127,471,109,109,109,109, -109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109, -109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109, -109,109,109,109,109,109,109,109,109,109,109,109,109,120,120,120, -120,120,109,109,109,109,120,120,120,120,120, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35,472,473, 35, 35, 35,474, 35, 35, + 35, 35, 35, 35, 35, 35,128,128,128,128,128,478,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,121,121,121, +121,121,110,110,110,110,121,121,121,121,121, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35,479,480, 35, 35, 35,481, 35, 35, /* block 57 */ - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,109,109,109,109,109, -109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,109, -109,109,109,109,109,109,109,109,109,109,109,109,109,109,109,120, -113,113,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,119,112,112,112,112,112, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,482, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,110,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110, +110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,121, +114,114,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,120,113,113,113,113,113, /* block 58 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, @@ -2251,12 +2286,12 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, -475,476, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, +483,484, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, /* block 59 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, - 32, 33, 32, 33, 32, 33, 35, 35, 35, 35, 35,477, 35, 35,478, 35, + 32, 33, 32, 33, 32, 33, 35, 35, 35, 35, 35,485, 35, 35,486, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, @@ -2265,58 +2300,58 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, /* block 60 */ -479,479,479,479,479,479,479,479,480,480,480,480,480,480,480,480, -479,479,479,479,479,479,119,119,480,480,480,480,480,480,119,119, -479,479,479,479,479,479,479,479,480,480,480,480,480,480,480,480, -479,479,479,479,479,479,479,479,480,480,480,480,480,480,480,480, -479,479,479,479,479,479,119,119,480,480,480,480,480,480,119,119, -127,479,127,479,127,479,127,479,119,480,119,480,119,480,119,480, -479,479,479,479,479,479,479,479,480,480,480,480,480,480,480,480, -481,481,482,482,482,482,483,483,484,484,485,485,486,486,119,119, +487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, +487,487,487,487,487,487,120,120,488,488,488,488,488,488,120,120, +487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, +487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, +487,487,487,487,487,487,120,120,488,488,488,488,488,488,120,120, +128,487,128,487,128,487,128,487,120,488,120,488,120,488,120,488, +487,487,487,487,487,487,487,487,488,488,488,488,488,488,488,488, +489,489,490,490,490,490,491,491,492,492,493,493,494,494,120,120, /* block 61 */ -479,479,479,479,479,479,479,479,487,487,487,487,487,487,487,487, -479,479,479,479,479,479,479,479,487,487,487,487,487,487,487,487, -479,479,479,479,479,479,479,479,487,487,487,487,487,487,487,487, -479,479,127,488,127,119,127,127,480,480,489,489,490,118,491,118, -118,118,127,488,127,119,127,127,492,492,492,492,490,118,118,118, -479,479,127,127,119,119,127,127,480,480,493,493,119,118,118,118, -479,479,127,127,127,168,127,127,480,480,494,494,173,118,118,118, -119,119,127,488,127,119,127,127,495,495,496,496,490,118,118,119, +487,487,487,487,487,487,487,487,495,495,495,495,495,495,495,495, +487,487,487,487,487,487,487,487,495,495,495,495,495,495,495,495, +487,487,487,487,487,487,487,487,495,495,495,495,495,495,495,495, +487,487,128,496,128,120,128,128,488,488,497,497,498,119,499,119, +119,119,128,496,128,120,128,128,500,500,500,500,498,119,119,119, +487,487,128,128,120,120,128,128,488,488,501,501,120,119,119,119, +487,487,128,128,128,169,128,128,488,488,502,502,174,119,119,119, +120,120,128,496,128,120,128,128,503,503,504,504,498,119,119,120, /* block 62 */ - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24,497,498, 24, 24, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 24,505,506, 24, 24, 10, 10, 10, 10, 10, 10, 5, 5, 23, 27, 7, 23, 23, 27, 7, 23, - 5, 5, 5, 5, 5, 5, 5, 5,499,500, 24, 24, 24, 24, 24, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 23, 27, 5,501, 5, 5, 16, - 16, 5, 5, 5, 9, 7, 8, 5, 5,501, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5,507,508, 24, 24, 24, 24, 24,509, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 23, 27, 5,510, 5, 5, 16, + 16, 5, 5, 5, 9, 7, 8, 5, 5,510, 5, 5, 5, 5, 5, 5, 5, 5, 9, 5, 16, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, - 24, 24, 24, 24, 24,502, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, - 25,109,119,119, 25, 25, 25, 25, 25, 25, 9, 9, 9, 7, 8,109, + 24, 24, 24, 24, 24,511, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 25,110,120,120, 25, 25, 25, 25, 25, 25, 9, 9, 9, 7, 8,110, /* block 63 */ - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 9, 9, 9, 7, 8,119, -109,109,109,109,109,109,109,109,109,109,109,109,109,119,119,119, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 9, 9, 9, 7, 8,120, +110,110,110,110,110,110,110,110,110,110,110,110,110,120,120,120, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -112,112,112,112,112,112,112,112,112,112,112,112,112,423,423,423, -423,112,423,423,423,112,112,112,112,112,112,112,112,112,112,112, -503,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +113,113,113,113,113,113,113,113,113,113,113,113,113,426,426,426, +426,113,426,426,426,113,113,113,113,113,113,113,113,113,113,113, +512,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 64 */ - 20, 20,504, 20, 20, 20, 20,504, 20, 20,505,504,504,504,505,505, -504,504,504,505, 20,504, 20, 20, 9,504,504,504,504,504, 20, 20, - 20, 20, 21, 20,504, 20,506, 20,504, 20,507,508,504,504, 20,505, -504,504,509,504,505,510,510,510,510,511, 20, 20,505,505,504,504, - 9, 9, 9, 9, 9,504,505,505,505,505, 20, 9, 20, 20,512, 20, + 20, 20,513, 20, 20, 20, 20,513, 20, 20,514,513,513,513,514,514, +513,513,513,514, 20,513, 20, 20, 9,513,513,513,513,513, 20, 20, + 20, 20, 21, 20,513, 20,515, 20,513, 20,516,517,513,513, 20,514, +513,513,518,513,514,519,519,519,519,520, 20, 20,514,514,513,513, + 9, 9, 9, 9, 9,513,514,514,514,514, 20, 9, 20, 20,521, 20, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, -514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +522,522,522,522,522,522,522,522,522,522,522,522,522,522,522,522, +523,523,523,523,523,523,523,523,523,523,523,523,523,523,523,523, /* block 65 */ -515,515,515, 32, 33,515,515,515,515, 25, 20, 20,119,119,119,119, - 9, 9, 9, 9,516, 21, 21, 21, 21, 21, 9, 9, 20, 20, 20, 20, +524,524,524, 32, 33,524,524,524,524, 25, 20, 20,120,120,120,120, + 9, 9, 9, 9,525, 21, 21, 21, 21, 21, 9, 9, 20, 20, 20, 20, 9, 20, 20, 9, 20, 20, 9, 20, 20, 21, 21, 20, 20, 20, 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 9, 9, @@ -2357,10 +2392,10 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ /* block 69 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, + 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, @@ -2368,10 +2403,10 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20,517,517,517,517,517,517,517,517,517,517, -517,517,518,517,517,517,517,517,517,517,517,517,517,517,517,517, -519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519, -519,519,519,519,519,519,519,519,519,519, 25, 25, 25, 25, 25, 25, + 20, 20, 20, 20, 20, 20,526,526,526,526,526,526,526,526,526,526, +526,526,527,526,526,526,526,526,526,526,526,526,526,526,526,526, +528,528,528,528,528,528,528,528,528,528,528,528,528,528,528,528, +528,528,528,528,528,528,528,528,528,528, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, /* block 71 */ @@ -2392,7 +2427,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 21, 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 9, 9, 9,516,516,516,516, 9, + 20, 20, 20, 20, 20, 20, 20, 20, 9, 9, 9,525,525,525,525, 9, /* block 73 */ 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -2401,7 +2436,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,516, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,525, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, /* block 74 */ @@ -2435,20 +2470,20 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, /* block 77 */ -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, -520,520,520,520,520,520,520,520,520,520,520,520,520,520,520,520, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, +529,529,529,529,529,529,529,529,529,529,529,529,529,529,529,529, /* block 78 */ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9,516,516, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9,525,525, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -2472,167 +2507,167 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 9, 9, 9, 9, 9, 20, 20, 9, 9, 9, 9, 9, 9, 20, 20, 20, 21, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20,119,119, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, /* block 81 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20,119,119, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20,120,120, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20,119, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,119, /* block 82 */ -521,521,521,521,521,521,521,521,521,521,521,521,521,521,521,521, -521,521,521,521,521,521,521,521,521,521,521,521,521,521,521,521, -521,521,521,521,521,521,521,521,521,521,521,521,521,521,521,119, -522,522,522,522,522,522,522,522,522,522,522,522,522,522,522,522, -522,522,522,522,522,522,522,522,522,522,522,522,522,522,522,522, -522,522,522,522,522,522,522,522,522,522,522,522,522,522,522,119, - 32, 33,523,524,525,526,527, 32, 33, 32, 33, 32, 33,528,529,530, -531, 35, 32, 33, 35, 32, 33, 35, 35, 35, 35, 35,109,109,532,532, +530,530,530,530,530,530,530,530,530,530,530,530,530,530,530,530, +530,530,530,530,530,530,530,530,530,530,530,530,530,530,530,530, +530,530,530,530,530,530,530,530,530,530,530,530,530,530,530,120, +531,531,531,531,531,531,531,531,531,531,531,531,531,531,531,531, +531,531,531,531,531,531,531,531,531,531,531,531,531,531,531,531, +531,531,531,531,531,531,531,531,531,531,531,531,531,531,531,120, + 32, 33,532,533,534,535,536, 32, 33, 32, 33, 32, 33,537,538,539, +540, 35, 32, 33, 35, 32, 33, 35, 35, 35, 35, 35,110,110,541,541, /* block 83 */ -164,165,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -164,165,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -164,165,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -164,165,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -164,165,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -164,165,164,165,164,165,164,165,164,165,164,165,164,165,164,165, -164,165,164,165,533,534,534,534,534,534,534,164,165,164,165,535, -535,535,164,165,119,119,119,119,119,536,536,536,536,537,536,536, +165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +165,166,165,166,165,166,165,166,165,166,165,166,165,166,165,166, +165,166,165,166,542,543,543,543,543,543,543,165,166,165,166,544, +544,544,165,166,120,120,120,120,120,545,545,545,545,546,545,545, /* block 84 */ -538,538,538,538,538,538,538,538,538,538,538,538,538,538,538,538, -538,538,538,538,538,538,538,538,538,538,538,538,538,538,538,538, -538,538,538,538,538,538,119,538,119,119,119,119,119,538,119,119, -539,539,539,539,539,539,539,539,539,539,539,539,539,539,539,539, -539,539,539,539,539,539,539,539,539,539,539,539,539,539,539,539, -539,539,539,539,539,539,539,539,539,539,539,539,539,539,539,539, -539,539,539,539,539,539,539,539,119,119,119,119,119,119,119,540, -541,119,119,119,119,119,119,119,119,119,119,119,119,119,119,542, +547,547,547,547,547,547,547,547,547,547,547,547,547,547,547,547, +547,547,547,547,547,547,547,547,547,547,547,547,547,547,547,547, +547,547,547,547,547,547,120,547,120,120,120,120,120,547,120,120, +548,548,548,548,548,548,548,548,548,548,548,548,548,548,548,548, +548,548,548,548,548,548,548,548,548,548,548,548,548,548,548,548, +548,548,548,548,548,548,548,548,548,548,548,548,548,548,548,548, +548,548,548,548,548,548,548,548,120,120,120,120,120,120,120,549, +550,120,120,120,120,120,120,120,120,120,120,120,120,120,120,551, /* block 85 */ -358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, -358,358,358,358,358,358,358,119,119,119,119,119,119,119,119,119, -358,358,358,358,358,358,358,119,358,358,358,358,358,358,358,119, -358,358,358,358,358,358,358,119,358,358,358,358,358,358,358,119, -358,358,358,358,358,358,358,119,358,358,358,358,358,358,358,119, -358,358,358,358,358,358,358,119,358,358,358,358,358,358,358,119, -543,543,543,543,543,543,543,543,543,543,543,543,543,543,543,543, -543,543,543,543,543,543,543,543,543,543,543,543,543,543,543,543, +360,360,360,360,360,360,360,360,360,360,360,360,360,360,360,360, +360,360,360,360,360,360,360,120,120,120,120,120,120,120,120,120, +360,360,360,360,360,360,360,120,360,360,360,360,360,360,360,120, +360,360,360,360,360,360,360,120,360,360,360,360,360,360,360,120, +360,360,360,360,360,360,360,120,360,360,360,360,360,360,360,120, +360,360,360,360,360,360,360,120,360,360,360,360,360,360,360,120, +552,552,552,552,552,552,552,552,552,552,552,552,552,552,552,552, +552,552,552,552,552,552,552,552,552,552,552,552,552,552,552,552, /* block 86 */ 5, 5, 23, 27, 23, 27, 5, 5, 5, 23, 27, 5, 23, 27, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 5, 5, 10, 5, 23, 27, 5, 5, - 23, 27, 7, 8, 7, 8, 7, 8, 7, 8, 5, 5, 5, 5, 5,110, + 23, 27, 7, 8, 7, 8, 7, 8, 7, 8, 5, 5, 5, 5, 5,111, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 5, 5, 5, 5, - 10, 5, 7,544, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, + 10, 5, 7,553, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 87 */ -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,119,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,119,119,119,119,119,119,119,119,119,119,119,119, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,120,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,120,120,120,120,120,120,120,120,120,120,120,120, /* block 88 */ -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, /* block 89 */ -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,545,545,545,545,545,545,545,545,545,545, -545,545,545,545,545,545,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,119,119,119,119, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554, +554,554,554,554,554,554,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120, /* block 90 */ - 4,546,546,547, 20,548,549,550,551,552,551,552,551,552,551,552, -551,552, 20,553,551,552,551,552,551,552,551,552,554,555,556,556, - 20,550,550,550,550,550,550,550,550,550,557,557,557,557,558,558, -559,560,560,560,560,560, 20,553,550,550,550,548,561,562,563,563, -119,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, + 4,555,555,556, 20,557,558,559,560,561,560,561,560,561,560,561, +560,561, 20,562,560,561,560,561,560,561,560,561,563,564,565,565, + 20,559,559,559,559,559,559,559,559,559,566,566,566,566,567,567, +568,569,569,569,569,569, 20,562,559,559,559,557,570,571,572,572, +120,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, /* block 91 */ -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,119,119,565,565,566,566,567,567,564, -568,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, -569,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, -569,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, -569,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, -569,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, -569,569,569,569,569,569,569,569,569,569,569,546,560,570,570,569, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,120,120,574,574,575,575,576,576,573, +577,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,555,569,579,579,578, /* block 92 */ -119,119,119,119,119,571,571,571,571,571,571,571,571,571,571,571, -571,571,571,571,571,571,571,571,571,571,571,571,571,571,571,571, -571,571,571,571,571,571,571,571,571,571,571,571,571,571,571,571, -119,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +120,120,120,120,120,580,580,580,580,580,580,580,580,580,580,580, +580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, +580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, +120,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, /* block 93 */ -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,119, -563,563,573,573,573,573,563,563,563,563,563,563,563,563,563,563, -571,571,571,571,571,571,571,571,571,571,571,571,571,571,571,571, -571,571,571,571,571,571,571,571,571,571,571,119,119,119,119,119, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, -563,563,563,563,119,119,119,119,119,119,119,119,119,119,119,119, -569,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,120, +572,572,582,582,582,582,572,572,572,572,572,572,572,572,572,572, +580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, +580,580,580,580,580,580,580,580,580,580,580,120,120,120,120,120, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +572,572,572,572,120,120,120,120,120,120,120,120,120,120,120,120, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, /* block 94 */ -574,574,574,574,574,574,574,574,574,574,574,574,574,574,574,574, -574,574,574,574,574,574,574,574,574,574,574,574,574,574,574,119, -573,573,573,573,573,573,573,573,573,573,563,563,563,563,563,563, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, -563,563,563,563,563,563,563,563, 25, 25, 25, 25, 25, 25, 25, 25, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,120, +582,582,582,582,582,582,582,582,582,582,572,572,572,572,572,572, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +572,572,572,572,572,572,572,572, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -574,574,574,574,574,574,574,574,574,574,574,574,574,574,574,574, -574,574,574,574,574,574,574,574,574,574,574,574,574,574,574, 20, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, +583,583,583,583,583,583,583,583,583,583,583,583,583,583,583, 20, /* block 95 */ -573,573,573,573,573,573,573,573,573,573,563,563,563,563,563,563, -563,563,563,563,563,563,563,575,563,575,563,563,563,563,563,563, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, -563, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -563,563,563,563,563,563,563,563,563,563,563,563, 20, 20, 20, 20, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,119, +582,582,582,582,582,582,582,582,582,582,572,572,572,572,572,572, +572,572,572,572,572,572,572,584,572,584,572,572,572,572,572,572, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +572, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +572,572,572,572,572,572,572,572,572,572,572,572, 20, 20, 20, 20, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,572, /* block 96 */ -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,576,576,576,576,576,576,576,576, -576,576,576,576,576,576,576,576,563,563,563,563,563,563,563,563, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, -563, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,563,563,563,563,563, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,585,585,585,585,585,585,585,585, +585,585,585,585,585,585,585,585,572,572,572,572,572,572,572,572, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +572, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,572,572,572,572,572, /* block 97 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -2641,1160 +2676,1190 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, -563,563,563,563,563,563,563,563,563,563,563,563,563,563,563, 20, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, +572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, 20, /* block 98 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, /* block 99 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,119,119,119,119,119,119,119,119,119,119, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,120,120,120,120,120,120,120,120,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, /* block 100 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 101 */ -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,579,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,588,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, /* block 102 */ -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, -578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, +587,587,587,587,587,587,587,587,587,587,587,587,587,587,587,587, /* block 103 */ -578,578,578,578,578,578,578,578,578,578,578,578,578,119,119,119, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -580,580,580,580,580,580,580,580,580,580,580,580,580,580,580,580, -580,580,580,580,580,580,580,119,119,119,119,119,119,119,119,119, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, -581,581,581,581,581,581,581,581,582,582,582,582,582,582,583,583, +587,587,587,587,587,587,587,587,587,587,587,587,587,120,120,120, +589,589,589,589,589,589,589,589,589,589,589,589,589,589,589,589, +589,589,589,589,589,589,589,589,589,589,589,589,589,589,589,589, +589,589,589,589,589,589,589,589,589,589,589,589,589,589,589,589, +589,589,589,589,589,589,589,120,120,120,120,120,120,120,120,120, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,590,590,590,590,590,590,590,590, +590,590,590,590,590,590,590,590,591,591,591,591,591,591,592,592, /* block 104 */ -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, /* block 105 */ -584,584,584,584,584,584,584,584,584,584,584,584,585,586,586,586, -584,584,584,584,584,584,584,584,584,584,584,584,584,584,584,584, -587,587,587,587,587,587,587,587,587,587,584,584,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -191,192,191,192,191,192,191,192,191,192,588,589,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,191,192,590,197, -199,199,199,591,543,543,543,543,543,543,543,543,543,543,591,472, +593,593,593,593,593,593,593,593,593,593,593,593,594,595,595,595, +593,593,593,593,593,593,593,593,593,593,593,593,593,593,593,593, +596,596,596,596,596,596,596,596,596,596,593,593,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +192,193,192,193,192,193,192,193,192,193,597,598,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,599,198, +200,200,200,600,552,552,552,552,552,552,552,552,552,552,600,479, /* block 106 */ -191,192,191,192,191,192,191,192,191,192,191,192,191,192,191,192, -191,192,191,192,191,192,191,192,191,192,191,192,472,472,543,543, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,593,593,593,593,593,593,593,593,593,593, -594,594,595,595,595,595,595,595,119,119,119,119,119,119,119,119, +192,193,192,193,192,193,192,193,192,193,192,193,192,193,192,193, +192,193,192,193,192,193,192,193,192,193,192,193,479,479,552,552, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,602,602,602,602,602,602,602,602,602,602, +603,603,604,604,604,604,604,604,120,120,120,120,120,120,120,120, /* block 107 */ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15,110,110,110,110,110,110,110,110,110, + 15, 15, 15, 15, 15, 15, 15,111,111,111,111,111,111,111,111,111, 15, 15, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 35, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, -109, 35, 35, 35, 35, 35, 35, 35, 35, 32, 33, 32, 33,596, 32, 33, +110, 35, 35, 35, 35, 35, 35, 35, 35, 32, 33, 32, 33,605, 32, 33, /* block 108 */ - 32, 33, 32, 33, 32, 33, 32, 33,110, 15, 15, 32, 33,597, 35, 22, - 32, 33, 32, 33, 35, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, - 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,598,599,600,601,598, 35, -602,603,604,605, 32, 33, 32, 33, 32, 33,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119, 22,109,109, 35, 22, 22, 22, 22, 22, + 32, 33, 32, 33, 32, 33, 32, 33,111, 15, 15, 32, 33,606, 35, 22, + 32, 33, 32, 33,607, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, + 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,608,609,610,611,608, 35, +612,613,614,615, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, +120,120, 32, 33,616,617,618,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120, 22,110,110, 35, 22, 22, 22, 22, 22, /* block 109 */ -606,606,607,606,606,606,607,606,606,606,606,607,606,606,606,606, -606,606,606,606,606,606,606,606,606,606,606,606,606,606,606,606, -606,606,606,608,608,607,607,608,609,609,609,609,119,119,119,119, -610,610,610,611,611,611,612,612,613,612,119,119,119,119,119,119, -614,614,614,614,614,614,614,614,614,614,614,614,614,614,614,614, -614,614,614,614,614,614,614,614,614,614,614,614,614,614,614,614, -614,614,614,614,614,614,614,614,614,614,614,614,614,614,614,614, -614,614,614,614,615,615,615,615,119,119,119,119,119,119,119,119, +619,619,620,619,619,619,620,619,619,619,619,620,619,619,619,619, +619,619,619,619,619,619,619,619,619,619,619,619,619,619,619,619, +619,619,619,621,621,620,620,621,622,622,622,622,120,120,120,120, +623,623,623,624,624,624,625,625,626,625,120,120,120,120,120,120, +627,627,627,627,627,627,627,627,627,627,627,627,627,627,627,627, +627,627,627,627,627,627,627,627,627,627,627,627,627,627,627,627, +627,627,627,627,627,627,627,627,627,627,627,627,627,627,627,627, +627,627,627,627,628,628,628,628,120,120,120,120,120,120,120,120, /* block 110 */ -616,616,617,617,617,617,617,617,617,617,617,617,617,617,617,617, -617,617,617,617,617,617,617,617,617,617,617,617,617,617,617,617, -617,617,617,617,617,617,617,617,617,617,617,617,617,617,617,617, -617,617,617,617,616,616,616,616,616,616,616,616,616,616,616,616, -616,616,616,616,618,618,119,119,119,119,119,119,119,119,619,619, -620,620,620,620,620,620,620,620,620,620,119,119,119,119,119,119, -251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251, -251,621,253,622,253,253,253,253,259,259,259,253,259,253,253,251, +629,629,630,630,630,630,630,630,630,630,630,630,630,630,630,630, +630,630,630,630,630,630,630,630,630,630,630,630,630,630,630,630, +630,630,630,630,630,630,630,630,630,630,630,630,630,630,630,630, +630,630,630,630,629,629,629,629,629,629,629,629,629,629,629,629, +629,629,629,629,631,631,120,120,120,120,120,120,120,120,632,632, +633,633,633,633,633,633,633,633,633,633,120,120,120,120,120,120, +252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252, +252,634,254,635,254,254,254,254,260,260,260,254,260,254,254,252, /* block 111 */ -623,623,623,623,623,623,623,623,623,623,624,624,624,624,624,624, -624,624,624,624,624,624,624,624,624,624,624,624,624,624,624,624, -624,624,624,624,624,624,625,625,625,625,625,625,625,625,626,627, -628,628,628,628,628,628,628,628,628,628,628,628,628,628,628,628, -628,628,628,628,628,628,628,629,629,629,629,629,629,629,629,629, -629,629,630,630,119,119,119,119,119,119,119,119,119,119,119,631, -355,355,355,355,355,355,355,355,355,355,355,355,355,355,355,355, -355,355,355,355,355,355,355,355,355,355,355,355,355,119,119,119, +636,636,636,636,636,636,636,636,636,636,637,637,637,637,637,637, +637,637,637,637,637,637,637,637,637,637,637,637,637,637,637,637, +637,637,637,637,637,637,638,638,638,638,638,638,638,638,639,640, +641,641,641,641,641,641,641,641,641,641,641,641,641,641,641,641, +641,641,641,641,641,641,641,642,642,642,642,642,642,642,642,642, +642,642,643,643,120,120,120,120,120,120,120,120,120,120,120,644, +357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, +357,357,357,357,357,357,357,357,357,357,357,357,357,120,120,120, /* block 112 */ -632,632,632,633,634,634,634,634,634,634,634,634,634,634,634,634, -634,634,634,634,634,634,634,634,634,634,634,634,634,634,634,634, -634,634,634,634,634,634,634,634,634,634,634,634,634,634,634,634, -634,634,634,632,633,633,632,632,632,632,633,633,632,633,633,633, -633,635,635,635,635,635,635,635,635,635,635,635,635,635,119,636, -637,637,637,637,637,637,637,637,637,637,119,119,119,119,635,635, -343,343,343,343,343,345,638,343,343,343,343,343,343,343,343,343, -349,349,349,349,349,349,349,349,349,349,343,343,343,343,343,119, +645,645,645,646,647,647,647,647,647,647,647,647,647,647,647,647, +647,647,647,647,647,647,647,647,647,647,647,647,647,647,647,647, +647,647,647,647,647,647,647,647,647,647,647,647,647,647,647,647, +647,647,647,645,646,646,645,645,645,645,646,646,645,645,646,646, +646,648,648,648,648,648,648,648,648,648,648,648,648,648,120,649, +650,650,650,650,650,650,650,650,650,650,120,120,120,120,648,648, +345,345,345,345,345,347,651,345,345,345,345,345,345,345,345,345, +351,351,351,351,351,351,351,351,351,351,345,345,345,345,345,120, /* block 113 */ -639,639,639,639,639,639,639,639,639,639,639,639,639,639,639,639, -639,639,639,639,639,639,639,639,639,639,639,639,639,639,639,639, -639,639,639,639,639,639,639,639,639,640,640,640,640,640,640,641, -641,640,640,641,641,640,640,119,119,119,119,119,119,119,119,119, -639,639,639,640,639,639,639,639,639,639,639,639,640,641,119,119, -642,642,642,642,642,642,642,642,642,642,119,119,643,643,643,643, -343,343,343,343,343,343,343,343,343,343,343,343,343,343,343,343, -638,343,343,343,343,343,343,350,350,350,343,344,345,344,343,343, +652,652,652,652,652,652,652,652,652,652,652,652,652,652,652,652, +652,652,652,652,652,652,652,652,652,652,652,652,652,652,652,652, +652,652,652,652,652,652,652,652,652,653,653,653,653,653,653,654, +654,653,653,654,654,653,653,120,120,120,120,120,120,120,120,120, +652,652,652,653,652,652,652,652,652,652,652,652,653,654,120,120, +655,655,655,655,655,655,655,655,655,655,120,120,656,656,656,656, +345,345,345,345,345,345,345,345,345,345,345,345,345,345,345,345, +651,345,345,345,345,345,345,352,352,352,345,346,347,346,345,345, /* block 114 */ -644,644,644,644,644,644,644,644,644,644,644,644,644,644,644,644, -644,644,644,644,644,644,644,644,644,644,644,644,644,644,644,644, -644,644,644,644,644,644,644,644,644,644,644,644,644,644,644,644, -645,644,645,645,645,644,644,645,645,644,644,644,644,644,645,645, -644,645,644,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,644,644,646,647,647, -648,648,648,648,648,648,648,648,648,648,648,649,650,650,649,649, -651,651,648,652,652,649,650,119,119,119,119,119,119,119,119,119, +657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +658,657,658,658,658,657,657,658,658,657,657,657,657,657,658,658, +657,658,657,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,657,657,659,660,660, +661,661,661,661,661,661,661,661,661,661,661,662,663,663,662,662, +664,664,661,665,665,662,663,120,120,120,120,120,120,120,120,120, /* block 115 */ -119,358,358,358,358,358,358,119,119,358,358,358,358,358,358,119, -119,358,358,358,358,358,358,119,119,119,119,119,119,119,119,119, -358,358,358,358,358,358,358,119,358,358,358,358,358,358,358,119, +120,360,360,360,360,360,360,120,120,360,360,360,360,360,360,120, +120,360,360,360,360,360,360,120,120,120,120,120,120,120,120,120, +360,360,360,360,360,360,360,120,360,360,360,360,360,360,360,120, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, - 35, 35, 35,653, 35, 35, 35, 35, 35, 35, 35, 15,109,109,109,109, - 35, 35, 35, 35, 35,127,119,119,119,119,119,119,119,119,119,119, -654,654,654,654,654,654,654,654,654,654,654,654,654,654,654,654, + 35, 35, 35,666, 35, 35, 35, 35, 35, 35, 35, 15,110,110,110,110, + 35, 35, 35, 35, 35,128, 35, 35,120,120,120,120,120,120,120,120, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, /* block 116 */ -654,654,654,654,654,654,654,654,654,654,654,654,654,654,654,654, -654,654,654,654,654,654,654,654,654,654,654,654,654,654,654,654, -654,654,654,654,654,654,654,654,654,654,654,654,654,654,654,654, -654,654,654,654,654,654,654,654,654,654,654,654,654,654,654,654, -648,648,648,648,648,648,648,648,648,648,648,648,648,648,648,648, -648,648,648,648,648,648,648,648,648,648,648,648,648,648,648,648, -648,648,648,649,649,650,649,649,650,649,649,651,649,650,119,119, -655,655,655,655,655,655,655,655,655,655,119,119,119,119,119,119, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, +667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, +661,661,661,661,661,661,661,661,661,661,661,661,661,661,661,661, +661,661,661,661,661,661,661,661,661,661,661,661,661,661,661,661, +661,661,661,662,662,663,662,662,663,662,662,664,662,663,120,120, +668,668,668,668,668,668,668,668,668,668,120,120,120,120,120,120, /* block 117 */ -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, /* block 118 */ -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, /* block 119 */ -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, /* block 120 */ -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, /* block 121 */ -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, /* block 122 */ -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, /* block 123 */ -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -656,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,656,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,656,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +669,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,669,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,669,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, /* block 124 */ -657,657,657,657,657,657,657,657,656,657,657,657,657,657,657,657, -657,657,657,657,657,657,657,657,657,657,657,657,657,657,657,657, -657,657,657,657,119,119,119,119,119,119,119,119,119,119,119,119, -356,356,356,356,356,356,356,356,356,356,356,356,356,356,356,356, -356,356,356,356,356,356,356,119,119,119,119,357,357,357,357,357, -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, -357,357,357,357,357,357,357,357,357,357,357,357,357,357,357,357, -357,357,357,357,357,357,357,357,357,357,357,357,119,119,119,119, +670,670,670,670,670,670,670,670,669,670,670,670,670,670,670,670, +670,670,670,670,670,670,670,670,670,670,670,670,670,670,670,670, +670,670,670,670,120,120,120,120,120,120,120,120,120,120,120,120, +358,358,358,358,358,358,358,358,358,358,358,358,358,358,358,358, +358,358,358,358,358,358,358,120,120,120,120,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,359,359,359,359, +359,359,359,359,359,359,359,359,359,359,359,359,120,120,120,120, /* block 125 */ -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, -658,658,658,658,658,658,658,658,658,658,658,658,658,658,658,658, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, +671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, /* block 126 */ -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, /* block 127 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,119,119, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, /* block 128 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 129 */ - 35, 35, 35, 35, 35, 35, 35,119,119,119,119,119,119,119,119,119, -119,119,119,205,205,205,205,205,119,119,119,119,119,214,211,214, -214,214,214,214,214,214,214,214,214,660,214,214,214,214,214,214, -214,214,214,214,214,214,214,119,214,214,214,214,214,119,214,119, -214,214,119,214,214,119,214,214,214,214,214,214,214,214,214,214, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, + 35, 35, 35, 35, 35, 35, 35,120,120,120,120,120,120,120,120,120, +120,120,120,206,206,206,206,206,120,120,120,120,120,215,212,215, +215,215,215,215,215,215,215,215,215,673,215,215,215,215,215,215, +215,215,215,215,215,215,215,120,215,215,215,215,215,120,215,120, +215,215,120,215,215,120,215,215,215,215,215,215,215,215,215,215, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 130 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,661,661,661,661,661,661,661,661,661,661,661,661,661,661, -661,661,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,674,674,674,674,674,674,674,674,674,674,674,674,674,674, +674,674,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 131 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 132 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224, 8, 7, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225, 8, 7, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, /* block 133 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -119,119,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -224,224,662,224,224,224,224,224,224,224,224,224,219,663,119,119, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +120,120,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +225,225,675,225,225,225,225,225,225,225,225,225,220,676,120,120, /* block 134 */ -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, - 5, 5, 5, 5, 5, 5, 5, 7, 8, 5,119,119,119,119,119,119, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,543,543, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, + 5, 5, 5, 5, 5, 5, 5, 7, 8, 5,120,120,120,120,120,120, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,552,552, 5, 10, 10, 16, 16, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8, 7, - 8, 7, 8, 7, 8,547,547, 7, 8, 5, 5, 5, 5, 16, 16, 16, - 5, 5, 5,119, 5, 5, 5, 5, 10, 7, 8, 7, 8, 7, 8, 5, - 5, 5, 9, 10, 9, 9, 9,119, 5, 6, 5, 5,119,119,119,119, -224,224,224,224,224,119,224,224,224,224,224,224,224,224,224,224, + 8, 7, 8, 7, 8,556,556, 7, 8, 5, 5, 5, 5, 16, 16, 16, + 5, 5, 5,120, 5, 5, 5, 5, 10, 7, 8, 7, 8, 7, 8, 5, + 5, 5, 9, 10, 9, 9, 9,120, 5, 6, 5, 5,120,120,120,120, +225,225,225,225,225,120,225,225,225,225,225,225,225,225,225,225, /* block 135 */ -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,119,119, 24, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,120,120, 24, /* block 136 */ -119, 5, 5, 5, 6, 5, 5, 5, 7, 8, 5, 9, 5, 10, 5, 5, +120, 5, 5, 5, 6, 5, 5, 5, 7, 8, 5, 9, 5, 10, 5, 5, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 5, 5, 9, 9, 9, 5, 5, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 7, 5, 8, 15, 16, 15, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 7, 9, 8, 9, 7, - 8,546,551,552,546,546,569,569,569,569,569,569,569,569,569,569, -560,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, + 8,555,560,561,555,555,578,578,578,578,578,578,578,578,578,578, +569,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, /* block 137 */ -569,569,569,569,569,569,569,569,569,569,569,569,569,569,569,569, -569,569,569,569,569,569,569,569,569,569,569,569,569,569,664,664, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,572, -572,572,572,572,572,572,572,572,572,572,572,572,572,572,572,119, -119,119,572,572,572,572,572,572,119,119,572,572,572,572,572,572, -119,119,572,572,572,572,572,572,119,119,572,572,572,119,119,119, - 6, 6, 9, 15, 20, 6, 6,119, 20, 9, 9, 9, 9, 20, 20,119, -502,502,502,502,502,502,502,502,502, 24, 24, 24, 20, 20,119,119, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,578,578, +578,578,578,578,578,578,578,578,578,578,578,578,578,578,677,677, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,581, +581,581,581,581,581,581,581,581,581,581,581,581,581,581,581,120, +120,120,581,581,581,581,581,581,120,120,581,581,581,581,581,581, +120,120,581,581,581,581,581,581,120,120,581,581,581,120,120,120, + 6, 6, 9, 15, 20, 6, 6,120, 20, 9, 9, 9, 9, 20, 20,120, +511,511,511,511,511,511,511,511,511, 24, 24, 24, 20, 20,120,120, /* block 138 */ -665,665,665,665,665,665,665,665,665,665,665,665,119,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,119,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,119,665,665,119,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,119,119, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +678,678,678,678,678,678,678,678,678,678,678,678,120,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,120,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,120,678,678,120,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,120,120, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 139 */ -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,665,665,665,665,665, -665,665,665,665,665,665,665,665,665,665,665,119,119,119,119,119, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, +678,678,678,678,678,678,678,678,678,678,678,120,120,120,120,120, /* block 140 */ -666,666,666,119,119,119,119,667,667,667,667,667,667,667,667,667, -667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, -667,667,667,667,667,667,667,667,667,667,667,667,667,667,667,667, -667,667,667,667,119,119,119,668,668,668,668,668,668,668,668,668, -669,669,669,669,669,669,669,669,669,669,669,669,669,669,669,669, -669,669,669,669,669,669,669,669,669,669,669,669,669,669,669,669, -669,669,669,669,669,669,669,669,669,669,669,669,669,669,669,669, -669,669,669,669,669,670,670,670,670,671,671,671,671,671,671,671, +679,679,679,120,120,120,120,680,680,680,680,680,680,680,680,680, +680,680,680,680,680,680,680,680,680,680,680,680,680,680,680,680, +680,680,680,680,680,680,680,680,680,680,680,680,680,680,680,680, +680,680,680,680,120,120,120,681,681,681,681,681,681,681,681,681, +682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682, +682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682, +682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682, +682,682,682,682,682,683,683,683,683,684,684,684,684,684,684,684, /* block 141 */ -671,671,671,671,671,671,671,671,671,671,670,670,671,671,671,119, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,119,119,119,119, -671,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +684,684,684,684,684,684,684,684,684,684,683,683,684,684,684,120, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120, +684,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,112,119,119, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,113,120,120, /* block 142 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 143 */ -672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, -672,672,672,672,672,672,672,672,672,672,672,672,672,119,119,119, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,673,673,673,673,673,673,673,673,673,673,673,673,673,673,673, -673,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -674,675,675,675,675,675,675,675,675,675,675,675,675,675,675,675, -675,675,675,675,675,675,675,675,675,675,675,675,119,119,119,119, +685,685,685,685,685,685,685,685,685,685,685,685,685,685,685,685, +685,685,685,685,685,685,685,685,685,685,685,685,685,120,120,120, +686,686,686,686,686,686,686,686,686,686,686,686,686,686,686,686, +686,686,686,686,686,686,686,686,686,686,686,686,686,686,686,686, +686,686,686,686,686,686,686,686,686,686,686,686,686,686,686,686, +686,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +687,688,688,688,688,688,688,688,688,688,688,688,688,688,688,688, +688,688,688,688,688,688,688,688,688,688,688,688,120,120,120,120, /* block 144 */ -676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, -676,676,676,676,676,676,676,676,676,676,676,676,676,676,676,676, -677,677,677,677,119,119,119,119,119,119,119,119,119,676,676,676, -678,678,678,678,678,678,678,678,678,678,678,678,678,678,678,678, -678,679,678,678,678,678,678,678,678,678,679,119,119,119,119,119, -680,680,680,680,680,680,680,680,680,680,680,680,680,680,680,680, -680,680,680,680,680,680,680,680,680,680,680,680,680,680,680,680, -680,680,680,680,680,680,681,681,681,681,681,119,119,119,119,119, +689,689,689,689,689,689,689,689,689,689,689,689,689,689,689,689, +689,689,689,689,689,689,689,689,689,689,689,689,689,689,689,689, +690,690,690,690,120,120,120,120,120,120,120,120,120,689,689,689, +691,691,691,691,691,691,691,691,691,691,691,691,691,691,691,691, +691,692,691,691,691,691,691,691,691,691,692,120,120,120,120,120, +693,693,693,693,693,693,693,693,693,693,693,693,693,693,693,693, +693,693,693,693,693,693,693,693,693,693,693,693,693,693,693,693, +693,693,693,693,693,693,694,694,694,694,694,120,120,120,120,120, /* block 145 */ -682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682, -682,682,682,682,682,682,682,682,682,682,682,682,682,682,119,683, -684,684,684,684,684,684,684,684,684,684,684,684,684,684,684,684, -684,684,684,684,684,684,684,684,684,684,684,684,684,684,684,684, -684,684,684,684,119,119,119,119,684,684,684,684,684,684,684,684, -685,686,686,686,686,686,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +695,695,695,695,695,695,695,695,695,695,695,695,695,695,695,695, +695,695,695,695,695,695,695,695,695,695,695,695,695,695,120,696, +697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, +697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, +697,697,697,697,120,120,120,120,697,697,697,697,697,697,697,697, +698,699,699,699,699,699,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 146 */ -687,687,687,687,687,687,687,687,687,687,687,687,687,687,687,687, -687,687,687,687,687,687,687,687,687,687,687,687,687,687,687,687, -687,687,687,687,687,687,687,687,688,688,688,688,688,688,688,688, -688,688,688,688,688,688,688,688,688,688,688,688,688,688,688,688, -688,688,688,688,688,688,688,688,688,688,688,688,688,688,688,688, -689,689,689,689,689,689,689,689,689,689,689,689,689,689,689,689, -689,689,689,689,689,689,689,689,689,689,689,689,689,689,689,689, -689,689,689,689,689,689,689,689,689,689,689,689,689,689,689,689, +700,700,700,700,700,700,700,700,700,700,700,700,700,700,700,700, +700,700,700,700,700,700,700,700,700,700,700,700,700,700,700,700, +700,700,700,700,700,700,700,700,701,701,701,701,701,701,701,701, +701,701,701,701,701,701,701,701,701,701,701,701,701,701,701,701, +701,701,701,701,701,701,701,701,701,701,701,701,701,701,701,701, +702,702,702,702,702,702,702,702,702,702,702,702,702,702,702,702, +702,702,702,702,702,702,702,702,702,702,702,702,702,702,702,702, +702,702,702,702,702,702,702,702,702,702,702,702,702,702,702,702, /* block 147 */ -690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690, -690,690,690,690,690,690,690,690,690,690,690,690,690,690,119,119, -691,691,691,691,691,691,691,691,691,691,119,119,119,119,119,119, -692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, -692,692,692,692,692,692,692,692,692,692,692,692,692,692,692,692, -692,692,692,692,119,119,119,119,693,693,693,693,693,693,693,693, -693,693,693,693,693,693,693,693,693,693,693,693,693,693,693,693, -693,693,693,693,693,693,693,693,693,693,693,693,119,119,119,119, +703,703,703,703,703,703,703,703,703,703,703,703,703,703,703,703, +703,703,703,703,703,703,703,703,703,703,703,703,703,703,120,120, +704,704,704,704,704,704,704,704,704,704,120,120,120,120,120,120, +705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705, +705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705, +705,705,705,705,120,120,120,120,706,706,706,706,706,706,706,706, +706,706,706,706,706,706,706,706,706,706,706,706,706,706,706,706, +706,706,706,706,706,706,706,706,706,706,706,706,120,120,120,120, /* block 148 */ -694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694, -694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694, -694,694,694,694,694,694,694,694,119,119,119,119,119,119,119,119, -695,695,695,695,695,695,695,695,695,695,695,695,695,695,695,695, -695,695,695,695,695,695,695,695,695,695,695,695,695,695,695,695, -695,695,695,695,695,695,695,695,695,695,695,695,695,695,695,695, -695,695,695,695,119,119,119,119,119,119,119,119,119,119,119,696, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707, +707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707, +707,707,707,707,707,707,707,707,120,120,120,120,120,120,120,120, +708,708,708,708,708,708,708,708,708,708,708,708,708,708,708,708, +708,708,708,708,708,708,708,708,708,708,708,708,708,708,708,708, +708,708,708,708,708,708,708,708,708,708,708,708,708,708,708,708, +708,708,708,708,120,120,120,120,120,120,120,120,120,120,120,709, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 149 */ -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, /* block 150 */ -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,697,119,119,119,119,119,119,119,119,119, -697,697,697,697,697,697,697,697,697,697,697,697,697,697,697,697, -697,697,697,697,697,697,119,119,119,119,119,119,119,119,119,119, -697,697,697,697,697,697,697,697,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,710,120,120,120,120,120,120,120,120,120, +710,710,710,710,710,710,710,710,710,710,710,710,710,710,710,710, +710,710,710,710,710,710,120,120,120,120,120,120,120,120,120,120, +710,710,710,710,710,710,710,710,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 151 */ -698,698,698,698,698,698,119,119,698,119,698,698,698,698,698,698, -698,698,698,698,698,698,698,698,698,698,698,698,698,698,698,698, -698,698,698,698,698,698,698,698,698,698,698,698,698,698,698,698, -698,698,698,698,698,698,119,698,698,119,119,119,698,119,119,698, -699,699,699,699,699,699,699,699,699,699,699,699,699,699,699,699, -699,699,699,699,699,699,119,700,701,701,701,701,701,701,701,701, -702,702,702,702,702,702,702,702,702,702,702,702,702,702,702,702, -702,702,702,702,702,702,702,703,703,704,704,704,704,704,704,704, +711,711,711,711,711,711,120,120,711,120,711,711,711,711,711,711, +711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, +711,711,711,711,711,711,711,711,711,711,711,711,711,711,711,711, +711,711,711,711,711,711,120,711,711,120,120,120,711,120,120,711, +712,712,712,712,712,712,712,712,712,712,712,712,712,712,712,712, +712,712,712,712,712,712,120,713,714,714,714,714,714,714,714,714, +715,715,715,715,715,715,715,715,715,715,715,715,715,715,715,715, +715,715,715,715,715,715,715,716,716,717,717,717,717,717,717,717, /* block 152 */ -705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705, -705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,119, -119,119,119,119,119,119,119,706,706,706,706,706,706,706,706,706, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -707,707,707,707,707,707,707,707,707,707,707,707,707,707,707,707, -707,707,707,119,707,707,119,119,119,119,119,708,708,708,708,708, +718,718,718,718,718,718,718,718,718,718,718,718,718,718,718,718, +718,718,718,718,718,718,718,718,718,718,718,718,718,718,718,120, +120,120,120,120,120,120,120,719,719,719,719,719,719,719,719,719, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +720,720,720,720,720,720,720,720,720,720,720,720,720,720,720,720, +720,720,720,120,720,720,120,120,120,120,120,721,721,721,721,721, /* block 153 */ -709,709,709,709,709,709,709,709,709,709,709,709,709,709,709,709, -709,709,709,709,709,709,710,710,710,710,710,710,119,119,119,711, -712,712,712,712,712,712,712,712,712,712,712,712,712,712,712,712, -712,712,712,712,712,712,712,712,712,712,119,119,119,119,119,713, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +722,722,722,722,722,722,722,722,722,722,722,722,722,722,722,722, +722,722,722,722,722,722,723,723,723,723,723,723,120,120,120,724, +725,725,725,725,725,725,725,725,725,725,725,725,725,725,725,725, +725,725,725,725,725,725,725,725,725,725,120,120,120,120,120,726, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 154 */ -714,714,714,714,714,714,714,714,714,714,714,714,714,714,714,714, -714,714,714,714,714,714,714,714,714,714,714,714,714,714,714,714, -715,715,715,715,715,715,715,715,715,715,715,715,715,715,715,715, -715,715,715,715,715,715,715,715,119,119,119,119,716,716,715,715, -716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, -119,119,716,716,716,716,716,716,716,716,716,716,716,716,716,716, -716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, -716,716,716,716,716,716,716,716,716,716,716,716,716,716,716,716, +727,727,727,727,727,727,727,727,727,727,727,727,727,727,727,727, +727,727,727,727,727,727,727,727,727,727,727,727,727,727,727,727, +728,728,728,728,728,728,728,728,728,728,728,728,728,728,728,728, +728,728,728,728,728,728,728,728,120,120,120,120,729,729,728,728, +729,729,729,729,729,729,729,729,729,729,729,729,729,729,729,729, +120,120,729,729,729,729,729,729,729,729,729,729,729,729,729,729, +729,729,729,729,729,729,729,729,729,729,729,729,729,729,729,729, +729,729,729,729,729,729,729,729,729,729,729,729,729,729,729,729, /* block 155 */ -717,718,718,718,119,718,718,119,119,119,119,119,718,718,718,718, -717,717,717,717,119,717,717,717,119,717,717,717,717,717,717,717, -717,717,717,717,717,717,717,717,717,717,717,717,717,717,717,717, -717,717,717,717,717,717,119,119,718,718,718,119,119,119,119,718, -719,719,719,719,719,719,719,719,719,119,119,119,119,119,119,119, -720,720,720,720,720,720,720,720,720,119,119,119,119,119,119,119, -721,721,721,721,721,721,721,721,721,721,721,721,721,721,721,721, -721,721,721,721,721,721,721,721,721,721,721,721,721,722,722,723, +730,731,731,731,120,731,731,120,120,120,120,120,731,731,731,731, +730,730,730,730,120,730,730,730,120,730,730,730,730,730,730,730, +730,730,730,730,730,730,730,730,730,730,730,730,730,730,730,730, +730,730,730,730,730,730,120,120,731,731,731,120,120,120,120,731, +732,732,732,732,732,732,732,732,732,120,120,120,120,120,120,120, +733,733,733,733,733,733,733,733,733,120,120,120,120,120,120,120, +734,734,734,734,734,734,734,734,734,734,734,734,734,734,734,734, +734,734,734,734,734,734,734,734,734,734,734,734,734,735,735,736, /* block 156 */ -724,724,724,724,724,724,724,724,724,724,724,724,724,724,724,724, -724,724,724,724,724,724,724,724,724,724,724,724,724,725,725,725, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -726,726,726,726,726,726,726,726,727,726,726,726,726,726,726,726, -726,726,726,726,726,726,726,726,726,726,726,726,726,726,726,726, -726,726,726,726,726,728,728,119,119,119,119,729,729,729,729,729, -730,730,730,730,730,730,730,119,119,119,119,119,119,119,119,119, +737,737,737,737,737,737,737,737,737,737,737,737,737,737,737,737, +737,737,737,737,737,737,737,737,737,737,737,737,737,738,738,738, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +739,739,739,739,739,739,739,739,740,739,739,739,739,739,739,739, +739,739,739,739,739,739,739,739,739,739,739,739,739,739,739,739, +739,739,739,739,739,741,741,120,120,120,120,742,742,742,742,742, +743,743,743,743,743,743,743,120,120,120,120,120,120,120,120,120, /* block 157 */ -731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731, -731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731, -731,731,731,731,731,731,731,731,731,731,731,731,731,731,731,731, -731,731,731,731,731,731,119,119,119,732,732,732,732,732,732,732, -733,733,733,733,733,733,733,733,733,733,733,733,733,733,733,733, -733,733,733,733,733,733,119,119,734,734,734,734,734,734,734,734, -735,735,735,735,735,735,735,735,735,735,735,735,735,735,735,735, -735,735,735,119,119,119,119,119,736,736,736,736,736,736,736,736, +744,744,744,744,744,744,744,744,744,744,744,744,744,744,744,744, +744,744,744,744,744,744,744,744,744,744,744,744,744,744,744,744, +744,744,744,744,744,744,744,744,744,744,744,744,744,744,744,744, +744,744,744,744,744,744,120,120,120,745,745,745,745,745,745,745, +746,746,746,746,746,746,746,746,746,746,746,746,746,746,746,746, +746,746,746,746,746,746,120,120,747,747,747,747,747,747,747,747, +748,748,748,748,748,748,748,748,748,748,748,748,748,748,748,748, +748,748,748,120,120,120,120,120,749,749,749,749,749,749,749,749, /* block 158 */ -737,737,737,737,737,737,737,737,737,737,737,737,737,737,737,737, -737,737,119,119,119,119,119,119,119,738,738,738,738,119,119,119, -119,119,119,119,119,119,119,119,119,739,739,739,739,739,739,739, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +750,750,750,750,750,750,750,750,750,750,750,750,750,750,750,750, +750,750,120,120,120,120,120,120,120,751,751,751,751,120,120,120, +120,120,120,120,120,120,120,120,120,752,752,752,752,752,752,752, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 159 */ -740,740,740,740,740,740,740,740,740,740,740,740,740,740,740,740, -740,740,740,740,740,740,740,740,740,740,740,740,740,740,740,740, -740,740,740,740,740,740,740,740,740,740,740,740,740,740,740,740, -740,740,740,740,740,740,740,740,740,740,740,740,740,740,740,740, -740,740,740,740,740,740,740,740,740,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +753,753,753,753,753,753,753,753,753,753,753,753,753,753,753,753, +753,753,753,753,753,753,753,753,753,753,753,753,753,753,753,753, +753,753,753,753,753,753,753,753,753,753,753,753,753,753,753,753, +753,753,753,753,753,753,753,753,753,753,753,753,753,753,753,753, +753,753,753,753,753,753,753,753,753,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 160 */ -741,741,741,741,741,741,741,741,741,741,741,741,741,741,741,741, -741,741,741,741,741,741,741,741,741,741,741,741,741,741,741,741, -741,741,741,741,741,741,741,741,741,741,741,741,741,741,741,741, -741,741,741,119,119,119,119,119,119,119,119,119,119,119,119,119, -742,742,742,742,742,742,742,742,742,742,742,742,742,742,742,742, -742,742,742,742,742,742,742,742,742,742,742,742,742,742,742,742, -742,742,742,742,742,742,742,742,742,742,742,742,742,742,742,742, -742,742,742,119,119,119,119,119,119,119,743,743,743,743,743,743, +754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, +754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, +754,754,754,754,754,754,754,754,754,754,754,754,754,754,754,754, +754,754,754,120,120,120,120,120,120,120,120,120,120,120,120,120, +755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, +755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, +755,755,755,755,755,755,755,755,755,755,755,755,755,755,755,755, +755,755,755,120,120,120,120,120,120,120,756,756,756,756,756,756, /* block 161 */ -744,744,744,744,744,744,744,744,744,744,744,744,744,744,744,744, -744,744,744,744,744,744,744,744,744,744,744,744,744,744,744,744, -744,744,744,744,745,745,745,745,119,119,119,119,119,119,119,119, -746,746,746,746,746,746,746,746,746,746,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +757,757,757,757,757,757,757,757,757,757,757,757,757,757,757,757, +757,757,757,757,757,757,757,757,757,757,757,757,757,757,757,757, +757,757,757,757,758,758,758,758,120,120,120,120,120,120,120,120, +759,759,759,759,759,759,759,759,759,759,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 162 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -747,747,747,747,747,747,747,747,747,747,747,747,747,747,747,747, -747,747,747,747,747,747,747,747,747,747,747,747,747,747,747,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +760,760,760,760,760,760,760,760,760,760,760,760,760,760,760,760, +760,760,760,760,760,760,760,760,760,760,760,760,760,760,760,120, /* block 163 */ -748,748,748,748,748,748,748,748,748,748,748,748,748,748,748,748, -748,748,748,748,748,748,748,748,748,748,748,748,748,749,749,749, -749,749,749,749,749,749,749,748,119,119,119,119,119,119,119,119, -750,750,750,750,750,750,750,750,750,750,750,750,750,750,750,750, -750,750,750,750,750,750,751,751,751,751,751,751,751,751,751,751, -751,752,752,752,752,753,753,753,753,753,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +761,761,761,761,761,761,761,761,761,761,761,761,761,761,761,761, +761,761,761,761,761,761,761,761,761,761,761,761,761,762,762,762, +762,762,762,762,762,762,762,761,120,120,120,120,120,120,120,120, +763,763,763,763,763,763,763,763,763,763,763,763,763,763,763,763, +763,763,763,763,763,763,764,764,764,764,764,764,764,764,764,764, +764,765,765,765,765,766,766,766,766,766,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 164 */ -754,755,754,756,756,756,756,756,756,756,756,756,756,756,756,756, -756,756,756,756,756,756,756,756,756,756,756,756,756,756,756,756, -756,756,756,756,756,756,756,756,756,756,756,756,756,756,756,756, -756,756,756,756,756,756,756,756,755,755,755,755,755,755,755,755, -755,755,755,755,755,755,755,757,757,757,757,757,757,757,119,119, -119,119,758,758,758,758,758,758,758,758,758,758,758,758,758,758, -758,758,758,758,758,758,759,759,759,759,759,759,759,759,759,759, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,755, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +767,767,767,767,767,767,767,767,767,767,767,767,767,767,767,767, +767,767,767,767,767,767,767,120,120,120,120,120,120,120,120,120, /* block 165 */ -760,760,761,762,762,762,762,762,762,762,762,762,762,762,762,762, -762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762, -762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762, -761,761,761,760,760,760,760,761,761,760,760,763,763,764,763,763, -763,763,119,119,119,119,119,119,119,119,119,119,119,764,119,119, -765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765, -765,765,765,765,765,765,765,765,765,119,119,119,119,119,119,119, -766,766,766,766,766,766,766,766,766,766,119,119,119,119,119,119, +768,769,768,770,770,770,770,770,770,770,770,770,770,770,770,770, +770,770,770,770,770,770,770,770,770,770,770,770,770,770,770,770, +770,770,770,770,770,770,770,770,770,770,770,770,770,770,770,770, +770,770,770,770,770,770,770,770,769,769,769,769,769,769,769,769, +769,769,769,769,769,769,769,771,771,771,771,771,771,771,120,120, +120,120,772,772,772,772,772,772,772,772,772,772,772,772,772,772, +772,772,772,772,772,772,773,773,773,773,773,773,773,773,773,773, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,769, /* block 166 */ -767,767,767,768,768,768,768,768,768,768,768,768,768,768,768,768, -768,768,768,768,768,768,768,768,768,768,768,768,768,768,768,768, -768,768,768,768,768,768,768,767,767,767,767,767,769,767,767,767, -767,767,767,767,767,119,770,770,770,770,770,770,770,770,770,770, -771,771,771,771,768,769,769,119,119,119,119,119,119,119,119,119, -772,772,772,772,772,772,772,772,772,772,772,772,772,772,772,772, -772,772,772,772,772,772,772,772,772,772,772,772,772,772,772,772, -772,772,772,773,774,774,772,119,119,119,119,119,119,119,119,119, +774,774,775,776,776,776,776,776,776,776,776,776,776,776,776,776, +776,776,776,776,776,776,776,776,776,776,776,776,776,776,776,776, +776,776,776,776,776,776,776,776,776,776,776,776,776,776,776,776, +775,775,775,774,774,774,774,775,775,774,774,777,777,778,777,777, +777,777,120,120,120,120,120,120,120,120,120,120,120,778,120,120, +779,779,779,779,779,779,779,779,779,779,779,779,779,779,779,779, +779,779,779,779,779,779,779,779,779,120,120,120,120,120,120,120, +780,780,780,780,780,780,780,780,780,780,120,120,120,120,120,120, /* block 167 */ -775,775,776,777,777,777,777,777,777,777,777,777,777,777,777,777, -777,777,777,777,777,777,777,777,777,777,777,777,777,777,777,777, -777,777,777,777,777,777,777,777,777,777,777,777,777,777,777,777, -777,777,777,776,776,776,775,775,775,775,775,775,775,775,775,776, -776,777,778,778,777,779,779,779,779,775,775,775,775,779,119,119, -780,780,780,780,780,780,780,780,780,780,777,779,777,779,779,779, -119,781,781,781,781,781,781,781,781,781,781,781,781,781,781,781, -781,781,781,781,781,119,119,119,119,119,119,119,119,119,119,119, +781,781,781,782,782,782,782,782,782,782,782,782,782,782,782,782, +782,782,782,782,782,782,782,782,782,782,782,782,782,782,782,782, +782,782,782,782,782,782,782,781,781,781,781,781,783,781,781,781, +781,781,781,781,781,120,784,784,784,784,784,784,784,784,784,784, +785,785,785,785,782,783,783,120,120,120,120,120,120,120,120,120, +786,786,786,786,786,786,786,786,786,786,786,786,786,786,786,786, +786,786,786,786,786,786,786,786,786,786,786,786,786,786,786,786, +786,786,786,787,788,788,786,120,120,120,120,120,120,120,120,120, /* block 168 */ -782,782,782,782,782,782,782,782,782,782,782,782,782,782,782,782, -782,782,119,782,782,782,782,782,782,782,782,782,782,782,782,782, -782,782,782,782,782,782,782,782,782,782,782,782,783,783,783,784, -784,784,783,783,784,783,784,784,785,785,785,785,785,785,784,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +789,789,790,791,791,791,791,791,791,791,791,791,791,791,791,791, +791,791,791,791,791,791,791,791,791,791,791,791,791,791,791,791, +791,791,791,791,791,791,791,791,791,791,791,791,791,791,791,791, +791,791,791,790,790,790,789,789,789,789,789,789,789,789,789,790, +790,791,792,792,791,793,793,793,793,789,789,789,789,793,120,120, +794,794,794,794,794,794,794,794,794,794,791,793,791,793,793,793, +120,795,795,795,795,795,795,795,795,795,795,795,795,795,795,795, +795,795,795,795,795,120,120,120,120,120,120,120,120,120,120,120, /* block 169 */ -786,786,786,786,786,786,786,119,786,119,786,786,786,786,119,786, -786,786,786,786,786,786,786,786,786,786,786,786,786,786,119,786, -786,786,786,786,786,786,786,786,786,787,119,119,119,119,119,119, -788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788, -788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,788, -788,788,788,788,788,788,788,788,788,788,788,788,788,788,788,789, -790,790,790,789,789,789,789,789,789,789,789,119,119,119,119,119, -791,791,791,791,791,791,791,791,791,791,119,119,119,119,119,119, +796,796,796,796,796,796,796,796,796,796,796,796,796,796,796,796, +796,796,120,796,796,796,796,796,796,796,796,796,796,796,796,796, +796,796,796,796,796,796,796,796,796,796,796,796,797,797,797,798, +798,798,797,797,798,797,798,798,799,799,799,799,799,799,798,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 170 */ -792,793,794,795,119,796,796,796,796,796,796,796,796,119,119,796, -796,119,119,796,796,796,796,796,796,796,796,796,796,796,796,796, -796,796,796,796,796,796,796,796,796,119,796,796,796,796,796,796, -796,119,796,796,119,796,796,796,796,796,119,797,793,796,798,794, -792,794,794,794,794,119,119,794,794,119,119,794,794,794,119,119, -796,119,119,119,119,119,119,798,119,119,119,119,119,796,796,796, -796,796,794,794,119,119,792,792,792,792,792,792,792,119,119,119, -792,792,792,792,792,119,119,119,119,119,119,119,119,119,119,119, +800,800,800,800,800,800,800,120,800,120,800,800,800,800,120,800, +800,800,800,800,800,800,800,800,800,800,800,800,800,800,120,800, +800,800,800,800,800,800,800,800,800,801,120,120,120,120,120,120, +802,802,802,802,802,802,802,802,802,802,802,802,802,802,802,802, +802,802,802,802,802,802,802,802,802,802,802,802,802,802,802,802, +802,802,802,802,802,802,802,802,802,802,802,802,802,802,802,803, +804,804,804,803,803,803,803,803,803,803,803,120,120,120,120,120, +805,805,805,805,805,805,805,805,805,805,120,120,120,120,120,120, /* block 171 */ -799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799, -799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799, -799,799,799,799,799,799,799,799,799,799,799,799,799,799,799,799, -799,799,799,799,799,800,800,800,801,801,801,801,801,801,801,801, -800,800,801,801,801,800,801,799,799,799,799,802,802,802,802,802, -803,803,803,803,803,803,803,803,803,803,119,802,119,802,801,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +806,807,808,809,120,810,810,810,810,810,810,810,810,120,120,810, +810,120,120,810,810,810,810,810,810,810,810,810,810,810,810,810, +810,810,810,810,810,810,810,810,810,120,810,810,810,810,810,810, +810,120,810,810,120,810,810,810,810,810,120,811,807,810,812,808, +806,808,808,808,808,120,120,808,808,120,120,808,808,808,120,120, +810,120,120,120,120,120,120,812,120,120,120,120,120,810,810,810, +810,810,808,808,120,120,806,806,806,806,806,806,806,120,120,120, +806,806,806,806,806,120,120,120,120,120,120,120,120,120,120,120, /* block 172 */ -804,804,804,804,804,804,804,804,804,804,804,804,804,804,804,804, -804,804,804,804,804,804,804,804,804,804,804,804,804,804,804,804, -804,804,804,804,804,804,804,804,804,804,804,804,804,804,804,804, -805,806,806,807,807,807,807,807,807,806,807,806,806,805,806,807, -807,806,807,807,804,804,808,804,119,119,119,119,119,119,119,119, -809,809,809,809,809,809,809,809,809,809,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +813,813,813,813,813,813,813,813,813,813,813,813,813,813,813,813, +813,813,813,813,813,813,813,813,813,813,813,813,813,813,813,813, +813,813,813,813,813,813,813,813,813,813,813,813,813,813,813,813, +813,813,813,813,813,814,814,814,815,815,815,815,815,815,815,815, +814,814,815,815,815,814,815,813,813,813,813,816,816,816,816,816, +817,817,817,817,817,817,817,817,817,817,120,816,120,816,815,813, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 173 */ -810,810,810,810,810,810,810,810,810,810,810,810,810,810,810,810, -810,810,810,810,810,810,810,810,810,810,810,810,810,810,810,810, -810,810,810,810,810,810,810,810,810,810,810,810,810,810,810,811, -812,812,813,813,813,813,119,119,812,812,812,812,813,813,812,813, -813,814,814,814,814,814,814,814,814,814,814,814,814,814,814,814, -814,814,814,814,814,814,814,814,810,810,810,810,813,813,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +818,818,818,818,818,818,818,818,818,818,818,818,818,818,818,818, +818,818,818,818,818,818,818,818,818,818,818,818,818,818,818,818, +818,818,818,818,818,818,818,818,818,818,818,818,818,818,818,818, +819,820,820,821,821,821,821,821,821,820,821,820,820,819,820,821, +821,820,821,821,818,818,822,818,120,120,120,120,120,120,120,120, +823,823,823,823,823,823,823,823,823,823,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 174 */ -815,815,815,815,815,815,815,815,815,815,815,815,815,815,815,815, -815,815,815,815,815,815,815,815,815,815,815,815,815,815,815,815, -815,815,815,815,815,815,815,815,815,815,815,815,815,815,815,815, -816,816,816,817,817,817,817,817,817,817,817,816,816,817,816,817, -817,818,818,818,815,119,119,119,119,119,119,119,119,119,119,119, -819,819,819,819,819,819,819,819,819,819,119,119,119,119,119,119, -392,392,392,392,392,392,392,392,392,392,392,392,392,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,824, +824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,824, +824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,825, +826,826,827,827,827,827,120,120,826,826,826,826,827,827,826,827, +827,828,828,828,828,828,828,828,828,828,828,828,828,828,828,828, +828,828,828,828,828,828,828,828,824,824,824,824,827,827,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 175 */ -820,820,820,820,820,820,820,820,820,820,820,820,820,820,820,820, -820,820,820,820,820,820,820,820,820,820,820,820,820,820,820,820, -820,820,820,820,820,820,820,820,820,820,820,821,822,821,822,822, -821,821,821,821,821,821,822,821,119,119,119,119,119,119,119,119, -823,823,823,823,823,823,823,823,823,823,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +829,829,829,829,829,829,829,829,829,829,829,829,829,829,829,829, +829,829,829,829,829,829,829,829,829,829,829,829,829,829,829,829, +829,829,829,829,829,829,829,829,829,829,829,829,829,829,829,829, +830,830,830,831,831,831,831,831,831,831,831,830,830,831,830,831, +831,832,832,832,829,120,120,120,120,120,120,120,120,120,120,120, +833,833,833,833,833,833,833,833,833,833,120,120,120,120,120,120, +395,395,395,395,395,395,395,395,395,395,395,395,395,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 176 */ -824,824,824,824,824,824,824,824,824,824,824,824,824,824,824,824, -824,824,824,824,824,824,824,824,824,824,824,119,119,825,825,825, -826,826,825,825,825,825,826,825,825,825,825,825,119,119,119,119, -827,827,827,827,827,827,827,827,827,827,828,828,829,829,829,830, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +834,834,834,834,834,834,834,834,834,834,834,834,834,834,834,834, +834,834,834,834,834,834,834,834,834,834,834,834,834,834,834,834, +834,834,834,834,834,834,834,834,834,834,834,835,836,835,836,836, +835,835,835,835,835,835,836,835,834,120,120,120,120,120,120,120, +837,837,837,837,837,837,837,837,837,837,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 177 */ -831,831,831,831,831,831,831,831,831,831,831,831,831,831,831,831, -831,831,831,831,831,831,831,831,831,831,831,831,831,831,831,831, -831,831,831,831,831,831,831,831,831,831,831,831,832,832,832,833, -833,833,833,833,833,833,833,833,832,833,833,834,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +838,838,838,838,838,838,838,838,838,838,838,838,838,838,838,838, +838,838,838,838,838,838,838,838,838,838,838,120,120,839,839,839, +840,840,839,839,839,839,840,839,839,839,839,839,120,120,120,120, +841,841,841,841,841,841,841,841,841,841,842,842,843,843,843,844, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 178 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -835,835,835,835,835,835,835,835,835,835,835,835,835,835,835,835, -835,835,835,835,835,835,835,835,835,835,835,835,835,835,835,835, -836,836,836,836,836,836,836,836,836,836,836,836,836,836,836,836, -836,836,836,836,836,836,836,836,836,836,836,836,836,836,836,836, -837,837,837,837,837,837,837,837,837,837,838,838,838,838,838,838, -838,838,838,119,119,119,119,119,119,119,119,119,119,119,119,839, - -/* block 179 */ -840,841,841,841,841,841,841,841,841,841,841,840,840,840,840,840, -840,840,840,840,840,840,840,840,840,840,840,840,840,840,840,840, -840,840,840,840,840,840,840,840,840,840,840,840,840,840,840,840, -840,840,840,841,841,841,841,841,841,842,843,841,841,841,841,844, -844,844,844,844,844,844,844,841,119,119,119,119,119,119,119,119, -845,846,846,846,846,846,846,847,847,846,846,846,845,845,845,845, 845,845,845,845,845,845,845,845,845,845,845,845,845,845,845,845, 845,845,845,845,845,845,845,845,845,845,845,845,845,845,845,845, +845,845,845,845,845,845,845,845,845,845,845,845,846,846,846,847, +847,847,847,847,847,847,847,847,846,847,847,848,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 180 */ -845,845,845,845,119,119,848,848,848,848,846,846,846,846,846,846, -846,846,846,846,846,846,846,847,846,846,849,849,849,845,849,849, -849,849,849,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -850,850,850,850,850,850,850,850,850,850,850,850,850,850,850,850, +/* block 179 */ +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +849,849,849,849,849,849,849,849,849,849,849,849,849,849,849,849, +849,849,849,849,849,849,849,849,849,849,849,849,849,849,849,849, 850,850,850,850,850,850,850,850,850,850,850,850,850,850,850,850, 850,850,850,850,850,850,850,850,850,850,850,850,850,850,850,850, -850,850,850,850,850,850,850,850,850,119,119,119,119,119,119,119, +851,851,851,851,851,851,851,851,851,851,852,852,852,852,852,852, +852,852,852,120,120,120,120,120,120,120,120,120,120,120,120,853, + +/* block 180 */ +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +854,854,854,854,854,854,854,854,120,120,854,854,854,854,854,854, +854,854,854,854,854,854,854,854,854,854,854,854,854,854,854,854, +854,854,854,854,854,854,854,854,854,854,854,854,854,854,854,854, +854,855,855,855,856,856,856,856,120,120,856,856,855,855,855,855, +856,854,857,854,855,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 181 */ -851,851,851,851,851,851,851,851,851,119,851,851,851,851,851,851, -851,851,851,851,851,851,851,851,851,851,851,851,851,851,851,851, -851,851,851,851,851,851,851,851,851,851,851,851,851,851,851,852, -853,853,853,853,853,853,853,119,853,853,853,853,853,853,852,853, -851,854,854,854,854,854,119,119,119,119,119,119,119,119,119,119, -855,855,855,855,855,855,855,855,855,855,856,856,856,856,856,856, -856,856,856,856,856,856,856,856,856,856,856,856,856,119,119,119, -857,857,858,858,858,858,858,858,858,858,858,858,858,858,858,858, +858,859,859,859,859,859,859,859,859,859,859,858,858,858,858,858, +858,858,858,858,858,858,858,858,858,858,858,858,858,858,858,858, +858,858,858,858,858,858,858,858,858,858,858,858,858,858,858,858, +858,858,858,859,859,859,859,859,859,860,861,859,859,859,859,862, +862,862,862,862,862,862,862,859,120,120,120,120,120,120,120,120, +863,864,864,864,864,864,864,865,865,864,864,864,863,863,863,863, +863,863,863,863,863,863,863,863,863,863,863,863,863,863,863,863, +863,863,863,863,863,863,863,863,863,863,863,863,863,863,863,863, /* block 182 */ -858,858,858,858,858,858,858,858,858,858,858,858,858,858,858,858, -119,119,859,859,859,859,859,859,859,859,859,859,859,859,859,859, -859,859,859,859,859,859,859,859,119,860,859,859,859,859,859,859, -859,860,859,859,860,859,859,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +863,863,863,863,866,866,866,866,866,866,864,864,864,864,864,864, +864,864,864,864,864,864,864,865,864,864,867,867,867,863,867,867, +867,867,867,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +868,868,868,868,868,868,868,868,868,868,868,868,868,868,868,868, +868,868,868,868,868,868,868,868,868,868,868,868,868,868,868,868, +868,868,868,868,868,868,868,868,868,868,868,868,868,868,868,868, +868,868,868,868,868,868,868,868,868,120,120,120,120,120,120,120, /* block 183 */ -861,861,861,861,861,861,861,119,861,861,119,861,861,861,861,861, -861,861,861,861,861,861,861,861,861,861,861,861,861,861,861,861, -861,861,861,861,861,861,861,861,861,861,861,861,861,861,861,861, -861,862,862,862,862,862,862,119,119,119,862,119,862,862,119,862, -862,862,862,862,862,862,863,862,119,119,119,119,119,119,119,119, -864,864,864,864,864,864,864,864,864,864,119,119,119,119,119,119, -865,865,865,865,865,865,119,865,865,119,865,865,865,865,865,865, -865,865,865,865,865,865,865,865,865,865,865,865,865,865,865,865, +869,869,869,869,869,869,869,869,869,120,869,869,869,869,869,869, +869,869,869,869,869,869,869,869,869,869,869,869,869,869,869,869, +869,869,869,869,869,869,869,869,869,869,869,869,869,869,869,870, +871,871,871,871,871,871,871,120,871,871,871,871,871,871,870,871, +869,872,872,872,872,872,120,120,120,120,120,120,120,120,120,120, +873,873,873,873,873,873,873,873,873,873,874,874,874,874,874,874, +874,874,874,874,874,874,874,874,874,874,874,874,874,120,120,120, +875,875,876,876,876,876,876,876,876,876,876,876,876,876,876,876, /* block 184 */ -865,865,865,865,865,865,865,865,865,865,866,866,866,866,866,119, -867,867,119,866,866,867,866,867,865,119,119,119,119,119,119,119, -868,868,868,868,868,868,868,868,868,868,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, +120,120,877,877,877,877,877,877,877,877,877,877,877,877,877,877, +877,877,877,877,877,877,877,877,120,878,877,877,877,877,877,877, +877,878,877,877,878,877,877,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 185 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -869,869,869,869,869,869,869,869,869,869,869,869,869,869,869,869, -869,869,869,870,870,871,871,872,872,119,119,119,119,119,119,119, +879,879,879,879,879,879,879,120,879,879,120,879,879,879,879,879, +879,879,879,879,879,879,879,879,879,879,879,879,879,879,879,879, +879,879,879,879,879,879,879,879,879,879,879,879,879,879,879,879, +879,880,880,880,880,880,880,120,120,120,880,120,880,880,120,880, +880,880,880,880,880,880,881,880,120,120,120,120,120,120,120,120, +882,882,882,882,882,882,882,882,882,882,120,120,120,120,120,120, +883,883,883,883,883,883,120,883,883,120,883,883,883,883,883,883, +883,883,883,883,883,883,883,883,883,883,883,883,883,883,883,883, /* block 186 */ -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, +883,883,883,883,883,883,883,883,883,883,884,884,884,884,884,120, +885,885,120,884,884,885,884,885,883,120,120,120,120,120,120,120, +886,886,886,886,886,886,886,886,886,886,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 187 */ -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +887,887,887,887,887,887,887,887,887,887,887,887,887,887,887,887, +887,887,887,888,888,889,889,890,890,120,120,120,120,120,120,120, /* block 188 */ -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,874, -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,874, -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,874, -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,874, -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,874, -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,874, -874,874,874,874,874,874,874,874,874,874,874,874,874,874,874,119, -875,875,875,875,875,119,119,119,119,119,119,119,119,119,119,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +891,891,891,891,891,891,891,891,891,891,891,891,891,891,891,891, +294,294,891,294,891,296,296,296,296,296,296,296,296,297,297,297, +297,296,296,296,296,296,296,296,296,296,296,296,296,296,296,296, +296,296,120,120,120,120,120,120,120,120,120,120,120,120,120,892, /* block 189 */ -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,873,873,873,873,873,873,873,873,873,873,873,873, -873,873,873,873,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, /* block 190 */ -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 191 */ -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,876, -876,876,876,876,876,876,876,876,876,876,876,876,876,876,876,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,894, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,894, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,894, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,894, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,894, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,894, +894,894,894,894,894,894,894,894,894,894,894,894,894,894,894,120, +895,895,895,895,895,120,120,120,120,120,120,120,120,120,120,120, /* block 192 */ -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, +893,893,893,893,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 193 */ -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,877,877,877,877,877,877,877,877,877, -877,877,877,877,877,877,877,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, /* block 194 */ -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, +896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,120, +897,897,897,897,897,897,897,897,897,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 195 */ -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,592,592,592,592,592,592,592, -592,592,592,592,592,592,592,592,592,119,119,119,119,119,119,119, -878,878,878,878,878,878,878,878,878,878,878,878,878,878,878,878, -878,878,878,878,878,878,878,878,878,878,878,878,878,878,878,119, -879,879,879,879,879,879,879,879,879,879,119,119,119,119,880,880, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, /* block 196 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -881,881,881,881,881,881,881,881,881,881,881,881,881,881,881,881, -881,881,881,881,881,881,881,881,881,881,881,881,881,881,119,119, -882,882,882,882,882,883,119,119,119,119,119,119,119,119,119,119, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,898,898,898,898,898,898,898,898,898, +898,898,898,898,898,898,898,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 197 */ -884,884,884,884,884,884,884,884,884,884,884,884,884,884,884,884, -884,884,884,884,884,884,884,884,884,884,884,884,884,884,884,884, -884,884,884,884,884,884,884,884,884,884,884,884,884,884,884,884, -885,885,885,885,885,885,885,886,886,886,886,886,887,887,887,887, -888,888,888,888,886,887,119,119,119,119,119,119,119,119,119,119, -889,889,889,889,889,889,889,889,889,889,119,890,890,890,890,890, -890,890,119,884,884,884,884,884,884,884,884,884,884,884,884,884, -884,884,884,884,884,884,884,884,119,119,119,119,119,884,884,884, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, /* block 198 */ -884,884,884,884,884,884,884,884,884,884,884,884,884,884,884,884, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,601,601,601,601,601,601,601, +601,601,601,601,601,601,601,601,601,120,120,120,120,120,120,120, +899,899,899,899,899,899,899,899,899,899,899,899,899,899,899,899, +899,899,899,899,899,899,899,899,899,899,899,899,899,899,899,120, +900,900,900,900,900,900,900,900,900,900,120,120,120,120,901,901, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 199 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -891,891,891,891,891,891,891,891,891,891,891,891,891,891,891,891, -891,891,891,891,891,891,891,891,891,891,891,891,891,891,891,891, -892,892,892,892,892,892,892,892,892,892,892,892,892,892,892,892, -892,892,892,892,892,892,892,892,892,892,892,892,892,892,892,892, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, +902,902,902,902,902,902,902,902,902,902,902,902,902,902,120,120, +903,903,903,903,903,904,120,120,120,120,120,120,120,120,120,120, /* block 200 */ -893,893,893,893,893,893,893,893,893,893,893,893,893,893,893,893, -893,893,893,893,893,893,893,894,894,894,894,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +905,905,905,905,905,905,905,905,905,905,905,905,905,905,905,905, +905,905,905,905,905,905,905,905,905,905,905,905,905,905,905,905, +905,905,905,905,905,905,905,905,905,905,905,905,905,905,905,905, +906,906,906,906,906,906,906,907,907,907,907,907,908,908,908,908, +909,909,909,909,907,908,120,120,120,120,120,120,120,120,120,120, +910,910,910,910,910,910,910,910,910,910,120,911,911,911,911,911, +911,911,120,905,905,905,905,905,905,905,905,905,905,905,905,905, +905,905,905,905,905,905,905,905,120,120,120,120,120,905,905,905, /* block 201 */ -895,895,895,895,895,895,895,895,895,895,895,895,895,895,895,895, -895,895,895,895,895,895,895,895,895,895,895,895,895,895,895,895, -895,895,895,895,895,895,895,895,895,895,895,895,895,895,895,895, -895,895,895,895,895,895,895,895,895,895,895,895,895,895,895,895, -895,895,895,895,895,119,119,119,119,119,119,119,119,119,119,119, -895,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, -896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,896, -896,896,896,896,896,896,896,896,896,896,896,896,896,896,896,119, +905,905,905,905,905,905,905,905,905,905,905,905,905,905,905,905, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 202 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,897, -897,897,897,898,898,898,898,898,898,898,898,898,898,898,898,898, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -899,900,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, +912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, +913,913,913,913,913,913,913,913,913,913,913,913,913,913,913,913, +913,913,913,913,913,913,913,913,913,913,913,913,913,913,913,913, /* block 203 */ -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, +914,914,914,914,914,914,914,914,914,914,914,914,914,914,914,914, +914,914,914,914,914,914,914,915,915,915,915,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 204 */ -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +916,916,916,916,916,916,916,916,916,916,916,916,916,916,916,916, +916,916,916,916,916,916,916,916,916,916,916,916,916,916,916,916, +916,916,916,916,916,916,916,916,916,916,916,916,916,916,916,916, +916,916,916,916,916,916,916,916,916,916,916,916,916,916,916,916, +916,916,916,916,916,916,916,916,916,916,916,120,120,120,120,917, +916,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, +918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, +918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, /* block 205 */ -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,901,901,901,901,901,901,901,901,901,901,901,901,901, -901,901,901,119,119,119,119,119,119,119,119,119,119,119,119,119, +918,918,918,918,918,918,918,918,120,120,120,120,120,120,120,917, +917,917,917,919,919,919,919,919,919,919,919,919,919,919,919,919, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +920,921, 5,111,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 206 */ -569,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, /* block 207 */ -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,120,120,120,120,120,120,120,120, /* block 208 */ -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,564, -564,564,564,564,564,564,564,564,564,564,564,564,564,564,564,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,922,922,922,922,922,922,922,922,922,922,922,922,922, +922,922,922,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 209 */ -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, +578,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, /* block 210 */ -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,902,902,902,902, -902,902,902,902,902,902,902,902,902,902,902,902,119,119,119,119, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, /* block 211 */ -903,903,903,903,903,903,903,903,903,903,903,903,903,903,903,903, -903,903,903,903,903,903,903,903,903,903,903,903,903,903,903,903, -903,903,903,903,903,903,903,903,903,903,903,903,903,903,903,903, -903,903,903,903,903,903,903,903,903,903,903,903,903,903,903,903, -903,903,903,903,903,903,903,903,903,903,903,903,903,903,903,903, -903,903,903,903,903,903,903,903,903,903,903,903,903,903,903,903, -903,903,903,903,903,903,903,903,903,903,903,119,119,119,119,119, -903,903,903,903,903,903,903,903,903,903,903,903,903,119,119,119, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, +573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +573,573,573,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,578,578,578,578,120,120,120,120,120,120,120,120, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, /* block 212 */ -903,903,903,903,903,903,903,903,903,119,119,119,119,119,119,119, -903,903,903,903,903,903,903,903,903,903,119,119,904,905,905,906, -907,907,907,907,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, /* block 213 */ +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +923,923,923,923,923,923,923,923,923,923,923,923,120,120,120,120, + +/* block 214 */ +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, +924,924,924,924,924,924,924,924,924,924,924,120,120,120,120,120, +924,924,924,924,924,924,924,924,924,924,924,924,924,120,120,120, + +/* block 215 */ +924,924,924,924,924,924,924,924,924,120,120,120,120,120,120,120, +924,924,924,924,924,924,924,924,924,924,120,120,925,926,926,927, +928,928,928,928,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 216 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -3802,309 +3867,339 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20,119,119,119,119,119,119,119,119,119,119, + 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120,120,120,120, -/* block 214 */ +/* block 217 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20,119,119, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20,120,120, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20,908,909,112,112,112, 20, 20, 20,909,908,908, -908,908,908, 24, 24, 24, 24, 24, 24, 24, 24,112,112,112,112,112, + 20, 20, 20, 20, 20,929,930,113,113,113, 20, 20, 20,930,929,929, +929,929,929, 24, 24, 24, 24, 24, 24, 24, 24,113,113,113,113,113, -/* block 215 */ -112,112,112, 20, 20,112,112,112,112,112,112,112, 20, 20, 20, 20, +/* block 218 */ +113,113,113, 20, 20,113,113,113,113,113,113,113, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,112,112,112,112, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,113,113,113,113, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, + 20, 20, 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 216 */ -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,671,671,671,671,671,671,671,671,671,671,671,671,671,671, -671,671,910,910,910,671,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +/* block 219 */ +684,684,684,684,684,684,684,684,684,684,684,684,684,684,684,684, +684,684,684,684,684,684,684,684,684,684,684,684,684,684,684,684, +684,684,684,684,684,684,684,684,684,684,684,684,684,684,684,684, +684,684,684,684,684,684,684,684,684,684,684,684,684,684,684,684, +684,684,931,931,931,684,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 217 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +/* block 220 */ +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25,119,119,119,119,119,119,119,119,119,119,119,119, + 25, 25, 25, 25,120,120,120,120,120,120,120,120,120,120,120,120, -/* block 218 */ +/* block 221 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20,119,119,119,119,119,119,119,119,119, -573,573,573,573,573,573,573,573,573,573,573,573,573,573,573,573, -573,573, 25, 25, 25, 25, 25, 25, 25,119,119,119,119,119,119,119, - -/* block 219 */ -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,505,505, -505,505,505,505,505,119,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, - -/* block 220 */ -504,504,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,504,119,504,504, -119,119,504,119,119,504,504,119,119,504,504,504,504,119,504,504, -504,504,504,504,504,504,505,505,505,505,119,505,119,505,505,505, -505,505,505,505,119,505,505,505,505,505,505,505,505,505,505,505, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, - -/* block 221 */ -505,505,505,505,504,504,119,504,504,504,504,119,119,504,504,504, -504,504,504,504,504,119,504,504,504,504,504,504,504,119,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,504,504,119,504,504,504,504,119, -504,504,504,504,504,119,504,119,119,119,504,504,504,504,504,504, -504,119,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, + 20, 20, 20, 20, 20, 20, 20,120,120,120,120,120,120,120,120,120, +582,582,582,582,582,582,582,582,582,582,582,582,582,582,582,582, +582,582, 25, 25, 25, 25, 25, 25, 25,120,120,120,120,120,120,120, /* block 222 */ -504,504,504,504,504,504,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,514,514, +514,514,514,514,514,120,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, /* block 223 */ -505,505,505,505,505,505,505,505,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, +513,513,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,513,120,513,513, +120,120,513,120,120,513,513,120,120,513,513,513,513,120,513,513, +513,513,513,513,513,513,514,514,514,514,120,514,120,514,514,514, +514,514,514,514,120,514,514,514,514,514,514,514,514,514,514,514, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, /* block 224 */ -504,504,504,504,504,504,504,504,504,504,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,119,119,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504, 9,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505, 9,505,505,505,505, -505,505,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504, 9,505,505,505,505, +514,514,514,514,513,513,120,513,513,513,513,120,120,513,513,513, +513,513,513,513,513,120,513,513,513,513,513,513,513,120,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,513,513,120,513,513,513,513,120, +513,513,513,513,513,120,513,120,120,120,513,513,513,513,513,513, +513,120,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, /* block 225 */ -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505, 9,505,505,505,505,505,505,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504, 9,505,505,505,505,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, 9, -505,505,505,505,505,505,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, 9, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, +513,513,513,513,513,513,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, /* block 226 */ -505,505,505,505,505,505,505,505,505, 9,505,505,505,505,505,505, -504,504,504,504,504,504,504,504,504,504,504,504,504,504,504,504, -504,504,504,504,504,504,504,504,504, 9,505,505,505,505,505,505, -505,505,505,505,505,505,505,505,505,505,505,505,505,505,505,505, -505,505,505, 9,505,505,505,505,505,505,504,505,119,119, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +514,514,514,514,514,514,514,514,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, /* block 227 */ -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, -911,911,911,911,911,911,911,911,911,911,911,911,911,911,911,911, +513,513,513,513,513,513,513,513,513,513,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,120,120,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513, 9,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514, 9,514,514,514,514, +514,514,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513, 9,514,514,514,514, /* block 228 */ -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -912,912,912,912,912,912,912,911,911,911,911,912,912,912,912,912, -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -912,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -912,912,912,912,912,912,912,912,912,912,912,912,912,911,911,911, -911,911,911,911,911,912,911,911,911,911,911,911,911,911,911,911, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514, 9,514,514,514,514,514,514,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513, 9,514,514,514,514,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, 9, +514,514,514,514,514,514,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, 9, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, /* block 229 */ -911,911,911,911,912,911,911,913,913,913,913,913,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,912,912,912,912,912, -119,912,912,912,912,912,912,912,912,912,912,912,912,912,912,912, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +514,514,514,514,514,514,514,514,514, 9,514,514,514,514,514,514, +513,513,513,513,513,513,513,513,513,513,513,513,513,513,513,513, +513,513,513,513,513,513,513,513,513, 9,514,514,514,514,514,514, +514,514,514,514,514,514,514,514,514,514,514,514,514,514,514,514, +514,514,514, 9,514,514,514,514,514,514,513,514,120,120, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, /* block 230 */ -914,914,914,914,914,914,914,119,914,914,914,914,914,914,914,914, -914,914,914,914,914,914,914,914,914,119,119,914,914,914,914,914, -914,914,119,914,914,119,914,914,914,914,914,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, +932,932,932,932,932,932,932,932,932,932,932,932,932,932,932,932, /* block 231 */ -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, +933,933,933,933,933,933,933,933,933,933,933,933,933,933,933,933, +933,933,933,933,933,933,933,933,933,933,933,933,933,933,933,933, +933,933,933,933,933,933,933,933,933,933,933,933,933,933,933,933, +933,933,933,933,933,933,933,932,932,932,932,933,933,933,933,933, +933,933,933,933,933,933,933,933,933,933,933,933,933,933,933,933, +933,933,933,933,933,933,933,933,933,933,933,933,933,933,933,933, +933,933,933,933,933,933,933,933,933,933,933,933,933,932,932,932, +932,932,932,932,932,933,932,932,932,932,932,932,932,932,932,932, /* block 232 */ -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,915,915,915,915,915,915,915,915,915,915,915, -915,915,915,915,915,119,119,916,916,916,916,916,916,916,916,916, -917,917,917,917,917,917,917,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +932,932,932,932,933,932,932,934,934,934,934,934,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,933,933,933,933,933, +120,933,933,933,933,933,933,933,933,933,933,933,933,933,933,933, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 233 */ -918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, -918,918,918,918,918,918,918,918,918,918,918,918,918,918,918,918, -918,918,919,919,919,919,919,919,919,919,919,919,919,919,919,919, -919,919,919,919,919,919,919,919,919,919,919,919,919,919,919,919, -919,919,919,919,920,920,920,920,920,920,920,119,119,119,119,119, -921,921,921,921,921,921,921,921,921,921,119,119,119,119,922,922, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +935,935,935,935,935,935,935,120,935,935,935,935,935,935,935,935, +935,935,935,935,935,935,935,935,935,120,120,935,935,935,935,935, +935,935,120,935,935,120,935,935,935,935,935,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 234 */ -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +936,936,936,936,936,936,936,936,936,936,936,936,936,936,936,936, +936,936,936,936,936,936,936,936,936,936,936,936,936,936,936,936, +936,936,936,936,936,936,936,936,936,936,936,936,936,120,120,120, +937,937,937,937,937,937,937,938,938,938,938,938,938,938,120,120, +939,939,939,939,939,939,939,939,939,939,120,120,120,120,936,940, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 235 */ - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, 25, 25, - 6, 25, 25, 25, 25,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +941,941,941,941,941,941,941,941,941,941,941,941,941,941,941,941, +941,941,941,941,941,941,941,941,941,941,941,941,941,941,941,941, +941,941,941,941,941,941,941,941,941,941,941,941,942,942,942,942, +943,943,943,943,943,943,943,943,943,943,120,120,120,120,120,944, /* block 236 */ -224,224,224,224,119,224,224,224,224,224,224,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, -119,224,224,119,224,119,119,224,119,224,224,224,224,224,224,224, -224,224,224,119,224,224,224,224,119,224,119,224,119,119,119,119, -119,119,224,119,119,119,119,224,119,224,119,224,119,224,224,224, -119,224,224,119,224,119,119,224,119,224,119,224,119,224,119,224, -119,224,224,119,224,119,119,224,224,224,224,119,224,224,224,224, -224,224,224,119,224,224,224,224,119,224,224,224,224,119,224,119, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, /* block 237 */ -224,224,224,224,224,224,224,224,224,224,119,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,119,119,119,119, -119,224,224,224,119,224,224,224,224,224,119,224,224,224,224,224, -224,224,224,224,224,224,224,224,224,224,224,224,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -217,217,119,119,119,119,119,119,119,119,119,119,119,119,119,119, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,945,945,945,945,945,945,945,945,945,945,945, +945,945,945,945,945,120,120,946,946,946,946,946,946,946,946,946, +947,947,947,947,947,947,947,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 238 */ +948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +948,948,948,948,948,948,948,948,948,948,948,948,948,948,948,948, +948,948,949,949,949,949,949,949,949,949,949,949,949,949,949,949, +949,949,949,949,949,949,949,949,949,949,949,949,949,949,949,949, +949,949,949,949,950,950,950,950,950,950,950,951,120,120,120,120, +952,952,952,952,952,952,952,952,952,952,120,120,120,120,953,953, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 239 */ +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + +/* block 240 */ + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, 25, 25, + 6, 25, 25, 25, 25,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 241 */ +120, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 20, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 242 */ +225,225,225,225,120,225,225,225,225,225,225,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,225,225,225,225, +120,225,225,120,225,120,120,225,120,225,225,225,225,225,225,225, +225,225,225,120,225,225,225,225,120,225,120,225,120,120,120,120, +120,120,225,120,120,120,120,225,120,225,120,225,120,225,225,225, +120,225,225,120,225,120,120,225,120,225,120,225,120,225,120,225, +120,225,225,120,225,120,120,225,225,225,225,120,225,225,225,225, +225,225,225,120,225,225,225,225,120,225,225,225,225,120,225,120, + +/* block 243 */ +225,225,225,225,225,225,225,225,225,225,120,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,120,120,120,120, +120,225,225,225,120,225,225,225,225,225,120,225,225,225,225,225, +225,225,225,225,225,225,225,225,225,225,225,225,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +218,218,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 244 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,923,923,923,923, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954,954,954,954, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 239 */ +/* block 245 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21,923,923,923,923,923,923,923,923,923,923,923,923, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,923, -923, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -923, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -923, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21,954,954,954,954,954,954,954,954,954,954,954,954, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954, +954, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, +954, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, +954, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21,923,923,923,923,923,923,923,923,923,923, + 21, 21, 21, 21, 21, 21,954,954,954,954,954,954,954,954,954,954, -/* block 240 */ - 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,923,923,923, +/* block 246 */ + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,954,954,954, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,954,954,954, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, -/* block 241 */ +/* block 247 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,924,924,924,924,924,924,924,924,924,924, -924,924,924,924,924,924,924,924,924,924,924,924,924,924,924,924, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,955,955,955,955,955,955,955,955,955,955, +955,955,955,955,955,955,955,955,955,955,955,955,955,955,955,955, -/* block 242 */ -925, 21, 21,923,923,923,923,923,923,923,923,923,923,923,923,923, +/* block 248 */ +956, 21, 21,954,954,954,954,954,954,954,954,954,954,954,954,954, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, - 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20,923,923,923,923, - 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923,923,923,923, -575,575,923,923,923,923,923,923,923,923,923,923,923,923,923,923, - 21, 21, 21, 21, 21, 21,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, + 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20,954,954,954,954, + 20, 20, 20, 20, 20, 20, 20, 20, 20,954,954,954,954,954,954,954, +584,584,954,954,954,954,954,954,954,954,954,954,954,954,954,954, + 21, 21, 21, 21, 21, 21,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, -/* block 243 */ -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, +/* block 249 */ +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, -/* block 244 */ +/* block 250 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4114,7 +4209,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 245 */ +/* block 251 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4122,9 +4217,9 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,926,926,926,926,926, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,957,957,957,957,957, -/* block 246 */ +/* block 252 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4134,7 +4229,7 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, -/* block 247 */ +/* block 253 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, @@ -4144,17 +4239,17 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -/* block 248 */ +/* block 254 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21,923,923,923,923,923,923,923,923,923,923,923, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,923,923,923, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,923,923,923,923,923,923, + 21, 21, 21, 21, 21, 21,954,954,954,954,954,954,954,954,954,954, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954,954,954, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954,954,954,954,954, -/* block 249 */ +/* block 255 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, @@ -4162,187 +4257,197 @@ const uint16_t PRIV(ucd_stage2)[] = { /* 68608 bytes, block = 128 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20,923,923,923,923,923,923,923,923,923,923,923,923, + 20, 20, 20, 20,954,954,954,954,954,954,954,954,954,954,954,954, -/* block 250 */ +/* block 256 */ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 21, 21, 21, 21,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, + 20, 20, 20, 20, 20, 21, 21, 21, 21,954,954,954,954,954,954,954, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, -/* block 251 */ - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923, +/* block 257 */ + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,954,954,954,954, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923,923,923,923,923, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923,923,923, + 20, 20, 20, 20, 20, 20, 20, 20,954,954,954,954,954,954,954,954, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,954,954,954,954,954,954, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -/* block 252 */ - 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923,923,923,923,923, +/* block 258 */ + 20, 20, 20, 20, 20, 20, 20, 20,954,954,954,954,954,954,954,954, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, -/* block 253 */ - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,923,923,923,923, +/* block 259 */ + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,954, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, 21, 21,923, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21,923,923, 21, 21, 21, 21,923,923,923, 21,923, 21, 21, 21, 21, + 21, 21,954, 21, 21, 21, 21,954,954,954, 21, 21, 21, 21, 21, 21, -/* block 254 */ +/* block 260 */ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - 21, 21, 21,923,923,923,923,923,923,923,923,923,923,923,923,923, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,923,923,923,923,923,923, - 21, 21, 21,923,923,923,923,923,923,923,923,923,923,923,923,923, + 21, 21, 21,954,954, 21, 21, 21, 21, 21, 21,954,954,954, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954,954, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, - -/* block 255 */ -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, - 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, - -/* block 256 */ -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,923,923, -923,923,923,923,923,923,923,923,923,923,923,923,923,923,119,119, - -/* block 257 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, - -/* block 258 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,119,119,119,119,119,119,119,119,119,119,119, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, - -/* block 259 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,119,119, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, - -/* block 260 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, /* block 261 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, + 21, 21, 21, 21,954,954,954,954,954,954,954,954,954,954,954,954, + 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,954,954, + 21, 21, 21, 21,954,954,954,954, 21, 21, 21,954,954,954,954,954, /* block 262 */ -577,577,577,577,577,577,577,577,577,577,577,577,577,577,577,577, -577,577,577,577,577,577,577,577,577,577,577,577,577,577,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, -119,119,119,119,119,119,119,119,119,119,119,119,119,119,119,119, + 21, 21, 21,954,954,954,954,954,954,954,954,954,954,954,954,954, + 21, 21, 21, 21, 21, 21,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, /* block 263 */ -502, 24,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, -927,927,927,927,927,927,927,927,927,927,927,927,927,927,927,927, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,954,954, +954,954,954,954,954,954,954,954,954,954,954,954,954,954,120,120, /* block 264 */ -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, /* block 265 */ -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,120,120,120,120,120,120,120,120,120,120,120, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, /* block 266 */ -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112, -502,502,502,502,502,502,502,502,502,502,502,502,502,502,502,502, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, /* block 267 */ -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,659,659, -659,659,659,659,659,659,659,659,659,659,659,659,659,659,119,119, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, + +/* block 268 */ +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 269 */ +586,586,586,586,586,586,586,586,586,586,586,586,586,586,586,586, +586,586,586,586,586,586,586,586,586,586,586,586,586,586,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, +120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120, + +/* block 270 */ +511, 24,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, +958,958,958,958,958,958,958,958,958,958,958,958,958,958,958,958, + +/* block 271 */ +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, + +/* block 272 */ +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, + +/* block 273 */ +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +113,113,113,113,113,113,113,113,113,113,113,113,113,113,113,113, +511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511, + +/* block 274 */ +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,672,672, +672,672,672,672,672,672,672,672,672,672,672,672,672,672,120,120, }; diff --git a/src/3rdparty/pcre2/src/pcre2_ucp.h b/src/3rdparty/pcre2/src/pcre2_ucp.h index 483abd18fc..84b22fb064 100644 --- a/src/3rdparty/pcre2/src/pcre2_ucp.h +++ b/src/3rdparty/pcre2/src/pcre2_ucp.h @@ -281,7 +281,12 @@ enum { ucp_Makasar, ucp_Medefaidrin, ucp_Old_Sogdian, - ucp_Sogdian + ucp_Sogdian, + /* New for Unicode 12.0.0 */ + ucp_Elymaic, + ucp_Nandinagari, + ucp_Nyiakeng_Puachue_Hmong, + ucp_Wancho }; #endif /* PCRE2_UCP_H_IDEMPOTENT_GUARD */ diff --git a/src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h b/src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h index ba60311e45..acba9da4be 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h +++ b/src/3rdparty/pcre2/src/sljit/sljitConfigInternal.h @@ -214,6 +214,10 @@ #define SLJIT_MEMCPY(dest, src, len) memcpy(dest, src, len) #endif +#ifndef SLJIT_MEMMOVE +#define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len) +#endif + #ifndef SLJIT_ZEROMEM #define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len) #endif diff --git a/src/3rdparty/pcre2/src/sljit/sljitExecAllocator.c b/src/3rdparty/pcre2/src/sljit/sljitExecAllocator.c index 3b37a9751f..92ddb94914 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitExecAllocator.c +++ b/src/3rdparty/pcre2/src/sljit/sljitExecAllocator.c @@ -118,10 +118,20 @@ static SLJIT_INLINE int get_map_jit_flag() if (map_jit_flag == -1) { struct utsname name; + map_jit_flag = 0; uname(&name); /* Kernel version for 10.14.0 (Mojave) */ - map_jit_flag = (atoi(name.release) >= 18) ? MAP_JIT : 0; + if (atoi(name.release) >= 18) { + /* Only use MAP_JIT if a hardened runtime is used, because MAP_JIT is incompatible with fork(). */ + void *ptr = mmap(NULL, getpagesize(), PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + + if (ptr == MAP_FAILED) { + map_jit_flag = MAP_JIT; + } else { + munmap(ptr, getpagesize()); + } + } } return map_jit_flag; @@ -137,6 +147,7 @@ static SLJIT_INLINE int get_map_jit_flag() static SLJIT_INLINE void* alloc_chunk(sljit_uw size) { void *retval; + const int prot = PROT_READ | PROT_WRITE | PROT_EXEC; #ifdef MAP_ANON @@ -146,16 +157,25 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size) flags |= get_map_jit_flag(); #endif - retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, flags, -1, 0); + retval = mmap(NULL, size, prot, flags, -1, 0); #else /* !MAP_ANON */ if (dev_zero < 0) { if (open_dev_zero()) return NULL; } - retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0); + retval = mmap(NULL, size, prot, MAP_PRIVATE, dev_zero, 0); #endif /* MAP_ANON */ - return (retval != MAP_FAILED) ? retval : NULL; + if (retval == MAP_FAILED) + retval = NULL; + else { + if (mprotect(retval, size, prot) < 0) { + munmap(retval, size); + retval = NULL; + } + } + + return retval; } static SLJIT_INLINE void free_chunk(void *chunk, sljit_uw size) diff --git a/src/3rdparty/pcre2/src/sljit/sljitLir.c b/src/3rdparty/pcre2/src/sljit/sljitLir.c index ded9541b31..9bab0c3ec6 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitLir.c +++ b/src/3rdparty/pcre2/src/sljit/sljitLir.c @@ -144,6 +144,7 @@ #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) # define PATCH_MD 0x10 #endif +# define TYPE_SHIFT 13 #endif #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) @@ -521,6 +522,12 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw } } +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_put_label(struct sljit_put_label *put_label, struct sljit_label *label) +{ + if (SLJIT_LIKELY(!!put_label)) + put_label->label = label; +} + SLJIT_API_FUNC_ATTRIBUTE void sljit_set_current_flags(struct sljit_compiler *compiler, sljit_s32 current_flags) { SLJIT_UNUSED_ARG(compiler); @@ -620,6 +627,30 @@ static SLJIT_INLINE sljit_s32 get_arg_count(sljit_s32 arg_types) return arg_count; } +#if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86) + +static SLJIT_INLINE sljit_uw compute_next_addr(struct sljit_label *label, struct sljit_jump *jump, + struct sljit_const *const_, struct sljit_put_label *put_label) +{ + sljit_uw result = ~(sljit_uw)0; + + if (label) + result = label->size; + + if (jump && jump->addr < result) + result = jump->addr; + + if (const_ && const_->addr < result) + result = const_->addr; + + if (put_label && put_label->addr < result) + result = put_label->addr; + + return result; +} + +#endif /* !SLJIT_CONFIG_X86 */ + static SLJIT_INLINE void set_emit_enter(struct sljit_compiler *compiler, sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds, sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size) @@ -687,6 +718,19 @@ static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_comp compiler->last_const = const_; } +static SLJIT_INLINE void set_put_label(struct sljit_put_label *put_label, struct sljit_compiler *compiler, sljit_uw offset) +{ + put_label->next = NULL; + put_label->label = NULL; + put_label->addr = compiler->size - offset; + put_label->flags = 0; + if (compiler->last_put_label) + compiler->last_put_label->next = put_label; + else + compiler->put_labels = put_label; + compiler->last_put_label = put_label; +} + #define ADDRESSING_DEPENDS_ON(exp, reg) \ (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg)) @@ -1905,6 +1949,21 @@ static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_const(struct sljit_compil CHECK_RETURN_OK; } +static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ +#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) + FUNCTION_CHECK_DST(dst, dstw, 0); +#endif +#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) + if (SLJIT_UNLIKELY(!!compiler->verbose)) { + fprintf(compiler->verbose, " put_label "); + sljit_verbose_param(compiler, dst, dstw); + fprintf(compiler->verbose, "\n"); + } +#endif + CHECK_RETURN_OK; +} + #endif /* SLJIT_ARGUMENT_CHECKS || SLJIT_VERBOSE */ #define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \ @@ -2581,6 +2640,14 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi return NULL; } +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + SLJIT_UNUSED_ARG(compiler); + SLJIT_UNUSED_ARG(dst); + SLJIT_UNUSED_ARG(dstw); + return NULL; +} + SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset) { SLJIT_UNUSED_ARG(addr); @@ -2597,4 +2664,4 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta SLJIT_UNREACHABLE(); } -#endif +#endif /* !SLJIT_CONFIG_UNSUPPORTED */ diff --git a/src/3rdparty/pcre2/src/sljit/sljitLir.h b/src/3rdparty/pcre2/src/sljit/sljitLir.h index e71890cf7b..836d25cf71 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitLir.h +++ b/src/3rdparty/pcre2/src/sljit/sljitLir.h @@ -348,13 +348,20 @@ struct sljit_label { struct sljit_jump { struct sljit_jump *next; sljit_uw addr; - sljit_sw flags; + sljit_uw flags; union { sljit_uw target; - struct sljit_label* label; + struct sljit_label *label; } u; }; +struct sljit_put_label { + struct sljit_put_label *next; + struct sljit_label *label; + sljit_uw addr; + sljit_uw flags; +}; + struct sljit_const { struct sljit_const *next; sljit_uw addr; @@ -366,10 +373,12 @@ struct sljit_compiler { struct sljit_label *labels; struct sljit_jump *jumps; + struct sljit_put_label *put_labels; struct sljit_const *consts; struct sljit_label *last_label; struct sljit_jump *last_jump; struct sljit_const *last_const; + struct sljit_put_label *last_put_label; void *allocator_data; struct sljit_memory_fragment *buf; @@ -1314,10 +1323,17 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compil Flags: - (may destroy flags) */ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_local_base(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw offset); -/* The constant can be changed runtime (see: sljit_set_const) +/* Store a value that can be changed runtime (see: sljit_get_const_addr / sljit_set_const) Flags: - (does not modify flags) */ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value); +/* Store the value of a label (see: sljit_set_put_label) + Flags: - (does not modify flags) */ +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw); + +/* Set the value stored by put_label to this label. */ +SLJIT_API_FUNC_ATTRIBUTE void sljit_set_put_label(struct sljit_put_label *put_label, struct sljit_label *label); + /* After the code generation the address for label, jump and const instructions are computed. Since these structures are freed by sljit_free_compiler, the addresses must be preserved by the user program elsewere. */ diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c b/src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c index 6d61eed9a7..71f7bcdadb 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeARM_32.c @@ -583,8 +583,9 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil sljit_uw *buf_end; sljit_uw size; sljit_uw word_count; + sljit_uw next_addr; sljit_sw executable_offset; - sljit_sw jump_addr; + sljit_sw addr; #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) sljit_uw cpool_size; sljit_uw cpool_skip_alignment; @@ -597,6 +598,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -625,11 +627,13 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil code_ptr = code; word_count = 0; + next_addr = 1; executable_offset = SLJIT_EXEC_OFFSET(code); label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; if (label && label->size == 0) { label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code, executable_offset); @@ -669,35 +673,45 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil else if ((*buf_ptr & 0xff000000) != PUSH_POOL) { #endif *code_ptr = *buf_ptr++; + if (next_addr == word_count) { + SLJIT_ASSERT(!label || label->size >= word_count); + SLJIT_ASSERT(!jump || jump->addr >= word_count); + SLJIT_ASSERT(!const_ || const_->addr >= word_count); + SLJIT_ASSERT(!put_label || put_label->addr >= word_count); + /* These structures are ordered by their address. */ - SLJIT_ASSERT(!label || label->size >= word_count); - SLJIT_ASSERT(!jump || jump->addr >= word_count); - SLJIT_ASSERT(!const_ || const_->addr >= word_count); - if (jump && jump->addr == word_count) { + if (jump && jump->addr == word_count) { #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) - if (detect_jump_type(jump, code_ptr, code, executable_offset)) - code_ptr--; - jump->addr = (sljit_uw)code_ptr; + if (detect_jump_type(jump, code_ptr, code, executable_offset)) + code_ptr--; + jump->addr = (sljit_uw)code_ptr; #else - jump->addr = (sljit_uw)(code_ptr - 2); - if (detect_jump_type(jump, code_ptr, code, executable_offset)) - code_ptr -= 2; + jump->addr = (sljit_uw)(code_ptr - 2); + if (detect_jump_type(jump, code_ptr, code, executable_offset)) + code_ptr -= 2; #endif - jump = jump->next; - } - if (label && label->size == word_count) { - /* code_ptr can be affected above. */ - label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr + 1, executable_offset); - label->size = (code_ptr + 1) - code; - label = label->next; - } - if (const_ && const_->addr == word_count) { + jump = jump->next; + } + if (label && label->size == word_count) { + /* code_ptr can be affected above. */ + label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr + 1, executable_offset); + label->size = (code_ptr + 1) - code; + label = label->next; + } + if (const_ && const_->addr == word_count) { #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) - const_->addr = (sljit_uw)code_ptr; + const_->addr = (sljit_uw)code_ptr; #else - const_->addr = (sljit_uw)(code_ptr - 1); + const_->addr = (sljit_uw)(code_ptr - 1); #endif - const_ = const_->next; + const_ = const_->next; + } + if (put_label && put_label->addr == word_count) { + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)code_ptr; + put_label = put_label->next; + } + next_addr = compute_next_addr(label, jump, const_, put_label); } code_ptr++; #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) @@ -725,6 +739,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) SLJIT_ASSERT(cpool_size == 0); @@ -755,15 +770,15 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil buf_ptr = (sljit_uw *)jump->addr; if (jump->flags & PATCH_B) { - jump_addr = (sljit_sw)SLJIT_ADD_EXEC_OFFSET(buf_ptr + 2, executable_offset); + addr = (sljit_sw)SLJIT_ADD_EXEC_OFFSET(buf_ptr + 2, executable_offset); if (!(jump->flags & JUMP_ADDR)) { SLJIT_ASSERT(jump->flags & JUMP_LABEL); - SLJIT_ASSERT(((sljit_sw)jump->u.label->addr - jump_addr) <= 0x01ffffff && ((sljit_sw)jump->u.label->addr - jump_addr) >= -0x02000000); - *buf_ptr |= (((sljit_sw)jump->u.label->addr - jump_addr) >> 2) & 0x00ffffff; + SLJIT_ASSERT(((sljit_sw)jump->u.label->addr - addr) <= 0x01ffffff && ((sljit_sw)jump->u.label->addr - addr) >= -0x02000000); + *buf_ptr |= (((sljit_sw)jump->u.label->addr - addr) >> 2) & 0x00ffffff; } else { - SLJIT_ASSERT(((sljit_sw)jump->u.target - jump_addr) <= 0x01ffffff && ((sljit_sw)jump->u.target - jump_addr) >= -0x02000000); - *buf_ptr |= (((sljit_sw)jump->u.target - jump_addr) >> 2) & 0x00ffffff; + SLJIT_ASSERT(((sljit_sw)jump->u.target - addr) <= 0x01ffffff && ((sljit_sw)jump->u.target - addr) >= -0x02000000); + *buf_ptr |= (((sljit_sw)jump->u.target - addr) >> 2) & 0x00ffffff; } } else if (jump->flags & SLJIT_REWRITABLE_JUMP) { @@ -813,6 +828,22 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil } #endif + put_label = compiler->put_labels; + while (put_label) { + addr = put_label->label->addr; + buf_ptr = (sljit_uw*)put_label->addr; + +#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) + SLJIT_ASSERT((buf_ptr[0] & 0xffff0000) == 0xe59f0000); + buf_ptr[((buf_ptr[0] & 0xfff) >> 2) + 2] = addr; +#else + SLJIT_ASSERT((buf_ptr[-1] & 0xfff00000) == MOVW && (buf_ptr[0] & 0xfff00000) == MOVT); + buf_ptr[-1] |= ((addr << 4) & 0xf0000) | (addr & 0xfff); + buf_ptr[0] |= ((addr >> 12) & 0xf0000) | ((addr >> 16) & 0xfff); +#endif + put_label = put_label->next; + } + SLJIT_ASSERT(code_ptr - code <= (sljit_s32)size); compiler->error = SLJIT_ERR_COMPILED; @@ -2639,28 +2670,55 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_mem(struct sljit_compiler *compile SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value) { struct sljit_const *const_; - sljit_s32 reg; + sljit_s32 dst_r; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); ADJUST_LOCAL_OFFSET(dst, dstw); + dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG2; + +#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) + PTR_FAIL_IF(push_inst_with_unique_literal(compiler, EMIT_DATA_TRANSFER(WORD_SIZE | LOAD_DATA, 1, dst_r, TMP_PC, 0), init_value)); + compiler->patches++; +#else + PTR_FAIL_IF(emit_imm(compiler, dst_r, init_value)); +#endif + const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const)); PTR_FAIL_IF(!const_); + set_const(const_, compiler); - reg = SLOW_IS_REG(dst) ? dst : TMP_REG2; + if (dst & SLJIT_MEM) + PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG2, dst, dstw, TMP_REG1)); + return const_; +} + +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_s32 dst_r; + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG2; #if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) - PTR_FAIL_IF(push_inst_with_unique_literal(compiler, EMIT_DATA_TRANSFER(WORD_SIZE | LOAD_DATA, 1, reg, TMP_PC, 0), init_value)); + PTR_FAIL_IF(push_inst_with_unique_literal(compiler, EMIT_DATA_TRANSFER(WORD_SIZE | LOAD_DATA, 1, dst_r, TMP_PC, 0), 0)); compiler->patches++; #else - PTR_FAIL_IF(emit_imm(compiler, reg, init_value)); + PTR_FAIL_IF(emit_imm(compiler, dst_r, 0)); #endif - set_const(const_, compiler); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 0); if (dst & SLJIT_MEM) PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE, TMP_REG2, dst, dstw, TMP_REG1)); - return const_; + return put_label; } SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset) diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c b/src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c index b015695c52..e15b3451e8 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeARM_64.c @@ -161,7 +161,7 @@ static SLJIT_INLINE void modify_imm64_const(sljit_ins* inst, sljit_uw new_imm) inst[3] = MOVK | dst | ((new_imm >> 48) << 5) | (3 << 21); } -static SLJIT_INLINE sljit_s32 detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code, sljit_sw executable_offset) +static SLJIT_INLINE sljit_sw detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code, sljit_sw executable_offset) { sljit_sw diff; sljit_uw target_addr; @@ -196,14 +196,14 @@ static SLJIT_INLINE sljit_s32 detect_jump_type(struct sljit_jump *jump, sljit_in return 4; } - if (target_addr <= 0xffffffffl) { + if (target_addr < 0x100000000l) { if (jump->flags & IS_COND) code_ptr[-5] -= (2 << 5); code_ptr[-2] = code_ptr[0]; return 2; } - if (target_addr <= 0xffffffffffffl) { + if (target_addr < 0x1000000000000l) { if (jump->flags & IS_COND) code_ptr[-5] -= (1 << 5); jump->flags |= PATCH_ABS48; @@ -215,6 +215,22 @@ static SLJIT_INLINE sljit_s32 detect_jump_type(struct sljit_jump *jump, sljit_in return 0; } +static SLJIT_INLINE sljit_sw put_label_get_length(struct sljit_put_label *put_label, sljit_uw max_label) +{ + if (max_label < 0x100000000l) { + put_label->flags = 0; + return 2; + } + + if (max_label < 0x1000000000000l) { + put_label->flags = 1; + return 1; + } + + put_label->flags = 2; + return 0; +} + SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; @@ -223,6 +239,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil sljit_ins *buf_ptr; sljit_ins *buf_end; sljit_uw word_count; + sljit_uw next_addr; sljit_sw executable_offset; sljit_uw addr; sljit_s32 dst; @@ -230,6 +247,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -241,34 +259,47 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil code_ptr = code; word_count = 0; + next_addr = 0; executable_offset = SLJIT_EXEC_OFFSET(code); label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; do { buf_ptr = (sljit_ins*)buf->memory; buf_end = buf_ptr + (buf->used_size >> 2); do { *code_ptr = *buf_ptr++; - /* These structures are ordered by their address. */ - SLJIT_ASSERT(!label || label->size >= word_count); - SLJIT_ASSERT(!jump || jump->addr >= word_count); - SLJIT_ASSERT(!const_ || const_->addr >= word_count); - if (label && label->size == word_count) { - label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); - label->size = code_ptr - code; - label = label->next; - } - if (jump && jump->addr == word_count) { - jump->addr = (sljit_uw)(code_ptr - 4); - code_ptr -= detect_jump_type(jump, code_ptr, code, executable_offset); - jump = jump->next; - } - if (const_ && const_->addr == word_count) { - const_->addr = (sljit_uw)code_ptr; - const_ = const_->next; + if (next_addr == word_count) { + SLJIT_ASSERT(!label || label->size >= word_count); + SLJIT_ASSERT(!jump || jump->addr >= word_count); + SLJIT_ASSERT(!const_ || const_->addr >= word_count); + SLJIT_ASSERT(!put_label || put_label->addr >= word_count); + + /* These structures are ordered by their address. */ + if (label && label->size == word_count) { + label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); + label->size = code_ptr - code; + label = label->next; + } + if (jump && jump->addr == word_count) { + jump->addr = (sljit_uw)(code_ptr - 4); + code_ptr -= detect_jump_type(jump, code_ptr, code, executable_offset); + jump = jump->next; + } + if (const_ && const_->addr == word_count) { + const_->addr = (sljit_uw)code_ptr; + const_ = const_->next; + } + if (put_label && put_label->addr == word_count) { + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)(code_ptr - 3); + code_ptr -= put_label_get_length(put_label, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_label->label->size)); + put_label = put_label->next; + } + next_addr = compute_next_addr(label, jump, const_, put_label); } code_ptr ++; word_count ++; @@ -286,6 +317,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size); jump = compiler->jumps; @@ -323,6 +355,23 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil jump = jump->next; } + put_label = compiler->put_labels; + while (put_label) { + addr = put_label->label->addr; + buf_ptr = (sljit_ins *)put_label->addr; + + buf_ptr[0] |= (addr & 0xffff) << 5; + buf_ptr[1] |= ((addr >> 16) & 0xffff) << 5; + + if (put_label->flags >= 1) + buf_ptr[2] |= ((addr >> 32) & 0xffff) << 5; + + if (put_label->flags >= 2) + buf_ptr[3] |= ((addr >> 48) & 0xffff) << 5; + + put_label = put_label->next; + } + compiler->error = SLJIT_ERR_COMPILED; compiler->executable_offset = executable_offset; compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins); @@ -1947,6 +1996,28 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi return const_; } +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_s32 dst_r; + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; + PTR_FAIL_IF(emit_imm64_const(compiler, dst_r, 0)); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 1); + + if (dst & SLJIT_MEM) + PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw, TMP_REG2)); + + return put_label; +} + SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset) { sljit_ins* inst = (sljit_ins*)addr; diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c b/src/3rdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c index d7024b6d7d..cdfe4a4d24 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeARM_T2_32.c @@ -365,11 +365,13 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil sljit_u16 *buf_ptr; sljit_u16 *buf_end; sljit_uw half_count; + sljit_uw next_addr; sljit_sw executable_offset; struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -381,34 +383,46 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil code_ptr = code; half_count = 0; + next_addr = 0; executable_offset = SLJIT_EXEC_OFFSET(code); label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; do { buf_ptr = (sljit_u16*)buf->memory; buf_end = buf_ptr + (buf->used_size >> 1); do { *code_ptr = *buf_ptr++; - /* These structures are ordered by their address. */ - SLJIT_ASSERT(!label || label->size >= half_count); - SLJIT_ASSERT(!jump || jump->addr >= half_count); - SLJIT_ASSERT(!const_ || const_->addr >= half_count); - if (label && label->size == half_count) { - label->addr = ((sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset)) | 0x1; - label->size = code_ptr - code; - label = label->next; - } - if (jump && jump->addr == half_count) { - jump->addr = (sljit_uw)code_ptr - ((jump->flags & IS_COND) ? 10 : 8); - code_ptr -= detect_jump_type(jump, code_ptr, code, executable_offset); - jump = jump->next; - } - if (const_ && const_->addr == half_count) { - const_->addr = (sljit_uw)code_ptr; - const_ = const_->next; + if (next_addr == half_count) { + SLJIT_ASSERT(!label || label->size >= half_count); + SLJIT_ASSERT(!jump || jump->addr >= half_count); + SLJIT_ASSERT(!const_ || const_->addr >= half_count); + SLJIT_ASSERT(!put_label || put_label->addr >= half_count); + + /* These structures are ordered by their address. */ + if (label && label->size == half_count) { + label->addr = ((sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset)) | 0x1; + label->size = code_ptr - code; + label = label->next; + } + if (jump && jump->addr == half_count) { + jump->addr = (sljit_uw)code_ptr - ((jump->flags & IS_COND) ? 10 : 8); + code_ptr -= detect_jump_type(jump, code_ptr, code, executable_offset); + jump = jump->next; + } + if (const_ && const_->addr == half_count) { + const_->addr = (sljit_uw)code_ptr; + const_ = const_->next; + } + if (put_label && put_label->addr == half_count) { + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)code_ptr; + put_label = put_label->next; + } + next_addr = compute_next_addr(label, jump, const_, put_label); } code_ptr ++; half_count ++; @@ -426,6 +440,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size); jump = compiler->jumps; @@ -434,6 +449,12 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil jump = jump->next; } + put_label = compiler->put_labels; + while (put_label) { + modify_imm32_const((sljit_u16 *)put_label->addr, put_label->label->addr); + put_label = put_label->next; + } + compiler->error = SLJIT_ERR_COMPILED; compiler->executable_offset = executable_offset; compiler->executable_size = (code_ptr - code) * sizeof(sljit_u16); @@ -2311,6 +2332,27 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi return const_; } +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_s32 dst_r; + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 0); + + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; + PTR_FAIL_IF(emit_imm32_const(compiler, dst_r, 0)); + + if (dst & SLJIT_MEM) + PTR_FAIL_IF(emit_op_mem(compiler, WORD_SIZE | STORE, dst_r, dst, dstw, TMP_REG2)); + return put_label; +} + SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset) { sljit_u16 *inst = (sljit_u16*)addr; diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_32.c b/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_32.c index ad970bf25a..16dec052fe 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_32.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_32.c @@ -425,6 +425,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta { sljit_ins *inst = (sljit_ins *)addr; + SLJIT_ASSERT((inst[0] & 0xffe00000) == LUI && (inst[1] & 0xfc000000) == ORI); inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 16) & 0xffff); inst[1] = (inst[1] & 0xffff0000) | (new_target & 0xffff); inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); @@ -435,6 +436,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta { sljit_ins *inst = (sljit_ins *)addr; + SLJIT_ASSERT((inst[0] & 0xffe00000) == LUI && (inst[1] & 0xfc000000) == ORI); inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 16) & 0xffff); inst[1] = (inst[1] & 0xffff0000) | (new_constant & 0xffff); inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_common.c b/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_common.c index e0d6a3f085..7d1d087496 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_common.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeMIPS_common.c @@ -449,6 +449,55 @@ static __attribute__ ((noinline)) void sljit_cache_flush(void* code, void* code_ } #endif +#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) + +static SLJIT_INLINE sljit_sw put_label_get_length(struct sljit_put_label *put_label, sljit_uw max_label) +{ + if (max_label < 0x80000000l) { + put_label->flags = 0; + return 1; + } + + if (max_label < 0x800000000000l) { + put_label->flags = 1; + return 3; + } + + put_label->flags = 2; + return 5; +} + +static SLJIT_INLINE void put_label_set(struct sljit_put_label *put_label) +{ + sljit_uw addr = put_label->label->addr; + sljit_ins *inst = (sljit_ins *)put_label->addr; + sljit_s32 reg = *inst; + + if (put_label->flags == 0) { + SLJIT_ASSERT(addr < 0x80000000l); + inst[0] = LUI | T(reg) | IMM(addr >> 16); + } + else if (put_label->flags == 1) { + SLJIT_ASSERT(addr < 0x800000000000l); + inst[0] = LUI | T(reg) | IMM(addr >> 32); + inst[1] = ORI | S(reg) | T(reg) | IMM((addr >> 16) & 0xffff); + inst[2] = DSLL | T(reg) | D(reg) | SH_IMM(16); + inst += 2; + } + else { + inst[0] = LUI | T(reg) | IMM(addr >> 48); + inst[1] = ORI | S(reg) | T(reg) | IMM((addr >> 32) & 0xffff); + inst[2] = DSLL | T(reg) | D(reg) | SH_IMM(16); + inst[3] = ORI | S(reg) | T(reg) | IMM((addr >> 16) & 0xffff); + inst[4] = DSLL | T(reg) | D(reg) | SH_IMM(16); + inst += 4; + } + + inst[1] = ORI | S(reg) | T(reg) | IMM(addr & 0xffff); +} + +#endif + SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; @@ -457,12 +506,14 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil sljit_ins *buf_ptr; sljit_ins *buf_end; sljit_uw word_count; + sljit_uw next_addr; sljit_sw executable_offset; sljit_uw addr; struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -474,39 +525,54 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil code_ptr = code; word_count = 0; + next_addr = 0; executable_offset = SLJIT_EXEC_OFFSET(code); label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; do { buf_ptr = (sljit_ins*)buf->memory; buf_end = buf_ptr + (buf->used_size >> 2); do { *code_ptr = *buf_ptr++; - SLJIT_ASSERT(!label || label->size >= word_count); - SLJIT_ASSERT(!jump || jump->addr >= word_count); - SLJIT_ASSERT(!const_ || const_->addr >= word_count); - /* These structures are ordered by their address. */ - if (label && label->size == word_count) { - label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); - label->size = code_ptr - code; - label = label->next; - } - if (jump && jump->addr == word_count) { + if (next_addr == word_count) { + SLJIT_ASSERT(!label || label->size >= word_count); + SLJIT_ASSERT(!jump || jump->addr >= word_count); + SLJIT_ASSERT(!const_ || const_->addr >= word_count); + SLJIT_ASSERT(!put_label || put_label->addr >= word_count); + + /* These structures are ordered by their address. */ + if (label && label->size == word_count) { + label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); + label->size = code_ptr - code; + label = label->next; + } + if (jump && jump->addr == word_count) { #if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) - jump->addr = (sljit_uw)(code_ptr - 3); + jump->addr = (sljit_uw)(code_ptr - 3); #else - jump->addr = (sljit_uw)(code_ptr - 7); + jump->addr = (sljit_uw)(code_ptr - 7); #endif - code_ptr = detect_jump_type(jump, code_ptr, code, executable_offset); - jump = jump->next; - } - if (const_ && const_->addr == word_count) { - /* Just recording the address. */ - const_->addr = (sljit_uw)code_ptr; - const_ = const_->next; + code_ptr = detect_jump_type(jump, code_ptr, code, executable_offset); + jump = jump->next; + } + if (const_ && const_->addr == word_count) { + const_->addr = (sljit_uw)code_ptr; + const_ = const_->next; + } + if (put_label && put_label->addr == word_count) { + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)code_ptr; +#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) + code_ptr += put_label_get_length(put_label, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_label->label->size)); + word_count += 5; +#endif + put_label = put_label->next; + } + next_addr = compute_next_addr(label, jump, const_, put_label); } code_ptr ++; word_count ++; @@ -524,6 +590,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size); jump = compiler->jumps; @@ -571,6 +638,21 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil jump = jump->next; } + put_label = compiler->put_labels; + while (put_label) { +#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) + addr = put_label->label->addr; + buf_ptr = (sljit_ins *)put_label->addr; + + SLJIT_ASSERT((buf_ptr[0] & 0xffe00000) == LUI && (buf_ptr[1] & 0xfc000000) == ORI); + buf_ptr[0] |= (addr >> 16) & 0xffff; + buf_ptr[1] |= addr & 0xffff; +#else + put_label_set(put_label); +#endif + put_label = put_label->next; + } + compiler->error = SLJIT_ERR_COMPILED; compiler->executable_offset = executable_offset; compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins); @@ -2157,7 +2239,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value) { struct sljit_const *const_; - sljit_s32 reg; + sljit_s32 dst_r; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); @@ -2167,11 +2249,38 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi PTR_FAIL_IF(!const_); set_const(const_, compiler); - reg = FAST_IS_REG(dst) ? dst : TMP_REG2; - - PTR_FAIL_IF(emit_const(compiler, reg, init_value)); + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; + PTR_FAIL_IF(emit_const(compiler, dst_r, init_value)); if (dst & SLJIT_MEM) PTR_FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, dst, dstw, TMP_REG1, 0, TMP_REG2, 0)); + return const_; } + +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_s32 dst_r; + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 0); + + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; +#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) + PTR_FAIL_IF(emit_const(compiler, dst_r, 0)); +#else + PTR_FAIL_IF(push_inst(compiler, dst_r, UNMOVABLE_INS)); + compiler->size += 5; +#endif + + if (dst & SLJIT_MEM) + PTR_FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, dst, dstw, TMP_REG1, 0, TMP_REG2, 0)); + + return put_label; +} diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c b/src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c index fc185f7847..3ce741153f 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativePPC_32.c @@ -259,6 +259,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta { sljit_ins *inst = (sljit_ins *)addr; + SLJIT_ASSERT((inst[0] & 0xfc1f0000) == ADDIS && (inst[1] & 0xfc000000) == ORI); inst[0] = (inst[0] & 0xffff0000) | ((new_target >> 16) & 0xffff); inst[1] = (inst[1] & 0xffff0000) | (new_target & 0xffff); inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); @@ -269,6 +270,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta { sljit_ins *inst = (sljit_ins *)addr; + SLJIT_ASSERT((inst[0] & 0xfc1f0000) == ADDIS && (inst[1] & 0xfc000000) == ORI); inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 16) & 0xffff); inst[1] = (inst[1] & 0xffff0000) | (new_constant & 0xffff); inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c b/src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c index 706b2ba20b..3b73021cc8 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativePPC_64.c @@ -35,9 +35,6 @@ #error "Must implement count leading zeroes" #endif -#define RLDI(dst, src, sh, mb, type) \ - (HI(30) | S(src) | A(dst) | ((type) << 2) | (((sh) & 0x1f) << 11) | (((sh) & 0x20) >> 4) | (((mb) & 0x1f) << 6) | ((mb) & 0x20)) - #define PUSH_RLDICR(reg, shift) \ push_inst(compiler, RLDI(reg, reg, 63 - shift, shift, 1)) diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativePPC_common.c b/src/3rdparty/pcre2/src/sljit/sljitNativePPC_common.c index b34e3965ed..e827514315 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativePPC_common.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativePPC_common.c @@ -231,6 +231,9 @@ static const sljit_u8 freg_map[SLJIT_NUMBER_OF_FLOAT_REGISTERS + 3] = { #define SIMM_MIN (-0x8000) #define UIMM_MAX (0xffff) +#define RLDI(dst, src, sh, mb, type) \ + (HI(30) | S(src) | A(dst) | ((type) << 2) | (((sh) & 0x1f) << 11) | (((sh) & 0x20) >> 4) | (((mb) & 0x1f) << 6) | ((mb) & 0x20)) + #if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_sw addr, void* func) { @@ -324,6 +327,55 @@ keep_address: return 0; } +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + +static SLJIT_INLINE sljit_sw put_label_get_length(struct sljit_put_label *put_label, sljit_uw max_label) +{ + if (max_label < 0x100000000l) { + put_label->flags = 0; + return 1; + } + + if (max_label < 0x1000000000000l) { + put_label->flags = 1; + return 3; + } + + put_label->flags = 2; + return 4; +} + +static SLJIT_INLINE void put_label_set(struct sljit_put_label *put_label) +{ + sljit_uw addr = put_label->label->addr; + sljit_ins *inst = (sljit_ins *)put_label->addr; + sljit_s32 reg = *inst; + + if (put_label->flags == 0) { + SLJIT_ASSERT(addr < 0x100000000l); + inst[0] = ORIS | S(TMP_ZERO) | A(reg) | IMM(addr >> 16); + } + else { + if (put_label->flags == 1) { + SLJIT_ASSERT(addr < 0x1000000000000l); + inst[0] = ORI | S(TMP_ZERO) | A(reg) | IMM(addr >> 32); + } + else { + inst[0] = ORIS | S(TMP_ZERO) | A(reg) | IMM(addr >> 48); + inst[1] = ORI | S(reg) | A(reg) | IMM((addr >> 32) & 0xffff); + inst ++; + } + + inst[1] = RLDI(reg, reg, 32, 31, 1); + inst[2] = ORIS | S(reg) | A(reg) | IMM((addr >> 16) & 0xffff); + inst += 2; + } + + inst[1] = ORI | S(reg) | A(reg) | IMM(addr & 0xffff); +} + +#endif + SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler) { struct sljit_memory_fragment *buf; @@ -332,12 +384,14 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil sljit_ins *buf_ptr; sljit_ins *buf_end; sljit_uw word_count; + sljit_uw next_addr; sljit_sw executable_offset; sljit_uw addr; struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -356,71 +410,87 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil code_ptr = code; word_count = 0; + next_addr = 0; executable_offset = SLJIT_EXEC_OFFSET(code); label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; do { buf_ptr = (sljit_ins*)buf->memory; buf_end = buf_ptr + (buf->used_size >> 2); do { *code_ptr = *buf_ptr++; - SLJIT_ASSERT(!label || label->size >= word_count); - SLJIT_ASSERT(!jump || jump->addr >= word_count); - SLJIT_ASSERT(!const_ || const_->addr >= word_count); - /* These structures are ordered by their address. */ - if (label && label->size == word_count) { - /* Just recording the address. */ - label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); - label->size = code_ptr - code; - label = label->next; - } - if (jump && jump->addr == word_count) { + if (next_addr == word_count) { + SLJIT_ASSERT(!label || label->size >= word_count); + SLJIT_ASSERT(!jump || jump->addr >= word_count); + SLJIT_ASSERT(!const_ || const_->addr >= word_count); + SLJIT_ASSERT(!put_label || put_label->addr >= word_count); + + /* These structures are ordered by their address. */ + if (label && label->size == word_count) { + /* Just recording the address. */ + label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); + label->size = code_ptr - code; + label = label->next; + } + if (jump && jump->addr == word_count) { #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) - jump->addr = (sljit_uw)(code_ptr - 3); + jump->addr = (sljit_uw)(code_ptr - 3); #else - jump->addr = (sljit_uw)(code_ptr - 6); + jump->addr = (sljit_uw)(code_ptr - 6); #endif - if (detect_jump_type(jump, code_ptr, code, executable_offset)) { + if (detect_jump_type(jump, code_ptr, code, executable_offset)) { #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) - code_ptr[-3] = code_ptr[0]; - code_ptr -= 3; -#else - if (jump->flags & PATCH_ABS32) { + code_ptr[-3] = code_ptr[0]; code_ptr -= 3; - code_ptr[-1] = code_ptr[2]; - code_ptr[0] = code_ptr[3]; - } - else if (jump->flags & PATCH_ABS48) { - code_ptr--; - code_ptr[-1] = code_ptr[0]; - code_ptr[0] = code_ptr[1]; - /* rldicr rX,rX,32,31 -> rX,rX,16,47 */ - SLJIT_ASSERT((code_ptr[-3] & 0xfc00ffff) == 0x780007c6); - code_ptr[-3] ^= 0x8422; - /* oris -> ori */ - code_ptr[-2] ^= 0x4000000; - } - else { - code_ptr[-6] = code_ptr[0]; - code_ptr -= 6; - } +#else + if (jump->flags & PATCH_ABS32) { + code_ptr -= 3; + code_ptr[-1] = code_ptr[2]; + code_ptr[0] = code_ptr[3]; + } + else if (jump->flags & PATCH_ABS48) { + code_ptr--; + code_ptr[-1] = code_ptr[0]; + code_ptr[0] = code_ptr[1]; + /* rldicr rX,rX,32,31 -> rX,rX,16,47 */ + SLJIT_ASSERT((code_ptr[-3] & 0xfc00ffff) == 0x780007c6); + code_ptr[-3] ^= 0x8422; + /* oris -> ori */ + code_ptr[-2] ^= 0x4000000; + } + else { + code_ptr[-6] = code_ptr[0]; + code_ptr -= 6; + } #endif - if (jump->flags & REMOVE_COND) { - code_ptr[0] = BCx | (2 << 2) | ((code_ptr[0] ^ (8 << 21)) & 0x03ff0001); - code_ptr++; - jump->addr += sizeof(sljit_ins); - code_ptr[0] = Bx; - jump->flags -= IS_COND; + if (jump->flags & REMOVE_COND) { + code_ptr[0] = BCx | (2 << 2) | ((code_ptr[0] ^ (8 << 21)) & 0x03ff0001); + code_ptr++; + jump->addr += sizeof(sljit_ins); + code_ptr[0] = Bx; + jump->flags -= IS_COND; + } } + jump = jump->next; } - jump = jump->next; - } - if (const_ && const_->addr == word_count) { - const_->addr = (sljit_uw)code_ptr; - const_ = const_->next; + if (const_ && const_->addr == word_count) { + const_->addr = (sljit_uw)code_ptr; + const_ = const_->next; + } + if (put_label && put_label->addr == word_count) { + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)code_ptr; +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + code_ptr += put_label_get_length(put_label, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_label->label->size)); + word_count += 4; +#endif + put_label = put_label->next; + } + next_addr = compute_next_addr(label, jump, const_, put_label); } code_ptr ++; word_count ++; @@ -438,6 +508,8 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); + #if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size - (sizeof(struct sljit_function_context) / sizeof(sljit_ins))); #else @@ -503,6 +575,21 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil jump = jump->next; } + put_label = compiler->put_labels; + while (put_label) { +#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) + addr = put_label->label->addr; + buf_ptr = (sljit_ins *)put_label->addr; + + SLJIT_ASSERT((buf_ptr[0] & 0xfc1f0000) == ADDIS && (buf_ptr[1] & 0xfc000000) == ORI); + buf_ptr[0] |= (addr >> 16) & 0xffff; + buf_ptr[1] |= addr & 0xffff; +#else + put_label_set(put_label); +#endif + put_label = put_label->next; + } + compiler->error = SLJIT_ERR_COMPILED; compiler->executable_offset = executable_offset; compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins); @@ -2261,7 +2348,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fmem(struct sljit_compiler *compil SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value) { struct sljit_const *const_; - sljit_s32 reg; + sljit_s32 dst_r; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); @@ -2271,11 +2358,38 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi PTR_FAIL_IF(!const_); set_const(const_, compiler); - reg = FAST_IS_REG(dst) ? dst : TMP_REG2; - - PTR_FAIL_IF(emit_const(compiler, reg, init_value)); + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; + PTR_FAIL_IF(emit_const(compiler, dst_r, init_value)); if (dst & SLJIT_MEM) PTR_FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, dst, dstw, TMP_REG1, 0, TMP_REG2, 0)); + return const_; } + +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_s32 dst_r; + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 0); + + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; +#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) + PTR_FAIL_IF(emit_const(compiler, dst_r, 0)); +#else + PTR_FAIL_IF(push_inst(compiler, dst_r)); + compiler->size += 4; +#endif + + if (dst & SLJIT_MEM) + PTR_FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, dst, dstw, TMP_REG1, 0, TMP_REG2, 0)); + + return put_label; +} diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_32.c b/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_32.c index 0671b130cc..8079fad8df 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_32.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_32.c @@ -267,6 +267,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta { sljit_ins *inst = (sljit_ins *)addr; + SLJIT_ASSERT(((inst[0] & 0xc1c00000) == 0x01000000) && ((inst[1] & 0xc1f82000) == 0x80102000)); inst[0] = (inst[0] & 0xffc00000) | ((new_target >> 10) & 0x3fffff); inst[1] = (inst[1] & 0xfffffc00) | (new_target & 0x3ff); inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); @@ -277,6 +278,7 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta { sljit_ins *inst = (sljit_ins *)addr; + SLJIT_ASSERT(((inst[0] & 0xc1c00000) == 0x01000000) && ((inst[1] & 0xc1f82000) == 0x80102000)); inst[0] = (inst[0] & 0xffc00000) | ((new_constant >> 10) & 0x3fffff); inst[1] = (inst[1] & 0xfffffc00) | (new_constant & 0x3ff); inst = (sljit_ins *)SLJIT_ADD_EXEC_OFFSET(inst, executable_offset); diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_common.c b/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_common.c index 669ecd8152..bfa4ecede2 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_common.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeSPARC_common.c @@ -298,12 +298,14 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil sljit_ins *buf_ptr; sljit_ins *buf_end; sljit_uw word_count; + sljit_uw next_addr; sljit_sw executable_offset; sljit_uw addr; struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -315,40 +317,52 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil code_ptr = code; word_count = 0; + next_addr = 0; executable_offset = SLJIT_EXEC_OFFSET(code); label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; do { buf_ptr = (sljit_ins*)buf->memory; buf_end = buf_ptr + (buf->used_size >> 2); do { *code_ptr = *buf_ptr++; - SLJIT_ASSERT(!label || label->size >= word_count); - SLJIT_ASSERT(!jump || jump->addr >= word_count); - SLJIT_ASSERT(!const_ || const_->addr >= word_count); - /* These structures are ordered by their address. */ - if (label && label->size == word_count) { - /* Just recording the address. */ - label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); - label->size = code_ptr - code; - label = label->next; - } - if (jump && jump->addr == word_count) { + if (next_addr == word_count) { + SLJIT_ASSERT(!label || label->size >= word_count); + SLJIT_ASSERT(!jump || jump->addr >= word_count); + SLJIT_ASSERT(!const_ || const_->addr >= word_count); + SLJIT_ASSERT(!put_label || put_label->addr >= word_count); + + /* These structures are ordered by their address. */ + if (label && label->size == word_count) { + /* Just recording the address. */ + label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); + label->size = code_ptr - code; + label = label->next; + } + if (jump && jump->addr == word_count) { #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) - jump->addr = (sljit_uw)(code_ptr - 3); + jump->addr = (sljit_uw)(code_ptr - 3); #else - jump->addr = (sljit_uw)(code_ptr - 6); + jump->addr = (sljit_uw)(code_ptr - 6); #endif - code_ptr = detect_jump_type(jump, code_ptr, code, executable_offset); - jump = jump->next; - } - if (const_ && const_->addr == word_count) { - /* Just recording the address. */ - const_->addr = (sljit_uw)code_ptr; - const_ = const_->next; + code_ptr = detect_jump_type(jump, code_ptr, code, executable_offset); + jump = jump->next; + } + if (const_ && const_->addr == word_count) { + /* Just recording the address. */ + const_->addr = (sljit_uw)code_ptr; + const_ = const_->next; + } + if (put_label && put_label->addr == word_count) { + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)code_ptr; + put_label = put_label->next; + } + next_addr = compute_next_addr(label, jump, const_, put_label); } code_ptr ++; word_count ++; @@ -366,6 +380,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); SLJIT_ASSERT(code_ptr - code <= (sljit_s32)compiler->size); jump = compiler->jumps; @@ -389,8 +404,9 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil /* Set the fields of immediate loads. */ #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) - buf_ptr[0] = (buf_ptr[0] & 0xffc00000) | ((addr >> 10) & 0x3fffff); - buf_ptr[1] = (buf_ptr[1] & 0xfffffc00) | (addr & 0x3ff); + SLJIT_ASSERT(((buf_ptr[0] & 0xc1cfffff) == 0x01000000) && ((buf_ptr[1] & 0xc1f83fff) == 0x80102000)); + buf_ptr[0] |= (addr >> 10) & 0x3fffff; + buf_ptr[1] |= addr & 0x3ff; #else #error "Implementation required" #endif @@ -398,6 +414,20 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil jump = jump->next; } + put_label = compiler->put_labels; + while (put_label) { + addr = put_label->label->addr; + buf_ptr = (sljit_ins *)put_label->addr; + +#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) + SLJIT_ASSERT(((buf_ptr[0] & 0xc1cfffff) == 0x01000000) && ((buf_ptr[1] & 0xc1f83fff) == 0x80102000)); + buf_ptr[0] |= (addr >> 10) & 0x3fffff; + buf_ptr[1] |= addr & 0x3ff; +#else +#error "Implementation required" +#endif + put_label = put_label->next; + } compiler->error = SLJIT_ERR_COMPILED; compiler->executable_offset = executable_offset; @@ -1465,8 +1495,8 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_cmov(struct sljit_compiler *compil SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw, sljit_sw init_value) { - sljit_s32 reg; struct sljit_const *const_; + sljit_s32 dst_r; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value)); @@ -1476,11 +1506,31 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi PTR_FAIL_IF(!const_); set_const(const_, compiler); - reg = FAST_IS_REG(dst) ? dst : TMP_REG2; - - PTR_FAIL_IF(emit_const(compiler, reg, init_value)); + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; + PTR_FAIL_IF(emit_const(compiler, dst_r, init_value)); if (dst & SLJIT_MEM) PTR_FAIL_IF(emit_op_mem(compiler, WORD_DATA, TMP_REG2, dst, dstw)); return const_; } + +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_s32 dst_r; + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 0); + + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; + PTR_FAIL_IF(emit_const(compiler, dst_r, 0)); + + if (dst & SLJIT_MEM) + PTR_FAIL_IF(emit_op_mem(compiler, WORD_DATA, TMP_REG2, dst, dstw)); + return put_label; +} diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeX86_32.c b/src/3rdparty/pcre2/src/sljit/sljitNativeX86_32.c index 074e64b9f2..34a3a3d940 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeX86_32.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeX86_32.c @@ -38,8 +38,10 @@ static sljit_s32 emit_do_imm(struct sljit_compiler *compiler, sljit_u8 opcode, s return SLJIT_SUCCESS; } -static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_s32 type, sljit_sw executable_offset) +static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_sw executable_offset) { + sljit_s32 type = jump->flags >> TYPE_SHIFT; + if (type == SLJIT_JUMP) { *code_ptr++ = JMP_i32; jump->addr++; diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeX86_64.c b/src/3rdparty/pcre2/src/sljit/sljitNativeX86_64.c index 8506565614..5758711954 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeX86_64.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeX86_64.c @@ -39,8 +39,10 @@ static sljit_s32 emit_load_imm64(struct sljit_compiler *compiler, sljit_s32 reg, return SLJIT_SUCCESS; } -static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_s32 type) +static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr) { + sljit_s32 type = jump->flags >> TYPE_SHIFT; + int short_addr = !(jump->flags & SLJIT_REWRITABLE_JUMP) && !(jump->flags & JUMP_LABEL) && (jump->u.target <= 0xffffffff); /* The relative jump below specialized for this case. */ @@ -72,6 +74,56 @@ static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ return code_ptr; } +static sljit_u8* generate_put_label_code(struct sljit_put_label *put_label, sljit_u8 *code_ptr, sljit_uw max_label) +{ + if (max_label > HALFWORD_MAX) { + put_label->addr -= put_label->flags; + put_label->flags = PATCH_MD; + return code_ptr; + } + + if (put_label->flags == 0) { + /* Destination is register. */ + code_ptr = (sljit_u8*)put_label->addr - 2 - sizeof(sljit_uw); + + SLJIT_ASSERT((code_ptr[0] & 0xf8) == REX_W); + SLJIT_ASSERT((code_ptr[1] & 0xf8) == MOV_r_i32); + + if ((code_ptr[0] & 0x07) != 0) { + code_ptr[0] = (sljit_u8)(code_ptr[0] & ~0x08); + code_ptr += 2 + sizeof(sljit_s32); + } + else { + code_ptr[0] = code_ptr[1]; + code_ptr += 1 + sizeof(sljit_s32); + } + + put_label->addr = (sljit_uw)code_ptr; + return code_ptr; + } + + code_ptr -= put_label->flags + (2 + sizeof(sljit_uw)); + SLJIT_MEMMOVE(code_ptr, code_ptr + (2 + sizeof(sljit_uw)), put_label->flags); + + SLJIT_ASSERT((code_ptr[0] & 0xf8) == REX_W); + + if ((code_ptr[1] & 0xf8) == MOV_r_i32) { + code_ptr += 2 + sizeof(sljit_uw); + SLJIT_ASSERT((code_ptr[0] & 0xf8) == REX_W); + } + + SLJIT_ASSERT(code_ptr[1] == MOV_rm_r); + + code_ptr[0] = (sljit_u8)(code_ptr[0] & ~0x4); + code_ptr[1] = MOV_rm_i32; + code_ptr[2] = (sljit_u8)(code_ptr[2] & ~(0x7 << 3)); + + code_ptr = (sljit_u8*)(put_label->addr - (2 + sizeof(sljit_uw)) + sizeof(sljit_s32)); + put_label->addr = (sljit_uw)code_ptr; + put_label->flags = 0; + return code_ptr; +} + SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, sljit_s32 options, sljit_s32 arg_types, sljit_s32 scratches, sljit_s32 saveds, sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size) diff --git a/src/3rdparty/pcre2/src/sljit/sljitNativeX86_common.c b/src/3rdparty/pcre2/src/sljit/sljitNativeX86_common.c index 6f02ee3e8b..6296da5382 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitNativeX86_common.c +++ b/src/3rdparty/pcre2/src/sljit/sljitNativeX86_common.c @@ -428,13 +428,15 @@ static sljit_u8 get_jump_code(sljit_s32 type) } #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) -static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_s32 type, sljit_sw executable_offset); +static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_sw executable_offset); #else -static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_s32 type); +static sljit_u8* generate_far_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr); +static sljit_u8* generate_put_label_code(struct sljit_put_label *put_label, sljit_u8 *code_ptr, sljit_uw max_label); #endif -static sljit_u8* generate_near_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_u8 *code, sljit_s32 type, sljit_sw executable_offset) +static sljit_u8* generate_near_jump_code(struct sljit_jump *jump, sljit_u8 *code_ptr, sljit_u8 *code, sljit_sw executable_offset) { + sljit_s32 type = jump->flags >> TYPE_SHIFT; sljit_s32 short_jump; sljit_uw label_addr; @@ -447,7 +449,7 @@ static sljit_u8* generate_near_jump_code(struct sljit_jump *jump, sljit_u8 *code #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if ((sljit_sw)(label_addr - (jump->addr + 1)) > HALFWORD_MAX || (sljit_sw)(label_addr - (jump->addr + 1)) < HALFWORD_MIN) - return generate_far_jump_code(jump, code_ptr, type); + return generate_far_jump_code(jump, code_ptr); #endif if (type == SLJIT_JUMP) { @@ -497,6 +499,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil struct sljit_label *label; struct sljit_jump *jump; struct sljit_const *const_; + struct sljit_put_label *put_label; CHECK_ERROR_PTR(); CHECK_PTR(check_sljit_generate_code(compiler)); @@ -511,6 +514,7 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil label = compiler->labels; jump = compiler->jumps; const_ = compiler->consts; + put_label = compiler->put_labels; executable_offset = SLJIT_EXEC_OFFSET(code); do { @@ -525,27 +529,38 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil buf_ptr += len; } else { - if (*buf_ptr >= 2) { + switch (*buf_ptr) { + case 0: + label->addr = (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code_ptr, executable_offset); + label->size = code_ptr - code; + label = label->next; + break; + case 1: jump->addr = (sljit_uw)code_ptr; if (!(jump->flags & SLJIT_REWRITABLE_JUMP)) - code_ptr = generate_near_jump_code(jump, code_ptr, code, *buf_ptr - 2, executable_offset); + code_ptr = generate_near_jump_code(jump, code_ptr, code, executable_offset); else { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - code_ptr = generate_far_jump_code(jump, code_ptr, *buf_ptr - 2, executable_offset); + code_ptr = generate_far_jump_code(jump, code_ptr, executable_offset); #else - code_ptr = generate_far_jump_code(jump, code_ptr, *buf_ptr - 2); + code_ptr = generate_far_jump_code(jump, code_ptr); #endif } jump = jump->next; - } - else if (*buf_ptr == 0) { - label->addr = ((sljit_uw)code_ptr) + executable_offset; - label->size = code_ptr - code; - label = label->next; - } - else { /* *buf_ptr is 1 */ + break; + case 2: const_->addr = ((sljit_uw)code_ptr) - sizeof(sljit_sw); const_ = const_->next; + break; + default: + SLJIT_ASSERT(*buf_ptr == 3); + SLJIT_ASSERT(put_label->label); + put_label->addr = (sljit_uw)code_ptr; +#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) + code_ptr = generate_put_label_code(put_label, code_ptr, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_label->label->size)); +#endif + put_label = put_label->next; + break; } buf_ptr++; } @@ -557,6 +572,8 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil SLJIT_ASSERT(!label); SLJIT_ASSERT(!jump); SLJIT_ASSERT(!const_); + SLJIT_ASSERT(!put_label); + SLJIT_ASSERT(code_ptr <= code + compiler->size); jump = compiler->jumps; while (jump) { @@ -591,8 +608,24 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compil jump = jump->next; } - /* Some space may be wasted because of short jumps. */ - SLJIT_ASSERT(code_ptr <= code + compiler->size); + put_label = compiler->put_labels; + while (put_label) { +#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) + sljit_unaligned_store_sw((void*)(put_label->addr - sizeof(sljit_sw)), (sljit_sw)put_label->label->addr); +#else + if (put_label->flags & PATCH_MD) { + SLJIT_ASSERT(put_label->label->addr > HALFWORD_MAX); + sljit_unaligned_store_sw((void*)(put_label->addr - sizeof(sljit_sw)), (sljit_sw)put_label->label->addr); + } + else { + SLJIT_ASSERT(put_label->label->addr <= HALFWORD_MAX); + sljit_unaligned_store_s32((void*)(put_label->addr - sizeof(sljit_s32)), (sljit_s32)put_label->label->addr); + } +#endif + + put_label = put_label->next; + } + compiler->error = SLJIT_ERR_COMPILED; compiler->executable_offset = executable_offset; compiler->executable_size = code_ptr - code; @@ -2481,7 +2514,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); PTR_FAIL_IF_NULL(jump); - set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP); + set_jump(jump, compiler, (type & SLJIT_REWRITABLE_JUMP) | ((type & 0xff) << TYPE_SHIFT)); type &= 0xff; /* Worst case size. */ @@ -2495,7 +2528,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile PTR_FAIL_IF_NULL(inst); *inst++ = 0; - *inst++ = type + 2; + *inst++ = 1; return jump; } @@ -2513,7 +2546,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compi if (src == SLJIT_IMM) { jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); FAIL_IF_NULL(jump); - set_jump(jump, compiler, JUMP_ADDR); + set_jump(jump, compiler, JUMP_ADDR | (type << TYPE_SHIFT)); jump->u.target = srcw; /* Worst case size. */ @@ -2527,7 +2560,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_ijump(struct sljit_compiler *compi FAIL_IF_NULL(inst); *inst++ = 0; - *inst++ = type + 2; + *inst++ = 1; } else { #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) @@ -2831,7 +2864,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi PTR_FAIL_IF(!inst); *inst++ = 0; - *inst++ = 1; + *inst++ = 2; #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if (dst & SLJIT_MEM) @@ -2842,6 +2875,54 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compi return const_; } +SLJIT_API_FUNC_ATTRIBUTE struct sljit_put_label* sljit_emit_put_label(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw) +{ + struct sljit_put_label *put_label; + sljit_u8 *inst; +#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) + sljit_s32 reg; + sljit_uw start_size; +#endif + + CHECK_ERROR_PTR(); + CHECK_PTR(check_sljit_emit_put_label(compiler, dst, dstw)); + ADJUST_LOCAL_OFFSET(dst, dstw); + + CHECK_EXTRA_REGS(dst, dstw, (void)0); + + put_label = (struct sljit_put_label*)ensure_abuf(compiler, sizeof(struct sljit_put_label)); + PTR_FAIL_IF(!put_label); + set_put_label(put_label, compiler, 0); + +#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) + compiler->mode32 = 0; + reg = FAST_IS_REG(dst) ? dst : TMP_REG1; + + if (emit_load_imm64(compiler, reg, 0)) + return NULL; +#else + if (emit_mov(compiler, dst, dstw, SLJIT_IMM, 0)) + return NULL; +#endif + +#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) + if (dst & SLJIT_MEM) { + start_size = compiler->size; + if (emit_mov(compiler, dst, dstw, TMP_REG1, 0)) + return NULL; + put_label->flags = compiler->size - start_size; + } +#endif + + inst = (sljit_u8*)ensure_buf(compiler, 2); + PTR_FAIL_IF(!inst); + + *inst++ = 0; + *inst++ = 3; + + return put_label; +} + SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_target, sljit_sw executable_offset) { SLJIT_UNUSED_ARG(executable_offset); diff --git a/src/3rdparty/pcre2/src/sljit/sljitUtils.c b/src/3rdparty/pcre2/src/sljit/sljitUtils.c index 2ead044b1b..39f6a44b24 100644 --- a/src/3rdparty/pcre2/src/sljit/sljitUtils.c +++ b/src/3rdparty/pcre2/src/sljit/sljitUtils.c @@ -154,7 +154,13 @@ SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_release_lock(void) #include "windows.h" #else /* Provides mmap function. */ +#include <sys/types.h> #include <sys/mman.h> +#ifndef MAP_ANON +#ifdef MAP_ANONYMOUS +#define MAP_ANON MAP_ANONYMOUS +#endif +#endif /* For detecting the page size. */ #include <unistd.h> -- cgit v1.2.3 From 6e3b4ddd9256801dc7d0c245808e81dc669b1f2f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Sat, 23 Nov 2019 15:05:35 +0100 Subject: QRegularExpression: adjust the error codes matching PCRE2 10.34 Change-Id: I78ecda1bdc784b8d7a69a4927dbe3b0f08c1d907 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> --- src/corelib/text/qregularexpression.cpp | 65 ++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index a02d471134..8627cbba4f 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -2867,7 +2867,7 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "numbers out of order in {} quantifier"), QT_TRANSLATE_NOOP("QRegularExpression", "number too big in {} quantifier"), QT_TRANSLATE_NOOP("QRegularExpression", "missing terminating ] for character class"), - QT_TRANSLATE_NOOP("QRegularExpression", "invalid escape sequence in character class"), + QT_TRANSLATE_NOOP("QRegularExpression", "escape sequence is invalid in character class"), QT_TRANSLATE_NOOP("QRegularExpression", "range out of order in character class"), QT_TRANSLATE_NOOP("QRegularExpression", "quantifier does not follow a repeatable item"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unexpected repeat"), @@ -2884,46 +2884,46 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "failed to allocate heap memory"), QT_TRANSLATE_NOOP("QRegularExpression", "unmatched closing parenthesis"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error: code overflow"), - QT_TRANSLATE_NOOP("QRegularExpression", "letter or underscore expected after (?< or (?'"), + QT_TRANSLATE_NOOP("QRegularExpression", "missing closing parenthesis for condition"), QT_TRANSLATE_NOOP("QRegularExpression", "lookbehind assertion is not fixed length"), - QT_TRANSLATE_NOOP("QRegularExpression", "malformed number or name after (?("), - QT_TRANSLATE_NOOP("QRegularExpression", "conditional group contains more than two branches"), + QT_TRANSLATE_NOOP("QRegularExpression", "a relative value of zero is not allowed"), + QT_TRANSLATE_NOOP("QRegularExpression", "conditional subpattern contains more than two branches"), QT_TRANSLATE_NOOP("QRegularExpression", "assertion expected after (?( or (?(?C)"), - QT_TRANSLATE_NOOP("QRegularExpression", "(?R or (?[+-]digits must be followed by )"), + QT_TRANSLATE_NOOP("QRegularExpression", "digit expected after (?+ or (?-"), QT_TRANSLATE_NOOP("QRegularExpression", "unknown POSIX class name"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error in pcre2_study(): should not occur"), QT_TRANSLATE_NOOP("QRegularExpression", "this version of PCRE2 does not have Unicode support"), QT_TRANSLATE_NOOP("QRegularExpression", "parentheses are too deeply nested (stack check)"), QT_TRANSLATE_NOOP("QRegularExpression", "character code point value in \\x{} or \\o{} is too large"), - QT_TRANSLATE_NOOP("QRegularExpression", "invalid condition (?(0)"), - QT_TRANSLATE_NOOP("QRegularExpression", "\\C is not allowed in a lookbehind assertion"), - QT_TRANSLATE_NOOP("QRegularExpression", "PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u"), + QT_TRANSLATE_NOOP("QRegularExpression", "lookbehind is too complicated"), + QT_TRANSLATE_NOOP("QRegularExpression", "\\C is not allowed in a lookbehind assertion in UTF-" "16" " mode"), + QT_TRANSLATE_NOOP("QRegularExpression", "PCRE2 does not support \\F, \\L, \\l, \\N{name}, \\U, or \\u"), QT_TRANSLATE_NOOP("QRegularExpression", "number after (?C is greater than 255"), QT_TRANSLATE_NOOP("QRegularExpression", "closing parenthesis for (?C expected"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid escape sequence in (*VERB) name"), QT_TRANSLATE_NOOP("QRegularExpression", "unrecognized character after (?P"), - QT_TRANSLATE_NOOP("QRegularExpression", "syntax error in subpattern name (missing terminator)"), + QT_TRANSLATE_NOOP("QRegularExpression", "syntax error in subpattern name (missing terminator?)"), QT_TRANSLATE_NOOP("QRegularExpression", "two named subpatterns have the same name (PCRE2_DUPNAMES not set)"), - QT_TRANSLATE_NOOP("QRegularExpression", "group name must start with a non-digit"), + QT_TRANSLATE_NOOP("QRegularExpression", "subpattern name must start with a non-digit"), QT_TRANSLATE_NOOP("QRegularExpression", "this version of PCRE2 does not have support for \\P, \\p, or \\X"), QT_TRANSLATE_NOOP("QRegularExpression", "malformed \\P or \\p sequence"), QT_TRANSLATE_NOOP("QRegularExpression", "unknown property name after \\P or \\p"), - QT_TRANSLATE_NOOP("QRegularExpression", "subpattern name is too long (maximum " "10000" " characters)"), - QT_TRANSLATE_NOOP("QRegularExpression", "too many named subpatterns (maximum " "256" ")"), + QT_TRANSLATE_NOOP("QRegularExpression", "subpattern name is too long (maximum " "32" " code units)"), + QT_TRANSLATE_NOOP("QRegularExpression", "too many named subpatterns (maximum " "10000" ")"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid range in character class"), QT_TRANSLATE_NOOP("QRegularExpression", "octal value is greater than \\377 in 8-bit non-UTF-8 mode"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error: overran compiling workspace"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error: previously-checked referenced subpattern not found"), - QT_TRANSLATE_NOOP("QRegularExpression", "DEFINE group contains more than one branch"), + QT_TRANSLATE_NOOP("QRegularExpression", "DEFINE subpattern contains more than one branch"), QT_TRANSLATE_NOOP("QRegularExpression", "missing opening brace after \\o"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unknown newline setting"), QT_TRANSLATE_NOOP("QRegularExpression", "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number"), - QT_TRANSLATE_NOOP("QRegularExpression", "a numbered reference must not be zero"), - QT_TRANSLATE_NOOP("QRegularExpression", "an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)"), + QT_TRANSLATE_NOOP("QRegularExpression", "(?R (recursive pattern call) must be followed by a closing parenthesis"), + QT_TRANSLATE_NOOP("QRegularExpression", "obsolete error (should not occur)"), QT_TRANSLATE_NOOP("QRegularExpression", "(*VERB) not recognized or malformed"), - QT_TRANSLATE_NOOP("QRegularExpression", "number is too big"), + QT_TRANSLATE_NOOP("QRegularExpression", "subpattern number is too big"), QT_TRANSLATE_NOOP("QRegularExpression", "subpattern name expected"), - QT_TRANSLATE_NOOP("QRegularExpression", "digit expected after (?+"), + QT_TRANSLATE_NOOP("QRegularExpression", "internal error: parsed pattern overflow"), QT_TRANSLATE_NOOP("QRegularExpression", "non-octal character in \\o{} (closing brace missing?)"), QT_TRANSLATE_NOOP("QRegularExpression", "different names for subpatterns of the same number are not allowed"), QT_TRANSLATE_NOOP("QRegularExpression", "(*MARK) must have an argument"), @@ -2931,16 +2931,16 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "\\c must be followed by a printable ASCII character"), QT_TRANSLATE_NOOP("QRegularExpression", "\\c must be followed by a letter or one of [\\]^_?"), QT_TRANSLATE_NOOP("QRegularExpression", "\\k is not followed by a braced, angle-bracketed, or quoted name"), - QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unknown opcode in find_fixedlength()"), + QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unknown meta code in check_lookbehinds()"), QT_TRANSLATE_NOOP("QRegularExpression", "\\N is not supported in a class"), - QT_TRANSLATE_NOOP("QRegularExpression", "SPARE ERROR"), + QT_TRANSLATE_NOOP("QRegularExpression", "callout string is too long"), QT_TRANSLATE_NOOP("QRegularExpression", "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"), QT_TRANSLATE_NOOP("QRegularExpression", "using UTF is disabled by the application"), QT_TRANSLATE_NOOP("QRegularExpression", "using UCP is disabled by the application"), QT_TRANSLATE_NOOP("QRegularExpression", "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"), QT_TRANSLATE_NOOP("QRegularExpression", "character code point value in \\u.... sequence is too large"), - QT_TRANSLATE_NOOP("QRegularExpression", "digits missing in \\x{} or \\o{}"), - QT_TRANSLATE_NOOP("QRegularExpression", "syntax error in (?(VERSION condition"), + QT_TRANSLATE_NOOP("QRegularExpression", "digits missing in \\x{} or \\o{} or \\N{U+}"), + QT_TRANSLATE_NOOP("QRegularExpression", "syntax error or number too big in (?(VERSION condition"), QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unknown opcode in auto_possessify()"), QT_TRANSLATE_NOOP("QRegularExpression", "missing terminating delimiter for callout with string argument"), QT_TRANSLATE_NOOP("QRegularExpression", "unrecognized string delimiter follows (?C"), @@ -2950,6 +2950,16 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "regular expression is too complicated"), QT_TRANSLATE_NOOP("QRegularExpression", "lookbehind assertion is too long"), QT_TRANSLATE_NOOP("QRegularExpression", "pattern string is longer than the limit set by the application"), + QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unknown code in parsed pattern"), + QT_TRANSLATE_NOOP("QRegularExpression", "internal error: bad code value in parsed_skip()"), + QT_TRANSLATE_NOOP("QRegularExpression", "PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES is not allowed in UTF-16 mode"), + QT_TRANSLATE_NOOP("QRegularExpression", "invalid option bits with PCRE2_LITERAL"), + QT_TRANSLATE_NOOP("QRegularExpression", "\\N{U+dddd} is supported only in Unicode (UTF) mode"), + QT_TRANSLATE_NOOP("QRegularExpression", "invalid hyphen in option setting"), + QT_TRANSLATE_NOOP("QRegularExpression", "(*alpha_assertion) not recognized"), + QT_TRANSLATE_NOOP("QRegularExpression", "script runs require Unicode support, which this version of PCRE2 does not have"), + QT_TRANSLATE_NOOP("QRegularExpression", "too many capturing groups (maximum 65535)"), + QT_TRANSLATE_NOOP("QRegularExpression", "atomic assertion expected after (?( or (?(?C)"), QT_TRANSLATE_NOOP("QRegularExpression", "no error"), QT_TRANSLATE_NOOP("QRegularExpression", "no match"), QT_TRANSLATE_NOOP("QRegularExpression", "partial match"), @@ -2987,7 +2997,7 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "bad option value"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid replacement string"), QT_TRANSLATE_NOOP("QRegularExpression", "bad offset into UTF string"), - QT_TRANSLATE_NOOP("QRegularExpression", "callout error code"), /* Never returned by PCRE2 itself */ + QT_TRANSLATE_NOOP("QRegularExpression", "callout error code"), QT_TRANSLATE_NOOP("QRegularExpression", "invalid data in workspace for DFA restart"), QT_TRANSLATE_NOOP("QRegularExpression", "too much recursion for DFA matching"), QT_TRANSLATE_NOOP("QRegularExpression", "backreference condition or recursion test is not supported for DFA matching"), @@ -3003,15 +3013,20 @@ static const char *pcreCompileErrorCodes[] = QT_TRANSLATE_NOOP("QRegularExpression", "non-unique substring name"), QT_TRANSLATE_NOOP("QRegularExpression", "NULL argument passed"), QT_TRANSLATE_NOOP("QRegularExpression", "nested recursion at the same subject position"), - QT_TRANSLATE_NOOP("QRegularExpression", "recursion limit exceeded"), + QT_TRANSLATE_NOOP("QRegularExpression", "matching depth limit exceeded"), QT_TRANSLATE_NOOP("QRegularExpression", "requested value is not available"), QT_TRANSLATE_NOOP("QRegularExpression", "requested value is not set"), QT_TRANSLATE_NOOP("QRegularExpression", "offset limit set without PCRE2_USE_OFFSET_LIMIT"), QT_TRANSLATE_NOOP("QRegularExpression", "bad escape sequence in replacement string"), QT_TRANSLATE_NOOP("QRegularExpression", "expected closing curly bracket in replacement string"), QT_TRANSLATE_NOOP("QRegularExpression", "bad substitution in replacement string"), - QT_TRANSLATE_NOOP("QRegularExpression", "match with end before start is not supported"), - QT_TRANSLATE_NOOP("QRegularExpression", "too many replacements (more than INT_MAX)") + QT_TRANSLATE_NOOP("QRegularExpression", "match with end before start or start moved backwards is not supported"), + QT_TRANSLATE_NOOP("QRegularExpression", "too many replacements (more than INT_MAX)"), + QT_TRANSLATE_NOOP("QRegularExpression", "bad serialized data"), + QT_TRANSLATE_NOOP("QRegularExpression", "heap limit exceeded"), + QT_TRANSLATE_NOOP("QRegularExpression", "invalid syntax"), + QT_TRANSLATE_NOOP("QRegularExpression", "internal error - duplicate substitution match"), + QT_TRANSLATE_NOOP("QRegularExpression", "PCRE2_MATCH_INVALID_UTF is not supported for DFA matching") }; #endif // #if 0 -- cgit v1.2.3 From 411c2e3e4f32ab98bab65bcd53faf11da3c4efd0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Fri, 27 Dec 2019 12:49:44 +0100 Subject: QCommonStyle: make sure to pass the widget to pixelMetric() QStyle::pixelMetric() expects the affected QWidget as third parameter. Some (external) styles rely on this to return the correct value. Therefore add the widget to the function calls where possible. Fixes: QTBUG-80971 Task-number: QTBUG-1857 Change-Id: I768ebb61a914cdba6e0549f841d46cf3edb0a2a6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/widgets/styles/qcommonstyle.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 09d65f0346..bc423187d2 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4569,7 +4569,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_MenuPanelWidth: case PM_TabBarBaseOverlap: case PM_TabBarBaseHeight: - ret = proxy()->pixelMetric(PM_DefaultFrameWidth, opt); + ret = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); break; case PM_MdiSubWindowFrameWidth: @@ -4801,7 +4801,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_TabBarIconSize: - ret = proxy()->pixelMetric(PM_SmallIconSize, opt); + ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); break; case PM_ListViewIconSize: #if QT_CONFIG(filedialog) @@ -4809,7 +4809,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = int(QStyleHelper::dpiScaled(24., opt)); else #endif - ret = proxy()->pixelMetric(PM_SmallIconSize, opt); + ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); break; case PM_ButtonIconSize: @@ -4817,7 +4817,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = int(QStyleHelper::dpiScaled(16, opt)); break; case PM_IconViewIconSize: - ret = proxy()->pixelMetric(PM_LargeIconSize, opt); + ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; case PM_LargeIconSize: @@ -4855,13 +4855,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = int(QStyleHelper::dpiScaled(16, opt)); break; case PM_ScrollView_ScrollBarSpacing: - ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt); + ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); break; case PM_ScrollView_ScrollBarOverlap: ret = 0; break; case PM_SubMenuOverlap: - ret = -proxy()->pixelMetric(QStyle::PM_MenuPanelWidth, opt); + ret = -proxy()->pixelMetric(QStyle::PM_MenuPanelWidth, opt, widget); break; case PM_TreeViewIndentation: ret = int(QStyleHelper::dpiScaled(20, opt)); -- cgit v1.2.3 From 27d139128013c969a939779536485c1a80be977e Mon Sep 17 00:00:00 2001 From: Tuomas Heimonen <tuomas.heimonen@qt.io> Date: Fri, 29 Nov 2019 09:27:35 +0200 Subject: QLocale: Support Indian number formatting When QLocale::Country is set to QLocale::India numbers are written so that after first three from the right and then after every second will be comma. E.g. 10000000 is written as 1,00,00,000 Task-number: QTBUG-24301 Change-Id: Ic06241c127b0af1824104f94f7e2ce6e2058a070 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Teemu Holappa <teemu.holappa@qt.io> --- src/corelib/text/qlocale.cpp | 45 +++++++++++++++++++++++++++++++++----------- src/corelib/text/qlocale_p.h | 3 ++- 2 files changed, 36 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 75a5bc802e..425cb87d31 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1969,7 +1969,8 @@ QString QLocale::toString(qlonglong i) const { int flags = d->m_numberOptions & OmitGroupSeparator ? 0 - : QLocaleData::ThousandsGroup; + : (d->m_data->m_country_id == Country::India) + ? QLocaleData::IndianNumberGrouping : QLocaleData::ThousandsGroup; return d->m_data->longLongToString(i, -1, 10, -1, flags); } @@ -1984,7 +1985,8 @@ QString QLocale::toString(qulonglong i) const { int flags = d->m_numberOptions & OmitGroupSeparator ? 0 - : QLocaleData::ThousandsGroup; + : (d->m_data->m_country_id == Country::India) + ? QLocaleData::IndianNumberGrouping : QLocaleData::ThousandsGroup; return d->m_data->unsLongLongToString(i, -1, 10, -1, flags); } @@ -3626,10 +3628,19 @@ QT_WARNING_DISABLE_MSVC(4146) QT_WARNING_POP uint cnt_thousand_sep = 0; - if (flags & ThousandsGroup && base == 10) { - for (int i = num_str.length() - 3; i > 0; i -= 3) { - num_str.insert(i, group); - ++cnt_thousand_sep; + if (base == 10){ + if (flags & ThousandsGroup) { + for (int i = num_str.length() - 3; i > 0; i -= 3) { + num_str.insert(i, group); + ++cnt_thousand_sep; + } + } else if (flags & IndianNumberGrouping) { + if (num_str.length() > 3) + num_str.insert(num_str.length() - 3 , group); + for (int i = num_str.length() - 6; i > 0; i -= 2) { + num_str.insert(i, group); + ++cnt_thousand_sep; + } } } @@ -3713,10 +3724,19 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, } uint cnt_thousand_sep = 0; - if (flags & ThousandsGroup && base == 10) { - for (int i = num_str.length() - 3; i > 0; i -=3) { - num_str.insert(i, group); - ++cnt_thousand_sep; + if (base == 10) { + if (flags & ThousandsGroup) { + for (int i = num_str.length() - 3; i > 0; i -=3) { + num_str.insert(i, group); + ++cnt_thousand_sep; + } + } else if (flags & IndianNumberGrouping) { + if (num_str.length() > 3) + num_str.insert(num_str.length() - 3 , group); + for (int i = num_str.length() - 6; i > 0; i -= 2) { + num_str.insert(i, group); + ++cnt_thousand_sep; + } } } @@ -3851,7 +3871,10 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o // check distance from the last separator or from the beginning of the digits // ### FIXME: Some locales allow other groupings! // See https://en.wikipedia.org/wiki/Thousands_separator - if (last_separator_idx != -1 && idx - last_separator_idx != 4) + if (m_country_id == QLocale::India) { + if (last_separator_idx != -1 && idx - last_separator_idx != 3) + return false; + } else if (last_separator_idx != -1 && idx - last_separator_idx != 4) return false; if (last_separator_idx == -1 && (start_of_digits_idx == -1 || idx - start_of_digits_idx > 3)) { diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index edee3a89c7..bb24009523 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -213,7 +213,8 @@ public: ShowBase = 0x80, UppercaseBase = 0x100, ZeroPadExponent = 0x200, - ForcePoint = 0x400 + ForcePoint = 0x400, + IndianNumberGrouping= 0x800 }; enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode }; -- cgit v1.2.3 From a63969081c2f1656636f6fbc24b402a0f72c410b Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva <neluhus.vagus@gmail.com> Date: Thu, 26 Dec 2019 16:17:20 +0300 Subject: wasm: support all cursor shapes Every Qt::CursorShape is supported. Tested in Chrome, Firefox and Safari. Change-Id: I38c9024dba4af70af789ac84ad7e38f749c847d7 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> --- src/plugins/platforms/wasm/qwasmcursor.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 2b3f37300d..28ec3b58dd 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -68,6 +68,7 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "default"; break; case Qt::UpArrowCursor: + cursorName = "n-resize"; break; case Qt::CrossCursor: cursorName = "crosshair"; @@ -91,7 +92,8 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "nwse-resize"; break; case Qt::SizeAllCursor: - break; // no equivalent? + cursorName = "move"; + break; case Qt::BlankCursor: cursorName = "none"; break; @@ -111,18 +113,23 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "help"; break; case Qt::BusyCursor: - cursorName = "wait"; + cursorName = "progress"; break; case Qt::OpenHandCursor: - break; // no equivalent? + cursorName = "grab"; + break; case Qt::ClosedHandCursor: - break; // no equivalent? + cursorName = "grabbing"; + break; case Qt::DragCopyCursor: - break; // no equivalent? + cursorName = "copy"; + break; case Qt::DragMoveCursor: - break; // no equivalent? + cursorName = "default"; + break; case Qt::DragLinkCursor: - break; // no equivalent? + cursorName = "alias"; + break; default: break; } -- cgit v1.2.3 From 663d00c71697a3383d9b3f3bb42b72c3d8eeaa05 Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@qt.io> Date: Thu, 19 Dec 2019 12:55:37 +0100 Subject: cborstreamwriter: Fix developer-build with clang Both functions are unused which results in a build error. Change-Id: If7e7a47cd62b91fbfc5bbf5330825bbb341a734b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/serialization/qcborstreamreader.cpp | 2 +- src/corelib/serialization/qcborstreamwriter.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp index 112fc6e226..c983436606 100644 --- a/src/corelib/serialization/qcborstreamreader.cpp +++ b/src/corelib/serialization/qcborstreamreader.cpp @@ -72,7 +72,7 @@ static CborError _cbor_value_dup_string(const CborValue *, void **, size_t *, Cb Q_UNREACHABLE(); return CborErrorInternalError; } -static CborError cbor_value_get_half_float_as_float(const CborValue *, float *) +static CborError Q_DECL_UNUSED cbor_value_get_half_float_as_float(const CborValue *, float *) { Q_UNREACHABLE(); return CborErrorInternalError; diff --git a/src/corelib/serialization/qcborstreamwriter.cpp b/src/corelib/serialization/qcborstreamwriter.cpp index d7f750b05e..9d78785416 100644 --- a/src/corelib/serialization/qcborstreamwriter.cpp +++ b/src/corelib/serialization/qcborstreamwriter.cpp @@ -63,13 +63,13 @@ QT_WARNING_POP // silence compilers that complain about this being a static function declared // but never defined -static CborError cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*) +static CborError Q_DECL_UNUSED cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*) { Q_UNREACHABLE(); return CborErrorInternalError; } -static CborError cbor_encode_float_as_half_float(CborEncoder *, float) +static CborError Q_DECL_UNUSED cbor_encode_float_as_half_float(CborEncoder *, float) { Q_UNREACHABLE(); return CborErrorInternalError; -- cgit v1.2.3 From 4b1d370f755578f60bd9c73ca98eeb8e71463caf Mon Sep 17 00:00:00 2001 From: Shawn Rutledge <shawn.rutledge@qt.io> Date: Fri, 27 Dec 2019 11:48:26 +0100 Subject: Check platformNativeInterface pointer before dereferencing QApplication::platformNativeInterface() returns null if started with -platform offscreen. Fixes: QTBUG-80946 Change-Id: I3ad03ad27148c8576bd3fab0b136827bb8d171ae Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/widgets/qmainwindow.cpp | 2 ++ src/widgets/widgets/qtoolbarlayout.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 16ed699137..e3dbe763e5 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1364,6 +1364,8 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) createWinId(); QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + if (!nativeInterface) + return; // Not Cocoa platform plugin. QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration("setContentBorderEnabled"); if (!function) diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 961a261e8f..92094a38fb 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -360,6 +360,8 @@ void QToolBarLayout::updateMacBorderMetrics() return; QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface(); + if (!nativeInterface) + return; // Not Cocoa platform plugin. QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration("registerContentBorderArea"); if (!function) -- cgit v1.2.3 From 809a96d6d94a93046dc63dd6f52c51ae90c374f8 Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Wed, 18 Dec 2019 19:06:18 +1000 Subject: wasm: fix setting translucent background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to set the requested SurfaceFormat which may contain the alphaBufferSize in order for the GL context to have the alpha attribute Fixes: QTBUG-77303 Change-Id: I39860e24de49a255ab7e73bca78af92e6c074d0d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/platforms/wasm/qwasmcompositor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index a810880c43..e9c4559971 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -694,7 +694,7 @@ void QWasmCompositor::frame() if (m_context.isNull()) { m_context.reset(new QOpenGLContext()); - //mContext->setFormat(mScreen->format()); + m_context->setFormat(someWindow->window()->requestedFormat()); m_context->setScreen(screen()->screen()); m_context->create(); } -- cgit v1.2.3 From a1f4321bbba2f3bff24d753ce766be738dbfa61a Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@qt.io> Date: Tue, 3 Dec 2019 15:12:51 +0100 Subject: QTextDocument: Give fontFamily() precedence over fontFamilies() If the singular fontFamily() is given, then this is obviously the one to be preferred over any plural fontFamilies(). Make sure it always ends up first in the list of emitted font families. Change-Id: I1e3b1ba29721c8298b1a0d4a1e1da49ba5b4e7ac Fixes: QTBUG-80475 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/gui/text/qtextdocument.cpp | 39 ++++++++++++++------------------------- src/gui/text/qtextdocument_p.h | 1 - 2 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 4b35509ace..25c153910d 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2297,6 +2297,17 @@ QTextHtmlExporter::QTextHtmlExporter(const QTextDocument *_doc) defaultCharFormat.clearProperty(QTextFormat::TextUnderlineStyle); } +static QStringList resolvedFontFamilies(const QTextCharFormat &format) +{ + QStringList fontFamilies = format.fontFamilies().toStringList(); + const QString mainFontFamily = format.fontFamily(); + if (!mainFontFamily.isEmpty() && !fontFamilies.startsWith(mainFontFamily)) { + fontFamilies.removeAll(mainFontFamily); + fontFamilies.prepend(mainFontFamily); + } + return fontFamilies; +} + /*! Returns the document in HTML format. The conversion may not be perfect, especially for complex documents, due to the limitations @@ -2325,11 +2336,7 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) if (mode == ExportEntireDocument) { html += QLatin1String(" style=\""); - QStringList fontFamilies = defaultCharFormat.fontFamilies().toStringList(); - if (!fontFamilies.isEmpty()) - emitFontFamily(fontFamilies); - else - emitFontFamily(defaultCharFormat.fontFamily()); + emitFontFamily(resolvedFontFamilies(defaultCharFormat)); if (defaultCharFormat.hasProperty(QTextFormat::FontPointSize)) { html += QLatin1String(" font-size:"); @@ -2391,14 +2398,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) bool attributesEmitted = false; { - const QStringList families = format.fontFamilies().toStringList(); - const QString family = format.fontFamily(); - if (!families.isEmpty() && families != defaultCharFormat.fontFamilies().toStringList()) { + const QStringList families = resolvedFontFamilies(format); + if (!families.isEmpty() && families != resolvedFontFamilies(defaultCharFormat)) { emitFontFamily(families); attributesEmitted = true; - } else if (!family.isEmpty() && family != defaultCharFormat.fontFamily()) { - emitFontFamily(family); - attributesEmitted = true; } } @@ -2661,20 +2664,6 @@ void QTextHtmlExporter::emitPageBreakPolicy(QTextFormat::PageBreakFlags policy) html += QLatin1String(" page-break-after:always;"); } -void QTextHtmlExporter::emitFontFamily(const QString &family) -{ - html += QLatin1String(" font-family:"); - - QLatin1String quote("\'"); - if (family.contains(QLatin1Char('\''))) - quote = QLatin1String("""); - - html += quote; - html += family.toHtmlEscaped(); - html += quote; - html += QLatin1Char(';'); -} - void QTextHtmlExporter::emitFontFamily(const QStringList &families) { html += QLatin1String(" font-family:"); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index f4e7a25f22..40252c93eb 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -396,7 +396,6 @@ private: void emitBorderStyle(QTextFrameFormat::BorderStyle style); void emitPageBreakPolicy(QTextFormat::PageBreakFlags policy); - void emitFontFamily(const QString &family); void emitFontFamily(const QStringList &families); void emitBackgroundAttribute(const QTextFormat &format); -- cgit v1.2.3 From c027d9b61e15ab021a6fb5503e3206929055da02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Thu, 2 Jan 2020 12:22:02 +0100 Subject: Remove commented out code added by mistake in 7ac4e55cb979d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibd53518be9d2b29dd880912bdb81c06435543789 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index d8c931e9a1..b7f15a2bf1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -396,8 +396,6 @@ QVariant QCocoaIntegration::styleHint(StyleHint hint) const return QCoreTextFontEngine::fontSmoothingGamma(); case ShowShortcutsInContextMenus: return QVariant(false); - // case CursorFlashTime: - // return 50000; default: break; } -- cgit v1.2.3 From a6f56251ca6090cb0ba4c4989d7ccc638b1dbe2b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 2 Jan 2020 12:24:15 +0100 Subject: Fix some qdoc warnings src/corelib/tools/qhash.cpp:2596: (qdoc) warning: clang found diagnostics parsing \fn template <class Key, class T> template <class InputIterator> QMultiHash::QMultiHash(InputIterator begin, InputIterator end) error: 'QMultiHash' is not a class, namespace, or enumeration src/corelib/kernel/qobject.cpp:4593: (qdoc) warning: Undocumented parameter 'EXPORT_MACRO' in QObject::Q_NAMESPACE_EXPORT src/corelib/global/qfloat16.cpp:129: (qdoc) warning: Cannot tie this documentation to anything src/corelib/text/qlocale.qdoc:1204: (qdoc) warning: Overrides a previous doc src/corelib/text/qlocale.qdoc:1187: (qdoc) warning: (The previous doc is here) src/network/kernel/qhostinfo.cpp:597: (qdoc) warning: clang found diagnostics parsing \fn QHostInfo(QHostInfo &&other) src/printsupport/dialogs/qabstractprintdialog.cpp:346: (qdoc) warning: clang found diagnostics parsing \fn int QAbstractPrintDialog::exec(): error: out-of-line definition of 'exec' does not match any declaration in 'QAbstractPrintDialog' src/testlib/qsignalspy.qdoc:101: (qdoc) warning: clang found diagnostics parsing \fn QSignalSpy(const QObject *obj, const QMetaMethod &signal): error: expected unqualified-id src/testlib/doc/src/qttest-best-practices.qdoc:28: (qdoc) warning: Can't link to 'Q_VERIFY2()' src/widgets/kernel/qactiongroup.cpp:291: (qdoc) warning: Undocumented parameter 'b' in QActionGroup::setExclusive() src/widgets/kernel/qactiongroup.cpp:305: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/widgets/kernel/qshortcut.cpp:542: (qdoc) warning: No such parameter 'context' in QShortcut::QShortcut() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'minimumTime' in QDateTimeEdit::setTimeRange() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'maximumTime' in QDateTimeEdit::setTimeRange() src/widgets/widgets/qdatetimeedit.cpp:632: (qdoc) warning: No such parameter 'less' in QDateTimeEdit::setTimeRange() Change-Id: I9799b5135e84c4d811674b2d114ef27315bc12df Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/global/qfloat16.cpp | 8 ++++---- src/corelib/kernel/qobject.cpp | 2 +- src/corelib/text/qlocale.qdoc | 8 -------- src/corelib/tools/qhash.cpp | 2 +- src/network/kernel/qhostinfo.cpp | 2 +- src/printsupport/dialogs/qabstractprintdialog.cpp | 7 ------- src/testlib/doc/src/qttest-best-practices.qdoc | 2 +- src/testlib/qsignalspy.qdoc | 2 +- src/widgets/kernel/qactiongroup.cpp | 5 +++-- src/widgets/kernel/qshortcut.cpp | 2 +- src/widgets/widgets/qdatetimeedit.cpp | 7 +++---- 11 files changed, 16 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 6c21b7de5a..c868e879b7 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -109,7 +109,7 @@ QT_BEGIN_NAMESPACE /*! \internal \since 5.14 - bool qfloat16::isInf() const noexcept + \fn bool qfloat16::isInf() const noexcept Tests whether this \c qfloat16 value is an infinity. @@ -119,7 +119,7 @@ QT_BEGIN_NAMESPACE /*! \internal \since 5.14 - bool qfloat16::isNaN() const noexcept + \fn bool qfloat16::isNaN() const noexcept Tests whether this \c qfloat16 value is "not a number". @@ -128,7 +128,7 @@ QT_BEGIN_NAMESPACE /*! \since 5.14 - bool qfloat16::isNormal() const noexcept + \fn bool qfloat16::isNormal() const noexcept Tests whether this \c qfloat16 value is finite and in normal form. @@ -138,7 +138,7 @@ QT_BEGIN_NAMESPACE /*! \internal \since 5.14 - bool qfloat16::isFinite() const noexcept + \fn bool qfloat16::isFinite() const noexcept Tests whether this \c qfloat16 value is finite. diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index cf107498dd..cc50d9ccc7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4612,7 +4612,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) It works exactly like the Q_NAMESPACE macro. However, the external \c{staticMetaObject} variable that gets defined in the namespace - is declared with the supplied \c{EXPORT_MACRO} qualifier. This is + is declared with the supplied \a EXPORT_MACRO qualifier. This is useful if the object needs to be exported from a dynamic library. \sa Q_NAMESPACE, {Creating Shared Libraries} diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index 6c9d6f9d11..dbcd71f1a0 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -1201,14 +1201,6 @@ \sa toShort() */ -/*! -\fn QString QLocale::toString(ushort i) const - -\overload - -\sa toUShort() -*/ - /*! \fn QString QLocale::toString(int i) const diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index a53d6db997..6ec8019ba3 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -2597,7 +2597,7 @@ uint qHash(long double key, uint seed) noexcept \sa operator=() */ -/*! \fn template <class Key, class T> template <class InputIterator> QMultiHash::QMultiHash(InputIterator begin, InputIterator end) +/*! \fn template <class Key, class T> template <class InputIterator> QMultiHash<Key, T>::QMultiHash(InputIterator begin, InputIterator end) \since 5.14 Constructs a multi-hash with a copy of each of the elements in the iterator range diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f9335c3bb9..9dbb154914 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -595,7 +595,7 @@ QHostInfo::QHostInfo(const QHostInfo &other) } /*! - \fn QHostInfo(QHostInfo &&other) + \fn QHostInfo::QHostInfo(QHostInfo &&other) Move-constructs a new QHostInfo from \a other. diff --git a/src/printsupport/dialogs/qabstractprintdialog.cpp b/src/printsupport/dialogs/qabstractprintdialog.cpp index 1a2aa7afac..b0d03037e6 100644 --- a/src/printsupport/dialogs/qabstractprintdialog.cpp +++ b/src/printsupport/dialogs/qabstractprintdialog.cpp @@ -343,13 +343,6 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter) pd = printer->d_func(); } -/*! - \fn int QAbstractPrintDialog::exec() - - This virtual function is called to pop up the dialog. It must be - reimplemented in subclasses. -*/ - /*! \class QPrintDialog diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc index 8ad67acce6..952fd3259d 100644 --- a/src/testlib/doc/src/qttest-best-practices.qdoc +++ b/src/testlib/doc/src/qttest-best-practices.qdoc @@ -243,7 +243,7 @@ Instead of \c Q_ASSERT, the \l QCOMPARE() or \l QVERIFY() macro variants should be used. They cause the current test to report a failure and terminate, but allow the remaining test functions to be executed and the - entire test program to terminate normally. \l Q_VERIFY2() even allows a + entire test program to terminate normally. \l QVERIFY2() even allows a descriptive error message to be recorded in the test log. \section1 Writing Reliable Tests diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc index d532ad478d..d40c84907c 100644 --- a/src/testlib/qsignalspy.qdoc +++ b/src/testlib/qsignalspy.qdoc @@ -98,7 +98,7 @@ \snippet code/doc_src_qsignalspy.cpp 6 */ -/*! \fn QSignalSpy(const QObject *obj, const QMetaMethod &signal) +/*! \fn QSignalSpy::QSignalSpy(const QObject *obj, const QMetaMethod &signal) \since 5.14 Constructs a new QSignalSpy that listens for emissions of the \a signal diff --git a/src/widgets/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp index 1d9213de0c..d359703db3 100644 --- a/src/widgets/kernel/qactiongroup.cpp +++ b/src/widgets/kernel/qactiongroup.cpp @@ -292,7 +292,8 @@ QList<QAction*> QActionGroup::actions() const \brief Enable or disable the group exclusion checking This is a convenience method that calls - setExclusionPolicy(ExclusionPolicy::Exclusive). + setExclusionPolicy(ExclusionPolicy::Exclusive) when \a b is true, + else setExclusionPolicy(QActionGroup::ExclusionPolicy::None). \sa QActionGroup::exclusionPolicy */ @@ -303,7 +304,7 @@ void QActionGroup::setExclusive(bool b) } /*! - \brief Returs true if the group is exclusive + \brief Returns true if the group is exclusive The group is exclusive if the ExclusionPolicy is either Exclusive or ExclusionOptional. diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index eec65c8625..f157ba2943 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -475,7 +475,7 @@ QShortcut::QShortcut(QWidget *parent) match the \a key sequence. Depending on the ambiguity of the event, the shortcut will call the \a member function, or the \a ambiguousMember function, if the key press was in the shortcut's - \a context. + \a shortcutContext. */ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, const char *member, const char *ambiguousMember, diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 9189319364..da4aaadc97 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -335,7 +335,6 @@ void QDateTimeEdit::setCalendar(QCalendar calendar) /*! \since 4.4 \property QDateTimeEdit::minimumDateTime - \brief the minimum datetime of the date time edit Changing this property implicitly updates the \l minimumDate and \l @@ -637,8 +636,8 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) Note that these only constrain the date time edit's value on, respectively, the \l minimumDate and \l maximumDate. When these date - properties do not coincide, times after \a maximumTime are allowed on dates - before \l maximumDate and times before \a minimumTime are allowed on dates + properties do not coincide, times after \a max are allowed on dates + before \l maximumDate and times before \a min are allowed on dates after \l minimumDate. \snippet code/src_gui_widgets_qdatetimeedit.cpp 5 @@ -649,7 +648,7 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max) If either \a min or \a max is invalid, this function does nothing. This function preserves the \l minimumDate and \l maximumDate properties. If those - properties coincide and max is \a less than \a min, \a min is used as \a max. + properties coincide and \a max is less than \a min, \a min is used as \a max. \sa minimumTime, maximumTime, setDateTimeRange(), QTime::isValid() */ -- cgit v1.2.3 From deddafe0a6a32aa438cc36c7dcfae8c323274487 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann <joerg.bornemann@qt.io> Date: Wed, 12 Jun 2019 13:42:39 +0200 Subject: Long live QFlatMap! Add a light-weight associative container, API-wise very similar to QMap, that's based on two sorted continuous containers (QVector by default). The class is internal for now. Change-Id: Ife12576c4abb39a3ea2acb0a1ba0faca91b3a4c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> --- src/corelib/tools/qflatmap_p.h | 982 +++++++++++++++++++++++++++++++++++++++++ src/corelib/tools/tools.pri | 1 + 2 files changed, 983 insertions(+) create mode 100644 src/corelib/tools/qflatmap_p.h (limited to 'src') diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h new file mode 100644 index 0000000000..590b0d942f --- /dev/null +++ b/src/corelib/tools/qflatmap_p.h @@ -0,0 +1,982 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFLATMAP_P_H +#define QFLATMAP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of a number of Qt sources files. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qvector.h" + +#include <algorithm> +#include <functional> +#include <initializer_list> +#include <iterator> +#include <numeric> +#include <type_traits> +#include <utility> + +QT_BEGIN_NAMESPACE + +/* + QFlatMap provides an associative container backed by sorted sequential + containers. By default, QVector is used. + + Keys and values are stored in two separate containers. This provides improved + cache locality for key iteration and makes keys() and values() fast + operations. + + One can customize the underlying container type by passing the KeyContainer + and MappedContainer template arguments: + QFlatMap<float, int, std::less<float>, std::vector<float>, std::vector<int>> +*/ + +namespace Qt { + +struct OrderedUniqueRange_t {}; +constexpr OrderedUniqueRange_t OrderedUniqueRange = {}; + +} // namespace Qt + +template <class Key, class T, class Compare> +class QFlatMapValueCompare : protected Compare +{ +public: + QFlatMapValueCompare() = default; + QFlatMapValueCompare(const Compare &key_compare) + : Compare(key_compare) + { + } + + using value_type = std::pair<const Key, T>; + static constexpr bool is_comparator_noexcept = noexcept( + std::declval<Compare>()(std::declval<Key>(), std::declval<Key>())); + + bool operator()(const value_type &lhs, const value_type &rhs) const + noexcept(is_comparator_noexcept) + { + return Compare::operator()(lhs.first, rhs.first); + } +}; + +template <class Key, class T, + class Compare = std::less<Key>, + class KeyContainer = QVector<Key>, + class MappedContainer = QVector<T>> +class QFlatMap : private QFlatMapValueCompare<Key, T, Compare> +{ + using full_map_t = QFlatMap<Key, T, Compare, KeyContainer, MappedContainer>; + + template <class U> + class mock_pointer + { + U ref; + public: + mock_pointer(U r) + : ref(r) + { + } + + U *operator->() + { + return &ref; + } + }; + +public: + using key_type = Key; + using mapped_type = T; + using value_compare = QFlatMapValueCompare<Key, T, Compare>; + using value_type = typename value_compare::value_type; + using key_container_type = KeyContainer; + using mapped_container_type = MappedContainer; + using size_type = typename key_container_type::size_type; + using key_compare = Compare; + + struct containers + { + key_container_type keys; + mapped_container_type values; + }; + + class iterator + { + public: + using difference_type = ptrdiff_t; + using value_type = std::pair<const Key, T>; + using reference = std::pair<const Key &, T &>; + using pointer = mock_pointer<reference>; + using iterator_category = std::random_access_iterator_tag; + + iterator() = default; + + iterator(containers *ac, size_type ai) + : c(ac), i(ai) + { + } + + reference operator*() + { + return { c->keys[i], c->values[i] }; + } + + pointer operator->() + { + return { operator*() }; + } + + bool operator==(const iterator &o) const + { + return c == o.c && i == o.i; + } + + bool operator!=(const iterator &o) const + { + return !operator==(o); + } + + iterator &operator++() + { + ++i; + return *this; + } + + iterator operator++(int) + { + + iterator r = *this; + i++; + return r; + } + + iterator &operator--() + { + --i; + return *this; + } + + iterator operator--(int) + { + iterator r = *this; + i--; + return r; + } + + iterator &operator+=(size_type n) + { + i += n; + return *this; + } + + friend iterator operator+(size_type n, const iterator a) + { + iterator ret = a; + return ret += n; + } + + friend iterator operator+(const iterator a, size_type n) + { + return n + a; + } + + iterator &operator-=(size_type n) + { + i -= n; + return *this; + } + + friend iterator operator-(const iterator a, size_type n) + { + iterator ret = a; + return ret -= n; + } + + friend difference_type operator-(const iterator b, const iterator a) + { + return b.i - a.i; + } + + reference operator[](size_type n) + { + size_type k = i + n; + return { c->keys[k], c->values[k] }; + } + + bool operator<(const iterator &other) const + { + return i < other.i; + } + + bool operator>(const iterator &other) const + { + return i > other.i; + } + + bool operator<=(const iterator &other) const + { + return i <= other.i; + } + + bool operator>=(const iterator &other) const + { + return i >= other.i; + } + + const Key &key() const { return c->keys[i]; } + T &value() { return c->values[i]; } + + private: + containers *c = nullptr; + size_type i = 0; + friend full_map_t; + }; + + class const_iterator + { + public: + using difference_type = ptrdiff_t; + using value_type = std::pair<const Key, const T>; + using reference = std::pair<const Key &, const T &>; + using pointer = mock_pointer<reference>; + using iterator_category = std::random_access_iterator_tag; + + const_iterator() = default; + + const_iterator(const containers *ac, size_type ai) + : c(ac), i(ai) + { + } + + const_iterator(iterator o) + : c(o.c), i(o.i) + { + } + + reference operator*() + { + return { c->keys[i], c->values[i] }; + } + + pointer operator->() + { + return { operator*() }; + } + + bool operator==(const const_iterator &o) const + { + return c == o.c && i == o.i; + } + + bool operator!=(const const_iterator &o) const + { + return !operator==(o); + } + + const_iterator &operator++() + { + ++i; + return *this; + } + + const_iterator operator++(int) + { + + const_iterator r = *this; + i++; + return r; + } + + const_iterator &operator--() + { + --i; + return *this; + } + + const_iterator operator--(int) + { + const_iterator r = *this; + i--; + return r; + } + + const_iterator &operator+=(size_type n) + { + i += n; + return *this; + } + + friend const_iterator operator+(size_type n, const const_iterator a) + { + const_iterator ret = a; + return ret += n; + } + + friend const_iterator operator+(const const_iterator a, size_type n) + { + return n + a; + } + + const_iterator &operator-=(size_type n) + { + i -= n; + return *this; + } + + friend const_iterator operator-(const const_iterator a, size_type n) + { + const_iterator ret = a; + return ret -= n; + } + + friend difference_type operator-(const const_iterator b, const const_iterator a) + { + return b.i - a.i; + } + + reference operator[](size_type n) + { + size_type k = i + n; + return { c->keys[k], c->values[k] }; + } + + bool operator<(const const_iterator &other) const + { + return i < other.i; + } + + bool operator>(const const_iterator &other) const + { + return i > other.i; + } + + bool operator<=(const const_iterator &other) const + { + return i <= other.i; + } + + bool operator>=(const const_iterator &other) const + { + return i >= other.i; + } + + const Key &key() const { return c->keys[i]; } + const T &value() { return c->values[i]; } + + private: + const containers *c = nullptr; + size_type i = 0; + friend full_map_t; + }; + +private: + template <class, class = void> + struct is_marked_transparent_type : std::false_type { }; + + template <class X> + struct is_marked_transparent_type<X, typename X::is_transparent> : std::true_type { }; + + template <class X> + using is_marked_transparent = typename std::enable_if< + is_marked_transparent_type<X>::value>::type *; + + template <typename It> + using is_compatible_iterator = typename std::enable_if< + std::is_same<value_type, typename std::iterator_traits<It>::value_type>::value>::type *; + +public: + QFlatMap() = default; + + explicit QFlatMap(const key_container_type &keys, const mapped_container_type &values) + : c{keys, values} + { + ensureOrderedUnique(); + } + + explicit QFlatMap(key_container_type &&keys, const mapped_container_type &values) + { + c.keys = std::move(keys); + c.values = values; + ensureOrderedUnique(); + } + + explicit QFlatMap(const key_container_type &keys, mapped_container_type &&values) + { + c.keys = keys; + c.values = std::move(values); + ensureOrderedUnique(); + } + + explicit QFlatMap(key_container_type &&keys, mapped_container_type &&values) + { + c.keys = std::move(keys); + c.values = std::move(values); + ensureOrderedUnique(); + } + + explicit QFlatMap(std::initializer_list<value_type> lst) + : QFlatMap(lst.begin(), lst.end()) + { + } + + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + explicit QFlatMap(InputIt first, InputIt last) + { + initWithRange(first, last); + ensureOrderedUnique(); + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, + const mapped_container_type &values) + { + c.keys = keys; + c.values = values; + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, + const mapped_container_type &values) + { + c.keys = std::move(keys); + c.values = values; + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, + mapped_container_type &&values) + { + c.keys = keys; + c.values = std::move(values); + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, + mapped_container_type &&values) + { + c.keys = std::move(keys); + c.values = std::move(values); + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, std::initializer_list<value_type> lst) + : QFlatMap(lst.begin(), lst.end()) + { + } + + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + explicit QFlatMap(Qt::OrderedUniqueRange_t, InputIt first, InputIt last) + { + initWithRange(first, last); + } + + explicit QFlatMap(const Compare &compare) + : value_compare(compare) + { + } + + explicit QFlatMap(const key_container_type &keys, const mapped_container_type &values, + const Compare &compare) + : value_compare(compare), c{keys, values} + { + ensureOrderedUnique(); + } + + explicit QFlatMap(key_container_type &&keys, const mapped_container_type &values, + const Compare &compare) + : value_compare(compare), c{std::move(keys), values} + { + ensureOrderedUnique(); + } + + explicit QFlatMap(const key_container_type &keys, mapped_container_type &&values, + const Compare &compare) + : value_compare(compare), c{keys, std::move(values)} + { + ensureOrderedUnique(); + } + + explicit QFlatMap(key_container_type &&keys, mapped_container_type &&values, + const Compare &compare) + : value_compare(compare), c{std::move(keys), std::move(values)} + { + ensureOrderedUnique(); + } + + explicit QFlatMap(std::initializer_list<value_type> lst, const Compare &compare) + : QFlatMap(lst.begin(), lst.end(), compare) + { + } + + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + explicit QFlatMap(InputIt first, InputIt last, const Compare &compare) + : value_compare(compare) + { + initWithRange(first, last); + ensureOrderedUnique(); + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, + const mapped_container_type &values, const Compare &compare) + : value_compare(compare), c{keys, values} + { + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, + const mapped_container_type &values, const Compare &compare) + : value_compare(compare), c{std::move(keys), values} + { + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, + mapped_container_type &&values, const Compare &compare) + : value_compare(compare), c{keys, std::move(values)} + { + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, + mapped_container_type &&values, const Compare &compare) + : value_compare(compare), c{std::move(keys), std::move(values)} + { + } + + explicit QFlatMap(Qt::OrderedUniqueRange_t, std::initializer_list<value_type> lst, + const Compare &compare) + : QFlatMap(Qt::OrderedUniqueRange, lst.begin(), lst.end(), compare) + { + } + + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + explicit QFlatMap(Qt::OrderedUniqueRange_t, InputIt first, InputIt last, const Compare &compare) + : value_compare(compare) + { + initWithRange(first, last); + } + + size_type count() const noexcept { return c.keys.size(); } + size_type size() const noexcept { return c.keys.size(); } + size_type capacity() const noexcept { return c.keys.capacity(); } + bool isEmpty() const noexcept { return c.keys.empty(); } + bool empty() const noexcept { return c.keys.empty(); } + containers extract() && { return std::move(c); } + const key_container_type &keys() const noexcept { return c.keys; } + const mapped_container_type &values() const noexcept { return c.values; } + + void reserve(size_type s) + { + c.keys.reserve(s); + c.values.reserve(s); + } + + void clear() + { + c.keys.clear(); + c.values.clear(); + } + + bool remove(const Key &key) + { + auto it = binary_find(key); + if (it != end()) { + c.keys.erase(toKeysIterator(it)); + c.values.erase(toValuesIterator(it)); + return true; + } + return false; + } + + iterator erase(iterator it) + { + c.values.erase(toValuesIterator(it)); + return fromKeysIterator(c.keys.erase(toKeysIterator(it))); + } + + T take(const Key &key) + { + auto it = binary_find(key); + if (it != end()) { + T result = std::move(it.value()); + erase(it); + return result; + } + return {}; + } + + bool contains(const Key &key) const + { + return binary_find(key) != end(); + } + + T value(const Key &key, const T &defaultValue) const + { + auto it = binary_find(key); + return it == end() ? defaultValue : it.value(); + } + + T value(const Key &key) const + { + auto it = binary_find(key); + return it == end() ? T() : it.value(); + } + + T &operator[](const Key &key) + { + auto it = lower_bound(key); + if (it == end() || key_compare::operator()(key, it.key())) { + c.keys.insert(toKeysIterator(it), key); + return *c.values.insert(toValuesIterator(it), T()); + } + return it.value(); + } + + T &operator[](Key &&key) + { + auto it = lower_bound(key); + if (it == end() || key_compare::operator()(key, it.key())) { + c.keys.insert(toKeysIterator(it), key); + return *c.values.insert(toValuesIterator(it), T()); + } + return it.value(); + } + + T operator[](const Key &key) const + { + return value(key); + } + + std::pair<iterator, bool> insert(const Key &key, const T &value) + { + auto it = lower_bound(key); + if (it == end() || key_compare::operator()(key, it.key())) { + c.values.insert(toValuesIterator(it), value); + auto k = c.keys.insert(toKeysIterator(it), key); + return { fromKeysIterator(k), true }; + } else { + it.value() = value; + return {it, false}; + } + } + + std::pair<iterator, bool> insert(Key &&key, const T &value) + { + auto it = lower_bound(key); + if (it == end() || key_compare::operator()(key, it.key())) { + c.values.insert(toValuesIterator(it), value); + return { c.keys.insert(it, std::move(key)), true }; + } else { + *toValuesIterator(it) = value; + return {it, false}; + } + } + + std::pair<iterator, bool> insert(const Key &key, T &&value) + { + auto it = lower_bound(key); + if (it == end() || key_compare::operator()(key, it.key())) { + c.values.insert(toValuesIterator(it), std::move(value)); + return { c.keys.insert(it, key), true }; + } else { + *toValuesIterator(it) = std::move(value); + return {it, false}; + } + } + + std::pair<iterator, bool> insert(Key &&key, T &&value) + { + auto it = lower_bound(key); + if (it == end() || key_compare::operator()(key, it.key())) { + c.values.insert(toValuesIterator(it), std::move(value)); + return { fromKeysIterator(c.keys.insert(toKeysIterator(it), std::move(key))), true }; + } else { + *toValuesIterator(it) = std::move(value); + return {it, false}; + } + } + + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + void insert(InputIt first, InputIt last) + { + insertRange(first, last); + } + + // ### Merge with the templated version above + // once we can use std::disjunction in is_compatible_iterator. + void insert(const value_type *first, const value_type *last) + { + insertRange(first, last); + } + + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + void insert(Qt::OrderedUniqueRange_t, InputIt first, InputIt last) + { + insertOrderedUniqueRange(first, last); + } + + // ### Merge with the templated version above + // once we can use std::disjunction in is_compatible_iterator. + void insert(Qt::OrderedUniqueRange_t, const value_type *first, const value_type *last) + { + insertOrderedUniqueRange(first, last); + } + + iterator begin() { return { &c, 0 }; } + const_iterator begin() const { return { &c, 0 }; } + const_iterator cbegin() const { return begin(); } + const_iterator constBegin() const { return cbegin(); } + iterator end() { return { &c, c.keys.size() }; } + const_iterator end() const { return { &c, c.keys.size() }; } + const_iterator cend() const { return end(); } + const_iterator constEnd() const { return cend(); } + std::reverse_iterator<iterator> rbegin() { return std::reverse_iterator<iterator>(end()); } + std::reverse_iterator<const_iterator> rbegin() const + { + return std::reverse_iterator<const_iterator>(end()); + } + std::reverse_iterator<const_iterator> crbegin() const { return rbegin(); } + std::reverse_iterator<iterator> rend() { + return std::reverse_iterator<iterator>(begin()); + } + std::reverse_iterator<const_iterator> rend() const + { + return std::reverse_iterator<const_iterator>(begin()); + } + std::reverse_iterator<const_iterator> crend() const { return rend(); } + + iterator lower_bound(const Key &key) + { + auto cit = const_cast<const full_map_t *>(this)->lower_bound(key); + return { &c, cit.i }; + } + + template <class X, class Y = Compare, is_marked_transparent<Y> = nullptr> + iterator lower_bound(const X &key) + { + auto cit = const_cast<const full_map_t *>(this)->lower_bound(key); + return { &c, cit.i }; + } + + const_iterator lower_bound(const Key &key) const + { + return fromKeysIterator(std::lower_bound(c.keys.begin(), c.keys.end(), key, key_comp())); + } + + template <class X, class Y = Compare, is_marked_transparent<Y> = nullptr> + const_iterator lower_bound(const X &key) const + { + return fromKeysIterator(std::lower_bound(c.keys.begin(), c.keys.end(), key, key_comp())); + } + + iterator find(const key_type &k) + { + return binary_find(k); + } + + const_iterator find(const key_type &k) const + { + return binary_find(k); + } + + key_compare key_comp() const noexcept + { + return static_cast<key_compare>(*this); + } + + value_compare value_comp() const noexcept + { + return static_cast<value_compare>(*this); + } + +private: + template <class InputIt, is_compatible_iterator<InputIt> = nullptr> + void initWithRange(InputIt first, InputIt last) + { + QtPrivate::reserveIfForwardIterator(this, first, last); + while (first != last) { + c.keys.push_back(first->first); + c.values.push_back(first->second); + ++first; + } + } + + iterator fromKeysIterator(typename key_container_type::iterator kit) + { + return { &c, static_cast<size_type>(std::distance(c.keys.begin(), kit)) }; + } + + const_iterator fromKeysIterator(typename key_container_type::const_iterator kit) const + { + return { &c, static_cast<size_type>(std::distance(c.keys.begin(), kit)) }; + } + + typename key_container_type::iterator toKeysIterator(iterator it) + { + return c.keys.begin() + it.i; + } + + typename mapped_container_type::iterator toValuesIterator(iterator it) + { + return c.values.begin() + it.i; + } + + template <class InputIt> + void insertRange(InputIt first, InputIt last) + { + size_type i = c.keys.size(); + c.keys.resize(i + std::distance(first, last)); + c.values.resize(c.keys.size()); + for (; first != last; ++first, ++i) { + c.keys[i] = first->first; + c.values[i] = first->second; + } + ensureOrderedUnique(); + } + + class IndexedKeyComparator + { + public: + IndexedKeyComparator(const full_map_t *am) + : m(am) + { + } + + bool operator()(size_type i, size_type k) const + { + return m->key_comp()(m->c.keys[i], m->c.keys[k]); + } + + private: + const full_map_t *m; + }; + + template <class InputIt> + void insertOrderedUniqueRange(InputIt first, InputIt last) + { + const size_type s = c.keys.size(); + c.keys.resize(s + std::distance(first, last)); + c.values.resize(c.keys.size()); + for (size_type i = s; first != last; ++first, ++i) { + c.keys[i] = first->first; + c.values[i] = first->second; + } + + std::vector<size_type> p(size_t(c.keys.size())); + std::iota(p.begin(), p.end(), 0); + std::inplace_merge(p.begin(), p.begin() + s, p.end(), IndexedKeyComparator(this)); + applyPermutation(p); + makeUnique(); + } + + iterator binary_find(const Key &key) + { + return { &c, const_cast<const full_map_t *>(this)->binary_find(key).i }; + } + + const_iterator binary_find(const Key &key) const + { + auto it = lower_bound(key); + if (it != end()) { + if (!key_compare::operator()(key, it.key())) + return it; + it = end(); + } + return it; + } + + void ensureOrderedUnique() + { + std::vector<size_type> p(size_t(c.keys.size())); + std::iota(p.begin(), p.end(), 0); + std::stable_sort(p.begin(), p.end(), IndexedKeyComparator(this)); + applyPermutation(p); + makeUnique(); + } + + void applyPermutation(const std::vector<size_type> &p) + { + const size_type s = c.keys.size(); + std::vector<bool> done(s); + for (size_type i = 0; i < s; ++i) { + if (done[i]) + continue; + done[i] = true; + size_type j = i; + size_type k = p[i]; + while (i != k) { + qSwap(c.keys[j], c.keys[k]); + qSwap(c.values[j], c.values[k]); + done[k] = true; + j = k; + k = p[j]; + } + } + } + + void makeUnique() + { + if (c.keys.size() < 2) + return; + auto k = std::end(c.keys) - 1; + auto i = k - 1; + for (;;) { + if (key_compare::operator()(*i, *k) || key_compare::operator()(*k, *i)) { + if (i == std::begin(c.keys)) + break; + --i; + --k; + } else { + c.values.erase(std::begin(c.values) + std::distance(std::begin(c.keys), i)); + i = c.keys.erase(i); + if (i == std::begin(c.keys)) + break; + k = i + 1; + } + } + c.keys.shrink_to_fit(); + c.values.shrink_to_fit(); + } + + containers c; +}; + +QT_END_NAMESPACE + +#endif // QFLATMAP_P_H diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index a1b243dd5f..230456bef9 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -12,6 +12,7 @@ HEADERS += \ tools/qcontainerfwd.h \ tools/qcontainertools_impl.h \ tools/qcryptographichash.h \ + tools/qflatmap_p.h \ tools/qfreelist_p.h \ tools/qhash.h \ tools/qhashfunctions.h \ -- cgit v1.2.3 From 045250ed4258932d7fbc13cdad163db1cd64dca7 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Date: Fri, 22 Nov 2019 14:26:12 +0100 Subject: Fix QPalette::isBrushSet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation did not take into account different color groups in resolve mask. It led to some issues when resolving a palette or checking whether a brush is set or not. Task-number: QTBUG-78544 Change-Id: I9b67b2c444eb62c022643022a874dc400005e6ee Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/kernel/qpalette.cpp | 97 ++++++++++++++++++++++++--------- src/gui/kernel/qpalette.h | 24 ++++---- src/widgets/kernel/qwidget.cpp | 4 +- src/widgets/kernel/qwidget_p.h | 4 +- src/widgets/styles/qstylesheetstyle_p.h | 2 +- 5 files changed, 87 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index fdcdef4345..44efad5910 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -48,6 +48,22 @@ QT_BEGIN_NAMESPACE static int qt_palette_count = 1; +static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup) +{ + return QPalette::NColorRoles * colorGroup; +} + +static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, + QPalette::ColorRole colorRole) +{ + return colorRole + colorRoleOffset(colorGroup); +} + +Q_STATIC_ASSERT_X(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1), + QPalette::ColorRole(QPalette::NColorRoles - 1)) + < sizeof(QPalette::ResolveMask) * CHAR_BIT, + "The resolve mask type is not wide enough to fit the entire bit mask."); + class QPalettePrivate { public: QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { } @@ -535,8 +551,6 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button) QPalette::QPalette() : d(nullptr) { - data.current_group = Active; - data.resolve_mask = 0; // Initialize to application palette if present, else default to black. // This makes it possible to instantiate QPalette outside QGuiApplication, // for example in the platform plugins. @@ -546,7 +560,7 @@ QPalette::QPalette() } else { init(); qt_palette_from_color(*this, Qt::black); - data.resolve_mask = 0; + data.resolveMask = 0; } } @@ -678,8 +692,6 @@ QPalette::~QPalette() /*!\internal*/ void QPalette::init() { d = new QPalettePrivate; - data.resolve_mask = 0; - data.current_group = Active; //as a default.. } /*! @@ -736,7 +748,7 @@ const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const Q_ASSERT(cr < NColorRoles); if(gr >= (int)NColorGroups) { if(gr == Current) { - gr = (ColorGroup)data.current_group; + gr = data.currentGroup; } else { qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr); gr = Active; @@ -774,7 +786,7 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) } if (cg == Current) { - cg = ColorGroup(data.current_group); + cg = data.currentGroup; } else if (cg >= NColorGroups) { qWarning("QPalette::setBrush: Unknown ColorGroup: %d", cg); cg = Active; @@ -784,7 +796,8 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) detach(); d->br[cg][cr] = b; } - data.resolve_mask |= (1<<cr); + + data.resolveMask |= ResolveMask(1) << bitPosition(cg, cr); } /*! @@ -793,12 +806,30 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) Returns \c true if the ColorGroup \a cg and ColorRole \a cr has been set previously on this palette; otherwise returns \c false. - \sa setBrush() + The ColorGroup \a cg should be less than QPalette::NColorGroups, + but you can use QPalette::Current. In this case, the previously + set current color group will be used. + + The ColorRole \a cr should be less than QPalette::NColorRoles. + + \sa setBrush(), currentColorGroup() */ bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const { - Q_UNUSED(cg); - return (data.resolve_mask & (1<<cr)); + if (cg == Current) + cg = data.currentGroup; + + if (cg >= NColorGroups) { + qWarning() << "Wrong color group:" << cg; + return false; + } + + if (cr >= NColorRoles) { + qWarning() << "Wrong color role:" << cr; + return false; + } + + return data.resolveMask & (ResolveMask(1) << bitPosition(cg, cr)); } /*! @@ -863,7 +894,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) { if(group1 >= (int)NColorGroups) { if(group1 == Current) { - group1 = (ColorGroup)data.current_group; + group1 = data.currentGroup; } else { qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1); group1 = Active; @@ -871,7 +902,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) } if(group2 >= (int)NColorGroups) { if(group2 == Current) { - group2 = (ColorGroup)data.current_group; + group2 = data.currentGroup; } else { qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2); group2 = Active; @@ -922,21 +953,25 @@ qint64 QPalette::cacheKey() const */ QPalette QPalette::resolve(const QPalette &other) const { - if ((*this == other && data.resolve_mask == other.data.resolve_mask) - || data.resolve_mask == 0) { + if ((*this == other && data.resolveMask == other.data.resolveMask) + || data.resolveMask == 0) { QPalette o = other; - o.data.resolve_mask = data.resolve_mask; + o.data.resolveMask = data.resolveMask; return o; } QPalette palette(*this); palette.detach(); - for(int role = 0; role < (int)NColorRoles; role++) - if (!(data.resolve_mask & (1<<role))) - for(int grp = 0; grp < (int)NColorGroups; grp++) + for (int role = 0; role < int(NColorRoles); ++role) { + for (int grp = 0; grp < int(NColorGroups); ++grp) { + if (!(data.resolveMask & (ResolveMask(1) << bitPosition(ColorGroup(grp), ColorRole(role))))) { palette.d->br[grp][role] = other.d->br[grp][role]; - palette.data.resolve_mask |= other.data.resolve_mask; + } + } + } + + palette.data.resolveMask |= other.data.resolveMask; return palette; } @@ -947,7 +982,12 @@ QPalette QPalette::resolve(const QPalette &other) const */ /*! - \fn void QPalette::resolve(uint mask) + \typedef ResolveMaskType + \internal + */ + +/*! + \fn void QPalette::resolve(ResolveMaskType mask) \internal */ @@ -1081,10 +1121,15 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBru QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase), QBrush(toolTipText)); - data.resolve_mask &= ~(1 << Highlight); - data.resolve_mask &= ~(1 << HighlightedText); - data.resolve_mask &= ~(1 << LinkVisited); - data.resolve_mask &= ~(1 << Link); + for (int cr = Highlight; cr <= LinkVisited; ++cr) { + if (cg == All) { + for (int group = Active; group < NColorGroups; ++group) { + data.resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(group), ColorRole(cr))); + } + } else { + data.resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(cg), ColorRole(cr))); + } + } } @@ -1189,7 +1234,7 @@ QDebug operator<<(QDebug dbg, const QPalette &p) "ToolTipBase","ToolTipText", "PlaceholderText" }; QDebugStateSaver saver(dbg); QDebug nospace = dbg.nospace(); - const uint mask = p.resolve(); + auto mask = p.resolve(); nospace << "QPalette(resolve=" << Qt::hex << Qt::showbase << mask << ','; for (int role = 0; role < (int)QPalette::NColorRoles; ++role) { if (mask & (1<<role)) { diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index d3a840d9ad..c95640d383 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -72,14 +72,12 @@ public: { other.d = nullptr; } inline QPalette &operator=(QPalette &&other) noexcept { - for_faster_swapping_dont_use = other.for_faster_swapping_dont_use; qSwap(d, other.d); return *this; } void swap(QPalette &other) noexcept { qSwap(d, other.d); - qSwap(for_faster_swapping_dont_use, other.for_faster_swapping_dont_use); } operator QVariant() const; @@ -103,8 +101,8 @@ public: }; Q_ENUM(ColorRole) - inline ColorGroup currentColorGroup() const { return static_cast<ColorGroup>(data.current_group); } - inline void setCurrentColorGroup(ColorGroup cg) { data.current_group = cg; } + inline ColorGroup currentColorGroup() const { return data.currentGroup; } + inline void setCurrentColorGroup(ColorGroup cg) { data.currentGroup = cg; } inline const QColor &color(ColorGroup cg, ColorRole cr) const { return brush(cg, cr).color(); } @@ -158,9 +156,11 @@ public: #endif qint64 cacheKey() const; - QPalette resolve(const QPalette &) const; - inline uint resolve() const { return data.resolve_mask; } - inline void resolve(uint mask) { data.resolve_mask = mask; } + QPalette resolve(const QPalette &other) const; + + using ResolveMask = quint64; + inline ResolveMask resolve() const { return data.resolveMask; } + inline void resolve(ResolveMask mask) { data.resolveMask = mask; } private: void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button, @@ -185,13 +185,11 @@ private: QPalettePrivate *d; struct Data { - uint current_group : 4; - uint resolve_mask : 28; - }; - union { - Data data; - quint32 for_faster_swapping_dont_use; + ResolveMask resolveMask{0}; + ColorGroup currentGroup{Active}; }; + Data data; + friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p); }; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index ecea94c66a..2160e54b8f 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1850,7 +1850,7 @@ void QWidgetPrivate::propagatePaletteChange() if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { inheritedPaletteResolveMask = 0; } - int mask = data.pal.resolve() | inheritedPaletteResolveMask; + QPalette::ResolveMask mask = data.pal.resolve() | inheritedPaletteResolveMask; const bool useStyleSheetPropagationInWidgetStyles = QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); @@ -4374,7 +4374,7 @@ void QWidget::setPalette(const QPalette &palette) widget's palette are implicitly imposed on this widget by the user). Note that this font does not take into account the palette set on \a w itself. */ -QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const +QPalette QWidgetPrivate::naturalWidgetPalette(QPalette::ResolveMask inheritedMask) const { Q_Q(const QWidget); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 6915782cb3..0d0077548c 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -299,7 +299,7 @@ public: void setPalette_helper(const QPalette &); void resolvePalette(); - QPalette naturalWidgetPalette(uint inheritedMask) const; + QPalette naturalWidgetPalette(QPalette::ResolveMask inheritedMask) const; void setMask_sys(const QRegion &); @@ -672,7 +672,7 @@ public: // Other variables. uint directFontResolveMask; uint inheritedFontResolveMask; - uint inheritedPaletteResolveMask; + QPalette::ResolveMask inheritedPaletteResolveMask; short leftmargin; short topmargin; short rightmargin; diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index c5266558af..81c532bf6a 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -194,7 +194,7 @@ public: template <typename T> struct Tampered { T oldWidgetValue; - uint resolveMask; + decltype(std::declval<T>().resolve()) resolveMask; // only call this function on an rvalue *this (it mangles oldWidgetValue) T reverted(T current) -- cgit v1.2.3 From 240a8514f84e9be116acb34991b12a7aa2279914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Thu, 2 Jan 2020 13:58:49 +0100 Subject: Fix syncqt warning in qtestsupport_widgets.h Change-Id: I4f350e3c209dc9a39e849c9c39c41da700abeb60 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qtestsupport_widgets.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qtestsupport_widgets.h b/src/widgets/kernel/qtestsupport_widgets.h index ca1406b0b2..2b37a9e858 100644 --- a/src/widgets/kernel/qtestsupport_widgets.h +++ b/src/widgets/kernel/qtestsupport_widgets.h @@ -40,7 +40,7 @@ #ifndef QTESTSUPPORT_WIDGETS_H #define QTESTSUPPORT_WIDGETS_H -#include "qtwidgetsglobal.h" +#include <QtWidgets/qtwidgetsglobal.h> QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 2ced01cbdd10a9959db03406f74529cdcce544ca Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Fri, 4 Dec 2015 12:44:45 +0100 Subject: QIdentityProxyModel: implement moveRows / moveColumns It makes sense for it (instead of triggering the QAbstractItemModel base class implementation, which doesn't do anything). Safe to override virtuals in this case -- code calling the old version could not do anything useful, so at least new code gets those functions properly implemented for free. Change-Id: Iefe1ff25e15d877435e93ab28289ad2579616f72 Task-number: QTBUG-48076 Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: David Faure <david.faure@kdab.com> --- src/corelib/itemmodels/qidentityproxymodel.cpp | 24 ++++++++++++++++++++++++ src/corelib/itemmodels/qidentityproxymodel.h | 2 ++ 2 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index 39992eccd3..f5684c6eda 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -311,6 +311,30 @@ bool QIdentityProxyModel::removeRows(int row, int count, const QModelIndex& pare return d->model->removeRows(row, count, mapToSource(parent)); } +/*! + \reimp + \since 5.15 + */ +bool QIdentityProxyModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) +{ + Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == this : true); + Q_ASSERT(destinationParent.isValid() ? destinationParent.model() == this : true); + Q_D(QIdentityProxyModel); + return d->model->moveRows(mapToSource(sourceParent), sourceRow, count, mapToSource(destinationParent), destinationChild); +} + +/*! + \reimp + \since 5.15 + */ +bool QIdentityProxyModel::moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) +{ + Q_ASSERT(sourceParent.isValid() ? sourceParent.model() == this : true); + Q_ASSERT(destinationParent.isValid() ? destinationParent.model() == this : true); + Q_D(QIdentityProxyModel); + return d->model->moveColumns(mapToSource(sourceParent), sourceColumn, count, mapToSource(destinationParent), destinationChild); +} + /*! \reimp */ diff --git a/src/corelib/itemmodels/qidentityproxymodel.h b/src/corelib/itemmodels/qidentityproxymodel.h index 89ac89cdba..4c14e6176a 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.h +++ b/src/corelib/itemmodels/qidentityproxymodel.h @@ -77,6 +77,8 @@ public: bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override; bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; + bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override; + bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override; protected: QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent); -- cgit v1.2.3 From 105e662221cc90d5002e06c97febf50c5c601336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Thu, 2 Jan 2020 13:21:58 +0100 Subject: macOS: Handle missing color space information in IOSurface backingstore Fixes: QTBUG-80972 Change-Id: Iab3f1a9cf03251340e5f32bcc73103428e93282d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm index 285e316d4a..fc187e0f51 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm @@ -89,9 +89,16 @@ QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer() void QIOSurfaceGraphicsBuffer::setColorSpace(QCFType<CGColorSpaceRef> colorSpace) { - Q_ASSERT(colorSpace); - IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), - QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace))); + static const auto kIOSurfaceColorSpace = CFSTR("IOSurfaceColorSpace"); + + qCDebug(lcQpaIOSurface) << "Tagging" << this << "with color space" << colorSpace; + + if (colorSpace) { + IOSurfaceSetValue(m_surface, kIOSurfaceColorSpace, + QCFType<CFPropertyListRef>(CGColorSpaceCopyPropertyList(colorSpace))); + } else { + IOSurfaceRemoveValue(m_surface, kIOSurfaceColorSpace); + } } const uchar *QIOSurfaceGraphicsBuffer::data() const -- cgit v1.2.3 From 947704cefe9e8723c8c9bb332268dcedb1ea1060 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Thu, 2 Jan 2020 08:34:38 +0100 Subject: Freetype: Don't embolden bold fonts If a font does not set the "bold" flag in its OS/2 table, we check the weight from the same table to determine whether it is bold or if we have to embolden it synthetically. But the actual definition of bold in OS/2 is 700 (which is also what QFont::Bold is documented to correspond to in qfont.h). The result was that we would embolden fonts with bold weight if the bold flag was not set. An example of such a font was the CJK JP family of Noto Sans. [ChangeLog][Text] Fixed a problem where certain bold fonts would be synthetically emboldened by Qt when using the Freetype font engine. Fixes: QTBUG-80866 Change-Id: I2133d9c44a9e19c0f5f216a649ec64388245d34f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp index 3e5939a5e4..64ceb69c23 100644 --- a/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp +++ b/src/platformsupport/fontdatabases/freetype/qfontengine_ft.cpp @@ -749,7 +749,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, // fake bold if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) { if (const TT_OS2 *os2 = reinterpret_cast<const TT_OS2 *>(FT_Get_Sfnt_Table(face, ft_sfnt_os2))) { - if (os2->usWeightClass < 750) + if (os2->usWeightClass < 700) embolden = true; } } -- cgit v1.2.3 From 4d8ee1b3493b79a6f1cd5200e6102711c0102c9e Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Date: Fri, 22 Nov 2019 15:23:51 +0100 Subject: QPalette: fix debug stream operator Current implementation takes both color group and color role into account. Code readability is also improved. Fixes: QTBUG-78544 Change-Id: Ibfa925f3e4cb0be89915607eee142926e05000b5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/gui/kernel/qpalette.cpp | 76 +++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 44efad5910..e31ce00e14 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -44,6 +44,8 @@ #include "qvariant.h" #include "qdebug.h" +#include <QtCore/qmetaobject.h> + QT_BEGIN_NAMESPACE static int qt_palette_count = 1; @@ -1224,36 +1226,58 @@ Q_GUI_EXPORT QPalette qt_fusionPalette() } #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QPalette &p) +static QString groupsToString(const QPalette &p, QPalette::ColorRole cr) { - const char *colorGroupNames[] = {"Active", "Disabled", "Inactive"}; - const char *colorRoleNames[] = - {"WindowText", "Button", "Light", "Midlight", "Dark", "Mid", "Text", - "BrightText", "ButtonText", "Base", "Window", "Shadow", "Highlight", - "HighlightedText", "Link", "LinkVisited", "AlternateBase", "NoRole", - "ToolTipBase","ToolTipText", "PlaceholderText" }; - QDebugStateSaver saver(dbg); - QDebug nospace = dbg.nospace(); - auto mask = p.resolve(); - nospace << "QPalette(resolve=" << Qt::hex << Qt::showbase << mask << ','; - for (int role = 0; role < (int)QPalette::NColorRoles; ++role) { - if (mask & (1<<role)) { - if (role) - nospace << ','; - nospace << colorRoleNames[role] << ":["; - for (int group = 0; group < (int)QPalette::NColorGroups; ++group) { - if (group) - nospace << ','; - const QRgb color = p.color(static_cast<QPalette::ColorGroup>(group), - static_cast<QPalette::ColorRole>(role)).rgba(); - nospace << colorGroupNames[group] << ':' << color; - } - nospace << ']'; + const auto groupEnum = QMetaEnum::fromType<QPalette::ColorGroup>(); + + QString groupString; + for (int group = 0; group < QPalette::NColorGroups; ++group) { + const auto cg = QPalette::ColorGroup(group); + + if (p.isBrushSet(cg, cr)) { + const auto &color = p.color(cg, cr); + groupString += QString::fromUtf8(groupEnum.valueToKey(cg)) + QLatin1Char(':') + + color.name(QColor::HexArgb) + QLatin1Char(','); } } - nospace << ')' << Qt::noshowbase << Qt::dec; - return dbg; + groupString.chop(1); + + return groupString; +} + +static QString rolesToString(const QPalette &p) +{ + const auto roleEnum = QMetaEnum::fromType<QPalette::ColorRole>(); + + QString roleString; + for (int role = 0; role < QPalette::NColorRoles; ++role) { + const auto cr = QPalette::ColorRole(role); + + auto groupString = groupsToString(p, cr); + if (!groupString.isEmpty()) + roleString += QString::fromUtf8(roleEnum.valueToKey(cr)) + QStringLiteral(":[") + + groupString + QStringLiteral("],"); + } + roleString.chop(1); + + return roleString; } + +QDebug operator<<(QDebug dbg, const QPalette &p) +{ + QDebugStateSaver saver(dbg); + dbg.nospace(); + + dbg << "QPalette(resolve=" << Qt::hex << Qt::showbase << p.resolve(); + + auto roleString = rolesToString(p); + if (!roleString.isEmpty()) + dbg << ',' << roleString; + + dbg << ')'; + + return dbg; + } #endif QT_END_NAMESPACE -- cgit v1.2.3 From dcef0b96eef04c4e17c2e51ea71aea1f78625864 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Thu, 19 Dec 2019 21:59:09 +0100 Subject: Fix CVE-2019-19242 in SQLite Task-number: QTBUG-80903 Change-Id: I78a72a574da5cf3503950afe47146ae6424f00c6 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- .../0002-Fix-CVE-2019-19242-in-SQLite.patch | 31 ++++++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 7 ++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch (limited to 'src') diff --git a/src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch b/src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch new file mode 100644 index 0000000000..92739192e4 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0002-Fix-CVE-2019-19242-in-SQLite.patch @@ -0,0 +1,31 @@ +From 7905740b8e79479298e83d8e559fc49b46cf980e Mon Sep 17 00:00:00 2001 +From: Andy Shaw <andy.shaw@qt.io> +Date: Thu, 19 Dec 2019 21:59:09 +0100 +Subject: [PATCH] Fix CVE-2019-19242 in SQLite + +Change-Id: I78a72a574da5cf3503950afe47146ae6424f00c6 +--- + src/3rdparty/sqlite/sqlite3.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index bd647ca1c2..d3e0c065b6 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -101055,7 +101055,12 @@ expr_code_doover: + ** constant. + */ + int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); +- int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); ++ int aff; ++ if( pExpr->y.pTab ){ ++ aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); ++ }else{ ++ aff = pExpr->affExpr; ++ } + if( aff>SQLITE_AFF_BLOB ){ + static const char zAff[] = "B\000C\000D\000E"; + assert( SQLITE_AFF_BLOB=='A' ); +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index bd647ca1c2..d3e0c065b6 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -101055,7 +101055,12 @@ expr_code_doover: ** constant. */ int iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); - int aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); + int aff; + if( pExpr->y.pTab ){ + aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); + }else{ + aff = pExpr->affExpr; + } if( aff>SQLITE_AFF_BLOB ){ static const char zAff[] = "B\000C\000D\000E"; assert( SQLITE_AFF_BLOB=='A' ); -- cgit v1.2.3 From a75d238b3194ae4973be7f6ce0508a526d4aa49e Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Thu, 19 Dec 2019 22:31:15 +0100 Subject: Fix CVE-2019-19603 in SQLite This includes the patch needed to fix this CVE and a supporting one to include a new function added that it depends on. Task-number: QTBUG-80903 Change-Id: Ic7639d50c89a3ee7d45426588c3ab0efd0eebb72 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- .../0003-Fix-CVE-2019-19603-in-SQLite.patch | 95 ++++++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 32 ++++++-- 2 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch (limited to 'src') diff --git a/src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch b/src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch new file mode 100644 index 0000000000..1b8deaa4a1 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0003-Fix-CVE-2019-19603-in-SQLite.patch @@ -0,0 +1,95 @@ +From 11a2f4647b67494fb731a6fd793f1b28074631d3 Mon Sep 17 00:00:00 2001 +From: Andy Shaw <andy.shaw@qt.io> +Date: Thu, 19 Dec 2019 22:31:15 +0100 +Subject: [PATCH] Fix CVE-2019-19603 in SQLite + +This includes the patch needed to fix this CVE and a supporting one to +include a new function added that it depends on. + +Task-number: QTBUG-80903 +Change-Id: Ic7639d50c89a3ee7d45426588c3ab0efd0eebb72 +--- + src/3rdparty/sqlite/sqlite3.c | 32 ++++++++++++++++++++++++++------ + 1 file changed, 26 insertions(+), 6 deletions(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index d3e0c065b6..a430554db7 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -19519,6 +19519,12 @@ SQLITE_PRIVATE Module *sqlite3VtabCreateModule( + ); + # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) + #endif ++SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); ++#else ++# define sqlite3ShadowTableName(A,B) 0 ++#endif + SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); + SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); + SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); +@@ -108483,6 +108489,22 @@ SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){ + return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema; + } + ++/* ++ ** Return TRUE if shadow tables should be read-only in the current ++ ** context. ++ */ ++int sqlite3ReadOnlyShadowTables(sqlite3 *db){ ++#ifndef SQLITE_OMIT_VIRTUALTABLE ++ if( (db->flags & SQLITE_Defensive)!=0 ++ && db->pVtabCtx==0 ++ && db->nVdbeExec==0 ++ ){ ++ return 1; ++ } ++#endif ++ return 0; ++} ++ + /* + ** This routine is used to check if the UTF-8 string zName is a legal + ** unqualified name for a new schema object (table, index, view or +@@ -108516,8 +108538,8 @@ SQLITE_PRIVATE int sqlite3CheckObjectName( + } + } + }else{ +- if( pParse->nested==0 +- && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ++ if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)) ++ || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName)) + ){ + sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", + zName); +@@ -109662,7 +109684,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ + ** zName is temporarily modified while this routine is running, but is + ** restored to its original value prior to this routine returning. + */ +-static int isShadowTableName(sqlite3 *db, char *zName){ ++int sqlite3ShadowTableName(sqlite3 *db, const char *zName){ + char *zTail; /* Pointer to the last "_" in zName */ + Table *pTab; /* Table that zName is a shadow of */ + Module *pMod; /* Module for the virtual table */ +@@ -109680,8 +109702,6 @@ static int isShadowTableName(sqlite3 *db, char *zName){ + if( pMod->pModule->xShadowName==0 ) return 0; + return pMod->pModule->xShadowName(zTail+1); + } +-#else +-# define isShadowTableName(x,y) 0 + #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ + + /* +@@ -109723,7 +109743,7 @@ SQLITE_PRIVATE void sqlite3EndTable( + p = pParse->pNewTable; + if( p==0 ) return; + +- if( pSelect==0 && isShadowTableName(db, p->zName) ){ ++ if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){ + p->tabFlags |= TF_Shadow; + } + +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index d3e0c065b6..a430554db7 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -19519,6 +19519,12 @@ SQLITE_PRIVATE Module *sqlite3VtabCreateModule( ); # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) #endif +SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); +#ifndef SQLITE_OMIT_VIRTUALTABLE +SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); +#else +# define sqlite3ShadowTableName(A,B) 0 +#endif SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); @@ -108483,6 +108489,22 @@ SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3 *db){ return (db->flags&(SQLITE_WriteSchema|SQLITE_Defensive))==SQLITE_WriteSchema; } +/* + ** Return TRUE if shadow tables should be read-only in the current + ** context. + */ +int sqlite3ReadOnlyShadowTables(sqlite3 *db){ +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( (db->flags & SQLITE_Defensive)!=0 + && db->pVtabCtx==0 + && db->nVdbeExec==0 + ){ + return 1; + } +#endif + return 0; +} + /* ** This routine is used to check if the UTF-8 string zName is a legal ** unqualified name for a new schema object (table, index, view or @@ -108516,8 +108538,8 @@ SQLITE_PRIVATE int sqlite3CheckObjectName( } } }else{ - if( pParse->nested==0 - && 0==sqlite3StrNICmp(zName, "sqlite_", 7) + if( (pParse->nested==0 && 0==sqlite3StrNICmp(zName, "sqlite_", 7)) + || (sqlite3ReadOnlyShadowTables(db) && sqlite3ShadowTableName(db, zName)) ){ sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName); @@ -109662,7 +109684,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ ** zName is temporarily modified while this routine is running, but is ** restored to its original value prior to this routine returning. */ -static int isShadowTableName(sqlite3 *db, char *zName){ +int sqlite3ShadowTableName(sqlite3 *db, const char *zName){ char *zTail; /* Pointer to the last "_" in zName */ Table *pTab; /* Table that zName is a shadow of */ Module *pMod; /* Module for the virtual table */ @@ -109680,8 +109702,6 @@ static int isShadowTableName(sqlite3 *db, char *zName){ if( pMod->pModule->xShadowName==0 ) return 0; return pMod->pModule->xShadowName(zTail+1); } -#else -# define isShadowTableName(x,y) 0 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ /* @@ -109723,7 +109743,7 @@ SQLITE_PRIVATE void sqlite3EndTable( p = pParse->pNewTable; if( p==0 ) return; - if( pSelect==0 && isShadowTableName(db, p->zName) ){ + if( pSelect==0 && sqlite3ShadowTableName(db, p->zName) ){ p->tabFlags |= TF_Shadow; } -- cgit v1.2.3 From 3b697f496303bd005ae9d1d2c974efeed259d8a3 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Thu, 2 Jan 2020 09:07:08 +0100 Subject: Fix CVE-2019-19646 in SQLite Task-number: QTBUG-81020 Change-Id: I7176db20d4a44b1fb443a6108675f719e9643343 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- .../0004-Fix-CVE-2019-19646-in-SQLite.patch | 29 ++++++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 4 ++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch (limited to 'src') diff --git a/src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch b/src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch new file mode 100644 index 0000000000..db436ab4f6 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0004-Fix-CVE-2019-19646-in-SQLite.patch @@ -0,0 +1,29 @@ +From a83bbce4d6f31d93ea4d2a681aa52c148f148e26 Mon Sep 17 00:00:00 2001 +From: Andy Shaw <andy.shaw@qt.io> +Date: Thu, 2 Jan 2020 09:07:08 +0100 +Subject: [PATCH] Fix CVE-2019-19646 in SQLite + +Task-number: QTBUG-81020 +Change-Id: I7176db20d4a44b1fb443a6108675f719e9643343 +--- + src/3rdparty/sqlite/sqlite3.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index 57e61b8313..980a149b1a 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -123765,7 +123765,9 @@ SQLITE_PRIVATE void sqlite3Pragma( + if( j==pTab->iPKey ) continue; + if( pTab->aCol[j].notNull==0 ) continue; + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); +- sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); ++ if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ ++ sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); ++ } + jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); + zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, + pTab->aCol[j].zName); +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index a430554db7..712a103ef6 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -123776,7 +123776,9 @@ SQLITE_PRIVATE void sqlite3Pragma( if( j==pTab->iPKey ) continue; if( pTab->aCol[j].notNull==0 ) continue; sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); - sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); + if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ + sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); + } jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, pTab->aCol[j].zName); -- cgit v1.2.3 From 1e89c132e1280276e1d3a82ec3464afec8c14c3a Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Thu, 2 Jan 2020 08:47:23 +0100 Subject: Fix CVE-2019-19645 in SQLite Task-number: QTBUG-81020 Change-Id: I58b1dd9e7a90ba998c3af7f25a4627d8bdd70970 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> --- .../0005-Fix-CVE-2019-19645-in-SQLite.patch | 83 ++++++++++++++++++++++ src/3rdparty/sqlite/sqlite3.c | 11 ++- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch (limited to 'src') diff --git a/src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch b/src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch new file mode 100644 index 0000000000..e92c566881 --- /dev/null +++ b/src/3rdparty/sqlite/patches/0005-Fix-CVE-2019-19645-in-SQLite.patch @@ -0,0 +1,83 @@ +From 78c972eec5bab03a408b8ba1373572bcfe2db630 Mon Sep 17 00:00:00 2001 +From: Andy Shaw <andy.shaw@qt.io> +Date: Thu, 2 Jan 2020 08:47:23 +0100 +Subject: [PATCH] Fix CVE-2019-19645 in SQLite + +Task-number: QTBUG-81020 +Change-Id: I58b1dd9e7a90ba998c3af7f25a4627d8bdd70970 +--- + src/3rdparty/sqlite/sqlite3.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c +index d3e0c065b6..57e61b8313 100644 +--- a/src/3rdparty/sqlite/sqlite3.c ++++ b/src/3rdparty/sqlite/sqlite3.c +@@ -17946,6 +17946,7 @@ struct Select { + #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */ + #define SF_ComplexResult 0x40000 /* Result contains subquery or function */ + #define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */ ++#define SF_View 0x0200000 /* SELECT statement is a view */ + + /* + ** The results of a SELECT can be distributed in several ways, as defined +@@ -103920,6 +103921,7 @@ static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ + static int renameUnmapSelectCb(Walker *pWalker, Select *p){ + Parse *pParse = pWalker->pParse; + int i; ++ if( p->selFlags & SF_View ) return WRC_Prune; + if( ALWAYS(p->pEList) ){ + ExprList *pList = p->pEList; + for(i=0; i<pList->nExpr; i++){ +@@ -104024,6 +104026,7 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ + ** descend into sub-select statements. + */ + static int renameColumnSelectCb(Walker *pWalker, Select *p){ ++ if( p->selFlags & SF_View ) return WRC_Prune; + renameWalkWith(pWalker, p); + return WRC_Continue; + } +@@ -104489,8 +104492,9 @@ static void renameColumnFunc( + if( sParse.pNewTable ){ + Select *pSelect = sParse.pNewTable->pSelect; + if( pSelect ){ ++ pSelect->selFlags &= ~SF_View; + sParse.rc = SQLITE_OK; +- sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); ++ sqlite3SelectPrep(&sParse, pSelect, 0); + rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); + if( rc==SQLITE_OK ){ + sqlite3WalkSelect(&sWalker, pSelect); +@@ -104602,6 +104606,7 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ + int i; + RenameCtx *p = pWalker->u.pRename; + SrcList *pSrc = pSelect->pSrc; ++ if( pSelect->selFlags & SF_View ) return WRC_Prune; + if( pSrc==0 ){ + assert( pWalker->pParse->db->mallocFailed ); + return WRC_Abort; +@@ -104681,10 +104686,13 @@ static void renameTableFunc( + + if( pTab->pSelect ){ + if( isLegacy==0 ){ ++ Select *pSelect = pTab->pSelect; + NameContext sNC; + memset(&sNC, 0, sizeof(sNC)); + sNC.pParse = &sParse; + ++ assert( pSelect->selFlags & SF_View ); ++ pSelect->selFlags &= ~SF_View; + sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); + if( sParse.nErr ) rc = sParse.rc; + sqlite3WalkSelect(&sWalker, pTab->pSelect); +@@ -109994,6 +110002,7 @@ SQLITE_PRIVATE void sqlite3CreateView( + ** allocated rather than point to the input string - which means that + ** they will persist after the current sqlite3_exec() call returns. + */ ++ pSelect->selFlags |= SF_View; + if( IN_RENAME_OBJECT ){ + p->pSelect = pSelect; + pSelect = 0; +-- +2.21.0 (Apple Git-122.2) + diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c index 712a103ef6..d5b43857ad 100644 --- a/src/3rdparty/sqlite/sqlite3.c +++ b/src/3rdparty/sqlite/sqlite3.c @@ -17946,6 +17946,7 @@ struct Select { #define SF_IncludeHidden 0x20000 /* Include hidden columns in output */ #define SF_ComplexResult 0x40000 /* Result contains subquery or function */ #define SF_WhereBegin 0x80000 /* Really a WhereBegin() call. Debug Only */ +#define SF_View 0x0200000 /* SELECT statement is a view */ /* ** The results of a SELECT can be distributed in several ways, as defined @@ -103926,6 +103927,7 @@ static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ Parse *pParse = pWalker->pParse; int i; + if( p->selFlags & SF_View ) return WRC_Prune; if( ALWAYS(p->pEList) ){ ExprList *pList = p->pEList; for(i=0; i<pList->nExpr; i++){ @@ -104030,6 +104032,7 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ ** descend into sub-select statements. */ static int renameColumnSelectCb(Walker *pWalker, Select *p){ + if( p->selFlags & SF_View ) return WRC_Prune; renameWalkWith(pWalker, p); return WRC_Continue; } @@ -104495,8 +104498,9 @@ static void renameColumnFunc( if( sParse.pNewTable ){ Select *pSelect = sParse.pNewTable->pSelect; if( pSelect ){ + pSelect->selFlags &= ~SF_View; sParse.rc = SQLITE_OK; - sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, 0); + sqlite3SelectPrep(&sParse, pSelect, 0); rc = (db->mallocFailed ? SQLITE_NOMEM : sParse.rc); if( rc==SQLITE_OK ){ sqlite3WalkSelect(&sWalker, pSelect); @@ -104608,6 +104612,7 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ int i; RenameCtx *p = pWalker->u.pRename; SrcList *pSrc = pSelect->pSrc; + if( pSelect->selFlags & SF_View ) return WRC_Prune; if( pSrc==0 ){ assert( pWalker->pParse->db->mallocFailed ); return WRC_Abort; @@ -104687,10 +104692,13 @@ static void renameTableFunc( if( pTab->pSelect ){ if( isLegacy==0 ){ + Select *pSelect = pTab->pSelect; NameContext sNC; memset(&sNC, 0, sizeof(sNC)); sNC.pParse = &sParse; + assert( pSelect->selFlags & SF_View ); + pSelect->selFlags &= ~SF_View; sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); if( sParse.nErr ) rc = sParse.rc; sqlite3WalkSelect(&sWalker, pTab->pSelect); @@ -110014,6 +110022,7 @@ SQLITE_PRIVATE void sqlite3CreateView( ** allocated rather than point to the input string - which means that ** they will persist after the current sqlite3_exec() call returns. */ + pSelect->selFlags |= SF_View; if( IN_RENAME_OBJECT ){ p->pSelect = pSelect; pSelect = 0; -- cgit v1.2.3 From 8669b8e60fc6a46baaeeea264a1ed3008dd52ea2 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale <fabian.kosmale@qt.io> Date: Wed, 11 Dec 2019 10:54:57 +0100 Subject: QVariant: Prefer direct conversion to QVariant{List,Map,Hash} If a type has both a converter to QVariantList and to QSequentialIterableImpl registered, we would have chosen the QSequentialIterableImpl version. In the case of types like QJSValue, this is more costly. With this change we therefore uses the direct conversion if it has been registered. The same applies to QAssociativeIterableImpl and QVariantHash/QVariantMap. Change-Id: I9c0b5068efe4bfbc5e0598a200e6db59201e9974 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> --- src/corelib/kernel/qvariant.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index a4957472ec..c95882d48f 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -801,7 +801,8 @@ namespace QtPrivate { static QVariantList invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId<QStringList>() || typeId == qMetaTypeId<QByteArrayList>() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) { + if (typeId == qMetaTypeId<QStringList>() || typeId == qMetaTypeId<QByteArrayList>() || + (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>()) && !QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QVariantList>()))) { QSequentialIterable iter = QVariantValueHelperInterface<QSequentialIterable>::invoke(v); QVariantList l; l.reserve(iter.size()); @@ -818,7 +819,7 @@ namespace QtPrivate { static QVariantHash invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId<QVariantMap>() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) { + if (typeId == qMetaTypeId<QVariantMap>() || ((QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) && !QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QVariantHash>()))) { QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v); QVariantHash l; l.reserve(iter.size()); @@ -835,7 +836,7 @@ namespace QtPrivate { static QVariantMap invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId<QVariantHash>() || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) { + if (typeId == qMetaTypeId<QVariantHash>() || (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>()) && !QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QVariantMap>()))) { QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) @@ -851,10 +852,8 @@ namespace QtPrivate { static QPair<QVariant, QVariant> invoke(const QVariant &v) { const int typeId = v.userType(); - if (typeId == qMetaTypeId<QPair<QVariant, QVariant> >()) - return QVariantValueHelper<QPair<QVariant, QVariant> >::invoke(v); - if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) { + if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>()) && !(typeId == qMetaTypeId<QPair<QVariant, QVariant> >())) { QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value<QtMetaTypePrivate::QPairVariantInterfaceImpl>(); const QtMetaTypePrivate::VariantData d1 = pi.first(); -- cgit v1.2.3 From 7c0341daeef9c975b0e736b9d8a52b9649c6a06c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 3 Jan 2020 12:51:20 +0100 Subject: uic: Fix empty strings for Python Introduce a constant in the language namespace. Fixes: PYSIDE-1174 Change-Id: Ic3e58580b20c1d9a6ddf97f20709a3046d4b6f0c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> --- src/tools/uic/cpp/cppwriteinitialization.cpp | 12 +++++------- src/tools/uic/shared/language.cpp | 3 +++ src/tools/uic/shared/language.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 570a61a1f1..4fbf01262b 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -731,7 +731,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition m_output << m_indent << parentWidget << language::derefPointer << "addTab(" - << varName << icon << ", " << "QString())" << language::eol; + << varName << icon << ", " << language::emptyString << ')' << language::eol; autoTrOutput(ptitleString, pageDefaultString) << m_indent << parentWidget << language::derefPointer << "setTabText(" << parentWidget @@ -2086,7 +2086,7 @@ void WriteInitialization::initializeComboBox(DomWidget *w) m_output << iconValue << ", "; if (needsTranslation(text->elementString())) { - m_output << "QString())" << language::eol; + m_output << language::emptyString << ')' << language::eol; m_refreshOut << m_indent << varName << language::derefPointer << "setItemText(" << i << ", " << trCall(text->elementString()) << ')' << language::eol; @@ -2288,7 +2288,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) if (str && str->text().isEmpty()) { m_output << m_indent << varName << language::derefPointer << "headerItem()" << language::derefPointer << "setText(" - << i << ", QString())" << language::eol; + << i << ", " << language::emptyString << ')' << language::eol; } } } @@ -2451,10 +2451,8 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) QString WriteInitialization::trCall(const QString &str, const QString &commentHint, const QString &id) const { - if (str.isEmpty()) { - return language::language() == Language::Cpp - ? QLatin1String("QString()") : QLatin1String("\"\""); - } + if (str.isEmpty()) + return language::emptyString; QString result; QTextStream ts(&result); diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp index 235a8ed2fc..987d51e30c 100644 --- a/src/tools/uic/shared/language.cpp +++ b/src/tools/uic/shared/language.cpp @@ -49,6 +49,7 @@ void setLanguage(Language l) qualifier = QLatin1String("::"); self = QLatin1String(""); // for testing: change to "this->"; eol = QLatin1String(";\n"); + emptyString = QLatin1String("QString()"); encoding = Encoding::Utf8; break; case Language::Python: @@ -59,6 +60,7 @@ void setLanguage(Language l) qualifier = QLatin1String("."); self = QLatin1String("self."); eol = QLatin1String("\n"); + emptyString = QLatin1String("\"\""); encoding = Encoding::Unicode; break; } @@ -71,6 +73,7 @@ QString qtQualifier; QString qualifier; QString self; QString eol; +QString emptyString; QString cppQualifier = QLatin1String("::"); QString cppTrue = QLatin1String("true"); diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h index fc8af9715b..7b019ec8fc 100644 --- a/src/tools/uic/shared/language.h +++ b/src/tools/uic/shared/language.h @@ -49,6 +49,7 @@ extern QString qtQualifier; extern QString qualifier; extern QString self; extern QString eol; +extern QString emptyString; extern QString cppQualifier; extern QString cppTrue; -- cgit v1.2.3 From 77f1d0bfa542e166deaa196b3b3b854d33a3a1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 3 Jan 2020 13:22:06 +0100 Subject: macOS: Skip uninitialized buffers in IOSurface backingstore Task-number: QTBUG-80972 Change-Id: Ifb8eb84d6b802556ccd52ac129a91e142e265a81 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 8a815a7665..2e15d11564 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -617,8 +617,10 @@ QImage QCALayerBackingStore::toImage() const void QCALayerBackingStore::backingPropertiesChanged() { qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers"; - for (auto &buffer : m_buffers) - buffer->setColorSpace(colorSpace()); + for (auto &buffer : m_buffers) { + if (buffer) + buffer->setColorSpace(colorSpace()); + } } QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const -- cgit v1.2.3 From b3f94eba6d4a329b5c64c7fb60ba33e3a8df301e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Mon, 30 Dec 2019 19:42:33 +0100 Subject: SQL: add proper support to build QMYSQL with MariaDB client libraries The QMYSQL plugin can also be build with the MariaDB client libraries since they are source compatible. But the MariaDB libraries could not be found on windows because the library name differs. Therefore add the correct library names and update the documentation to make clear that MariaDB is supported through the QMYSQL plugin. [ChangeLog][Sql][QMYSQL] The QMYSQL plugin can now be build with the MariaDB C connector libs on Windows. Change-Id: Id99f8be96c4179fd2321b3e61c90bb300c53bb82 Reviewed-by: Marius Kittler <mariuskittler@gmx.de> Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/plugins/sqldrivers/configure.json | 2 ++ src/plugins/sqldrivers/mysql/main.cpp | 4 ++- src/sql/doc/snippets/code/doc_src_sql-driver.qdoc | 2 +- src/sql/doc/src/sql-driver.qdoc | 32 ++++++++++++++++------- 4 files changed, 29 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json index cd20eef1df..28ccbeadcd 100644 --- a/src/plugins/sqldrivers/configure.json +++ b/src/plugins/sqldrivers/configure.json @@ -72,7 +72,9 @@ { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": false }, { "type": "mysqlConfig", "query": "--libs", "cleanlibs": false }, { "libs": "-lmysqlclient_r", "condition": "!config.win32" }, + { "libs": "-llibmariadb", "condition": "config.win32" }, { "libs": "-llibmysql", "condition": "config.win32" }, + { "libs": "-lmariadb", "condition": "!config.win32" }, { "libs": "-lmysqlclient", "condition": "!config.win32" } ] }, diff --git a/src/plugins/sqldrivers/mysql/main.cpp b/src/plugins/sqldrivers/mysql/main.cpp index d8d70483ef..4c6753097f 100644 --- a/src/plugins/sqldrivers/mysql/main.cpp +++ b/src/plugins/sqldrivers/mysql/main.cpp @@ -61,7 +61,9 @@ QMYSQLDriverPlugin::QMYSQLDriverPlugin() QSqlDriver* QMYSQLDriverPlugin::create(const QString &name) { - if (name == QLatin1String("QMYSQL") || name == QLatin1String("QMYSQL3")) { + if (name == QLatin1String("QMYSQL") || + name == QLatin1String("QMYSQL3") || + name == QLatin1String("QMARIADB")) { QMYSQLDriver* driver = new QMYSQLDriver(); return driver; } diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc index 12a39d80b2..b869b309b7 100644 --- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc +++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc @@ -235,7 +235,7 @@ make sub-oci //! [35] QSqlDatabase: QPSQL driver not loaded -QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 +QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QMARIADB QODBC QODBC3 QPSQL QPSQL7 Could not create database object //! [35] diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 3a0fcfa1e7..4d6df63749 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -48,7 +48,7 @@ \header \li Driver name \li DBMS \row \li \l{#QDB2}{QDB2} \li IBM DB2 (version 7.1 and above) \row \li \l{#QIBASE}{QIBASE} \li Borland InterBase - \row \li \l{#QMYSQL}{QMYSQL} \li MySQL (version 5.0 and above) + \row \li \l{#QMYSQL}{QMYSQL / MARIADB} \li MySQL or MariaDB (version 5.0 and above) \row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver \row \li \l{#QODBC}{QODBC} \li Open Database Connectivity (ODBC) - Microsoft SQL Server and other @@ -123,7 +123,13 @@ \section1 Driver Specifics \target QMYSQL - \section2 QMYSQL for MySQL 5 and higher + \section2 QMYSQL for MySQL or MariaDB 5 and higher + + MariaDB is a fork of MySQL intended to remain free and open-source software + under the GNU General Public License. MariaDB intended to maintain high + compatibility with MySQL, ensuring a drop-in replacement capability with + library binary parity and exact matching with MySQL APIs and commands. + Therefore the plugin for MySQL and MariaDB are combined into one Qt plugin. \section3 QMYSQL Stored Procedure Support @@ -158,12 +164,13 @@ \section3 How to Build the QMYSQL Plugin on Unix and \macos - You need the MySQL header files, as well as the shared library - \c{libmysqlclient.so}. Depending on your Linux distribution, you may - need to install a package which is usually called "mysql-devel". + You need the MySQL / MariaDB header files, as well as the shared library + \c{libmysqlclient.so} / \c{libmariadb.so}. Depending on your Linux distribution, + you may need to install a package which is usually called "mysql-devel" + or "mariadb-devel". - Tell \l qmake where to find the MySQL header files and shared - libraries (here it is assumed that MySQL is installed in + Tell \l qmake where to find the MySQL / MariaDB header files and shared + libraries (here it is assumed that MySQL / MariaDB is installed in \c{/usr/local}) and run \c{make}: \snippet code/doc_src_sql-driver.qdoc 3 @@ -171,7 +178,8 @@ \section3 How to Build the QMYSQL Plugin on Windows You need to get the MySQL installation files (e.g. - \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}). + \l {https://dev.mysql.com/downloads/installer/}{mysql-installer-web-community-8.0.18.0.msi}) or + \l {https://downloads.mariadb.org/connector-c/3.1.5/}{mariadb-connector-c-3.1.5-win64.msi}. Run the installer, select custom installation and install the MySQL C Connector which matches your Qt installation (x86 or x64). @@ -181,6 +189,12 @@ \li \c {<MySQL dir>/lib/libmysql.dll} \li \c {<MySQL dir>/include/mysql.h} \endlist + and for MariaDB + \list + \li \c {<MariaDB dir>/lib/libmariadb.lib} + \li \c {<MariaDB dir>/lib/libmariadb.dll} + \li \c {<MariaDB dir>/include/mysql.h} + \endlist Build the plugin as follows (here it is assumed that the MySQL C Connector is installed in @@ -191,7 +205,7 @@ If you are not using a Microsoft compiler, replace \c nmake with \c mingw32-make in the line above. - When you distribute your application, remember to include libmysql.dll + When you distribute your application, remember to include libmysql.dll / libmariadb.dll in your installation package. It must be placed in the same folder as the application executable. \e libmysql.dll additionally needs the MSVC runtime libraries which can be installed with vcredist.exe -- cgit v1.2.3 From 3a9251e8691f77c849c93f8d40784fae77f0a923 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 2 Jan 2020 13:08:21 +0100 Subject: Fix parameter of QJsonObject::const_iterator operator-(const_iterator) It used to be "iterator", causing a qdoc warning: src/corelib/serialization/qjsonobject.cpp:1405: (qdoc) warning: clang found diagnostics parsing \fn int QJsonObject::const_iterator::operator-(const_iterator other) const error: out-of-line definition of 'operator-' does not match any declaration in 'QJsonObject::const_iterator' Add a small test. Change-Id: Id65effffa720ed1e0fb0ee6937dcc4298f3ef363 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/serialization/qjsonobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index cfb44c9c55..c31be0353d 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -221,7 +221,7 @@ public: inline const_iterator operator-(int j) const { return operator+(-j); } inline const_iterator &operator+=(int j) { i += j; return *this; } inline const_iterator &operator-=(int j) { i -= j; return *this; } - int operator-(iterator j) const { return i - j.i; } + int operator-(const_iterator j) const { return i - j.i; } inline bool operator==(const iterator &other) const { return i == other.i; } inline bool operator!=(const iterator &other) const { return i != other.i; } -- cgit v1.2.3 From 71477104eb0be31452664e22927beb909465ffcd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 2 Jan 2020 12:31:27 +0100 Subject: Fix some qdoc warnings src/corelib/serialization/qjsonvalue.cpp:174: (qdoc) warning: No such parameter 'n' in QJsonValue::QJsonValue() ... examples/widgets/doc/src/icons.qdoc:584: (qdoc) warning: Command '\snippet (//! [24])' failed at end of file 'widgets/icons/mainwindow.cpp' src/corelib/text/qbytearray.cpp:5177: (qdoc) warning: clang found diagnostics parsing \fn QByteArray::FromBase64Result::operator QByteArray() const error: out-of-line definition of 'operator QByteArray' does not match any declaration in 'QByteArray::FromBase64Result' src/corelib/serialization/qjsonarray.cpp:178: (qdoc) warning: Overrides a previous doc src/corelib/serialization/qjsonarray.cpp:140: (qdoc) warning: (The previous doc is here) src/corelib/serialization/qjsonobject.cpp:1016: (qdoc) warning: clang found diagnostics parsing \fn QJsonValueRef QJsonObject::iterator::operator[](int j) const error: out-of-line definition of 'operator[]' does not match any declaration in 'QJsonObject::iterator' src/corelib/serialization/qjsonobject.cpp:1267: (qdoc) warning: clang found diagnostics parsing \fn QJsonValue QJsonObject::const_iterator::operator[](int j) const error: out-of-line definition of 'operator[]' does not match any declaration in 'QJsonObject::const_iterator' src/corelib/tools/qhash.cpp:2641: (qdoc) warning: Overrides a previous doc src/corelib/tools/qhash.cpp:1492: (qdoc) warning: (The previous doc is here) src/corelib/tools/qhash.cpp:2659: (qdoc) warning: Can't link to 'unit()' src/corelib/text/qchar.cpp:274: (qdoc) warning: Undocumented enum item 'Script_Sundanese' in QChar::Script src/corelib/text/qchar.cpp:274: (qdoc) warning: No such enum item 'Script_Sundaneseo' in QChar::Script src/network/ssl/qsslsocket.cpp:1514: (qdoc) warning: Can't link to 'QSslConfiguration::addDefaultCaCertificate()' src/widgets/widgets/qtabwidget.cpp:581: (qdoc) warning: Undocumented parameter 'visible' in QTabWidget::setTabVisible() Change-Id: I05c2a4884873850b684fa94036cd90db1a6e7726 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/serialization/qjsonarray.cpp | 12 ++++++------ src/corelib/serialization/qjsonobject.cpp | 4 ++-- src/corelib/serialization/qjsonvalue.cpp | 6 +++--- src/corelib/text/qbytearray.cpp | 13 +++++++------ src/corelib/text/qchar.cpp | 2 +- src/corelib/tools/qhash.cpp | 4 ++-- src/network/ssl/qsslsocket.cpp | 2 +- src/widgets/widgets/qtabwidget.cpp | 2 +- 8 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp index c5d4bf0315..08702771a8 100644 --- a/src/corelib/serialization/qjsonarray.cpp +++ b/src/corelib/serialization/qjsonarray.cpp @@ -175,12 +175,6 @@ void QJsonArray::initialize() */ QJsonArray::~QJsonArray() = default; -/*! - Creates a copy of \a other. - - Since QJsonArray is implicitly shared, the copy is shallow - as long as the object doesn't get modified. - */ QJsonArray::QJsonArray(std::initializer_list<QJsonValue> args) { initialize(); @@ -188,6 +182,12 @@ QJsonArray::QJsonArray(std::initializer_list<QJsonValue> args) append(arg); } +/*! + Creates a copy of \a other. + + Since QJsonArray is implicitly shared, the copy is shallow + as long as the object doesn't get modified. + */ QJsonArray::QJsonArray(const QJsonArray &other) { a = other.a; diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index ae37481f31..a6987279d3 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -1013,7 +1013,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const Returns a pointer to a modifiable reference to the current item. */ -/*! \fn QJsonValueRef QJsonObject::iterator::operator[](int j) const +/*! \fn const QJsonValueRef QJsonObject::iterator::operator[](int j) Returns a modifiable reference to the item at offset \a j from the item pointed to by this iterator (the item at position \c{*this + j}). @@ -1264,7 +1264,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const Returns a pointer to the current item. */ -/*! \fn QJsonValue QJsonObject::const_iterator::operator[](int j) const +/*! \fn const QJsonValue QJsonObject::const_iterator::operator[](int j) Returns the item at offset \a j from the item pointed to by this iterator (the item at position \c{*this + j}). diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index 6cf4c7fdf9..7b6728d525 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -149,7 +149,7 @@ QJsonValue::QJsonValue(bool b) } /*! - Creates a value of type Double, with value \a n. + Creates a value of type Double, with value \a v. */ QJsonValue::QJsonValue(double v) : d(nullptr) @@ -164,7 +164,7 @@ QJsonValue::QJsonValue(double v) /*! \overload - Creates a value of type Double, with value \a n. + Creates a value of type Double, with value \a v. */ QJsonValue::QJsonValue(int v) : n(v), t(QCborValue::Integer) @@ -173,7 +173,7 @@ QJsonValue::QJsonValue(int v) /*! \overload - Creates a value of type Double, with value \a n. + Creates a value of type Double, with value \a v. NOTE: the integer limits for IEEE 754 double precision data is 2^53 (-9007199254740992 to +9007199254740992). If you pass in values outside this range expect a loss of precision to occur. */ diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 94d22e288e..27e0d56225 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -5175,7 +5175,7 @@ void warn(WarningType w, EmittingClass c) */ /*! - \fn QByteArray::FromBase64Result::operator QByteArray() const + \fn QByteArray &QByteArray::FromBase64Result::operator*() const Returns the decoded byte array. */ @@ -5184,17 +5184,18 @@ void warn(WarningType w, EmittingClass c) \fn bool operator==(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept \relates QByteArray::FromBase64Result - Compares \a lhs and \a rhs for equality. \a lhs and \a rhs are equal - if and only if they contain the same decoding status and, if the - status is QByteArray::Base64DecodingStatus::Ok, if and only if - they contain the same decoded data. + Returns \c true if \a lhs and \a rhs are equal, otherwise returns \c false. + + \a lhs and \a rhs are equal if and only if they contain the same decoding + status and, if the status is QByteArray::Base64DecodingStatus::Ok, if and + only if they contain the same decoded data. */ /*! \fn bool operator!=(const QByteArray::FromBase64Result &lhs, const QByteArray::FromBase64Result &rhs) noexcept \relates QByteArray::FromBase64Result - Compares \a lhs and \a rhs for inequality. + Returns \c true if \a lhs and \a rhs are different, otherwise returns \c false. */ /*! diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 847b4f0b08..61b61125b1 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -418,7 +418,7 @@ QT_BEGIN_NAMESPACE \value Script_Sogdian Since Qt 5.15 \value Script_SoraSompeng \value Script_Soyombo Since Qt 5.11 - \value Script_Sundaneseo + \value Script_Sundanese \value Script_SylotiNagri \value Script_Syriac \value Script_Tagalog diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 3ff8f886f1..77c8da7f4a 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -2638,7 +2638,7 @@ uint qHash(long double key, uint seed) noexcept \sa insert() */ -/*! \fn template <class Key, class T> QList<Key> QHash<Key, T>::uniqueKeys() const +/*! \fn template <class Key, class T> QList<Key> QMultiHash<Key, T>::uniqueKeys() const \since 5.13 Returns a list containing all the keys in the map. Keys that occur multiple @@ -2661,7 +2661,7 @@ uint qHash(long double key, uint seed) noexcept Inserts all the items in the \a other hash into this hash and returns a reference to this hash. - \sa unit(), insert() + \sa unite(), insert() */ /*! \fn template <class Key, class T> QMultiHash QMultiHash<Key, T>::operator+(const QMultiHash &other) const diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 0828a795f1..1b72be66fe 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1526,7 +1526,7 @@ QList<QSslCertificate> QSslSocket::caCertificates() const default CA certificate database. \sa QSslConfiguration::caCertificates(), QSslConfiguration::addCaCertificates(), - QSslConfiguration::addDefaultCaCertificate() + QSslConfiguration::addCaCertificate() */ bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat encoding, QRegExp::PatternSyntax syntax) diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index 5b3dcfa45b..f0bfe67e3a 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -579,7 +579,7 @@ bool QTabWidget::isTabVisible(int index) const } /*! - If \a enable is true, the page at position \a index is visible; otherwise the page at + If \a visible is true, the page at position \a index is visible; otherwise the page at position \a index is hidden. The page's tab is redrawn appropriately. \sa isTabVisible() -- cgit v1.2.3 From 8b0b2057d060c9f33cfeb0ea38a08ace22079f93 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 3 Jan 2020 13:08:52 +0100 Subject: uic: Add colon missing for "if()" constructs in Python Task-number: PYSIDE-1169 Change-Id: I63c5305b0ddad1c4fcd585b65c3c78c05b40bac1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> --- src/tools/uic/cpp/cppwriteinitialization.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 4fbf01262b..5dbe10082c 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -2372,9 +2372,11 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &columns = w->elementColumn(); if (!columns.empty()) { - m_output << m_indent << "if (" << varName << language::derefPointer << "columnCount() < " - << columns.size() << ")\n" - << m_dindent << varName << language::derefPointer << "setColumnCount(" + m_output << m_indent << "if (" << varName << language::derefPointer + << "columnCount() < " << columns.size() << ')'; + if (language::language() == Language::Python) + m_output << ':'; + m_output << '\n' << m_dindent << varName << language::derefPointer << "setColumnCount(" << columns.size() << ')' << language::eol; } @@ -2400,8 +2402,11 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const auto &rows = w->elementRow(); if (!rows.isEmpty()) { - m_output << m_indent << "if (" << varName << language::derefPointer << "rowCount() < " << rows.size() << ")\n" - << m_dindent << varName << language::derefPointer << "setRowCount(" + m_output << m_indent << "if (" << varName << language::derefPointer + << "rowCount() < " << rows.size() << ')'; + if (language::language() == Language::Python) + m_output << ':'; + m_output << '\n' << m_dindent << varName << language::derefPointer << "setRowCount(" << rows.size() << ')' << language::eol; } -- cgit v1.2.3 From 65b8514cb5eae5a7055f55fd375da7b2eea487d6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 2 Jan 2020 15:16:34 +0100 Subject: MSVC: Fix integer conversion warnings in containers Add some casts, fixing warnings like: src/corelib/text/qbytearray.h(490): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/text/qstring.h(1045): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/tools/qarraydatapointer.h(80): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/tools/qarraydatapointer.h(75): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/text/qbytearray.h(490): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data Change-Id: I221db4d5b660224f0fc1869248802c496db1b91c Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/text/qbytearray.cpp | 2 +- src/corelib/text/qbytearray.h | 2 +- src/corelib/text/qstring.h | 2 +- src/corelib/tools/qarraydata.cpp | 4 ++-- src/corelib/tools/qarraydataops.h | 4 ++-- src/corelib/tools/qarraydatapointer.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 23296896b2..3fa1868437 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1218,7 +1218,7 @@ QByteArray &QByteArray::operator=(const char *str) d = QByteArrayData(pair.first, pair.second, 0); } else { const int len = int(strlen(str)); - const size_t fullLen = len + 1; + const uint fullLen = uint(len) + 1; if (d->needsDetach() || fullLen > d->allocatedCapacity() || (len < size() && fullLen < (d->allocatedCapacity() >> 1))) reallocData(fullLen, d->detachFlags()); diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 863898f7e2..e3fec1e62c 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -487,7 +487,7 @@ inline QByteArray::QByteArray(const QByteArray &a) noexcept : d(a.d) {} inline int QByteArray::capacity() const -{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } +{ const auto realCapacity = d->constAllocatedCapacity(); return realCapacity ? int(realCapacity) - 1 : 0; } inline void QByteArray::reserve(int asize) { diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index a611410fac..0350dabfc9 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1042,7 +1042,7 @@ inline void QString::clear() inline QString::QString(const QString &other) noexcept : d(other.d) { } inline int QString::capacity() const -{ int realCapacity = d->constAllocatedCapacity(); return realCapacity ? realCapacity - 1 : 0; } +{ const auto realCapacity = d->constAllocatedCapacity(); return realCapacity ? int(realCapacity) - 1 : 0; } inline QString &QString::setNum(short n, int base) { return setNum(qlonglong(n), base); } inline QString &QString::setNum(ushort n, int base) diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 00f6dfe6ef..497eae1f7f 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -233,7 +233,7 @@ void *QArrayData::allocate(QArrayData **dptr, size_t objectSize, size_t alignmen // find where offset should point to so that data() is aligned to alignment bytes data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); - header->alloc = capacity; + header->alloc = uint(capacity); } *dptr = header; @@ -262,7 +262,7 @@ QArrayData::reallocateUnaligned(QArrayData *data, void *dataPointer, options |= AllocatedDataType | MutableData; QArrayData *header = reallocateData(data, allocSize, options); if (header) { - header->alloc = capacity; + header->alloc = uint(capacity); dataPointer = reinterpret_cast<char *>(header) + offset; } return qMakePair(static_cast<QArrayData *>(header), dataPointer); diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 6b110c5143..0d2be5d51c 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -158,7 +158,7 @@ struct QPodArrayOps ::memmove(static_cast<void *>(where + n), static_cast<void *>(where), (static_cast<const T*>(this->end()) - where) * sizeof(T)); - this->size += n; // PODs can't throw on copy + this->size += int(n); // PODs can't throw on copy while (n--) *where++ = t; } @@ -655,7 +655,7 @@ struct QMovableArrayOps copier.copy(n, t); displace.commit(); - this->size += n; + this->size += int(n); } // use moving insert diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 7bba7241e9..a17cf4a101 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -71,12 +71,12 @@ public: } QArrayDataPointer(Data *header, T *adata, size_t n = 0) noexcept - : d(header), ptr(adata), size(n) + : d(header), ptr(adata), size(int(n)) { } explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, size_t n = 0) - : d(adata.first), ptr(adata.second), size(n) + : d(adata.first), ptr(adata.second), size(int(n)) { Q_CHECK_PTR(d); } -- cgit v1.2.3 From 01f0df1cf559991e4b7fbee1cb14b068fb6895c8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 3 Jan 2020 15:02:44 +0100 Subject: uic: Add handling of resources imports for Python The Python-bases pyside2-uic would write an import for each resource file encountered, adding a "_rc" suffix. Add this handling. Task-number: PYSIDE-1171 Task-number: PYSIDE-1170 Change-Id: I870d61ca7262c0684de5359a5f990d23a4171032 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> --- src/tools/uic/main.cpp | 5 +++++ src/tools/uic/option.h | 2 ++ src/tools/uic/python/pythonwriteimports.cpp | 32 +++++++++++++++++++++++++++++ src/tools/uic/python/pythonwriteimports.h | 1 + 4 files changed, 40 insertions(+) (limited to 'src') diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 9cf22d502d..d6c63de869 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -108,6 +108,10 @@ int runUic(int argc, char *argv[]) idBasedOption.setDescription(QStringLiteral("Use id based function for i18n")); parser.addOption(idBasedOption); + QCommandLineOption fromImportsOption(QStringLiteral("from-imports")); + fromImportsOption.setDescription(QStringLiteral("Python: generate imports relative to '.'")); + parser.addOption(fromImportsOption); + parser.addPositionalArgument(QStringLiteral("[uifile]"), QStringLiteral("Input file (*.ui), otherwise stdin.")); parser.process(app); @@ -118,6 +122,7 @@ int runUic(int argc, char *argv[]) driver.option().headerProtection = !parser.isSet(noProtOption); driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption); driver.option().idBased = parser.isSet(idBasedOption); + driver.option().fromImports = parser.isSet(fromImportsOption); driver.option().postfix = parser.value(postfixOption); driver.option().translateFunction = parser.value(translateOption); driver.option().includeFile = parser.value(includeOption); diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h index 4fc442e94a..8e882079c9 100644 --- a/src/tools/uic/option.h +++ b/src/tools/uic/option.h @@ -45,6 +45,7 @@ struct Option unsigned int limitXPM_LineLength : 1; unsigned int implicitIncludes: 1; unsigned int idBased: 1; + unsigned int fromImports: 1; QString inputFile; QString outputFile; @@ -65,6 +66,7 @@ struct Option limitXPM_LineLength(0), implicitIncludes(1), idBased(0), + fromImports(0), prefix(QLatin1String("Ui_")) { indent.fill(QLatin1Char(' '), 4); } diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index 303615f77b..be55696683 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -29,6 +29,7 @@ #include "pythonwriteimports.h" #include <customwidgetsinfo.h> +#include <option.h> #include <uic.h> #include <ui4.h> @@ -46,6 +47,20 @@ from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, from PySide2.QtWidgets import * )I"; +// Change the name of a qrc file "dir/foo.qrc" file to the Python +// module name "foo_rc" according to project conventions. +static QString pythonResource(QString resource) +{ + const int lastSlash = resource.lastIndexOf(QLatin1Char('/')); + if (lastSlash != -1) + resource.remove(0, lastSlash + 1); + if (resource.endsWith(QLatin1String(".qrc"))) { + resource.chop(4); + resource.append(QLatin1String("_rc")); + } + return resource; +} + namespace Python { WriteImports::WriteImports(Uic *uic) : m_uic(uic) @@ -60,6 +75,23 @@ void WriteImports::acceptUI(DomUI *node) TreeWalker::acceptCustomWidgets(customWidgets); output << '\n'; } + + if (auto resources = node->elementResources()) { + const auto includes = resources->elementInclude(); + for (auto include : includes) { + if (include->hasAttributeLocation()) + writeImport(pythonResource(include->attributeLocation())); + } + output << '\n'; + } +} + +void WriteImports::writeImport(const QString &module) +{ + + if (m_uic->option().fromImports) + m_uic->output() << "from . "; + m_uic->output() << "import " << module << '\n'; } QString WriteImports::qtModuleOf(const DomCustomWidget *node) const diff --git a/src/tools/uic/python/pythonwriteimports.h b/src/tools/uic/python/pythonwriteimports.h index 427cbb48b1..5462453962 100644 --- a/src/tools/uic/python/pythonwriteimports.h +++ b/src/tools/uic/python/pythonwriteimports.h @@ -46,6 +46,7 @@ public: void acceptCustomWidget(DomCustomWidget *node) override; private: + void writeImport(const QString &module); QString qtModuleOf(const DomCustomWidget *node) const; Uic *const m_uic; -- cgit v1.2.3 From d593c5865acb544d02e45ac24245d9bc9988ffb1 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Thu, 12 Dec 2019 14:06:31 +0100 Subject: Remove QOpenGLTexture dependency from QTextureFileData Just print the hex value of the format. Task-number: QTBUG-74409 Change-Id: I0441eda050735325f7686532b17ef765f71bec9b Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/util/qtexturefiledata.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src') diff --git a/src/gui/util/qtexturefiledata.cpp b/src/gui/util/qtexturefiledata.cpp index 41cbd1b15a..3c8130c229 100644 --- a/src/gui/util/qtexturefiledata.cpp +++ b/src/gui/util/qtexturefiledata.cpp @@ -38,11 +38,7 @@ ****************************************************************************/ #include "qtexturefiledata_p.h" -#include <QMetaEnum> #include <QSize> -#if QT_CONFIG(opengl) -#include <QOpenGLTexture> -#endif QT_BEGIN_NAMESPACE @@ -247,13 +243,7 @@ void QTextureFileData::setLogName(const QByteArray &name) static QByteArray glFormatName(quint32 fmt) { - const char *id = nullptr; -#if QT_CONFIG(opengl) - id = QMetaEnum::fromType<QOpenGLTexture::TextureFormat>().valueToKey(fmt); -#endif - QByteArray res(id ? id : "(?)"); - res += " [0x" + QByteArray::number(fmt, 16).rightJustified(4, '0') + ']'; - return res; + return QByteArray("0x" + QByteArray::number(fmt, 16).rightJustified(4, '0')); } QDebug operator<<(QDebug dbg, const QTextureFileData &d) -- cgit v1.2.3 From e65c43fd0ffa57248e7d750570b7deae171a82f5 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Mon, 30 Dec 2019 18:28:33 +0800 Subject: Code style fix Amends commit a0eb51c3870d90c06966dbfbe26b114f39103b60 Change-Id: Ida0bf55cb9a056607181241dd84522a010c40890 Reviewed-by: Federico Guerinoni <guerinoni@micro-systems.it> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> --- src/corelib/tools/qbitarray.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index 4db0f61599..a1dd537d4d 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -343,34 +343,32 @@ QBitArray QBitArray::fromBits(const char *data, qsizetype size) } /*! - \since 5.13 + \since 6.0 - Returns the array of bit converted to an int. The conversion is based of endianness value. - Converts up to the first 32 bits of the array to \c uint32_t and returns it, - obeying \a endianness. If the array has more than 32 bits, \a ok is set to false - and this function returns zero; otherwise, it's set to true. + Returns the array of bit converted to an int. The conversion is based on \a endianness. + Converts up to the first 32 bits of the array to \c quint32 and returns it, + obeying \a endianness. If \a ok is not a null pointer, and the array has more + than 32 bits, \a ok is set to false and this function returns zero; otherwise, + it's set to true. */ quint32 QBitArray::toUInt32(QSysInfo::Endian endianness, bool *ok) const noexcept { - if (size() > 32) { - if (ok != nullptr) { + const qsizetype _size = size(); + if (_size > 32) { + if (ok) *ok = false; - } - return 0; } - if (ok != nullptr) { + if (ok) *ok = true; - } - auto factor = 1; + quint32 factor = 1; quint32 total = 0; - for (auto i = 0; i < size(); ++i, factor *= 2) { - const auto index = endianness == QSysInfo::Endian::LittleEndian ? i : (size() - i - 1); - if (testBit(index)) { + for (qsizetype i = 0; i < _size; ++i, factor *= 2) { + const auto index = endianness == QSysInfo::Endian::LittleEndian ? i : (_size - i - 1); + if (testBit(index)) total += factor; - } } return total; -- cgit v1.2.3 From 02ddf08db808304363454a9ef7cba9b41af3f112 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Thu, 2 Jan 2020 15:03:16 +0100 Subject: Note that zh's "Chinese" is in fact Mandarin Task-number: QTBUG-63457 Change-Id: If1e36c3b2230d8c45311add26c976843eb5b3d36 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/text/qlocale.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc index dbcd71f1a0..592f9d0785 100644 --- a/src/corelib/text/qlocale.qdoc +++ b/src/corelib/text/qlocale.qdoc @@ -174,7 +174,7 @@ \value Chewa Obsolete, please use Nyanja \value Chickasaw Since Qt 5.14 \value Chiga - \value Chinese + \value Chinese (Mandarin) \value Church \value Chuvash \value ClassicalMandaic Since Qt 5.1 -- cgit v1.2.3 From c62333424839b3229706a6ebb64ba271689a3b8c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 22 Dec 2019 17:53:20 +0100 Subject: QPlainTextEdit: make sure firstVisibleBlock() is valid Under some circumstances it's possible that firstVisibleBlock() returns an invalid block within QPlainTextEditPrivate::_q_textChanged() which results in a nullptr access later on. Therefore add a check similar to other places and test the validity of the returned block before accessing it. Fixes: QTBUG-80929 Change-Id: I1fd4643b10b842acfe1c356048379f0ba225dddf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/widgets/qplaintextedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index e8da720b58..7e9e0fabe9 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -839,7 +839,8 @@ void QPlainTextEditPrivate::_q_textChanged() placeholderVisible = !placeholderText.isEmpty() && q->document()->isEmpty() - && q->firstVisibleBlock().layout()->preeditAreaText().isEmpty(); + && (!q->firstVisibleBlock().isValid() || + q->firstVisibleBlock().layout()->preeditAreaText().isEmpty()); if (placeholderCurrentyVisible != placeholderVisible) viewport->update(); -- cgit v1.2.3 From 9b647bf5acf6a5bd4bf87646feed7b19960fc274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= <cristian.maureira-fredes@qt.io> Date: Fri, 3 Jan 2020 16:26:37 +0100 Subject: uic: setWeight replace semi-colon by language::eol Change-Id: I87f9c2896cfd6f83f683cf731e4a62aef627d69c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/tools/uic/cpp/cppwriteinitialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 5dbe10082c..1444c681c0 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1612,7 +1612,7 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) } if (f->hasElementWeight() && f->elementWeight() > 0) { m_output << m_indent << fontName << ".setWeight(" - << f->elementWeight() << ");" << Qt::endl; + << f->elementWeight() << ")" << language::eol; } if (f->hasElementStrikeOut()) { m_output << m_indent << fontName << ".setStrikeOut(" -- cgit v1.2.3 From 56674dca36f113369d3ed598192a392ceb723605 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Wed, 25 Dec 2019 19:37:53 +0100 Subject: QSS/QComboBox: set correct palette when drawing SC_ComboBoxArrow When the dropdown button of a combobox is drawn with QStyleSheetStyle, not only the background color is used for drawing but also QPalette::Light/Dark/Shadow. Since the palette was not properly set up in some cases, the shaded frame around the button was drawn with the default colors instead the ones derived from the given background. Therefore we have to properly set up the palette before drawing the drop down button by calling QRenderRule::configurePalette() Fixes: QTBUG-80950 Change-Id: Ibf98fa28612b5c7527ef9dd6ae06c417315f2632 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/styles/qstylesheetstyle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 98c85684ae..c694e9db97 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3019,6 +3019,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction); subRule2.drawRule(p, r); } else { + rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button); cmbOpt.subControls = QStyle::SC_ComboBoxArrow; QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w); } -- cgit v1.2.3 From 2c3eaa7b87219d24facfe81a5b22cb218324f1ae Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Fri, 27 Dec 2019 18:01:49 +0100 Subject: Fix semi-transparent text on Linux with subpixel anti-aliasing The newly optimized rgbBlend function wasn't updated to handle SourceOver compositing when dealing with semi-transparent text color. The extra composition isn't SIMD optimized but short-cut for all opaque colors. Fixes: QTBUG-80982 Change-Id: I88c1e60fd5e80a8c7f9e6b0e7de8248c7c00ebc2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> --- src/gui/painting/qdrawhelper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e8d129d047..f8d5914f37 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6048,7 +6048,11 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba // Give up and do a naive gray alphablend. Needed to deal with ARGB32 and invalid ARGB32_premultiplied, see QTBUG-60571 blend_pixel(*dst, src, qRgbAvg(coverage)); } else if (!colorProfile) { - *dst = rgbBlend(*dst, src, coverage); + // First do naive blend with text-color + QRgb s = *dst; + blend_pixel(s, src); + // Then a naive blend with glyph shape + *dst = rgbBlend(*dst, s, coverage); } else if (srcLinear.isOpaque()) { rgbBlendPixel(dst, coverage, srcLinear, colorProfile); } else { -- cgit v1.2.3 From aa542be4e005b1feedc2e17fd6ca2387bf2fea1b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Wed, 18 Dec 2019 17:23:50 +0100 Subject: Modernize setAlphaChannel(), and deprecated alphaChannel() The two methods have been marked obsolete for a very long time, setAlphaChannel() is still convenient though, so this patch modernizes it and removes obsolete from the API, while marking QImage::alphaChannel() as deprecated. They don't work as getter and setter anyway, since setAlphaChannel() actually does an alpha composition. Change-Id: I634d6463f78c42bb9c5fa3df17500ec01bfcac33 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/image/qimage.cpp | 95 +++++++++------------------- src/gui/image/qimage.h | 4 +- src/plugins/imageformats/ico/qicohandler.cpp | 2 - 3 files changed, 32 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 99d64737c5..3ddc52bed4 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4410,99 +4410,61 @@ bool QImage::isDetached() const /*! - \obsolete Sets the alpha channel of this image to the given \a alphaChannel. - If \a alphaChannel is an 8 bit grayscale image, the intensity values are - written into this buffer directly. Otherwise, \a alphaChannel is converted - to 32 bit and the intensity of the RGB pixel values is used. - - Note that the image will be converted to the Format_ARGB32_Premultiplied - format if the function succeeds. + If \a alphaChannel is an 8 bit alpha image, the alpha values are + used directly. Otherwise, \a alphaChannel is converted to 8 bit + grayscale and the intensity of the pixel values is used. - Use one of the composition modes in QPainter::CompositionMode instead. + If the image already has an alpha channel, the existing alpha channel + is multiplied with the new one. If the image doesn't have an alpha + channel it will be converted to a format that does. - \warning This function is expensive. + The operation is similar to painting \a alphaChannel as an alpha image + over this image using \c QPainter::CompositionMode_DestinationIn. - \sa alphaChannel(), {QImage#Image Transformations}{Image - Transformations}, {QImage#Image Formats}{Image Formats} + \sa hasAlphaChannel(), alphaChannel(), + {QImage#Image Transformations}{Image Transformations}, + {QImage#Image Formats}{Image Formats} */ void QImage::setAlphaChannel(const QImage &alphaChannel) { - if (!d) + if (!d || alphaChannel.isNull()) return; - int w = d->width; - int h = d->height; - - if (w != alphaChannel.d->width || h != alphaChannel.d->height) { - qWarning("QImage::setAlphaChannel: " - "Alpha channel must have same dimensions as the target image"); - return; - } - if (d->paintEngine && d->paintEngine->isActive()) { qWarning("QImage::setAlphaChannel: " "Unable to set alpha channel while image is being painted on"); return; } - if (d->format == QImage::Format_ARGB32_Premultiplied) + const Format alphaFormat = qt_alphaVersionForPainting(d->format); + if (d->format == alphaFormat) detach(); else - *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); + convertTo(alphaFormat); if (isNull()) return; - // Slight optimization since alphachannels are returned as 8-bit grays. - if (alphaChannel.format() == QImage::Format_Alpha8 ||( alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) { - const uchar *src_data = alphaChannel.d->data; - uchar *dest_data = d->data; - for (int y=0; y<h; ++y) { - const uchar *src = src_data; - QRgb *dest = (QRgb *)dest_data; - for (int x=0; x<w; ++x) { - int alpha = *src; - int destAlpha = qt_div_255(alpha * qAlpha(*dest)); - *dest = ((destAlpha << 24) - | (qt_div_255(qRed(*dest) * alpha) << 16) - | (qt_div_255(qGreen(*dest) * alpha) << 8) - | (qt_div_255(qBlue(*dest) * alpha))); - ++dest; - ++src; - } - src_data += alphaChannel.d->bytes_per_line; - dest_data += d->bytes_per_line; - } + QImage sourceImage; + if (alphaChannel.format() == QImage::Format_Alpha8 || (alphaChannel.d->depth == 8 && alphaChannel.isGrayscale())) + sourceImage = alphaChannel; + else + sourceImage = alphaChannel.convertToFormat(QImage::Format_Grayscale8); + if (!sourceImage.reinterpretAsFormat(QImage::Format_Alpha8)) + return; - } else { - const QImage sourceImage = alphaChannel.convertToFormat(QImage::Format_RGB32); - if (sourceImage.isNull()) - return; - const uchar *src_data = sourceImage.d->data; - uchar *dest_data = d->data; - for (int y=0; y<h; ++y) { - const QRgb *src = (const QRgb *) src_data; - QRgb *dest = (QRgb *) dest_data; - for (int x=0; x<w; ++x) { - int alpha = qGray(*src); - int destAlpha = qt_div_255(alpha * qAlpha(*dest)); - *dest = ((destAlpha << 24) - | (qt_div_255(qRed(*dest) * alpha) << 16) - | (qt_div_255(qGreen(*dest) * alpha) << 8) - | (qt_div_255(qBlue(*dest) * alpha))); - ++dest; - ++src; - } - src_data += sourceImage.d->bytes_per_line; - dest_data += d->bytes_per_line; - } - } + QPainter painter(this); + if (sourceImage.size() != size()) + painter.setRenderHint(QPainter::SmoothPixmapTransform); + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + painter.drawImage(rect(), sourceImage); } +#if QT_DEPRECATED_SINCE(5, 15) /*! \obsolete @@ -4592,6 +4554,7 @@ QImage QImage::alphaChannel() const return image; } +#endif /*! Returns \c true if the image has a format that respects the alpha diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 7544ccca05..115071c16e 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -266,7 +266,9 @@ public: bool hasAlphaChannel() const; void setAlphaChannel(const QImage &alphaChannel); - QImage alphaChannel() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED QImage alphaChannel() const; +#endif QImage createAlphaMask(Qt::ImageConversionFlags flags = Qt::AutoColor) const; #ifndef QT_NO_IMAGE_HEURISTIC_MASK QImage createHeuristicMask(bool clipTight = true) const; diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 6515748bf5..eb50f52bd6 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -535,8 +535,6 @@ QImage ICOReader::iconAt(int index) if (!mask.isNull()) { img = image; img.setAlphaChannel(mask); - // (Luckily, it seems that setAlphaChannel() does not ruin the alpha values - // of partially transparent pixels in those icons that have that) } } } -- cgit v1.2.3 From 24b8b2cb6ccd3704545ef44519f567edb3da5d5d Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Fri, 3 Jan 2020 13:39:04 +0100 Subject: Stylesheet: Handle tabs with elide mode set correctly In order for SE_TabBarTabText to correctly calculate the space available for the text it needs to get the rectangle of the tab directly instead of relying on the option's rectangle as this may have been modified before this point. Therefore we introduce QStyleOptionTabV4 to be able to store the index as part of the option so it can be queried directly. [ChangeLog][QtWidgets] Added QStyleOptionTabV4 as a subclass of QStyleOptionTab so that the tab's index information can be obtained. Fixes: QTBUG-50637 Change-Id: If705f5069fdd14eeccf06bc63dba4e8d2e704359 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- src/widgets/styles/qstyleoption.cpp | 16 ++++++++++++++++ src/widgets/styles/qstyleoption.h | 8 ++++++++ src/widgets/styles/qstylesheetstyle.cpp | 10 ++++++++++ src/widgets/widgets/qtabbar.cpp | 16 +++++++++------- 4 files changed, 43 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 5292d971ea..aca4eec0e7 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1470,6 +1470,22 @@ QStyleOptionTab::QStyleOptionTab(int version) The default value is QSize(-1, -1), i.e. an invalid size; */ +/*! + Constructs a QStyleOptionTabV4 object, initializing the members + variables to their default values. + */ + +QStyleOptionTabV4::QStyleOptionTabV4() : QStyleOptionTab(QStyleOptionTabV4::Version) +{ +} + +/*! + \variable QStyleOptionTabV4::tabIndex + \brief the index for the tab being represented. + + The default value is -1, i.e. a tab not on a tabbar; + */ + #endif // QT_CONFIG(tabbar) /*! diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index 7f5edf4279..a8ce3b465e 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -296,6 +296,14 @@ protected: QStyleOptionTab(int version); }; +class Q_WIDGETS_EXPORT QStyleOptionTabV4 : public QStyleOptionTab +{ +public: + enum StyleOptionVersion { Version = 4 }; + QStyleOptionTabV4(); + int tabIndex = -1; +}; + Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets) typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV2; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 7e8c9a6050..7fe46e24b6 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -6009,6 +6009,16 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c case SE_TabBarTabRightButton: { QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); if (subRule.hasBox() || !subRule.hasNativeBorder()) { + if (se == SE_TabBarTabText) { + if (const QStyleOptionTabV4 *tab = qstyleoption_cast<const QStyleOptionTabV4 *>(opt)) { + const QTabBar *bar = qobject_cast<const QTabBar *>(w); + const QRect optRect = bar && tab->tabIndex != -1 ? bar->tabRect(tab->tabIndex) : opt->rect; + const QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, optRect, opt->direction); + QStyleOptionTabV4 tabCopy(*tab); + tabCopy.rect = subRule.contentsRect(r); + return ParentStyle::subElementRect(se, &tabCopy, w); + } + } return ParentStyle::subElementRect(se, opt, w); } break; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index aff95b0931..a7b115a1bc 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -229,6 +229,8 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) option->cornerWidgets |= QStyleOptionTab::RightCornerWidget; } #endif + if (QStyleOptionTabV4 *optv4 = qstyleoption_cast<QStyleOptionTabV4 *>(option)) + optv4->tabIndex = tabIndex; } /*! @@ -628,7 +630,7 @@ QRect QTabBarPrivate::normalizedScrollRect(int index) // tab bar itself is in a different orientation. Q_Q(QTabBar); - QStyleOptionTab opt; + QStyleOptionTabV4 opt; q->initStyleOption(&opt, currentIndex); opt.rect = q->rect(); @@ -757,7 +759,7 @@ void QTabBarPrivate::layoutTab(int index) if (!(tab.leftWidget || tab.rightWidget)) return; - QStyleOptionTab opt; + QStyleOptionTabV4 opt; q->initStyleOption(&opt, index); if (tab.leftWidget) { QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q); @@ -1003,7 +1005,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text) } if (d->closeButtonOnTabs) { - QStyleOptionTab opt; + QStyleOptionTabV4 opt; initStyleOption(&opt, index); ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this); QAbstractButton *closeButton = new CloseButton(this); @@ -1574,7 +1576,7 @@ QSize QTabBar::tabSizeHint(int index) const //Note: this must match with the computations in QCommonStylePrivate::tabLayout Q_D(const QTabBar); if (const QTabBarPrivate::Tab *tab = d->at(index)) { - QStyleOptionTab opt; + QStyleOptionTabV4 opt; d->initBasicStyleOption(&opt, index); opt.text = d->tabList.at(index).text; QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize; @@ -1819,7 +1821,7 @@ void QTabBar::paintEvent(QPaintEvent *) for (int i = 0; i < d->tabList.count(); ++i) { if (!d->at(i)->visible) continue; - QStyleOptionTab tab; + QStyleOptionTabV4 tab; initStyleOption(&tab, i); if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) { if (vertical) { @@ -1859,7 +1861,7 @@ void QTabBar::paintEvent(QPaintEvent *) // Draw the selected tab last to get it "on top" if (selected >= 0) { - QStyleOptionTab tab; + QStyleOptionTabV4 tab; initStyleOption(&tab, selected); if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) { if (vertical) @@ -2209,7 +2211,7 @@ void QTabBarPrivate::setupMovableTab() grabImage.fill(Qt::transparent); QStylePainter p(&grabImage, q); - QStyleOptionTab tab; + QStyleOptionTabV4 tab; q->initStyleOption(&tab, pressedIndex); tab.position = QStyleOptionTab::OnlyOneTab; if (verticalTabs(shape)) -- cgit v1.2.3 From 5b22d1719881b5f061be6b832a96a1e4305d981f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 19 Dec 2019 10:36:15 +0100 Subject: Fix some issues of a clang-cl developer build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - qeasingcurve.cpp: Add a cast, fixing: qeasingcurve.cpp(1515,25): error: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Werror,-Wmicrosoft-cast] - Disable copy and move of QMainWindowLayoutSeparatorHelper, fixing: qbasictimer.h(59,5): note: 'QBasicTimer' has been explicitly marked deprecated here QT_DEPRECATED_X("copy-construction is unsupported; use move-construction instead") Task-number: QTBUG-63512 Change-Id: I4d12a29cb1dcd68da9f9316c9e42992f218e6045 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/corelib/tools/qeasingcurve.cpp | 2 +- src/widgets/widgets/qmainwindowlayout_p.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 52c8d13fe3..bf2fd2e401 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -1512,7 +1512,7 @@ QDebug operator<<(QDebug debug, const QEasingCurve &item) { QDebugStateSaver saver(debug); debug << "type:" << item.d_ptr->type - << "func:" << item.d_ptr->func; + << "func:" << reinterpret_cast<const void *>(item.d_ptr->func); if (item.d_ptr->config) { debug << QString::fromLatin1("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20) << QString::fromLatin1("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20) diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 967b713096..f882908708 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -88,6 +88,10 @@ class QMainWindowLayoutSeparatorHelper QWidget *window() { return layout()->parentWidget(); } public: + Q_DISABLE_COPY_MOVE(QMainWindowLayoutSeparatorHelper) + + QMainWindowLayoutSeparatorHelper() = default; + QList<int> hoverSeparator; QPoint hoverPos; -- cgit v1.2.3 From 6b835d5e51bafe93090286fa2acb36f3d5d8f719 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Fri, 3 Jan 2020 09:13:34 +0100 Subject: QTextDocument: Set the font family to be after the families set This amends a1f4321bbba2f3bff24d753ce766be738dbfa61a as the font families should take precedence over the font family set. If the font family is already included in the families then it should keep its placement. Otherwise it should be appended. Task-number: QTBUG-80475 Change-Id: I0049189c88b6879e57619815ec780960e9c0a300 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> --- src/gui/text/qtextdocument.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 25c153910d..1353568ec1 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2301,10 +2301,8 @@ static QStringList resolvedFontFamilies(const QTextCharFormat &format) { QStringList fontFamilies = format.fontFamilies().toStringList(); const QString mainFontFamily = format.fontFamily(); - if (!mainFontFamily.isEmpty() && !fontFamilies.startsWith(mainFontFamily)) { - fontFamilies.removeAll(mainFontFamily); - fontFamilies.prepend(mainFontFamily); - } + if (!mainFontFamily.isEmpty() && !fontFamilies.contains(mainFontFamily)) + fontFamilies.append(mainFontFamily); return fontFamilies; } -- cgit v1.2.3 From 6d201aa1bddad04fd4176c526a878ec9cad6f9ab Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Fri, 3 Jan 2020 12:00:10 +0100 Subject: QRegularExpression: make escape-like functions work on QStringView They don't store the strings. [ChangeLog][QtCore][QRegularExpression] The escape(), wildcardToRegularExpression() and anchoredPattern() functions now have overloads taking a QStringView parameter. Change-Id: Icc66ba1201ef1f1064d9565900439e78912b675c Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> --- src/corelib/text/qregularexpression.cpp | 48 +++++++++++++++++++++++++++++---- src/corelib/text/qregularexpression.h | 20 ++++++++------ 2 files changed, 55 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 068c960910..fb8f5a5efc 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 Giuseppe D'Angelo <dangelog@gmail.com>. -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +** Copyright (C) 2020 Giuseppe D'Angelo <dangelog@gmail.com>. +** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** @@ -1829,7 +1829,19 @@ uint qHash(const QRegularExpression &key, uint seed) noexcept return seed; } +#if QT_STRINGVIEW_LEVEL < 2 /*! + \overload +*/ +QString QRegularExpression::escape(const QString &str) +{ + return escape(QStringView(str)); +} +#endif // QT_STRINGVIEW_LEVEL < 2 + +/*! + \since 5.15 + Escapes all characters of \a str so that they no longer have any special meaning when used as a regular expression pattern string, and returns the escaped string. For instance: @@ -1847,7 +1859,7 @@ uint qHash(const QRegularExpression &key, uint seed) noexcept inside \a str is escaped with the sequence \c{"\\0"} (backslash + \c{'0'}), instead of \c{"\\\0"} (backslash + \c{NUL}). */ -QString QRegularExpression::escape(const QString &str) +QString QRegularExpression::escape(QStringView str) { QString result; const int count = str.size(); @@ -1882,8 +1894,19 @@ QString QRegularExpression::escape(const QString &str) return result; } +#if QT_STRINGVIEW_LEVEL < 2 /*! \since 5.12 + \overload +*/ +QString QRegularExpression::wildcardToRegularExpression(const QString &pattern) +{ + return wildcardToRegularExpression(QStringView(pattern)); +} +#endif // QT_STRINGVIEW_LEVEL < 2 + +/*! + \since 5.15 Returns a regular expression representation of the given glob \a pattern. The transformation is targeting file path globbing, which means in particular @@ -1928,13 +1951,13 @@ QString QRegularExpression::escape(const QString &str) \sa escape() */ -QString QRegularExpression::wildcardToRegularExpression(const QString &pattern) +QString QRegularExpression::wildcardToRegularExpression(QStringView pattern) { const int wclen = pattern.length(); QString rx; rx.reserve(wclen + wclen / 16); int i = 0; - const QChar *wc = pattern.unicode(); + const QChar *wc = pattern.data(); #ifdef Q_OS_WIN const QLatin1Char nativePathSeparator('\\'); @@ -2006,16 +2029,31 @@ QString QRegularExpression::wildcardToRegularExpression(const QString &pattern) return anchoredPattern(rx); } +#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QRegularExpression::anchoredPattern(const QString &expression) \since 5.12 + \overload +*/ +#endif // QT_STRINGVIEW_LEVEL < 2 + +/*! + \since 5.15 + Returns the \a expression wrapped between the \c{\A} and \c{\z} anchors to be used for exact matching. \sa {Porting from QRegExp's Exact Matching} */ +QString QRegularExpression::anchoredPattern(QStringView expression) +{ + return QString() + + QLatin1String("\\A(?:") + + expression + + QLatin1String(")\\z"); +} /*! \since 5.1 diff --git a/src/corelib/text/qregularexpression.h b/src/corelib/text/qregularexpression.h index f799a38ae4..4fa258b080 100644 --- a/src/corelib/text/qregularexpression.h +++ b/src/corelib/text/qregularexpression.h @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>. -** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +** Copyright (C) 2020 Giuseppe D'Angelo <dangelog@gmail.com>. +** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -42,9 +42,8 @@ #define QREGULAREXPRESSION_H #include <QtCore/qglobal.h> - #include <QtCore/qstring.h> -#include <QtCore/qstringlist.h> +#include <QtCore/qstringview.h> #include <QtCore/qshareddata.h> #include <QtCore/qvariant.h> @@ -52,7 +51,8 @@ QT_REQUIRE_CONFIG(regularexpression); QT_BEGIN_NAMESPACE -class QStringView; +class QStringList; +class QLatin1String; class QRegularExpressionMatch; class QRegularExpressionMatchIterator; @@ -137,14 +137,18 @@ public: void optimize() const; +#if QT_STRINGVIEW_LEVEL < 2 static QString escape(const QString &str); static QString wildcardToRegularExpression(const QString &str); static inline QString anchoredPattern(const QString &expression) { - return QLatin1String("\\A(?:") - + expression - + QLatin1String(")\\z"); + return anchoredPattern(QStringView(expression)); } +#endif + + static QString escape(QStringView str); + static QString wildcardToRegularExpression(QStringView str); + static QString anchoredPattern(QStringView expression); bool operator==(const QRegularExpression &re) const; inline bool operator!=(const QRegularExpression &re) const { return !operator==(re); } -- cgit v1.2.3 From 908df199d0782d161e83d75dd7a7d9aab29ff9e7 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete <paul.tvete@qt.io> Date: Fri, 13 Dec 2019 14:18:11 +0100 Subject: Add environment variables for customizing Vulkan QT_VULKAN_INSTANCE_EXTENSIONS to specify additional instance extensions. QT_VULKAN_INSTANCE_LAYERS to specify additional instance layers. QT_VULKAN_DEVICE_EXTENSIONS to specify additional device extensions. These will apply to all QVulkanWindows and everything that uses RHI, including Qt Quick with the Vulkan RHI backend. Task-number: QTBUG-80499 Change-Id: I912495affa987d62a9823d55d06d6a8209f6adc6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/rhi/qrhivulkan.cpp | 11 +++++++++++ src/gui/vulkan/qvulkanwindow.cpp | 9 +++++++++ .../vkconvenience/qbasicvulkanplatforminstance.cpp | 16 ++++++++++++++++ 3 files changed, 36 insertions(+) (limited to 'src') diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 21ae142b1d..c540e9fa85 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -501,6 +501,17 @@ bool QRhiVulkan::create(QRhi::Flags flags) } } + QByteArrayList envExtList; + if (qEnvironmentVariableIsSet("QT_VULKAN_DEVICE_EXTENSIONS")) { + envExtList = qgetenv("QT_VULKAN_DEVICE_EXTENSIONS").split(';'); + for (auto ext : requestedDevExts) + envExtList.removeAll(ext); + for (const QByteArray &ext : envExtList) { + if (!ext.isEmpty()) + requestedDevExts.append(ext.constData()); + } + } + VkDeviceCreateInfo devInfo; memset(&devInfo, 0, sizeof(devInfo)); devInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; diff --git a/src/gui/vulkan/qvulkanwindow.cpp b/src/gui/vulkan/qvulkanwindow.cpp index ed73a77683..e211863f21 100644 --- a/src/gui/vulkan/qvulkanwindow.cpp +++ b/src/gui/vulkan/qvulkanwindow.cpp @@ -689,6 +689,15 @@ void QVulkanWindowPrivate::init() QVulkanInfoVector<QVulkanExtension> supportedExtensions = q->supportedDeviceExtensions(); QByteArrayList reqExts = requestedDevExtensions; reqExts.append("VK_KHR_swapchain"); + + QByteArray envExts = qgetenv("QT_VULKAN_DEVICE_EXTENSIONS"); + if (!envExts.isEmpty()) { + QByteArrayList envExtList = envExts.split(';'); + for (auto ext : reqExts) + envExtList.removeAll(ext); + reqExts.append(envExtList); + } + for (const QByteArray &ext : reqExts) { if (supportedExtensions.contains(ext)) devExts.append(ext.constData()); diff --git a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp index 68340a3173..6f6ba58319 100644 --- a/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp +++ b/src/platformsupport/vkconvenience/qbasicvulkanplatforminstance.cpp @@ -214,6 +214,22 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const for (const QByteArray &ext : extraExts) m_enabledExtensions.append(ext); + QByteArray envExts = qgetenv("QT_VULKAN_INSTANCE_EXTENSIONS"); + if (!envExts.isEmpty()) { + QByteArrayList envExtList = envExts.split(';'); + for (auto ext : m_enabledExtensions) + envExtList.removeAll(ext); + m_enabledExtensions.append(envExtList); + } + + QByteArray envLayers = qgetenv("QT_VULKAN_INSTANCE_LAYERS"); + if (!envLayers.isEmpty()) { + QByteArrayList envLayerList = envLayers.split(';'); + for (auto ext : m_enabledLayers) + envLayerList.removeAll(ext); + m_enabledLayers.append(envLayerList); + } + // No clever stuff with QSet and friends: the order for layers matters // and the user-provided order must be kept. for (int i = 0; i < m_enabledLayers.count(); ++i) { -- cgit v1.2.3 From 844ef184e8021237280a45ead04a3ab39cefa657 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete <paul.tvete@qt.io> Date: Tue, 17 Dec 2019 15:15:24 +0100 Subject: RHI: Remove old native texture API Task-number: QTBUG-78570 Change-Id: I8c4850828ac03319ac923a26c2e985883956c286 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/rhi/qrhi.cpp | 44 -------------------------------------- src/gui/rhi/qrhi_p.h | 2 -- src/gui/rhi/qrhid3d11.cpp | 43 +------------------------------------ src/gui/rhi/qrhid3d11_p.h | 5 ----- src/gui/rhi/qrhid3d11_p_p.h | 3 --- src/gui/rhi/qrhigles2.cpp | 41 +---------------------------------- src/gui/rhi/qrhigles2_p.h | 5 ----- src/gui/rhi/qrhigles2_p_p.h | 4 +--- src/gui/rhi/qrhimetal.mm | 43 +------------------------------------ src/gui/rhi/qrhimetal_p.h | 5 ----- src/gui/rhi/qrhimetal_p_p.h | 3 --- src/gui/rhi/qrhinull.cpp | 22 ++----------------- src/gui/rhi/qrhinull_p.h | 4 ---- src/gui/rhi/qrhinull_p_p.h | 3 --- src/gui/rhi/qrhivulkan.cpp | 51 +------------------------------------------- src/gui/rhi/qrhivulkan_p.h | 6 ------ src/gui/rhi/qrhivulkan_p_p.h | 3 --- 17 files changed, 7 insertions(+), 280 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 58f30deb41..00d4df53bd 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2214,20 +2214,6 @@ QRhiResource::Type QRhiTexture::resourceType() const Regardless of the return value, calling release() is always safe. */ -/*! - \return a pointer to a backend-specific QRhiNativeHandles subclass, such as - QRhiVulkanTextureNativeHandles. The returned value is null when exposing - the underlying native resources is not supported by the backend. - - \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, - QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles - */ -// TODO: remove this version once QtQuick has stopped using it -const QRhiNativeHandles *QRhiTexture::nativeHandles() -{ - return nullptr; -} - /*! \return the underlying native resources for this texture. The returned value will be empty if exposing the underlying native resources is not supported by @@ -2240,36 +2226,6 @@ QRhiTexture::NativeTexture QRhiTexture::nativeTexture() return {}; } -/*! - Similar to build() except that no new native textures are created. Instead, - the texture from \a src is used. - - This allows importing an existing native texture object (which must belong - to the same device or sharing context, depending on the graphics API) from - an external graphics engine. - - \note format(), pixelSize(), sampleCount(), and flags() must still be set - correctly. Passing incorrect sizes and other values to QRhi::newTexture() - and then following it with a buildFrom() expecting that the native texture - object alone is sufficient to deduce such values is \b wrong and will lead - to problems. - - \note QRhiTexture does not take ownership of the texture object. release() - does not free the object or any associated memory. - - The opposite of this operation, exposing a QRhiTexture-created native - texture object to a foreign engine, is possible via nativeHandles(). - - \sa QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, - QRhiMetalTextureNativeHandles, QRhiGles2TextureNativeHandles - */ -// TODO: remove this version once QtQuick has stopped using it -bool QRhiTexture::buildFrom(const QRhiNativeHandles *src) -{ - Q_UNUSED(src); - return false; -} - /*! Similar to build() except that no new native textures are created. Instead, the native texture resources specified by \a src is used. diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 44118b2f10..a6c65aac5e 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -780,9 +780,7 @@ public: void setSampleCount(int s) { m_sampleCount = s; } virtual bool build() = 0; - virtual const QRhiNativeHandles *nativeHandles(); virtual NativeTexture nativeTexture(); - virtual bool buildFrom(const QRhiNativeHandles *src); virtual bool buildFrom(NativeTexture src); protected: diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index ba2488bffb..c5923fe411 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -108,17 +108,6 @@ QT_BEGIN_NAMESPACE \c{ID3D11Device *} and \c{ID3D11DeviceContext *}. */ -/*! - \class QRhiD3D11TextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the D3D texture object that is backing a QRhiTexture instance. - - \note The class uses \c{void *} as the type since including the COM-based - \c{d3d11.h} headers is not acceptable here. The actual type is - \c{ID3D11Texture2D *}. - */ - // help mingw with its ancient sdk headers #ifndef DXGI_ADAPTER_FLAG_SOFTWARE #define DXGI_ADAPTER_FLAG_SOFTWARE 2 @@ -2674,8 +2663,6 @@ bool QD3D11Texture::finishBuild() return false; } - nativeHandlesStruct.texture = tex; - generation += 1; return true; } @@ -2741,29 +2728,6 @@ bool QD3D11Texture::build() return true; } -bool QD3D11Texture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiD3D11TextureNativeHandles *h = static_cast<const QRhiD3D11TextureNativeHandles *>(src); - if (!h || !h->texture) - return false; - - if (!prepareBuild()) - return false; - - tex = static_cast<ID3D11Texture2D *>(h->texture); - - if (!finishBuild()) - return false; - - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, int(sampleDesc.Count))); - - owns = false; - QRHI_RES_RHI(QRhiD3D11); - rhiD->registerResource(this); - return true; -} - bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) { auto *srcTex = static_cast<ID3D11Texture2D * const *>(src.object); @@ -2787,14 +2751,9 @@ bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) return true; } -const QRhiNativeHandles *QD3D11Texture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QD3D11Texture::nativeTexture() { - return {&nativeHandlesStruct.texture, 0}; + return {&tex, 0}; } ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) diff --git a/src/gui/rhi/qrhid3d11_p.h b/src/gui/rhi/qrhid3d11_p.h index 5df1843b1e..aba0f37ee7 100644 --- a/src/gui/rhi/qrhid3d11_p.h +++ b/src/gui/rhi/qrhid3d11_p.h @@ -69,11 +69,6 @@ struct Q_GUI_EXPORT QRhiD3D11NativeHandles : public QRhiNativeHandles void *context = nullptr; }; -struct Q_GUI_EXPORT QRhiD3D11TextureNativeHandles : public QRhiNativeHandles -{ - void *texture = nullptr; // ID3D11Texture2D* -}; - QT_END_NAMESPACE #endif diff --git a/src/gui/rhi/qrhid3d11_p_p.h b/src/gui/rhi/qrhid3d11_p_p.h index 8f02c4300b..9ddd2aa797 100644 --- a/src/gui/rhi/qrhid3d11_p_p.h +++ b/src/gui/rhi/qrhid3d11_p_p.h @@ -99,9 +99,7 @@ struct QD3D11Texture : public QRhiTexture ~QD3D11Texture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); @@ -114,7 +112,6 @@ struct QD3D11Texture : public QRhiTexture DXGI_FORMAT dxgiFormat; uint mipLevelCount = 0; DXGI_SAMPLE_DESC sampleDesc; - QRhiD3D11TextureNativeHandles nativeHandlesStruct; ID3D11UnorderedAccessView *perLevelViews[QRhi::MAX_LEVELS]; uint generation = 0; friend class QRhiD3D11; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index ffaccbad71..e63ed11dd4 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -137,13 +137,6 @@ QT_BEGIN_NAMESPACE \brief Holds the OpenGL context used by the QRhi. */ -/*! - \class QRhiGles2TextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the OpenGL texture object that is backing a QRhiTexture instance. - */ - #ifndef GL_BGRA #define GL_BGRA 0x80E1 #endif @@ -3324,7 +3317,6 @@ void QGles2Texture::release() texture = 0; specified = false; - nativeHandlesStruct.texture = 0; QRHI_RES_RHI(QRhiGles2); if (owns) @@ -3483,31 +3475,6 @@ bool QGles2Texture::build() QRHI_PROF_F(newTexture(this, true, mipLevelCount, isCube ? 6 : 1, 1)); owns = true; - nativeHandlesStruct.texture = texture; - - generation += 1; - rhiD->registerResource(this); - return true; -} - -bool QGles2Texture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiGles2TextureNativeHandles *h = static_cast<const QRhiGles2TextureNativeHandles *>(src); - if (!h || !h->texture) - return false; - - if (!prepareBuild()) - return false; - - texture = h->texture; - specified = true; - - QRHI_RES_RHI(QRhiGles2); - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); - - owns = false; - nativeHandlesStruct.texture = texture; generation += 1; rhiD->registerResource(this); @@ -3531,21 +3498,15 @@ bool QGles2Texture::buildFrom(QRhiTexture::NativeTexture src) QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); owns = false; - nativeHandlesStruct.texture = texture; generation += 1; rhiD->registerResource(this); return true; } -const QRhiNativeHandles *QGles2Texture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QGles2Texture::nativeTexture() { - return {&nativeHandlesStruct.texture, 0}; + return {&texture, 0}; } QGles2Sampler::QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, diff --git a/src/gui/rhi/qrhigles2_p.h b/src/gui/rhi/qrhigles2_p.h index 7f7c8b4c40..8d8f0c7396 100644 --- a/src/gui/rhi/qrhigles2_p.h +++ b/src/gui/rhi/qrhigles2_p.h @@ -74,11 +74,6 @@ struct Q_GUI_EXPORT QRhiGles2NativeHandles : public QRhiNativeHandles QOpenGLContext *context = nullptr; }; -struct Q_GUI_EXPORT QRhiGles2TextureNativeHandles : public QRhiNativeHandles -{ - uint texture = 0; -}; - QT_END_NAMESPACE #endif diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index d4f1336c3e..a9b3022612 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -132,9 +132,7 @@ struct QGles2Texture : public QRhiTexture ~QGles2Texture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); @@ -149,7 +147,7 @@ struct QGles2Texture : public QRhiTexture QGles2SamplerData samplerState; bool specified = false; int mipLevelCount = 0; - QRhiGles2TextureNativeHandles nativeHandlesStruct; + enum Access { AccessNone, AccessSample, diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index b6ca40e08b..222bf170dc 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -113,15 +113,6 @@ QT_BEGIN_NAMESPACE \c{id<MTLCommandQueue>}. */ -/*! - \class QRhiMetalTextureNativeHandles - \inmodule QtRhi - \brief Holds the Metal texture object that is backing a QRhiTexture instance. - - \note The class uses \c{void *} as the type since including the Objective C - headers is not acceptable here. The actual type is \c{id<MTLTexture>}. - */ - /*! \class QRhiMetalCommandBufferNativeHandles \inmodule QtRhi @@ -2296,7 +2287,6 @@ void QMetalTexture::release() e.texture.texture = d->owns ? d->tex : nil; d->tex = nil; - nativeHandlesStruct.texture = nullptr; for (int i = 0; i < QMTL_FRAMES_IN_FLIGHT; ++i) { e.texture.stagingBuffers[i] = d->stagingBuf[i]; @@ -2508,7 +2498,6 @@ bool QMetalTexture::build() d->tex.label = [NSString stringWithUTF8String: m_objectName.constData()]; d->owns = true; - nativeHandlesStruct.texture = d->tex; QRHI_PROF; QRHI_PROF_F(newTexture(this, true, mipLevelCount, isCube ? 6 : 1, samples)); @@ -2519,30 +2508,6 @@ bool QMetalTexture::build() return true; } -bool QMetalTexture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiMetalTextureNativeHandles *h = static_cast<const QRhiMetalTextureNativeHandles *>(src); - if (!h || !h->texture) - return false; - - if (!prepareBuild()) - return false; - - d->tex = (id<MTLTexture>) h->texture; - - d->owns = false; - nativeHandlesStruct.texture = d->tex; - - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples)); - - lastActiveFrameSlot = -1; - generation += 1; - QRHI_RES_RHI(QRhiMetal); - rhiD->registerResource(this); - return true; -} - bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) { void * const * tex = (void * const *) src.object; @@ -2555,7 +2520,6 @@ bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) d->tex = (id<MTLTexture>) *tex; d->owns = false; - nativeHandlesStruct.texture = d->tex; QRHI_PROF; QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, samples)); @@ -2567,14 +2531,9 @@ bool QMetalTexture::buildFrom(QRhiTexture::NativeTexture src) return true; } -const QRhiNativeHandles *QMetalTexture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QMetalTexture::nativeTexture() { - return {&nativeHandlesStruct.texture, 0}; + return {&d->tex, 0}; } id<MTLTexture> QMetalTextureData::viewForLevel(int level) diff --git a/src/gui/rhi/qrhimetal_p.h b/src/gui/rhi/qrhimetal_p.h index 094801c58c..17e28b2c0f 100644 --- a/src/gui/rhi/qrhimetal_p.h +++ b/src/gui/rhi/qrhimetal_p.h @@ -64,11 +64,6 @@ struct Q_GUI_EXPORT QRhiMetalNativeHandles : public QRhiNativeHandles void *cmdQueue = nullptr; // id<MTLCommandQueue> }; -struct Q_GUI_EXPORT QRhiMetalTextureNativeHandles : public QRhiNativeHandles -{ - void *texture = nullptr; // id<MTLTexture> -}; - struct Q_GUI_EXPORT QRhiMetalCommandBufferNativeHandles : public QRhiNativeHandles { void *commandBuffer = nullptr; // id<MTLCommandBuffer> diff --git a/src/gui/rhi/qrhimetal_p_p.h b/src/gui/rhi/qrhimetal_p_p.h index 8e655fd98b..71d4325b1a 100644 --- a/src/gui/rhi/qrhimetal_p_p.h +++ b/src/gui/rhi/qrhimetal_p_p.h @@ -100,15 +100,12 @@ struct QMetalTexture : public QRhiTexture ~QMetalTexture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); QMetalTextureData *d; - QRhiMetalTextureNativeHandles nativeHandlesStruct; int mipLevelCount = 0; int samples = 1; uint generation = 0; diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index 80f004e049..ea67f80138 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -67,13 +67,6 @@ QT_BEGIN_NAMESPACE \brief Empty. */ -/*! - \class QRhiNullTextureNativeHandles - \internal - \inmodule QtGui - \brief Empty. - */ - QRhiNull::QRhiNull(QRhiNullInitParams *params) : offscreenCommandBuffer(this) { @@ -638,9 +631,9 @@ bool QNullTexture::build() return true; } -bool QNullTexture::buildFrom(const QRhiNativeHandles *src) +bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src) { - Q_UNUSED(src); + Q_UNUSED(src) QRHI_RES_RHI(QRhiNull); const bool isCube = m_flags.testFlag(CubeMap); const bool hasMipMaps = m_flags.testFlag(MipMapped); @@ -651,17 +644,6 @@ bool QNullTexture::buildFrom(const QRhiNativeHandles *src) return true; } -bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src) -{ - Q_UNUSED(src) - return buildFrom(nullptr); -} - -const QRhiNativeHandles *QNullTexture::nativeHandles() -{ - return &nativeHandlesStruct; -} - QNullSampler::QNullSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v) : QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v) diff --git a/src/gui/rhi/qrhinull_p.h b/src/gui/rhi/qrhinull_p.h index 7d3ce5dbf1..dbf385555d 100644 --- a/src/gui/rhi/qrhinull_p.h +++ b/src/gui/rhi/qrhinull_p.h @@ -60,10 +60,6 @@ struct Q_GUI_EXPORT QRhiNullNativeHandles : public QRhiNativeHandles { }; -struct Q_GUI_EXPORT QRhiNullTextureNativeHandles : public QRhiNativeHandles -{ -}; - QT_END_NAMESPACE #endif diff --git a/src/gui/rhi/qrhinull_p_p.h b/src/gui/rhi/qrhinull_p_p.h index 57c3de0418..f541fd90b8 100644 --- a/src/gui/rhi/qrhinull_p_p.h +++ b/src/gui/rhi/qrhinull_p_p.h @@ -80,11 +80,8 @@ struct QNullTexture : public QRhiTexture ~QNullTexture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; - QRhiNullTextureNativeHandles nativeHandlesStruct; QImage image[QRhi::MAX_LAYERS][QRhi::MAX_LEVELS]; }; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c540e9fa85..c5719b54aa 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -176,21 +176,6 @@ QT_BEGIN_NAMESPACE \note Ownership of the Vulkan objects is never transferred. */ -/*! - \class QRhiVulkanTextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the Vulkan image object that is backing a QRhiTexture. - - Importing and exporting Vulkan image objects that back a QRhiTexture when - running with the Vulkan backend is supported via this class. Ownership of - the Vulkan object is never transferred. - - \note Memory allocation details are not exposed. This is intentional since - memory is typically suballocated from a bigger chunk of VkDeviceMemory, and - exposing the allocator details is not desirable for now. - */ - /*! \class QRhiVulkanCommandBufferNativeHandles \internal @@ -5198,7 +5183,6 @@ void QVkTexture::release() image = VK_NULL_HANDLE; imageView = VK_NULL_HANDLE; imageAlloc = nullptr; - nativeHandlesStruct.image = VK_NULL_HANDLE; QRHI_RES_RHI(QRhiVulkan); rhiD->releaseQueue.append(e); @@ -5283,8 +5267,6 @@ bool QVkTexture::finishBuild() return false; } - nativeHandlesStruct.image = image; - lastActiveFrameSlot = -1; generation += 1; @@ -5356,31 +5338,6 @@ bool QVkTexture::build() return true; } -bool QVkTexture::buildFrom(const QRhiNativeHandles *src) -{ - const QRhiVulkanTextureNativeHandles *h = static_cast<const QRhiVulkanTextureNativeHandles *>(src); - if (!h || !h->image) - return false; - - if (!prepareBuild()) - return false; - - image = h->image; - - if (!finishBuild()) - return false; - - QRHI_PROF; - QRHI_PROF_F(newTexture(this, false, int(mipLevelCount), m_flags.testFlag(CubeMap) ? 6 : 1, samples)); - - usageState.layout = h->layout; - - owns = false; - QRHI_RES_RHI(QRhiVulkan); - rhiD->registerResource(this); - return true; -} - bool QVkTexture::buildFrom(QRhiTexture::NativeTexture src) { auto *img = static_cast<const VkImage*>(src.object); @@ -5406,15 +5363,9 @@ bool QVkTexture::buildFrom(QRhiTexture::NativeTexture src) return true; } -const QRhiNativeHandles *QVkTexture::nativeHandles() -{ - nativeHandlesStruct.layout = usageState.layout; - return &nativeHandlesStruct; -} - QRhiTexture::NativeTexture QVkTexture::nativeTexture() { - return {&nativeHandlesStruct.image, usageState.layout}; + return {&image, usageState.layout}; } VkImageView QVkTexture::imageViewForLevel(int level) diff --git a/src/gui/rhi/qrhivulkan_p.h b/src/gui/rhi/qrhivulkan_p.h index ff19c7a54e..d495919671 100644 --- a/src/gui/rhi/qrhivulkan_p.h +++ b/src/gui/rhi/qrhivulkan_p.h @@ -69,12 +69,6 @@ struct Q_GUI_EXPORT QRhiVulkanNativeHandles : public QRhiNativeHandles void *vmemAllocator = nullptr; }; -struct Q_GUI_EXPORT QRhiVulkanTextureNativeHandles : public QRhiNativeHandles -{ - VkImage image = VK_NULL_HANDLE; - VkImageLayout layout = VK_IMAGE_LAYOUT_GENERAL; -}; - struct Q_GUI_EXPORT QRhiVulkanCommandBufferNativeHandles : public QRhiNativeHandles { VkCommandBuffer commandBuffer = VK_NULL_HANDLE; diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index d1b77870a1..9f18d0bf5e 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -120,9 +120,7 @@ struct QVkTexture : public QRhiTexture ~QVkTexture(); void release() override; bool build() override; - bool buildFrom(const QRhiNativeHandles *src) override; bool buildFrom(NativeTexture src) override; - const QRhiNativeHandles *nativeHandles() override; NativeTexture nativeTexture() override; bool prepareBuild(QSize *adjustedSize = nullptr); @@ -136,7 +134,6 @@ struct QVkTexture : public QRhiTexture QVkAlloc stagingAllocations[QVK_FRAMES_IN_FLIGHT]; VkImageView perLevelImageViews[QRhi::MAX_LEVELS]; bool owns = true; - QRhiVulkanTextureNativeHandles nativeHandlesStruct; struct UsageState { // no tracking of subresource layouts (some operations can keep // subresources in different layouts for some time, but that does not -- cgit v1.2.3 From 82d02b7b95908dec16e41c5af1c63579729c589b Mon Sep 17 00:00:00 2001 From: Sona Kurazyan <sona.kurazyan@qt.io> Date: Thu, 7 Nov 2019 17:26:55 +0100 Subject: Deprecate SAX classes in Qt XML Deprecated the SAX classes and disabled or replaced their uses in tests if applicable. Removed the saxbookmarks example, no point in keeping examples for the deprecated code. [ChangeLog][QtXml] SAX classes are now deprecated. Use QXmlStreamReader, QXmlStreamWriter in QtCore instead. Task-number: QTBUG-76177 Change-Id: Ic171d62fa0527b0f36f94cf09a69586092269957 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io> --- src/xml/dom/qdom.cpp | 37 ++++++++++++++++++++++-- src/xml/dom/qdom.h | 12 ++++++++ src/xml/dom/qdom_p.h | 5 ++++ src/xml/dom/qdomhelpers.cpp | 22 +++++++++++++- src/xml/dom/qdomhelpers_p.h | 23 +++++++++++++++ src/xml/sax/qxml.cpp | 38 ++++++++++++++++++++++++ src/xml/sax/qxml.h | 70 ++++++++++++++++++++++++++++++++++----------- src/xml/sax/qxml_p.h | 9 ++++++ 8 files changed, 196 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index cb753ed573..bbc877eead 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5691,6 +5691,10 @@ void QDomDocumentPrivate::clear() QDomNodePrivate::clear(); } +#if QT_DEPRECATED_SINCE(5, 15) + +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing) { reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing); @@ -5734,6 +5738,9 @@ bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader return true; } +QT_WARNING_POP + +#endif // QT_DEPRECATED_SINCE(5, 15) bool QDomDocumentPrivate::setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn) @@ -6183,8 +6190,11 @@ bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QSt if (!impl) impl = new QDomDocumentPrivate(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QXmlInputSource source; +QT_WARNING_POP source.setData(text); return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn); #else @@ -6252,10 +6262,13 @@ bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing, if (!impl) impl = new QDomDocumentPrivate(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15) QBuffer buf; buf.setData(data); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QXmlInputSource source(&buf); +QT_WARNING_POP return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn); #else QXmlStreamReader streamReader(data); @@ -6275,8 +6288,11 @@ bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString if (!impl) impl = new QDomDocumentPrivate(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QXmlInputSource source(dev); +QT_WARNING_POP return IMPL->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn); #else QXmlStreamReader streamReader(dev); @@ -6285,14 +6301,18 @@ bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString #endif } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete \since 4.5 This function reads the XML document from the QXmlInputSource \a source, returning true if the content was successfully parsed; otherwise returns \c false. */ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn ) { if (!impl) @@ -6301,6 +6321,9 @@ bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, initializeReader(reader, namespaceProcessing); return IMPL->setContent(source, &reader, &reader, errorMsg, errorLine, errorColumn); } +QT_WARNING_POP + +#endif /*! \overload @@ -6333,6 +6356,7 @@ bool QDomDocument::setContent(const QByteArray& buffer, QString *errorMsg, int * /*! \overload + \obsolete This function reads the XML document from the IO device \a dev, returning true if the content was successfully parsed; otherwise returns \c false. @@ -6344,8 +6368,10 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine, return setContent(dev, false, errorMsg, errorLine, errorColumn); } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete This function reads the XML document from the QXmlInputSource \a source and parses it with the QXmlReader \a reader, returning true if the content was @@ -6357,12 +6383,17 @@ bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine, \sa QXmlSimpleReader */ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn ) { if (!impl) impl = new QDomDocumentPrivate(); return IMPL->setContent(source, reader, nullptr, errorMsg, errorLine, errorColumn); } +QT_WARNING_POP + +#endif /*! \overload diff --git a/src/xml/dom/qdom.h b/src/xml/dom/qdom.h index 1b00a14179..d50c5e8394 100644 --- a/src/xml/dom/qdom.h +++ b/src/xml/dom/qdom.h @@ -339,11 +339,23 @@ public: bool setContent(const QByteArray& text, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); bool setContent(const QString& text, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); bool setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + QT_DEPRECATED_X("Use other overloads instead") bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); +QT_WARNING_POP +#endif bool setContent(const QByteArray& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); bool setContent(const QString& text, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); bool setContent(QIODevice* dev, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + QT_DEPRECATED_X("Use other overloads instead") bool setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg=nullptr, int *errorLine=nullptr, int *errorColumn=nullptr ); +QT_WARNING_POP +#endif bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg = nullptr, int *errorLine = nullptr, int *errorColumn = nullptr); diff --git a/src/xml/dom/qdom_p.h b/src/xml/dom/qdom_p.h index b66c756af0..a9399d9901 100644 --- a/src/xml/dom/qdom_p.h +++ b/src/xml/dom/qdom_p.h @@ -461,10 +461,15 @@ public: QDomDocumentPrivate(QDomDocumentPrivate *n, bool deep); ~QDomDocumentPrivate(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn); bool setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader, QString *errorMsg, int *errorLine, int *errorColumn); +QT_WARNING_POP +#endif bool setContent(QXmlStreamReader *reader, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn); diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp index 9399ad3b9b..10e37f7c0f 100644 --- a/src/xml/dom/qdomhelpers.cpp +++ b/src/xml/dom/qdomhelpers.cpp @@ -44,12 +44,15 @@ QT_BEGIN_NAMESPACE +#if QT_DEPRECATED_SINCE(5, 15) + /************************************************************** * * QDomHandler * **************************************************************/ - +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QDomHandler::QDomHandler(QDomDocumentPrivate *adoc, QXmlSimpleReader *areader, bool namespaceProcessing) : cdata(false), reader(areader), domBuilder(adoc, &locator, namespaceProcessing) @@ -160,6 +163,9 @@ QDomBuilder::ErrorInfo QDomHandler::errorInfo() const { return domBuilder.error(); } +QT_WARNING_POP + +#endif // QT_DEPRECATED_SINCE(5, 15) /************************************************************** * @@ -179,10 +185,15 @@ int QDomDocumentLocator::line() const return static_cast<int>(reader->lineNumber()); } +#if QT_DEPRECATED_SINCE(5, 15) + +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void QSAXDocumentLocator::setLocator(QXmlLocator *l) { locator = l; } +QT_WARNING_POP int QSAXDocumentLocator::column() const { @@ -200,6 +211,8 @@ int QSAXDocumentLocator::line() const return static_cast<int>(locator->lineNumber()); } +#endif // QT_DEPRECATED_SINCE(5, 15) + /************************************************************** * * QDomBuilder @@ -234,6 +247,10 @@ bool QDomBuilder::startDTD(const QString &name, const QString &publicId, const Q return true; } +#if QT_DEPRECATED_SINCE(5, 15) + +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED bool QDomBuilder::startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts) { @@ -264,6 +281,9 @@ bool QDomBuilder::startElement(const QString &nsURI, const QString &qName, return true; } +QT_WARNING_POP + +#endif // QT_DEPRECATED_SINCE(5, 15) inline QString stringRefToString(const QStringRef &stringRef) { diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h index f5efd8a42d..4de18f7d4d 100644 --- a/src/xml/dom/qdomhelpers_p.h +++ b/src/xml/dom/qdomhelpers_p.h @@ -93,6 +93,11 @@ private: QXmlStreamReader *reader; }; +#if QT_DEPRECATED_SINCE(5, 15) + +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + class QSAXDocumentLocator : public QXmlDocumentLocator { public: @@ -107,6 +112,10 @@ private: QXmlLocator *locator = nullptr; }; +QT_WARNING_POP + +#endif + /************************************************************** * * QDomBuilder @@ -120,7 +129,12 @@ public: ~QDomBuilder(); bool endDocument(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED bool startElement(const QString &nsURI, const QString &qName, const QXmlAttributes &atts); +QT_WARNING_POP +#endif bool startElement(const QString &nsURI, const QString &qName, const QXmlStreamAttributes &atts); bool endElement(); bool characters(const QString &characters, bool cdata = false); @@ -152,12 +166,17 @@ private: bool nsProcessing; }; +#if QT_DEPRECATED_SINCE(5, 15) + /************************************************************** * * QDomHandler * **************************************************************/ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + class QDomHandler : public QXmlDefaultHandler { public: @@ -205,6 +224,10 @@ private: QDomBuilder domBuilder; }; +QT_WARNING_POP + +#endif // QT_DEPRECATED_SINCE(5, 15) + /************************************************************** * * QDomParser diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 1993073cce..0033d042d4 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -51,6 +51,7 @@ #include "qstack.h" #include <qdebug.h> +#if QT_DEPRECATED_SINCE(5, 15) #ifdef Q_CC_BOR // borland 6 finds bogus warnings when building this file in uic3 # pragma warn -8080 @@ -284,6 +285,7 @@ class QXmlDefaultHandlerPrivate /*! \class QXmlParseException + \obsolete \reentrant \brief The QXmlParseException class is used to report errors with the QXmlErrorHandler interface. @@ -403,6 +405,7 @@ QString QXmlParseException::systemId() const /*! \class QXmlLocator + \obsolete \reentrant \brief The QXmlLocator class provides the XML handler classes with information about the parsing position within a file. @@ -445,6 +448,9 @@ QXmlLocator::~QXmlLocator() number available. */ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + class QXmlSimpleReaderLocator : public QXmlLocator { public: @@ -497,6 +503,7 @@ public: /*! \class QXmlNamespaceSupport + \obsolete \since 4.4 \reentrant \brief The QXmlNamespaceSupport class is a helper class for XML @@ -745,6 +752,7 @@ void QXmlNamespaceSupport::reset() /*! \class QXmlAttributes + \obsolete \reentrant \brief The QXmlAttributes class provides XML attributes. @@ -1028,6 +1036,7 @@ void QXmlAttributes::append(const QString &qName, const QString &uri, const QStr /*! \class QXmlInputSource + \obsolete \reentrant \brief The QXmlInputSource class provides the input data for the QXmlReader subclasses. @@ -1446,6 +1455,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) /*! \class QXmlContentHandler + \obsolete \reentrant \brief The QXmlContentHandler class provides an interface to report the logical content of XML data. @@ -1688,6 +1698,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) /*! \class QXmlErrorHandler + \obsolete \reentrant \brief The QXmlErrorHandler class provides an interface to report errors in XML data. @@ -1763,6 +1774,7 @@ events are reported. /*! \class QXmlDTDHandler + \obsolete \reentrant \brief The QXmlDTDHandler class provides an interface to report DTD content of XML data. @@ -1830,6 +1842,7 @@ events are reported. /*! \class QXmlEntityResolver + \obsolete \reentrant \brief The QXmlEntityResolver class provides an interface to resolve external entities contained in XML data. @@ -1886,6 +1899,7 @@ events are reported. /*! \class QXmlLexicalHandler + \obsolete \reentrant \brief The QXmlLexicalHandler class provides an interface to report the lexical content of XML data. @@ -2037,6 +2051,7 @@ events are reported. /*! \class QXmlDeclHandler + \obsolete \reentrant \brief The QXmlDeclHandler class provides an interface to report declaration content of XML data. @@ -2124,6 +2139,7 @@ events are reported. /*! \class QXmlDefaultHandler + \obsolete \reentrant \brief The QXmlDefaultHandler class provides a default implementation of all the XML handler classes. @@ -2558,6 +2574,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() /*! \class QXmlReader + \obsolete \reentrant \brief The QXmlReader class provides an interface for XML readers (i.e. parsers). @@ -2597,6 +2614,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() setDeclHandler(). The parse itself is started with a call to parse(). + Note that this class is now deprecated, please use QXmlStreamReader or + QDomDocument for reading XML files. + \sa QXmlSimpleReader */ @@ -2783,6 +2803,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() /*! \class QXmlSimpleReader + \obsolete \nonreentrant \brief The QXmlSimpleReader class provides an implementation of a simple XML parser. @@ -2845,6 +2866,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing() QXmlSimpleReader is not reentrant. If you want to use the class in threaded code, lock the code using QXmlSimpleReader with a locking mechanism, such as a QMutex. + + Note that this class is now deprecated, please use QXmlStreamReader or + QDomDocument for reading XML files. */ static inline bool is_S(QChar ch) @@ -5255,7 +5279,10 @@ bool QXmlSimpleReaderPrivate::parsePEReference() } else if (entityRes) { QMap<QString,QXmlSimpleReaderPrivate::ExternParameterEntity>::Iterator it2; it2 = externParameterEntities.find(ref()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QXmlInputSource *ret = nullptr; +QT_WARNING_POP if (it2 != externParameterEntities.end()) { if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) { delete ret; @@ -7610,7 +7637,10 @@ bool QXmlSimpleReaderPrivate::processReference() // Included if validating bool skipIt = true; if (entityRes) { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QXmlInputSource *ret = nullptr; +QT_WARNING_POP if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) { delete ret; reportParseError(entityRes->errorString()); @@ -7850,6 +7880,8 @@ bool QXmlSimpleReaderPrivate::next_eat_ws() This private function initializes the reader. \a i is the input source to read the data from. */ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i) { lineNr = 0; @@ -7870,6 +7902,7 @@ void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i) standalone = QXmlSimpleReaderPrivate::Unknown; error.clear(); } +QT_WARNING_POP /* This private function initializes the XML data related variables. Especially, @@ -7898,6 +7931,8 @@ bool QXmlSimpleReaderPrivate::entityExist(const QString& e) const } } +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void QXmlSimpleReaderPrivate::reportParseError(const QString& error) { this->error = error; @@ -7913,6 +7948,7 @@ void QXmlSimpleReaderPrivate::reportParseError(const QString& error) } } } +QT_WARNING_POP /* This private function is called when a parsing function encounters an @@ -8006,3 +8042,5 @@ void QXmlSimpleReaderPrivate::refAddC(QChar ch) refArray[refArrayPos++] = ch; } QT_END_NAMESPACE + +#endif // QT_DEPRECATED_SINCE(5, 15) diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h index 9be14bd7a9..e19a398ca7 100644 --- a/src/xml/sax/qxml.h +++ b/src/xml/sax/qxml.h @@ -40,6 +40,26 @@ #ifndef QXML_H #define QXML_H +#if 0 +// This is needed because of QTBUG-80347 +#pragma qt_class(QXmlNamespaceSupport) +#pragma qt_class(QXmlAttributes) +#pragma qt_class(QXmlInputSource) +#pragma qt_class(QXmlParseException) +#pragma qt_class(QXmlReader) +#pragma qt_class(QXmlSimpleReader) +#pragma qt_class(QXmlLocator) +#pragma qt_class(QXmlContentHandler) +#pragma qt_class(QXmlErrorHandler) +#pragma qt_class(QXmlDTDHandler) +#pragma qt_class(QXmlEntityResolver) +#pragma qt_class(QXmlLexicalHandler) +#pragma qt_class(QXmlDeclHandler) +#pragma qt_class(QXmlDefaultHandler) +#endif + +#include <QtCore/qglobal.h> + #include <QtXml/qtxmlglobal.h> #include <QtCore/qtextstream.h> #include <QtCore/qfile.h> @@ -48,8 +68,12 @@ #include <QtCore/qlist.h> #include <QtCore/qscopedpointer.h> +#if QT_DEPRECATED_SINCE(5, 15) + QT_BEGIN_NAMESPACE +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED class QXmlNamespaceSupport; class QXmlAttributes; @@ -76,12 +100,11 @@ class QXmlParseExceptionPrivate; class QXmlLocatorPrivate; class QXmlDefaultHandlerPrivate; - // // SAX Namespace Support // -class Q_XML_EXPORT QXmlNamespaceSupport +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlNamespaceSupport { public: QXmlNamespaceSupport(); @@ -112,10 +135,15 @@ private: // SAX Attributes // +// Although deprecated warnings are disabled, the intel icc 18 compiler +// still complains during the instantiation of the templated qSwap() call below +// (with the parameter QXmlAttributes::AttributeList) when QXmlAttributes is +// deprecated. This makes the build fail when warnings are treated as errors. +// To workaround this, deprecated only the constructor. class Q_XML_EXPORT QXmlAttributes { public: - QXmlAttributes(); + QT_DEPRECATED_VERSION(5, 15) QXmlAttributes(); QXmlAttributes(const QXmlAttributes &) = default; QXmlAttributes(QXmlAttributes &&) noexcept = default; QXmlAttributes &operator=(const QXmlAttributes &) = default; @@ -158,6 +186,7 @@ private: QXmlAttributesPrivate *d; }; + Q_DECLARE_TYPEINFO(QXmlAttributes::Attribute, Q_MOVABLE_TYPE); Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlAttributes) @@ -165,7 +194,7 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlAttributes) // SAX Input Source // -class Q_XML_EXPORT QXmlInputSource +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlInputSource { public: QXmlInputSource(); @@ -194,7 +223,7 @@ private: // SAX Exception Classes // -class Q_XML_EXPORT QXmlParseException +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlParseException { public: explicit QXmlParseException(const QString &name = QString(), int c = -1, int l = -1, @@ -217,7 +246,7 @@ private: // XML Reader // -class Q_XML_EXPORT QXmlReader +class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlReader { public: virtual ~QXmlReader() {} @@ -243,7 +272,8 @@ public: virtual bool parse(const QXmlInputSource* input) = 0; }; -class Q_XML_EXPORT QXmlSimpleReader : public QXmlReader +class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlSimpleReader + : public QXmlReader { public: QXmlSimpleReader(); @@ -288,7 +318,7 @@ private: // SAX Locator // -class Q_XML_EXPORT QXmlLocator +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLocator { public: QXmlLocator(); @@ -304,7 +334,7 @@ public: // SAX handler classes // -class Q_XML_EXPORT QXmlContentHandler +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlContentHandler { public: virtual ~QXmlContentHandler() {} @@ -322,7 +352,7 @@ public: virtual QString errorString() const = 0; }; -class Q_XML_EXPORT QXmlErrorHandler +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlErrorHandler { public: virtual ~QXmlErrorHandler() {} @@ -332,7 +362,7 @@ public: virtual QString errorString() const = 0; }; -class Q_XML_EXPORT QXmlDTDHandler +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDTDHandler { public: virtual ~QXmlDTDHandler() {} @@ -341,7 +371,7 @@ public: virtual QString errorString() const = 0; }; -class Q_XML_EXPORT QXmlEntityResolver +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlEntityResolver { public: virtual ~QXmlEntityResolver() {} @@ -349,7 +379,7 @@ public: virtual QString errorString() const = 0; }; -class Q_XML_EXPORT QXmlLexicalHandler +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLexicalHandler { public: virtual ~QXmlLexicalHandler() {} @@ -363,7 +393,7 @@ public: virtual QString errorString() const = 0; }; -class Q_XML_EXPORT QXmlDeclHandler +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDeclHandler { public: virtual ~QXmlDeclHandler() {} @@ -374,8 +404,12 @@ public: // ### Conform to SAX by adding elementDecl }; - -class Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler, public QXmlErrorHandler, public QXmlDTDHandler, public QXmlEntityResolver, public QXmlLexicalHandler, public QXmlDeclHandler +class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler, + public QXmlErrorHandler, + public QXmlDTDHandler, + public QXmlEntityResolver, + public QXmlLexicalHandler, + public QXmlDeclHandler { public: QXmlDefaultHandler(); @@ -426,6 +460,10 @@ private: inline int QXmlAttributes::count() const { return length(); } +QT_WARNING_POP + QT_END_NAMESPACE +#endif // QT_DEPRECATED_SINCE(5, 15) + #endif // QXML_H diff --git a/src/xml/sax/qxml_p.h b/src/xml/sax/qxml_p.h index eb6135db04..1b614dd886 100644 --- a/src/xml/sax/qxml_p.h +++ b/src/xml/sax/qxml_p.h @@ -46,6 +46,8 @@ #include <stack> +#if QT_DEPRECATED_SINCE(5, 15) + QT_BEGIN_NAMESPACE // @@ -59,6 +61,9 @@ QT_BEGIN_NAMESPACE // We mean it. // +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + class QXmlSimpleReaderPrivate { public: @@ -313,6 +318,10 @@ Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::XmlRef, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternParameterEntity, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternEntity, Q_MOVABLE_TYPE); +QT_WARNING_POP + QT_END_NAMESPACE +#endif // QT_DEPRECATED_SINCE(5, 15) + #endif // QXML_P_H -- cgit v1.2.3 From bd4a1b98b813dfbbb4a9db35a380bed8dd5f0ce3 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Mon, 6 Jan 2020 10:50:33 +0100 Subject: eglfs: kms: Query the current mode correctly via the encoder ...not the connector. Passing the connector id to drmModeGetEncoder() is clearly an oversight. Task-number: QTBUG-80976 Change-Id: I80a6088fca558d1637bd01b0aca8c4a8ba3b25f5 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/platformsupport/kmsconvenience/qkmsdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp index b820fafd50..18f7b5e23b 100644 --- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp +++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp @@ -262,7 +262,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources, // Get the current mode on the current crtc drmModeModeInfo crtc_mode; memset(&crtc_mode, 0, sizeof crtc_mode); - if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) { + if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoder_id)) { drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id); drmModeFreeEncoder(encoder); -- cgit v1.2.3 From fd9b0b86bb5f78ffa855409c4dd5976505ef83f5 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@qt.io> Date: Mon, 6 Jan 2020 12:26:43 +0100 Subject: Don't mix QHash and QMultiHash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8a6ec788f995ef2609e971e0a2f330973975657a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/itemmodels/qabstractitemmodel.cpp | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 3be56f5fe6..3bcd81bcdf 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -63,7 +63,7 @@ QPersistentModelIndexData *QPersistentModelIndexData::create(const QModelIndex & Q_ASSERT(index.isValid()); // we will _never_ insert an invalid index in the list QPersistentModelIndexData *d = nullptr; QAbstractItemModel *model = const_cast<QAbstractItemModel *>(index.model()); - QHash<QModelIndex, QPersistentModelIndexData *> &indexes = model->d_func()->persistent.indexes; + QMultiHash<QModelIndex, QPersistentModelIndexData *> &indexes = model->d_func()->persistent.indexes; const auto it = indexes.constFind(index); if (it != indexes.cend()) { d = (*it); @@ -662,8 +662,7 @@ void QAbstractItemModelPrivate::rowsAboutToBeInserted(const QModelIndex &parent, Q_UNUSED(last); QVector<QPersistentModelIndexData *> persistent_moved; if (first < q->rowCount(parent)) { - for (QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it = persistent.indexes.constBegin(); - it != persistent.indexes.constEnd(); ++it) { + for (auto it = persistent.indexes.constBegin(); it != persistent.indexes.constEnd(); ++it) { QPersistentModelIndexData *data = *it; const QModelIndex &index = data->index; if (index.row() >= first && index.isValid() && index.parent() == parent) { @@ -699,14 +698,13 @@ void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent QVector<QPersistentModelIndexData *> persistent_moved_in_source; QVector<QPersistentModelIndexData *> persistent_moved_in_destination; - QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it; - const QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator begin = persistent.indexes.constBegin(); - const QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator end = persistent.indexes.constEnd(); + const auto begin = persistent.indexes.constBegin(); + const auto end = persistent.indexes.constEnd(); const bool sameParent = (srcParent == destinationParent); const bool movingUp = (srcFirst > destinationChild); - for ( it = begin; it != end; ++it) { + for (auto it = begin; it != end; ++it) { QPersistentModelIndexData *data = *it; const QModelIndex &index = data->index; const QModelIndex &parent = index.parent(); @@ -811,8 +809,7 @@ void QAbstractItemModelPrivate::rowsAboutToBeRemoved(const QModelIndex &parent, QVector<QPersistentModelIndexData *> persistent_invalidated; // find the persistent indexes that are affected by the change, either by being in the removed subtree // or by being on the same level and below the removed rows - for (QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it = persistent.indexes.constBegin(); - it != persistent.indexes.constEnd(); ++it) { + for (auto it = persistent.indexes.constBegin(); it != persistent.indexes.constEnd(); ++it) { QPersistentModelIndexData *data = *it; bool level_changed = false; QModelIndex current = data->index; @@ -867,8 +864,7 @@ void QAbstractItemModelPrivate::columnsAboutToBeInserted(const QModelIndex &pare Q_UNUSED(last); QVector<QPersistentModelIndexData *> persistent_moved; if (first < q->columnCount(parent)) { - for (QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it = persistent.indexes.constBegin(); - it != persistent.indexes.constEnd(); ++it) { + for (auto it = persistent.indexes.constBegin(); it != persistent.indexes.constEnd(); ++it) { QPersistentModelIndexData *data = *it; const QModelIndex &index = data->index; if (index.column() >= first && index.isValid() && index.parent() == parent) @@ -904,8 +900,7 @@ void QAbstractItemModelPrivate::columnsAboutToBeRemoved(const QModelIndex &paren QVector<QPersistentModelIndexData *> persistent_invalidated; // find the persistent indexes that are affected by the change, either by being in the removed subtree // or by being on the same level and to the right of the removed columns - for (QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it = persistent.indexes.constBegin(); - it != persistent.indexes.constEnd(); ++it) { + for (auto it = persistent.indexes.constBegin(); it != persistent.indexes.constEnd(); ++it) { QPersistentModelIndexData *data = *it; bool level_changed = false; QModelIndex current = data->index; @@ -3376,8 +3371,7 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const Q_D(const QAbstractItemModel); QModelIndexList result; result.reserve(d->persistent.indexes.count()); - for (QHash<QModelIndex, QPersistentModelIndexData *>::const_iterator it = d->persistent.indexes.constBegin(); - it != d->persistent.indexes.constEnd(); ++it) { + for (auto it = d->persistent.indexes.constBegin(); it != d->persistent.indexes.constEnd(); ++it) { QPersistentModelIndexData *data = *it; result.append(data->index); } @@ -3995,8 +3989,8 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti */ void QAbstractItemModelPrivate::Persistent::insertMultiAtEnd(const QModelIndex& key, QPersistentModelIndexData *data) { - QHash<QModelIndex,QPersistentModelIndexData *>::iterator newIt = indexes.insert(key, data); - QHash<QModelIndex,QPersistentModelIndexData *>::iterator it = newIt; + auto newIt = indexes.insert(key, data); + auto it = newIt; ++it; while (it != indexes.end() && it.key() == key) { qSwap(*newIt,*it); -- cgit v1.2.3 From 1535fc9fb9ddbfce1680979c0634b4fdf8d75fca Mon Sep 17 00:00:00 2001 From: Shawn Rutledge <shawn.rutledge@qt.io> Date: Fri, 20 Dec 2019 15:41:32 +0100 Subject: tablets on xcb: report correct local coordinates to nested windows Change e4532224145a0a72cde9b40cb7fd39011624d1c1 tried to map global position directly from the desktop to the window that should receive the event. That's fine for single-window applications; but media players like OBS and VLC often use embedded windows to play video. So the mapping needs to traverse the window parent hierarchy somehow. In this patch it's done by calling QWindow::mapFromGlobal(), but that only works with integer coordinates (QPoint). To preserve the fix for QTBUG-48151 (and other jitter bugs), we need sub-pixel accuracy; so we have to add back the fractional part after mapping the int part. Fixes: QTBUG-77826 Change-Id: Ib52ce14138e477182e0ef53b0ff30ce1eff40372 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io> --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 4639185416..0a82bbc7a9 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1252,14 +1252,16 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD if (Q_LIKELY(useValuators)) { const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width()); global.setX(value); - local.setX(value - window->handle()->geometry().x()); + // mapFromGlobal is ok for nested/embedded windows, but works only with whole-number QPoint; + // so map it first, then add back the sub-pixel position + local.setX(window->mapFromGlobal(QPoint(int(value), 0)).x() + (value - int(value))); } break; case QXcbAtom::AbsY: if (Q_LIKELY(useValuators)) { qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height()); global.setY(value); - local.setY(value - window->handle()->geometry().y()); + local.setY(window->mapFromGlobal(QPoint(0, int(value))).y() + (value - int(value))); } break; case QXcbAtom::AbsPressure: -- cgit v1.2.3 From 42ecdfe6f3bcbf3e35ca88b24af07249e3936fc7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Date: Mon, 6 Jan 2020 12:33:55 +0100 Subject: Revert "Android: Implement MaximizeUsingFullscreenGeometryHint" This reverts commit c17a5cec1901dd23f4c39ec2ae47a060fbb06895. The patch introduced a call to View.getRootViewInsets() which was introduced in API level 23. We don't want to change the minimum level for Qt 5.x series now, so we will revert the change in 5.15 and reintroduce it in Qt 6, simultaneously setting the minimum API level to 23. Task-number: QTBUG-74202 Change-Id: Ia25bb2cd62287aa80a43bbd294fb757f3f79ff5e Reviewed-by: BogDan Vatra <bogdan@kdab.com> --- .../qtproject/qt5/android/QtActivityDelegate.java | 63 ++++++++------------ .../src/org/qtproject/qt5/android/QtLayout.java | 31 ++-------- .../src/org/qtproject/qt5/android/QtNative.java | 40 +++++-------- .../qtproject/qt5/android/QtServiceDelegate.java | 2 +- src/plugins/platforms/android/androidjniinput.cpp | 4 +- src/plugins/platforms/android/androidjnimain.cpp | 69 +++++++++++++--------- src/plugins/platforms/android/androidjnimain.h | 13 ++-- .../android/qandroidplatformintegration.cpp | 54 +++++++++-------- .../android/qandroidplatformintegration.h | 28 +++++---- .../platforms/android/qandroidplatformscreen.cpp | 11 ++-- .../platforms/android/qandroidplatformwindow.cpp | 32 +++------- .../platforms/android/qandroidplatformwindow.h | 4 +- 12 files changed, 149 insertions(+), 202 deletions(-) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index 0db9441749..2df2ed9a1d 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -121,10 +121,6 @@ public class QtActivityDelegate private static final String EXTRACT_STYLE_KEY = "extract.android.style"; private static final String EXTRACT_STYLE_MINIMAL_KEY = "extract.android.style.option"; - public static final int SYSTEM_UI_VISIBILITY_NORMAL = 0; - public static final int SYSTEM_UI_VISIBILITY_FULLSCREEN = 1; - public static final int SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2; - private static String m_environmentVariables = null; private static String m_applicationParameters = null; @@ -135,7 +131,7 @@ public class QtActivityDelegate private long m_metaState; private int m_lastChar = 0; private int m_softInputMode = 0; - private int m_systemUiVisibility = SYSTEM_UI_VISIBILITY_NORMAL; + private boolean m_fullScreen = false; private boolean m_started = false; private HashMap<Integer, QtSurface> m_surfaces = null; private HashMap<Integer, View> m_nativeViews = null; @@ -157,51 +153,38 @@ public class QtActivityDelegate private CursorHandle m_rightSelectionHandle; private EditPopupMenu m_editPopupMenu; - - public void setSystemUiVisibility(int systemUiVisibility) + public void setFullScreen(boolean enterFullScreen) { - if (m_systemUiVisibility == systemUiVisibility) + if (m_fullScreen == enterFullScreen) return; - m_systemUiVisibility = systemUiVisibility; - - int systemUiVisibilityFlags = 0; - switch (m_systemUiVisibility) { - case SYSTEM_UI_VISIBILITY_NORMAL: - m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE; - break; - case SYSTEM_UI_VISIBILITY_FULLSCREEN: + if (m_fullScreen = enterFullScreen) { m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | View.INVISIBLE; - break; - case SYSTEM_UI_VISIBILITY_TRANSLUCENT: - m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN - | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION - | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); + try { + int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + flags |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE; + flags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + flags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; + flags |= View.SYSTEM_UI_FLAG_FULLSCREEN; + flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").getInt(null); + m_activity.getWindow().getDecorView().setSystemUiVisibility(flags | View.INVISIBLE); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - systemUiVisibilityFlags = View.SYSTEM_UI_FLAG_VISIBLE; - break; - }; - - m_activity.getWindow().getDecorView().setSystemUiVisibility(systemUiVisibilityFlags); - + m_activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); + } m_layout.requestLayout(); } public void updateFullScreen() { - if (m_systemUiVisibility == SYSTEM_UI_VISIBILITY_FULLSCREEN) { - m_systemUiVisibility = SYSTEM_UI_VISIBILITY_NORMAL; - setSystemUiVisibility(SYSTEM_UI_VISIBILITY_FULLSCREEN); + if (m_fullScreen) { + m_fullScreen = false; + setFullScreen(true); } } @@ -960,7 +943,7 @@ public class QtActivityDelegate } catch (Exception e) { e.printStackTrace(); } - outState.putInt("SystemUiVisibility", m_systemUiVisibility); + outState.putBoolean("FullScreen", m_fullScreen); outState.putBoolean("Started", m_started); // It should never } diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java index 63993f81b5..f22b8176c8 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java @@ -46,7 +46,6 @@ import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; -import android.view.WindowInsets; public class QtLayout extends ViewGroup { @@ -70,32 +69,10 @@ public class QtLayout extends ViewGroup @Override protected void onSizeChanged (int w, int h, int oldw, int oldh) { - WindowInsets insets = getRootWindowInsets(); - - DisplayMetrics realMetrics = new DisplayMetrics(); - ((Activity) getContext()).getWindowManager().getDefaultDisplay().getRealMetrics(realMetrics); - - boolean isFullScreenView = h == realMetrics.heightPixels; - - int insetLeft = isFullScreenView ? insets.getSystemWindowInsetLeft() : 0; - int insetTop = isFullScreenView ? insets.getSystemWindowInsetTop() : 0; - int insetRight = isFullScreenView ? insets.getSystemWindowInsetRight() : 0; - int insetBottom = isFullScreenView ? insets.getSystemWindowInsetBottom() : 0; - - int usableAreaWidth = w - insetLeft - insetRight; - int usableAreaHeight = h - insetTop - insetBottom; - - QtNative.setApplicationDisplayMetrics(realMetrics.widthPixels, - realMetrics.heightPixels, - insetLeft, - insetTop, - usableAreaWidth, - usableAreaHeight, - realMetrics.xdpi, - realMetrics.ydpi, - realMetrics.scaledDensity, - realMetrics.density); - + DisplayMetrics metrics = new DisplayMetrics(); + ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); + QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, w, h, + metrics.xdpi, metrics.ydpi, metrics.scaledDensity, metrics.density); if (m_startApplicationRunnable != null) { m_startApplicationRunnable.run(); m_startApplicationRunnable = null; diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index dee5628144..7db16002ff 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -91,10 +91,8 @@ public class QtNative private static boolean m_started = false; private static int m_displayMetricsScreenWidthPixels = 0; private static int m_displayMetricsScreenHeightPixels = 0; - private static int m_displayMetricsAvailableLeftPixels = 0; - private static int m_displayMetricsAvailableTopPixels = 0; - private static int m_displayMetricsAvailableWidthPixels = 0; - private static int m_displayMetricsAvailableHeightPixels = 0; + private static int m_displayMetricsDesktopWidthPixels = 0; + private static int m_displayMetricsDesktopHeightPixels = 0; private static double m_displayMetricsXDpi = .0; private static double m_displayMetricsYDpi = .0; private static double m_displayMetricsScaledDensity = 1.0; @@ -378,10 +376,8 @@ public class QtNative res[0] = startQtAndroidPlugin(qtParams, environment); setDisplayMetrics(m_displayMetricsScreenWidthPixels, m_displayMetricsScreenHeightPixels, - m_displayMetricsAvailableLeftPixels, - m_displayMetricsAvailableTopPixels, - m_displayMetricsAvailableWidthPixels, - m_displayMetricsAvailableHeightPixels, + m_displayMetricsDesktopWidthPixels, + m_displayMetricsDesktopHeightPixels, m_displayMetricsXDpi, m_displayMetricsYDpi, m_displayMetricsScaledDensity, @@ -402,10 +398,8 @@ public class QtNative public static void setApplicationDisplayMetrics(int screenWidthPixels, int screenHeightPixels, - int availableLeftPixels, - int availableTopPixels, - int availableWidthPixels, - int availableHeightPixels, + int desktopWidthPixels, + int desktopHeightPixels, double XDpi, double YDpi, double scaledDensity, @@ -421,10 +415,8 @@ public class QtNative if (m_started) { setDisplayMetrics(screenWidthPixels, screenHeightPixels, - availableLeftPixels, - availableTopPixels, - availableWidthPixels, - availableHeightPixels, + desktopWidthPixels, + desktopHeightPixels, XDpi, YDpi, scaledDensity, @@ -432,10 +424,8 @@ public class QtNative } else { m_displayMetricsScreenWidthPixels = screenWidthPixels; m_displayMetricsScreenHeightPixels = screenHeightPixels; - m_displayMetricsAvailableLeftPixels = availableLeftPixels; - m_displayMetricsAvailableTopPixels = availableTopPixels; - m_displayMetricsAvailableWidthPixels = availableWidthPixels; - m_displayMetricsAvailableHeightPixels = availableHeightPixels; + m_displayMetricsDesktopWidthPixels = desktopWidthPixels; + m_displayMetricsDesktopHeightPixels = desktopHeightPixels; m_displayMetricsXDpi = XDpi; m_displayMetricsYDpi = YDpi; m_displayMetricsScaledDensity = scaledDensity; @@ -696,13 +686,13 @@ public class QtNative }); } - private static void setSystemUiVisibility(final int systemUiVisibility) + private static void setFullScreen(final boolean fullScreen) { runAction(new Runnable() { @Override public void run() { if (m_activityDelegate != null) { - m_activityDelegate.setSystemUiVisibility(systemUiVisibility); + m_activityDelegate.setFullScreen(fullScreen); } updateWindow(); } @@ -1045,10 +1035,8 @@ public class QtNative // screen methods public static native void setDisplayMetrics(int screenWidthPixels, int screenHeightPixels, - int availableLeftPixels, - int availableTopPixels, - int availableWidthPixels, - int availableHeightPixels, + int desktopWidthPixels, + int desktopHeightPixels, double XDpi, double YDpi, double scaledDensity, diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java index 4cceab50c7..33bcb364de 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtServiceDelegate.java @@ -115,7 +115,7 @@ public class QtServiceDelegate QtNative.setService(m_service, this); QtNative.setClassLoader(classLoader); - QtNative.setApplicationDisplayMetrics(10, 10, 0, 0, 10, 10, 120, 120, 1.0, 1.0); + QtNative.setApplicationDisplayMetrics(10, 10, 10, 10, 120, 120, 1.0, 1.0); if (loaderParams.containsKey(STATIC_INIT_CLASSES_KEY)) { for (String className: loaderParams.getStringArray(STATIC_INIT_CLASSES_KEY)) { diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 049f9b0b13..56885f2e23 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -247,8 +247,8 @@ namespace QtAndroidInput break; } - const int dw = availableWidthPixels(); - const int dh = availableHeightPixels(); + const int dw = desktopWidthPixels(); + const int dh = desktopHeightPixels(); QWindowSystemInterface::TouchPoint touchPoint; touchPoint.id = id; touchPoint.pressure = pressure; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index bdbd3517bd..fd2644717e 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -111,8 +111,8 @@ static int m_surfaceId = 1; static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr; -static int m_availableWidthPixels = 0; -static int m_availableHeightPixels = 0; +static int m_desktopWidthPixels = 0; +static int m_desktopHeightPixels = 0; static double m_scaledDensity = 0; static double m_density = 1.0; @@ -155,14 +155,14 @@ namespace QtAndroid : 0; } - int availableWidthPixels() + int desktopWidthPixels() { - return m_availableWidthPixels; + return m_desktopWidthPixels; } - int availableHeightPixels() + int desktopHeightPixels() { - return m_availableHeightPixels; + return m_desktopHeightPixels; } double scaledDensity() @@ -200,9 +200,22 @@ namespace QtAndroid return m_serviceObject; } - void setSystemUiVisibility(SystemUiVisibility uiVisibility) + void showStatusBar() { - QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setSystemUiVisibility", "(I)V", jint(uiVisibility)); + if (m_statusBarShowing) + return; + + QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", false); + m_statusBarShowing = true; + } + + void hideStatusBar() + { + if (!m_statusBarShowing) + return; + + QJNIObjectPrivate::callStaticMethod<void>(m_applicationClass, "setFullScreen", "(Z)V", true); + m_statusBarShowing = false; } jobject createBitmap(QImage img, JNIEnv *env) @@ -607,33 +620,35 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, } static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, - jint screenWidthPixels, jint screenHeightPixels, - jint availableLeftPixels, jint availableTopPixels, - jint availableWidthPixels, jint availableHeightPixels, + jint widthPixels, jint heightPixels, + jint desktopWidthPixels, jint desktopHeightPixels, jdouble xdpi, jdouble ydpi, jdouble scaledDensity, jdouble density) { - m_availableWidthPixels = availableWidthPixels; - m_availableHeightPixels = availableHeightPixels; + // Android does not give us the correct screen size for immersive mode, but + // the surface does have the right size + + widthPixels = qMax(widthPixels, desktopWidthPixels); + heightPixels = qMax(heightPixels, desktopHeightPixels); + + m_desktopWidthPixels = desktopWidthPixels; + m_desktopHeightPixels = desktopHeightPixels; m_scaledDensity = scaledDensity; m_density = density; QMutexLocker lock(&m_platformMutex); if (!m_androidPlatformIntegration) { - QAndroidPlatformIntegration::setDefaultDisplayMetrics(availableLeftPixels, - availableTopPixels, - availableWidthPixels, - availableHeightPixels, - qRound(double(screenWidthPixels) / xdpi * 25.4), - qRound(double(screenHeightPixels) / ydpi * 25.4), - screenWidthPixels, - screenHeightPixels); + QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels, + desktopHeightPixels, + qRound(double(widthPixels) / xdpi * 25.4), + qRound(double(heightPixels) / ydpi * 25.4), + widthPixels, + heightPixels); } else { - m_androidPlatformIntegration->setPhysicalSize(qRound(double(screenWidthPixels) / xdpi * 25.4), - qRound(double(screenHeightPixels) / ydpi * 25.4)); - m_androidPlatformIntegration->setScreenSize(screenWidthPixels, screenHeightPixels); - m_androidPlatformIntegration->setAvailableGeometry(QRect(availableLeftPixels, availableTopPixels, - availableWidthPixels, availableHeightPixels)); + m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4), + qRound(double(heightPixels) / ydpi * 25.4)); + m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels); + m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); } } @@ -759,7 +774,7 @@ static JNINativeMethod methods[] = { {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"waitForServiceSetup", "()V", (void *)waitForServiceSetup}, - {"setDisplayMetrics", "(IIIIIIDDDD)V", (void *)setDisplayMetrics}, + {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"updateWindow", "()V", (void *)updateWindow}, {"updateApplicationState", "(I)V", (void *)updateApplicationState}, diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 63be5910f9..17ae30a1be 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -77,8 +77,8 @@ namespace QtAndroid void bringChildToBack(int surfaceId); QWindow *topLevelWindowAt(const QPoint &globalPos); - int availableWidthPixels(); - int availableHeightPixels(); + int desktopWidthPixels(); + int desktopHeightPixels(); double scaledDensity(); double pixelDensity(); JavaVM *javaVM(); @@ -88,13 +88,8 @@ namespace QtAndroid jobject activity(); jobject service(); - // Keep synchronized with flags in ActivityDelegate.java - enum SystemUiVisibility { - SYSTEM_UI_VISIBILITY_NORMAL = 0, - SYSTEM_UI_VISIBILITY_FULLSCREEN = 1, - SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2 - }; - void setSystemUiVisibility(SystemUiVisibility uiVisibility); + void showStatusBar(); + void hideStatusBar(); jobject createBitmap(QImage img, JNIEnv *env = 0); jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 48f330680b..e0c437be27 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -76,9 +76,12 @@ QT_BEGIN_NAMESPACE -QSize QAndroidPlatformIntegration::m_defaultScreenSize = QSize(320, 455); -QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry = QRect(0, 0, 320, 455); -QSize QAndroidPlatformIntegration::m_defaultPhysicalSize = QSize(50, 71); +int QAndroidPlatformIntegration::m_defaultGeometryWidth = 320; +int QAndroidPlatformIntegration::m_defaultGeometryHeight = 455; +int QAndroidPlatformIntegration::m_defaultScreenWidth = 320; +int QAndroidPlatformIntegration::m_defaultScreenHeight = 455; +int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth = 50; +int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; @@ -171,9 +174,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen = new QAndroidPlatformScreen(); QWindowSystemInterface::handleScreenAdded(m_primaryScreen); - m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); - m_primaryScreen->setSize(m_defaultScreenSize); - m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); + m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); + m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); + m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); m_mainThread = QThread::currentThread(); @@ -263,7 +266,6 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity(); case RasterGLSurface: return QtAndroid::activity(); case TopStackedNativeChildWindows: return false; - case MaximizeUsingFullscreenGeometry: return true; default: return QPlatformIntegration::hasCapability(cap); } @@ -413,19 +415,20 @@ QPlatformTheme *QAndroidPlatformIntegration::createPlatformTheme(const QString & return 0; } -void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int availableLeft, - int availableTop, - int availableWidth, - int availableHeight, - int physicalWidth, - int physicalHeight, - int screenWidth, - int screenHeight) +void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int screenWidth, int screenHeight) { - m_defaultAvailableGeometry = QRect(availableLeft, availableTop, - availableWidth, availableHeight); - m_defaultPhysicalSize = QSize(physicalWidth, physicalHeight); - m_defaultScreenSize = QSize(screenWidth, screenHeight); + m_defaultGeometryWidth = gw; + m_defaultGeometryHeight = gh; + m_defaultPhysicalSizeWidth = sw; + m_defaultPhysicalSizeHeight = sh; + m_defaultScreenWidth = screenWidth; + m_defaultScreenHeight = screenHeight; +} + +void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh) +{ + m_defaultGeometryWidth = gw; + m_defaultGeometryHeight = gh; } void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation, @@ -437,9 +440,10 @@ void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation cur void QAndroidPlatformIntegration::flushPendingUpdates() { - m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); - m_primaryScreen->setSize(m_defaultScreenSize); - m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); + m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, + m_defaultPhysicalSizeHeight)); + m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); + m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); } #ifndef QT_NO_ACCESSIBILITY @@ -449,13 +453,13 @@ QPlatformAccessibility *QAndroidPlatformIntegration::accessibility() const } #endif -void QAndroidPlatformIntegration::setAvailableGeometry(const QRect &availableGeometry) +void QAndroidPlatformIntegration::setDesktopSize(int width, int height) { if (m_primaryScreen) - QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, availableGeometry)); + QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height))); } -void QAndroidPlatformIntegration::setPhysicalSize(int width, int height) +void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height) { if (m_primaryScreen) QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height))); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index d607ec0064..c795c499bc 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -91,8 +91,8 @@ public: QAndroidPlatformScreen *screen() { return m_primaryScreen; } QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; - void setAvailableGeometry(const QRect &availableGeometry); - void setPhysicalSize(int width, int height); + virtual void setDesktopSize(int width, int height); + virtual void setDisplayMetrics(int width, int height); void setScreenSize(int width, int height); bool isVirtualDesktop() { return true; } @@ -116,17 +116,16 @@ public: QStringList themeNames() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; - static void setDefaultDisplayMetrics(int availableLeft, - int availableTop, - int availableWidth, - int availableHeight, - int physicalWidth, - int physicalHeight, - int screenWidth, - int screenHeight); + static void setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int width, int height); + static void setDefaultDesktopSize(int gw, int gh); static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, Qt::ScreenOrientation nativeOrientation); + static QSize defaultDesktopSize() + { + return QSize(m_defaultGeometryWidth, m_defaultGeometryHeight); + } + QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } @@ -144,9 +143,12 @@ private: QThread *m_mainThread; - static QRect m_defaultAvailableGeometry; - static QSize m_defaultPhysicalSize; - static QSize m_defaultScreenSize; + static int m_defaultGeometryWidth; + static int m_defaultGeometryHeight; + static int m_defaultPhysicalSizeWidth; + static int m_defaultPhysicalSizeHeight; + static int m_defaultScreenWidth; + static int m_defaultScreenHeight; static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_nativeOrientation; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 5f8486a7a2..80757c2135 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -90,8 +90,8 @@ private: QAndroidPlatformScreen::QAndroidPlatformScreen() : QObject(), QPlatformScreen() { - m_availableGeometry = QAndroidPlatformIntegration::m_defaultAvailableGeometry; - m_size = QAndroidPlatformIntegration::m_defaultScreenSize; + m_availableGeometry = QRect(0, 0, QAndroidPlatformIntegration::m_defaultGeometryWidth, QAndroidPlatformIntegration::m_defaultGeometryHeight); + m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight); // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // is way much faster than 32 if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { @@ -101,7 +101,8 @@ QAndroidPlatformScreen::QAndroidPlatformScreen() m_format = QImage::Format_ARGB32_Premultiplied; m_depth = 32; } - m_physicalSize = QAndroidPlatformIntegration::m_defaultPhysicalSize; + m_physicalSize.setHeight(QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight); + m_physicalSize.setWidth(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth); connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QAndroidPlatformScreen::applicationStateChanged); } @@ -293,7 +294,7 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w) if (w != 0) { QAndroidPlatformWindow *platformWindow = static_cast<QAndroidPlatformWindow *>(w->handle()); if (platformWindow != 0) - platformWindow->updateSystemUiVisibility(); + platformWindow->updateStatusBarVisibility(); } } @@ -333,7 +334,7 @@ void QAndroidPlatformScreen::doRedraw() } QMutexLocker lock(&m_surfaceMutex); if (m_id == -1 && m_rasterSurfaces) { - m_id = QtAndroid::createSurface(this, geometry(), true, m_depth); + m_id = QtAndroid::createSurface(this, m_availableGeometry, true, m_depth); AndroidDeadlockProtector protector; if (!protector.acquire()) return; diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index a88cb9b823..4f691ce112 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -67,39 +67,25 @@ void QAndroidPlatformWindow::lower() void QAndroidPlatformWindow::raise() { - updateSystemUiVisibility(); + updateStatusBarVisibility(); platformScreen()->raise(this); } -QMargins QAndroidPlatformWindow::safeAreaMargins() const -{ - if ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint)) { - QRect availableGeometry = platformScreen()->availableGeometry(); - return QMargins(availableGeometry.left(), availableGeometry.top(), - availableGeometry.right(), availableGeometry.bottom()); - } else { - return QPlatformWindow::safeAreaMargins(); - } -} - void QAndroidPlatformWindow::setGeometry(const QRect &rect) { - QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); } void QAndroidPlatformWindow::setVisible(bool visible) { if (visible) - updateSystemUiVisibility(); + updateStatusBarVisibility(); if (visible) { - if ((m_windowState & Qt::WindowFullScreen) - || ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint))) { + if (m_windowState & Qt::WindowFullScreen) setGeometry(platformScreen()->geometry()); - } else if (m_windowState & Qt::WindowMaximized) { + else if (m_windowState & Qt::WindowMaximized) setGeometry(platformScreen()->availableGeometry()); - } } if (visible) @@ -121,7 +107,7 @@ void QAndroidPlatformWindow::setWindowState(Qt::WindowStates state) m_windowState = state; if (window()->isVisible()) - updateSystemUiVisibility(); + updateStatusBarVisibility(); } void QAndroidPlatformWindow::setWindowFlags(Qt::WindowFlags flags) @@ -157,17 +143,15 @@ void QAndroidPlatformWindow::requestActivateWindow() platformScreen()->topWindowChanged(window()); } -void QAndroidPlatformWindow::updateSystemUiVisibility() +void QAndroidPlatformWindow::updateStatusBarVisibility() { Qt::WindowFlags flags = window()->flags(); bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window; if (!isNonRegularWindow) { if (m_windowState & Qt::WindowFullScreen) - QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_FULLSCREEN); - else if (flags & Qt::MaximizeUsingFullscreenGeometryHint) - QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_TRANSLUCENT); + QtAndroid::hideStatusBar(); else - QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_NORMAL); + QtAndroid::showStatusBar(); } } diff --git a/src/plugins/platforms/android/qandroidplatformwindow.h b/src/plugins/platforms/android/qandroidplatformwindow.h index f83ad7bea3..d8eb6b7b7f 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.h +++ b/src/plugins/platforms/android/qandroidplatformwindow.h @@ -70,11 +70,9 @@ public: QAndroidPlatformScreen *platformScreen() const; - QMargins safeAreaMargins() const override; - void propagateSizeHints() override; void requestActivateWindow() override; - void updateSystemUiVisibility(); + void updateStatusBarVisibility(); inline bool isRaster() const { if (isForeignWindow()) return false; -- cgit v1.2.3 From e52239f525d59f965dbbc5dbe2c28314498690b0 Mon Sep 17 00:00:00 2001 From: BogDan Vatra <bogdan@kde.org> Date: Mon, 6 Jan 2020 16:06:35 +0200 Subject: Use prefixed ssl libs when "-openssl-linked" configure params is used As long as we do a multi abi build in one go there is no easy way for us to know where the ssl libs are located for each ABI. The easiest way is to use libs prefixed with the ABI. For configure set we are using "_arm64-v8a" prefix as the configure script will always use arm64-v8a to run the tests. Don't show the OPENSSL_LIBS example as it won't work on Android. Here https://github.com/KDAB/android_openssl/commit/ebb0b68be4 you can find a script which builds these libs. Fixes: QTBUG-80862 Change-Id: I019c2a208ae48a7356b8f3933d0f4aad5ac156a3 Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/network/configure.json | 6 +++++- src/network/ssl/ssl.pri | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/network/configure.json b/src/network/configure.json index f501465c91..ddf8f4c709 100644 --- a/src/network/configure.json +++ b/src/network/configure.json @@ -93,6 +93,10 @@ "libs": "-llibssl -llibcrypto -lUser32 -lWs2_32 -lAdvapi32 -lCrypt32", "condition": "config.msvc" }, + { + "libs": "-lssl_arm64-v8a -lcrypto_arm64-v8a", + "condition": "config.android" + }, { "libs": "-lssl -lcrypto", "condition": "!config.msvc" @@ -445,7 +449,7 @@ "report": [ { "type": "note", - "condition": "features.openssl-linked && libs.openssl.source != 0 + "condition": "!config.android && features.openssl-linked && libs.openssl.source != 0 && input.openssl.prefix == '' && input.openssl.libs == '' && input.openssl.libs.debug == ''", "message": "When linking against OpenSSL, you can override the default library names through OPENSSL_LIBS. diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 8bb70a2aed..a9b7197aca 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -125,9 +125,11 @@ qtConfig(ssl) { # - libs in <OPENSSL_DIR>\lib\VC\static # - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD" - qtConfig(openssl-linked): \ - QMAKE_USE_FOR_PRIVATE += openssl - else: \ + qtConfig(openssl-linked): { + android { + build_pass: LIBS_PRIVATE += -lssl_$${QT_ARCH} -lcrypto_$${QT_ARCH} + } else: QMAKE_USE_FOR_PRIVATE += openssl + } else: \ QMAKE_USE_FOR_PRIVATE += openssl/nolink win32 { LIBS_PRIVATE += -lcrypt32 -- cgit v1.2.3 From 78d2a04a01dbb989c017843f9d6d1f0c485c0e86 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Mon, 2 Dec 2019 14:05:58 +0100 Subject: QSystemTrayIcon: Fix geometry() to work with scaling enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing call to QHighDpi::fromNativePixels(), retrieving the screen from the menu. Task-number: QTBUG-79248 Change-Id: I9f358c8010615c3f96ed9dc3b6666013ae9a0ed9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/widgets/util/qsystemtrayicon_qpa.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/util/qsystemtrayicon_qpa.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp index c0bf058681..f2b0819132 100644 --- a/src/widgets/util/qsystemtrayicon_qpa.cpp +++ b/src/widgets/util/qsystemtrayicon_qpa.cpp @@ -42,6 +42,7 @@ #include <QtGui/qpa/qplatformsystemtrayicon.h> #include <qpa/qplatformtheme.h> #include <private/qguiapplication_p.h> +#include <private/qhighdpiscaling_p.h> #include <QApplication> #include <QStyle> @@ -75,10 +76,14 @@ void QSystemTrayIconPrivate::remove_sys() QRect QSystemTrayIconPrivate::geometry_sys() const { - if (qpa_sys) - return qpa_sys->geometry(); - else + if (!qpa_sys) return QRect(); + auto screen = QGuiApplication::primaryScreen(); +#if QT_CONFIG(menu) + if (menu) + screen = menu->screen(); +#endif + return QHighDpi::fromNativePixels(qpa_sys->geometry(), screen); } void QSystemTrayIconPrivate::updateIcon_sys() -- cgit v1.2.3 From 24217594581e93b7ec3849fb56e49279c5cd3be2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 2 Jan 2020 11:33:53 +0100 Subject: Restore High DPI scale factors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the default rounding policy to "Round" so that 2 is used for 150% (144DPI) on Windows, as it was in 5.13. Fixes: QTBUG-80934 Change-Id: I0cba986ce6afc9e2737c656000ad854c07844360 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/gui/kernel/qguiapplication.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index d49f349e7a..888ccd8453 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -153,7 +153,7 @@ Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorR // that behavior by disabling rounding by default. Qt::HighDpiScaleFactorRoundingPolicy::PassThrough; #else - Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor; + Qt::HighDpiScaleFactorRoundingPolicy::Round; #endif bool QGuiApplicationPrivate::highDpiScalingUpdated = false; @@ -3554,8 +3554,8 @@ Qt::ApplicationState QGuiApplication::applicationState() environment variable. The QGuiApplication::highDpiScaleFactorRoundingPolicy() accessor will reflect the environment, if set. - The default value is Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor. - On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThough, + The default value is Qt::HighDpiScaleFactorRoundingPolicy::Round. + On Qt for Android the default is Qt::HighDpiScaleFactorRoundingPolicy::PassThrough, which preserves historical behavior from earlier Qt versions. */ void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy) -- cgit v1.2.3 From 5af73cd9db52da287070cede300295b90f7ced67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 7 Jan 2020 13:45:49 +0100 Subject: Skip WA_DontShowOnScreen widgets when checking whether application can quit QApplication tries to close all windows on quit using closeAllWindows, but closeAllWindows skips some windows, in particular any widget with WA_DontShowOnScreen set. QApplication then tries to verify that all windows have been closed, and that logic should skip the same kind of windows as closeAllWindows does. We include WA_DontShowOnScreen so that widgets that are proxied via QGraphicProxyWidget will not prevent the application from quitting. There's still some divergence between closeAllWindows and the logic in QApplication::event's quit handling, but aligning that requires more work than this particular fix, and should probably also be based on using the return value of tryCloseAllWindows() directly. Change-Id: I2555eeee0cb04b8e736109fed57f37150efd1964 Fixes: QTBUG-81107 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/widgets/kernel/qapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index bf3cf090ba..f334cc58f9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1868,7 +1868,7 @@ bool QApplication::event(QEvent *e) closeAllWindows(); for (auto *w : topLevelWidgets()) { if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) && - (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) { + (!(w->windowType() == Qt::Dialog) || !w->parentWidget()) && !w->testAttribute(Qt::WA_DontShowOnScreen)) { e->ignore(); return true; } -- cgit v1.2.3 From f3b3c971cf4d41d8e10c1374e23917e38c537c54 Mon Sep 17 00:00:00 2001 From: Nico Vertriest <nico.vertriest@qt.io> Date: Fri, 3 Jan 2020 16:19:32 +0100 Subject: Doc: Correct link errors Task-number: QTBUG-79824 Change-Id: I05caaccab1efa16bc0a01ce3045a9377f9ef640e Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/testlib/doc/qttestlib.qdocconf | 2 +- src/testlib/doc/src/qttestlib-manual.qdoc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 73310221cf..52e1480295 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -28,7 +28,7 @@ qhp.QtTestLib.subprojects.classes.sortPages = true tagfile = ../../../doc/qttestlib/qttestlib.tags -depends += qtcore qtdoc qtwidgets qtgui qmake qtqmltest +depends += qtcore qtdoc qtwidgets qtgui qmake qtqmltest qtcmake headerdirs += .. diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc index 688cc2f2f6..89edabf3f3 100644 --- a/src/testlib/doc/src/qttestlib-manual.qdoc +++ b/src/testlib/doc/src/qttestlib-manual.qdoc @@ -85,7 +85,7 @@ You can use a Qt Creator wizard to create a project that contains Qt tests and build and run them directly from Qt Creator. For more information, see - \l {Running Autotests}. + \l {Qt Creator: Running Autotests}{Running Autotests}. \section1 Creating a Test @@ -146,7 +146,7 @@ \section2 Building with CMake and CTest - You can use \l {CMake and CTest} to create a test. + You can use \l {Building with CMake and CTest} to create a test. \l{https://cmake.org/cmake/help/latest/manual/ctest.1.html}{CTest} enables you to include or exclude tests based on a regular expression that is matched against the test name. You can further apply the \c LABELS property -- cgit v1.2.3 From 8040f11f1d82cbaa44071fc8c6cf7244022146cf Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 1 Dec 2019 20:15:10 +0100 Subject: SQL: cleanup private classes Cleanup private SQL classes: - use nullptr - use member initialization - adjust style - remove deprecated functions Change-Id: I845f5b1081649fdd40f4f80e1052331806230cf7 Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 6 ----- src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 9 +------ src/sql/kernel/qsqlcachedresult.cpp | 8 ------ src/sql/kernel/qsqlcachedresult_p.h | 9 ++++--- src/sql/kernel/qsqldriver.cpp | 5 ++-- src/sql/kernel/qsqldriver.h | 16 +++++------- src/sql/kernel/qsqldriver_p.h | 17 ++++++------- src/sql/kernel/qsqlresult_p.h | 35 +++++++++++---------------- 8 files changed, 35 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index d735d29fc7..27841d9494 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1683,12 +1683,6 @@ void QPSQLDriver::_q_handleNotification(int) #if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 70400 if (notify->extra) payload = d->isUtf8 ? QString::fromUtf8(notify->extra) : QString::fromLatin1(notify->extra); -#endif -#if QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - emit notification(name); -QT_WARNING_POP #endif QSqlDriver::NotificationSource source = (notify->be_pid == PQbackendPID(d->connection)) ? QSqlDriver::SelfSource : QSqlDriver::OtherSource; emit notification(name, source, payload); diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index 65d3f0a580..5ef76eec21 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -1043,15 +1043,8 @@ QStringList QSQLiteDriver::subscribedToNotifications() const void QSQLiteDriver::handleNotification(const QString &tableName, qint64 rowid) { Q_D(const QSQLiteDriver); - if (d->notificationid.contains(tableName)) { -#if QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - emit notification(tableName); -QT_WARNING_POP -#endif + if (d->notificationid.contains(tableName)) emit notification(tableName, QSqlDriver::UnknownSource, QVariant(rowid)); - } } QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index c335d7d8fe..1e76154f82 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -60,14 +60,6 @@ QT_BEGIN_NAMESPACE static const uint initial_cache_size = 128; -QSqlCachedResultPrivate::QSqlCachedResultPrivate(QSqlCachedResult *q, const QSqlDriver *drv) - : QSqlResultPrivate(q, drv), - rowCacheEnd(0), - colCount(0), - atEnd(false) -{ -} - void QSqlCachedResultPrivate::cleanup() { cache.clear(); diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h index 543a902554..1bca1fd090 100644 --- a/src/sql/kernel/qsqlcachedresult_p.h +++ b/src/sql/kernel/qsqlcachedresult_p.h @@ -101,7 +101,8 @@ class Q_SQL_EXPORT QSqlCachedResultPrivate: public QSqlResultPrivate Q_DECLARE_PUBLIC(QSqlCachedResult) public: - QSqlCachedResultPrivate(QSqlCachedResult *q, const QSqlDriver *drv); + using QSqlResultPrivate::QSqlResultPrivate; + bool canSeek(int i) const; inline int cacheCount() const; void init(int count, bool fo); @@ -110,9 +111,9 @@ public: void revertLast(); QSqlCachedResult::ValueCache cache; - int rowCacheEnd; - int colCount; - bool atEnd; + int rowCacheEnd = 0; + int colCount = 0; + bool atEnd = false; }; QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index fcd3c70a04..adf4421c89 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -51,11 +51,10 @@ QT_BEGIN_NAMESPACE static QString prepareIdentifier(const QString &identifier, QSqlDriver::IdentifierType type, const QSqlDriver *driver) { - Q_ASSERT( driver != nullptr ); + Q_ASSERT(driver != nullptr); QString ret = identifier; - if (!driver->isIdentifierEscaped(identifier, type)) { + if (!driver->isIdentifierEscaped(identifier, type)) ret = driver->escapeIdentifier(identifier, type); - } return ret; } diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h index ca9f7dc51e..31de63be15 100644 --- a/src/sql/kernel/qsqldriver.h +++ b/src/sql/kernel/qsqldriver.h @@ -100,7 +100,7 @@ public: virtual QStringList tables(QSql::TableType tableType) const; virtual QSqlIndex primaryIndex(const QString &tableName) const; virtual QSqlRecord record(const QString &tableName) const; - virtual QString formatValue(const QSqlField& field, bool trimStrings = false) const; + virtual QString formatValue(const QSqlField &field, bool trimStrings = false) const; virtual QString escapeIdentifier(const QString &identifier, IdentifierType type) const; virtual QString sqlStatement(StatementType type, const QString &tableName, @@ -113,12 +113,12 @@ public: virtual void close() = 0; virtual QSqlResult *createResult() const = 0; - virtual bool open(const QString& db, - const QString& user = QString(), - const QString& password = QString(), - const QString& host = QString(), + virtual bool open(const QString &db, + const QString &user = QString(), + const QString &password = QString(), + const QString &host = QString(), int port = -1, - const QString& connOpts = QString()) = 0; + const QString &connOpts = QString()) = 0; virtual bool subscribeToNotification(const QString &name); virtual bool unsubscribeFromNotification(const QString &name); virtual QStringList subscribedToNotifications() const; @@ -135,10 +135,6 @@ public Q_SLOTS: virtual bool cancelQuery(); Q_SIGNALS: -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use the 3-args version of notification() instead.") - void notification(const QString &name); -#endif void notification(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload); protected: diff --git a/src/sql/kernel/qsqldriver_p.h b/src/sql/kernel/qsqldriver_p.h index c8ec961124..614fbf69a1 100644 --- a/src/sql/kernel/qsqldriver_p.h +++ b/src/sql/kernel/qsqldriver_p.h @@ -63,19 +63,16 @@ class QSqlDriverPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QSqlDriver) public: - QSqlDriverPrivate() - : QObjectPrivate(), - isOpen(false), - isOpenError(false), - precisionPolicy(QSql::LowPrecisionDouble), - dbmsType(QSqlDriver::UnknownDbms) - { } + QSqlDriverPrivate(QSqlDriver::DbmsType dbmstype = QSqlDriver::UnknownDbms) + : QObjectPrivate() + , dbmsType(dbmstype) + {} - uint isOpen; - uint isOpenError; QSqlError error; - QSql::NumericalPrecisionPolicy precisionPolicy; + QSql::NumericalPrecisionPolicy precisionPolicy = QSql::LowPrecisionDouble; QSqlDriver::DbmsType dbmsType; + bool isOpen = false; + bool isOpenError = false; }; QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqlresult_p.h b/src/sql/kernel/qsqlresult_p.h index f0816a7fb5..3b9697046d 100644 --- a/src/sql/kernel/qsqlresult_p.h +++ b/src/sql/kernel/qsqlresult_p.h @@ -79,16 +79,9 @@ class Q_SQL_EXPORT QSqlResultPrivate public: QSqlResultPrivate(QSqlResult *q, const QSqlDriver *drv) : q_ptr(q), - sqldriver(const_cast<QSqlDriver*>(drv)), - idx(QSql::BeforeFirstRow), - active(false), - isSel(false), - forwardOnly(false), - precisionPolicy(QSql::LowPrecisionDouble), - bindCount(0), - binds(QSqlResult::PositionalBinding) + sqldriver(const_cast<QSqlDriver *>(drv)) { } - virtual ~QSqlResultPrivate() { } + virtual ~QSqlResultPrivate() = default; void clearValues() { @@ -111,7 +104,7 @@ public: void clear() { clearValues(); - clearIndex();; + clearIndex(); } virtual QString fieldSerial(int) const; @@ -119,27 +112,27 @@ public: QString namedToPositionalBinding(const QString &query); QString holderAt(int index) const; - QSqlResult *q_ptr; + QSqlResult *q_ptr = nullptr; QPointer<QSqlDriver> sqldriver; - int idx; QString sql; - bool active; - bool isSel; QSqlError error; - bool forwardOnly; - QSql::NumericalPrecisionPolicy precisionPolicy; - - int bindCount; - QSqlResult::BindingSyntax binds; QString executedQuery; QHash<int, QSql::ParamType> types; QVector<QVariant> values; - typedef QHash<QString, QVector<int> > IndexMap; + using IndexMap = QHash<QString, QVector<int> >; IndexMap indexes; - typedef QVector<QHolder> QHolderVector; + using QHolderVector = QVector<QHolder>; QHolderVector holders; + + QSqlResult::BindingSyntax binds = QSqlResult::PositionalBinding; + QSql::NumericalPrecisionPolicy precisionPolicy = QSql::LowPrecisionDouble; + int idx = QSql::BeforeFirstRow; + int bindCount = 0; + bool active = false; + bool isSel = false; + bool forwardOnly = false; }; QT_END_NAMESPACE -- cgit v1.2.3 From f2a61f2ce2fa81acb526965d55e5f22d47673b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= <spaz16@wp.pl> Date: Mon, 2 Dec 2019 18:17:35 +0100 Subject: xcb: Propagate size hints when window changes its scaling factor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Properly scale size hints to the new scaling factor. Fixes: QTBUG-80476 Change-Id: I1081c9b01560f7e434f0f1de0199ef3d3cae787c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/xcb/qxcbwindow.cpp | 5 +++++ src/plugins/platforms/xcb/qxcbwindow.h | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 97da420798..cfe048d5c4 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1398,6 +1398,8 @@ void QXcbWindow::propagateSizeHints() } xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints); + + m_sizeHintsScaleFactor = QHighDpiScaling::scaleAndOrigin(screen()).factor; } void QXcbWindow::requestActivateWindow() @@ -1789,6 +1791,9 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * // will make the comparison later. QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); + if (!qFuzzyCompare(QHighDpiScaling::scaleAndOrigin(newScreen).factor, m_sizeHintsScaleFactor)) + propagateSizeHints(); + // Send the synthetic expose event on resize only when the window is shrinked, // because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically. if (!m_oldWindowSize.isEmpty() diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 5de5974ca7..a808437c5a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -280,6 +280,8 @@ protected: QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr; int m_swapInterval = -1; + + qreal m_sizeHintsScaleFactor = 1.0; }; class QXcbForeignWindow : public QXcbWindow -- cgit v1.2.3 From 84bf4d90b7154940486d3c3969a81c259496e830 Mon Sep 17 00:00:00 2001 From: Karsten Heimrich <karsten.heimrich@qt.io> Date: Tue, 7 Jan 2020 14:52:53 +0100 Subject: Fix comile issues with VS 2017 'QTypedArrayData<T>::iterator QVector<T>::insert(int,QItemSelectionRange &&)': cannot convert argument 1 from 'QTypedArrayData<T>::iterator' to 'int' 'bool QVector<QItemSelectionRange>::isValidIterator(QTypedArrayData<T>::const_iterator) const': cannot convert argument 1 from 'QTypedArrayData<T>::iterator' to 'QTypedArrayData<T>::const_iterator' Change-Id: Id43ca5a9cd7b5709d47515ffdab3896feb298087 Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/tools/qvector.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 8d01b7ec12..3e98de41f4 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -508,10 +508,10 @@ inline void QVector<T>::remove(int i, int n) template <typename T> inline void QVector<T>::prepend(const T &t) -{ insert(begin(), 1, t); } +{ insert(0, 1, t); } template <typename T> void QVector<T>::prepend(rvalue_ref t) -{ insert(begin(), std::move(t)); } +{ insert(0, std::move(t)); } template<typename T> inline T QVector<T>::value(int i, const T &defaultValue) const @@ -618,8 +618,8 @@ QVector<T>::insert(int i, rvalue_ref t) template <typename T> typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend) { - Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid"); - Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid"); + Q_ASSERT_X(isValidIterator(const_iterator(abegin)), "QVector::erase", "The specified iterator argument 'abegin' is invalid"); + Q_ASSERT_X(isValidIterator(const_iterator(aend)), "QVector::erase", "The specified iterator argument 'aend' is invalid"); Q_ASSERT(aend >= abegin); // d.begin() so we don't detach just yet -- cgit v1.2.3 From c2687d1e5d26a7e9409bc0e226ebb802011702f9 Mon Sep 17 00:00:00 2001 From: Lorn Potter <lorn.potter@gmail.com> Date: Fri, 3 Jan 2020 13:13:28 +1000 Subject: wasm: futureproof EmscriptenMouseEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Future versions of emscripten will remove the timestamp, so we need to replace this with the current timestamp See https://github.com/emscripten-core/emscripten/commit/a7f058a1e6e4b72b4446a3b36f8e96f9f8f41f2d#diff-9a5d68085dc7db2938b37a2b7b05c1f5 Change-Id: Ieba323ad54933626d90ac7cbae5a2c471c52628e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index ad94ba9c77..a4ec78f27b 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -544,7 +544,7 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode, void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) { - auto timestamp = mouseEvent->timestamp; + auto timestamp = emscripten_date_now(); QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY); QPoint globalPoint = screen()->geometry().topLeft() + targetPoint; @@ -670,7 +670,7 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh QWasmEventTranslator *translator = (QWasmEventTranslator*)userData; Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent); - auto timestamp = mouseEvent.timestamp; + auto timestamp = emscripten_date_now(); QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY); QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint; -- cgit v1.2.3 From c77efa6d3881554b9e593658fff80acbb8b1388d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= <jeanmichael.celerier@gmail.com> Date: Thu, 19 Dec 2019 21:33:10 +0100 Subject: Disable support for RasterOpModes in GL paint engine This leads to crashes for instance when displaying a text cursor in a graphics scene. Change-Id: I1b5c884ddb8325a7f5bdbc6027f0fae13f139a1c Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/opengl/qopenglpaintengine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 47394999c6..6c796776c0 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1330,6 +1330,7 @@ void QOpenGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stop QOpenGL2PaintEngineEx::QOpenGL2PaintEngineEx() : QPaintEngineEx(*(new QOpenGL2PaintEngineExPrivate(this))) { + gccaps &= ~QPaintEngine::RasterOpModes; } QOpenGL2PaintEngineEx::~QOpenGL2PaintEngineEx() -- cgit v1.2.3 From 22942058aa9c83acb809d0d4c6b78d29a3c33e12 Mon Sep 17 00:00:00 2001 From: Nico Vertriest <nico.vertriest@qt.io> Date: Mon, 2 Dec 2019 15:41:51 +0100 Subject: Doc: Correct qdoc compilation errors qtbase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-79824 Change-Id: I4be365d92b1adfde09efd04d088f75c506666a95 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> --- src/testlib/doc/src/qttest-best-practices.qdoc | 2 +- src/widgets/widgets/qdatetimeedit.cpp | 33 +++++++++++++------------- src/widgets/widgets/qtextbrowser.cpp | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc index 952fd3259d..7143e644fd 100644 --- a/src/testlib/doc/src/qttest-best-practices.qdoc +++ b/src/testlib/doc/src/qttest-best-practices.qdoc @@ -270,7 +270,7 @@ When side-effects are unavoidable, ensure that the prior state is restored at the end of the test function, even if the test fails. This commonly requires use of an RAII (resource acquisition is initialization) class - that restores state when the function returns, or a \l cleanup() method. + that restores state when the function returns, or a \c cleanup() method. Do not simply put the restoration code at the end of the test. If part of the test fails, such code will be skipped and the prior state will not be restored. diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index da4aaadc97..64795d7ccb 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -216,7 +216,7 @@ QDateTimeEdit::~QDateTimeEdit() /*! \property QDateTimeEdit::dateTime - \brief the QDateTime that is set in the QDateTimeEdit + \brief The QDateTime that is set in the QDateTimeEdit. When setting this property the timespec of the QDateTimeEdit remains the same and the timespec of the new QDateTime is ignored. @@ -253,7 +253,7 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime) /*! \property QDateTimeEdit::date - \brief the QDate that is set in the widget + \brief The QDate that is set in the widget. By default, this property contains a date that refers to January 1, 2000. @@ -290,7 +290,7 @@ void QDateTimeEdit::setDate(const QDate &date) /*! \property QDateTimeEdit::time - \brief the QTime that is set in the widget + \brief The QTime that is set in the widget. By default, this property contains a time of 00:00:00 and 0 milliseconds. @@ -335,7 +335,8 @@ void QDateTimeEdit::setCalendar(QCalendar calendar) /*! \since 4.4 \property QDateTimeEdit::minimumDateTime - \brief the minimum datetime of the date time edit + + \brief The minimum datetime of the date time edit. Changing this property implicitly updates the \l minimumDate and \l minimumTime properties to the date and time parts of this property, @@ -376,7 +377,7 @@ void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt) \since 4.4 \property QDateTimeEdit::maximumDateTime - \brief the maximum datetime of the date time edit + \brief The maximum datetime of the date time edit. Changing this property implicitly updates the \l maximumDate and \l maximumTime properties to the date and time parts of this property, @@ -444,7 +445,7 @@ void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max) /*! \property QDateTimeEdit::minimumDate - \brief the minimum date of the date time edit + \brief The minimum date of the date time edit. Changing this property updates the date of the \l minimumDateTime property while preserving the \l minimumTime property. When setting this property, @@ -484,7 +485,7 @@ void QDateTimeEdit::clearMinimumDate() /*! \property QDateTimeEdit::maximumDate - \brief the maximum date of the date time edit + \brief The maximum date of the date time edit. Changing this property updates the date of the \l maximumDateTime property while preserving the \l maximumTime property. When setting this property, the @@ -523,7 +524,7 @@ void QDateTimeEdit::clearMaximumDate() /*! \property QDateTimeEdit::minimumTime - \brief the minimum time of the date time edit + \brief The minimum time of the date time edit. Changing this property updates the time of the \l minimumDateTime property while preserving the \l minimumDate and \l maximumDate properties. If those @@ -562,7 +563,7 @@ void QDateTimeEdit::clearMinimumTime() /*! \property QDateTimeEdit::maximumTime - \brief the maximum time of the date time edit + \brief The maximum time of the date time edit. Changing this property updates the time of the \l maximumDateTime property while preserving the \l minimumDate and \l maximumDate properties. If those @@ -665,7 +666,7 @@ void QDateTimeEdit::setTimeRange(const QTime &min, const QTime &max) /*! \property QDateTimeEdit::displayedSections - \brief the currently displayed fields of the date time edit + \brief The currently displayed fields of the date time edit. Returns a bit set of the displayed sections for this format. \a setDisplayFormat(), displayFormat() @@ -680,7 +681,7 @@ QDateTimeEdit::Sections QDateTimeEdit::displayedSections() const /*! \property QDateTimeEdit::currentSection - \brief the current section of the spinbox + \brief The current section of the spinbox. \a setCurrentSection() */ @@ -739,7 +740,7 @@ QDateTimeEdit::Section QDateTimeEdit::sectionAt(int index) const \property QDateTimeEdit::sectionCount - \brief the number of sections displayed. + \brief The number of sections displayed. If the format is 'yyyy/yy/yyyy', sectionCount returns 3 */ @@ -755,7 +756,7 @@ int QDateTimeEdit::sectionCount() const \property QDateTimeEdit::currentSectionIndex - \brief the current section index of the spinbox + \brief The current section index of the spinbox. If the format is 'yyyy/MM/dd', the displayText is '2001/05/21', and the cursorPosition is 5, currentSectionIndex returns 1. If the @@ -879,7 +880,7 @@ QString QDateTimeEdit::sectionText(Section section) const /*! \property QDateTimeEdit::displayFormat - \brief the format used to display the time/date of the date time edit + \brief The format used to display the time/date of the date time edit. This format is described in QDateTime::toString() and QDateTime::fromString() @@ -951,7 +952,7 @@ void QDateTimeEdit::setDisplayFormat(const QString &format) /*! \property QDateTimeEdit::calendarPopup - \brief the current calendar pop-up show mode. + \brief The current calendar pop-up show mode. \since 4.2 The calendar pop-up will be shown upon clicking the arrow button. @@ -983,7 +984,7 @@ void QDateTimeEdit::setCalendarPopup(bool enable) /*! \property QDateTimeEdit::timeSpec - \brief the current timespec used by the date time edit. + \brief The current timespec used by the date time edit. \since 4.4 */ diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 3e49390315..d0ccd435b3 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -823,7 +823,7 @@ void QTextBrowser::setSource(const QUrl &url) /*! Attempts to load the document at the given \a url with the specified \a type. - If \a type is \l {QTextDocument::ResourceType::UnknownResource}{UnknownResource} + If \a type is \l {QTextDocument::UnknownResource}{UnknownResource} (the default), the document type will be detected: that is, if the url ends with an extension of \c{.md}, \c{.mkd} or \c{.markdown}, the document will be loaded via \l QTextDocument::setMarkdown(); otherwise it will be loaded via -- cgit v1.2.3 From c61cedcc5475a77fb94ed12788f61039835f8079 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Fri, 3 Jan 2020 23:06:45 +0100 Subject: GCC: revoke constexpr before 5.0 It's causing build failures on GCC 4.9 due to our code hitting https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57694 (at least since de82d239f814cf2a717bea0defeee3732384e271). Task-number: QTBUG-80997 Change-Id: I80a9d1fcbf26d8c0bf514ddc7bdb86eb7173360f Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> --- src/corelib/global/qcompilerdetection.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 0091cfcb60..1ea4e7d287 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -883,7 +883,6 @@ # define Q_COMPILER_DEFAULT_MEMBERS # define Q_COMPILER_DELETE_MEMBERS /* C++11 features supported in GCC 4.6: */ -# define Q_COMPILER_CONSTEXPR # define Q_COMPILER_NULLPTR # define Q_COMPILER_UNRESTRICTED_UNIONS # define Q_COMPILER_RANGE_FOR @@ -914,7 +913,11 @@ # define Q_COMPILER_REF_QUALIFIERS # endif # endif - /* C++11 features are complete as of GCC 4.8.1 */ +# if Q_CC_GNU >= 500 + /* GCC 4.6 introduces constexpr, but it's bugged (at least) in the whole + * 4.x series, see e.g. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57694 */ +# define Q_COMPILER_CONSTEXPR +# endif # endif # if __cplusplus > 201103L # if Q_CC_GNU >= 409 -- cgit v1.2.3 From 64359ad710756e7cca5ca553521b2aada18fb0fe Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Tue, 7 Jan 2020 16:25:37 -0800 Subject: ucstrncmp: Fix UBSan report of array overflowing The expression "a + offset + N" will eventually calculate an address past the end of a, since we are comparing to end. That's undefined behavior. Instead, calculate end - a and compare that to offset + N. This commit subtracts "a" from both sides of the inequalities and swaps the two sides to make them obey Qt coding style. Testing with GCC 9 (which is the only one I care about) shows the compiler generates the same code. Fixes: QTBUG-81218 Change-Id: Id84da383373844f3a4b0fffd15e7c1ab904daccd Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> --- src/corelib/text/qstring.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 4d83f19db7..b929786255 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -915,7 +915,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l) }; // we're going to read a[0..15] and b[0..15] (32 bytes) - for ( ; a + offset + 16 <= end; offset += 16) { + for ( ; end - a >= offset + 16; offset += 16) { #ifdef __AVX2__ __m256i a_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(a + offset)); __m256i b_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(b + offset)); @@ -939,7 +939,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l) } // we're going to read a[0..7] and b[0..7] (16 bytes) - if (a + offset + 8 <= end) { + if (end - a >= offset + 8) { __m128i a_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset)); __m128i b_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset)); if (isDifferent(a_data, b_data)) @@ -949,7 +949,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l) } // we're going to read a[0..3] and b[0..3] (8 bytes) - if (a + offset + 4 <= end) { + if (end - a >= offset + 4) { __m128i a_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(a + offset)); __m128i b_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(b + offset)); if (isDifferent(a_data, b_data)) @@ -970,7 +970,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l) if (l >= 8) { const QChar *end = a + l; const uint16x8_t mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 }; - while (a + 7 < end) { + while (end - a > 7) { uint16x8_t da = vld1q_u16(reinterpret_cast<const uint16_t *>(a)); uint16x8_t db = vld1q_u16(reinterpret_cast<const uint16_t *>(b)); -- cgit v1.2.3 From 445c1a873fcdc58a7880394b8d7473b7eff43d99 Mon Sep 17 00:00:00 2001 From: Inho Lee <inho.lee@qt.io> Date: Tue, 7 Jan 2020 15:06:37 +0100 Subject: Resolve a build error for ICC 19 This argument name makes an error with "line 302:Type t = Undefined;" Change-Id: I5488ff02ab7c9f9391c17361da5e2aac2727a6a0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/serialization/qcborvalue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index 914103b0a5..dcbe7efc26 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -320,9 +320,9 @@ private: return Type(quint8(st) | SimpleType); } - Q_DECL_CONSTEXPR static bool isTag_helper(Type t) + Q_DECL_CONSTEXPR static bool isTag_helper(Type tt) { - return t == Tag || t >= 0x10000; + return tt == Tag || tt >= 0x10000; } }; Q_DECLARE_SHARED(QCborValue) -- cgit v1.2.3 From 0c37bc11b5f379d442ed3475483d57449b63963d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 20 Dec 2019 17:45:58 +0100 Subject: Share updates to QGuiApplicationPrivate::app_pal via helper function Change-Id: I2f582358efaadcd33b39c52317222322c589423f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> --- src/gui/kernel/qguiapplication.cpp | 19 ++++++++++++++----- src/gui/kernel/qguiapplication_p.h | 2 ++ src/widgets/kernel/qapplication.cpp | 6 +----- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 888ccd8453..bdcea275c3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3293,12 +3293,8 @@ QPalette QGuiApplication::palette() */ void QGuiApplication::setPalette(const QPalette &pal) { - if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) + if (!QGuiApplicationPrivate::setPalette(pal)) return; - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(pal); - else - *QGuiApplicationPrivate::app_pal = pal; QCoreApplication::setAttribute(Qt::AA_SetPalette); @@ -3306,6 +3302,19 @@ void QGuiApplication::setPalette(const QPalette &pal) qGuiApp->d_func()->sendApplicationPaletteChange(); } +bool QGuiApplicationPrivate::setPalette(const QPalette &palette) +{ + if (app_pal && palette.isCopyOf(*app_pal)) + return false; + + if (!app_pal) + app_pal = new QPalette(palette); + else + *app_pal = palette; + + return true; +} + void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { windowGeometrySpecification.applyTo(window); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 26f65b2f16..7454bba0e5 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -323,6 +323,8 @@ public: static void resetCachedDevicePixelRatio(); + static bool setPalette(const QPalette &palette); + protected: virtual void notifyThemeChanged(); virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f334cc58f9..d28a425c43 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1374,12 +1374,8 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* bool all = false; PaletteHash *hash = app_palettes(); if (!className) { - if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal)) + if (!QGuiApplicationPrivate::setPalette(pal)) return; - if (!QApplicationPrivate::app_pal) - QApplicationPrivate::app_pal = new QPalette(pal); - else - *QApplicationPrivate::app_pal = pal; if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal)) QCoreApplication::setAttribute(Qt::AA_SetPalette); -- cgit v1.2.3 From 2a02487ff00341fcc07023b37ec527c2694fa4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 20 Dec 2019 17:51:01 +0100 Subject: Move tracking of widget specific app palettes to QApplicationPrivate Change-Id: I43cc25207026f174e46534baedf08e0c300728d1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 42 ++++++++++++++++++------------------- src/widgets/kernel/qapplication_p.h | 6 +++--- 2 files changed, 23 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index d28a425c43..28575a20f5 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -414,11 +414,9 @@ bool Q_WIDGETS_EXPORT qt_tab_all_widgets() } // ######## move to QApplicationPrivate -// Default application palettes and fonts (per widget type) -Q_GLOBAL_STATIC(PaletteHash, app_palettes) +// Default fonts (per widget type) Q_GLOBAL_STATIC(FontHash, app_fonts) -// Exported accessors for use outside of this file -PaletteHash *qt_app_palettes_hash() { return app_palettes(); } +// Exported accessor for use outside of this file FontHash *qt_app_fonts_hash() { return app_fonts(); } QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus @@ -643,7 +641,8 @@ void QApplicationPrivate::initializeWidgetPaletteHash() QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); if (!platformTheme) return; - app_palettes()->clear(); + + widgetPalettes.clear(); setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton"); setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton"); @@ -802,7 +801,7 @@ QApplication::~QApplication() delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; clearSystemPalette(); - app_palettes()->clear(); + QApplicationPrivate::widgetPalettes.clear(); delete QApplicationPrivate::sys_font; QApplicationPrivate::sys_font = 0; @@ -1315,6 +1314,8 @@ void QApplication::setGlobalStrut(const QSize& strut) QApplicationPrivate::app_strut = strut; } +// Widget specific palettes +QApplicationPrivate::PaletteHash QApplicationPrivate::widgetPalettes; /*! \fn QPalette QApplication::palette(const QWidget* widget) @@ -1329,15 +1330,13 @@ void QApplication::setGlobalStrut(const QSize& strut) */ QPalette QApplication::palette(const QWidget* w) { - typedef PaletteHash::const_iterator PaletteHashConstIt; - - PaletteHash *hash = app_palettes(); - if (w && hash && hash->size()) { - PaletteHashConstIt it = hash->constFind(w->metaObject()->className()); - const PaletteHashConstIt cend = hash->constEnd(); + auto &widgetPalettes = QApplicationPrivate::widgetPalettes; + if (w && !widgetPalettes.isEmpty()) { + auto it = widgetPalettes.constFind(w->metaObject()->className()); + const auto cend = widgetPalettes.constEnd(); if (it != cend) return *it; - for (it = hash->constBegin(); it != cend; ++it) { + for (it = widgetPalettes.constBegin(); it != cend; ++it) { if (w->inherits(it.key())) return it.value(); } @@ -1354,10 +1353,10 @@ QPalette QApplication::palette(const QWidget* w) */ QPalette QApplication::palette(const char *className) { - PaletteHash *hash = app_palettes(); - if (className && hash && hash->size()) { - QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className); - if (it != hash->constEnd()) + auto &widgetPalettes = QApplicationPrivate::widgetPalettes; + if (className && !widgetPalettes.isEmpty()) { + auto it = widgetPalettes.constFind(className); + if (it != widgetPalettes.constEnd()) return *it; } @@ -1372,7 +1371,6 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* QApplicationPrivate::app_style->polish(pal); // NB: non-const reference bool all = false; - PaletteHash *hash = app_palettes(); if (!className) { if (!QGuiApplicationPrivate::setPalette(pal)) return; @@ -1380,13 +1378,13 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal)) QCoreApplication::setAttribute(Qt::AA_SetPalette); - if (hash && hash->size()) { + if (!widgetPalettes.isEmpty()) { all = true; if (clearWidgetPaletteHash) - hash->clear(); + widgetPalettes.clear(); } - } else if (hash) { - hash->insert(className, pal); + } else { + widgetPalettes.insert(className, pal); } if (qApp) diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 79d06ed98c..8751cc772b 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -94,9 +94,6 @@ extern QClipboard *qt_clipboard; typedef QHash<QByteArray, QFont> FontHash; Q_WIDGETS_EXPORT FontHash *qt_app_fonts_hash(); -typedef QHash<QByteArray, QPalette> PaletteHash; -PaletteHash *qt_app_palettes_hash(); - #define QApplicationPrivateBase QGuiApplicationPrivate class Q_WIDGETS_EXPORT QApplicationPrivate : public QApplicationPrivateBase @@ -193,6 +190,9 @@ public: static void initializeWidgetFontHash(); static void setSystemFont(const QFont &font); + using PaletteHash = QHash<QByteArray, QPalette>; + static PaletteHash widgetPalettes; + static QApplicationPrivate *instance() { return self; } #ifdef QT_KEYPAD_NAVIGATION -- cgit v1.2.3 From 7b092b3fe3c9960a2e2866a3b03818fe63bbbac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Fri, 20 Dec 2019 19:09:44 +0100 Subject: Remove clearWidgetPaletteHash argument from setPalette_helper The argument is only used when the application palette is set, (as opposed to setting the palette for a specific widget class), and that code path is only triggered from QApplication::setPalette, which passes 'true' for this argument. Change-Id: I67a1cc3741f6f62653b0f95ff88d28228f9977d4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/widgets/kernel/qapplication.cpp | 9 ++++----- src/widgets/kernel/qapplication_p.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 28575a20f5..ef76265f8b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -633,7 +633,7 @@ static void setPossiblePalette(const QPalette *palette, const char *className) { if (palette == 0) return; - QApplicationPrivate::setPalette_helper(*palette, className, false); + QApplicationPrivate::setPalette_helper(*palette, className); } void QApplicationPrivate::initializeWidgetPaletteHash() @@ -1363,7 +1363,7 @@ QPalette QApplication::palette(const char *className) return QGuiApplication::palette(); } -void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash) +void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className) { QPalette pal = palette; @@ -1380,8 +1380,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* if (!widgetPalettes.isEmpty()) { all = true; - if (clearWidgetPaletteHash) - widgetPalettes.clear(); + widgetPalettes.clear(); } } else { widgetPalettes.insert(className, pal); @@ -1416,7 +1415,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* void QApplication::setPalette(const QPalette &palette, const char* className) { - QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true); + QApplicationPrivate::setPalette_helper(palette, className); } diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 8751cc772b..71f695cc18 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -185,7 +185,7 @@ public: static bool widgetCount; // Coupled with -widgetcount switch static void setSystemPalette(const QPalette &pal); - static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash); + static void setPalette_helper(const QPalette &palette, const char* className); static void initializeWidgetPaletteHash(); static void initializeWidgetFontHash(); static void setSystemFont(const QFont &font); -- cgit v1.2.3 From 1edf8bc46542ad302085b9e957c8c3c31c7db9da Mon Sep 17 00:00:00 2001 From: Andre Hartmann <aha_1980@gmx.de> Date: Sat, 4 Jan 2020 16:03:35 +0100 Subject: QObject: Replace more 0 and NULL with nullptr ... in docs, comments, and warnings. Also adopt some occurrences around there and in the snippets. Change-Id: Icc0aa0868cadd8ec2270dda794bf83cd7ab84160 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> --- .../snippets/code/src_corelib_kernel_qobject.cpp | 16 ++--- src/corelib/kernel/qobject.cpp | 76 +++++++++++----------- 2 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 1966f8195a..43bcc22720 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -71,7 +71,7 @@ QTimer *timer = qobject_cast<QTimer *>(obj); // timer == (QObject *)obj QAbstractButton *button = qobject_cast<QAbstractButton *>(obj); -// button == 0 +// button == nullptr //! [3] @@ -144,7 +144,7 @@ class MyObject : public QObject Q_OBJECT public: - MyObject(QObject *parent = 0); + MyObject(QObject *parent = nullptr); protected: void timerEvent(QTimerEvent *event) override; @@ -322,7 +322,7 @@ QObject::connect: Cannot queue arguments of type 'MyType' //! [26] -disconnect(myObject, 0, 0, 0); +disconnect(myObject, nullptr, nullptr, nullptr); //! [26] @@ -332,7 +332,7 @@ myObject->disconnect(); //! [28] -disconnect(myObject, SIGNAL(mySignal()), 0, 0); +disconnect(myObject, SIGNAL(mySignal()), nullptr, nullptr); //! [28] @@ -342,7 +342,7 @@ myObject->disconnect(SIGNAL(mySignal())); //! [30] -disconnect(myObject, 0, myReceiver, 0); +disconnect(myObject, nullptr, myReceiver, nullptr); //! [30] @@ -391,7 +391,7 @@ class MyClass : public QObject Q_OBJECT public: - MyClass(QObject *parent = 0); + MyClass(QObject *parent = nullptr); ~MyClass(); enum Priority { High, Low, VeryHigh, VeryLow }; @@ -467,7 +467,7 @@ QObject::connect(socket, &QTcpSocket::connected, [=] () { //! [46] //! [47] -disconnect(myObject, &MyObject::mySignal(), 0, 0); +disconnect(myObject, &MyObject::mySignal(), nullptr, nullptr); //! [47] //! [48] @@ -505,7 +505,7 @@ class MyClass : public QWidget Q_OBJECT public: - MyClass(QWidget *parent = 0); + MyClass(QWidget *parent = nullptr); ~MyClass(); bool event(QEvent* ev) override diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index cc50d9ccc7..e2e133ac28 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1185,8 +1185,8 @@ QObjectPrivate::Connection::~Connection() \relates QObject Returns the given \a object cast to type T if the object is of type - T (or of a subclass); otherwise returns 0. If \a object is 0 then - it will also return 0. + T (or of a subclass); otherwise returns \nullptr. If \a object is + \nullptr then it will also return \nullptr. The class T must inherit (directly or indirectly) QObject and be declared with the \l Q_OBJECT macro. @@ -1538,7 +1538,7 @@ QThread *QObject::thread() const the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the \a targetThread, - provided it is non-null: when it is \nullptr, no event processing + provided it is not \nullptr: when it is \nullptr, no event processing for this object or its children can happen, as they are no longer associated with any thread. @@ -2335,7 +2335,7 @@ void QObject::deleteLater() If the same \a sourceText is used in different roles within the same context, an additional identifying string may be passed in - \a disambiguation (0 by default). In Qt 4.4 and earlier, this was + \a disambiguation (\nullptr by default). In Qt 4.4 and earlier, this was the preferred way to pass comments to translators. Example: @@ -2521,7 +2521,7 @@ QObject *QObject::sender() const For signals with default parameters, this function will always return the index with all parameters, regardless of which was used with - connect(). For example, the signal \c {destroyed(QObject *obj = 0)} + connect(). For example, the signal \c {destroyed(QObject *obj = \nullptr)} will have two different indexes (with and without the parameter), but this function will always return the index with a parameter. This does not apply when overloading signals with different parameters. @@ -2662,7 +2662,7 @@ bool QObject::isSignalConnected(const QMetaMethod &signal) const member in the specified class. \list - \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1. + \li If member.mobj is \nullptr then both signalIndex and methodIndex are set to -1. \li If specified member is not a member of obj instance class (or one of its parent classes) then both signalIndex and methodIndex are set to -1. @@ -2799,12 +2799,12 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign const QObject *receiver, const char *method, Qt::ConnectionType type) { - if (sender == 0 || receiver == 0 || signal == 0 || method == 0) { + if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) { qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", - sender ? sender->metaObject()->className() : "(null)", - (signal && *signal) ? signal+1 : "(null)", - receiver ? receiver->metaObject()->className() : "(null)", - (method && *method) ? method+1 : "(null)"); + sender ? sender->metaObject()->className() : "(nullptr)", + (signal && *signal) ? signal+1 : "(nullptr)", + receiver ? receiver->metaObject()->className() : "(nullptr)", + (method && *method) ? method+1 : "(nullptr)"); return QMetaObject::Connection(0); } QByteArray tmp_signal_name; @@ -2937,14 +2937,14 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) { - if (sender == 0 - || receiver == 0 + if (sender == nullptr + || receiver == nullptr || signal.methodType() != QMetaMethod::Signal || method.methodType() == QMetaMethod::Constructor) { qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", - sender ? sender->metaObject()->className() : "(null)", + sender ? sender->metaObject()->className() : "(nullptr)", signal.methodSignature().constData(), - receiver ? receiver->metaObject()->className() : "(null)", + receiver ? receiver->metaObject()->className() : "(nullptr)", method.methodSignature().constData() ); return QMetaObject::Connection(0); } @@ -3046,20 +3046,20 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho \endlist - 0 may be used as a wildcard, meaning "any signal", "any receiving + \nullptr may be used as a wildcard, meaning "any signal", "any receiving object", or "any slot in the receiving object", respectively. The \a sender may never be \nullptr. (You cannot disconnect signals from more than one object in a single call.) - If \a signal is 0, it disconnects \a receiver and \a method from + If \a signal is \nullptr, it disconnects \a receiver and \a method from any signal. If not, only the specified signal is disconnected. - If \a receiver is 0, it disconnects anything connected to \a + If \a receiver is \nullptr, it disconnects anything connected to \a signal. If not, slots in objects other than \a receiver are not disconnected. - If \a method is 0, it disconnects anything that is connected to \a + If \a method is \nullptr, it disconnects anything that is connected to \a receiver. If not, only slots named \a method will be disconnected, and all other slots are left alone. The \a method must be \nullptr if \a receiver is left out, so you cannot disconnect a @@ -3070,8 +3070,8 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho bool QObject::disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) { - if (sender == 0 || (receiver == 0 && method != 0)) { - qWarning("QObject::disconnect: Unexpected null parameter"); + if (sender == nullptr || (receiver == nullptr && method != nullptr)) { + qWarning("QObject::disconnect: Unexpected nullptr parameter"); return false; } @@ -3197,16 +3197,16 @@ bool QObject::disconnect(const QObject *sender, const char *signal, \endlist QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". - In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case - method should also be QMetaMethod(). \a sender parameter should be never 0. + In the same way \nullptr can be used for \a receiver in the meaning "any receiving object". + In this case method should also be QMetaMethod(). \a sender parameter should be never \nullptr. \sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) */ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) { - if (sender == 0 || (receiver == 0 && method.mobj != 0)) { - qWarning("QObject::disconnect: Unexpected null parameter"); + if (sender == nullptr || (receiver == nullptr && method.mobj != nullptr)) { + qWarning("QObject::disconnect: Unexpected nullptr parameter"); return false; } if (signal.mobj) { @@ -3240,7 +3240,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy); QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index); } - // If we are here sender is not null. If signal is not null while signal_index + // If we are here sender is not nullptr. If signal is not nullptr while signal_index // is -1 then this signal is not a member of sender. if (signal.mobj && signal_index == -1) { qWarning("QObject::disconect: signal %s not found on class %s", @@ -3329,7 +3329,7 @@ void QObject::connectNotify(const QMetaMethod &signal) \a signal with a specific signal. If all signals were disconnected from this object (e.g., the - signal argument to disconnect() was 0), disconnectNotify() + signal argument to disconnect() was \nullptr), disconnectNotify() is only called once, and the \a signal will be an invalid QMetaMethod (QMetaMethod::isValid() returns \c false). @@ -4929,7 +4929,7 @@ void qDeleteInEventHandler(QObject *o) \a sender is the sender object \a signal is a pointer to a pointer to a member signal of the sender - \a receiver is the receiver object, may not be null, will be equal to sender when + \a receiver is the receiver object, may not be \nullptr, will be equal to sender when connecting to a static function or a functor \a slot a pointer only used when using Qt::UniqueConnection \a type the Qt::ConnctionType passed as argument to connect @@ -4937,7 +4937,7 @@ void qDeleteInEventHandler(QObject *o) to be used with queued connection must stay valid at least for the whole time of the connection, this function do not take ownership. typically static data. - If null, then the types will be computed when the signal is emit in a queued + If \nullptr, then the types will be computed when the signal is emit in a queued connection from the types from the signature. \a senderMetaObject is the metaobject used to lookup the signal, the signal must be in this metaobject @@ -4948,7 +4948,7 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa const int *types, const QMetaObject *senderMetaObject) { if (!signal) { - qWarning("QObject::connect: invalid null parameter"); + qWarning("QObject::connect: invalid nullptr parameter"); if (slotObj) slotObj->destroyIfLastRef(); return QMetaObject::Connection(); @@ -4988,7 +4988,7 @@ QMetaObject::Connection QObjectPrivate::connectImpl(const QObject *sender, int s : "Unknown"; const char *receiverString = receiver ? receiver->metaObject()->className() : "Unknown"; - qWarning("QObject::connect(%s, %s): invalid null parameter", senderString, receiverString); + qWarning("QObject::connect(%s, %s): invalid nullptr parameter", senderString, receiverString); if (slotObj) slotObj->destroyIfLastRef(); return QMetaObject::Connection(); @@ -5121,20 +5121,20 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) \endlist - 0 may be used as a wildcard, meaning "any signal", "any receiving + \nullptr may be used as a wildcard, meaning "any signal", "any receiving object", or "any slot in the receiving object", respectively. The \a sender may never be \nullptr. (You cannot disconnect signals from more than one object in a single call.) - If \a signal is 0, it disconnects \a receiver and \a method from + If \a signal is \nullptr, it disconnects \a receiver and \a method from any signal. If not, only the specified signal is disconnected. - If \a receiver is 0, it disconnects anything connected to \a + If \a receiver is \nullptr, it disconnects anything connected to \a signal. If not, slots in objects other than \a receiver are not disconnected. - If \a method is 0, it disconnects anything that is connected to \a + If \a method is \nullptr, it disconnects anything that is connected to \a receiver. If not, only slots named \a method will be disconnected, and all other slots are left alone. The \a method must be \nullptr if \a receiver is left out, so you cannot disconnect a @@ -5150,8 +5150,8 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject) { - if (sender == 0 || (receiver == 0 && slot != 0)) { - qWarning("QObject::disconnect: Unexpected null parameter"); + if (sender == nullptr || (receiver == nullptr && slot != nullptr)) { + qWarning("QObject::disconnect: Unexpected nullptr parameter"); return false; } @@ -5182,7 +5182,7 @@ bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type) { if (!sender) { - qWarning("QObject::connect: invalid null parameter"); + qWarning("QObject::connect: invalid nullptr parameter"); if (slotObj) slotObj->destroyIfLastRef(); return QMetaObject::Connection(); -- cgit v1.2.3 From 3b54009b13e9629b75827a59f8537451d25613a4 Mon Sep 17 00:00:00 2001 From: BogDan Vatra <bogdan@kde.org> Date: Tue, 3 Dec 2019 10:35:44 +0200 Subject: AAB files can be signed only with jarsigner tool Fixes: QTBUG-80406 Change-Id: I04b99477c744e7dd729a791c81194b90c4ec658a Reviewed-by: Andy Shaw <andy.shaw@qt.io> --- src/tools/androiddeployqt/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 6fd32c2d29..d993518665 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -416,6 +416,7 @@ Options parseOptions() } else if (argument.compare(QLatin1String("--aab"), Qt::CaseInsensitive) == 0) { options.buildAAB = true; options.build = true; + options.jarSigner = true; } else if (options.buildAAB && argument.compare(QLatin1String("--no-build"), Qt::CaseInsensitive) == 0) { options.build = false; } else if (argument.compare(QLatin1String("--install"), Qt::CaseInsensitive) == 0) { -- cgit v1.2.3 From 34e467b481059b275d919b057d847b7dd1917f57 Mon Sep 17 00:00:00 2001 From: Lars Schmertmann <Lars.Schmertmann@governikus.de> Date: Fri, 6 Dec 2019 07:52:05 +0100 Subject: Remove dead code to fix a lint warning Obsolete SDK_INT Version Check ------------------------------ This check flags version checks that are not necessary, because the minSdkVersion (or surrounding known API level) is already at least as high as the version checked for. The mindSdkVersion in templates/AndroidManifest.xml is 21 for Qt 5.14 and androiddeployqt also ensures that the minSdkVersion is not below 21. Change-Id: I452de5b152f572efc69e6b292a8b15dbbfba639b Reviewed-by: BogDan Vatra <bogdan@kdab.com> (cherry picked from commit b8e404f6d0631e04d30a864dc68b0574bfca90f1) --- .../qt5/android/bindings/QtActivityLoader.java | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src') diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java index 6beb5e3161..fad9588425 100644 --- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java +++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivityLoader.java @@ -132,23 +132,6 @@ public class QtActivityLoader extends QtLoader { return; } - if (Build.VERSION.SDK_INT < 21) { - // fatal error, show the error and quit - AlertDialog errorDialog = new AlertDialog.Builder(m_activity).create(); - if (m_contextInfo.metaData.containsKey("android.app.unsupported_android_version")) - errorDialog.setMessage(m_contextInfo.metaData.getString("android.app.unsupported_android_version")); - else - errorDialog.setMessage("Unsupported Android version."); - errorDialog.setButton(m_activity.getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }); - errorDialog.show(); - return; - } - try { m_activity.setTheme(Class.forName("android.R$style").getDeclaredField(QT_ANDROID_DEFAULT_THEME).getInt(null)); } catch (Exception e) { -- cgit v1.2.3 From 2385ab73be79e5eb69b4feb3d4c787060a56da5f Mon Sep 17 00:00:00 2001 From: Samuli Piippo <samuli.piippo@qt.io> Date: Tue, 7 Jan 2020 13:52:11 +0200 Subject: QInputDeviceManager: initialize device counts The device counts were used before they were initialized, causing problems e.g. with mouse cursor. Fixes: QTBUG-81207 Change-Id: Ic9dadcaebeb4c4a64bb506e4236d5a9260e0fdbc Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/gui/kernel/qinputdevicemanager_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index 871f9315c3..82a86446a0 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -69,7 +69,7 @@ public: int deviceCount(QInputDeviceManager::DeviceType type) const; void setDeviceCount(QInputDeviceManager::DeviceType type, int count); - std::array<int, QInputDeviceManager::NumDeviceTypes> m_deviceCount; + std::array<int, QInputDeviceManager::NumDeviceTypes> m_deviceCount = {}; Qt::KeyboardModifiers keyboardModifiers; }; -- cgit v1.2.3 From 6f1ae59ee6b82123f073fc8fd0ed6d010818041e Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Mon, 6 Jan 2020 13:25:30 +0100 Subject: Change getMacLocaleName() to return a QString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Returning a QByteArray required doing a toUtf8() to a QString on one of its paths, which was promptly undone by its caller using fromUTf8(), since a QString was needed anyway. Drive-by - remove spurious default for parameter in method definition. Change-Id: I45f553d74cd0ba9dab25c439ba8291c00b7ceb5b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qlocale_mac.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm index 9719278426..31ede1352b 100644 --- a/src/corelib/text/qlocale_mac.mm +++ b/src/corelib/text/qlocale_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -67,16 +67,16 @@ static QByteArray envVarLocale() return lang; } -static QByteArray getMacLocaleName() +static QString getMacLocaleName() { - QByteArray result = envVarLocale(); + QString result = QString::fromLocal8Bit(envVarLocale()); QString lang, script, cntry; if (result.isEmpty() - || (result != "C" && !qt_splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry))) { + || (result != QLatin1String("C") && !qt_splitLocaleName(result, lang, script, cntry))) { QCFType<CFLocaleRef> l = CFLocaleCopyCurrent(); CFStringRef locale = CFLocaleGetIdentifier(l); - result = QString::fromCFString(locale).toUtf8(); + result = QString::fromCFString(locale); } return result; } @@ -402,10 +402,10 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef & QLocale QSystemLocale::fallbackUiLocale() const { - return QLocale(QString::fromUtf8(getMacLocaleName().constData())); + return QLocale(getMacLocaleName()); } -QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const +QVariant QSystemLocale::query(QueryType type, QVariant in) const { QMacAutoReleasePool pool; switch(type) { -- cgit v1.2.3 From 6224130cc821b0ef0dbdda80837e872c7996b916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= <pasi.petajajarvi@qt.io> Date: Thu, 19 Dec 2019 13:01:21 +0200 Subject: Add touch input device mapping support via QT_QPA_EGLFS_KMS_CONFIG To be feature parity with evdev touch which already supports this Change-Id: Ie7f9c868ea888725b24c3855106e1c0c0ba943a9 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- .../input/libinput/qlibinputtouch.cpp | 40 +++++++++++++++++++--- .../input/libinput/qlibinputtouch_p.h | 7 +++- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index ad85360b0e..e1abd44eb5 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qlibinputtouch_p.h" +#include "qtouchoutputmapping_p.h" #include <libinput.h> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> @@ -45,6 +46,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(qLcLibInput) + QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t slot) { const int id = qMax(0, slot); @@ -62,12 +65,23 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e return &m_devState[dev]; } -static inline QPointF getPos(libinput_event_touch *e) +QPointF QLibInputTouch::getPos(libinput_event_touch *e) { - // TODO Map to correct screen using QTouchOutputMapping. - // Perhaps investigate libinput_device_get_output_name as well. - // For now just use the primary screen. + DeviceState *state = deviceState(e); QScreen *screen = QGuiApplication::primaryScreen(); + if (!state->m_screenName.isEmpty()) { + if (!m_screen) { + const QList<QScreen *> screens = QGuiApplication::screens(); + for (QScreen *s : screens) { + if (s->name() == state->m_screenName) { + m_screen = s; + break; + } + } + } + if (m_screen) + screen = m_screen; + } const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen); const double x = libinput_event_touch_get_x_transformed(e, geom.width()); const double y = libinput_event_touch_get_y_transformed(e, geom.height()); @@ -76,9 +90,25 @@ static inline QPointF getPos(libinput_event_touch *e) void QLibInputTouch::registerDevice(libinput_device *dev) { + struct udev_device *udev_device; + udev_device = libinput_device_get_udev_device(dev); + QString devNode = QString::fromUtf8(udev_device_get_devnode(udev_device)); + QString devName = QString::fromUtf8(libinput_device_get_name(dev)); + + qCDebug(qLcLibInput, "libinput: registerDevice %s - %s", + qPrintable(devNode), qPrintable(devName)); + + QTouchOutputMapping mapping; + if (mapping.load()) { + m_devState[dev].m_screenName = mapping.screenNameForDeviceNode(devNode); + if (!m_devState[dev].m_screenName.isEmpty()) + qCDebug(qLcLibInput, "libinput: Mapping device %s to screen %s", + qPrintable(devNode), qPrintable(m_devState[dev].m_screenName)); + } + QTouchDevice *&td = m_devState[dev].m_touchDevice; td = new QTouchDevice; - td->setName(QString::fromUtf8(libinput_device_get_name(dev))); + td->setName(devName); td->setType(QTouchDevice::TouchScreen); td->setCapabilities(QTouchDevice::Position | QTouchDevice::Area); QWindowSystemInterface::registerTouchDevice(td); diff --git a/src/platformsupport/input/libinput/qlibinputtouch_p.h b/src/platformsupport/input/libinput/qlibinputtouch_p.h index 51304e6a21..2682b83b26 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch_p.h +++ b/src/platformsupport/input/libinput/qlibinputtouch_p.h @@ -42,6 +42,7 @@ #include <QtCore/QHash> #include <QtCore/QList> +#include <QtCore/QPointer> #include <qpa/qwindowsysteminterface.h> // @@ -60,6 +61,7 @@ struct libinput_device; QT_BEGIN_NAMESPACE +class QScreen; class QLibInputTouch { public: @@ -73,15 +75,18 @@ public: private: struct DeviceState { - DeviceState() : m_touchDevice(nullptr) { } + DeviceState() : m_touchDevice(nullptr), m_screenName() { } QWindowSystemInterface::TouchPoint *point(int32_t slot); QList<QWindowSystemInterface::TouchPoint> m_points; QTouchDevice *m_touchDevice; + QString m_screenName; }; DeviceState *deviceState(libinput_event_touch *e); + QPointF getPos(libinput_event_touch *e); QHash<libinput_device *, DeviceState> m_devState; + mutable QPointer<QScreen> m_screen; }; QT_END_NAMESPACE -- cgit v1.2.3 From f91af791cc3be1dfb9645ed4ebba10a7d9f74134 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 7 Jan 2020 15:06:54 +0100 Subject: Add advance warning of change of return types coming in Qt6 The QLocale methods that report the fragments used in making up numbers all return QChar. A note dating from before Qt5 times warned that we need to change these to return QString (since we might need a surrogate pair to represent the relevant characters). Give advance warning in the documentation that this shall happen at Qt 6. [ChangeLog][QtCore][QLocale] decimalPoint(), groupSeparator(), percent(), zeroDigit(), negativeSign(), positiveSign() and exponential() still return QChar but shall be changed to return QString in Qt 6. Callers are encouraged to switch to QString early, exploiting the QString(QChar) constructor. Task-number: QTBUG-81053 Change-Id: Ia802c7665676ecf13669c6a6f173f2e70eac578e Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/text/qlocale.cpp | 30 +++++++++++++++++++++++++++++- src/corelib/text/qlocale.h | 6 +++--- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 425cb87d31..dd3263e5aa 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -2525,6 +2525,10 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal \since 4.1 Returns the decimal point character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::decimalPoint() const { @@ -2535,6 +2539,10 @@ QChar QLocale::decimalPoint() const \since 4.1 Returns the group separator character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::groupSeparator() const { @@ -2545,6 +2553,10 @@ QChar QLocale::groupSeparator() const \since 4.1 Returns the percent character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::percent() const { @@ -2555,6 +2567,10 @@ QChar QLocale::percent() const \since 4.1 Returns the zero digit character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::zeroDigit() const { @@ -2565,6 +2581,10 @@ QChar QLocale::zeroDigit() const \since 4.1 Returns the negative sign character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::negativeSign() const { @@ -2575,6 +2595,10 @@ QChar QLocale::negativeSign() const \since 4.5 Returns the positive sign character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::positiveSign() const { @@ -2585,6 +2609,10 @@ QChar QLocale::positiveSign() const \since 4.1 Returns the exponential character of this locale. + + \note This function shall change to return a QString instead of QChar in + Qt6. Callers are encouraged to exploit the QString(QChar) constructor to + convert early in preparation for this. */ QChar QLocale::exponential() const { diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index 8b73eb5493..513e0f097b 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -1044,8 +1044,8 @@ public: QDateTime toDateTime(const QString &string, const QString &format, QCalendar cal) const; #endif - // ### Qt 5: We need to return QString from these function since - // unicode data contains several characters for these fields. + // ### Qt 6: We need to return QString from these function since + // UTF-16 may need surrogate pairs to represent these fields. QChar decimalPoint() const; QChar groupSeparator() const; QChar percent() const; -- cgit v1.2.3 From 0f80452b924230013d713c2bc6681efc0e654a1b Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Wed, 8 Jan 2020 12:00:09 +0100 Subject: Improve QLocale method documentation Add missing \sa lines, clarify what the exponential character is and mention that C is an exception to the "no number options set". Change-Id: I13ca483a07738908640408e0ca512de31586cec9 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qlocale.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index dd3263e5aa..e3e0ebdcbd 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1048,6 +1048,8 @@ uint qHash(const QLocale &key, uint seed) noexcept Sets the \a options related to number conversions for this QLocale instance. + + \sa numberOptions() */ void QLocale::setNumberOptions(NumberOptions options) { @@ -1060,7 +1062,10 @@ void QLocale::setNumberOptions(NumberOptions options) Returns the options related to number conversions for this QLocale instance. - By default, no options are set for the standard locales. + By default, no options are set for the standard locales, except + for the "C" locale, which has OmitGroupSeparator set by default. + + \sa setNumberOptions(), toString(), groupSeparator() */ QLocale::NumberOptions QLocale::numberOptions() const { @@ -1962,7 +1967,7 @@ double QLocale::toDouble(QStringView s, bool *ok) const /*! Returns a localized string representation of \a i. - \sa toLongLong() + \sa toLongLong(), numberOptions(), zeroDigit(), positiveSign() */ QString QLocale::toString(qlonglong i) const @@ -1978,7 +1983,7 @@ QString QLocale::toString(qlonglong i) const /*! \overload - \sa toULongLong() + \sa toULongLong(), numberOptions(), zeroDigit(), positiveSign() */ QString QLocale::toString(qulonglong i) const @@ -2529,6 +2534,8 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa groupSeparator(), toString() */ QChar QLocale::decimalPoint() const { @@ -2543,6 +2550,8 @@ QChar QLocale::decimalPoint() const \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa decimalPoint(), toString() */ QChar QLocale::groupSeparator() const { @@ -2557,6 +2566,8 @@ QChar QLocale::groupSeparator() const \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa toString() */ QChar QLocale::percent() const { @@ -2571,6 +2582,8 @@ QChar QLocale::percent() const \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa toString() */ QChar QLocale::zeroDigit() const { @@ -2585,6 +2598,8 @@ QChar QLocale::zeroDigit() const \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa positiveSign(), toString() */ QChar QLocale::negativeSign() const { @@ -2599,6 +2614,8 @@ QChar QLocale::negativeSign() const \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa negativeSign(), toString() */ QChar QLocale::positiveSign() const { @@ -2608,11 +2625,14 @@ QChar QLocale::positiveSign() const /*! \since 4.1 - Returns the exponential character of this locale. + Returns the exponential character of this locale, used to separate exponent + from mantissa in some floating-point numeric representations. \note This function shall change to return a QString instead of QChar in Qt6. Callers are encouraged to exploit the QString(QChar) constructor to convert early in preparation for this. + + \sa toString(double, char, int) */ QChar QLocale::exponential() const { @@ -2637,7 +2657,7 @@ static char qToLower(char c) \a f and \a prec have the same meaning as in QString::number(double, char, int). - \sa toDouble() + \sa toDouble(), numberOptions(), exponential(), decimalPoint(), zeroDigit(), positiveSign(), percent() */ QString QLocale::toString(double i, char f, int prec) const -- cgit v1.2.3 From 11c5c078c7743050a115a4dcc31f52caaa378e35 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Mon, 6 Jan 2020 12:11:28 +0100 Subject: Eliminate QLocale's default_number_options global static It had create()'s default number options when passed to create, so wasn't useful then; and otherwise shadowed the value held by the cached private for the default locale. Noticed in the course of adding an analogous global for the system locale. Drive-by - eliminated a redundant language != C check. Change-Id: I5601dc09188804c11dede5be460bfdd12b8152ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qlocale.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index e3e0ebdcbd..e3530eeee1 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -651,7 +651,6 @@ int qt_repeatCount(QStringView s) } static const QLocaleData *default_data = nullptr; -static QLocale::NumberOptions default_number_options = QLocale::DefaultNumberOptions; static const QLocaleData *const c_data = locale_data; static QLocalePrivate *c_private() @@ -834,7 +833,7 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l) static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1; Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate, - (QLocalePrivate::create(defaultData(), default_number_options))) + (QLocalePrivate::create(defaultData()))) Q_GLOBAL_STATIC_WITH_ARGS(QExplicitlySharedDataPointer<QLocalePrivate>, systemLocalePrivate, (QLocalePrivate::create(systemData()))) @@ -862,8 +861,9 @@ static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Sc QLocale::NumberOptions numberOptions = QLocale::DefaultNumberOptions; // If not found, should default to system - if (data->m_language_id == QLocale::C && language != QLocale::C) { - numberOptions = default_number_options; + if (data->m_language_id == QLocale::C) { + if (defaultLocalePrivate.exists()) + numberOptions = defaultLocalePrivate->data()->m_numberOptions; data = defaultData(); } return QLocalePrivate::create(data, offset, numberOptions); @@ -1175,12 +1175,9 @@ QString QLocale::createSeparatedList(const QStringList &list) const void QLocale::setDefault(const QLocale &locale) { default_data = locale.d->m_data; - default_number_options = locale.numberOptions(); - if (defaultLocalePrivate.exists()) { - // update the cached private + if (defaultLocalePrivate.exists()) // update the cached private *defaultLocalePrivate = locale.d; - } } /*! -- cgit v1.2.3 From 1e42c97cf055ac20352d20150e2786c14565ea2b Mon Sep 17 00:00:00 2001 From: Jani Heikkinen <jani.heikkinen@qt.io> Date: Wed, 8 Jan 2020 15:11:21 +0200 Subject: Bump copyright year MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I9468ef21a2cf03cf07c38f012a2aa9bae6d02a03 Reviewed-by: Johanna Äijälä <johanna.aijala@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 4 ++-- src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 4 ++-- src/widgets/dialogs/qmessagebox.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 522c55593f..81ebafad79 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the tools applications of the Qt Toolkit. @@ -61,7 +61,7 @@ static const char docTypeHeader[] = #define PROGRAMNAME "qdbuscpp2xml" #define PROGRAMVERSION "0.2" -#define PROGRAMCOPYRIGHT "Copyright (C) 2019 The Qt Company Ltd." +#define PROGRAMCOPYRIGHT "Copyright (C) 2020 The Qt Company Ltd." static QString outputFile; static int flags; diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index ce4232f3e8..9cf753a3f1 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the tools applications of the Qt Toolkit. @@ -46,7 +46,7 @@ #define PROGRAMNAME "qdbusxml2cpp" #define PROGRAMVERSION "0.8" -#define PROGRAMCOPYRIGHT "Copyright (C) 2019 The Qt Company Ltd." +#define PROGRAMCOPYRIGHT "Copyright (C) 2020 The Qt Company Ltd." #define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply" diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 8dad212692..e20657a0f6 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1890,7 +1890,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title) "<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>" "<p>Qt is The Qt Company Ltd product developed as an open source " "project. See <a href=\"http://%3/\">%3</a> for more information.</p>" - ).arg(QStringLiteral("2019"), + ).arg(QStringLiteral("2020"), QStringLiteral("qt.io/licensing"), QStringLiteral("qt.io")); QMessageBox *msgBox = new QMessageBox(parent); -- cgit v1.2.3 From bfbf8ca4536fda39a8fb34dbf149794437f68dff Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 7 Jan 2020 09:58:14 +0100 Subject: Silence deprecation warning about QImage::alphaChannel() in qpixmap.h Amends aa542be4e005b1feedc2e17fd6ca2387bf2fea1b. Change-Id: Id1a256a101cc16fa36d1254d3523cf0732c24045 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/gui/image/qpixmap.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 8c1395857e..8a06ebe603 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -227,7 +227,10 @@ inline bool QPixmap::loadFromData(const QByteArray &buf, const char *format, #if QT_DEPRECATED_SINCE(5, 0) inline QPixmap QPixmap::alphaChannel() const { + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED return QPixmap::fromImage(toImage().alphaChannel()); + QT_WARNING_POP } inline void QPixmap::setAlphaChannel(const QPixmap &p) -- cgit v1.2.3 From 89c4bb5f2473b4616fdccbcc616eedfaa5d628cc Mon Sep 17 00:00:00 2001 From: Sona Kurazyan <sona.kurazyan@qt.io> Date: Wed, 8 Jan 2020 13:43:54 +0100 Subject: Deprecate QJsonDocument methods for converting to/from JSON binary Also remove the example code for deprecated methods and use CBOR instead where it makes sense. Task-number: QTBUG-81068 Change-Id: Iffb7a4b3d7b16a1e485fc05b3ab2e2468e9e0718 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> --- src/corelib/serialization/qjsondocument.cpp | 7 +++++-- src/corelib/serialization/qjsondocument.h | 10 ++++++++-- src/gui/rhi/qshaderdescription.cpp | 10 ++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index b9b1902f34..fe0500bdef 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -237,7 +237,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) the application. */ -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! Creates a QJsonDocument that uses the first \a size bytes from \a data. It assumes \a data contains a binary encoded JSON document. @@ -385,10 +385,13 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati QByteArray QJsonDocument::toBinaryData() const { int size = 0; +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED const char *raw = rawData(&size); +QT_WARNING_POP return QByteArray(raw, size); } -#endif // QT_CONFIG(binaryjson) +#endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! Creates a QJsonDocument from the QVariant \a variant. diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index 325e47b531..758bbfd9dd 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -111,13 +111,19 @@ public: BypassValidation }; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use CBOR format instead") static QJsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); + + QT_DEPRECATED_X("Use CBOR format instead") const char *rawData(int *size) const; + QT_DEPRECATED_X("Use CBOR format instead") static QJsonDocument fromBinaryData(const QByteArray &data, DataValidation validation = Validate); + + QT_DEPRECATED_X("Use CBOR format instead") QByteArray toBinaryData() const; -#endif // QT_CONFIG(binaryjson) +#endif // QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) static QJsonDocument fromVariant(const QVariant &variant); QVariant toVariant() const; diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index d0f73f6aa7..7e9b7d7b8e 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -342,8 +342,11 @@ bool QShaderDescription::isValid() const */ QByteArray QShaderDescription::toBinaryJson() const { -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED return d->makeDoc().toBinaryData(); +QT_WARNING_POP #else qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); return QByteArray(); @@ -382,8 +385,11 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); +QT_WARNING_POP #else Q_UNUSED(data); qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); -- cgit v1.2.3 From 1c75f59588694557caba69c2fc173dd8f1d7f514 Mon Sep 17 00:00:00 2001 From: Andy Shaw <andy.shaw@qt.io> Date: Wed, 8 Jan 2020 14:48:12 +0100 Subject: iOS: Handle positionFromPosition out of bounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the documentation for positionFromPosition, if the resulting position is less than 0 or longer than the text, then we should return nil. This fixes problems with placement of the cursor and selection rectangle when auto-completion is used. Fixes: QTBUG-79445 Change-Id: I44a18881527a8a22012fe5fcbbc3216e60c48bc9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/plugins/platforms/ios/qiostextresponder.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 1bc9744528..a3350bda87 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -745,7 +745,11 @@ - (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset { int p = static_cast<QUITextPosition *>(position).index; - return [QUITextPosition positionWithIndex:p + offset]; + const int posWithIndex = p + offset; + const int textLength = [self currentImeState:Qt::ImSurroundingText].toString().length(); + if (posWithIndex < 0 || posWithIndex > textLength) + return nil; + return [QUITextPosition positionWithIndex:posWithIndex]; } - (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset -- cgit v1.2.3 From 0a78e5f117a1988b4cf41195b4ac57ea3010a041 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Thu, 9 Jan 2020 16:34:07 +0100 Subject: xcb: Fix nullptr vs. VK_NULL_HANDLE error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fallout from a recent 0 - nullptr fixup in 5.15. Change-Id: I17adf742d4f65dc6a468fbe72d0f02d3efa276d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/plugins/platforms/xcb/qxcbvulkaninstance.cpp | 2 +- src/plugins/platforms/xcb/qxcbvulkanwindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp index 7c15882768..bb82bcec39 100644 --- a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp @@ -93,7 +93,7 @@ bool QXcbVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window) { - VkSurfaceKHR surface = nullptr; + VkSurfaceKHR surface = VK_NULL_HANDLE; if (!m_createSurface) { m_createSurface = reinterpret_cast<PFN_vkCreateXcbSurfaceKHR>( diff --git a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp index 17d7d9791e..a05ecab51d 100644 --- a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window) : QXcbWindow(window), - m_surface(nullptr) + m_surface(VK_NULL_HANDLE) { } -- cgit v1.2.3 From 2671fb27773fa318cde486d310dcf853a8290639 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Wed, 8 Jan 2020 13:23:59 +0100 Subject: rhi: Remove ugly fallthroughs The coding style does not actually require this. Change-Id: I2be7cd29c4dabfed2822cd7fb63e597c071e5e15 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhid3d11.cpp | 26 -------------------------- src/gui/rhi/qrhigles2.cpp | 13 ------------- src/gui/rhi/qrhimetal.mm | 12 ------------ src/gui/rhi/qrhivulkan.cpp | 21 --------------------- 4 files changed, 72 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index c5923fe411..e58ce88095 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -630,9 +630,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -644,9 +642,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -1128,39 +1124,24 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; case QRhiTexture::ETC2_RGB8: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGB8A1: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGBA8: qWarning("QRhiD3D11 does not support ETC2 textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; case QRhiTexture::ASTC_4x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x12: qWarning("QRhiD3D11 does not support ASTC textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; @@ -1201,7 +1182,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -1867,9 +1847,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -1885,9 +1863,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -3356,11 +3332,9 @@ static inline D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::OneMinusDstAlpha: return D3D11_BLEND_INV_DEST_ALPHA; case QRhiGraphicsPipeline::ConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::ConstantAlpha: return D3D11_BLEND_BLEND_FACTOR; case QRhiGraphicsPipeline::OneMinusConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusConstantAlpha: return D3D11_BLEND_INV_BLEND_FACTOR; case QRhiGraphicsPipeline::SrcAlphaSaturate: diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index e63ed11dd4..24ae0a3740 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -681,7 +681,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture switch (format) { case QRhiTexture::D16: - Q_FALLTHROUGH(); case QRhiTexture::D32F: return caps.depthTexture; @@ -695,7 +694,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture return caps.r16Format; case QRhiTexture::RGBA16F: - Q_FALLTHROUGH(); case QRhiTexture::RGBA32F: return caps.floatFormats; @@ -899,9 +897,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); @@ -917,9 +913,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); @@ -1654,11 +1648,8 @@ static inline GLenum toGlBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::SrcAlphaSaturate: return GL_SRC_ALPHA_SATURATE; case QRhiGraphicsPipeline::Src1Color: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusSrc1Color: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::Src1Alpha: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusSrc1Alpha: qWarning("Unsupported blend factor %d", f); return GL_ZERO; @@ -2573,9 +2564,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); @@ -2591,9 +2580,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 222bf170dc..ef2de8c994 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -761,9 +761,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -786,9 +784,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); @@ -996,9 +992,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -1011,9 +1005,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); @@ -2928,9 +2920,7 @@ bool QMetalShaderResourceBindings::build() } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -2939,9 +2929,7 @@ bool QMetalShaderResourceBindings::build() } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c5719b54aa..2c9249e911 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -864,7 +864,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -2373,9 +2372,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); @@ -2394,9 +2391,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); @@ -3564,9 +3559,7 @@ static inline VkImageLayout toVkLayout(QRhiPassResourceTracker::TextureAccess ac case QRhiPassResourceTracker::TexDepthOutput: return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; case QRhiPassResourceTracker::TexStorageLoad: - Q_FALLTHROUGH(); case QRhiPassResourceTracker::TexStorageStore: - Q_FALLTHROUGH(); case QRhiPassResourceTracker::TexStorageLoadStore: return VK_IMAGE_LAYOUT_GENERAL; default: @@ -4045,9 +4038,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); @@ -4072,9 +4063,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); @@ -4863,16 +4852,12 @@ static inline VkDescriptorType toVkDescriptorType(const QRhiShaderResourceBindin return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -6356,17 +6341,11 @@ static inline bool isSrgbFormat(VkFormat format) { switch (format) { case VK_FORMAT_R8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8B8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_B8G8R8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8B8A8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_B8G8R8A8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_A8B8G8R8_SRGB_PACK32: return true; default: -- cgit v1.2.3 From e4d0187edc8aa5c70d181728b18630c1749ca288 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Wed, 8 Jan 2020 11:15:42 +0100 Subject: rhi: metal: Fix incorrect native res. binding map check Checking for nullptr is insufficient: just because there is an empty map present, it does not mean it is valid. The two cases must be handled identically. This fixes a regression when using QShaders that do not have an associated native resource binding map. Amends 4639660dedceba7c16e1a8110bba16eff30be312 Change-Id: Icb239bf9a9261ed32f2cb7b22c60b608195618fc Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhimetal.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index ef2de8c994..53422470e8 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -664,15 +664,15 @@ static inline int mapBinding(int binding, BindingType type) { const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex]; - if (!map) + if (!map || map->isEmpty()) return binding; // old QShader versions do not have this map, assume 1:1 mapping then auto it = map->constFind(binding); if (it != map->cend()) return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive - // Hitting this path is normal too, is not given that the resource (e.g. a - // uniform block) is really present in the shaders for all the stages + // Hitting this path is normal too. It is not given that the resource (for + // example, a uniform block) is present in the shaders for all the stages // specified by the visibility mask in the QRhiShaderResourceBinding. return -1; } -- cgit v1.2.3 From e8199a5c4d8c7218178db809bbfc0464f49714b1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Thu, 9 Jan 2020 15:28:54 +0100 Subject: rhi: Add R16F and R32F Can be relevant for Qt Quick 3D shadows, where the shadow map is R16F. Task-number: QTBUG-81268 Change-Id: Ic33e100929e133d1cbe0b062a15697c82536f62a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qrhi.cpp | 6 ++++++ src/gui/rhi/qrhi_p.h | 2 ++ src/gui/rhi/qrhid3d11.cpp | 4 ++++ src/gui/rhi/qrhigles2.cpp | 24 ++++++++++++++++++++++++ src/gui/rhi/qrhimetal.mm | 4 ++++ src/gui/rhi/qrhivulkan.cpp | 4 ++++ 6 files changed, 44 insertions(+) (limited to 'src') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 00d4df53bd..d2c8ae104e 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -3939,6 +3939,12 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi case QRhiTexture::RGBA32F: bpc = 16; break; + case QRhiTexture::R16F: + bpc = 2; + break; + case QRhiTexture::R32F: + bpc = 4; + break; case QRhiTexture::D16: bpc = 2; diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index a6c65aac5e..3a64835c22 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -728,6 +728,8 @@ public: RGBA16F, RGBA32F, + R16F, + R32F, D16, D32F, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index e58ce88095..445d162595 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1102,6 +1102,10 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return DXGI_FORMAT_R16G16B16A16_FLOAT; case QRhiTexture::RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case QRhiTexture::R16F: + return DXGI_FORMAT_R16_FLOAT; + case QRhiTexture::R32F: + return DXGI_FORMAT_R32_FLOAT; case QRhiTexture::D16: return DXGI_FORMAT_R16_TYPELESS; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 24ae0a3740..afa3a397e6 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -165,6 +165,14 @@ QT_BEGIN_NAMESPACE #define GL_RGBA16F 0x881A #endif +#ifndef GL_R16F +#define GL_R16F 0x822D +#endif + +#ifndef GL_R32F +#define GL_R32F 0x822E +#endif + #ifndef GL_HALF_FLOAT #define GL_HALF_FLOAT 0x140B #endif @@ -697,6 +705,10 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture case QRhiTexture::RGBA32F: return caps.floatFormats; + case QRhiTexture::R16F: + case QRhiTexture::R32F: + return caps.floatFormats; + default: break; } @@ -3384,6 +3396,18 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize) glformat = GL_RGBA; gltype = GL_FLOAT; break; + case QRhiTexture::R16F: + glintformat = GL_R16F; + glsizedintformat = glintformat; + glformat = GL_RED; + gltype = GL_HALF_FLOAT; + break; + case QRhiTexture::R32F: + glintformat = GL_R32F; + glsizedintformat = glintformat; + glformat = GL_RED; + gltype = GL_FLOAT; + break; case QRhiTexture::D16: glintformat = GL_DEPTH_COMPONENT16; glsizedintformat = glintformat; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 53422470e8..883d6923b9 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2320,6 +2320,10 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR return MTLPixelFormatRGBA16Float; case QRhiTexture::RGBA32F: return MTLPixelFormatRGBA32Float; + case QRhiTexture::R16F: + return MTLPixelFormatR16Float; + case QRhiTexture::R32F: + return MTLPixelFormatR32Float; case QRhiTexture::D16: #ifdef Q_OS_MACOS diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 2c9249e911..c4f56f2dd2 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -767,6 +767,10 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture return VK_FORMAT_R16G16B16A16_SFLOAT; case QRhiTexture::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; + case QRhiTexture::R16F: + return VK_FORMAT_R16_SFLOAT; + case QRhiTexture::R32F: + return VK_FORMAT_R32_SFLOAT; case QRhiTexture::D16: return VK_FORMAT_D16_UNORM; -- cgit v1.2.3 From 22f0905b4ac1af125d382440716b97f4e6142676 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Sat, 7 Mar 2015 10:37:52 -0800 Subject: forkfd: Implement forkfd in terms of Linux 5.2's CLONE_PIDFD Linux 5.2 added the CLONE_PIDFD flag to the clone(2) system call. Linux 5.3 also added the clone3(2) system call, which allows both CLONE_PIDFD and CLONE_PARENT_SETTID, which we could use but don't really need. Unfortunately, 5.2 missed one crucial and one convenient change. Without the P_PIDFD support in waitid(2), we would need to either remember the PID of the child process or obtain it from /proc. But without support for polling on pidfds, we can't find out when the child process exited. Support for the latter was added in 5.3, which would be sufficient for us, but it's not easy to detect it at runtime. The support is also being backported to Android's 4.9 kernel[1], so we can't do version checks, only functionality. This commit relies on waitid(2) support, which was the last to be added and is fortunately the easiest to detect. If it's present, we assume the whole series is present and use pidfds. [1] https://android-review.googlesource.com/q/topic:%22pidfd+polling+support+4.9+backport%22 See-Also: https://lkml.org/lkml/2015/3/12/1044 (original idea) See-Also: https://lkml.org/lkml/2019/4/19/441 (CLONE_PIDFD) See-Also: https://lkml.org/lkml/2019/4/25/884 (poll(2) support) See-Also: https://lkml.org/lkml/2019/7/27/334 (P_PIDFD) Change-Id: Ia0aac2f09e9245339951ffff13c94b3aa13d8b63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/3rdparty/forkfd/forkfd.c | 2 + src/3rdparty/forkfd/forkfd_linux.c | 251 +++++++++++++++++++++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 src/3rdparty/forkfd/forkfd_linux.c (limited to 'src') diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index e4f3bd85de..2ae85d6f37 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -822,6 +822,8 @@ int forkfd_close(int ffd) #if defined(__FreeBSD__) && __FreeBSD__ >= 9 # include "forkfd_freebsd.c" +#elif defined(__linux__) +# include "forkfd_linux.c" #else int system_has_forkfd() { diff --git a/src/3rdparty/forkfd/forkfd_linux.c b/src/3rdparty/forkfd/forkfd_linux.c new file mode 100644 index 0000000000..ea587b7ed5 --- /dev/null +++ b/src/3rdparty/forkfd/forkfd_linux.c @@ -0,0 +1,251 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Intel Corporation. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to deal +** in the Software without restriction, including without limitation the rights +** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +** copies of the Software, and to permit persons to whom the Software is +** furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +** THE SOFTWARE. +** +****************************************************************************/ + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#include "forkfd.h" + +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <sched.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/resource.h> +#include <sys/syscall.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +#include "forkfd_atomic.h" + +#ifndef CLONE_PIDFD +# define CLONE_PIDFD 0x00001000 +#endif +#ifndef P_PIDFD +# define P_PIDFD 3 +#endif + +static ffd_atomic_int system_forkfd_state = FFD_ATOMIC_INIT(0); + +static int sys_waitid(int which, int pid_or_pidfd, siginfo_t *infop, int options, + struct rusage *ru) +{ + /* use the waitid raw system call, which has an extra parameter that glibc + * doesn't offer to us */ + return syscall(__NR_waitid, which, pid_or_pidfd, infop, options, ru); +} + +static int sys_clone(unsigned long cloneflags, int *ptid) +{ + void *child_stack = NULL; + int *ctid = NULL; + unsigned long newtls = 0; +#if defined(__NR_clone2) + size_t stack_size = 0; + return syscall(__NR_clone2, cloneflags, child_stack, stack_size, ptid, ctid, newtls); +#elif defined(__cris__) || defined(__s390__) + /* a.k.a., CONFIG_CLONE_BACKWARDS2 architectures */ + return syscall(__NR_clone, child_stack, cloneflags, ptid, newtls, ctid); +#elif defined(__microblaze__) + /* a.k.a., CONFIG_CLONE_BACKWARDS3 architectures */ + size_t stack_size = 0; + return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid); +#elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \ + defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \ + defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) + /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures, + * but since both values are 0, there's no harm. */ + return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls); +#else + (void) child_stack; + (void) ctid; + (void) newtls; + errno = ENOSYS; + return -1; +#endif +} + +static int detect_clone_pidfd_support() +{ + /* + * Detect support for CLONE_PIDFD and P_PIDFD. Support was added in steps: + * - Linux 5.2 added CLONE_PIDFD support in clone(2) system call + * - Linux 5.2 added pidfd_send_signal(2) + * - Linux 5.3 added support for poll(2) on pidfds + * - Linux 5.3 added clone3(2) + * - Linux 5.4 added P_PIDFD support in waitid(2) + * + * We need CLONE_PIDFD and the poll(2) support. We could emulate the + * P_PIDFD support by reading the PID from /proc/self/fdinfo/n, which works + * in Linux 5.2, but without poll(2), we can't guarantee the functionality + * anyway. + * + * So we detect by trying to waitid(2) on a positive file descriptor that + * is definitely closed (INT_MAX). If P_PIDFD is supported, waitid(2) will + * return EBADF. If it isn't supported, it returns EINVAL (as it would for + * a negative file descriptor). This will succeed on Linux 5.4. + * + * We could have instead detected by the existence of the clone3(2) system + * call, but for that we would have needed to wait for __NR_clone3 to show + * up on the libcs. We choose to go via the waitid(2) route, which requires + * platform-independent constants only. It would have simplified the + * sys_clone() mess above... + */ + + sys_waitid(P_PIDFD, INT_MAX, NULL, WEXITED|WNOHANG, NULL); + return errno == EBADF ? 1 : -1; + +#if 0 + /* Detection methods not used: */ +#ifdef __NR_pidfd_send_signal + /* + * pidfd_send_signal was added at the same time as CLONE_PIDFD, so if this + * system call exists, so does CLONE_PIDFD. We make a system call with a + * file descriptor of -1: if it's supported, we get EBADF; otherwise, the + * typical ENOSYS. + */ + syscall(__NR_pidfd_send_signal, -1, 0, NULL, 0); + return errno == EBADF ? 1 : -1; +#else + /* + * detect kernel CLONE_PIDFD support directly: CLONE_PIDFD | + * CLONE_PARENT_SETTID causes EINVAL on kernel >= 5.2, but on older + * kernels, that combination is ignored. Therefore, if we EINVAL, we know + * that CLONE_PIDFD is supported. + * + * To avoid creating a process unnecessarily, we add CLONE_NEWUTS, which is + * a privileged operation. Therefore, if we're not root, we'll get EPERM. + * If we're root, we need to exit the child process and wait for it on the + * parent. + */ + pid_t pid = sys_clone(CLONE_PIDFD | CLONE_PARENT_SETTID | CLONE_NEWUTS, NULL); + if (pid == -1 && errno == EINVAL) + return 1; + if (pid == 0) + _exit(0); /* Child */ + if (pid > 0) + sys_waitid(P_PID, pid, NULL, WEXITED | __WALL, NULL); /* Parent */ + + return -1; +#endif +#endif // 0 +} + +#if 0 +/* To be used if waitid's P_PIDFD support gets bumped to 5.4 */ +static pid_t pidfd_to_pid(int pidfd) +{ + static const char pidtext[] = "Pid:\t"; + int fdinfo; + ssize_t ret; + char buf[256]; + char *text, *endpid = NULL; + + snprintf(buf, sizeof(buf), "/proc/self/fdinfo/%d", pidfd); + fdinfo = open(buf, O_RDONLY | O_CLOEXEC); + if (fdinfo < 0) + return fdinfo; + + ret = read(fdinfo, buf, sizeof(buf) - 1); + close(fdinfo); + if (ret < 1) + return ret; + + buf[ret] = '\0'; + text = (char *) memmem(buf, ret, pidtext, sizeof(pidtext) - 1); + if (text == NULL) + return -1; + + text += sizeof(pidtext) - 1; + ret = strtol(text, &endpid, 10); + if (ret < 0 || (endpid && *endpid != '\n')) + return -1; + return ret; +} +#endif + +int system_has_forkfd() +{ + return ffd_atomic_load(&system_forkfd_state, FFD_ATOMIC_RELAXED) > 0; +} + +int system_forkfd(int flags, pid_t *ppid, int *system) +{ + pid_t pid; + int pidfd; + + int state = ffd_atomic_load(&system_forkfd_state, FFD_ATOMIC_RELAXED); + if (state == 0) { + state = detect_clone_pidfd_support(); + ffd_atomic_store(&system_forkfd_state, state, FFD_ATOMIC_RELAXED); + } + if (state < 0) { + *system = 0; + return state; + } + + *system = 1; + pid = sys_clone(CLONE_PIDFD, &pidfd); + if (ppid) + *ppid = pid; + + if (pid == 0) { + /* Child process */ + return FFD_CHILD_PROCESS; + } + + /* parent process */ + if ((flags & FFD_CLOEXEC) == 0) { + /* pidfd defaults to O_CLOEXEC */ + fcntl(pidfd, F_SETFD, 0); + } + if (flags & FFD_NONBLOCK) + fcntl(pidfd, F_SETFL, fcntl(pidfd, F_GETFL) | O_NONBLOCK); + return pidfd; +} + +int system_forkfd_wait(int ffd, struct forkfd_info *info, struct rusage *rusage) +{ + siginfo_t si; + int options = WEXITED | __WALL; + int ret = fcntl(ffd, F_GETFL); + if (ret == -1) + return ret; + if (ret & O_NONBLOCK) + options |= WNOHANG; + + ret = sys_waitid(P_PIDFD, ffd, &si, options, rusage); + if (ret == -1 && errno == ECHILD) { + errno = EWOULDBLOCK; + } else if (ret == 0 && info) { + info->code = si.si_code; + info->status = si.si_status; + } + return ret; +} -- cgit v1.2.3 From 079fbebb6ab91479107e84e2c81966ca5f157529 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Fri, 11 Oct 2019 22:07:46 -0700 Subject: forkfd/Linux: remove unused code The detection code for Linux 5.2 and 5.3 went unused. We had it in the initial commit so it got recorded for posterity, in case someone wants to detect them (the road not taken). Change-Id: Ib5d667bf77a740c28d2efffd15cccdff5aa5a622 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> --- src/3rdparty/forkfd/forkfd_linux.c | 68 -------------------------------------- 1 file changed, 68 deletions(-) (limited to 'src') diff --git a/src/3rdparty/forkfd/forkfd_linux.c b/src/3rdparty/forkfd/forkfd_linux.c index ea587b7ed5..27ab09f748 100644 --- a/src/3rdparty/forkfd/forkfd_linux.c +++ b/src/3rdparty/forkfd/forkfd_linux.c @@ -120,76 +120,8 @@ static int detect_clone_pidfd_support() sys_waitid(P_PIDFD, INT_MAX, NULL, WEXITED|WNOHANG, NULL); return errno == EBADF ? 1 : -1; - -#if 0 - /* Detection methods not used: */ -#ifdef __NR_pidfd_send_signal - /* - * pidfd_send_signal was added at the same time as CLONE_PIDFD, so if this - * system call exists, so does CLONE_PIDFD. We make a system call with a - * file descriptor of -1: if it's supported, we get EBADF; otherwise, the - * typical ENOSYS. - */ - syscall(__NR_pidfd_send_signal, -1, 0, NULL, 0); - return errno == EBADF ? 1 : -1; -#else - /* - * detect kernel CLONE_PIDFD support directly: CLONE_PIDFD | - * CLONE_PARENT_SETTID causes EINVAL on kernel >= 5.2, but on older - * kernels, that combination is ignored. Therefore, if we EINVAL, we know - * that CLONE_PIDFD is supported. - * - * To avoid creating a process unnecessarily, we add CLONE_NEWUTS, which is - * a privileged operation. Therefore, if we're not root, we'll get EPERM. - * If we're root, we need to exit the child process and wait for it on the - * parent. - */ - pid_t pid = sys_clone(CLONE_PIDFD | CLONE_PARENT_SETTID | CLONE_NEWUTS, NULL); - if (pid == -1 && errno == EINVAL) - return 1; - if (pid == 0) - _exit(0); /* Child */ - if (pid > 0) - sys_waitid(P_PID, pid, NULL, WEXITED | __WALL, NULL); /* Parent */ - - return -1; -#endif -#endif // 0 } -#if 0 -/* To be used if waitid's P_PIDFD support gets bumped to 5.4 */ -static pid_t pidfd_to_pid(int pidfd) -{ - static const char pidtext[] = "Pid:\t"; - int fdinfo; - ssize_t ret; - char buf[256]; - char *text, *endpid = NULL; - - snprintf(buf, sizeof(buf), "/proc/self/fdinfo/%d", pidfd); - fdinfo = open(buf, O_RDONLY | O_CLOEXEC); - if (fdinfo < 0) - return fdinfo; - - ret = read(fdinfo, buf, sizeof(buf) - 1); - close(fdinfo); - if (ret < 1) - return ret; - - buf[ret] = '\0'; - text = (char *) memmem(buf, ret, pidtext, sizeof(pidtext) - 1); - if (text == NULL) - return -1; - - text += sizeof(pidtext) - 1; - ret = strtol(text, &endpid, 10); - if (ret < 0 || (endpid && *endpid != '\n')) - return -1; - return ret; -} -#endif - int system_has_forkfd() { return ffd_atomic_load(&system_forkfd_state, FFD_ATOMIC_RELAXED) > 0; -- cgit v1.2.3 From 702e49eeb5654b6881f91618e5bc95853e206b6c Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Thu, 21 Nov 2019 15:30:01 +0100 Subject: forkfd: add FFD_USE_FORK to force use of fork() Change-Id: Ia2aa807ffa8a4c798425fffd15d933e47919247a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> --- src/3rdparty/forkfd/forkfd.c | 14 +++++++++++--- src/3rdparty/forkfd/forkfd.h | 5 +++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index 2ae85d6f37..31189fa2cd 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -586,6 +586,12 @@ static int create_pipe(int filedes[], int flags) * descriptor. You probably want to set this flag, since forkfd() does not work * if the original parent process dies. * + * @li @C FFD_USE_FORK Tell forkfd() to actually call fork() instead of a + * different system implementation that may be available. On systems where a + * different implementation is available, its behavior may differ from that of + * fork(), such as not calling the functions registered with pthread_atfork(). + * If that's necessary, pass this flag. + * * The file descriptor returned by forkfd() supports the following operations: * * @li read(2) When the child process exits, then the buffer supplied to @@ -613,9 +619,11 @@ int forkfd(int flags, pid_t *ppid) int efd; #endif - fd = system_forkfd(flags, ppid, &ret); - if (ret) - return fd; + if ((flags & FFD_USE_FORK) == 0) { + fd = system_forkfd(flags, ppid, &ret); + if (ret) + return fd; + } (void) pthread_once(&forkfd_initialization, forkfd_initialize); diff --git a/src/3rdparty/forkfd/forkfd.h b/src/3rdparty/forkfd/forkfd.h index eb121de593..fe70371719 100644 --- a/src/3rdparty/forkfd/forkfd.h +++ b/src/3rdparty/forkfd/forkfd.h @@ -38,8 +38,9 @@ extern "C" { #endif -#define FFD_CLOEXEC 1 -#define FFD_NONBLOCK 2 +#define FFD_CLOEXEC 1 +#define FFD_NONBLOCK 2 +#define FFD_USE_FORK 4 #define FFD_CHILD_PROCESS (-2) -- cgit v1.2.3 From 97645478de3ceffce11f58eab140c4c775e48be5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Fri, 22 Nov 2019 09:55:46 +0100 Subject: QProcess: use FFD_USE_FORK when the class is not QProcess itself If the user derived from QProcess, it's likely to override the setupChildProcess() virtual. Unlike fork(), the system calls for enhenced functionality (FreeBSD pdfork() and Linux's clone()) won't call pthread_atfork() callbacks and the environment in the child process could be inconsistent. Qt's own code is safe, but we can't make the same statement about users' code. So we err on the safe side for correctness and run the old, less safe implementation (thread-unsafe, subject to hijacking of the signal handler, etc.). Change-Id: Ia2aa807ffa8a4c798425fffd15d9703bd03f6f09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/io/qprocess_unix.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 9cd3bd531b..2186f23ab6 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -451,8 +451,13 @@ void QProcessPrivate::startProcess() } // Start the process manager, and fork off the child process. + // ### Qt6: revisit whether the change in behavior due to not using fork() + // is acceptable for derived classes. + int ffdflags = FFD_CLOEXEC; + if (typeid(*q) != typeid(QProcess)) + ffdflags |= FFD_USE_FORK; pid_t childPid; - forkfd = ::forkfd(FFD_CLOEXEC, &childPid); + forkfd = ::forkfd(ffdflags , &childPid); int lastForkErrno = errno; if (forkfd != FFD_CHILD_PROCESS) { // Parent process. -- cgit v1.2.3 From f1e5c5575cc362bc23da500d069dc98e082492e4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen <allan.jensen@qt.io> Date: Tue, 7 Jan 2020 11:29:04 +0100 Subject: Remove use of QImage::alphaChannel() A direct logical replacement. Not sure what is going on though or why an inversion is necessary, but logic is unchanged. Change-Id: Id9b5531895371f6467018fa82336aff6238ae126 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/painting/qtextureglyphcache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index f40ca9d8b4..91214f27ca 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -341,9 +341,10 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP } else if (m_format == QFontEngine::Format_Mono) { if (mask.depth() > 1) { // TODO optimize this - mask = mask.alphaChannel(); + mask.convertTo(QImage::Format_Alpha8); + mask.reinterpretAsFormat(QImage::Format_Grayscale8); mask.invertPixels(); - mask = mask.convertToFormat(QImage::Format_Mono, Qt::ThresholdDither); + mask.convertTo(QImage::Format_Mono, Qt::ThresholdDither); } int mw = qMin(mask.width(), c.w); -- cgit v1.2.3 From 9a112bebe56f5975bdb11549c8d66773cf60419f Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev <nodir.temir@gmail.com> Date: Thu, 19 Dec 2019 17:24:24 +0500 Subject: QWindowsVistaStyle: Fix build with no dockwidget & commandlinkbutton features Change-Id: I0f7465cbe80e305680df37b2bf5e2f50874e6fe3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 9 ++++++++- src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index 345267c8fc..e8d74180cd 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -1365,6 +1365,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsStyle::drawControl(element, ©Opt, painter, widget); } break; +#if QT_CONFIG(dockwidget) case CE_DockWidgetTitle: if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(widget); @@ -1431,6 +1432,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } } break; +#endif // QT_CONFIG(dockwidget) #if QT_CONFIG(itemviews) case CE_ItemViewItem: { @@ -2311,11 +2313,13 @@ void QWindowsVistaStyle::polish(QWidget *widget) #endif // QT_CONFIG(lineedit) if (qobject_cast<QGroupBox*>(widget)) widget->setAttribute(Qt::WA_Hover); +#if QT_CONFIG(commandlinkbutton) else if (qobject_cast<QCommandLinkButton*>(widget)) { QFont buttonFont = widget->font(); buttonFont.setFamily(QLatin1String("Segoe UI")); widget->setFont(buttonFont); } +#endif // QT_CONFIG(commandlinkbutton) else if (widget->inherits("QTipLabel")){ //note that since tooltips are not reused //we do not have to care about unpolishing @@ -2392,12 +2396,15 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) #endif // QT_CONFIG(inputdialog) else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) { tree->viewport()->setAttribute(Qt::WA_Hover, false); - } else if (qobject_cast<QCommandLinkButton*>(widget)) { + } +#if QT_CONFIG(commandlinkbutton) + else if (qobject_cast<QCommandLinkButton*>(widget)) { QFont font = QApplication::font("QCommandLinkButton"); QFont widgetFont = widget->font(); widgetFont.setFamily(font.family()); //Only family set by polish widget->setFont(widgetFont); } +#endif // QT_CONFIG(commandlinkbutton) } diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h index 8fef9f9927..c1d764a60e 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h @@ -106,7 +106,9 @@ #include <qtableview.h> #endif #include <qdatetime.h> +#if QT_CONFIG(commandlinkbutton) #include <qcommandlinkbutton.h> +#endif QT_BEGIN_NAMESPACE -- cgit v1.2.3 From efff8ff57a70f6de9a70e2bfda625bef86a9d6b6 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 15 Dec 2019 13:17:39 +0100 Subject: QFileSystemWatcher/win: watch also for attribute changes of directories The windows filesystemwatcher did not watch for attribute changes for directories (e.g. hidden flag) so it was not in sync with other backends. Fix it by adding FILE_NOTIFY_CHANGE_ATTRIBUTES to the watch flags when watching a directory. [ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that caused QFSW not to watch for attribute changes on Windows. Now it will correctly report when files and directories become hidden or unhidden, for example. Fixes: QTBUG-80545 Change-Id: I31767a0da899963e3940b4f5b36d1d581e6aa57c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/corelib/io/qfilesystemwatcher_win.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 5f91ce5e3d..3b67dd61c7 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -403,6 +403,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, const QString absolutePath = isDir ? fileInfo.absoluteFilePath() : fileInfo.absolutePath(); const uint flags = isDir ? (FILE_NOTIFY_CHANGE_DIR_NAME + | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_FILE_NAME) : (FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_FILE_NAME -- cgit v1.2.3 From c4a9429be7e0e927289abbe7a34c061df0c07628 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Thu, 19 Dec 2019 10:36:15 +0100 Subject: Fix developer build with clang-cl failing due exception spec Clang does seem to understand __declspec(nothrow) as used by the COM macros like STDMETHOD. Suppress the warning, fixing errors like: qwindowsfontenginedirectwrite.cpp(105,24): error: 'AddBeziers' is missing exception specification '__attribute__((nothrow))' [-Werror,-Wmicrosoft-exception-spec] Task-number: QTBUG-63512 Change-Id: If582cb0c12c62a7d12c4ae702747aac1f735db3c Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 3 +++ src/plugins/platforms/windows/qwindowscombase.h | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp index e796c18e79..bc34a77e08 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp @@ -62,6 +62,9 @@ QT_BEGIN_NAMESPACE +// Clang does not consider __declspec(nothrow) as nothrow +QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec") + // Convert from design units to logical pixels #define DESIGN_TO_LOGICAL(DESIGN_UNIT_VALUE) \ QFixed::fromReal((qreal(DESIGN_UNIT_VALUE) / qreal(m_unitsPerEm)) * fontDef.pixelSize) diff --git a/src/plugins/platforms/windows/qwindowscombase.h b/src/plugins/platforms/windows/qwindowscombase.h index 45cba9c68b..bb4b295395 100644 --- a/src/plugins/platforms/windows/qwindowscombase.h +++ b/src/plugins/platforms/windows/qwindowscombase.h @@ -107,6 +107,9 @@ private: ULONG m_ref; }; +// Clang does not consider __declspec(nothrow) as nothrow +QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec") + QT_END_NAMESPACE #endif // QWINDOWSCOMBASE_H -- cgit v1.2.3 From 94b3dd77f29a00ebbd1efdc66d75f57e1c75b152 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Thu, 9 Jan 2020 11:58:34 +0100 Subject: QAbstractSocket: deprecate 'error' member-function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The one that is a getter for the last error found. This is to disambiguate the expression '&QAbstractSocket::error'. Introduce a new member-function socketError as a replacement. [ChangeLog][Deprecation Notice] QAbstractSocket::error() (the getter) is deprecated; superseded by socketError(). Task-number: QTBUG-80369 Change-Id: Ia2e3d108657aaa7929ab0810babe2ede309740ba Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/access/qhttpprotocolhandler.cpp | 2 +- .../access/qnetworkaccessdebugpipebackend.cpp | 4 +-- src/network/socket/qabstractsocket.cpp | 29 ++++++++++++++++++---- src/network/socket/qabstractsocket.h | 7 +++++- src/network/socket/qhttpsocketengine.cpp | 13 +++++----- src/network/socket/qlocalsocket_unix.cpp | 2 +- src/network/socket/qsocks5socketengine.cpp | 22 ++++++++-------- src/network/ssl/qdtls_openssl.cpp | 2 +- src/network/ssl/qsslsocket.cpp | 8 +++--- src/network/ssl/qsslsocket_openssl.cpp | 2 +- src/network/ssl/qsslsocket_schannel.cpp | 4 +-- 11 files changed, 59 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index d39589fb96..981effb54f 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -233,7 +233,7 @@ void QHttpProtocolHandler::_q_readyRead() char c; qint64 ret = m_socket->peek(&c, 1); if (ret < 0) { - m_channel->_q_error(m_socket->error()); + m_channel->_q_error(m_socket->socketError()); // We still need to handle the reply so it emits its signals etc. if (m_reply) _q_receiveReply(); diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index 03ffc69628..0406f2fac1 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -242,9 +242,9 @@ void QNetworkAccessDebugPipeBackend::closeDownstreamChannel() void QNetworkAccessDebugPipeBackend::socketError() { - qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.error()); + qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.socketError()); QNetworkReply::NetworkError code; - switch (socket.error()) { + switch (socket.socketError()) { case QAbstractSocket::RemoteHostClosedError: return; // socketDisconnected will be called diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index cbc4114904..0d9e25954d 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -215,7 +215,7 @@ connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). - \sa error(), errorString(), {Creating Custom Qt Types} + \sa socketError(), errorString(), {Creating Custom Qt Types} */ /*! @@ -329,7 +329,7 @@ is non-blocking). \value UnknownSocketError An unidentified error occurred. - \sa QAbstractSocket::error() + \sa QAbstractSocket::socketError() */ /*! @@ -2094,7 +2094,7 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option) Waits until the socket is connected, up to \a msecs milliseconds. If the connection has been established, this function returns \c true; otherwise it returns \c false. In the case - where it returns \c false, you can call error() to determine + where it returns \c false, you can call socketError() to determine the cause of the error. The following example waits up to one second for a connection @@ -2873,7 +2873,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size) /*! Returns the state of the socket. - \sa error() + \sa socketError() */ QAbstractSocket::SocketState QAbstractSocket::state() const { @@ -2900,16 +2900,35 @@ QAbstractSocket::SocketType QAbstractSocket::socketType() const return d_func()->socketType; } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + + Use socketError() instead. + Returns the type of error that last occurred. - \sa state(), errorString() + \sa state(), errorString(), socketError() */ QAbstractSocket::SocketError QAbstractSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns the type of error that last occurred. + + \sa state(), errorString() +*/ +QAbstractSocket::SocketError QAbstractSocket::socketError() const { return d_func()->socketError; } + /*! Sets the type of error that last occurred to \a socketError. diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index de09195eeb..cbc79ea684 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -180,7 +180,12 @@ public: SocketType socketType() const; SocketState state() const; - SocketError error() const; + +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use socketError()") SocketError error() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + + SocketError socketError() const; // from QIODevice void close() override; diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 76b3053224..9a26868edc 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -370,8 +370,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { if (d->socket->state() == QAbstractSocket::UnconnectedState) return true; - setError(d->socket->error(), d->socket->errorString()); - if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->socket->socketError(), d->socket->errorString()); + if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -385,8 +385,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) // Report any error that may occur. if (d->state != Connected) { - setError(d->socket->error(), d->socket->errorString()); - if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->socket->socketError(), d->socket->errorString()); + if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -401,7 +401,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) if (d->state == Connected) { if (d->socket->bytesToWrite()) { if (!d->socket->waitForBytesWritten(msecs)) { - if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut) + if (d->socket->socketError() == QAbstractSocket::SocketTimeoutError && timedOut) *timedOut = true; return false; } @@ -421,8 +421,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) // Report any error that may occur. if (d->state != Connected) { -// setError(d->socket->error(), d->socket->errorString()); - if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) + if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; } diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 7de9a7d4c7..55bdd12748 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -464,7 +464,7 @@ void QLocalSocket::disconnectFromServer() QLocalSocket::LocalSocketError QLocalSocket::error() const { Q_D(const QLocalSocket); - switch (d->unixSocket.error()) { + switch (d->unixSocket.socketError()) { case QAbstractSocket::ConnectionRefusedError: return QLocalSocket::ConnectionRefusedError; case QAbstractSocket::RemoteHostClosedError: diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 622d5df131..3bce891ee9 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -594,7 +594,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString case ConnectError: case ControlSocketError: { - QAbstractSocket::SocketError controlSocketError = data->controlSocket->error(); + QAbstractSocket::SocketError controlSocketError = data->controlSocket->socketError(); if (socks5State != Connected) { switch (controlSocketError) { case QAbstractSocket::ConnectionRefusedError: @@ -918,7 +918,7 @@ void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification() return; // check if there needs to be a new zero read notification if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState - && data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) { + && data->controlSocket->socketError() == QAbstractSocket::RemoteHostClosedError) { connectData->readBuffer.clear(); emitReadNotification(); } @@ -1256,7 +1256,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr data->controlSocket->close(); emitConnectionNotification(); } else { - q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); + q_func()->setError(data->controlSocket->socketError(), data->controlSocket->errorString()); emitReadNotification(); emitWriteNotification(); } @@ -1348,7 +1348,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port) if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { if (!d->udpData->udpSocket->bind(address, port)) { QSOCKS5_Q_DEBUG << "local udp bind failed"; - setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); + setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); return false; } d->localAddress = d->udpData->udpSocket->localAddress(); @@ -1656,8 +1656,8 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI } if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) { //### try frgamenting - if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError) - setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); + if (d->udpData->udpSocket->socketError() == QAbstractSocket::DatagramTooLargeError) + setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); //### else maybe more serious error return -1; } @@ -1727,7 +1727,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut) return true; setErrorState(QSocks5SocketEnginePrivate::ControlSocketError); - if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) + if (timedOut && data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -1765,8 +1765,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) return true; - setError(d->data->controlSocket->error(), d->data->controlSocket->errorString()); - if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->data->controlSocket->socketError(), d->data->controlSocket->errorString()); + if (timedOut && d->data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -1775,8 +1775,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) } else { while (!d->readNotificationActivated) { if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { - setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); - if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); + if (timedOut && d->udpData->udpSocket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } diff --git a/src/network/ssl/qdtls_openssl.cpp b/src/network/ssl/qdtls_openssl.cpp index 25a6c5f49c..36b4d572fd 100644 --- a/src/network/ssl/qdtls_openssl.cpp +++ b/src/network/ssl/qdtls_openssl.cpp @@ -1125,7 +1125,7 @@ qint64 QDtlsPrivateOpenSSL::writeDatagramEncrypted(QUdpSocket *socket, // some errors can be just ignored (it's UDP, not TCP after all). // Unlike QSslSocket we do not abort though. QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); - if (socket->error() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { + if (socket->socketError() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString()); } else { setDtlsError(QDtlsError::TlsFatalError, diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 1b72be66fe..9286a9a622 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -549,7 +549,7 @@ bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state d->createPlainSocket(openMode); bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode); d->cachedSocketDescriptor = d->plainSocket->socketDescriptor(); - d->setError(d->plainSocket->error(), d->plainSocket->errorString()); + d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); setSocketState(state); setOpenMode(openMode); setLocalPort(d->plainSocket->localPort()); @@ -1651,7 +1651,7 @@ bool QSslSocket::waitForConnected(int msecs) bool retVal = d->plainSocket->waitForConnected(msecs); if (!retVal) { setSocketState(d->plainSocket->state()); - d->setError(d->plainSocket->error(), d->plainSocket->errorString()); + d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); } return retVal; } @@ -1820,7 +1820,7 @@ bool QSslSocket::waitForDisconnected(int msecs) bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed())); if (!retVal) { setSocketState(d->plainSocket->state()); - d->setError(d->plainSocket->error(), d->plainSocket->errorString()); + d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); } return retVal; } @@ -2668,7 +2668,7 @@ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error) readBufferMaxSize = tmpReadBufferMaxSize; } - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); } /*! diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 8fbbffcaca..41f933b299 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -993,7 +993,7 @@ void QSslSocketBackendPrivate::transmit() if (actualWritten < 0) { //plain socket write fails if it was in the pending close state. const ScopedBool bg(inSetAndEmitError, true); - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); return; } transmitting = true; diff --git a/src/network/ssl/qsslsocket_schannel.cpp b/src/network/ssl/qsslsocket_schannel.cpp index 31b0db4818..f9586b7862 100644 --- a/src/network/ssl/qsslsocket_schannel.cpp +++ b/src/network/ssl/qsslsocket_schannel.cpp @@ -582,7 +582,7 @@ bool QSslSocketBackendPrivate::sendToken(void *token, unsigned long tokenLength, if (written != qint64(tokenLength)) { // Failed to write/buffer everything or an error occurred if (emitError) - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); return false; } return true; @@ -1292,7 +1292,7 @@ void QSslSocketBackendPrivate::transmit() if (bytesWritten >= 0) { totalBytesWritten += bytesWritten; } else { - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); return; } } -- cgit v1.2.3 From 0de6c26ac17c90f513329fdbe87ef036fc25925a Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Tue, 7 Jan 2020 13:32:02 +0100 Subject: QLocalSocket - deprecate ambiguous 'error' overloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QLocalSocket::error is overloaded as a signal and an accessor (for the error reported by the signal). This means connecting to the signal using a pointer to member function would require ambiguity resolution. We deprecate the old accessor (to be removed in Qt 6) and introduce a new one - 'socketError'. [ChangeLog][Deprecation Notice] QLocalSocket::error() (the getter) is deprecated; superseded by socketError(). Task-number: QTBUG-80369 Change-Id: Iab346f7b4cd1024dee9e5ef71b4b7e09f6d95b12 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/socket/qlocalsocket.cpp | 24 +++++++++++++++++++----- src/network/socket/qlocalsocket.h | 7 ++++++- src/network/socket/qlocalsocket_tcp.cpp | 7 +++++++ src/network/socket/qlocalsocket_unix.cpp | 7 +++++++ src/network/socket/qlocalsocket_win.cpp | 7 +++++++ 5 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index d35f838af5..d517f91aad 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -220,11 +220,25 @@ QT_BEGIN_NAMESPACE /*! \fn QLocalSocket::LocalSocketError QLocalSocket::error() const + \deprecated + + Use socketError() instead. + + Returns the type of error that last occurred. + + \sa state(), errorString(), socketError() +*/ + +/*! + \fn QLocalSocket::LocalSocketError QLocalSocket::socketError() const + \since 5.15 + Returns the type of error that last occurred. \sa state(), errorString() */ + /*! \fn bool QLocalSocket::isValid() const @@ -272,7 +286,7 @@ QT_BEGIN_NAMESPACE Waits until the socket is connected, up to \a msecs milliseconds. If the connection has been established, this function returns \c true; otherwise it returns \c false. In the case where it returns \c false, you can call - error() to determine the cause of the error. + socketError() to determine the cause of the error. The following example waits up to one second for a connection to be established: @@ -291,7 +305,7 @@ QT_BEGIN_NAMESPACE connection was successfully disconnected, this function returns \c true; otherwise it returns \c false (if the operation timed out, if an error occurred, or if this QLocalSocket is already disconnected). In the case - where it returns \c false, you can call error() to determine the cause of + where it returns \c false, you can call socketError() to determine the cause of the error. The following example waits up to one second for a connection @@ -337,7 +351,7 @@ QT_BEGIN_NAMESPACE connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). - \sa error(), errorString(), {Creating Custom Qt Types} + \sa socketError(), errorString(), {Creating Custom Qt Types} */ /*! @@ -446,7 +460,7 @@ QString QLocalSocket::fullServerName() const /*! Returns the state of the socket. - \sa error() + \sa socketError() */ QLocalSocket::LocalSocketState QLocalSocket::state() const { @@ -466,7 +480,7 @@ bool QLocalSocket::isSequential() const The LocalServerError enumeration represents the errors that can occur. The most recent error can be retrieved through a call to - \l QLocalSocket::error(). + \l QLocalSocket::socketError(). \value ConnectionRefusedError The connection was refused by the peer (or timed out). diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index 1876a6ac0d..9cf76d1022 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -97,7 +97,12 @@ public: virtual bool canReadLine() const override; virtual bool open(OpenMode openMode = ReadWrite) override; virtual void close() override; - LocalSocketError error() const; + +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use socketError()") LocalSocketError error() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + + LocalSocketError socketError() const; bool flush(); bool isValid() const; qint64 readBufferSize() const; diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 41e5b47627..74d3d547b9 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -363,7 +363,14 @@ void QLocalSocket::disconnectFromServer() d->tcpSocket->disconnectFromHost(); } +#if QT_DEPRECATED_SINCE(5, 15) QLocalSocket::LocalSocketError QLocalSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +QLocalSocket::LocalSocketError QLocalSocket::socketError() const { Q_D(const QLocalSocket); switch (d->tcpSocket->error()) { diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 55bdd12748..2e2eb7dee9 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -461,7 +461,14 @@ void QLocalSocket::disconnectFromServer() d->unixSocket.disconnectFromHost(); } +#if QT_DEPRECATED_SINCE(5, 15) QLocalSocket::LocalSocketError QLocalSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +QLocalSocket::LocalSocketError QLocalSocket::socketError() const { Q_D(const QLocalSocket); switch (d->unixSocket.socketError()) { diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 4decbd5ded..657790519b 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -330,7 +330,14 @@ void QLocalSocket::disconnectFromServer() } } +#if QT_DEPRECATED_SINCE(5, 15) QLocalSocket::LocalSocketError QLocalSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +QLocalSocket::LocalSocketError QLocalSocket::socketError() const { Q_D(const QLocalSocket); return d->error; -- cgit v1.2.3 From 69e7dfdb289b65ac27b581a164aefbbc28fc4fae Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@qt.io> Date: Thu, 9 Jan 2020 10:50:35 +0100 Subject: Remove QShaderDescription::toBinaryJson(), deprecated fromBinaryJson() Binary Json is deprecated and we should not use it. We can already serialize shaders to CBOR. Push the deprecation warning mechanism to the only user of fromBinaryJson(). Change-Id: I1d56157ab92f74eaab49400be647317e7833e35e Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/rhi/qshader.cpp | 13 +++++++++++-- src/gui/rhi/qshaderdescription.cpp | 37 ++++++++----------------------------- src/gui/rhi/qshaderdescription_p.h | 4 +++- 3 files changed, 22 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 0b99281f08..9203d63cd2 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -439,10 +439,19 @@ QShader QShader::fromSerialized(const QByteArray &data) d->stage = Stage(intVal); QByteArray descBin; ds >> descBin; - if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) + if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { d->desc = QShaderDescription::fromCbor(descBin); - else + } else { +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED d->desc = QShaderDescription::fromBinaryJson(descBin); + QT_WARNING_POP +#else + qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); + d->desc = QShaderDescription(); +#endif + } int count; ds >> count; for (int i = 0; i < count; ++i) { diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index 7e9b7d7b8e..76c5d0ebef 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE float \c opacity at offset 64. All this is described by a QShaderDescription object. QShaderDescription - can also be serialized to JSON and binary JSON, and can be deserialized - from binary JSON. In practice this is rarely needed since QShader + can also be serialized to JSON and CBOR, and can be deserialized + from CBOR. In practice this is rarely needed since QShader takes care of the associated QShaderDescription automatically, but if the QShaderDescription of the above shader would be written out as JSON, it would look like the following: @@ -335,29 +335,11 @@ bool QShaderDescription::isValid() const || !d->combinedImageSamplers.isEmpty() || !d->storageImages.isEmpty(); } -/*! - \return a serialized binary version of the data. - - \sa toJson(), toCbor() - */ -QByteArray QShaderDescription::toBinaryJson() const -{ -#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - return d->makeDoc().toBinaryData(); -QT_WARNING_POP -#else - qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); - return QByteArray(); -#endif -} - /*! \return a serialized binary version of the data in CBOR (Concise Binary Object Representation) format. - \sa QCborValue, toBinaryJson(), toJson() + \sa QCborValue, toJson() */ QByteArray QShaderDescription::toCbor() const { @@ -369,14 +351,17 @@ QByteArray QShaderDescription::toCbor() const \note There is no deserialization method provided for JSON text. - \sa toBinaryJson(), toCbor() + \sa toCbor() */ QByteArray QShaderDescription::toJson() const { return d->makeDoc().toJson(); } +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + Deserializes the given binary JSON \a data and returns a new QShaderDescription. @@ -385,22 +370,16 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); QT_WARNING_POP -#else - Q_UNUSED(data); - qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); -#endif return desc; } +#endif /*! Deserializes the given CBOR \a data and returns a new QShaderDescription. - - \sa fromBinaryJson() */ QShaderDescription QShaderDescription::fromCbor(const QByteArray &data) { diff --git a/src/gui/rhi/qshaderdescription_p.h b/src/gui/rhi/qshaderdescription_p.h index e02a53dcb5..872ee8b138 100644 --- a/src/gui/rhi/qshaderdescription_p.h +++ b/src/gui/rhi/qshaderdescription_p.h @@ -68,11 +68,13 @@ public: bool isValid() const; - QByteArray toBinaryJson() const; QByteArray toCbor() const; QByteArray toJson() const; +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use CBOR format instead") static QShaderDescription fromBinaryJson(const QByteArray &data); +#endif static QShaderDescription fromCbor(const QByteArray &data); enum VariableType { -- cgit v1.2.3 From 76c4c5d5581b2cd36a043234eb167dd55041301d Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Fri, 10 Jan 2020 11:32:40 +0100 Subject: QSslSocket: deprecate sslErrors() getter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To disambiguate &QSslSocket::sslErrors() expression. Add a new getter - sslHandshakeErrors(). [ChangeLog][Deprecation Notice] QSslSocket::sslErrors() (the getter) was deprecated and superseded by sslHandshakeErrors() Task-number: QTBUG-80369 Change-Id: I9dcca3c8499800c122db230753dc19b07654f8a2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/ssl/qsslsocket.cpp | 27 ++++++++++++++++++++++++--- src/network/ssl/qsslsocket.h | 5 ++++- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 9286a9a622..cf971a30bf 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -289,7 +289,7 @@ If you want to continue connecting despite the errors that have occurred, you must call QSslSocket::ignoreSslErrors() from inside a slot connected to this signal. If you need to access the error list at a later point, you - can call sslErrors() (without arguments). + can call sslHandshakeErrors(). \a errors contains one or more errors that prevent QSslSocket from verifying the identity of the peer. @@ -1825,15 +1825,36 @@ bool QSslSocket::waitForDisconnected(int msecs) return retVal; } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + + Use sslHandshakeErrors() instead. + Returns a list of the last SSL errors that occurred. This is the same list as QSslSocket passes via the sslErrors() signal. If the connection has been encrypted with no errors, this function will return an empty list. - \sa connectToHostEncrypted() + \sa connectToHostEncrypted(), sslHandshakeErrors() */ QList<QSslError> QSslSocket::sslErrors() const +{ + return sslHandshakeErrors(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns a list of the last SSL errors that occurred. This is the + same list as QSslSocket passes via the sslErrors() signal. If the + connection has been encrypted with no errors, this function will + return an empty list. + + \sa connectToHostEncrypted() +*/ +QList<QSslError> QSslSocket::sslHandshakeErrors() const { Q_D(const QSslSocket); return d->sslErrors; @@ -2035,7 +2056,7 @@ void QSslSocket::ignoreSslErrors() You can clear the list of errors you want to ignore by calling this function with an empty list. - \sa sslErrors() + \sa sslErrors(), sslHandshakeErrors() */ void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors) { diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index 843e2d15f5..2c3b876c49 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -192,7 +192,10 @@ public: bool waitForBytesWritten(int msecs = 30000) override; bool waitForDisconnected(int msecs = 30000) override; - QList<QSslError> sslErrors() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use sslHandshakeErrors()") QList<QSslError> sslErrors() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + QList<QSslError> sslHandshakeErrors() const; static bool supportsSsl(); static long sslLibraryVersionNumber(); -- cgit v1.2.3 From c584380c6901b1bcd9f8100fa1087b09d3cb023d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Fri, 10 Jan 2020 13:20:42 +0100 Subject: Windows QPA: Update documentation on command line options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort alphabetically and add recent relevant options with version information. Change-Id: I10c8cc82ce357775ed68cb811a0c906cd38633a5 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/kernel/qguiapplication.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bdcea275c3..2b3299f745 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -605,8 +605,13 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME The following parameters are available for \c {-platform windows}: \list + \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as + Qt::GroupSwitchModifier (since Qt 5.12). \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. + + \li \c {dpiawareness=[0|1|2} Sets the DPI awareness of the process + (see \l{High DPI Displays}, since Qt 5.4). \li \c {fontengine=freetype}, uses the FreeType font engine. \li \c {menus=[native|none]}, controls the use of native menus. @@ -616,10 +621,23 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME provide hover signals. They are mainly intended for Qt Quick. By default, they will be used if the application is not an instance of QApplication or for Qt Quick Controls 2 - applications. + applications (since Qt 5.10). - \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as - Qt::GroupSwitchModifier. + \li \c {nocolorfonts} Turn off DirectWrite Color fonts + (since Qt 5.8). + + \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). + + \li \c {nomousefromtouch} Ignores mouse events synthesized + from touch events by the operating system. + + \li \c {nowmpointer} Switches from Pointer Input Messages handling + to legacy mouse handling (since Qt 5.12). + \li \c {reverse} Activates Right-to-left mode (experimental). + Windows title bars will be shown accordingly in Right-to-left locales + (since Qt 5.13). + \li \c {tabletabsoluterange=<value>} Sets a value for mouse mode detection + of WinTab tablets (Legacy, since Qt 5.3). \endlist The following parameter is available for \c {-platform cocoa} (on macOS): -- cgit v1.2.3 From 577d698b8e72bc0969ae7545a1a56d3a3d08bdda Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Mon, 16 Dec 2019 20:09:25 +0100 Subject: QString::isLower/isUpper: redo the implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use QStringIterator rather than indexed loops. This fixes handling of non-BMP code points (which may be lower or uppercase, see the test). Change also the semantics of the functions, adopting Unicode §3.13 definitions: a string is lowercase/uppercase if it's equal to its own toLower/toUpper folding. As a side effect, empty strings are now correctly reported to be lowercase AND uppercase. [ChangeLog][Important Behavior Changes] The semantics of QString::isLower() and QString::isUpper() have been changed to match the Unicode specification. Now lowercase (resp. uppercase) strings are allowed to contain any character; a string is considered lowercase (resp. uppercase) if it's equal to its own toLower() (resp. toUpper()) folding. Previously, a non-letter character would make the string not lowercase nor uppercase, and the mere presence of an uppercase (resp. lowercase) letter would make isLower() (resp. isUpper()) return false, even if the letter wouldn't change under case folding. As a consequence, now empty strings are lowercase and uppercase. [ChangeLog][QtCore][QString] Fixed a number of bugs of QString::isLower() and QString::isUpper(). Empty strings are now correctly reported to be lowercase (resp. uppercase), and strings containing code points outside the BMP are now correctly handled. Note that the behavior of these functions has also been changed. Change-Id: Iba1398279a072399a9f21295fe75f6e414f3f813 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qstring.cpp | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index b929786255..fa8b5cf3f8 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -5109,21 +5109,25 @@ bool QString::endsWith(QChar c, Qt::CaseSensitivity cs) const } /*! - Returns \c true if the string only contains uppercase letters, - otherwise returns \c false. + Returns \c true if the string is uppercase, that is, it's identical + to its toUpper() folding. + + Note that this does \e not mean that the string does not contain + lowercase letters (some lowercase letters do not have a uppercase + folding; they are left unchanged by toUpper()). + For more information, refer to the Unicode standard, section 3.13. + \since 5.12 - \sa QChar::isUpper(), isLower() + \sa QChar::toUpper(), isLower() */ bool QString::isUpper() const { - if (isEmpty()) - return false; + QStringIterator it(*this); - const QChar *d = data(); - - for (int i = 0, max = size(); i < max; ++i) { - if (!d[i].isUpper()) + while (it.hasNext()) { + uint uc = it.nextUnchecked(); + if (qGetProp(uc)->cases[QUnicodeTables::UpperCase].diff) return false; } @@ -5131,21 +5135,25 @@ bool QString::isUpper() const } /*! - Returns \c true if the string only contains lowercase letters, - otherwise returns \c false. + Returns \c true if the string is lowercase, that is, it's identical + to its toLower() folding. + + Note that this does \e not mean that the string does not contain + uppercase letters (some uppercase letters do not have a lowercase + folding; they are left unchanged by toLower()). + For more information, refer to the Unicode standard, section 3.13. + \since 5.12 - \sa QChar::isLower(), isUpper() + \sa QChar::toLower(), isUpper() */ bool QString::isLower() const { - if (isEmpty()) - return false; + QStringIterator it(*this); - const QChar *d = data(); - - for (int i = 0, max = size(); i < max; ++i) { - if (!d[i].isLower()) + while (it.hasNext()) { + uint uc = it.nextUnchecked(); + if (qGetProp(uc)->cases[QUnicodeTables::LowerCase].diff) return false; } -- cgit v1.2.3 From 2f536411d8d6918a8fed53198190d60fe188b0a4 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Mon, 6 Jan 2020 11:51:07 +0100 Subject: QRegularExpression: minor doc fixes Amends d24a1d4323e73400ef4ecca99e03ff0f41c60389 Change-Id: I108f85b174e21ef71bf269fb9f6725972e76f107 Reviewed-by: David Faure <david.faure@kdab.com> --- src/corelib/text/qregularexpression.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 8627cbba4f..67be67c243 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -463,10 +463,10 @@ QT_BEGIN_NAMESPACE \c{\xHHHH} with more than 2 digits. A pattern like \c{\x2022} neeeds to be ported to \c{\x{2022}}, or it will match a space (\c{0x20}) followed by the string \c{"22"}. In general, it is highly recommended to always use - curly braces with the \c{\\x} escape, no matter the amount of digits + curly braces with the \c{\x} escape, no matter the amount of digits specified. - \li A 0-to-n quantification like \c{{,n}} needs to be ported to c{{0,n}} to + \li A 0-to-n quantification like \c{{,n}} needs to be ported to \c{{0,n}} to preserve semantics. Otherwise, a pattern such as \c{\d{,3}} would actually match a digit followed by the exact string \c{"{,3}"}. -- cgit v1.2.3 From 3d1e257770e8c79c7cd9a08f9caf1bd8395cb10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> Date: Thu, 31 Oct 2019 09:33:40 +0100 Subject: Wasm: Support event loop wakeup from secondary threads Minimal fix for the missing wakeup issue, in leu of a new event loop implementation. So far, emscripten_async_run_in_main_runtime_thread_ looks to be our option for scheduling calls on the main thread. This function is available on emsdk 1.38.22 and higher. Requires making from QEventDispatcherUNIX::wakeUp() non-final. The future event dispatcher implementation will not inherit QEventDispatcherUNIX, so this is a temporary change. Fixes: QTBUG-75793 Task-number: QTBUG-76007 Change-Id: Ie6f6ee6f7674206fc0673a4fe866ac614432ab65 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> --- src/corelib/kernel/qeventdispatcher_unix_p.h | 2 +- .../platforms/wasm/qwasmeventdispatcher.cpp | 23 ++++++++++++++++++++++ src/plugins/platforms/wasm/qwasmeventdispatcher.h | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index f37edfc967..581df9242c 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -118,7 +118,7 @@ public: int remainingTime(int timerId) final; - void wakeUp() final; + void wakeUp() override; void interrupt() final; void flush() override; diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index 41355d72ae..d89cd78b28 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -33,6 +33,14 @@ #include <emscripten.h> +#if (__EMSCRIPTEN_major__ > 1 || __EMSCRIPTEN_minor__ > 38 || __EMSCRIPTEN_minor__ == 38 && __EMSCRIPTEN_tiny__ >= 22) +# define EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD +#endif + +#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD +#include <emscripten/threading.h> +#endif + class QWasmEventDispatcherPrivate : public QEventDispatcherUNIXPrivate { @@ -179,3 +187,18 @@ void QWasmEventDispatcher::doMaintainTimers() emscripten_async_call(callback, this, toWaitDuration); m_currentTargetTime = newTargetTime; } + +void QWasmEventDispatcher::wakeUp() +{ +#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD + if (!emscripten_is_main_runtime_thread()) + emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); +#endif + QEventDispatcherUNIX::wakeUp(); +} + +void QWasmEventDispatcher::mainThreadWakeUp(void *eventDispatcher) +{ + emscripten_resume_main_loop(); // Service possible requestUpdate Calls + static_cast<QWasmEventDispatcher *>(eventDispatcher)->processEvents(QEventLoop::AllEvents); +} diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.h b/src/plugins/platforms/wasm/qwasmeventdispatcher.h index 5300b3de73..f72d92ce07 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.h +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.h @@ -51,6 +51,8 @@ public: protected: bool processEvents(QEventLoop::ProcessEventsFlags flags) override; void doMaintainTimers(); + void wakeUp() override; + static void mainThreadWakeUp(void *eventDispatcher); private: bool m_hasMainLoop = false; -- cgit v1.2.3 From a16c37b78fff5c4b24328d52bf9b2c7f57db0d12 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Sat, 11 Jan 2020 12:36:01 +0100 Subject: Enforce that char16_t / char32_t are 16/32 bits The standard makes them as big as int_least16_t / 32_t, i.e. big enough to hold UTF-16 / UTF-32 code units. We're relying on them to be *exactly* 16/32 bit instead. Drive by: move the check that a char is 8 bits before saying that some other type is not its expected sizeof() * 8. Change-Id: Idbf3d33331667d417702d9dde221905bcfc4d021 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qglobal.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 20046e3fcf..da69628d2b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -139,10 +139,12 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); // in. The idea here is to error or warn if otherwise implicit Qt // assumptions are not fulfilled on new hardware or compilers // (if this list becomes too long, consider factoring into a separate file) -Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits"); Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); +Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits"); Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly"); Q_STATIC_ASSERT_X(sizeof(float) == 4, "Qt assumes that float is 32 bits"); +Q_STATIC_ASSERT_X(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits"); +Q_STATIC_ASSERT_X(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits"); // While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011 // Annex F (C11, normative for C++11), there are a few corner cases regarding -- cgit v1.2.3 From 18e06c37e10943f4b4f6d57b7044b9bce3a23202 Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva <neluhus.vagus@gmail.com> Date: Mon, 30 Dec 2019 14:40:03 +0300 Subject: wasm: do not get canvas as property of js global object You cannot be sure that property with specified key in a global object is really a canvas. Should use `document.getElementById`. Change-Id: Ife55adaad5517aed64122b0c9bff32489cf19a2f Reviewed-by: Lorn Potter <lorn.potter@gmail.com> --- src/plugins/platforms/wasm/qwasmclipboard.cpp | 4 +++- src/plugins/platforms/wasm/qwasmcursor.cpp | 8 ++++++-- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 12 +++++++----- src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 2 +- src/plugins/platforms/wasm/qwasmscreen.cpp | 9 ++++++--- 5 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp index d4a1e4dd50..fb46f1534f 100644 --- a/src/plugins/platforms/wasm/qwasmclipboard.cpp +++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp @@ -198,7 +198,9 @@ void QWasmClipboard::installEventHandlers(const QString &canvasId) return; // Fallback path for browsers which do not support direct clipboard access - val canvas = val::global(canvasId.toUtf8().constData()); + val document = val::global("document"); + val canvas = document.call<val>("getElementById", val(canvasId.toUtf8().constData())); + canvas.call<void>("addEventListener", std::string("cut"), val::module_property("qtClipboardCutTo")); canvas.call<void>("addEventListener", std::string("copy"), diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 28ec3b58dd..c04fa6441a 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -36,6 +36,8 @@ #include <emscripten/emscripten.h> #include <emscripten/bind.h> +using namespace emscripten; + void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (!windowCursor || !window) @@ -54,8 +56,10 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) htmlCursorName = "auto"; // Set cursor on the canvas - QString canvasId = QWasmScreen::get(screen)->canvasId(); - emscripten::val canvasStyle = emscripten::val::global(canvasId.toUtf8().constData())["style"]; + QByteArray canvasId = QWasmScreen::get(screen)->canvasId().toUtf8(); + val document = val::global("document"); + val canvas = document.call<val>("getElementById", val(canvasId.constData())); + val canvasStyle = canvas["style"]; canvasStyle.set("cursor", emscripten::val(htmlCursorName.constData())); } diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index ad94ba9c77..8b7d00082f 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -47,9 +47,10 @@ #include <iostream> -QT_BEGIN_NAMESPACE using namespace emscripten; +QT_BEGIN_NAMESPACE + typedef struct emkb2qt { const char *em; unsigned int qt; @@ -353,10 +354,11 @@ void QWasmEventTranslator::initEventHandlers() g_useNaturalScrolling = false; // make this !default on macOS if (emscripten::val::global("window")["safari"].isUndefined()) { - - emscripten::val::global(canvasId).call<void>("addEventListener", - std::string("wheel"), - val::module_property("qtMouseWheelEvent")); + val document = val::global("document"); + val canvas = document.call<val>("getElementById", val(canvasId)); + canvas.call<void>("addEventListener", + std::string("wheel"), + val::module_property("qtMouseWheelEvent")); } } diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 0532b7e726..501ab99116 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -106,7 +106,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons attributes.depth = useDepthStencil; attributes.stencil = useDepthStencil; - EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes); + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toUtf8().constData(), &attributes); return context; } diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 37f1ea832a..fe44fdb096 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -44,6 +44,7 @@ #include <QtGui/qguiapplication.h> #include <private/qhighdpiscaling_p.h> +using namespace emscripten; QT_BEGIN_NAMESPACE @@ -182,13 +183,15 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize() QSizeF cssSize(css_width, css_height); QSizeF canvasSize = cssSize * devicePixelRatio(); - emscripten::val canvas = emscripten::val::global(canvasId.constData()); + val document = val::global("document"); + val canvas = document.call<val>("getElementById", val(canvasId.constData())); + canvas.set("width", canvasSize.width()); canvas.set("height", canvasSize.height()); QPoint offset; - offset.setX(emscripten::val::global(canvasId.constData())["offsetTop"].as<int>()); - offset.setY(emscripten::val::global(canvasId.constData())["offsetLeft"].as<int>()); + offset.setX(canvas["offsetTop"].as<int>()); + offset.setY(canvas["offsetLeft"].as<int>()); emscripten::val rect = canvas.call<emscripten::val>("getBoundingClientRect"); QPoint position(rect["left"].as<int>() - offset.x(), rect["top"].as<int>() - offset.y()); -- cgit v1.2.3 From 76fbe75abee7d77911467d56630176f777e8ed78 Mon Sep 17 00:00:00 2001 From: Rainer Keller <Rainer.Keller@qt.io> Date: Tue, 7 Jan 2020 09:13:21 +0100 Subject: Remove empty block at beginning of imported markdown An empty QTextDocument already contains a block; so when the formatting is fully determined, if the document is still empty, then instead of inserting a new block, we can set formatting on the cursor, which affects the pre-existing block, before inserting text. This avoids leaving a blank line (the default block) above the inserted content. Fixes: QTBUG-81060 Change-Id: I14e45e300a602493aa59680417d74d4c2b25862d Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/gui/text/qtextmarkdownimporter.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 78d18a714b..88965046ce 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -207,7 +207,12 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det) charFmt.setFontWeight(QFont::Bold); blockFmt.setHeadingLevel(int(detail->level)); m_needsInsertBlock = false; - m_cursor->insertBlock(blockFmt, charFmt); + if (m_doc->isEmpty()) { + m_cursor->setBlockFormat(blockFmt); + m_cursor->setCharFormat(charFmt); + } else { + m_cursor->insertBlock(blockFmt, charFmt); + } qCDebug(lcMD, "H%d", detail->level); } break; case MD_BLOCK_LI: { @@ -592,7 +597,12 @@ void QTextMarkdownImporter::insertBlock() blockFormat.setMarker(m_markerType); if (!m_listStack.isEmpty()) blockFormat.setIndent(m_listStack.count()); - m_cursor->insertBlock(blockFormat, charFormat); + if (m_doc->isEmpty()) { + m_cursor->setBlockFormat(blockFormat); + m_cursor->setCharFormat(charFormat); + } else { + m_cursor->insertBlock(blockFormat, charFormat); + } if (m_needsInsertList) { m_listStack.push(m_cursor->createList(m_listFormat)); } else if (!m_listStack.isEmpty() && m_listItem) { -- cgit v1.2.3 From f936ca4f86e359cb919be9d21ad239618a878559 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Sun, 12 Jan 2020 11:32:06 -0800 Subject: qglobal.h: remove non-ASCII quotes from comment Because MSVC warns. Added by me on commit. c496fee2a5b65fd1b0672923293db058486e350e Fixes: QTBUG-81310 Change-Id: I596aec77785a4e4e84d5fffd15e93a8e367e035e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/corelib/global/qglobal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e636a7cf8f..fe8e8e8bc8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -945,7 +945,7 @@ QT_WARNING_POP #endif QT_WARNING_PUSH -// warning: noexcept-expression evaluates to ‘false’ because of a call to ‘void swap(..., ...)' +// warning: noexcept-expression evaluates to 'false' because of a call to 'void swap(..., ...)' QT_WARNING_DISABLE_GCC("-Wnoexcept") namespace QtPrivate -- cgit v1.2.3 From 04f6073da2eb9af1d0728aa688c906b682a44801 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Thu, 9 Jan 2020 10:35:12 +0100 Subject: ICC compile-fix for __builtin_add_overflow()'s parameter type Based on Glen Johnson's patch, but rearranged to avoid repetition. Fixes: QTBUG-81248 Change-Id: I9c23ab233ebd5514bc05fd155999597ada7295ef Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qnumeric_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index fdfcbda6ca..7418579fe0 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -249,7 +249,8 @@ QT_WARNING_POP // size_t. Implementations for 8- and 16-bit types will work but may not be as // efficient. Implementations for 64-bit may be missing on 32-bit platforms. -#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || __has_builtin(__builtin_add_overflow) +#if ((defined(Q_CC_INTEL) ? (Q_CC_INTEL >= 1800 && !defined(Q_OS_WIN)) : defined(Q_CC_GNU)) \ + && Q_CC_GNU >= 500) || __has_builtin(__builtin_add_overflow) // GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows template <typename T> inline -- cgit v1.2.3 From 41b44c6f21442892e2c0749940f716dc91c74b1f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge <shawn.rutledge@qt.io> Date: Wed, 1 Jan 2020 06:24:26 +0100 Subject: doc: explain QWheelEvent::angleDelta() more thoroughly It has been a QPoint for a long time now, to support both the usual vertical mouse wheel and also the wheel tilt for horizontal scrolling, or the actual horizontal wheel if the mouse has one, or the simulation of a horizontal wheel via touchpad gestures; but the docs continued to read as if it was just one value. Task-number: QTBUG-71575 Change-Id: I3efa686ace4f09c7f237f72bf0500fbfbd3213cb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> --- src/gui/kernel/qevent.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index f555f4dc05..0706ae3e90 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -667,9 +667,9 @@ QHoverEvent::~QHoverEvent() if that widget does not handle the event they are sent to the focus widget. Wheel events are generated for both mouse wheels and trackpad scroll gestures. There are two ways to read the - wheel event delta: angleDelta() returns the delta in wheel - degrees. This value is always provided. pixelDelta() returns - the delta in screen pixels and is available on platforms that + wheel event delta: angleDelta() returns the deltas in wheel + degrees. These values are always provided. pixelDelta() returns + the deltas in screen pixels, and is available on platforms that have high-resolution trackpads, such as \macos. If that is the case, source() will return Qt::MouseEventSynthesizedBySystem. @@ -852,7 +852,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, by \a globalPos. \a pixelDelta contains the scrolling distance in pixels on screen, while - \a angleDelta contains the wheel rotation distance. \a pixelDelta is + \a angleDelta contains the wheel rotation angle. \a pixelDelta is optional and can be null. The mouse and keyboard states at the time of the event are specified by @@ -914,10 +914,16 @@ QWheelEvent::~QWheelEvent() /*! \fn QPoint QWheelEvent::angleDelta() const - Returns the distance that the wheel is rotated, in eighths of a - degree. A positive value indicates that the wheel was rotated - forwards away from the user; a negative value indicates that the - wheel was rotated backwards toward the user. + Returns the relative amount that the wheel was rotated, in eighths of a + degree. A positive value indicates that the wheel was rotated forwards away + from the user; a negative value indicates that the wheel was rotated + backwards toward the user. \c angleDelta().y() provides the angle through + which the common vertical mouse wheel was rotated since the previous event. + \c angleDelta().x() provides the angle through which the horizontal mouse + wheel was rotated, if the mouse has a horizontal wheel; otherwise it stays + at zero. Some mice allow the user to tilt the wheel to perform horizontal + scrolling, and some touchpads support a horizontal scrolling gesture; that + will also appear in \c angleDelta().x(). Most mouse types work in steps of 15 degrees, in which case the delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees. @@ -926,7 +932,9 @@ QWheelEvent::~QWheelEvent() that are less than 120 units (less than 15 degrees). To support this possibility, you can either cumulatively add the delta values from events until the value of 120 is reached, then scroll the widget, or you can - partially scroll the widget in response to each wheel event. + partially scroll the widget in response to each wheel event. But to + provide a more native feel, you should prefer \l pixelDelta() on platforms + where it's available. Example: @@ -937,6 +945,8 @@ QWheelEvent::~QWheelEvent() \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin), \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). \endlist + + \see pixelDelta() */ /*! -- cgit v1.2.3 From 9233ffa2d10094faeea05b48c9779ad73942e6a1 Mon Sep 17 00:00:00 2001 From: Paul Wicking <paul.wicking@qt.io> Date: Mon, 13 Jan 2020 11:48:21 +0100 Subject: Doc: Don't document QTextStreamManipulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-81002 Change-Id: Ic7d0516a25a8a6e63e1a305ca87498948d41013c Reviewed-by: Topi Reiniö <topi.reinio@qt.io> --- src/corelib/doc/src/dontdocument.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/doc/src/dontdocument.qdoc b/src/corelib/doc/src/dontdocument.qdoc index 19ca7db299..ff0aa98709 100644 --- a/src/corelib/doc/src/dontdocument.qdoc +++ b/src/corelib/doc/src/dontdocument.qdoc @@ -37,5 +37,5 @@ QCborValueRef qfloat16 QDeferredDeleteEvent QSpecialInteger QLittleEndianStorageType QBigEndianStorageType QFactoryInterface QFutureWatcherBase QJsonValuePtr QJsonValueRefPtr QLinkedListNode QAbstractConcatenable QStringBuilderCommon - QTextCodec::ConverterState QThreadStorageData) + QTextCodec::ConverterState QThreadStorageData QTextStreamManipulator) */ -- cgit v1.2.3 From ccb2cb84f535b0bfce19a95d7f3a36803480cae8 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Fri, 10 Jan 2020 14:15:35 +0100 Subject: QNetworkReply: deprecate the 'error' getter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To disambiguate &QNetworkReply::error expression. [ChangeLog][Deprecation Notice] QNetworkReply::error() (the getter) was deprecated; superseded by networkError(). Task-number: QTBUG-80369 Change-Id: I545f963788bce0800c9e0f0c94d5f1029946effe Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/access/qnetworkreply.cpp | 25 +++++++++++++++++++++++-- src/network/access/qnetworkreply.h | 7 ++++++- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index fb30bfd4f1..0a5a17a3b8 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -554,13 +554,34 @@ QNetworkAccessManager::Operation QNetworkReply::operation() const return d_func()->operation; } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + + Use networkError() instead. + Returns the error that was found during the processing of this request. If no error was found, returns NoError. - \sa setError() + \sa setError(), networkError() */ +/* QNetworkReply::NetworkError QNetworkReply::error() const +{ + return networkError(); +} +*/ +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns the error that was found during the processing of this + request. If no error was found, returns NoError. + + \sa setError() +*/ +QNetworkReply::NetworkError QNetworkReply::networkError() const { return d_func()->errorCode; } @@ -858,7 +879,7 @@ void QNetworkReply::setRequest(const QNetworkRequest &request) Calling setError() does not emit the error(QNetworkReply::NetworkError) signal. - \sa error(), errorString() + \sa error(), errorString(), networkError() */ void QNetworkReply::setError(NetworkError errorCode, const QString &errorString) { diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h index 4a402daa91..1bcb6d9680 100644 --- a/src/network/access/qnetworkreply.h +++ b/src/network/access/qnetworkreply.h @@ -124,7 +124,12 @@ public: QNetworkAccessManager *manager() const; QNetworkAccessManager::Operation operation() const; QNetworkRequest request() const; - NetworkError error() const; + +#if QT_DEPRECATED_SINCE(5, 15) + // QT_DEPRECATED_X("Use networkError()") NetworkError error() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + NetworkError networkError() const; + bool isFinished() const; bool isRunning() const; QUrl url() const; -- cgit v1.2.3 From 62e98af40f97b865aeed897e90231e76b329d614 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Thu, 9 Jan 2020 15:08:11 +0100 Subject: rhi: gl: Do not issue glMemoryBarrier when compute is not supported Avoid crashing in a < GLES 3.1 and < GL 4.3 contexts. Change-Id: I0f713a527890ec209c967ebb6c5bb3baa77d9a31 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> --- src/gui/rhi/qrhigles2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index afa3a397e6..81a1daa16b 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2287,12 +2287,13 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) barriers |= GL_ALL_BARRIER_BITS; } } - if (barriers) + if (barriers && caps.compute) f->glMemoryBarrier(barriers); } break; case QGles2CommandBuffer::Command::Barrier: - f->glMemoryBarrier(cmd.args.barrier.barriers); + if (caps.compute) + f->glMemoryBarrier(cmd.args.barrier.barriers); break; default: break; -- cgit v1.2.3 From 9a0ab41f28042c7f27208337e419435d16f00006 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Wed, 8 Jan 2020 12:55:57 +0100 Subject: rhi: gl: vulkan: Generate barriers between dispatches in a compute pass The new float16texture_with_compute manual test demonstrates a case that was not handled correctly before: multiple dispatch() calls in a row storing to and then loading from the same subresource(s). Without the appropriate barriers subtle data corruption issues appear. For Vulkan this also adds better batching for image/buffer barriers when using deferred recording. Also, for OpenGL this fixes the case of updating a buffer or rendering into a texture and then using it for load/store in a compute pass (previously this also lacked an appropriate glMemoryBarrier). Task-number: QTBUG-81217 Change-Id: I7970c445564473f9452662f4b1a20618cb8627a3 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Johan Helsing <johan.helsing@qt.io> --- src/gui/rhi/qrhigles2.cpp | 124 +++++++++++++++++++++++++++++++--- src/gui/rhi/qrhigles2_p_p.h | 11 +++ src/gui/rhi/qrhivulkan.cpp | 157 +++++++++++++++++++++++++++++++++++++++++-- src/gui/rhi/qrhivulkan_p_p.h | 17 ++++- 4 files changed, 291 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 81a1daa16b..ec5e531e14 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -269,6 +269,14 @@ QT_BEGIN_NAMESPACE #define GL_ALL_BARRIER_BITS 0xFFFFFFFF #endif +#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#endif + +#ifndef GL_SHADER_STORAGE_BARRIER_BIT +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#endif + #ifndef GL_VERTEX_PROGRAM_POINT_SIZE #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 #endif @@ -1307,6 +1315,21 @@ QRhi::FrameOpResult QRhiGles2::finish() return QRhi::FrameOpSuccess; } +static bool bufferAccessIsWrite(QGles2Buffer::Access access) +{ + return access == QGles2Buffer::AccessStorageWrite + || access == QGles2Buffer::AccessStorageReadWrite + || access == QGles2Buffer::AccessUpdate; +} + +static bool textureAccessIsWrite(QGles2Texture::Access access) +{ + return access == QGles2Texture::AccessStorageWrite + || access == QGles2Texture::AccessStorageReadWrite + || access == QGles2Texture::AccessUpdate + || access == QGles2Texture::AccessFramebuffer; +} + void QRhiGles2::trackedBufferBarrier(QGles2CommandBuffer *cbD, QGles2Buffer *bufD, QGles2Buffer::Access access) { Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::NoPass); // this is for resource updates only @@ -1314,7 +1337,7 @@ void QRhiGles2::trackedBufferBarrier(QGles2CommandBuffer *cbD, QGles2Buffer *buf if (access == prevAccess) return; - if (prevAccess == QGles2Buffer::AccessStorageWrite || prevAccess == QGles2Buffer::AccessStorageReadWrite) { + if (bufferAccessIsWrite(prevAccess)) { // Generating the minimal barrier set is way too complicated to do // correctly (prevAccess is overwritten so we won't have proper // tracking across multiple passes) so setting all barrier bits will do @@ -1335,7 +1358,7 @@ void QRhiGles2::trackedImageBarrier(QGles2CommandBuffer *cbD, QGles2Texture *tex if (access == prevAccess) return; - if (prevAccess == QGles2Texture::AccessStorageWrite || prevAccess == QGles2Texture::AccessStorageReadWrite) { + if (textureAccessIsWrite(prevAccess)) { QGles2CommandBuffer::Command cmd; cmd.cmd = QGles2CommandBuffer::Command::Barrier; cmd.args.barrier.barriers = GL_ALL_BARRIER_BITS; @@ -2273,19 +2296,13 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb) // subsequent pass. for (auto it = tracker.cbeginBuffers(), itEnd = tracker.cendBuffers(); it != itEnd; ++it) { QGles2Buffer::Access accessBeforePass = QGles2Buffer::Access(it->stateAtPassBegin.access); - if (accessBeforePass == QGles2Buffer::AccessStorageWrite - || accessBeforePass == QGles2Buffer::AccessStorageReadWrite) - { + if (bufferAccessIsWrite(accessBeforePass)) barriers |= GL_ALL_BARRIER_BITS; - } } for (auto it = tracker.cbeginTextures(), itEnd = tracker.cendTextures(); it != itEnd; ++it) { QGles2Texture::Access accessBeforePass = QGles2Texture::Access(it->stateAtPassBegin.access); - if (accessBeforePass == QGles2Texture::AccessStorageWrite - || accessBeforePass == QGles2Texture::AccessStorageReadWrite) - { + if (textureAccessIsWrite(accessBeforePass)) barriers |= GL_ALL_BARRIER_BITS; - } } if (barriers && caps.compute) f->glMemoryBarrier(barriers); @@ -2792,6 +2809,8 @@ void QRhiGles2::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch cbD->recordingPass = QGles2CommandBuffer::ComputePass; cbD->resetCachedState(); + + cbD->computePassState.reset(); } void QRhiGles2::endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) @@ -2824,11 +2843,96 @@ void QRhiGles2::setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *p } } +template<typename T> +inline void qrhigl_accumulateComputeResource(T *writtenResources, QRhiResource *resource, + QRhiShaderResourceBinding::Type bindingType, + int loadTypeVal, int storeTypeVal, int loadStoreTypeVal) +{ + int access = 0; + if (bindingType == loadTypeVal) { + access = QGles2CommandBuffer::ComputePassState::Read; + } else { + access = QGles2CommandBuffer::ComputePassState::Write; + if (bindingType == loadStoreTypeVal) + access |= QGles2CommandBuffer::ComputePassState::Read; + } + auto it = writtenResources->find(resource); + if (it != writtenResources->end()) + it->first |= access; + else if (bindingType == storeTypeVal || bindingType == loadStoreTypeVal) + writtenResources->insert(resource, { access, true }); +} + void QRhiGles2::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) { QGles2CommandBuffer *cbD = QRHI_RES(QGles2CommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QGles2CommandBuffer::ComputePass); + if (cbD->currentComputeSrb) { + GLbitfield barriers = 0; + + // The key in the writtenResources map indicates that the resource was + // written in a previous dispatch, whereas the value accumulates the + // access mask in the current one. + for (auto &accessAndIsNewFlag : cbD->computePassState.writtenResources) + accessAndIsNewFlag = { 0, false }; + + QGles2ShaderResourceBindings *srbD = QRHI_RES(QGles2ShaderResourceBindings, cbD->currentComputeSrb); + const int bindingCount = srbD->m_bindings.count(); + for (int i = 0; i < bindingCount; ++i) { + const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); + switch (b->type) { + case QRhiShaderResourceBinding::ImageLoad: + case QRhiShaderResourceBinding::ImageStore: + case QRhiShaderResourceBinding::ImageLoadStore: + qrhigl_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.simage.tex, + b->type, + QRhiShaderResourceBinding::ImageLoad, + QRhiShaderResourceBinding::ImageStore, + QRhiShaderResourceBinding::ImageLoadStore); + break; + case QRhiShaderResourceBinding::BufferLoad: + case QRhiShaderResourceBinding::BufferStore: + case QRhiShaderResourceBinding::BufferLoadStore: + qrhigl_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.sbuf.buf, + b->type, + QRhiShaderResourceBinding::BufferLoad, + QRhiShaderResourceBinding::BufferStore, + QRhiShaderResourceBinding::BufferLoadStore); + break; + default: + break; + } + } + + for (auto it = cbD->computePassState.writtenResources.begin(); it != cbD->computePassState.writtenResources.end(); ) { + const int accessInThisDispatch = it->first; + const bool isNewInThisDispatch = it->second; + if (accessInThisDispatch && !isNewInThisDispatch) { + if (it.key()->resourceType() == QRhiResource::Texture) + barriers |= GL_SHADER_IMAGE_ACCESS_BARRIER_BIT; + else + barriers |= GL_SHADER_STORAGE_BARRIER_BIT; + } + // Anything that was previously written, but is only read now, can be + // removed from the written list (because that previous write got a + // corresponding barrier now). + if (accessInThisDispatch == QGles2CommandBuffer::ComputePassState::Read) + it = cbD->computePassState.writtenResources.erase(it); + else + ++it; + } + + if (barriers) { + QGles2CommandBuffer::Command cmd; + cmd.cmd = QGles2CommandBuffer::Command::Barrier; + cmd.args.barrier.barriers = barriers; + cbD->commands.append(cmd); + } + } + QGles2CommandBuffer::Command cmd; cmd.cmd = QGles2CommandBuffer::Command::Dispatch; cmd.args.dispatch.x = GLuint(x); diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h index a9b3022612..679f806004 100644 --- a/src/gui/rhi/qrhigles2_p_p.h +++ b/src/gui/rhi/qrhigles2_p_p.h @@ -521,6 +521,17 @@ struct QGles2CommandBuffer : public QRhiCommandBuffer QRhiShaderResourceBindings *currentComputeSrb; uint currentSrbGeneration; + struct ComputePassState { + enum Access { + Read = 0x01, + Write = 0x02 + }; + QHash<QRhiResource *, QPair<int, bool> > writtenResources; + void reset() { + writtenResources.clear(); + } + } computePassState; + QVector<QByteArray> dataRetainPool; QVector<QImage> imageRetainPool; diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c4f56f2dd2..f4c72d2cca 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -2219,6 +2219,8 @@ void QRhiVulkan::beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch cbD->recordingPass = QVkCommandBuffer::ComputePass; + cbD->computePassState.reset(); + if (cbD->useSecondaryCb) cbD->secondaryCbs.append(startSecondaryCommandBuffer()); } @@ -2267,15 +2269,152 @@ void QRhiVulkan::setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline * psD->lastActiveFrameSlot = currentFrameSlot; } +template<typename T> +inline void qrhivk_accumulateComputeResource(T *writtenResources, QRhiResource *resource, + QRhiShaderResourceBinding::Type bindingType, + int loadTypeVal, int storeTypeVal, int loadStoreTypeVal) +{ + VkAccessFlags access = 0; + if (bindingType == loadTypeVal) { + access = VK_ACCESS_SHADER_READ_BIT; + } else { + access = VK_ACCESS_SHADER_WRITE_BIT; + if (bindingType == loadStoreTypeVal) + access |= VK_ACCESS_SHADER_READ_BIT; + } + auto it = writtenResources->find(resource); + if (it != writtenResources->end()) + it->first |= access; + else if (bindingType == storeTypeVal || bindingType == loadStoreTypeVal) + writtenResources->insert(resource, { access, true }); +} + void QRhiVulkan::dispatch(QRhiCommandBuffer *cb, int x, int y, int z) { QVkCommandBuffer *cbD = QRHI_RES(QVkCommandBuffer, cb); Q_ASSERT(cbD->recordingPass == QVkCommandBuffer::ComputePass); + // When there are multiple dispatches, read-after-write and + // write-after-write need a barrier. + QVarLengthArray<VkImageMemoryBarrier, 8> imageBarriers; + QVarLengthArray<VkBufferMemoryBarrier, 8> bufferBarriers; + if (cbD->currentComputeSrb) { + // The key in the writtenResources map indicates that the resource was + // written in a previous dispatch, whereas the value accumulates the + // access mask in the current one. + for (auto &accessAndIsNewFlag : cbD->computePassState.writtenResources) + accessAndIsNewFlag = { 0, false }; + + QVkShaderResourceBindings *srbD = QRHI_RES(QVkShaderResourceBindings, cbD->currentComputeSrb); + const int bindingCount = srbD->m_bindings.count(); + for (int i = 0; i < bindingCount; ++i) { + const QRhiShaderResourceBinding::Data *b = srbD->m_bindings.at(i).data(); + switch (b->type) { + case QRhiShaderResourceBinding::ImageLoad: + case QRhiShaderResourceBinding::ImageStore: + case QRhiShaderResourceBinding::ImageLoadStore: + qrhivk_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.simage.tex, + b->type, + QRhiShaderResourceBinding::ImageLoad, + QRhiShaderResourceBinding::ImageStore, + QRhiShaderResourceBinding::ImageLoadStore); + break; + case QRhiShaderResourceBinding::BufferLoad: + case QRhiShaderResourceBinding::BufferStore: + case QRhiShaderResourceBinding::BufferLoadStore: + qrhivk_accumulateComputeResource(&cbD->computePassState.writtenResources, + b->u.sbuf.buf, + b->type, + QRhiShaderResourceBinding::BufferLoad, + QRhiShaderResourceBinding::BufferStore, + QRhiShaderResourceBinding::BufferLoadStore); + break; + default: + break; + } + } + + for (auto it = cbD->computePassState.writtenResources.begin(); it != cbD->computePassState.writtenResources.end(); ) { + const int accessInThisDispatch = it->first; + const bool isNewInThisDispatch = it->second; + if (accessInThisDispatch && !isNewInThisDispatch) { + if (it.key()->resourceType() == QRhiResource::Texture) { + QVkTexture *texD = QRHI_RES(QVkTexture, it.key()); + VkImageMemoryBarrier barrier; + memset(&barrier, 0, sizeof(barrier)); + barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; + barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + // won't care about subresources, pretend the whole resource was written + barrier.subresourceRange.baseMipLevel = 0; + barrier.subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS; + barrier.subresourceRange.baseArrayLayer = 0; + barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS; + barrier.oldLayout = texD->usageState.layout; + barrier.newLayout = texD->usageState.layout; + barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + barrier.dstAccessMask = accessInThisDispatch; + barrier.image = texD->image; + imageBarriers.append(barrier); + } else { + QVkBuffer *bufD = QRHI_RES(QVkBuffer, it.key()); + VkBufferMemoryBarrier barrier; + memset(&barrier, 0, sizeof(barrier)); + barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; + barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; + barrier.dstAccessMask = accessInThisDispatch; + barrier.buffer = bufD->buffers[bufD->m_type == QRhiBuffer::Dynamic ? currentFrameSlot : 0]; + barrier.size = VK_WHOLE_SIZE; + bufferBarriers.append(barrier); + } + } + // Anything that was previously written, but is only read now, can be + // removed from the written list (because that previous write got a + // corresponding barrier now). + if (accessInThisDispatch == VK_ACCESS_SHADER_READ_BIT) + it = cbD->computePassState.writtenResources.erase(it); + else + ++it; + } + } + if (cbD->useSecondaryCb) { - df->vkCmdDispatch(cbD->secondaryCbs.last(), uint32_t(x), uint32_t(y), uint32_t(z)); + VkCommandBuffer secondaryCb = cbD->secondaryCbs.last(); + if (!imageBarriers.isEmpty()) { + df->vkCmdPipelineBarrier(secondaryCb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, 0, nullptr, + 0, nullptr, + imageBarriers.count(), imageBarriers.constData()); + } + if (!bufferBarriers.isEmpty()) { + df->vkCmdPipelineBarrier(secondaryCb, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, + 0, 0, nullptr, + bufferBarriers.count(), bufferBarriers.constData(), + 0, nullptr); + } + df->vkCmdDispatch(secondaryCb, uint32_t(x), uint32_t(y), uint32_t(z)); } else { QVkCommandBuffer::Command cmd; + if (!imageBarriers.isEmpty()) { + cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; + cmd.args.imageBarrier.srcStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.imageBarrier.dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.imageBarrier.count = imageBarriers.count(); + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cbD->pools.imageBarrier.append(imageBarriers.constData(), imageBarriers.count()); + cbD->commands.append(cmd); + } + if (!bufferBarriers.isEmpty()) { + cmd.cmd = QVkCommandBuffer::Command::BufferBarrier; + cmd.args.bufferBarrier.srcStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.bufferBarrier.dstStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; + cmd.args.bufferBarrier.count = bufferBarriers.count(); + cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.count(); + cbD->pools.bufferBarrier.append(bufferBarriers.constData(), bufferBarriers.count()); + cbD->commands.append(cmd); + } cmd.cmd = QVkCommandBuffer::Command::Dispatch; cmd.args.dispatch.x = x; cmd.args.dispatch.y = y; @@ -2465,7 +2604,9 @@ void QRhiVulkan::trackedBufferBarrier(QVkCommandBuffer *cbD, QVkBuffer *bufD, in cmd.cmd = QVkCommandBuffer::Command::BufferBarrier; cmd.args.bufferBarrier.srcStageMask = s.stage; cmd.args.bufferBarrier.dstStageMask = stage; - cmd.args.bufferBarrier.desc = bufMemBarrier; + cmd.args.bufferBarrier.count = 1; + cmd.args.bufferBarrier.index = cbD->pools.bufferBarrier.count(); + cbD->pools.bufferBarrier.append(bufMemBarrier); cbD->commands.append(cmd); s.access = access; @@ -2507,7 +2648,9 @@ void QRhiVulkan::trackedImageBarrier(QVkCommandBuffer *cbD, QVkTexture *texD, cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; cmd.args.imageBarrier.srcStageMask = srcStage; cmd.args.imageBarrier.dstStageMask = stage; - cmd.args.imageBarrier.desc = barrier; + cmd.args.imageBarrier.count = 1; + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cbD->pools.imageBarrier.append(barrier); cbD->commands.append(cmd); s.layout = layout; @@ -2541,7 +2684,9 @@ void QRhiVulkan::subresourceBarrier(QVkCommandBuffer *cbD, VkImage image, cmd.cmd = QVkCommandBuffer::Command::ImageBarrier; cmd.args.imageBarrier.srcStageMask = srcStage; cmd.args.imageBarrier.dstStageMask = dstStage; - cmd.args.imageBarrier.desc = barrier; + cmd.args.imageBarrier.count = 1; + cmd.args.imageBarrier.index = cbD->pools.imageBarrier.count(); + cbD->pools.imageBarrier.append(barrier); cbD->commands.append(cmd); } @@ -3409,12 +3554,12 @@ void QRhiVulkan::recordPrimaryCommandBuffer(QVkCommandBuffer *cbD) case QVkCommandBuffer::Command::ImageBarrier: df->vkCmdPipelineBarrier(cbD->cb, cmd.args.imageBarrier.srcStageMask, cmd.args.imageBarrier.dstStageMask, 0, 0, nullptr, 0, nullptr, - 1, &cmd.args.imageBarrier.desc); + cmd.args.imageBarrier.count, cbD->pools.imageBarrier.constData() + cmd.args.imageBarrier.index); break; case QVkCommandBuffer::Command::BufferBarrier: df->vkCmdPipelineBarrier(cbD->cb, cmd.args.bufferBarrier.srcStageMask, cmd.args.bufferBarrier.dstStageMask, 0, 0, nullptr, - 1, &cmd.args.bufferBarrier.desc, + cmd.args.bufferBarrier.count, cbD->pools.bufferBarrier.constData() + cmd.args.bufferBarrier.index, 0, nullptr); break; case QVkCommandBuffer::Command::BlitImage: diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h index 9f18d0bf5e..b0e90dae56 100644 --- a/src/gui/rhi/qrhivulkan_p_p.h +++ b/src/gui/rhi/qrhivulkan_p_p.h @@ -370,6 +370,13 @@ struct QVkCommandBuffer : public QRhiCommandBuffer QVarLengthArray<VkCommandBuffer, 4> secondaryCbs; bool inExternal; + struct { + QHash<QRhiResource *, QPair<VkAccessFlags, bool> > writtenResources; + void reset() { + writtenResources.clear(); + } + } computePassState; + struct Command { enum Cmd { CopyBuffer, @@ -429,12 +436,14 @@ struct QVkCommandBuffer : public QRhiCommandBuffer struct { VkPipelineStageFlags srcStageMask; VkPipelineStageFlags dstStageMask; - VkImageMemoryBarrier desc; + int count; + int index; } imageBarrier; struct { VkPipelineStageFlags srcStageMask; VkPipelineStageFlags dstStageMask; - VkBufferMemoryBarrier desc; + int count; + int index; } bufferBarrier; struct { VkImage src; @@ -537,6 +546,8 @@ struct QVkCommandBuffer : public QRhiCommandBuffer pools.vertexBuffer.clear(); pools.vertexBufferOffset.clear(); pools.debugMarkerData.clear(); + pools.imageBarrier.clear(); + pools.bufferBarrier.clear(); } struct { @@ -546,6 +557,8 @@ struct QVkCommandBuffer : public QRhiCommandBuffer QVarLengthArray<VkBuffer, 4> vertexBuffer; QVarLengthArray<VkDeviceSize, 4> vertexBufferOffset; QVarLengthArray<QByteArray, 4> debugMarkerData; + QVarLengthArray<VkImageMemoryBarrier, 8> imageBarrier; + QVarLengthArray<VkBufferMemoryBarrier, 8> bufferBarrier; } pools; friend class QRhiVulkan; -- cgit v1.2.3 From 7e2cef0f15b133c07bd11aa5e5065b0b9959fb0d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@qt.io> Date: Sun, 12 Jan 2020 17:33:31 +0100 Subject: Move away from CBOR in QShaderDescription serialization ...but keep support for deserializing for all older versions in order to play nice with existing .qsb files. The usage of binary JSON and then CBOR is a historical artifact: relying on the QJsonDocument (which we generate for purposes unrelated to binary serialization) was a convenient shortcut. However, writing to and reading from a QDataStream instead (which QShader already does) is trivial. In order not to be limited by potential CBOR requirements in the future, take it all into our own hands. Extend the qshader autotest accordingly. Task-number: QTBUG-81298 Change-Id: If0047b659bd6601ca47b5bbbce1b719630cde01e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> --- src/gui/rhi/qshader.cpp | 13 +- src/gui/rhi/qshader_p_p.h | 3 +- src/gui/rhi/qshaderdescription.cpp | 235 +++++++++++++++++++++++++++++++++++ src/gui/rhi/qshaderdescription_p.h | 3 + src/gui/rhi/qshaderdescription_p_p.h | 2 + 5 files changed, 251 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 9203d63cd2..69f4a68215 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -367,7 +367,7 @@ QByteArray QShader::serialized() const ds << QShaderPrivate::QSB_VERSION; ds << int(d->stage); - ds << d->desc.toCbor(); + d->desc.serialize(&ds); ds << d->shaders.count(); for (auto it = d->shaders.cbegin(), itEnd = d->shaders.cend(); it != itEnd; ++it) { const QShaderKey &k(it.key()); @@ -428,6 +428,7 @@ QShader QShader::fromSerialized(const QByteArray &data) ds >> intVal; d->qsbVersion = intVal; if (d->qsbVersion != QShaderPrivate::QSB_VERSION + && d->qsbVersion != QShaderPrivate::QSB_VERSION_WITH_CBOR && d->qsbVersion != QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON && d->qsbVersion != QShaderPrivate::QSB_VERSION_WITHOUT_BINDINGS) { @@ -437,14 +438,18 @@ QShader QShader::fromSerialized(const QByteArray &data) ds >> intVal; d->stage = Stage(intVal); - QByteArray descBin; - ds >> descBin; - if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { + if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_CBOR) { + d->desc = QShaderDescription::deserialize(&ds); + } else if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { + QByteArray descBin; + ds >> descBin; d->desc = QShaderDescription::fromCbor(descBin); } else { #if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED + QByteArray descBin; + ds >> descBin; d->desc = QShaderDescription::fromBinaryJson(descBin); QT_WARNING_POP #else diff --git a/src/gui/rhi/qshader_p_p.h b/src/gui/rhi/qshader_p_p.h index 8c89f2b45f..66ef18f391 100644 --- a/src/gui/rhi/qshader_p_p.h +++ b/src/gui/rhi/qshader_p_p.h @@ -57,7 +57,8 @@ QT_BEGIN_NAMESPACE struct Q_GUI_EXPORT QShaderPrivate { - static const int QSB_VERSION = 3; + static const int QSB_VERSION = 4; + static const int QSB_VERSION_WITH_CBOR = 3; static const int QSB_VERSION_WITH_BINARY_JSON = 2; static const int QSB_VERSION_WITHOUT_BINDINGS = 1; diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index 76c5d0ebef..96c8d082fc 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -36,6 +36,7 @@ #include "qshaderdescription_p_p.h" #include <QDebug> +#include <QDataStream> #include <QJsonObject> #include <QJsonArray> #include <QCborValue> @@ -358,6 +359,11 @@ QByteArray QShaderDescription::toJson() const return d->makeDoc().toJson(); } +void QShaderDescription::serialize(QDataStream *stream) const +{ + d->writeToStream(stream); +} + #if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! \deprecated @@ -396,6 +402,13 @@ QShaderDescription QShaderDescription::fromCbor(const QByteArray &data) return desc; } +QShaderDescription QShaderDescription::deserialize(QDataStream *stream) +{ + QShaderDescription desc; + QShaderDescriptionPrivate::get(&desc)->loadFromStream(stream); + return desc; +} + /*! \return the list of input variables. This includes vertex inputs (sometimes called attributes) for the vertex stage, and inputs for other stages @@ -867,6 +880,15 @@ static void addDeco(QJsonObject *obj, const QShaderDescription::InOutVariable &v (*obj)[imageFlagsKey] = int(v.imageFlags); } +static void serializeDecorations(QDataStream *stream, const QShaderDescription::InOutVariable &v) +{ + (*stream) << v.location; + (*stream) << v.binding; + (*stream) << v.descriptorSet; + (*stream) << int(v.imageFormat); + (*stream) << int(v.imageFlags); +} + static QJsonObject inOutObject(const QShaderDescription::InOutVariable &v) { QJsonObject obj; @@ -876,6 +898,13 @@ static QJsonObject inOutObject(const QShaderDescription::InOutVariable &v) return obj; } +static void serializeInOutVar(QDataStream *stream, const QShaderDescription::InOutVariable &v) +{ + (*stream) << v.name; + (*stream) << int(v.type); + serializeDecorations(stream, v); +} + static QJsonObject blockMemberObject(const QShaderDescription::BlockVariable &v) { QJsonObject obj; @@ -904,6 +933,23 @@ static QJsonObject blockMemberObject(const QShaderDescription::BlockVariable &v) return obj; } +static void serializeBlockMemberVar(QDataStream *stream, const QShaderDescription::BlockVariable &v) +{ + (*stream) << v.name; + (*stream) << int(v.type); + (*stream) << v.offset; + (*stream) << v.size; + (*stream) << v.arrayDims.count(); + for (int dim : v.arrayDims) + (*stream) << dim; + (*stream) << v.arrayStride; + (*stream) << v.matrixStride; + (*stream) << v.matrixIsRowMajor; + (*stream) << v.structMembers.count(); + for (const QShaderDescription::BlockVariable &sv : v.structMembers) + serializeBlockMemberVar(stream, sv); +} + QJsonDocument QShaderDescriptionPrivate::makeDoc() { QJsonObject root; @@ -1002,6 +1048,67 @@ QJsonDocument QShaderDescriptionPrivate::makeDoc() return QJsonDocument(root); } +void QShaderDescriptionPrivate::writeToStream(QDataStream *stream) +{ + (*stream) << inVars.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(inVars)) + serializeInOutVar(stream, v); + + (*stream) << outVars.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(outVars)) + serializeInOutVar(stream, v); + + (*stream) << uniformBlocks.count(); + for (const QShaderDescription::UniformBlock &b : uniformBlocks) { + (*stream) << b.blockName; + (*stream) << b.structName; + (*stream) << b.size; + (*stream) << b.binding; + (*stream) << b.descriptorSet; + (*stream) << b.members.count(); + for (const QShaderDescription::BlockVariable &v : b.members) + serializeBlockMemberVar(stream, v); + } + + (*stream) << pushConstantBlocks.count(); + for (const QShaderDescription::PushConstantBlock &b : pushConstantBlocks) { + (*stream) << b.name; + (*stream) << b.size; + (*stream) << b.members.count(); + for (const QShaderDescription::BlockVariable &v : b.members) + serializeBlockMemberVar(stream, v); + } + + (*stream) << storageBlocks.count(); + for (const QShaderDescription::StorageBlock &b : storageBlocks) { + (*stream) << b.blockName; + (*stream) << b.instanceName; + (*stream) << b.knownSize; + (*stream) << b.binding; + (*stream) << b.descriptorSet; + (*stream) << b.members.count(); + for (const QShaderDescription::BlockVariable &v : b.members) + serializeBlockMemberVar(stream, v); + } + + (*stream) << combinedImageSamplers.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(combinedImageSamplers)) { + (*stream) << v.name; + (*stream) << int(v.type); + serializeDecorations(stream, v); + } + + (*stream) << storageImages.count(); + for (const QShaderDescription::InOutVariable &v : qAsConst(storageImages)) { + (*stream) << v.name; + (*stream) << int(v.type); + serializeDecorations(stream, v); + } + + for (size_t i = 0; i < 3; ++i) + (*stream) << localSize[i]; +} + static QShaderDescription::InOutVariable inOutVar(const QJsonObject &obj) { QShaderDescription::InOutVariable var; @@ -1020,6 +1127,29 @@ static QShaderDescription::InOutVariable inOutVar(const QJsonObject &obj) return var; } +static void deserializeDecorations(QDataStream *stream, QShaderDescription::InOutVariable *v) +{ + (*stream) >> v->location; + (*stream) >> v->binding; + (*stream) >> v->descriptorSet; + int f; + (*stream) >> f; + v->imageFormat = QShaderDescription::ImageFormat(f); + (*stream) >> f; + v->imageFlags = QShaderDescription::ImageFlags(f); +} + +static QShaderDescription::InOutVariable deserializeInOutVar(QDataStream *stream) +{ + QShaderDescription::InOutVariable var; + (*stream) >> var.name; + int t; + (*stream) >> t; + var.type = QShaderDescription::VariableType(t); + deserializeDecorations(stream, &var); + return var; +} + static QShaderDescription::BlockVariable blockVar(const QJsonObject &obj) { QShaderDescription::BlockVariable var; @@ -1046,6 +1176,30 @@ static QShaderDescription::BlockVariable blockVar(const QJsonObject &obj) return var; } +static QShaderDescription::BlockVariable deserializeBlockMemberVar(QDataStream *stream) +{ + QShaderDescription::BlockVariable var; + (*stream) >> var.name; + int t; + (*stream) >> t; + var.type = QShaderDescription::VariableType(t); + (*stream) >> var.offset; + (*stream) >> var.size; + int count; + (*stream) >> count; + var.arrayDims.resize(count); + for (int i = 0; i < count; ++i) + (*stream) >> var.arrayDims[i]; + (*stream) >> var.arrayStride; + (*stream) >> var.matrixStride; + (*stream) >> var.matrixIsRowMajor; + (*stream) >> count; + var.structMembers.resize(count); + for (int i = 0; i < count; ++i) + var.structMembers[i] = deserializeBlockMemberVar(stream); + return var; +} + void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc) { if (doc.isNull()) { @@ -1150,6 +1304,87 @@ void QShaderDescriptionPrivate::loadDoc(const QJsonDocument &doc) } } +void QShaderDescriptionPrivate::loadFromStream(QDataStream *stream) +{ + Q_ASSERT(ref.loadRelaxed() == 1); // must be detached + + int count; + (*stream) >> count; + inVars.resize(count); + for (int i = 0; i < count; ++i) + inVars[i] = deserializeInOutVar(stream); + + (*stream) >> count; + outVars.resize(count); + for (int i = 0; i < count; ++i) + outVars[i] = deserializeInOutVar(stream); + + (*stream) >> count; + uniformBlocks.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> uniformBlocks[i].blockName; + (*stream) >> uniformBlocks[i].structName; + (*stream) >> uniformBlocks[i].size; + (*stream) >> uniformBlocks[i].binding; + (*stream) >> uniformBlocks[i].descriptorSet; + int memberCount; + (*stream) >> memberCount; + uniformBlocks[i].members.resize(memberCount); + for (int memberIdx = 0; memberIdx < memberCount; ++memberIdx) + uniformBlocks[i].members[memberIdx] = deserializeBlockMemberVar(stream); + } + + (*stream) >> count; + pushConstantBlocks.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> pushConstantBlocks[i].name; + (*stream) >> pushConstantBlocks[i].size; + int memberCount; + (*stream) >> memberCount; + pushConstantBlocks[i].members.resize(memberCount); + for (int memberIdx = 0; memberIdx < memberCount; ++memberIdx) + pushConstantBlocks[i].members[memberIdx] = deserializeBlockMemberVar(stream); + } + + (*stream) >> count; + storageBlocks.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> storageBlocks[i].blockName; + (*stream) >> storageBlocks[i].instanceName; + (*stream) >> storageBlocks[i].knownSize; + (*stream) >> storageBlocks[i].binding; + (*stream) >> storageBlocks[i].descriptorSet; + int memberCount; + (*stream) >> memberCount; + storageBlocks[i].members.resize(memberCount); + for (int memberIdx = 0; memberIdx < memberCount; ++memberIdx) + storageBlocks[i].members[memberIdx] = deserializeBlockMemberVar(stream); + } + + (*stream) >> count; + combinedImageSamplers.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> combinedImageSamplers[i].name; + int t; + (*stream) >> t; + combinedImageSamplers[i].type = QShaderDescription::VariableType(t); + deserializeDecorations(stream, &combinedImageSamplers[i]); + } + + (*stream) >> count; + storageImages.resize(count); + for (int i = 0; i < count; ++i) { + (*stream) >> storageImages[i].name; + int t; + (*stream) >> t; + storageImages[i].type = QShaderDescription::VariableType(t); + deserializeDecorations(stream, &storageImages[i]); + } + + for (size_t i = 0; i < 3; ++i) + (*stream) >> localSize[i]; +} + /*! Returns \c true if the two QShaderDescription objects \a lhs and \a rhs are equal. diff --git a/src/gui/rhi/qshaderdescription_p.h b/src/gui/rhi/qshaderdescription_p.h index 872ee8b138..108fc32a56 100644 --- a/src/gui/rhi/qshaderdescription_p.h +++ b/src/gui/rhi/qshaderdescription_p.h @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE struct QShaderDescriptionPrivate; +class QDataStream; class Q_GUI_EXPORT QShaderDescription { @@ -69,6 +70,7 @@ public: bool isValid() const; QByteArray toCbor() const; + void serialize(QDataStream *stream) const; QByteArray toJson() const; #if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) @@ -76,6 +78,7 @@ public: static QShaderDescription fromBinaryJson(const QByteArray &data); #endif static QShaderDescription fromCbor(const QByteArray &data); + static QShaderDescription deserialize(QDataStream *stream); enum VariableType { Unknown = 0, diff --git a/src/gui/rhi/qshaderdescription_p_p.h b/src/gui/rhi/qshaderdescription_p_p.h index 1caee24984..69b6e811a1 100644 --- a/src/gui/rhi/qshaderdescription_p_p.h +++ b/src/gui/rhi/qshaderdescription_p_p.h @@ -80,7 +80,9 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate static const QShaderDescriptionPrivate *get(const QShaderDescription *desc) { return desc->d; } QJsonDocument makeDoc(); + void writeToStream(QDataStream *stream); void loadDoc(const QJsonDocument &doc); + void loadFromStream(QDataStream *stream); QAtomicInt ref; QVector<QShaderDescription::InOutVariable> inVars; -- cgit v1.2.3 From 9dcbf2cf5cbdfe35637ff323fd44729badaae811 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher <ch.ehrlicher@gmx.de> Date: Sun, 29 Dec 2019 16:27:29 +0100 Subject: QScrollBar: allow scrolling any scrollbar with any mouse wheel The most common mouse wheel movement corresponds to angleDelta().y(). We have previously allowed the user to use either wheel to scroll either a horizontal or a vertical scrollbar when the mouse is hovering over it; but 7d29807296cb7ccc7f3459e106d74f93a321c493 changed it so that the vertical mouse wheel could no longer scroll a horizontal scrollbar. The behavior is now restored as it was in 59cc316620a2169d48e00822c97a96bd03079eed. Task-number: QTBUG-81007 Change-Id: Ieacdce539d5311499a86af645bbe0d5098e16be6 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> --- src/widgets/widgets/qscrollbar.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index 08d771a27a..4606f57fb8 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -497,14 +497,20 @@ bool QScrollBar::event(QEvent *event) void QScrollBar::wheelEvent(QWheelEvent *event) { event->ignore(); + bool horizontal = qAbs(event->angleDelta().x()) > qAbs(event->angleDelta().y()); + // The vertical wheel can be used to scroll a horizontal scrollbar, but only if + // there is no simultaneous horizontal wheel movement. This is to avoid chaotic + // scrolling on touchpads. + if (!horizontal && event->angleDelta().x() != 0 && orientation() == Qt::Horizontal) + return; // scrollbar is a special case - in vertical mode it reaches minimum // value in the upper position, however QSlider's minimum value is on // the bottom. So we need to invert the value, but since the scrollbar is // inverted by default, we need to invert the delta value only for the // horizontal orientation. - int delta = (orientation() == Qt::Horizontal ? -event->angleDelta().x() : event->angleDelta().y()); + int delta = horizontal ? -event->angleDelta().x() : event->angleDelta().y(); Q_D(QScrollBar); - if (d->scrollByDelta(orientation(), event->modifiers(), delta)) + if (d->scrollByDelta(horizontal ? Qt::Horizontal : Qt::Vertical, event->modifiers(), delta)) event->accept(); if (event->phase() == Qt::ScrollBegin) -- cgit v1.2.3 From 0a93db4d82c051164923a10e4382b12de9049b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Wed, 8 Jan 2020 17:48:58 +0100 Subject: Unify application palette handling between QGuiApplication and QApplication The logic is now mostly handled in QGuiApplication, with QApplication only dealing with the widget-specific palettes and interaction between the style and the palette. The application now picks up changes to the platform theme and will re-resolve the current application palette appropriately. This also works even if an explicit application palette has been set, in which case any missing roles are filled in by the theme. The palette can now also be reset back to the default application palette that's fully based on the theme, by passing in the default constructed palette (or any palette that doesn't have any roles set). This is also correctly reflected in the Qt::AA_SetPalette attribute. Conceptually this means QGuiApplication and QApplication follow the same behavior as QWidget, where the palette falls back to a base or inherited palette for roles that are not set, in this case the theme. Behavior-wise this means that the default application palette of the application does not have any roles set, but clients should not have relied on this, nor does QWidget rely on that internally. It also means that setting a palette on the application and then getting it back again will not produce the same palette as set, since the palette was resolved against the theme in the meantime. This is the same behavior as for QWidget, and although it's a behavior change it's one towards a more sane behavior, so we accept it. [ChangeLog] Application palettes are now resolved against the platform's theme palette, the same way widget palettes are resolved against their parents, and the application palette. This means the application palette reflected through QGuiApplication::palette() may not be exactly the same palette as set via QGuiApplication::setPalette(). Change-Id: I76b99fcd27285e564899548349aa2a5713e5965d Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/gui/kernel/qguiapplication.cpp | 117 ++++++----- src/gui/kernel/qguiapplication_p.h | 11 +- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- .../styles/windowsvista/qwindowsxpstyle.cpp | 3 +- src/widgets/kernel/qapplication.cpp | 231 +++++++++------------ src/widgets/kernel/qapplication_p.h | 10 +- 6 files changed, 179 insertions(+), 195 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index ffd5b04276..445ad6b835 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -236,21 +236,6 @@ static bool qt_detectRTLLanguage() " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); } -static void initPalette() -{ - if (!QGuiApplicationPrivate::app_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); -} - -static inline void clearPalette() -{ - delete QGuiApplicationPrivate::app_pal; - QGuiApplicationPrivate::app_pal = nullptr; -} - static void initFontUnlocked() { if (!QGuiApplicationPrivate::app_font) { @@ -691,7 +676,7 @@ QGuiApplication::~QGuiApplication() d->session_manager = nullptr; #endif //QT_NO_SESSIONMANAGER - clearPalette(); + QGuiApplicationPrivate::clearPalette(); QFontDatabase::removeAllApplicationFonts(); #ifndef QT_NO_CURSOR @@ -1611,7 +1596,7 @@ void QGuiApplicationPrivate::init() if (platform_integration == nullptr) createPlatformIntegration(); - initPalette(); + updatePalette(); QFont::initialize(); initThemeHints(); @@ -3289,46 +3274,97 @@ QClipboard * QGuiApplication::clipboard() */ /*! - Returns the default application palette. + Returns the current application palette. + + Roles that have not been explicitly set will reflect the system's platform theme. \sa setPalette() */ QPalette QGuiApplication::palette() { - initPalette(); + if (!QGuiApplicationPrivate::app_pal) + QGuiApplicationPrivate::updatePalette(); + return *QGuiApplicationPrivate::app_pal; } +void QGuiApplicationPrivate::updatePalette() +{ + if (app_pal) { + if (setPalette(*app_pal) && qGuiApp) + qGuiApp->d_func()->handlePaletteChanged(); + } else { + setPalette(QPalette()); + } +} + +void QGuiApplicationPrivate::clearPalette() +{ + delete app_pal; + app_pal = nullptr; +} + /*! - Changes the default application palette to \a pal. + Changes the application palette to \a pal. + + The color roles from this palette are combined with the system's platform + theme to form the application's final palette. \sa palette() */ void QGuiApplication::setPalette(const QPalette &pal) { - if (!QGuiApplicationPrivate::setPalette(pal)) - return; - - QCoreApplication::setAttribute(Qt::AA_SetPalette); - - if (qGuiApp) - qGuiApp->d_func()->sendApplicationPaletteChange(); + if (QGuiApplicationPrivate::setPalette(pal) && qGuiApp) + qGuiApp->d_func()->handlePaletteChanged(); } bool QGuiApplicationPrivate::setPalette(const QPalette &palette) { - if (app_pal && palette.isCopyOf(*app_pal)) + // Resolve the palette against the theme palette, filling in + // any missing roles, while keeping the original resolve mask. + QPalette basePalette = qGuiApp ? qGuiApp->d_func()->basePalette() : Qt::gray; + basePalette.resolve(0); // The base palette only contributes missing colors roles + QPalette resolvedPalette = palette.resolve(basePalette); + + if (app_pal && resolvedPalette == *app_pal && resolvedPalette.resolve() == app_pal->resolve()) return false; if (!app_pal) - app_pal = new QPalette(palette); + app_pal = new QPalette(resolvedPalette); else - *app_pal = palette; + *app_pal = resolvedPalette; + + QCoreApplication::setAttribute(Qt::AA_SetPalette, app_pal->resolve() != 0); return true; } +/* + Returns the base palette used to fill in missing roles in + the current application palette. + + Normally this is the theme palette, but QApplication + overrides this for compatibility reasons. +*/ +QPalette QGuiApplicationPrivate::basePalette() const +{ + return platformTheme() ? *platformTheme()->palette() : Qt::gray; +} + +void QGuiApplicationPrivate::handlePaletteChanged(const char *className) +{ + if (!className) { + Q_ASSERT(app_pal); + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + } + + if (is_app_running && !is_app_closing) { + QEvent event(QEvent::ApplicationPaletteChange); + QGuiApplication::sendEvent(qGuiApp, &event); + } +} + void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { windowGeometrySpecification.applyTo(window); @@ -4127,11 +4163,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!testAttribute(Qt::AA_SetPalette)) { - clearPalette(); - initPalette(); - sendApplicationPaletteChange(); - } + updatePalette(); + if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { const auto locker = qt_scoped_lock(applicationFontMutex); clearFontUnlocked(); @@ -4140,20 +4173,6 @@ void QGuiApplicationPrivate::notifyThemeChanged() initThemeHints(); } -void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) -{ - Q_UNUSED(toAllWidgets) - - if (!className) - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); - - if (!is_app_running || is_app_closing) - return; - - QEvent event(QEvent::ApplicationPaletteChange); - QGuiApplication::sendEvent(QGuiApplication::instance(), &event); -} - #if QT_CONFIG(draganddrop) void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) { diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 2fe4ae02cf..5239b58c97 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -323,17 +323,22 @@ public: static void resetCachedDevicePixelRatio(); - static bool setPalette(const QPalette &palette); - protected: virtual void notifyThemeChanged(); - virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr); + + static bool setPalette(const QPalette &palette); + virtual QPalette basePalette() const; + virtual void handlePaletteChanged(const char *className = nullptr); + bool tryCloseRemainingWindows(QWindowList processedWindows); #if QT_CONFIG(draganddrop) virtual void notifyDragStarted(const QDrag *); #endif // QT_CONFIG(draganddrop) private: + static void clearPalette(); + static void updatePalette(); + friend class QDragManager; static QGuiApplicationPrivate *self; diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 5aa7befb84..37b658dd76 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2585,7 +2585,7 @@ QPalette QMacStyle::standardPalette() const auto platformTheme = QGuiApplicationPrivate::platformTheme(); auto styleNames = platformTheme->themeHint(QPlatformTheme::StyleNames); if (styleNames.toStringList().contains("macintosh")) - return *platformTheme->palette(); + return QPalette(); // Inherit everything from theme else return QStyle::standardPalette(); } diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index bf80138b32..5d2e8efd68 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -3774,8 +3774,7 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const /*! \reimp */ QPalette QWindowsXPStyle::standardPalette() const { - return QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal - ? *QApplicationPrivate::sys_pal : QWindowsStyle::standardPalette(); + return QWindowsXPStylePrivate::useXP() ? QPalette() : QWindowsStyle::standardPalette(); } /*! diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 4b1daab4cf..eea97b2c0b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -140,30 +140,6 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int QApplicationPrivate *QApplicationPrivate::self = nullptr; -static void initSystemPalette() -{ - if (QApplicationPrivate::sys_pal) - return; // Already initialized - - QPalette defaultPalette; - if (QApplicationPrivate::app_style) - defaultPalette = QApplicationPrivate::app_style->standardPalette(); - - auto *platformTheme = QGuiApplicationPrivate::platformTheme(); - if (const QPalette *themePalette = platformTheme ? platformTheme->palette() : nullptr) { - QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPalette)); - QApplicationPrivate::initializeWidgetPaletteHash(); - } else { - QApplicationPrivate::setSystemPalette(defaultPalette); - } -} - -static void clearSystemPalette() -{ - delete QApplicationPrivate::sys_pal; - QApplicationPrivate::sys_pal = nullptr; -} - bool QApplicationPrivate::autoSipEnabled = true; QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) @@ -381,8 +357,6 @@ QString QApplicationPrivate::styleSheet; // default application styles #endif QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr; -QPalette *QApplicationPrivate::sys_pal = nullptr; // default system palette - QFont *QApplicationPrivate::sys_font = nullptr; // default system font QFont *QApplicationPrivate::set_font = nullptr; // default font set by programmer @@ -545,12 +519,7 @@ void QApplicationPrivate::init() // Must be called before initialize() QColormap::initialize(); - if (sys_pal) { - // Now that we have a platform theme we need to reset - // the system palette to pick up the theme colors. - clearSystemPalette(); - initSystemPalette(); - } + initializeWidgetPalettesFromTheme(); qt_init_tooltip_palette(); QApplicationPrivate::initializeWidgetFontHash(); @@ -629,38 +598,6 @@ void QApplicationPrivate::initialize() is_app_running = true; // no longer starting up } -static void setPossiblePalette(const QPalette *palette, const char *className) -{ - if (palette == nullptr) - return; - QApplicationPrivate::setPalette_helper(*palette, className); -} - -void QApplicationPrivate::initializeWidgetPaletteHash() -{ - QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); - if (!platformTheme) - return; - - widgetPalettes.clear(); - - setPossiblePalette(platformTheme->palette(QPlatformTheme::ToolButtonPalette), "QToolButton"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::ButtonPalette), "QAbstractButton"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::CheckBoxPalette), "QCheckBox"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::RadioButtonPalette), "QRadioButton"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::HeaderPalette), "QHeaderView"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::ItemViewPalette), "QAbstractItemView"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::MessageBoxLabelPalette), "QMessageBoxLabel"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::TabBarPalette), "QTabBar"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::LabelPalette), "QLabel"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::GroupBoxPalette), "QGroupBox"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuPalette), "QMenu"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::MenuBarPalette), "QMenuBar"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextEdit"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::TextEditPalette), "QTextControl"); - setPossiblePalette(platformTheme->palette(QPlatformTheme::TextLineEditPalette), "QLineEdit"); -} - void QApplicationPrivate::initializeWidgetFontHash() { const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme(); @@ -798,9 +735,6 @@ QApplication::~QApplication() delete qt_desktopWidget; qt_desktopWidget = nullptr; - delete QApplicationPrivate::app_pal; - QApplicationPrivate::app_pal = nullptr; - clearSystemPalette(); QApplicationPrivate::widgetPalettes.clear(); delete QApplicationPrivate::sys_font; @@ -1051,10 +985,10 @@ QStyle *QApplication::style() // Take ownership of the style defaultStyle->setParent(qApp); - initSystemPalette(); - if (testAttribute(Qt::AA_SetPalette)) defaultStyle->polish(*QGuiApplicationPrivate::app_pal); + else + QApplicationPrivate::initializeWidgetPalettesFromTheme(); #ifndef QT_NO_STYLE_STYLESHEET if (!QApplicationPrivate::styleSheet.isEmpty()) { @@ -1128,13 +1062,10 @@ void QApplication::setStyle(QStyle *style) // take care of possible palette requirements of certain gui // styles. Do it before polishing the application since the style // might call QApplication::setPalette() itself - if (testAttribute(Qt::AA_SetPalette)) { + if (testAttribute(Qt::AA_SetPalette)) QApplicationPrivate::app_style->polish(*QGuiApplicationPrivate::app_pal); - } else { - if (QApplicationPrivate::sys_pal) - clearSystemPalette(); - initSystemPalette(); - } + else + QApplicationPrivate::initializeWidgetPalettesFromTheme(); // The default widget font hash is based on the platform theme, // not the style, but the widget fonts could in theory have been @@ -1317,6 +1248,22 @@ void QApplication::setGlobalStrut(const QSize& strut) // Widget specific palettes QApplicationPrivate::PaletteHash QApplicationPrivate::widgetPalettes; +QPalette QApplicationPrivate::basePalette() const +{ + // Start out with a palette based on the style, in case there's no theme + // available, or so that we can fill in missing roles in the theme. + QPalette palette = app_style ? app_style->standardPalette() : Qt::gray; + + // Prefer theme palette if available, but fill in missing roles from style + // for compatibility. Note that the style's standard palette is not prioritized + // over the theme palette, as the documented way of applying the style's palette + // is to set it explicitly using QApplication::setPalette(). + if (const QPalette *themePalette = platformTheme() ? platformTheme()->palette() : nullptr) + palette = themePalette->resolve(palette); + + return palette; +} + /*! \fn QPalette QApplication::palette(const QWidget* widget) @@ -1363,35 +1310,8 @@ QPalette QApplication::palette(const char *className) return QGuiApplication::palette(); } -void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className) -{ - QPalette pal = palette; - - if (QApplicationPrivate::app_style) - QApplicationPrivate::app_style->polish(pal); // NB: non-const reference - - bool all = false; - if (!className) { - if (!QGuiApplicationPrivate::setPalette(pal)) - return; - - if (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal)) - QCoreApplication::setAttribute(Qt::AA_SetPalette); - - if (!widgetPalettes.isEmpty()) { - all = true; - widgetPalettes.clear(); - } - } else { - widgetPalettes.insert(className, pal); - } - - if (qApp) - qApp->d_func()->sendApplicationPaletteChange(all, className); -} - /*! - Changes the default application palette to \a palette. + Changes the application palette to \a palette. If \a className is passed, the change applies only to widgets that inherit \a className (as reported by QObject::inherits()). If \a className is left @@ -1412,23 +1332,87 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* \sa QWidget::setPalette(), palette(), QStyle::polish() */ - void QApplication::setPalette(const QPalette &palette, const char* className) { - QApplicationPrivate::setPalette_helper(palette, className); + QPalette polishedPalette = palette; + + if (QApplicationPrivate::app_style) + QApplicationPrivate::app_style->polish(polishedPalette); + + if (className) { + QApplicationPrivate::widgetPalettes.insert(className, polishedPalette); + if (qApp) + qApp->d_func()->handlePaletteChanged(className); + } else { + QGuiApplication::setPalette(polishedPalette); + } } +void QApplicationPrivate::handlePaletteChanged(const char *className) +{ + if (!is_app_running || is_app_closing) + return; + + // Setting the global application palette is documented to + // reset any previously set class specific widget palettes. + bool sendPaletteChangeToAllWidgets = false; + if (!className && !widgetPalettes.isEmpty()) { + sendPaletteChangeToAllWidgets = true; + widgetPalettes.clear(); + } + QGuiApplicationPrivate::handlePaletteChanged(className); -void QApplicationPrivate::setSystemPalette(const QPalette &pal) + QEvent event(QEvent::ApplicationPaletteChange); + const QWidgetList widgets = QApplication::allWidgets(); + for (auto widget : widgets) { + if (sendPaletteChangeToAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className))) + QCoreApplication::sendEvent(widget, &event); + } + +#if QT_CONFIG(graphicsview) + for (auto scene : qAsConst(scene_list)) + QCoreApplication::sendEvent(scene, &event); +#endif + + // Palette has been reset back to the default application palette, + // so we need to reinitialize the widget palettes from the theme. + if (!className && !testAttribute(Qt::AA_SetPalette)) + initializeWidgetPalettesFromTheme(); +} + +void QApplicationPrivate::initializeWidgetPalettesFromTheme() { - if (!sys_pal) - sys_pal = new QPalette(pal); - else - *sys_pal = pal; + QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme(); + if (!platformTheme) + return; - if (!testAttribute(Qt::AA_SetPalette)) - QApplication::setPalette(*sys_pal); + widgetPalettes.clear(); + + struct ThemedWidget { const char *className; QPlatformTheme::Palette palette; }; + + static const ThemedWidget themedWidgets[] = { + { "QToolButton", QPlatformTheme::ToolButtonPalette }, + { "QAbstractButton", QPlatformTheme::ButtonPalette }, + { "QCheckBox", QPlatformTheme::CheckBoxPalette }, + { "QRadioButton", QPlatformTheme::RadioButtonPalette }, + { "QHeaderView", QPlatformTheme::HeaderPalette }, + { "QAbstractItemView", QPlatformTheme::ItemViewPalette }, + { "QMessageBoxLabel", QPlatformTheme::MessageBoxLabelPalette }, + { "QTabBar", QPlatformTheme::TabBarPalette }, + { "QLabel", QPlatformTheme::LabelPalette }, + { "QGroupBox", QPlatformTheme::GroupBoxPalette }, + { "QMenu", QPlatformTheme::MenuPalette }, + { "QMenuBar", QPlatformTheme::MenuBarPalette }, + { "QTextEdit", QPlatformTheme::TextEditPalette }, + { "QTextControl", QPlatformTheme::TextEditPalette }, + { "QLineEdit", QPlatformTheme::TextLineEditPalette }, + }; + + for (const auto themedWidget : themedWidgets) { + if (auto *palette = platformTheme->palette(themedWidget.palette)) + QApplication::setPalette(*palette, themedWidget.className); + } } /*! @@ -4413,29 +4397,8 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times void QApplicationPrivate::notifyThemeChanged() { QGuiApplicationPrivate::notifyThemeChanged(); - clearSystemPalette(); - initSystemPalette(); - qt_init_tooltip_palette(); -} - -void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) -{ - if (!is_app_running || is_app_closing) - return; - QGuiApplicationPrivate::sendApplicationPaletteChange(toAllWidgets, className); - - QEvent event(QEvent::ApplicationPaletteChange); - const QWidgetList widgets = QApplication::allWidgets(); - for (auto widget : widgets) { - if (toAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className))) - QCoreApplication::sendEvent(widget, &event); - } - -#if QT_CONFIG(graphicsview) - for (auto scene : qAsConst(scene_list)) - QCoreApplication::sendEvent(scene, &event); -#endif // QT_CONFIG(graphicsview) + qt_init_tooltip_palette(); } #if QT_CONFIG(draganddrop) diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 71f695cc18..ab6d85aeb9 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -158,12 +158,12 @@ public: static QSize app_strut; static QWidgetList *popupWidgets; static QStyle *app_style; - static QPalette *sys_pal; protected: void notifyThemeChanged() override; - void sendApplicationPaletteChange(bool toAllWidgets = false, - const char *className = nullptr) override; + + QPalette basePalette() const override; + void handlePaletteChanged(const char *className = nullptr) override; #if QT_CONFIG(draganddrop) void notifyDragStarted(const QDrag *) override; @@ -184,9 +184,7 @@ public: static int enabledAnimations; // Combination of QPlatformTheme::UiEffect static bool widgetCount; // Coupled with -widgetcount switch - static void setSystemPalette(const QPalette &pal); - static void setPalette_helper(const QPalette &palette, const char* className); - static void initializeWidgetPaletteHash(); + static void initializeWidgetPalettesFromTheme(); static void initializeWidgetFontHash(); static void setSystemFont(const QFont &font); -- cgit v1.2.3 From 99b396631999d7fc4e5e95b90a83858a5cb5a941 Mon Sep 17 00:00:00 2001 From: Paul Wicking <paul.wicking@qt.io> Date: Mon, 13 Jan 2020 14:43:34 +0100 Subject: Doc: Add note about mac-specific behavior for setWindowIcon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-74985 Change-Id: I7379865ab9564301c1e636ba1fda40cbb9e04c61 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/widgets/kernel/qwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index dcc694efe4..c389c4ab4d 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5955,7 +5955,11 @@ void QWidget::setWindowTitle(const QString &title) has been set, windowIcon() returns the application icon (QApplication::windowIcon()). - \sa windowTitle + \note On \macos, window icons represent the active document, + and will not be displayed unless a file path has also been + set using setFilePath. + + \sa windowTitle, setFilePath */ QIcon QWidget::windowIcon() const { -- cgit v1.2.3 From 3f6275960c4da87a18f3740bc3fef68dcf8a65d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=C3=A1n=20Maureira-Fredes?= <cristian.maureira-fredes@qt.io> Date: Wed, 18 Dec 2019 17:56:23 +0100 Subject: uic: add customwidget imports support for python Fixes: QTBUG-81073 Change-Id: I29659481b14927ffcb8f2cb1829b577a67e4b937 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/tools/uic/python/pythonwriteimports.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index be55696683..ce1df2284e 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -114,11 +114,29 @@ void WriteImports::acceptCustomWidget(DomCustomWidget *node) const auto &className = node->elementClass(); if (className.contains(QLatin1String("::"))) return; // Exclude namespaced names (just to make tests pass). - const QString &qtModule = qtModuleOf(node); + const QString &importModule = qtModuleOf(node); auto &output = m_uic->output(); - if (!qtModule.isEmpty()) - output << "from PySide2." << qtModule << ' '; - output << "import " << className << '\n'; + // For starting importing PySide2 modules + if (!importModule.isEmpty()) { + output << "from "; + if (importModule.startsWith(QLatin1String("Qt"))) + output << "PySide2."; + output << importModule; + if (!className.isEmpty()) + output << " import " << className << "\n\n"; + } else { + // When the elementHeader is not set, we know it's the continuation + // of a PySide2 import or a normal import of another module. + if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) { + output << "import " << className << '\n'; + } else { // When we do have elementHeader, we know it's a relative import. + QString modulePath = node->elementHeader()->text(); + // '.h' is added by default on headers for <customwidget> + if (modulePath.endsWith(QLatin1String(".h"))) + modulePath.chop(2); + output << "from " << modulePath << " import " << className << '\n'; + } + } } } // namespace Python -- cgit v1.2.3 From 2f366a63b20a943ae3099605c2cdb34009ca5602 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Mon, 13 Jan 2020 15:58:14 +0100 Subject: Windows QPA: Fix message box and other system sounds Re-add the code hooking into QWindowsUiaAccessibility::notifyAccessibilityUpdate() which was removed by 0cf6297c15be45d852be98c862bd0211e6de1aa2. Fixes: QTBUG-81342 Change-Id: Ie97d7cca5b774196d53b675c92d84f4ce208f987 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> --- .../uiautomation/qwindowsuiaaccessibility.cpp | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index c7c0deab3f..32a57473ad 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -52,6 +52,8 @@ #include <qpa/qplatformintegration.h> #include <QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h> +#include <QtCore/private/qwinregistry_p.h> + QT_BEGIN_NAMESPACE using namespace QWindowsUiAutomation; @@ -85,12 +87,63 @@ bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARA return false; } +// Retrieve sound name by checking the icon property of a message box +// should it be the event object. +static QString alertSound(const QObject *object) +{ + if (object->inherits("QMessageBox")) { + enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon + Information = 1, + Warning = 2, + Critical = 3 + }; + switch (object->property("icon").toInt()) { + case Information: + return QStringLiteral("SystemAsterisk"); + case Warning: + return QStringLiteral("SystemExclamation"); + case Critical: + return QStringLiteral("SystemHand"); + } + } + return QStringLiteral("SystemAsterisk"); +} + +static QString soundFileName(const QString &soundName) +{ + const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\") + + soundName + QStringLiteral("\\.Current"); + return QWinRegistryKey(HKEY_CURRENT_USER, key).stringValue(L""); +} + +static void playSystemSound(const QString &soundName) +{ + if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) { + PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), nullptr, + SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT); + } +} + // Handles accessibility update notifications. void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { if (!event) return; + switch (event->type()) { + case QAccessible::PopupMenuStart: + playSystemSound(QStringLiteral("MenuPopup")); + break; + case QAccessible::MenuCommand: + playSystemSound(QStringLiteral("MenuCommand")); + break; + case QAccessible::Alert: + playSystemSound(alertSound(event->object())); + break; + default: + break; + } + QAccessibleInterface *accessible = event->accessibleInterface(); if (!isActive() || !accessible || !accessible->isValid()) return; -- cgit v1.2.3 From 01d24eea09e1312e9fa7eee98e98ce22ed504aba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 14 Jan 2020 09:26:46 +0100 Subject: Windows QPA: Fix co-existence of several Qt versions in an application Change qtbase/ef54abae43db79792b40dfdca30ac0fa1b582354 added a new dummy message window for power notification. This causes the static class name conflict check to assume there is no conflict since it does not exist in previous Qt versions. Change it to perform the for each class name. Fixes: QTBUG-81347 Change-Id: I290806d021ac7de130a41e996d03b8fb4eb2c437 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> --- src/plugins/platforms/windows/qwindowscontext.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a2dd25f8cc..d31352b854 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -604,15 +604,12 @@ QString QWindowsContext::registerWindowClass(QString cname, // each one has to have window class names with a unique name // The first instance gets the unmodified name; if the class // has already been registered by another instance of Qt then - // add a UUID. - static int classExists = -1; - + // add a UUID. The check needs to be performed for each name + // in case new message windows are added (QTBUG-81347). const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); - if (classExists == -1) { - WNDCLASS wcinfo; - classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo); - classExists = classExists && wcinfo.lpfnWndProc != proc; - } + WNDCLASS wcinfo; + const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo) == TRUE + && wcinfo.lpfnWndProc != proc; if (classExists) cname += QUuid::createUuid().toString(); -- cgit v1.2.3 From 0f568d0a671e9f0667a1b47ffa6fbb9f7a10d9f5 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov <timur.pocheptsov@qt.io> Date: Tue, 14 Jan 2020 10:24:38 +0100 Subject: Uncomment erroneously commented 'error' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was meant to be deprecated in 5.15, not deleted (yet). Change-Id: I6e3772d6c1d12dc060c1f540e55e756566db22e6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/network/access/qnetworkreply.cpp | 2 -- src/network/access/qnetworkreply.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index 0a5a17a3b8..c22dce8f1c 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -565,12 +565,10 @@ QNetworkAccessManager::Operation QNetworkReply::operation() const \sa setError(), networkError() */ -/* QNetworkReply::NetworkError QNetworkReply::error() const { return networkError(); } -*/ #endif // QT_DEPRECATED_SINCE(5, 15) /*! diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h index 1bcb6d9680..139009a56a 100644 --- a/src/network/access/qnetworkreply.h +++ b/src/network/access/qnetworkreply.h @@ -126,7 +126,7 @@ public: QNetworkRequest request() const; #if QT_DEPRECATED_SINCE(5, 15) - // QT_DEPRECATED_X("Use networkError()") NetworkError error() const; + QT_DEPRECATED_X("Use networkError()") NetworkError error() const; #endif // QT_DEPRECATED_SINCE(5, 15) NetworkError networkError() const; -- cgit v1.2.3 From 7b3d0abfa25676c34808e714d4f0cccc6b6bb885 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Tue, 3 Dec 2019 15:48:21 +0100 Subject: Do fewer calendrical calculations in QDateTimeParser::setDigit() It was calling a QDate's year(), month() and day() methods, each of which repeats most of the same calendrical calculations; and the same results can be obtained from the calendar's partsFromDate() all in one go. This also reduces the number of local variables needed. Change-Id: I8f84e66a5f677f55cb2113c56ebbdf7c2517e828 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/time/qdatetimeparser.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 61214b0c7e..2636928e69 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -137,13 +137,12 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const #endif return false; } - const SectionNode &node = sectionNodes.at(index); - const QDate date = v.date(); + QCalendar::YearMonthDay date = calendar.partsFromDate(v.date()); + if (!date.isValid()) + return false; + const QTime time = v.time(); - int year = date.year(calendar); - int month = date.month(calendar); - int day = date.day(calendar); int hour = time.hour(); int minute = time.minute(); int second = time.second(); @@ -152,14 +151,15 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const // Only offset from UTC is amenable to setting an int value: int offset = tspec == Qt::OffsetFromUTC ? v.offsetFromUtc() : 0; + const SectionNode &node = sectionNodes.at(index); switch (node.type) { case Hour24Section: case Hour12Section: hour = newVal; break; case MinuteSection: minute = newVal; break; case SecondSection: second = newVal; break; case MSecSection: msec = newVal; break; case YearSection2Digits: - case YearSection: year = newVal; break; - case MonthSection: month = newVal; break; + case YearSection: date.year = newVal; break; + case MonthSection: date.month = newVal; break; case DaySection: case DayOfWeekSectionShort: case DayOfWeekSectionLong: @@ -169,7 +169,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const // to 31 for february should return true return false; } - day = newVal; + date.day = newVal; break; case TimeZoneSection: if (newVal < absoluteMin(index) || newVal > absoluteMax(index)) @@ -185,15 +185,14 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const } if (!(node.type & DaySectionMask)) { - if (day < cachedDay) - day = cachedDay; - const int max = calendar.daysInMonth(month, year); - if (day > max) { - day = max; - } + if (date.day < cachedDay) + date.day = cachedDay; + const int max = calendar.daysInMonth(date.month, date.year); + if (date.day > max) + date.day = max; } - const QDate newDate(year, month, day, calendar); + const QDate newDate = calendar.dateFromParts(date); const QTime newTime(hour, minute, second, msec); if (!newDate.isValid() || !newTime.isValid()) return false; -- cgit v1.2.3 From 96dea48c154e5971593582f92917db3b3f17c7fa Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Tue, 14 Jan 2020 09:28:27 +0100 Subject: Make the opengl module optionally depend on widgets Previously, it was a hard dependency, so the opengl module wouldn't get built when configured with -no-feature-widgets even though the widget dependency is only needed for QOpenGLWidget. Task-number: QTBUG-74409 Change-Id: Icc6e7599d0c9c31e9448456eef1e5ecc4605234a Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/opengl/qopenglwidget.h | 4 ++-- src/src.pro | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/opengl/qopenglwidget.h b/src/opengl/qopenglwidget.h index b331880b5d..b266dc359d 100644 --- a/src/opengl/qopenglwidget.h +++ b/src/opengl/qopenglwidget.h @@ -42,7 +42,7 @@ #include <QtOpenGL/qtopenglglobal.h> -#ifndef QT_NO_OPENGL +#ifdef QT_WIDGETS_LIB #include <QtWidgets/QWidget> #include <QtGui/QSurfaceFormat> @@ -110,6 +110,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_OPENGL +#endif // QT_WIDGETS_LIB #endif // QOPENGLWIDGET_H diff --git a/src/src.pro b/src/src.pro index 592f0cf644..0b8ae6d308 100644 --- a/src/src.pro +++ b/src/src.pro @@ -134,7 +134,7 @@ src_widgets.depends = src_corelib src_gui src_tools_uic src_platformheaders src_opengl.subdir = $$PWD/opengl src_opengl.target = sub-opengl -src_opengl.depends = src_gui src_widgets +src_opengl.depends = src_gui src_openglextensions.subdir = $$PWD/openglextensions src_openglextensions.target = sub-openglextensions @@ -217,7 +217,11 @@ qtConfig(gui) { TOOLS += src_tools_qvkgen } SUBDIRS += src_gui src_platformsupport src_platformheaders - qtConfig(opengl): SUBDIRS += src_openglextensions + qtConfig(opengl) { + SUBDIRS += src_openglextensions + SUBDIRS += src_opengl + src_plugins.depends += src_opengl + } src_plugins.depends += src_gui src_platformsupport src_platformheaders src_testlib.depends += src_gui # if QtGui is enabled, QtTest requires QtGui's headers qtConfig(widgets) { @@ -225,14 +229,11 @@ qtConfig(gui) { TOOLS += src_tools_uic src_plugins.depends += src_widgets src_testlib.depends += src_widgets # if QtWidgets is enabled, QtTest requires QtWidgets's headers + src_opengl.depends += src_widgets qtConfig(printer) { SUBDIRS += src_printsupport src_plugins.depends += src_printsupport } - qtConfig(opengl) { - SUBDIRS += src_opengl - src_plugins.depends += src_opengl - } } } SUBDIRS += src_plugins -- cgit v1.2.3 From 21a14767b30f6f8d27b06e609ec8eaa5ddffb324 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 14 Jan 2020 13:56:54 +0100 Subject: uic/Python: Fix missing QCursor import Fixes: PYSIDE-1182 Change-Id: I1ccc524a152ea75508166f3d2c0c60f8d829cd8f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> --- src/tools/uic/python/pythonwriteimports.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index ce1df2284e..963244d450 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE static const char *standardImports = R"I(from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, QRect, QSize, QUrl, Qt) -from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont, +from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient) from PySide2.QtWidgets import * -- cgit v1.2.3 From 8298118c527ae427ea2e8718122e1a65f4bb8bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= <tor.arne.vestbo@qt.io> Date: Tue, 7 Jan 2020 16:18:10 +0100 Subject: macOS: Move palette setup into platform theme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The theme was the only client, so there's no point in keeping it separate from its only call site. Change-Id: I4783c5db6975ad2daaede704ab5855c57f190344 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> --- src/plugins/platforms/cocoa/cocoa.pro | 2 - src/plugins/platforms/cocoa/qcocoasystemsettings.h | 54 ----- .../platforms/cocoa/qcocoasystemsettings.mm | 245 --------------------- src/plugins/platforms/cocoa/qcocoatheme.mm | 196 ++++++++++++++++- 4 files changed, 195 insertions(+), 302 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/qcocoasystemsettings.h delete mode 100644 src/plugins/platforms/cocoa/qcocoasystemsettings.mm (limited to 'src') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 4cf9e64447..6645b6c90a 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -25,7 +25,6 @@ SOURCES += main.mm \ qcocoaclipboard.mm \ qcocoadrag.mm \ qmacclipboard.mm \ - qcocoasystemsettings.mm \ qcocoainputcontext.mm \ qcocoaservices.mm \ qcocoasystemtrayicon.mm \ @@ -59,7 +58,6 @@ HEADERS += qcocoaintegration.h \ qcocoaclipboard.h \ qcocoadrag.h \ qmacclipboard.h \ - qcocoasystemsettings.h \ qcocoainputcontext.h \ qcocoaservices.h \ qcocoasystemtrayicon.h \ diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.h b/src/plugins/platforms/cocoa/qcocoasystemsettings.h deleted file mode 100644 index cf5688bbed..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QCOCOASYSTEMSETTINGS_H -#define QCOCOASYSTEMSETTINGS_H - -#include <QtCore/qhash.h> -#include <QtGui/qpalette.h> -#include <qpa/qplatformtheme.h> - -QT_BEGIN_NAMESPACE - -QPalette * qt_mac_createSystemPalette(); -QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes(); - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm deleted file mode 100644 index cb25bd7d81..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qcocoasystemsettings.h" - -#include "qcocoahelpers.h" - -#include <QtCore/private/qcore_mac_p.h> -#include <QtGui/qfont.h> -#include <QtGui/private/qcoregraphics_p.h> - -#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) -@interface NSColor (MojaveForwardDeclarations) -@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSArray<NSColor *> *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14); -// Missing from non-Mojave SDKs, even if introduced in 10.10 -@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10); -@end -#endif - -QT_BEGIN_NAMESPACE - -QPalette * qt_mac_createSystemPalette() -{ - QColor qc; - - // Standard palette initialization (copied from Qt 4 styles) - QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]); - QColor background = backgroundBrush.color(); - QColor light(background.lighter(110)); - QColor dark(background.darker(160)); - QColor mid(background.darker(140)); - QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); - - palette->setBrush(QPalette::Window, backgroundBrush); - - palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark); - palette->setBrush(QPalette::Disabled, QPalette::Text, dark); - palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark); - palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush); - QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]); - palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush); - palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush); - palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); - palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); - palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); - - // System palette initialization: - QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]); - palette->setBrush(QPalette::Active, QPalette::Highlight, br); - if (__builtin_available(macOS 10.14, *)) { - const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]); - palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); - palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight); - } else { - palette->setBrush(QPalette::Inactive, QPalette::Highlight, br); - palette->setBrush(QPalette::Disabled, QPalette::Highlight, br); - } - - palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor])); - - qc = qt_mac_toQColor([NSColor controlTextColor]); - palette->setColor(QPalette::Active, QPalette::Text, qc); - palette->setColor(QPalette::Active, QPalette::WindowText, qc); - palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); - palette->setColor(QPalette::Inactive, QPalette::Text, qc); - palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); - palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); - - qc = qt_mac_toQColor([NSColor disabledControlTextColor]); - palette->setColor(QPalette::Disabled, QPalette::Text, qc); - palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); - palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - - palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); - - palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor])); - - return palette; -} - -struct QMacPaletteMap { - inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) : - active(a), inactive(i), paletteRole(p) { } - - NSColor *active; - NSColor *inactive; - QPlatformTheme::Palette paletteRole; -}; - -#define MAC_PALETTE_ENTRY(pal, active, inactive) \ - QMacPaletteMap(pal, [NSColor active], [NSColor inactive]) -static QMacPaletteMap mac_widget_colors[] = { - MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor) -}; -#undef MAC_PALETTE_ENTRY - -static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]); - -QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes() -{ - QHash<QPlatformTheme::Palette, QPalette*> palettes; - QColor qc; - for (int i = 0; i < mac_widget_colors_count; i++) { - QPalette &pal = *qt_mac_createSystemPalette(); - if (mac_widget_colors[i].active) { - qc = qt_mac_toQColor(mac_widget_colors[i].active); - pal.setColor(QPalette::Active, QPalette::Text, qc); - pal.setColor(QPalette::Inactive, QPalette::Text, qc); - pal.setColor(QPalette::Active, QPalette::WindowText, qc); - pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); - pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Active, QPalette::ButtonText, qc); - pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); - qc = qt_mac_toQColor(mac_widget_colors[i].inactive); - pal.setColor(QPalette::Disabled, QPalette::Text, qc); - pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); - pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); - } - if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette - || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { - NSColor *selectedMenuItemColor = nil; - if (__builtin_available(macOS 10.14, *)) { - // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) - selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; - } else { - // selectedMenuItemColor would presumably be the correct color to use as the background - // for selected menu items. But that color is always blue, and doesn't follow the - // appearance color in system preferences. So we therefore deliberatly choose to use - // keyboardFocusIndicatorColor instead, which appears to have the same color value. - selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; - } - pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); - qc = qt_mac_toQColor([NSColor labelColor]); - pal.setBrush(QPalette::ButtonText, qc); - pal.setBrush(QPalette::Text, qc); - qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]); - pal.setBrush(QPalette::HighlightedText, qc); - qc = qt_mac_toQColor([NSColor disabledControlTextColor]); - pal.setBrush(QPalette::Disabled, QPalette::Text, qc); - } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette) - || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette) - || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) { - pal.setColor(QPalette::Disabled, QPalette::ButtonText, - pal.color(QPalette::Disabled, QPalette::Text)); - pal.setColor(QPalette::Inactive, QPalette::ButtonText, - pal.color(QPalette::Inactive, QPalette::Text)); - pal.setColor(QPalette::Active, QPalette::ButtonText, - pal.color(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) { - NSArray<NSColor *> *baseColors = nil; - NSColor *activeHighlightColor = nil; - if (__builtin_available(macOS 10.14, *)) { - baseColors = [NSColor alternatingContentBackgroundColors]; - activeHighlightColor = [NSColor selectedContentBackgroundColor]; - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor])); - } else { - baseColors = [NSColor controlAlternatingRowBackgroundColors]; - activeHighlightColor = [NSColor alternateSelectedControlColor]; - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - pal.brush(QPalette::Active, QPalette::Text)); - } - pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0])); - pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1])); - pal.setBrush(QPalette::Active, QPalette::Highlight, - qt_mac_toQBrush(activeHighlightColor)); - pal.setBrush(QPalette::Active, QPalette::HighlightedText, - qt_mac_toQBrush([NSColor alternateSelectedControlTextColor])); - pal.setBrush(QPalette::Inactive, QPalette::Text, - pal.brush(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) { - pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); - pal.setBrush(QPalette::Inactive, QPalette::Text, - pal.brush(QPalette::Active, QPalette::Text)); - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - pal.brush(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette - || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) { - pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); - pal.setBrush(QPalette::Disabled, QPalette::Base, - pal.brush(QPalette::Active, QPalette::Base)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { - qc = qt_mac_toQColor([NSColor labelColor]); - pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); - } - palettes.insert(mac_widget_colors[i].paletteRole, &pal); - } - return palettes; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 387df65721..a76ba300e9 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -45,7 +45,6 @@ #include <QtCore/QOperatingSystemVersion> #include <QtCore/QVariant> -#include "qcocoasystemsettings.h" #include "qcocoasystemtrayicon.h" #include "qcocoamenuitem.h" #include "qcocoamenu.h" @@ -80,8 +79,203 @@ #include <CoreServices/CoreServices.h> +#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) +@interface NSColor (MojaveForwardDeclarations) +@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSArray<NSColor *> *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14); +// Missing from non-Mojave SDKs, even if introduced in 10.10 +@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10); +@end +#endif + QT_BEGIN_NAMESPACE +static QPalette *qt_mac_createSystemPalette() +{ + QColor qc; + + // Standard palette initialization (copied from Qt 4 styles) + QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]); + QColor background = backgroundBrush.color(); + QColor light(background.lighter(110)); + QColor dark(background.darker(160)); + QColor mid(background.darker(140)); + QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); + + palette->setBrush(QPalette::Window, backgroundBrush); + + palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark); + palette->setBrush(QPalette::Disabled, QPalette::Text, dark); + palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark); + palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush); + QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]); + palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush); + palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush); + palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); + palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); + palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); + + // System palette initialization: + QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]); + palette->setBrush(QPalette::Active, QPalette::Highlight, br); + if (__builtin_available(macOS 10.14, *)) { + const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]); + palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight); + } else { + palette->setBrush(QPalette::Inactive, QPalette::Highlight, br); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, br); + } + + palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor])); + + qc = qt_mac_toQColor([NSColor controlTextColor]); + palette->setColor(QPalette::Active, QPalette::Text, qc); + palette->setColor(QPalette::Active, QPalette::WindowText, qc); + palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); + palette->setColor(QPalette::Inactive, QPalette::Text, qc); + palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); + palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + + qc = qt_mac_toQColor([NSColor disabledControlTextColor]); + palette->setColor(QPalette::Disabled, QPalette::Text, qc); + palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); + palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + + palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); + + palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor])); + + return palette; +} + +struct QMacPaletteMap { + inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) : + active(a), inactive(i), paletteRole(p) { } + + NSColor *active; + NSColor *inactive; + QPlatformTheme::Palette paletteRole; +}; + +#define MAC_PALETTE_ENTRY(pal, active, inactive) \ + QMacPaletteMap(pal, [NSColor active], [NSColor inactive]) +static QMacPaletteMap mac_widget_colors[] = { + MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor) +}; +#undef MAC_PALETTE_ENTRY + +static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]); + +static QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes() +{ + QHash<QPlatformTheme::Palette, QPalette*> palettes; + QColor qc; + for (int i = 0; i < mac_widget_colors_count; i++) { + QPalette &pal = *qt_mac_createSystemPalette(); + if (mac_widget_colors[i].active) { + qc = qt_mac_toQColor(mac_widget_colors[i].active); + pal.setColor(QPalette::Active, QPalette::Text, qc); + pal.setColor(QPalette::Inactive, QPalette::Text, qc); + pal.setColor(QPalette::Active, QPalette::WindowText, qc); + pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); + pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Active, QPalette::ButtonText, qc); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); + qc = qt_mac_toQColor(mac_widget_colors[i].inactive); + pal.setColor(QPalette::Disabled, QPalette::Text, qc); + pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); + pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); + } + if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { + NSColor *selectedMenuItemColor = nil; + if (__builtin_available(macOS 10.14, *)) { + // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) + selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; + } else { + // selectedMenuItemColor would presumably be the correct color to use as the background + // for selected menu items. But that color is always blue, and doesn't follow the + // appearance color in system preferences. So we therefore deliberatly choose to use + // keyboardFocusIndicatorColor instead, which appears to have the same color value. + selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; + } + pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::ButtonText, qc); + pal.setBrush(QPalette::Text, qc); + qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]); + pal.setBrush(QPalette::HighlightedText, qc); + qc = qt_mac_toQColor([NSColor disabledControlTextColor]); + pal.setBrush(QPalette::Disabled, QPalette::Text, qc); + } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette) + || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette) + || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) { + pal.setColor(QPalette::Disabled, QPalette::ButtonText, + pal.color(QPalette::Disabled, QPalette::Text)); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, + pal.color(QPalette::Inactive, QPalette::Text)); + pal.setColor(QPalette::Active, QPalette::ButtonText, + pal.color(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) { + NSArray<NSColor *> *baseColors = nil; + NSColor *activeHighlightColor = nil; + if (__builtin_available(macOS 10.14, *)) { + baseColors = [NSColor alternatingContentBackgroundColors]; + activeHighlightColor = [NSColor selectedContentBackgroundColor]; + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor])); + } else { + baseColors = [NSColor controlAlternatingRowBackgroundColors]; + activeHighlightColor = [NSColor alternateSelectedControlColor]; + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + pal.brush(QPalette::Active, QPalette::Text)); + } + pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0])); + pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1])); + pal.setBrush(QPalette::Active, QPalette::Highlight, + qt_mac_toQBrush(activeHighlightColor)); + pal.setBrush(QPalette::Active, QPalette::HighlightedText, + qt_mac_toQBrush([NSColor alternateSelectedControlTextColor])); + pal.setBrush(QPalette::Inactive, QPalette::Text, + pal.brush(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) { + pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); + pal.setBrush(QPalette::Inactive, QPalette::Text, + pal.brush(QPalette::Active, QPalette::Text)); + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + pal.brush(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) { + pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); + pal.setBrush(QPalette::Disabled, QPalette::Base, + pal.brush(QPalette::Active, QPalette::Base)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); + } + palettes.insert(mac_widget_colors[i].paletteRole, &pal); + } + return palettes; +} + const char *QCocoaTheme::name = "cocoa"; QCocoaTheme::QCocoaTheme() -- cgit v1.2.3 From 2cbc5f6f7ae8ba580126a7cafc1898377c2a2407 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Fri, 3 Jan 2020 12:07:43 +0100 Subject: Fix -Wdeprecated-copy warning QDBusReply has an user-specified operator= but no copy constructor. Change-Id: If7fcec3193af375f1bf2dd913d82548d6e035b48 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/dbus/qdbusreply.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h index 869687ac85..8cdc0ae246 100644 --- a/src/dbus/qdbusreply.h +++ b/src/dbus/qdbusreply.h @@ -64,6 +64,7 @@ public: { *this = reply; } + inline QDBusReply(const QDBusReply &) = default; inline QDBusReply& operator=(const QDBusMessage &reply) { QVariant data(qMetaTypeId<Type>(), nullptr); -- cgit v1.2.3 From 7a59d6f138ff8799170cc03d709525ab965d703a Mon Sep 17 00:00:00 2001 From: Nico Vertriest <nico.vertriest@qt.io> Date: Wed, 8 Jan 2020 14:46:12 +0100 Subject: Doc: Correct non-link related qdoc compilation errors Task-number: QTBUG-79824 Change-Id: I94dc566c9fb11bc8c598c0d5c043b6f388ebdc80 Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/corelib/io/qprocess.cpp | 4 +++- src/corelib/itemmodels/qstringlistmodel.cpp | 5 +++++ src/corelib/tools/qline.cpp | 2 +- src/corelib/tools/qscopeguard.qdoc | 8 ++++---- src/corelib/tools/qsharedpointer.cpp | 2 ++ src/testlib/qsignalspy.qdoc | 6 +++--- src/widgets/dialogs/qfiledialog.cpp | 3 ++- src/widgets/dialogs/qfilesystemmodel.cpp | 3 ++- src/widgets/kernel/qshortcut.cpp | 2 +- 9 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 3a77242d7c..49e0847d44 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1004,7 +1004,7 @@ QT_WARNING_POP /*! \internal - Returns true if we emitted readyRead(). + Returns \c true if we emitted readyRead(). */ bool QProcessPrivate::tryReadFromChannel(Channel *channel) { @@ -2187,6 +2187,8 @@ bool QProcess::startDetached(qint64 *pid) This method is an alias for start(), and exists only to fully implement the interface defined by QIODevice. + Returns \c true if the program has been started. + \sa start(), setProgram(), setArguments() */ bool QProcess::open(OpenMode mode) diff --git a/src/corelib/itemmodels/qstringlistmodel.cpp b/src/corelib/itemmodels/qstringlistmodel.cpp index a248cdcd38..4c7616a126 100644 --- a/src/corelib/itemmodels/qstringlistmodel.cpp +++ b/src/corelib/itemmodels/qstringlistmodel.cpp @@ -212,6 +212,7 @@ Qt::ItemFlags QStringListModel::flags(const QModelIndex &index) const \a index in the model, to the provided \a value. The dataChanged() signal is emitted if the item is changed. + Returns \c true after emitting the dataChanged() signal. \sa Qt::ItemDataRole, data() */ @@ -249,6 +250,8 @@ bool QStringListModel::clearItemData(const QModelIndex &index) specified, indicating that the rows are inserted in the top level of the model. + Returns \c true if the insertion was successful. + \sa QAbstractItemModel::insertRows() */ @@ -275,6 +278,8 @@ bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent) specified, indicating that the rows are removed in the top level of the model. + Returns \c true if the row removal was successful. + \sa QAbstractItemModel::removeRows() */ diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 3afd23d76b..dde66ed093 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -374,7 +374,7 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) */ /*! - \enum QLineF::IntersectionType + \enum QLineF::IntersectType Describes the intersection between two lines. diff --git a/src/corelib/tools/qscopeguard.qdoc b/src/corelib/tools/qscopeguard.qdoc index 5a9b7fd210..6b3c942e84 100644 --- a/src/corelib/tools/qscopeguard.qdoc +++ b/src/corelib/tools/qscopeguard.qdoc @@ -51,10 +51,10 @@ QT_BEGIN_NAMESPACE of the scope. \ingroup misc - QScopeGuard<F> is a class which sole purpose is to run a function \e F in - its destructor. This is useful for guaranteeing your cleanup code is - executed, whether the function is exited normally, exited early by a return - statement, or exited by an exception. + QScopeGuard<F> is a class of which the sole purpose is to run the function + \a f in its destructor. This is useful for guaranteeing + your cleanup code is executed, whether the function is exited normally, + exited early by a return statement, or exited by an exception. If \e F is a lambda then you cannot instantiate the template directly, therefore the qScopeGuard() helper is provided and QScopeGuard<F> is made a diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index f185d2f23f..0576fb2bd0 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1285,6 +1285,8 @@ \relates QSharedPointer \since 5.14 + Returns a shared pointer to the pointer held by \a src. + Same as qSharedPointerObjectCast(). This function is provided for STL compatibility. */ diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc index d40c84907c..42e02ed601 100644 --- a/src/testlib/qsignalspy.qdoc +++ b/src/testlib/qsignalspy.qdoc @@ -102,9 +102,9 @@ \since 5.14 Constructs a new QSignalSpy that listens for emissions of the \a signal - from the QObject \a object. If QSignalSpy is not able to listen for a - valid signal (for example, because \a object is \nullptr or \a signal does - not denote a valid signal of \a object), an explanatory warning message + from the QObject \a obj. If QSignalSpy is not able to listen for a + valid signal (for example, because \a obj is \nullptr or \a signal does + not denote a valid signal of \a obj), an explanatory warning message will be output using qWarning() and subsequent calls to \c isValid() will return false. diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index a1b9003c1c..787c0e6511 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2374,7 +2374,8 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent, This function is used to access local files on Qt for WebAssembly, where the web sandbox places restrictions on how such access may happen. Its implementation will - make the browser display a native file dialog, where the user makes the file selection. + make the browser display a native file dialog, where the user makes the file selection + based on the parameter \a nameFilter. It can also be used on other platforms, where it will fall back to using QFileDialog. diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a04189513a..86afb27719 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1214,7 +1214,8 @@ QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const /*! Handles the \a data supplied by a drag and drop operation that ended with the given \a action over the row in the model specified by the \a row and - \a column and by the \a parent index. + \a column and by the \a parent index. Returns true if the operation was + successful. \sa supportedDropActions() */ diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index f157ba2943..eec65c8625 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -475,7 +475,7 @@ QShortcut::QShortcut(QWidget *parent) match the \a key sequence. Depending on the ambiguity of the event, the shortcut will call the \a member function, or the \a ambiguousMember function, if the key press was in the shortcut's - \a shortcutContext. + \a context. */ QShortcut::QShortcut(const QKeySequence &key, QWidget *parent, const char *member, const char *ambiguousMember, -- cgit v1.2.3 From c4b71844f779370ced5e3b959e20bac068963313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Tue, 14 Jan 2020 12:16:53 +0100 Subject: QHostInfo: Remove useless code This code has not been doing anything interesting since symbian times Change-Id: If652c75b85e20f631edc4f946aacdee479a19212 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> --- src/network/kernel/qhostinfo.cpp | 21 --------------------- src/network/kernel/qhostinfo_p.h | 7 ------- src/network/socket/qabstractsocket.cpp | 21 +++++++-------------- 3 files changed, 7 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 6476ff7741..93be053ef3 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -383,27 +383,6 @@ QHostInfo QHostInfo::fromName(const QString &name) return hostInfo; } -#ifndef QT_NO_BEARERMANAGEMENT -QHostInfo QHostInfoPrivate::fromName(const QString &name, QSharedPointer<QNetworkSession> session) -{ -#if defined QHOSTINFO_DEBUG - qDebug("QHostInfoPrivate::fromName(\"%s\") with session %p",name.toLatin1().constData(), session.data()); -#endif - - QHostInfo hostInfo = QHostInfoAgent::fromName(name, session); - QHostInfoLookupManager* manager = theHostInfoLookupManager(); - manager->cache.put(name, hostInfo); - return hostInfo; -} -#endif - -#ifndef QT_NO_BEARERMANAGEMENT -QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer<QNetworkSession>) -{ - return QHostInfoAgent::fromName(hostName); -} -#endif - QHostInfo QHostInfoAgent::reverseLookup(const QHostAddress &address) { QHostInfo results; diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 1798ceab0a..d7875a0673 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -119,9 +119,6 @@ class QHostInfoAgent { public: static QHostInfo fromName(const QString &hostName); -#ifndef QT_NO_BEARERMANAGEMENT - static QHostInfo fromName(const QString &hostName, QSharedPointer<QNetworkSession> networkSession); -#endif private: static QHostInfo lookup(const QString &hostName); static QHostInfo reverseLookup(const QHostAddress &address); @@ -136,10 +133,6 @@ public: lookupId(0) { } -#ifndef QT_NO_BEARERMANAGEMENT - //not a public API yet - static QHostInfo fromName(const QString &hostName, QSharedPointer<QNetworkSession> networkSession); -#endif static int lookupHostImpl(const QString &name, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj, diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 0d9e25954d..b8957ce818 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -2144,20 +2144,13 @@ bool QAbstractSocket::waitForConnected(int msecs) #endif QHostInfo::abortHostLookup(d->hostLookupId); d->hostLookupId = -1; -#ifndef QT_NO_BEARERMANAGEMENT - if (networkSession) { - d->_q_startConnecting(QHostInfoPrivate::fromName(d->hostName, networkSession)); - } else -#endif - { - QHostAddress temp; - if (temp.setAddress(d->hostName)) { - QHostInfo info; - info.setAddresses(QList<QHostAddress>() << temp); - d->_q_startConnecting(info); - } else { - d->_q_startConnecting(QHostInfo::fromName(d->hostName)); - } + QHostAddress temp; + if (temp.setAddress(d->hostName)) { + QHostInfo info; + info.setAddresses(QList<QHostAddress>() << temp); + d->_q_startConnecting(info); + } else { + d->_q_startConnecting(QHostInfo::fromName(d->hostName)); } } if (state() == UnconnectedState) -- cgit v1.2.3 From 4772a2da15ae0624633f3fc4d029d5f0e1e33892 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Wed, 11 Dec 2019 12:20:06 +0100 Subject: Move QOpenGLWindow from QtGui to QtOpenGL Task-number: QTBUG-74409 Change-Id: If7d27cdfa2c6cd5b167887ad77b9cfe413cb106a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qopenglwindow.cpp | 698 --------------------------------------- src/gui/kernel/qopenglwindow.h | 107 ------ src/opengl/opengl.pro | 2 + src/opengl/qopenglwindow.cpp | 698 +++++++++++++++++++++++++++++++++++++++ src/opengl/qopenglwindow.h | 107 ++++++ 6 files changed, 809 insertions(+), 809 deletions(-) delete mode 100644 src/gui/kernel/qopenglwindow.cpp delete mode 100644 src/gui/kernel/qopenglwindow.h create mode 100644 src/opengl/qopenglwindow.cpp create mode 100644 src/opengl/qopenglwindow.h (limited to 'src') diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 3784abdacc..d47fd6e4e4 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -158,13 +158,11 @@ qtConfig(opengl) { HEADERS += \ kernel/qplatformopenglcontext.h \ kernel/qopenglcontext.h \ - kernel/qopenglcontext_p.h \ - kernel/qopenglwindow.h + kernel/qopenglcontext_p.h SOURCES += \ kernel/qplatformopenglcontext.cpp \ - kernel/qopenglcontext.cpp \ - kernel/qopenglwindow.cpp + kernel/qopenglcontext.cpp } qtConfig(shortcut) { diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp deleted file mode 100644 index 2ea8f43711..0000000000 --- a/src/gui/kernel/qopenglwindow.cpp +++ /dev/null @@ -1,698 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qopenglwindow.h" -#include "qpaintdevicewindow_p.h" -#include <QtGui/QOpenGLFramebufferObject> -#include <QtGui/QOpenGLPaintDevice> -#include <QtGui/QOpenGLFunctions> -#include <QtGui/QOpenGLTextureBlitter> -#include <QtGui/private/qopenglextensions_p.h> -#include <QtGui/private/qopenglcontext_p.h> -#include <QtGui/QMatrix4x4> -#include <QtGui/QOffscreenSurface> - -QT_BEGIN_NAMESPACE - -/*! - \class QOpenGLWindow - \inmodule QtGui - \since 5.4 - \brief The QOpenGLWindow class is a convenience subclass of QWindow to perform OpenGL painting. - - QOpenGLWindow is an enhanced QWindow that allows easily creating windows that - perform OpenGL rendering using an API that is compatible with QOpenGLWidget - and is similar to the legacy QGLWidget. Unlike QOpenGLWidget, QOpenGLWindow - has no dependency on the widgets module and offers better performance. - - A typical application will subclass QOpenGLWindow and reimplement the following - virtual functions: - - \list - - \li initializeGL() to perform OpenGL resource initialization - - \li resizeGL() to set up the transformation matrices and other window size dependent resources - - \li paintGL() to issue OpenGL commands or draw using QPainter - - \endlist - - To schedule a repaint, call the update() function. Note that this will not - immediately result in a call to paintGL(). Calling update() multiple times in - a row will not change the behavior in any way. - - This is a slot so it can be connected to a \l QTimer::timeout() signal to - perform animation. Note however that in the modern OpenGL world it is a much - better choice to rely on synchronization to the vertical refresh rate of the - display. See \l{QSurfaceFormat::setSwapInterval()}{setSwapInterval()} on a - description of the swap interval. With a swap interval of \c 1, which is the - case on most systems by default, the - \l{QOpenGLContext::swapBuffers()}{swapBuffers()} call, that is executed - internally by QOpenGLWindow after each repaint, will block and wait for - vsync. This means that whenever the swap is done, an update can be scheduled - again by calling update(), without relying on timers. - - To request a specific configuration for the context, use setFormat() - like for any other QWindow. This allows, among others, requesting a - given OpenGL version and profile, or enabling depth and stencil - buffers. - - Unlike QWindow, QOpenGLWindow allows opening a painter on itself and perform - QPainter-based drawing. - - QOpenGLWindow supports multiple update behaviors. The default, - \c NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow or the - legacy QGLWidget. In contrast, \c PartialUpdateBlit and \c PartialUpdateBlend are - more in line with QOpenGLWidget's way of working, where there is always an - extra, dedicated framebuffer object present. These modes allow, by - sacrificing some performance, redrawing only a smaller area on each paint and - having the rest of the content preserved from of the previous frame. This is - useful for applications than render incrementally using QPainter, because - this way they do not have to redraw the entire window content on each - paintGL() call. - - Similarly to QOpenGLWidget, QOpenGLWindow supports the Qt::AA_ShareOpenGLContexts - attribute. When enabled, the OpenGL contexts of all QOpenGLWindow instances will share - with each other. This allows accessing each other's shareable OpenGL resources. - - For more information on graphics in Qt, see \l {Graphics}. - */ - -/*! - \enum QOpenGLWindow::UpdateBehavior - - This enum describes the update strategy of the QOpenGLWindow. - - \value NoPartialUpdate Indicates that the entire window surface will - redrawn on each update and so no additional framebuffers are needed. - This is the setting used in most cases and is equivalent to how drawing - directly via QWindow would function. - - \value PartialUpdateBlit Indicates that the drawing performed in paintGL() - does not cover the entire window. In this case an extra framebuffer object - is created under the hood, and rendering performed in paintGL() will target - this framebuffer. This framebuffer is then blitted onto the window surface's - default framebuffer after each paint. This allows having QPainter-based drawing - code in paintGL() which only repaints a smaller area at a time, because, unlike - NoPartialUpdate, the previous content is preserved. - - \value PartialUpdateBlend Similar to PartialUpdateBlit, but instead of using - framebuffer blits, the contents of the extra framebuffer is rendered by - drawing a textured quad with blending enabled. This, unlike PartialUpdateBlit, - allows alpha blended content and works even when the glBlitFramebuffer is - not available. Performance-wise this setting is likely to be somewhat slower - than PartialUpdateBlit. - */ - -/*! - \fn void QOpenGLWindow::frameSwapped() - - This signal is emitted after the potentially blocking - \l{QOpenGLContext::swapBuffers()}{buffer swap} has been done. Applications - that wish to continuously repaint synchronized to the vertical refresh, - should issue an update() upon this signal. This allows for a much smoother - experience compared to the traditional usage of timers. -*/ - -// GLES2 builds won't have these constants with the suffixless names -#ifndef GL_READ_FRAMEBUFFER -#define GL_READ_FRAMEBUFFER 0x8CA8 -#endif -#ifndef GL_DRAW_FRAMEBUFFER -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#endif - -class QOpenGLWindowPaintDevice : public QOpenGLPaintDevice -{ -public: - QOpenGLWindowPaintDevice(QOpenGLWindow *window) : m_window(window) { } - void ensureActiveTarget() override; - - QOpenGLWindow *m_window; -}; - -class QOpenGLWindowPrivate : public QPaintDeviceWindowPrivate -{ - Q_DECLARE_PUBLIC(QOpenGLWindow) -public: - QOpenGLWindowPrivate(QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior) - : updateBehavior(updateBehavior) - , hasFboBlit(false) - , shareContext(shareContext) - { - if (!shareContext) - this->shareContext = qt_gl_global_share_context(); - } - - ~QOpenGLWindowPrivate(); - - static QOpenGLWindowPrivate *get(QOpenGLWindow *w) { return w->d_func(); } - - void bindFBO(); - void initialize(); - - void beginPaint(const QRegion ®ion) override; - void endPaint() override; - void flush(const QRegion ®ion) override; - - QOpenGLWindow::UpdateBehavior updateBehavior; - bool hasFboBlit; - QScopedPointer<QOpenGLContext> context; - QOpenGLContext *shareContext; - QScopedPointer<QOpenGLFramebufferObject> fbo; - QScopedPointer<QOpenGLWindowPaintDevice> paintDevice; - QOpenGLTextureBlitter blitter; - QColor backgroundColor; - QScopedPointer<QOffscreenSurface> offscreenSurface; -}; - -QOpenGLWindowPrivate::~QOpenGLWindowPrivate() -{ - Q_Q(QOpenGLWindow); - if (q->isValid()) { - q->makeCurrent(); // this works even when the platformwindow is destroyed - paintDevice.reset(nullptr); - fbo.reset(nullptr); - blitter.destroy(); - q->doneCurrent(); - } -} - -void QOpenGLWindowPrivate::initialize() -{ - Q_Q(QOpenGLWindow); - - if (context) - return; - - if (!q->handle()) - qWarning("Attempted to initialize QOpenGLWindow without a platform window"); - - context.reset(new QOpenGLContext); - context->setShareContext(shareContext); - context->setFormat(q->requestedFormat()); - if (!context->create()) - qWarning("QOpenGLWindow::beginPaint: Failed to create context"); - if (!context->makeCurrent(q)) - qWarning("QOpenGLWindow::beginPaint: Failed to make context current"); - - paintDevice.reset(new QOpenGLWindowPaintDevice(q)); - if (updateBehavior == QOpenGLWindow::PartialUpdateBlit) - hasFboBlit = QOpenGLFramebufferObject::hasOpenGLFramebufferBlit(); - - q->initializeGL(); -} - -void QOpenGLWindowPrivate::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); - Q_Q(QOpenGLWindow); - - initialize(); - context->makeCurrent(q); - - const int deviceWidth = q->width() * q->devicePixelRatio(); - const int deviceHeight = q->height() * q->devicePixelRatio(); - const QSize deviceSize(deviceWidth, deviceHeight); - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { - if (!fbo || fbo->size() != deviceSize) { - QOpenGLFramebufferObjectFormat fboFormat; - fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - const int samples = q->requestedFormat().samples(); - if (samples > 0) { - if (updateBehavior != QOpenGLWindow::PartialUpdateBlend) - fboFormat.setSamples(samples); - else - qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling"); - } - fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat)); - markWindowAsDirty(); - } - } else { - markWindowAsDirty(); - } - - paintDevice->setSize(QSize(deviceWidth, deviceHeight)); - paintDevice->setDevicePixelRatio(q->devicePixelRatio()); - context->functions()->glViewport(0, 0, deviceWidth, deviceHeight); - - context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); - - q->paintUnderGL(); - - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) - fbo->bind(); -} - -void QOpenGLWindowPrivate::endPaint() -{ - Q_Q(QOpenGLWindow); - - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) - fbo->release(); - - context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); - - if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) { - const int deviceWidth = q->width() * q->devicePixelRatio(); - const int deviceHeight = q->height() * q->devicePixelRatio(); - QOpenGLExtensions extensions(context.data()); - extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle()); - extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject()); - extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight, - 0, 0, deviceWidth, deviceHeight, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { - if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) { - context->functions()->glEnable(GL_BLEND); - context->functions()->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - if (!blitter.isCreated()) - blitter.create(); - - QRect windowRect(QPoint(0, 0), fbo->size()); - QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect); - blitter.bind(); - blitter.blit(fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft); - blitter.release(); - - if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) - context->functions()->glDisable(GL_BLEND); - } - - q->paintOverGL(); -} - -void QOpenGLWindowPrivate::bindFBO() -{ - if (updateBehavior > QOpenGLWindow::NoPartialUpdate) - fbo->bind(); - else - QOpenGLFramebufferObject::bindDefault(); -} - -void QOpenGLWindowPrivate::flush(const QRegion ®ion) -{ - Q_UNUSED(region); - Q_Q(QOpenGLWindow); - context->swapBuffers(q); - emit q->frameSwapped(); -} - -void QOpenGLWindowPaintDevice::ensureActiveTarget() -{ - QOpenGLWindowPrivate::get(m_window)->bindFBO(); -} - -/*! - Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. - - \sa QOpenGLWindow::UpdateBehavior - */ -QOpenGLWindow::QOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior, QWindow *parent) - : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(nullptr, updateBehavior)), parent) -{ - setSurfaceType(QSurface::OpenGLSurface); -} - -/*! - Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. The QOpenGLWindow's context will share with \a shareContext. - - \sa QOpenGLWindow::UpdateBehavior shareContext -*/ -QOpenGLWindow::QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior, QWindow *parent) - : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(shareContext, updateBehavior)), parent) -{ - setSurfaceType(QSurface::OpenGLSurface); -} - -/*! - Destroys the QOpenGLWindow instance, freeing its resources. - - The OpenGLWindow's context is made current in the destructor, allowing for - safe destruction of any child object that may need to release OpenGL - resources belonging to the context provided by this window. - - \warning if you have objects wrapping OpenGL resources (such as - QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a QOpenGLWindow - subclass, you may need to add a call to makeCurrent() in that subclass' - destructor as well. Due to the rules of C++ object destruction, those objects - will be destroyed \e{before} calling this function (but after that the - destructor of the subclass has run), therefore making the OpenGL context - current in this function happens too late for their safe disposal. - - \sa makeCurrent - - \since 5.5 -*/ -QOpenGLWindow::~QOpenGLWindow() -{ - makeCurrent(); -} - -/*! - \return the update behavior for this QOpenGLWindow. -*/ -QOpenGLWindow::UpdateBehavior QOpenGLWindow::updateBehavior() const -{ - Q_D(const QOpenGLWindow); - return d->updateBehavior; -} - -/*! - \return \c true if the window's OpenGL resources, like the context, have - been successfully initialized. Note that the return value is always \c false - until the window becomes exposed (shown). -*/ -bool QOpenGLWindow::isValid() const -{ - Q_D(const QOpenGLWindow); - return d->context && d->context->isValid(); -} - -/*! - Prepares for rendering OpenGL content for this window by making the - corresponding context current and binding the framebuffer object, if there is - one, in that context context. - - It is not necessary to call this function in most cases, because it is called - automatically before invoking paintGL(). It is provided nonetheless to support - advanced, multi-threaded scenarios where a thread different than the GUI or main - thread may want to update the surface or framebuffer contents. See QOpenGLContext - for more information on threading related issues. - - This function is suitable for calling also when the underlying platform window - is already destroyed. This means that it is safe to call this function from - a QOpenGLWindow subclass' destructor. If there is no native window anymore, - an offscreen surface is used instead. This ensures that OpenGL resource - cleanup operations in the destructor will always work, as long as - this function is called first. - - \sa QOpenGLContext, context(), paintGL(), doneCurrent() - */ -void QOpenGLWindow::makeCurrent() -{ - Q_D(QOpenGLWindow); - - if (!isValid()) - return; - - // The platform window may be destroyed at this stage and therefore - // makeCurrent() may not safely be called with 'this'. - if (handle()) { - d->context->makeCurrent(this); - } else { - if (!d->offscreenSurface) { - d->offscreenSurface.reset(new QOffscreenSurface(screen())); - d->offscreenSurface->setFormat(d->context->format()); - d->offscreenSurface->create(); - } - d->context->makeCurrent(d->offscreenSurface.data()); - } - - d->bindFBO(); -} - -/*! - Releases the context. - - It is not necessary to call this function in most cases, since the widget - will make sure the context is bound and released properly when invoking - paintGL(). - - \sa makeCurrent() - */ -void QOpenGLWindow::doneCurrent() -{ - Q_D(QOpenGLWindow); - - if (!isValid()) - return; - - d->context->doneCurrent(); -} - -/*! - \return The QOpenGLContext used by this window or \c 0 if not yet initialized. - */ -QOpenGLContext *QOpenGLWindow::context() const -{ - Q_D(const QOpenGLWindow); - return d->context.data(); -} - -/*! - \return The QOpenGLContext requested to be shared with this window's QOpenGLContext. -*/ -QOpenGLContext *QOpenGLWindow::shareContext() const -{ - Q_D(const QOpenGLWindow); - return d->shareContext; -} - -/*! - The framebuffer object handle used by this window. - - When the update behavior is set to \c NoPartialUpdate, there is no separate - framebuffer object. In this case the returned value is the ID of the - default framebuffer. - - Otherwise the value of the ID of the framebuffer object or \c 0 if not - yet initialized. - */ -GLuint QOpenGLWindow::defaultFramebufferObject() const -{ - Q_D(const QOpenGLWindow); - if (d->updateBehavior > NoPartialUpdate && d->fbo) - return d->fbo->handle(); - else if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) - return ctx->defaultFramebufferObject(); - else - return 0; -} - -extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); - -/*! - Returns a copy of the framebuffer. - - \note This is a potentially expensive operation because it relies on - glReadPixels() to read back the pixels. This may be slow and can stall the - GPU pipeline. - - \note When used together with update behavior \c NoPartialUpdate, the returned - image may not contain the desired content when called after the front and back - buffers have been swapped (unless preserved swap is enabled in the underlying - windowing system interface). In this mode the function reads from the back - buffer and the contents of that may not match the content on the screen (the - front buffer). In this case the only place where this function can safely be - used is paintGL() or paintOverGL(). - */ -QImage QOpenGLWindow::grabFramebuffer() -{ - if (!isValid()) - return QImage(); - - makeCurrent(); - - const bool hasAlpha = format().hasAlpha(); - QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), hasAlpha, hasAlpha); - img.setDevicePixelRatio(devicePixelRatio()); - return img; -} - -/*! - This virtual function is called once before the first call to paintGL() or - resizeGL(). Reimplement it in a subclass. - - This function should set up any required OpenGL resources and state. - - There is no need to call makeCurrent() because this has already been done - when this function is called. Note however that the framebuffer, in case - partial update mode is used, is not yet available at this stage, so avoid - issuing draw calls from here. Defer such calls to paintGL() instead. - - \sa paintGL(), resizeGL() - */ -void QOpenGLWindow::initializeGL() -{ -} - -/*! - This virtual function is called whenever the widget has been resized. - Reimplement it in a subclass. The new size is passed in \a w and \a h. - - \note This is merely a convenience function in order to provide an API that is - compatible with QOpenGLWidget. Unlike with QOpenGLWidget, derived classes are - free to choose to override resizeEvent() instead of this function. - - \note Avoid issuing OpenGL commands from this function as there may not be a - context current when it is invoked. If it cannot be avoided, call makeCurrent(). - - \note Scheduling updates from here is not necessary. The windowing systems - will send expose events that trigger an update automatically. - - \sa initializeGL(), paintGL() - */ -void QOpenGLWindow::resizeGL(int w, int h) -{ - Q_UNUSED(w); - Q_UNUSED(h); -} - -/*! - This virtual function is called whenever the window contents needs to be - painted. Reimplement it in a subclass. - - There is no need to call makeCurrent() because this has already - been done when this function is called. - - Before invoking this function, the context and the framebuffer, if there is - one, are bound, and the viewport is set up by a call to glViewport(). No - other state is set and no clearing or drawing is performed by the framework. - - \note When using a partial update behavior, like \c PartialUpdateBlend, the - output of the previous paintGL() call is preserved and, after the additional - drawing perfomed in the current invocation of the function, the content is - blitted or blended over the content drawn directly to the window in - paintUnderGL(). - - \sa initializeGL(), resizeGL(), paintUnderGL(), paintOverGL(), UpdateBehavior - */ -void QOpenGLWindow::paintGL() -{ -} - -/*! - The virtual function is called before each invocation of paintGL(). - - When the update mode is set to \c NoPartialUpdate, there is no difference - between this function and paintGL(), performing rendering in either of them - leads to the same result. - - The difference becomes significant when using \c PartialUpdateBlend, where an - extra framebuffer object is used. There, paintGL() targets this additional - framebuffer object, which preserves its contents, while paintUnderGL() and - paintOverGL() target the default framebuffer, i.e. directly the window - surface, the contents of which is lost after each displayed frame. - - \note Avoid relying on this function when the update behavior is - \c PartialUpdateBlit. This mode involves blitting the extra framebuffer used by - paintGL() onto the default framebuffer after each invocation of paintGL(), - thus overwriting all drawing generated in this function. - - \sa paintGL(), paintOverGL(), UpdateBehavior - */ -void QOpenGLWindow::paintUnderGL() -{ -} - -/*! - This virtual function is called after each invocation of paintGL(). - - When the update mode is set to NoPartialUpdate, there is no difference - between this function and paintGL(), performing rendering in either of them - leads to the same result. - - Like paintUnderGL(), rendering in this function targets the default - framebuffer of the window, regardless of the update behavior. It gets called - after paintGL() has returned and the blit (PartialUpdateBlit) or quad drawing - (PartialUpdateBlend) has been done. - - \sa paintGL(), paintUnderGL(), UpdateBehavior - */ -void QOpenGLWindow::paintOverGL() -{ -} - -/*! - Paint \a event handler. Calls paintGL(). - - \sa paintGL() - */ -void QOpenGLWindow::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - paintGL(); -} - -/*! - Resize \a event handler. Calls resizeGL(). - - \sa resizeGL() - */ -void QOpenGLWindow::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - Q_D(QOpenGLWindow); - d->initialize(); - resizeGL(width(), height()); -} - -/*! - \internal - */ -int QOpenGLWindow::metric(PaintDeviceMetric metric) const -{ - Q_D(const QOpenGLWindow); - - switch (metric) { - case PdmDepth: - if (d->paintDevice) - return d->paintDevice->depth(); - break; - default: - break; - } - return QPaintDeviceWindow::metric(metric); -} - -/*! - \internal - */ -QPaintDevice *QOpenGLWindow::redirected(QPoint *) const -{ - Q_D(const QOpenGLWindow); - if (QOpenGLContext::currentContext() == d->context.data()) - return d->paintDevice.data(); - return nullptr; -} - -QT_END_NAMESPACE diff --git a/src/gui/kernel/qopenglwindow.h b/src/gui/kernel/qopenglwindow.h deleted file mode 100644 index 7b3bf004a3..0000000000 --- a/src/gui/kernel/qopenglwindow.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOPENGLWINDOW_H -#define QOPENGLWINDOW_H - -#include <QtGui/qtguiglobal.h> - -#ifndef QT_NO_OPENGL - -#include <QtGui/QPaintDeviceWindow> -#include <QtGui/QOpenGLContext> -#include <QtGui/QImage> - -QT_BEGIN_NAMESPACE - -class QOpenGLWindowPrivate; - -class Q_GUI_EXPORT QOpenGLWindow : public QPaintDeviceWindow -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QOpenGLWindow) - -public: - enum UpdateBehavior { - NoPartialUpdate, - PartialUpdateBlit, - PartialUpdateBlend - }; - - explicit QOpenGLWindow(UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); - explicit QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); - ~QOpenGLWindow(); - - UpdateBehavior updateBehavior() const; - bool isValid() const; - - void makeCurrent(); - void doneCurrent(); - - QOpenGLContext *context() const; - QOpenGLContext *shareContext() const; - - GLuint defaultFramebufferObject() const; - - QImage grabFramebuffer(); - -Q_SIGNALS: - void frameSwapped(); - -protected: - virtual void initializeGL(); - virtual void resizeGL(int w, int h); - virtual void paintGL(); - virtual void paintUnderGL(); - virtual void paintOverGL(); - - void paintEvent(QPaintEvent *event) override; - void resizeEvent(QResizeEvent *event) override; - int metric(PaintDeviceMetric metric) const override; - QPaintDevice *redirected(QPoint *) const override; - -private: - Q_DISABLE_COPY(QOpenGLWindow) -}; - -QT_END_NAMESPACE - -#endif // QT_NO_OPENGL - -#endif diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index eaa10de22a..a726db2be9 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -11,9 +11,11 @@ qtConfig(opengles2): CONFIG += opengles2 HEADERS += \ qopengldebug.h \ + qopenglwindow.h \ qtopenglglobal.h SOURCES += \ + qopenglwindow.cpp \ qopengldebug.cpp !qtConfig(opengles2) { diff --git a/src/opengl/qopenglwindow.cpp b/src/opengl/qopenglwindow.cpp new file mode 100644 index 0000000000..8cdf134bfd --- /dev/null +++ b/src/opengl/qopenglwindow.cpp @@ -0,0 +1,698 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qopenglwindow.h" +#include <QtGui/QOpenGLFramebufferObject> +#include <QtGui/QOpenGLPaintDevice> +#include <QtGui/QOpenGLFunctions> +#include <QtGui/QOpenGLTextureBlitter> +#include <QtGui/private/qpaintdevicewindow_p.h> +#include <QtGui/private/qopenglextensions_p.h> +#include <QtGui/private/qopenglcontext_p.h> +#include <QtGui/QMatrix4x4> +#include <QtGui/QOffscreenSurface> + +QT_BEGIN_NAMESPACE + +/*! + \class QOpenGLWindow + \inmodule QtOpenGL + \since 5.4 + \brief The QOpenGLWindow class is a convenience subclass of QWindow to perform OpenGL painting. + + QOpenGLWindow is an enhanced QWindow that allows easily creating windows that + perform OpenGL rendering using an API that is compatible with QOpenGLWidget + and is similar to the legacy QGLWidget. Unlike QOpenGLWidget, QOpenGLWindow + has no dependency on the widgets module and offers better performance. + + A typical application will subclass QOpenGLWindow and reimplement the following + virtual functions: + + \list + + \li initializeGL() to perform OpenGL resource initialization + + \li resizeGL() to set up the transformation matrices and other window size dependent resources + + \li paintGL() to issue OpenGL commands or draw using QPainter + + \endlist + + To schedule a repaint, call the update() function. Note that this will not + immediately result in a call to paintGL(). Calling update() multiple times in + a row will not change the behavior in any way. + + This is a slot so it can be connected to a \l QTimer::timeout() signal to + perform animation. Note however that in the modern OpenGL world it is a much + better choice to rely on synchronization to the vertical refresh rate of the + display. See \l{QSurfaceFormat::setSwapInterval()}{setSwapInterval()} on a + description of the swap interval. With a swap interval of \c 1, which is the + case on most systems by default, the + \l{QOpenGLContext::swapBuffers()}{swapBuffers()} call, that is executed + internally by QOpenGLWindow after each repaint, will block and wait for + vsync. This means that whenever the swap is done, an update can be scheduled + again by calling update(), without relying on timers. + + To request a specific configuration for the context, use setFormat() + like for any other QWindow. This allows, among others, requesting a + given OpenGL version and profile, or enabling depth and stencil + buffers. + + Unlike QWindow, QOpenGLWindow allows opening a painter on itself and perform + QPainter-based drawing. + + QOpenGLWindow supports multiple update behaviors. The default, + \c NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow or the + legacy QGLWidget. In contrast, \c PartialUpdateBlit and \c PartialUpdateBlend are + more in line with QOpenGLWidget's way of working, where there is always an + extra, dedicated framebuffer object present. These modes allow, by + sacrificing some performance, redrawing only a smaller area on each paint and + having the rest of the content preserved from of the previous frame. This is + useful for applications than render incrementally using QPainter, because + this way they do not have to redraw the entire window content on each + paintGL() call. + + Similarly to QOpenGLWidget, QOpenGLWindow supports the Qt::AA_ShareOpenGLContexts + attribute. When enabled, the OpenGL contexts of all QOpenGLWindow instances will share + with each other. This allows accessing each other's shareable OpenGL resources. + + For more information on graphics in Qt, see \l {Graphics}. + */ + +/*! + \enum QOpenGLWindow::UpdateBehavior + + This enum describes the update strategy of the QOpenGLWindow. + + \value NoPartialUpdate Indicates that the entire window surface will + redrawn on each update and so no additional framebuffers are needed. + This is the setting used in most cases and is equivalent to how drawing + directly via QWindow would function. + + \value PartialUpdateBlit Indicates that the drawing performed in paintGL() + does not cover the entire window. In this case an extra framebuffer object + is created under the hood, and rendering performed in paintGL() will target + this framebuffer. This framebuffer is then blitted onto the window surface's + default framebuffer after each paint. This allows having QPainter-based drawing + code in paintGL() which only repaints a smaller area at a time, because, unlike + NoPartialUpdate, the previous content is preserved. + + \value PartialUpdateBlend Similar to PartialUpdateBlit, but instead of using + framebuffer blits, the contents of the extra framebuffer is rendered by + drawing a textured quad with blending enabled. This, unlike PartialUpdateBlit, + allows alpha blended content and works even when the glBlitFramebuffer is + not available. Performance-wise this setting is likely to be somewhat slower + than PartialUpdateBlit. + */ + +/*! + \fn void QOpenGLWindow::frameSwapped() + + This signal is emitted after the potentially blocking + \l{QOpenGLContext::swapBuffers()}{buffer swap} has been done. Applications + that wish to continuously repaint synchronized to the vertical refresh, + should issue an update() upon this signal. This allows for a much smoother + experience compared to the traditional usage of timers. +*/ + +// GLES2 builds won't have these constants with the suffixless names +#ifndef GL_READ_FRAMEBUFFER +#define GL_READ_FRAMEBUFFER 0x8CA8 +#endif +#ifndef GL_DRAW_FRAMEBUFFER +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#endif + +class QOpenGLWindowPaintDevice : public QOpenGLPaintDevice +{ +public: + QOpenGLWindowPaintDevice(QOpenGLWindow *window) : m_window(window) { } + void ensureActiveTarget() override; + + QOpenGLWindow *m_window; +}; + +class QOpenGLWindowPrivate : public QPaintDeviceWindowPrivate +{ + Q_DECLARE_PUBLIC(QOpenGLWindow) +public: + QOpenGLWindowPrivate(QOpenGLContext *shareContext, QOpenGLWindow::UpdateBehavior updateBehavior) + : updateBehavior(updateBehavior) + , hasFboBlit(false) + , shareContext(shareContext) + { + if (!shareContext) + this->shareContext = qt_gl_global_share_context(); + } + + ~QOpenGLWindowPrivate(); + + static QOpenGLWindowPrivate *get(QOpenGLWindow *w) { return w->d_func(); } + + void bindFBO(); + void initialize(); + + void beginPaint(const QRegion ®ion) override; + void endPaint() override; + void flush(const QRegion ®ion) override; + + QOpenGLWindow::UpdateBehavior updateBehavior; + bool hasFboBlit; + QScopedPointer<QOpenGLContext> context; + QOpenGLContext *shareContext; + QScopedPointer<QOpenGLFramebufferObject> fbo; + QScopedPointer<QOpenGLWindowPaintDevice> paintDevice; + QOpenGLTextureBlitter blitter; + QColor backgroundColor; + QScopedPointer<QOffscreenSurface> offscreenSurface; +}; + +QOpenGLWindowPrivate::~QOpenGLWindowPrivate() +{ + Q_Q(QOpenGLWindow); + if (q->isValid()) { + q->makeCurrent(); // this works even when the platformwindow is destroyed + paintDevice.reset(nullptr); + fbo.reset(nullptr); + blitter.destroy(); + q->doneCurrent(); + } +} + +void QOpenGLWindowPrivate::initialize() +{ + Q_Q(QOpenGLWindow); + + if (context) + return; + + if (!q->handle()) + qWarning("Attempted to initialize QOpenGLWindow without a platform window"); + + context.reset(new QOpenGLContext); + context->setShareContext(shareContext); + context->setFormat(q->requestedFormat()); + if (!context->create()) + qWarning("QOpenGLWindow::beginPaint: Failed to create context"); + if (!context->makeCurrent(q)) + qWarning("QOpenGLWindow::beginPaint: Failed to make context current"); + + paintDevice.reset(new QOpenGLWindowPaintDevice(q)); + if (updateBehavior == QOpenGLWindow::PartialUpdateBlit) + hasFboBlit = QOpenGLFramebufferObject::hasOpenGLFramebufferBlit(); + + q->initializeGL(); +} + +void QOpenGLWindowPrivate::beginPaint(const QRegion ®ion) +{ + Q_UNUSED(region); + Q_Q(QOpenGLWindow); + + initialize(); + context->makeCurrent(q); + + const int deviceWidth = q->width() * q->devicePixelRatio(); + const int deviceHeight = q->height() * q->devicePixelRatio(); + const QSize deviceSize(deviceWidth, deviceHeight); + if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { + if (!fbo || fbo->size() != deviceSize) { + QOpenGLFramebufferObjectFormat fboFormat; + fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + const int samples = q->requestedFormat().samples(); + if (samples > 0) { + if (updateBehavior != QOpenGLWindow::PartialUpdateBlend) + fboFormat.setSamples(samples); + else + qWarning("QOpenGLWindow: PartialUpdateBlend does not support multisampling"); + } + fbo.reset(new QOpenGLFramebufferObject(deviceSize, fboFormat)); + markWindowAsDirty(); + } + } else { + markWindowAsDirty(); + } + + paintDevice->setSize(QSize(deviceWidth, deviceHeight)); + paintDevice->setDevicePixelRatio(q->devicePixelRatio()); + context->functions()->glViewport(0, 0, deviceWidth, deviceHeight); + + context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); + + q->paintUnderGL(); + + if (updateBehavior > QOpenGLWindow::NoPartialUpdate) + fbo->bind(); +} + +void QOpenGLWindowPrivate::endPaint() +{ + Q_Q(QOpenGLWindow); + + if (updateBehavior > QOpenGLWindow::NoPartialUpdate) + fbo->release(); + + context->functions()->glBindFramebuffer(GL_FRAMEBUFFER, context->defaultFramebufferObject()); + + if (updateBehavior == QOpenGLWindow::PartialUpdateBlit && hasFboBlit) { + const int deviceWidth = q->width() * q->devicePixelRatio(); + const int deviceHeight = q->height() * q->devicePixelRatio(); + QOpenGLExtensions extensions(context.data()); + extensions.glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle()); + extensions.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, context->defaultFramebufferObject()); + extensions.glBlitFramebuffer(0, 0, deviceWidth, deviceHeight, + 0, 0, deviceWidth, deviceHeight, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + } else if (updateBehavior > QOpenGLWindow::NoPartialUpdate) { + if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) { + context->functions()->glEnable(GL_BLEND); + context->functions()->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + if (!blitter.isCreated()) + blitter.create(); + + QRect windowRect(QPoint(0, 0), fbo->size()); + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect); + blitter.bind(); + blitter.blit(fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft); + blitter.release(); + + if (updateBehavior == QOpenGLWindow::PartialUpdateBlend) + context->functions()->glDisable(GL_BLEND); + } + + q->paintOverGL(); +} + +void QOpenGLWindowPrivate::bindFBO() +{ + if (updateBehavior > QOpenGLWindow::NoPartialUpdate) + fbo->bind(); + else + QOpenGLFramebufferObject::bindDefault(); +} + +void QOpenGLWindowPrivate::flush(const QRegion ®ion) +{ + Q_UNUSED(region); + Q_Q(QOpenGLWindow); + context->swapBuffers(q); + emit q->frameSwapped(); +} + +void QOpenGLWindowPaintDevice::ensureActiveTarget() +{ + QOpenGLWindowPrivate::get(m_window)->bindFBO(); +} + +/*! + Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. + + \sa QOpenGLWindow::UpdateBehavior + */ +QOpenGLWindow::QOpenGLWindow(QOpenGLWindow::UpdateBehavior updateBehavior, QWindow *parent) + : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(nullptr, updateBehavior)), parent) +{ + setSurfaceType(QSurface::OpenGLSurface); +} + +/*! + Constructs a new QOpenGLWindow with the given \a parent and \a updateBehavior. The QOpenGLWindow's context will share with \a shareContext. + + \sa QOpenGLWindow::UpdateBehavior shareContext +*/ +QOpenGLWindow::QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior, QWindow *parent) + : QPaintDeviceWindow(*(new QOpenGLWindowPrivate(shareContext, updateBehavior)), parent) +{ + setSurfaceType(QSurface::OpenGLSurface); +} + +/*! + Destroys the QOpenGLWindow instance, freeing its resources. + + The OpenGLWindow's context is made current in the destructor, allowing for + safe destruction of any child object that may need to release OpenGL + resources belonging to the context provided by this window. + + \warning if you have objects wrapping OpenGL resources (such as + QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a QOpenGLWindow + subclass, you may need to add a call to makeCurrent() in that subclass' + destructor as well. Due to the rules of C++ object destruction, those objects + will be destroyed \e{before} calling this function (but after that the + destructor of the subclass has run), therefore making the OpenGL context + current in this function happens too late for their safe disposal. + + \sa makeCurrent + + \since 5.5 +*/ +QOpenGLWindow::~QOpenGLWindow() +{ + makeCurrent(); +} + +/*! + \return the update behavior for this QOpenGLWindow. +*/ +QOpenGLWindow::UpdateBehavior QOpenGLWindow::updateBehavior() const +{ + Q_D(const QOpenGLWindow); + return d->updateBehavior; +} + +/*! + \return \c true if the window's OpenGL resources, like the context, have + been successfully initialized. Note that the return value is always \c false + until the window becomes exposed (shown). +*/ +bool QOpenGLWindow::isValid() const +{ + Q_D(const QOpenGLWindow); + return d->context && d->context->isValid(); +} + +/*! + Prepares for rendering OpenGL content for this window by making the + corresponding context current and binding the framebuffer object, if there is + one, in that context context. + + It is not necessary to call this function in most cases, because it is called + automatically before invoking paintGL(). It is provided nonetheless to support + advanced, multi-threaded scenarios where a thread different than the GUI or main + thread may want to update the surface or framebuffer contents. See QOpenGLContext + for more information on threading related issues. + + This function is suitable for calling also when the underlying platform window + is already destroyed. This means that it is safe to call this function from + a QOpenGLWindow subclass' destructor. If there is no native window anymore, + an offscreen surface is used instead. This ensures that OpenGL resource + cleanup operations in the destructor will always work, as long as + this function is called first. + + \sa QOpenGLContext, context(), paintGL(), doneCurrent() + */ +void QOpenGLWindow::makeCurrent() +{ + Q_D(QOpenGLWindow); + + if (!isValid()) + return; + + // The platform window may be destroyed at this stage and therefore + // makeCurrent() may not safely be called with 'this'. + if (handle()) { + d->context->makeCurrent(this); + } else { + if (!d->offscreenSurface) { + d->offscreenSurface.reset(new QOffscreenSurface(screen())); + d->offscreenSurface->setFormat(d->context->format()); + d->offscreenSurface->create(); + } + d->context->makeCurrent(d->offscreenSurface.data()); + } + + d->bindFBO(); +} + +/*! + Releases the context. + + It is not necessary to call this function in most cases, since the widget + will make sure the context is bound and released properly when invoking + paintGL(). + + \sa makeCurrent() + */ +void QOpenGLWindow::doneCurrent() +{ + Q_D(QOpenGLWindow); + + if (!isValid()) + return; + + d->context->doneCurrent(); +} + +/*! + \return The QOpenGLContext used by this window or \c 0 if not yet initialized. + */ +QOpenGLContext *QOpenGLWindow::context() const +{ + Q_D(const QOpenGLWindow); + return d->context.data(); +} + +/*! + \return The QOpenGLContext requested to be shared with this window's QOpenGLContext. +*/ +QOpenGLContext *QOpenGLWindow::shareContext() const +{ + Q_D(const QOpenGLWindow); + return d->shareContext; +} + +/*! + The framebuffer object handle used by this window. + + When the update behavior is set to \c NoPartialUpdate, there is no separate + framebuffer object. In this case the returned value is the ID of the + default framebuffer. + + Otherwise the value of the ID of the framebuffer object or \c 0 if not + yet initialized. + */ +GLuint QOpenGLWindow::defaultFramebufferObject() const +{ + Q_D(const QOpenGLWindow); + if (d->updateBehavior > NoPartialUpdate && d->fbo) + return d->fbo->handle(); + else if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) + return ctx->defaultFramebufferObject(); + else + return 0; +} + +extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); + +/*! + Returns a copy of the framebuffer. + + \note This is a potentially expensive operation because it relies on + glReadPixels() to read back the pixels. This may be slow and can stall the + GPU pipeline. + + \note When used together with update behavior \c NoPartialUpdate, the returned + image may not contain the desired content when called after the front and back + buffers have been swapped (unless preserved swap is enabled in the underlying + windowing system interface). In this mode the function reads from the back + buffer and the contents of that may not match the content on the screen (the + front buffer). In this case the only place where this function can safely be + used is paintGL() or paintOverGL(). + */ +QImage QOpenGLWindow::grabFramebuffer() +{ + if (!isValid()) + return QImage(); + + makeCurrent(); + + const bool hasAlpha = format().hasAlpha(); + QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), hasAlpha, hasAlpha); + img.setDevicePixelRatio(devicePixelRatio()); + return img; +} + +/*! + This virtual function is called once before the first call to paintGL() or + resizeGL(). Reimplement it in a subclass. + + This function should set up any required OpenGL resources and state. + + There is no need to call makeCurrent() because this has already been done + when this function is called. Note however that the framebuffer, in case + partial update mode is used, is not yet available at this stage, so avoid + issuing draw calls from here. Defer such calls to paintGL() instead. + + \sa paintGL(), resizeGL() + */ +void QOpenGLWindow::initializeGL() +{ +} + +/*! + This virtual function is called whenever the widget has been resized. + Reimplement it in a subclass. The new size is passed in \a w and \a h. + + \note This is merely a convenience function in order to provide an API that is + compatible with QOpenGLWidget. Unlike with QOpenGLWidget, derived classes are + free to choose to override resizeEvent() instead of this function. + + \note Avoid issuing OpenGL commands from this function as there may not be a + context current when it is invoked. If it cannot be avoided, call makeCurrent(). + + \note Scheduling updates from here is not necessary. The windowing systems + will send expose events that trigger an update automatically. + + \sa initializeGL(), paintGL() + */ +void QOpenGLWindow::resizeGL(int w, int h) +{ + Q_UNUSED(w); + Q_UNUSED(h); +} + +/*! + This virtual function is called whenever the window contents needs to be + painted. Reimplement it in a subclass. + + There is no need to call makeCurrent() because this has already + been done when this function is called. + + Before invoking this function, the context and the framebuffer, if there is + one, are bound, and the viewport is set up by a call to glViewport(). No + other state is set and no clearing or drawing is performed by the framework. + + \note When using a partial update behavior, like \c PartialUpdateBlend, the + output of the previous paintGL() call is preserved and, after the additional + drawing perfomed in the current invocation of the function, the content is + blitted or blended over the content drawn directly to the window in + paintUnderGL(). + + \sa initializeGL(), resizeGL(), paintUnderGL(), paintOverGL(), UpdateBehavior + */ +void QOpenGLWindow::paintGL() +{ +} + +/*! + The virtual function is called before each invocation of paintGL(). + + When the update mode is set to \c NoPartialUpdate, there is no difference + between this function and paintGL(), performing rendering in either of them + leads to the same result. + + The difference becomes significant when using \c PartialUpdateBlend, where an + extra framebuffer object is used. There, paintGL() targets this additional + framebuffer object, which preserves its contents, while paintUnderGL() and + paintOverGL() target the default framebuffer, i.e. directly the window + surface, the contents of which is lost after each displayed frame. + + \note Avoid relying on this function when the update behavior is + \c PartialUpdateBlit. This mode involves blitting the extra framebuffer used by + paintGL() onto the default framebuffer after each invocation of paintGL(), + thus overwriting all drawing generated in this function. + + \sa paintGL(), paintOverGL(), UpdateBehavior + */ +void QOpenGLWindow::paintUnderGL() +{ +} + +/*! + This virtual function is called after each invocation of paintGL(). + + When the update mode is set to NoPartialUpdate, there is no difference + between this function and paintGL(), performing rendering in either of them + leads to the same result. + + Like paintUnderGL(), rendering in this function targets the default + framebuffer of the window, regardless of the update behavior. It gets called + after paintGL() has returned and the blit (PartialUpdateBlit) or quad drawing + (PartialUpdateBlend) has been done. + + \sa paintGL(), paintUnderGL(), UpdateBehavior + */ +void QOpenGLWindow::paintOverGL() +{ +} + +/*! + Paint \a event handler. Calls paintGL(). + + \sa paintGL() + */ +void QOpenGLWindow::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + paintGL(); +} + +/*! + Resize \a event handler. Calls resizeGL(). + + \sa resizeGL() + */ +void QOpenGLWindow::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + Q_D(QOpenGLWindow); + d->initialize(); + resizeGL(width(), height()); +} + +/*! + \internal + */ +int QOpenGLWindow::metric(PaintDeviceMetric metric) const +{ + Q_D(const QOpenGLWindow); + + switch (metric) { + case PdmDepth: + if (d->paintDevice) + return d->paintDevice->depth(); + break; + default: + break; + } + return QPaintDeviceWindow::metric(metric); +} + +/*! + \internal + */ +QPaintDevice *QOpenGLWindow::redirected(QPoint *) const +{ + Q_D(const QOpenGLWindow); + if (QOpenGLContext::currentContext() == d->context.data()) + return d->paintDevice.data(); + return nullptr; +} + +QT_END_NAMESPACE diff --git a/src/opengl/qopenglwindow.h b/src/opengl/qopenglwindow.h new file mode 100644 index 0000000000..926e4fabfd --- /dev/null +++ b/src/opengl/qopenglwindow.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtOpenGL 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOPENGLWINDOW_H +#define QOPENGLWINDOW_H + +#include <QtOpenGL/qtopenglglobal.h> + +#ifndef QT_NO_OPENGL + +#include <QtGui/QPaintDeviceWindow> +#include <QtGui/QOpenGLContext> +#include <QtGui/QImage> + +QT_BEGIN_NAMESPACE + +class QOpenGLWindowPrivate; + +class Q_OPENGL_EXPORT QOpenGLWindow : public QPaintDeviceWindow +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QOpenGLWindow) + +public: + enum UpdateBehavior { + NoPartialUpdate, + PartialUpdateBlit, + PartialUpdateBlend + }; + + explicit QOpenGLWindow(UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); + explicit QOpenGLWindow(QOpenGLContext *shareContext, UpdateBehavior updateBehavior = NoPartialUpdate, QWindow *parent = nullptr); + ~QOpenGLWindow(); + + UpdateBehavior updateBehavior() const; + bool isValid() const; + + void makeCurrent(); + void doneCurrent(); + + QOpenGLContext *context() const; + QOpenGLContext *shareContext() const; + + GLuint defaultFramebufferObject() const; + + QImage grabFramebuffer(); + +Q_SIGNALS: + void frameSwapped(); + +protected: + virtual void initializeGL(); + virtual void resizeGL(int w, int h); + virtual void paintGL(); + virtual void paintUnderGL(); + virtual void paintOverGL(); + + void paintEvent(QPaintEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + int metric(PaintDeviceMetric metric) const override; + QPaintDevice *redirected(QPoint *) const override; + +private: + Q_DISABLE_COPY(QOpenGLWindow) +}; + +QT_END_NAMESPACE + +#endif // QT_NO_OPENGL + +#endif -- cgit v1.2.3 From bd828bacb982a51ee21f03487f8390cfc96cc6d3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@intel.com> Date: Thu, 20 Jun 2019 14:26:15 -0700 Subject: QResource: Add API to get the decompressed content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtCore][QResource] Added uncompressedSize() and uncompressedData(), which will perform any required decompression on the data, prior to returning (unlike data() and size()). Change-Id: Ief874765cd7b43798de3fffd15aa053bc505dcb1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> --- src/corelib/io/qresource.cpp | 216 ++++++++++++++++++++++++++++++------------- src/corelib/io/qresource.h | 5 +- 2 files changed, 158 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 43df284d50..225ee0a769 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. -** Copyright (C) 2019 Intel Corporation. +** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -60,14 +60,14 @@ #include "private/qtools_p.h" #include "private/qsystemerror_p.h" +#ifndef QT_NO_COMPRESS +# include <zconf.h> +# include <zlib.h> +#endif #if QT_CONFIG(zstd) # include <zstd.h> #endif -#ifdef Q_OS_UNIX -# include "private/qcore_unix_p.h" -#endif - #if defined(Q_OS_UNIX) && !defined(Q_OS_NACL) && !defined(Q_OS_INTEGRITY) # define QT_USE_MMAP # include <sys/mman.h> @@ -296,6 +296,8 @@ public: void ensureInitialized() const; void ensureChildren() const; + qint64 uncompressedSize() const Q_DECL_PURE_FUNCTION; + qsizetype decompress(char *buffer, qsizetype bufferSize) const; bool load(const QString &file); void clear(); @@ -440,6 +442,78 @@ QResourcePrivate::ensureChildren() const } } +qint64 QResourcePrivate::uncompressedSize() const +{ + switch (compressionAlgo) { + case QResource::NoCompression: + return size; + + case QResource::ZlibCompression: +#ifndef QT_NO_COMPRESS + if (size_t(size) >= sizeof(quint32)) + return qFromBigEndian<quint32>(data); +#else + Q_ASSERT(!"QResource: Qt built without support for Zlib compression"); + Q_UNREACHABLE(); +#endif + break; + + case QResource::ZstdCompression: { +#if QT_CONFIG(zstd) + size_t n = ZSTD_getFrameContentSize(data, size); + return ZSTD_isError(n) ? -1 : qint64(n); +#else + // This should not happen because we've refused to load such resource + Q_ASSERT(!"QResource: Qt built without support for Zstd compression"); + Q_UNREACHABLE(); +#endif + } + + } + return -1; +} + +qsizetype QResourcePrivate::decompress(char *buffer, qsizetype bufferSize) const +{ + Q_ASSERT(data); + + switch (compressionAlgo) { + case QResource::NoCompression: + Q_UNREACHABLE(); + break; + + case QResource::ZlibCompression: { +#ifndef QT_NO_COMPRESS + uLong len = uLong(bufferSize); + int res = ::uncompress(reinterpret_cast<Bytef *>(buffer), &len, + data + sizeof(quint32), uLong(size - sizeof(quint32))); + if (res != Z_OK) { + qWarning("QResource: error decompressing zlib content (%d)", res); + return -1; + } + return len; +#else + Q_UNREACHABLE(); +#endif + } + + case QResource::ZstdCompression: { +#if QT_CONFIG(zstd) + size_t usize = ZSTD_decompress(buffer, bufferSize, data, size); + if (ZSTD_isError(usize)) { + qWarning("QResource: error decompressing zstd content: %s", ZSTD_getErrorName(usize)); + return -1; + } + return usize; +#else + Q_UNREACHABLE(); +#endif + } + } + + return -1; +} + /*! Constructs a QResource pointing to \a file. \a locale is used to load a specific localization of a resource data. @@ -600,9 +674,12 @@ QResource::Compression QResource::compressionAlgorithm() const } /*! - Returns the size of the data backing the resource. + Returns the size of the stored data backing the resource. - \sa data(), isFile() + If the resource is compressed, this function returns the size of the + compressed data. See uncompressedSize() for the uncompressed size. + + \sa data(), uncompressedSize(), isFile() */ qint64 QResource::size() const @@ -613,12 +690,29 @@ qint64 QResource::size() const } /*! - Returns direct access to a read only segment of data that this resource - represents. If the resource is compressed the data returned is compressed - and the appropriate library functions must be used to access the data. If - the resource is a directory \nullptr is returned. + \since 5.15 + + Returns the size of the data in this resource. If the data was not + compressed, this function returns the same as size(). If it was, then this + function extracts the size of the original uncompressed data from the + stored stream. - \sa size(), compressionAlgorithm(), isFile() + \sa size(), uncompressedData(), isFile() +*/ +qint64 QResource::uncompressedSize() const +{ + Q_D(const QResource); + d->ensureInitialized(); + return d->uncompressedSize(); +} + +/*! + Returns direct access to a segment of read-only data, that this resource + represents. If the resource is compressed, the data returned is also + compressed. The caller must then decompress the data or use + uncompressedData(). If the resource is a directory, \c nullptr is returned. + + \sa uncompressedData(), size(), isFile() */ const uchar *QResource::data() const @@ -628,6 +722,42 @@ const uchar *QResource::data() const return d->data; } +/*! + \since 5.15 + + Returns the resource data, decompressing it first, if the data was stored + compressed. If the resource is a directory or an error occurs while + decompressing, a null QByteArray is returned. + + \note If the data was compressed, this function will decompress every time + it is called. The result is not cached between calls. + + \sa uncompressedData(), size(), isCompressed(), isFile() +*/ + +QByteArray QResource::uncompressedData() const +{ + Q_D(const QResource); + qint64 n = uncompressedSize(); + if (n < 0) + return QByteArray(); + if (n > std::numeric_limits<QByteArray::size_type>::max()) { + qWarning("QResource: compressed content does not fit into a QByteArray; use QFile instead"); + return QByteArray(); + } + if (d->compressionAlgo == NoCompression) + return QByteArray::fromRawData(reinterpret_cast<const char *>(d->data), n); + + // decompress + QByteArray result(n, Qt::Uninitialized); + n = d->decompress(result.data(), n); + if (n < 0) + result.clear(); + else + result.truncate(n); + return result; +} + /*! \since 5.8 @@ -1451,13 +1581,7 @@ bool QResourceFileEngine::link(const QString &) qint64 QResourceFileEngine::size() const { Q_D(const QResourceFileEngine); - if (!d->resource.isValid()) - return 0; - if (d->resource.compressionAlgorithm() != QResource::NoCompression) { - d->uncompress(); - return d->uncompressed.size(); - } - return d->resource.size(); + return d->resource.isValid() ? d->resource.uncompressedSize() : 0; } qint64 QResourceFileEngine::pos() const @@ -1615,12 +1739,7 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory Q_Q(QResourceFileEngine); Q_UNUSED(flags); - qint64 max = resource.size(); - if (resource.compressionAlgorithm() != QResource::NoCompression) { - uncompress(); - max = uncompressed.size(); - } - + qint64 max = resource.uncompressedSize(); qint64 end; if (offset < 0 || size <= 0 || !resource.isValid() || add_overflow(offset, size, &end) || end > max) { @@ -1629,8 +1748,12 @@ uchar *QResourceFileEnginePrivate::map(qint64 offset, qint64 size, QFile::Memory } const uchar *address = resource.data(); - if (resource.compressionAlgorithm() != QResource::NoCompression) + if (resource.compressionAlgorithm() != QResource::NoCompression) { + uncompress(); + if (uncompressed.isNull()) + return nullptr; address = reinterpret_cast<const uchar *>(uncompressed.constData()); + } return const_cast<uchar *>(address) + offset; } @@ -1643,41 +1766,10 @@ bool QResourceFileEnginePrivate::unmap(uchar *ptr) void QResourceFileEnginePrivate::uncompress() const { - if (uncompressed.isEmpty() && resource.size()) { - quint64 size; - switch (resource.compressionAlgorithm()) { - case QResource::NoCompression: - return; // nothing to do - - case QResource::ZlibCompression: -#ifndef QT_NO_COMPRESS - uncompressed = qUncompress(resource.data(), resource.size()); -#else - Q_ASSERT(!"QResourceFileEngine::open: Qt built without support for Zlib compression"); -#endif - break; - - case QResource::ZstdCompression: -#if QT_CONFIG(zstd) - size = ZSTD_getFrameContentSize(resource.data(), resource.size()); - if (!ZSTD_isError(size)) { - if (size >= MaxAllocSize) { - qWarning("QResourceFileEngine::open: content bigger than memory (size %lld)", size); - } else { - uncompressed = QByteArray(size, Qt::Uninitialized); - size = ZSTD_decompress(const_cast<char *>(uncompressed.data()), size, - resource.data(), resource.size()); - } - } - if (ZSTD_isError(size)) - qWarning("QResourceFileEngine::open: error decoding: %s", ZSTD_getErrorName(size)); -#else - Q_UNUSED(size); - Q_ASSERT(!"QResourceFileEngine::open: Qt built without support for Zstd compression"); -#endif - break; - } - } + if (resource.compressionAlgorithm() == QResource::NoCompression + || !uncompressed.isEmpty() || resource.size() == 0) + return; // nothing to do + uncompressed = resource.uncompressedData(); } #endif // !defined(QT_BOOTSTRAPPED) diff --git a/src/corelib/io/qresource.h b/src/corelib/io/qresource.h index 5ee8d5d266..52b0d74d29 100644 --- a/src/corelib/io/qresource.h +++ b/src/corelib/io/qresource.h @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -75,6 +76,8 @@ public: Compression compressionAlgorithm() const; qint64 size() const; const uchar *data() const; + qint64 uncompressedSize() const; + QByteArray uncompressedData() const; QDateTime lastModified() const; #if QT_DEPRECATED_SINCE(5, 13) -- cgit v1.2.3 From 9f1948f59b916966ea0ecdf9c7d3473f7685e08e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Wed, 15 Jan 2020 21:04:17 +0100 Subject: QRegularExpression: fixup docs of wildcardToRegularExpression Fix a couple of typos, and add a paragraph explaining that there is no need of anchor the pattern again; a wildcard is always anchored. Fixes: QTBUG-81396 Change-Id: Ia67dc7477a05a450bdcc3def1ebbacce2006da4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qregularexpression.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 67be67c243..59d21e0a23 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -1892,6 +1892,10 @@ QString QRegularExpression::escape(const QString &str) \snippet code/src_corelib_tools_qregularexpression.cpp 31 + The returned regular expression is already fully anchored. In other + words, there is no need of calling anchoredPattern() again on the + result. + \warning Unlike QRegExp, this implementation follows closely the definition of wildcard for glob patterns: \table @@ -1918,12 +1922,12 @@ QString QRegularExpression::escape(const QString &str) \note The backslash (\\) character is \e not an escape char in this context. In order to match one of the special characters, place it in square brackets - (for example, "[?]"). + (for example, \c{[?]}). More information about the implementation can be found in: \list \li \l {https://en.wikipedia.org/wiki/Glob_(programming)} {The Wikipedia Glob article} - \li \c man 7 glob + \li \c {man 7 glob} \endlist \sa escape() -- cgit v1.2.3 From 6faaef5a665f86465d616f20b5effd2ba650cee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Wed, 15 Jan 2020 09:56:06 +0100 Subject: QNetworkAccessManager: Avoid unnecessary calls to sender() As it searches through all connections, of which we have multiple for each network reply. Fixes: QTBUG-81336 Change-Id: Iba28278edae5f254bf884f427e0944d348b47d03 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> --- src/network/access/qnetworkaccessmanager.cpp | 23 ++++++++++------------- src/network/access/qnetworkaccessmanager.h | 2 -- src/network/access/qnetworkaccessmanager_p.h | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index ff916ff283..1f05fd931f 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1753,16 +1753,13 @@ void QNetworkAccessManager::setTransferTimeout(int timeout) d_func()->transferTimeout = timeout; } -void QNetworkAccessManagerPrivate::_q_replyFinished() +void QNetworkAccessManagerPrivate::_q_replyFinished(QNetworkReply *reply) { Q_Q(QNetworkAccessManager); - QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); - if (reply) { - emit q->finished(reply); - if (reply->request().attribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, false).toBool()) - QMetaObject::invokeMethod(reply, [reply] { reply->deleteLater(); }, Qt::QueuedConnection); - } + emit q->finished(reply); + if (reply->request().attribute(QNetworkRequest::AutoDeleteReplyOnFinishAttribute, false).toBool()) + QMetaObject::invokeMethod(reply, [reply] { reply->deleteLater(); }, Qt::QueuedConnection); #ifndef QT_NO_BEARERMANAGEMENT // If there are no active requests, release our reference to the network session. @@ -1774,13 +1771,11 @@ void QNetworkAccessManagerPrivate::_q_replyFinished() #endif } -void QNetworkAccessManagerPrivate::_q_replyEncrypted() +void QNetworkAccessManagerPrivate::_q_replyEncrypted(QNetworkReply *reply) { #ifndef QT_NO_SSL Q_Q(QNetworkAccessManager); - QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); - if (reply) - emit q->encrypted(reply); + emit q->encrypted(reply); #endif } @@ -1812,11 +1807,13 @@ QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply) { Q_Q(QNetworkAccessManager); QNetworkReplyPrivate::setManager(reply, q); - q->connect(reply, SIGNAL(finished()), SLOT(_q_replyFinished())); + q->connect(reply, &QNetworkReply::finished, reply, + [this, reply]() { _q_replyFinished(reply); }); #ifndef QT_NO_SSL /* In case we're compiled without SSL support, we don't have this signal and we need to * avoid getting a connection error. */ - q->connect(reply, SIGNAL(encrypted()), SLOT(_q_replyEncrypted())); + q->connect(reply, &QNetworkReply::encrypted, reply, + [this, reply]() { _q_replyEncrypted(reply); }); q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>))); q->connect(reply, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), SLOT(_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))); #endif diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index aa4765a043..931602bbf4 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -208,8 +208,6 @@ private: friend class QNetworkReplyWasmImpl; #endif Q_DECLARE_PRIVATE(QNetworkAccessManager) - Q_PRIVATE_SLOT(d_func(), void _q_replyFinished()) - Q_PRIVATE_SLOT(d_func(), void _q_replyEncrypted()) Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>)) Q_PRIVATE_SLOT(d_func(), void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)) #ifndef QT_NO_BEARERMANAGEMENT diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index d558f61eed..da92cad704 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -120,8 +120,8 @@ public: QThread * createThread(); void destroyThread(); - void _q_replyFinished(); - void _q_replyEncrypted(); + void _q_replyFinished(QNetworkReply *reply); + void _q_replyEncrypted(QNetworkReply *reply); void _q_replySslErrors(const QList<QSslError> &errors); void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator); QNetworkReply *postProcess(QNetworkReply *reply); -- cgit v1.2.3 From c0ea88a6776b6281d5774d03572b1aecc2ef3c25 Mon Sep 17 00:00:00 2001 From: Edward Welbourne <edward.welbourne@qt.io> Date: Mon, 6 Jan 2020 17:47:41 +0100 Subject: Fix MS-Win system locale code to return QString for numeric tokens QSystemLocale::query() is specified to return a QString (wrapped in a QVariant) for the various tokens used in formatting numbers (zero digit, signs, separators) but the MS-Win back-end was returning QChar (wrapped as QVariant) instead, using the first UCS-2 code-point of the string (even if this was the first of a surrogate pair). The same error shall be perpetrated by its caller, but we can at least DTRT in the back-end, ready for the coming fix (in Qt 6) to its caller. In the process, eliminate some local variables that shadowed a member variable and adapt number-conversion to cope with surrogate-pair digits. Optimised the latter for the case where zero is "0". Change-Id: Idfb416c301add4c961dde613b3dc28b2e31fd0af Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/text/qlocale_win.cpp | 97 +++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp index 79ea67f966..4b4152c519 100644 --- a/src/corelib/text/qlocale_win.cpp +++ b/src/corelib/text/qlocale_win.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -106,11 +106,11 @@ struct QSystemLocalePrivate { QSystemLocalePrivate(); - QChar zeroDigit(); - QChar decimalPoint(); - QChar groupSeparator(); - QChar negativeSign(); - QChar positiveSign(); + QString zeroDigit(); + QString decimalPoint(); + QString groupSeparator(); + QString negativeSign(); + QString positiveSign(); QVariant dateFormat(QLocale::FormatType); QVariant timeFormat(QLocale::FormatType); QVariant dateTimeFormat(QLocale::FormatType); @@ -147,12 +147,11 @@ private: WCHAR lcName[LOCALE_NAME_MAX_LENGTH]; #endif SubstitutionType substitutionType; - QChar zero; + QString zero; // cached value for zeroDigit() int getLocaleInfo(LCTYPE type, LPWSTR data, int size); QString getLocaleInfo(LCTYPE type, int maxlen = 0); int getLocaleInfo_int(LCTYPE type, int maxlen = 0); - QChar getLocaleInfo_qchar(LCTYPE type); int getCurrencyFormat(DWORD flags, LPCWSTR value, const CURRENCYFMTW *format, LPWSTR data, int size); int getDateFormat(DWORD flags, const SYSTEMTIME * date, LPCWSTR format, LPWSTR data, int size); @@ -236,12 +235,6 @@ int QSystemLocalePrivate::getLocaleInfo_int(LCTYPE type, int maxlen) return ok ? v : 0; } -QChar QSystemLocalePrivate::getLocaleInfo_qchar(LCTYPE type) -{ - QString str = getLocaleInfo(type); - return str.isEmpty() ? QChar() : str.at(0); -} - QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution() { if (substitutionType == SUnknown) { @@ -257,13 +250,12 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution() else if (buf[0] == '2') substitutionType = QSystemLocalePrivate::SAlways; else { - wchar_t digits[11]; + wchar_t digits[11]; // See zeroDigit() for why 11. if (!getLocaleInfo(LOCALE_SNATIVEDIGITS, digits, 11)) { substitutionType = QSystemLocalePrivate::SNever; return substitutionType; } - const wchar_t zero = digits[0]; - if (buf[0] == zero + 2) + if (buf[0] == digits[0] + 2) substitutionType = QSystemLocalePrivate::SAlways; else substitutionType = QSystemLocalePrivate::SNever; @@ -274,40 +266,75 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution() QString &QSystemLocalePrivate::substituteDigits(QString &string) { - ushort zero = zeroDigit().unicode(); - ushort *qch = reinterpret_cast<ushort *>(string.data()); - for (ushort *end = qch + string.size(); qch != end; ++qch) { - if (*qch >= '0' && *qch <= '9') - *qch = zero + (*qch - '0'); + zeroDigit(); // Ensure zero is set. + switch (zero.size()) { + case 1: { + const ushort offset = zero.at(0).unicode() - '0'; + if (!offset) // Nothing to do + break; + Q_ASSERT(offset > 9); + ushort *const qch = reinterpret_cast<ushort *>(string.data()); + for (int i = 0, stop = string.size(); i < stop; ++i) { + ushort &ch = qch[i]; + if (ch >= '0' && ch <= '9') + ch += offset; + } + break; + } + case 2: { + // Surrogate pair (high, low): + uint digit = QChar::surrogateToUcs4(zero.at(0), zero.at(1)); + for (int i = 0; i < 10; i++) { + const QChar s[2] = { QChar::highSurrogate(digit + i), QChar::lowSurrogate(digit + i) }; + string.replace(QString(QLatin1Char('0' + i)), QString(s, 2)); + } + break; + } + default: + Q_ASSERT(!"Expected zero digit to be a single UCS2 code-point or a surrogate pair"); + case 0: // Apparently this locale info was not available. + break; } return string; } -QChar QSystemLocalePrivate::zeroDigit() +QString QSystemLocalePrivate::zeroDigit() { - if (zero.isNull()) - zero = getLocaleInfo_qchar(LOCALE_SNATIVEDIGITS); + if (zero.isEmpty()) { + /* Ten digits plus a terminator. + + https://docs.microsoft.com/en-us/windows/win32/intl/locale-snative-constants + "Native equivalents of ASCII 0 through 9. The maximum number of + characters allowed for this string is eleven, including a terminating + null character." + */ + wchar_t digits[11]; + if (getLocaleInfo(LOCALE_SNATIVEDIGITS, digits, 11)) { + // assert all(digits[i] == i + digits[0] for i in range(1, 10)), assumed above + zero = QString::fromWCharArray(digits, 1); + } + } return zero; } -QChar QSystemLocalePrivate::decimalPoint() +QString QSystemLocalePrivate::decimalPoint() { - return getLocaleInfo_qchar(LOCALE_SDECIMAL); + return getLocaleInfo(LOCALE_SDECIMAL); } -QChar QSystemLocalePrivate::groupSeparator() +QString QSystemLocalePrivate::groupSeparator() { - return getLocaleInfo_qchar(LOCALE_STHOUSAND); + return getLocaleInfo(LOCALE_STHOUSAND); } -QChar QSystemLocalePrivate::negativeSign() +QString QSystemLocalePrivate::negativeSign() { - return getLocaleInfo_qchar(LOCALE_SNEGATIVESIGN); + return getLocaleInfo(LOCALE_SNEGATIVESIGN); } -QChar QSystemLocalePrivate::positiveSign() +QString QSystemLocalePrivate::positiveSign() { - return getLocaleInfo_qchar(LOCALE_SPOSITIVESIGN); + return getLocaleInfo(LOCALE_SPOSITIVESIGN); } QVariant QSystemLocalePrivate::dateFormat(QLocale::FormatType type) @@ -677,7 +704,7 @@ void QSystemLocalePrivate::update() GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH); #endif substitutionType = SUnknown; - zero = QChar(); + zero.resize(0); } QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt) @@ -749,7 +776,7 @@ QLocale QSystemLocale::fallbackUiLocale() const return QLocale(QString::fromLatin1(getWinLocaleName())); } -QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const +QVariant QSystemLocale::query(QueryType type, QVariant in) const { QSystemLocalePrivate *d = systemLocalePrivate(); switch(type) { -- cgit v1.2.3 From 800dda19a611339863aa5cfe6da13bc235d68e68 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Wed, 15 Jan 2020 23:00:58 +0100 Subject: Do not anchor an already-anchored regexp wildcardToRegularExpression() returns an anchored regexp, so it is pointless to anchor it again. Change-Id: If470179d63ae7ca2e7f137c0f403ec5bb5be8aaf Task-number: QTBUG-81396 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> --- src/corelib/io/qdiriterator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index ce436b06e3..1cf6b1be08 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -181,7 +181,7 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QS #elif QT_CONFIG(regularexpression) nameRegExps.reserve(nameFilters.size()); for (const auto &filter : nameFilters) { - QString re = QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(filter)); + QString re = QRegularExpression::wildcardToRegularExpression(filter); nameRegExps.append( QRegularExpression(re, (filters & QDir::CaseSensitive) ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption)); } -- cgit v1.2.3 From 5dc16d132497b54af608126ecf92f9e064c5aaf1 Mon Sep 17 00:00:00 2001 From: Topi Reinio <topi.reinio@qt.io> Date: Wed, 2 Oct 2019 00:03:18 +0200 Subject: Doc: Fix ButtonRole enum docs for QMessageBox and QDialogButtonBox Multiple topic commands (in this case, \enum) do not work across different classes. Reuse the documentation comment via an \include statement instead. Fixes: QTBUG-78910 Change-Id: Ife83bdc9bbad650835fafc072180d10037648d0a Reviewed-by: Paul Wicking <paul.wicking@qt.io> --- src/widgets/dialogs/qmessagebox.cpp | 6 ++++++ src/widgets/widgets/qdialogbuttonbox.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index e20657a0f6..e1cc475a93 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -755,6 +755,12 @@ void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button \sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example} */ +/*! + \enum QMessageBox::ButtonRole + + \include qdialogbuttonbox.cpp buttonrole-enum +*/ + /*! \enum QMessageBox::StandardButton \since 4.2 diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 28f6cdc7bd..7dba6df15c 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -522,8 +522,8 @@ QDialogButtonBox::~QDialogButtonBox() /*! \enum QDialogButtonBox::ButtonRole - \enum QMessageBox::ButtonRole +//! [buttonrole-enum] This enum describes the roles that can be used to describe buttons in the button box. Combinations of these roles are as flags used to describe different aspects of their behavior. @@ -546,6 +546,7 @@ QDialogButtonBox::~QDialogButtonBox() \omitvalue NRoles \sa StandardButton +//! [buttonrole-enum] */ /*! -- cgit v1.2.3 From 983432effdae888a372d814ff9516abbcb7a3c29 Mon Sep 17 00:00:00 2001 From: Olivier Goffart <ogoffart@woboq.com> Date: Fri, 3 Jan 2020 15:03:39 +0100 Subject: Introduce Q_MOC_INCLUDE A new macro that can be added in the header file parsed by moc to tell moc to include that file in the generated file Change-Id: I03ad702c3fcd8380371015f226ee4b7456daf132 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/kernel/qobject.cpp | 17 +++++++++++++++++ src/corelib/kernel/qtmetamacros.h | 1 + src/tools/moc/keywords.cpp | 25 ++++++++++++++++++------- src/tools/moc/moc.cpp | 21 +++++++++++++++++++++ src/tools/moc/moc.h | 1 + src/tools/moc/token.h | 1 + src/tools/moc/util/generate_keywords.cpp | 1 + 7 files changed, 60 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 133ccc88d9..c72383ff4a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4542,6 +4542,23 @@ QDebug operator<<(QDebug dbg, const QObject *o) \sa Q_NAMESPACE, {Creating Shared Libraries} */ +/*! + \macro Q_MOC_INCLUDE + \relates QObject + \since 6.0 + + The Q_MOC_INCLUDE macro can be used within or outside a class, and tell the + \l{moc}{Meta Object Compiler} to add an include. + + \code + // Put this in your code and the generated code will include this header. + Q_MOC_INCLUDE("myheader.h") + \endcode + + This is useful if the types you use as properties or signal/slots arguments + are forward declared. +*/ + /*! \macro Q_SIGNALS \relates QObject diff --git a/src/corelib/kernel/qtmetamacros.h b/src/corelib/kernel/qtmetamacros.h index 19b6bfa358..1d095c0d7c 100644 --- a/src/corelib/kernel/qtmetamacros.h +++ b/src/corelib/kernel/qtmetamacros.h @@ -112,6 +112,7 @@ QT_BEGIN_NAMESPACE #define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) #define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) #define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) +#define Q_MOC_INCLUDE(...) QT_ANNOTATE_CLASS(qt_moc_include, __VA_ARGS__) #endif // QT_NO_META_MACROS #ifndef QT_NO_TRANSLATION diff --git a/src/tools/moc/keywords.cpp b/src/tools/moc/keywords.cpp index 7da8d94efc..cc7d747f5b 100644 --- a/src/tools/moc/keywords.cpp +++ b/src/tools/moc/keywords.cpp @@ -30,12 +30,12 @@ // DO NOT EDIT. static const short keyword_trans[][128] = { - {0,0,0,0,0,0,0,0,0,568,565,0,0,0,0,0, + {0,0,0,0,0,0,0,0,0,579,576,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 568,252,566,569,8,38,239,567,25,26,236,234,30,235,27,237, + 579,252,577,580,8,38,239,578,25,26,236,234,30,235,27,237, 22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43, 0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,21,8,8,8,8,8,8,8,8,8,31,571,32,238,8, + 8,21,8,8,8,8,8,8,8,8,8,31,582,32,238,8, 0,1,2,3,4,5,6,7,8,9,8,8,10,11,12,13, 14,8,15,16,17,18,19,20,8,8,8,36,245,37,248,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -177,7 +177,7 @@ static const short keyword_trans[][128] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,42,0,0,0,28,0, - 574,574,574,574,574,574,574,574,574,574,0,0,0,0,0,0, + 585,585,585,585,585,585,585,585,585,585,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -336,7 +336,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,573,0,0,0,0,572, + 0,0,0,0,0,0,0,0,0,0,584,0,0,0,0,583, 0,0,0,0,0,0,0,0,0,0,0,0,0,258,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -378,7 +378,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,475,424,408,416,380,0,484,0,0,0,0,364,358, + 0,0,0,475,424,408,416,380,0,484,0,0,0,565,364,358, 386,0,557,472,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -1021,11 +1021,22 @@ static const struct {CHARACTER, 0, 79, 563, CHARACTER}, {CHARACTER, 0, 78, 564, CHARACTER}, {Q_REVISION_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 79, 566, CHARACTER}, + {CHARACTER, 0, 67, 567, CHARACTER}, + {CHARACTER, 0, 95, 568, CHARACTER}, + {CHARACTER, 0, 73, 569, CHARACTER}, + {CHARACTER, 0, 78, 570, CHARACTER}, + {CHARACTER, 0, 67, 571, CHARACTER}, + {CHARACTER, 0, 76, 572, CHARACTER}, + {CHARACTER, 0, 85, 573, CHARACTER}, + {CHARACTER, 0, 68, 574, CHARACTER}, + {CHARACTER, 0, 69, 575, CHARACTER}, + {Q_MOC_INCLUDE_TOKEN, 0, 0, 0, CHARACTER}, {NEWLINE, 0, 0, 0, NOTOKEN}, {QUOTE, 0, 0, 0, NOTOKEN}, {SINGLEQUOTE, 0, 0, 0, NOTOKEN}, {WHITESPACE, 0, 0, 0, NOTOKEN}, - {HASH, 0, 35, 570, HASH}, + {HASH, 0, 35, 581, HASH}, {PP_HASHHASH, 0, 0, 0, NOTOKEN}, {BACKSLASH, 0, 0, 0, NOTOKEN}, {CPP_COMMENT, 0, 0, 0, NOTOKEN}, diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 7b132493f8..2fb8c8dee3 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -653,6 +653,11 @@ void Moc::parse() case Q_CLASSINFO_TOKEN: parseClassInfo(&def); break; + case Q_MOC_INCLUDE_TOKEN: + // skip it, the namespace is parsed twice + next(LPAREN); + lexemUntil(RPAREN); + break; case ENUM: { EnumDef enumDef; if (parseEnum(&enumDef)) @@ -696,6 +701,9 @@ void Moc::parse() case Q_DECLARE_METATYPE_TOKEN: parseDeclareMetatype(); break; + case Q_MOC_INCLUDE_TOKEN: + parseMocInclude(); + break; case USING: if (test(NAMESPACE)) { while (test(SCOPE) || test(IDENTIFIER)) @@ -828,6 +836,9 @@ void Moc::parse() case Q_CLASSINFO_TOKEN: parseClassInfo(&def); break; + case Q_MOC_INCLUDE_TOKEN: + parseMocInclude(); + break; case Q_INTERFACES_TOKEN: parseInterfaces(&def); break; @@ -1562,6 +1573,16 @@ void Moc::parseDeclareMetatype() metaTypes.append(typeName); } +void Moc::parseMocInclude() +{ + next(LPAREN); + QByteArray include = lexemUntil(RPAREN); + // remove parentheses + include.remove(0, 1); + include.chop(1); + includeFiles.append(include); +} + void Moc::parseSlotInPrivate(ClassDef *def, FunctionDef::Access access) { next(LPAREN); diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index 1d70fa154b..91a03a767f 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -256,6 +256,7 @@ public: void parseInterfaces(ClassDef *def); void parseDeclareInterface(); void parseDeclareMetatype(); + void parseMocInclude(); void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access); void parsePrivateProperty(ClassDef *def); diff --git a/src/tools/moc/token.h b/src/tools/moc/token.h index 0cc163f9e4..c11ec6a38c 100644 --- a/src/tools/moc/token.h +++ b/src/tools/moc/token.h @@ -179,6 +179,7 @@ QT_BEGIN_NAMESPACE F(Q_SCRIPTABLE_TOKEN) \ F(Q_PRIVATE_PROPERTY_TOKEN) \ F(Q_REVISION_TOKEN) \ + F(Q_MOC_INCLUDE_TOKEN) \ F(SPECIAL_TREATMENT_MARK) \ F(MOC_INCLUDE_BEGIN) \ F(MOC_INCLUDE_END) \ diff --git a/src/tools/moc/util/generate_keywords.cpp b/src/tools/moc/util/generate_keywords.cpp index 9248e9e2e7..c2cfe37fab 100644 --- a/src/tools/moc/util/generate_keywords.cpp +++ b/src/tools/moc/util/generate_keywords.cpp @@ -243,6 +243,7 @@ static const Keyword keywords[] = { { "Q_SCRIPTABLE", "Q_SCRIPTABLE_TOKEN" }, { "Q_PRIVATE_PROPERTY", "Q_PRIVATE_PROPERTY_TOKEN" }, { "Q_REVISION", "Q_REVISION_TOKEN" }, + { "Q_MOC_INCLUDE", "Q_MOC_INCLUDE_TOKEN" }, { "\n", "NEWLINE" }, { "\"", "QUOTE" }, { "\'", "SINGLEQUOTE" }, -- cgit v1.2.3 From 63b0b857f3cc84315a10c9b6d988bd657e7ce998 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov <vitaly.fanaskov@qt.io> Date: Thu, 16 Jan 2020 17:21:15 +0100 Subject: QPalette: fix function swap and move operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additional data should also be taken into account when using move operator and function swap. This is already implemented for move constructor. Task-number: QTBUG-78544 Change-Id: I24ba34b0957a8fba7e15a934f2d08222dc95650f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> --- src/gui/kernel/qpalette.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index c95640d383..fd0ef2e2d9 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -72,11 +72,12 @@ public: { other.d = nullptr; } inline QPalette &operator=(QPalette &&other) noexcept { - qSwap(d, other.d); return *this; + swap(other); return *this; } void swap(QPalette &other) noexcept { + qSwap(data, other.data); qSwap(d, other.d); } -- cgit v1.2.3 From a3b2eac380bcd7d787e8fcc92a27bd7ed4f80b55 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Date: Thu, 16 Jan 2020 11:18:21 +0100 Subject: QColor: add casts to ushort Silence lossy conversion warnings on MSVC. Task-number: QTBUG-80997 Change-Id: I0e5778b9f20b599de6fc8894c4b98fbc1b1510b9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> --- src/gui/painting/qcolor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index f0d7dd23ad..0189f4e5f1 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -72,10 +72,10 @@ public: QColor(Qt::GlobalColor color) noexcept; Q_DECL_CONSTEXPR QColor(int r, int g, int b, int a = 255) noexcept : cspec(isRgbaValid(r, g, b, a) ? Rgb : Invalid), - ct(cspec == Rgb ? a * 0x0101 : 0, - cspec == Rgb ? r * 0x0101 : 0, - cspec == Rgb ? g * 0x0101 : 0, - cspec == Rgb ? b * 0x0101 : 0, + ct(ushort(cspec == Rgb ? a * 0x0101 : 0), + ushort(cspec == Rgb ? r * 0x0101 : 0), + ushort(cspec == Rgb ? g * 0x0101 : 0), + ushort(cspec == Rgb ? b * 0x0101 : 0), 0) {} QColor(QRgb rgb) noexcept; QColor(QRgba64 rgba64) noexcept; -- cgit v1.2.3 From 89312b2eabc86a9de6892778a458b914c9b2b72c Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer <volker.hilsheimer@qt.io> Date: Thu, 16 Jan 2020 16:31:36 +0100 Subject: Remove unused parameters from default-synthesized members Fixes build error with gcc when compiled with -Werror=unused-parameters. Change-Id: I12c3ecb30f489986b112f9736caec40aa50c7283 Fixes: QTBUG-81465 Reviewed-by: Liang Qi <liang.qi@qt.io> --- src/widgets/itemviews/qtablewidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index b1dbafa997..9134abe270 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -923,8 +923,8 @@ QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bo Constructs a the table selection range by copying the given \a other table selection range. */ -QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) = default; -QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &other) = default; +QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &) = default; +QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &) = default; /*! Destroys the table selection range. -- cgit v1.2.3 From 28f95d4688c28f8c06aa103012c6a00e197db12c Mon Sep 17 00:00:00 2001 From: Nico Vertriest <nico.vertriest@qt.io> Date: Wed, 15 Jan 2020 14:38:14 +0100 Subject: Doc: Fix qdoc compilation errors qtbase Task-number: QTBUG-79824 Change-Id: I5a39525e3e735415ba96e2d585c5de754deb15de Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> --- src/corelib/doc/qtcore.qdocconf | 2 +- src/corelib/doc/src/qtcore-index.qdoc | 2 +- src/corelib/global/qendian.cpp | 1 - src/corelib/time/qcalendar.cpp | 2 +- src/corelib/time/qtimezone.cpp | 2 +- src/dbus/qdbusabstractinterface.cpp | 6 +++--- src/dbus/qdbuspendingcall.cpp | 5 ++--- src/dbus/qdbuspendingreply.cpp | 3 +-- src/gui/doc/qtgui.qdocconf | 1 + src/gui/kernel/qwindow.cpp | 1 - src/gui/painting/qbackingstore.cpp | 2 -- src/gui/painting/qpainter.cpp | 3 +-- src/gui/rhi/qrhimetal.mm | 2 +- 13 files changed, 13 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index 15b1925e51..2b9adabc3a 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -26,7 +26,7 @@ qhp.QtCore.subprojects.classes.sortPages = true tagfile = ../../../doc/qtcore/qtcore.tags -depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras qtqml +depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras qtqml qtcmake headerdirs += .. diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc index 29fc25f69d..5838d13914 100644 --- a/src/corelib/doc/src/qtcore-index.qdoc +++ b/src/corelib/doc/src/qtcore-index.qdoc @@ -56,7 +56,7 @@ \include module-use.qdocinc using qt module \quotefile overview/using-qt-core.cmake - See also the \l[QtDoc]{Build with CMake} overview. + See also the \l{Build with CMake} overview. \section2 Building with qmake diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp index 98dc6a9a4b..eb08b2f848 100644 --- a/src/corelib/global/qendian.cpp +++ b/src/corelib/global/qendian.cpp @@ -192,7 +192,6 @@ QT_BEGIN_NAMESPACE an in-place swap (if necessary). If they are not the same, the memory regions must not overlap. - \sa qFromLittleEndian() \sa qToBigEndian() \sa qToLittleEndian() */ diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index 6a4623ce92..9d485f181e 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -723,7 +723,7 @@ QCalendar::QCalendar(QLatin1String name) QCalendar::QCalendar(QStringView name) : d(QCalendarBackend::fromName(name)) {} -/* +/*! \fn bool QCalendar::isValid() const Returns true if this is a valid calendar object. diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index ef323de14a..0bba2afc61 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -217,7 +217,7 @@ Q_GLOBAL_STATIC(QTimeZoneSingleton, global_tz); This class includes data obtained from the CLDR data files under the terms of the Unicode Data Files and Software License. See - \l{Unicode Common Locale Data Repository (CLDR)} for details. + \l{unicode-cldr}{Unicode Common Locale Data Repository (CLDR)} for details. \sa QDateTime */ diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 87de784fc0..d15496a792 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -696,7 +696,7 @@ void QDBusAbstractInterface::internalPropSet(const char *propname, const QVarian */ /*! - \fn QDBusAbstractInterface::call(const QString &message, Args&&...args) + \fn template <typename...Args> QDBusMessage QDBusAbstractInterface::call(const QString &method, Args&&...args) Calls the method \a method on this interface and passes \a args to the method. All \a args must be convertible to QVariant. @@ -745,7 +745,7 @@ QDBusMessage QDBusAbstractInterface::call(const QString &method, const QVariant */ /*! - \fn QDBusAbstractInterface::call(QDBus::CallMode mode, const QString &message, Args&&...args) + \fn template <typename...Args> QDBusMessage QDBusAbstractInterface::call(QDBus::CallMode mode, const QString &method, Args&&...args) \overload @@ -827,7 +827,7 @@ QDBusMessage QDBusAbstractInterface::call(QDBus::CallMode mode, const QString &m */ /*! - \fn QDBusAbstractInterface::asyncCall(const QString &message, Args&&...args) + \fn template <typename...Args> QDBusPendingCall QDBusAbstractInterface::asyncCall(const QString &method, Args&&...args) Calls the method \a method on this interface and passes \a args to the method. All \a args must be convertible to QVariant. diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 8e604d5a77..eeb9c266a3 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -82,8 +82,7 @@ QT_BEGIN_NAMESPACE provide a method of detaching the copies (since they refer to the same pending call) - \sa QDBusPendingReply, QDBusPendingCallWatcher, - QDBusAbstractInterface::asyncCall() + \sa QDBusPendingReply, QDBusPendingCallWatcher */ /*! @@ -115,7 +114,7 @@ QT_BEGIN_NAMESPACE (one string and one QByteArray), QDBusPendingReply::isError() will return true. - \sa QDBusPendingReply, QDBusAbstractInterface::asyncCall() + \sa QDBusPendingReply */ /*! diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp index ec49bafb60..b1b5fb3431 100644 --- a/src/dbus/qdbuspendingreply.cpp +++ b/src/dbus/qdbuspendingreply.cpp @@ -91,8 +91,7 @@ QDBusPendingCallWatcher objects, which emit signals when the reply arrives. - \sa QDBusPendingCallWatcher, QDBusReply, - QDBusAbstractInterface::asyncCall() + \sa QDBusPendingCallWatcher, QDBusReply */ /*! diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index 76dd6d7ea1..d149caf069 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -41,6 +41,7 @@ depends += \ qtwidgets \ qtdoc \ qmake \ + qtcmake \ qttestlib headerdirs += .. diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f701755500..0a4277c118 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2690,7 +2690,6 @@ QOpenGLContext *QWindowPrivate::shareContext() const platform dependent and untested. \sa setParent() - \sa setTransientParent() */ QWindow *QWindow::fromWinId(WId id) { diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index b0393aff95..0a49269c36 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -220,8 +220,6 @@ static bool isRasterSurface(QWindow *window) to the backingstore's top level window. You should call this function after ending painting with endPaint(). - - \sa QWindow::transientParent() */ void QBackingStore::flush(const QRegion ®ion, QWindow *window, const QPoint &offset) { diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3ce54c20be..75e7dc49fd 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1404,8 +1404,7 @@ void QPainterPrivate::updateState(QPainterState *newState) cases where expensive operations are ok to use, for instance when the result is cached in a QPixmap. - \sa QPaintDevice, QPaintEngine, {Qt SVG}, {Basic Drawing Example}, - {Drawing Utility Functions} + \sa QPaintDevice, QPaintEngine, {Qt SVG}, {Basic Drawing Example}, {<qdrawutil.h>}{Drawing Utility Functions} */ /*! diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 3ecc56d147..83fec31081 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -129,7 +129,7 @@ QT_BEGIN_NAMESPACE recording a frame, that is, between a \l{QRhi::beginFrame()}{beginFrame()} - \l{QRhi::endFrame()}{endFrame()} or \l{QRhi::beginOffscreenFrame()}{beginOffscreenFrame()} - - \l{QRhi::endOffsrceenFrame()}{endOffscreenFrame()} pair. + \l{QRhi::endOffscreenFrame()}{endOffsrceenFrame()} pair. \note The command encoder is only valid while recording a pass, that is, between \l{QRhiCommandBuffer::beginPass()} - -- cgit v1.2.3 From fd31e4ce43be112b42ffb7624c02b1de62dabcf5 Mon Sep 17 00:00:00 2001 From: Paul Wicking <paul.wicking@qt.io> Date: Fri, 17 Jan 2020 13:02:25 +0100 Subject: Doc: Display correct include for QWindowsWindowFunctions Fixes: QTBUG-55412 Change-Id: I3a38fa26911b1c151af9f0b47f1be602058aa4af Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> --- src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc index 0c52cde753..31a8d40abe 100644 --- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc +++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc @@ -28,6 +28,7 @@ /*! \class QWindowsWindowFunctions \inmodule QtPlatformHeaders + \inheaderfile QtPlatformHeaders/QWindowsWindowFunctions \since 5.5 \brief The QWindowsWindowFunctions class is an inline class containing miscellaneous functionality for Windows window specific functionality. -- cgit v1.2.3 From 9c172af7d5d8696a692fb2e040be11eae99a4b0c Mon Sep 17 00:00:00 2001 From: Paul Wicking <paul.wicking@qt.io> Date: Mon, 23 Jul 2018 10:01:23 +0200 Subject: Doc: Update text that refers to deprecated member function width() * Add see also links from the deprecated function to the replacement. * Change introduction text to reflect new function name rather than the old and deprecated width(). * Change see also and inline references to width(), so that they now refer to horizontalAdvance(). Task-number: QTBUG-65141 Change-Id: Iadfbc517e5df96e32058516f8795bd210cc4c5e4 Reviewed-by: Nico Vertriest <nico.vertriest@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> --- src/gui/text/qfontmetrics.cpp | 70 +++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index d3e4f11e8c..b7a3066f3a 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -106,12 +106,12 @@ extern void qt_format_text(const QFont& font, const QRectF &_r, These are by necessity slow, and we recommend avoiding them if possible. - For each character, you can get its width(), leftBearing() and - rightBearing() and find out whether it is in the font using + For each character, you can get its horizontalAdvance(), leftBearing(), + and rightBearing(), and find out whether it is in the font using inFont(). You can also treat the character as a string, and use the string functions on it. - The string functions include width(), to return the width of a + The string functions include horizontalAdvance(), to return the width of a string in pixels (or points, for a printer), boundingRect(), to return a rectangle large enough to contain the rendered string, and size(), to return the size of that rectangle. @@ -464,9 +464,9 @@ bool QFontMetrics::inFontUcs4(uint ucs4) const value is negative if the pixels of the character extend to the left of the logical origin. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa rightBearing(), minLeftBearing(), width() + \sa rightBearing(), minLeftBearing(), horizontalAdvance() */ int QFontMetrics::leftBearing(QChar ch) const { @@ -495,11 +495,11 @@ int QFontMetrics::leftBearing(QChar ch) const The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if the pixels of the character - extend to the right of the width() of the character. + extend to the right of the horizontalAdvance() of the character. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa leftBearing(), minRightBearing(), width() + \sa leftBearing(), minRightBearing(), horizontalAdvance() */ int QFontMetrics::rightBearing(QChar ch) const { @@ -535,7 +535,7 @@ int QFontMetrics::rightBearing(QChar ch) const \deprecated in Qt 5.11. Use horizontalAdvance() instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ int QFontMetrics::width(const QString &text, int len) const { @@ -601,7 +601,7 @@ int QFontMetrics::width(const QString &text, int len, int flags) const processing strings cannot be taken into account. When implementing an interactive text control, use QTextLayout instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ int QFontMetrics::width(QChar ch) const { @@ -751,7 +751,8 @@ int QFontMetrics::charWidth(const QString &text, int pos) const Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method + returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -762,7 +763,8 @@ int QFontMetrics::charWidth(const QString &text, int pos) const The height of the bounding rectangle is at least as large as the value returned by height(). - \sa width(), height(), QPainter::boundingRect(), tightBoundingRect() + \sa horizontalAdvance(), height(), QPainter::boundingRect(), + tightBoundingRect() */ QRect QFontMetrics::boundingRect(const QString &text) const { @@ -790,7 +792,7 @@ QRect QFontMetrics::boundingRect(const QString &text) const \warning The width of the returned rectangle is not the advance width of the character. Use boundingRect(const QString &) or horizontalAdvance() instead. - \sa width() + \sa horizontalAdvance() */ QRect QFontMetrics::boundingRect(QChar ch) const { @@ -864,7 +866,7 @@ QRect QFontMetrics::boundingRect(QChar ch) const fontHeight() and lineSpacing() are used to calculate the height, rather than individual character heights. - \sa width(), QPainter::boundingRect(), Qt::Alignment + \sa horizontalAdvance(), QPainter::boundingRect(), Qt::Alignment */ QRect QFontMetrics::boundingRect(const QRect &rect, int flags, const QString &text, int tabStops, int *tabArray) const @@ -920,7 +922,8 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method + returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -930,7 +933,7 @@ QSize QFontMetrics::size(int flags, const QString &text, int tabStops, int *tabA \warning Calling this method is very slow on Windows. - \sa width(), height(), boundingRect() + \sa horizontalAdvance(), height(), boundingRect() */ QRect QFontMetrics::tightBoundingRect(const QString &text) const { @@ -1079,12 +1082,12 @@ qreal QFontMetrics::fontDpi() const These are by necessity slow, and we recommend avoiding them if possible. - For each character, you can get its width(), leftBearing() and - rightBearing() and find out whether it is in the font using + For each character, you can get its horizontalAdvance(), leftBearing(), and + rightBearing(), and find out whether it is in the font using inFont(). You can also treat the character as a string, and use the string functions on it. - The string functions include width(), to return the width of a + The string functions include horizontalAdvance(), to return the width of a string in pixels (or points, for a printer), boundingRect(), to return a rectangle large enough to contain the rendered string, and size(), to return the size of that rectangle. @@ -1434,9 +1437,9 @@ bool QFontMetricsF::inFontUcs4(uint ucs4) const value is negative if the pixels of the character extend to the left of the logical origin. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa rightBearing(), minLeftBearing(), width() + \sa rightBearing(), minLeftBearing(), horizontalAdvance() */ qreal QFontMetricsF::leftBearing(QChar ch) const { @@ -1465,11 +1468,11 @@ qreal QFontMetricsF::leftBearing(QChar ch) const The right bearing is the left-ward distance of the right-most pixel of the character from the logical origin of a subsequent character. This value is negative if the pixels of the character - extend to the right of the width() of the character. + extend to the right of the horizontalAdvance() of the character. - See width() for a graphical description of this metric. + See horizontalAdvance() for a graphical description of this metric. - \sa leftBearing(), minRightBearing(), width() + \sa leftBearing(), minRightBearing(), horizontalAdvance() */ qreal QFontMetricsF::rightBearing(QChar ch) const { @@ -1504,7 +1507,7 @@ qreal QFontMetricsF::rightBearing(QChar ch) const \deprecated in Qt 5.11. Use horizontalAdvance() instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ qreal QFontMetricsF::width(const QString &text) const { @@ -1535,7 +1538,7 @@ qreal QFontMetricsF::width(const QString &text) const processing strings cannot be taken into account. When implementing an interactive text control, use QTextLayout instead. - \sa boundingRect() + \sa boundingRect(), horizontalAdvance() */ qreal QFontMetricsF::width(QChar ch) const { @@ -1581,7 +1584,7 @@ qreal QFontMetricsF::horizontalAdvance(const QString &text, int length) const ch. Some of the metrics are described in the image to the right. The - central dark rectangles cover the logical width() of each + central dark rectangles cover the logical horizontalAdvance() of each character. The outer pale rectangles cover the leftBearing() and rightBearing() of each character. Notice that the bearings of "f" in this particular font are both negative, while the bearings of @@ -1632,7 +1635,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -1643,7 +1646,7 @@ qreal QFontMetricsF::horizontalAdvance(QChar ch) const The height of the bounding rectangle is at least as large as the value returned height(). - \sa width(), height(), QPainter::boundingRect() + \sa horizontalAdvance(), height(), QPainter::boundingRect() */ QRectF QFontMetricsF::boundingRect(const QString &text) const { @@ -1669,7 +1672,7 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const Note that the rectangle usually extends both above and below the base line. - \sa width() + \sa horizontalAdvance() */ QRectF QFontMetricsF::boundingRect(QChar ch) const { @@ -1746,7 +1749,7 @@ QRectF QFontMetricsF::boundingRect(QChar ch) const fontHeight() and lineSpacing() are used to calculate the height, rather than individual character heights. - \sa width(), QPainter::boundingRect(), Qt::Alignment + \sa horizontalAdvance(), QPainter::boundingRect(), Qt::Alignment */ QRectF QFontMetricsF::boundingRect(const QRectF &rect, int flags, const QString& text, int tabStops, int *tabArray) const @@ -1805,7 +1808,8 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned - rectangle might be different than what the width() method returns. + rectangle might be different than what the horizontalAdvance() method + returns. If you want to know the advance width of the string (to lay out a set of strings next to each other), use horizontalAdvance() instead. @@ -1815,7 +1819,7 @@ QSizeF QFontMetricsF::size(int flags, const QString &text, int tabStops, int *ta \warning Calling this method is very slow on Windows. - \sa width(), height(), boundingRect() + \sa horizontalAdvance(), height(), boundingRect() */ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const { -- cgit v1.2.3 From 4ec6748c6a30f74e6d8fbb90fc118b306d1fa690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io> Date: Tue, 26 Nov 2019 16:08:38 +0100 Subject: QMap: deprecate insertMulti, unite and friends insertMulti and unite will silently transform a QMap into a multi-map which is not behavior we want to keep around anymore and as such is being deprecated. QMap functions that only make sense in a multi-map scenario are also deprecated and the implementation is moved to QMultiMap where it makes sense. Use QMultiMap if multiple keys are desired and insert(const QMap &) if a non multi-map-converting unite is desired. [ChangeLog][QtCore][QMap] insertMulti(), unite(), values(Key), uniqueKeys(), count(Key) is now deprecated. Please use QMultiMap instead. Task-number: QTBUG-35544 Change-Id: I158c938ceefb5aaba0e6e7513b2c26a64d29d521 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> --- src/corelib/tools/qmap.cpp | 95 +++++++----- src/corelib/tools/qmap.h | 351 ++++++++++++++++++++++++++------------------- 2 files changed, 262 insertions(+), 184 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 970373101f..d747a8cda4 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -468,10 +468,9 @@ void QMapDataBase::freeData(QMapDataBase *d) \snippet code/src_corelib_tools_qmap.cpp 9 However, you can store multiple values per key by using - insertMulti() instead of insert() (or using the convenience - subclass QMultiMap). If you want to retrieve all the values for a - single key, you can use values(const Key &key), which returns a - QList<T>: + using the subclass QMultiMap. If you want + to retrieve all the values for a single key, you can use + values(const Key &key), which returns a QList<T>: \snippet code/src_corelib_tools_qmap.cpp 10 @@ -676,9 +675,8 @@ void QMapDataBase::freeData(QMapDataBase *d) /*! \fn template <class Key, class T> int QMap<Key, T>::remove(const Key &key) Removes all the items that have the key \a key from the map. - Returns the number of items removed which is usually 1 but will be - 0 if the key isn't in the map, or \> 1 if insertMulti() has been - used with the \a key. + Returns the number of items removed which will be 1 if the key + exists in the map, and 0 otherwise. \sa clear(), take(), QMultiMap::remove() */ @@ -742,28 +740,26 @@ void QMapDataBase::freeData(QMapDataBase *d) /*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::uniqueKeys() const \since 4.2 + \obsolete Returns a list containing all the keys in the map in ascending order. Keys that occur multiple times in the map (because items were inserted with insertMulti(), or unite() was used) occur only once in the returned list. - \sa keys(), values() + \sa QMultiMap::uniqueKeys() */ /*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::keys() const Returns a list containing all the keys in the map in ascending - order. Keys that occur multiple times in the map (because items - were inserted with insertMulti(), or unite() was used) also - occur multiple times in the list. - - To obtain a list of unique keys, where each key from the map only - occurs once, use uniqueKeys(). + order. Keys that occur multiple times in the map (because the + method is operating on a QMultiMap) also occur multiple times + in the list. The order is guaranteed to be the same as that used by values(). - \sa uniqueKeys(), values(), key() + \sa QMultiMap::uniqueKeys(), values(), key() */ /*! \fn template <class Key, class T> QList<Key> QMap<Key, T>::keys(const T &value) const @@ -806,6 +802,7 @@ void QMapDataBase::freeData(QMapDataBase *d) */ /*! \fn template <class Key, class T> QList<T> QMap<Key, T>::values(const Key &key) const + \obsolete \overload @@ -813,14 +810,15 @@ void QMapDataBase::freeData(QMapDataBase *d) \a key, from the most recently inserted to the least recently inserted one. - \sa count(), insertMulti() + \sa QMultiMap::values() */ /*! \fn template <class Key, class T> int QMap<Key, T>::count(const Key &key) const + \obsolete Returns the number of items associated with key \a key. - \sa contains(), insertMulti(), QMultiMap::count() + \sa QMultiMap::count() */ /*! \fn template <class Key, class T> int QMap<Key, T>::count() const @@ -1118,7 +1116,7 @@ void QMapDataBase::freeData(QMapDataBase *d) If there are multiple items with the key \a key, the most recently inserted item's value is replaced with \a value. - \sa insertMulti() + \sa QMultiMap::insert() */ /*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const Key &key, const T &value) @@ -1147,7 +1145,7 @@ void QMapDataBase::freeData(QMapDataBase *d) \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might crash but there is also a risk that it will silently corrupt both the map and the \a pos map. - \sa insertMulti() + \sa QMultiMap::insert() */ /*! \fn template <class Key, class T> void QMap<Key, T>::insert(const QMap<Key, T> &map) @@ -1161,10 +1159,11 @@ void QMapDataBase::freeData(QMapDataBase *d) \note If \a map contains multiple entries with the same key then the final value of the key is undefined. - \sa insertMulti() + \sa QMultiMap::insert() */ /*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &key, const T &value) + \obsolete Inserts a new item with the key \a key and a value of \a value. @@ -1173,12 +1172,13 @@ void QMapDataBase::freeData(QMapDataBase *d) different from insert(), which overwrites the value of an existing item.) - \sa insert(), values() + \sa QMultiMap::insert() */ /*! \fn template <class Key, class T> QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, const Key &key, const T &value) \overload \since 5.1 + \obsolete Inserts a new item with the key \a key and value \a value and with hint \a pos suggesting where to do the insert. @@ -1192,17 +1192,18 @@ void QMapDataBase::freeData(QMapDataBase *d) \b {Note:} Be careful with the hint. Providing an iterator from an older shared instance might crash but there is also a risk that it will silently corrupt both the map and the \a pos map. - \sa insert() + \sa QMultiMap::insert() */ /*! \fn template <class Key, class T> QMap<Key, T> &QMap<Key, T>::unite(const QMap<Key, T> &other) + \obsolete Inserts all the items in the \a other map into this map. If a key is common to both maps, the resulting map will contain the key multiple times. - \sa insertMulti() + \sa QMultiMap::unite() */ /*! \typedef QMap::Iterator @@ -1285,9 +1286,8 @@ void QMapDataBase::freeData(QMapDataBase *d) Unlike QHash, which stores its items in an arbitrary order, QMap stores its items ordered by key. Items that share the same key - (because they were inserted using QMap::insertMulti(), or due to a - unite()) will appear consecutively, from the most recently to the - least recently inserted value. + (because the map is a QMultiMap) will appear consecutively, + from the most recently to the least recently inserted value. Let's see a few examples of things we can do with a QMap::iterator that we cannot do with a QMap::const_iterator. @@ -1533,9 +1533,8 @@ void QMapDataBase::freeData(QMapDataBase *d) Unlike QHash, which stores its items in an arbitrary order, QMap stores its items ordered by key. Items that share the same key - (because they were inserted using QMap::insertMulti()) will - appear consecutively, from the most recently to the least - recently inserted value. + (because the map is a QMultiMap) will appear consecutively, + from the most recently to the least recently inserted value. Multiple iterators can be used on the same map. If you add items to the map, existing iterators will remain valid. If you remove @@ -1907,20 +1906,20 @@ void QMapDataBase::freeData(QMapDataBase *d) \reentrant QMultiMap\<Key, T\> is one of Qt's generic \l{container classes}. - It inherits QMap and extends it with a few convenience functions - that make it more suitable than QMap for storing multi-valued - maps. A multi-valued map is a map that allows multiple values - with the same key; QMap normally doesn't allow that, unless you - call QMap::insertMulti(). + It inherits QMap and extends it with a few functions + that make it able to store multi-valued maps. A multi-valued map + is a map that allows multiple values with the same key; QMap + doesn't allow that. Because QMultiMap inherits QMap, all of QMap's functionality also applies to QMultiMap. For example, you can use isEmpty() to test whether the map is empty, and you can traverse a QMultiMap using QMap's iterator classes (for example, QMapIterator). But in - addition, it provides an insert() function that corresponds to - QMap::insertMulti(), and a replace() function that corresponds to - QMap::insert(). It also provides convenient operator+() and - operator+=(). + addition, it provides an insert() function that inserts but does + not overwrite any previous value if the key already exists, + and a replace() function that corresponds which does overwite + an existing value if they key is already in the map. + It also provides convenient operator+() and operator+=(). Example: \snippet code/src_corelib_tools_qmap.cpp 25 @@ -2109,4 +2108,24 @@ void QMapDataBase::freeData(QMapDataBase *d) \sa QMap::constFind() */ +/*! \fn template <class Key, class T> QList<T> QMultiMap<Key, T>::values(const Key &key) const + + Returns a list containing all the values associated with key + \a key, from the most recently inserted to the least recently + inserted one. +*/ + +/*! \fn template <class Key, class T> int QMultiMap<Key, T>::count(const Key &key) const + + Returns the number of items associated with key \a key. +*/ + +/*! \fn template <class Key, class T> QList<Key> QMultiMap<Key, T>::uniqueKeys() const + \since 4.2 + + Returns a list containing all the keys in the map in ascending + order. Keys that occur multiple times in the map occur only + once in the returned list. +*/ + QT_END_NAMESPACE diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index fa736e8413..281812b5e6 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -380,12 +380,15 @@ public: T &operator[](const Key &key); const T operator[](const Key &key) const; - QList<Key> uniqueKeys() const; QList<Key> keys() const; QList<Key> keys(const T &value) const; QList<T> values() const; - QList<T> values(const Key &key) const; - int count(const Key &key) const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use QMultiMap for maps storing multiple values with the same key.") QList<Key> uniqueKeys() const; + QT_DEPRECATED_X("Use QMultiMap for maps storing multiple values with the same key.") QList<T> values(const Key &key) const; + QT_DEPRECATED_X("Use QMultiMap for maps storing multiple values with the same key.") int count(const Key &key) const; +#endif + inline const Key &firstKey() const { Q_ASSERT(!isEmpty()); return constBegin().key(); } inline const Key &lastKey() const { Q_ASSERT(!isEmpty()); return (constEnd() - 1).key(); } @@ -452,6 +455,7 @@ public: { return i != o.i; } #endif friend class QMap<Key, T>; + friend class QMultiMap<Key, T>; }; friend class iterator; @@ -514,6 +518,7 @@ public: inline bool operator!=(const iterator &o) const { return operator!=(const_iterator(o)); } #endif friend class QMap<Key, T>; + friend class QMultiMap<Key, T>; }; friend class const_iterator; @@ -579,9 +584,11 @@ public: iterator insert(const Key &key, const T &value); iterator insert(const_iterator pos, const Key &key, const T &value); void insert(const QMap<Key, T> &map); - iterator insertMulti(const Key &key, const T &value); - iterator insertMulti(const_iterator pos, const Key &akey, const T &avalue); - QMap<Key, T> &unite(const QMap<Key, T> &other); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use QMultiMap for maps storing multiple values with the same key.") iterator insertMulti(const Key &key, const T &value); + QT_DEPRECATED_X("Use QMultiMap for maps storing multiple values with the same key.") iterator insertMulti(const_iterator pos, const Key &akey, const T &avalue); + QT_DEPRECATED_X("Use QMultiMap for maps storing multiple values with the same key.") QMap<Key, T> &unite(const QMap<Key, T> &other); +#endif // STL compatibility typedef Key key_type; @@ -610,6 +617,8 @@ private: return true; #endif } + + friend class QMultiMap<Key, T>; }; template <class Key, class T> @@ -671,23 +680,6 @@ Q_INLINE_TEMPLATE T &QMap<Key, T>::operator[](const Key &akey) return n->value; } -template <class Key, class T> -Q_INLINE_TEMPLATE int QMap<Key, T>::count(const Key &akey) const -{ - Node *firstNode; - Node *lastNode; - d->nodeRange(akey, &firstNode, &lastNode); - - const_iterator ci_first(firstNode); - const const_iterator ci_last(lastNode); - int cnt = 0; - while (ci_first != ci_last) { - ++cnt; - ++ci_first; - } - return cnt; -} - template <class Key, class T> Q_INLINE_TEMPLATE bool QMap<Key, T>::contains(const Key &akey) const { @@ -832,75 +824,6 @@ Q_INLINE_TEMPLATE void QMap<Key, T>::insert(const QMap<Key, T> &map) } } -template <class Key, class T> -Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &akey, - const T &avalue) -{ - detach(); - Node* y = d->end(); - Node* x = static_cast<Node *>(d->root()); - bool left = true; - while (x != nullptr) { - left = !qMapLessThanKey(x->key, akey); - y = x; - x = left ? x->leftNode() : x->rightNode(); - } - Node *z = d->createNode(akey, avalue, y, left); - return iterator(z); -} - -template <class Key, class T> -typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, const Key &akey, const T &avalue) -{ - if (d->ref.isShared()) - return this->insertMulti(akey, avalue); - - Q_ASSERT_X(isValidIterator(pos), "QMap::insertMulti", "The specified const_iterator argument 'pos' is invalid"); - - if (pos == constEnd()) { - // Hint is that the Node is larger than (or equal to) the largest value. - Node *n = static_cast<Node *>(pos.i->left); - if (n) { - while (n->right) - n = static_cast<Node *>(n->right); - - if (!qMapLessThanKey(n->key, akey)) - return this->insertMulti(akey, avalue); // ignore hint - Node *z = d->createNode(akey, avalue, n, false); // insert right most - return iterator(z); - } - return this->insertMulti(akey, avalue); - } else { - // Hint indicates that the node should be less (or equal to) the hint given - // but larger than the previous value. - Node *next = const_cast<Node*>(pos.i); - if (qMapLessThanKey(next->key, akey)) - return this->insertMulti(akey, avalue); // ignore hint - - if (pos == constBegin()) { - // There is no previous value (insert left most) - Node *z = d->createNode(akey, avalue, begin().i, true); - return iterator(z); - } else { - Node *prev = const_cast<Node*>(pos.i->previousNode()); - if (!qMapLessThanKey(prev->key, akey)) - return this->insertMulti(akey, avalue); // ignore hint - - // Hint is ok - do insert - if (prev->right == nullptr) { - Node *z = d->createNode(akey, avalue, prev, false); - return iterator(z); - } - if (next->left == nullptr) { - Node *z = d->createNode(akey, avalue, next, true); - return iterator(z); - } - Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr. - return this->insertMulti(akey, avalue); - } - } -} - template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::constFind(const Key &akey) const @@ -923,19 +846,6 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::find(const Key & return iterator(n ? n : d->end()); } -template <class Key, class T> -Q_INLINE_TEMPLATE QMap<Key, T> &QMap<Key, T>::unite(const QMap<Key, T> &other) -{ - QMap<Key, T> copy(other); - const_iterator it = copy.constEnd(); - const const_iterator b = copy.constBegin(); - while (it != b) { - --it; - insertMulti(it.key(), it.value()); - } - return *this; -} - template <class Key, class T> QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &akey) { @@ -1051,26 +961,6 @@ Q_OUTOFLINE_TEMPLATE void QMap<Key, T>::detach_helper() d->recalcMostLeftNode(); } -template <class Key, class T> -Q_OUTOFLINE_TEMPLATE QList<Key> QMap<Key, T>::uniqueKeys() const -{ - QList<Key> res; - res.reserve(size()); // May be too much, but assume short lifetime - const_iterator i = begin(); - if (i != end()) { - for (;;) { - const Key &aKey = i.key(); - res.append(aKey); - do { - if (++i == end()) - goto break_out_of_outer_loop; - } while (!qMapLessThanKey(aKey, i.key())); // loop while (key == i.key()) - } - } -break_out_of_outer_loop: - return res; -} - template <class Key, class T> Q_OUTOFLINE_TEMPLATE QList<Key> QMap<Key, T>::keys() const { @@ -1123,21 +1013,6 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values() const return res; } -template <class Key, class T> -Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values(const Key &akey) const -{ - QList<T> res; - Node *n = d->findNode(akey); - if (n) { - const_iterator it(n); - do { - res.append(*it); - ++it; - } while (it != constEnd() && !qMapLessThanKey<Key>(akey, it.key())); - } - return res; -} - template <class Key, class T> Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &akey) const { @@ -1234,15 +1109,20 @@ public: QMultiMap(QMap<Key, T> &&other) noexcept : QMap<Key, T>(std::move(other)) {} void swap(QMultiMap<Key, T> &other) noexcept { QMap<Key, T>::swap(other); } + QList<Key> uniqueKeys() const; + QList<T> values(const Key &key) const; + + using typename QMap<Key, T>::iterator; + using typename QMap<Key, T>::const_iterator; + inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value) { return QMap<Key, T>::insert(key, value); } - inline typename QMap<Key, T>::iterator insert(const Key &key, const T &value) - { return QMap<Key, T>::insertMulti(key, value); } - inline typename QMap<Key, T>::iterator insert(typename QMap<Key, T>::const_iterator pos, const Key &key, const T &value) - { return QMap<Key, T>::insertMulti(pos, key, value); } + iterator insert(const Key &key, const T &value); + iterator insert(const_iterator pos, const Key &key, const T &value); + QMultiMap &unite(const QMultiMap &other); inline QMultiMap &operator+=(const QMultiMap &other) - { this->unite(other); return *this; } + { return unite(other); } inline QMultiMap operator+(const QMultiMap &other) const { QMultiMap result = *this; result += other; return result; } @@ -1251,11 +1131,18 @@ public: using QMap<Key, T>::count; using QMap<Key, T>::find; using QMap<Key, T>::constFind; + using QMap<Key, T>::values; + using QMap<Key, T>::size; + using QMap<Key, T>::detach; + using QMap<Key, T>::erase; + using QMap<Key, T>::isValidIterator; + using typename QMap<Key, T>::Node; bool contains(const Key &key, const T &value) const; int remove(const Key &key, const T &value); + int count(const Key &key) const; int count(const Key &key, const T &value) const; typename QMap<Key, T>::iterator find(const Key &key, const T &value) { @@ -1285,6 +1172,123 @@ private: const T operator[](const Key &key) const; }; +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QList<Key> QMultiMap<Key, T>::uniqueKeys() const +{ + QList<Key> res; + res.reserve(size()); // May be too much, but assume short lifetime + const_iterator i = this->begin(); + if (i != this->end()) { + for (;;) { + const Key &aKey = i.key(); + res.append(aKey); + do { + if (++i == this->end()) + goto break_out_of_outer_loop; + } while (!qMapLessThanKey(aKey, i.key())); // loop while (key == i.key()) + } + } +break_out_of_outer_loop: + return res; +} + +template <class Key, class T> +Q_OUTOFLINE_TEMPLATE QList<T> QMultiMap<Key, T>::values(const Key &akey) const +{ + QList<T> res; + Node *n = this->d->findNode(akey); + if (n) { + const_iterator it(n); + do { + res.append(*it); + ++it; + } while (it != this->constEnd() && !qMapLessThanKey<Key>(akey, it.key())); + } + return res; +} + +template <class Key, class T> +Q_INLINE_TEMPLATE typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const Key &akey, + const T &avalue) +{ + detach(); + Node* y = this->d->end(); + Node* x = static_cast<Node *>(this->d->root()); + bool left = true; + while (x != nullptr) { + left = !qMapLessThanKey(x->key, akey); + y = x; + x = left ? x->leftNode() : x->rightNode(); + } + Node *z = this->d->createNode(akey, avalue, y, left); + return iterator(z); +} + +template <class Key, class T> +typename QMultiMap<Key, T>::iterator QMultiMap<Key, T>::insert(const_iterator pos, const Key &akey, const T &avalue) +{ + if (this->d->ref.isShared()) + return insert(akey, avalue); + + Q_ASSERT_X(isValidIterator(pos), "QMap::insert", "The specified const_iterator argument 'pos' is invalid"); + + if (pos == this->constEnd()) { + // Hint is that the Node is larger than (or equal to) the largest value. + Node *n = static_cast<Node *>(pos.i->left); + if (n) { + while (n->right) + n = static_cast<Node *>(n->right); + + if (!qMapLessThanKey(n->key, akey)) + return insert(akey, avalue); // ignore hint + Node *z = this->d->createNode(akey, avalue, n, false); // insert right most + return iterator(z); + } + return insert(akey, avalue); + } else { + // Hint indicates that the node should be less (or equal to) the hint given + // but larger than the previous value. + Node *next = const_cast<Node*>(pos.i); + if (qMapLessThanKey(next->key, akey)) + return insert(akey, avalue); // ignore hint + + if (pos == this->constBegin()) { + // There is no previous value (insert left most) + Node *z = this->d->createNode(akey, avalue, this->begin().i, true); + return iterator(z); + } else { + Node *prev = const_cast<Node*>(pos.i->previousNode()); + if (!qMapLessThanKey(prev->key, akey)) + return insert(akey, avalue); // ignore hint + + // Hint is ok - do insert + if (prev->right == nullptr) { + Node *z = this->d->createNode(akey, avalue, prev, false); + return iterator(z); + } + if (next->left == nullptr) { + Node *z = this->d->createNode(akey, avalue, next, true); + return iterator(z); + } + Q_ASSERT(false); // We should have prev->right == nullptr or next->left == nullptr. + return insert(akey, avalue); + } + } +} + +template <class Key, class T> +Q_INLINE_TEMPLATE QMultiMap<Key, T> &QMultiMap<Key, T>::unite(const QMultiMap<Key, T> &other) +{ + QMultiMap<Key, T> copy(other); + const_iterator it = copy.constEnd(); + const const_iterator b = copy.constBegin(); + while (it != b) { + --it; + insert(it.key(), it.value()); + } + return *this; +} + template <class Key, class T> Q_INLINE_TEMPLATE bool QMultiMap<Key, T>::contains(const Key &key, const T &value) const { @@ -1299,7 +1303,7 @@ Q_INLINE_TEMPLATE int QMultiMap<Key, T>::remove(const Key &key, const T &value) typename QMap<Key, T>::iterator end(QMap<Key, T>::end()); while (i != end && !qMapLessThanKey<Key>(key, i.key())) { if (i.value() == value) { - i = this->erase(i); + i = erase(i); ++n; } else { ++i; @@ -1308,6 +1312,23 @@ Q_INLINE_TEMPLATE int QMultiMap<Key, T>::remove(const Key &key, const T &value) return n; } +template <class Key, class T> +Q_INLINE_TEMPLATE int QMultiMap<Key, T>::count(const Key &akey) const +{ + QMultiMap::Node *firstNode; + QMultiMap::Node *lastNode; + this->d->nodeRange(akey, &firstNode, &lastNode); + + const_iterator ci_first(firstNode); + const const_iterator ci_last(lastNode); + int cnt = 0; + while (ci_first != ci_last) { + ++cnt; + ++ci_first; + } + return cnt; +} + template <class Key, class T> Q_INLINE_TEMPLATE int QMultiMap<Key, T>::count(const Key &key, const T &value) const { @@ -1322,6 +1343,44 @@ Q_INLINE_TEMPLATE int QMultiMap<Key, T>::count(const Key &key, const T &value) c return n; } +#if QT_DEPRECATED_SINCE(5, 15) +template<class Key, class T> +QList<Key> QMap<Key, T>::uniqueKeys() const +{ + return static_cast<const QMultiMap<Key, T> *>(this)->uniqueKeys(); +} + +template<class Key, class T> +QList<T> QMap<Key, T>::values(const Key &key) const +{ + return static_cast<const QMultiMap<Key, T> *>(this)->values(key); +} + +template<class Key, class T> +int QMap<Key, T>::count(const Key &key) const +{ + return static_cast<const QMultiMap<Key, T> *>(this)->count(key); +} + +template<class Key, class T> +typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &key, const T &value) +{ + return static_cast<QMultiMap<Key, T> *>(this)->insert(key, value); +} + +template<class Key, class T> +typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, const Key &akey, const T &avalue) +{ + return static_cast<QMultiMap<Key, T> *>(this)->insert(pos, akey, avalue); +} + +template<class Key, class T> +QMap<Key, T> &QMap<Key, T>::unite(const QMap<Key, T> &other) +{ + return static_cast<QMultiMap<Key, T> *>(this)->unite(other); +} +#endif + Q_DECLARE_ASSOCIATIVE_ITERATOR(Map) Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Map) -- cgit v1.2.3 From 06bb315beb6c2c398223cfe52cbc7f66e14a8557 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing <johan.helsing@qt.io> Date: Thu, 12 Dec 2019 12:58:11 +0100 Subject: Remove QOpenGLTextureHelper dependency from QOpenGLContext It's now just a pointer to a forward declared class Task-number: QTBUG-74409 Change-Id: I34df385154dcff2bbba2f6318825ab5258fa6695 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> --- src/gui/kernel/qopenglcontext.cpp | 10 ++++++---- src/gui/kernel/qopenglcontext.h | 2 +- src/gui/kernel/qopenglcontext_p.h | 1 + src/gui/opengl/qopengltexture.cpp | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 124b39f2a9..ab71434c13 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -56,8 +56,6 @@ #include <private/qopenglextensions_p.h> #include <private/qopenglversionfunctionsfactory_p.h> -#include <private/qopengltexturehelper_p.h> - #include <QDebug> #ifndef QT_OPENGL_ES_2 @@ -664,7 +662,10 @@ void QOpenGLContext::destroy() qDeleteAll(d->versionFunctions); d->versionFunctions.clear(); - delete d->textureFunctions; + if (d->textureFunctionsDestroyCallback) { + d->textureFunctionsDestroyCallback(); + d->textureFunctionsDestroyCallback = nullptr; + } d->textureFunctions = nullptr; d->nativeHandle = QVariant(); @@ -1388,10 +1389,11 @@ QOpenGLTextureHelper* QOpenGLContext::textureFunctions() const /*! \internal */ -void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs) +void QOpenGLContext::setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback) { Q_D(QOpenGLContext); d->textureFunctions = textureFuncs; + d->textureFunctionsDestroyCallback = destroyCallback; } /*! diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index 9cfaa52f17..f19dde465a 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -243,7 +243,7 @@ private: void removeExternalFunctions(QAbstractOpenGLFunctions *f); QOpenGLTextureHelper* textureFunctions() const; - void setTextureFunctions(QOpenGLTextureHelper* textureFuncs); + void setTextureFunctions(QOpenGLTextureHelper* textureFuncs, std::function<void()> destroyCallback); void destroy(); diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 833cfb20c3..7770b1ce02 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -240,6 +240,7 @@ public: QOpenGLFunctions *functions; mutable QSet<QByteArray> extensionNames; QOpenGLTextureHelper* textureFunctions; + std::function<void()> textureFunctionsDestroyCallback; GLint max_texture_size; diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index fd282e3ba0..35d90898e5 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -151,7 +151,8 @@ void QOpenGLTexturePrivate::initializeOpenGLFunctions() texFuncs = context->textureFunctions(); if (!texFuncs) { texFuncs = new QOpenGLTextureHelper(context); - context->setTextureFunctions(texFuncs); + auto *funcs = texFuncs; // lets us capture by pointer value below + context->setTextureFunctions(funcs, [funcs] { delete funcs; }); } } -- cgit v1.2.3